full site update
This commit is contained in:
8
node_modules/astro/dist/prefetch/index.d.ts
generated
vendored
8
node_modules/astro/dist/prefetch/index.d.ts
generated
vendored
@@ -23,6 +23,14 @@ export interface PrefetchOptions {
|
||||
* Should prefetch even on data saver mode or slow connection. (default `false`)
|
||||
*/
|
||||
ignoreSlowConnection?: boolean;
|
||||
/**
|
||||
* A string providing a hint to the browser as to how eagerly it should prefetch/prerender link targets in order to balance performance advantages against resource overheads. (default `immediate`)
|
||||
* Only works if `clientPrerender` is enabled and browser supports Speculation Rules API.
|
||||
* The browser takes this hint into consideration along with its own heuristics, so it may select a link that the author has hinted as less eager than another, if the less eager candidate is considered a better choice.
|
||||
*
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/speculationrules#eagerness
|
||||
*/
|
||||
eagerness?: 'immediate' | 'eager' | 'moderate' | 'conservative';
|
||||
}
|
||||
/**
|
||||
* Prefetch a URL so it's cached when the user navigates to it.
|
||||
|
10
node_modules/astro/dist/prefetch/index.js
generated
vendored
10
node_modules/astro/dist/prefetch/index.js
generated
vendored
@@ -125,7 +125,7 @@ function prefetch(url, opts) {
|
||||
prefetchedUrls.add(url);
|
||||
if (clientPrerender && HTMLScriptElement.supports?.("speculationrules")) {
|
||||
debug?.(`[astro] Prefetching ${url} with <script type="speculationrules">`);
|
||||
appendSpeculationRules(url);
|
||||
appendSpeculationRules(url, opts?.eagerness ?? "immediate");
|
||||
} else if (document.createElement("link").relList?.supports?.("prefetch") && opts?.with !== "fetch") {
|
||||
debug?.(`[astro] Prefetching ${url} with <link rel="prefetch">`);
|
||||
const link = document.createElement("link");
|
||||
@@ -182,14 +182,15 @@ function onPageLoad(cb) {
|
||||
cb();
|
||||
});
|
||||
}
|
||||
function appendSpeculationRules(url) {
|
||||
function appendSpeculationRules(url, eagerness) {
|
||||
const script = document.createElement("script");
|
||||
script.type = "speculationrules";
|
||||
script.textContent = JSON.stringify({
|
||||
prerender: [
|
||||
{
|
||||
source: "list",
|
||||
urls: [url]
|
||||
urls: [url],
|
||||
eagerness
|
||||
}
|
||||
],
|
||||
// Currently, adding `prefetch` is required to fallback if `prerender` fails.
|
||||
@@ -198,7 +199,8 @@ function appendSpeculationRules(url) {
|
||||
prefetch: [
|
||||
{
|
||||
source: "list",
|
||||
urls: [url]
|
||||
urls: [url],
|
||||
eagerness
|
||||
}
|
||||
]
|
||||
});
|
||||
|
2
node_modules/astro/dist/prefetch/vite-plugin-prefetch.d.ts
generated
vendored
2
node_modules/astro/dist/prefetch/vite-plugin-prefetch.d.ts
generated
vendored
@@ -1,5 +1,5 @@
|
||||
import type * as vite from 'vite';
|
||||
import type { AstroSettings } from '../@types/astro.js';
|
||||
import type { AstroSettings } from '../types/astro.js';
|
||||
export default function astroPrefetch({ settings }: {
|
||||
settings: AstroSettings;
|
||||
}): vite.Plugin;
|
||||
|
2
node_modules/astro/dist/prefetch/vite-plugin-prefetch.js
generated
vendored
2
node_modules/astro/dist/prefetch/vite-plugin-prefetch.js
generated
vendored
@@ -25,7 +25,7 @@ function astroPrefetch({ settings }) {
|
||||
load(id) {
|
||||
if (id === resolvedVirtualModuleId) {
|
||||
if (!prefetch) throwPrefetchNotEnabledError();
|
||||
return `export { prefetch } from "astro/virtual-modules/prefetch.js";`;
|
||||
return { code: `export { prefetch } from "astro/virtual-modules/prefetch.js";` };
|
||||
}
|
||||
},
|
||||
transform(code, id) {
|
||||
|
Reference in New Issue
Block a user