docs: random games and Leave site

CLAUDE.md: why /random keeps its picks in memory and only the reader
rolls, the crypto sampling (not Math.random), why the route is top-level,
and the base key a plural needs; how Leave site finds the page before the
site, the watchdog and its three cancel events, the deliberate second click
to close, and why Decline quits through exit(). Both READMEs list the
random page and its modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 5.5 committed 2026-11-03 19:27:56 +07:00
1 parent 5981c24bcd
commit 4c987036e2
3 files changed
+45 -1

No files matched your search

+41
View File
@@ -1118,6 +1118,28 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
The gate renders only after `consent.hydrated`: rendered before storage was
read, it was baked into every prerendered page and flashed for returning
visitors.
- **Declining or leaving at the gate.** In the apps Decline calls `exit()` from
`@tauri-apps/api/app` (capability `core:app:allow-exit` in
`capabilities/default.json`), never `getCurrentWindow().close()`: on Android
that resolves without closing anything (tao reports a destroyed window only
from the Activity's `onDestroy`), so Decline did nothing there before 2.5.0.
`exit()` finishes the activity on Android and ends the process on the
desktop; the declined notice appears if the app is still alive 2 s later. On
the web, "Leave site" (`lib/leave-site.ts`, hidden under Tauri) goes back to
the page before the site, because no page may open the browser's own start
page (`chrome://newtab`, `about:home`). Rules:
- It steps over ALL of the site's entries at once,
`history.go(-(navigation.currentEntry.index + 1))`: `entries()` is the
contiguous same-origin run, other documents and SvelteKit's pushState
entries included. Without the Navigation API it is one step back.
- `history.go()` is silent when there is nowhere to go (the foreign entries
can all be forward ones), so a 1.5 s watchdog shows "Nothing to go back
to"; `beforeunload`, `pagehide` and `popstate` cancel it. `pagehide`
matters: timers freeze in the back/forward cache and resume on restore.
- When every entry is the site's, closing the tab is a SECOND, explicit click
(`closeTab()`): closing the last tab closes the browser window with it.
- `consent-gate.test.ts` holds the exit import, the capability and the two
guarded Leave buttons; `leave-site.test.ts` holds the algorithm.
- **`/welcome` is shown once, by the layout, and only to a visit that STARTED
on `/`** (not a deep link, not `/#/…`, not mid-session), after consent and
the human check. It
@@ -1135,6 +1157,25 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
from a game keeps the page and a changed filter starts again at page 1.
The language filter (`?lang=`) offers the names stored in `languages`,
Steam's English ones: data, never i18n keys.
- **`/random` keeps its picks in memory, and only the reader rolls.**
`lib/random.svelte.ts` holds appids, module-level so Back from a game shows
the same games, and NO `f2p:*` key: the Privacy Policy lists every stored
key, and editing it reopens the consent gate for everyone. Rules:
- A roll happens in a handler, or once in an `untrack`ed effect when the
catalogue first arrives - never in `$derived` or markup, which would roll
again on every revalidation or language switch. `resolve()` is the
deterministic part: it drops a pick that left the catalogue or stopped
qualifying, and nothing tops it back up.
- Randomness is `crypto.getRandomValues` with rejection sampling and a sparse
Fisher-Yates (`lib/random-pick.ts`). Never `Math.random`: SonarCloud
reports it as hotspot S2245, and an unreviewed hotspot fails the gate.
- Never a game marked unsafe or without an appid; dead games only on
request. The route is top-level on purpose: under `/games/` the header
search would stop jumping to /games, `isActive` would light Games too, and
the PWA's `globIgnores` would leave it out of the precache.
- A plural key needs its base key (`random.pool` beside `random.pool_one`):
`t()` falls back from `_other` to the base, and the i18n test requires
every literal key to exist.
- **Search folds; storage never does.** `lib/search-fold.ts` `fold()` is NFKC
plus hiragana to katakana, applied to BOTH sides of every search box
(`/games`' Fuse index, the palette, /developers, /publishers, the anti-cheat
+1
View File
@@ -46,6 +46,7 @@ A SvelteKit 2 / Svelte 5 app, prerendered and served by a Cloudflare Worker that
- **Browse** — virtualised table (TanStack Virtual), filters for genre, type, platform, status, anti-cheat and safety, Fuse.js fuzzy search, sortable columns, 50/100/200/500/all pages. Filters live in the URL, so a filtered view can be shared.
- **Charts** — Apache ECharts: dashboard KPIs, genres, platforms, languages, tags, anti-cheat (chart and a searchable index), reviews, player tiers, release years and catalogue growth, DRM/DLC, delisted games, plus a stats page (Metacritic, retention, games that went quiet).
- **A page per game** — `/games/:appid` is prerendered for search engines and filled with live player counts and reviews in the browser.
- **Random games** — `/random` rolls one to five games when you cannot decide: online, offline or either, dead games only if you ask, never one marked unsafe. Roll again for a new set; opening a game and coming back keeps the picks.
- **Fresh data, verified** — `data/index.json` carries a SHA-256 per shard; the app only caches a generation it could verify, keeps the last good one offline, and re-checks when you come back to the tab.
- **Installable** — a web app you can install, with an offline mode and an update prompt.
- **i18n** vi / en — auto-detected, switchable from the welcome page or Settings.
+3 -1
View File
@@ -94,13 +94,15 @@ web/
│ ├── routes/ # pages; +layout, +error, sitemap.xml
│ ├── params/ # route param matchers (legal document slugs)
│ ├── lib/
│ │ ├── *.svelte.ts # rune state: games, filters, prefs, i18n, pwa
│ │ ├── *.svelte.ts # rune state: games, filters, random picks, prefs, i18n, pwa
│ │ ├── schema.ts # mirrors scripts/core/constants.py
│ │ ├── games-loader.ts # verified shard generations, offline fallback
│ │ ├── cache.ts # IndexedDB read/write
│ │ ├── fallback-route.ts # re-renders routes served the SPA shell
│ │ ├── consent.svelte.ts # legal consent, hashed per document
│ │ ├── diff.ts # the line diff the consent gate shows
│ │ ├── leave-site.ts # the consent gate's "Leave site": back to the page before
│ │ ├── random-pick.ts # /random: crypto sampling and who may come up
│ │ ├── analytics.ts # the beacon, appended only after consent
│ │ ├── human-check.ts # the Turnstile check's rules (+ -state.svelte.ts, turnstile.ts)
│ │ ├── gates.ts # the routes no first-run gate covers