vike 0.4.229-commit-847f1b6 → 0.4.229-commit-e1ca16d
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/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +8 -8
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +13 -13
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +1 -11
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -77,7 +77,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
77
77
|
routeParams: Record<string, string>;
|
|
78
78
|
} & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & import("../../shared/types.js").PageContextInternalClient & Omit<Partial<{
|
|
79
79
|
isPageContext: true;
|
|
80
|
-
Page: import("../../
|
|
80
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
81
81
|
routeParams: Record<string, string>;
|
|
82
82
|
data: unknown;
|
|
83
83
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -101,7 +101,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
101
101
|
isBaseMissing?: true;
|
|
102
102
|
}> & Pick<{
|
|
103
103
|
isPageContext: true;
|
|
104
|
-
Page: import("../../
|
|
104
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
105
105
|
routeParams: Record<string, string>;
|
|
106
106
|
data: unknown;
|
|
107
107
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -148,7 +148,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
148
148
|
_hasPageContextFromServer: true;
|
|
149
149
|
} & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & Omit<Partial<{
|
|
150
150
|
isPageContext: true;
|
|
151
|
-
Page: import("../../
|
|
151
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
152
152
|
routeParams: Record<string, string>;
|
|
153
153
|
data: unknown;
|
|
154
154
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -172,7 +172,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
172
172
|
isBaseMissing?: true;
|
|
173
173
|
}> & Pick<{
|
|
174
174
|
isPageContext: true;
|
|
175
|
-
Page: import("../../
|
|
175
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
176
176
|
routeParams: Record<string, string>;
|
|
177
177
|
data: unknown;
|
|
178
178
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -288,7 +288,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
288
288
|
routeParams: Record<string, string>;
|
|
289
289
|
} & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & import("../../shared/types.js").PageContextInternalClient & Omit<Partial<{
|
|
290
290
|
isPageContext: true;
|
|
291
|
-
Page: import("../../
|
|
291
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
292
292
|
routeParams: Record<string, string>;
|
|
293
293
|
data: unknown;
|
|
294
294
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -312,7 +312,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
312
312
|
isBaseMissing?: true;
|
|
313
313
|
}> & Pick<{
|
|
314
314
|
isPageContext: true;
|
|
315
|
-
Page: import("../../
|
|
315
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
316
316
|
routeParams: Record<string, string>;
|
|
317
317
|
data: unknown;
|
|
318
318
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -357,7 +357,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
357
357
|
}) | null;
|
|
358
358
|
} & PageConfigUserFriendlyOld & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & Omit<Partial<{
|
|
359
359
|
isPageContext: true;
|
|
360
|
-
Page: import("../../
|
|
360
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
361
361
|
routeParams: Record<string, string>;
|
|
362
362
|
data: unknown;
|
|
363
363
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -381,7 +381,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
381
381
|
isBaseMissing?: true;
|
|
382
382
|
}> & Pick<{
|
|
383
383
|
isPageContext: true;
|
|
384
|
-
Page: import("../../
|
|
384
|
+
Page: import("../../types/index.js").Config["Page"];
|
|
385
385
|
routeParams: Record<string, string>;
|
|
386
386
|
data: unknown;
|
|
387
387
|
config: import("../../shared/page-configs/Config/PageContextConfig.js").PageContextConfig;
|
|
@@ -65,7 +65,7 @@ async function getPageContextFromServerHooks(pageContext, isErrorPage) {
|
|
|
65
65
|
return { pageContextFromServerHooks };
|
|
66
66
|
}
|
|
67
67
|
async function getPageContextFromClientHooks(pageContext, isErrorPage) {
|
|
68
|
-
let
|
|
68
|
+
let dataHookExec = false;
|
|
69
69
|
// At this point, we need to call the client-side guard(), data() and onBeforeRender() hooks, if they exist on client
|
|
70
70
|
// env. However if we have fetched pageContext from the server, some of them might have run already on the
|
|
71
71
|
// server-side, so we run only the client-only ones in this case.
|
|
@@ -82,16 +82,17 @@ async function getPageContextFromClientHooks(pageContext, isErrorPage) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
if (hookName === 'data')
|
|
86
|
-
dataHookExists = true;
|
|
87
85
|
if (hookClientOnlyExists(hookName, pageContext) || !pageContext._hasPageContextFromServer) {
|
|
86
|
+
if (hookName === 'data')
|
|
87
|
+
dataHookExec = true;
|
|
88
88
|
// This won't do anything if no hook has been defined or if the hook's env.client is false.
|
|
89
89
|
await executeDataLikeHook(hookName, pageContext);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
// Execute +onData
|
|
94
|
-
|
|
94
|
+
const dataHookEnv = getHookEnv('data', pageContext);
|
|
95
|
+
if ((dataHookExec && dataHookEnv.client) || (pageContext._hasPageContextFromServer && dataHookEnv.server)) {
|
|
95
96
|
await execHookClient('onData', pageContext);
|
|
96
97
|
}
|
|
97
98
|
const pageContextFromClientHooks = pageContext;
|
|
@@ -188,23 +189,22 @@ async function hookServerOnlyExists(hookName, pageContext) {
|
|
|
188
189
|
return hasOnBeforeRenderServerSideOnlyHook;
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
|
-
/**
|
|
192
|
-
* @param hookName
|
|
193
|
-
* @param pageContext
|
|
194
|
-
* @returns `true` if the given page has a `hookName` hook defined with a client-only env.
|
|
195
|
-
*/
|
|
196
192
|
function hookClientOnlyExists(hookName, pageContext) {
|
|
193
|
+
const hookEnv = getHookEnv(hookName, pageContext);
|
|
194
|
+
return !!hookEnv.client && !hookEnv.server;
|
|
195
|
+
}
|
|
196
|
+
function getHookEnv(hookName, pageContext) {
|
|
197
197
|
if (pageContext._pageConfigs.length > 0) {
|
|
198
198
|
// V1
|
|
199
199
|
const pageConfig = getPageConfig(pageContext.pageId, pageContext._pageConfigs);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return
|
|
200
|
+
// No runtime validation to save client-side KBs
|
|
201
|
+
const hookEnv = (getConfigValueRuntime(pageConfig, `${hookName}Env`)?.value ?? {});
|
|
202
|
+
return hookEnv;
|
|
203
203
|
}
|
|
204
204
|
else {
|
|
205
205
|
// TODO/v1-release: remove
|
|
206
206
|
// Client-only onBeforeRender() or data() hooks were never supported for the V0.4 design
|
|
207
|
-
return false;
|
|
207
|
+
return { client: false, server: true };
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
async function fetchPageContextFromServer(pageContext) {
|
|
@@ -4,7 +4,7 @@ export { disableClientRouting };
|
|
|
4
4
|
export { firstRenderStartPromise };
|
|
5
5
|
export { getPageContextClient };
|
|
6
6
|
import { assert, isSameErrorMessage, objectAssign, redirectHard, getGlobalObject, hasProp, augmentType, genPromise, isCallable, catchInfiniteLoop } from './utils.js';
|
|
7
|
-
import { getPageContextFromClientHooks, getPageContextFromServerHooks, getPageContextFromHooks_isHydration, getPageContextFromHooks_serialized, setPageContextInitIsPassedToClient
|
|
7
|
+
import { getPageContextFromClientHooks, getPageContextFromServerHooks, getPageContextFromHooks_isHydration, getPageContextFromHooks_serialized, setPageContextInitIsPassedToClient } from './getPageContextFromHooks.js';
|
|
8
8
|
import { createPageContextClientSide } from './createPageContextClientSide.js';
|
|
9
9
|
import { addLinkPrefetchHandlers, addLinkPrefetchHandlers_unwatch, addLinkPrefetchHandlers_watch, getPageContextPrefetched, populatePageContextPrefetchCache } from './prefetch.js';
|
|
10
10
|
import { assertInfo, assertWarning, isReact } from './utils.js';
|
|
@@ -203,16 +203,6 @@ async function renderPageClientSide(renderArgs) {
|
|
|
203
203
|
// TO-DO/eventually: create helper assertPageContextFromHook()
|
|
204
204
|
assert(!('urlOriginal' in pageContextFromServerHooks));
|
|
205
205
|
objectAssign(pageContext, pageContextFromServerHooks);
|
|
206
|
-
// Execute +onData
|
|
207
|
-
try {
|
|
208
|
-
await execHookClient('onData', pageContext);
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
await onError(err);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (isRenderOutdated())
|
|
215
|
-
return;
|
|
216
206
|
// Get pageContext from client-side hooks
|
|
217
207
|
let pageContextFromClientHooks;
|
|
218
208
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.229-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.229-commit-e1ca16d";
|
|
@@ -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-e1ca16d';
|