Skip to content

Commit 9fce25a

Browse files
authored
Merge pull request #7598 from QwikDev/v2-merge-main
chore: merge main into v2
2 parents 5d16e66 + 17e2ea2 commit 9fce25a

File tree

17 files changed

+62
-98
lines changed

17 files changed

+62
-98
lines changed

.github/assets/qwik-logo.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<br>
22
<p align="center">
3-
<img alt="Qwik Logo" width="400" src="https://raw.githubusercontent.com/QwikDev/qwik/main/.github/assets/qwik-logo.svg" />
3+
<img alt="Qwik Logo" width="400" src="https://raw.githubusercontent.com/QwikDev/qwik/main/packages/docs/public/logos/qwik.svg" />
44
</p>
55
<br>
66
<p align="center">
Lines changed: 4 additions & 4 deletions
Loading

packages/docs/public/logos/qwik.svg

Lines changed: 18 additions & 1 deletion
Loading

packages/docs/src/entry.ssr.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Root from './root';
66
const preloaderSettings = [
77
'ssrPreloads',
88
'ssrPreloadProbability',
9-
'maxBufferedPreloads',
9+
'maxIdlePreloads',
1010
'preloadProbability',
1111
] as const;
1212

packages/docs/src/routes/api/qwik-server/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
}
125125
],
126126
"kind": "Interface",
127-
"content": "```typescript\nexport interface PreloaderOptions \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[debug?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nboolean\n\n\n</td><td>\n\n_(Optional)_ Log preloader debug information to the console.\n\nDefaults to `false`\n\n\n</td></tr>\n<tr><td>\n\n[maxBufferedPreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of simultaneous preload links that the preloader will maintain. If you set this higher, the browser will have all JS files in memory sooner, but it will contend with other resource downloads. Furthermore, if a bundle suddenly becomes more likely, it will have to wait longer to be preloaded.\n\nBundles that reach 100% probability (static imports of other bundles) will always be preloaded immediately, no limit.\n\nDefaults to `25`\n\n\n</td></tr>\n<tr><td>\n\n[preloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added to the preload queue.\n\nDefaults to `0.35` (35% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added as a preload link during SSR.\n\nDefaults to `0.7` (70% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of preload links to add during SSR. These instruct the browser to preload likely bundles before the preloader script is active. This most likely includes the core and the preloader script itself. Setting this to 0 will disable all preload links.\n\nPreload links can delay LCP, which is a Core Web Vital, but it can increase TTI, which is not a Core Web Vital but more noticeable to the user.\n\nDefaults to `5`\n\n\n</td></tr>\n</tbody></table>",
127+
"content": "```typescript\nexport interface PreloaderOptions \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[debug?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nboolean\n\n\n</td><td>\n\n_(Optional)_ Log preloader debug information to the console.\n\nDefaults to `false`\n\n\n</td></tr>\n<tr><td>\n\n[maxIdlePreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of simultaneous preload links that the preloader will maintain. If you set this higher, the browser will have all JS files in memory sooner, but it will contend with other resource downloads. Furthermore, if a bundle suddenly becomes more likely, it will have to wait longer to be preloaded.\n\nBundles that reach 100% probability (static imports of other bundles) will always be preloaded immediately, no limit.\n\nDefaults to `25`\n\n\n</td></tr>\n<tr><td>\n\n[preloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added to the preload queue.\n\nDefaults to `0.35` (35% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added as a preload link during SSR.\n\nDefaults to `0.7` (70% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of preload links to add during SSR. These instruct the browser to preload likely bundles before the preloader script is active. This most likely includes the core and the preloader script itself. Setting this to 0 will disable all preload links.\n\nPreload links can delay LCP, which is a Core Web Vital, but it can increase TTI, which is not a Core Web Vital but more noticeable to the user.\n\nDefaults to `5`\n\n\n</td></tr>\n</tbody></table>",
128128
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/server/types.ts",
129129
"mdFile": "core.preloaderoptions.md"
130130
},

packages/docs/src/routes/api/qwik-server/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ Defaults to `false`
466466
</td></tr>
467467
<tr><td>
468468

469-
[maxBufferedPreloads?](#)
469+
[maxIdlePreloads?](#)
470470

471471
</td><td>
472472

packages/qwik-router/src/runtime/src/link-component.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ import {
55
Slot,
66
sync$,
77
untrack,
8+
useSignal,
9+
useVisibleTask$,
810
type QwikIntrinsicElements,
911
} from '@qwik.dev/core';
1012
import { prefetchSymbols } from './client-navigate';
1113
import { loadClientData } from './use-endpoint';
1214
import { useLocation, useNavigate } from './use-functions';
13-
import { getClientNavPath, shouldPrefetchData, shouldPrefetchSymbols } from './utils';
15+
import { getClientNavPath, shouldPreload } from './utils';
1416

1517
/** @public */
1618
export const Link = component$<LinkProps>((props) => {
1719
const nav = useNavigate();
1820
const loc = useLocation();
1921
const originalHref = props.href;
22+
const anchorRef = useSignal<HTMLAnchorElement>();
2023
const {
2124
onClick$,
2225
prefetch: prefetchProp,
@@ -29,18 +32,13 @@ export const Link = component$<LinkProps>((props) => {
2932
linkProps.href = clientNavPath || originalHref;
3033

3134
const prefetchData = untrack(
32-
() =>
33-
(!!clientNavPath &&
34-
prefetchProp !== false &&
35-
prefetchProp !== 'js' &&
36-
shouldPrefetchData(clientNavPath, loc)) ||
37-
undefined
35+
() => (!!clientNavPath && prefetchProp !== false && prefetchProp !== 'js') || undefined
3836
);
3937

4038
const prefetch = untrack(
4139
() =>
4240
prefetchData ||
43-
(!!clientNavPath && prefetchProp !== false && shouldPrefetchSymbols(clientNavPath, loc))
41+
(!!clientNavPath && prefetchProp !== false && shouldPreload(clientNavPath, loc))
4442
);
4543

4644
const handlePrefetch = prefetch
@@ -81,17 +79,25 @@ export const Link = component$<LinkProps>((props) => {
8179
}
8280
})
8381
: undefined;
82+
83+
useVisibleTask$(({ track }) => {
84+
track(() => loc.url.pathname);
85+
// Don't prefetch on visible in dev mode
86+
if (!isDev && anchorRef.value) {
87+
handlePrefetch?.(undefined, anchorRef.value!);
88+
}
89+
});
90+
8491
return (
8592
<a
93+
ref={anchorRef}
8694
// Attr 'q:link' is used as a selector for bootstrapping into spa after context loss
8795
{...{ 'q:link': !!clientNavPath }}
8896
{...linkProps}
8997
onClick$={[preventDefault, onClick$, handleClick]}
9098
data-prefetch={prefetchData}
9199
onMouseOver$={[linkProps.onMouseOver$, handlePrefetch]}
92100
onFocus$={[linkProps.onFocus$, handlePrefetch]}
93-
// Don't prefetch on visible in dev mode
94-
onQVisible$={[linkProps.onQVisible$, !isDev ? handlePrefetch : undefined]}
95101
>
96102
<Slot />
97103
</a>

packages/qwik-router/src/runtime/src/utils.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,7 @@ export const getClientNavPath = (props: Record<string, any>, baseUrl: { url: URL
5858
return null;
5959
};
6060

61-
export const shouldPrefetchData = (clientNavPath: string | null, currentLoc: { url: URL }) => {
62-
if (clientNavPath) {
63-
const prefetchUrl = toUrl(clientNavPath, currentLoc.url);
64-
const currentUrl = toUrl('', currentLoc.url);
65-
return !isSamePath(prefetchUrl, currentUrl);
66-
}
67-
return false;
68-
};
69-
70-
export const shouldPrefetchSymbols = (clientNavPath: string | null, currentLoc: { url: URL }) => {
61+
export const shouldPreload = (clientNavPath: string | null, currentLoc: { url: URL }) => {
7162
if (clientNavPath) {
7263
const prefetchUrl = toUrl(clientNavPath, currentLoc.url);
7364
const currentUrl = toUrl('', currentLoc.url);

0 commit comments

Comments
 (0)