From d24b6c0c41ce5795ff13067cb06f92771bfa8bdb Mon Sep 17 00:00:00 2001 From: timbretimber <105982513+timbretimber@users.noreply.github.com> Date: Sun, 19 Apr 2026 15:23:12 -0600 Subject: [PATCH 1/3] Add offline PWA functionality with VitePWA --- package.json | 3 +- public/site.webmanifest | 21 ---------- vite.config.ts | 87 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 22 deletions(-) delete mode 100644 public/site.webmanifest diff --git a/package.json b/package.json index 16234fb42..22a226fba 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "husky": "^8.0.3", "typescript": "^5.6.2", "vite": "^4.1.4", - "vite-plugin-html": "^3.2.0" + "vite-plugin-html": "^3.2.0", + "vite-plugin-pwa": "^1.2.0" } } \ No newline at end of file diff --git a/public/site.webmanifest b/public/site.webmanifest deleted file mode 100644 index cf1e19ba1..000000000 --- a/public/site.webmanifest +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "VIA", - "short_name": "VIA", - "description": "VIA - Your keyboard's best friend", - "start_url": ".", - "icons": [ - { - "src": "/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "/android-chrome-512x512.png", - "sizes": "512x512", - "type": "image/png" - } - ], - "theme_color": "#dadada", - "background_color": "#dadada", - "display": "standalone" -} diff --git a/vite.config.ts b/vite.config.ts index f8e28af0a..b7f5dbf88 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react'; import path from 'path'; import {splitVendorChunkPlugin} from 'vite'; import {createHtmlPlugin} from 'vite-plugin-html'; +import {VitePWA} from 'vite-plugin-pwa'; import fs from 'fs'; const hash = fs.readFileSync('public/definitions/hash.json', 'utf8'); @@ -10,6 +11,92 @@ const hash = fs.readFileSync('public/definitions/hash.json', 'utf8'); // https://vitejs.dev/config/ export default defineConfig({ plugins: [ + VitePWA({ + includeAssets: [ + 'favicon.ico', + 'apple-touch-icon.png', + 'favicon-16x16.png', + 'favicon-32x32.png', + 'safari-pinned-tab.svg', + ], + manifest: { + name: "VIA", + short_name: "VIA", + description: "VIA - Your keyboard's best friend", + id: "/", + start_url: ".", + icons: [ + { + src: "/android-chrome-192x192.png", + sizes: "192x192", + type: "image/png", + }, + { + src: "/android-chrome-512x512.png", + sizes: "512x512", + type: "image/png" + } + ], + theme_color: "#dadada", + background_color: "#dadada", + display: "standalone" + }, + manifestFilename: 'site.webmanifest', + workbox: { + runtimeCaching: [ + { + urlPattern: ({ url }) => url.origin === self.origin && (['/definitions/', '/fonts/', '/images/'].some(prefix => url.pathname.startsWith(prefix)) || url.pathname.endsWith('.glb')), + handler: 'CacheFirst', + options: { + cacheName: 'via-assets', + expiration: { maxAgeSeconds: 60 * 60 * 24 * 365 } + } + }, + { + urlPattern: ({ url }) => url.origin === 'https://fonts.googleapis.com' && url.pathname.startsWith('/css'), + handler: 'CacheFirst', + options: { + cacheName: 'google-fonts-stylesheets', + expiration: { + maxEntries: 10, + maxAgeSeconds: 60 * 60 * 24 * 365 + }, + cacheableResponse: { + statuses: [0, 200] + } + } + }, + { + urlPattern: ({ url }) => url.origin === 'https://fonts.gstatic.com', + handler: 'CacheFirst', + options: { + cacheName: 'gstatic-fonts', + expiration: { + maxEntries: 30, + maxAgeSeconds: 60 * 60 * 24 * 365 + }, + cacheableResponse: { + statuses: [0, 200] + } + } + }, + { + urlPattern: ({ url }) => url.origin === 'https://www.gstatic.com' && url.pathname.startsWith('/draco/'), + handler: 'CacheFirst', + options: { + cacheName: 'gstatic-draco', + expiration: { + maxEntries: 30, + maxAgeSeconds: 60 * 60 * 24 * 365 + }, + cacheableResponse: { + statuses: [0, 200] + } + } + } + ] + } + }), react(), createHtmlPlugin({ inject: { From f98adb02e11eba7d146c74ccdc11a31c774667a3 Mon Sep 17 00:00:00 2001 From: timbretimber <105982513+timbretimber@users.noreply.github.com> Date: Sun, 19 Apr 2026 15:38:43 -0600 Subject: [PATCH 2/3] Fix error preventing building --- src/components/panes/design.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/panes/design.tsx b/src/components/panes/design.tsx index fb5559589..521007ebc 100644 --- a/src/components/panes/design.tsx +++ b/src/components/panes/design.tsx @@ -173,7 +173,7 @@ function importDefinitions( [] ).map( (e) => - `${fileName} ${e.dataPath ? e.dataPath + ': ' : 'Object: '}${ + `${fileName} ${e.instancePath ? e.instancePath + ': ' : 'Object: '}${ e.message }`, ); From 77df9e8830bf291793f2392d57d401a3096877f8 Mon Sep 17 00:00:00 2001 From: timbretimber <105982513+timbretimber@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:08:16 -0600 Subject: [PATCH 3/3] Reorder options for closer relations --- vite.config.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index b7f5dbf88..bffd02323 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,13 +12,7 @@ const hash = fs.readFileSync('public/definitions/hash.json', 'utf8'); export default defineConfig({ plugins: [ VitePWA({ - includeAssets: [ - 'favicon.ico', - 'apple-touch-icon.png', - 'favicon-16x16.png', - 'favicon-32x32.png', - 'safari-pinned-tab.svg', - ], + manifestFilename: 'site.webmanifest', manifest: { name: "VIA", short_name: "VIA", @@ -41,7 +35,13 @@ export default defineConfig({ background_color: "#dadada", display: "standalone" }, - manifestFilename: 'site.webmanifest', + includeAssets: [ + 'favicon.ico', + 'apple-touch-icon.png', + 'favicon-16x16.png', + 'favicon-32x32.png', + 'safari-pinned-tab.svg', + ], workbox: { runtimeCaching: [ {