From a797729dd081531593630c8f117a5e22b5356e6a Mon Sep 17 00:00:00 2001 From: Sebastian G Date: Thu, 3 Sep 2026 11:10:58 +0200 Subject: [PATCH 1/8] feat(checkin): gym membership QR check-in (mobile-only) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a mobile-only gym check-in screen: saved membership codes shown as QR codes in a swipeable carousel, reached from a 'Check in' card on Home. Cards are added by typing the code, importing a photo, or scanning with the camera. Only the code value + symbology are stored — never a photo; the QR is regenerated from the value on every display. Rendering uses lean-qr (MIT); camera scan and photo decode use @capacitor-mlkit/barcode-scanning (Apache-2.0), pinned to the 7.x line for Capacitor 7. Both are documented in NOTICE.md and bundled only in the mobile build — the whole feature folds away in web/demo builds via MOBILE, so nothing new lands in the web bundle. No backend/schema change: gymCards rides the existing state sync and backup like every other field. Non-QR symbologies are readable but not reproducible, so capture refuses them rather than storing a code that would display wrong bars. Native wiring: CAMERA permission + ML Kit barcode_ui meta-data (AndroidManifest), NSCameraUsageDescription (iOS Info.plist), mlkit plugin registered via cap sync. Debug builds get an applicationIdSuffix '.test' and an 'OpenGymTest' label so a test build installs alongside the real app. --- NOTICE.md | 46 +++++ frontend/android/app/build.gradle | 6 + frontend/android/app/capacitor.build.gradle | 1 + .../app/src/debug/res/values/strings.xml | 7 + .../android/app/src/main/AndroidManifest.xml | 6 + frontend/android/capacitor.settings.gradle | 3 + frontend/ios/App/App/Info.plist | 2 + frontend/package-lock.json | 30 +++ frontend/package.json | 2 + frontend/src/App.jsx | 6 + frontend/src/components/Icon.jsx | 5 + frontend/src/components/QrCanvas.jsx | 33 ++++ frontend/src/index.css | 37 ++++ frontend/src/lib/qr.js | 67 +++++++ frontend/src/lib/scan.js | 109 +++++++++++ frontend/src/locales/es.js | 25 +++ frontend/src/store/useStore.js | 8 + frontend/src/views/CheckIn.jsx | 176 ++++++++++++++++++ frontend/src/views/Home.jsx | 18 ++ 19 files changed, 587 insertions(+) create mode 100644 frontend/android/app/src/debug/res/values/strings.xml create mode 100644 frontend/src/components/QrCanvas.jsx create mode 100644 frontend/src/lib/qr.js create mode 100644 frontend/src/lib/scan.js create mode 100644 frontend/src/views/CheckIn.jsx diff --git a/NOTICE.md b/NOTICE.md index a6a1cf2..0ae5a0a 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -123,3 +123,49 @@ English source produced with OpenAI Codex and Anthropic Claude Code language-model assistance. They are not copied from a separate Portuguese dataset. Their review status and translation policy are documented alongside the source files. + +## Gym check-in QR codes + +The mobile-only gym check-in feature (a saved membership code shown as a QR/barcode on the phone, +added by typing, importing a photo, or scanning with the camera) uses two third-party packages. +Both are permissively licensed and compatible with openGym's AGPL, and both are bundled only in +the mobile build — the web and demo builds never ship them. + +### QR/barcode rendering — `lean-qr` + +openGym renders each saved code on the phone with [**lean-qr**](https://github.com/davidje13/lean-qr) +by David Evans, used under the **MIT License** and reproduced below. Only the code's stored value +is kept; the picture is generated fresh from that value each time it is shown, never stored. + +``` +MIT License + +Copyright (c) 2021-2025 David Evans + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### Camera scan & photo decode — `@capacitor-mlkit/barcode-scanning` + +Reading a code — from the camera or from an imported photo — uses the +[**@capacitor-mlkit/barcode-scanning**](https://github.com/capawesome-team/capacitor-mlkit) plugin +by the Capawesome Team (Robin Genz), a Capacitor wrapper around Google's ML Kit, used under the +**Apache License 2.0**. openGym pins the `7.x` line to stay on Capacitor 7. The full license text is +available at and in the package's own `LICENSE` file. +The decoded string is what openGym keeps; the photo itself is never stored. diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle index 98868cd..f477595 100644 --- a/frontend/android/app/build.gradle +++ b/frontend/android/app/build.gradle @@ -21,6 +21,12 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } + debug { + // Test build installs side-by-side with the real app: its own applicationId, so both + // can live on one device. The name/icon label is overridden by the debug resource + // overlay in src/debug/res. The release build (the "real" app) is untouched. + applicationIdSuffix ".test" + } } } diff --git a/frontend/android/app/capacitor.build.gradle b/frontend/android/app/capacitor.build.gradle index af1bea9..815aa6b 100644 --- a/frontend/android/app/capacitor.build.gradle +++ b/frontend/android/app/capacitor.build.gradle @@ -9,6 +9,7 @@ android { apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" dependencies { + implementation project(':capacitor-mlkit-barcode-scanning') implementation project(':capacitor-app') implementation project(':capacitor-filesystem') implementation project(':capacitor-local-notifications') diff --git a/frontend/android/app/src/debug/res/values/strings.xml b/frontend/android/app/src/debug/res/values/strings.xml new file mode 100644 index 0000000..eff2a58 --- /dev/null +++ b/frontend/android/app/src/debug/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + OpenGymTest + OpenGymTest + diff --git a/frontend/android/app/src/main/AndroidManifest.xml b/frontend/android/app/src/main/AndroidManifest.xml index d137fe6..d84111a 100644 --- a/frontend/android/app/src/main/AndroidManifest.xml +++ b/frontend/android/app/src/main/AndroidManifest.xml @@ -27,6 +27,10 @@ android:grantUriPermissions="true"> + + + @@ -36,4 +40,6 @@ on Android 12+. Where it isn't granted, scheduling silently falls back to inexact alarms — the reminder still arrives, just not to the minute. --> + + diff --git a/frontend/android/capacitor.settings.gradle b/frontend/android/capacitor.settings.gradle index d757f12..90dbbe8 100644 --- a/frontend/android/capacitor.settings.gradle +++ b/frontend/android/capacitor.settings.gradle @@ -2,6 +2,9 @@ include ':capacitor-android' project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') +include ':capacitor-mlkit-barcode-scanning' +project(':capacitor-mlkit-barcode-scanning').projectDir = new File('../node_modules/@capacitor-mlkit/barcode-scanning/android') + include ':capacitor-app' project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android') diff --git a/frontend/ios/App/App/Info.plist b/frontend/ios/App/App/Info.plist index 8e81fcd..1987307 100644 --- a/frontend/ios/App/App/Info.plist +++ b/frontend/ios/App/App/Info.plist @@ -45,5 +45,7 @@ UIViewControllerBasedStatusBarAppearance + NSCameraUsageDescription + Used to scan your gym membership QR code so you can check in from the app. diff --git a/frontend/package-lock.json b/frontend/package-lock.json index a4e04ce..57d6a3c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -9,11 +9,13 @@ "version": "1.2.14", "license": "AGPL-3.0-or-later", "dependencies": { + "@capacitor-mlkit/barcode-scanning": "^7.5.0", "@capacitor/app": "^7.1.2", "@capacitor/core": "^7.6.8", "@capacitor/filesystem": "^7.1.8", "@capacitor/local-notifications": "^7.0.7", "@capacitor/share": "^7.0.4", + "lean-qr": "^2.7.3", "react": "^19.2.7", "react-dom": "^19.2.7", "react-router-dom": "^7.18.2", @@ -54,6 +56,25 @@ "node": ">=6.9.0" } }, + "node_modules/@capacitor-mlkit/barcode-scanning": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@capacitor-mlkit/barcode-scanning/-/barcode-scanning-7.5.0.tgz", + "integrity": "sha512-DBWRykYYLW0YMj/UzlQ0sVGn83mwGAJsbZVxFsd44pppEEy88OO04lxy9Esv5QpnNBIKPjSIqLWmSLuhoFGPaQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/capawesome-team/" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/capawesome" + } + ], + "license": "Apache-2.0", + "peerDependencies": { + "@capacitor/core": ">=7.0.0" + } + }, "node_modules/@capacitor/android": { "version": "7.6.8", "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-7.6.8.tgz", @@ -3742,6 +3763,15 @@ "node": ">=6" } }, + "node_modules/lean-qr": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lean-qr/-/lean-qr-2.7.3.tgz", + "integrity": "sha512-/eQryMvYyTL3dSMK/IlvSjUYG0ShQv62owXiFbGkSH+lFZzf4VOsPP+UInAgeUH/rPIyz59uQE9XHRbn9o8SyQ==", + "license": "MIT", + "bin": { + "lean-qr": "cli.mjs" + } + }, "node_modules/lightningcss": { "version": "1.32.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 7ee96e5..dded906 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,11 +14,13 @@ }, "license": "AGPL-3.0-or-later", "dependencies": { + "@capacitor-mlkit/barcode-scanning": "^7.5.0", "@capacitor/app": "^7.1.2", "@capacitor/core": "^7.6.8", "@capacitor/filesystem": "^7.1.8", "@capacitor/local-notifications": "^7.0.7", "@capacitor/share": "^7.0.4", + "lean-qr": "^2.7.3", "react": "^19.2.7", "react-dom": "^19.2.7", "react-router-dom": "^7.18.2", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index b30af2f..bd0f340 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -5,6 +5,7 @@ import { useUI } from './store/useUI.js' import { bindUI } from './components/ui.jsx' import { ACCENTS } from './lib/format.js' import { setLang, useLang } from './lib/i18n.js' +import { MOBILE } from './lib/mobile.js' import { setNav } from './lib/nav.js' import { initBackButton } from './lib/back.js' import { useWakeLock } from './lib/wakelock.js' @@ -19,6 +20,7 @@ import TimerFlash from './components/TimerFlash.jsx' import Login from './views/Login.jsx' import MobileOnboarding from './views/MobileOnboarding.jsx' import Home from './views/Home.jsx' +import CheckIn from './views/CheckIn.jsx' import Plan from './views/Plan.jsx' import RoutineEdit from './views/RoutineEdit.jsx' import Workout from './views/Workout.jsx' @@ -110,6 +112,10 @@ function Shell() { {!authed ? : needsMobileOnboarding ? : ( } /> + {/* Gym check-in is mobile-only — it needs the native scanner and showing a QR to + a turnstile makes no sense in a browser tab. Off mobile the route falls through + to the catch-all redirect below. */} + {MOBILE && } />} } /> } /> } /> diff --git a/frontend/src/components/Icon.jsx b/frontend/src/components/Icon.jsx index b270cd3..033f3f1 100644 --- a/frontend/src/components/Icon.jsx +++ b/frontend/src/components/Icon.jsx @@ -112,6 +112,11 @@ const P = { signOut: <>, shuffle: <>, info: <>, + // Three position-detection squares plus a scatter of modules — reads as "QR / scan this" + // at tab-bar size without trying to draw a real (unscannable) code. + qr: <>, + camera: <>, + image: <>, warning: <>, } diff --git a/frontend/src/components/QrCanvas.jsx b/frontend/src/components/QrCanvas.jsx new file mode 100644 index 0000000..543e052 --- /dev/null +++ b/frontend/src/components/QrCanvas.jsx @@ -0,0 +1,33 @@ +import { useEffect, useRef, useState } from 'react' +import { renderQrToCanvas } from '../lib/qr.js' + +// Renders a gym check-in code as a QR image on a . lean-qr draws one module per pixel; +// CSS (.qr-canvas) scales it up with image-rendering: pixelated so it stays razor-sharp at any +// display size without re-generating. Regenerated from `value` on every change — we never store +// the picture (see lib/qr.js). +// +// The lib loads via dynamic import, so the first paint is a frame behind; a plain box holds the +// space until then. A render failure (empty value, lib load error) shows nothing rather than a +// broken canvas — the caller decides what an unusable card looks like. +export default function QrCanvas({ value, size = 240, className = '' }) { + const ref = useRef(null) + const [ok, setOk] = useState(false) + + useEffect(() => { + let alive = true + setOk(false) + renderQrToCanvas(ref.current, value) + .then(mods => { if (alive) setOk(mods > 0) }) + .catch(() => { if (alive) setOk(false) }) + return () => { alive = false } + }, [value]) + + return ( + + ) +} diff --git a/frontend/src/index.css b/frontend/src/index.css index ca0528e..cfbb542 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1056,3 +1056,40 @@ h4.sec{ .exmedia img{height:380px} .hm-wrap{display:flex;flex-direction:column;align-items:center} } + +/* ------------------------------------------------------- gym check-in -- */ +/* Mobile-only feature (views/CheckIn.jsx): saved membership codes shown as QR, swiped + through horizontally. The rail is a scroll-snap track — one card per viewport, no JS + carousel — with a trailing "+" card to add another. */ +.ci-rail{ + display:flex;gap:14px;overflow-x:auto;scroll-snap-type:x mandatory; + -webkit-overflow-scrolling:touch;scrollbar-width:none; + padding:4px 0 8px;margin:0 -16px;padding-left:16px;padding-right:16px; +} +.ci-rail::-webkit-scrollbar{display:none} +.ci-card{ + scroll-snap-align:center;flex:0 0 100%;box-sizing:border-box; + background:var(--surface);border-radius:var(--r-xl);padding:22px 18px; + display:flex;flex-direction:column;align-items:center;gap:14px; +} +.ci-card .ci-label{font-size:19px;font-weight:600;letter-spacing:-.014em;text-align:center} +.ci-card .ci-value{font-size:14px;color:var(--label-2);word-break:break-all;text-align:center;font-variant-numeric:tabular-nums} +/* The QR itself: lean-qr paints 1 module per pixel, so scale it up with the browser's + nearest-neighbour so every module stays a crisp square instead of a blurred blob. White + quiet-zone padding is baked in by the renderer; the plate underneath just frames it. */ +.ci-qr-plate{background:#fff;border-radius:var(--r-lg);padding:16px} +.qr-canvas{display:block;image-rendering:pixelated;image-rendering:crisp-edges;transition:opacity var(--fast)} +/* the trailing add card — a big + on a dashed outline, same footprint as a real card */ +.ci-add{ + scroll-snap-align:center;flex:0 0 100%;box-sizing:border-box; + min-height:280px;border-radius:var(--r-xl); + border:2px dashed var(--surface-3);background:none;color:var(--label-2); + display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px; +} +.ci-add:active{background:var(--surface);transform:scale(.99)} +.ci-add .icn{font-size:40px;--icon-stroke:1.8} +.ci-add .ci-add-t{font-size:16px;font-weight:500} +/* dots under the rail — which card you're on. Purely a hint; the rail itself is the control. */ +.ci-dots{display:flex;justify-content:center;gap:7px;margin-top:4px} +.ci-dot{width:7px;height:7px;border-radius:50%;background:var(--surface-3);transition:background var(--fast),transform var(--fast)} +.ci-dot.on{background:var(--acc);transform:scale(1.15)} diff --git a/frontend/src/lib/qr.js b/frontend/src/lib/qr.js new file mode 100644 index 0000000..a3af848 --- /dev/null +++ b/frontend/src/lib/qr.js @@ -0,0 +1,67 @@ +// QR rendering for the gym check-in cards (mobile-only feature — see views/CheckIn.jsx). +// +// We never store a photo of a membership card, only its decoded value (+ its symbology in +// `fmt`). The picture a turnstile scanner reads is regenerated from that value every time the +// card is shown, here. +// +// lean-qr (MIT, see NOTICE.md) is loaded with a dynamic import so its ~4kB never lands in the +// web bundle — the whole feature is gated behind MOBILE, but the library itself is plain JS a +// static import would otherwise pull into every build. +// +// Scope: lean-qr generates QR codes only. A gym card is virtually always a QR code, and the +// capture flow (lib/scan.js) refuses any symbology we cannot faithfully reproduce, so a stored +// card is guaranteed renderable here — canRenderFmt() is the single source of that truth, shared +// by both sides. + +let _leanqr = null + +// Cached loader for lean-qr. Resolves once; every card after the first reuses the same module. +async function loadLeanQr() { + if (!_leanqr) _leanqr = await import('lean-qr') + return _leanqr +} + +// The symbologies we can both read (mlkit) AND redraw (lean-qr). Stored `fmt` is a lower-cased +// BarcodeFormat. Only QR qualifies: reproducing an EAN/Code128/etc. would need a 1D renderer we +// deliberately did not add, and a code we can't redraw faithfully is worse than not storing it — +// it would look scannable but carry the wrong bars. +export function canRenderFmt(fmt) { + return normalizeFmt(fmt) === 'qrcode' +} + +// mlkit reports BarcodeFormat as e.g. 'QR_CODE' | 'QrCode'; older callers may pass 'qr'. Fold +// them all to a stable lower-case token we store and compare on. +export function normalizeFmt(fmt) { + const s = String(fmt || '').toLowerCase().replace(/[^a-z0-9]/g, '') + if (s === 'qr' || s === 'qrcode') return 'qrcode' + return s +} + +// Draw `value` as a QR code onto `canvas` at 1 module per pixel; CSS scales it up with +// image-rendering: pixelated (see .qr-canvas in index.css) so it stays crisp at any size. +// `on`/`off` default to solid black on white — turnstile scanners want maximum contrast, not +// the app's theme colours, and a themed (e.g. lime-on-black) code fails to read on many +// readers. Returns the module count (QR size) so the caller can react if it wants. +export async function renderQrToCanvas(canvas, value, { on = '#000000', off = '#ffffff' } = {}) { + if (!canvas || !value) return 0 + const { generate, correction } = await loadLeanQr() + // Medium error correction: a good default that survives a scratched or partly-obscured phone + // screen without inflating the code so much it gets dense on small screens. + const code = generate(value, { minCorrectionLevel: correction.M }) + code.toCanvas(canvas, { + on: hexToRgba(on), + off: hexToRgba(off), + padX: 2, + padY: 2, + }) + return code.size +} + +// lean-qr wants colours as [r,g,b,a]. Accept a #rrggbb (or #rgb) string; anything else is +// treated as opaque black/white by the caller's defaults, so this only has to handle hex. +function hexToRgba(hex) { + let h = String(hex).replace('#', '') + if (h.length === 3) h = h.split('').map(c => c + c).join('') + const n = parseInt(h, 16) + return [(n >> 16) & 255, (n >> 8) & 255, n & 255, 255] +} diff --git a/frontend/src/lib/scan.js b/frontend/src/lib/scan.js new file mode 100644 index 0000000..f7bb9f8 --- /dev/null +++ b/frontend/src/lib/scan.js @@ -0,0 +1,109 @@ +// Capturing a gym check-in code (mobile-only — see views/CheckIn.jsx). Three ways in: +// 1. type it — no plugin, handled entirely in the view +// 2. import a photo — importCodeFromImage(file): decode a picture the user already has +// 3. scan with camera — scanCode(): live camera via ML Kit's own scanner UI +// +// Both plugin paths dynamic-import @capacitor-mlkit/barcode-scanning (Apache-2.0, see NOTICE.md) +// so it never lands in the web bundle — the whole feature is behind MOBILE, and every entry point +// here throws a plain Error off mobile rather than importing a native module that isn't there. +// +// What comes back is a normalized { value, fmt } (or null when the user cancels / nothing was +// found). `value` is the code's machine-readable content; `fmt` is a lower-cased symbology token +// matching lib/qr.js's normalizeFmt. The caller checks canRenderFmt(fmt) before saving — we can +// read many barcode kinds but only redraw QR, so a non-QR code is reported and refused there, not +// silently stored. +import { MOBILE } from './mobile.js' +import { normalizeFmt } from './qr.js' + +// A found barcode from either path → our stored shape. mlkit gives rawValue (machine-readable, +// what a turnstile actually reads) and a BarcodeFormat; we keep rawValue and fold the format. +function toCode(barcode) { + if (!barcode) return null + const value = barcode.rawValue || barcode.displayValue || '' + if (!value) return null + return { value, fmt: normalizeFmt(barcode.format) } +} + +// Live camera scan. On Android this opens Google's own full-screen scanner UI (no camera view we +// have to host); on iOS the plugin's native scanner. Returns the first barcode found, or null if +// the user backed out without scanning. Throws if scanning isn't supported or permission is hard- +// denied so the caller can explain why. +export async function scanCode() { + if (!MOBILE) throw new Error('Scanning is only available in the app') + const { BarcodeScanner } = await import('@capacitor-mlkit/barcode-scanning') + + const { supported } = await BarcodeScanner.isSupported() + if (!supported) throw new Error('unsupported') + + await ensureCameraPermission(BarcodeScanner) + await ensureScannerModule(BarcodeScanner) + + const { barcodes } = await BarcodeScanner.scan() + return barcodes && barcodes.length ? toCode(barcodes[0]) : null +} + +// Decode a barcode out of an image the user picked. mlkit's readBarcodesFromImage wants a local +// file PATH, and a browser only hands us a File/blob — so we bounce the bytes +// through the app's cache dir (reusing @capacitor/filesystem, already a dependency) to get a real +// path, decode, then delete the temp file. Returns the first barcode, or null if none was found. +export async function importCodeFromImage(file) { + if (!MOBILE) throw new Error('Importing is only available in the app') + if (!file) return null + const { BarcodeScanner } = await import('@capacitor-mlkit/barcode-scanning') + const { Filesystem, Directory } = await import('@capacitor/filesystem') + + const base64 = await fileToBase64(file) + const name = `checkin-import-${Date.now()}.${extOf(file.name)}` + let uri = null + try { + const w = await Filesystem.writeFile({ path: name, directory: Directory.Cache, data: base64 }) + uri = w.uri + const { barcodes } = await BarcodeScanner.readBarcodesFromImage({ path: uri }) + return barcodes && barcodes.length ? toCode(barcodes[0]) : null + } finally { + // Best effort — a leftover temp image in the cache dir is harmless, but tidy up anyway. + try { await Filesystem.deleteFile({ path: name, directory: Directory.Cache }) } catch (e) { /* */ } + } +} + +// Camera permission for the live scanner. checkPermissions first so an already-granted user never +// sees a prompt; request only when needed. A hard denial throws so the caller can point the user +// at Settings rather than silently doing nothing. +async function ensureCameraPermission(BarcodeScanner) { + let { camera } = await BarcodeScanner.checkPermissions() + if (camera !== 'granted' && camera !== 'limited') { + ({ camera } = await BarcodeScanner.requestPermissions()) + } + if (camera !== 'granted' && camera !== 'limited') throw new Error('permission-denied') +} + +// On Android the ML Kit scanner ships as an on-demand Google Play module, absent on first use. +// Install it (once) before scanning; a no-op / not-applicable on iOS, where the check simply +// reports available. Failures here are non-fatal — scan() will surface a clearer error if it +// truly can't proceed. +async function ensureScannerModule(BarcodeScanner) { + try { + if (!BarcodeScanner.isGoogleBarcodeScannerModuleAvailable) return + const { available } = await BarcodeScanner.isGoogleBarcodeScannerModuleAvailable() + if (!available) await BarcodeScanner.installGoogleBarcodeScannerModule() + } catch (e) { /* let scan() decide whether it can still run */ } +} + +// A File/Blob → bare base64 (no data: prefix), which Filesystem.writeFile expects. +function fileToBase64(file) { + return new Promise((resolve, reject) => { + const r = new FileReader() + r.onerror = () => reject(r.error || new Error('read failed')) + r.onload = () => { + const s = String(r.result || '') + const comma = s.indexOf(',') + resolve(comma === -1 ? s : s.slice(comma + 1)) + } + r.readAsDataURL(file) + }) +} + +function extOf(filename) { + const m = /\.([a-z0-9]+)$/i.exec(filename || '') + return m ? m[1].toLowerCase() : 'jpg' +} diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index 1167792..ec7dbfd 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Pon 0 para volver al valor por defecto ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Se aplica a este ejercicio en todas partes, no solo en este plan.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Sigues registrando el peso total — la barra solo se usa para calcular los discos por lado.', + // Gym check-in (mobile-only) + 'Check in': 'Registrarse', + 'At the gym': 'En el gimnasio', + 'Show this at the gym': 'Muestra esto en el gimnasio', + 'Add your gym card': 'Añade tu tarjeta del gimnasio', + 'Add a card': 'Añadir una tarjeta', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Escribe el número de tu tarjeta de socio, importa una foto o escanéala con la cámara. No hace falta otra app en el gimnasio — solo abre esta pantalla.', + 'Remove this card?': '¿Eliminar esta tarjeta?', + 'Scan it, import a photo, or type the code by hand.': 'Escanéala, importa una foto o escribe el código a mano.', + 'Scan': 'Escanear', + 'Import photo': 'Importar foto', + 'Label': 'Etiqueta', + 'e.g. FitZone downtown': 'p. ej. FitZone centro', + 'Code': 'Código', + 'Membership number or code': 'Número de socio o código', + 'Save card': 'Guardar tarjeta', + 'Gym card': 'Tarjeta del gimnasio', + 'Card added': 'Tarjeta añadida', + 'Nothing to save yet': 'Nada que guardar todavía', + "That's not a QR code — only QR cards can be shown here": 'Eso no es un código QR — aquí solo se pueden mostrar tarjetas QR', + 'No QR code found in that image': 'No se encontró ningún código QR en esa imagen', + 'Could not read that image': 'No se pudo leer esa imagen', + 'Camera permission is needed to scan. Enable it in Settings.': 'Se necesita permiso de cámara para escanear. Actívalo en Ajustes.', + 'Scanning is not available on this device.': 'El escaneo no está disponible en este dispositivo.', + 'Could not start the scanner': 'No se pudo iniciar el escáner', } diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js index c86f7a8..2476cb7 100644 --- a/frontend/src/store/useStore.js +++ b/frontend/src/store/useStore.js @@ -29,6 +29,14 @@ export const DEF = { // lib/bar.js). Personal equipment, so it syncs with the account but never travels in a // shared plan. Logged weights stay the total — this only feeds the plate math. barWeights: {}, + // Gym check-in cards (mobile-only feature, see views/CheckIn.jsx). Each is a membership + // code shown as a QR/barcode at the gym's turnstile — added by typing it, importing a photo + // of the card, or scanning it. We only ever keep the code's VALUE, never a photo: the image + // is regenerated from `value` every time it's shown (lib/qr.js). `fmt` is the barcode symbology + // ('qrcode' | 'ean13' | 'code128' | … — lower-cased BarcodeFormat) so it renders as the same + // kind of code the gym issued. Just data, so it syncs and backs up like everything else. + // [{ id, label, value, fmt }] + gymCards: [], } const clone = o => JSON.parse(JSON.stringify(o)) diff --git a/frontend/src/views/CheckIn.jsx b/frontend/src/views/CheckIn.jsx new file mode 100644 index 0000000..6083f83 --- /dev/null +++ b/frontend/src/views/CheckIn.jsx @@ -0,0 +1,176 @@ +import { useEffect, useRef, useState } from 'react' +import { useNavigate } from 'react-router-dom' +import { useStore } from '../store/useStore.js' +import { useUI } from '../store/useUI.js' +import { uid } from '../lib/format.js' +import { t } from '../lib/i18n.js' +import { canRenderFmt } from '../lib/qr.js' +import { scanCode, importCodeFromImage } from '../lib/scan.js' +import Icon from '../components/Icon.jsx' +import QrCanvas from '../components/QrCanvas.jsx' +import { Button, TextField } from '../components/ui.jsx' +import { confirmSheet } from '../sheets.jsx' +import { tappable } from '../lib/use-sheet-keyboard.js' + +// Gym check-in (mobile-only, reached from the Home "Check in" card). Shows each saved membership +// code as a QR the turnstile can read, swiped through horizontally, with a trailing "+" to add +// another. We only ever store the code's value + symbology; the QR is regenerated from it here +// every time (see lib/qr.js), so nothing sensitive is kept as an image. +export default function CheckIn() { + const nav = useNavigate() + const cards = useStore(s => s.S.gymCards) || [] + const railRef = useRef(null) + const [active, setActive] = useState(0) + + // Which card the horizontal scroll has settled on — drives the little dots. Reading it off the + // scroll position keeps the rail itself the single control; no separate paging state to sync. + const onScroll = () => { + const rail = railRef.current + if (!rail) return + const i = Math.round(rail.scrollLeft / rail.clientWidth) + setActive(i) + } + + return
+
+ +
+

{t('Check in')}

+
{cards.length ? t('Show this at the gym') : t('Add your gym card')}
+
+
+ +
+ {cards.map(card => )} + +
+ + {(cards.length > 0) &&
+ {cards.map((c, i) => )} + {/* the add card is a slide too, so it gets a dot */} + = cards.length ? ' on' : '')} /> +
} + + {!cards.length &&
+ {t('Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.')} +
} +
+} + +// One saved card: its label, the QR, and the raw value underneath (handy when a reader is fussy +// and a staff member types it in). Long-press / the trash button removes it. +function CardFace({ card }) { + const update = useStore(s => s.update) + const remove = () => confirmSheet({ + title: t('Remove this card?'), + message: card.label, + confirmText: t('Remove'), + danger: true, + onConfirm: () => update(s => { s.gymCards = (s.gymCards || []).filter(c => c.id !== card.id) }), + }) + return
+
+
{card.label}
+ +
+
+
{card.value}
+
+} + +/* ------------------------------------------------------------- add-card sheet -- */ + +// Opens the add-card sheet. Co-located with the view (not sheets.jsx) because the whole feature +// is mobile-only and pulls in the native scanner — keeping it here keeps that out of the shared, +// web-bundled sheets module. +export function openAddCard() { + useUI.getState().openSheet(close => ) +} + +function saveCard({ label, value, fmt }) { + const update = useStore.getState().update + const toast = useUI.getState().toast + const trimmed = (value || '').trim() + if (!trimmed) { toast(t('Nothing to save yet')); return false } + // We can read many barcode kinds but only redraw QR faithfully — refuse anything else rather + // than store a code that would display as the wrong bars at the turnstile. + if (fmt && !canRenderFmt(fmt)) { toast(t("That's not a QR code — only QR cards can be shown here")); return false } + update(s => { + if (!Array.isArray(s.gymCards)) s.gymCards = [] + s.gymCards.push({ id: uid(), label: (label || '').trim() || t('Gym card'), value: trimmed, fmt: 'qrcode' }) + }) + toast(t('Card added')) + return true +} + +function AddCard({ close }) { + const [label, setLabel] = useState('') + const [value, setValue] = useState('') + const [busy, setBusy] = useState(false) + const fileRef = useRef(null) + const toast = useUI(s => s.toast) + + const commitTyped = () => { if (saveCard({ label, value, fmt: 'qrcode' })) close() } + + // Camera scan: hands off to the native scanner, comes back with a value we drop straight into + // the form so the user can still name it before saving. + const doScan = async () => { + setBusy(true) + try { + const code = await scanCode() + if (!code) return // user backed out + if (!canRenderFmt(code.fmt)) { toast(t("That's not a QR code — only QR cards can be shown here")); return } + setValue(code.value) + } catch (e) { + toast(scanErrorMessage(e)) + } finally { setBusy(false) } + } + + const onFile = async ev => { + const file = ev.target.files && ev.target.files[0] + ev.target.value = '' // let the same file be picked again later + if (!file) return + setBusy(true) + try { + const code = await importCodeFromImage(file) + if (!code) { toast(t('No QR code found in that image')); return } + if (!canRenderFmt(code.fmt)) { toast(t("That's not a QR code — only QR cards can be shown here")); return } + setValue(code.value) + } catch (e) { + toast(t('Could not read that image')) + } finally { setBusy(false) } + } + + return <> +

{t('Add a card')}

+
{t('Scan it, import a photo, or type the code by hand.')}
+ +
+ + +
+ + + setLabel(e.target.value)} placeholder={t('e.g. FitZone downtown')} style={{ marginBottom: 12 }} /> + + + setValue(e.target.value)} placeholder={t('Membership number or code')} inputMode="text" style={{ marginBottom: 16 }} /> + + {value.trim() &&
} + + + + + +} + +// Map the thrown reasons from lib/scan.js to something a person can act on. +function scanErrorMessage(e) { + const m = String(e && e.message) + if (m === 'permission-denied') return t('Camera permission is needed to scan. Enable it in Settings.') + if (m === 'unsupported') return t('Scanning is not available on this device.') + return t('Could not start the scanner') +} diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsx index 158a459..c597218 100644 --- a/frontend/src/views/Home.jsx +++ b/frontend/src/views/Home.jsx @@ -10,6 +10,7 @@ import Icon from '../components/Icon.jsx' import { Button } from '../components/ui.jsx' import { tappable } from '../lib/use-sheet-keyboard.js' import { glyphOf } from '../lib/glyphs.js' +import { MOBILE } from '../lib/mobile.js' // Home = what to do now + a quick glance. Deep charts & history live in Stats. export default function Home() { @@ -94,6 +95,23 @@ export default function Home() { + {/* Mobile-only: jump to the gym check-in cards (QR membership codes). Shown here as a quick + tap on arrival at the gym; the whole feature folds away in web/demo builds via MOBILE. */} + {MOBILE && ( +
nav('/checkin'))}> +
+
+ +
+
{t('At the gym')}
+
{t('Check in')}
+
+
+ +
+
+ )} + {!S.routines.length && !S.active && (
From 0f1500b10260d2dbad47aeac5d7baa4e60770322 Mon Sep 17 00:00:00 2001 From: Sebastian G Date: Thu, 3 Sep 2026 11:24:17 +0200 Subject: [PATCH 2/8] i18n and tests --- frontend/src/lib/pt-br-locale.test.js | 6 +- frontend/src/lib/qr.test.js | 51 ++++++++++++++ frontend/src/lib/scan.test.js | 18 +++++ frontend/src/locales/de.js | 25 +++++++ frontend/src/locales/fr.js | 25 +++++++ frontend/src/locales/hi.js | 25 +++++++ frontend/src/locales/hu.js | 25 +++++++ frontend/src/locales/it.js | 25 +++++++ frontend/src/locales/ko.js | 25 +++++++ frontend/src/locales/pl.js | 25 +++++++ frontend/src/locales/pt-BR.js | 15 +++- frontend/src/locales/pt.js | 25 +++++++ frontend/src/locales/ru.js | 25 +++++++ frontend/src/locales/th.js | 25 +++++++ frontend/src/locales/tr.js | 25 +++++++ frontend/src/locales/zh.js | 25 +++++++ frontend/src/store/useStore.gymcards.test.jsx | 69 +++++++++++++++++++ 17 files changed, 455 insertions(+), 4 deletions(-) create mode 100644 frontend/src/lib/qr.test.js create mode 100644 frontend/src/lib/scan.test.js create mode 100644 frontend/src/store/useStore.gymcards.test.jsx diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index 6298de3..f6a042d 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -27,11 +27,11 @@ describe('Brazilian Portuguese locale', () => { .sort(byCodeUnit) const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex') - expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(342) - expect(inherited).toHaveLength(463) + expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(354) + expect(inherited).toHaveLength(475) // If this fails, review the changed keys and wording before accepting a new hash. From // frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list - expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('cafd0b6fde9f8261563b5040aa6e1278f5b469dc2d6b9c81d7d5554bb6825a05') + expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('d379a3a509af71a6773017d3374938c2067cc870bbf7bd5bbc0bb8ad853d0781') }) test('does not leak European Portuguese UI terms', () => { diff --git a/frontend/src/lib/qr.test.js b/frontend/src/lib/qr.test.js new file mode 100644 index 0000000..dfb7eb4 --- /dev/null +++ b/frontend/src/lib/qr.test.js @@ -0,0 +1,51 @@ +import { describe, it, expect } from 'vitest' +import { normalizeFmt, canRenderFmt } from './qr.js' + +// The QR helpers decide which scanned/typed codes the check-in feature will store: it can read +// many symbologies but only redraw QR, so canRenderFmt is the gate, and normalizeFmt is what +// folds every spelling mlkit might report into the single token everything else compares on. + +describe('normalizeFmt', () => { + it('folds every QR spelling to "qrcode"', () => { + // mlkit's BarcodeFormat, the enum-ish casings, and the casual 'qr' all mean the same thing. + expect(normalizeFmt('QR_CODE')).toBe('qrcode') + expect(normalizeFmt('QrCode')).toBe('qrcode') + expect(normalizeFmt('qrcode')).toBe('qrcode') + expect(normalizeFmt('qr')).toBe('qrcode') + expect(normalizeFmt('QR')).toBe('qrcode') + }) + + it('lower-cases and strips separators for other formats', () => { + expect(normalizeFmt('EAN_13')).toBe('ean13') + expect(normalizeFmt('Code128')).toBe('code128') + expect(normalizeFmt('CODE_128')).toBe('code128') + }) + + it('treats empty / nullish as an empty token rather than throwing', () => { + expect(normalizeFmt('')).toBe('') + expect(normalizeFmt(null)).toBe('') + expect(normalizeFmt(undefined)).toBe('') + }) +}) + +describe('canRenderFmt', () => { + it('accepts only QR, in any spelling', () => { + expect(canRenderFmt('QR_CODE')).toBe(true) + expect(canRenderFmt('QrCode')).toBe(true) + expect(canRenderFmt('qr')).toBe(true) + }) + + it('rejects 1D and other 2D symbologies we cannot faithfully redraw', () => { + // These are readable by the scanner but lean-qr can't reproduce them, so a card in one of + // these formats must never be stored — it would display as the wrong bars at the turnstile. + for (const fmt of ['EAN_13', 'EAN_8', 'CODE_128', 'CODE_39', 'ITF', 'UPC_A', 'PDF_417', 'AZTEC', 'DATA_MATRIX']) { + expect(canRenderFmt(fmt)).toBe(false) + } + }) + + it('rejects empty / unknown formats', () => { + expect(canRenderFmt('')).toBe(false) + expect(canRenderFmt(null)).toBe(false) + expect(canRenderFmt('something-else')).toBe(false) + }) +}) diff --git a/frontend/src/lib/scan.test.js b/frontend/src/lib/scan.test.js new file mode 100644 index 0000000..07941db --- /dev/null +++ b/frontend/src/lib/scan.test.js @@ -0,0 +1,18 @@ +import { describe, it, expect } from 'vitest' +import { scanCode, importCodeFromImage } from './scan.js' + +// In the test environment VITE_MOBILE is unset, so MOBILE is false — the same as a web build. +// Both capture paths must refuse to run there rather than reach for a native plugin that isn't +// present. (The happy-path decoding is exercised on-device; here we pin the guard that keeps the +// scanner out of every non-mobile build.) + +describe('scan guards off mobile', () => { + it('scanCode rejects when not in the mobile build', async () => { + await expect(scanCode()).rejects.toThrow(/only available in the app/) + }) + + it('importCodeFromImage rejects when not in the mobile build', async () => { + const fakeFile = new Blob(['x'], { type: 'image/png' }) + await expect(importCodeFromImage(fakeFile)).rejects.toThrow(/only available in the app/) + }) +}) diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index 0059d37..740e50b 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -760,4 +760,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Auf 0 stellen, um zum Standard ({0}) zurückzukehren.', 'Applies to this exercise everywhere, not just this plan.': 'Gilt überall für diese Übung, nicht nur in diesem Plan.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Eingetragen wird weiterhin das Gesamtgewicht — die Stange zählt nur für die Scheiben-Rechnung pro Seite.', + // Gym check-in (mobile-only) + 'Check in': 'Einchecken', + 'At the gym': 'Im Studio', + 'Show this at the gym': 'Im Studio vorzeigen', + 'Add your gym card': 'Studio-Karte hinzufügen', + 'Add a card': 'Karte hinzufügen', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Tippe die Nummer deiner Mitgliedskarte ein, importiere ein Foto oder scanne sie mit der Kamera. Keine zusätzliche App im Studio nötig — öffne einfach diesen Bildschirm.', + 'Remove this card?': 'Diese Karte entfernen?', + 'Scan it, import a photo, or type the code by hand.': 'Scanne sie, importiere ein Foto oder tippe den Code von Hand ein.', + 'Scan': 'Scannen', + 'Import photo': 'Foto importieren', + 'Label': 'Bezeichnung', + 'e.g. FitZone downtown': 'z. B. FitZone Zentrum', + 'Code': 'Code', + 'Membership number or code': 'Mitgliedsnummer oder Code', + 'Save card': 'Karte speichern', + 'Gym card': 'Studio-Karte', + 'Card added': 'Karte hinzugefügt', + 'Nothing to save yet': 'Noch nichts zu speichern', + "That's not a QR code — only QR cards can be shown here": 'Das ist kein QR-Code — hier lassen sich nur QR-Karten anzeigen', + 'No QR code found in that image': 'Kein QR-Code im Bild gefunden', + 'Could not read that image': 'Bild konnte nicht gelesen werden', + 'Camera permission is needed to scan. Enable it in Settings.': 'Zum Scannen wird die Kamera-Berechtigung benötigt. Aktiviere sie in den Einstellungen.', + 'Scanning is not available on this device.': 'Scannen ist auf diesem Gerät nicht verfügbar.', + 'Could not start the scanner': 'Scanner konnte nicht gestartet werden', } diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 7765ede..b524f01 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Mets 0 pour revenir à la valeur par défaut ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'S’applique à cet exercice partout, pas seulement dans ce plan.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Tu enregistres toujours le poids total — la barre ne sert qu’au calcul des disques par côté.', + // Gym check-in (mobile-only) + 'Check in': 'Enregistrement', + 'At the gym': 'À la salle', + 'Show this at the gym': 'À présenter à la salle', + 'Add your gym card': 'Ajoute ta carte de salle', + 'Add a card': 'Ajouter une carte', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Saisis le numéro de ta carte de membre, importe une photo ou scanne-la avec l’appareil photo. Aucune autre appli nécessaire à la salle — ouvre simplement cet écran.', + 'Remove this card?': 'Supprimer cette carte ?', + 'Scan it, import a photo, or type the code by hand.': 'Scanne-la, importe une photo ou saisis le code à la main.', + 'Scan': 'Scanner', + 'Import photo': 'Importer une photo', + 'Label': 'Libellé', + 'e.g. FitZone downtown': 'p. ex. FitZone centre-ville', + 'Code': 'Code', + 'Membership number or code': 'Numéro de membre ou code', + 'Save card': 'Enregistrer la carte', + 'Gym card': 'Carte de salle', + 'Card added': 'Carte ajoutée', + 'Nothing to save yet': 'Rien à enregistrer pour l’instant', + "That's not a QR code — only QR cards can be shown here": 'Ce n’est pas un code QR — seules les cartes QR peuvent être affichées ici', + 'No QR code found in that image': 'Aucun code QR trouvé dans cette image', + 'Could not read that image': 'Impossible de lire cette image', + 'Camera permission is needed to scan. Enable it in Settings.': 'L’autorisation caméra est nécessaire pour scanner. Active-la dans les Réglages.', + 'Scanning is not available on this device.': 'Le scan n’est pas disponible sur cet appareil.', + 'Could not start the scanner': 'Impossible de démarrer le scanner', } diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 4096f21..919577d 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'डिफ़ॉल्ट ({0}) पर लौटने के लिए 0 सेट करें।', 'Applies to this exercise everywhere, not just this plan.': 'यह इस एक्सरसाइज़ पर हर जगह लागू होता है, सिर्फ़ इसी प्लान पर नहीं।', 'You still log the total weight — the bar only feeds the per-side plate math.': 'आप अब भी कुल वज़न ही दर्ज करते हैं — बार सिर्फ़ हर तरफ़ की प्लेट गिनती में काम आता है।', + // Gym check-in (mobile-only) + 'Check in': 'चेक इन', + 'At the gym': 'जिम में', + 'Show this at the gym': 'इसे जिम में दिखाएँ', + 'Add your gym card': 'अपना जिम कार्ड जोड़ें', + 'Add a card': 'कार्ड जोड़ें', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'अपने मेंबरशिप कार्ड का नंबर लिखें, उसकी फ़ोटो इम्पोर्ट करें, या कैमरे से स्कैन करें। जिम में किसी और ऐप की ज़रूरत नहीं — बस यह स्क्रीन खोलें।', + 'Remove this card?': 'यह कार्ड हटाएँ?', + 'Scan it, import a photo, or type the code by hand.': 'इसे स्कैन करें, फ़ोटो इम्पोर्ट करें, या कोड हाथ से लिखें।', + 'Scan': 'स्कैन करें', + 'Import photo': 'फ़ोटो इम्पोर्ट करें', + 'Label': 'लेबल', + 'e.g. FitZone downtown': 'जैसे FitZone डाउनटाउन', + 'Code': 'कोड', + 'Membership number or code': 'मेंबरशिप नंबर या कोड', + 'Save card': 'कार्ड सहेजें', + 'Gym card': 'जिम कार्ड', + 'Card added': 'कार्ड जोड़ा गया', + 'Nothing to save yet': 'अभी सहेजने के लिए कुछ नहीं', + "That's not a QR code — only QR cards can be shown here": 'यह QR कोड नहीं है — यहाँ केवल QR कार्ड दिखाए जा सकते हैं', + 'No QR code found in that image': 'उस छवि में कोई QR कोड नहीं मिला', + 'Could not read that image': 'वह छवि पढ़ी नहीं जा सकी', + 'Camera permission is needed to scan. Enable it in Settings.': 'स्कैन करने के लिए कैमरा अनुमति चाहिए। इसे सेटिंग्स में चालू करें।', + 'Scanning is not available on this device.': 'इस डिवाइस पर स्कैनिंग उपलब्ध नहीं है।', + 'Could not start the scanner': 'स्कैनर शुरू नहीं हो सका', } diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js index fd2b760..89c98f2 100644 --- a/frontend/src/locales/hu.js +++ b/frontend/src/locales/hu.js @@ -748,4 +748,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Állítsd 0-ra az alapérték ({0}) visszaállításához.', 'Applies to this exercise everywhere, not just this plan.': 'Mindenhol érvényes erre a gyakorlatra, nem csak ebben a tervben.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Továbbra is a teljes súlyt rögzíted — a rúd csak az oldalankénti tárcsaszámításhoz kell.', + // Gym check-in (mobile-only) + 'Check in': 'Bejelentkezés', + 'At the gym': 'A teremben', + 'Show this at the gym': 'Mutasd fel a teremben', + 'Add your gym card': 'Add hozzá a terembérleted', + 'Add a card': 'Kártya hozzáadása', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Írd be a tagsági kártyád számát, importálj róla egy fotót, vagy olvasd be a kamerával. Nincs szükség külön alkalmazásra a teremben — csak nyisd meg ezt a képernyőt.', + 'Remove this card?': 'Törlöd ezt a kártyát?', + 'Scan it, import a photo, or type the code by hand.': 'Olvasd be, importálj egy fotót, vagy írd be a kódot kézzel.', + 'Scan': 'Beolvasás', + 'Import photo': 'Fotó importálása', + 'Label': 'Címke', + 'e.g. FitZone downtown': 'pl. FitZone belváros', + 'Code': 'Kód', + 'Membership number or code': 'Tagsági szám vagy kód', + 'Save card': 'Kártya mentése', + 'Gym card': 'Terembérlet', + 'Card added': 'Kártya hozzáadva', + 'Nothing to save yet': 'Még nincs mit menteni', + "That's not a QR code — only QR cards can be shown here": 'Ez nem QR-kód — itt csak QR-kártyák jeleníthetők meg', + 'No QR code found in that image': 'Nem található QR-kód a képen', + 'Could not read that image': 'A kép nem olvasható be', + 'Camera permission is needed to scan. Enable it in Settings.': 'A beolvasáshoz kameraengedély szükséges. Engedélyezd a Beállításokban.', + 'Scanning is not available on this device.': 'A beolvasás nem érhető el ezen az eszközön.', + 'Could not start the scanner': 'A szkenner nem indítható el', } diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index 8f80be2..7aef968 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Imposta 0 per tornare al valore predefinito ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Vale per questo esercizio ovunque, non solo in questo piano.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Registri comunque il peso totale — il bilanciere serve solo al calcolo dei dischi per lato.', + // Gym check-in (mobile-only) + 'Check in': 'Check-in', + 'At the gym': 'In palestra', + 'Show this at the gym': 'Mostralo in palestra', + 'Add your gym card': 'Aggiungi la tua tessera', + 'Add a card': 'Aggiungi una tessera', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Digita il numero della tua tessera, importa una foto o scansionala con la fotocamera. Nessuna app extra in palestra — apri semplicemente questa schermata.', + 'Remove this card?': 'Rimuovere questa tessera?', + 'Scan it, import a photo, or type the code by hand.': 'Scansionala, importa una foto o digita il codice a mano.', + 'Scan': 'Scansiona', + 'Import photo': 'Importa foto', + 'Label': 'Etichetta', + 'e.g. FitZone downtown': 'es. FitZone centro', + 'Code': 'Codice', + 'Membership number or code': 'Numero tessera o codice', + 'Save card': 'Salva tessera', + 'Gym card': 'Tessera palestra', + 'Card added': 'Tessera aggiunta', + 'Nothing to save yet': 'Ancora niente da salvare', + "That's not a QR code — only QR cards can be shown here": 'Non è un codice QR — qui si possono mostrare solo tessere QR', + 'No QR code found in that image': 'Nessun codice QR trovato nell’immagine', + 'Could not read that image': 'Impossibile leggere l’immagine', + 'Camera permission is needed to scan. Enable it in Settings.': 'Per scansionare serve l’autorizzazione alla fotocamera. Attivala nelle Impostazioni.', + 'Scanning is not available on this device.': 'La scansione non è disponibile su questo dispositivo.', + 'Could not start the scanner': 'Impossibile avviare lo scanner', } diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index d341d8a..19f8c0d 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': '0으로 두면 기본값({0})으로 돌아갑니다.', 'Applies to this exercise everywhere, not just this plan.': '이 플랜만이 아니라 어디서든 이 운동에 적용됩니다.', 'You still log the total weight — the bar only feeds the per-side plate math.': '기록은 여전히 총 무게입니다 — 바 무게는 한쪽에 끼울 원판 계산에만 쓰입니다.', + // Gym check-in (mobile-only) + 'Check in': '체크인', + 'At the gym': '헬스장에서', + 'Show this at the gym': '헬스장에서 이것을 보여주세요', + 'Add your gym card': '헬스장 카드 추가', + 'Add a card': '카드 추가', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': '멤버십 카드 번호를 입력하거나, 사진을 가져오거나, 카메라로 스캔하세요. 헬스장에서 별도 앱이 필요 없이 이 화면만 열면 됩니다.', + 'Remove this card?': '이 카드를 삭제할까요?', + 'Scan it, import a photo, or type the code by hand.': '스캔하거나 사진을 가져오거나 코드를 직접 입력하세요.', + 'Scan': '스캔', + 'Import photo': '사진 가져오기', + 'Label': '이름', + 'e.g. FitZone downtown': '예: FitZone 시내점', + 'Code': '코드', + 'Membership number or code': '회원 번호 또는 코드', + 'Save card': '카드 저장', + 'Gym card': '헬스장 카드', + 'Card added': '카드가 추가되었습니다', + 'Nothing to save yet': '아직 저장할 내용이 없습니다', + "That's not a QR code — only QR cards can be shown here": 'QR 코드가 아닙니다 — 여기서는 QR 카드만 표시할 수 있습니다', + 'No QR code found in that image': '이미지에서 QR 코드를 찾을 수 없습니다', + 'Could not read that image': '이미지를 읽을 수 없습니다', + 'Camera permission is needed to scan. Enable it in Settings.': '스캔하려면 카메라 권한이 필요합니다. 설정에서 켜세요.', + 'Scanning is not available on this device.': '이 기기에서는 스캔을 사용할 수 없습니다.', + 'Could not start the scanner': '스캐너를 시작할 수 없습니다', } diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index d3668cd..aba75e4 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Ustaw 0, aby wrócić do wartości domyślnej ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Dotyczy tego ćwiczenia wszędzie, nie tylko w tym planie.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Nadal zapisujesz ciężar całkowity — gryf służy tylko do wyliczenia talerzy na stronę.', + // Gym check-in (mobile-only) + 'Check in': 'Zamelduj się', + 'At the gym': 'Na siłowni', + 'Show this at the gym': 'Pokaż to na siłowni', + 'Add your gym card': 'Dodaj kartę siłowni', + 'Add a card': 'Dodaj kartę', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Wpisz numer karty członkowskiej, zaimportuj jej zdjęcie lub zeskanuj aparatem. Na siłowni nie potrzebujesz osobnej aplikacji — po prostu otwórz ten ekran.', + 'Remove this card?': 'Usunąć tę kartę?', + 'Scan it, import a photo, or type the code by hand.': 'Zeskanuj ją, zaimportuj zdjęcie lub wpisz kod ręcznie.', + 'Scan': 'Skanuj', + 'Import photo': 'Importuj zdjęcie', + 'Label': 'Etykieta', + 'e.g. FitZone downtown': 'np. FitZone centrum', + 'Code': 'Kod', + 'Membership number or code': 'Numer członkowski lub kod', + 'Save card': 'Zapisz kartę', + 'Gym card': 'Karta siłowni', + 'Card added': 'Dodano kartę', + 'Nothing to save yet': 'Nie ma jeszcze nic do zapisania', + "That's not a QR code — only QR cards can be shown here": 'To nie jest kod QR — tutaj można pokazać tylko karty QR', + 'No QR code found in that image': 'Nie znaleziono kodu QR na tym obrazie', + 'Could not read that image': 'Nie udało się odczytać tego obrazu', + 'Camera permission is needed to scan. Enable it in Settings.': 'Do skanowania potrzebne jest pozwolenie na aparat. Włącz je w Ustawieniach.', + 'Scanning is not available on this device.': 'Skanowanie nie jest dostępne na tym urządzeniu.', + 'Could not start the scanner': 'Nie udało się uruchomić skanera', } diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index f57f794..ee3e43a 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -357,7 +357,20 @@ export const PT_BR_OVERRIDES = { 'Default for this bar type.': 'Padrão para este tipo de barra.', 'Set to 0 to go back to the default ({0}).': 'Defina 0 para voltar ao padrão ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Vale para este exercício em todos os lugares, não só neste plano.', - 'You still log the total weight — the bar only feeds the per-side plate math.': 'Você continua registrando o peso total — a barra só entra no cálculo das anilhas por lado.' + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Você continua registrando o peso total — a barra só entra no cálculo das anilhas por lado.', + // Gym check-in (mobile-only) — only where pt-BR differs from pt (inherited via ...pt) + 'At the gym': 'Na academia', + 'Show this at the gym': 'Mostre isto na academia', + 'Add your gym card': 'Adicione seu cartão da academia', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Digite o número do seu cartão de sócio, importe uma foto ou escaneie com a câmera. Não é preciso outro app na academia — é só abrir esta tela.', + 'Scan it, import a photo, or type the code by hand.': 'Escaneie, importe uma foto ou digite o código à mão.', + 'Scan': 'Escanear', + 'e.g. FitZone downtown': 'ex. FitZone centro', + 'Gym card': 'Cartão da academia', + 'Could not read that image': 'Não foi possível ler essa imagem', + 'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmera para escanear. Ative-a nos Ajustes.', + 'Scanning is not available on this device.': 'O escaneamento não está disponível neste dispositivo.', + 'Could not start the scanner': 'Não foi possível iniciar o scanner' } export default { ...pt, ...PT_BR_OVERRIDES } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 67c2ef2..391f79b 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Coloca 0 para voltar à predefinição ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Aplica-se a este exercício em todo o lado, não só neste plano.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Continuas a registar o peso total — a barra só conta para o cálculo dos discos por lado.', + // Gym check-in (mobile-only) + 'Check in': 'Check-in', + 'At the gym': 'No ginásio', + 'Show this at the gym': 'Mostra isto no ginásio', + 'Add your gym card': 'Adiciona o teu cartão de sócio', + 'Add a card': 'Adicionar um cartão', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Escreve o número do teu cartão de sócio, importa uma foto ou digitaliza-o com a câmara. Não é preciso outra app no ginásio — basta abrir este ecrã.', + 'Remove this card?': 'Remover este cartão?', + 'Scan it, import a photo, or type the code by hand.': 'Digitaliza-o, importa uma foto ou escreve o código à mão.', + 'Scan': 'Digitalizar', + 'Import photo': 'Importar foto', + 'Label': 'Etiqueta', + 'e.g. FitZone downtown': 'p. ex. FitZone centro', + 'Code': 'Código', + 'Membership number or code': 'Número de sócio ou código', + 'Save card': 'Guardar cartão', + 'Gym card': 'Cartão do ginásio', + 'Card added': 'Cartão adicionado', + 'Nothing to save yet': 'Ainda não há nada para guardar', + "That's not a QR code — only QR cards can be shown here": 'Isto não é um código QR — aqui só podem ser mostrados cartões QR', + 'No QR code found in that image': 'Nenhum código QR encontrado nessa imagem', + 'Could not read that image': 'Não foi possível ler essa imagem', + 'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmara para digitalizar. Ativa-a nas Definições.', + 'Scanning is not available on this device.': 'A digitalização não está disponível neste dispositivo.', + 'Could not start the scanner': 'Não foi possível iniciar o scanner', } diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index 93dd646..dddad4e 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Поставь 0, чтобы вернуться к значению по умолчанию ({0}).', 'Applies to this exercise everywhere, not just this plan.': 'Действует для этого упражнения везде, а не только в этом плане.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Записывается по-прежнему общий вес — гриф нужен только для расчёта блинов на сторону.', + // Gym check-in (mobile-only) + 'Check in': 'Отметиться', + 'At the gym': 'В зале', + 'Show this at the gym': 'Покажите это в зале', + 'Add your gym card': 'Добавьте карту зала', + 'Add a card': 'Добавить карту', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Введите номер клубной карты, импортируйте её фото или отсканируйте камерой. В зале не нужно отдельное приложение — просто откройте этот экран.', + 'Remove this card?': 'Удалить эту карту?', + 'Scan it, import a photo, or type the code by hand.': 'Отсканируйте её, импортируйте фото или введите код вручную.', + 'Scan': 'Сканировать', + 'Import photo': 'Импортировать фото', + 'Label': 'Название', + 'e.g. FitZone downtown': 'напр. FitZone в центре', + 'Code': 'Код', + 'Membership number or code': 'Номер участника или код', + 'Save card': 'Сохранить карту', + 'Gym card': 'Карта зала', + 'Card added': 'Карта добавлена', + 'Nothing to save yet': 'Пока нечего сохранять', + "That's not a QR code — only QR cards can be shown here": 'Это не QR-код — здесь можно показывать только QR-карты', + 'No QR code found in that image': 'На изображении не найден QR-код', + 'Could not read that image': 'Не удалось прочитать изображение', + 'Camera permission is needed to scan. Enable it in Settings.': 'Для сканирования нужен доступ к камере. Включите его в настройках.', + 'Scanning is not available on this device.': 'Сканирование недоступно на этом устройстве.', + 'Could not start the scanner': 'Не удалось запустить сканер', } diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js index e7c9406..b8ffd5e 100644 --- a/frontend/src/locales/th.js +++ b/frontend/src/locales/th.js @@ -756,4 +756,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'ตั้งเป็น 0 เพื่อกลับไปใช้ค่าเริ่มต้น ({0})', 'Applies to this exercise everywhere, not just this plan.': 'มีผลกับท่านี้ทุกที่ ไม่ใช่เฉพาะในแผนนี้', 'You still log the total weight — the bar only feeds the per-side plate math.': 'คุณยังบันทึกน้ำหนักรวมเหมือนเดิม — บาร์ใช้สำหรับคำนวณแผ่นน้ำหนักต่อข้างเท่านั้น', + // Gym check-in (mobile-only) + 'Check in': 'เช็คอิน', + 'At the gym': 'ที่ยิม', + 'Show this at the gym': 'แสดงสิ่งนี้ที่ยิม', + 'Add your gym card': 'เพิ่มบัตรสมาชิกยิมของคุณ', + 'Add a card': 'เพิ่มบัตร', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'พิมพ์หมายเลขบนบัตรสมาชิก นำเข้ารูปถ่าย หรือสแกนด้วยกล้อง ไม่ต้องใช้แอปอื่นที่ยิม — แค่เปิดหน้าจอนี้', + 'Remove this card?': 'ลบบัตรนี้หรือไม่?', + 'Scan it, import a photo, or type the code by hand.': 'สแกน นำเข้ารูปถ่าย หรือพิมพ์รหัสด้วยตนเอง', + 'Scan': 'สแกน', + 'Import photo': 'นำเข้ารูปถ่าย', + 'Label': 'ป้ายชื่อ', + 'e.g. FitZone downtown': 'เช่น FitZone ใจกลางเมือง', + 'Code': 'รหัส', + 'Membership number or code': 'หมายเลขสมาชิกหรือรหัส', + 'Save card': 'บันทึกบัตร', + 'Gym card': 'บัตรยิม', + 'Card added': 'เพิ่มบัตรแล้ว', + 'Nothing to save yet': 'ยังไม่มีอะไรให้บันทึก', + "That's not a QR code — only QR cards can be shown here": 'นี่ไม่ใช่คิวอาร์โค้ด — ที่นี่แสดงได้เฉพาะบัตรคิวอาร์โค้ดเท่านั้น', + 'No QR code found in that image': 'ไม่พบคิวอาร์โค้ดในรูปภาพนั้น', + 'Could not read that image': 'ไม่สามารถอ่านรูปภาพนั้นได้', + 'Camera permission is needed to scan. Enable it in Settings.': 'ต้องมีสิทธิ์กล้องเพื่อสแกน เปิดใช้งานในการตั้งค่า', + 'Scanning is not available on this device.': 'อุปกรณ์นี้ไม่รองรับการสแกน', + 'Could not start the scanner': 'ไม่สามารถเริ่มเครื่องสแกนได้', } diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 0ccd514..963912b 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': 'Varsayılana ({0}) dönmek için 0 yap.', 'Applies to this exercise everywhere, not just this plan.': 'Yalnızca bu planda değil, bu egzersiz için her yerde geçerli.', 'You still log the total weight — the bar only feeds the per-side plate math.': 'Yine de toplam ağırlığı kaydedersin — bar yalnızca taraf başına plaka hesabına girer.', + // Gym check-in (mobile-only) + 'Check in': 'Giriş yap', + 'At the gym': 'Salonda', + 'Show this at the gym': 'Bunu salonda göster', + 'Add your gym card': 'Salon kartını ekle', + 'Add a card': 'Kart ekle', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': 'Üyelik kartındaki numarayı yaz, fotoğrafını içe aktar ya da kamerayla tara. Salonda ekstra bir uygulamaya gerek yok — sadece bu ekranı aç.', + 'Remove this card?': 'Bu kart kaldırılsın mı?', + 'Scan it, import a photo, or type the code by hand.': 'Tara, bir fotoğraf içe aktar ya da kodu elle yaz.', + 'Scan': 'Tara', + 'Import photo': 'Fotoğraf içe aktar', + 'Label': 'Etiket', + 'e.g. FitZone downtown': 'örn. FitZone merkez', + 'Code': 'Kod', + 'Membership number or code': 'Üyelik numarası veya kodu', + 'Save card': 'Kartı kaydet', + 'Gym card': 'Salon kartı', + 'Card added': 'Kart eklendi', + 'Nothing to save yet': 'Henüz kaydedilecek bir şey yok', + "That's not a QR code — only QR cards can be shown here": 'Bu bir QR kod değil — burada yalnızca QR kartlar gösterilebilir', + 'No QR code found in that image': 'Bu görüntüde QR kod bulunamadı', + 'Could not read that image': 'Bu görüntü okunamadı', + 'Camera permission is needed to scan. Enable it in Settings.': 'Taramak için kamera izni gerekir. Ayarlar’dan etkinleştir.', + 'Scanning is not available on this device.': 'Tarama bu cihazda kullanılamıyor.', + 'Could not start the scanner': 'Tarayıcı başlatılamadı', } diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 2580efb..72b7cfb 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -743,4 +743,29 @@ export default { 'Set to 0 to go back to the default ({0}).': '设为 0 即恢复默认值({0})。', 'Applies to this exercise everywhere, not just this plan.': '对这个动作处处生效,不只在此计划中。', 'You still log the total weight — the bar only feeds the per-side plate math.': '记录的仍是总重量——杆重只用于每侧杠铃片的计算。', + // Gym check-in (mobile-only) + 'Check in': '签到', + 'At the gym': '在健身房', + 'Show this at the gym': '在健身房出示这个', + 'Add your gym card': '添加你的会员卡', + 'Add a card': '添加卡片', + 'Type the number on your membership card, import a photo of it, or scan it with the camera. No extra app needed at the gym — just open this screen.': '输入会员卡上的号码、导入卡片照片,或用相机扫描。在健身房无需额外应用——打开此界面即可。', + 'Remove this card?': '删除这张卡片?', + 'Scan it, import a photo, or type the code by hand.': '扫描它、导入照片,或手动输入代码。', + 'Scan': '扫描', + 'Import photo': '导入照片', + 'Label': '名称', + 'e.g. FitZone downtown': '例如 FitZone 市中心店', + 'Code': '代码', + 'Membership number or code': '会员号或代码', + 'Save card': '保存卡片', + 'Gym card': '健身房卡片', + 'Card added': '已添加卡片', + 'Nothing to save yet': '暂无可保存的内容', + "That's not a QR code — only QR cards can be shown here": '这不是二维码——此处只能显示二维码卡片', + 'No QR code found in that image': '在该图片中未找到二维码', + 'Could not read that image': '无法读取该图片', + 'Camera permission is needed to scan. Enable it in Settings.': '扫描需要相机权限。请在设置中开启。', + 'Scanning is not available on this device.': '此设备不支持扫描。', + 'Could not start the scanner': '无法启动扫描器', } diff --git a/frontend/src/store/useStore.gymcards.test.jsx b/frontend/src/store/useStore.gymcards.test.jsx new file mode 100644 index 0000000..8f0fe52 --- /dev/null +++ b/frontend/src/store/useStore.gymcards.test.jsx @@ -0,0 +1,69 @@ +// @vitest-environment happy-dom + +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +vi.mock('../lib/api.js', () => ({ api: vi.fn(), setRemoteAuth: vi.fn() })) + +import { DEF, useStore } from './useStore.js' + +const clone = value => JSON.parse(JSON.stringify(value)) + +beforeEach(() => { + localStorage.clear() + useStore.setState({ S: clone(DEF), user: null, ready: false }) +}) + +afterEach(() => { + localStorage.clear() + useStore.setState({ S: clone(DEF), user: null, ready: false }) +}) + +// gymCards is plain profile data — it rides the same update()/persist() path as everything else, +// with no backend or schema change. These pin the contract the check-in view relies on: a fresh +// profile starts empty, and adding/removing a card mutates and persists like any other field. + +describe('gymCards state', () => { + it('defaults to an empty array on a fresh profile', () => { + expect(useStore.getState().S.gymCards).toEqual([]) + }) + + it('adds a card via update and persists it to localStorage', () => { + useStore.getState().update(s => { + s.gymCards.push({ id: 'c1', label: 'FitZone', value: 'ABC123', fmt: 'qrcode' }) + }, false) + + const cards = useStore.getState().S.gymCards + expect(cards).toHaveLength(1) + expect(cards[0]).toMatchObject({ id: 'c1', label: 'FitZone', value: 'ABC123', fmt: 'qrcode' }) + + // persist() writes the whole state under the app's storage key — the card must be in it. + const saved = JSON.parse(localStorage.getItem('gym_state_v1')) + expect(saved.gymCards).toHaveLength(1) + expect(saved.gymCards[0].value).toBe('ABC123') + }) + + it('removes a card by id, leaving the others', () => { + useStore.getState().update(s => { + s.gymCards.push({ id: 'a', label: 'A', value: '1', fmt: 'qrcode' }) + s.gymCards.push({ id: 'b', label: 'B', value: '2', fmt: 'qrcode' }) + }, false) + + useStore.getState().update(s => { + s.gymCards = s.gymCards.filter(c => c.id !== 'a') + }, false) + + const cards = useStore.getState().S.gymCards + expect(cards).toHaveLength(1) + expect(cards[0].id).toBe('b') + }) + + it('keeps multiple cards in insertion order', () => { + useStore.getState().update(s => { + s.gymCards.push({ id: '1', label: 'One', value: 'x', fmt: 'qrcode' }) + s.gymCards.push({ id: '2', label: 'Two', value: 'y', fmt: 'qrcode' }) + s.gymCards.push({ id: '3', label: 'Three', value: 'z', fmt: 'qrcode' }) + }, false) + + expect(useStore.getState().S.gymCards.map(c => c.id)).toEqual(['1', '2', '3']) + }) +}) From 2899f27fa6ebe00e770a97057c4fd53d811740b0 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 14:06:50 +0200 Subject: [PATCH 3/8] CI: Pipelines fuer Fork-MRs, Testberichte im MR, Stack-Check der Images, Trivy+SBOM, Release-Preflight Was die Pipeline neu kann: - release:preflight prueft auf einem v*-Tag, dass frontend/api-package.json und CHANGELOG zum Tag passen und der Commit auf main liegt - bevor 40 Minuten Build anlaufen. - test:* liefern JUnit (Fehler stehen im MR-Widget) und Coverage (Badge + Diff-Annotation); test:frontend misst das Bundle und zeigt im MR die Differenz zu main. - verify:stack startet die gerade gepushten Images ueber die echte docker-compose.yml und fragt sie durch nginx ab; verify:scan (Trivy) scannt beide Images und legt je ein CycloneDX-SBOM ab, das der Release verlinkt. - Der Release nennt Digests, Pull-Befehl und APK-SHA-256. - mr:fork-pipelines startet die Pipelines von Fork-MRs bekannter Contributor hier im Projekt (Fork-Pipelines laufen sonst im Fork ohne Runner); Erstkontakte bekommen das Label ci-approval-needed. Braucht PIPELINE_API_TOKEN und den Zeitplan SCHEDULE_JOB=fork-mrs. Korrekturen: - web/Dockerfile: npm ci --ignore-scripts statt "npm ci || npm install" - der sharp/libvips-Download hatte v1.3.1 rot gemacht, und der Fallback ignorierte das Lockfile. - interruptible + Retry bei Runner-Fehlern fuer alle Jobs, Timeouts pro Job, release-cli gepinnt, Docker-/Rules-Vorlagen statt Copy-Paste. - Zeitplaene unterscheiden sich per SCHEDULE_JOB, damit Renovate und der MR-Starter sich nicht gegenseitig ausloesen. --- .gitignore | 5 + .gitlab-ci.yml | 465 ++++++++++++++++++++----- CONTRIBUTING.md | 14 + README.md | 2 + frontend/package-lock.json | 327 ++++++++++++++--- frontend/package.json | 1 + frontend/scripts/bundle-size.mjs | 73 ++++ mcp/package-lock.json | 580 ++++++++++++++++++++----------- mcp/package.json | 3 +- scripts/ci/fork-mr-pipelines.py | 124 +++++++ web/Dockerfile | 5 +- 11 files changed, 1259 insertions(+), 340 deletions(-) create mode 100644 frontend/scripts/bundle-size.mjs create mode 100755 scripts/ci/fork-mr-pipelines.py diff --git a/.gitignore b/.gitignore index 88720c4..41d8817 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,8 @@ node_modules/ node_modules .claude/ .agents/ + +# CI reports (test:* jobs write these next to the suites) +junit.xml +coverage/ +frontend/bundle-size.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4ef730..f06e849 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,12 +5,20 @@ # gitea.com ones (.gitea/, kept only so the mirror stays buildable). # # What it does, in order: -# test — frontend, MCP and api (Coach) suites, on every branch, MR and tag -# build — the two container images → registry.gitlab.com/duartesantos8/opengym/{api,web}, -# and a run of both api targets that proves what each one does and does not carry -# package — the signed Android APK → job artifact + generic package registry -# deploy — the browser-only demo → GitLab Pages -# release — a GitLab Release with the changelog section and links to APK + images +# test — frontend, MCP and api (Coach) suites on every branch, MR and tag, each with a +# JUnit report (failures show up in the MR widget) and coverage; the frontend +# job also measures the bundle and compares it with main's. +# On a v* tag: release:preflight checks tag, package versions and CHANGELOG +# before anything expensive starts. +# build — the two container images → registry.gitlab.com/duartesantos8/opengym/{api,web}, +# and a run of both api targets that proves what each one does and does not carry +# package — the signed Android APK → job artifact + generic package registry +# verify — the images that were just pushed, started together through docker-compose.yml +# and asked to serve; plus a Trivy scan and an SBOM per image +# deploy — the browser-only demo → GitLab Pages +# release — a GitLab Release: changelog section, install commands, image digests, +# links to APK, checksum and SBOMs +# maintenance — Renovate (scheduled) and the fork-MR pipeline starter (scheduled + main) # # One deliberate difference from the GitHub copy: GitHub could distinguish a bare tag # push from a *published* release, and only shipped images from the latter (issue #87 — @@ -19,11 +27,18 @@ # rule is enforced by hand — **only push a tag when you actually mean to release it.** # Everything version-tagged (latest images, signed APK, Release) hangs off `v*` tags, # which are protected, so nobody else can trigger a release either. +# +# Contributor merge requests come from forks, and on gitlab.com a fork's pipeline runs in the +# fork — where almost nobody has runners enabled. So those MRs would sit at "no pipeline" +# forever. `mr:fork-pipelines` (bottom of this file) starts them here instead, for returning +# contributors; first-timers get the `ci-approval-needed` label and a maintainer presses +# "Run pipeline" on the MR after reading the diff. stages: - test - build - package + - verify - deploy - release - maintenance @@ -31,11 +46,35 @@ stages: variables: # node:22-alpine in web/Dockerfile and api/Dockerfile — CI must match production. NODE_IMAGE: "node:22-alpine" + DOCKER_IMAGE: "docker:28-cli" + DOCKER_DIND_IMAGE: "docker:28-dind" + TRIVY_IMAGE: "aquasec/trivy:0.74.0" # The demo build has no backend and no local media: the exercise images/GIFs (~140 MB) # are never committed, so it points at the upstream dataset on jsDelivr, pinned to a # commit so the CDN can cache it forever. DATASET: "https://cdn.jsdelivr.net/gh/hasaneyldrm/exercises-dataset@7455efae41b330c265e7cd4b78dfa848e7ce5ebd" GIT_DEPTH: "50" + # npm's own progress bars and funding notices are noise in a job log. + npm_config_fund: "false" + npm_config_audit: "false" + npm_config_progress: "false" + +default: + # A newer push to the same branch cancels the pipeline that is still running for the old + # one — every job, not just the ones that had not started yet. Tag pipelines are never + # superseded, and `release` opts out below anyway. + interruptible: true + # Infrastructure hiccups (runner lost, docker daemon not answering) get one automatic + # second try. A failing script does not — that one is the job's actual verdict. + retry: + max: 1 + when: + - runner_system_failure + - stuck_or_timeout_failure + - api_failure + - scheduler_failure + - data_integrity_failure + - unknown_failure # Branch pipeline *or* MR pipeline, never both for the same commit. workflow: @@ -46,11 +85,65 @@ workflow: - if: $CI_COMMIT_TAG - if: $CI_COMMIT_BRANCH -# ---------------------------------------------------------------------------- test +# ------------------------------------------------------------------------- templates + +# Every scheduled pipeline is a maintenance run (Renovate, the fork-MR starter) and says +# which one through its SCHEDULE_JOB variable. Nothing else may run on a schedule — the +# monthly Renovate run must not re-test the tree and republish the edge images for nothing. +.rules: + not_on_schedule: + - if: $CI_PIPELINE_SOURCE == "schedule" + when: never .node: image: $NODE_IMAGE - interruptible: true + timeout: 20 minutes + +# docker-in-docker with TLS, the way gitlab.com's shared runners expect it. +.docker: + image: $DOCKER_IMAGE + services: + - $DOCKER_DIND_IMAGE + variables: + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + DOCKER_TLS_VERIFY: "1" + DOCKER_CERT_PATH: "/certs/client" + timeout: 40 minutes + +# The only way to tell a v* tag pipeline apart from everything else. Release-only jobs and +# the "build it like a release" paths key off this. +.release_tag: &release_tag + if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + +# ---------------------------------------------------------------------------- test + +# A release is `git tag`, nothing else — so the tag has to be checked before the pipeline +# spends forty minutes building it. Everything in the build stage `needs` this job when it +# exists, so a bad tag stops here with a one-line reason rather than a half-published release. +release:preflight: + extends: .node + stage: test + timeout: 5 minutes + script: + - apk add --no-cache git >/dev/null + - | + set -eu + SEMVER="${CI_COMMIT_TAG#v}" + fail() { echo "FATAL: $*" >&2; exit 1; } + for pkg in frontend/package.json api/package.json; do + v="$(node -p "require('./$pkg').version")" + [ "$v" = "$SEMVER" ] || fail "$CI_COMMIT_TAG but $pkg says $v — bump it (or tag the bump commit) and re-tag" + done + grep -Eq "^## $CI_COMMIT_TAG([^0-9.]|$)" CHANGELOG.md \ + || fail "CHANGELOG.md has no '## $CI_COMMIT_TAG' section — the release notes come from there" + # A release of a commit that is not on main would ship code main does not have. + git fetch --depth=1000 origin "$CI_DEFAULT_BRANCH" + git merge-base --is-ancestor "$CI_COMMIT_SHA" FETCH_HEAD \ + || fail "$CI_COMMIT_TAG points at $CI_COMMIT_SHORT_SHA, which is not on $CI_DEFAULT_BRANCH" + echo "OK: $CI_COMMIT_TAG = frontend $SEMVER = api $SEMVER, changelog section present, on $CI_DEFAULT_BRANCH" + rules: + - *release_tag test:frontend: extends: .node @@ -63,10 +156,25 @@ test:frontend: - frontend/.npm script: - cd frontend - - npm ci --cache .npm --prefer-offline - - npm test + # --ignore-scripts: nothing here needs a postinstall, and the one package that has a + # heavy one (@capacitor/assets → sharp, a 10 MB libvips download from GitHub) is only + # used to draw app icons. That download timing out is what turned a release red. + - npm ci --cache .npm --prefer-offline --ignore-scripts + # JUnit → the MR widget lists exactly which tests failed; cobertura → coverage on the + # diff; text-summary → the number the coverage badge shows. + - npx vitest run + --reporter=default --reporter=junit --outputFile.junit=junit.xml + --coverage --coverage.reporter=text-summary --coverage.reporter=cobertura # A broken import or bad JSX fails the build long before any test covers it. - npm run build + # What this commit costs on the wire, and — in an MR — what it adds compared with main. + # main's numbers are the artifact of its last green test:frontend; report-only. + - node scripts/bundle-size.mjs --out bundle-size.json + - | + if [ "$CI_COMMIT_BRANCH" != "$CI_DEFAULT_BRANCH" ]; then + wget -qO baseline.json "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_DEFAULT_BRANCH/raw/frontend/bundle-size.json?job=test:frontend" || true + node scripts/bundle-size.mjs --compare baseline.json bundle-size.json + fi - node scripts/check-locales.mjs # check-locales compares the packs to each other, so a key missing from ALL of them is # invisible to it. This walks src/ instead. Report-only for now: there is a known @@ -75,11 +183,19 @@ test:frontend: # The fatigue model must never read higher after a rest day than before it. # Property probe over ~108k comparisons; too slow for the unit suite, cheap here. - npm run test:fatigue-probe + coverage: '/Lines\s*:\s*(\d+\.?\d*)%/' + artifacts: + when: always + paths: + - frontend/bundle-size.json + reports: + junit: frontend/junit.xml + coverage_report: + coverage_format: cobertura + path: frontend/coverage/cobertura-coverage.xml + expire_in: 2 weeks rules: - # A scheduled pipeline exists only to run `renovate` (bottom of this file) — it must not - # re-run the suite or republish the edge images once a month for nothing. - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never + - !reference [.rules, not_on_schedule] - when: on_success test:mcp: @@ -93,18 +209,25 @@ test:mcp: - mcp/.npm script: - cd mcp - - npm ci --cache .npm --prefer-offline - - npm test + - npm ci --cache .npm --prefer-offline --ignore-scripts + - npx vitest run + --reporter=default --reporter=junit --outputFile.junit=junit.xml + --coverage --coverage.reporter=text-summary --coverage.reporter=cobertura # The one check the vitest suite structurally cannot make. The MCP server is a bare node # process, but vitest runs its tests through Vite — import.meta.glob, .jsx imports and # ?raw all resolve happily there. That is how a Vite-only import reached a shared lib # module with 33 green tests standing over a server that died on startup. - npm run check:node-loadable + coverage: '/Lines\s*:\s*(\d+\.?\d*)%/' + artifacts: + when: always + reports: + junit: mcp/junit.xml + coverage_report: + coverage_format: cobertura + path: mcp/coverage/cobertura-coverage.xml rules: - # A scheduled pipeline exists only to run `renovate` (bottom of this file) — it must not - # re-run the suite or republish the edge images once a month for nothing. - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never + - !reference [.rules, not_on_schedule] - when: on_success test:api: @@ -121,7 +244,11 @@ test:api: - npm ci --cache .npm --prefer-offline --omit=optional # The Coach tests run on node:test and drive the in-repo fixture provider plus a local mock # of the Chat Completions shape, so the whole job works without an AI account or the network. - - npm test + # Same suite `npm test` runs, plus the JUnit file and node's own coverage table. + - node --experimental-test-coverage --test + --test-reporter=spec --test-reporter-destination=stdout + --test-reporter=junit --test-reporter-destination=junit.xml + test/*.test.js - cd .. # The api's copy of the exercise catalogue and the prompt module are generated and committed. # A dataset or prompt change that forgets to regenerate them would otherwise only surface as @@ -130,9 +257,13 @@ test:api: # api/coach/core is imported by the server under bare node AND by the phone under Vite. # vitest forgives what node does not (?raw, import.meta.glob); this runs outside vitest. - node api/scripts/check-core-loadable.mjs + coverage: '/all files\s*\|\s*(\d+\.?\d*)/' + artifacts: + when: always + reports: + junit: api/junit.xml rules: - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never + - !reference [.rules, not_on_schedule] - when: on_success # --------------------------------------------------------------------------- images @@ -150,17 +281,18 @@ test:api: # `latest` and the version out of frontend/package.json — without cutting a release. It is # there for the rebuild-without-a-code-change case: a base image picking up a CVE fix, where # the published `latest` needs to move but the app did not change. +# +# Each matrix job hands the tag and digest of what it pushed to the later stages (images-*.env): +# verify:stack starts exactly these images, and the Release lists them. build:images: + extends: .docker stage: build - image: docker:28-cli - services: - - docker:28-dind - variables: - DOCKER_HOST: tcp://docker:2376 - DOCKER_TLS_CERTDIR: "/certs" - DOCKER_TLS_VERIFY: "1" - DOCKER_CERT_PATH: "/certs/client" - needs: ["test:frontend", "test:mcp", "test:api"] + needs: + - test:frontend + - test:mcp + - test:api + - job: release:preflight + optional: true parallel: matrix: - IMAGE: api @@ -192,6 +324,7 @@ build:images: echo "PUBLISH_LATEST: building $SEMVER off $CI_COMMIT_REF_NAME, no release involved" fi VERSION="v$SEMVER" + IMAGE_TAG="$SEMVER" PLATFORMS="linux/amd64,linux/arm64" TAGS="-t $REPO:$SEMVER -t $REPO:${SEMVER%.*} -t $REPO:latest" # Only the arm64 leg needs emulation, and only for the api image (web's build @@ -199,6 +332,7 @@ build:images: docker run --privileged --rm tonistiigi/binfmt --install arm64 else VERSION="main-$CI_COMMIT_SHORT_SHA" + IMAGE_TAG="$VERSION" PLATFORMS="linux/amd64" TAGS="-t $REPO:edge -t $REPO:$VERSION" fi @@ -216,12 +350,19 @@ build:images: $TAGS \ --push \ "$CONTEXT" + DIGEST="$(docker buildx imagetools inspect "$REPO:$IMAGE_TAG" --format '{{.Manifest.Digest}}')" + echo "pushed $REPO:$IMAGE_TAG @ $DIGEST" + UPPER="$(echo "$IMAGE" | tr a-z A-Z)" + { + echo "IMAGE_TAG=$IMAGE_TAG" + echo "IMAGE_DIGEST_$UPPER=$DIGEST" + } > "images-$IMAGE.env" + artifacts: + reports: + dotenv: images-$IMAGE.env rules: - # A scheduled pipeline exists only to run `renovate` (bottom of this file) — it must not - # re-run the suite or republish the edge images once a month for nothing. - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never - - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + - !reference [.rules, not_on_schedule] + - *release_tag - if: ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "api") && $PUBLISH_LATEST - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == "merge_request_event" @@ -235,15 +376,8 @@ build:images: # the coach one additionally resolves the Agent SDK's per-platform runtime (musl on this base), # which is the one thing that cannot be checked from the source tree. amd64 only, never pushed. build:api-check: + extends: .docker stage: build - image: docker:28-cli - services: - - docker:28-dind - variables: - DOCKER_HOST: tcp://docker:2376 - DOCKER_TLS_CERTDIR: "/certs" - DOCKER_TLS_VERIFY: "1" - DOCKER_CERT_PATH: "/certs/client" needs: ["test:api"] script: - docker build --target default -t opengym-api:default ./api @@ -305,9 +439,8 @@ build:api-check: # user disables every one of their jobs — including the fixture. Cheaper to assert here. docker run --rm opengym-api:default id coach rules: - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never - - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + - !reference [.rules, not_on_schedule] + - *release_tag - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == "merge_request_event" changes: @@ -323,15 +456,8 @@ build:api-check: # Pages build goes through that Dockerfile, so an MR could pass everything and still ship an # image that does not build (v1.2.15 did). Built here, never pushed. build:web-check: + extends: .docker stage: build - image: docker:28-cli - services: - - docker:28-dind - variables: - DOCKER_HOST: tcp://docker:2376 - DOCKER_TLS_CERTDIR: "/certs" - DOCKER_TLS_VERIFY: "1" - DOCKER_CERT_PATH: "/certs/client" needs: ["test:frontend"] script: - docker build -f web/Dockerfile -t opengym-web:check . @@ -344,9 +470,8 @@ build:web-check: docker exec web-check sh -c 'grep -l "coach" /usr/share/nginx/html/assets/index-*.js >/dev/null' docker rm -f web-check rules: - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never - - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + - !reference [.rules, not_on_schedule] + - *release_tag - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == "merge_request_event" changes: @@ -374,7 +499,11 @@ build:web-check: build:apk: stage: package image: cimg/android:2026.08-node - needs: ["test:frontend"] + timeout: 40 minutes + needs: + - test:frontend + - job: release:preflight + optional: true variables: GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle" GRADLE_OPTS: "-Dorg.gradle.daemon=false" @@ -429,6 +558,7 @@ build:apk: # digest next to it rather than leaving people to trust the download. sha256sum "openGym-$APK_VERSION.apk" > "openGym-$APK_VERSION.apk.sha256" cat "openGym-$APK_VERSION.apk.sha256" + echo "APK_SHA256=$(cut -d' ' -f1 "openGym-$APK_VERSION.apk.sha256")" >> apk.env for f in "openGym-$APK_VERSION.apk" "openGym-$APK_VERSION.apk.sha256"; do curl --fail --silent --show-error \ --header "JOB-TOKEN: $CI_JOB_TOKEN" \ @@ -446,11 +576,8 @@ build:apk: dotenv: apk.env expire_in: 30 days rules: - # A scheduled pipeline exists only to run `renovate` (bottom of this file) — it must not - # re-run the suite or republish the edge images once a month for nothing. - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never - - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + - !reference [.rules, not_on_schedule] + - *release_tag # An APK build is ~8 minutes of shared-runner time; on main and MRs it is one click # away rather than automatic. Flip `when: manual` off to have every push build one. - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -460,6 +587,116 @@ build:apk: when: manual allow_failure: true +# --------------------------------------------------------------------------- verify + +# The two images that were just pushed, started the way a self-hoster starts them — through +# the repository's own docker-compose.yml — and asked to serve through nginx. build:api-check +# and build:web-check each prove one container on its own; this is the only place the +# proxy between them, the compose file and the *pushed* artifacts are exercised together. +# On a tag the Release waits for it. +verify:stack: + extends: .docker + stage: verify + timeout: 15 minutes + needs: + - job: build:images + artifacts: true + script: + - docker compose version + - | + set -eu + # The compose file reads .env (RP_ID/ORIGIN for passkeys); none of it matters for GET. + cp .env.example .env + cat > ci-images.override.yml </dev/null 2>&1 && break + sleep 1 + done + echo "--- /api/health through nginx"; curl -fsS http://web/api/health | grep -q '"ok":true' + echo "--- /api/config through nginx"; curl -fsS http://web/api/config | tee /dev/stderr | grep -q '"invite_only"' + echo "--- the app shell"; curl -fsS http://web/ | grep -q '
' + echo "--- revision labels" + for i in api web; do + docker inspect --format '{{index .Config.Labels "org.opencontainers.image.revision"}}' "$CI_REGISTRY_IMAGE/$i:$IMAGE_TAG" \ + | grep -q "$CI_COMMIT_SHA" || { echo "$i image does not carry this commit's revision label" >&2; exit 1; } + done + docker compose -f docker-compose.yml -f ci-images.override.yml logs --no-color api | tail -20 + docker compose -f docker-compose.yml -f ci-images.override.yml down -v + echo "OK: api:$IMAGE_TAG + web:$IMAGE_TAG serve together" + rules: + - !reference [.rules, not_on_schedule] + - *release_tag + - if: ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "api") && $PUBLISH_LATEST + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +# What the pushed images carry: a Trivy scan of OS packages and the npm trees (fixable +# HIGH/CRITICAL only — an unfixed CVE in alpine is not something a release can wait for), and +# a CycloneDX SBOM per image. On a tag the SBOMs go to the package registry and the Release +# links them. Findings turn the job yellow, never the pipeline red: the point is that the +# maintainer *sees* them next to the release, and Renovate opens the fix. +verify:scan: + stage: verify + image: + name: $TRIVY_IMAGE + entrypoint: [""] + timeout: 15 minutes + needs: + - job: build:images + artifacts: true + variables: + TRIVY_CACHE_DIR: "$CI_PROJECT_DIR/.trivycache" + TRIVY_NO_PROGRESS: "true" + TRIVY_USERNAME: "$CI_REGISTRY_USER" + TRIVY_PASSWORD: "$CI_REGISTRY_PASSWORD" + cache: + key: trivy-db + paths: + - .trivycache/ + script: + - apk add --no-cache curl >/dev/null + - | + set -u + rc=0 + for i in api web; do + REF="$CI_REGISTRY_IMAGE/$i:$IMAGE_TAG" + echo "=================== $REF" + trivy image --format cyclonedx --output "opengym-$i-$IMAGE_TAG.cdx.json" "$REF" + trivy image --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 "$REF" || rc=1 + done + if [ -n "${CI_COMMIT_TAG:-}" ]; then + for f in opengym-*.cdx.json; do + curl --fail --silent --show-error --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "$f" \ + "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/opengym-sbom/$IMAGE_TAG/$f" + echo "uploaded $f to the generic package registry" + done + fi + [ "$rc" = 0 ] || echo "fixable HIGH/CRITICAL findings above — see the tables; the release is not blocked" + exit $rc + artifacts: + when: always + paths: + - "opengym-*.cdx.json" + expire_in: 90 days + allow_failure: true + rules: + - !reference [.rules, not_on_schedule] + - *release_tag + - if: ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "api") && $PUBLISH_LATEST + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + # ---------------------------------------------------------------------------- pages # The browser-only demo: https://opengym-bc111a.gitlab.io/ @@ -474,9 +711,15 @@ pages: needs: ["test:frontend"] variables: VITE_DEMO: "1" + cache: + key: + files: + - frontend/package-lock.json + paths: + - frontend/.npm script: - cd frontend - - npm ci + - npm ci --cache .npm --prefer-offline --ignore-scripts - VITE_IMG_BASE="$DATASET/images/" VITE_GIF_BASE="$DATASET/videos/" npm run build - cd .. - rm -rf public && mv frontend/dist public @@ -484,14 +727,12 @@ pages: paths: - public rules: - # A scheduled pipeline exists only to run `renovate` (bottom of this file) — it must not - # re-run the suite or republish the edge images once a month for nothing. - - if: $CI_PIPELINE_SOURCE == "schedule" - when: never + - !reference [.rules, not_on_schedule] - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH changes: paths: - "frontend/**/*" + - "api/coach/core/**/*" - ".gitlab-ci.yml" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH when: manual @@ -501,16 +742,25 @@ pages: release: stage: release - image: registry.gitlab.com/gitlab-org/release-cli:latest + image: registry.gitlab.com/gitlab-org/release-cli:v0.24.0 + interruptible: false + timeout: 10 minutes needs: - job: build:images + artifacts: true - job: build:apk artifacts: true + - job: verify:stack + artifacts: false + - job: verify:scan + artifacts: false rules: - - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + - *release_tag script: # The release notes are the matching section of CHANGELOG.md, verbatim — headings # there are "## v1.2.9 — 2026-08-23", so take everything up to the next "## ". + # release:preflight already made sure the section exists. Below it: how to install + # this exact build, with the digests the images were pushed under. - | set -eu awk -v tag="$CI_COMMIT_TAG" ' @@ -518,10 +768,26 @@ release: inside && /^## / { exit } inside { print } ' CHANGELOG.md > release-notes.md - if [ ! -s release-notes.md ]; then - echo "openGym $CI_COMMIT_TAG" > release-notes.md - fi - head -40 release-notes.md + SEMVER="${CI_COMMIT_TAG#v}" + MINOR="${SEMVER%.*}" + cat >> release-notes.md < [![Pipeline](https://gitlab.com/DuarteSantos8/opengym/badges/main/pipeline.svg?style=flat-square)](https://gitlab.com/DuarteSantos8/opengym/-/pipelines) +[![Coverage](https://gitlab.com/DuarteSantos8/opengym/badges/main/coverage.svg?job=test:frontend&style=flat-square)](https://gitlab.com/DuarteSantos8/opengym/-/pipelines?ref=main) +[![Release](https://gitlab.com/DuarteSantos8/opengym/-/badges/release.svg?style=flat-square)](https://gitlab.com/DuarteSantos8/opengym/-/releases) ![Last commit](https://img.shields.io/gitlab/last-commit/DuarteSantos8%2Fopengym?style=flat-square) [![Stars](https://img.shields.io/gitlab/stars/DuarteSantos8%2Fopengym?style=flat-square)](https://gitlab.com/DuarteSantos8/opengym/-/starrers) [![Issues](https://img.shields.io/gitlab/issues/open/DuarteSantos8%2Fopengym?style=flat-square)](https://gitlab.com/DuarteSantos8/opengym/-/issues) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b343bcc..b7956fa 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -26,6 +26,7 @@ "@capacitor/cli": "^7.6.8", "@capacitor/ios": "^7.6.8", "@vitejs/plugin-react": "^6.0.3", + "@vitest/coverage-v8": "^4.1.11", "happy-dom": "^20.11.2", "linkedom": "^0.18.13", "vite": "^8.1.5", @@ -60,6 +61,16 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/helper-validator-identifier": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", @@ -69,6 +80,46 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/@capacitor/android": { "version": "7.6.8", "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-7.6.8.tgz", @@ -1066,7 +1117,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@trapezedev/gradle-parse": { "version": "7.1.3", @@ -1235,6 +1287,7 @@ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", "dev": true, + "license": "MIT", "dependencies": { "@types/deep-eql": "*", "assertion-error": "^2.0.1" @@ -1244,13 +1297,15 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/estree": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/fs-extra": { "version": "8.1.5", @@ -1670,16 +1725,48 @@ } } }, - "node_modules/@vitest/expect": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.10.tgz", - "integrity": "sha512-YsCn+qAk1GWjQOWFEsEcL2gNQ0zmVmQu3T03qP6UyjhtmdtwtbuI+DASn/7iQB3HGTXkdBwGddzxPlmiql5vlA==", + "node_modules/@vitest/coverage-v8": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.11.tgz", + "integrity": "sha512-8MVGEFnJIcdGjcbfKmeq8z0pZHH0JlVtoVZH9Q/qwUp6wyFnEJUBMrw9DCaj+ra3vShGmhavjalMIhPNxZAUcw==", "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/utils": "4.1.11", + "ast-v8-to-istanbul": "^1.0.0", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.2.0", + "magicast": "^0.5.2", + "obug": "^2.1.1", + "std-env": "^4.0.0-rc.1", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "4.1.11", + "vitest": "4.1.11" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "node_modules/@vitest/expect": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.11.tgz", + "integrity": "sha512-VX2x5vNJXET47KAFzwERI+KRMtTTCSWTfSMKsW7JsUsXV4psq++e3DvZpuTDOpHcxytiDs6p2nhVb2tVDiiUYw==", + "dev": true, + "license": "MIT", "dependencies": { "@standard-schema/spec": "^1.1.0", "@types/chai": "^5.2.2", - "@vitest/spy": "4.1.10", - "@vitest/utils": "4.1.10", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", "chai": "^6.2.2", "tinyrainbow": "^3.1.0" }, @@ -1688,12 +1775,13 @@ } }, "node_modules/@vitest/mocker": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.10.tgz", - "integrity": "sha512-v0xaezt+DKEmKfaxg133ldzADrwLGd7Ze1MfQQTYfvs8OqZIwbxyxaYURivwV7sWy5fqn3rH5uOrSp07bp44Ow==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.11.tgz", + "integrity": "sha512-2XJVD55d1o5AZous5CCGKS74g/riOj9odEt2bQpCVZeblHyHdnMeFl4jl0XjU21stf4mbjUkew2eXQZt65g5CQ==", "dev": true, + "license": "MIT", "dependencies": { - "@vitest/spy": "4.1.10", + "@vitest/spy": "4.1.11", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, @@ -1714,10 +1802,11 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.10.tgz", - "integrity": "sha512-W1HsjSH4MXQ9YfmmhLAoIYf1HRfekQCGngeIgcei6MP5QQGWUe0gkopdZQaVCFO+JDJMrAJGwa5pRpNpvy4P8Q==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.11.tgz", + "integrity": "sha512-yiZzPbGTS9Sr/JpFl8zHrcIkAofNbFV6k21vIgQN/cY/oxZeXhJv5sc/MBJ5jFKWmWs+oJHw0UXLZjmf931+Vw==", "dev": true, + "license": "MIT", "dependencies": { "tinyrainbow": "^3.1.0" }, @@ -1726,12 +1815,13 @@ } }, "node_modules/@vitest/runner": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.10.tgz", - "integrity": "sha512-IKI6kpIH+LmpROplyLwBBaCfMgOZOMsygVa6BARD6ahA04VRuJSa6OaVG7kRvSEMD870Vd91rSSw0eegtWyLGg==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.11.tgz", + "integrity": "sha512-LztvUgdwMNJMIkj3hQnnxiC2Xy1zNxq928W/xhjCLaNCzqTZOudjwbQf6v9IntZGPw132i2Lq2rgTRZHD3JHNw==", "dev": true, + "license": "MIT", "dependencies": { - "@vitest/utils": "4.1.10", + "@vitest/utils": "4.1.11", "pathe": "^2.0.3" }, "funding": { @@ -1739,13 +1829,14 @@ } }, "node_modules/@vitest/snapshot": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.10.tgz", - "integrity": "sha512-xRkfOT1qpTAi/Ti4Y1LtfRc3kEuqxGw59eN2jN9pRWMtS/XDevekhcFSqvQqjUNGksfjMJu3Y+oJ+4Ypn2OaJw==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.11.tgz", + "integrity": "sha512-pN7ikn1ON7h8ee4gIAp4AzyK+zBtJPzVbqOgu5LCEh4VaJVbPQcgYQYJIMGQPXVeJJq1fnfazis7a5pFNPahog==", "dev": true, + "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.1.10", - "@vitest/utils": "4.1.10", + "@vitest/pretty-format": "4.1.11", + "@vitest/utils": "4.1.11", "magic-string": "^0.30.21", "pathe": "^2.0.3" }, @@ -1754,21 +1845,23 @@ } }, "node_modules/@vitest/spy": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.10.tgz", - "integrity": "sha512-PLf/Ugvoq5wO/b4rwYCR1h2PSIdXz7wnkQFMiUpLdtM7l6pqVFcQIBEHyT1+l+cj7mNwAfZHzqXqDyjvOuwbDw==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.11.tgz", + "integrity": "sha512-apNa/prQy2qCeywhnixOHPRCgGNhvg7T4Dapfl1GahLp/R+uhBm5cPyFoNVyqsNd2h1nJxL6BqqdIjiABL60YA==", "dev": true, + "license": "MIT", "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/utils": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.10.tgz", - "integrity": "sha512-fy9am/HWxbaGt/Sawrp90vt6Y6jQwf1RX77cz3uwoJwJVMli/e1IEwRPnMNJ7vKfPTwo0diXifkpPvwH9v7nGA==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.11.tgz", + "integrity": "sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ==", "dev": true, + "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.1.10", + "@vitest/pretty-format": "4.1.11", "convert-source-map": "^2.0.0", "tinyrainbow": "^3.1.0" }, @@ -1874,10 +1967,41 @@ "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", "dev": true, + "license": "MIT", "engines": { "node": ">=12" } }, + "node_modules/ast-v8-to-istanbul": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.5.tgz", + "integrity": "sha512-UPAgKJFSEGMWSDr3LX4tqnAb4f7KGT8O40Tyx8wbYmmZ/yn58lNCm8h3svs3eXgiGd5AXxz8NDOvXWvicq+rJA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^10.0.0" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/js-tokens": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", + "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", @@ -2155,6 +2279,7 @@ "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", "dev": true, + "license": "MIT", "engines": { "node": ">=18" } @@ -2552,7 +2677,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/cookie": { "version": "1.1.1", @@ -2933,6 +3059,7 @@ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", "dev": true, + "license": "MIT", "dependencies": { "@types/estree": "^1.0.0" } @@ -3676,6 +3803,75 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-reports/node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4244,10 +4440,39 @@ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/magicast": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.4.tgz", + "integrity": "sha512-llBEhWm1SacoRwgHUoQJYtwp4PBLF4faQi5TCpIGyGs9n4y5+juI0tDgyKIfpqxckRHaHzouUEph3THklWh03w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", + "source-map-js": "^1.2.1" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -4855,7 +5080,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/pend": { "version": "1.2.0", @@ -6390,18 +6616,19 @@ } }, "node_modules/vitest": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.10.tgz", - "integrity": "sha512-R9jUTe5S4Qb0HCd4TNqpC7oGcrMssMRGXLW80ubjWsW9VH5GF8y1Y0SFLY9AbqSk6nt0PnOx4H4WNJYZ13GUPw==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.11.tgz", + "integrity": "sha512-fhACrNXUidIbGSBr5FlbuBkO7VWC1ZyLl0DO4CU2DrQoAPxX84Ysxs+HeGQpii5lZWV1Q4gBZTTu49mF+A6Edw==", "dev": true, + "license": "MIT", "dependencies": { - "@vitest/expect": "4.1.10", - "@vitest/mocker": "4.1.10", - "@vitest/pretty-format": "4.1.10", - "@vitest/runner": "4.1.10", - "@vitest/snapshot": "4.1.10", - "@vitest/spy": "4.1.10", - "@vitest/utils": "4.1.10", + "@vitest/expect": "4.1.11", + "@vitest/mocker": "4.1.11", + "@vitest/pretty-format": "4.1.11", + "@vitest/runner": "4.1.11", + "@vitest/snapshot": "4.1.11", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", "es-module-lexer": "^2.0.0", "expect-type": "^1.3.0", "magic-string": "^0.30.21", @@ -6429,12 +6656,12 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.1.10", - "@vitest/browser-preview": "4.1.10", - "@vitest/browser-webdriverio": "4.1.10", - "@vitest/coverage-istanbul": "4.1.10", - "@vitest/coverage-v8": "4.1.10", - "@vitest/ui": "4.1.10", + "@vitest/browser-playwright": "4.1.11", + "@vitest/browser-preview": "4.1.11", + "@vitest/browser-webdriverio": "4.1.11", + "@vitest/coverage-istanbul": "4.1.11", + "@vitest/coverage-v8": "4.1.11", + "@vitest/ui": "4.1.11", "happy-dom": "*", "jsdom": "*", "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" diff --git a/frontend/package.json b/frontend/package.json index 8d4fa0e..a937684 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -31,6 +31,7 @@ "@capacitor/cli": "^7.6.8", "@capacitor/ios": "^7.6.8", "@vitejs/plugin-react": "^6.0.3", + "@vitest/coverage-v8": "^4.1.11", "happy-dom": "^20.11.2", "linkedom": "^0.18.13", "vite": "^8.1.5", diff --git a/frontend/scripts/bundle-size.mjs b/frontend/scripts/bundle-size.mjs new file mode 100644 index 0000000..edaf239 --- /dev/null +++ b/frontend/scripts/bundle-size.mjs @@ -0,0 +1,73 @@ +#!/usr/bin/env node +// Measures the production bundle (raw + gzip, per file and total) and, given a baseline, +// prints the difference. CI runs it in every pipeline and keeps the result as an artifact, +// so a merge request can fetch main's numbers and show what it adds — the one thing +// reviewers otherwise never see until a self-hoster asks why the app got slower. +// +// node scripts/bundle-size.mjs --out bundle-size.json # measure dist/ +// node scripts/bundle-size.mjs --compare baseline.json current.json # print the delta +// +// Report-only: growth is a review question, not a build failure. +import { readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs' +import { join, relative } from 'node:path' +import { gzipSync } from 'node:zlib' + +const args = process.argv.slice(2) +const dist = new URL('../dist/', import.meta.url).pathname + +function walk(dir) { + return readdirSync(dir, { withFileTypes: true }).flatMap((e) => + e.isDirectory() ? walk(join(dir, e.name)) : [join(dir, e.name)] + ) +} + +function measure() { + const files = {} + let raw = 0, gzip = 0 + for (const f of walk(dist)) { + if (!/\.(js|css|html)$/.test(f)) continue + const buf = readFileSync(f) + const g = gzipSync(buf, { level: 9 }).length + // Hashed chunk names change on every build; key by the stable part so deltas line up. + const key = relative(dist, f).replace(/-[A-Za-z0-9_-]{8}\.(js|css)$/, '.$1') + files[key] = { raw: buf.length, gzip: g } + raw += buf.length + gzip += g + } + return { total: { raw, gzip }, files } +} + +const kb = (n) => (n / 1024).toFixed(1).padStart(8) + ' kB' +const delta = (a, b) => { + const d = b - a + if (!a) return ' (new)' + const pct = ((d / a) * 100).toFixed(1) + return (d >= 0 ? '+' : '') + (d / 1024).toFixed(1) + ' kB (' + (d >= 0 ? '+' : '') + pct + '%)' +} + +if (args[0] === '--out') { + const r = measure() + writeFileSync(args[1], JSON.stringify(r, null, 2)) + console.log(`bundle: ${kb(r.total.raw).trim()} raw, ${kb(r.total.gzip).trim()} gzip, ${Object.keys(r.files).length} files`) +} else if (args[0] === '--compare') { + let base + try { base = JSON.parse(readFileSync(args[1], 'utf8')) } catch { base = null } + const cur = JSON.parse(readFileSync(args[2], 'utf8')) + if (!base) { + console.log('no baseline from main available — nothing to compare against') + process.exit(0) + } + console.log('bundle size vs main (gzip):') + const names = new Set([...Object.keys(base.files), ...Object.keys(cur.files)]) + for (const n of [...names].sort()) { + const a = base.files[n]?.gzip ?? 0, b = cur.files[n]?.gzip ?? 0 + if (a === b) continue + console.log(` ${n.padEnd(40)} ${kb(a)} -> ${kb(b)} ${b ? delta(a, b) : '(removed)'}`) + } + console.log(` ${'TOTAL'.padEnd(40)} ${kb(base.total.gzip)} -> ${kb(cur.total.gzip)} ${delta(base.total.gzip, cur.total.gzip)}`) + const growth = (cur.total.gzip - base.total.gzip) / base.total.gzip + if (growth > 0.1) console.log(`\n⚠ the gzipped bundle grew by ${(growth * 100).toFixed(1)}% — worth a look in review`) +} else { + console.error('usage: bundle-size.mjs --out FILE | --compare BASE CURRENT') + process.exit(2) +} diff --git a/mcp/package-lock.json b/mcp/package-lock.json index f29cb60..6cefdf4 100644 --- a/mcp/package-lock.json +++ b/mcp/package-lock.json @@ -16,41 +16,68 @@ "opengym-mcp": "src/index.js" }, "devDependencies": { + "@vitest/coverage-v8": "^4.1.11", "vitest": "^4.1.10" } }, - "node_modules/@emnapi/core": { - "version": "2.0.0-alpha.3", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-alpha.3.tgz", - "integrity": "sha512-AZypUeJ/yByuxyS7BlSNRDOMLMlROYtjYdIAuBmJssVz1UJDSeYxLrdizhXCFYhedC5bqd/ASy8EuNXbVVXp9g==", + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", "dev": true, "license": "MIT", - "optional": true, - "dependencies": { - "@emnapi/wasi-threads": "2.0.1", - "tslib": "^2.4.0" + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@emnapi/runtime": { - "version": "2.0.0-alpha.3", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-alpha.3.tgz", - "integrity": "sha512-hFPAhMUjJD9BSyCANEISPOogeXC9Zo9ZQl7L6vKnaVsMkCtzznaW/naYypeyl0Gv5rYfWYsZbpixTMpjDJzQeA==", + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", "dev": true, "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^2.4.0" + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@emnapi/wasi-threads": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.0.1.tgz", - "integrity": "sha512-9DsSk+o5NBX0CCJT8s0EROGSGxjR/tKu6aBTaVyq+SjAEQH4XcdcRxPBRzsBLizTTJ49MJjF+jgu3qnO9GLQcQ==", + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", "dev": true, "license": "MIT", - "optional": true, "dependencies": { - "tslib": "^2.4.0" + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" } }, "node_modules/@hono/node-server": { @@ -65,13 +92,34 @@ "hono": "^4" } }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", "dev": true, "license": "MIT" }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@modelcontextprotocol/sdk": { "version": "1.30.0", "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.30.0.tgz", @@ -112,42 +160,37 @@ } } }, - "node_modules/@napi-rs/wasm-runtime": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.2.tgz", - "integrity": "sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==", + "node_modules/@oxc-project/types": { + "version": "0.148.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.148.0.tgz", + "integrity": "sha512-Nm4s/jB+4FpFsPhWGEC4h7rzksesmtnMXomo6rCMcg/b8zLQuOziRgkCS1fxDCXOlJB/6Q8oABOZ/OP6RIPj9A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.7.tgz", + "integrity": "sha512-EypzgnYCwyVY4NDHKzGmNJT5b+XaQEBniHxsMdeIQLB/tcCzZnhqrzHpZFbX9iaxx+5RiB8caATBtfvZP7zVxQ==", + "cpu": [ + "arm" + ], "dev": true, "license": "MIT", "optional": true, - "dependencies": { - "@tybys/wasm-util": "^0.10.3" - }, + "os": [ + "android" + ], "engines": { - "node": "^20.19.0 || ^22.13.0 || >=23.5.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Brooooooklyn" - }, - "peerDependencies": { - "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.3", - "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.3" - } - }, - "node_modules/@oxc-project/types": { - "version": "0.142.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.142.0.tgz", - "integrity": "sha512-7W+2q5AKQVU36fkaryontrHn3YDt1RyUYXatw9i5H8ocYe2sPKSFB6eS8WNPeRKiN1qAWWZUPm7gwFzJGrccqQ==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/Boshen" + "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.1.tgz", - "integrity": "sha512-02hOeOSryYxVrOIphmLAsqnCJWxwlzFk+pEt/N/i6OgT3lShHO7xGCU5cpgchRDHboAEbSjzgGh+O/u1GswQmA==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.7.tgz", + "integrity": "sha512-l17HE9EweWaqJZhuUuNBN/FzM62xw+DECVnJyvMsxn8vJFAGLy5QfLDoYAcronkAN8VxKZHezDpulHDPx95vFw==", "cpu": [ "arm64" ], @@ -162,9 +205,9 @@ } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.1.tgz", - "integrity": "sha512-fMsTOnN0OjFm3CyppWPitKnc8UlliVARUULW6cfU6AIqjdtgmSFWSk9vecHzZduv/yMWIHDlRhM1e8Iff9uAfA==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.7.tgz", + "integrity": "sha512-8ED8ELFvHXc6OCETIn4gXObPiaR6bckM/ipXtbzlPVDRMBfEGjCKgO90F9YtfdpDatVx/ZQw7aZ1vUMf/+T3Mw==", "cpu": [ "arm64" ], @@ -179,9 +222,9 @@ } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.1.tgz", - "integrity": "sha512-1wjKdz/XLGKHaTNHjQveQ/B23TKx4ItAqm1JbyVuvNPc4Ze0Fb48s49TAd/2zcplPl8okE/UbTgmlVfwT7eFeQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.7.tgz", + "integrity": "sha512-/WPripjtiAIZ2tWY7ddijORT0Ujg87wxWW/qcoFVCKAWVDPhtY0xr7Dj0M3GyNGz60jGwTElhro/mkF9dT7dDQ==", "cpu": [ "x64" ], @@ -196,9 +239,9 @@ } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.1.tgz", - "integrity": "sha512-Fa0jHR07E7YBN4vOEsbVf2briYNsuOowfLJaXULZM0ldMlaCaj2LJgLMbMe4iacRyZmvR8efFhgR9wKuGclQUg==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.7.tgz", + "integrity": "sha512-14DI4NcqpvbICxSnGLx3PmtDaWqRP/KGSGb6C+JLLVPeZRl6dKdHba3pGsqT3vpdTqhEYIPG0MMQ8c0xYqoJxA==", "cpu": [ "x64" ], @@ -213,9 +256,9 @@ } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.1.tgz", - "integrity": "sha512-pzkgu1SSHGgRRyRZ4fbmSgmajbVt+epaLP99NDjFft69v/ypfTi6swBMiVdh2EkQ0OSnHE1lZDM7DRGkyAzUpA==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.7.tgz", + "integrity": "sha512-bxrWIRvHWQvbJwi+VIie/kDJmQxcNE6xxWwZdqF/ExVAigtHkv54WTLQPb+QsZdnFy18fg7JPfWGL0RH6vwIlQ==", "cpu": [ "arm" ], @@ -230,9 +273,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.1.tgz", - "integrity": "sha512-QI5SEDY8cbiYWHx0VO4vIc3UlS6a32vXHjU8Qy/17adEmZIPuByJg13UEvo9c/UCiUkdcVWY83C+b+JrwnNyUg==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.7.tgz", + "integrity": "sha512-toOY2BChBZyuxU7OYX6Tn389di4IzAqPTycVcci0O7FSfBqzRB3RZn+K5Is6ANf4tmgRd/K1yZTsNTXbkXsnLg==", "cpu": [ "arm64" ], @@ -250,9 +293,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.1.tgz", - "integrity": "sha512-Sm41FyCeXqmYcERoYOCbGIL5hNfd8w9LQ7Y61Bev48HkcjaJqV/iiVOaiDxjVTRMS+QKrZmD8cfPt4uMVnvM+A==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.7.tgz", + "integrity": "sha512-lAIXTH/aiLRLxsTgQvfhjo4K1ydWIp00+V0voOr9beb/9ZmkUFrSIb03dXNFRgMNvkE6oGsF10ioQ6UsI+vS5Q==", "cpu": [ "arm64" ], @@ -270,9 +313,9 @@ } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.1.tgz", - "integrity": "sha512-2x+WhXTGl9yJYPbltW/BSEPTVz9OIWQyER4N+gJEDWkkn904eRcBzELqh/Hf7K0w/ubGbKNMv0ZC+94QK/IFEg==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.7.tgz", + "integrity": "sha512-kdnwS28Pkenp/mZMRwjXXXwxQ7pIsm+bF919LUK93BOyhcLsrVKdP2p9fxpiPNPAbNuch8ypQt0pm2P2LYCAGg==", "cpu": [ "ppc64" ], @@ -290,9 +333,9 @@ } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.1.tgz", - "integrity": "sha512-eEjmQpuRQayHPWWnywaWHkFT3ToPbP3RYy42VVd/B9aBGDA+Ol25EIWHxKQST3IiWJjikCWUF7KtbfqwZrzVwQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.7.tgz", + "integrity": "sha512-516OdsyLdr5E65paF3yBF55t8mfm9+gmtCsK3xI7XKXIT7EfRlHhxL8K/NR6Hu8BWSgF5+1w74lTL0+nxcc8Qw==", "cpu": [ "s390x" ], @@ -310,9 +353,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.1.tgz", - "integrity": "sha512-/Orga1fZYkLc/56jBICcHrKchl8Z2UKdDSr3LG9ToWO1lQ6a4Livk9Xz+9WN91zsz5QR3XQz2NNoSDEvP6qadw==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.7.tgz", + "integrity": "sha512-r8/z8n7GFaYRln3xmP1Cxy0HH/HLM0uBUPkEuSVEfKGDA89M0FsZRZJRSwe/tJjRx+fpH/gjorfhB8tmEbSFLA==", "cpu": [ "x64" ], @@ -330,9 +373,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.1.tgz", - "integrity": "sha512-xxBJRL+0q0Kce7orznGWLuylHDY65vuARXZRpX+hPdv+DqK2c3NlCsVA98tlWzWNEE7yPqA/1NQ5nnCrj49Y5A==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.7.tgz", + "integrity": "sha512-pAsE8iiDxUg1xBqdhrTfg45AVDVpirjz00sblEYClGNNcMnDb+e8beQgqIAw6LvauX/APvgxUnwrgun/YYGBhw==", "cpu": [ "x64" ], @@ -350,9 +393,9 @@ } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.1.tgz", - "integrity": "sha512-M6AdXIXw3s+/8XpKMzdGDEXGS1S7kwUsy+rcTIUIOx5Ge4nXKCtAFHFV9YKkXvGcC5WMoTjAteLzlsQROVI0Yw==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.7.tgz", + "integrity": "sha512-lTcIYmmnQQA8Or/2DatS6oSqcdLHvendjS+zLu+FwgToynWMRSmQdpM65fTANJgIS4mjbMOo5KT2lnT9SAb96w==", "cpu": [ "arm64" ], @@ -366,26 +409,10 @@ "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/@rolldown/binding-wasm32-wasi": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.1.tgz", - "integrity": "sha512-/TX0SoRGojHzSAHpfVBbavRVSazg5U3h3Y3VXfcc0cdugq6kxdqw8LPGFiPr+/7gE/60zRcsOY2Vi9b9eT0jww==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@emnapi/core": "2.0.0-alpha.3", - "@emnapi/runtime": "2.0.0-alpha.3", - "@napi-rs/wasm-runtime": "^1.2.0" - }, - "engines": { - "node": "^20.19.0 || ^22.13.0 || >=23.5.0" - } - }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.1.tgz", - "integrity": "sha512-EvRrivJieyHG+AO9lleZWgq+g0+S7oV2C51yuqlcyU/R9net+sI4Pj0F+lUoP2bEr6TWX3SqFaaS0SzfLxSzkw==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.7.tgz", + "integrity": "sha512-e3Gu3WxbNk/UqQhxqU7YIYO+9ZBvWNz3U+h/qRFosscMFzdRPbXYSaSWgSnklv2fz1TgzBTcti2z35c/7irsHw==", "cpu": [ "arm64" ], @@ -400,9 +427,9 @@ } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.1.tgz", - "integrity": "sha512-Z4eCmn5QJ/5+azF9knpLWKfVd9aidn0mAe9TpJgvBLId9Ax3t0+JVxBmT25Bv7NBbVW1TZyKjQjQReouMeH5UQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.7.tgz", + "integrity": "sha512-W/jg5qoRSqjsEv0+dZi4e687mcHqmVuU0P4fK6qS/xjetW2Gmc1W8j//z5nAeNcC8Ttm0hV46IjcYeuVwYhuiw==", "cpu": [ "x64" ], @@ -430,17 +457,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@tybys/wasm-util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", - "integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, "node_modules/@types/chai": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", @@ -466,17 +482,48 @@ "dev": true, "license": "MIT" }, + "node_modules/@vitest/coverage-v8": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.11.tgz", + "integrity": "sha512-8MVGEFnJIcdGjcbfKmeq8z0pZHH0JlVtoVZH9Q/qwUp6wyFnEJUBMrw9DCaj+ra3vShGmhavjalMIhPNxZAUcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/utils": "4.1.11", + "ast-v8-to-istanbul": "^1.0.0", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.2.0", + "magicast": "^0.5.2", + "obug": "^2.1.1", + "std-env": "^4.0.0-rc.1", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "4.1.11", + "vitest": "4.1.11" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, "node_modules/@vitest/expect": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.10.tgz", - "integrity": "sha512-YsCn+qAk1GWjQOWFEsEcL2gNQ0zmVmQu3T03qP6UyjhtmdtwtbuI+DASn/7iQB3HGTXkdBwGddzxPlmiql5vlA==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.11.tgz", + "integrity": "sha512-VX2x5vNJXET47KAFzwERI+KRMtTTCSWTfSMKsW7JsUsXV4psq++e3DvZpuTDOpHcxytiDs6p2nhVb2tVDiiUYw==", "dev": true, "license": "MIT", "dependencies": { "@standard-schema/spec": "^1.1.0", "@types/chai": "^5.2.2", - "@vitest/spy": "4.1.10", - "@vitest/utils": "4.1.10", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", "chai": "^6.2.2", "tinyrainbow": "^3.1.0" }, @@ -485,13 +532,13 @@ } }, "node_modules/@vitest/mocker": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.10.tgz", - "integrity": "sha512-v0xaezt+DKEmKfaxg133ldzADrwLGd7Ze1MfQQTYfvs8OqZIwbxyxaYURivwV7sWy5fqn3rH5uOrSp07bp44Ow==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.11.tgz", + "integrity": "sha512-2XJVD55d1o5AZous5CCGKS74g/riOj9odEt2bQpCVZeblHyHdnMeFl4jl0XjU21stf4mbjUkew2eXQZt65g5CQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "4.1.10", + "@vitest/spy": "4.1.11", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, @@ -512,9 +559,9 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.10.tgz", - "integrity": "sha512-W1HsjSH4MXQ9YfmmhLAoIYf1HRfekQCGngeIgcei6MP5QQGWUe0gkopdZQaVCFO+JDJMrAJGwa5pRpNpvy4P8Q==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.11.tgz", + "integrity": "sha512-yiZzPbGTS9Sr/JpFl8zHrcIkAofNbFV6k21vIgQN/cY/oxZeXhJv5sc/MBJ5jFKWmWs+oJHw0UXLZjmf931+Vw==", "dev": true, "license": "MIT", "dependencies": { @@ -525,13 +572,13 @@ } }, "node_modules/@vitest/runner": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.10.tgz", - "integrity": "sha512-IKI6kpIH+LmpROplyLwBBaCfMgOZOMsygVa6BARD6ahA04VRuJSa6OaVG7kRvSEMD870Vd91rSSw0eegtWyLGg==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.11.tgz", + "integrity": "sha512-LztvUgdwMNJMIkj3hQnnxiC2Xy1zNxq928W/xhjCLaNCzqTZOudjwbQf6v9IntZGPw132i2Lq2rgTRZHD3JHNw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "4.1.10", + "@vitest/utils": "4.1.11", "pathe": "^2.0.3" }, "funding": { @@ -539,14 +586,14 @@ } }, "node_modules/@vitest/snapshot": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.10.tgz", - "integrity": "sha512-xRkfOT1qpTAi/Ti4Y1LtfRc3kEuqxGw59eN2jN9pRWMtS/XDevekhcFSqvQqjUNGksfjMJu3Y+oJ+4Ypn2OaJw==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.11.tgz", + "integrity": "sha512-pN7ikn1ON7h8ee4gIAp4AzyK+zBtJPzVbqOgu5LCEh4VaJVbPQcgYQYJIMGQPXVeJJq1fnfazis7a5pFNPahog==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.1.10", - "@vitest/utils": "4.1.10", + "@vitest/pretty-format": "4.1.11", + "@vitest/utils": "4.1.11", "magic-string": "^0.30.21", "pathe": "^2.0.3" }, @@ -555,9 +602,9 @@ } }, "node_modules/@vitest/spy": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.10.tgz", - "integrity": "sha512-PLf/Ugvoq5wO/b4rwYCR1h2PSIdXz7wnkQFMiUpLdtM7l6pqVFcQIBEHyT1+l+cj7mNwAfZHzqXqDyjvOuwbDw==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.11.tgz", + "integrity": "sha512-apNa/prQy2qCeywhnixOHPRCgGNhvg7T4Dapfl1GahLp/R+uhBm5cPyFoNVyqsNd2h1nJxL6BqqdIjiABL60YA==", "dev": true, "license": "MIT", "funding": { @@ -565,13 +612,13 @@ } }, "node_modules/@vitest/utils": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.10.tgz", - "integrity": "sha512-fy9am/HWxbaGt/Sawrp90vt6Y6jQwf1RX77cz3uwoJwJVMli/e1IEwRPnMNJ7vKfPTwo0diXifkpPvwH9v7nGA==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.11.tgz", + "integrity": "sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.1.10", + "@vitest/pretty-format": "4.1.11", "convert-source-map": "^2.0.0", "tinyrainbow": "^3.1.0" }, @@ -635,6 +682,18 @@ "node": ">=12" } }, + "node_modules/ast-v8-to-istanbul": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.5.tgz", + "integrity": "sha512-UPAgKJFSEGMWSDr3LX4tqnAb4f7KGT8O40Tyx8wbYmmZ/yn58lNCm8h3svs3eXgiGd5AXxz8NDOvXWvicq+rJA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^10.0.0" + } + }, "node_modules/body-parser": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", @@ -1170,6 +1229,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/has-symbols": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", @@ -1203,6 +1272,13 @@ "node": ">=16.9.0" } }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/http-errors": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", @@ -1275,6 +1351,45 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "license": "ISC" }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jose": { "version": "6.2.7", "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.7.tgz", @@ -1284,6 +1399,13 @@ "url": "https://github.com/sponsors/panva" } }, + "node_modules/js-tokens": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", + "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -1579,6 +1701,34 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/magicast": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.4.tgz", + "integrity": "sha512-llBEhWm1SacoRwgHUoQJYtwp4PBLF4faQi5TCpIGyGs9n4y5+juI0tDgyKIfpqxckRHaHzouUEph3THklWh03w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", + "source-map-js": "^1.2.1" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -1645,9 +1795,9 @@ "license": "MIT" }, "node_modules/nanoid": { - "version": "3.3.16", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz", - "integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==", + "version": "3.3.18", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz", + "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==", "dev": true, "funding": [ { @@ -1771,9 +1921,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", - "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true, "license": "MIT", "engines": { @@ -1793,9 +1943,9 @@ } }, "node_modules/postcss": { - "version": "8.5.25", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.25.tgz", - "integrity": "sha512-DTPx3RWSSnWyzLxQnlH0rJP+EW5ekl16ZU4/psbIhA0e53kJfdgaN5vKM+xP7yJtXVu+nfdVFmlgFDEKAe4Pyw==", + "version": "8.5.28", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz", + "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==", "dev": true, "funding": [ { @@ -1813,7 +1963,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.16", + "nanoid": "^3.3.18", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, @@ -1888,13 +2038,13 @@ } }, "node_modules/rolldown": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.1.tgz", - "integrity": "sha512-4FKJhg8d3OiyQOA6Q1Q0hoFFpW9/OoX+VsHzpECsdsIZoOArrAK90gl59YK/Z+gnDel45bgJZK03ozH/9bCqEw==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.7.tgz", + "integrity": "sha512-g0EtLvBjTUB7jhyV0S/TCup3v/XSVl45vUIGbOGU4QPiyjTenCe4mKuFvW9fEgYmS2Fo42AUssRmNuMziXdrig==", "dev": true, "license": "MIT", "dependencies": { - "@oxc-project/types": "=0.142.0", + "@oxc-project/types": "=0.148.0", "@rolldown/pluginutils": "^1.0.0" }, "bin": { @@ -1904,21 +2054,21 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm64": "1.2.1", - "@rolldown/binding-darwin-arm64": "1.2.1", - "@rolldown/binding-darwin-x64": "1.2.1", - "@rolldown/binding-freebsd-x64": "1.2.1", - "@rolldown/binding-linux-arm-gnueabihf": "1.2.1", - "@rolldown/binding-linux-arm64-gnu": "1.2.1", - "@rolldown/binding-linux-arm64-musl": "1.2.1", - "@rolldown/binding-linux-ppc64-gnu": "1.2.1", - "@rolldown/binding-linux-s390x-gnu": "1.2.1", - "@rolldown/binding-linux-x64-gnu": "1.2.1", - "@rolldown/binding-linux-x64-musl": "1.2.1", - "@rolldown/binding-openharmony-arm64": "1.2.1", - "@rolldown/binding-wasm32-wasi": "1.2.1", - "@rolldown/binding-win32-arm64-msvc": "1.2.1", - "@rolldown/binding-win32-x64-msvc": "1.2.1" + "@rolldown/binding-android-arm-eabi": "1.2.7", + "@rolldown/binding-android-arm64": "1.2.7", + "@rolldown/binding-darwin-arm64": "1.2.7", + "@rolldown/binding-darwin-x64": "1.2.7", + "@rolldown/binding-freebsd-x64": "1.2.7", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.7", + "@rolldown/binding-linux-arm64-gnu": "1.2.7", + "@rolldown/binding-linux-arm64-musl": "1.2.7", + "@rolldown/binding-linux-ppc64-gnu": "1.2.7", + "@rolldown/binding-linux-s390x-gnu": "1.2.7", + "@rolldown/binding-linux-x64-gnu": "1.2.7", + "@rolldown/binding-linux-x64-musl": "1.2.7", + "@rolldown/binding-openharmony-arm64": "1.2.7", + "@rolldown/binding-win32-arm64-msvc": "1.2.7", + "@rolldown/binding-win32-x64-msvc": "1.2.7" } }, "node_modules/router": { @@ -1943,6 +2093,19 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "license": "MIT" }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/send": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", @@ -2127,6 +2290,19 @@ "dev": true, "license": "MIT" }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -2180,14 +2356,6 @@ "node": ">=0.6" } }, - "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, - "license": "0BSD", - "optional": true - }, "node_modules/type-is": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", @@ -2238,16 +2406,16 @@ } }, "node_modules/vite": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.0.tgz", - "integrity": "sha512-pn+CFpM0lwDeKwmOq1ZaBK/9sjorZcgqxki6MbY/jPEVd9vichIlmlD4HmQ5wdP5EgqQCFRaACBxMC7uEGc6lQ==", + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz", + "integrity": "sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==", "dev": true, "license": "MIT", "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.5", - "postcss": "^8.5.23", - "rolldown": "~1.2.0", + "postcss": "^8.5.26", + "rolldown": "~1.2.4", "tinyglobby": "^0.2.17" }, "bin": { @@ -2264,7 +2432,7 @@ }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", - "@vitejs/devtools": "^0.4.0", + "@vitejs/devtools": "^0.4.0 || ^0.5.0", "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", @@ -2316,19 +2484,19 @@ } }, "node_modules/vitest": { - "version": "4.1.10", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.10.tgz", - "integrity": "sha512-R9jUTe5S4Qb0HCd4TNqpC7oGcrMssMRGXLW80ubjWsW9VH5GF8y1Y0SFLY9AbqSk6nt0PnOx4H4WNJYZ13GUPw==", + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.11.tgz", + "integrity": "sha512-fhACrNXUidIbGSBr5FlbuBkO7VWC1ZyLl0DO4CU2DrQoAPxX84Ysxs+HeGQpii5lZWV1Q4gBZTTu49mF+A6Edw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/expect": "4.1.10", - "@vitest/mocker": "4.1.10", - "@vitest/pretty-format": "4.1.10", - "@vitest/runner": "4.1.10", - "@vitest/snapshot": "4.1.10", - "@vitest/spy": "4.1.10", - "@vitest/utils": "4.1.10", + "@vitest/expect": "4.1.11", + "@vitest/mocker": "4.1.11", + "@vitest/pretty-format": "4.1.11", + "@vitest/runner": "4.1.11", + "@vitest/snapshot": "4.1.11", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", "es-module-lexer": "^2.0.0", "expect-type": "^1.3.0", "magic-string": "^0.30.21", @@ -2356,12 +2524,12 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.1.10", - "@vitest/browser-preview": "4.1.10", - "@vitest/browser-webdriverio": "4.1.10", - "@vitest/coverage-istanbul": "4.1.10", - "@vitest/coverage-v8": "4.1.10", - "@vitest/ui": "4.1.10", + "@vitest/browser-playwright": "4.1.11", + "@vitest/browser-preview": "4.1.11", + "@vitest/browser-webdriverio": "4.1.11", + "@vitest/coverage-istanbul": "4.1.11", + "@vitest/coverage-v8": "4.1.11", + "@vitest/ui": "4.1.11", "happy-dom": "*", "jsdom": "*", "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" diff --git a/mcp/package.json b/mcp/package.json index 92e3de6..19a5ee2 100644 --- a/mcp/package.json +++ b/mcp/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "type": "module", - "description": "MCP (Model Context Protocol) bridge for openGym \u2014 lets an external LLM read your routines, workouts, body-weight log, estimated 1RMs and muscle balance from your self-hosted data. Read-only, stdio transport; no extra container.", + "description": "MCP (Model Context Protocol) bridge for openGym — lets an external LLM read your routines, workouts, body-weight log, estimated 1RMs and muscle balance from your self-hosted data. Read-only, stdio transport; no extra container.", "license": "AGPL-3.0-or-later", "main": "src/index.js", "bin": { @@ -19,6 +19,7 @@ "zod": "^3.23.8" }, "devDependencies": { + "@vitest/coverage-v8": "^4.1.11", "vitest": "^4.1.10" } } diff --git a/scripts/ci/fork-mr-pipelines.py b/scripts/ci/fork-mr-pipelines.py new file mode 100755 index 0000000..b09a827 --- /dev/null +++ b/scripts/ci/fork-mr-pipelines.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +"""Start merge-request pipelines for contributor MRs that would otherwise never get one. + +On gitlab.com a merge request from a fork runs its pipeline in the *fork*, on the fork +owner's runner minutes — and most contributors have never enabled shared runners there +(it needs identity verification), so their MR sits at "no pipeline" forever. A maintainer +can press "Run pipeline" on the MR page to run it in this project instead; this script +presses that button for them, with the same care a maintainer would take: + + * only for authors who are already trusted — project members, or people with at + least one merged MR here (the GitHub "first-time contributor" rule). Everyone else + gets the `ci-approval-needed` label so a maintainer can find and start them by hand. + * never when the MR touches `.gitlab-ci.yml`: the pipeline runs with this project's + job token, and a changed pipeline definition is exactly where that token could be + misused. Same label, a maintainer reads the diff first. + * never twice for the same commit, never for drafts, and at most MAX_TRIGGERS per run. + +Runs from the `mr:fork-pipelines` job (scheduled, and after every push to main). Needs +PIPELINE_API_TOKEN — a token with `api` scope and at least Developer on the project. +""" +import json +import os +import sys +import urllib.parse +import urllib.request + +API = os.environ["CI_API_V4_URL"] +PROJECT = os.environ["CI_PROJECT_ID"] +TOKEN = os.environ["PIPELINE_API_TOKEN"] +MAX_TRIGGERS = int(os.environ.get("FORK_MR_MAX_TRIGGERS", "8")) +LABEL = "ci-approval-needed" +DRY_RUN = "--dry-run" in sys.argv + + +def call(method, path, body=None, params=None): + url = f"{API}/projects/{PROJECT}/{path}" + if params: + url += "?" + urllib.parse.urlencode(params) + data = json.dumps(body).encode() if body is not None else None + req = urllib.request.Request(url, data=data, method=method) + req.add_header("PRIVATE-TOKEN", TOKEN) + req.add_header("Content-Type", "application/json") + with urllib.request.urlopen(req, timeout=60) as r: + return json.load(r) + + +def paged(path, **params): + page = 1 + while True: + batch = call("GET", path, params={**params, "per_page": 100, "page": page}) + if not batch: + return + yield from batch + if len(batch) < 100: + return + page += 1 + + +def trusted_authors(): + members = {m["username"] for m in paged("members/all") if m["access_level"] >= 30} + merged = {m["author"]["username"] for m in paged("merge_requests", state="merged")} + return members | merged + + +def ensure_label(): + if any(l["name"] == LABEL for l in paged("labels")): + return + if not DRY_RUN: + call("POST", "labels", {"name": LABEL, "color": "#ed9121", + "description": "Fork MR whose pipeline a maintainer has to start by hand"}) + + +def set_label(mr, present): + has = LABEL in mr["labels"] + if has == present or DRY_RUN: + return + key = "add_labels" if present else "remove_labels" + call("PUT", f"merge_requests/{mr['iid']}", {key: LABEL}) + + +def main(): + trusted = trusted_authors() + ensure_label() + triggered = 0 + for mr in paged("merge_requests", state="opened", order_by="updated_at"): + iid, author, sha = mr["iid"], mr["author"]["username"], mr["sha"] + tag = f"!{iid} ({author}, {mr['source_branch']})" + if mr["source_project_id"] == mr["target_project_id"]: + continue # same-project branch: gets its pipeline on push like any other + if mr.get("draft"): + print(f"skip {tag}: draft") + continue + if author not in trusted: + print(f"hold {tag}: first-time contributor — a maintainer starts this one") + set_label(mr, True) + continue + touched = {c["new_path"] for c in call("GET", f"merge_requests/{iid}/changes")["changes"]} + if ".gitlab-ci.yml" in touched or any(p.startswith("scripts/ci/") for p in touched): + print(f"hold {tag}: changes the pipeline itself — a maintainer reads it first") + set_label(mr, True) + continue + set_label(mr, False) + # A pipeline that exists but never got a runner (created/pending in a fork with none) + # is the very thing this script is for, so only a pipeline that actually ran counts. + STUCK = {"created", "pending", "waiting_for_resource", "preparing"} + ran = [p for p in call("GET", f"merge_requests/{iid}/pipelines") if p["sha"] == sha and p["status"] not in STUCK] + if ran: + where = "here" if ran[0]["project_id"] == int(PROJECT) else "in the fork" + print(f"ok {tag}: {sha[:8]} already has a pipeline {where} ({ran[0]['status']})") + continue + if triggered >= MAX_TRIGGERS: + print(f"defer {tag}: per-run cap of {MAX_TRIGGERS} reached, next run picks it up") + continue + if DRY_RUN: + print(f"would {tag}: start pipeline for {sha[:8]}") + else: + p = call("POST", f"merge_requests/{iid}/pipelines") + print(f"start {tag}: pipeline {p['id']} for {sha[:8]} — {p['web_url']}") + triggered += 1 + print(f"done: {triggered} pipeline(s) started") + + +if __name__ == "__main__": + main() diff --git a/web/Dockerfile b/web/Dockerfile index 22f0b90..1e2f8eb 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -14,7 +14,10 @@ FROM --platform=$BUILDPLATFORM node:22-alpine AS build # is exactly what made the v1.2.15 web image fail to build. WORKDIR /app/frontend COPY frontend/package.json frontend/package-lock.json* ./ -RUN npm ci 2>/dev/null || npm install +# --ignore-scripts: the web image only needs `vite build`; the one heavy postinstall in this tree +# (@capacitor/assets -> sharp, a libvips download from GitHub) is for drawing app icons and has +# timed out on the shared runners — a lockfile-ignoring `npm install` fallback is no answer to that. +RUN npm ci --ignore-scripts COPY api/coach/core/ /app/api/coach/core/ COPY frontend/ ./ RUN npm run build From 5478b2d621bf8f0066c760f9854f3262d3791584 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 14:09:40 +0200 Subject: [PATCH 4/8] CI: Image-Digest robust auslesen (buildx druckte den ganzen Block, dotenv-Upload scheiterte) --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f06e849..d3b9475 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -350,7 +350,10 @@ build:images: $TAGS \ --push \ "$CONTEXT" - DIGEST="$(docker buildx imagetools inspect "$REPO:$IMAGE_TAG" --format '{{.Manifest.Digest}}')" + # Older buildx builds ignore --format and print the whole Name/MediaType/Digest block, so + # pick the digest out of whatever comes back — a multi-line value breaks the dotenv upload. + DIGEST="$(docker buildx imagetools inspect "$REPO:$IMAGE_TAG" --format '{{.Manifest.Digest}}' | grep -oE 'sha256:[0-9a-f]{64}' | head -1)" + [ -n "$DIGEST" ] || { echo "could not read the digest of $REPO:$IMAGE_TAG" >&2; exit 1; } echo "pushed $REPO:$IMAGE_TAG @ $DIGEST" UPPER="$(echo "$IMAGE" | tr a-z A-Z)" { From 0af9f5552816d6e9c6ab66dd5a9497e0cc1b0d7b Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 14:42:48 +0200 Subject: [PATCH 5/8] Gym check-in: Settings switch to turn the feature off Off hides the Home card and the /checkin route; saved cards stay. On by default, profiles without the key read as on. pt-BR: trailing comma the MR's last override line was missing, override count 600. --- frontend/src/App.jsx | 6 +++--- frontend/src/lib/pt-br-locale.test.js | 2 +- frontend/src/locales/de.js | 2 ++ frontend/src/locales/es.js | 2 ++ frontend/src/locales/fr.js | 2 ++ frontend/src/locales/hi.js | 2 ++ frontend/src/locales/hu.js | 2 ++ frontend/src/locales/it.js | 2 ++ frontend/src/locales/ko.js | 2 ++ frontend/src/locales/pl.js | 2 ++ frontend/src/locales/pt-BR.js | 4 +++- frontend/src/locales/pt.js | 2 ++ frontend/src/locales/ru.js | 2 ++ frontend/src/locales/th.js | 2 ++ frontend/src/locales/tr.js | 2 ++ frontend/src/locales/zh.js | 2 ++ frontend/src/store/useStore.gymcards.test.jsx | 18 ++++++++++++++++++ frontend/src/store/useStore.js | 4 ++++ frontend/src/views/Home.jsx | 5 +++-- frontend/src/views/Settings.jsx | 6 ++++++ 20 files changed, 64 insertions(+), 7 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index ae2c41c..bf5ed48 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -116,9 +116,9 @@ function Shell() { } /> {/* Gym check-in is mobile-only — it needs the native scanner and showing a QR to - a turnstile makes no sense in a browser tab. Off mobile the route falls through - to the catch-all redirect below. */} - {MOBILE && } />} + a turnstile makes no sense in a browser tab. Off mobile (or switched off in + Settings) the route falls through to the catch-all redirect below. */} + {MOBILE && S.checkIn !== false && } />} } /> } /> } /> diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index a263acd..03b4549 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => { .sort(byCodeUnit) const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex') - expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(598) + expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(600) expect(inherited).toHaveLength(565) // If this fails, review the changed keys and wording before accepting a new hash. From // frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index b8b9335..be72df2 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -1124,4 +1124,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'Zum Scannen wird die Kamera-Berechtigung benötigt. Aktiviere sie in den Einstellungen.', 'Scanning is not available on this device.': 'Scannen ist auf diesem Gerät nicht verfügbar.', 'Could not start the scanner': 'Scanner konnte nicht gestartet werden', + 'Gym check-in': 'Gym-Check-in', + 'Show a card on Home with your membership QR codes.': 'Zeigt auf Start eine Karte mit deinen Mitglieds-QR-Codes.', } diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index 7c429bb..f0e4d65 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'Se necesita permiso de cámara para escanear. Actívalo en Ajustes.', 'Scanning is not available on this device.': 'El escaneo no está disponible en este dispositivo.', 'Could not start the scanner': 'No se pudo iniciar el escáner', + 'Gym check-in': 'Check-in del gimnasio', + 'Show a card on Home with your membership QR codes.': 'Muestra en Inicio una tarjeta con tus códigos QR de socio.', } diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 3ab6a7d..a499e85 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'L’autorisation caméra est nécessaire pour scanner. Active-la dans les Réglages.', 'Scanning is not available on this device.': 'Le scan n’est pas disponible sur cet appareil.', 'Could not start the scanner': 'Impossible de démarrer le scanner', + 'Gym check-in': 'Enregistrement à la salle', + 'Show a card on Home with your membership QR codes.': 'Affiche sur l’Accueil une carte avec vos codes QR d’abonné.', } diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 49a7d16..ab24120 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'स्कैन करने के लिए कैमरा अनुमति चाहिए। इसे सेटिंग्स में चालू करें।', 'Scanning is not available on this device.': 'इस डिवाइस पर स्कैनिंग उपलब्ध नहीं है।', 'Could not start the scanner': 'स्कैनर शुरू नहीं हो सका', + 'Gym check-in': 'जिम चेक-इन', + 'Show a card on Home with your membership QR codes.': 'होम पर आपके सदस्यता QR कोड वाला कार्ड दिखाता है।', } diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js index 0479a04..649ca29 100644 --- a/frontend/src/locales/hu.js +++ b/frontend/src/locales/hu.js @@ -1108,4 +1108,6 @@ export default { 'What should change?': 'Mi változzon?', 'Coach is thinking…': 'Az Edző gondolkodik…', 'Message the Coach…': 'Üzenet az Edzőnek…', + 'Gym check-in': 'Bejelentkezés a teremben', + 'Show a card on Home with your membership QR codes.': 'A Kezdőlapon egy kártyát mutat a tagsági QR-kódjaiddal.', } diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index be3c8cb..c58bf9b 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'Per scansionare serve l’autorizzazione alla fotocamera. Attivala nelle Impostazioni.', 'Scanning is not available on this device.': 'La scansione non è disponibile su questo dispositivo.', 'Could not start the scanner': 'Impossibile avviare lo scanner', + 'Gym check-in': 'Check-in in palestra', + 'Show a card on Home with your membership QR codes.': 'Mostra nella Home una scheda con i tuoi codici QR di iscrizione.', } diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index 6814e36..881ecf6 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': '스캔하려면 카메라 권한이 필요합니다. 설정에서 켜세요.', 'Scanning is not available on this device.': '이 기기에서는 스캔을 사용할 수 없습니다.', 'Could not start the scanner': '스캐너를 시작할 수 없습니다', + 'Gym check-in': '헬스장 체크인', + 'Show a card on Home with your membership QR codes.': '홈 화면에 회원 QR 코드 카드를 표시합니다.', } diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index 31db24d..017f900 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'Do skanowania potrzebne jest pozwolenie na aparat. Włącz je w Ustawieniach.', 'Scanning is not available on this device.': 'Skanowanie nie jest dostępne na tym urządzeniu.', 'Could not start the scanner': 'Nie udało się uruchomić skanera', + 'Gym check-in': 'Zameldowanie na siłowni', + 'Show a card on Home with your membership QR codes.': 'Pokazuje na Starcie kartę z Twoimi kodami QR członkowskimi.', } diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index 42be41a..c7d366d 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -621,7 +621,9 @@ export const PT_BR_OVERRIDES = { 'Could not read that image': 'Não foi possível ler essa imagem', 'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmera para escanear. Ative-a nos Ajustes.', 'Scanning is not available on this device.': 'O escaneamento não está disponível neste dispositivo.', - 'Could not start the scanner': 'Não foi possível iniciar o scanner' + 'Could not start the scanner': 'Não foi possível iniciar o scanner', + 'Gym check-in': 'Check-in na academia', + 'Show a card on Home with your membership QR codes.': 'Mostra no Início um cartão com seus códigos QR de sócio.', } export default { ...pt, ...PT_BR_OVERRIDES } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 7ca5c1c..aafc1ea 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmara para digitalizar. Ativa-a nas Definições.', 'Scanning is not available on this device.': 'A digitalização não está disponível neste dispositivo.', 'Could not start the scanner': 'Não foi possível iniciar o scanner', + 'Gym check-in': 'Check-in no ginásio', + 'Show a card on Home with your membership QR codes.': 'Mostra no Início um cartão com os teus códigos QR de sócio.', } diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index c7e11d7..1f19344 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'Для сканирования нужен доступ к камере. Включите его в настройках.', 'Scanning is not available on this device.': 'Сканирование недоступно на этом устройстве.', 'Could not start the scanner': 'Не удалось запустить сканер', + 'Gym check-in': 'Отметка в зале', + 'Show a card on Home with your membership QR codes.': 'Показывает на Главной карточку с вашими QR-кодами абонемента.', } diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js index 2a6ba67..83a57ca 100644 --- a/frontend/src/locales/th.js +++ b/frontend/src/locales/th.js @@ -1116,4 +1116,6 @@ export default { 'What should change?': 'ควรเปลี่ยนอะไร', 'Coach is thinking…': 'โค้ชกำลังคิด…', 'Message the Coach…': 'ส่งข้อความถึงโค้ช…', + 'Gym check-in': 'เช็คอินที่ยิม', + 'Show a card on Home with your membership QR codes.': 'แสดงการ์ดพร้อม QR โค้ดสมาชิกของคุณบนหน้าหลัก', } diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 36c107c..92a7b16 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': 'Taramak için kamera izni gerekir. Ayarlar’dan etkinleştir.', 'Scanning is not available on this device.': 'Tarama bu cihazda kullanılamıyor.', 'Could not start the scanner': 'Tarayıcı başlatılamadı', + 'Gym check-in': 'Salon girişi', + 'Show a card on Home with your membership QR codes.': 'Ana sayfada üyelik QR kodlarınızı içeren bir kart gösterir.', } diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 931b154..a4f7868 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -1105,4 +1105,6 @@ export default { 'Camera permission is needed to scan. Enable it in Settings.': '扫描需要相机权限。请在设置中开启。', 'Scanning is not available on this device.': '此设备不支持扫描。', 'Could not start the scanner': '无法启动扫描器', + 'Gym check-in': '健身房签到', + 'Show a card on Home with your membership QR codes.': '在首页显示一张包含会员二维码的卡片。', } diff --git a/frontend/src/store/useStore.gymcards.test.jsx b/frontend/src/store/useStore.gymcards.test.jsx index 8f0fe52..d3fcab9 100644 --- a/frontend/src/store/useStore.gymcards.test.jsx +++ b/frontend/src/store/useStore.gymcards.test.jsx @@ -67,3 +67,21 @@ describe('gymCards state', () => { expect(useStore.getState().S.gymCards.map(c => c.id)).toEqual(['1', '2', '3']) }) }) + +// The Settings switch. On by default; an older profile that predates the key must read as on +// too, and off only hides the feature — the cards themselves survive the round trip. +describe('checkIn switch', () => { + it('is on for a fresh profile', () => { + expect(useStore.getState().S.checkIn).toBe(true) + }) + + it('turning it off keeps the saved cards', () => { + useStore.getState().update(s => { + s.gymCards.push({ id: 'c1', label: 'FitZone', value: 'ABC123', fmt: 'qrcode' }) + s.checkIn = false + }, false) + const S = useStore.getState().S + expect(S.checkIn).toBe(false) + expect(S.gymCards).toHaveLength(1) + }) +}) diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js index 802e8f2..09abeec 100644 --- a/frontend/src/store/useStore.js +++ b/frontend/src/store/useStore.js @@ -42,6 +42,10 @@ export const DEF = { // kind of code the gym issued. Just data, so it syncs and backs up like everything else. // [{ id, label, value, fmt }] gymCards: [], + // Whether the check-in feature is on at all (Settings toggle, mobile-only). Off hides the Home + // card and the /checkin route; the saved gymCards stay so turning it back on restores them. + // Defaults on; an older profile without the key reads as on (`!== false`). + checkIn: true, } const clone = o => JSON.parse(JSON.stringify(o)) diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsx index c597218..0cf46b4 100644 --- a/frontend/src/views/Home.jsx +++ b/frontend/src/views/Home.jsx @@ -96,8 +96,9 @@ export default function Home() {
{/* Mobile-only: jump to the gym check-in cards (QR membership codes). Shown here as a quick - tap on arrival at the gym; the whole feature folds away in web/demo builds via MOBILE. */} - {MOBILE && ( + tap on arrival at the gym; the whole feature folds away in web/demo builds via MOBILE, + and per user via the "Gym check-in" switch in Settings. */} + {MOBILE && S.checkIn !== false && (
nav('/checkin'))}>
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx index 5b94d06..7d12f2d 100644 --- a/frontend/src/views/Settings.jsx +++ b/frontend/src/views/Settings.jsx @@ -140,6 +140,12 @@ export default function Settings() { options={[{ value: MONDAY, label: t('Monday') }, { value: SUNDAY, label: t('Sunday') }]} value={weekStartOf(S)} onChange={v => update(s => { s.weekStart = v })} /> + {/* Membership QR codes on Home (views/CheckIn.jsx). Only the app can scan and show them + at a turnstile, so the switch exists only there; off = no Home card, no route. */} + {MOBILE && + update(s => { s.checkIn = v })} /> + } {/* ---------- during a workout ---------- */} From aa487d29f4d8140170dec104f94463c224a81596 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 15:15:31 +0200 Subject: [PATCH 6/8] Gym check-in in the browser/PWA too The feature was gated behind MOBILE because scanning went through the native ML Kit plugin. iPhone users only have the PWA, so: route, Home card and Settings switch on every platform; photo import and a live camera sheet decode in the browser with BarcodeDetector where it exists and jsQR (Apache-2.0, lazy chunk) otherwise. The app build keeps ML Kit. Round-trip test lean-qr -> jsQR. --- NOTICE.md | 22 +++++-- frontend/package-lock.json | 6 ++ frontend/package.json | 1 + frontend/src/App.jsx | 8 +-- frontend/src/components/CameraScan.jsx | 69 +++++++++++++++++++++ frontend/src/index.css | 5 ++ frontend/src/lib/pt-br-locale.test.js | 2 +- frontend/src/lib/qr.js | 7 +-- frontend/src/lib/scan-web.js | 83 ++++++++++++++++++++++++++ frontend/src/lib/scan-web.test.js | 44 ++++++++++++++ frontend/src/lib/scan.js | 15 +++-- frontend/src/lib/scan.test.js | 15 +++-- frontend/src/locales/de.js | 3 + frontend/src/locales/es.js | 3 + frontend/src/locales/fr.js | 3 + frontend/src/locales/hi.js | 3 + frontend/src/locales/hu.js | 3 + frontend/src/locales/it.js | 3 + frontend/src/locales/ko.js | 3 + frontend/src/locales/pl.js | 3 + frontend/src/locales/pt-BR.js | 3 + frontend/src/locales/pt.js | 3 + frontend/src/locales/ru.js | 3 + frontend/src/locales/th.js | 3 + frontend/src/locales/tr.js | 3 + frontend/src/locales/zh.js | 3 + frontend/src/store/useStore.js | 4 +- frontend/src/views/CheckIn.jsx | 24 ++++++-- frontend/src/views/Home.jsx | 8 +-- frontend/src/views/Settings.jsx | 7 +-- 30 files changed, 315 insertions(+), 47 deletions(-) create mode 100644 frontend/src/components/CameraScan.jsx create mode 100644 frontend/src/lib/scan-web.js create mode 100644 frontend/src/lib/scan-web.test.js diff --git a/NOTICE.md b/NOTICE.md index 0ae5a0a..e5090bc 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -126,16 +126,18 @@ the source files. ## Gym check-in QR codes -The mobile-only gym check-in feature (a saved membership code shown as a QR/barcode on the phone, -added by typing, importing a photo, or scanning with the camera) uses two third-party packages. -Both are permissively licensed and compatible with openGym's AGPL, and both are bundled only in -the mobile build — the web and demo builds never ship them. +The gym check-in feature (a saved membership code shown as a QR code on the phone, added by +typing, importing a photo, or scanning with the camera) uses three third-party packages. All are +permissively licensed and compatible with openGym's AGPL, and all load on demand: the QR renderer +and the browser decoder only when a card is shown or scanned, the ML Kit plugin only in the +Android/iOS app. ### QR/barcode rendering — `lean-qr` openGym renders each saved code on the phone with [**lean-qr**](https://github.com/davidje13/lean-qr) by David Evans, used under the **MIT License** and reproduced below. Only the code's stored value is kept; the picture is generated fresh from that value each time it is shown, never stored. +It runs the same way in the app and in the browser/PWA. ``` MIT License @@ -161,9 +163,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -### Camera scan & photo decode — `@capacitor-mlkit/barcode-scanning` +### Camera scan & photo decode in the browser — `jsQR` -Reading a code — from the camera or from an imported photo — uses the +In a browser (including the installed PWA), reading a code from the camera or from an imported +photo uses [**jsQR**](https://github.com/cozmo/jsQR) by Cosmo Wolfe, under the **Apache License +2.0** (text at and in the package's own `LICENSE`). +Where the browser has a native `BarcodeDetector`, that is tried first and jsQR is the fallback. +Video frames are decoded in memory and never uploaded or stored. + +### Camera scan & photo decode in the app — `@capacitor-mlkit/barcode-scanning` + +In the Android/iOS app, reading a code — from the camera or from an imported photo — uses the [**@capacitor-mlkit/barcode-scanning**](https://github.com/capawesome-team/capacitor-mlkit) plugin by the Capawesome Team (Robin Genz), a Capacitor wrapper around Google's ML Kit, used under the **Apache License 2.0**. openGym pins the `7.x` line to stay on Capacitor 7. The full license text is diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 9c3fcd0..5a2b94e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -16,6 +16,7 @@ "@capacitor/filesystem": "^7.1.8", "@capacitor/local-notifications": "^7.0.7", "@capacitor/share": "^7.0.4", + "jsqr": "^1.4.0", "lean-qr": "^2.7.3", "react": "^19.2.7", "react-dom": "^19.2.7", @@ -3758,6 +3759,11 @@ "node": "*" } }, + "node_modules/jsqr": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.4.0.tgz", + "integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A==" + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", diff --git a/frontend/package.json b/frontend/package.json index e751b0e..39a2cf4 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -21,6 +21,7 @@ "@capacitor/filesystem": "^7.1.8", "@capacitor/local-notifications": "^7.0.7", "@capacitor/share": "^7.0.4", + "jsqr": "^1.4.0", "lean-qr": "^2.7.3", "react": "^19.2.7", "react-dom": "^19.2.7", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index bf5ed48..c9d70aa 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -5,7 +5,6 @@ import { useUI } from './store/useUI.js' import { bindUI } from './components/ui.jsx' import { ACCENTS } from './lib/format.js' import { setLang, useLang } from './lib/i18n.js' -import { MOBILE } from './lib/mobile.js' import { setNav } from './lib/nav.js' import { initBackButton } from './lib/back.js' import { useWakeLock } from './lib/wakelock.js' @@ -115,10 +114,9 @@ function Shell() { {!authed ? : needsMobileOnboarding ? : ( } /> - {/* Gym check-in is mobile-only — it needs the native scanner and showing a QR to - a turnstile makes no sense in a browser tab. Off mobile (or switched off in - Settings) the route falls through to the catch-all redirect below. */} - {MOBILE && S.checkIn !== false && } />} + {/* Gym check-in — switched off in Settings, the route falls through to the + catch-all redirect below. */} + {S.checkIn !== false && } />} } /> } /> } /> diff --git a/frontend/src/components/CameraScan.jsx b/frontend/src/components/CameraScan.jsx new file mode 100644 index 0000000..dc04aba --- /dev/null +++ b/frontend/src/components/CameraScan.jsx @@ -0,0 +1,69 @@ +import { useEffect, useRef, useState } from 'react' +import { t } from '../lib/i18n.js' +import { decodeSource } from '../lib/scan-web.js' +import { Button } from '../components/ui.jsx' + +// Live camera scanner for the browser/PWA (the app build uses ML Kit's own UI instead — see +// lib/scan.js). Opens the rear camera into a
- {/* Mobile-only: jump to the gym check-in cards (QR membership codes). Shown here as a quick - tap on arrival at the gym; the whole feature folds away in web/demo builds via MOBILE, - and per user via the "Gym check-in" switch in Settings. */} - {MOBILE && S.checkIn !== false && ( + {/* Jump to the gym check-in cards (QR membership codes). Shown here as a quick tap on + arrival at the gym; folds away per user via the "Gym check-in" switch in Settings. */} + {S.checkIn !== false && (
nav('/checkin'))}>
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx index 7d12f2d..f36d16b 100644 --- a/frontend/src/views/Settings.jsx +++ b/frontend/src/views/Settings.jsx @@ -140,12 +140,11 @@ export default function Settings() { options={[{ value: MONDAY, label: t('Monday') }, { value: SUNDAY, label: t('Sunday') }]} value={weekStartOf(S)} onChange={v => update(s => { s.weekStart = v })} /> - {/* Membership QR codes on Home (views/CheckIn.jsx). Only the app can scan and show them - at a turnstile, so the switch exists only there; off = no Home card, no route. */} - {MOBILE && update(s => { s.checkIn = v })} /> - } + {/* ---------- during a workout ---------- */} From 50a8b962858f1ed3de9cfd8a5135f18142d8fd84 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 15:16:23 +0200 Subject: [PATCH 7/8] cap sync: secure-storage and ML Kit plugin in the generated gradle/Podfile lists --- frontend/android/app/capacitor.build.gradle | 1 + frontend/android/capacitor.settings.gradle | 3 +++ frontend/ios/App/Podfile | 2 ++ 3 files changed, 6 insertions(+) diff --git a/frontend/android/app/capacitor.build.gradle b/frontend/android/app/capacitor.build.gradle index 815aa6b..d612497 100644 --- a/frontend/android/app/capacitor.build.gradle +++ b/frontend/android/app/capacitor.build.gradle @@ -9,6 +9,7 @@ android { apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" dependencies { + implementation project(':aparajita-capacitor-secure-storage') implementation project(':capacitor-mlkit-barcode-scanning') implementation project(':capacitor-app') implementation project(':capacitor-filesystem') diff --git a/frontend/android/capacitor.settings.gradle b/frontend/android/capacitor.settings.gradle index 90dbbe8..7d3aea6 100644 --- a/frontend/android/capacitor.settings.gradle +++ b/frontend/android/capacitor.settings.gradle @@ -2,6 +2,9 @@ include ':capacitor-android' project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') +include ':aparajita-capacitor-secure-storage' +project(':aparajita-capacitor-secure-storage').projectDir = new File('../node_modules/@aparajita/capacitor-secure-storage/android') + include ':capacitor-mlkit-barcode-scanning' project(':capacitor-mlkit-barcode-scanning').projectDir = new File('../node_modules/@capacitor-mlkit/barcode-scanning/android') diff --git a/frontend/ios/App/Podfile b/frontend/ios/App/Podfile index 4faddd0..46ec9a1 100644 --- a/frontend/ios/App/Podfile +++ b/frontend/ios/App/Podfile @@ -11,6 +11,8 @@ install! 'cocoapods', :disable_input_output_paths => true def capacitor_pods pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' + pod 'AparajitaCapacitorSecureStorage', :path => '../../node_modules/@aparajita/capacitor-secure-storage' + pod 'CapacitorMlkitBarcodeScanning', :path => '../../node_modules/@capacitor-mlkit/barcode-scanning' pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem' pod 'CapacitorLocalNotifications', :path => '../../node_modules/@capacitor/local-notifications' From dca6bcdf2da03024d7d81d8f06be7d9901027743 Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 15:34:49 +0200 Subject: [PATCH 8/8] Images: alpine-Upgrades beim Bauen, npm aus dem publizierten api-Image, APK-Checksumme bei jedem Build Der Trivy-Scan meldete 13 Funde, alle im api-Image und keiner in einer Abhaengigkeit der App: 2x openssl aus alpine (node:22-alpine hinkt alpines Fixes hinterher) und 11x in npms eigenem gebuendelten Baum (tar, brace-expansion, pacote, ...). Beide Images ziehen jetzt `apk upgrade` beim Bauen; das publizierte api-Image (Target default) verliert npm komplett - der Server startet mit `node server.js`, nichts spawnt npm. build:api-check prueft das. Das coach-Target behaelt npm fuer die Codex-CLI. build:apk schreibt die .sha256 jetzt bei jedem Build (die Artefakt-Warnung auf Branches ist weg), hochgeladen wird sie weiterhin nur vom Release-Tag. --- .gitlab-ci.yml | 12 ++++++++---- api/Dockerfile | 10 ++++++++++ web/Dockerfile | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3b9475..2f17c95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -395,6 +395,10 @@ build:api-check: 'import("@anthropic-ai/claude-agent-sdk").then(()=>{console.error("AI runtime present in the published image -- the last Dockerfile stage is no longer the runtime-free one");process.exit(1)},()=>process.exit(0))' ! docker run --rm opengym-api:published codex --version 2>/dev/null ! docker run --rm opengym-api:published bwrap --version 2>/dev/null + # npm is stripped from the published image (see api/Dockerfile) — its bundled tree was + # the only source of scanner findings, and nothing at runtime needs it. + ! docker run --rm opengym-api:published npm --version 2>/dev/null + ! docker run --rm opengym-api:published test -d /usr/local/lib/node_modules/npm docker run --rm opengym-api:published node --input-type=module -e ' const { adapterFor } = await import("./coach/adapters/index.js"); for (const id of ["anthropic", "openai", "gemini", "compatible"]) { @@ -556,11 +560,11 @@ build:apk: set -eu cd "$CI_PROJECT_DIR" . ./apk.env + # Sideloading means nobody's app store checked this file for you, so publish the + # digest next to it rather than leaving people to trust the download. Written for + # every build (branch artifacts too), uploaded only from a release tag. + for apk in openGym-*.apk; do sha256sum "$apk" > "$apk.sha256"; cat "$apk.sha256"; done if [ -n "${CI_COMMIT_TAG:-}" ] && [ -f "openGym-$APK_VERSION.apk" ]; then - # Sideloading means nobody's app store checked this file for you, so publish the - # digest next to it rather than leaving people to trust the download. - sha256sum "openGym-$APK_VERSION.apk" > "openGym-$APK_VERSION.apk.sha256" - cat "openGym-$APK_VERSION.apk.sha256" echo "APK_SHA256=$(cut -d' ' -f1 "openGym-$APK_VERSION.apk.sha256")" >> apk.env for f in "openGym-$APK_VERSION.apk" "openGym-$APK_VERSION.apk.sha256"; do curl --fail --silent --show-error \ diff --git a/api/Dockerfile b/api/Dockerfile index 92f187f..90a1199 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -31,6 +31,11 @@ LABEL maintainer="Duarte Santos https://gitlab.com/DuarteSantos8" \ WORKDIR /app +# The base image is rebuilt on node's schedule, not alpine's: between two node releases the +# alpine packages it ships (openssl above all) fall behind their fixes. Taking the upgrades at +# build time keeps the published image at alpine's current state without waiting for node. +RUN apk upgrade --no-cache + # The unprivileged user Coach jobs drop to. Its uid cannot read /data, which is the control that # keeps a provider runtime away from users, passkeys and the session secret. # @@ -82,3 +87,8 @@ VOLUME ["/coach-auth"] # --------------------------------------------------------------------------------------------- # Last, so that a plain `docker build ./api` keeps producing the runtime-free image. FROM base AS default +# npm itself is only a build-time tool here: the server is started with `node server.js` and +# nothing in it spawns npm. Its bundled dependency tree (tar, brace-expansion, ...) is where +# every vulnerability the image scan ever reported lived — none of them was in a package the +# app uses. Gone from the published image; the coach target keeps npm for the Codex CLI. +RUN rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx diff --git a/web/Dockerfile b/web/Dockerfile index 1e2f8eb..20978ff 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -23,6 +23,8 @@ COPY frontend/ ./ RUN npm run build FROM nginx:alpine +# Same reason as in api/Dockerfile: alpine fixes land faster than the nginx image is rebuilt. +RUN apk upgrade --no-cache ARG VERSION=dev ARG VCS_REF=dev ARG BUILD_DATE=unknown