vike 0.4.252-commit-3c0065c → 0.4.252-commit-e3a6e9d
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/client/runtime-client-routing/entry.js +0 -4
- package/dist/client/runtime-client-routing/getPageContextCurrent.js +1 -1
- package/dist/client/runtime-client-routing/getPageContextFromHooks.js +1 -1
- package/dist/client/runtime-client-routing/history.d.ts +1 -1
- package/dist/client/runtime-client-routing/history.js +2 -2
- package/dist/client/runtime-client-routing/initClientRouter.d.ts +1 -1
- package/dist/client/runtime-client-routing/initClientRouter.js +13 -6
- package/dist/client/runtime-client-routing/navigate.js +4 -3
- package/dist/client/runtime-client-routing/prefetch.js +1 -1
- package/dist/client/runtime-client-routing/renderPageClient.d.ts +0 -2
- package/dist/client/runtime-client-routing/renderPageClient.js +25 -19
- package/dist/client/runtime-client-routing/scrollRestoration.js +1 -1
- package/dist/client/runtime-client-routing/setScrollPosition.d.ts +3 -0
- package/dist/client/runtime-client-routing/setScrollPosition.js +6 -2
- package/dist/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +6 -2
- package/dist/server/runtime/renderPageServer/handlePageContextRequestUrl.js +5 -5
- package/dist/shared-server-client/assertVirtualFileExports.js +3 -3
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/package.json +17 -17
|
@@ -4,11 +4,7 @@ assertClientRouting();
|
|
|
4
4
|
import { initClientRouter } from './initClientRouter.js';
|
|
5
5
|
import { assertSingleInstance_onClientEntryClientRouting } from '../../utils/assertSingleInstance.js';
|
|
6
6
|
import { removeFoucBuster } from '../shared/removeFoucBuster.js';
|
|
7
|
-
import { setVirtualFileExportsGlobalEntry } from '../shared/getGlobalContextClientInternalShared.js';
|
|
8
|
-
// @ts-expect-error
|
|
9
|
-
import * as virtualFileExportsGlobalEntry from 'virtual:vike:global-entry:client:client-routing';
|
|
10
7
|
assertSingleInstance_onClientEntryClientRouting(import.meta.env.PROD);
|
|
11
|
-
setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry);
|
|
12
8
|
initClientRouter();
|
|
13
9
|
if (import.meta.env.DEV)
|
|
14
10
|
removeFoucBuster();
|
|
@@ -2,7 +2,7 @@ import '../assertEnvClient.js';
|
|
|
2
2
|
export { setPageContextCurrent };
|
|
3
3
|
export { getPageContextCurrent };
|
|
4
4
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
5
|
-
const globalObject = getGlobalObject('
|
|
5
|
+
const globalObject = getGlobalObject('getPageContextCurrent.ts', {
|
|
6
6
|
pageContextCurrent: null,
|
|
7
7
|
});
|
|
8
8
|
function getPageContextCurrent() {
|
|
@@ -24,7 +24,7 @@ import { pageContextInitIsPassedToClient } from '../../shared-server-client/misc
|
|
|
24
24
|
import { isServerSideError } from '../../shared-server-client/misc/isServerSideError.js';
|
|
25
25
|
import { execHook } from '../../shared-server-client/hooks/execHook.js';
|
|
26
26
|
import { getPageContextPublicClient } from './getPageContextPublicClient.js';
|
|
27
|
-
const globalObject = getGlobalObject('
|
|
27
|
+
const globalObject = getGlobalObject('getPageContextFromHooks.ts', {});
|
|
28
28
|
// TO-DO/soon/cumulative-hooks: filter & execute all client-only hooks (see other TO-DO/soon/cumulative-hooks comments)
|
|
29
29
|
// - The client-side needs to know what hooks are client-only
|
|
30
30
|
// - Possible implementation: new computed prop `clientOnlyHooks: string[]` (list of hook ids) and add `hookId` to serialized config values
|
|
@@ -17,7 +17,7 @@ type ScrollPosition = {
|
|
|
17
17
|
x: number;
|
|
18
18
|
y: number;
|
|
19
19
|
};
|
|
20
|
-
declare function saveScrollPosition(): void;
|
|
20
|
+
declare function saveScrollPosition(scrollPosition?: ScrollPosition): void;
|
|
21
21
|
declare function pushHistoryState(url: string, overwriteLastHistoryEntry: boolean): void;
|
|
22
22
|
declare function replaceHistoryStateOriginal(state: unknown, url?: Parameters<typeof window.history.replaceState>[2]): void;
|
|
23
23
|
type HistoryInfo = {
|
|
@@ -48,8 +48,8 @@ function getScrollPosition() {
|
|
|
48
48
|
function getTimestamp() {
|
|
49
49
|
return new Date().getTime();
|
|
50
50
|
}
|
|
51
|
-
function saveScrollPosition() {
|
|
52
|
-
|
|
51
|
+
function saveScrollPosition(scrollPosition) {
|
|
52
|
+
scrollPosition || (scrollPosition = getScrollPosition());
|
|
53
53
|
// Don't overwrite history.state if it was set by a non-Vike history.pushState() call.
|
|
54
54
|
// https://github.com/vikejs/vike/issues/2801#issuecomment-3490431479
|
|
55
55
|
if (!isEnhanced(window.history.state))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import '../assertEnvClient.js';
|
|
2
2
|
export { initClientRouter };
|
|
3
3
|
import { assert } from '../../utils/assert.js';
|
|
4
|
+
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
4
5
|
import { getRenderCount, renderPageClient } from './renderPageClient.js';
|
|
5
6
|
import { initOnPopState } from './initOnPopState.js';
|
|
6
7
|
import { initOnLinkClick } from './initOnLinkClick.js';
|
|
@@ -8,21 +9,27 @@ import { scrollRestoration_init } from './scrollRestoration.js';
|
|
|
8
9
|
import { autoSaveScrollPosition } from './setScrollPosition.js';
|
|
9
10
|
import { initLinkPrefetchHandlers } from './prefetch.js';
|
|
10
11
|
import { initHistory } from './history.js';
|
|
11
|
-
|
|
12
|
+
import { setVirtualFileExportsGlobalEntry } from '../shared/getGlobalContextClientInternalShared.js';
|
|
13
|
+
// @ts-expect-error
|
|
14
|
+
import * as virtualFileExportsGlobalEntry from 'virtual:vike:global-entry:client:client-routing';
|
|
15
|
+
const globalObject = getGlobalObject('initClientRouter.ts', {});
|
|
16
|
+
function initClientRouter() {
|
|
17
|
+
setVirtualFileExportsGlobalEntry(virtualFileExportsGlobalEntry);
|
|
18
|
+
if (globalObject.done)
|
|
19
|
+
return;
|
|
20
|
+
globalObject.done = true;
|
|
12
21
|
// Init navigation history and scroll restoration
|
|
13
22
|
initHistoryAndScroll();
|
|
14
23
|
// Render/hydrate
|
|
15
|
-
|
|
24
|
+
renderFirstPage();
|
|
16
25
|
// Intercept <a> clicks
|
|
17
26
|
initOnLinkClick();
|
|
18
27
|
// Add <a> prefetch handlers
|
|
19
28
|
initLinkPrefetchHandlers();
|
|
20
|
-
// Preserve stack track
|
|
21
|
-
await renderFirstPagePromise;
|
|
22
29
|
}
|
|
23
|
-
|
|
30
|
+
function renderFirstPage() {
|
|
24
31
|
assert(getRenderCount() === 0);
|
|
25
|
-
|
|
32
|
+
renderPageClient({
|
|
26
33
|
scrollTarget: { preserveScroll: true },
|
|
27
34
|
isClientSideNavigation: false,
|
|
28
35
|
});
|
|
@@ -4,8 +4,9 @@ export { reload };
|
|
|
4
4
|
// import { modifyUrlSameOrigin, ModifyUrlSameOriginOptions } from '../../shared/modifyUrlSameOrigin.js'
|
|
5
5
|
import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
6
6
|
import { normalizeUrlArgument } from './normalizeUrlArgument.js';
|
|
7
|
-
import {
|
|
7
|
+
import { renderPageClient } from './renderPageClient.js';
|
|
8
8
|
import { assertClientRouting } from '../../utils/assertRoutingType.js';
|
|
9
|
+
import { initClientRouter } from './initClientRouter.js';
|
|
9
10
|
assertClientRouting();
|
|
10
11
|
/** Programmatically navigate to a new page.
|
|
11
12
|
*
|
|
@@ -19,8 +20,8 @@ async function navigate(url, options) {
|
|
|
19
20
|
// let url = normalizeUrlArgument(options.url ?? getCurrentUrl(), 'navigate')
|
|
20
21
|
// url = modifyUrlSameOrigin(url, options)
|
|
21
22
|
normalizeUrlArgument(url, 'navigate');
|
|
22
|
-
//
|
|
23
|
-
|
|
23
|
+
// Ensure initClientRouter() is called before navigate() — otherwise race condition when +client.js calls navigate() before initClientRouter() is called in runtime-client-routing/entry.ts
|
|
24
|
+
initClientRouter();
|
|
24
25
|
const { keepScrollPosition, overwriteLastHistoryEntry, pageContext } = options ?? {};
|
|
25
26
|
const scrollTarget = { preserveScroll: keepScrollPosition ?? false };
|
|
26
27
|
await renderPageClient({
|
|
@@ -24,7 +24,7 @@ import { PAGE_CONTEXT_MAX_AGE_DEFAULT, getPrefetchSettings, } from './prefetch/g
|
|
|
24
24
|
import pc from '@brillout/picocolors';
|
|
25
25
|
import { normalizeUrlArgument } from './normalizeUrlArgument.js';
|
|
26
26
|
assertClientRouting();
|
|
27
|
-
const globalObject = getGlobalObject('
|
|
27
|
+
const globalObject = getGlobalObject('prefetch.ts', {
|
|
28
28
|
linkPrefetchHandlerAdded: new WeakSet(),
|
|
29
29
|
addLinkPrefetchHandlers_debounce: null,
|
|
30
30
|
mutationObserver: new MutationObserver(addLinkPrefetchHandlers),
|
|
@@ -2,7 +2,6 @@ import '../assertEnvClient.js';
|
|
|
2
2
|
export { renderPageClient };
|
|
3
3
|
export { getRenderCount };
|
|
4
4
|
export { disableClientRouting };
|
|
5
|
-
export { firstRenderStartPromise };
|
|
6
5
|
export { getPageContextClient };
|
|
7
6
|
export type { PageContextBegin };
|
|
8
7
|
export type { PageContextInternalClientAfterRender };
|
|
@@ -14,7 +13,6 @@ import type { PageContextClient } from '../../types/PageContext.js';
|
|
|
14
13
|
import { type PageContextPublicClient } from './getPageContextPublicClient.js';
|
|
15
14
|
import type { VikeGlobalInternal } from '../../types/VikeGlobalInternal.js';
|
|
16
15
|
type PageContextInternalClientAfterRender = NonNullable<Awaited<ReturnType<typeof renderPageClient>>>;
|
|
17
|
-
declare const firstRenderStartPromise: Promise<void>;
|
|
18
16
|
type PreviousPageContext = {
|
|
19
17
|
pageId: string;
|
|
20
18
|
} & PageContextConfig & PageContextRouted & PageContextCreatedClient & PageContextPublicClient;
|
|
@@ -2,7 +2,6 @@ import '../assertEnvClient.js';
|
|
|
2
2
|
export { renderPageClient };
|
|
3
3
|
export { getRenderCount };
|
|
4
4
|
export { disableClientRouting };
|
|
5
|
-
export { firstRenderStartPromise };
|
|
6
5
|
export { getPageContextClient };
|
|
7
6
|
import { assert, assertInfo, assertWarning } from '../../utils/assert.js';
|
|
8
7
|
import { catchInfiniteLoop } from '../../utils/catchInfiniteLoop.js';
|
|
@@ -19,11 +18,11 @@ import { createPageContextClient } from './createPageContextClient.js';
|
|
|
19
18
|
import { addLinkPrefetchHandlers, addLinkPrefetchHandlers_unwatch, addLinkPrefetchHandlers_watch, getPageContextPrefetched, populatePageContextPrefetchCache, } from './prefetch.js';
|
|
20
19
|
import { execHookOnRenderClient } from '../shared/execHookOnRenderClient.js';
|
|
21
20
|
import { isErrorFetchingStaticAssets, loadPageConfigsLazyClientSide, } from '../shared/loadPageConfigsLazyClientSide.js';
|
|
22
|
-
import { pushHistoryState } from './history.js';
|
|
21
|
+
import { pushHistoryState, saveScrollPosition } from './history.js';
|
|
23
22
|
import { addNewPageContextAborted, getPageContextAddendumAbort, isAbortError, logAbort, } from '../../shared-server-client/route/abort.js';
|
|
24
23
|
import { route } from '../../shared-server-client/route/index.js';
|
|
25
24
|
import { isClientSideRoutable } from './isClientSideRoutable.js';
|
|
26
|
-
import { setScrollPosition } from './setScrollPosition.js';
|
|
25
|
+
import { isScrollPosition, setScrollPosition } from './setScrollPosition.js';
|
|
27
26
|
import { scrollRestoration_initialRenderIsDone } from './scrollRestoration.js';
|
|
28
27
|
import { getErrorPageId, isErrorPage } from '../../shared-server-client/error-page.js';
|
|
29
28
|
import { setPageContextCurrent } from './getPageContextCurrent.js';
|
|
@@ -34,15 +33,14 @@ import { getPageContextPublicClient } from './getPageContextPublicClient.js';
|
|
|
34
33
|
import { getHooksFromPageContextNew } from '../../shared-server-client/hooks/getHook.js';
|
|
35
34
|
import { getPageContextPublicClientMinimal } from '../shared/getPageContextPublicClientShared.js';
|
|
36
35
|
import { logErrorClient } from './logErrorClient.js';
|
|
37
|
-
const globalObject = getGlobalObject('
|
|
38
|
-
const { promise:
|
|
36
|
+
const globalObject = getGlobalObject('renderPageClient.ts', (() => {
|
|
37
|
+
const { promise: hydrationAwaitPromise, resolve: hydrationAwaitPromiseResolve } = genPromise();
|
|
39
38
|
return {
|
|
40
39
|
renderCounter: 0,
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
hydrationAwaitPromise,
|
|
41
|
+
hydrationAwaitPromiseResolve,
|
|
43
42
|
};
|
|
44
43
|
})());
|
|
45
|
-
const { firstRenderStartPromise } = globalObject;
|
|
46
44
|
async function renderPageClient(renderArgs) {
|
|
47
45
|
catchInfiniteLoop('renderPageClient()');
|
|
48
46
|
const { urlOriginal = getCurrentUrl(), overwriteLastHistoryEntry = false, isBackwardNavigation = false, isHistoryNavigation = false, doNotRenderIfSamePage, isClientSideNavigation = true, pageContextInitClient, pageContextsAborted = [], } = renderArgs;
|
|
@@ -63,7 +61,15 @@ async function renderPageClient(renderArgs) {
|
|
|
63
61
|
redirectHard(urlOriginal);
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
66
|
-
|
|
64
|
+
// Await hydration (unless +hydrationCanBeAborted)
|
|
65
|
+
if (!isFirstRender) {
|
|
66
|
+
await globalObject.hydrationAwaitPromise;
|
|
67
|
+
if (isRenderOutdated())
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Ensure no concurrent onRenderClient() calls.
|
|
71
|
+
// - We could `await globalObject.onRenderClientPreviousPromise` later just before execHookOnRenderClient() but we prefer doing it early to ensure `getPageContext() === usePageContext()` (and maybe it prevents other potential inconsistencies?).
|
|
72
|
+
await globalObject.onRenderClientPreviousPromise;
|
|
67
73
|
if (isRenderOutdated())
|
|
68
74
|
return;
|
|
69
75
|
return await renderPageNominal();
|
|
@@ -175,7 +181,9 @@ async function renderPageClient(renderArgs) {
|
|
|
175
181
|
setHydrationCanBeAborted();
|
|
176
182
|
}
|
|
177
183
|
else {
|
|
178
|
-
|
|
184
|
+
if (globalThis.__VIKE__IS_DEV) {
|
|
185
|
+
assertWarning(!isReact(), 'You seem to be using React; we recommend setting hydrationCanBeAborted to true, see https://vike.dev/hydrationCanBeAborted', { onlyOnce: true });
|
|
186
|
+
}
|
|
179
187
|
}
|
|
180
188
|
// There wasn't any `await` but the isRenderOutdated() return value may have changed because we called setHydrationCanBeAborted()
|
|
181
189
|
if (isRenderOutdated())
|
|
@@ -396,16 +404,9 @@ async function renderPageClient(renderArgs) {
|
|
|
396
404
|
logErrorClient(err);
|
|
397
405
|
}
|
|
398
406
|
};
|
|
399
|
-
// We use globalObject.onRenderClientPreviousPromise in order to ensure that there is never two concurrent onRenderClient() calls
|
|
400
|
-
if (globalObject.onRenderClientPreviousPromise) {
|
|
401
|
-
// Make sure that the previous render has finished
|
|
402
|
-
await globalObject.onRenderClientPreviousPromise;
|
|
403
|
-
assert(globalObject.onRenderClientPreviousPromise === undefined);
|
|
404
|
-
if (isRenderOutdated())
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
407
|
changeUrl(urlOriginal, overwriteLastHistoryEntry);
|
|
408
408
|
globalObject.previousPageContext = pageContext;
|
|
409
|
+
// There should never be concurrent onRenderClient() calls
|
|
409
410
|
assert(globalObject.onRenderClientPreviousPromise === undefined);
|
|
410
411
|
const onRenderClientPromise = (async () => {
|
|
411
412
|
let onRenderClientError;
|
|
@@ -422,7 +423,6 @@ async function renderPageClient(renderArgs) {
|
|
|
422
423
|
})();
|
|
423
424
|
globalObject.onRenderClientPreviousPromise = onRenderClientPromise;
|
|
424
425
|
const onRenderClientError = await onRenderClientPromise;
|
|
425
|
-
assert(globalObject.onRenderClientPreviousPromise === undefined);
|
|
426
426
|
if (onRenderClientError) {
|
|
427
427
|
await onError(onRenderClientError);
|
|
428
428
|
if (!isErrorPage)
|
|
@@ -474,6 +474,10 @@ async function renderPageClient(renderArgs) {
|
|
|
474
474
|
}
|
|
475
475
|
// Page scrolling
|
|
476
476
|
setScrollPosition(scrollTarget, urlOriginal);
|
|
477
|
+
if (isScrollPosition(scrollTarget)) {
|
|
478
|
+
// Restore window.history.state.vike.scrollPosition (in case scrolling occurred during rendering)
|
|
479
|
+
saveScrollPosition(scrollTarget);
|
|
480
|
+
}
|
|
477
481
|
scrollRestoration_initialRenderIsDone();
|
|
478
482
|
if (pageContext._hasPageContextFromServer)
|
|
479
483
|
setPageContextInitIsPassedToClient(pageContext);
|
|
@@ -482,6 +486,7 @@ async function renderPageClient(renderArgs) {
|
|
|
482
486
|
addLinkPrefetchHandlers();
|
|
483
487
|
globalObject.renderedPageContext = pageContext;
|
|
484
488
|
stampFinished(urlOriginal);
|
|
489
|
+
globalObject.hydrationAwaitPromiseResolve();
|
|
485
490
|
return pageContext;
|
|
486
491
|
}
|
|
487
492
|
}
|
|
@@ -549,6 +554,7 @@ function getIsRenderOutdated() {
|
|
|
549
554
|
let hydrationCanBeAborted = false;
|
|
550
555
|
const setHydrationCanBeAborted = () => {
|
|
551
556
|
hydrationCanBeAborted = true;
|
|
557
|
+
globalObject.hydrationAwaitPromiseResolve();
|
|
552
558
|
};
|
|
553
559
|
/** Whether the rendering should be aborted because a new rendering has started. We should call this after each `await`. */
|
|
554
560
|
const isRenderOutdated = (isRenderCleanup) => {
|
|
@@ -8,7 +8,7 @@ export { scrollRestoration_initialRenderIsDone };
|
|
|
8
8
|
// See also: https://github.com/cyco130/knave/blob/e9e1bc7687848504293197f1b314b7d12ad0d228/design.md#scroll-restoration
|
|
9
9
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
10
10
|
import { onPageHide, onPageShow } from '../../utils/onPageVisibilityChange.js';
|
|
11
|
-
const globalObject = getGlobalObject('
|
|
11
|
+
const globalObject = getGlobalObject('scrollRestoration.ts', {});
|
|
12
12
|
function scrollRestoration_init() {
|
|
13
13
|
// Use the native scroll restoration mechanism only for the first render
|
|
14
14
|
scrollRestoration_enable();
|
|
@@ -2,11 +2,14 @@ import '../assertEnvClient.js';
|
|
|
2
2
|
export { setScrollPosition };
|
|
3
3
|
export { autoSaveScrollPosition };
|
|
4
4
|
export { scrollToHashOrTop };
|
|
5
|
+
export { isScrollPosition };
|
|
5
6
|
export type { ScrollTarget };
|
|
6
7
|
import { type ScrollPosition } from './history.js';
|
|
7
8
|
type ScrollTarget = undefined | {
|
|
8
9
|
preserveScroll: boolean;
|
|
10
|
+
y?: undefined;
|
|
9
11
|
} | ScrollPosition;
|
|
10
12
|
declare function setScrollPosition(scrollTarget: ScrollTarget, url?: string): void;
|
|
11
13
|
declare function scrollToHashOrTop(hash: null | string): void;
|
|
14
|
+
declare function isScrollPosition(scrollTarget: ScrollTarget | undefined): scrollTarget is ScrollPosition;
|
|
12
15
|
declare function autoSaveScrollPosition(): void;
|
|
@@ -2,6 +2,7 @@ import '../assertEnvClient.js';
|
|
|
2
2
|
export { setScrollPosition };
|
|
3
3
|
export { autoSaveScrollPosition };
|
|
4
4
|
export { scrollToHashOrTop };
|
|
5
|
+
export { isScrollPosition };
|
|
5
6
|
import { assert } from '../../utils/assert.js';
|
|
6
7
|
import { onPageHide } from '../../utils/onPageVisibilityChange.js';
|
|
7
8
|
import { sleep } from '../../utils/sleep.js';
|
|
@@ -12,7 +13,7 @@ function setScrollPosition(scrollTarget, url) {
|
|
|
12
13
|
scrollToTextFragment(url);
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
if (scrollTarget
|
|
16
|
+
if (isScrollPosition(scrollTarget)) {
|
|
16
17
|
setScroll(scrollTarget);
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
@@ -58,6 +59,9 @@ function scrollToHashOrTop(hash) {
|
|
|
58
59
|
function scrollToTop() {
|
|
59
60
|
setScroll({ x: 0, y: 0 });
|
|
60
61
|
}
|
|
62
|
+
function isScrollPosition(scrollTarget) {
|
|
63
|
+
return scrollTarget?.y !== undefined;
|
|
64
|
+
}
|
|
61
65
|
/**
|
|
62
66
|
* Change the browser's scroll position, in a way that works during a repaint.
|
|
63
67
|
*
|
|
@@ -118,6 +122,6 @@ function getUrlHash() {
|
|
|
118
122
|
// Save scroll position (needed for back-/forward navigation)
|
|
119
123
|
function autoSaveScrollPosition() {
|
|
120
124
|
// Safari cannot handle more than 100 `history.replaceState()` calls within 30 seconds (https://github.com/vikejs/vike/issues/46)
|
|
121
|
-
window.addEventListener('scroll', throttle(saveScrollPosition,
|
|
125
|
+
window.addEventListener('scroll', throttle(saveScrollPosition, 300), { passive: true });
|
|
122
126
|
onPageHide(saveScrollPosition);
|
|
123
127
|
}
|
|
@@ -219,7 +219,12 @@ const configDefinitionsBuiltIn = {
|
|
|
219
219
|
keepScrollPosition: {
|
|
220
220
|
env: { client: true },
|
|
221
221
|
},
|
|
222
|
-
middleware: {
|
|
222
|
+
middleware: {
|
|
223
|
+
env: { server: true },
|
|
224
|
+
cumulative: true,
|
|
225
|
+
eager: true,
|
|
226
|
+
global: true,
|
|
227
|
+
},
|
|
223
228
|
cli: {
|
|
224
229
|
env: { config: true },
|
|
225
230
|
global: true,
|
|
@@ -229,7 +234,6 @@ const configDefinitionsBuiltIn = {
|
|
|
229
234
|
eager: true,
|
|
230
235
|
global: true,
|
|
231
236
|
},
|
|
232
|
-
// TODO: align all meta configs
|
|
233
237
|
prerender: {
|
|
234
238
|
env: { config: true },
|
|
235
239
|
global: (value, { isGlobalLocation }) => typeof value === 'object' || isGlobalLocation,
|
|
@@ -8,6 +8,7 @@ import { assert } from '../../../utils/assert.js';
|
|
|
8
8
|
import { hasProp } from '../../../utils/hasProp.js';
|
|
9
9
|
import { isObject } from '../../../utils/isObject.js';
|
|
10
10
|
import { parseUrl } from '../../../utils/parseUrl.js';
|
|
11
|
+
const pageContextJsonFileExtensionUrl = `/index${pageContextJsonFileExtension}`;
|
|
11
12
|
// See also shared/getPageContextRequestUrl.ts
|
|
12
13
|
function handlePageContextRequestUrl(url) {
|
|
13
14
|
const urlParsed = parseUrl(url, baseServer);
|
|
@@ -33,16 +34,15 @@ function handlePageContextRequestUrl(url) {
|
|
|
33
34
|
}
|
|
34
35
|
function isMatch(urlParsed) {
|
|
35
36
|
const { pathnameOriginal, pathname } = urlParsed;
|
|
36
|
-
assert(pathname.endsWith(
|
|
37
|
-
return pathname.endsWith(
|
|
37
|
+
assert(pathname.endsWith(pageContextJsonFileExtensionUrl) === pathnameOriginal.endsWith(pageContextJsonFileExtensionUrl));
|
|
38
|
+
return pathname.endsWith(pageContextJsonFileExtensionUrl);
|
|
38
39
|
}
|
|
39
40
|
function processUrl(urlParsed, url) {
|
|
40
41
|
// We cannot use `urlParsed.pathname` because it would break the `urlParsed.pathnameOriginal` value of subsequent `parseUrl()` calls.
|
|
41
42
|
const { pathnameOriginal, search } = urlParsed;
|
|
42
43
|
assert(doNotCreateExtraDirectory === false);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let pathnameModified = slice(pathnameOriginal, 0, -1 * urlSuffix.length);
|
|
44
|
+
assert(pathnameOriginal.endsWith(pageContextJsonFileExtensionUrl), { url });
|
|
45
|
+
let pathnameModified = slice(pathnameOriginal, 0, -1 * pageContextJsonFileExtensionUrl.length);
|
|
46
46
|
if (pathnameModified === '')
|
|
47
47
|
pathnameModified = '/';
|
|
48
48
|
const searchVikeArgs = search?._vike;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
// TO-DO/eventually: remove
|
|
1
2
|
export { assertVirtualFileExports };
|
|
2
3
|
import { assert } from '../utils/assert.js';
|
|
3
4
|
function assertVirtualFileExports(moduleExports, test, moduleId) {
|
|
4
|
-
|
|
5
|
+
assert(moduleExports, typeof moduleExports);
|
|
6
|
+
if (!test(moduleExports)) {
|
|
5
7
|
/* https://github.com/vikejs/vike/issues/2903#issuecomment-3642285811
|
|
6
8
|
throw getProjectError('@cloudflare/vite-plugin error https://github.com/vikejs/vike/issues/2903#issuecomment-3642285811')
|
|
7
9
|
/*/
|
|
@@ -10,7 +12,5 @@ function assertVirtualFileExports(moduleExports, test, moduleId) {
|
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
function getKeys(obj) {
|
|
13
|
-
if (obj === undefined)
|
|
14
|
-
return null;
|
|
15
15
|
return [...Object.getOwnPropertyNames(obj), ...Object.getOwnPropertySymbols(obj), ...Object.keys(obj)];
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.252-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.252-commit-e3a6e9d";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.252-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.252-commit-e3a6e9d';
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.252-commit-
|
|
3
|
+
"version": "0.4.252-commit-e3a6e9d",
|
|
4
4
|
"repository": "https://github.com/vikejs/vike",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": {
|
|
7
|
+
"types": "./dist/server/runtime/index.d.ts",
|
|
7
8
|
"worker": "./dist/server/runtime/index.js",
|
|
8
9
|
"workerd": "./dist/server/runtime/index.js",
|
|
9
10
|
"node": "./dist/server/runtime/index.js",
|
|
10
11
|
"browser": "./dist/client/node.js",
|
|
11
|
-
"types": "./dist/server/runtime/index.d.ts",
|
|
12
12
|
"default": "./dist/server/runtime/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./client": {
|
|
@@ -19,89 +19,89 @@
|
|
|
19
19
|
"default": "./dist/types/index.js"
|
|
20
20
|
},
|
|
21
21
|
"./client/router": {
|
|
22
|
+
"types": "./dist/client/runtime-client-routing/index.d.ts",
|
|
22
23
|
"worker": "./dist/server/client/router.js",
|
|
23
24
|
"workerd": "./dist/server/client/router.js",
|
|
24
25
|
"node": "./dist/server/client/router.js",
|
|
25
26
|
"browser": "./dist/client/runtime-client-routing/index.js",
|
|
26
|
-
"types": "./dist/client/runtime-client-routing/index.d.ts",
|
|
27
27
|
"default": "./dist/client/runtime-client-routing/index.js"
|
|
28
28
|
},
|
|
29
29
|
"./routing": {
|
|
30
|
+
"types": "./dist/shared-server-client/route/routing.d.ts",
|
|
30
31
|
"worker": "./dist/shared-server-client/route/routing.js",
|
|
31
32
|
"workerd": "./dist/shared-server-client/route/routing.js",
|
|
32
33
|
"node": "./dist/shared-server-client/route/routing.js",
|
|
33
34
|
"browser": "./dist/shared-server-client/route/routing.js",
|
|
34
|
-
"types": "./dist/shared-server-client/route/routing.d.ts",
|
|
35
35
|
"default": "./dist/shared-server-client/route/routing.js"
|
|
36
36
|
},
|
|
37
37
|
"./cli": {
|
|
38
|
-
"node": "./dist/node/cli/index.js",
|
|
39
38
|
"types": "./dist/node/cli/index.d.ts",
|
|
39
|
+
"node": "./dist/node/cli/index.js",
|
|
40
40
|
"default": "./dist/node/cli/index.js"
|
|
41
41
|
},
|
|
42
42
|
"./api": {
|
|
43
|
-
"node": "./dist/node/api/index.js",
|
|
44
43
|
"types": "./dist/node/api/index.d.ts",
|
|
44
|
+
"node": "./dist/node/api/index.js",
|
|
45
45
|
"default": "./dist/node/api/index.js"
|
|
46
46
|
},
|
|
47
47
|
"./prerender": {
|
|
48
|
-
"node": "./dist/node/prerender/index.js",
|
|
49
48
|
"types": "./dist/node/prerender/index.d.ts",
|
|
49
|
+
"node": "./dist/node/prerender/index.js",
|
|
50
50
|
"default": "./dist/node/prerender/index.js"
|
|
51
51
|
},
|
|
52
52
|
"./plugin": {
|
|
53
|
-
"node": "./dist/node/vite/index.js",
|
|
54
53
|
"types": "./dist/node/vite/index.d.ts",
|
|
54
|
+
"node": "./dist/node/vite/index.js",
|
|
55
55
|
"default": "./dist/node/vite/index.js"
|
|
56
56
|
},
|
|
57
57
|
"./RenderErrorPage": {
|
|
58
|
+
"types": "./dist/shared-server-client/RenderErrorPage.d.ts",
|
|
58
59
|
"worker": "./dist/shared-server-client/RenderErrorPage.js",
|
|
59
60
|
"workerd": "./dist/shared-server-client/RenderErrorPage.js",
|
|
60
61
|
"node": "./dist/shared-server-client/RenderErrorPage.js",
|
|
61
62
|
"browser": "./dist/shared-server-client/RenderErrorPage.js",
|
|
62
|
-
"types": "./dist/shared-server-client/RenderErrorPage.d.ts",
|
|
63
63
|
"default": "./dist/shared-server-client/RenderErrorPage.js"
|
|
64
64
|
},
|
|
65
65
|
"./abort": {
|
|
66
|
+
"types": "./dist/shared-server-client/abort.d.ts",
|
|
66
67
|
"worker": "./dist/shared-server-client/abort.js",
|
|
67
68
|
"workerd": "./dist/shared-server-client/abort.js",
|
|
68
69
|
"node": "./dist/shared-server-client/abort.js",
|
|
69
70
|
"browser": "./dist/shared-server-client/abort.js",
|
|
70
|
-
"types": "./dist/shared-server-client/abort.d.ts",
|
|
71
71
|
"default": "./dist/shared-server-client/abort.js"
|
|
72
72
|
},
|
|
73
73
|
"./getPageContext": {
|
|
74
|
+
"types": "./dist/server/runtime/getPageContext.d.ts",
|
|
74
75
|
"worker": "./dist/server/runtime/getPageContext.js",
|
|
75
76
|
"workerd": "./dist/server/runtime/getPageContext.js",
|
|
76
77
|
"node": "./dist/server/runtime/getPageContext.js",
|
|
77
78
|
"browser": "./dist/client/runtime-client-routing/getPageContext.js",
|
|
78
|
-
"types": "./dist/server/runtime/getPageContext.d.ts",
|
|
79
79
|
"default": "./dist/server/runtime/getPageContext.js"
|
|
80
80
|
},
|
|
81
81
|
"./modifyUrl": {
|
|
82
|
+
"types": "./dist/shared-server-client/modifyUrl.d.ts",
|
|
82
83
|
"worker": "./dist/shared-server-client/modifyUrl.js",
|
|
83
84
|
"workerd": "./dist/shared-server-client/modifyUrl.js",
|
|
84
85
|
"node": "./dist/shared-server-client/modifyUrl.js",
|
|
85
86
|
"browser": "./dist/shared-server-client/modifyUrl.js",
|
|
86
|
-
"types": "./dist/shared-server-client/modifyUrl.d.ts",
|
|
87
87
|
"default": "./dist/shared-server-client/modifyUrl.js"
|
|
88
88
|
},
|
|
89
89
|
"./universal-middleware": {
|
|
90
|
+
"types": "./dist/server/runtime/universal-middleware.d.ts",
|
|
90
91
|
"worker": "./dist/server/runtime/universal-middleware.js",
|
|
91
92
|
"workerd": "./dist/server/runtime/universal-middleware.js",
|
|
92
93
|
"node": "./dist/server/runtime/universal-middleware.js",
|
|
93
94
|
"browser": "./dist/client/node.js",
|
|
94
|
-
"types": "./dist/server/runtime/universal-middleware.d.ts",
|
|
95
95
|
"default": "./dist/server/runtime/universal-middleware.js"
|
|
96
96
|
},
|
|
97
97
|
"./__internal": {
|
|
98
|
-
"node": "./dist/server/__internal/index.js",
|
|
99
98
|
"types": "./dist/server/__internal/index.d.ts",
|
|
99
|
+
"node": "./dist/server/__internal/index.js",
|
|
100
100
|
"default": "./dist/server/__internal/index.js"
|
|
101
101
|
},
|
|
102
102
|
"./__internal/setup": {
|
|
103
|
-
"node": "./dist/server/runtime/page-files/setup.js",
|
|
104
103
|
"types": "./dist/server/runtime/page-files/setup.d.ts",
|
|
104
|
+
"node": "./dist/server/runtime/page-files/setup.js",
|
|
105
105
|
"default": "./dist/server/runtime/page-files/setup.js"
|
|
106
106
|
},
|
|
107
107
|
"./__internal/vite": {
|
|
@@ -109,11 +109,11 @@
|
|
|
109
109
|
"default": "./dist/server/__internal/vite.js"
|
|
110
110
|
},
|
|
111
111
|
".": {
|
|
112
|
+
"types": "./dist/server/runtime/index.d.ts",
|
|
112
113
|
"worker": "./dist/server/runtime/index.js",
|
|
113
114
|
"workerd": "./dist/server/runtime/index.js",
|
|
114
115
|
"node": "./dist/server/runtime/index.js",
|
|
115
116
|
"browser": "./dist/client/index.js",
|
|
116
|
-
"types": "./dist/server/runtime/index.d.ts",
|
|
117
117
|
"default": "./dist/server/runtime/index.js"
|
|
118
118
|
}
|
|
119
119
|
},
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"node": ">=20.19.0"
|
|
154
154
|
},
|
|
155
155
|
"license": "MIT",
|
|
156
|
-
"description": "(Replaces Next.js/Nuxt) 🔨 Composable framework to build
|
|
156
|
+
"description": "(Replaces Next.js/Nuxt) 🔨 Composable framework to build advanced applications with flexibility and stability.",
|
|
157
157
|
"keywords": [
|
|
158
158
|
"vite-plugin",
|
|
159
159
|
"ssr",
|