diff --git a/.cursor/rules/architectural_decision_record.mdc b/.cursor/rules/architectural_decision_record.mdc index d78a0f23..fdc53c60 100644 --- a/.cursor/rules/architectural_decision_record.mdc +++ b/.cursor/rules/architectural_decision_record.mdc @@ -149,7 +149,7 @@ export function createBuildConfig(mode: string) { return { define: { 'process.env.VITE_PLATFORM': JSON.stringify(mode), - 'process.env.VITE_PWA_ENABLED': JSON.stringify(!isNative), + // PWA is automatically enabled for web platforms via build configuration __IS_MOBILE__: JSON.stringify(isCapacitor), __USE_QR_READER__: JSON.stringify(!isCapacitor) } diff --git a/.env.development b/.env.development index 420490a5..e9628ae4 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1 @@ VITE_DEFAULT_ENDORSER_API_SERVER=http://127.0.0.1:3000 -VITE_PWA_ENABLED=true diff --git a/.env.production b/.env.production index e6be236e..bbf73a08 100644 --- a/.env.production +++ b/.env.production @@ -10,4 +10,3 @@ VITE_DEFAULT_ENDORSER_API_SERVER=https://api.endorser.ch VITE_DEFAULT_IMAGE_API_SERVER=https://image-api.timesafari.app VITE_DEFAULT_PARTNER_API_SERVER=https://partner-api.endorser.ch VITE_DEFAULT_PUSH_SERVER=https://timesafari.app -VITE_PWA_ENABLED=true diff --git a/.env.test b/.env.test index ec1cfdfa..a01c323c 100644 --- a/.env.test +++ b/.env.test @@ -11,4 +11,3 @@ VITE_DEFAULT_IMAGE_API_SERVER=https://test-image-api.timesafari.app VITE_DEFAULT_PARTNER_API_SERVER=https://test-partner-api.endorser.ch VITE_DEFAULT_PUSH_SERVER=https://test.timesafari.app VITE_PASSKEYS_ENABLED=true -VITE_PWA_ENABLED=false diff --git a/dev-dist/sw.js b/dev-dist/sw.js index 16f4ba71..fa679426 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.qptlo5ufc6o" + "revision": "0.6n0ha79iivo" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/dev-dist/sw.js.map b/dev-dist/sw.js.map index 27b343a9..522621e0 100644 --- a/dev-dist/sw.js.map +++ b/dev-dist/sw.js.map @@ -1 +1 @@ -{"version":3,"file":"sw.js","sources":["../../../../../tmp/fdcc5e063da6e933f47f5dfe0802a72e/sw.js"],"sourcesContent":["import {clientsClaim as workbox_core_clientsClaim} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {cleanupOutdatedCaches as workbox_precaching_cleanupOutdatedCaches} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-precaching/cleanupOutdatedCaches.mjs';\nimport {registerRoute as workbox_routing_registerRoute} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-routing/registerRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"registerSW.js\",\n \"revision\": \"3ca0b8505b4bec776b69afdba2768812\"\n },\n {\n \"url\": \"index.html\",\n \"revision\": \"0.qptlo5ufc6o\"\n }\n], {});\nworkbox_precaching_cleanupOutdatedCaches();\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"index.html\"), {\n allowlist: [/^\\/$/],\n \n}));\n\n\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","workbox_precaching_cleanupOutdatedCaches","workbox_routing_registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerBoundToURL","allowlist"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBAA,CAAI,CAAA,CAAA,CAAA,CAACC,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAA;AAElBC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAyB,EAAE,CAAA;;AAG3B,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,CAAA,CAAA,CAAA,CAA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AA,CAAA,CAAA,CAAA;EACnB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,EAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACd,CAAA,CAAA,CAAC,CACF,CAAA,CAAE,CAAE,CAAA,CAAC,CAAA;AACNC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAwC,EAAE,CAAA;AAC1CC,CAA6B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,IAAIC,CAA+B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAACC,+BAA0C,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAC,CAAE,CAAA,CAAA;IAC1HC,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA;AAEpB,CAAA,CAAA,CAAC,CAAC,CAAC,CAAA;;"} \ No newline at end of file +{"version":3,"file":"sw.js","sources":["../../../../../tmp/100524a8f29de2d06cb347c5726e62b0/sw.js"],"sourcesContent":["import {clientsClaim as workbox_core_clientsClaim} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-core/clientsClaim.mjs';\nimport {precacheAndRoute as workbox_precaching_precacheAndRoute} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-precaching/precacheAndRoute.mjs';\nimport {cleanupOutdatedCaches as workbox_precaching_cleanupOutdatedCaches} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-precaching/cleanupOutdatedCaches.mjs';\nimport {registerRoute as workbox_routing_registerRoute} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-routing/registerRoute.mjs';\nimport {NavigationRoute as workbox_routing_NavigationRoute} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-routing/NavigationRoute.mjs';\nimport {createHandlerBoundToURL as workbox_precaching_createHandlerBoundToURL} from '/home/noone/projects/timesafari/crowd-master/node_modules/workbox-precaching/createHandlerBoundToURL.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"registerSW.js\",\n \"revision\": \"3ca0b8505b4bec776b69afdba2768812\"\n },\n {\n \"url\": \"index.html\",\n \"revision\": \"0.6n0ha79iivo\"\n }\n], {});\nworkbox_precaching_cleanupOutdatedCaches();\nworkbox_routing_registerRoute(new workbox_routing_NavigationRoute(workbox_precaching_createHandlerBoundToURL(\"index.html\"), {\n allowlist: [/^\\/$/],\n \n}));\n\n\n\n\n\n\n"],"names":["self","skipWaiting","workbox_core_clientsClaim","workbox_precaching_precacheAndRoute","workbox_precaching_cleanupOutdatedCaches","workbox_routing_registerRoute","workbox_routing_NavigationRoute","workbox_precaching_createHandlerB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AAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAwC,EAAE,CAAA;AAC1CC,CAA6B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,IAAIC,CAA+B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAACC,+BAA0C,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAC,CAAE,CAAA,CAAA;IAC1HC,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA;AAEpB,CAAA,CAAA,CAAC,CAAC,CAAC,CAAA;;"} \ No newline at end of file diff --git a/doc/qr-code-implementation-guide.md b/doc/qr-code-implementation-guide.md index e6e36fcd..13405160 100644 --- a/doc/qr-code-implementation-guide.md +++ b/doc/qr-code-implementation-guide.md @@ -168,7 +168,7 @@ export async function createBuildConfig(mode: string) { return defineConfig({ define: { 'process.env.VITE_PLATFORM': JSON.stringify(mode), - 'process.env.VITE_PWA_ENABLED': JSON.stringify(!isNative), + // PWA is automatically enabled for web platforms via build configuration __IS_MOBILE__: JSON.stringify(isCapacitor), __USE_QR_READER__: JSON.stringify(!isCapacitor) }, diff --git a/docker/README.md b/docker/README.md index d28f52bf..b79a8b6d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -72,7 +72,7 @@ docker build --build-arg BUILD_MODE=development -t timesafari:dev . docker build \ --build-arg BUILD_MODE=staging \ --build-arg NODE_ENV=staging \ - --build-arg VITE_PWA_ENABLED=true \ + -t timesafari:custom . ``` @@ -103,8 +103,7 @@ The Dockerfile supports these build arguments: | `BUILD_MODE` | `production` | Build mode: development, staging, or production | | `NODE_ENV` | `production` | Node.js environment | | `VITE_PLATFORM` | `web` | Vite platform type | -| `VITE_PWA_ENABLED` | `true` | Enable PWA features | -| `VITE_DISABLE_PWA` | `false` | Disable PWA features | +| PWA | `enabled` | Automatically enabled for web platforms | ### Environment Variables @@ -115,8 +114,7 @@ Docker Compose supports these environment variables: | `BUILD_MODE` | `production` | Build mode | | `NODE_ENV` | `production` | Node environment | | `VITE_PLATFORM` | `web` | Vite platform | -| `VITE_PWA_ENABLED` | `true` | Enable PWA | -| `VITE_DISABLE_PWA` | `false` | Disable PWA | +| PWA | `enabled` | Automatically enabled for web platforms | | `DEV_PORT` | `5173` | Development port | | `STAGING_PORT` | `8080` | Staging port | | `PROD_PORT` | `80` | Production port | @@ -214,7 +212,7 @@ BUILD_MODE=staging NODE_ENV=staging ./docker/run.sh custom docker build \ --build-arg BUILD_MODE=staging \ --build-arg NODE_ENV=staging \ - --build-arg VITE_PWA_ENABLED=false \ + -t timesafari:staging-no-pwa . # Run with custom configuration diff --git a/docker/run.sh b/docker/run.sh index 641b8947..7353a572 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -13,8 +13,7 @@ # BUILD_MODE: development, staging, or production # NODE_ENV: node environment # VITE_PLATFORM: vite platform -# VITE_PWA_ENABLED: enable PWA -# VITE_DISABLE_PWA: disable PWA +# PWA: automatically enabled for web platforms # PORT: port to expose # ENV_FILE: environment file to use @@ -72,8 +71,7 @@ show_usage() { echo " BUILD_MODE: development, staging, or production" echo " NODE_ENV: node environment" echo " VITE_PLATFORM: vite platform" - echo " VITE_PWA_ENABLED: enable PWA" - echo " VITE_DISABLE_PWA: disable PWA" + echo " PWA: automatically enabled for web platforms" echo " PORT: port to expose" echo " ENV_FILE: environment file to use" } @@ -88,8 +86,7 @@ show_build_args() { echo " BUILD_MODE: development" echo " NODE_ENV: development" echo " VITE_PLATFORM: web" - echo " VITE_PWA_ENABLED: true" - echo " VITE_DISABLE_PWA: false" + echo " PWA: enabled (web platform)" echo " Target: development" echo " Port: 5173" ;; @@ -97,8 +94,7 @@ show_build_args() { echo " BUILD_MODE: staging" echo " NODE_ENV: staging" echo " VITE_PLATFORM: web" - echo " VITE_PWA_ENABLED: true" - echo " VITE_DISABLE_PWA: false" + echo " PWA: enabled (web platform)" echo " Target: staging" echo " Port: 80 (mapped to 8080)" ;; @@ -106,8 +102,7 @@ show_build_args() { echo " BUILD_MODE: production" echo " NODE_ENV: production" echo " VITE_PLATFORM: web" - echo " VITE_PWA_ENABLED: true" - echo " VITE_DISABLE_PWA: false" + echo " PWA: enabled (web platform)" echo " Target: production" echo " Port: 80" ;; @@ -115,8 +110,7 @@ show_build_args() { echo " BUILD_MODE: \${BUILD_MODE:-production}" echo " NODE_ENV: \${NODE_ENV:-production}" echo " VITE_PLATFORM: \${VITE_PLATFORM:-web}" - echo " VITE_PWA_ENABLED: \${VITE_PWA_ENABLED:-true}" - echo " VITE_DISABLE_PWA: \${VITE_DISABLE_PWA:-false}" + echo " PWA: enabled for web platforms" echo " Target: \${BUILD_TARGET:-production}" echo " Port: \${CUSTOM_PORT:-8080}:\${CUSTOM_INTERNAL_PORT:-80}" ;; diff --git a/docs/build-systems-overview.md b/docs/build-systems-overview.md index 39d8be5a..ddd8dc91 100644 --- a/docs/build-systems-overview.md +++ b/docs/build-systems-overview.md @@ -38,7 +38,7 @@ All build scripts follow a consistent pattern: ```bash # Set platform-specific environment variables VITE_PLATFORM= -VITE_PWA_ENABLED= +PWA: automatically enabled for web platforms VITE_GIT_HASH= ``` @@ -212,8 +212,7 @@ All build systems use consistent environment variable patterns: VITE_PLATFORM=web|capacitor|electron # PWA configuration -VITE_PWA_ENABLED=true|false -VITE_DISABLE_PWA=true|false +PWA: automatically enabled for web platforms # Build information VITE_GIT_HASH= @@ -396,7 +395,7 @@ xcrun devicectl list devices ```bash # Verify environment variables echo $VITE_PLATFORM -echo $VITE_PWA_ENABLED +echo "PWA: automatically enabled for web platforms" # Check environment files ls -la .env* diff --git a/docs/build-troubleshooting.md b/docs/build-troubleshooting.md index a03df18c..13b1d35e 100644 --- a/docs/build-troubleshooting.md +++ b/docs/build-troubleshooting.md @@ -22,7 +22,7 @@ npx vite --version # Check environment variables echo $VITE_PLATFORM -echo $VITE_PWA_ENABLED +echo "PWA: automatically enabled for web platforms" ``` ### Build System Status @@ -75,8 +75,8 @@ npm run build:web:dev # Clear browser cache # DevTools > Application > Storage > Clear site data -# Restart with PWA disabled -VITE_DISABLE_PWA=true npm run build:web:dev +# Restart development server +npm run build:web:dev ``` ### Production Build Issues @@ -414,11 +414,10 @@ ls -la .env* # Set required variables export VITE_PLATFORM=web -export VITE_PWA_ENABLED=true # Check in build script echo $VITE_PLATFORM -echo $VITE_PWA_ENABLED +echo "PWA: automatically enabled for web platforms" ``` #### Wrong Environment Loaded diff --git a/docs/pwa-build-analysis.md b/docs/pwa-build-analysis.md new file mode 100644 index 00000000..0d0d1ca4 --- /dev/null +++ b/docs/pwa-build-analysis.md @@ -0,0 +1,289 @@ +# PWA Build Analysis - Web Environments + +**Date**: July 15, 2025 +**Author**: Matthew Raymer +**Scope**: Web builds across dev, test, and prod environments + +## Executive Summary + +The TimeSafari application has comprehensive PWA (Progressive Web App) support configured across all web build environments. **PWA functionality is now always enabled for web platforms**, removing the previous environment-specific toggle mechanism. The PWA features are properly integrated and provide consistent functionality across all web builds. + +## PWA Configuration Overview + +### Core PWA Setup +- **Plugin**: `vite-plugin-pwa` with `VitePWA` configuration +- **Service Worker**: Custom service worker with Workbox integration +- **Manifest**: Dynamic PWA manifest with environment-specific settings +- **Registration**: Auto-update registration type +- **Status**: ✅ **Always enabled for web platforms** + +### Environment-Specific PWA Status + +| Environment | PWA Status | Dev Options | Service Worker | Manifest | Install Prompt | +|-------------|------------|-------------|----------------|----------|----------------| +| **Development** | ✅ Always Enabled | ✅ `enabled: true` | ✅ Active | ✅ Generated | ✅ Available | +| **Test** | ✅ Always Enabled | ✅ `enabled: true` | ✅ Active | ✅ Generated | ✅ Available | +| **Production** | ✅ Always Enabled | ✅ `enabled: true` | ✅ Active | ✅ Generated | ✅ Available | + +## Detailed Environment Analysis + +### Development Environment (`.env.development`) + +**Configuration**: +```bash +VITE_DEFAULT_ENDORSER_API_SERVER=http://127.0.0.1:3000 +``` + +**PWA Features**: +- ✅ **Full PWA Support**: Always enabled for development testing +- ✅ **Service Worker**: Active with development optimizations +- ✅ **Manifest**: Generated with development settings +- ✅ **Install Prompt**: Available for testing PWA installation +- ✅ **Dev Options**: `enabled: true` for consistent testing + +**Build Command**: +```bash +npm run build:web:dev +# or +./scripts/build-web.sh --dev +``` + +### Test Environment (`.env.test`) + +**Configuration**: +```bash +VITE_APP_SERVER=https://test.timesafari.app +VITE_DEFAULT_ENDORSER_API_SERVER=https://test-api.endorser.ch +``` + +**PWA Features**: +- ✅ **Full PWA Support**: Always enabled for test environment +- ✅ **Service Worker**: Active with test optimizations +- ✅ **Manifest**: Generated and fully utilized +- ✅ **Install Prompt**: Available for test installations +- ✅ **Dev Options**: Enabled for debugging + +**Build Command**: +```bash +npm run build:web:test +# or +./scripts/build-web.sh --test +``` + +### Production Environment (`.env.production`) + +**Configuration**: +```bash +VITE_APP_SERVER=https://timesafari.app +VITE_DEFAULT_ENDORSER_API_SERVER=https://api.endorser.ch +``` + +**PWA Features**: +- ✅ **Full PWA Support**: Always enabled for production users +- ✅ **Service Worker**: Active with production optimizations +- ✅ **Manifest**: Generated with production settings +- ✅ **Install Prompt**: Available for user installations +- ✅ **Dev Options**: Enabled for production debugging + +**Build Command**: +```bash +npm run build:web:prod +# or +./scripts/build-web.sh --prod +``` + +## Technical Implementation + +### Vite Configuration (`vite.config.web.mts`) + +```typescript +VitePWA({ + registerType: 'autoUpdate', + manifest: appConfig.pwaConfig?.manifest, + // Enable PWA in all web environments for consistent testing + devOptions: { + enabled: true, // ✅ Enable in all environments + type: 'module' + }, + workbox: { + cleanupOutdatedCaches: true, + skipWaiting: true, + clientsClaim: true, + sourcemap: mode !== 'production', + maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10MB + // Environment-specific caching strategies + runtimeCaching: mode === 'production' ? [ + { + urlPattern: /^https:\/\/api\./, + handler: 'NetworkFirst', + options: { + cacheName: 'api-cache', + expiration: { + maxEntries: 100, + maxAgeSeconds: 60 * 60 * 24 // 24 hours + } + } + } + ] : [] + } +}) +``` + +### PWA Manifest Configuration (`vite.config.utils.mts`) + +```typescript +manifest: { + name: appName, + short_name: appName, + theme_color: "#4a90e2", + background_color: "#ffffff", + icons: [ + { + src: "./img/icons/android-chrome-192x192.png", + sizes: "192x192", + type: "image/png", + }, + { + src: "./img/icons/android-chrome-512x512.png", + sizes: "512x512", + type: "image/png", + }, + { + src: "./img/icons/android-chrome-maskable-192x192.png", + sizes: "192x192", + type: "image/png", + purpose: "maskable", + }, + { + src: "./img/icons/android-chrome-maskable-512x512.png", + sizes: "512x512", + type: "image/png", + purpose: "maskable", + }, + ], + share_target: { + action: "/share-target", + method: "POST", + enctype: "multipart/form-data", + params: { + files: [ + { + name: "photo", + accept: ["image/*"], + }, + ], + }, + }, +} +``` + +## Build Process Analysis + +### Environment Detection +The build system automatically detects the environment and applies appropriate PWA settings: + +1. **Environment Files**: `.env.development`, `.env.test`, `.env.production` +2. **Vite Mode**: Passed via `--mode` parameter +3. **PWA Status**: Always enabled for web platforms (no longer environment-dependent) +4. **Dev Options**: Always enabled for consistent testing + +### Build Script Integration +The `build-web.sh` script properly handles environment setup: + +```bash +# Environment-specific configuration +case $BUILD_MODE in + "production") + export NODE_ENV="production" + ;; + "test") + export NODE_ENV="test" + ;; + "development"|*) + export NODE_ENV="development" + ;; +esac + +# Load environment-specific .env file +local env_file=".env.$BUILD_MODE" +if [ -f "$env_file" ]; then + load_env_file "$env_file" +fi +``` + +## PWA Features by Environment + +### Development Features +- **Hot Reload**: Service worker updates automatically +- **Debug Mode**: Full PWA functionality for testing +- **Local Testing**: Install prompt available +- **Development Server**: PWA features work on localhost + +### Test Features +- **Full PWA**: Complete PWA functionality for testing +- **Service Worker**: Active with test optimizations +- **Manifest**: Generated and fully utilized +- **Install Prompt**: Available for test installations + +### Production Features +- **Full PWA**: Complete Progressive Web App functionality +- **Service Worker**: Production-optimized caching +- **Install Prompt**: Available for user installations +- **API Caching**: Network-first strategy for API calls +- **Offline Support**: Cached resources for offline use + +## Recent Changes + +### PWA Always Enabled +- **Removed**: `VITE_PWA_ENABLED` environment variable (no longer used) +- **Updated**: Service worker registration to always run +- **Simplified**: PWA component logic +- **Consistent**: PWA behavior across all environments + +### Updated Files +- `vite.config.common.mts`: Removed PWA toggle logic +- `src/registerServiceWorker.ts`: Removed (VitePWA handles registration automatically) +- `src/main.web.ts`: Always import service worker +- `src/components/PWAInstallPrompt.vue`: Removed PWA check +- `src/services/platforms/WebPlatformService.ts`: Always return true for PWA +- `scripts/common.sh`: Removed VITE_PWA_ENABLED setting +- Environment files: Removed VITE_PWA_ENABLED variables +- Vite configs: Removed VITE_PWA_ENABLED and VITE_DISABLE_PWA assignments + +## Recommendations + +### Current State Assessment +✅ **Excellent**: PWA is properly configured and always enabled for web +✅ **Consistent**: Same PWA functionality across all environments +✅ **Simplified**: Removed unnecessary conditional logic +✅ **Reliable**: No environment-specific PWA toggles + +### Potential Improvements +1. **Test Environment**: Consider PWA-specific test scenarios +2. **Caching Strategy**: Review API caching for all environments +3. **Manifest Icons**: Ensure all icon sizes are optimized +4. **Service Worker**: Add more sophisticated offline strategies + +### Monitoring Considerations +1. **Installation Metrics**: Track PWA installations across environments +2. **Service Worker Performance**: Monitor cache hit rates +3. **Offline Usage**: Analyze offline functionality usage +4. **Update Success**: Monitor service worker update success rates + +## Conclusion + +The TimeSafari web build system now has **simplified and consistent PWA support** across all environments. PWA functionality is controlled entirely through build-time configuration: + +- **Web platforms**: PWA is always enabled via `vite.config.web.mts` plugin inclusion +- **Native platforms**: PWA is disabled via build-time package exclusion in `vite.config.common.mts` +- **No environment variables**: Removed redundant `VITE_PWA_ENABLED` and `VITE_DISABLE_PWA` variables + +This approach provides a more reliable and predictable user experience with cleaner configuration. + +The implementation follows best practices with proper environment detection, consistent PWA enabling, and comprehensive service worker configuration. The PWA features are well-integrated into the build process and provide a solid foundation for progressive web app functionality across all web environments. + +--- + +**Analysis Date**: July 15, 2025 +**Status**: ✅ PWA always enabled for web platforms +**Next Review**: After major PWA feature updates \ No newline at end of file diff --git a/experiment.sh b/experiment.sh index bd2d7e97..ecfdaed6 100755 --- a/experiment.sh +++ b/experiment.sh @@ -92,8 +92,8 @@ rm -rf dist* || log_warn "No previous builds to clean" # Set environment variables for the build log_info "Configuring build environment..." export VITE_PLATFORM=electron -export VITE_PWA_ENABLED=false -export VITE_DISABLE_PWA=true + + export DEBUG_MIGRATIONS=0 # Ensure TypeScript is installed diff --git a/scripts/common.sh b/scripts/common.sh index 47c5c6b8..3d27f19b 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -178,27 +178,19 @@ setup_build_env() { case $build_type in "capacitor") export VITE_PLATFORM=capacitor - export VITE_PWA_ENABLED=false - export VITE_DISABLE_PWA=true export DEBUG_MIGRATIONS=0 ;; "electron") export VITE_PLATFORM=electron - export VITE_PWA_ENABLED=false - export VITE_DISABLE_PWA=true export DEBUG_MIGRATIONS=0 ;; "web") export VITE_PLATFORM=web - export VITE_PWA_ENABLED=true - export VITE_DISABLE_PWA=false export DEBUG_MIGRATIONS=0 ;; *) log_warn "Unknown build type: $build_type, using default environment" export VITE_PLATFORM=web - export VITE_PWA_ENABLED=true - export VITE_DISABLE_PWA=false export DEBUG_MIGRATIONS=0 ;; esac @@ -206,8 +198,6 @@ setup_build_env() { # Log environment setup log_debug "Environment variables set:" log_debug " VITE_PLATFORM=$VITE_PLATFORM" - log_debug " VITE_PWA_ENABLED=$VITE_PWA_ENABLED" - log_debug " VITE_DISABLE_PWA=$VITE_DISABLE_PWA" log_debug " DEBUG_MIGRATIONS=$DEBUG_MIGRATIONS" if [ -n "$NODE_ENV" ]; then log_debug " NODE_ENV=$NODE_ENV" diff --git a/src/components/PWAInstallPrompt.vue b/src/components/PWAInstallPrompt.vue index a1da3a1c..c99f0476 100644 --- a/src/components/PWAInstallPrompt.vue +++ b/src/components/PWAInstallPrompt.vue @@ -79,12 +79,6 @@ export default class PWAInstallPrompt extends Vue { } private setupInstallPrompt() { - // Only show install prompt if PWA is enabled - if (process.env.VITE_PWA_ENABLED !== "true") { - logger.debug("[PWA] Install prompt disabled - PWA not enabled"); - return; - } - // Check if already installed if (this.isPWAInstalled()) { logger.debug("[PWA] Install prompt disabled - PWA already installed"); @@ -95,9 +89,6 @@ export default class PWAInstallPrompt extends Vue { window.addEventListener('beforeinstallprompt', (e) => { logger.debug("[PWA] beforeinstallprompt event fired"); - // Prevent the mini-infobar from appearing on mobile - e.preventDefault(); - // Stash the event so it can be triggered later this.deferredPrompt = e as BeforeInstallPromptEvent; diff --git a/src/libs/fontawesome.ts b/src/libs/fontawesome.ts index 2fa70e3c..8c36ee14 100644 --- a/src/libs/fontawesome.ts +++ b/src/libs/fontawesome.ts @@ -36,6 +36,7 @@ import { faComment, faCopy, faDollar, + faDownload, faEllipsis, faEllipsisVertical, faEnvelopeOpenText, @@ -121,6 +122,7 @@ library.add( faComment, faCopy, faDollar, + faDownload, faEllipsis, faEllipsisVertical, faEnvelopeOpenText, diff --git a/src/main.web.ts b/src/main.web.ts index ff7e2097..5ceebdd6 100644 --- a/src/main.web.ts +++ b/src/main.web.ts @@ -2,12 +2,8 @@ import { initializeApp } from "./main.common"; import { logger } from "./utils/logger"; const platform = process.env.VITE_PLATFORM; -const pwa_enabled = process.env.VITE_PWA_ENABLED === "true"; -// Only import service worker for web builds -if (pwa_enabled) { - import("./registerServiceWorker"); // Web PWA support -} +// PWA service worker is automatically registered by VitePWA plugin const app = initializeApp(); diff --git a/src/registerServiceWorker.ts b/src/registerServiceWorker.ts deleted file mode 100644 index c5d894a0..00000000 --- a/src/registerServiceWorker.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* eslint-disable no-console */ - -import { register } from "register-service-worker"; - -// Register service worker if PWA is enabled -// Enable in all environments for consistent testing and functionality -if (process.env.VITE_PWA_ENABLED === "true") { - register(`${process.env.BASE_URL}sw.js`, { - ready() { - console.log("Service worker is active."); - }, - registered() { - console.log("Service worker has been registered."); - }, - cached() { - console.log("Content has been cached for offline use."); - }, - updatefound() { - console.log("New content is downloading."); - }, - updated() { - console.log("New content is available; please refresh."); - }, - offline() { - console.log( - "No internet connection found. App is running in offline mode.", - ); - }, - error(error) { - console.error("Error during service worker registration:", error); - }, - }); -} else { - console.log( - `Service worker registration skipped - PWA not enabled (VITE_PWA_ENABLED=${process.env.VITE_PWA_ENABLED})`, - ); -} diff --git a/src/services/platforms/WebPlatformService.ts b/src/services/platforms/WebPlatformService.ts index b25c7920..854eb7d0 100644 --- a/src/services/platforms/WebPlatformService.ts +++ b/src/services/platforms/WebPlatformService.ts @@ -647,13 +647,13 @@ export class WebPlatformService implements PlatformService { // --- PWA/Web-only methods --- public registerServiceWorker(): void { - if (this.isPWAEnabled) { - import("@/registerServiceWorker"); - } + // PWA service worker is automatically registered by VitePWA plugin + // No manual registration needed } public get isPWAEnabled(): boolean { - return process.env.VITE_PWA_ENABLED === "true"; + // PWA is always enabled for web platform + return true; } /** diff --git a/vite.config.common.mts b/vite.config.common.mts index ecbfe693..0bca2e19 100644 --- a/vite.config.common.mts +++ b/vite.config.common.mts @@ -17,17 +17,8 @@ export async function createBuildConfig(platform: string): Promise { const isElectron = platform === "electron"; const isNative = isCapacitor || isElectron; - // Set platform and configure PWA based on environment or platform + // Set platform - PWA is always enabled for web platforms process.env.VITE_PLATFORM = platform; - - // Use .env file value if set, otherwise default based on platform - if (process.env.VITE_PWA_ENABLED === undefined) { - process.env.VITE_PWA_ENABLED = isNative ? 'false' : 'true'; - } - - if (isNative) { - process.env.VITE_PWA_ENABLED = 'false'; - } return { base: "/", @@ -63,7 +54,7 @@ export async function createBuildConfig(platform: string): Promise { define: { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), 'process.env.VITE_PLATFORM': JSON.stringify(platform), - 'process.env.VITE_PWA_ENABLED': JSON.stringify(!isNative), + // PWA is always enabled for web platforms __dirname: JSON.stringify(process.cwd()), __IS_MOBILE__: JSON.stringify(isCapacitor), __IS_ELECTRON__: JSON.stringify(isElectron), diff --git a/vite.config.electron.mts b/vite.config.electron.mts index e387e7d5..dc54dacd 100644 --- a/vite.config.electron.mts +++ b/vite.config.electron.mts @@ -20,8 +20,7 @@ * * Environment Variables: * - VITE_PLATFORM: Set to "electron" - * - VITE_PWA_ENABLED: Disabled for desktop - * - VITE_DISABLE_PWA: Enabled for desktop + * - PWA: Disabled for desktop (via build exclusion) */ import { defineConfig } from "vite"; @@ -140,8 +139,8 @@ export default defineConfig(async () => { define: { ...baseConfig.define, 'process.env.VITE_PLATFORM': JSON.stringify('electron'), - 'process.env.VITE_PWA_ENABLED': JSON.stringify(false), - 'process.env.VITE_DISABLE_PWA': JSON.stringify(true), + + // Electron-specific flags '__ELECTRON__': JSON.stringify(true), '__IS_DESKTOP__': JSON.stringify(true), diff --git a/vite.config.optimized.mts b/vite.config.optimized.mts index a2b22a2a..61a31a8a 100644 --- a/vite.config.optimized.mts +++ b/vite.config.optimized.mts @@ -24,14 +24,8 @@ export async function createOptimizedBuildConfig(mode: string): Promise { // Enable PWA in all web environments for consistent testing devOptions: { enabled: true, // ✅ Enable in all environments - type: 'module' + type: 'classic' }, workbox: { cleanupOutdatedCaches: true,