mirror of
https://github.com/jcreek/BankStatementAnalyser.git
synced 2026-07-13 02:53:49 +00:00
chore(*): Add base project files
This commit is contained in:
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare module '*.svg' {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
export default function loadServiceWorker() {
|
||||
let deferredPrompt;
|
||||
|
||||
window.addEventListener('beforeinstallprompt', (e) => {
|
||||
const installApp = document.getElementById('install-app-btn-container');
|
||||
|
||||
installApp.addEventListener('click', async () => {
|
||||
if (deferredPrompt !== null) {
|
||||
deferredPrompt.prompt();
|
||||
const { outcome } = await deferredPrompt.userChoice;
|
||||
if (outcome === 'accepted') {
|
||||
deferredPrompt = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('install-app-btn-container').style.display = 'block';
|
||||
deferredPrompt = e;
|
||||
});
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/service-worker.js');
|
||||
});
|
||||
|
||||
if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||
document.getElementById('install-app-btn-container').style.display = 'none';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { precacheAndRoute } from 'workbox-precaching';
|
||||
import * as navigationPreload from 'workbox-navigation-preload';
|
||||
import { NetworkFirst, CacheFirst, StaleWhileRevalidate } from 'workbox-strategies';
|
||||
import { registerRoute, NavigationRoute, Route } from 'workbox-routing';
|
||||
|
||||
// Precache the manifest
|
||||
// eslint-disable-next-line no-underscore-dangle, no-restricted-globals
|
||||
precacheAndRoute(self.__WB_MANIFEST);
|
||||
|
||||
const navigationRoute = new NavigationRoute(new NetworkFirst({
|
||||
cacheName: 'navigations',
|
||||
}));
|
||||
|
||||
const imageAssetRoute = new Route(({ request }) => request.destination === 'image', new CacheFirst({
|
||||
cacheName: 'image-assets',
|
||||
}));
|
||||
|
||||
registerRoute(navigationRoute);
|
||||
registerRoute(imageAssetRoute);
|
||||
|
||||
registerRoute(
|
||||
({ url }) => url.origin === 'https://fonts.googleapis.com',
|
||||
new StaleWhileRevalidate({
|
||||
cacheName: 'google-fonts-stylesheets',
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user