-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.7.0 Fix endpoints of static files (#204)
* update tsconfig & sveltekit from 2.5.0 to 2.5.2 (#192) * update sveltekit from 2.5.0 to 2.5.2 * remove unused properties on tsconfig * fix: format * [Snyk] Upgrade prettier-plugin-svelte from 3.1.2 to 3.2.0 (#195) * fix: upgrade prettier-plugin-svelte from 3.1.2 to 3.2.0 Snyk has created this PR to upgrade prettier-plugin-svelte from 3.1.2 to 3.2.0. See this package in npm: https://www.npmjs.com/package/prettier-plugin-svelte See this project in Snyk: https://app.snyk.io/org/u-sho/project/56523540-5a4b-485d-ae86-4b4f9b0ef853?utm_source=github&utm_medium=referral&page=upgrade-pr * fetch package-lock.json --------- Co-authored-by: snyk-bot <[email protected]> * [Snyk] Upgrade vitest from 1.2.2 to 1.3.1 (#198) * fix: upgrade @vitest/coverage-v8 from 1.2.2 to 1.3.0 Snyk has created this PR to upgrade @vitest/coverage-v8 from 1.2.2 to 1.3.0. See this package in npm: https://www.npmjs.com/package/@vitest/coverage-v8 See this project in Snyk: https://app.snyk.io/org/u-sho/project/56523540-5a4b-485d-ae86-4b4f9b0ef853?utm_source=github&utm_medium=referral&page=upgrade-pr * upgrade vitest from 1.2.2 to 1.3.1 --------- Co-authored-by: snyk-bot <[email protected]> * Update build tool packages (#201) * update vite(st) to the latest * update SvelteKit and its toolchanis to the latest * fix: file access conflict on coverage directory * fix: type safety of service-worker see https://kit.svelte.dev/docs/service-workers#type-safety * save static files to cache & don't separate cache with online/offline (#202) * Fix: deployments and analytics (vercel) (#203) * fix CSP setting for vercel/analytics * fix: trailing slash of static files * update sitemap: last modified date --------- Co-authored-by: snyk-bot <[email protected]>
- Loading branch information
Showing
11 changed files
with
222 additions
and
212 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/// <reference types="@sveltejs/kit" /> | ||
/// <reference no-default-lib="true"/> | ||
/// <reference lib="esnext" /> | ||
/// <reference lib="WebWorker" /> | ||
|
||
import { build, files, version } from '$service-worker'; | ||
|
||
declare const self: ServiceWorkerGlobalScope; | ||
|
||
const ASSETS = `cache${version}`; | ||
const cached = [...build, ...files]; | ||
|
||
self.addEventListener('install', (event) => { | ||
event.waitUntil( | ||
caches | ||
.open(ASSETS) | ||
.then(async (cache) => cache.addAll(cached)) | ||
.then(() => { | ||
void self.skipWaiting(); | ||
}) | ||
); | ||
}); | ||
|
||
self.addEventListener('activate', (event) => { | ||
event.waitUntil( | ||
caches.keys().then(async (keys) => { | ||
// delete old caches | ||
for (const key of keys) { | ||
if (key !== ASSETS) await caches.delete(key); | ||
} | ||
void self.clients.claim(); | ||
}) | ||
); | ||
}); | ||
|
||
self.addEventListener('fetch', (event) => { | ||
if (event.request.method !== 'GET' || event.request.headers.has('range')) return; | ||
|
||
const url = new URL(event.request.url); | ||
|
||
// don't try to handle e.g. data: URIs | ||
if (!url.protocol.startsWith('http')) return; | ||
|
||
// ignore dev server requests | ||
if (url.hostname === self.location.hostname && url.port !== self.location.port) return; | ||
|
||
async function respond(): Promise<Response> { | ||
const cache = await caches.open(ASSETS); | ||
|
||
// always serve static files and bundler-generated assets from cache | ||
if (url.host === self.location.host && cached.includes(url.pathname)) { | ||
const response = await cache.match(event.request); | ||
if (response) return response; | ||
} | ||
|
||
// if (event.request.cache === 'only-if-cached') return; | ||
|
||
// for everything else, try the network first, falling back to | ||
// cache if the user is offline. (If the pages never change, you | ||
// might prefer a cache-first approach to a network-first one.) | ||
try { | ||
const response = await fetch(event.request); | ||
if (!(response instanceof Response)) { | ||
throw new Error('invalid response from fetch'); | ||
} | ||
if (response.status === 200) { | ||
void cache.put(event.request, response.clone()); | ||
} | ||
return response; | ||
} catch (err) { | ||
const response = await cache.match(event.request); | ||
if (response) return response; | ||
|
||
throw err; | ||
} | ||
} | ||
|
||
event.respondWith(respond()); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"$schema": "http://openapi.vercel.sh/vercel.json", | ||
"trailingSlash": false | ||
} |