web: a prerendered page's first load uses the answers in its html, also the parts that stream in after the app starts
Signed-off-by: dawn <90008@klbr.net>
8 unmodified lines910111213131415161740 unmodified lines585960616262636465664163 unmodified linesExpand all42304231423242334234423442354236423742381843 unmodified linesExpand all8 unmodified lines '@storybook/svelte': 10.6.1
patchedDependencies: '@pierre/diffs@1.6.1': e8e5e0bc2979e4de3622a06a03baadadccbd2873ee092de51b68b71722d4feeb '@sveltejs/kit@3.1.0': 027f4eb7822a895e53ad5681300675d8e8545082f64ed4267439b8fd836ac06b '@sveltejs/kit@3.1.0': 2d17b7026e589e5848f9a90c124b1263f560cb9a02313297cd71aff9a443e12e boneyard-js@1.9.0: e9bda6b0720bed34eefee605bd041784ac2849ae4d27120d9815663d342f694f svelte@5.57.2: ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117
importers:40 unmodified lines specifier: ^1.6.1 version: 1.6.1(patch_hash=e8e5e0bc2979e4de3622a06a03baadadccbd2873ee092de51b68b71722d4feeb)(@shikijs/themes@4.3.1)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) '@sveltejs/kit': specifier: ^3.1.0 version: 3.1.0(patch_hash=027f4eb7822a895e53ad5681300675d8e8545082f64ed4267439b8fd836ac06b)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0)))(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(typescript@6.0.3)(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0)) version: 3.1.0(patch_hash=2d17b7026e589e5848f9a90c124b1263f560cb9a02313297cd71aff9a443e12e)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0)))(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(typescript@6.0.3)(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0)) '@tanstack/svelte-virtual': specifier: ^3.13.35 version: 3.13.35(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0)) ansi_up:4163 unmodified linesExpand all '@sveltejs/acorn-typescript@1.0.13(acorn@8.18.0)': dependencies: acorn: 8.18.0
'@sveltejs/kit@3.1.0(patch_hash=027f4eb7822a895e53ad5681300675d8e8545082f64ed4267439b8fd836ac06b)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0)))(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(typescript@6.0.3)(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0))': '@sveltejs/kit@3.1.0(patch_hash=2d17b7026e589e5848f9a90c124b1263f560cb9a02313297cd71aff9a443e12e)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0)))(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(typescript@6.0.3)(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0))': dependencies: '@rolldown/pluginutils': 1.0.1 '@standard-schema/spec': 1.1.0 '@sveltejs/vite-plugin-svelte': 7.3.1(svelte@5.57.2(patch_hash=ea4cd117072ee1f738eef9403b73710aff64ede205564fb5b70173803dddb117)(@typescript-eslint/types@8.64.0))(vite@8.3.4(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0))1843 unmodified linesExpand all12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879280818283847 unmodified linesdiff --git a/src/runtime/client/client.js b/src/runtime/client/client.jsindex e174f9dbce28e05e71af2a1b03f787eed5dc33af..0217ba658b316f00a712d4813de42d154a0bf95b 100644--- a/src/runtime/client/client.js+++ b/src/runtime/client/client.js@@ -10,7 +10,15 @@ import { DEV } from 'esm-env'; import { settled, tick, fork, onMount, hydrate, mount } from 'svelte'; import { HttpError, Redirect, SvelteKitError, HandledHttpError } from '@sveltejs/kit/internal'; import { decode_pathname, strip_hash, make_trackable, normalize_path } from '../../utils/url.js';-import { dev_fetch, initial_fetch, lock_fetch, subsequent_fetch, unlock_fetch } from './fetcher.js';+import {+ dev_fetch,+ drop_inlined,+ has_inlined,+ initial_fetch,+ lock_fetch,+ subsequent_fetch,+ unlock_fetch+} from './fetcher.js'; import { parse_routes, parse_server_route } from './parse.js'; import * as storage from './session-storage.js'; import { blur_active_element, reset_focus } from './focus.js';@@ -577,6 +585,7 @@ async function _invalidate(reset_page_state = true) { await (pending_invalidate ||= Promise.resolve()); if (pending_invalidate === null) return; pending_invalidate = null;+ drop_inlined(); const token = (invalidation_token = {}); const nav_token = navigation_token;@@ -1272,9 +1281,10 @@ function resolve_fetch_url(input, init, url) { const requested = fetch_cache_url(resolved, url); - const promise = started- ? subsequent_fetch(requested, resolved.href, init)- : initial_fetch(requested, init);+ const promise =+ started && !has_inlined(requested, init)+ ? subsequent_fetch(requested, resolved.href, init)+ : initial_fetch(requested, init); return { resolved, promise }; }@@ -1983,6 +1993,7 @@ async function navigate({ accept(); is_navigating = true;+ drop_inlined(); if (started && nav.navigation.type !== 'enter') { set_navigation(nav.navigation);diff --git a/src/runtime/client/fetcher.js b/src/runtime/client/fetcher.jsindex 91541e07dc2bd553fd5a2779ba12606c4013f8cd..43fea8ee3e554dafb8d339f6ab8cd10b06ae155b 100644--- a/src/runtime/client/fetcher.js+++ b/src/runtime/client/fetcher.js@@ -110,6 +110,22 @@ export function initial_fetch(resource, opts) { return DEV ? dev_fetch(resource, opts) : window.fetch(resource, opts); } +/**+ * Whether the page's html still holds a response for this request: the streamed parts of the+ * page's first load ask after the app has started, and the server already answered them.+ * @param {URL | string} resource+ * @param {RequestInit} [opts]+ */+export function has_inlined(resource, opts) {+ const selector = build_selector(resource, opts);+ return !!selector && !!document.querySelector(selector);+}++/** a navigation or an invalidation wants fresh answers, not the page's first ones */+export function drop_inlined() {+ for (const script of document.querySelectorAll('script[data-sveltekit-fetched]')) script.remove();+}+ /** * Tries to get the response from the cache, if max-age allows it, else does a fetch. * @param {URL | string} resourcediff --git a/src/runtime/server/page/render.js b/src/runtime/server/page/render.jsindex 0a8042eb03fa01a378517d8b5ef48891438122be..61793fdbd645ecad068f4edce55f2ff7e3062d79 100644index 0a8042eb03fa01a378517d8b5ef48891438122be..62da9a00d362e75df163bbc31630d9bbfd9c01be 100644--- a/src/runtime/server/page/render.js+++ b/src/runtime/server/page/render.js@@ -620,7 +620,7 @@ export async function render_response({ done: true7 unmodified lines