feat: remove Cache API, rework preload(), cancel() and fetch() (#25289)

* feat: remove Cache API, rework preload(), cancel() and fetch()

perf - replace broadcast channel with direct postMessage

* remove sw response handling

* review comments
This commit is contained in:
Min Idzelis
2026-02-12 11:25:20 -05:00
committed by GitHub
parent a62e8ed179
commit 81f592ca52
7 changed files with 119 additions and 144 deletions
+33
View File
@@ -0,0 +1,33 @@
/// <reference types="@sveltejs/kit" />
/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />
/// <reference lib="webworker" />
import { handleCancel } from './request';
const sw = globalThis as unknown as ServiceWorkerGlobalScope;
export const installMessageListener = () => {
sw.addEventListener('message', (event) => {
if (!event.data?.type) {
return;
}
switch (event.data.type) {
case 'cancel': {
const url = event.data.url ? new URL(event.data.url, self.location.origin) : undefined;
if (!url) {
return;
}
const client = event.source;
if (!client) {
return;
}
handleCancel(url);
break;
}
}
});
};