diff --git a/front/dist/service-worker-dev.js b/front/dist/service-worker-dev.js new file mode 100644 index 00000000..43bd0070 --- /dev/null +++ b/front/dist/service-worker-dev.js @@ -0,0 +1,39 @@ +let CACHE_NAME = 'workavdenture-cache-v1'; +let urlsToCache = [ + '/' +]; + +self.addEventListener('install', function(event) { + // Perform install steps + event.waitUntil( + caches.open(CACHE_NAME) + .then((cache) => { + return cache.addAll(urlsToCache); + }) + ); +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request) + .then((response) => { + return fetch(event.request).then((response) => { + //Dev service worker, just return reponse + return response; + } + ); + }) + ); +}); + +self.addEventListener('wait', function(event) { + //TODO wait +}); + +self.addEventListener('update', function(event) { + //TODO update +}); + +self.addEventListener('beforeinstallprompt', (e) => { + //TODO change prompt +}); \ No newline at end of file diff --git a/front/dist/service-worker.js b/front/dist/service-worker-prod.js similarity index 100% rename from front/dist/service-worker.js rename to front/dist/service-worker-prod.js diff --git a/front/dist/static/images/favicons/android-icon-144x144.png b/front/dist/static/images/favicons/android-icon-144x144.png index 59a7c4ce..037f624c 100644 Binary files a/front/dist/static/images/favicons/android-icon-144x144.png and b/front/dist/static/images/favicons/android-icon-144x144.png differ diff --git a/front/dist/static/images/favicons/android-icon-192x192.png b/front/dist/static/images/favicons/android-icon-192x192.png index e1a4b3ed..0968b1bd 100644 Binary files a/front/dist/static/images/favicons/android-icon-192x192.png and b/front/dist/static/images/favicons/android-icon-192x192.png differ diff --git a/front/dist/static/images/favicons/android-icon-36x36.png b/front/dist/static/images/favicons/android-icon-36x36.png index f9d822e9..fabc0fa4 100644 Binary files a/front/dist/static/images/favicons/android-icon-36x36.png and b/front/dist/static/images/favicons/android-icon-36x36.png differ diff --git a/front/dist/static/images/favicons/android-icon-48x48.png b/front/dist/static/images/favicons/android-icon-48x48.png index 35b1f177..ed206753 100644 Binary files a/front/dist/static/images/favicons/android-icon-48x48.png and b/front/dist/static/images/favicons/android-icon-48x48.png differ diff --git a/front/dist/static/images/favicons/android-icon-72x72.png b/front/dist/static/images/favicons/android-icon-72x72.png index b04f1b25..f92ffa32 100644 Binary files a/front/dist/static/images/favicons/android-icon-72x72.png and b/front/dist/static/images/favicons/android-icon-72x72.png differ diff --git a/front/dist/static/images/favicons/android-icon-96x96.png b/front/dist/static/images/favicons/android-icon-96x96.png index 380de08a..fda1933e 100644 Binary files a/front/dist/static/images/favicons/android-icon-96x96.png and b/front/dist/static/images/favicons/android-icon-96x96.png differ diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index 163489bb..b63f4f07 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -17,6 +17,7 @@ const MAX_EXTRAPOLATION_TIME = 100; // Extrapolate a maximum of 250ms if no new export const MAX_USERNAME_LENGTH = parseInt(process.env.MAX_USERNAME_LENGTH || "") || 8; export const MAX_PER_GROUP = parseInt(process.env.MAX_PER_GROUP || "4"); export const DISPLAY_TERMS_OF_USE = process.env.DISPLAY_TERMS_OF_USE == "true"; +export const NODE_ENV = process.env.NODE_ENV || "development"; export const isMobile = (): boolean => window.innerWidth <= 800 || window.innerHeight <= 600; diff --git a/front/src/Network/ServiceWorker.ts b/front/src/Network/ServiceWorker.ts index 59f913e2..e75f202f 100644 --- a/front/src/Network/ServiceWorker.ts +++ b/front/src/Network/ServiceWorker.ts @@ -1,3 +1,5 @@ +import { NODE_ENV } from "../Enum/EnvironmentVariable"; + export class _ServiceWorker { constructor() { if ("serviceWorker" in navigator) { @@ -6,8 +8,19 @@ export class _ServiceWorker { } init() { + if (NODE_ENV === "development") { + navigator.serviceWorker + .register("/service-worker-dev.js") + .then((serviceWorker) => { + console.info("Service Worker registered: ", serviceWorker); + }) + .catch((error) => { + console.error("Error registering the Service Worker: ", error); + }); + return; + } navigator.serviceWorker - .register("/service-worker.js") + .register("/service-worker-prod.js") .then((serviceWorker) => { console.info("Service Worker registered: ", serviceWorker); }) diff --git a/front/webpack.config.ts b/front/webpack.config.ts index 13647b30..4b7fd205 100644 --- a/front/webpack.config.ts +++ b/front/webpack.config.ts @@ -201,6 +201,7 @@ module.exports = { MAX_USERNAME_LENGTH: 8, MAX_PER_GROUP: 4, DISPLAY_TERMS_OF_USE: false, + NODE_ENV: "development", }), ], } as Configuration & WebpackDevServer.Configuration;