vike 0.4.197-commit-ab2fbbe → 0.4.197-commit-9330153
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/prefetch.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +13 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +4 -4
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export { addLinkPrefetchHandlers };
|
|
|
6
6
|
export { addLinkPrefetchHandlers_watch };
|
|
7
7
|
export { addLinkPrefetchHandlers_unwatch };
|
|
8
8
|
import { type PageContextFromServerHooks, getPageContextFromServerHooks } from './getPageContextFromHooks.js';
|
|
9
|
-
import { PageFile } from '../../shared/getPageFiles.js';
|
|
9
|
+
import type { PageContextExports, PageFile } from '../../shared/getPageFiles.js';
|
|
10
10
|
import { type PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
11
11
|
type ResultPageContextFromServer = Awaited<ReturnType<typeof getPageContextFromServerHooks>>;
|
|
12
12
|
type PageContextForPrefetch = {
|
|
@@ -19,7 +19,7 @@ type PageContextForPrefetch = {
|
|
|
19
19
|
};
|
|
20
20
|
declare function getPageContextPrefetched(pageContext: {
|
|
21
21
|
urlPathname: string;
|
|
22
|
-
}): null | PageContextFromServerHooks;
|
|
22
|
+
} & PageContextExports): null | PageContextFromServerHooks;
|
|
23
23
|
declare function populatePageContextPrefetchCache(pageContext: PageContextForPrefetch, result: ResultPageContextFromServer): void;
|
|
24
24
|
/**
|
|
25
25
|
* Programmatically prefetch client assets.
|
|
@@ -27,6 +27,10 @@ const globalObject = getGlobalObject('prefetch.ts', {
|
|
|
27
27
|
prefetchedPageContexts: {}
|
|
28
28
|
});
|
|
29
29
|
function getPageContextPrefetched(pageContext) {
|
|
30
|
+
const prefetchSettings = getPrefetchSettings(pageContext, null);
|
|
31
|
+
// TODO/pageContext-prefetch: I guess we need linkTag to make this condition work
|
|
32
|
+
if (!prefetchSettings.pageContext)
|
|
33
|
+
return null;
|
|
30
34
|
const key = getCacheKey(pageContext.urlPathname);
|
|
31
35
|
const found = globalObject.prefetchedPageContexts[key];
|
|
32
36
|
if (!found || found.result.is404ServerSideRouted || isExpired(found))
|
|
@@ -55,13 +59,17 @@ async function prefetchPageContextFromServerHooks(pageContextLink, resultMaxAge)
|
|
|
55
59
|
const result = await getPageContextFromServerHooks(pageContextLink, false);
|
|
56
60
|
setPageContextPrefetchCache(pageContextLink, result, resultMaxAge);
|
|
57
61
|
}
|
|
58
|
-
function populatePageContextPrefetchCache(pageContext
|
|
62
|
+
function populatePageContextPrefetchCache(pageContext /*& PageContextExports*/, result) {
|
|
63
|
+
// TODO/pageContext-prefetch: replace with using pageContext.config.prerender instead. (For being able to do that: eager configs need to be accessible without have to use PageContextExports as it isn't available here.)
|
|
64
|
+
if (!isBrilloutDocpress())
|
|
65
|
+
return;
|
|
59
66
|
setPageContextPrefetchCache(pageContext, result, null);
|
|
60
67
|
}
|
|
61
68
|
function setPageContextPrefetchCache(pageContext, result, resultMaxAge) {
|
|
62
69
|
if (resultMaxAge === null)
|
|
63
70
|
resultMaxAge = getResultMaxAge();
|
|
64
71
|
const key = getCacheKey(pageContext.urlPathname);
|
|
72
|
+
assert(isBrilloutDocpress()); // Ensure this API isn't used by anyone else
|
|
65
73
|
globalObject.prefetchedPageContexts[key] = {
|
|
66
74
|
resultFetchedAt: Date.now(),
|
|
67
75
|
resultMaxAge,
|
|
@@ -230,3 +238,7 @@ function getCacheKey(url) {
|
|
|
230
238
|
const key = url.split('#')[0];
|
|
231
239
|
return key;
|
|
232
240
|
}
|
|
241
|
+
// TODO/pageContext-prefetch: remove
|
|
242
|
+
function isBrilloutDocpress() {
|
|
243
|
+
return '_isBrilloutDocpress' in window;
|
|
244
|
+
}
|
|
@@ -53,10 +53,9 @@ async function renderPageClientSide(renderArgs) {
|
|
|
53
53
|
const onError = async (err) => {
|
|
54
54
|
await renderErrorPage({ err });
|
|
55
55
|
};
|
|
56
|
-
const pageContext = await getPageContextBegin();
|
|
56
|
+
const pageContext = await getPageContextBegin(false);
|
|
57
57
|
if (isRenderOutdated())
|
|
58
58
|
return;
|
|
59
|
-
objectAssign(pageContext, { isHydration: isFirstRender });
|
|
60
59
|
// onPageTransitionStart()
|
|
61
60
|
if (globalObject.isFirstRenderDone) {
|
|
62
61
|
assert(previousPageContext);
|
|
@@ -217,11 +216,12 @@ async function renderPageClientSide(renderArgs) {
|
|
|
217
216
|
await renderPageView(pageContext);
|
|
218
217
|
}
|
|
219
218
|
}
|
|
220
|
-
async function getPageContextBegin() {
|
|
219
|
+
async function getPageContextBegin(isForErrorPage) {
|
|
221
220
|
const pageContext = await createPageContext(urlOriginal);
|
|
222
221
|
objectAssign(pageContext, {
|
|
223
222
|
isBackwardNavigation,
|
|
224
223
|
isClientSideNavigation,
|
|
224
|
+
isHydration: isFirstRender && !isForErrorPage,
|
|
225
225
|
_previousPageContext: previousPageContext
|
|
226
226
|
});
|
|
227
227
|
{
|
|
@@ -256,7 +256,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
256
256
|
// We handle the abort error down below.
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
const pageContext = await getPageContextBegin();
|
|
259
|
+
const pageContext = await getPageContextBegin(true);
|
|
260
260
|
if (isRenderOutdated())
|
|
261
261
|
return;
|
|
262
262
|
if (args.is404)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.197-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.197-commit-9330153";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.197-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.197-commit-9330153';
|