vike 0.4.244 → 0.4.245-commit-189d2b8
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/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +6 -0
- package/dist/esm/client/runtime-client-routing/history.d.ts +5 -1
- package/dist/esm/client/runtime-client-routing/history.js +25 -3
- package/dist/esm/client/runtime-client-routing/initClientRouter.js +0 -1
- package/dist/esm/client/runtime-client-routing/initOnLinkClick.js +3 -4
- package/dist/esm/client/runtime-client-routing/initOnPopState.js +9 -15
- package/dist/esm/client/runtime-client-routing/isLinkSkipped.d.ts +6 -0
- package/dist/esm/client/runtime-client-routing/{skipLink.js → isLinkSkipped.js} +10 -15
- package/dist/esm/client/runtime-client-routing/navigate.js +0 -1
- package/dist/esm/client/runtime-client-routing/prefetch.js +3 -3
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +8 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +4 -4
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -0
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -0
- package/dist/esm/node/runtime/renderPage/html/serializeContext.js +8 -0
- package/dist/esm/node/vite/plugins/build/handleAssetsManifest.js +4 -3
- package/dist/esm/node/vite/plugins/build/pluginBuildApp.js +1 -1
- package/dist/esm/node/vite/plugins/pluginViteConfigVikeExtensions.js +8 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +3 -3
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +10 -9
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -2
- package/dist/esm/types/Config.d.ts +93 -24
- package/dist/esm/types/PageContext.d.ts +18 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +2 -2
- package/dist/esm/client/runtime-client-routing/skipLink.d.ts +0 -6
|
@@ -89,6 +89,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
89
89
|
url: string;
|
|
90
90
|
} & import("../../shared/page-configs/resolveVikeConfigPublic.js").GlobalConfigPublic & {
|
|
91
91
|
isBackwardNavigation: boolean | null;
|
|
92
|
+
isHistoryNavigation: boolean;
|
|
92
93
|
isClientSideNavigation: boolean;
|
|
93
94
|
isHydration: boolean;
|
|
94
95
|
previousPageContext: ({
|
|
@@ -144,6 +145,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
144
145
|
} & {
|
|
145
146
|
isHydration: boolean;
|
|
146
147
|
isBackwardNavigation: boolean | null;
|
|
148
|
+
isHistoryNavigation: boolean;
|
|
147
149
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
148
150
|
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
149
151
|
} & {
|
|
@@ -209,6 +211,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
209
211
|
} & {
|
|
210
212
|
isHydration: boolean;
|
|
211
213
|
isBackwardNavigation: boolean | null;
|
|
214
|
+
isHistoryNavigation: boolean;
|
|
212
215
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
213
216
|
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
214
217
|
} & {
|
|
@@ -310,6 +313,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
310
313
|
url: string;
|
|
311
314
|
} & import("../../shared/page-configs/resolveVikeConfigPublic.js").GlobalConfigPublic & {
|
|
312
315
|
isBackwardNavigation: boolean | null;
|
|
316
|
+
isHistoryNavigation: boolean;
|
|
313
317
|
isClientSideNavigation: boolean;
|
|
314
318
|
isHydration: boolean;
|
|
315
319
|
previousPageContext: ({
|
|
@@ -365,6 +369,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
365
369
|
} & {
|
|
366
370
|
isHydration: boolean;
|
|
367
371
|
isBackwardNavigation: boolean | null;
|
|
372
|
+
isHistoryNavigation: boolean;
|
|
368
373
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
369
374
|
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
370
375
|
} & {
|
|
@@ -428,6 +433,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
428
433
|
} & {
|
|
429
434
|
isHydration: boolean;
|
|
430
435
|
isBackwardNavigation: boolean | null;
|
|
436
|
+
isHistoryNavigation: boolean;
|
|
431
437
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
432
438
|
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
433
439
|
} & {
|
|
@@ -23,8 +23,12 @@ type HistoryInfo = {
|
|
|
23
23
|
state: StateEnhanced;
|
|
24
24
|
};
|
|
25
25
|
declare function onPopStateBegin(): {
|
|
26
|
-
|
|
26
|
+
skip: true;
|
|
27
|
+
previous?: undefined;
|
|
28
|
+
current?: undefined;
|
|
29
|
+
} | {
|
|
27
30
|
previous: HistoryInfo;
|
|
28
31
|
current: HistoryInfo;
|
|
32
|
+
skip?: undefined;
|
|
29
33
|
};
|
|
30
34
|
declare function initHistory(): void;
|
|
@@ -4,7 +4,7 @@ export { onPopStateBegin };
|
|
|
4
4
|
export { saveScrollPosition };
|
|
5
5
|
export { initHistory };
|
|
6
6
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
7
|
-
import { assert, assertUsage, getGlobalObject, isObject, deepEqual, cast } from './utils.js';
|
|
7
|
+
import { assert, assertUsage, getGlobalObject, isObject, deepEqual, cast, redirectHard } from './utils.js';
|
|
8
8
|
const globalObject = getGlobalObject('history.ts', {
|
|
9
9
|
monkeyPatched: false,
|
|
10
10
|
previous: undefined,
|
|
@@ -66,6 +66,10 @@ function getTimestamp() {
|
|
|
66
66
|
}
|
|
67
67
|
function saveScrollPosition() {
|
|
68
68
|
const scrollPosition = getScrollPosition();
|
|
69
|
+
// Don't overwrite history.state if it was set by a non-Vike history.pushState() call.
|
|
70
|
+
// https://github.com/vikejs/vike/issues/2801#issuecomment-3490431479
|
|
71
|
+
if (!isVikeEnhanced(window.history.state))
|
|
72
|
+
return;
|
|
69
73
|
const state = getState();
|
|
70
74
|
replaceHistoryState({ ...state, scrollPosition });
|
|
71
75
|
}
|
|
@@ -160,13 +164,31 @@ function getHistoryInfo() {
|
|
|
160
164
|
}
|
|
161
165
|
function onPopStateBegin() {
|
|
162
166
|
const { previous } = globalObject;
|
|
163
|
-
const isHistoryStateEnhanced = window.history.state
|
|
167
|
+
const isHistoryStateEnhanced = isVikeEnhanced(window.history.state);
|
|
168
|
+
// Either:
|
|
169
|
+
// - `window.history.pushState(null, '', '/some-path')` , or
|
|
170
|
+
// - hash navigation
|
|
171
|
+
// - Click on `<a href="#some-hash">`
|
|
172
|
+
// - Using the `location` API (only hash navigation)
|
|
173
|
+
// See comments a the top of the ./initOnPopState.ts file.
|
|
174
|
+
const isHistoryStatePristine = window.history.state === null;
|
|
175
|
+
if (!isHistoryStateEnhanced && !isHistoryStatePristine) {
|
|
176
|
+
// Going to a history entry not created by Vike — entering another "SPA realm" => hard reload
|
|
177
|
+
// https://github.com/vikejs/vike/issues/2801#issuecomment-3490431479
|
|
178
|
+
redirectHard(getCurrentUrl());
|
|
179
|
+
return { skip: true };
|
|
180
|
+
}
|
|
164
181
|
if (!isHistoryStateEnhanced)
|
|
165
182
|
enhanceHistoryState();
|
|
166
183
|
assertIsVikeEnhanced(window.history.state);
|
|
167
184
|
const current = getHistoryInfo();
|
|
168
185
|
globalObject.previous = current;
|
|
169
|
-
|
|
186
|
+
// Let the browser handle hash navigations.
|
|
187
|
+
// - Upon hash navigation: `isHistoryStatePristine===true` (see comment above).
|
|
188
|
+
if (isHistoryStatePristine) {
|
|
189
|
+
return { skip: true };
|
|
190
|
+
}
|
|
191
|
+
return { previous, current };
|
|
170
192
|
}
|
|
171
193
|
function initHistory() {
|
|
172
194
|
monkeyPatchHistoryAPI(); // the earlier we call it the better (Vike can workaround erroneous library monkey patches if Vike is the last one in the monkey patch chain)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { initOnLinkClick };
|
|
2
|
-
import { isLinkIgnored,
|
|
2
|
+
import { isLinkIgnored, isHrefCurrentUrl, isLinkSkipped } from './isLinkSkipped.js';
|
|
3
3
|
import { renderPageClientSide } from './renderPageClientSide.js';
|
|
4
4
|
import { scrollToHashOrTop } from './setScrollPosition.js';
|
|
5
5
|
function initOnLinkClick() {
|
|
@@ -19,14 +19,14 @@ async function onLinkClick(ev) {
|
|
|
19
19
|
// Workaround for Firefox bug: clicking on a hash link that doesn't change the current URL causes Firefox to erroneously set `window.history.state = null` without firing any signal that we can detect.
|
|
20
20
|
// - https://github.com/vikejs/vike/issues/1962
|
|
21
21
|
// - https://github.com/sveltejs/kit/issues/8725
|
|
22
|
-
if (href.includes('#') &&
|
|
22
|
+
if (href.includes('#') && isHrefCurrentUrl(href)) {
|
|
23
23
|
// Prevent Firefox from setting `window.history.state` to `null`
|
|
24
24
|
ev.preventDefault();
|
|
25
25
|
// Replicate the browser's native behavior
|
|
26
26
|
scrollToHashOrTop(href.split('#')[1]);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
if (
|
|
29
|
+
if (isLinkSkipped(linkTag))
|
|
30
30
|
return;
|
|
31
31
|
ev.preventDefault();
|
|
32
32
|
let scrollTarget;
|
|
@@ -38,7 +38,6 @@ async function onLinkClick(ev) {
|
|
|
38
38
|
await renderPageClientSide({
|
|
39
39
|
scrollTarget,
|
|
40
40
|
urlOriginal: href,
|
|
41
|
-
isBackwardNavigation: false,
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
43
|
function isNormalLeftClick(ev) {
|
|
@@ -14,7 +14,7 @@ import { catchInfiniteLoop } from './utils.js';
|
|
|
14
14
|
// 2. URL hash changes:
|
|
15
15
|
// - By the user clicking on `<a href="#some-hash">`
|
|
16
16
|
// - The popstate event is *only* triggered if `href` starts with '#' (even if `href==='/foo#bar'` and the current URL has the same pathname '/foo' then popstate isn't triggered)
|
|
17
|
-
// - Vike doesn't intercept hash links (see `
|
|
17
|
+
// - Vike doesn't intercept hash links (see `isLinkSkipped()`) and let's the browser handle them.
|
|
18
18
|
// - By the app using a `location` API such as `location.hash = 'some-hash'`
|
|
19
19
|
// - Only upon hash navigation: setting `location.href='/foo'` triggers a full page reload and no popstate event is fired.
|
|
20
20
|
// - Also upon `location.href='/foo#bar'` while the current URL is '/foo' (unlike <a> clicks).
|
|
@@ -23,26 +23,20 @@ import { catchInfiniteLoop } from './utils.js';
|
|
|
23
23
|
// - It isn't possible to monkey patch the `location` APIs. (Chrome throws `TypeError: Cannot redefine property` when attempt to overwrite any `location` property.)
|
|
24
24
|
// - Text links aren't supported: https://github.com/vikejs/vike/issues/2114
|
|
25
25
|
// - docs/ is a good playground to test all this.
|
|
26
|
+
// - No 'popstate' event is fired upon Server Routing — when the user clicks on a link before the page's JavaScript loaded.
|
|
27
|
+
// - On a pristine page without JavaScript such as https://brillout.com we have `window.history.state === null`.
|
|
26
28
|
function initOnPopState() {
|
|
27
29
|
window.addEventListener('popstate', onPopState);
|
|
28
30
|
}
|
|
29
31
|
async function onPopState() {
|
|
30
32
|
catchInfiniteLoop('onPopState()');
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
// - Click on `<a href="#some-hash">`
|
|
34
|
-
// - Using the `location` API (only hash navigation, see comments above).
|
|
35
|
-
// - `isHistoryStateEnhanced===true` <=> back-/forward navigation (including back-/forward hash navigation).
|
|
36
|
-
// > Only back-/forward client-side navigation: no 'popstate' event is fired upon Server Routing (when the user clicks on a link before the page's JavaScript loaded), see comments above.
|
|
37
|
-
if (!isHistoryStateEnhanced) {
|
|
38
|
-
// Let the browser handle it
|
|
33
|
+
const res = onPopStateBegin();
|
|
34
|
+
if (res.skip)
|
|
39
35
|
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await handleBackForwardNavigation(previous, current);
|
|
43
|
-
}
|
|
36
|
+
const { previous, current } = res;
|
|
37
|
+
await handleHistoryNavigation(previous, current);
|
|
44
38
|
}
|
|
45
|
-
async function
|
|
39
|
+
async function handleHistoryNavigation(previous, current) {
|
|
46
40
|
const scrollTarget = current.state.scrollPosition || undefined;
|
|
47
41
|
const isHashNavigation = removeHash(current.url) === removeHash(previous.url) && current.url !== previous.url;
|
|
48
42
|
if (isHashNavigation) {
|
|
@@ -53,7 +47,7 @@ async function handleBackForwardNavigation(previous, current) {
|
|
|
53
47
|
const isUserPushStateNavigation = current.state.triggeredBy === 'user' || previous.state.triggeredBy === 'user';
|
|
54
48
|
const doNotRenderIfSamePage = isUserPushStateNavigation;
|
|
55
49
|
const isBackwardNavigation = !current.state.timestamp || !previous.state.timestamp ? null : current.state.timestamp < previous.state.timestamp;
|
|
56
|
-
await renderPageClientSide({ scrollTarget, isBackwardNavigation, doNotRenderIfSamePage });
|
|
50
|
+
await renderPageClientSide({ scrollTarget, isBackwardNavigation, doNotRenderIfSamePage, isHistoryNavigation: true });
|
|
57
51
|
}
|
|
58
52
|
function removeHash(url) {
|
|
59
53
|
return url.split('#')[0];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { isLinkSkipped };
|
|
2
|
+
export { isLinkIgnored };
|
|
3
|
+
export { isHrefCurrentUrl };
|
|
4
|
+
declare function isLinkSkipped(linkTag: HTMLElement): boolean;
|
|
5
|
+
declare function isLinkIgnored(linkTag: HTMLElement): boolean;
|
|
6
|
+
declare function isHrefCurrentUrl(href: string): boolean;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
export { skipLink };
|
|
1
|
+
export { isLinkSkipped };
|
|
3
2
|
export { isLinkIgnored };
|
|
4
|
-
export {
|
|
3
|
+
export { isHrefCurrentUrl };
|
|
5
4
|
import { normalizeClientSideUrl } from '../shared/normalizeClientSideUrl.js';
|
|
6
5
|
import { getBaseServer } from './getBaseServer.js';
|
|
7
6
|
import { assert, parseUrl, isBaseServer, isUrl, isUrlExternal } from './utils.js';
|
|
8
|
-
function
|
|
7
|
+
function isLinkSkipped(linkTag) {
|
|
9
8
|
const href = linkTag.getAttribute('href');
|
|
10
9
|
return (href === null ||
|
|
11
10
|
!isUrl(href) ||
|
|
12
11
|
href === '' ||
|
|
13
12
|
isUrlExternal(href) ||
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
isHrefSamePageHash(href) ||
|
|
14
|
+
isLinkExternal(linkTag) ||
|
|
16
15
|
isLinkIgnored(linkTag) ||
|
|
17
16
|
!hasBaseServer(href) ||
|
|
18
17
|
// Purposely last because disableAutomaticLinkInterception will be removed in the next major release
|
|
@@ -25,13 +24,11 @@ function isVikeLink(linkTag) {
|
|
|
25
24
|
return true;
|
|
26
25
|
}
|
|
27
26
|
else {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return target !== null && target !== 'false';
|
|
27
|
+
const attrVal = linkTag.getAttribute('data-vike-link');
|
|
28
|
+
return attrVal !== null && attrVal !== 'false';
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
function isNewTabLink(linkTag) {
|
|
31
|
+
function isLinkExternal(linkTag) {
|
|
35
32
|
const target = linkTag.getAttribute('target');
|
|
36
33
|
const rel = linkTag.getAttribute('rel');
|
|
37
34
|
return target === '_blank' || target === '_external' || rel === 'external' || linkTag.hasAttribute('download');
|
|
@@ -39,11 +36,9 @@ function isNewTabLink(linkTag) {
|
|
|
39
36
|
function isLinkIgnored(linkTag) {
|
|
40
37
|
return linkTag.getAttribute('data-vike') === 'false';
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
function isSamePageHashLink(href) {
|
|
39
|
+
function isHrefSamePageHash(href) {
|
|
44
40
|
if (href.startsWith('#'))
|
|
45
41
|
return true;
|
|
46
|
-
// TODO: remove?
|
|
47
42
|
if (href.includes('#') &&
|
|
48
43
|
normalizeClientSideUrl(href, { withoutHash: true }) ===
|
|
49
44
|
normalizeClientSideUrl(window.location.href, { withoutHash: true })) {
|
|
@@ -51,7 +46,7 @@ function isSamePageHashLink(href) {
|
|
|
51
46
|
}
|
|
52
47
|
return false;
|
|
53
48
|
}
|
|
54
|
-
function
|
|
49
|
+
function isHrefCurrentUrl(href) {
|
|
55
50
|
if (href.startsWith('#'))
|
|
56
51
|
return href === window.location.hash;
|
|
57
52
|
return normalizeClientSideUrl(href) === normalizeClientSideUrl(window.location.href);
|
|
@@ -7,7 +7,7 @@ export { addLinkPrefetchHandlers_watch };
|
|
|
7
7
|
export { addLinkPrefetchHandlers_unwatch };
|
|
8
8
|
import { assert, assertClientRouting, assertUsage, assertWarning, checkIfClientRouting, getGlobalObject, hasProp, objectAssign, } from './utils.js';
|
|
9
9
|
import { isErrorFetchingStaticAssets, loadPageConfigsLazyClientSide } from '../shared/loadPageConfigsLazyClientSide.js';
|
|
10
|
-
import {
|
|
10
|
+
import { isLinkSkipped } from './isLinkSkipped.js';
|
|
11
11
|
import { disableClientRouting } from './renderPageClientSide.js';
|
|
12
12
|
import { isClientSideRoutable } from './isClientSideRoutable.js';
|
|
13
13
|
import { createPageContextClientSide } from './createPageContextClientSide.js';
|
|
@@ -170,7 +170,7 @@ function addLinkPrefetchHandlers_apply() {
|
|
|
170
170
|
if (globalObject.linkPrefetchHandlerAdded.has(linkTag))
|
|
171
171
|
continue;
|
|
172
172
|
globalObject.linkPrefetchHandlerAdded.add(linkTag);
|
|
173
|
-
if (
|
|
173
|
+
if (isLinkSkipped(linkTag))
|
|
174
174
|
continue;
|
|
175
175
|
linkTag.addEventListener('mouseover', () => {
|
|
176
176
|
prefetchOnEvent(linkTag, 'hover');
|
|
@@ -205,7 +205,7 @@ async function prefetchOnEvent(linkTag, event) {
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
// Check again in case DOM was manipulated since last check
|
|
208
|
-
if (
|
|
208
|
+
if (isLinkSkipped(linkTag))
|
|
209
209
|
return;
|
|
210
210
|
const urlOfLink = linkTag.getAttribute('href');
|
|
211
211
|
const pageContextLink = await getPageContextLink(urlOfLink);
|
|
@@ -19,7 +19,8 @@ type PageContextRouted = {
|
|
|
19
19
|
type PageContextBegin = Awaited<ReturnType<typeof getPageContextBegin>>;
|
|
20
20
|
type RenderArgs = {
|
|
21
21
|
scrollTarget: ScrollTarget;
|
|
22
|
-
isBackwardNavigation
|
|
22
|
+
isBackwardNavigation?: boolean | null;
|
|
23
|
+
isHistoryNavigation?: true;
|
|
23
24
|
urlOriginal?: string;
|
|
24
25
|
overwriteLastHistoryEntry?: boolean;
|
|
25
26
|
pageContextsFromRewrite?: PageContextFromRewrite[];
|
|
@@ -103,6 +104,7 @@ declare function renderPageClientSide(renderArgs: RenderArgs): Promise<({
|
|
|
103
104
|
url: string;
|
|
104
105
|
} & import("../../shared/page-configs/resolveVikeConfigPublic.js").GlobalConfigPublic & {
|
|
105
106
|
isBackwardNavigation: boolean | null;
|
|
107
|
+
isHistoryNavigation: boolean;
|
|
106
108
|
isClientSideNavigation: boolean;
|
|
107
109
|
isHydration: boolean;
|
|
108
110
|
previousPageContext: ({
|
|
@@ -155,6 +157,7 @@ declare function renderPageClientSide(renderArgs: RenderArgs): Promise<({
|
|
|
155
157
|
} & {
|
|
156
158
|
isHydration: boolean;
|
|
157
159
|
isBackwardNavigation: boolean | null;
|
|
160
|
+
isHistoryNavigation: boolean;
|
|
158
161
|
previousPageContext: PageContextClient<unknown> | null;
|
|
159
162
|
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
160
163
|
} & {
|
|
@@ -174,9 +177,10 @@ declare function renderPageClientSide(renderArgs: RenderArgs): Promise<({
|
|
|
174
177
|
urlPathname: string;
|
|
175
178
|
_hasPageContextFromServer: boolean;
|
|
176
179
|
} & PageContextRouted) | undefined>;
|
|
177
|
-
declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isBackwardNavigation, pageContextsFromRewrite, isClientSideNavigation, pageContextInitClient, isFirstRender, }: {
|
|
180
|
+
declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isBackwardNavigation, isHistoryNavigation, pageContextsFromRewrite, isClientSideNavigation, pageContextInitClient, isFirstRender, }: {
|
|
178
181
|
urlOriginal: string;
|
|
179
182
|
isBackwardNavigation: boolean | null;
|
|
183
|
+
isHistoryNavigation: boolean;
|
|
180
184
|
pageContextsFromRewrite: PageContextFromRewrite[];
|
|
181
185
|
isClientSideNavigation: boolean;
|
|
182
186
|
pageContextInitClient: Record<string, unknown> | undefined;
|
|
@@ -250,6 +254,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
250
254
|
url: string;
|
|
251
255
|
} & import("../../shared/page-configs/resolveVikeConfigPublic.js").GlobalConfigPublic & {
|
|
252
256
|
isBackwardNavigation: boolean | null;
|
|
257
|
+
isHistoryNavigation: boolean;
|
|
253
258
|
isClientSideNavigation: boolean;
|
|
254
259
|
isHydration: boolean;
|
|
255
260
|
previousPageContext: ({
|
|
@@ -302,6 +307,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
302
307
|
} & {
|
|
303
308
|
isHydration: boolean;
|
|
304
309
|
isBackwardNavigation: boolean | null;
|
|
310
|
+
isHistoryNavigation: boolean;
|
|
305
311
|
previousPageContext: PageContextClient<unknown> | null;
|
|
306
312
|
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
307
313
|
} & {
|
|
@@ -36,7 +36,7 @@ const globalObject = getGlobalObject('runtime-client-routing/renderPageClientSid
|
|
|
36
36
|
const { firstRenderStartPromise } = globalObject;
|
|
37
37
|
async function renderPageClientSide(renderArgs) {
|
|
38
38
|
catchInfiniteLoop('renderPageClientSide()');
|
|
39
|
-
const { urlOriginal = getCurrentUrl(), overwriteLastHistoryEntry = false, isBackwardNavigation, pageContextsFromRewrite = [], redirectCount = 0, doNotRenderIfSamePage, isClientSideNavigation = true, pageContextInitClient, } = renderArgs;
|
|
39
|
+
const { urlOriginal = getCurrentUrl(), overwriteLastHistoryEntry = false, isBackwardNavigation = false, isHistoryNavigation = false, pageContextsFromRewrite = [], redirectCount = 0, doNotRenderIfSamePage, isClientSideNavigation = true, pageContextInitClient, } = renderArgs;
|
|
40
40
|
let { scrollTarget } = renderArgs;
|
|
41
41
|
const { previousPageContext } = globalObject;
|
|
42
42
|
addLinkPrefetchHandlers_unwatch();
|
|
@@ -45,6 +45,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
45
45
|
const pageContextBeginArgs = {
|
|
46
46
|
urlOriginal,
|
|
47
47
|
isBackwardNavigation,
|
|
48
|
+
isHistoryNavigation,
|
|
48
49
|
pageContextsFromRewrite,
|
|
49
50
|
isClientSideNavigation,
|
|
50
51
|
pageContextInitClient,
|
|
@@ -369,7 +370,6 @@ async function renderPageClientSide(renderArgs) {
|
|
|
369
370
|
scrollTarget: undefined,
|
|
370
371
|
urlOriginal: urlRedirect,
|
|
371
372
|
overwriteLastHistoryEntry: false,
|
|
372
|
-
isBackwardNavigation: false,
|
|
373
373
|
redirectCount: redirectCount + 1,
|
|
374
374
|
});
|
|
375
375
|
}
|
|
@@ -476,11 +476,12 @@ async function renderPageClientSide(renderArgs) {
|
|
|
476
476
|
return pageContext;
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
|
-
async function getPageContextBegin(isForErrorPage, { urlOriginal, isBackwardNavigation, pageContextsFromRewrite, isClientSideNavigation, pageContextInitClient, isFirstRender, }) {
|
|
479
|
+
async function getPageContextBegin(isForErrorPage, { urlOriginal, isBackwardNavigation, isHistoryNavigation, pageContextsFromRewrite, isClientSideNavigation, pageContextInitClient, isFirstRender, }) {
|
|
480
480
|
const previousPageContext = globalObject.previousPageContext ?? null;
|
|
481
481
|
const pageContext = await createPageContextClientSide(urlOriginal);
|
|
482
482
|
objectAssign(pageContext, {
|
|
483
483
|
isBackwardNavigation,
|
|
484
|
+
isHistoryNavigation,
|
|
484
485
|
isClientSideNavigation,
|
|
485
486
|
isHydration: isFirstRender && !isForErrorPage,
|
|
486
487
|
previousPageContext,
|
|
@@ -662,7 +663,6 @@ if (import.meta.env.DEV && import.meta.hot)
|
|
|
662
663
|
scrollTarget: { preserveScroll: false },
|
|
663
664
|
urlOriginal: getCurrentUrl(),
|
|
664
665
|
overwriteLastHistoryEntry: true,
|
|
665
|
-
isBackwardNavigation: false,
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
668
|
});
|
|
@@ -18,6 +18,7 @@ async function createPageContextClientSide() {
|
|
|
18
18
|
_globalContext: globalContext,
|
|
19
19
|
_pageFilesAll: globalContext._pageFilesAll, // TO-DO/next-major-release: remove
|
|
20
20
|
isBackwardNavigation: null,
|
|
21
|
+
isHistoryNavigation: null,
|
|
21
22
|
_hasPageContextFromServer: true,
|
|
22
23
|
});
|
|
23
24
|
objectAssign(pageContextCreated, getPageContextSerializedInHtml());
|
|
@@ -10,6 +10,7 @@ import { NOT_SERIALIZABLE } from '../../../../shared/NOT_SERIALIZABLE.js';
|
|
|
10
10
|
import { pageContextInitIsPassedToClient } from '../../../../shared/misc/pageContextInitIsPassedToClient.js';
|
|
11
11
|
import { isServerSideError } from '../../../../shared/misc/isServerSideError.js';
|
|
12
12
|
import { getPropKeys, getPropVal, setPropVal } from './propKeys.js';
|
|
13
|
+
import { assertRouteParams } from '../../../../shared/route/resolveRouteFunction.js';
|
|
13
14
|
const passToClientBuiltInPageContext = [
|
|
14
15
|
'abortReason',
|
|
15
16
|
'_urlRewrite',
|
|
@@ -123,6 +124,7 @@ function serializeValue(value, isHtmlJsonScript, varName) {
|
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
126
|
function getPassToClientPageContext(pageContext) {
|
|
127
|
+
assertPageContext(pageContext);
|
|
126
128
|
let passToClient = [...pageContext._passToClient, ...passToClientBuiltInPageContext];
|
|
127
129
|
if (isErrorPage(pageContext.pageId, pageContext._globalContext._pageConfigs)) {
|
|
128
130
|
assert(hasProp(pageContext, 'is404', 'boolean'));
|
|
@@ -182,3 +184,9 @@ function applyPassToClient(passToClient, obj) {
|
|
|
182
184
|
});
|
|
183
185
|
return { objClient, objClientProps };
|
|
184
186
|
}
|
|
187
|
+
// Ensure the following client-side assert() don't fail:
|
|
188
|
+
// https://github.com/vikejs/vike/blob/a33b6e6319a9a0e34ea78e23c5aa156022e3745c/packages/vike/client/shared/getJsonSerializedInHtml.ts#L15-L16
|
|
189
|
+
function assertPageContext(pageContext) {
|
|
190
|
+
assertUsage(hasProp(pageContext, 'pageId', 'string'), `${pc.bold('pageContext.pageId')} should be a ${pc.bold('string')}`);
|
|
191
|
+
assertRouteParams(pageContext, `${pc.bold('pageContext.routeParams')} should`);
|
|
192
|
+
}
|
|
@@ -221,9 +221,10 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
|
221
221
|
}
|
|
222
222
|
function handleAssetsManifest_alignCssTarget(config) {
|
|
223
223
|
globalObject.configsAll.push(config);
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
const clientSideConfigs = globalObject.configsAll.filter((c) => !isViteServerSide_viteEnvOptional(c, undefined));
|
|
225
|
+
if (clientSideConfigs.length === 0)
|
|
226
|
+
return;
|
|
227
|
+
const { cssTarget } = clientSideConfigs.at(-1).build;
|
|
227
228
|
assert(cssTarget);
|
|
228
229
|
globalObject.configsAll.forEach((c) => (c.build.cssTarget = cssTarget));
|
|
229
230
|
}
|
|
@@ -89,6 +89,7 @@ function pluginBuildApp() {
|
|
|
89
89
|
*/
|
|
90
90
|
async handler(options, bundle) {
|
|
91
91
|
try {
|
|
92
|
+
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
92
93
|
await handleAssetsManifest(config, this.environment, options, bundle);
|
|
93
94
|
await triggerPrerendering(config, this.environment, bundle);
|
|
94
95
|
}
|
|
@@ -112,7 +113,6 @@ function pluginBuildApp() {
|
|
|
112
113
|
order: 'post',
|
|
113
114
|
handler() {
|
|
114
115
|
onSetupBuild();
|
|
115
|
-
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
116
116
|
},
|
|
117
117
|
},
|
|
118
118
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { pluginViteConfigVikeExtensions };
|
|
2
2
|
import { mergeConfig } from 'vite';
|
|
3
|
-
import { assertUsage, isObject } from '../utils.js';
|
|
3
|
+
import { assertUsage, isCallable, isObject } from '../utils.js';
|
|
4
4
|
import { getVikeConfigInternalEarly } from '../../api/resolveViteConfigFromUser.js';
|
|
5
5
|
// Apply +vite
|
|
6
6
|
// - For example, Vike extensions adding Vite plugins
|
|
@@ -12,10 +12,13 @@ async function pluginViteConfigVikeExtensions() {
|
|
|
12
12
|
const viteConfigsExtensions = vikeConfig._from.configsCumulative.vite;
|
|
13
13
|
if (!viteConfigsExtensions)
|
|
14
14
|
return [];
|
|
15
|
-
viteConfigsExtensions.values.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
await Promise.all(viteConfigsExtensions.values.map(async (v) => {
|
|
16
|
+
let val = v.value;
|
|
17
|
+
if (isCallable(val))
|
|
18
|
+
val = await val();
|
|
19
|
+
assertUsage(isObject(val), `${v.definedAt} should be an object, or a function returning an object`);
|
|
20
|
+
viteConfigFromExtensions = mergeConfig(viteConfigFromExtensions, val);
|
|
21
|
+
}));
|
|
19
22
|
const pluginsFromExtensions = (viteConfigFromExtensions.plugins ?? []);
|
|
20
23
|
delete viteConfigFromExtensions.plugins;
|
|
21
24
|
return [
|
|
@@ -2,7 +2,6 @@ export { getVikeConfig };
|
|
|
2
2
|
export type { VikeConfig };
|
|
3
3
|
export { getVikeConfigInternal };
|
|
4
4
|
export { getVikeConfigInternalOptional };
|
|
5
|
-
export { getVikeConfigInternalSync };
|
|
6
5
|
export { setVikeConfigContext };
|
|
7
6
|
export { isVikeConfigContextSet };
|
|
8
7
|
export { reloadVikeConfig };
|
|
@@ -38,13 +37,14 @@ type VikeConfigInternal = GlobalConfigPublic & {
|
|
|
38
37
|
};
|
|
39
38
|
declare function reloadVikeConfig(): void;
|
|
40
39
|
declare function getVikeConfigInternal(doNotRestartViteOnError?: boolean): Promise<VikeConfigInternal>;
|
|
41
|
-
declare function getVikeConfigInternalSync(): VikeConfigInternal;
|
|
42
40
|
/**
|
|
43
41
|
* Get all the information Vike knows about the app in your Vite plugin.
|
|
44
42
|
*
|
|
45
43
|
* https://vike.dev/getVikeConfig
|
|
46
44
|
*/
|
|
47
|
-
declare function getVikeConfig(
|
|
45
|
+
declare function getVikeConfig(
|
|
46
|
+
/** @deprecated the `config` argument isn't needed anymore — remove it (it doesn't have any effect) */
|
|
47
|
+
config?: ResolvedConfig | UserConfig): VikeConfig;
|
|
48
48
|
type VikeConfig = Pick<VikeConfigInternal, 'config' | 'pages' | 'prerenderContext'> & {
|
|
49
49
|
/** https://vike.dev/warning/internals */
|
|
50
50
|
dangerouslyUseInternals: DangerouslyUseInternals<VikeConfigInternal>;
|
|
@@ -3,7 +3,6 @@ export { getVikeConfig };
|
|
|
3
3
|
// Internal usage
|
|
4
4
|
export { getVikeConfigInternal };
|
|
5
5
|
export { getVikeConfigInternalOptional };
|
|
6
|
-
export { getVikeConfigInternalSync };
|
|
7
6
|
export { setVikeConfigContext };
|
|
8
7
|
export { isVikeConfigContextSet };
|
|
9
8
|
export { reloadVikeConfig };
|
|
@@ -58,11 +57,6 @@ doNotRestartViteOnError = false) {
|
|
|
58
57
|
const vikeConfig = await getOrResolveVikeConfig(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError);
|
|
59
58
|
return vikeConfig;
|
|
60
59
|
}
|
|
61
|
-
// TO-DO/next-major-release: remove
|
|
62
|
-
function getVikeConfigInternalSync() {
|
|
63
|
-
assert(globalObject.vikeConfigSync);
|
|
64
|
-
return globalObject.vikeConfigSync;
|
|
65
|
-
}
|
|
66
60
|
// TO-DO/eventually: this maybe(/probably?) isn't safe against race conditions upon file changes in development, thus:
|
|
67
61
|
// - Like getGlobalContext() and getGlobalContextSync() — make getVikeConfig() async and provide a getVikeConfigSync() while discourage using it
|
|
68
62
|
// Public usage
|
|
@@ -72,10 +66,17 @@ function getVikeConfigInternalSync() {
|
|
|
72
66
|
* https://vike.dev/getVikeConfig
|
|
73
67
|
*/
|
|
74
68
|
function getVikeConfig(
|
|
75
|
-
|
|
76
|
-
// - No rush: we can do it later since it's getVikeConfig() is a beta feature as documented at https://vike.dev/getVikeConfig
|
|
69
|
+
/** @deprecated the `config` argument isn't needed anymore — remove it (it doesn't have any effect) */
|
|
77
70
|
config) {
|
|
78
|
-
|
|
71
|
+
/* TO-DO/eventualy: add deprecation warning. We don't do it yet because of vike-server and vike-cloudflare which are using getVikeConfig() with the argument.
|
|
72
|
+
assertWarning(
|
|
73
|
+
config === undefined,
|
|
74
|
+
`getVikeConfig() doesn't accept any argument anymore — remove the argument (it doesn't have any effect)`,
|
|
75
|
+
{ onlyOnce: true, showStackTrace: true },
|
|
76
|
+
)
|
|
77
|
+
*/
|
|
78
|
+
assert(globalObject.vikeConfigSync);
|
|
79
|
+
const vikeConfig = globalObject.vikeConfigSync;
|
|
79
80
|
assertUsage(vikeConfig, 'getVikeConfig() can only be used when Vite is loaded (i.e. during development or build) — Vite is never loaded in production.');
|
|
80
81
|
const vikeConfigPublic = getProxyForPublicUsage(vikeConfig, 'vikeConfig');
|
|
81
82
|
return vikeConfigPublic;
|
|
@@ -9,6 +9,6 @@ declare function resolveRouteFunction(routeFunction: (arg: unknown) => unknown,
|
|
|
9
9
|
}>;
|
|
10
10
|
declare function assertSyncRouting(res: unknown, errPrefix: string): void;
|
|
11
11
|
declare function warnDeprecatedAllowKey(): void;
|
|
12
|
-
declare function assertRouteParams<T>(result: T, errPrefix: string): asserts result is T & {
|
|
12
|
+
declare function assertRouteParams<T>(result: T, errPrefix: `${string} should`): asserts result is T & {
|
|
13
13
|
routeParams?: Record<string, string>;
|
|
14
14
|
};
|
|
@@ -63,6 +63,5 @@ function assertRouteParams(result, errPrefix) {
|
|
|
63
63
|
if (!hasProp(result, 'routeParams')) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
assertUsage(hasProp(result, 'routeParams', 'string{}'), `${errPrefix} be an object holding string values.`);
|
|
66
|
+
assertUsage(hasProp(result, 'routeParams', 'string{}'), `${errPrefix} be ${pc.bold('Record<string, string>')}`);
|
|
68
67
|
}
|
|
@@ -55,37 +55,64 @@ type HookNameOldDesign = 'render' | 'prerender' | 'onBeforePrerender';
|
|
|
55
55
|
type ConfigNameBuiltIn = Exclude<keyof ConfigBuiltIn, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | 'hasServerOnlyHook' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware';
|
|
56
56
|
type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
|
|
57
57
|
type Config = ConfigBuiltIn & Vike.Config;
|
|
58
|
-
/** @deprecated This type is deprecated, see
|
|
58
|
+
/** @deprecated This type is deprecated, see:
|
|
59
|
+
* - https://vike.dev/migration/hook-types
|
|
60
|
+
* - https://vike.dev/data
|
|
61
|
+
*/
|
|
59
62
|
type DataAsync<Data = unknown> = (pageContext: PageContextServer) => Promise<Data>;
|
|
60
|
-
/** @deprecated This type is deprecated, see
|
|
63
|
+
/** @deprecated This type is deprecated, see:
|
|
64
|
+
* - https://vike.dev/migration/hook-types
|
|
65
|
+
* - https://vike.dev/data
|
|
66
|
+
*/
|
|
61
67
|
type DataSync<Data = unknown> = (pageContext: PageContextServer) => Data;
|
|
62
|
-
/** @deprecated This type is deprecated, see
|
|
68
|
+
/** @deprecated This type is deprecated, see:
|
|
69
|
+
* - https://vike.dev/migration/hook-types
|
|
70
|
+
* - https://vike.dev/guard
|
|
71
|
+
*/
|
|
63
72
|
type GuardAsync = (pageContext: PageContextServer) => Promise<void>;
|
|
64
|
-
/** @deprecated This type is deprecated, see
|
|
73
|
+
/** @deprecated This type is deprecated, see:
|
|
74
|
+
* - https://vike.dev/migration/hook-types
|
|
75
|
+
* - https://vike.dev/guard
|
|
76
|
+
*/
|
|
65
77
|
type GuardSync = (pageContext: PageContextServer) => void;
|
|
66
|
-
/** @deprecated This type is deprecated, see
|
|
78
|
+
/** @deprecated This type is deprecated, see:
|
|
79
|
+
* - https://vike.dev/migration/hook-types
|
|
80
|
+
* - https://vike.dev/onBeforePrerenderStart
|
|
81
|
+
*/
|
|
67
82
|
type OnBeforePrerenderStartAsync<Data = unknown> = () => Promise<(string | {
|
|
68
83
|
url: string;
|
|
69
84
|
pageContext: Partial<Vike.PageContext & {
|
|
70
85
|
data: Data;
|
|
71
86
|
}>;
|
|
72
87
|
})[]>;
|
|
73
|
-
/** @deprecated This type is deprecated, see
|
|
88
|
+
/** @deprecated This type is deprecated, see:
|
|
89
|
+
* - https://vike.dev/migration/hook-types
|
|
90
|
+
* - https://vike.dev/onBeforePrerenderStart
|
|
91
|
+
*/
|
|
74
92
|
type OnBeforePrerenderStartSync<Data = unknown> = () => (string | {
|
|
75
93
|
url: string;
|
|
76
94
|
pageContext: Partial<Vike.PageContext & {
|
|
77
95
|
data: Data;
|
|
78
96
|
}>;
|
|
79
97
|
})[];
|
|
80
|
-
/** @deprecated This type is deprecated, see
|
|
98
|
+
/** @deprecated This type is deprecated, see:
|
|
99
|
+
* - https://vike.dev/migration/hook-types
|
|
100
|
+
* - https://vike.dev/onBeforeRender
|
|
101
|
+
*/
|
|
81
102
|
type OnBeforeRenderAsync = (pageContext: PageContextServer) => Promise<{
|
|
82
103
|
pageContext: Partial<Vike.PageContext>;
|
|
83
104
|
} | void>;
|
|
84
|
-
/** @deprecated This type is deprecated, see
|
|
105
|
+
/** @deprecated This type is deprecated, see:
|
|
106
|
+
* - https://vike.dev/migration/hook-types
|
|
107
|
+
* - https://vike.dev/onBeforeRender
|
|
108
|
+
*/
|
|
85
109
|
type OnBeforeRenderSync = (pageContext: PageContextServer) => {
|
|
86
110
|
pageContext: Partial<Vike.PageContext>;
|
|
87
111
|
} | void;
|
|
88
|
-
/** @deprecated This type is deprecated, see
|
|
112
|
+
/** @deprecated This type is deprecated, see:
|
|
113
|
+
* - https://vike.dev/migration/hook-types
|
|
114
|
+
* - https://vike.dev/onBeforeRoute
|
|
115
|
+
*/
|
|
89
116
|
type OnBeforeRouteAsync = (pageContext: PageContextServer) => Promise<{
|
|
90
117
|
pageContext: Partial<{
|
|
91
118
|
/** The URL you provided to Vike when calling `renderPage({ urlOriginal })` in your server middleware.
|
|
@@ -95,7 +122,10 @@ type OnBeforeRouteAsync = (pageContext: PageContextServer) => Promise<{
|
|
|
95
122
|
urlOriginal: string;
|
|
96
123
|
} | Vike.PageContext>;
|
|
97
124
|
}>;
|
|
98
|
-
/** @deprecated This type is deprecated, see
|
|
125
|
+
/** @deprecated This type is deprecated, see:
|
|
126
|
+
* - https://vike.dev/migration/hook-types
|
|
127
|
+
* - https://vike.dev/onBeforeRoute
|
|
128
|
+
*/
|
|
99
129
|
type OnBeforeRouteSync = (pageContext: PageContextServer) => {
|
|
100
130
|
pageContext: Partial<{
|
|
101
131
|
/** The URL you provided to Vike when calling `renderPage({ urlOriginal })` in your server middleware.
|
|
@@ -105,19 +135,40 @@ type OnBeforeRouteSync = (pageContext: PageContextServer) => {
|
|
|
105
135
|
urlOriginal: string;
|
|
106
136
|
} | Vike.PageContext>;
|
|
107
137
|
};
|
|
108
|
-
/** @deprecated This type is deprecated, see
|
|
138
|
+
/** @deprecated This type is deprecated, see:
|
|
139
|
+
* - https://vike.dev/migration/hook-types
|
|
140
|
+
* - https://vike.dev/onHydrationEnd
|
|
141
|
+
*/
|
|
109
142
|
type OnHydrationEndAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
110
|
-
/** @deprecated This type is deprecated, see
|
|
143
|
+
/** @deprecated This type is deprecated, see:
|
|
144
|
+
* - https://vike.dev/migration/hook-types
|
|
145
|
+
* - https://vike.dev/onHydrationEnd
|
|
146
|
+
*/
|
|
111
147
|
type OnHydrationEndSync = (pageContext: PageContextClient) => void;
|
|
112
|
-
/** @deprecated This type is deprecated, see
|
|
148
|
+
/** @deprecated This type is deprecated, see:
|
|
149
|
+
* - https://vike.dev/migration/hook-types
|
|
150
|
+
* - https://vike.dev/onPageTransitionEnd
|
|
151
|
+
*/
|
|
113
152
|
type OnPageTransitionEndAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
114
|
-
/** @deprecated This type is deprecated, see
|
|
153
|
+
/** @deprecated This type is deprecated, see:
|
|
154
|
+
* - https://vike.dev/migration/hook-types
|
|
155
|
+
* - https://vike.dev/onPageTransitionEnd
|
|
156
|
+
*/
|
|
115
157
|
type OnPageTransitionEndSync = (pageContext: PageContextClient) => void;
|
|
116
|
-
/** @deprecated This type is deprecated, see
|
|
158
|
+
/** @deprecated This type is deprecated, see:
|
|
159
|
+
* - https://vike.dev/migration/hook-types
|
|
160
|
+
* - https://vike.dev/onPageTransitionStart
|
|
161
|
+
*/
|
|
117
162
|
type OnPageTransitionStartAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
118
|
-
/** @deprecated This type is deprecated, see
|
|
163
|
+
/** @deprecated This type is deprecated, see:
|
|
164
|
+
* - https://vike.dev/migration/hook-types
|
|
165
|
+
* - https://vike.dev/onPageTransitionStart
|
|
166
|
+
*/
|
|
119
167
|
type OnPageTransitionStartSync = (pageContext: PageContextClient) => void;
|
|
120
|
-
/** @deprecated This type is deprecated, see
|
|
168
|
+
/** @deprecated This type is deprecated, see:
|
|
169
|
+
* - https://vike.dev/migration/hook-types
|
|
170
|
+
* - https://vike.dev/onPrerenderStart
|
|
171
|
+
*/
|
|
121
172
|
type OnPrerenderStartAsync = (prerenderContext: {
|
|
122
173
|
pageContexts: PageContextServer[];
|
|
123
174
|
}) => Promise<{
|
|
@@ -125,7 +176,10 @@ type OnPrerenderStartAsync = (prerenderContext: {
|
|
|
125
176
|
pageContexts: PageContextServer[];
|
|
126
177
|
};
|
|
127
178
|
}>;
|
|
128
|
-
/** @deprecated This type is deprecated, see
|
|
179
|
+
/** @deprecated This type is deprecated, see:
|
|
180
|
+
* - https://vike.dev/migration/hook-types
|
|
181
|
+
* - https://vike.dev/onPrerenderStart
|
|
182
|
+
*/
|
|
129
183
|
type OnPrerenderStartSync = (prerenderContext: {
|
|
130
184
|
pageContexts: PageContextServer[];
|
|
131
185
|
}) => {
|
|
@@ -133,13 +187,25 @@ type OnPrerenderStartSync = (prerenderContext: {
|
|
|
133
187
|
pageContexts: PageContextServer[];
|
|
134
188
|
};
|
|
135
189
|
};
|
|
136
|
-
/** @deprecated This type is deprecated, see
|
|
190
|
+
/** @deprecated This type is deprecated, see:
|
|
191
|
+
* - https://vike.dev/migration/hook-types
|
|
192
|
+
* - https://vike.dev/onRenderClient
|
|
193
|
+
*/
|
|
137
194
|
type OnRenderClientAsync = (pageContext: PageContextClient) => Promise<void>;
|
|
138
|
-
/** @deprecated This type is deprecated, see
|
|
195
|
+
/** @deprecated This type is deprecated, see:
|
|
196
|
+
* - https://vike.dev/migration/hook-types
|
|
197
|
+
* - https://vike.dev/onRenderClient
|
|
198
|
+
*/
|
|
139
199
|
type OnRenderClientSync = (pageContext: PageContextClient) => void;
|
|
140
|
-
/** @deprecated This type is deprecated, see
|
|
200
|
+
/** @deprecated This type is deprecated, see:
|
|
201
|
+
* - https://vike.dev/migration/hook-types
|
|
202
|
+
* - https://vike.dev/onRenderHtml
|
|
203
|
+
*/
|
|
141
204
|
type OnRenderHtmlAsync = (pageContext: PageContextServer) => Promise<OnRenderHtmlReturn>;
|
|
142
|
-
/** @deprecated This type is deprecated, see
|
|
205
|
+
/** @deprecated This type is deprecated, see:
|
|
206
|
+
* - https://vike.dev/migration/hook-types
|
|
207
|
+
* - https://vike.dev/onRenderHtml
|
|
208
|
+
*/
|
|
143
209
|
type OnRenderHtmlSync = (pageContext: PageContextServer) => OnRenderHtmlReturn;
|
|
144
210
|
type OnRenderHtmlReturn = DocumentHtml | {
|
|
145
211
|
injectFilter?: (assets: InjectFilterEntry[]) => void;
|
|
@@ -155,7 +221,10 @@ type RouteAsync = (pageContext: PageContextServer | PageContextClient) => Promis
|
|
|
155
221
|
routeParams?: Record<string, string>;
|
|
156
222
|
precedence?: number;
|
|
157
223
|
} | boolean>;
|
|
158
|
-
/** @deprecated This type is deprecated, see
|
|
224
|
+
/** @deprecated This type is deprecated, see:
|
|
225
|
+
* - https://vike.dev/migration/hook-types
|
|
226
|
+
* - https://vike.dev/route
|
|
227
|
+
*/
|
|
159
228
|
type RouteSync = (pageContext: PageContextServer | PageContextClient) => {
|
|
160
229
|
routeParams?: Record<string, string>;
|
|
161
230
|
precedence?: number;
|
|
@@ -386,7 +455,7 @@ type ConfigBuiltIn = {
|
|
|
386
455
|
*
|
|
387
456
|
* https://vite.dev/config/
|
|
388
457
|
*/
|
|
389
|
-
vite?: InlineConfig;
|
|
458
|
+
vite?: InlineConfig | (() => InlineConfig | Promise<InlineConfig>);
|
|
390
459
|
/** Permanent redirections (HTTP status code 301)
|
|
391
460
|
*
|
|
392
461
|
* https://vike.dev/redirects
|
|
@@ -170,19 +170,28 @@ type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageConte
|
|
|
170
170
|
cspNonce: string | null;
|
|
171
171
|
isHydration?: undefined;
|
|
172
172
|
isBackwardNavigation?: undefined;
|
|
173
|
+
isHistoryNavigation?: undefined;
|
|
173
174
|
previousPageContext?: undefined;
|
|
174
175
|
};
|
|
175
176
|
type PageContextBuiltInClientWithClientRouting<Data> = Partial<PageContextBuiltInCommon<Data>> & Pick<PageContextBuiltInCommon<Data>, 'Page' | 'routeParams' | 'pageExports' | 'config' | 'configEntries' | 'exports' | 'exportsAll' | 'abortReason' | 'data' | 'pageId' | 'source' | 'sources' | 'from'> & PageContextClientCommon & {
|
|
176
177
|
/** Whether the current page is already rendered to HTML */
|
|
177
178
|
isHydration: boolean;
|
|
178
179
|
/**
|
|
179
|
-
* Whether the user is navigating
|
|
180
|
+
* Whether the user is navigating backward in history.
|
|
180
181
|
*
|
|
181
182
|
* The value is `true` when the user clicks on his browser's backward navigation button, or when invoking `history.back()`.
|
|
182
183
|
*
|
|
183
184
|
* https://vike.dev/pageContext#isBackwardNavigation
|
|
184
185
|
*/
|
|
185
186
|
isBackwardNavigation: boolean | null;
|
|
187
|
+
/**
|
|
188
|
+
* Whether the user is navigating back or forward in history.
|
|
189
|
+
*
|
|
190
|
+
* The value is `true` when the user clicks on his browser's backward/forward button, or when invoking `history.back()` or `history.forward()`.
|
|
191
|
+
*
|
|
192
|
+
* https://vike.dev/pageContext#isHistoryNavigation
|
|
193
|
+
*/
|
|
194
|
+
isHistoryNavigation: boolean;
|
|
186
195
|
/**
|
|
187
196
|
* Upon client-side page navigation, you can use `pageContext.previousPageContext` to access the `pageContext` of the previous page.
|
|
188
197
|
*
|
|
@@ -208,6 +217,14 @@ type PageContextBuiltInClientWithServerRouting<Data> = Partial<PageContextBuiltI
|
|
|
208
217
|
* https://vike.dev/pageContext#isBackwardNavigation
|
|
209
218
|
*/
|
|
210
219
|
isBackwardNavigation: null;
|
|
220
|
+
/**
|
|
221
|
+
* Whether the user is navigating back or forward in history.
|
|
222
|
+
*
|
|
223
|
+
* The `isHistoryNavigation` property only works with Client Routing. (The value is always `null` when using Server Routing.)
|
|
224
|
+
*
|
|
225
|
+
* https://vike.dev/pageContext#isHistoryNavigation
|
|
226
|
+
*/
|
|
227
|
+
isHistoryNavigation: null;
|
|
211
228
|
globalContext: GlobalContextClientWithServerRouting;
|
|
212
229
|
};
|
|
213
230
|
type PageContextClientCommon = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.245-commit-189d2b8";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.245-commit-189d2b8';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.245-commit-189d2b8",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"dependencies": {
|
|
116
116
|
"@brillout/import": "^0.2.6",
|
|
117
117
|
"@brillout/json-serializer": "^0.5.21",
|
|
118
|
-
"@brillout/picocolors": "^1.0.
|
|
118
|
+
"@brillout/picocolors": "^1.0.29",
|
|
119
119
|
"@brillout/require-shim": "^0.1.2",
|
|
120
120
|
"@brillout/vite-plugin-server-entry": "^0.7.15",
|
|
121
121
|
"acorn": "^8.0.0",
|