🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Add Vitest for testing and refactor time handling in the application
Bill Yangbc63e9894e5d
diff --git a/client/package-lock.json b/client/package-lock.jsonindex 34932632f..fab488c78 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -109,7 +109,8 @@"prettier": "^3.8.1","tailwindcss": "^4.1.17","tw-animate-css": "^1.4.0",- "typescript": "^5.8.3"+ "typescript": "^5.8.3",+ "vitest": "^4.1.10"}},"../shared": {@@ -590,20 +591,20 @@"license": "MIT"},"node_modules/@emnapi/core": {- "version": "1.7.1",- "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.7.1.tgz",- "integrity": "sha512-o1uhUASyo921r2XtHYOHy7gdkGLge8ghBEQHMWmyJFoXlpU58kIrhhN3w26lpQb6dspetweapMn2CSNwQ8I4wg==",+ "version": "1.11.1",+ "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz",+ "integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==","license": "MIT","optional": true,"dependencies": {- "@emnapi/wasi-threads": "1.1.0",+ "@emnapi/wasi-threads": "1.2.2","tslib": "^2.4.0"}},"node_modules/@emnapi/runtime": {- "version": "1.7.1",- "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz",- "integrity": "sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA==",+ "version": "1.11.1",+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.1.tgz",+ "integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==","license": "MIT","optional": true,"dependencies": {@@ -611,9 +612,9 @@}},"node_modules/@emnapi/wasi-threads": {- "version": "1.1.0",- "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.1.0.tgz",- "integrity": "sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==",+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz",+ "integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==","license": "MIT","optional": true,"dependencies": {@@ -1501,15 +1502,21 @@}},"node_modules/@napi-rs/wasm-runtime": {- "version": "1.1.0",- "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.0.tgz",- "integrity": "sha512-Fq6DJW+Bb5jaWE69/qOE0D1TUN9+6uWhCeZpdnSBk14pjLcCWR7Q8n49PTSPHazM37JqrsdpEthXy2xn6jWWiA==",+ "version": "1.1.6",+ "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz",+ "integrity": "sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==","license": "MIT","optional": true,"dependencies": {+ "@tybys/wasm-util": "^0.10.3"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/Brooooooklyn"+ },+ "peerDependencies": {"@emnapi/core": "^1.7.1",- "@emnapi/runtime": "^1.7.1",- "@tybys/wasm-util": "^0.10.1"+ "@emnapi/runtime": "^1.7.1"}},"node_modules/@next/env": {@@ -2437,6 +2444,16 @@"node": ">=14"}},+ "node_modules/@oxc-project/types": {+ "version": "0.139.0",+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.139.0.tgz",+ "integrity": "sha512-r9gHphtCs+1M7J0pw6Sn/hh/Wpa/iQrOOkrNAlVLF/gHq+/CJmHIWKKUUhdWjcD6CIa8idarspCsASiXCXvFUw==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/Boshen"+ }+ },"node_modules/@oxc-resolver/binding-android-arm-eabi": {"version": "11.15.0","resolved": "https://registry.npmjs.org/@oxc-resolver/binding-android-arm-eabi/-/binding-android-arm-eabi-11.15.0.tgz",@@ -5048,6 +5065,270 @@"integrity": "sha512-HVj7LrZ4ReHWBimBvu2SKND3cDVUPWKLqRTmWe/fNY6o1owGOX0cAHbdPDTMelgBlVbrTKrre6lFkhqGZErK/g==","license": "MIT"},+ "node_modules/@rolldown/binding-android-arm64": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.1.5.tgz",+ "integrity": "sha512-lZg8fqIv2v7FF237bwMgzGZEJvGL79/s5knJ/i6FmsGF4XXlzccZ4jb+TrFIxtSSxFtIpdsgrPZeMk1I9AFcyQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-darwin-arm64": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.1.5.tgz",+ "integrity": "sha512-51Bnx9pNiMRKSUNtBfySkNJ9vMU9Hh3I1ozDd6gyPPYzaXCfnptUcEZxXGYFn+ul2dtcMUiqGR1Yai2K10uoTw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-darwin-x64": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.1.5.tgz",+ "integrity": "sha512-Tm+gbfC0aHu1tBA/JvKQh32S0K6YgCHkiAF4/W6xX0K0RmNuc94VeK419dJoE65R5aRxmo+noZQSWrAMF6yb6g==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-freebsd-x64": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.1.5.tgz",+ "integrity": "sha512-JMzDKCCXq93YccG5gz3hvOs1oXRKAf0XYpfOS88e+wZrC8Iugj6j68867vrYZkvpDDpKn/KoKORThmchMpF6TA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.1.5.tgz",+ "integrity": "sha512-uML21j2K5TfPGutKxub+M+nLjZIrWjXQ5Grx4lCe/nimTj9B4L63zHpjXLl4y0L3mcm2htEQIb06oCG/szerNw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm64-gnu": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.1.5.tgz",+ "integrity": "sha512-navSiuTMogvnQoZoM/v+l3ZWo50/NTwSHSzheABx/RCnmUPaKwq9qSo4Br2OYRs21+Fz8uFqITZM3H4opOB0/Q==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm64-musl": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.1.5.tgz",+ "integrity": "sha512-lAryqH7IteztmCXQXk0etKj4wBQ7Gx5S6LjKhsgp9zb8I5bsuvU/2llH1hDQcjsFeqIsovMVN339/8pUDDBXxA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.1.5.tgz",+ "integrity": "sha512-fsK/sNBnxzBlL4O1JNrZakVQxPspqpED5dLtNsZS9oOKmtSpdNIzxH2kkol5HYTWJN47sE20ztMJPxfZ89qGOg==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-s390x-gnu": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.1.5.tgz",+ "integrity": "sha512-gLYb4BIadlfTOYT5gO503n8zQjXflgzpD0FcyKh0Mzx3rqCZKnHoJWV9xe1KXUJ5lx2JfcSHr/mhzS0PC/McAA==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-x64-gnu": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.1.5.tgz",+ "integrity": "sha512-FjcpEKUyJygHgs1o50VYNvkt5+7Le/VEdYt0AkRpkL33MnyQfwr8l5mXwMmfmTbyMPr5vJLC+8/Gd9gXnwU1QQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-x64-musl": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.1.5.tgz",+ "integrity": "sha512-Me+PfPI2TMeOQk0gYWfLQZtTktrmzbr8cDboqX83XKc7UrgAi55gF+2dUkWdxd19n55Essp2yeca+O9N5rBxHg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-openharmony-arm64": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.1.5.tgz",+ "integrity": "sha512-yc5WrLzXks6zCQfn9Oxr8pORKyl/pF+QjHmW/Qx3qu0oyrrNC+y2JLTU1E2rcWYAmzlnqngWXHQjy51VzW70Vw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openharmony"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-wasm32-wasi": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.1.5.tgz",+ "integrity": "sha512-VbQGPX2b4r48TAMIM2cjgluIM1HYutm4pcTEJsle7iEP7sB1dFqtPLBVbdLAZCxy1txCcPxf4QFf4v8uvltPqA==",+ "cpu": [+ "wasm32"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@emnapi/core": "1.11.1",+ "@emnapi/runtime": "1.11.1",+ "@napi-rs/wasm-runtime": "^1.1.6"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-win32-arm64-msvc": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.1.5.tgz",+ "integrity": "sha512-gHv82k63z4qpV5+Q1y/12KrK0ltWBukVDI8nZcbT7Tt/ZlOIVwppazneq0F93oDxTo3IgAMEDIoQh3E2n6mVsw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-win32-x64-msvc": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.1.5.tgz",+ "integrity": "sha512-tTZuDBPw85tEN5PQi1pnEBzDy0Z49HtScLAbD5t6hyeU92A95pRWaSMw1GZZi/RwgSgUIl0xrSlXIT/9QzvYSA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/pluginutils": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",+ "dev": true,+ "license": "MIT"+ },"node_modules/@rrweb/packer": {"version": "2.0.0-alpha.20","resolved": "https://registry.npmjs.org/@rrweb/packer/-/packer-2.0.0-alpha.20.tgz",@@ -5692,15 +5973,26 @@"license": "MIT"},"node_modules/@tybys/wasm-util": {- "version": "0.10.1",- "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz",- "integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==",+ "version": "0.10.3",+ "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz",+ "integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==","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",+ "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/deep-eql": "*",+ "assertion-error": "^2.0.1"+ }+ },"node_modules/@types/country-flag-icons": {"version": "1.2.2","resolved": "https://registry.npmjs.org/@types/country-flag-icons/-/country-flag-icons-1.2.2.tgz",@@ -5987,6 +6279,13 @@"@types/d3-selection": "*"}},+ "node_modules/@types/deep-eql": {+ "version": "4.0.2",+ "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",+ "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",+ "dev": true,+ "license": "MIT"+ },"node_modules/@types/estree": {"version": "1.0.8","resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",@@ -6717,29 +7016,149 @@"win32"]},- "node_modules/@xstate/fsm": {- "version": "1.6.5",- "resolved": "https://registry.npmjs.org/@xstate/fsm/-/fsm-1.6.5.tgz",- "integrity": "sha512-b5o1I6aLNeYlU/3CPlj/Z91ybk1gUsKT+5NAJI+2W4UjvS5KLG28K9v5UvNoFVjHV8PajVZ00RH3vnjyQO7ZAw==",- "license": "MIT"- },- "node_modules/acorn": {- "version": "8.15.0",- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",- "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",+ "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==","dev": true,"license": "MIT",- "bin": {- "acorn": "bin/acorn"+ "dependencies": {+ "@standard-schema/spec": "^1.1.0",+ "@types/chai": "^5.2.2",+ "@vitest/spy": "4.1.10",+ "@vitest/utils": "4.1.10",+ "chai": "^6.2.2",+ "tinyrainbow": "^3.1.0"},- "engines": {- "node": ">=0.4.0"+ "funding": {+ "url": "https://opencollective.com/vitest"}},- "node_modules/acorn-jsx": {- "version": "5.3.2",- "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",- "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",+ "node_modules/@vitest/expect/node_modules/@standard-schema/spec": {+ "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,+ "license": "MIT"+ },+ "node_modules/@vitest/mocker": {+ "version": "4.1.10",+ "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.10.tgz",+ "integrity": "sha512-v0xaezt+DKEmKfaxg133ldzADrwLGd7Ze1MfQQTYfvs8OqZIwbxyxaYURivwV7sWy5fqn3rH5uOrSp07bp44Ow==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/spy": "4.1.10",+ "estree-walker": "^3.0.3",+ "magic-string": "^0.30.21"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "msw": "^2.4.9",+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0"+ },+ "peerDependenciesMeta": {+ "msw": {+ "optional": true+ },+ "vite": {+ "optional": true+ }+ }+ },+ "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==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "tinyrainbow": "^3.1.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/runner": {+ "version": "4.1.10",+ "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.10.tgz",+ "integrity": "sha512-IKI6kpIH+LmpROplyLwBBaCfMgOZOMsygVa6BARD6ahA04VRuJSa6OaVG7kRvSEMD870Vd91rSSw0eegtWyLGg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/utils": "4.1.10",+ "pathe": "^2.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "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==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/pretty-format": "4.1.10",+ "@vitest/utils": "4.1.10",+ "magic-string": "^0.30.21",+ "pathe": "^2.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "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==",+ "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==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/pretty-format": "4.1.10",+ "convert-source-map": "^2.0.0",+ "tinyrainbow": "^3.1.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@xstate/fsm": {+ "version": "1.6.5",+ "resolved": "https://registry.npmjs.org/@xstate/fsm/-/fsm-1.6.5.tgz",+ "integrity": "sha512-b5o1I6aLNeYlU/3CPlj/Z91ybk1gUsKT+5NAJI+2W4UjvS5KLG28K9v5UvNoFVjHV8PajVZ00RH3vnjyQO7ZAw==",+ "license": "MIT"+ },+ "node_modules/acorn": {+ "version": "8.15.0",+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",+ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",+ "dev": true,+ "license": "MIT",+ "bin": {+ "acorn": "bin/acorn"+ },+ "engines": {+ "node": ">=0.4.0"+ }+ },+ "node_modules/acorn-jsx": {+ "version": "5.3.2",+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",+ "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==","dev": true,"license": "MIT","peerDependencies": {@@ -6979,6 +7398,16 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/assertion-error": {+ "version": "2.0.1",+ "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-types-flow": {"version": "0.0.8","resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz",@@ -7359,6 +7788,16 @@],"license": "CC-BY-4.0"},+ "node_modules/chai": {+ "version": "6.2.2",+ "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz",+ "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=18"+ }+ },"node_modules/chalk": {"version": "4.1.2","resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",@@ -8382,6 +8821,13 @@"node": ">= 0.4"}},+ "node_modules/es-module-lexer": {+ "version": "2.3.1",+ "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.1.tgz",+ "integrity": "sha512-shc1dbU90Yl/xq1QrC7QRtfcwURZuVRfPhZbDoldJ1cn1gzDvBaBWlv0eFolj5+0znnPJz5TXLxsN77X/12KTA==",+ "dev": true,+ "license": "MIT"+ },"node_modules/es-object-atoms": {"version": "1.1.1","resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",@@ -8906,6 +9352,16 @@"node": ">=4.0"}},+ "node_modules/estree-walker": {+ "version": "3.0.3",+ "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"+ }+ },"node_modules/esutils": {"version": "2.0.3","resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",@@ -8916,6 +9372,16 @@"node": ">=0.10.0"}},+ "node_modules/expect-type": {+ "version": "1.4.0",+ "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",+ "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=12.0.0"+ }+ },"node_modules/fast-deep-equal": {"version": "3.1.3","resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",@@ -9197,6 +9663,21 @@}}},+ "node_modules/fsevents": {+ "version": "2.3.3",+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"+ }+ },"node_modules/function-bind": {"version": "1.1.2","resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",@@ -11079,9 +11560,9 @@"license": "MIT"},"node_modules/nanoid": {- "version": "3.3.11",- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",- "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",+ "version": "3.3.16",+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz",+ "integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==","funding": [{"type": "github",@@ -11517,6 +11998,20 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/obug": {+ "version": "2.1.4",+ "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.4.tgz",+ "integrity": "sha512-4a+OsYv9UktOJKE+l1A4OufDgdRF9PifWj+tJnHURo/P+WOxpG4GzUFL9qCalmWauao6ogiG+QvnCovwPoyAWA==",+ "dev": true,+ "funding": [+ "https://github.com/sponsors/sxzz",+ "https://opencollective.com/debug"+ ],+ "license": "MIT",+ "engines": {+ "node": ">=12.20.0"+ }+ },"node_modules/ol": {"version": "10.7.0","resolved": "https://registry.npmjs.org/ol/-/ol-10.7.0.tgz",@@ -11717,6 +12212,13 @@"dev": true,"license": "MIT"},+ "node_modules/pathe": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",+ "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",+ "dev": true,+ "license": "MIT"+ },"node_modules/pbf": {"version": "4.0.1","resolved": "https://registry.npmjs.org/pbf/-/pbf-4.0.1.tgz",@@ -11736,9 +12238,9 @@"license": "ISC"},"node_modules/picomatch": {- "version": "4.0.4",- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",- "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",+ "version": "4.0.5",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==","license": "MIT","engines": {"node": ">=12"@@ -11764,9 +12266,9 @@}},"node_modules/postcss": {- "version": "8.5.14",- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.14.tgz",- "integrity": "sha512-SoSL4+OSEtR99LHFZQiJLkT59C5B1amGO1NzTwj7TT1qCUgUO6hxOvzkOYxD+vMrXBM3XJIKzokoERdqQq/Zmg==",+ "version": "8.5.20",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.20.tgz",+ "integrity": "sha512-lW616l85ucIQL+FocMmL7pQFPqBmwejrCMg+iPxyImlrANNJG9NHq/RkyCZopDhd8C3LA03PHRJDjkbGu8vvug==","funding": [{"type": "opencollective",@@ -11783,7 +12285,7 @@],"license": "MIT","dependencies": {- "nanoid": "^3.3.11",+ "nanoid": "^3.3.16","picocolors": "^1.1.1","source-map-js": "^1.2.1"},@@ -12327,6 +12829,40 @@"integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==","license": "Unlicense"},+ "node_modules/rolldown": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.1.5.tgz",+ "integrity": "sha512-t9z29cJjXf/vxQ8dyhCSpt6H6aSwHTk8cT5I3iy6SMXuFpk5mB6PL6XfC8PCwrPTx93udwKUm9HRteAlTGBLiA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@oxc-project/types": "=0.139.0",+ "@rolldown/pluginutils": "^1.0.0"+ },+ "bin": {+ "rolldown": "bin/cli.mjs"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ },+ "optionalDependencies": {+ "@rolldown/binding-android-arm64": "1.1.5",+ "@rolldown/binding-darwin-arm64": "1.1.5",+ "@rolldown/binding-darwin-x64": "1.1.5",+ "@rolldown/binding-freebsd-x64": "1.1.5",+ "@rolldown/binding-linux-arm-gnueabihf": "1.1.5",+ "@rolldown/binding-linux-arm64-gnu": "1.1.5",+ "@rolldown/binding-linux-arm64-musl": "1.1.5",+ "@rolldown/binding-linux-ppc64-gnu": "1.1.5",+ "@rolldown/binding-linux-s390x-gnu": "1.1.5",+ "@rolldown/binding-linux-x64-gnu": "1.1.5",+ "@rolldown/binding-linux-x64-musl": "1.1.5",+ "@rolldown/binding-openharmony-arm64": "1.1.5",+ "@rolldown/binding-wasm32-wasi": "1.1.5",+ "@rolldown/binding-win32-arm64-msvc": "1.1.5",+ "@rolldown/binding-win32-x64-msvc": "1.1.5"+ }+ },"node_modules/rou3": {"version": "0.7.12","resolved": "https://registry.npmjs.org/rou3/-/rou3-0.7.12.tgz",@@ -12723,6 +13259,13 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/siginfo": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",+ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",+ "dev": true,+ "license": "ISC"+ },"node_modules/smol-toml": {"version": "1.6.1","resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.6.1.tgz",@@ -12781,12 +13324,26 @@"dev": true,"license": "MIT"},+ "node_modules/stackback": {+ "version": "0.0.2",+ "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",+ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",+ "dev": true,+ "license": "MIT"+ },"node_modules/state-local": {"version": "1.0.7","resolved": "https://registry.npmjs.org/state-local/-/state-local-1.0.7.tgz","integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==","license": "MIT"},+ "node_modules/std-env": {+ "version": "4.2.0",+ "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.2.0.tgz",+ "integrity": "sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==",+ "dev": true,+ "license": "MIT"+ },"node_modules/stop-iteration-iterator": {"version": "1.1.0","resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz",@@ -13042,15 +13599,32 @@"url": "https://opencollective.com/webpack"}},+ "node_modules/tinybench": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",+ "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/tinyexec": {+ "version": "1.2.4",+ "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.2.4.tgz",+ "integrity": "sha512-SHf/r48b7vOrjve9PxJo3MN5v5yuyjHvdUcrQffT3WXMUfnGmHDVbC4k3sHJaJTgZCwpUplIaAo5ANtMyp3YHg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=18"+ }+ },"node_modules/tinyglobby": {- "version": "0.2.15",- "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",- "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",+ "version": "0.2.17",+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==","dev": true,"license": "MIT","dependencies": {"fdir": "^6.5.0",- "picomatch": "^4.0.3"+ "picomatch": "^4.0.4"},"engines": {"node": ">=12.0.0"@@ -13065,6 +13639,16 @@"integrity": "sha512-gRa9gwYU3ECmQYv3lslts5hxuIa90veaEcxDYuu3QGOIAEM2mOZkVHp48ANJuu1CURtRdHKUBY5Lm1tHV+sD4g==","license": "ISC"},+ "node_modules/tinyrainbow": {+ "version": "3.1.0",+ "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz",+ "integrity": "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=14.0.0"+ }+ },"node_modules/to-regex-range": {"version": "5.0.1","resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",@@ -13454,6 +14038,435 @@"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0.0 || ^19.0.0-rc"}},+ "node_modules/vite": {+ "version": "8.1.5",+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.1.5.tgz",+ "integrity": "sha512-7ULLwsCdYx/nRyrpiEwvqb5TFHrMVZyBt+rg/OAXT7rgj/z+DtTDyKFeLAdDkubDVDKD8jOsndmy7m55XcfUsw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "lightningcss": "^1.32.0",+ "picomatch": "^4.0.5",+ "postcss": "^8.5.17",+ "rolldown": "~1.1.5",+ "tinyglobby": "^0.2.17"+ },+ "bin": {+ "vite": "bin/vite.js"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ },+ "funding": {+ "url": "https://github.com/vitejs/vite?sponsor=1"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.3"+ },+ "peerDependencies": {+ "@types/node": "^20.19.0 || >=22.12.0",+ "@vitejs/devtools": "^0.3.0",+ "esbuild": "^0.27.0 || ^0.28.0",+ "jiti": ">=1.21.0",+ "less": "^4.0.0",+ "sass": "^1.70.0",+ "sass-embedded": "^1.70.0",+ "stylus": ">=0.54.8",+ "sugarss": "^5.0.0",+ "terser": "^5.16.0",+ "tsx": "^4.8.1",+ "yaml": "^2.4.2"+ },+ "peerDependenciesMeta": {+ "@types/node": {+ "optional": true+ },+ "@vitejs/devtools": {+ "optional": true+ },+ "esbuild": {+ "optional": true+ },+ "jiti": {+ "optional": true+ },+ "less": {+ "optional": true+ },+ "sass": {+ "optional": true+ },+ "sass-embedded": {+ "optional": true+ },+ "stylus": {+ "optional": true+ },+ "sugarss": {+ "optional": true+ },+ "terser": {+ "optional": true+ },+ "tsx": {+ "optional": true+ },+ "yaml": {+ "optional": true+ }+ }+ },+ "node_modules/vite/node_modules/lightningcss": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz",+ "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==",+ "dev": true,+ "license": "MPL-2.0",+ "dependencies": {+ "detect-libc": "^2.0.3"+ },+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ },+ "optionalDependencies": {+ "lightningcss-android-arm64": "1.32.0",+ "lightningcss-darwin-arm64": "1.32.0",+ "lightningcss-darwin-x64": "1.32.0",+ "lightningcss-freebsd-x64": "1.32.0",+ "lightningcss-linux-arm-gnueabihf": "1.32.0",+ "lightningcss-linux-arm64-gnu": "1.32.0",+ "lightningcss-linux-arm64-musl": "1.32.0",+ "lightningcss-linux-x64-gnu": "1.32.0",+ "lightningcss-linux-x64-musl": "1.32.0",+ "lightningcss-win32-arm64-msvc": "1.32.0",+ "lightningcss-win32-x64-msvc": "1.32.0"+ }+ },+ "node_modules/vite/node_modules/lightningcss-android-arm64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz",+ "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-darwin-arm64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz",+ "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-darwin-x64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz",+ "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-freebsd-x64": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz",+ "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-linux-arm-gnueabihf": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz",+ "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-linux-arm64-gnu": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz",+ "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-linux-arm64-musl": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz",+ "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-linux-x64-gnu": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz",+ "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-linux-x64-musl": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz",+ "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-win32-arm64-msvc": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz",+ "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vite/node_modules/lightningcss-win32-x64-msvc": {+ "version": "1.32.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz",+ "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/vitest": {+ "version": "4.1.10",+ "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.10.tgz",+ "integrity": "sha512-R9jUTe5S4Qb0HCd4TNqpC7oGcrMssMRGXLW80ubjWsW9VH5GF8y1Y0SFLY9AbqSk6nt0PnOx4H4WNJYZ13GUPw==",+ "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",+ "es-module-lexer": "^2.0.0",+ "expect-type": "^1.3.0",+ "magic-string": "^0.30.21",+ "obug": "^2.1.1",+ "pathe": "^2.0.3",+ "picomatch": "^4.0.3",+ "std-env": "^4.0.0-rc.1",+ "tinybench": "^2.9.0",+ "tinyexec": "^1.0.2",+ "tinyglobby": "^0.2.15",+ "tinyrainbow": "^3.1.0",+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",+ "why-is-node-running": "^2.3.0"+ },+ "bin": {+ "vitest": "vitest.mjs"+ },+ "engines": {+ "node": "^20.0.0 || ^22.0.0 || >=24.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "@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",+ "happy-dom": "*",+ "jsdom": "*",+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0"+ },+ "peerDependenciesMeta": {+ "@edge-runtime/vm": {+ "optional": true+ },+ "@opentelemetry/api": {+ "optional": true+ },+ "@types/node": {+ "optional": true+ },+ "@vitest/browser-playwright": {+ "optional": true+ },+ "@vitest/browser-preview": {+ "optional": true+ },+ "@vitest/browser-webdriverio": {+ "optional": true+ },+ "@vitest/coverage-istanbul": {+ "optional": true+ },+ "@vitest/coverage-v8": {+ "optional": true+ },+ "@vitest/ui": {+ "optional": true+ },+ "happy-dom": {+ "optional": true+ },+ "jsdom": {+ "optional": true+ },+ "vite": {+ "optional": false+ }+ }+ },"node_modules/walk-up-path": {"version": "4.0.0","resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-4.0.0.tgz",@@ -13582,6 +14595,23 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/why-is-node-running": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",+ "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "siginfo": "^2.0.0",+ "stackback": "0.0.2"+ },+ "bin": {+ "why-is-node-running": "cli.js"+ },+ "engines": {+ "node": ">=8"+ }+ },"node_modules/word-wrap": {"version": "1.2.5","resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",diff --git a/client/package.json b/client/package.jsonindex 872192f00..7c58aa03b 100644--- a/client/package.json+++ b/client/package.json@@ -8,6 +8,8 @@"start": "next start -p 3002","extract": "node scripts/extract-messages.mjs","lint": "eslint .",+ "test": "vitest run",+ "test:watch": "vitest --watch","knip": "knip","format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"","format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\""@@ -114,7 +116,8 @@"prettier": "^3.8.1","tailwindcss": "^4.1.17","tw-animate-css": "^1.4.0",- "typescript": "^5.8.3"+ "typescript": "^5.8.3",+ "vitest": "^4.1.10"},"overrides": {"@types/react": "19.2.7"diff --git a/client/src/lib/parsers.ts b/client/src/lib/parsers.tsindex c298d4ccc..8a5eead8f 100644--- a/client/src/lib/parsers.ts+++ b/client/src/lib/parsers.ts@@ -1,5 +1,6 @@import { Filter, FilterParameter, FilterType, TimeBucket } from "@rybbit/shared";import { createParser, parseAsBoolean, parseAsInteger, parseAsJson, parseAsString, parseAsStringEnum } from "nuqs";+import { DASHBOARD_DEFAULT_TIME_RANGES } from "./defaultTimeRange";import { StatType } from "./store";import { Time } from "@/components/DateSelector/types";@@ -40,28 +41,8 @@ const timeModeValues: string[] = ["day", "range", "week", "month", "year", "all-export const parseAsTimeMode = parseAsStringEnum(timeModeValues);-// Well-known preset parser-const wellKnownValues: string[] = [- "today",- "yesterday",- "last-3-days",- "last-7-days",- "last-14-days",- "last-30-days",- "last-60-days",- "this-week",- "last-week",- "this-month",- "last-month",- "this-year",- "last-30-minutes",- "last-1-hour",- "last-6-hours",- "last-24-hours",- "all-time",-];--export const parseAsWellKnown = parseAsStringEnum(wellKnownValues);+// Well-known preset parser — the preset list lives in defaultTimeRange.ts.+export const parseAsWellKnown = parseAsStringEnum<string>([...DASHBOARD_DEFAULT_TIME_RANGES]);// ISO date string parser (for dates like "2024-01-01")export const parseAsIsoDate = parseAsString;diff --git a/client/src/lib/store.ts b/client/src/lib/store.tsindex d8bc6657d..e9d05ffc2 100644--- a/client/src/lib/store.ts+++ b/client/src/lib/store.ts@@ -5,6 +5,14 @@ import { persist } from "zustand/middleware";import { Time } from "../components/DateSelector/types";import { LITE_DASHBOARD } from "./const";import { getDashboardTimeForRange, getStoredDashboardDefaultTime } from "./defaultTimeRange";+import {+ canGoForward as canGoForwardFrom,+ deriveTimeState,+ hasRangeTimes,+ recalculateTimeForTimezone,+ shiftTimeBackward,+ shiftTimeForward,+} from "./time";// The lite dashboard is backed by hourly materialized views, so anything finer// than an hour has no underlying data. Clamp auto-selected buckets up to "hour".@@ -16,205 +24,14 @@ const clampBucketForLite = (bucket: TimeBucket): TimeBucket =>const getSystemTimezone = () =>typeof window !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().timeZone : "UTC";-// Recalculate time based on wellKnown value for a new timezone-const recalculateTimeForTimezone = (time: Time, timezone: string): Time | null => {- if (!time.wellKnown) return null;-- const now = DateTime.now().setZone(timezone);- const today = now.toISODate() ?? "";- const yesterday = now.minus({ days: 1 }).toISODate() ?? "";-- switch (time.wellKnown) {- case "today":- return { mode: "day", day: today, wellKnown: "today" };- case "yesterday":- return { mode: "day", day: yesterday, wellKnown: "yesterday" };- case "last-3-days":- return {- mode: "range",- startDate: now.minus({ days: 2 }).toISODate() ?? "",- endDate: today,- wellKnown: "last-3-days",- };- case "last-7-days":- return {- mode: "range",- startDate: now.minus({ days: 6 }).toISODate() ?? "",- endDate: today,- wellKnown: "last-7-days",- };- case "last-14-days":- return {- mode: "range",- startDate: now.minus({ days: 13 }).toISODate() ?? "",- endDate: today,- wellKnown: "last-14-days",- };- case "last-30-days":- return {- mode: "range",- startDate: now.minus({ days: 29 }).toISODate() ?? "",- endDate: today,- wellKnown: "last-30-days",- };- case "last-60-days":- return {- mode: "range",- startDate: now.minus({ days: 59 }).toISODate() ?? "",- endDate: today,- wellKnown: "last-60-days",- };- case "this-week":- return {- mode: "week",- week: now.startOf("week").toISODate() ?? "",- wellKnown: "this-week",- };- case "last-week":- return {- mode: "week",- week: now.minus({ weeks: 1 }).startOf("week").toISODate() ?? "",- wellKnown: "last-week",- };- case "this-month":- return {- mode: "month",- month: now.startOf("month").toISODate() ?? "",- wellKnown: "this-month",- };- case "last-month":- return {- mode: "month",- month: now.minus({ months: 1 }).startOf("month").toISODate() ?? "",- wellKnown: "last-month",- };- case "this-year":- return {- mode: "year",- year: now.startOf("year").toISODate() ?? "",- wellKnown: "this-year",- };- case "all-time":- return { mode: "all-time", wellKnown: "all-time" };- // past-minutes modes don't need date recalculation (they're relative to "now")- case "last-30-minutes":- case "last-1-hour":- case "last-6-hours":- case "last-24-hours":- return null;- default:- return null;- }-};-export type StatType = "pageviews" | "sessions" | "users" | "pages_per_session" | "bounce_rate" | "session_duration";-type RangeWithTimes = Extract<Time, { mode: "range" }> & { startTime: string; endTime: string };--const hasRangeTimes = (time: Time): time is RangeWithTimes =>- time.mode === "range" && typeof time.startTime === "string" && typeof time.endTime === "string";--const getRangeDateTimeBounds = (time: RangeWithTimes) => {- const zone = getTimezone();- return {- start: DateTime.fromISO(`${time.startDate}T${time.startTime}`, { zone }),- end: DateTime.fromISO(`${time.endDate}T${time.endTime}`, { zone }),- };-};--const toRangeWithTimes = (start: DateTime, end: DateTime): RangeWithTimes => ({- mode: "range",- startDate: start.toISODate() ?? "",- startTime: start.toFormat("HH:mm:ss"),- endDate: end.toISODate() ?? "",- endTime: end.toFormat("HH:mm:ss"),-});--const getBucketForDateTimeRange = (start: DateTime, end: DateTime): TimeBucket => {- const minutes = end.diff(start, "minutes").minutes;-- if (minutes <= 120) return "minute";- if (minutes <= 1440) return "five_minutes";- if (minutes <= 14 * 1440) return "hour";- if (minutes <= 60 * 1440) return "day";- if (minutes <= 180 * 1440) return "week";- return "month";-};-const getTimeState = (time: Time): Pick<Store, "time" | "previousTime" | "bucket"> => {- let bucketToUse: TimeBucket = "hour";- let previousTime: Time;-- if (time.mode === "day") {- bucketToUse = "hour";- previousTime = {- mode: "day",- day: DateTime.fromISO(time.day).minus({ days: 1 }).toISODate() ?? "",- };- } else if (time.mode === "past-minutes") {- const timeDiff = time.pastMinutesStart - time.pastMinutesEnd;-- if (timeDiff <= 120) {- bucketToUse = "minute";- }-- previousTime = {- mode: "past-minutes",- pastMinutesStart: time.pastMinutesStart + timeDiff,- pastMinutesEnd: time.pastMinutesEnd + timeDiff,- };- } else if (time.mode === "range") {- if (hasRangeTimes(time)) {- const { start, end } = getRangeDateTimeBounds(time);- const duration = end.diff(start);- bucketToUse = getBucketForDateTimeRange(start, end);-- previousTime = toRangeWithTimes(start.minus(duration), end.minus(duration));- } else {- const timeRangeLength = DateTime.fromISO(time.endDate).diff(DateTime.fromISO(time.startDate), "days").days + 1;-- if (timeRangeLength > 180) {- bucketToUse = "month";- } else if (timeRangeLength > 31) {- bucketToUse = "week";- } else {- bucketToUse = "day";- }-- previousTime = {- mode: "range",- startDate: DateTime.fromISO(time.startDate).minus({ days: timeRangeLength }).toISODate() ?? "",- endDate: DateTime.fromISO(time.startDate).minus({ days: 1 }).toISODate() ?? "",- };- }- } else if (time.mode === "week") {- bucketToUse = "day";- previousTime = {- mode: "week",- week: DateTime.fromISO(time.week).minus({ weeks: 1 }).toISODate() ?? "",- };- } else if (time.mode === "month") {- bucketToUse = "day";- previousTime = {- mode: "month",- month: DateTime.fromISO(time.month).minus({ months: 1 }).toISODate() ?? "",- };- } else if (time.mode === "year") {- bucketToUse = "month";- previousTime = {- mode: "year",- year: DateTime.fromISO(time.year).minus({ years: 1 }).toISODate() ?? "",- };- } else if (time.mode === "all-time") {- bucketToUse = "day";- previousTime = {- mode: "all-time",- };- } else {- previousTime = time;- }-- return { time, previousTime, bucket: clampBucketForLite(bucketToUse) };+ // Resolve the zone lazily: this runs during store creation (before useStore+ // exists), and only range-with-times values actually need the zone.+ const zone = hasRangeTimes(time) ? getTimezone() : "UTC";+ const { previousTime, bucket } = deriveTimeState(time, zone);+ return { time, previousTime, bucket: clampBucketForLite(bucket) };};type Store = {@@ -340,163 +157,19 @@ export const resetStore = () => {export const goBack = () => {const { time, setTime } = useStore.getState();-- if (time.mode === "day") {- setTime(- {- mode: "day",- day: DateTime.fromISO(time.day).minus({ days: 1 }).toISODate() ?? "",- },- false- );- } else if (time.mode === "range") {- if (hasRangeTimes(time)) {- const { start, end } = getRangeDateTimeBounds(time);- const duration = end.diff(start);-- setTime(toRangeWithTimes(start.minus(duration), end.minus(duration)), false);- return;- }-- const startDate = DateTime.fromISO(time.startDate);- const endDate = DateTime.fromISO(time.endDate);-- const daysBetweenStartAndEnd = endDate.diff(startDate, "days").days;- if (daysBetweenStartAndEnd === 0) {- const previousDate = startDate.minus({ days: 1 }).toISODate() ?? "";- setTime(- {- mode: "range",- startDate: previousDate,- endDate: previousDate,- },- false- );- return;- }-- setTime(- {- mode: "range",- startDate: startDate.minus({ days: daysBetweenStartAndEnd }).toISODate() ?? "",- endDate: startDate.toISODate() ?? "",- },- false- );- } else if (time.mode === "week") {- setTime(- {- mode: "week",- week: DateTime.fromISO(time.week).minus({ weeks: 1 }).toISODate() ?? "",- },- false- );- } else if (time.mode === "month") {- setTime(- {- mode: "month",- month: DateTime.fromISO(time.month).minus({ months: 1 }).toISODate() ?? "",- },- false- );- } else if (time.mode === "year") {- setTime(- {- mode: "year",- year: DateTime.fromISO(time.year).minus({ years: 1 }).toISODate() ?? "",- },- false- );+ const next = shiftTimeBackward(time, getTimezone());+ if (next) {+ setTime(next, false);}};export const goForward = () => {const { time, setTime } = useStore.getState();-- if (time.mode === "day") {- setTime({- mode: "day",- day: DateTime.fromISO(time.day).plus({ days: 1 }).toISODate() ?? "",- });- } else if (time.mode === "range") {- if (hasRangeTimes(time)) {- const { start, end } = getRangeDateTimeBounds(time);- const duration = end.diff(start);- const proposedStart = start.plus(duration);- const proposedEnd = end.plus(duration);- const now = DateTime.now().setZone(getTimezone());-- if (proposedStart > now) {- return;- }-- setTime(toRangeWithTimes(proposedStart, proposedEnd > now ? now : proposedEnd), false);- return;- }-- const startDate = DateTime.fromISO(time.startDate);- const endDate = DateTime.fromISO(time.endDate);- const now = DateTime.now();-- const daysBetweenStartAndEnd = endDate.diff(startDate, "days").days;- if (daysBetweenStartAndEnd === 0) {- const proposedDate = startDate.plus({ days: 1 });- if (proposedDate > now) {- return;- }-- const nextDate = proposedDate.toISODate() ?? "";- setTime(- {- mode: "range",- startDate: nextDate,- endDate: nextDate,- },- false- );- return;- }-- const proposedEndDate = endDate.plus({ days: daysBetweenStartAndEnd });-- // Don't allow moving forward if it would put the entire range in the future- if (startDate.plus({ days: daysBetweenStartAndEnd }) > now) {- return;- }-- setTime(- {- mode: "range",- startDate: startDate.plus({ days: daysBetweenStartAndEnd }).toISODate() ?? "",- // Cap the end date at today- endDate: proposedEndDate.toISODate() ?? "",- },- false- );- } else if (time.mode === "week") {- setTime(- {- mode: "week",- week: DateTime.fromISO(time.week).plus({ weeks: 1 }).toISODate() ?? "",- },- false- );- } else if (time.mode === "month") {- setTime(- {- mode: "month",- month: DateTime.fromISO(time.month).plus({ months: 1 }).toISODate() ?? "",- },- false- );- } else if (time.mode === "year") {- setTime(- {- mode: "year",- year: DateTime.fromISO(time.year).plus({ years: 1 }).toISODate() ?? "",- },- false- );+ const next = shiftTimeForward(time, getTimezone());+ if (next) {+ // Historical quirk kept as-is: forward day steps recalculate the bucket,+ // every other mode keeps the current one (matching goBack).+ setTime(next, next.mode === "day");}};@@ -528,31 +201,4 @@ export const getFilteredFilters = (parameters: FilterParameter[]) => {return filters.filter(f => parameters.includes(f.parameter));};-export const canGoForward = (time: Time) => {- const currentDay = DateTime.now().startOf("day");- if (time.mode === "day") {- return !(DateTime.fromISO(time.day).startOf("day") >= currentDay);- }-- if (time.mode === "range") {- if (hasRangeTimes(time)) {- return !(getRangeDateTimeBounds(time).end >= DateTime.now().setZone(getTimezone()));- }-- return !(DateTime.fromISO(time.endDate).startOf("day") >= currentDay);- }-- if (time.mode === "week") {- return !(DateTime.fromISO(time.week).startOf("week") >= currentDay);- }-- if (time.mode === "month") {- return !(DateTime.fromISO(time.month).startOf("month") >= currentDay);- }-- if (time.mode === "year") {- return !(DateTime.fromISO(time.year).startOf("year") >= currentDay);- }-- return false;-};+export const canGoForward = (time: Time) => canGoForwardFrom(time, getTimezone());diff --git a/client/src/lib/time.test.ts b/client/src/lib/time.test.tsnew file mode 100644index 000000000..8714fe476--- /dev/null+++ b/client/src/lib/time.test.ts@@ -0,0 +1,307 @@+import { DateTime } from "luxon";+import { describe, expect, it } from "vitest";+import { Time } from "../components/DateSelector/types";+import { getDashboardTimeForRange } from "./defaultTimeRange";+import {+ canGoForward,+ deriveTimeState,+ getBucketForDateTimeRange,+ recalculateTimeForTimezone,+ shiftTimeBackward,+ shiftTimeForward,+ timeToUrlParams,+ urlParamsToTime,+} from "./time";++const ZONE = "America/New_York";++const dt = (iso: string, zone = ZONE) => DateTime.fromISO(iso, { zone });++describe("deriveTimeState", () => {+ it("day: previous day, hour bucket", () => {+ expect(deriveTimeState({ mode: "day", day: "2024-03-15" }, ZONE)).toEqual({+ previousTime: { mode: "day", day: "2024-03-14" },+ bucket: "hour",+ });+ });++ it("day: steps across month boundaries", () => {+ expect(deriveTimeState({ mode: "day", day: "2024-03-01" }, ZONE).previousTime).toEqual({+ mode: "day",+ day: "2024-02-29",+ });+ });++ it("past-minutes: doubles the window backwards, minute bucket for short windows", () => {+ expect(deriveTimeState({ mode: "past-minutes", pastMinutesStart: 30, pastMinutesEnd: 0 }, ZONE)).toEqual({+ previousTime: { mode: "past-minutes", pastMinutesStart: 60, pastMinutesEnd: 30 },+ bucket: "minute",+ });+ });++ it("past-minutes: windows over 2h keep the hour bucket", () => {+ const { bucket } = deriveTimeState({ mode: "past-minutes", pastMinutesStart: 1440, pastMinutesEnd: 0 }, ZONE);+ expect(bucket).toBe("hour");+ });++ it("range: previous range is the same length, ending the day before the start", () => {+ const { previousTime, bucket } = deriveTimeState(+ { mode: "range", startDate: "2024-03-08", endDate: "2024-03-14" },+ ZONE+ );+ expect(previousTime).toEqual({ mode: "range", startDate: "2024-03-01", endDate: "2024-03-07" });+ expect(bucket).toBe("day");+ });++ it("range: bucket scales with the range length", () => {+ expect(deriveTimeState({ mode: "range", startDate: "2024-01-01", endDate: "2024-02-15" }, ZONE).bucket).toBe(+ "week"+ );+ expect(deriveTimeState({ mode: "range", startDate: "2023-01-01", endDate: "2024-01-01" }, ZONE).bucket).toBe(+ "month"+ );+ });++ it("range with times: shifts by the exact duration in the given zone", () => {+ const { previousTime, bucket } = deriveTimeState(+ {+ mode: "range",+ startDate: "2024-03-15",+ startTime: "09:00:00",+ endDate: "2024-03-15",+ endTime: "17:00:00",+ },+ ZONE+ );+ expect(previousTime).toEqual({+ mode: "range",+ startDate: "2024-03-15",+ startTime: "01:00:00",+ endDate: "2024-03-15",+ endTime: "09:00:00",+ });+ expect(bucket).toBe("five_minutes");+ });++ it("week/month/year: step one unit back with day/day/month buckets", () => {+ expect(deriveTimeState({ mode: "week", week: "2024-03-11" }, ZONE)).toEqual({+ previousTime: { mode: "week", week: "2024-03-04" },+ bucket: "day",+ });+ expect(deriveTimeState({ mode: "month", month: "2024-03-01" }, ZONE)).toEqual({+ previousTime: { mode: "month", month: "2024-02-01" },+ bucket: "day",+ });+ expect(deriveTimeState({ mode: "year", year: "2024-01-01" }, ZONE)).toEqual({+ previousTime: { mode: "year", year: "2023-01-01" },+ bucket: "month",+ });+ });++ it("all-time: previous is all-time, day bucket", () => {+ expect(deriveTimeState({ mode: "all-time" }, ZONE)).toEqual({+ previousTime: { mode: "all-time" },+ bucket: "day",+ });+ });+});++describe("getBucketForDateTimeRange", () => {+ it("maps duration to bucket at each threshold", () => {+ const start = dt("2024-03-15T00:00:00");+ expect(getBucketForDateTimeRange(start, start.plus({ hours: 2 }))).toBe("minute");+ expect(getBucketForDateTimeRange(start, start.plus({ hours: 24 }))).toBe("five_minutes");+ expect(getBucketForDateTimeRange(start, start.plus({ days: 14 }))).toBe("hour");+ expect(getBucketForDateTimeRange(start, start.plus({ days: 60 }))).toBe("day");+ expect(getBucketForDateTimeRange(start, start.plus({ days: 180 }))).toBe("week");+ expect(getBucketForDateTimeRange(start, start.plus({ days: 181 }))).toBe("month");+ });+});++describe("shiftTimeBackward / shiftTimeForward", () => {+ it("day: moves one day either direction (forward has no future clamp)", () => {+ expect(shiftTimeBackward({ mode: "day", day: "2024-03-15" }, ZONE)).toEqual({ mode: "day", day: "2024-03-14" });+ expect(shiftTimeForward({ mode: "day", day: "2024-03-15" }, ZONE, dt("2024-03-15T12:00:00"))).toEqual({+ mode: "day",+ day: "2024-03-16",+ });+ });++ it("range: shifts by the range length", () => {+ expect(shiftTimeBackward({ mode: "range", startDate: "2024-03-08", endDate: "2024-03-14" }, ZONE)).toEqual({+ mode: "range",+ startDate: "2024-03-02",+ endDate: "2024-03-08",+ });+ expect(+ shiftTimeForward({ mode: "range", startDate: "2024-03-01", endDate: "2024-03-07" }, ZONE, dt("2024-03-20T00:00:00"))+ ).toEqual({ mode: "range", startDate: "2024-03-07", endDate: "2024-03-13" });+ });++ it("range: forward is blocked when the whole range would be in the future", () => {+ expect(+ shiftTimeForward({ mode: "range", startDate: "2024-03-10", endDate: "2024-03-16" }, ZONE, dt("2024-03-14T00:00:00"))+ ).toBeNull();+ });++ it("single-day range: steps one day, blocked at the future edge", () => {+ const now = dt("2024-03-15T12:00:00");+ expect(shiftTimeForward({ mode: "range", startDate: "2024-03-14", endDate: "2024-03-14" }, ZONE, now)).toEqual({+ mode: "range",+ startDate: "2024-03-15",+ endDate: "2024-03-15",+ });+ expect(shiftTimeForward({ mode: "range", startDate: "2024-03-15", endDate: "2024-03-15" }, ZONE, now)).toBeNull();+ });++ it("range with times: forward clamps the end at now", () => {+ const now = dt("2024-03-15T20:00:00");+ const shifted = shiftTimeForward(+ {+ mode: "range",+ startDate: "2024-03-15",+ startTime: "08:00:00",+ endDate: "2024-03-15",+ endTime: "16:00:00",+ },+ ZONE,+ now+ );+ expect(shifted).toEqual({+ mode: "range",+ startDate: "2024-03-15",+ startTime: "16:00:00",+ endDate: "2024-03-15",+ endTime: "20:00:00",+ });+ });++ it("range with times: forward is blocked when the next window starts in the future", () => {+ expect(+ shiftTimeForward(+ {+ mode: "range",+ startDate: "2024-03-15",+ startTime: "08:00:00",+ endDate: "2024-03-15",+ endTime: "16:00:00",+ },+ ZONE,+ dt("2024-03-15T12:00:00")+ )+ ).toBeNull();+ });++ it("all-time and past-minutes do not navigate", () => {+ expect(shiftTimeBackward({ mode: "all-time" }, ZONE)).toBeNull();+ expect(shiftTimeForward({ mode: "all-time" }, ZONE)).toBeNull();+ expect(shiftTimeBackward({ mode: "past-minutes", pastMinutesStart: 30, pastMinutesEnd: 0 }, ZONE)).toBeNull();+ });+});++describe("canGoForward", () => {+ const now = dt("2024-03-15T12:00:00");++ it("day: false for today and the future, true for the past", () => {+ expect(canGoForward({ mode: "day", day: "2024-03-15" }, ZONE, now)).toBe(false);+ expect(canGoForward({ mode: "day", day: "2024-03-14" }, ZONE, now)).toBe(true);+ });++ it("range: gated by the end date", () => {+ expect(canGoForward({ mode: "range", startDate: "2024-03-01", endDate: "2024-03-15" }, ZONE, now)).toBe(false);+ expect(canGoForward({ mode: "range", startDate: "2024-03-01", endDate: "2024-03-14" }, ZONE, now)).toBe(true);+ });++ it("range with times: gated by the end datetime against now in the zone", () => {+ const range = {+ mode: "range",+ startDate: "2024-03-15",+ startTime: "00:00:00",+ endDate: "2024-03-15",+ endTime: "11:00:00",+ } satisfies Time;+ expect(canGoForward(range, ZONE, now)).toBe(true);+ expect(canGoForward({ ...range, endTime: "13:00:00" }, ZONE, now)).toBe(false);+ });++ it("week/month/year: gated by the period start (quirk: the CURRENT period can still step forward, into an entirely-future one)", () => {+ expect(canGoForward({ mode: "week", week: "2024-03-11" }, ZONE, now)).toBe(true);+ expect(canGoForward({ mode: "week", week: "2024-03-18" }, ZONE, now)).toBe(false);+ expect(canGoForward({ mode: "month", month: "2024-03-01" }, ZONE, now)).toBe(true);+ expect(canGoForward({ mode: "month", month: "2024-04-01" }, ZONE, now)).toBe(false);+ expect(canGoForward({ mode: "year", year: "2024-01-01" }, ZONE, now)).toBe(true);+ expect(canGoForward({ mode: "year", year: "2025-01-01" }, ZONE, now)).toBe(false);+ });++ it("all-time and past-minutes: never", () => {+ expect(canGoForward({ mode: "all-time" }, ZONE, now)).toBe(false);+ expect(canGoForward({ mode: "past-minutes", pastMinutesStart: 30, pastMinutesEnd: 0 }, ZONE, now)).toBe(false);+ });+});++describe("recalculateTimeForTimezone", () => {+ it("re-anchors date presets via the canonical preset table", () => {+ const time: Time = { mode: "day", day: "2024-03-15", wellKnown: "today" };+ expect(recalculateTimeForTimezone(time, "Asia/Tokyo")).toEqual(getDashboardTimeForRange("today", "Asia/Tokyo"));+ });++ it("returns null for past-minutes presets and non-preset times", () => {+ expect(+ recalculateTimeForTimezone(+ { mode: "past-minutes", pastMinutesStart: 30, pastMinutesEnd: 0, wellKnown: "last-30-minutes" },+ "Asia/Tokyo"+ )+ ).toBeNull();+ expect(recalculateTimeForTimezone({ mode: "day", day: "2024-03-15" }, "Asia/Tokyo")).toBeNull();+ });+});++describe("URL serialization", () => {+ it("a preset serializes as wellKnown alone", () => {+ const params = timeToUrlParams({ mode: "day", day: "2024-03-15", wellKnown: "today" });+ expect(params.wellKnown).toBe("today");+ expect(params.day).toBeNull();+ expect(params.timeMode).toBe("day");+ });++ it("explicit times round-trip through the URL for every mode", () => {+ const times: Time[] = [+ { mode: "day", day: "2024-03-15" },+ { mode: "range", startDate: "2024-03-01", endDate: "2024-03-14" },+ {+ mode: "range",+ startDate: "2024-03-01",+ endDate: "2024-03-14",+ startTime: "08:00:00",+ endTime: "17:00:00",+ },+ { mode: "week", week: "2024-03-11" },+ { mode: "month", month: "2024-03-01" },+ { mode: "year", year: "2024-01-01" },+ { mode: "past-minutes", pastMinutesStart: 30, pastMinutesEnd: 0 },+ { mode: "all-time" },+ ];++ for (const time of times) {+ expect(urlParamsToTime(timeToUrlParams(time), ZONE)).toEqual(time);+ }+ });++ it("a wellKnown param deserializes through the preset table", () => {+ expect(urlParamsToTime({ wellKnown: "last-7-days" }, ZONE)).toEqual(getDashboardTimeForRange("last-7-days", ZONE));+ });++ it("incomplete params fall through to null", () => {+ expect(urlParamsToTime({}, ZONE)).toBeNull();+ expect(urlParamsToTime({ timeMode: "range", startDate: "2024-03-01" }, ZONE)).toBeNull();+ expect(urlParamsToTime({ timeMode: "day" }, ZONE)).toBeNull();+ });++ it("mode switches clear the other modes' fields", () => {+ const params = timeToUrlParams({ mode: "week", week: "2024-03-11" });+ expect(params.week).toBe("2024-03-11");+ expect(params.day).toBeNull();+ expect(params.startDate).toBeNull();+ expect(params.past_minutes_start).toBeNull();+ });+});diff --git a/client/src/lib/time.ts b/client/src/lib/time.tsnew file mode 100644index 000000000..3ab8ace0e--- /dev/null+++ b/client/src/lib/time.ts@@ -0,0 +1,400 @@+import { TimeBucket } from "@rybbit/shared";+import { DateTime } from "luxon";+import { Time } from "../components/DateSelector/types";+import { getDashboardTimeForRange } from "./defaultTimeRange";++// The Time module: every derivation over a `Time` value lives here — previous+// period, bucket selection, forward/back navigation, timezone recalculation,+// and URL (de)serialization. Pure: the user's zone and "now" are passed in, so+// everything is unit-testable. The store and URL-sync hook are thin callers.++export type RangeWithTimes = Extract<Time, { mode: "range" }> & { startTime: string; endTime: string };++export const hasRangeTimes = (time: Time): time is RangeWithTimes =>+ time.mode === "range" && typeof time.startTime === "string" && typeof time.endTime === "string";++export const getRangeDateTimeBounds = (time: RangeWithTimes, zone: string) => ({+ start: DateTime.fromISO(`${time.startDate}T${time.startTime}`, { zone }),+ end: DateTime.fromISO(`${time.endDate}T${time.endTime}`, { zone }),+});++export const toRangeWithTimes = (start: DateTime, end: DateTime): RangeWithTimes => ({+ mode: "range",+ startDate: start.toISODate() ?? "",+ startTime: start.toFormat("HH:mm:ss"),+ endDate: end.toISODate() ?? "",+ endTime: end.toFormat("HH:mm:ss"),+});++export const getBucketForDateTimeRange = (start: DateTime, end: DateTime): TimeBucket => {+ const minutes = end.diff(start, "minutes").minutes;++ if (minutes <= 120) return "minute";+ if (minutes <= 1440) return "five_minutes";+ if (minutes <= 14 * 1440) return "hour";+ if (minutes <= 60 * 1440) return "day";+ if (minutes <= 180 * 1440) return "week";+ return "month";+};++/**+ * The comparison period and default bucket for a Time. This is the single+ * implementation of "previous period" math (day-1, shifted ranges, doubled+ * past-minutes windows, week/month/year steps).+ */+export const deriveTimeState = (time: Time, zone: string): { previousTime: Time; bucket: TimeBucket } => {+ let bucket: TimeBucket = "hour";+ let previousTime: Time;++ if (time.mode === "day") {+ bucket = "hour";+ previousTime = {+ mode: "day",+ day: DateTime.fromISO(time.day).minus({ days: 1 }).toISODate() ?? "",+ };+ } else if (time.mode === "past-minutes") {+ const timeDiff = time.pastMinutesStart - time.pastMinutesEnd;++ if (timeDiff <= 120) {+ bucket = "minute";+ }++ previousTime = {+ mode: "past-minutes",+ pastMinutesStart: time.pastMinutesStart + timeDiff,+ pastMinutesEnd: time.pastMinutesEnd + timeDiff,+ };+ } else if (time.mode === "range") {+ if (hasRangeTimes(time)) {+ const { start, end } = getRangeDateTimeBounds(time, zone);+ const duration = end.diff(start);+ bucket = getBucketForDateTimeRange(start, end);++ previousTime = toRangeWithTimes(start.minus(duration), end.minus(duration));+ } else {+ const timeRangeLength = DateTime.fromISO(time.endDate).diff(DateTime.fromISO(time.startDate), "days").days + 1;++ if (timeRangeLength > 180) {+ bucket = "month";+ } else if (timeRangeLength > 31) {+ bucket = "week";+ } else {+ bucket = "day";+ }++ previousTime = {+ mode: "range",+ startDate: DateTime.fromISO(time.startDate).minus({ days: timeRangeLength }).toISODate() ?? "",+ endDate: DateTime.fromISO(time.startDate).minus({ days: 1 }).toISODate() ?? "",+ };+ }+ } else if (time.mode === "week") {+ bucket = "day";+ previousTime = {+ mode: "week",+ week: DateTime.fromISO(time.week).minus({ weeks: 1 }).toISODate() ?? "",+ };+ } else if (time.mode === "month") {+ bucket = "day";+ previousTime = {+ mode: "month",+ month: DateTime.fromISO(time.month).minus({ months: 1 }).toISODate() ?? "",+ };+ } else if (time.mode === "year") {+ bucket = "month";+ previousTime = {+ mode: "year",+ year: DateTime.fromISO(time.year).minus({ years: 1 }).toISODate() ?? "",+ };+ } else if (time.mode === "all-time") {+ bucket = "day";+ previousTime = { mode: "all-time" };+ } else {+ previousTime = time;+ }++ return { previousTime, bucket };+};++/** One step back in time. Null when the mode doesn't navigate (all-time, past-minutes). */+export const shiftTimeBackward = (time: Time, zone: string): Time | null => {+ if (time.mode === "day") {+ return {+ mode: "day",+ day: DateTime.fromISO(time.day).minus({ days: 1 }).toISODate() ?? "",+ };+ }++ if (time.mode === "range") {+ if (hasRangeTimes(time)) {+ const { start, end } = getRangeDateTimeBounds(time, zone);+ const duration = end.diff(start);+ return toRangeWithTimes(start.minus(duration), end.minus(duration));+ }++ const startDate = DateTime.fromISO(time.startDate);+ const endDate = DateTime.fromISO(time.endDate);++ const daysBetweenStartAndEnd = endDate.diff(startDate, "days").days;+ if (daysBetweenStartAndEnd === 0) {+ const previousDate = startDate.minus({ days: 1 }).toISODate() ?? "";+ return { mode: "range", startDate: previousDate, endDate: previousDate };+ }++ return {+ mode: "range",+ startDate: startDate.minus({ days: daysBetweenStartAndEnd }).toISODate() ?? "",+ endDate: startDate.toISODate() ?? "",+ };+ }++ if (time.mode === "week") {+ return {+ mode: "week",+ week: DateTime.fromISO(time.week).minus({ weeks: 1 }).toISODate() ?? "",+ };+ }++ if (time.mode === "month") {+ return {+ mode: "month",+ month: DateTime.fromISO(time.month).minus({ months: 1 }).toISODate() ?? "",+ };+ }++ if (time.mode === "year") {+ return {+ mode: "year",+ year: DateTime.fromISO(time.year).minus({ years: 1 }).toISODate() ?? "",+ };+ }++ return null;+};++/**+ * One step forward in time. Null when the mode doesn't navigate or the step+ * would land entirely in the future (ranges clamp against `now`).+ */+export const shiftTimeForward = (time: Time, zone: string, now: DateTime = DateTime.now()): Time | null => {+ if (time.mode === "day") {+ return {+ mode: "day",+ day: DateTime.fromISO(time.day).plus({ days: 1 }).toISODate() ?? "",+ };+ }++ if (time.mode === "range") {+ if (hasRangeTimes(time)) {+ const { start, end } = getRangeDateTimeBounds(time, zone);+ const duration = end.diff(start);+ const proposedStart = start.plus(duration);+ const proposedEnd = end.plus(duration);+ const zonedNow = now.setZone(zone);++ if (proposedStart > zonedNow) {+ return null;+ }++ return toRangeWithTimes(proposedStart, proposedEnd > zonedNow ? zonedNow : proposedEnd);+ }++ const startDate = DateTime.fromISO(time.startDate);+ const endDate = DateTime.fromISO(time.endDate);++ const daysBetweenStartAndEnd = endDate.diff(startDate, "days").days;+ if (daysBetweenStartAndEnd === 0) {+ const proposedDate = startDate.plus({ days: 1 });+ if (proposedDate > now) {+ return null;+ }++ const nextDate = proposedDate.toISODate() ?? "";+ return { mode: "range", startDate: nextDate, endDate: nextDate };+ }++ // Don't allow moving forward if it would put the entire range in the future+ if (startDate.plus({ days: daysBetweenStartAndEnd }) > now) {+ return null;+ }++ return {+ mode: "range",+ startDate: startDate.plus({ days: daysBetweenStartAndEnd }).toISODate() ?? "",+ endDate: endDate.plus({ days: daysBetweenStartAndEnd }).toISODate() ?? "",+ };+ }++ if (time.mode === "week") {+ return {+ mode: "week",+ week: DateTime.fromISO(time.week).plus({ weeks: 1 }).toISODate() ?? "",+ };+ }++ if (time.mode === "month") {+ return {+ mode: "month",+ month: DateTime.fromISO(time.month).plus({ months: 1 }).toISODate() ?? "",+ };+ }++ if (time.mode === "year") {+ return {+ mode: "year",+ year: DateTime.fromISO(time.year).plus({ years: 1 }).toISODate() ?? "",+ };+ }++ return null;+};++export const canGoForward = (time: Time, zone: string, now: DateTime = DateTime.now()): boolean => {+ const currentDay = now.startOf("day");++ if (time.mode === "day") {+ return !(DateTime.fromISO(time.day).startOf("day") >= currentDay);+ }++ if (time.mode === "range") {+ if (hasRangeTimes(time)) {+ return !(getRangeDateTimeBounds(time, zone).end >= now.setZone(zone));+ }++ return !(DateTime.fromISO(time.endDate).startOf("day") >= currentDay);+ }++ if (time.mode === "week") {+ return !(DateTime.fromISO(time.week).startOf("week") >= currentDay);+ }++ if (time.mode === "month") {+ return !(DateTime.fromISO(time.month).startOf("month") >= currentDay);+ }++ if (time.mode === "year") {+ return !(DateTime.fromISO(time.year).startOf("year") >= currentDay);+ }++ return false;+};++/**+ * Re-anchor a preset ("today", "last-7-days", ...) to a new timezone. Null when+ * the Time has no preset or is relative to now (past-minutes) — nothing to do.+ */+export const recalculateTimeForTimezone = (time: Time, zone: string): Time | null => {+ if (!time.wellKnown) return null;+ // past-minutes presets are relative to "now"; no date recalculation needed.+ if (time.mode === "past-minutes") return null;++ return getDashboardTimeForRange(time.wellKnown, zone);+};++// ---------------------------------------------------------------------------+// URL (de)serialization — the single definition of how a Time appears in the+// query string. All time-related fields are always present (null = cleared) so+// stale params from a previous mode never survive a mode switch.++export interface TimeUrlParams {+ timeMode: string | null;+ wellKnown: string | null;+ day: string | null;+ startDate: string | null;+ endDate: string | null;+ startTime: string | null;+ endTime: string | null;+ week: string | null;+ month: string | null;+ year: string | null;+ past_minutes_start: number | null;+ past_minutes_end: number | null;+}++export const timeToUrlParams = (time: Time): TimeUrlParams => {+ const params: TimeUrlParams = {+ timeMode: time.mode,+ wellKnown: null,+ day: null,+ startDate: null,+ endDate: null,+ startTime: null,+ endTime: null,+ week: null,+ month: null,+ year: null,+ past_minutes_start: null,+ past_minutes_end: null,+ };++ // A preset is stored alone; explicit date fields only appear without one.+ if (time.wellKnown) {+ params.wellKnown = time.wellKnown;+ return params;+ }++ if (time.mode === "day") {+ params.day = time.day;+ } else if (time.mode === "range") {+ params.startDate = time.startDate;+ params.endDate = time.endDate;+ params.startTime = time.startTime ?? null;+ params.endTime = time.endTime ?? null;+ } else if (time.mode === "week") {+ params.week = time.week;+ } else if (time.mode === "month") {+ params.month = time.month;+ } else if (time.mode === "year") {+ params.year = time.year;+ } else if (time.mode === "past-minutes") {+ params.past_minutes_start = time.pastMinutesStart;+ params.past_minutes_end = time.pastMinutesEnd;+ }++ return params;+};++/** Null when the params don't describe a complete Time (caller falls back to the default). */+export const urlParamsToTime = (params: Partial<TimeUrlParams>, zone: string): Time | null => {+ if (params.wellKnown) {+ return getDashboardTimeForRange(params.wellKnown, zone);+ }++ if (!params.timeMode) return null;++ if (params.timeMode === "day" && params.day) {+ return { mode: "day", day: params.day };+ }+ if (params.timeMode === "range" && params.startDate && params.endDate) {+ return params.startTime && params.endTime+ ? {+ mode: "range",+ startDate: params.startDate,+ endDate: params.endDate,+ startTime: params.startTime,+ endTime: params.endTime,+ }+ : { mode: "range", startDate: params.startDate, endDate: params.endDate };+ }+ if (params.timeMode === "week" && params.week) {+ return { mode: "week", week: params.week };+ }+ if (params.timeMode === "month" && params.month) {+ return { mode: "month", month: params.month };+ }+ if (params.timeMode === "year" && params.year) {+ return { mode: "year", year: params.year };+ }+ if (params.timeMode === "past-minutes" && params.past_minutes_start != null && params.past_minutes_end != null) {+ return {+ mode: "past-minutes",+ pastMinutesStart: params.past_minutes_start,+ pastMinutesEnd: params.past_minutes_end,+ };+ }+ if (params.timeMode === "all-time") {+ return { mode: "all-time" };+ }++ return null;+};diff --git a/client/src/lib/urlParams.ts b/client/src/lib/urlParams.tsindex dd841329e..89ec31cdb 100644--- a/client/src/lib/urlParams.ts+++ b/client/src/lib/urlParams.ts@@ -3,11 +3,11 @@import { usePathname, useSearchParams } from "next/navigation";import { useQueryStates } from "nuqs";import React, { useEffect } from "react";-import { Time } from "../components/DateSelector/types";-import { getDashboardTimeForRange, getStoredDashboardDefaultTime } from "./defaultTimeRange";+import { getStoredDashboardDefaultTime } from "./defaultTimeRange";import { analyticsParsers } from "./parsers";import { getSiteRouteContext, isSyncedAnalyticsRoute } from "./siteRoute";import { getTimezone, useStore } from "./store";+import { timeToUrlParams, urlParamsToTime } from "./time";// Hook to sync store state with URLexport const useSyncStateWithUrl = () => {@@ -39,46 +39,7 @@ export const useSyncStateWithUrl = () => {if (!hydrationKey || site !== routeContext.siteId || hydratedUrlKey === hydrationKey) return;// Deserialize time from URL- let timeFromUrl: Time | null = null;-- // Try to resolve wellKnown preset first- if (urlParams.wellKnown) {- timeFromUrl = getDashboardTimeForRange(urlParams.wellKnown, getTimezone());- } else if (urlParams.timeMode) {- // Fallback to explicit date parameters- if (urlParams.timeMode === "day" && urlParams.day) {- timeFromUrl = { mode: "day", day: urlParams.day };- } else if (urlParams.timeMode === "range" && urlParams.startDate && urlParams.endDate) {- timeFromUrl =- urlParams.startTime && urlParams.endTime- ? {- mode: "range",- startDate: urlParams.startDate,- endDate: urlParams.endDate,- startTime: urlParams.startTime,- endTime: urlParams.endTime,- }- : { mode: "range", startDate: urlParams.startDate, endDate: urlParams.endDate };- } else if (urlParams.timeMode === "week" && urlParams.week) {- timeFromUrl = { mode: "week", week: urlParams.week };- } else if (urlParams.timeMode === "month" && urlParams.month) {- timeFromUrl = { mode: "month", month: urlParams.month };- } else if (urlParams.timeMode === "year" && urlParams.year) {- timeFromUrl = { mode: "year", year: urlParams.year };- } else if (- urlParams.timeMode === "past-minutes" &&- urlParams.past_minutes_start !== null &&- urlParams.past_minutes_end !== null- ) {- timeFromUrl = {- mode: "past-minutes",- pastMinutesStart: urlParams.past_minutes_start,- pastMinutesEnd: urlParams.past_minutes_end,- };- } else if (urlParams.timeMode === "all-time") {- timeFromUrl = { mode: "all-time" };- }- }+ const timeFromUrl = urlParamsToTime(urlParams, getTimezone());if (timeFromUrl) {setTime(timeFromUrl, !urlParams.bucket);@@ -118,62 +79,15 @@ export const useSyncStateWithUrl = () => {// Build params object to update - values, not parsersconst newParams: Record<string, any> = {- timeMode: time.mode,+ ...timeToUrlParams(time),+ // startDateTime/endDateTime are legacy params no mode writes anymore.+ startDateTime: null,+ endDateTime: null,bucket,stat: selectedStat,filters: filters.length > 0 ? filters : null,};- // If wellKnown preset, only store that- if (time.wellKnown) {- newParams.wellKnown = time.wellKnown;- // Clear explicit date fields- newParams.day = null;- newParams.startDate = null;- newParams.endDate = null;- newParams.startTime = null;- newParams.endTime = null;- newParams.startDateTime = null;- newParams.endDateTime = null;- newParams.week = null;- newParams.month = null;- newParams.year = null;- newParams.past_minutes_start = null;- newParams.past_minutes_end = null;- } else {- newParams.wellKnown = null;- newParams.day = null;- newParams.startDate = null;- newParams.endDate = null;- newParams.startTime = null;- newParams.endTime = null;- newParams.startDateTime = null;- newParams.endDateTime = null;- newParams.week = null;- newParams.month = null;- newParams.year = null;- newParams.past_minutes_start = null;- newParams.past_minutes_end = null;- // Store explicit date fields based on mode- if (time.mode === "day" && "day" in time) {- newParams.day = time.day;- } else if (time.mode === "range" && "startDate" in time && "endDate" in time) {- newParams.startDate = time.startDate;- newParams.endDate = time.endDate;- newParams.startTime = time.startTime ?? null;- newParams.endTime = time.endTime ?? null;- } else if (time.mode === "week" && "week" in time) {- newParams.week = time.week;- } else if (time.mode === "month" && "month" in time) {- newParams.month = time.month;- } else if (time.mode === "year" && "year" in time) {- newParams.year = time.year;- } else if (time.mode === "past-minutes" && "pastMinutesStart" in time && "pastMinutesEnd" in time) {- newParams.past_minutes_start = time.pastMinutesStart;- newParams.past_minutes_end = time.pastMinutesEnd;- }- }-// Note: embed params are automatically preserved by nuqssetUrlParams(newParams);}, [time, bucket, selectedStat, filters, site, setUrlParams, hydrationKey, hydratedUrlKey, routeContext.siteId]);diff --git a/client/vitest.config.ts b/client/vitest.config.tsnew file mode 100644index 000000000..fb91caaf8--- /dev/null+++ b/client/vitest.config.ts@@ -0,0 +1,14 @@+import { defineConfig } from "vitest/config";+import path from "path";++export default defineConfig({+ resolve: {+ alias: {+ "@": path.resolve(__dirname, "src"),+ },+ },+ test: {+ include: ["src/**/*.test.{ts,tsx}"],+ environment: "node",+ },+});