diff --git a/angular.json b/angular.json index 07c1e9e..ffc444a 100644 --- a/angular.json +++ b/angular.json @@ -57,7 +57,8 @@ "maximumError": "8kB" } ], - "outputHashing": "all" + "outputHashing": "all", + "serviceWorker": "ngsw-config.json" }, "development": { "optimization": false, diff --git a/ngsw-config.json b/ngsw-config.json new file mode 100644 index 0000000..69edd28 --- /dev/null +++ b/ngsw-config.json @@ -0,0 +1,30 @@ +{ + "$schema": "./node_modules/@angular/service-worker/config/schema.json", + "index": "/index.html", + "assetGroups": [ + { + "name": "app", + "installMode": "prefetch", + "resources": { + "files": [ + "/favicon.ico", + "/index.csr.html", + "/index.html", + "/manifest.webmanifest", + "/*.css", + "/*.js" + ] + } + }, + { + "name": "assets", + "installMode": "lazy", + "updateMode": "prefetch", + "resources": { + "files": [ + "/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)" + ] + } + } + ] +} diff --git a/package-lock.json b/package-lock.json index 6f52c01..fe8a2a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@angular/forms": "^21.0.0", "@angular/platform-browser": "^21.0.0", "@angular/router": "^21.0.0", + "@angular/service-worker": "^21.0.6", "angular-web-sqlite": "^1.0.34", "rxjs": "~7.8.0", "tslib": "^2.3.0" @@ -602,6 +603,25 @@ "rxjs": "^6.5.3 || ^7.4.0" } }, + "node_modules/@angular/service-worker": { + "version": "21.0.6", + "resolved": "https://registry.npmjs.org/@angular/service-worker/-/service-worker-21.0.6.tgz", + "integrity": "sha512-/T1aHc7ys3in7qTGO8MLIHvoXumMPxv7vU1C1sKbK14mw8ahwuqYo8m2Y+f6/ZcYwUZIbN3Ipd9sHEEB7VCz3A==", + "license": "MIT", + "dependencies": { + "tslib": "^2.3.0" + }, + "bin": { + "ngsw-config": "ngsw-config.js" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@angular/core": "21.0.6", + "rxjs": "^6.5.3 || ^7.4.0" + } + }, "node_modules/@asamuzakjp/css-color": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-4.1.1.tgz", diff --git a/package.json b/package.json index a27e401..07cec7a 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@angular/forms": "^21.0.0", "@angular/platform-browser": "^21.0.0", "@angular/router": "^21.0.0", + "@angular/service-worker": "^21.0.6", "angular-web-sqlite": "^1.0.34", "rxjs": "~7.8.0", "tslib": "^2.3.0" diff --git a/public/icons/icon-128x128.png b/public/icons/icon-128x128.png new file mode 100644 index 0000000..d402cb9 Binary files /dev/null and b/public/icons/icon-128x128.png differ diff --git a/public/icons/icon-144x144.png b/public/icons/icon-144x144.png new file mode 100644 index 0000000..6433529 Binary files /dev/null and b/public/icons/icon-144x144.png differ diff --git a/public/icons/icon-152x152.png b/public/icons/icon-152x152.png new file mode 100644 index 0000000..fe0495e Binary files /dev/null and b/public/icons/icon-152x152.png differ diff --git a/public/icons/icon-192x192.png b/public/icons/icon-192x192.png new file mode 100644 index 0000000..1bab76b Binary files /dev/null and b/public/icons/icon-192x192.png differ diff --git a/public/icons/icon-384x384.png b/public/icons/icon-384x384.png new file mode 100644 index 0000000..8532df9 Binary files /dev/null and b/public/icons/icon-384x384.png differ diff --git a/public/icons/icon-48x48.png b/public/icons/icon-48x48.png new file mode 100644 index 0000000..e69657d Binary files /dev/null and b/public/icons/icon-48x48.png differ diff --git a/public/icons/icon-512x512.png b/public/icons/icon-512x512.png new file mode 100644 index 0000000..db72509 Binary files /dev/null and b/public/icons/icon-512x512.png differ diff --git a/public/icons/icon-72x72.png b/public/icons/icon-72x72.png new file mode 100644 index 0000000..64f0886 Binary files /dev/null and b/public/icons/icon-72x72.png differ diff --git a/public/icons/icon-96x96.png b/public/icons/icon-96x96.png new file mode 100644 index 0000000..35d025a Binary files /dev/null and b/public/icons/icon-96x96.png differ diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest new file mode 100644 index 0000000..4aaba9b --- /dev/null +++ b/public/manifest.webmanifest @@ -0,0 +1,64 @@ +{ + "name": "Groceries price tracker", + "background_color": "#ffffff", + "short_name": "Price tracker", + "display": "standalone", + "scope": "./", + "start_url": "./", + "icons": [ + { + "src": "icons/icon-48x48.png", + "sizes": "48x48", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-72x72.png", + "sizes": "72x72", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-96x96.png", + "sizes": "96x96", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-128x128.png", + "sizes": "128x128", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-144x144.png", + "sizes": "144x144", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-152x152.png", + "sizes": "152x152", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-384x384.png", + "sizes": "384x384", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable any" + } + ] +} diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 6b5672e..670fcd3 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -1,10 +1,16 @@ -import { ApplicationConfig, inject, provideAppInitializer, provideBrowserGlobalErrorListeners } from '@angular/core'; +import { + ApplicationConfig, + inject, + provideAppInitializer, + provideBrowserGlobalErrorListeners, + isDevMode, +} from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; import { WebSqlite } from 'angular-web-sqlite'; import { Sqlite } from './services/sqlite'; import { tables } from '../migrations/20260117'; - +import { provideServiceWorker } from '@angular/service-worker'; export const appConfig: ApplicationConfig = { providers: [ @@ -15,8 +21,12 @@ export const appConfig: ApplicationConfig = { await sqlite.executeQuery('PRAGMA foreign_keys = ON;'); document.dispatchEvent(new CustomEvent('ng-boot')); }), - {provide: WebSqlite, useClass: WebSqlite}, + { provide: WebSqlite, useClass: WebSqlite }, provideBrowserGlobalErrorListeners(), - provideRouter(routes) - ] + provideRouter(routes), + provideServiceWorker('ngsw-worker.js', { + enabled: !isDevMode(), + registrationStrategy: 'registerWhenStable:30000', + }), + ], }; diff --git a/src/index.html b/src/index.html index 0ce60b1..055e367 100644 --- a/src/index.html +++ b/src/index.html @@ -6,6 +6,7 @@ + @@ -16,5 +17,6 @@ document.querySelector('scan-loading-screen').remove(); }) +