@ohmykreee/dsh-remote-control 0.0.0-stage → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +556 -0
- package/INSTALLATION.md +310 -0
- package/LICENSE +21 -0
- package/README.md +195 -2
- package/client.js +3 -0
- package/components.json +20 -0
- package/cordis.patch.yml +3 -0
- package/docs/README.en.md +196 -0
- package/docs/screenshots/en/overview.png +0 -0
- package/docs/screenshots/en/question.png +0 -0
- package/docs/screenshots/zh/overview.png +0 -0
- package/docs/screenshots/zh/question.png +0 -0
- package/icon.svg +24 -0
- package/index.js +2 -0
- package/lib/account.js +1 -0
- package/lib/app-mapping.js +1 -0
- package/lib/i18n.js +1 -0
- package/lib/media-enrich.js +1 -0
- package/lib/notifications.js +1 -0
- package/lib/performance.js +1 -0
- package/lib/platform/index.js +1 -0
- package/lib/probe-adapter.js +1 -0
- package/lib/probe-daemon.js +1 -0
- package/lib/probe.js +1 -0
- package/lib/qr.js +1 -0
- package/lib/runtime.js +1 -0
- package/lib/service.js +1 -0
- package/lib/sessions.js +1 -0
- package/lib/settings.js +1 -0
- package/lib/types.js +1 -0
- package/lib/util.js +1 -0
- package/lib/weather.js +1 -0
- package/lib/ws.js +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +118 -4
- package/scripts/browser-shot.mjs +217 -0
- package/scripts/build-dsh.mjs +228 -0
- package/scripts/build-rust.mjs +319 -0
- package/scripts/build-web.mjs +17 -0
- package/scripts/check-npm-package.mjs +322 -0
- package/scripts/mock-preview.py +574 -0
- package/scripts/screenshot-compose.py +89 -0
- package/scripts/screenshot-device.sh +75 -0
- package/src/dsh/client/api.ts +68 -0
- package/src/dsh/client/i18n.ts +573 -0
- package/src/dsh/client/icons.ts +56 -0
- package/src/dsh/client/index.ts +95 -0
- package/src/dsh/client/logic.ts +310 -0
- package/src/dsh/client/panel.ts +483 -0
- package/src/dsh/client/sections/apps.ts +40 -0
- package/src/dsh/client/sections/balance.ts +38 -0
- package/src/dsh/client/sections/connection.ts +97 -0
- package/src/dsh/client/sections/notifications.ts +43 -0
- package/src/dsh/client/sections/pomodoro.ts +184 -0
- package/src/dsh/client/sections/preferences.ts +138 -0
- package/src/dsh/client/sections/system.ts +120 -0
- package/src/dsh/client/sections/weather.ts +276 -0
- package/src/dsh/client/styles.ts +1119 -0
- package/src/dsh/client/types.ts +366 -0
- package/src/dsh/client/ui.ts +142 -0
- package/src/dsh/index.ts +108 -0
- package/src/dsh/lib/account.ts +520 -0
- package/src/dsh/lib/app-mapping.ts +366 -0
- package/src/dsh/lib/i18n.ts +82 -0
- package/src/dsh/lib/media-enrich.ts +202 -0
- package/src/dsh/lib/notifications.ts +322 -0
- package/src/dsh/lib/performance.ts +279 -0
- package/src/dsh/lib/platform/index.ts +43 -0
- package/src/dsh/lib/probe-adapter.ts +275 -0
- package/src/dsh/lib/probe-daemon.ts +359 -0
- package/src/dsh/lib/probe.ts +395 -0
- package/src/dsh/lib/qr.ts +42 -0
- package/src/dsh/lib/runtime.ts +126 -0
- package/src/dsh/lib/service.ts +1645 -0
- package/src/dsh/lib/sessions.ts +907 -0
- package/src/dsh/lib/settings.ts +468 -0
- package/src/dsh/lib/types.ts +231 -0
- package/src/dsh/lib/util.ts +115 -0
- package/src/dsh/lib/weather.ts +532 -0
- package/src/dsh/lib/ws.ts +328 -0
- package/src/dsh/types/qrcode-generator.d.ts +16 -0
- package/src/rust/Cargo.lock +1431 -0
- package/src/rust/Cargo.toml +68 -0
- package/src/rust/src/cli.rs +233 -0
- package/src/rust/src/daemon.rs +140 -0
- package/src/rust/src/location/linux.rs +118 -0
- package/src/rust/src/location/macos.rs +26 -0
- package/src/rust/src/location/mod.rs +170 -0
- package/src/rust/src/location/windows.rs +205 -0
- package/src/rust/src/main.rs +42 -0
- package/src/rust/src/media/catalog.rs +454 -0
- package/src/rust/src/media/linux.rs +350 -0
- package/src/rust/src/media/macos/accessibility.rs +59 -0
- package/src/rust/src/media/macos.rs +366 -0
- package/src/rust/src/media/mod.rs +298 -0
- package/src/rust/src/media/vendor/apple_music.rs +90 -0
- package/src/rust/src/media/vendor/common.rs +186 -0
- package/src/rust/src/media/vendor/kugou.rs +52 -0
- package/src/rust/src/media/vendor/kuwo.rs +49 -0
- package/src/rust/src/media/vendor/mod.rs +75 -0
- package/src/rust/src/media/vendor/netease.rs +1715 -0
- package/src/rust/src/media/vendor/qishui.rs +36 -0
- package/src/rust/src/media/vendor/qqmusic.rs +33 -0
- package/src/rust/src/media/vendor/spotify.rs +46 -0
- package/src/rust/src/media/vendor/wesing.rs +39 -0
- package/src/rust/src/media/vendor/youtube_music.rs +49 -0
- package/src/rust/src/media/windows/accessibility.rs +85 -0
- package/src/rust/src/media/windows/audio.rs +116 -0
- package/src/rust/src/media/windows/private.rs +291 -0
- package/src/rust/src/media/windows.rs +775 -0
- package/src/rust/src/notifications/linux.rs +276 -0
- package/src/rust/src/notifications/macos.rs +382 -0
- package/src/rust/src/notifications/mod.rs +244 -0
- package/src/rust/src/notifications/windows.rs +565 -0
- package/src/rust/src/perf/common.rs +109 -0
- package/src/rust/src/perf/linux.rs +282 -0
- package/src/rust/src/perf/macos.rs +28 -0
- package/src/rust/src/perf/mod.rs +157 -0
- package/src/rust/src/perf/windows.rs +981 -0
- package/src/rust/src/util.rs +360 -0
- package/src/rust/src/volume/linux.rs +195 -0
- package/src/rust/src/volume/macos.rs +54 -0
- package/src/rust/src/volume/mod.rs +116 -0
- package/src/rust/src/volume/windows.rs +75 -0
- package/src/rust/tests/cli.rs +79 -0
- package/src/rust/tests/daemon.rs +107 -0
- package/src/svelte/App.svelte +385 -0
- package/src/svelte/index.html +18 -0
- package/src/svelte/lib/billing.svelte.ts +228 -0
- package/src/svelte/lib/components/BalanceCard.svelte +173 -0
- package/src/svelte/lib/components/ClockCard.svelte +183 -0
- package/src/svelte/lib/components/CountdownCard.svelte +261 -0
- package/src/svelte/lib/components/CpuMemoryCard.svelte +238 -0
- package/src/svelte/lib/components/EmptyState.svelte +34 -0
- package/src/svelte/lib/components/GpuCard.svelte +245 -0
- package/src/svelte/lib/components/HomePage.svelte +34 -0
- package/src/svelte/lib/components/MusicControls.svelte +256 -0
- package/src/svelte/lib/components/MusicCover.svelte +88 -0
- package/src/svelte/lib/components/MusicPage.svelte +116 -0
- package/src/svelte/lib/components/NotificationsCard.svelte +109 -0
- package/src/svelte/lib/components/Panel.svelte +22 -0
- package/src/svelte/lib/components/PerformancePage.svelte +55 -0
- package/src/svelte/lib/components/PomodoroCard.svelte +250 -0
- package/src/svelte/lib/components/QuestionSheet.svelte +354 -0
- package/src/svelte/lib/components/RadialGauge.svelte +99 -0
- package/src/svelte/lib/components/Rail.svelte +217 -0
- package/src/svelte/lib/components/SectionHeader.svelte +40 -0
- package/src/svelte/lib/components/SeekBar.svelte +421 -0
- package/src/svelte/lib/components/SessionList.svelte +364 -0
- package/src/svelte/lib/components/SessionStats.svelte +98 -0
- package/src/svelte/lib/components/SessionsPage.svelte +61 -0
- package/src/svelte/lib/components/SpendCard.svelte +105 -0
- package/src/svelte/lib/components/ThermalCard.svelte +249 -0
- package/src/svelte/lib/components/Toast.svelte +32 -0
- package/src/svelte/lib/components/WeatherIcon.svelte +40 -0
- package/src/svelte/lib/components/WeatherPanel.svelte +420 -0
- package/src/svelte/lib/components/ui/alert/alert-action.svelte +20 -0
- package/src/svelte/lib/components/ui/alert/alert-description.svelte +23 -0
- package/src/svelte/lib/components/ui/alert/alert-title.svelte +23 -0
- package/src/svelte/lib/components/ui/alert/alert.svelte +43 -0
- package/src/svelte/lib/components/ui/alert/index.ts +17 -0
- package/src/svelte/lib/components/ui/avatar/avatar-badge.svelte +26 -0
- package/src/svelte/lib/components/ui/avatar/avatar-fallback.svelte +20 -0
- package/src/svelte/lib/components/ui/avatar/avatar-group-count.svelte +23 -0
- package/src/svelte/lib/components/ui/avatar/avatar-group.svelte +23 -0
- package/src/svelte/lib/components/ui/avatar/avatar-image.svelte +17 -0
- package/src/svelte/lib/components/ui/avatar/avatar.svelte +26 -0
- package/src/svelte/lib/components/ui/avatar/index.ts +22 -0
- package/src/svelte/lib/components/ui/badge/badge.svelte +49 -0
- package/src/svelte/lib/components/ui/badge/index.ts +2 -0
- package/src/svelte/lib/components/ui/button/button.svelte +82 -0
- package/src/svelte/lib/components/ui/button/index.ts +17 -0
- package/src/svelte/lib/components/ui/card/card-action.svelte +23 -0
- package/src/svelte/lib/components/ui/card/card-content.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card-description.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card-footer.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card-header.svelte +23 -0
- package/src/svelte/lib/components/ui/card/card-title.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card.svelte +22 -0
- package/src/svelte/lib/components/ui/card/index.ts +25 -0
- package/src/svelte/lib/components/ui/dialog/dialog-close.svelte +11 -0
- package/src/svelte/lib/components/ui/dialog/dialog-content.svelte +48 -0
- package/src/svelte/lib/components/ui/dialog/dialog-description.svelte +17 -0
- package/src/svelte/lib/components/ui/dialog/dialog-footer.svelte +32 -0
- package/src/svelte/lib/components/ui/dialog/dialog-header.svelte +20 -0
- package/src/svelte/lib/components/ui/dialog/dialog-overlay.svelte +17 -0
- package/src/svelte/lib/components/ui/dialog/dialog-portal.svelte +7 -0
- package/src/svelte/lib/components/ui/dialog/dialog-title.svelte +17 -0
- package/src/svelte/lib/components/ui/dialog/dialog-trigger.svelte +11 -0
- package/src/svelte/lib/components/ui/dialog/dialog.svelte +7 -0
- package/src/svelte/lib/components/ui/dialog/index.ts +34 -0
- package/src/svelte/lib/components/ui/empty/empty-content.svelte +23 -0
- package/src/svelte/lib/components/ui/empty/empty-description.svelte +23 -0
- package/src/svelte/lib/components/ui/empty/empty-header.svelte +20 -0
- package/src/svelte/lib/components/ui/empty/empty-media.svelte +41 -0
- package/src/svelte/lib/components/ui/empty/empty-title.svelte +20 -0
- package/src/svelte/lib/components/ui/empty/empty.svelte +23 -0
- package/src/svelte/lib/components/ui/empty/index.ts +22 -0
- package/src/svelte/lib/components/ui/input/index.ts +7 -0
- package/src/svelte/lib/components/ui/input/input.svelte +48 -0
- package/src/svelte/lib/components/ui/progress/index.ts +7 -0
- package/src/svelte/lib/components/ui/progress/progress.svelte +27 -0
- package/src/svelte/lib/components/ui/scroll-area/index.ts +10 -0
- package/src/svelte/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte +30 -0
- package/src/svelte/lib/components/ui/scroll-area/scroll-area.svelte +43 -0
- package/src/svelte/lib/components/ui/separator/index.ts +7 -0
- package/src/svelte/lib/components/ui/separator/separator.svelte +21 -0
- package/src/svelte/lib/components/ui/sheet/index.ts +34 -0
- package/src/svelte/lib/components/ui/sheet/sheet-close.svelte +7 -0
- package/src/svelte/lib/components/ui/sheet/sheet-content.svelte +55 -0
- package/src/svelte/lib/components/ui/sheet/sheet-description.svelte +17 -0
- package/src/svelte/lib/components/ui/sheet/sheet-footer.svelte +20 -0
- package/src/svelte/lib/components/ui/sheet/sheet-header.svelte +20 -0
- package/src/svelte/lib/components/ui/sheet/sheet-overlay.svelte +20 -0
- package/src/svelte/lib/components/ui/sheet/sheet-portal.svelte +7 -0
- package/src/svelte/lib/components/ui/sheet/sheet-title.svelte +17 -0
- package/src/svelte/lib/components/ui/sheet/sheet-trigger.svelte +7 -0
- package/src/svelte/lib/components/ui/sheet/sheet.svelte +7 -0
- package/src/svelte/lib/components/ui/skeleton/index.ts +7 -0
- package/src/svelte/lib/components/ui/skeleton/skeleton.svelte +17 -0
- package/src/svelte/lib/components/ui/slider/index.ts +7 -0
- package/src/svelte/lib/components/ui/slider/slider.svelte +52 -0
- package/src/svelte/lib/components/ui/tooltip/index.ts +19 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-content.svelte +51 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-portal.svelte +7 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-provider.svelte +7 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-trigger.svelte +7 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip.svelte +7 -0
- package/src/svelte/lib/countdown.svelte.ts +252 -0
- package/src/svelte/lib/format.ts +199 -0
- package/src/svelte/lib/i18n.svelte.ts +583 -0
- package/src/svelte/lib/media.ts +32 -0
- package/src/svelte/lib/pages.ts +18 -0
- package/src/svelte/lib/pomodoro.svelte.ts +223 -0
- package/src/svelte/lib/session-tree.ts +80 -0
- package/src/svelte/lib/state.svelte.ts +359 -0
- package/src/svelte/lib/timer-alarm.svelte.ts +319 -0
- package/src/svelte/lib/types.ts +306 -0
- package/src/svelte/lib/utils.ts +8 -0
- package/src/svelte/lib/weather.ts +84 -0
- package/src/svelte/lib/ws.ts +104 -0
- package/src/svelte/main.ts +13 -0
- package/src/svelte/styles/global.css +315 -0
- package/src/svelte/vite-env.d.ts +12 -0
- package/static/fonts/LICENSE.txt +287 -0
- package/static/icon.svg +24 -0
- package/static/manifest.webmanifest +18 -0
- package/svelte.config.js +5 -0
- package/tsconfig.dsh-client.json +18 -0
- package/tsconfig.dsh.json +21 -0
- package/tsconfig.json +20 -0
- package/vite.config.js +31 -0
- package/web/assets/index-DLdSfnJ3.css +1 -0
- package/web/assets/index-YNE8X0Uy.js +6 -0
- package/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/web/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/web/assets/noto-sans-sc-100-wght-normal-DluiXYzi.woff2 +0 -0
- package/web/assets/noto-sans-sc-101-wght-normal-CPkZHnw0.woff2 +0 -0
- package/web/assets/noto-sans-sc-102-wght-normal-gzIulUH6.woff2 +0 -0
- package/web/assets/noto-sans-sc-103-wght-normal-CJfSBxFo.woff2 +0 -0
- package/web/assets/noto-sans-sc-104-wght-normal-B3QMglgE.woff2 +0 -0
- package/web/assets/noto-sans-sc-105-wght-normal-xXh_OMfk.woff2 +0 -0
- package/web/assets/noto-sans-sc-106-wght-normal-B9n3jMjP.woff2 +0 -0
- package/web/assets/noto-sans-sc-107-wght-normal-D7fvVprN.woff2 +0 -0
- package/web/assets/noto-sans-sc-108-wght-normal-J0_LhxVo.woff2 +0 -0
- package/web/assets/noto-sans-sc-109-wght-normal-Dsp-De_0.woff2 +0 -0
- package/web/assets/noto-sans-sc-110-wght-normal-DE_6NUrb.woff2 +0 -0
- package/web/assets/noto-sans-sc-111-wght-normal-C4S-TlTn.woff2 +0 -0
- package/web/assets/noto-sans-sc-112-wght-normal-BcFuP3w6.woff2 +0 -0
- package/web/assets/noto-sans-sc-113-wght-normal-Dk932kmj.woff2 +0 -0
- package/web/assets/noto-sans-sc-114-wght-normal-CO_5Xo-i.woff2 +0 -0
- package/web/assets/noto-sans-sc-115-wght-normal-BWy07H14.woff2 +0 -0
- package/web/assets/noto-sans-sc-116-wght-normal-B4HVAfHo.woff2 +0 -0
- package/web/assets/noto-sans-sc-117-wght-normal-siZzFqgK.woff2 +0 -0
- package/web/assets/noto-sans-sc-118-wght-normal-xhBB7f6V.woff2 +0 -0
- package/web/assets/noto-sans-sc-119-wght-normal-Ck_g2FGz.woff2 +0 -0
- package/web/assets/noto-sans-sc-21-wght-normal-D0x9-yBt.woff2 +0 -0
- package/web/assets/noto-sans-sc-22-wght-normal-BBUVTShg.woff2 +0 -0
- package/web/assets/noto-sans-sc-23-wght-normal-Du1oYWkE.woff2 +0 -0
- package/web/assets/noto-sans-sc-24-wght-normal-CmWjJ0gt.woff2 +0 -0
- package/web/assets/noto-sans-sc-25-wght-normal-BFHiqilg.woff2 +0 -0
- package/web/assets/noto-sans-sc-26-wght-normal-C0sF2Z2f.woff2 +0 -0
- package/web/assets/noto-sans-sc-27-wght-normal-COFdrquJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-28-wght-normal-DMgdNu1o.woff2 +0 -0
- package/web/assets/noto-sans-sc-29-wght-normal-Cmq8em30.woff2 +0 -0
- package/web/assets/noto-sans-sc-30-wght-normal-CZWqZ3yU.woff2 +0 -0
- package/web/assets/noto-sans-sc-31-wght-normal-Wfi_lutW.woff2 +0 -0
- package/web/assets/noto-sans-sc-32-wght-normal-BRJQ4PY5.woff2 +0 -0
- package/web/assets/noto-sans-sc-33-wght-normal-CUVQXNAJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-34-wght-normal-Bspba0wC.woff2 +0 -0
- package/web/assets/noto-sans-sc-35-wght-normal-K8fX_YPG.woff2 +0 -0
- package/web/assets/noto-sans-sc-36-wght-normal-CkITyjoT.woff2 +0 -0
- package/web/assets/noto-sans-sc-37-wght-normal-WCZ2zfEe.woff2 +0 -0
- package/web/assets/noto-sans-sc-38-wght-normal-DeM7CUce.woff2 +0 -0
- package/web/assets/noto-sans-sc-39-wght-normal-BMZNLWQU.woff2 +0 -0
- package/web/assets/noto-sans-sc-4-wght-normal-AR5bdDjz.woff2 +0 -0
- package/web/assets/noto-sans-sc-40-wght-normal-BQ5xpS5j.woff2 +0 -0
- package/web/assets/noto-sans-sc-41-wght-normal-Hthm7FFi.woff2 +0 -0
- package/web/assets/noto-sans-sc-42-wght-normal-eaS2gKds.woff2 +0 -0
- package/web/assets/noto-sans-sc-43-wght-normal-o-T53XXV.woff2 +0 -0
- package/web/assets/noto-sans-sc-44-wght-normal-BJH5J4Ez.woff2 +0 -0
- package/web/assets/noto-sans-sc-45-wght-normal-BKuxSCOJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-46-wght-normal-BR_5Mu6e.woff2 +0 -0
- package/web/assets/noto-sans-sc-47-wght-normal-CyY7gKNX.woff2 +0 -0
- package/web/assets/noto-sans-sc-48-wght-normal-BNMfTR6k.woff2 +0 -0
- package/web/assets/noto-sans-sc-49-wght-normal-DX-0y7wg.woff2 +0 -0
- package/web/assets/noto-sans-sc-5-wght-normal-CfWugllB.woff2 +0 -0
- package/web/assets/noto-sans-sc-50-wght-normal-DAOGW-Dr.woff2 +0 -0
- package/web/assets/noto-sans-sc-51-wght-normal-BlFLOjcP.woff2 +0 -0
- package/web/assets/noto-sans-sc-52-wght-normal-OZjrybnw.woff2 +0 -0
- package/web/assets/noto-sans-sc-53-wght-normal-CwyWNT6x.woff2 +0 -0
- package/web/assets/noto-sans-sc-54-wght-normal-DM0nRe18.woff2 +0 -0
- package/web/assets/noto-sans-sc-55-wght-normal-DBK2wUOR.woff2 +0 -0
- package/web/assets/noto-sans-sc-56-wght-normal-C-VKK1LS.woff2 +0 -0
- package/web/assets/noto-sans-sc-57-wght-normal-Cdbfh5kq.woff2 +0 -0
- package/web/assets/noto-sans-sc-58-wght-normal-CflMKARZ.woff2 +0 -0
- package/web/assets/noto-sans-sc-59-wght-normal-BS4Kwzxx.woff2 +0 -0
- package/web/assets/noto-sans-sc-6-wght-normal-ChnZIQfQ.woff2 +0 -0
- package/web/assets/noto-sans-sc-60-wght-normal-B7QOYsXJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-61-wght-normal-C8JjQS7w.woff2 +0 -0
- package/web/assets/noto-sans-sc-62-wght-normal-bS4wq1Gg.woff2 +0 -0
- package/web/assets/noto-sans-sc-63-wght-normal-BJr8P-OB.woff2 +0 -0
- package/web/assets/noto-sans-sc-64-wght-normal-DVB11t7j.woff2 +0 -0
- package/web/assets/noto-sans-sc-65-wght-normal-DMPCXBvK.woff2 +0 -0
- package/web/assets/noto-sans-sc-66-wght-normal-BobaG10V.woff2 +0 -0
- package/web/assets/noto-sans-sc-67-wght-normal-Dzk7WhCR.woff2 +0 -0
- package/web/assets/noto-sans-sc-68-wght-normal-DGbCD9xu.woff2 +0 -0
- package/web/assets/noto-sans-sc-69-wght-normal-Ctrv1EqA.woff2 +0 -0
- package/web/assets/noto-sans-sc-70-wght-normal-RgTO941D.woff2 +0 -0
- package/web/assets/noto-sans-sc-71-wght-normal-D9sG-CWv.woff2 +0 -0
- package/web/assets/noto-sans-sc-72-wght-normal-C4oWy3ul.woff2 +0 -0
- package/web/assets/noto-sans-sc-73-wght-normal-B1ZoOTgM.woff2 +0 -0
- package/web/assets/noto-sans-sc-74-wght-normal-F7dH_rZJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-75-wght-normal-Cp2wp4si.woff2 +0 -0
- package/web/assets/noto-sans-sc-76-wght-normal-B494D7xS.woff2 +0 -0
- package/web/assets/noto-sans-sc-77-wght-normal-B3MVY9Ax.woff2 +0 -0
- package/web/assets/noto-sans-sc-78-wght-normal-5jX7iNMC.woff2 +0 -0
- package/web/assets/noto-sans-sc-79-wght-normal-BIoZy8fr.woff2 +0 -0
- package/web/assets/noto-sans-sc-80-wght-normal-Bje1Fxy1.woff2 +0 -0
- package/web/assets/noto-sans-sc-81-wght-normal-B2NN7Qi3.woff2 +0 -0
- package/web/assets/noto-sans-sc-82-wght-normal-CUggNZi4.woff2 +0 -0
- package/web/assets/noto-sans-sc-83-wght-normal-99rD8YO-.woff2 +0 -0
- package/web/assets/noto-sans-sc-84-wght-normal-zMBmUocm.woff2 +0 -0
- package/web/assets/noto-sans-sc-85-wght-normal-CjI3qdxG.woff2 +0 -0
- package/web/assets/noto-sans-sc-86-wght-normal-BHY8TVEH.woff2 +0 -0
- package/web/assets/noto-sans-sc-87-wght-normal-DioZSHnU.woff2 +0 -0
- package/web/assets/noto-sans-sc-88-wght-normal-BXYxwf2t.woff2 +0 -0
- package/web/assets/noto-sans-sc-89-wght-normal-ClMFrFaL.woff2 +0 -0
- package/web/assets/noto-sans-sc-90-wght-normal-BnOlPreP.woff2 +0 -0
- package/web/assets/noto-sans-sc-91-wght-normal-DTr9RQcS.woff2 +0 -0
- package/web/assets/noto-sans-sc-97-wght-normal-9u6Aiav-.woff2 +0 -0
- package/web/assets/noto-sans-sc-98-wght-normal-BR-H2C0V.woff2 +0 -0
- package/web/assets/noto-sans-sc-99-wght-normal-BI6XPoxp.woff2 +0 -0
- package/web/assets/noto-sans-sc-cyrillic-wght-normal-BGmsQlw-.woff2 +0 -0
- package/web/assets/noto-sans-sc-latin-ext-wght-normal-DuJTpTg_.woff2 +0 -0
- package/web/assets/noto-sans-sc-latin-wght-normal-DDW8mKAR.woff2 +0 -0
- package/web/assets/noto-sans-sc-vietnamese-wght-normal-Bi3ATJ76.woff2 +0 -0
- package/web/fonts/LICENSE.txt +287 -0
- package/web/icon.svg +24 -0
- package/web/index.html +19 -0
- package/web/manifest.webmanifest +18 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, tick } from 'svelte';
|
|
3
|
+
import WifiOff from '@lucide/svelte/icons/wifi-off';
|
|
4
|
+
import { app, exposeState, restoreUrl, startLive, startTicks, stopLive, toast } from './lib/state.svelte';
|
|
5
|
+
import { DEFAULT_ORDER, enabledOrder, normalizeOrder } from './lib/pages';
|
|
6
|
+
import { pageLabel, t } from './lib/i18n.svelte';
|
|
7
|
+
import type { PageKey } from './lib/types';
|
|
8
|
+
import { refreshLive } from './lib/ws';
|
|
9
|
+
import { tabAlert } from './lib/timer-alarm.svelte';
|
|
10
|
+
import HomePage from './lib/components/HomePage.svelte';
|
|
11
|
+
import MusicPage from './lib/components/MusicPage.svelte';
|
|
12
|
+
import PerformancePage from './lib/components/PerformancePage.svelte';
|
|
13
|
+
import QuestionSheet from './lib/components/QuestionSheet.svelte';
|
|
14
|
+
import Rail from './lib/components/Rail.svelte';
|
|
15
|
+
import SessionsPage from './lib/components/SessionsPage.svelte';
|
|
16
|
+
import Toast from './lib/components/Toast.svelte';
|
|
17
|
+
|
|
18
|
+
interface DisplayPage {
|
|
19
|
+
key: PageKey;
|
|
20
|
+
clone: 'first' | 'last' | null;
|
|
21
|
+
uid: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const order = $derived(enabledOrder(normalizeOrder(app.pageOrder), app.pageEnabled));
|
|
25
|
+
const questionCount = $derived(app.sessions.filter((session) => session.status === 'question').length);
|
|
26
|
+
const errorCount = $derived(app.sessions.filter((session) => session.status === 'error').length);
|
|
27
|
+
|
|
28
|
+
const displayPages = $derived.by<DisplayPage[]>(() => {
|
|
29
|
+
const pages: DisplayPage[] = order.map((key) => ({ key, clone: null, uid: `real-${key}` }));
|
|
30
|
+
if (order.length < 2) return pages;
|
|
31
|
+
return [
|
|
32
|
+
{ key: order[order.length - 1], clone: 'last', uid: `clone-last-${order[order.length - 1]}` },
|
|
33
|
+
...pages,
|
|
34
|
+
{ key: order[0], clone: 'first', uid: `clone-first-${order[0]}` },
|
|
35
|
+
];
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
let pager: HTMLElement | undefined = $state();
|
|
39
|
+
let jumpTimer: ReturnType<typeof setTimeout> | null = null;
|
|
40
|
+
let suppressScrollUntil = 0;
|
|
41
|
+
let appliedOrderSignature = '';
|
|
42
|
+
let revisionSeen = 0;
|
|
43
|
+
let scrollFrame = 0;
|
|
44
|
+
|
|
45
|
+
const params = new URLSearchParams(location.search);
|
|
46
|
+
const pageParam = params.get('page');
|
|
47
|
+
if (pageParam && DEFAULT_ORDER.includes(pageParam as PageKey)) app.initialKey = pageParam as PageKey;
|
|
48
|
+
|
|
49
|
+
function pageOffset(): number {
|
|
50
|
+
return order.length > 1 ? 1 : 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function scrollToKey(key: PageKey, smooth = false): void {
|
|
54
|
+
if (!pager) return;
|
|
55
|
+
const index = order.indexOf(key);
|
|
56
|
+
if (index < 0) return;
|
|
57
|
+
const left = (index + pageOffset()) * pager.clientWidth;
|
|
58
|
+
if (smooth) {
|
|
59
|
+
pager.scrollTo({ left, behavior: 'smooth' });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
pager.scrollLeft = left;
|
|
63
|
+
requestAnimationFrame(() => {
|
|
64
|
+
if (pager) pager.scrollLeft = left;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function goTo(key: PageKey, smooth = true): void {
|
|
69
|
+
if (!order.includes(key)) return;
|
|
70
|
+
app.hasNavigated = true;
|
|
71
|
+
app.activeKey = key;
|
|
72
|
+
suppressScrollUntil = Date.now() + (smooth ? 620 : 120);
|
|
73
|
+
if (jumpTimer) {
|
|
74
|
+
clearTimeout(jumpTimer);
|
|
75
|
+
jumpTimer = null;
|
|
76
|
+
}
|
|
77
|
+
scrollToKey(key, smooth);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function applyPageOrder(): void {
|
|
81
|
+
if (revisionSeen === 0) return;
|
|
82
|
+
const signature = order.join('|');
|
|
83
|
+
const same = signature === appliedOrderSignature;
|
|
84
|
+
const previousKey = app.activeKey;
|
|
85
|
+
const initialKey = app.initialKey && order.includes(app.initialKey) ? app.initialKey : null;
|
|
86
|
+
const wanted: PageKey = initialKey ?? (!app.hasNavigated ? order[0] : order.includes(previousKey) ? previousKey : order[0]);
|
|
87
|
+
app.initialKey = null;
|
|
88
|
+
app.hasNavigated = true;
|
|
89
|
+
app.activeKey = wanted;
|
|
90
|
+
appliedOrderSignature = signature;
|
|
91
|
+
if (initialKey || !same || wanted !== previousKey) {
|
|
92
|
+
suppressScrollUntil = Date.now() + 220;
|
|
93
|
+
scrollToKey(wanted, false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
$effect(() => {
|
|
98
|
+
const revision = app.pageRevision;
|
|
99
|
+
if (revision === revisionSeen) return;
|
|
100
|
+
revisionSeen = revision;
|
|
101
|
+
applyPageOrder();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
$effect(() => {
|
|
105
|
+
document.body.dataset.theme = app.theme;
|
|
106
|
+
document.body.dataset.page = app.activeKey;
|
|
107
|
+
document.documentElement.classList.toggle('dark', app.theme === 'dark');
|
|
108
|
+
document.documentElement.classList.toggle('light', app.theme === 'light');
|
|
109
|
+
document.querySelector('meta[name="theme-color"]')?.setAttribute('content', app.theme === 'light' ? '#eef2f8' : '#151a23');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
function scheduleEdgeJump(jumpTo: number, count: number): void {
|
|
113
|
+
if (jumpTimer) clearTimeout(jumpTimer);
|
|
114
|
+
jumpTimer = setTimeout(() => {
|
|
115
|
+
jumpTimer = null;
|
|
116
|
+
if (!pager) return;
|
|
117
|
+
const raw = Math.round(pager.scrollLeft / Math.max(1, pager.clientWidth));
|
|
118
|
+
const stillAtEdge = jumpTo === count ? raw <= 0 : raw >= count + 1;
|
|
119
|
+
if (!stillAtEdge) return;
|
|
120
|
+
pager.style.scrollSnapType = 'none';
|
|
121
|
+
suppressScrollUntil = Date.now() + 220;
|
|
122
|
+
pager.scrollLeft = jumpTo * pager.clientWidth;
|
|
123
|
+
requestAnimationFrame(() => {
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
if (pager) pager.style.scrollSnapType = '';
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}, 150);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function handleScroll(): void {
|
|
132
|
+
if (!pager) return;
|
|
133
|
+
cancelAnimationFrame(scrollFrame);
|
|
134
|
+
scrollFrame = requestAnimationFrame(() => {
|
|
135
|
+
if (!pager || Date.now() < suppressScrollUntil) return;
|
|
136
|
+
const count = order.length;
|
|
137
|
+
const raw = Math.round(pager.scrollLeft / Math.max(1, pager.clientWidth));
|
|
138
|
+
let key: PageKey | null = null;
|
|
139
|
+
let jumpTo: number | null = null;
|
|
140
|
+
if (count < 2) {
|
|
141
|
+
key = order[0];
|
|
142
|
+
} else if (raw <= 0) {
|
|
143
|
+
key = order[count - 1];
|
|
144
|
+
jumpTo = count;
|
|
145
|
+
} else if (raw >= count + 1) {
|
|
146
|
+
key = order[0];
|
|
147
|
+
jumpTo = 1;
|
|
148
|
+
} else {
|
|
149
|
+
key = order[raw - 1] ?? null;
|
|
150
|
+
}
|
|
151
|
+
if (key && key !== app.activeKey) {
|
|
152
|
+
app.activeKey = key;
|
|
153
|
+
app.hasNavigated = true;
|
|
154
|
+
}
|
|
155
|
+
if (jumpTo !== null) scheduleEdgeJump(jumpTo, count);
|
|
156
|
+
else if (jumpTimer) {
|
|
157
|
+
clearTimeout(jumpTimer);
|
|
158
|
+
jumpTimer = null;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function handleResize(): void {
|
|
164
|
+
if (!pager) return;
|
|
165
|
+
suppressScrollUntil = Date.now() + 160;
|
|
166
|
+
pager.scrollLeft = (order.indexOf(app.activeKey) + pageOffset()) * pager.clientWidth;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type FullscreenDocument = Document & {
|
|
170
|
+
webkitFullscreenElement?: Element | null;
|
|
171
|
+
webkitExitFullscreen?: () => Promise<void> | void;
|
|
172
|
+
};
|
|
173
|
+
type FullscreenElement = HTMLElement & {
|
|
174
|
+
webkitRequestFullscreen?: () => Promise<void> | void;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
function isFullscreen(): boolean {
|
|
178
|
+
return Boolean(document.fullscreenElement || (document as FullscreenDocument).webkitFullscreenElement);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function updateFullscreen(): void {
|
|
182
|
+
app.fullscreen = isFullscreen();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function toggleFullscreen(): Promise<void> {
|
|
186
|
+
try {
|
|
187
|
+
if (isFullscreen()) {
|
|
188
|
+
const doc = document as FullscreenDocument;
|
|
189
|
+
if (document.exitFullscreen) await document.exitFullscreen();
|
|
190
|
+
else if (doc.webkitExitFullscreen) await doc.webkitExitFullscreen();
|
|
191
|
+
} else {
|
|
192
|
+
const root = document.documentElement as FullscreenElement;
|
|
193
|
+
if (root.requestFullscreen) await root.requestFullscreen();
|
|
194
|
+
else if (root.webkitRequestFullscreen) await root.webkitRequestFullscreen();
|
|
195
|
+
else toast(t('fullscreenUnsupported'));
|
|
196
|
+
}
|
|
197
|
+
} catch {
|
|
198
|
+
toast(t('fullscreenDenied'));
|
|
199
|
+
}
|
|
200
|
+
setTimeout(updateFullscreen, 120);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function handleVisibility(): void {
|
|
204
|
+
if (!document.hidden) refreshLive();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function handleRefresh(): void {
|
|
208
|
+
refreshLive();
|
|
209
|
+
toast(t('refreshing'));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
onMount(() => {
|
|
213
|
+
const stopTicks = startTicks();
|
|
214
|
+
const initial = app.initialKey && order.includes(app.initialKey) ? app.initialKey : order[0];
|
|
215
|
+
app.activeKey = initial;
|
|
216
|
+
appliedOrderSignature = order.join('|');
|
|
217
|
+
void tick().then(() => scrollToKey(initial, false));
|
|
218
|
+
startLive();
|
|
219
|
+
exposeState();
|
|
220
|
+
restoreUrl();
|
|
221
|
+
updateFullscreen();
|
|
222
|
+
|
|
223
|
+
document.addEventListener('fullscreenchange', updateFullscreen);
|
|
224
|
+
document.addEventListener('webkitfullscreenchange' as 'fullscreenchange', updateFullscreen);
|
|
225
|
+
document.addEventListener('visibilitychange', handleVisibility);
|
|
226
|
+
window.addEventListener('resize', handleResize);
|
|
227
|
+
|
|
228
|
+
return () => {
|
|
229
|
+
stopTicks();
|
|
230
|
+
stopLive();
|
|
231
|
+
if (jumpTimer) clearTimeout(jumpTimer);
|
|
232
|
+
cancelAnimationFrame(scrollFrame);
|
|
233
|
+
document.removeEventListener('fullscreenchange', updateFullscreen);
|
|
234
|
+
document.removeEventListener('webkitfullscreenchange' as 'fullscreenchange', updateFullscreen);
|
|
235
|
+
document.removeEventListener('visibilitychange', handleVisibility);
|
|
236
|
+
window.removeEventListener('resize', handleResize);
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
</script>
|
|
240
|
+
|
|
241
|
+
<div class="app-shell nav-{app.navPosition}">
|
|
242
|
+
<Rail
|
|
243
|
+
{order}
|
|
244
|
+
activeKey={app.activeKey}
|
|
245
|
+
{questionCount}
|
|
246
|
+
{errorCount}
|
|
247
|
+
timerAlert={tabAlert.active}
|
|
248
|
+
onNavigate={goTo}
|
|
249
|
+
onFullscreen={toggleFullscreen}
|
|
250
|
+
onRefresh={handleRefresh}
|
|
251
|
+
/>
|
|
252
|
+
|
|
253
|
+
<main class="pager" bind:this={pager} onscroll={handleScroll}>
|
|
254
|
+
{#each displayPages as item (item.uid)}
|
|
255
|
+
<section
|
|
256
|
+
class="page page-{item.key}"
|
|
257
|
+
class:page-clone={item.clone !== null}
|
|
258
|
+
data-page-key={item.clone ? (item.clone === 'first' ? '__first-clone' : '__last-clone') : item.key}
|
|
259
|
+
data-source-key={item.clone ? item.key : undefined}
|
|
260
|
+
aria-label={pageLabel(item.key)}
|
|
261
|
+
aria-hidden={item.clone ? 'true' : undefined}
|
|
262
|
+
>
|
|
263
|
+
{#if item.key === 'home'}
|
|
264
|
+
<HomePage />
|
|
265
|
+
{:else if item.key === 'sessions'}
|
|
266
|
+
<SessionsPage />
|
|
267
|
+
{:else if item.key === 'music'}
|
|
268
|
+
<MusicPage />
|
|
269
|
+
{:else if item.key === 'performance'}
|
|
270
|
+
<PerformancePage />
|
|
271
|
+
{/if}
|
|
272
|
+
</section>
|
|
273
|
+
{/each}
|
|
274
|
+
</main>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
{#if app.online === false}
|
|
278
|
+
<div class="offline" role="status">
|
|
279
|
+
<WifiOff class="size-3.5" strokeWidth={1.8} />
|
|
280
|
+
<span>{t('offline')}</span>
|
|
281
|
+
</div>
|
|
282
|
+
{/if}
|
|
283
|
+
|
|
284
|
+
<Toast />
|
|
285
|
+
<QuestionSheet />
|
|
286
|
+
|
|
287
|
+
<style>
|
|
288
|
+
.app-shell {
|
|
289
|
+
display: flex;
|
|
290
|
+
width: 100%;
|
|
291
|
+
height: 100%;
|
|
292
|
+
gap: 14px;
|
|
293
|
+
padding: 14px;
|
|
294
|
+
background: transparent;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/* Navigation placement: the rail itself is styled from Rail.svelte. */
|
|
298
|
+
.app-shell.nav-right {
|
|
299
|
+
flex-direction: row-reverse;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.app-shell.nav-top {
|
|
303
|
+
flex-direction: column;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.app-shell.nav-bottom {
|
|
307
|
+
flex-direction: column-reverse;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.app-shell.nav-top .pager,
|
|
311
|
+
.app-shell.nav-bottom .pager {
|
|
312
|
+
height: auto;
|
|
313
|
+
min-height: 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.pager {
|
|
317
|
+
flex: 1;
|
|
318
|
+
min-width: 0;
|
|
319
|
+
min-height: 0;
|
|
320
|
+
display: flex;
|
|
321
|
+
overflow-x: auto;
|
|
322
|
+
overflow-y: hidden;
|
|
323
|
+
scroll-snap-type: x mandatory;
|
|
324
|
+
scroll-behavior: auto;
|
|
325
|
+
scrollbar-width: none;
|
|
326
|
+
overscroll-behavior-x: contain;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.pager::-webkit-scrollbar {
|
|
330
|
+
display: none;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.page {
|
|
334
|
+
position: relative;
|
|
335
|
+
flex: 0 0 100%;
|
|
336
|
+
width: 100%;
|
|
337
|
+
height: 100%;
|
|
338
|
+
overflow: hidden;
|
|
339
|
+
scroll-snap-align: start;
|
|
340
|
+
/* One gesture can advance at most one page, no matter how fast the fling. */
|
|
341
|
+
scroll-snap-stop: always;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.page-music {
|
|
345
|
+
isolation: isolate;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.offline {
|
|
349
|
+
position: fixed;
|
|
350
|
+
z-index: 50;
|
|
351
|
+
top: 20px;
|
|
352
|
+
left: 50%;
|
|
353
|
+
display: inline-flex;
|
|
354
|
+
transform: translateX(-50%);
|
|
355
|
+
align-items: center;
|
|
356
|
+
gap: 8px;
|
|
357
|
+
padding: 10px 16px;
|
|
358
|
+
border-radius: 999px;
|
|
359
|
+
border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
|
|
360
|
+
background: color-mix(in srgb, var(--card) 92%, transparent);
|
|
361
|
+
color: var(--danger);
|
|
362
|
+
font-size: 15px;
|
|
363
|
+
font-weight: 600;
|
|
364
|
+
box-shadow: 0 12px 28px rgb(0 0 0 / 18%);
|
|
365
|
+
backdrop-filter: blur(16px);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
@media (max-height: 760px) {
|
|
369
|
+
.app-shell {
|
|
370
|
+
gap: 10px;
|
|
371
|
+
padding: 10px;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
@media (orientation: portrait) {
|
|
376
|
+
.app-shell {
|
|
377
|
+
gap: 10px;
|
|
378
|
+
padding: 10px;
|
|
379
|
+
}
|
|
380
|
+
.page {
|
|
381
|
+
overflow-y: auto;
|
|
382
|
+
scrollbar-width: none;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, maximum-scale=1">
|
|
6
|
+
<meta name="theme-color" content="#151a23">
|
|
7
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
8
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
9
|
+
<meta name="apple-mobile-web-app-title" content="DSH Home">
|
|
10
|
+
<title>DSH Home</title>
|
|
11
|
+
<link rel="manifest" href="/manifest.webmanifest">
|
|
12
|
+
<link rel="icon" href="/icon.svg" type="image/svg+xml">
|
|
13
|
+
</head>
|
|
14
|
+
<body data-theme="dark">
|
|
15
|
+
<div id="app"></div>
|
|
16
|
+
<script type="module" src="/main.ts"></script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peak/off-peak tariff indicator for the console balance card.
|
|
3
|
+
*
|
|
4
|
+
* The console decides this in the browser: weekdays in 09:00–12:00 and
|
|
5
|
+
* 14:00–18:00 Beijing time are peak; everything else — including weekends and
|
|
6
|
+
* statutory holidays all day — is off-peak.
|
|
7
|
+
*
|
|
8
|
+
* Holiday dates come exclusively from the timor.tech API, fetched by this
|
|
9
|
+
* browser. There is deliberately no local holiday calendar: holiday policy can
|
|
10
|
+
* change, so the API is the only authority. If it is unreachable the indicator
|
|
11
|
+
* still follows the time/weekend rules, using only cached API data if present.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type TariffPeriod = 'peak' | 'offpeak';
|
|
15
|
+
|
|
16
|
+
const BEIJING_TIME_ZONE = 'Asia/Shanghai';
|
|
17
|
+
const HOLIDAY_API = 'https://timor.tech/api/holiday/year';
|
|
18
|
+
const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
19
|
+
const RETRY_MS = 10 * 60 * 1000;
|
|
20
|
+
|
|
21
|
+
export interface HolidayState {
|
|
22
|
+
year: number;
|
|
23
|
+
status: 'idle' | 'loading' | 'ready' | 'stale' | 'error';
|
|
24
|
+
days: Record<string, true>;
|
|
25
|
+
source: string;
|
|
26
|
+
version: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const holidayState = $state<HolidayState>({
|
|
30
|
+
year: 0,
|
|
31
|
+
status: 'idle',
|
|
32
|
+
days: {},
|
|
33
|
+
source: '',
|
|
34
|
+
version: 0,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
interface BeijingParts {
|
|
38
|
+
year: number;
|
|
39
|
+
month: number;
|
|
40
|
+
day: number;
|
|
41
|
+
hour: number;
|
|
42
|
+
minute: number;
|
|
43
|
+
weekday: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let dateTimeFormatter: Intl.DateTimeFormat | null = null;
|
|
47
|
+
|
|
48
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
49
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getFormatter(): Intl.DateTimeFormat {
|
|
53
|
+
dateTimeFormatter ??= new Intl.DateTimeFormat('en-US', {
|
|
54
|
+
timeZone: BEIJING_TIME_ZONE,
|
|
55
|
+
year: 'numeric',
|
|
56
|
+
month: '2-digit',
|
|
57
|
+
day: '2-digit',
|
|
58
|
+
hour: '2-digit',
|
|
59
|
+
minute: '2-digit',
|
|
60
|
+
weekday: 'short',
|
|
61
|
+
hourCycle: 'h23',
|
|
62
|
+
});
|
|
63
|
+
return dateTimeFormatter;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const WEEKDAY_INDEX: Record<string, number> = { Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6 };
|
|
67
|
+
|
|
68
|
+
export function beijingParts(now: Date = new Date()): BeijingParts {
|
|
69
|
+
const parts = getFormatter().formatToParts(now);
|
|
70
|
+
const get = (type: Intl.DateTimeFormatPartTypes): string => parts.find((part) => part.type === type)?.value || '';
|
|
71
|
+
return {
|
|
72
|
+
year: Number(get('year')),
|
|
73
|
+
month: Number(get('month')),
|
|
74
|
+
day: Number(get('day')),
|
|
75
|
+
hour: Number(get('hour')),
|
|
76
|
+
minute: Number(get('minute')),
|
|
77
|
+
weekday: WEEKDAY_INDEX[get('weekday')] ?? 0,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function beijingDateKey(now: Date = new Date()): string {
|
|
82
|
+
const parts = beijingParts(now);
|
|
83
|
+
return `${parts.year}-${String(parts.month).padStart(2, '0')}-${String(parts.day).padStart(2, '0')}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function beijingYear(now: Date = new Date()): number {
|
|
87
|
+
return beijingParts(now).year;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Only API-provided holiday data is authoritative; unknown days are not holidays. */
|
|
91
|
+
export function isStatutoryHoliday(now: Date = new Date()): boolean {
|
|
92
|
+
const year = beijingYear(now);
|
|
93
|
+
if (holidayState.year !== year) return false;
|
|
94
|
+
if (holidayState.status !== 'ready' && holidayState.status !== 'stale') return false;
|
|
95
|
+
return Boolean(holidayState.days[beijingDateKey(now)]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Peak only on a non-holiday weekday inside the two Beijing price windows. */
|
|
99
|
+
export function tariffPeriod(now: Date = new Date()): TariffPeriod {
|
|
100
|
+
const parts = beijingParts(now);
|
|
101
|
+
if (parts.weekday === 0 || parts.weekday === 6) return 'offpeak';
|
|
102
|
+
if (isStatutoryHoliday(now)) return 'offpeak';
|
|
103
|
+
const minutes = parts.hour * 60 + parts.minute;
|
|
104
|
+
return (minutes >= 9 * 60 && minutes < 12 * 60) || (minutes >= 14 * 60 && minutes < 18 * 60) ? 'peak' : 'offpeak';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function storageKey(year: number): string {
|
|
108
|
+
return `dsh-rc-holiday-${year}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface CachedHolidays {
|
|
112
|
+
at: number;
|
|
113
|
+
days: Set<string>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function readCache(year: number): CachedHolidays | null {
|
|
117
|
+
try {
|
|
118
|
+
const raw = localStorage.getItem(storageKey(year));
|
|
119
|
+
if (!raw) return null;
|
|
120
|
+
const parsed: unknown = JSON.parse(raw);
|
|
121
|
+
if (!isRecord(parsed) || !Array.isArray(parsed.days) || typeof parsed.at !== 'number') return null;
|
|
122
|
+
const days = new Set(parsed.days.filter((day): day is string => typeof day === 'string'));
|
|
123
|
+
return days.size > 0 ? { at: parsed.at, days } : null;
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function writeCache(year: number, days: Set<string>): void {
|
|
130
|
+
try {
|
|
131
|
+
localStorage.setItem(storageKey(year), JSON.stringify({ at: Date.now(), days: [...days] }));
|
|
132
|
+
} catch {
|
|
133
|
+
/* storage may be unavailable in private mode */
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function markDays(year: number, days: Set<string>, status: HolidayState['status'], source: string): void {
|
|
138
|
+
holidayState.year = year;
|
|
139
|
+
holidayState.days = Object.fromEntries([...days].map((day) => [day, true] as const));
|
|
140
|
+
holidayState.status = status;
|
|
141
|
+
holidayState.source = source;
|
|
142
|
+
holidayState.version += 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function markUnavailable(year: number): void {
|
|
146
|
+
holidayState.year = year;
|
|
147
|
+
holidayState.days = {};
|
|
148
|
+
holidayState.status = 'error';
|
|
149
|
+
holidayState.source = '';
|
|
150
|
+
holidayState.version += 1;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const inflight = new Map<number, Promise<void>>();
|
|
154
|
+
const failedAt = new Map<number, number>();
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Load one year of holiday data from the API in this browser. A successful
|
|
158
|
+
* response is cached for a day; a failed request retries later without
|
|
159
|
+
* inventing holiday dates locally.
|
|
160
|
+
*/
|
|
161
|
+
export function ensureHolidayYear(year: number): Promise<void> {
|
|
162
|
+
if (holidayState.year === year && holidayState.status === 'ready') return Promise.resolve();
|
|
163
|
+
if (holidayState.year === year && holidayState.status === 'error') {
|
|
164
|
+
const failed = failedAt.get(year) || 0;
|
|
165
|
+
if (Date.now() - failed < RETRY_MS) return Promise.resolve();
|
|
166
|
+
}
|
|
167
|
+
const cached = readCache(year);
|
|
168
|
+
if (cached && Date.now() - cached.at <= CACHE_TTL_MS) {
|
|
169
|
+
markDays(year, cached.days, 'ready', 'cache');
|
|
170
|
+
return Promise.resolve();
|
|
171
|
+
}
|
|
172
|
+
const running = inflight.get(year);
|
|
173
|
+
if (running) return running;
|
|
174
|
+
|
|
175
|
+
holidayState.year = year;
|
|
176
|
+
holidayState.status = 'loading';
|
|
177
|
+
holidayState.version += 1;
|
|
178
|
+
|
|
179
|
+
const task = (async (): Promise<void> => {
|
|
180
|
+
try {
|
|
181
|
+
const controller = new AbortController();
|
|
182
|
+
const timer = setTimeout(() => controller.abort(), 7000);
|
|
183
|
+
let response: Response;
|
|
184
|
+
try {
|
|
185
|
+
response = await fetch(`${HOLIDAY_API}/${year}/?type=Y&week=N`, {
|
|
186
|
+
signal: controller.signal,
|
|
187
|
+
headers: { accept: 'application/json' },
|
|
188
|
+
cache: 'no-store',
|
|
189
|
+
});
|
|
190
|
+
} finally {
|
|
191
|
+
clearTimeout(timer);
|
|
192
|
+
}
|
|
193
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
194
|
+
const payload: unknown = await response.json();
|
|
195
|
+
const map = isRecord(payload) && isRecord(payload.holiday) ? payload.holiday : null;
|
|
196
|
+
if (!map) throw new Error('invalid holiday payload');
|
|
197
|
+
const days = new Set<string>();
|
|
198
|
+
for (const [key, value] of Object.entries(map)) {
|
|
199
|
+
if (isRecord(value) && value.holiday === true) days.add(`${year}-${key}`);
|
|
200
|
+
}
|
|
201
|
+
if (days.size === 0) throw new Error('empty holiday payload');
|
|
202
|
+
writeCache(year, days);
|
|
203
|
+
markDays(year, days, 'ready', 'timor.tech');
|
|
204
|
+
} catch {
|
|
205
|
+
failedAt.set(year, Date.now());
|
|
206
|
+
// An expired cache still contains API-provided dates; keep using it
|
|
207
|
+
// rather than guessing a holiday calendar locally.
|
|
208
|
+
const stale = readCache(year);
|
|
209
|
+
if (stale) markDays(year, stale.days, 'stale', 'cache');
|
|
210
|
+
else markUnavailable(year);
|
|
211
|
+
} finally {
|
|
212
|
+
inflight.delete(year);
|
|
213
|
+
}
|
|
214
|
+
})();
|
|
215
|
+
inflight.set(year, task);
|
|
216
|
+
return task;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (typeof window !== 'undefined') {
|
|
220
|
+
(window as unknown as { __DSH_BILLING__?: unknown }).__DSH_BILLING__ = {
|
|
221
|
+
beijingDateKey,
|
|
222
|
+
beijingParts,
|
|
223
|
+
ensureHolidayYear,
|
|
224
|
+
holidayState,
|
|
225
|
+
isStatutoryHoliday,
|
|
226
|
+
tariffPeriod,
|
|
227
|
+
};
|
|
228
|
+
}
|