v1.0 with SW PWA enabled

This commit is contained in:
Blomios
2026-01-01 17:40:53 +01:00
parent 1c0e22aac1
commit 3c8bebb2ad
29775 changed files with 2197201 additions and 119080 deletions

View File

@ -0,0 +1,2 @@
// @ts-ignore
try{self['workbox:recipes:7.4.0']&&_()}catch(e){}

View File

@ -0,0 +1,64 @@
/*
Copyright 2020 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {registerRoute} from 'workbox-routing/registerRoute.js';
import {StaleWhileRevalidate} from 'workbox-strategies/StaleWhileRevalidate.js';
import {CacheFirst} from 'workbox-strategies/CacheFirst.js';
import {CacheableResponsePlugin} from 'workbox-cacheable-response/CacheableResponsePlugin.js';
import {ExpirationPlugin} from 'workbox-expiration/ExpirationPlugin.js';
import './_version.js';
export interface GoogleFontCacheOptions {
cachePrefix?: string;
maxAgeSeconds?: number;
maxEntries?: number;
}
/**
* An implementation of the [Google fonts]{@link https://developers.google.com/web/tools/workbox/guides/common-recipes#google_fonts} caching recipe
*
* @memberof workbox-recipes
*
* @param {Object} [options]
* @param {string} [options.cachePrefix] Cache prefix for caching stylesheets and webfonts. Defaults to google-fonts
* @param {number} [options.maxAgeSeconds] Maximum age, in seconds, that font entries will be cached for. Defaults to 1 year
* @param {number} [options.maxEntries] Maximum number of fonts that will be cached. Defaults to 30
*/
function googleFontsCache(options: GoogleFontCacheOptions = {}): void {
const sheetCacheName = `${options.cachePrefix || 'google-fonts'}-stylesheets`;
const fontCacheName = `${options.cachePrefix || 'google-fonts'}-webfonts`;
const maxAgeSeconds = options.maxAgeSeconds || 60 * 60 * 24 * 365;
const maxEntries = options.maxEntries || 30;
// Cache the Google Fonts stylesheets with a stale-while-revalidate strategy.
registerRoute(
({url}) => url.origin === 'https://fonts.googleapis.com',
new StaleWhileRevalidate({
cacheName: sheetCacheName,
}),
);
// Cache the underlying font files with a cache-first strategy for 1 year.
registerRoute(
({url}) => url.origin === 'https://fonts.gstatic.com',
new CacheFirst({
cacheName: fontCacheName,
plugins: [
new CacheableResponsePlugin({
statuses: [0, 200],
}),
new ExpirationPlugin({
maxAgeSeconds,
maxEntries,
}),
],
}),
);
}
export {googleFontsCache};

View File

@ -0,0 +1,77 @@
/*
Copyright 2020 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {warmStrategyCache} from './warmStrategyCache';
import {registerRoute} from 'workbox-routing/registerRoute.js';
import {CacheFirst} from 'workbox-strategies/CacheFirst.js';
import {CacheableResponsePlugin} from 'workbox-cacheable-response/CacheableResponsePlugin.js';
import {ExpirationPlugin} from 'workbox-expiration/ExpirationPlugin.js';
import {
RouteMatchCallback,
RouteMatchCallbackOptions,
WorkboxPlugin,
} from 'workbox-core/types.js';
import './_version.js';
export interface ImageCacheOptions {
cacheName?: string;
matchCallback?: RouteMatchCallback;
maxAgeSeconds?: number;
maxEntries?: number;
plugins?: Array<WorkboxPlugin>;
warmCache?: Array<string>;
}
/**
* An implementation of the [image caching recipe]{@link https://developers.google.com/web/tools/workbox/guides/common-recipes#caching_images}
*
* @memberof workbox-recipes
*
* @param {Object} [options]
* @param {string} [options.cacheName] Name for cache. Defaults to images
* @param {RouteMatchCallback} [options.matchCallback] Workbox callback function to call to match to. Defaults to request.destination === 'image';
* @param {number} [options.maxAgeSeconds] Maximum age, in seconds, that font entries will be cached for. Defaults to 30 days
* @param {number} [options.maxEntries] Maximum number of images that will be cached. Defaults to 60
* @param {WorkboxPlugin[]} [options.plugins] Additional plugins to use for this recipe
* @param {string[]} [options.warmCache] Paths to call to use to warm this cache
*/
function imageCache(options: ImageCacheOptions = {}): void {
const defaultMatchCallback = ({request}: RouteMatchCallbackOptions) =>
request.destination === 'image';
const cacheName = options.cacheName || 'images';
const matchCallback = options.matchCallback || defaultMatchCallback;
const maxAgeSeconds = options.maxAgeSeconds || 30 * 24 * 60 * 60;
const maxEntries = options.maxEntries || 60;
const plugins = options.plugins || [];
plugins.push(
new CacheableResponsePlugin({
statuses: [0, 200],
}),
);
plugins.push(
new ExpirationPlugin({
maxEntries,
maxAgeSeconds,
}),
);
const strategy = new CacheFirst({
cacheName,
plugins,
});
registerRoute(matchCallback, strategy);
// Warms the cache
if (options.warmCache) {
warmStrategyCache({urls: options.warmCache, strategy});
}
}
export {imageCache};

38
frontend/node_modules/workbox-recipes/src/index.ts generated vendored Normal file
View File

@ -0,0 +1,38 @@
/*
Copyright 2020 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {googleFontsCache, GoogleFontCacheOptions} from './googleFontsCache';
import {imageCache, ImageCacheOptions} from './imageCache';
import {
staticResourceCache,
StaticResourceOptions,
} from './staticResourceCache';
import {pageCache, PageCacheOptions} from './pageCache';
import {offlineFallback, OfflineFallbackOptions} from './offlineFallback';
import {warmStrategyCache, WarmStrategyCacheOptions} from './warmStrategyCache';
import './_version.js';
/**
* @module workbox-recipes
*/
export {
GoogleFontCacheOptions,
googleFontsCache,
imageCache,
ImageCacheOptions,
offlineFallback,
OfflineFallbackOptions,
pageCache,
PageCacheOptions,
staticResourceCache,
StaticResourceOptions,
warmStrategyCache,
WarmStrategyCacheOptions,
};

View File

@ -0,0 +1,87 @@
/*
Copyright 2020 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {setCatchHandler} from 'workbox-routing/setCatchHandler.js';
import {matchPrecache} from 'workbox-precaching/matchPrecache.js';
import {RouteHandler, RouteHandlerCallbackOptions} from 'workbox-core/types.js';
import './_version.js';
export interface OfflineFallbackOptions {
pageFallback?: string;
imageFallback?: string;
fontFallback?: string;
}
// Give TypeScript the correct global.
declare let self: ServiceWorkerGlobalScope;
/**
* An implementation of the [comprehensive fallbacks recipe]{@link https://developers.google.com/web/tools/workbox/guides/advanced-recipes#comprehensive_fallbacks}. Be sure to include the fallbacks in your precache injection
*
* @memberof workbox-recipes
*
* @param {Object} [options]
* @param {string} [options.pageFallback] Precache name to match for pag fallbacks. Defaults to offline.html
* @param {string} [options.imageFallback] Precache name to match for image fallbacks.
* @param {string} [options.fontFallback] Precache name to match for font fallbacks.
*/
function offlineFallback(options: OfflineFallbackOptions = {}): void {
const pageFallback = options.pageFallback || 'offline.html';
const imageFallback = options.imageFallback || false;
const fontFallback = options.fontFallback || false;
self.addEventListener('install', (event) => {
const files = [pageFallback];
if (imageFallback) {
files.push(imageFallback);
}
if (fontFallback) {
files.push(fontFallback);
}
event.waitUntil(
self.caches
.open('workbox-offline-fallbacks')
.then((cache) => cache.addAll(files)),
);
});
const handler: RouteHandler = async (
options: RouteHandlerCallbackOptions,
) => {
const dest = options.request.destination;
const cache = await self.caches.open('workbox-offline-fallbacks');
if (dest === 'document') {
const match =
(await matchPrecache(pageFallback)) ||
(await cache.match(pageFallback));
return match || Response.error();
}
if (dest === 'image' && imageFallback !== false) {
const match =
(await matchPrecache(imageFallback)) ||
(await cache.match(imageFallback));
return match || Response.error();
}
if (dest === 'font' && fontFallback !== false) {
const match =
(await matchPrecache(fontFallback)) ||
(await cache.match(fontFallback));
return match || Response.error();
}
return Response.error();
};
setCatchHandler(handler);
}
export {offlineFallback};

69
frontend/node_modules/workbox-recipes/src/pageCache.ts generated vendored Normal file
View File

@ -0,0 +1,69 @@
/*
Copyright 2020 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {warmStrategyCache} from './warmStrategyCache';
import {registerRoute} from 'workbox-routing/registerRoute.js';
import {NetworkFirst} from 'workbox-strategies/NetworkFirst.js';
import {CacheableResponsePlugin} from 'workbox-cacheable-response/CacheableResponsePlugin.js';
import {
RouteMatchCallback,
RouteMatchCallbackOptions,
WorkboxPlugin,
} from 'workbox-core/types.js';
import './_version.js';
export interface PageCacheOptions {
cacheName?: string;
matchCallback?: RouteMatchCallback;
networkTimeoutSeconds?: number;
plugins?: Array<WorkboxPlugin>;
warmCache?: Array<string>;
}
/**
* An implementation of a page caching recipe with a network timeout
*
* @memberof workbox-recipes
*
* @param {Object} [options]
* @param {string} [options.cacheName] Name for cache. Defaults to pages
* @param {RouteMatchCallback} [options.matchCallback] Workbox callback function to call to match to. Defaults to request.mode === 'navigate';
* @param {number} [options.networkTimoutSeconds] Maximum amount of time, in seconds, to wait on the network before falling back to cache. Defaults to 3
* @param {WorkboxPlugin[]} [options.plugins] Additional plugins to use for this recipe
* @param {string[]} [options.warmCache] Paths to call to use to warm this cache
*/
function pageCache(options: PageCacheOptions = {}): void {
const defaultMatchCallback = ({request}: RouteMatchCallbackOptions) =>
request.mode === 'navigate';
const cacheName = options.cacheName || 'pages';
const matchCallback = options.matchCallback || defaultMatchCallback;
const networkTimeoutSeconds = options.networkTimeoutSeconds || 3;
const plugins = options.plugins || [];
plugins.push(
new CacheableResponsePlugin({
statuses: [0, 200],
}),
);
const strategy = new NetworkFirst({
networkTimeoutSeconds,
cacheName,
plugins,
});
// Registers the route
registerRoute(matchCallback, strategy);
// Warms the cache
if (options.warmCache) {
warmStrategyCache({urls: options.warmCache, strategy});
}
}
export {pageCache};

View File

@ -0,0 +1,66 @@
/*
Copyright 2020 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import {warmStrategyCache} from './warmStrategyCache';
import {registerRoute} from 'workbox-routing/registerRoute.js';
import {StaleWhileRevalidate} from 'workbox-strategies/StaleWhileRevalidate.js';
import {CacheableResponsePlugin} from 'workbox-cacheable-response/CacheableResponsePlugin.js';
import {
RouteMatchCallback,
RouteMatchCallbackOptions,
WorkboxPlugin,
} from 'workbox-core/types.js';
import './_version.js';
export interface StaticResourceOptions {
cacheName?: string;
matchCallback?: RouteMatchCallback;
plugins?: Array<WorkboxPlugin>;
warmCache?: Array<string>;
}
/**
* An implementation of the [CSS and JavaScript files recipe]{@link https://developers.google.com/web/tools/workbox/guides/common-recipes#cache_css_and_javascript_files}
*
* @memberof workbox-recipes
*
* @param {Object} [options]
* @param {string} [options.cacheName] Name for cache. Defaults to static-resources
* @param {RouteMatchCallback} [options.matchCallback] Workbox callback function to call to match to. Defaults to request.destination === 'style' || request.destination === 'script' || request.destination === 'worker';
* @param {WorkboxPlugin[]} [options.plugins] Additional plugins to use for this recipe
* @param {string[]} [options.warmCache] Paths to call to use to warm this cache
*/
function staticResourceCache(options: StaticResourceOptions = {}): void {
const defaultMatchCallback = ({request}: RouteMatchCallbackOptions) =>
request.destination === 'style' ||
request.destination === 'script' ||
request.destination === 'worker';
const cacheName = options.cacheName || 'static-resources';
const matchCallback = options.matchCallback || defaultMatchCallback;
const plugins = options.plugins || [];
plugins.push(
new CacheableResponsePlugin({
statuses: [0, 200],
}),
);
const strategy = new StaleWhileRevalidate({
cacheName,
plugins,
});
registerRoute(matchCallback, strategy);
// Warms the cache
if (options.warmCache) {
warmStrategyCache({urls: options.warmCache, strategy});
}
}
export {staticResourceCache};

View File

@ -0,0 +1,34 @@
import {Strategy} from 'workbox-strategies/Strategy.js';
import './_version.js';
export interface WarmStrategyCacheOptions {
urls: Array<string>;
strategy: Strategy;
}
// Give TypeScript the correct global.
declare let self: ServiceWorkerGlobalScope;
/**
* @memberof workbox-recipes
* @param {Object} options
* @param {string[]} options.urls Paths to warm the strategy's cache with
* @param {Strategy} options.strategy Strategy to use
*/
function warmStrategyCache(options: WarmStrategyCacheOptions): void {
self.addEventListener('install', (event) => {
const done = options.urls.map(
(path) =>
options.strategy.handleAll({
event,
request: new Request(path),
})[1],
);
event.waitUntil(Promise.all(done));
});
}
export {warmStrategyCache};