vike 0.4.229-commit-58f7ed0 → 0.4.229-commit-5da80bf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/server-routing-runtime/utils.js +1 -0
- package/dist/cjs/client/shared/{preparePageContextForUserConsumptionClientSide.js → preparePageContextForPublicUsageClientShared.js} +15 -19
- package/dist/cjs/node/api/build.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +12 -6
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -2
- package/dist/cjs/node/prerender/runPrerender.js +42 -38
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +13 -27
- package/dist/cjs/node/runtime/html/serializeContext.js +1 -1
- 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 +6 -9
- package/dist/cjs/node/runtime/renderPage/execHookServer.js +11 -0
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +14 -15
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -12
- package/dist/cjs/node/runtime/renderPage/{loadUserFilesServerSide.js → loadPageConfigsLazyServerSide.js} +4 -4
- package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +10 -0
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -5
- package/dist/cjs/node/runtime/renderPage.js +9 -7
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -1
- package/dist/cjs/shared/addIs404ToPageProps.js +0 -7
- package/dist/cjs/shared/createGlobalContextShared.js +37 -8
- package/dist/cjs/shared/createPageContextShared.js +16 -11
- package/dist/cjs/shared/getPageContext.js +3 -3
- package/dist/cjs/shared/getPageContextUrlComputed.js +2 -36
- package/dist/cjs/shared/getProxyForPublicUsage.js +106 -0
- package/dist/cjs/shared/hooks/execHook.js +164 -0
- package/dist/cjs/shared/hooks/getHook.js +23 -4
- package/dist/cjs/shared/page-configs/{getPageConfigUserFriendly.js → getUserFriendlyConfigs.js} +54 -47
- package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +10 -0
- package/dist/cjs/shared/preparePageContextForPublicUsage.js +75 -0
- package/dist/cjs/shared/route/abort.js +2 -2
- package/dist/cjs/shared/route/executeGuardHook.js +4 -9
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +4 -3
- package/dist/cjs/shared/route/index.js +2 -4
- package/dist/cjs/shared/route/loadPageRoutes.js +6 -0
- package/dist/cjs/shared/route/resolveRouteFunction.js +14 -10
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/objectAssign.js +3 -3
- package/dist/cjs/utils/objectDefineProperty.js +1 -1
- package/dist/esm/client/client-routing-runtime/{createPageContext.d.ts → createPageContextClientSide.d.ts} +21 -13
- package/dist/esm/client/client-routing-runtime/{createPageContext.js → createPageContextClientSide.js} +9 -11
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +400 -15
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +46 -44
- package/dist/esm/client/client-routing-runtime/globalContext.d.ts +11 -1
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +3 -8
- package/dist/esm/client/client-routing-runtime/prefetch.js +3 -3
- package/dist/esm/client/client-routing-runtime/preparePageContextForPublicUsageClient.d.ts +11 -0
- package/dist/esm/client/client-routing-runtime/preparePageContextForPublicUsageClient.js +5 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +135 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +79 -78
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/utils.js +1 -0
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.d.ts +19 -13
- package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +12 -15
- package/dist/esm/client/server-routing-runtime/entry.js +4 -4
- package/dist/esm/client/server-routing-runtime/globalContext.d.ts +11 -1
- package/dist/esm/client/server-routing-runtime/preparePageContextForPublicUsageClient.d.ts +9 -0
- package/dist/esm/client/server-routing-runtime/preparePageContextForPublicUsageClient.js +5 -0
- package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/utils.js +1 -0
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +11 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +3 -3
- package/dist/esm/client/shared/executeOnRenderClientHook.js +4 -13
- package/dist/esm/client/shared/{loadUserFilesClientSide.d.ts → loadPageConfigsLazyClientSide.d.ts} +2 -2
- package/dist/esm/client/shared/{loadUserFilesClientSide.js → loadPageConfigsLazyClientSide.js} +4 -4
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +11 -0
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.js +40 -0
- package/dist/esm/node/api/build.js +1 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -0
- 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/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +37 -73
- package/dist/esm/node/prerender/runPrerender.js +42 -38
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/globalContext.d.ts +46 -251
- package/dist/esm/node/runtime/globalContext.js +14 -28
- package/dist/esm/node/runtime/html/serializeContext.d.ts +1 -1
- package/dist/esm/node/runtime/html/serializeContext.js +1 -1
- 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 +26 -41
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +7 -10
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +12 -0
- package/dist/esm/node/runtime/renderPage/execHookServer.js +9 -0
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -3
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +14 -15
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +4 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -12
- package/dist/esm/node/runtime/renderPage/{loadUserFilesServerSide.d.ts → loadPageConfigsLazyServerSide.d.ts} +6 -6
- package/dist/esm/node/runtime/renderPage/{loadUserFilesServerSide.js → loadPageConfigsLazyServerSide.js} +4 -4
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +20 -0
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +8 -0
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +38 -74
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +5 -5
- package/dist/esm/node/runtime/renderPage.d.ts +21 -39
- package/dist/esm/node/runtime/renderPage.js +9 -7
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/shared/NOT_SERIALIZABLE.js +0 -1
- package/dist/esm/shared/addIs404ToPageProps.d.ts +1 -6
- package/dist/esm/shared/addIs404ToPageProps.js +1 -8
- package/dist/esm/shared/createGlobalContextShared.d.ts +28 -6
- package/dist/esm/shared/createGlobalContextShared.js +37 -8
- package/dist/esm/shared/createPageContextShared.d.ts +7 -6
- package/dist/esm/shared/createPageContextShared.js +17 -12
- package/dist/esm/shared/getPageContext.d.ts +1 -1
- package/dist/esm/shared/getPageContext.js +1 -1
- package/dist/esm/shared/getPageContextUrlComputed.d.ts +2 -5
- package/dist/esm/shared/getPageContextUrlComputed.js +3 -37
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/getProxyForPublicUsage.d.ts +12 -0
- package/dist/esm/shared/getProxyForPublicUsage.js +104 -0
- package/dist/esm/shared/hooks/execHook.d.ts +63 -0
- package/dist/esm/shared/hooks/execHook.js +162 -0
- package/dist/esm/shared/hooks/getHook.d.ts +10 -11
- package/dist/esm/shared/hooks/getHook.js +23 -4
- package/dist/esm/shared/page-configs/Config.d.ts +11 -4
- package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.d.ts → getUserFriendlyConfigs.d.ts} +8 -6
- package/dist/esm/shared/page-configs/{getPageConfigUserFriendly.js → getUserFriendlyConfigs.js} +55 -48
- package/dist/esm/shared/prepareGlobalContextForPublicUsage.d.ts +7 -0
- package/dist/esm/shared/prepareGlobalContextForPublicUsage.js +8 -0
- package/dist/esm/shared/preparePageContextForPublicUsage.d.ts +12 -0
- package/dist/esm/shared/preparePageContextForPublicUsage.js +73 -0
- package/dist/esm/shared/route/abort.js +1 -1
- package/dist/esm/shared/route/executeGuardHook.d.ts +4 -3
- package/dist/esm/shared/route/executeGuardHook.js +4 -9
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +4 -3
- package/dist/esm/shared/route/index.js +2 -4
- package/dist/esm/shared/route/loadPageRoutes.d.ts +2 -1
- package/dist/esm/shared/route/loadPageRoutes.js +7 -1
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +14 -10
- package/dist/esm/shared/types.d.ts +14 -4
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/objectAssign.d.ts +1 -1
- package/dist/esm/utils/objectAssign.js +3 -3
- package/dist/esm/utils/objectDefineProperty.d.ts +0 -1
- package/dist/esm/utils/objectDefineProperty.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/client/shared/getPageContextProxyForUser.js +0 -16
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +0 -16
- package/dist/cjs/shared/getPageConfigsRuntime.js +0 -23
- package/dist/cjs/shared/hooks/executeHook.js +0 -87
- package/dist/cjs/shared/hooks/executeHookGeneric.js +0 -18
- package/dist/cjs/shared/preparePageContextForUserConsumption.js +0 -34
- package/dist/cjs/utils/getPublicProxy.js +0 -27
- package/dist/esm/client/shared/getPageContextProxyForUser.d.ts +0 -2
- package/dist/esm/client/shared/getPageContextProxyForUser.js +0 -14
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +0 -12
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.js +0 -44
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +0 -24
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +0 -14
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +0 -14
- package/dist/esm/shared/getPageConfigsRuntime.js +0 -21
- package/dist/esm/shared/hooks/executeHook.d.ts +0 -21
- package/dist/esm/shared/hooks/executeHook.js +0 -85
- package/dist/esm/shared/hooks/executeHookGeneric.d.ts +0 -8
- package/dist/esm/shared/hooks/executeHookGeneric.js +0 -16
- package/dist/esm/shared/preparePageContextForUserConsumption.d.ts +0 -5
- package/dist/esm/shared/preparePageContextForUserConsumption.js +0 -32
- package/dist/esm/utils/getPublicProxy.d.ts +0 -2
- package/dist/esm/utils/getPublicProxy.js +0 -25
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
|
-
import { assert, isObject, assertWarning, assertUsage, makeLast, isBrowser, isScriptFile, isTemplateFile } from '../utils.js';
|
|
7
|
+
import { assert, isObject, assertWarning, assertUsage, makeLast, isBrowser, isScriptFile, isTemplateFile, objectDefineProperty } 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
|
});
|
|
@@ -90,7 +92,7 @@ function getPageConfigUserFriendly_oldDesign(pageFiles, pageConfig, pageConfigGl
|
|
|
90
92
|
configsComputed: {}
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
|
-
const pageExports =
|
|
95
|
+
const pageExports = {};
|
|
94
96
|
const exports = {};
|
|
95
97
|
Object.entries(exportsAll).forEach(([exportName, values]) => {
|
|
96
98
|
values.forEach(({ exportValue, _fileType, _isFromDefaultExport }) => {
|
|
@@ -113,13 +115,27 @@ function getPageConfigUserFriendly_oldDesign(pageFiles, pageConfig, pageConfigGl
|
|
|
113
115
|
// TODO/eventually: deprecate/remove every prop below
|
|
114
116
|
configEntries,
|
|
115
117
|
exports,
|
|
116
|
-
exportsAll
|
|
117
|
-
pageExports
|
|
118
|
+
exportsAll
|
|
118
119
|
};
|
|
120
|
+
// TODO/v1-release: remove
|
|
121
|
+
objectDefineProperty(pageContextExports, 'pageExports', {
|
|
122
|
+
get: () => {
|
|
123
|
+
// We only show the warning in Node.js because when using Client Routing Vue integration uses `Object.assign(pageContextReactive, pageContext)` which will wrongully trigger the warning. There is no cross-browser way to catch whether the property accessor was initiated by an `Object.assign()` call.
|
|
124
|
+
if (!isBrowser()) {
|
|
125
|
+
assertWarning(false, 'pageContext.pageExports is outdated, use pageContext.exports instead', {
|
|
126
|
+
onlyOnce: true,
|
|
127
|
+
showStackTrace: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return pageExports;
|
|
131
|
+
},
|
|
132
|
+
enumerable: false,
|
|
133
|
+
configurable: true
|
|
134
|
+
});
|
|
119
135
|
return pageContextExports;
|
|
120
136
|
}
|
|
121
137
|
// V1 design
|
|
122
|
-
function
|
|
138
|
+
function getUserFriendlyConfigs_V1Design(pageConfig) {
|
|
123
139
|
const config = {};
|
|
124
140
|
const configEntries = {};
|
|
125
141
|
const exportsAll = {};
|
|
@@ -135,19 +151,30 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
135
151
|
sources[configName] ?? (sources[configName] = []);
|
|
136
152
|
sources[configName].push(src);
|
|
137
153
|
};
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const configDefinedAt = getConfigDefinedAtOptional('Config', configName, configValue.definedAtData);
|
|
142
|
-
config[configName] = config[configName] ?? value;
|
|
154
|
+
const addLegacy = (configName, value, definedAtData) => {
|
|
155
|
+
const configValueFilePathToShowToUser = getConfigValueFilePathToShowToUser(definedAtData);
|
|
156
|
+
const configDefinedAt = getConfigDefinedAtOptional('Config', configName, definedAtData);
|
|
143
157
|
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
158
|
configEntries[configName].push({
|
|
147
159
|
configValue: value,
|
|
148
160
|
configDefinedAt,
|
|
149
161
|
configDefinedByFile: configValueFilePathToShowToUser
|
|
150
162
|
});
|
|
163
|
+
// TODO/v1-release: remove
|
|
164
|
+
const exportName = configName;
|
|
165
|
+
exportsAll[exportName] = exportsAll[exportName] ?? [];
|
|
166
|
+
exportsAll[exportName].push({
|
|
167
|
+
exportValue: value,
|
|
168
|
+
exportSource: configDefinedAt,
|
|
169
|
+
filePath: configValueFilePathToShowToUser,
|
|
170
|
+
_filePath: configValueFilePathToShowToUser,
|
|
171
|
+
_fileType: null,
|
|
172
|
+
_isFromDefaultExport: null
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
Object.entries(pageConfig.configValues).forEach(([configName, configValue]) => {
|
|
176
|
+
const { value } = configValue;
|
|
177
|
+
config[configName] = config[configName] ?? value;
|
|
151
178
|
if (configValue.type === 'standard') {
|
|
152
179
|
const src = {
|
|
153
180
|
type: 'configsStandard',
|
|
@@ -156,6 +183,7 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
156
183
|
};
|
|
157
184
|
addSrc(src, configName);
|
|
158
185
|
from.configsStandard[configName] = src;
|
|
186
|
+
addLegacy(configName, value, configValue.definedAtData);
|
|
159
187
|
}
|
|
160
188
|
if (configValue.type === 'cumulative') {
|
|
161
189
|
const src = {
|
|
@@ -164,6 +192,7 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
164
192
|
const definedAtFile = configValue.definedAtData[i];
|
|
165
193
|
assert(definedAtFile);
|
|
166
194
|
const definedAt = getDefinedAtString(definedAtFile, configName);
|
|
195
|
+
addLegacy(configName, value, definedAtFile);
|
|
167
196
|
return {
|
|
168
197
|
value,
|
|
169
198
|
definedAt
|
|
@@ -180,18 +209,8 @@ function getPageConfigUserFriendly_V1Design(pageConfig) {
|
|
|
180
209
|
};
|
|
181
210
|
addSrc(src, configName);
|
|
182
211
|
from.configsComputed[configName] = src;
|
|
212
|
+
addLegacy(configName, value, configValue.definedAtData);
|
|
183
213
|
}
|
|
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
214
|
});
|
|
196
215
|
return {
|
|
197
216
|
config: config,
|
|
@@ -239,15 +258,3 @@ function getExportValues(pageFile) {
|
|
|
239
258
|
});
|
|
240
259
|
return exportValues;
|
|
241
260
|
}
|
|
242
|
-
// TODO/v1-release: remove
|
|
243
|
-
function createObjectWithDeprecationWarning() {
|
|
244
|
-
return new Proxy({}, {
|
|
245
|
-
get(...args) {
|
|
246
|
-
// We only show the warning in Node.js because when using Client Routing Vue integration uses `Object.assign(pageContextReactive, pageContext)` which will wrongully trigger the warning. There is no cross-browser way to catch whether the property accessor was initiated by an `Object.assign()` call.
|
|
247
|
-
if (!isBrowser()) {
|
|
248
|
-
assertWarning(false, '`pageContext.pageExports` is outdated. Use `pageContext.exports` instead, see https://vike.dev/exports', { onlyOnce: true, showStackTrace: true });
|
|
249
|
-
}
|
|
250
|
-
return Reflect.get(...args);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { prepareGlobalContextForPublicUsage };
|
|
2
|
+
export type { GlobalContextPrepareMinimum };
|
|
3
|
+
type GlobalContextPrepareMinimum = {
|
|
4
|
+
_isOriginalObject: true;
|
|
5
|
+
isGlobalContext: true;
|
|
6
|
+
};
|
|
7
|
+
declare function prepareGlobalContextForPublicUsage<GlobalContext extends GlobalContextPrepareMinimum>(globalContext: GlobalContext): GlobalContext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { prepareGlobalContextForPublicUsage };
|
|
2
|
+
import { getProxyForPublicUsage } from './getProxyForPublicUsage.js';
|
|
3
|
+
import { assert } from './utils.js';
|
|
4
|
+
function prepareGlobalContextForPublicUsage(globalContext) {
|
|
5
|
+
assert(globalContext._isOriginalObject); // ensure we preserve the original object reference
|
|
6
|
+
const globalContextPublic = getProxyForPublicUsage(globalContext, 'globalContext');
|
|
7
|
+
return globalContextPublic;
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { preparePageContextForPublicUsage };
|
|
2
|
+
export { assertPropertyGetters };
|
|
3
|
+
export type { PageContextPrepareMinimum };
|
|
4
|
+
import { type GlobalContextPrepareMinimum } from './prepareGlobalContextForPublicUsage.js';
|
|
5
|
+
type PageContextPrepareMinimum = {
|
|
6
|
+
_isOriginalObject: true;
|
|
7
|
+
isPageContext: true;
|
|
8
|
+
_globalContext: GlobalContextPrepareMinimum;
|
|
9
|
+
globalContext?: never;
|
|
10
|
+
};
|
|
11
|
+
declare function preparePageContextForPublicUsage(pageContext: PageContextPrepareMinimum): never;
|
|
12
|
+
declare function assertPropertyGetters(pageContext: Record<string, unknown>): void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export { preparePageContextForPublicUsage };
|
|
2
|
+
export { assertPropertyGetters };
|
|
3
|
+
import { assert, assertWarning, compareString, isPropertyGetter, objectAssign } from './utils.js';
|
|
4
|
+
import { addIs404ToPageProps } from './addIs404ToPageProps.js';
|
|
5
|
+
import { prepareGlobalContextForPublicUsage } from './prepareGlobalContextForPublicUsage.js';
|
|
6
|
+
import { getProxyForPublicUsageFlat } from './getProxyForPublicUsage.js';
|
|
7
|
+
function preparePageContextForPublicUsage(pageContext) {
|
|
8
|
+
assert(pageContext._isOriginalObject); // ensure we preserve the original object reference
|
|
9
|
+
const globalContextPublic = prepareGlobalContextForPublicUsage(pageContext._globalContext);
|
|
10
|
+
objectAssign(pageContext, {
|
|
11
|
+
globalContext: globalContextPublic
|
|
12
|
+
});
|
|
13
|
+
addIs404ToPageProps(pageContext);
|
|
14
|
+
// TODO/next-major-release: remove
|
|
15
|
+
if (!('_pageId' in pageContext)) {
|
|
16
|
+
Object.defineProperty(pageContext, '_pageId', {
|
|
17
|
+
get() {
|
|
18
|
+
assertWarning(false, 'pageContext._pageId has been renamed to pageContext.pageId', {
|
|
19
|
+
showStackTrace: true,
|
|
20
|
+
onlyOnce: true
|
|
21
|
+
});
|
|
22
|
+
return pageContext.pageId;
|
|
23
|
+
},
|
|
24
|
+
enumerable: false
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// For a more readable `console.log(pageContext)` output
|
|
28
|
+
sortPageContext(pageContext);
|
|
29
|
+
const pageContextPublic = getProxyForPublicUsageFlat(pageContext, 'pageContext',
|
|
30
|
+
// We must skip it in the client-side because of the reactivity mechanism of UI frameworks like Solid.
|
|
31
|
+
// - TODO/now: double check whether that's true
|
|
32
|
+
true);
|
|
33
|
+
return pageContextPublic;
|
|
34
|
+
}
|
|
35
|
+
// Sort `pageContext` keys alphabetically, in order to make reading the `console.log(pageContext)` output easier
|
|
36
|
+
function sortPageContext(pageContext) {
|
|
37
|
+
return;
|
|
38
|
+
let descriptors = Object.getOwnPropertyDescriptors(pageContext);
|
|
39
|
+
for (const key of Object.keys(pageContext))
|
|
40
|
+
delete pageContext[key];
|
|
41
|
+
descriptors = Object.fromEntries(Object.entries(descriptors).sort(([key1], [key2]) => compareString(key1, key2)));
|
|
42
|
+
Object.defineProperties(pageContext, descriptors);
|
|
43
|
+
}
|
|
44
|
+
function assertPropertyGetters(pageContext) {
|
|
45
|
+
/*
|
|
46
|
+
If the isPropertyGetter() assertions fail then it's most likely because Object.assign() was used instead of `objectAssign()`:
|
|
47
|
+
```js
|
|
48
|
+
const PageContextUrlComputed = getPageContextUrlComputed(pageContext)
|
|
49
|
+
|
|
50
|
+
// ❌ Breaks the property descriptors/getters of pageContext defined by getPageContextUrlComputed() such as pageContext.urlPathname
|
|
51
|
+
Object.assign(pageContext, pageContextUrlComputed)
|
|
52
|
+
|
|
53
|
+
// ❌ Also breaks property descriptors/getters
|
|
54
|
+
const pageContext = { ...pageContextUrlComputed }
|
|
55
|
+
|
|
56
|
+
// ✅ Preserves property descriptors/getters (see objectAssign() implementation)
|
|
57
|
+
objectAssign(pageContext, pageContextUrlComputed)
|
|
58
|
+
```
|
|
59
|
+
*/
|
|
60
|
+
;
|
|
61
|
+
[
|
|
62
|
+
'urlPathname',
|
|
63
|
+
// TODO/v1-release: remove
|
|
64
|
+
'urlParsed',
|
|
65
|
+
// TODO/v1-release: remove
|
|
66
|
+
'url',
|
|
67
|
+
// TODO/v1-release: remove
|
|
68
|
+
'pageExports'
|
|
69
|
+
].forEach((prop) => {
|
|
70
|
+
if (pageContext.prop)
|
|
71
|
+
assert(isPropertyGetter(pageContext, prop));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -7,7 +7,7 @@ export { logAbortErrorHandled };
|
|
|
7
7
|
export { getPageContextFromAllRewrites };
|
|
8
8
|
export { AbortRender };
|
|
9
9
|
export { assertNoInfiniteAbortLoop };
|
|
10
|
-
import { isUserHookError } from '../hooks/
|
|
10
|
+
import { isUserHookError } from '../hooks/execHook.js';
|
|
11
11
|
import { assert, assertInfo, assertUsage, assertUsageUrlPathnameAbsolute, assertUsageUrlRedirectTarget, assertWarning, checkType, hasProp, joinEnglish, objectAssign, truncateString } from './utils.js';
|
|
12
12
|
import pc from '@brillout/picocolors';
|
|
13
13
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { executeGuardHook };
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageFile } from '../getPageFiles.js';
|
|
3
3
|
import type { PageConfigRuntime } from '../page-configs/PageConfig.js';
|
|
4
|
-
|
|
4
|
+
import { type PageContextExecuteHook } from '../hooks/execHook.js';
|
|
5
|
+
declare function executeGuardHook<PageContext extends {
|
|
5
6
|
pageId: string;
|
|
6
7
|
_pageFilesAll: PageFile[];
|
|
7
8
|
_pageConfigs: PageConfigRuntime[];
|
|
8
|
-
}>(pageContext:
|
|
9
|
+
} & PageContextExecuteHook>(pageContext: PageContext, prepareForPublicUsage: (pageConfig: PageContext) => PageContext): Promise<void>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { executeGuardHook };
|
|
2
2
|
import { getHookFromPageContext, getHookTimeoutDefault } from '../hooks/getHook.js';
|
|
3
3
|
import { assert, assertUsage, isCallable } from './utils.js';
|
|
4
|
-
import {
|
|
4
|
+
import { execHookSingle } from '../hooks/execHook.js';
|
|
5
5
|
const errIntro = 'The guard() hook defined by';
|
|
6
|
-
async function executeGuardHook(pageContext,
|
|
6
|
+
async function executeGuardHook(pageContext, prepareForPublicUsage) {
|
|
7
7
|
let hook;
|
|
8
8
|
if (pageContext._pageFilesAll.length > 0) {
|
|
9
|
+
// TODO/v1-release: remove
|
|
9
10
|
// V0.4 design
|
|
10
11
|
assert(pageContext._pageConfigs.length === 0);
|
|
11
12
|
hook = findPageGuard(pageContext.pageId, pageContext._pageFilesAll);
|
|
@@ -16,13 +17,7 @@ async function executeGuardHook(pageContext, prepareForUserConsumption) {
|
|
|
16
17
|
}
|
|
17
18
|
if (!hook)
|
|
18
19
|
return;
|
|
19
|
-
|
|
20
|
-
let pageContextForUserConsumption = pageContext;
|
|
21
|
-
const res = prepareForUserConsumption(pageContext);
|
|
22
|
-
if (res)
|
|
23
|
-
pageContextForUserConsumption = res;
|
|
24
|
-
const hookResult = await executeHook(() => guard(pageContextForUserConsumption), hook, pageContext);
|
|
25
|
-
assertUsage(hookResult === undefined, `${errIntro} ${hook.hookFilePath} returns a value, but guard() shouldn't return any value`);
|
|
20
|
+
await execHookSingle(hook, pageContext, prepareForPublicUsage);
|
|
26
21
|
}
|
|
27
22
|
function findPageGuard(pageId, pageFilesAll) {
|
|
28
23
|
const pageRouteFile = pageFilesAll.find((p) => p.pageId === pageId && p.fileType === '.page.route');
|
|
@@ -3,7 +3,8 @@ import { assertPageContextProvidedByUser } from '../assertPageContextProvidedByU
|
|
|
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 { execHookSync } from '../hooks/execHook.js';
|
|
7
|
+
import { preparePageContextForPublicUsage } from '../preparePageContextForPublicUsage.js';
|
|
7
8
|
async function executeOnBeforeRouteHook(pageContext) {
|
|
8
9
|
const pageContextFromOnBeforeRouteHook = {};
|
|
9
10
|
if (!pageContext._onBeforeRouteHook)
|
|
@@ -33,10 +34,10 @@ async function executeOnBeforeRouteHook(pageContext) {
|
|
|
33
34
|
return pageContextFromOnBeforeRouteHook;
|
|
34
35
|
}
|
|
35
36
|
async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
36
|
-
let hookReturn = onBeforeRouteHook
|
|
37
|
+
let { hookReturn } = execHookSync(onBeforeRouteHook, pageContext, preparePageContextForPublicUsage);
|
|
37
38
|
assertSyncRouting(hookReturn, `The onBeforeRoute() hook ${onBeforeRouteHook.hookFilePath}`);
|
|
38
39
|
// TODO/v1-release: make executeOnBeforeRouteHook() and route() sync
|
|
39
|
-
hookReturn = await
|
|
40
|
+
hookReturn = await hookReturn;
|
|
40
41
|
const errPrefix = `The onBeforeRoute() hook defined by ${onBeforeRouteHook.hookFilePath}`;
|
|
41
42
|
assertUsage(hookReturn === null ||
|
|
42
43
|
hookReturn === undefined ||
|
|
@@ -6,7 +6,6 @@ if (isBrowser()) {
|
|
|
6
6
|
assertClientRouting();
|
|
7
7
|
}
|
|
8
8
|
import { assert, assertUsage, isPlainObject, objectAssign } from './utils.js';
|
|
9
|
-
import { assertPageContextUrl } from '../getPageContextUrlComputed.js';
|
|
10
9
|
import { resolvePrecendence } from './resolvePrecedence.js';
|
|
11
10
|
import { resolveRouteString } from './resolveRouteString.js';
|
|
12
11
|
import { resolveRouteFunction } from './resolveRouteFunction.js';
|
|
@@ -15,7 +14,6 @@ import { debug } from './debug.js';
|
|
|
15
14
|
import pc from '@brillout/picocolors';
|
|
16
15
|
async function route(pageContext, skipOnBeforeRouteHook) {
|
|
17
16
|
debug('Pages routes:', pageContext._pageRoutes);
|
|
18
|
-
assertPageContextUrl(pageContext);
|
|
19
17
|
const pageContextFromRoute = {};
|
|
20
18
|
// onBeforeRoute()
|
|
21
19
|
if (!skipOnBeforeRouteHook) {
|
|
@@ -69,8 +67,8 @@ async function route(pageContext, skipOnBeforeRouteHook) {
|
|
|
69
67
|
}
|
|
70
68
|
// Route Function defined in `.page.route.js`
|
|
71
69
|
if (pageRoute.routeType === 'FUNCTION') {
|
|
72
|
-
const { routeFunction,
|
|
73
|
-
const match = await resolveRouteFunction(routeFunction, pageContext,
|
|
70
|
+
const { routeFunction, routeFunctionFilePath } = pageRoute;
|
|
71
|
+
const match = await resolveRouteFunction(routeFunction, pageContext, routeFunctionFilePath);
|
|
74
72
|
if (match) {
|
|
75
73
|
const { routeParams, precedence } = match;
|
|
76
74
|
routeMatches.push({ pageId, precedence, routeParams, routeType });
|
|
@@ -2,7 +2,7 @@ export { loadPageRoutes };
|
|
|
2
2
|
import { isErrorPageId } from '../error-page.js';
|
|
3
3
|
import { assert, assertUsage, hasProp, slice } from './utils.js';
|
|
4
4
|
import { deduceRouteStringFromFilesystemPath } from './deduceRouteStringFromFilesystemPath.js';
|
|
5
|
-
import { isCallable } from '../utils.js';
|
|
5
|
+
import { isArray, isCallable } from '../utils.js';
|
|
6
6
|
import { getConfigValueRuntime } from '../page-configs/getConfigValueRuntime.js';
|
|
7
7
|
import { getDefinedAtString } from '../page-configs/getConfigDefinedAt.js';
|
|
8
8
|
import { warnDeprecatedAllowKey } from './resolveRouteFunction.js';
|
|
@@ -44,6 +44,10 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
+
const { definedAtData } = configValue;
|
|
48
|
+
assert(!isArray(definedAtData) && !definedAtData.definedBy);
|
|
49
|
+
const { filePathToShowToUser } = definedAtData;
|
|
50
|
+
assert(filePathToShowToUser);
|
|
47
51
|
assert(isCallable(route));
|
|
48
52
|
// TODO/next-major: remove
|
|
49
53
|
if (getConfigValueRuntime(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
|
|
@@ -52,6 +56,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
52
56
|
pageId,
|
|
53
57
|
comesFromV1PageConfig,
|
|
54
58
|
routeFunction: route,
|
|
59
|
+
routeFunctionFilePath: filePathToShowToUser,
|
|
55
60
|
routeDefinedAtString: definedAtString,
|
|
56
61
|
routeType: 'FUNCTION'
|
|
57
62
|
};
|
|
@@ -125,6 +130,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
125
130
|
pageId,
|
|
126
131
|
comesFromV1PageConfig,
|
|
127
132
|
routeFunction,
|
|
133
|
+
routeFunctionFilePath: filePath,
|
|
128
134
|
routeDefinedAtString: filePath,
|
|
129
135
|
routeType: 'FUNCTION'
|
|
130
136
|
});
|
|
@@ -2,8 +2,8 @@ export { resolveRouteFunction };
|
|
|
2
2
|
export { assertRouteParams };
|
|
3
3
|
export { assertSyncRouting };
|
|
4
4
|
export { warnDeprecatedAllowKey };
|
|
5
|
-
import { PageContextUrlInternal } from '../getPageContextUrlComputed.js';
|
|
6
|
-
declare function resolveRouteFunction(routeFunction:
|
|
5
|
+
import type { PageContextUrlInternal } from '../getPageContextUrlComputed.js';
|
|
6
|
+
declare function resolveRouteFunction(routeFunction: (arg: unknown) => unknown, pageContext: PageContextUrlInternal, routeFunctionFilePath: string): Promise<null | {
|
|
7
7
|
precedence: number | null;
|
|
8
8
|
routeParams: Record<string, string>;
|
|
9
9
|
}>;
|
|
@@ -2,13 +2,17 @@ export { resolveRouteFunction };
|
|
|
2
2
|
export { assertRouteParams };
|
|
3
3
|
export { assertSyncRouting };
|
|
4
4
|
export { warnDeprecatedAllowKey };
|
|
5
|
-
import {
|
|
5
|
+
import { execHookSync } from '../hooks/execHook.js';
|
|
6
|
+
import { preparePageContextForPublicUsage } from '../preparePageContextForPublicUsage.js';
|
|
6
7
|
import { assert, assertUsage, assertWarning, hasProp, isPlainObject, isPromise } from './utils.js';
|
|
7
8
|
import pc from '@brillout/picocolors';
|
|
8
|
-
async function resolveRouteFunction(routeFunction, pageContext,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
async function resolveRouteFunction(routeFunction, pageContext, routeFunctionFilePath) {
|
|
10
|
+
let { hookReturn: result } = execHookSync({
|
|
11
|
+
hookFn: routeFunction,
|
|
12
|
+
hookFilePath: routeFunctionFilePath,
|
|
13
|
+
hookName: 'route'
|
|
14
|
+
}, pageContext, preparePageContextForPublicUsage);
|
|
15
|
+
assertSyncRouting(result, `The Route Function ${routeFunctionFilePath}`);
|
|
12
16
|
// TODO/v1-release: make resolveRouteFunction() and route() sync
|
|
13
17
|
//* We disallow asynchronous routing, because we need to check whether a link is a Vike link in a synchronous fashion before calling ev.preventDefault() in the 'click' event listener
|
|
14
18
|
result = await result;
|
|
@@ -19,11 +23,11 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAtSt
|
|
|
19
23
|
if (result === true) {
|
|
20
24
|
result = {};
|
|
21
25
|
}
|
|
22
|
-
assertUsage(isPlainObject(result), `The Route Function ${
|
|
26
|
+
assertUsage(isPlainObject(result), `The Route Function ${routeFunctionFilePath} should return a boolean or a plain JavaScript object (but it's ${pc.cyan(`typeof result === ${JSON.stringify(typeof result)}`)} instead)`);
|
|
23
27
|
// AFAICT this return interface is superfluous. Should we soft-deprecate it and remove it?
|
|
24
28
|
if ('match' in result) {
|
|
25
29
|
const { match } = result;
|
|
26
|
-
assertUsage(typeof match === 'boolean', `The ${pc.cyan('match')} value returned by the Route Function ${
|
|
30
|
+
assertUsage(typeof match === 'boolean', `The ${pc.cyan('match')} value returned by the Route Function ${routeFunctionFilePath} should be a boolean.`);
|
|
27
31
|
if (!match) {
|
|
28
32
|
return null;
|
|
29
33
|
}
|
|
@@ -31,14 +35,14 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAtSt
|
|
|
31
35
|
let precedence = null;
|
|
32
36
|
if ('precedence' in result) {
|
|
33
37
|
precedence = result.precedence;
|
|
34
|
-
assertUsage(typeof precedence === 'number', `The ${pc.cyan('precedence')} value returned by the Route Function ${
|
|
38
|
+
assertUsage(typeof precedence === 'number', `The ${pc.cyan('precedence')} value returned by the Route Function ${routeFunctionFilePath} should be a number.`);
|
|
35
39
|
}
|
|
36
|
-
assertRouteParams(result, `The ${pc.cyan('routeParams')} object returned by the Route Function ${
|
|
40
|
+
assertRouteParams(result, `The ${pc.cyan('routeParams')} object returned by the Route Function ${routeFunctionFilePath} should`);
|
|
37
41
|
const routeParams = result.routeParams || {};
|
|
38
42
|
assertUsage(!('pageContext' in result), `Providing ${pc.cyan('pageContext')} in Route Functions is prohibited, see https://vike.dev/route-function#cannot-provide-pagecontext`);
|
|
39
43
|
assert(isPlainObject(routeParams));
|
|
40
44
|
Object.keys(result).forEach((key) => {
|
|
41
|
-
assertUsage(key === 'match' || key === 'routeParams' || key === 'precedence', `The Route Function ${
|
|
45
|
+
assertUsage(key === 'match' || key === 'routeParams' || key === 'precedence', `The Route Function ${routeFunctionFilePath} returned an object with an unknown property ${pc.cyan(key)} (the known properties are ${pc.cyan('match')}, ${pc.cyan('routeParams')}, and ${pc.cyan('precedence')})`);
|
|
42
46
|
});
|
|
43
47
|
return {
|
|
44
48
|
precedence,
|
|
@@ -7,12 +7,15 @@ export type { GlobalContextClient };
|
|
|
7
7
|
export type { PageContextWithServerRouting };
|
|
8
8
|
export type { PageContextClientWithServerRouting };
|
|
9
9
|
export type { GlobalContextClientWithServerRouting };
|
|
10
|
-
export type {
|
|
10
|
+
export type { PageContextInternalServer };
|
|
11
|
+
export type { PageContextInternalClient };
|
|
12
|
+
export type { PageContextInternalClient_ServerRouting };
|
|
13
|
+
export type { PageContextInternalClient_ClientRouting };
|
|
11
14
|
export type { PageContextBuiltInServer_deprecated as PageContextBuiltInServer };
|
|
12
15
|
export type { PageContextBuiltInClientWithClientRouting_deprecated as PageContextBuiltInClientWithClientRouting };
|
|
13
16
|
export type { PageContextBuiltInClientWithServerRouting_deprecated as PageContextBuiltInClientWithServerRouting };
|
|
14
17
|
import type { PageContextUrlInternal, PageContextUrlClient, PageContextUrlServer } from './getPageContextUrlComputed.js';
|
|
15
|
-
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-configs/
|
|
18
|
+
import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-configs/getUserFriendlyConfigs.js';
|
|
16
19
|
import type { Config } from './page-configs/Config.js';
|
|
17
20
|
import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
|
|
18
21
|
import type { AbortStatusCode } from './route/abort.js';
|
|
@@ -235,8 +238,15 @@ type PageContextClientCommon = {
|
|
|
235
238
|
*/
|
|
236
239
|
isPrerendering: false;
|
|
237
240
|
};
|
|
238
|
-
|
|
239
|
-
type
|
|
241
|
+
type PageContextInternalServer = Omit<PageContextBuiltInCommon<unknown> & PageContextUrlInternal, 'data' | 'globalContext'>;
|
|
242
|
+
type OnlyUsers = 'data' | 'Page' | 'globalContext';
|
|
243
|
+
type PageContextInternalClient = Omit<PageContextInternalClient_ClientRouting | PageContextInternalClient_ServerRouting, OnlyUsers>;
|
|
244
|
+
type PageContextInternalClient_ClientRouting = Omit<PageContextBuiltInClientWithClientRouting<unknown>, OnlyUsers | 'previousPageContext'> & {
|
|
245
|
+
previousPageContext: {
|
|
246
|
+
pageId: string;
|
|
247
|
+
} | null;
|
|
248
|
+
};
|
|
249
|
+
type PageContextInternalClient_ServerRouting = Omit<PageContextBuiltInClientWithServerRouting<unknown>, OnlyUsers>;
|
|
240
250
|
/** @deprecated
|
|
241
251
|
* Replace:
|
|
242
252
|
* ```
|
|
@@ -23,3 +23,5 @@ export * from '../utils/changeEnumerable.js';
|
|
|
23
23
|
export * from '../utils/objectDefineProperty.js';
|
|
24
24
|
export * from '../utils/isScriptFile.js';
|
|
25
25
|
export * from '../utils/objectFilter.js';
|
|
26
|
+
export * from '../utils/getPropAccessNotation.js';
|
|
27
|
+
export * from '../utils/objectReplace.js';
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -27,3 +27,5 @@ export * from '../utils/changeEnumerable.js';
|
|
|
27
27
|
export * from '../utils/objectDefineProperty.js';
|
|
28
28
|
export * from '../utils/isScriptFile.js';
|
|
29
29
|
export * from '../utils/objectFilter.js';
|
|
30
|
+
export * from '../utils/getPropAccessNotation.js';
|
|
31
|
+
export * from '../utils/objectReplace.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-5da80bf";
|
|
@@ -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-5da80bf';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { objectAssign };
|
|
2
|
-
declare function objectAssign<Obj extends object, ObjAddendum extends
|
|
2
|
+
declare function objectAssign<Obj extends object, ObjAddendum extends Record<string, any> | null | undefined>(obj: Obj, objAddendum: ObjAddendum, objAddendumCanBeOriginalObject?: true): asserts obj is Obj & ObjAddendum;
|
|
@@ -3,10 +3,10 @@ import { assert } from './assert.js';
|
|
|
3
3
|
// Same as Object.assign() but:
|
|
4
4
|
// - With type inference
|
|
5
5
|
// - Preserves property descriptors, which we need for preserving the getters of getPageContextUrlComputed()
|
|
6
|
-
function objectAssign(obj, objAddendum,
|
|
6
|
+
function objectAssign(obj, objAddendum, objAddendumCanBeOriginalObject) {
|
|
7
7
|
if (!objAddendum)
|
|
8
8
|
return;
|
|
9
|
-
if (!
|
|
10
|
-
assert(!
|
|
9
|
+
if (!objAddendumCanBeOriginalObject)
|
|
10
|
+
assert(!objAddendum._isOriginalObject);
|
|
11
11
|
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
12
12
|
}
|