diff --git a/functions/router/index.js b/functions/router/index.js new file mode 100644 index 00000000..54f4f7a2 --- /dev/null +++ b/functions/router/index.js @@ -0,0 +1,28 @@ +export default async function(req) { + const url = new URL(req.url); + const path = url.pathname; + + // Determine version from path + let version = 'latest'; + if (path.startsWith('/v/')) { + const match = path.match(/^\/v\/([^\/]+)/); + if (match) version = match[1]; + } + + // For HTML navigation (no file extension), serve index.html + if (!path.match(/\.[a-z]+$/i)) { + const htmlUrl = `https://${url.host}/v/${version}/index.html`; + const response = await fetch(htmlUrl); + return new Response(response.body, { + headers: { + 'Content-Type': 'text/html', + 'Cache-Control': 'no-cache' + } + }); + } + + // For assets, pass through + const assetUrl = `https://${url.host}${path}`; + return fetch(assetUrl); +} + diff --git a/functions/router/package.json b/functions/router/package.json new file mode 100644 index 00000000..a2a59768 --- /dev/null +++ b/functions/router/package.json @@ -0,0 +1,6 @@ +{ + "name": "router", + "version": "1.0.0", + "main": "index.js" +} + diff --git a/ui/build-all.sh b/ui/build-all.sh new file mode 100755 index 00000000..1ed908c8 --- /dev/null +++ b/ui/build-all.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +# Build latest (includes device list) +echo "Building latest..." +VITE_BASE_PATH=/v/latest/ npm run build:prod -- --outDir dist-temp +mkdir -p dist/v/latest +cp -r dist-temp/* dist/v/latest/ + +# Build for each firmware version you support +echo "Building v2025.11.07..." +VITE_BASE_PATH=/v/2025.11.07/ npm run build:prod -- --outDir dist-temp +mkdir -p dist/v/2025.11.07 +cp -r dist-temp/* dist/v/2025.11.07/ + +echo "Building v2025.10.15..." +VITE_BASE_PATH=/v/2025.10.15/ npm run build:prod -- --outDir dist-temp +mkdir -p dist/v/2025.10.15 +cp -r dist-temp/* dist/v/2025.10.15/ + +rm -rf dist-temp +echo "✓ All versions built to dist/v/" + diff --git a/ui/package.json b/ui/package.json index 70eaa662..f56ff63a 100644 --- a/ui/package.json +++ b/ui/package.json @@ -4,13 +4,14 @@ "version": "2025.11.07.2130", "type": "module", "engines": { - "node": "^22.20.0" + "node": "22.x" }, "scripts": { "dev": "./dev_device.sh", "dev:ssl": "USE_SSL=true ./dev_device.sh", "dev:cloud": "vite dev --mode=cloud-development", "build": "npm run build:prod", + "build:all": "./build-all.sh", "build:device": "npm run i18n:compile && tsc && vite build --mode=device --emptyOutDir", "build:staging": "npm run i18n:compile && tsc && vite build --mode=cloud-staging", "build:prod": "npm run i18n:compile && tsc && vite build --mode=cloud-production",