Compare commits

...
8 Commits
Author SHA1 Message Date
poli0981 277e7f14c6 Merge pull request #219 from poli0981/release/v4.5.0
release: v4.5.0 "Groundwork" / apps 2.3.0
2026-10-26 15:00:12 +07:00
poli0981andClaude Opus 5.5 3bd5d90447 release: v4.5.0 "Groundwork" / apps 2.3.0
SvelteKit 3 (PR #218) under the site and the apps, plus Tauri 2.12.5 from
Dependabot #214. Desktop and Android 2.2.2 -> 2.3.0 (package.json + lock,
Cargo.toml + the f2p-tracker entry in Cargo.lock, tauri.conf.json);
CHANGELOG section dated, fresh [Unreleased].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 14:58:03 +07:00
poli0981 1c501957cf Merge pull request #214 from poli0981/dependabot/cargo/web/src-tauri/cargo-minor-patch-4007e36411
build(deps): Bump the cargo-minor-patch group across 1 directory with 2 updates
2026-10-26 14:56:58 +07:00
dependabot[bot] fc23baf117 build(deps): Bump the cargo-minor-patch group across 1 directory with 2 updates
Bumps the cargo-minor-patch group with 2 updates in the /web/src-tauri directory: [tauri](https://github.com/tauri-apps/tauri) and [tauri-build](https://github.com/tauri-apps/tauri).


Updates `tauri` from 2.12.4 to 2.12.5
- [Release notes](https://github.com/tauri-apps/tauri/releases)
- [Commits](https://github.com/tauri-apps/tauri/compare/tauri-v2.12.4...tauri-v2.12.5)

Updates `tauri-build` from 2.7.3 to 2.7.4
- [Release notes](https://github.com/tauri-apps/tauri/releases)
- [Commits](https://github.com/tauri-apps/tauri/compare/tauri-build-v2.7.3...tauri-build-v2.7.4)

---
updated-dependencies:
- dependency-name: tauri
  dependency-version: 2.12.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-patch
- dependency-name: tauri-build
  dependency-version: 2.7.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-26 07:47:12 +00:00
poli0981 e4edeb43e4 Merge pull request #218 from poli0981/feat/sveltekit-3
SvelteKit 3: migrate web/ to kit 3.1 and adapter-static 4
2026-10-26 14:45:53 +07:00
poli0981andClaude Opus 5.5 f42a854b66 fix(web): keep legacy hash links on this site (CodeQL js/xss)
The SvelteKit 3 fallback for a /#/ path that matches no route passed the
hash straight to location.replace(): CodeQL code-scanning alert #25,
client-side XSS, and an open redirect in practice - `#//other.example/x`
resolved to another site once goto rejected it.

The hash is now resolved against the page's origin and ignored when it
names another one, goto gets that URL, and an unmatched path goes to the
404 page at its fixed address (/error/404). Nothing from the hash reaches
location.* any more. Tests cover both off-site forms (`#//host`,
`#/\host`) and the 404 fallback; checked in a browser on `npm run dev`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 14:42:59 +07:00
poli0981andClaude Opus 5.5 0c454fad2c test(web): hold the SvelteKit 3 navigation, matcher and hook changes
- legacy-url: a /#/ path renders in place with { replace, reset: false },
  and one that matches no route falls back to location.replace (kit 3's
  goto rejects it).
- fallback-route: the re-render uses replace / reset: false / refreshAll
  (noScroll and keepFocus throw in kit 3's dev build), and leaves routes
  that hydrated or cannot fall back alone.
- params.legaldoc: every legal document matches; anything else does not.
- hooks.client: returns nothing for an ordinary error (kit 3 keeps its own
  message), and says it is reloading only when the stale-chunk reload ran.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 14:38:44 +07:00
poli0981andClaude Opus 5.5 0f600a99aa build(web): migrate to SvelteKit 3 and adapter-static 4
@sveltejs/kit 2.70.3 -> 3.1.0, @sveltejs/adapter-static 3.0.10 -> 4.0.0.
Closes GHSA-27mw-82g8-phjj and GHSA-pfhg-q3qv-9q6r (dismissed in v4.4.1
as not applicable), and drops the cookie override kit 2 needed: npm audit
reports nothing.

- Config: svelte.config.js is refused by kit 3. Its options are now
  sveltekitConfig(tauri) in build/sveltekit-config.ts, passed by
  vite.config.ts as sveltekit(sveltekitConfig(IS_TAURI)), with tests for
  both CSP flavours, paths.relative, the sitemap entry and the prerender
  404 handler. The unused, now-deprecated "@" alias and typescript.config
  hook are gone; tsconfig.json extends $app/tsconfig and owns `include`.
- $lib -> #lib (package.json imports), with .js on module imports.
  tsconfig repeats the mapping in `paths`: svelte-check --tsgo only maps
  .svelte imports through `paths`, and without it every #lib component
  fell back to the *.svelte shim (props unchecked; proven with a planted
  error).
- Param matchers: src/params/legaldoc.ts -> src/params.ts (defineParams).
  vite build imports that file with Node's own import(), so it imports
  #lib/legal.ts and legal.ts imports ./schema.ts by their real names.
- PWA: @vite-pwa/sveltekit never supported kit 3 and wrote the worker when
  the SERVER build closed, which kit 3's environment build does first.
  build/pwa.ts wires vite-plugin-pwa in a buildApp hook after kit's
  prerender and before its adapter, with the same globs and URL mapping.
- goto options renamed (replace, reset: false, refreshAll); the /games
  filter write is a shallow goto; a legacy /#/ path that matches no route
  falls back to location.replace (kit 3's goto rejects it). Hook types
  from @sveltejs/kit/hooks; the client handleError returns nothing to keep
  kit's message.
- runed 0.35 (bits-ui) peers kit ^2: overridden to our kit, as for
  echarts-wordcloud.

Verified against a kit 2 build of the same commit: same 11,037 files bar
hashed chunks, same non-immutable precache URLs, navigateFallback "/",
identical CSP per page (hashes masked), manifest and sitemap byte-equal,
same visible text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 14:35:49 +07:00
75 changed files with 1081 additions and 609 deletions

No files matched your search

+2 -2
View File
@@ -34,8 +34,8 @@ updates:
patterns: ['@tauri-apps/*']
ignore:
# Framework majors are migrations with their own staged PRs, not
# something to take as an unattended bump. (SvelteKit 3 needs the
# cookie override in package.json re-keyed or dropped; see CLAUDE.md.)
# something to take as an unattended bump (SvelteKit 3 moved its config,
# its $lib alias, its param matchers and the PWA wiring; see CLAUDE.md).
- dependency-name: '@sveltejs/kit'
update-types: [version-update:semver-major]
- dependency-name: '@sveltejs/adapter-static'
+37
View File
@@ -4,6 +4,43 @@ All notable changes to this awesome noob repo will be documented here.
## [Unreleased]
## [v4.5.0] – 2026-10-26 (The "Groundwork" Edition)
The site and the apps move to SvelteKit 3, the framework every page is
built on. Nothing about how they look or work should change: every page,
the Content-Security-Policy and the offline cache were compared with a
SvelteKit 2 build of the same commit before the switch. The apps also take
Tauri 2.12.5. Desktop and Android bumped `2.2.2` → `2.3.0`; repo
public-facing version `4.4.1` → `4.5.0`. The desktop app offers 2.3.0
through its updater once the release is published; on Android, install the
new APK over the old one.
### 🧹 Changed
- **The site and the apps build on SvelteKit 3** (3.1, with adapter-static
4). Nothing changes for readers: the same pages with the same text, the
same Content-Security-Policy and the same service-worker precache, each
checked against a SvelteKit 2 build of the same commit. SvelteKit 3 refuses
`svelte.config.js`, so its options moved to `web/build/sveltekit-config.ts`,
now with tests for both the web and the app policies; `$lib` imports became
`#lib`, and the `/legal/<slug>` matcher moved to `web/src/params.ts`.
- The service worker is wired into the build by `web/build/pwa.ts`, on
vite-plugin-pwa: `@vite-pwa/sveltekit` never supported SvelteKit 3.
- An old `/#/…` link to a page that no longer exists now opens the "Page not
found" page (`/error/404`); SvelteKit 3 refuses to navigate to it in place.
One that names another site (`/#//other.example/…`) is ignored.
- SvelteKit now asks the site for its version (`/_app/version.json`, a few
bytes) when a tab regains focus and once an hour, where it used to ask only
after a navigation failed. A newer deploy still changes nothing until a
navigation fails, which then reloads the page, as before.
- The desktop and Android apps take Tauri 2.12.5 (tauri-build 2.7.4).
### 🔐 Security
- The two SvelteKit advisories dismissed in v4.4.1 (GHSA-27mw-82g8-phjj,
GHSA-pfhg-q3qv-9q6r) are fixed by the upgrade, and `npm audit` reports
nothing: the `cookie` override SvelteKit 2 needed is gone.
## [v4.4.1] – 2026-10-26 (The "Tune-Up" Edition)
A dependency and security pass. The desktop and Android apps take the
+62 -33
View File
@@ -658,23 +658,45 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
- `echarts-wordcloud` declares a stale `echarts@^5` peer. It runs fine on
echarts 6 (all the legacy APIs it uses are still exported), so `package.json`
carries an `overrides` entry. Do not "fix" it by pinning echarts back to 5.
- **The `"@sveltejs/kit@2.70.3": { "cookie": "^0.7.2" }` override closes
GHSA-pxg6-pf52-xh8x** (kit 2 declares `cookie ^0.6.0`; only kit 3 moved on).
Kit imports just `parse`/`serialize`, which 0.7 keeps, and under
adapter-static that code runs only at prerender and in `vite dev`. The key
names kit's EXACT version because npm refuses a range key for a direct
dependency (`EOVERRIDE`). A kit bump therefore silently drops the override
and the alert comes back: re-key it, or delete it once kit asks for
`cookie` >= 0.7. Never carry it onto kit 3, which needs `cookie` 2.
- **Kit stays on 2 with GHSA-27mw-82g8-phjj and GHSA-pfhg-q3qv-9q6r
dismissed** (Dependabot #71, #72, 2026-10-26: "vulnerable code not used").
Both are fixed only in kit 3 and need code this app does not have: a
prerendered page passing an untrusted `cache-control` to `setHeaders`, and
`use:enhance` form actions. There is neither a `setHeaders` call nor a form
action anywhere (the sitemap's `Cache-Control` is a constant); add one and
both advisories apply again. Kit 3 is a migration of its own - config moves
out of `svelte.config.js`, `$lib` becomes `#lib`, matchers move into
`src/params.ts` - and `@vite-pwa/sveltekit` 1.1.0 accepts only kit 2.
- `runed` 0.35 (bits-ui's) declares an optional `@sveltejs/kit ^2.21.0` peer,
which npm enforces once kit is installed, so `package.json` overrides it to
our kit. bits-ui uses none of runed's kit code (`useSearchParams`, the only
part runed 0.38 changed for kit 3). Drop the entry once bits-ui depends on
runed >= 0.38.
- **SvelteKit 3 takes its options from its Vite plugin.** They are
`sveltekitConfig(tauri)` in `web/build/sveltekit-config.ts`, which
`vite.config.ts` passes as `sveltekit(sveltekitConfig(IS_TAURI))`;
`sveltekit-config.test.ts` holds both flavours. `svelte.config.js` is
refused (the build stops while the file exists), and what was `kit.*` there
is a top-level option (`adapter`, `csp`, `paths`, `prerender`). Rules that
are easy to break:
- **`$lib` is gone; `#lib/*` is package.json `imports`.** A module import
names `.js` even for a `.ts` file (`#lib/utils.js`), a component its
`.svelte`. `tsconfig.json` repeats the mapping in `paths`, because
`svelte-check --tsgo` redirects `.svelte` imports to the declarations it
emits only through `paths`: without it every `#lib` component fell back to
the `*.svelte` shim - props unchecked, no error.
- **`src/params.ts` is imported by Node itself** (`vite build` uses
`import()`, not Vite), so it and what it imports (`lib/legal.ts`,
`lib/schema.ts`) name real `.ts` files and stay type-strippable; a `.js`
or extensionless import there is ERR_MODULE_NOT_FOUND at build time.
- **The PWA is `build/pwa.ts`**: vite-plugin-pwa wired into kit 3's
`buildApp`. @vite-pwa/sveltekit never supported kit 3; it wrote the worker
when the SERVER build closed, which kit 3 does first. Ours writes it in a
default-order `buildApp` hook placed after `sveltekit()` - after kit's
build-and-prerender, before the adapter's `post` hook copies
`.svelte-kit/output/client` into `dist/`. Placed before `sveltekit()`, it
would glob an empty output.
- `goto` options are `replace` (not `replaceState`), `reset: false` (not
`noScroll`/`keepFocus`, which THROW in dev) and `refreshAll` (not
`invalidateAll`); `/games` writes its filters with `goto(url, {shallow:
true, replace: true})`. `goto` rejects a URL that matches no route.
- Hook types come from `@sveltejs/kit/hooks`. The client `handleError` gets
`{kind, error, event}` for every error and returns nothing to keep kit's
own status and message.
- `version.pollInterval` is kit's default (an hour), and kit also checks
`/_app/version.json` whenever the tab regains focus. A new version only
sets `updated.current`; a navigation that then fails reloads natively.
- **The `"miniflare": { "undici": "^7.30.1" }` override closes
GHSA-xjj6-f33q-929c** and the two other undici advisories `npm audit`
lists. miniflare pins undici EXACTLY (7.29.1, in the miniflare of wrangler
@@ -707,7 +729,11 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
HashRouter-era `/#/…` URLs still arrive - from released 1.4.x builds, and from
old links to the GitHub Pages site, whose tombstone redirect forwards the
fragment - and `upgradeLegacyHashUrl()` upgrades them on load with
`goto(…, {replaceState})`. Do not remove it, and do not reduce it to a
`goto(…, {replace: true})`; a path that matches no route (kit 3's `goto`
rejects it) goes to `/error/404`. The hash is resolved against the page's
origin and ignored if it names another (`#//other.example`), and nothing
from it may reach `location.*` - CodeQL flagged exactly that as XSS and an
open redirect. Do not remove it, and do not reduce it to a
`history.replaceState`: that fixed the address bar and left the dashboard
rendered.
- **`web/static/_headers` sets the browser cache, by path.** Hashed output
@@ -730,7 +756,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
must still trigger a build, or the site keeps the old text and hash; see
`docs/DEPLOYMENT.md` "Which commits deploy" for a configuration that does
both. Excludes beat includes there.
- **The CSP lives in `web/svelte.config.js` (`kit.csp`), not in `_headers`.**
- **The CSP lives in `web/build/sveltekit-config.ts` (`csp`), not in `_headers`.**
SvelteKit emits one inline bootstrap script per page and hashes it there. A
header CSP cannot coexist: browsers enforce the INTERSECTION of header and
meta policies, so a `script-src 'self'` header blocks the script whatever the
@@ -740,7 +766,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
- **That CSP has TWO flavours, chosen by `TAURI_ENV_PLATFORM`.** Under Tauri
the page origin is `tauri://localhost`, so `'self'` means the BUNDLE, not the
site — a `connect-src 'self'` policy blocks every `/api/data/*` fetch and the
packaged apps show an empty catalogue. `svelte.config.js` adds
packaged apps show an empty catalogue. `sveltekitConfig(true)` adds
`https://free-steam-games.win`, `https://api.github.com`, `ipc:` and
`http://ipc.localhost` only for that build; the web policy stays `'self'`,
because dropping `api.github.com` from it was deliberate (`/api/activity`
@@ -759,7 +785,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
the Tauri build with any of them.
- **Cloudflare Web Analytics must stay on "JS Snippet installation", never
automatic.** Automatic injection adds an INLINE loader at the edge, after our
response; `kit.csp` is `mode: "hash"`, and CSP3 makes a `script-src` carrying
response; the CSP is `mode: "hash"`, and CSP3 makes a `script-src` carrying
a hash ignore `'unsafe-inline'` — so no policy can ever admit it. It was
enabled that way for months, logging two CSP violations per page load and
collecting nothing. `lib/analytics.ts` appends the beacon itself, from the
@@ -800,7 +826,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
- **Never put `use:`, `onload` or `onerror` on an `<img>` that can be
prerendered.** Svelte then writes `onload="this.__e=event"` and
`onerror="this.__e=event"` into the HTML, to replay an event that fired
before hydration, and `kit.csp` is a hash policy, which refuses inline event
before hydration, and the CSP is a hash policy, which refuses inline event
handlers: one CSP violation per page view (the game hero logged it on every
page until it moved to an attachment). Use `{@attach}`, which writes nothing;
`lib/img-fallback.ts` recovers a load that already failed from
@@ -875,7 +901,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
`lib/fallback-route.ts` recovers the route offline the same way it does
online. `verify-dist.mjs` now parses `dist/sw.js` and fails if the bound URL
is not a precache entry.
- **`kit.paths.relative` must stay `false`.** SvelteKit defaults it to `true`,
- **`paths.relative` must stay `false`.** SvelteKit defaults it to `true`,
which gives every PRERENDERED page `./_app/...` asset URLs. Served as the
fallback for `/games/730` those resolve to `/games/_app/...`, which misses,
falls into the SPA handler, and comes back as `index.html` with
@@ -899,8 +925,9 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
`fallback-route.test.ts` holds the list against the routes whose `prerender`
is not literally `true`, and checks each one marks itself. A path that matches NO route hydrates the same
way with `page.route.id === null`; the root layout renders the 404 view in
place. Never `goto()` an unmatched URL — SvelteKit falls back to a native
load, the host answers with `index.html` again, and it loops forever.
place. Never `goto()` an unmatched URL: SvelteKit 3 rejects it (SvelteKit 2
fell back to a native load, the host answered with `index.html` again, and
it looped forever).
- **Game pages are prerendered from build-time seeds, through a UNIVERSAL load.**
`build/game-seeds.ts` serves `virtual:game-seeds`: in the SSR build it reads
`../data` and inlines a seed per game (slow-changing fields only — never
@@ -909,7 +936,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
Do not turn it into `+page.server.ts`: client navigation would then fetch
`__data.json`, which for a game added after the deploy is `index.html` at
200, and the page errors. `__PRERENDER_GAMES__` is false for Tauri.
`kit.prerender.handleHttpError` ignores 404s under `/img/` and `/api/` only,
`prerender.handleHttpError` ignores 404s under `/img/` and `/api/` only,
because the crawler follows the page's `<img>` into a Worker route that does
not exist at build time. That handler only decides pass/fail; the
`[404] GET /img/…` line per game came from SvelteKit's DEFAULT server
@@ -936,7 +963,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
`page.url.origin`, which during prerender is SvelteKit's internal
`http://sveltekit-prerender` host. `seo.test.ts` enforces both.
- **`sitemap.xml` is a prerendered route**, not a static file, driven by
`import.meta.glob` over the route table. It needs `kit.prerender.entries`
`import.meta.glob` over the route table. It needs `prerender.entries`
because nothing links to it. Extra exports from a `+server.ts` must be
`_`-prefixed or SvelteKit rejects the build.
- **`static/` art is generated.** `icon.svg` is the only hand-edited mark;
@@ -945,7 +972,7 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
SVG.
- **The web app registers its service worker itself, after consent and the
human check.**
`@vite-pwa/sveltekit` cannot inject a registration script — SvelteKit has no
vite-plugin-pwa cannot inject a registration script — SvelteKit has no
`index.html` for it to write into — so for the whole of 2.0.0 the worker was
built and never registered, and the manifest was linked from no page.
`lib/pwa-state.svelte.ts` calls `registerSW` (`registerType: "prompt"`, so a
@@ -1010,13 +1037,13 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
the human check. It
uses `replaceState`, and the page marks itself seen on mount, so Back cannot
loop into it. Crawlers never consent, so `/` stays the indexable page.
- **`/legal/[doc=legaldoc]` has a param matcher** (`src/params/legaldoc.ts`).
- **`/legal/[doc=legaldoc]` has a param matcher** (`legaldoc` in `src/params.ts`).
An unknown slug therefore matches NO route and gets the layout's translated
404; without it the host's fallback (the prerendered dashboard) hydrated as
the doc route. Legal labels and hints in `lib/legal.ts` are i18n keys.
- **`/games` mirrors its filters into the query string, browser-only**:
`onMount` reads `location.search` (a link with filter parameters replaces the
stored filters) and a debounced `replaceState` writes back. Never read
stored filters) and a debounced shallow `goto` writes back. Never read
`url.search` in markup or a load - prerender throws on it. The page number
lives in the filter store, keyed to the criteria (`filters.pageFor`), so Back
from a game keeps the page and a changed filter starts again at page 1.
@@ -1046,8 +1073,9 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
first: `worker/index.ts` imports the generated module, so a bare
`wrangler deploy` or `tsc` without it fails. That failure is intended.
`build:admin` runs `svelte-kit sync` first: the admin imports files under
`web/src`, whose `tsconfig.json` extends `.svelte-kit/tsconfig.json`, and on a
clean checkout (CI) that file does not exist until SvelteKit has synced. The
`web/src`, whose `tsconfig.json` extends `$app/tsconfig`
(`node_modules/$app/tsconfig.json`), and on a clean checkout (CI) that file
does not exist until SvelteKit has synced. The
emitter reads the bundle in `writeBundle`, never the output directory in
`closeBundle`, which also runs after a FAILED build and hid that error behind
an ENOENT.
@@ -1069,7 +1097,8 @@ scraping pipeline (`scripts/`) driven by GitHub Actions.
- **It may import only pure modules of the public app**: `src/lib/ui/*`,
`src/lib/utils.ts`, `src/lib/prefs.svelte.ts`, `src/fonts.css`,
`src/styles/theme.css` (the design tokens, shared by both builds). Never
`$app/*` or `$lib/*`; that build cannot resolve them.
`$app/*` (nor a module that imports it) and no virtual module; that build
cannot resolve them.
- **`admin/mock/` is a dev server, not a mode.** `npm run dev:admin` runs the
real handlers against an in-memory D1 and fake GitHub; nothing under `worker/`
or `admin/src` may import it, and the Worker has no flag that skips
+5 -4
View File
@@ -16,7 +16,7 @@ Three places now, and none inherits from the others:
| File | Covers |
|---|---|
| `web/svelte.config.js` (`kit.csp`) | the Content-Security-Policy on every app page |
| `web/build/sveltekit-config.ts` (`csp`) | the Content-Security-Policy on every app page |
| `web/static/_headers` | every other security header on static assets |
| `web/worker/lib/http.ts` | everything the Worker generates (`/api/*`, `/img/*`) |
@@ -35,8 +35,9 @@ Executing inline script violates the following Content Security Policy
directive 'script-src 'self''
```
`kit.csp` with `mode: "hash"` makes SvelteKit compute that script's sha256 at
build time and emit the whole policy as a `<meta>` tag that already trusts it.
The `csp` option with `mode: "hash"` makes SvelteKit compute that script's
sha256 at build time and emit the whole policy as a `<meta>` tag that already
trusts it.
**The header CSP had to go, not just relax.** Browsers enforce the
INTERSECTION of a header policy and a meta policy, so leaving
@@ -627,7 +628,7 @@ only fix available is not to use that mode.
`routes/+layout.svelte` that waits on `consent.accepted` and on the human
check (section 12), so nothing loads before the reader accepts the terms,
and never under Tauri.
4. `svelte.config.js` allows `https://static.cloudflareinsights.com` in
4. `build/sveltekit-config.ts` allows `https://static.cloudflareinsights.com` in
`script-src` and `https://cloudflareinsights.com` in `connect-src`, **web
flavour only**. `scripts/verify-dist.mjs` fails the build if either is
missing from the web build or present in the Tauri build.
+13 -11
View File
@@ -119,12 +119,13 @@ web/
├── shared/ # queue rules, API types, the human check's constants
├── build/game-seeds.ts # build-time seeds for the prerendered game pages
├── build/legal-versions.ts # content hashes + sources for the legal documents
├── build/sveltekit-config.ts # SvelteKit's options: adapter, CSP, prerender entries
├── build/pwa.ts # the service worker, wired into SvelteKit's build
├── src-tauri/ # desktop + Android shell
├── static/ # _headers, robots.txt, security.txt, generated art
├── scripts/verify-dist.mjs # checks the built output (run in CI)
├── scripts/gen-fontface.py # subsetted @font-face rules
├── scripts/gen-icons.py # icons + og.png, from static/icon.svg
├── svelte.config.js # adapter, CSP, prerender entries
└── wrangler.jsonc # Worker + static-asset config
```
@@ -142,9 +143,9 @@ never prerendered: those are served the app shell and rendered from the
catalogue.
Two things about that are load-bearing and easy to break — both are explained
at length in `svelte.config.js` and `src/lib/fallback-route.ts`:
at length in `build/sveltekit-config.ts` and `src/lib/fallback-route.ts`:
- `kit.paths.relative` is **false**. The default (`true`) gives prerendered
- `paths.relative` is **false**. The default (`true`) gives prerendered
pages relative asset URLs, which resolve against the wrong directory the
moment a page is served as the fallback.
- Both hosts answer an unmatched path with `index.html` — the prerendered
@@ -154,11 +155,11 @@ at length in `svelte.config.js` and `src/lib/fallback-route.ts`:
## Content-Security-Policy
Owned by `kit.csp` in `svelte.config.js` and emitted as a `<meta>` tag with the
sha256 of SvelteKit's inline bootstrap. It is deliberately **not** in
`static/_headers`: browsers enforce the intersection of header and meta
policies, so a `script-src 'self'` header blocks that script whatever the meta
says, and the app renders but never hydrates.
Owned by the `csp` option in `build/sveltekit-config.ts` and emitted as a
`<meta>` tag with the sha256 of SvelteKit's inline bootstrap. It is
deliberately **not** in `static/_headers`: browsers enforce the intersection
of header and meta policies, so a `script-src 'self'` header blocks that
script whatever the meta says, and the app renders but never hydrates.
The policy has two flavours, selected by `TAURI_ENV_PLATFORM`. Under Tauri the
origin is `tauri://localhost` (or `http://tauri.localhost` on Windows and
@@ -180,9 +181,10 @@ on "Enable with JS Snippet installation".
## PWA
`@vite-pwa/sveltekit` builds a Workbox service worker, registered only after
the legal consent step and the human check, and never in the Tauri build (a
worker at `tauri.localhost` can never update).
`vite-plugin-pwa` builds a Workbox service worker (`build/pwa.ts` wires it into
SvelteKit's build), registered only after the legal consent step and the human
check, and never in the Tauri build (a worker at `tauri.localhost` can never
update).
- Updates prompt ("Update available" → Reload) rather than swapping the app
under an open page, and the worker checks for a new version hourly.
+3 -2
View File
@@ -25,8 +25,9 @@ export default defineConfig(({ command, mode }) => ({
publicDir: false,
plugins: [
tailwindcss(),
// configFile false: web/svelte.config.js is the SvelteKit app's, and its
// kit options mean nothing here.
// configFile false: SvelteKit's options are passed to its plugin in
// web/vite.config.ts and mean nothing here; no svelte.config.js may be
// picked up either (SvelteKit 3 refuses the file).
svelte({ configFile: false, preprocess: vitePreprocess() }),
command === "serve" && adminDevApi({ preview: mode === "preview" }),
command === "build" &&
+79
View File
@@ -0,0 +1,79 @@
import { describe, expect, it, vi } from "vitest";
import { configureWorkbox, entryUrl, manifestTransform, svelteKitPWA } from "./pwa";
/**
* build/pwa.ts turns SvelteKit's output paths into precache URLs the way
* @vite-pwa/sveltekit 1.1.0 did, so the worker keeps precaching what it always
* did. verify-dist.mjs checks the built sw.js (navigateFallback "/" must be one
* of its entries); these hold the mapping and the wiring.
*/
describe("entryUrl", () => {
it.each([
["prerendered/pages/index.html", "/"],
["prerendered/pages/games.html", "games"],
["prerendered/pages/charts/anti-cheat.html", "charts/anti-cheat"],
["prerendered/pages/legal/index.html", "legal"],
["prerendered/dependencies/sitemap.xml", "sitemap.xml"],
["client/_app/immutable/entry/start.CRIF3DB3.js", "_app/immutable/entry/start.CRIF3DB3.js"],
["client/icon.svg", "icon.svg"],
])("%s -> %s", (file, url) => {
expect(entryUrl(file)).toBe(url);
});
});
describe("manifestTransform", () => {
it("drops SvelteKit's fallback and the web manifest, and maps the rest", async () => {
const result = await manifestTransform([
{ url: "prerendered/fallback.html", revision: "a", size: 1 },
{ url: "client/manifest.webmanifest", revision: "b", size: 1 },
{ url: "prerendered/pages/index.html", revision: "c", size: 1 },
]);
expect(result.manifest).toEqual([{ url: "/", revision: "c", size: 1 }]);
});
});
describe("configureWorkbox", () => {
it("globs SvelteKit's output, and adds each pattern once however often it runs", () => {
const workbox = { globPatterns: ["**/*.{js,css,html,svg,woff2}"], globIgnores: ["**/og.png"] };
configureWorkbox(workbox, "E:\\2\\web");
configureWorkbox(workbox, "E:\\2\\web");
expect(workbox).toMatchObject({
globDirectory: "E:/2/web/.svelte-kit/output",
globPatterns: [
"**/*.{js,css,html,svg,woff2}",
"prerendered/**/*.{html,json}",
"client/**/*.{js,css,ico,png,svg,webp,webmanifest}",
],
globIgnores: ["**/og.png", "server/**"],
manifestTransforms: [manifestTransform],
});
});
it("does not cache-bust the hashed assets", () => {
const workbox: Parameters<typeof configureWorkbox>[0] = {};
configureWorkbox(workbox, "/srv/web");
expect(workbox.dontCacheBustURLsMatching?.test("_app/immutable/entry/start.CRIF3DB3.js")).toBe(true);
expect(workbox.dontCacheBustURLsMatching?.test("index.html")).toBe(false);
});
});
describe("svelteKitPWA", () => {
const plugins = svelteKitPWA({ registerType: "prompt", injectRegister: false });
const own = plugins.find((p) => p.name === "f2p-pwa:sveltekit");
it("swaps vite-plugin-pwa's build step for one inside SvelteKit's buildApp", () => {
const names = plugins.map((p) => p.name);
expect(names).toContain("vite-plugin-pwa");
expect(names).not.toContain("vite-plugin-pwa:build");
expect(names).not.toContain("vite-plugin-pwa:pwa-assets");
expect(own?.apply).toBe("build");
expect(own?.buildApp).toBeTypeOf("function");
});
it("emits the web manifest from the client build only", () => {
const emitFile = vi.fn();
const generateBundle = own?.generateBundle as (this: unknown, ...args: unknown[]) => void;
generateBundle.call({ environment: { name: "ssr" }, emitFile }, {}, {});
expect(emitFile).not.toHaveBeenCalled();
});
});
+139
View File
@@ -0,0 +1,139 @@
/**
* The PWA (manifest, service worker, `virtual:pwa-register`,
* `virtual:pwa-info`), wired into SvelteKit 3's build.
*
* This replaces @vite-pwa/sveltekit, which never shipped for SvelteKit 3 (its
* last release, 1.1.0, accepts kit `^1 || ^2`). It does not import SvelteKit
* at all; what it depends on is the order of SvelteKit 2's builds: it wrote
* the service worker when the SERVER build closed, which in SvelteKit 2 came
* after the client build and the prerender. SvelteKit 3 builds through Vite's
* environment API instead - one `buildApp` hook builds the server, then the
* client, then prerenders, and a `post`-ordered `buildApp` runs the adapter.
* The server build now finishes FIRST, so the old hook would glob an output
* directory with no client and no pages in it.
*
* Here the worker is written in a `buildApp` hook of our own. It has the
* default order and comes after sveltekit() in vite.config.ts, so it runs
* after SvelteKit's build-and-prerender hook and before the adapter's: the
* glob sees every prerendered page, and the adapter then copies
* `.svelte-kit/output/client` - sw.js and workbox-*.js included - into dist/.
*
* Everything else is what @vite-pwa/sveltekit 1.1.0 configured, unchanged, so
* the precache lists the same URLs: the glob runs over `.svelte-kit/output`,
* `client/` and `prerendered/pages/` are stripped from each entry's URL, a
* page's `.html` becomes its route (`index.html` -> `/`, `legal/tos.html` ->
* `legal/tos`), immutable assets are not cache-busted, and the web manifest
* stays out of the precache.
*/
import path from "node:path";
import type { Plugin } from "vite";
import { VitePWA, type VitePWAOptions, type VitePluginPWAAPI } from "vite-plugin-pwa";
type Workbox = NonNullable<VitePWAOptions["workbox"]>;
type ManifestTransform = NonNullable<Workbox["manifestTransforms"]>[number];
/** SvelteKit's output directory, relative to the Vite root (web/). */
const OUTPUT = ".svelte-kit/output";
/** SvelteKit's `appDir`, where every hashed asset lives under `immutable/`. */
const APP_DIR = "_app";
const WEB_MANIFEST = "manifest.webmanifest";
/** Each glob is added only when the caller has none for that directory. */
function globPatterns(patterns: string[] = []): string[] {
const out = [...patterns];
if (!out.some((g) => g.startsWith("prerendered/"))) out.push("prerendered/**/*.{html,json}");
if (!out.some((g) => g.startsWith("client/"))) out.push("client/**/*.{js,css,ico,png,svg,webp,webmanifest}");
if (!out.some((g) => g.includes("webmanifest"))) out.push("client/*.webmanifest");
return out;
}
/** SvelteKit's server bundle sits beside the client and must never be precached. */
function globIgnores(ignores: string[] = []): string[] {
return ignores.some((g) => g.startsWith("server/")) ? [...ignores] : [...ignores, "server/**"];
}
/** A precache entry's URL as the site serves it, from its path under `.svelte-kit/output`. */
export function entryUrl(file: string): string {
let url = file;
for (const prefix of ["client/", "prerendered/dependencies/", "prerendered/pages/"]) {
if (url.startsWith(prefix)) {
url = url.slice(prefix.length);
break;
}
}
if (!url.endsWith(".html")) return url;
if (url === "index.html") return "/";
if (url.endsWith("/index.html")) return url.slice(0, -"/index.html".length);
return url.slice(0, -".html".length);
}
export const manifestTransform: ManifestTransform = async (entries) => ({
manifest: entries
// SvelteKit's own SPA fallback, never served under that name.
.filter(({ url }) => url !== "prerendered/fallback.html")
.map((entry) => ({ ...entry, url: entryUrl(entry.url) }))
.filter(({ url }) => url !== WEB_MANIFEST),
});
/**
* Point workbox at SvelteKit's output. Mutates `workbox` (vite-plugin-pwa reads
* the options object it was given) and may run more than once, so every step
* keeps what an earlier run set.
*/
export function configureWorkbox(workbox: Workbox, root: string): void {
workbox.globDirectory ??= path.posix.join(root.replaceAll("\\", "/"), OUTPUT);
workbox.globPatterns = globPatterns(workbox.globPatterns);
workbox.globIgnores = globIgnores(workbox.globIgnores);
workbox.dontCacheBustURLsMatching ??= new RegExp(`${APP_DIR}/immutable/`);
workbox.manifestTransforms ??= [manifestTransform];
}
/**
* vite-plugin-pwa with SvelteKit 3's output layout. Takes the same options as
* `VitePWA()`; `outDir`, the glob directory and the manifest transform are set
* here.
*/
export function svelteKitPWA(options: Partial<VitePWAOptions>): Plugin[] {
const userOptions: Partial<VitePWAOptions> = {
...options,
includeManifestIcons: options.includeManifestIcons ?? false,
// Where sw.js and workbox-*.js are written: the client output, which the
// adapter copies into dist/ after this plugin has run.
outDir: `${OUTPUT}/client`,
integration: {
// Runs in vite-plugin-pwa's configResolved, once the root is known.
configureOptions(viteConfig, resolved) {
configureWorkbox((resolved.workbox ??= {}), viteConfig.root);
},
},
};
const plugins = VitePWA(userOptions);
const main = plugins.find((p) => p.name === "vite-plugin-pwa");
const api = () => main?.api as VitePluginPWAAPI | undefined;
return [
// vite-plugin-pwa's own build plugin writes the worker when a build
// closes - the wrong moment under SvelteKit, as described above. Its
// pwa-assets plugin does nothing without a `pwaAssets` option, and SvelteKit
// warns about its transformIndexHtml hook on every build.
...plugins.filter((p) => p.name !== "vite-plugin-pwa:build" && p.name !== "vite-plugin-pwa:pwa-assets"),
{
name: "f2p-pwa:sveltekit",
apply: "build",
// The web manifest is emitted into the CLIENT output only.
generateBundle(_, bundle) {
if (this.environment.name !== "client") return;
// vite-plugin-pwa types both with Rollup's interfaces; Vite 8 passes
// Rolldown's, which it handles the same way (@vite-pwa/sveltekit did
// exactly this).
api()?.generateBundle(bundle as never, this as never);
},
async buildApp() {
const pwa = api();
if (!pwa || pwa.disabled) return;
await pwa.generateSW();
},
},
];
}
+70
View File
@@ -0,0 +1,70 @@
import { describe, expect, it } from "vitest";
import { sveltekitConfig } from "./sveltekit-config";
/**
* The SvelteKit options that carry decisions CLAUDE.md explains ("Frontend
* gotchas"), checked in both flavours without a build. verify-dist.mjs checks
* the policies as they come out of one.
*/
const web = sveltekitConfig(false);
const tauri = sveltekitConfig(true);
function directive(config: typeof web, name: string): string[] | undefined {
return (config.csp?.directives as Record<string, string[] | undefined> | undefined)?.[name];
}
function httpErrorHandler(): (details: { path: string; message: string }) => void {
const handler = web.prerender?.handleHttpError;
if (typeof handler !== "function") throw new Error("prerender.handleHttpError is not a function");
return handler as (details: { path: string; message: string }) => void;
}
describe("sveltekitConfig", () => {
it("keeps asset URLs absolute in both flavours", () => {
expect(web.paths?.relative).toBe(false);
expect(tauri.paths?.relative).toBe(false);
});
it("builds with adapter-static and prerenders the sitemap nothing links to", () => {
expect(web.adapter?.name).toBe("@sveltejs/adapter-static");
expect(web.prerender?.entries).toEqual(["*", "/sitemap.xml"]);
});
it("forgives prerender 404s under the Worker's two prefixes and nowhere else", () => {
const handle = httpErrorHandler();
expect(() => handle({ path: "/img/d2/730.jpg", message: "404 /img/d2/730.jpg" })).not.toThrow();
expect(() => handle({ path: "/api/data/data/index.json", message: "404 /api" })).not.toThrow();
expect(() => handle({ path: "/games/nope", message: "404 /games/nope" })).toThrow("404 /games/nope");
expect(() => handle({ path: "/imgs/x", message: "404 /imgs/x" })).toThrow();
});
it("hashes the bootstrap script rather than allowing inline code", () => {
expect(web.csp?.mode).toBe("hash");
expect(directive(web, "script-src")).not.toContain("unsafe-inline");
expect(directive(tauri, "script-src")).toEqual(["self"]);
});
it("lets the web load the beacon, Turnstile and the media host, and nothing more", () => {
expect(directive(web, "script-src")).toEqual([
"self",
"https://static.cloudflareinsights.com",
"https://challenges.cloudflare.com",
]);
expect(directive(web, "frame-src")).toEqual(["self", "https://challenges.cloudflare.com"]);
expect(directive(web, "img-src")).toContain("https://media.free-steam-games.win");
expect(directive(web, "connect-src")).toEqual(["self", "https://cloudflareinsights.com"]);
});
it("lets the packaged apps reach the site and GitHub, and none of the web's hosts", () => {
expect(directive(tauri, "connect-src")).toEqual([
"self",
"https://free-steam-games.win",
"https://api.github.com",
"ipc:",
"http://ipc.localhost",
]);
expect(directive(tauri, "img-src")).toContain("https://free-steam-games.win");
expect(directive(tauri, "img-src")).not.toContain("https://media.free-steam-games.win");
expect(directive(tauri, "frame-src")).toBeUndefined();
});
});
@@ -1,20 +1,18 @@
import adapter from "@sveltejs/adapter-static";
import type { sveltekit } from "@sveltejs/kit/vite";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
/**
* True while the Tauri CLI is driving this build.
*
* Tauri 2 sets TAURI_ENV_* for the process running beforeBuildCommand, so
* this needs no extra npm script and no cross-env - which matters, because
* `VAR=1 vite build` in package.json does not work on Windows.
*/
const IS_TAURI = Boolean(process.env.TAURI_ENV_PLATFORM);
type SvelteKitConfig = NonNullable<Parameters<typeof sveltekit>[0]>;
/**
* One adapter, two targets.
* SvelteKit's own options, passed to its Vite plugin by vite.config.ts as
* `sveltekit(sveltekitConfig(IS_TAURI))`. They lived in svelte.config.js until
* SvelteKit 3, which refuses that file (the build stops if it exists) and
* takes the same options, minus the `kit` level, from the plugin. A function
* of the flavour, so sveltekit-config.test.ts can hold both policies.
*
* `adapter-static` with a fallback produces output that works unmodified in
* both places this app ships:
* One adapter, two targets. `adapter-static` with a fallback produces output
* that works unmodified in both places this app ships:
*
* - Cloudflare, where `not_found_handling: "single-page-application"` in
* wrangler.jsonc already serves index.html for an unmatched path, and the
@@ -29,9 +27,9 @@ const IS_TAURI = Boolean(process.env.TAURI_ENV_PLATFORM);
* comment in the old React main.tsx claiming the webview has no server
* fallback is out of date.
*/
const config = {
preprocess: vitePreprocess(),
kit: {
export function sveltekitConfig(tauri: boolean): SvelteKitConfig {
return {
preprocess: vitePreprocess(),
adapter: adapter({
// dist/, not build/: wrangler.jsonc's assets.directory and Tauri's
// frontendDist both already point here, and changing them would mean
@@ -92,13 +90,6 @@ const config = {
*/
relative: false,
},
alias: {
// The React app used "@/..." for src-relative imports. Kept so a ported
// file does not have to rewrite every import path at the same time as
// its rendering.
"@": "src",
},
/**
* The Content-Security-Policy, owned HERE rather than in static/_headers.
*
@@ -142,9 +133,11 @@ const config = {
* the human check, and tauri.conf.json's header policy would block
* both anyway. verify-dist.mjs fails either build that gets this wrong.
*/
// `as const` on every conditional list below: a spread is not typed
// by the directive it lands in, and SvelteKit types each source.
"script-src": [
"self",
...(IS_TAURI ? [] : ["https://static.cloudflareinsights.com", "https://challenges.cloudflare.com"]),
...(tauri ? [] : (["https://static.cloudflareinsights.com", "https://challenges.cloudflare.com"] as const)),
],
// 'unsafe-inline' is load-bearing for style-src: Bits UI positions
// popovers and dialogs with inline style attributes, and ECharts sizes
@@ -156,14 +149,14 @@ const config = {
"data:",
// Same reason as connect-src: under Tauri 'self' is the bundle, so
// artwork proxied through /img/* is cross-origin.
...(IS_TAURI ? ["https://free-steam-games.win", "blob:"] : []),
...(tauri ? (["https://free-steam-games.win", "blob:"] as const) : []),
// The R2 bucket's custom domain (MEDIA_ORIGIN in lib/site.ts): the
// minted AVIF art, served from Cloudflare's cache without running
// the Worker. Web only - under Tauri every image comes through
// /img/*. Without it every thumbnail would silently fall back to
// /img (lib/img-fallback.ts), so verify-dist fails a web build that
// lacks it.
...(IS_TAURI ? [] : ["https://media.free-steam-games.win"]),
...(tauri ? [] : (["https://media.free-steam-games.win"] as const)),
"https://shared.akamai.steamstatic.com",
"https://shared.fastly.steamstatic.com",
"https://cdn.akamai.steamstatic.com",
@@ -182,7 +175,7 @@ const config = {
* only there, by the Android release check, which the web never runs
* (it is gated on isTauri() && isAndroid()).
*/
"connect-src": IS_TAURI
"connect-src": tauri
? [
"self",
"https://free-steam-games.win",
@@ -199,7 +192,7 @@ const config = {
* default-src 'self' and the widget is refused. The Tauri policy keeps
* no frame-src at all, so it stays exactly as it was.
*/
...(IS_TAURI ? {} : { "frame-src": ["self", "https://challenges.cloudflare.com"] }),
...(tauri ? {} : { "frame-src": ["self", "https://challenges.cloudflare.com"] }),
"worker-src": ["self"],
"manifest-src": ["self"],
"media-src": ["none"],
@@ -208,7 +201,6 @@ const config = {
"form-action": ["none"],
},
},
prerender: {
// "*" is every route SvelteKit can reach by crawling links from the
// entry points. /sitemap.xml is linked from robots.txt, not from any
@@ -235,17 +227,5 @@ const config = {
throw new Error(message);
},
},
typescript: {
config(cfg) {
// The generated config is what svelte-check uses. The Worker and the
// tests have their own tsconfigs; this one must not try to typecheck
// either of them.
cfg.exclude = [...(cfg.exclude ?? []), "../worker/**"];
return cfg;
},
},
},
};
export default config;
};
}
+4 -1
View File
@@ -2,7 +2,10 @@
"$schema": "https://unpkg.com/knip@6/schema.json",
"entry": [
"src/workers/jsonl-parser.ts",
"src/index.css"
"src/index.css",
// SvelteKit 3's param matchers. knip's SvelteKit plugin still looks for
// the per-file src/params/*, so without this the file is "unused".
"src/params.ts"
],
// worker/** was absent until 2026-09-12, so nothing in the Cloudflare Worker
// was ever analysed - which is why five dead exports (commitFile,
+40 -110
View File
@@ -1,12 +1,12 @@
{
"name": "free-steam-games-web",
"version": "2.2.2",
"version": "2.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "free-steam-games-web",
"version": "2.2.2",
"version": "2.3.0",
"dependencies": {
"@fontsource-variable/bricolage-grotesque": "^5.3.0",
"@fontsource-variable/ibm-plex-sans": "^5.3.0",
@@ -28,14 +28,13 @@
"tailwind-merge": "^3.7.0"
},
"devDependencies": {
"@sveltejs/adapter-static": "3.0.10",
"@sveltejs/kit": "2.70.3",
"@sveltejs/adapter-static": "4.0.0",
"@sveltejs/kit": "3.1.0",
"@sveltejs/vite-plugin-svelte": "7.3.1",
"@tailwindcss/vite": "^4.3.3",
"@tauri-apps/cli": "^2.12.4",
"@types/node": "^26.6.5",
"@typescript/native": "npm:typescript@~7.0.2",
"@vite-pwa/sveltekit": "^1.1.0",
"@vitest/coverage-v8": "^5.0.5",
"knip": "^6.43.0",
"rehype-sanitize": "^6.0.0",
@@ -4072,47 +4071,43 @@
}
},
"node_modules/@sveltejs/adapter-static": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-3.0.10.tgz",
"integrity": "sha512-7D9lYFWJmB7zxZyTE/qxjksvMqzMuYrrsyh1f4AlZqeZeACPRySjbC3aFiY55wb1tWUaKOQG9PVbm74JcN2Iew==",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-4.0.0.tgz",
"integrity": "sha512-aF1J23R1ebKqUxQ4/qLr/Lxu63NFmLAtg8UZl3HFLxaoA1D/nhTVGcD9lTqx65iUbjNR2iOL0TgOxSX82x6Paw==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"@sveltejs/kit": "^2.0.0"
"@sveltejs/kit": "^3.0.0-next.0"
}
},
"node_modules/@sveltejs/kit": {
"version": "2.70.3",
"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.70.3.tgz",
"integrity": "sha512-UDvEYuZqAMbfB/oXIoqKvbKcb7YczK5zYrzmsGV1zRJk03jntwp8dXiYoIJotxAndsKvcPFtx9H1GRSKFdSHgg==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-3.1.0.tgz",
"integrity": "sha512-JTWlq2HQlkqx6vIoxhC0R6sc4WVqbQoRyEmr5YlqKmiYbzY1U3awtSWTmjMLlS056a49AmkQR6rnNANXIE8B0Q==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@sveltejs/acorn-typescript": "^1.0.9",
"@types/cookie": "^0.6.0",
"acorn": "^8.16.0",
"cookie": "^0.6.0",
"devalue": "^5.8.1",
"@rolldown/pluginutils": "^1.0.1",
"@standard-schema/spec": "^1.1.0",
"cookie": "^2.0.1",
"devalue": "^5.9.4",
"esm-env": "^1.2.2",
"kleur": "^4.1.5",
"magic-string": "^0.30.5",
"mrmime": "^2.0.0",
"set-cookie-parser": "^3.0.0",
"sirv": "^3.0.0"
"magic-string": "^1.2.3",
"mrmime": "^2.0.1",
"sirv": "^3.0.2"
},
"bin": {
"svelte-kit": "svelte-kit.js"
},
"engines": {
"node": ">=18.13"
"node": ">=22.17"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0 || ^7.0.0",
"svelte": "^4.0.0 || ^5.0.0-next.0",
"typescript": "^5.3.3 || ^6.0.0",
"vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0 || ^8.0.0"
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"svelte": "^5.57.1",
"typescript": "^6.0.0",
"vite": "^8.0.12"
},
"peerDependenciesMeta": {
"@opentelemetry/api": {
@@ -4124,21 +4119,28 @@
}
},
"node_modules/@sveltejs/kit/node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-2.0.1.tgz",
"integrity": "sha512-yuToqVvRrj6pfDXREyQAAv8SkAEk/8GS3jQRTiUMm66TVtBYmqQeoEjL2Lmq8Rpo6271vH76InTChTitEAm65w==",
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">= 0.6"
"node": ">=22"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/@sveltejs/kit/node_modules/set-cookie-parser": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-3.1.2.tgz",
"integrity": "sha512-5/r/lTwbJ3zQ+qwdUFZYeRNqda7P5HD8zQKqlSjdGt1/S0cjLAphHusj4Y58ahDtWn/g32xrIS58/ikOvwl0Lw==",
"node_modules/@sveltejs/kit/node_modules/magic-string": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.4.tgz",
"integrity": "sha512-jQz9sVhrZuphH4NrAIHSgkDJCluQO7Ioi4KGRLa7aTUjAODQ13hENX0YIytqYE/rIkO485gQG2LeBxJaW53kkQ==",
"devOptional": true,
"license": "MIT"
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.6.0"
}
},
"node_modules/@sveltejs/load-config": {
"version": "0.2.3",
@@ -4862,13 +4864,6 @@
"assertion-error": "^2.0.1"
}
},
"node_modules/@types/cookie": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz",
"integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==",
"devOptional": true,
"license": "MIT"
},
"node_modules/@types/debug": {
"version": "4.1.13",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz",
@@ -5333,64 +5328,6 @@
"dev": true,
"license": "ISC"
},
"node_modules/@vite-pwa/sveltekit": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@vite-pwa/sveltekit/-/sveltekit-1.1.0.tgz",
"integrity": "sha512-mMIf2tY+7Hg8jecpu/WY+Ki2ikoXy3hVmt3tOxi0K+lYYnKQrDYthuHireI0S+26Mg9BXzL7qQF1xeB5VYlYlg==",
"dev": true,
"license": "MIT",
"dependencies": {
"kolorist": "^1.8.0",
"tinyglobby": "^0.2.9",
"vite-plugin-pwa": "^1.2.0"
},
"engines": {
"node": ">=18.13"
},
"funding": {
"url": "https://github.com/sponsors/antfu"
},
"peerDependencies": {
"@sveltejs/kit": "^1.3.1 || ^2.0.1",
"@vite-pwa/assets-generator": "^1.0.0"
},
"peerDependenciesMeta": {
"@vite-pwa/assets-generator": {
"optional": true
}
}
},
"node_modules/@vite-pwa/sveltekit/node_modules/vite-plugin-pwa": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-1.3.0.tgz",
"integrity": "sha512-c5kMgN+ITrOtHXp8PAtk2uOIEea6XjP/unCGxOWWBzQ6qa65qj/awHg0wf+QF9E/2u9vh86LqxPwzEPNbM2r5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"debug": "^4.3.6",
"pretty-bytes": "^6.1.1",
"tinyglobby": "^0.2.10",
"workbox-build": "^7.4.1",
"workbox-window": "^7.4.1"
},
"engines": {
"node": ">=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/antfu"
},
"peerDependencies": {
"@vite-pwa/assets-generator": "^1.0.0",
"vite": "^3.1.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
"workbox-build": "^7.4.1",
"workbox-window": "^7.4.1"
},
"peerDependenciesMeta": {
"@vite-pwa/assets-generator": {
"optional": true
}
}
},
"node_modules/@vitest/coverage-v8": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.5.tgz",
@@ -8000,7 +7937,7 @@
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
"integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==",
"devOptional": true,
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@@ -8044,13 +7981,6 @@
"node": "^20.19.0 || >=22.12.0"
}
},
"node_modules/kolorist": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz",
"integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==",
"dev": true,
"license": "MIT"
},
"node_modules/leven": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz",
+8 -6
View File
@@ -1,8 +1,11 @@
{
"name": "free-steam-games-web",
"private": true,
"version": "2.2.2",
"version": "2.3.0",
"type": "module",
"imports": {
"#lib/*": "./src/lib/*"
},
"scripts": {
"dev": "vite dev",
"dev:admin": "svelte-kit sync && vite --config admin/vite.config.ts",
@@ -52,14 +55,13 @@
"tailwind-merge": "^3.7.0"
},
"devDependencies": {
"@sveltejs/adapter-static": "3.0.10",
"@sveltejs/kit": "2.70.3",
"@sveltejs/adapter-static": "4.0.0",
"@sveltejs/kit": "3.1.0",
"@sveltejs/vite-plugin-svelte": "7.3.1",
"@tailwindcss/vite": "^4.3.3",
"@tauri-apps/cli": "^2.12.4",
"@types/node": "^26.6.5",
"@typescript/native": "npm:typescript@~7.0.2",
"@vite-pwa/sveltekit": "^1.1.0",
"@vitest/coverage-v8": "^5.0.5",
"knip": "^6.43.0",
"rehype-sanitize": "^6.0.0",
@@ -83,8 +85,8 @@
"echarts-wordcloud": {
"echarts": "$echarts"
},
"@sveltejs/kit@2.70.3": {
"cookie": "^0.7.2"
"runed": {
"@sveltejs/kit": "$@sveltejs/kit"
},
"miniflare": {
"undici": "^7.30.1"
+18 -18
View File
@@ -623,7 +623,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a"
dependencies = [
"quote",
"syn 2.0.117",
"syn 3.0.6",
]
[[package]]
@@ -747,7 +747,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -927,7 +927,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -952,7 +952,7 @@ dependencies = [
[[package]]
name = "f2p-tracker"
version = "2.2.2"
version = "2.3.0"
dependencies = [
"serde",
"serde_json",
@@ -2125,7 +2125,7 @@ dependencies = [
"png",
"serde",
"thiserror 2.0.18",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -2457,7 +2457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
dependencies = [
"libc",
"windows-sys 0.45.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -2947,7 +2947,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -3003,7 +3003,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -3398,7 +3398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
dependencies = [
"libc",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -3664,9 +3664,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "tauri"
version = "2.12.4"
version = "2.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f316751027fc2644221d1a448564d519efb07067fda584879d9cda966391d212"
checksum = "5fb0244332cfb9cee7e2a568bf5da29a36ed8fdbd717f6f47a66b6b7b358c072"
dependencies = [
"anyhow",
"bytes",
@@ -3715,9 +3715,9 @@ dependencies = [
[[package]]
name = "tauri-build"
version = "2.7.3"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "641dd5fd297c99ab92717b0428cca5b9c6f960b2ac96ca131b3eebc9d70b8ddc"
checksum = "adddb0e648752aaac5da9c3c3c6a68e1e87cab55e3b757b18a9441ef8c3ac614"
dependencies = [
"anyhow",
"cargo_toml",
@@ -3985,7 +3985,7 @@ dependencies = [
"getrandom 0.4.2",
"once_cell",
"rustix",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -4322,7 +4322,7 @@ dependencies = [
"png",
"serde",
"thiserror 2.0.18",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -4351,7 +4351,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
dependencies = [
"memoffset",
"tempfile",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -4745,7 +4745,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -4766,7 +4766,7 @@ dependencies = [
"objc2-foundation",
"objc2-quartz-core",
"raw-window-handle",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
"windows-version",
]
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "f2p-tracker"
version = "2.2.2"
version = "2.3.0"
description = "Desktop wrapper around the Steam F2P Tracker web app"
authors = ["poli0981"]
license = "MIT"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "F2P Tracker",
"version": "2.2.2",
"version": "2.3.0",
"identifier": "io.github.poli0981.f2p-tracker",
"build": {
"beforeBuildCommand": "npm run build:desktop",
+39
View File
@@ -0,0 +1,39 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const chunk = vi.hoisted(() => ({ isChunkLoadError: vi.fn(), reloadOnceForStaleChunk: vi.fn() }));
vi.mock("#lib/chunk-error.js", () => chunk);
import { handleError } from "./hooks.client";
/** The hook as SvelteKit 3 calls it: every error, with its kind. */
function run(error: unknown, kind: "app" | "framework" | "unknown" = "unknown") {
return handleError({ kind, error, event: {} } as Parameters<typeof handleError>[0]);
}
describe("hooks.client handleError", () => {
beforeEach(() => {
chunk.isChunkLoadError.mockReset();
chunk.reloadOnceForStaleChunk.mockReset();
});
it("returns nothing for an ordinary error, so SvelteKit keeps its status and message", () => {
chunk.isChunkLoadError.mockReturnValue(false);
expect(run(new Error("boom"))).toBeUndefined();
expect(run({ status: 404, message: "Not Found" }, "framework")).toBeUndefined();
expect(chunk.reloadOnceForStaleChunk).not.toHaveBeenCalled();
});
it("says it is reloading when a stale chunk starts the one reload", () => {
chunk.isChunkLoadError.mockReturnValue(true);
chunk.reloadOnceForStaleChunk.mockReturnValue(true);
expect(run(new TypeError("Failed to fetch dynamically imported module"))).toEqual({
message: "Reloading to pick up the latest version",
});
});
it("lets the error show once the tab has already reloaded for it", () => {
chunk.isChunkLoadError.mockReturnValue(true);
chunk.reloadOnceForStaleChunk.mockReturnValue(false);
expect(run(new TypeError("Failed to fetch dynamically imported module"))).toBeUndefined();
});
});
+4 -4
View File
@@ -8,12 +8,12 @@
* this reloads once to pick up the new build instead of showing an error page
* for an app that is not actually broken.
*/
import type { HandleClientError } from "@sveltejs/kit";
import { isChunkLoadError, reloadOnceForStaleChunk } from "$lib/chunk-error";
import type { HandleClientError } from "@sveltejs/kit/hooks";
import { isChunkLoadError, reloadOnceForStaleChunk } from "#lib/chunk-error.js";
export const handleError: HandleClientError = ({ error, message }) => {
export const handleError: HandleClientError = ({ error }) => {
if (isChunkLoadError(error) && reloadOnceForStaleChunk()) {
return { message: "Reloading to pick up the latest version" };
}
return { message };
// Returning nothing keeps SvelteKit's own status and safe message.
};
+6 -6
View File
@@ -10,18 +10,18 @@
* `[404] GET /img/...` line for it - 91% of the Workers Builds log, burying
* anything worth reading. Answering before routing skips both.
*
* The prerenderer still sees a 404. `kit.prerender.handleHttpError`
* (svelte.config.js) ignores it for exactly these two prefixes and fails the
* build for any other path, so a genuinely broken internal link still stops
* the build.
* The prerenderer still sees a 404. `prerender.handleHttpError`
* (build/sveltekit-config.ts) ignores it for exactly these two prefixes and
* fails the build for any other path, so a genuinely broken internal link
* still stops the build.
*
* `vite dev` never gets here for these paths: its proxy (vite.config.ts)
* forwards /api and /img to production before SvelteKit's middleware runs.
*/
import type { Handle } from "@sveltejs/kit";
import type { Handle } from "@sveltejs/kit/hooks";
export const handle: Handle = ({ event, resolve }) => {
// Same prefixes, same test, as handleHttpError in svelte.config.js.
// Same prefixes, same test, as handleHttpError in build/sveltekit-config.ts.
const { pathname } = event.url;
if (pathname.startsWith("/img/") || pathname.startsWith("/api/")) {
return new Response(null, { status: 404 });
+4 -3
View File
@@ -3,9 +3,10 @@
*
* WHY NOT THE AUTOMATIC SETUP. Cloudflare's "automatic" Web Analytics rewrites
* HTML responses at the edge, after our origin response, and inserts the beacon
* tag PLUS an inline loader script. `kit.csp` runs in `mode: "hash"`, and CSP3
* says a script-src carrying a hash or nonce IGNORES 'unsafe-inline' — so there
* is no policy we could write that admits that inline script. It had been
* tag PLUS an inline loader script. The CSP (build/sveltekit-config.ts) runs
* in `mode: "hash"`, and CSP3 says a script-src carrying a hash or nonce
* IGNORES 'unsafe-inline' — so there is no policy we could write that admits
* that inline script. It had been
* enabled on the zone for months, logging two CSP violations per page load and
* collecting exactly nothing (docs/SECURITY_SETUP.md §9). The dashboard must
* stay on "Enable with JS Snippet installation" for this module to be the only
+1 -1
View File
@@ -20,7 +20,7 @@
* not anything read off the request.
*/
import { page } from "$app/state";
import { SITE_ORIGIN } from "$lib/site";
import { SITE_ORIGIN } from "#lib/site.js";
interface Props {
/** Page title WITHOUT the site suffix. Pass "" on the home page, whose
+36 -2
View File
@@ -1,7 +1,11 @@
import { describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import { readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { MAY_FALL_BACK_ROUTES } from "./fallback-route";
const goto = vi.hoisted(() => vi.fn());
vi.mock("$app/navigation", () => ({ goto }));
import { MAY_FALL_BACK_ROUTES, markRouteRendered, recoverFallbackRoute } from "./fallback-route";
/**
* Keeps fallback-route.ts's list honest.
@@ -69,3 +73,33 @@ describe("the may-fall-back route list", () => {
expect(src).toContain(`markRouteRendered("${routeId}")`);
});
});
describe("recoverFallbackRoute", () => {
afterEach(() => {
vi.unstubAllGlobals();
goto.mockReset();
});
it("re-renders a route the host answered with the dashboard, in place and with its own load", () => {
vi.stubGlobal("location", { pathname: "/developers/Valve", search: "?page=2", hash: "#top" });
recoverFallbackRoute("/developers/[name]");
// SvelteKit 3's names: `replace`, not `replaceState`; `reset: false`, not
// `noScroll` (which throws there); `refreshAll`, not `invalidateAll`.
expect(goto).toHaveBeenCalledWith("/developers/Valve?page=2#top", {
replace: true,
reset: false,
refreshAll: true,
});
});
it("leaves a route alone when its own prerendered page hydrated", () => {
markRouteRendered("/publishers/[name]");
recoverFallbackRoute("/publishers/[name]");
expect(goto).not.toHaveBeenCalled();
});
it.each([null, "/", "/legal/[doc=legaldoc]"])("never re-renders %s, which cannot fall back", (routeId) => {
recoverFallbackRoute(routeId);
expect(goto).not.toHaveBeenCalled();
});
});
+6 -6
View File
@@ -64,13 +64,13 @@ export function recoverFallbackRoute(routeId: string | null): void {
// The route's own page hydrated: it was a real (prerendered) document.
if (rendered === routeId) return;
// invalidateAll so the route's own load() runs; without it SvelteKit can
// reuse the shell's `data: [null, null]`. replaceState so the shell does not
// become a Back-button stop, and noScroll because the user has not moved.
// refreshAll so the route's own load() runs; without it SvelteKit can
// reuse the shell's `data: [null, null]`. replace so the shell does not
// become a Back-button stop, and reset false because the user has not moved.
void goto(location.pathname + location.search + location.hash, {
replaceState: true,
noScroll: true,
invalidateAll: true,
replace: true,
reset: false,
refreshAll: true,
});
}
+1 -1
View File
@@ -11,7 +11,7 @@
* player count would be days old on the page; those come only from the live
* catalogue once it loads.
*
* This file must stay free of Svelte, $lib aliases and browser globals:
* This file must stay free of Svelte, `#lib` imports and browser globals:
* build/game-seeds.ts imports it from vite.config.ts, in Node.
*/
+5 -5
View File
@@ -124,11 +124,11 @@ describe("every media-host image can fall back to /img", () => {
});
it("is allowed by the web CSP and checked by verify-dist, under the same name as lib/site.ts", () => {
// svelte.config.js and verify-dist.mjs are plain Node and cannot import
// site.ts, so the literal is repeated there; this keeps the three equal.
// A web policy without the host blocks every image, the fallback hides it,
// and every view costs a Worker request again.
for (const file of ["svelte.config.js", "scripts/verify-dist.mjs"]) {
// build/sveltekit-config.ts (the CSP) and verify-dist.mjs repeat the
// literal rather than import site.ts; this keeps the three equal. A web
// policy without the host blocks every image, the fallback hides it, and
// every view costs a Worker request again.
for (const file of ["build/sveltekit-config.ts", "scripts/verify-dist.mjs"]) {
expect(readFileSync(join(WEB, file), "utf-8"), file).toContain(`"${MEDIA_ORIGIN}"`);
}
});
+1 -1
View File
@@ -11,7 +11,7 @@
* An ATTACHMENT, never an action. On a prerendered <img>, `use:` (like an
* onload/onerror handler) makes Svelte write `onload="this.__e=event"` and
* `onerror="this.__e=event"` into the HTML, so it can replay an event that
* fired before hydration - and kit.csp, a hash policy, refuses inline event
* fired before hydration - and the CSP, a hash policy, refuses inline event
* handlers: a CSP violation on every game page. verify-dist.mjs fails the
* build if one appears. The replay is not needed anyway: a load that already
* failed is `complete` with no `naturalWidth` by the time this runs.
+61
View File
@@ -0,0 +1,61 @@
import { afterEach, describe, expect, it, vi } from "vitest";
const goto = vi.hoisted(() => vi.fn());
vi.mock("$app/navigation", () => ({ goto }));
import { upgradeLegacyHashUrl } from "./legacy-url";
const ORIGIN = "https://free-steam-games.win";
/** A page loaded at `/` + hash, as a 1.4.x link or the old Pages tombstone sends it. */
function loadWithHash(hash: string) {
vi.stubGlobal("window", { location: { hash, origin: ORIGIN } });
}
describe("upgradeLegacyHashUrl", () => {
afterEach(() => {
vi.unstubAllGlobals();
goto.mockReset();
});
it("does nothing outside a browser", () => {
upgradeLegacyHashUrl();
expect(goto).not.toHaveBeenCalled();
});
it.each(["", "#", "#section", "#games/730"])("leaves the hash %j alone", (hash) => {
loadWithHash(hash);
upgradeLegacyHashUrl();
expect(goto).not.toHaveBeenCalled();
});
it.each([
["#/games/730", "/games/730"],
["#/games?q=dota", "/games?q=dota"],
["#/", "/"],
])("renders %s as %s in place of the history entry", (hash, path) => {
goto.mockResolvedValue(undefined);
loadWithHash(hash);
upgradeLegacyHashUrl();
expect(goto).toHaveBeenCalledOnce();
const [url, options] = goto.mock.calls[0];
expect(String(url)).toBe(`${ORIGIN}${path}`);
expect(options).toEqual({ replace: true, reset: false });
});
it.each(["#//other.example/games/730", "#/\\other.example/games/730"])(
"never leaves the site for %s",
(hash) => {
loadWithHash(hash);
upgradeLegacyHashUrl();
expect(goto).not.toHaveBeenCalled();
},
);
it("sends a path that matches no route to the 404 page", async () => {
goto.mockRejectedValueOnce(new Error("Cannot find a route for /no-such-page")).mockResolvedValue(undefined);
loadWithHash("#/no-such-page");
upgradeLegacyHashUrl();
await vi.waitFor(() => expect(goto).toHaveBeenLastCalledWith("/error/404", { replace: true }));
});
});
+13 -4
View File
@@ -27,12 +27,21 @@ import { goto } from "$app/navigation";
export function upgradeLegacyHashUrl(): void {
if (typeof window === "undefined") return;
const { hash } = window.location;
const { hash, origin } = window.location;
if (!hash.startsWith("#/")) return;
// The hash is anyone's to write. Resolved against this origin and checked
// against it, because `#//other.example/…` (or `#/\other.example`) names
// another site, and an old link is never a reason to leave this one.
const url = new URL(hash.slice(1), origin);
if (url.origin !== origin) return;
// goto, not history.replaceState. By the time this runs the router has
// already rendered the document it was given - "/", the dashboard - and a
// bare replaceState changed the address bar while leaving the dashboard on
// screen. goto renders the route the hash names; replaceState keeps the hash
// URL out of history, so Back does not bounce through it.
void goto(hash.slice(1) || "/", { replaceState: true, noScroll: true });
// screen. goto renders the route the hash names; replace keeps the hash URL
// out of history, so Back does not bounce through it.
//
// goto rejects a path that matches no route (SvelteKit 3; SvelteKit 2 loaded
// it natively). Such a link gets the 404 page at its fixed address: nothing
// from the hash ever reaches a navigation that bypasses the router.
void goto(url, { replace: true, reset: false }).catch(() => goto("/error/404", { replace: true }));
}
+8 -2
View File
@@ -1,4 +1,4 @@
import { REPO_OWNER, REPO_NAME } from "./schema";
import { REPO_OWNER, REPO_NAME } from "./schema.ts";
/**
* Single source of truth for the project's legal documents.
@@ -6,6 +6,12 @@ import { REPO_OWNER, REPO_NAME } from "./schema";
* Lifted out of About.tsx so the first-run consent gate and the About page
* render the same list. Long-form legal bodies stay in English (markdown in
* the repo `docs/` folder); only the surrounding UI chrome is translated.
*
* Node loads this file as it is (no Vite) while the site builds: src/params.ts
* imports it, and SvelteKit 3 imports params.ts with Node's import(). So every
* import here names its real file - `./schema.ts`, never `./schema` or `.js` -
* and the syntax stays type-strippable (no enums, no namespaces). Break it and
* `vite build` stops with ERR_MODULE_NOT_FOUND or a syntax error.
*/
export interface LegalDoc {
/** i18n key: render with t(). The document title as the lists show it. */
@@ -59,7 +65,7 @@ export function legalDocUrl(path: string): string {
}
/** Whether a /legal/<slug> names a document. The route's param matcher
* (src/params/legaldoc.ts), so an unknown slug matches no route at all and
* (`legaldoc` in src/params.ts), so an unknown slug matches no route at all and
* renders the layout's translated 404 instead of the dashboard. */
export function isLegalDocSlug(slug: string): boolean {
return LEGAL_DOCS.some((d) => legalDocSlug(d.path) === slug);
+1 -1
View File
@@ -14,7 +14,7 @@
*
* THIS FILE IS SHARED WITH THE ADMIN SPA (admin/src/App.svelte imports
* `theme`), which builds with its own Vite config. It must therefore stay free
* of `$app/*`, `$lib/*` and any virtual module - the reason consent moved out:
* of `$app/*` and any virtual module - the reason consent moved out:
* it needs `virtual:legal-versions`, and pulling that in here failed the admin
* build outright.
*/
+2 -2
View File
@@ -43,7 +43,7 @@ export const API_ORIGIN = isTauri() ? SITE_ORIGIN : "";
* CDN cache, without the Worker running at all - a Worker always runs BEFORE
* the cache, so /img/* can never be served from it. Web only: the packaged
* apps' CSP does not list this host, so under Tauri art keeps coming through
* /img/* (lib/image.ts). In kit.csp img-src (svelte.config.js), web flavour
* only; images.test.ts keeps that literal equal to this one.
* /img/* (lib/image.ts). In the CSP's img-src (build/sveltekit-config.ts),
* web flavour only; images.test.ts keeps that literal equal to this one.
*/
export const MEDIA_ORIGIN = "https://media.free-steam-games.win";
+3 -3
View File
@@ -3,9 +3,9 @@
* human check (common/HumanCheck.svelte), which runs after consent.
*
* Appended at runtime, like lib/analytics.ts's beacon and for the same reason:
* kit.csp runs in mode "hash", which admits an external script by host
* (`script-src https://challenges.cloudflare.com`, web flavour only) and never
* an inline one. The widget itself is an iframe from that host, which is what
* the CSP (build/sveltekit-config.ts) runs in mode "hash", which admits an
* external script by host (`script-src https://challenges.cloudflare.com`, web
* flavour only) and never an inline one. The widget itself is an iframe from that host, which is what
* the web policy's `frame-src` is for. The Tauri policy has neither.
*
* Always Cloudflare's exact URL, never a proxied or cached copy: Cloudflare
+18
View File
@@ -0,0 +1,18 @@
import { describe, expect, it } from "vitest";
import { LEGAL_DOCS, legalDocSlug } from "#lib/legal.js";
import { params } from "./params";
/** The matcher as SvelteKit 3 runs it: a Standard Schema over the raw segment. */
async function legaldoc(slug: string) {
return await params.legaldoc["~standard"].validate(slug);
}
describe("params.legaldoc", () => {
it.each(LEGAL_DOCS.map((d) => legalDocSlug(d.path)))("matches the document /legal/%s", async (slug) => {
expect(await legaldoc(slug)).toEqual({ value: slug });
});
it.each(["nope", "", "TOS", "tos.html", "../LICENSE"])("matches no route for /legal/%j", async (slug) => {
expect(await legaldoc(slug)).toHaveProperty("issues");
});
});
+21
View File
@@ -0,0 +1,21 @@
import { defineParams } from "@sveltejs/kit/params";
// `.ts`, not the `.js` every other #lib import uses: `vite build` loads this
// file with Node's own import(), not through Vite, and Node maps no extension.
// Everything it imports must load that way too (lib/legal.ts says so).
import { isLegalDocSlug } from "#lib/legal.ts";
/**
* Route param matchers. SvelteKit 3 reads them from this one file; until then
* each was a file of its own under src/params/.
*/
export const params = defineParams({
/**
* /legal/<slug> matches only a real document.
*
* Without it, /legal/nope was answered by the host's fallback (the
* prerendered dashboard) and hydrated as the doc route with no data.
* Unmatched, it lands in the layout's `page.route.id === null` branch and
* shows the translated 404.
*/
legaldoc: (param) => (isLegalDocSlug(param) ? param : undefined),
});
-11
View File
@@ -1,11 +0,0 @@
import type { ParamMatcher } from "@sveltejs/kit";
import { isLegalDocSlug } from "$lib/legal";
/**
* /legal/<slug> matches only a real document.
*
* Without it, /legal/nope was answered by the host's fallback (the prerendered
* dashboard) and hydrated as the doc route with no data. Unmatched, it lands in
* the layout's `page.route.id === null` branch and shows the translated 404.
*/
export const match: ParamMatcher = (param) => isLegalDocSlug(param);
+2 -2
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from "$app/state";
import ErrorView from "$lib/common/ErrorView.svelte";
import { isChunkLoadError } from "$lib/chunk-error";
import ErrorView from "#lib/common/ErrorView.svelte";
import { isChunkLoadError } from "#lib/chunk-error.js";
// SvelteKit's own error boundary. A 404 from the router, a load() throw, or
// a failed lazy import all land here.
+29 -29
View File
@@ -5,33 +5,33 @@
import { Dialog } from "bits-ui";
import { page } from "$app/state";
import { afterNavigate, goto } from "$app/navigation";
import { i18n } from "$lib/i18n.svelte";
import { theme, welcome, scrollbars } from "$lib/prefs.svelte";
import { consent } from "$lib/consent.svelte";
import { humanCheck } from "$lib/human-check-state.svelte";
import { appReady } from "$lib/app-ready";
import { installPaletteShortcut } from "$lib/palette.svelte";
import { games, installGamesRevalidation } from "$lib/games.svelte";
import { upgradeLegacyHashUrl } from "$lib/legacy-url";
import { recoverFallbackRoute } from "$lib/fallback-route";
import { installExternalLinkInterceptor } from "$lib/external-link-interceptor";
import { checkAndroidUpdate } from "$lib/android-update";
import { purgeTauriServiceWorker, purgeLegacyDataCache } from "$lib/pwa";
import { pwa } from "$lib/pwa-state.svelte";
import { loadAnalytics } from "$lib/analytics";
import { i18n } from "#lib/i18n.svelte.js";
import { theme, welcome, scrollbars } from "#lib/prefs.svelte.js";
import { consent } from "#lib/consent.svelte.js";
import { humanCheck } from "#lib/human-check-state.svelte.js";
import { appReady } from "#lib/app-ready.js";
import { installPaletteShortcut } from "#lib/palette.svelte.js";
import { games, installGamesRevalidation } from "#lib/games.svelte.js";
import { upgradeLegacyHashUrl } from "#lib/legacy-url.js";
import { recoverFallbackRoute } from "#lib/fallback-route.js";
import { installExternalLinkInterceptor } from "#lib/external-link-interceptor.js";
import { checkAndroidUpdate } from "#lib/android-update.js";
import { purgeTauriServiceWorker, purgeLegacyDataCache } from "#lib/pwa.js";
import { pwa } from "#lib/pwa-state.svelte.js";
import { loadAnalytics } from "#lib/analytics.js";
import { pwaInfo } from "virtual:pwa-info";
import PwaIndicator from "$lib/common/PwaIndicator.svelte";
import DesktopUpdateDialog from "$lib/common/DesktopUpdateDialog.svelte";
import { isTauri, isAndroid, openExternal } from "$lib/external-open";
import PwaIndicator from "#lib/common/PwaIndicator.svelte";
import DesktopUpdateDialog from "#lib/common/DesktopUpdateDialog.svelte";
import { isTauri, isAndroid, openExternal } from "#lib/external-open.js";
import { toast } from "svelte-sonner";
import ConsentGate from "$lib/common/ConsentGate.svelte";
import HumanCheck from "$lib/common/HumanCheck.svelte";
import Sidebar from "$lib/layout/Sidebar.svelte";
import Topbar from "$lib/layout/Topbar.svelte";
import CommandPalette from "$lib/common/CommandPalette.svelte";
import BackToTop from "$lib/common/BackToTop.svelte";
import ErrorView from "$lib/common/ErrorView.svelte";
import { clearStaleChunkFlag } from "$lib/chunk-error";
import ConsentGate from "#lib/common/ConsentGate.svelte";
import HumanCheck from "#lib/common/HumanCheck.svelte";
import Sidebar from "#lib/layout/Sidebar.svelte";
import Topbar from "#lib/layout/Topbar.svelte";
import CommandPalette from "#lib/common/CommandPalette.svelte";
import BackToTop from "#lib/common/BackToTop.svelte";
import ErrorView from "#lib/common/ErrorView.svelte";
import { clearStaleChunkFlag } from "#lib/chunk-error.js";
// ?url so Vite returns the fingerprinted path. A hand-typed content hash
// stops matching the moment the font or the bundler changes, and a preload
// that 404s is worse than no preload - the browser still pays for it.
@@ -168,7 +168,7 @@
$effect(() => {
if (!landedOnHome || !consent.hydrated || !appReady() || welcome.seen) return;
landedOnHome = false;
if (page.url.pathname === "/") void goto("/welcome", { replaceState: true });
if (page.url.pathname === "/") void goto("/welcome", { replace: true });
});
// Close the mobile drawer on navigation, or it stays open over the new page.
@@ -189,9 +189,9 @@
* router does know: `page.route.id` is null. That is rendered as a 404 in
* place.
*
* NEVER goto() here. Navigating to an unmatched URL makes SvelteKit fall back
* to a native page load, the host serves index.html again, and the page
* reloads itself forever.
* NEVER goto() here. SvelteKit 3 rejects a goto() to an unmatched URL;
* SvelteKit 2 fell back to a native page load, the host served index.html
* again, and the page reloaded itself forever.
*/
const unmatched = $derived(page.route.id === null);
</script>
+13 -13
View File
@@ -7,19 +7,19 @@
import Trash2 from "@lucide/svelte/icons/trash-2";
import TrendingUp from "@lucide/svelte/icons/trending-up";
import ArrowRight from "@lucide/svelte/icons/arrow-right";
import { games, removedGames } from "$lib/games.svelte";
import { computeKpis, countBy, topByPlayers } from "$lib/stats";
import { i18n } from "$lib/i18n.svelte";
import { formatNumber } from "$lib/utils";
import { appidOf } from "$lib/data-store";
import { headerToCapsule, thumbFallback } from "$lib/image";
import { imgFallback } from "$lib/img-fallback";
import { CHART_PAGES } from "$lib/chart-nav";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import Seo from "$lib/common/Seo.svelte";
import { games, removedGames } from "#lib/games.svelte.js";
import { computeKpis, countBy, topByPlayers } from "#lib/stats.js";
import { i18n } from "#lib/i18n.svelte.js";
import { formatNumber } from "#lib/utils.js";
import { appidOf } from "#lib/data-store.js";
import { headerToCapsule, thumbFallback } from "#lib/image.js";
import { imgFallback } from "#lib/img-fallback.js";
import { CHART_PAGES } from "#lib/chart-nav.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import EChart from "#lib/charts/EChart.svelte";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+8 -8
View File
@@ -8,14 +8,14 @@
import TriangleAlert from "@lucide/svelte/icons/triangle-alert";
import FileText from "@lucide/svelte/icons/file-text";
import Bug from "@lucide/svelte/icons/bug";
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { LEGAL_DOCS, legalDocSlug } from "$lib/legal";
import { REPO_OWNER, REPO_NAME } from "$lib/schema";
import { formatNumber } from "$lib/utils";
import PageHeader from "$lib/common/PageHeader.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { LEGAL_DOCS, legalDocSlug } from "#lib/legal.js";
import { REPO_OWNER, REPO_NAME } from "#lib/schema.js";
import { formatNumber } from "#lib/utils.js";
import PageHeader from "#lib/common/PageHeader.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
const REPO_URL = `https://github.com/${REPO_OWNER}/${REPO_NAME}`;
+11 -11
View File
@@ -6,17 +6,17 @@
import Bot from "@lucide/svelte/icons/bot";
import User from "@lucide/svelte/icons/user";
import Filter from "@lucide/svelte/icons/funnel";
import { Resource } from "$lib/resource.svelte";
import { appReady } from "$lib/app-ready";
import { i18n } from "$lib/i18n.svelte";
import { API_ORIGIN } from "$lib/site";
import { DEFAULT_BRANCH } from "$lib/schema";
import { formatRelativeDate, cn } from "$lib/utils";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Button from "$lib/ui/Button.svelte";
import Seo from "$lib/common/Seo.svelte";
import { Resource } from "#lib/resource.svelte.js";
import { appReady } from "#lib/app-ready.js";
import { i18n } from "#lib/i18n.svelte.js";
import { API_ORIGIN } from "#lib/site.js";
import { DEFAULT_BRANCH } from "#lib/schema.js";
import { formatRelativeDate, cn } from "#lib/utils.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Button from "#lib/ui/Button.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+4 -4
View File
@@ -1,9 +1,9 @@
<script lang="ts">
import ArrowRight from "@lucide/svelte/icons/arrow-right";
import { CHART_PAGES } from "$lib/chart-nav";
import { i18n } from "$lib/i18n.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Seo from "$lib/common/Seo.svelte";
import { CHART_PAGES } from "#lib/chart-nav.js";
import { i18n } from "#lib/i18n.svelte.js";
import PageHeader from "#lib/common/PageHeader.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
</script>
@@ -1,11 +1,11 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import { acLevel, type AcLevel } from "$lib/anti-cheat";
import { countBy } from "$lib/stats";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import { acLevel, type AcLevel } from "#lib/anti-cheat.js";
import { countBy } from "#lib/stats.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
const t = i18n.t;
@@ -3,16 +3,16 @@
import ArrowUp from "@lucide/svelte/icons/arrow-up";
import ArrowDown from "@lucide/svelte/icons/arrow-down";
import ChevronsUpDown from "@lucide/svelte/icons/chevrons-up-down";
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { acLevel, bucketByAntiCheat, type AcLevel } from "$lib/anti-cheat";
import { appidOf } from "$lib/data-store";
import { cn, formatNumber, parseIntSafe } from "$lib/utils";
import type { GameRecord } from "$lib/schema";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Badge, { type BadgeVariant } from "$lib/ui/Badge.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { acLevel, bucketByAntiCheat, type AcLevel } from "#lib/anti-cheat.js";
import { appidOf } from "#lib/data-store.js";
import { cn, formatNumber, parseIntSafe } from "#lib/utils.js";
import type { GameRecord } from "#lib/schema.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import Badge, { type BadgeVariant } from "#lib/ui/Badge.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+8 -8
View File
@@ -1,12 +1,12 @@
<script lang="ts">
import { removedGames } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import { formatNumber } from "$lib/utils";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import EChart from "$lib/charts/EChart.svelte";
import Seo from "$lib/common/Seo.svelte";
import { removedGames } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import { formatNumber } from "#lib/utils.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import EChart from "#lib/charts/EChart.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+5 -5
View File
@@ -1,9 +1,9 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
const t = i18n.t;
+7 -7
View File
@@ -1,11 +1,11 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { countBy } from "$lib/stats";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme } from "$lib/chart-theme";
import { formatNumber } from "$lib/utils";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { games } from "#lib/games.svelte.js";
import { countBy } from "#lib/stats.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme } from "#lib/chart-theme.js";
import { formatNumber } from "#lib/utils.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
const t = i18n.t;
const genres = $derived(countBy(games.data?.records ?? [], (r) => r.genre));
+5 -5
View File
@@ -1,9 +1,9 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
const t = i18n.t;
+6 -6
View File
@@ -1,10 +1,10 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme } from "$lib/chart-theme";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { countBy } from "$lib/stats";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme } from "#lib/chart-theme.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
import { countBy } from "#lib/stats.js";
const t = i18n.t;
+6 -6
View File
@@ -1,10 +1,10 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme } from "$lib/chart-theme";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { parseIntSafe } from "$lib/utils";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme } from "#lib/chart-theme.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
import { parseIntSafe } from "#lib/utils.js";
const t = i18n.t;
+7 -7
View File
@@ -1,11 +1,11 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { parseReviewPercent } from "$lib/utils";
import { reviewBand } from "$lib/games/columns";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
import { parseReviewPercent } from "#lib/utils.js";
import { reviewBand } from "#lib/games/columns.js";
const t = i18n.t;
+7 -7
View File
@@ -1,11 +1,11 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme } from "$lib/chart-theme";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { countBy } from "$lib/stats";
import { SKIP_GENRE_TAGS } from "$lib/schema";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme } from "#lib/chart-theme.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
import { countBy } from "#lib/stats.js";
import { SKIP_GENRE_TAGS } from "#lib/schema.js";
const t = i18n.t;
+6 -6
View File
@@ -1,10 +1,10 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import ChartPage from "$lib/charts/ChartPage.svelte";
import EChart from "$lib/charts/EChart.svelte";
import { countByMonth, monthLabel, releaseYears, runningTotal } from "$lib/stats";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import ChartPage from "#lib/charts/ChartPage.svelte";
import EChart from "#lib/charts/EChart.svelte";
import { countByMonth, monthLabel, releaseYears, runningTotal } from "#lib/stats.js";
const t = i18n.t;
+8 -8
View File
@@ -1,13 +1,13 @@
<script lang="ts">
import Building2 from "@lucide/svelte/icons/building-2";
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { countBy } from "$lib/stats";
import { formatNumber } from "$lib/utils";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Input from "$lib/ui/Input.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { countBy } from "#lib/stats.js";
import { formatNumber } from "#lib/utils.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import Input from "#lib/ui/Input.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+12 -12
View File
@@ -1,18 +1,18 @@
<script lang="ts">
import ArrowLeft from "@lucide/svelte/icons/arrow-left";
import { page } from "$app/state";
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { appidOf } from "$lib/data-store";
import { headerToCapsule, thumbFallback } from "$lib/image";
import { imgFallback } from "$lib/img-fallback";
import { formatNumber, parseReviewPercent } from "$lib/utils";
import { reviewTone } from "$lib/games/columns";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Seo from "$lib/common/Seo.svelte";
import { markRouteRendered } from "$lib/fallback-route";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { appidOf } from "#lib/data-store.js";
import { headerToCapsule, thumbFallback } from "#lib/image.js";
import { imgFallback } from "#lib/img-fallback.js";
import { formatNumber, parseReviewPercent } from "#lib/utils.js";
import { reviewTone } from "#lib/games/columns.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Seo from "#lib/common/Seo.svelte";
import { markRouteRendered } from "#lib/fallback-route.js";
const t = i18n.t;
+3 -3
View File
@@ -6,9 +6,9 @@
import Github from "@lucide/svelte/icons/git-branch";
import CreditCard from "@lucide/svelte/icons/credit-card";
import ExternalLink from "@lucide/svelte/icons/external-link";
import { i18n } from "$lib/i18n.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Seo from "$lib/common/Seo.svelte";
import { i18n } from "#lib/i18n.svelte.js";
import PageHeader from "#lib/common/PageHeader.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { page } from "$app/state";
import ErrorView, { isErrorCode } from "$lib/common/ErrorView.svelte";
import ErrorView, { isErrorCode } from "#lib/common/ErrorView.svelte";
// An unknown code falls back to 404 IN PLACE rather than redirecting: a
// redirect would replace the URL the user was sent, which is exactly the
+1 -1
View File
@@ -1,4 +1,4 @@
import { ERROR_CODES } from "$lib/common/ErrorView.svelte";
import { ERROR_CODES } from "#lib/common/ErrorView.svelte";
import type { EntryGenerator } from "./$types";
/** Prerender one page per known code, so /error/503 is a real static document
+17 -14
View File
@@ -3,19 +3,19 @@
import X from "@lucide/svelte/icons/x";
import Download from "@lucide/svelte/icons/download";
import { page as appPage } from "$app/state";
import { replaceState } from "$app/navigation";
import { games } from "$lib/games.svelte";
import { filters, FILTER_PARAMS, PAGE_SIZES } from "$lib/filters.svelte";
import { i18n } from "$lib/i18n.svelte";
import { buildSearchIndex, applyFilters, applySort, facets } from "$lib/games/filtering";
import { formatNumber } from "$lib/utils";
import { exportCsv, exportJson } from "$lib/export";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import GamesTable from "$lib/games/GamesTable.svelte";
import MobileGameCards from "$lib/games/MobileGameCards.svelte";
import Button from "$lib/ui/Button.svelte";
import Seo from "$lib/common/Seo.svelte";
import { goto } from "$app/navigation";
import { games } from "#lib/games.svelte.js";
import { filters, FILTER_PARAMS, PAGE_SIZES } from "#lib/filters.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { buildSearchIndex, applyFilters, applySort, facets } from "#lib/games/filtering.js";
import { formatNumber } from "#lib/utils.js";
import { exportCsv, exportJson } from "#lib/export.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import GamesTable from "#lib/games/GamesTable.svelte";
import MobileGameCards from "#lib/games/MobileGameCards.svelte";
import Button from "#lib/ui/Button.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
@@ -73,7 +73,10 @@
const timer = setTimeout(() => {
const next = location.pathname + (query ? `?${query}` : "") + location.hash;
if (next !== location.pathname + location.search + location.hash) {
replaceState(next, appPage.state);
// Shallow: the address bar and history entry change, nothing reloads,
// and with no `reset` the search box keeps its focus and the page its
// scroll position.
void goto(next, { shallow: true, replace: true, state: appPage.state });
}
}, 250);
return () => clearTimeout(timer);
+16 -16
View File
@@ -3,28 +3,28 @@
import ExternalLink from "@lucide/svelte/icons/external-link";
import Monitor from "@lucide/svelte/icons/monitor";
import { page } from "$app/state";
import { games, removedGames } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { heroFallback, heroImage, socialImagePath } from "$lib/image";
import { imgFallback } from "$lib/img-fallback";
import { steamWebUrl, steamProtocolUrl } from "$lib/steam-link";
import { isAndroid } from "$lib/external-open";
import { games, removedGames } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { heroFallback, heroImage, socialImagePath } from "#lib/image.js";
import { imgFallback } from "#lib/img-fallback.js";
import { steamWebUrl, steamProtocolUrl } from "#lib/steam-link.js";
import { isAndroid } from "#lib/external-open.js";
import {
formatNumber,
formatRelativeDate,
parseReleaseDate,
parseReviewPercent,
reviewLabel,
} from "$lib/utils";
import { reviewTone } from "$lib/games/columns";
import { extractAppid } from "$lib/data-store";
import { seedScript, toSeed, type GameSeed } from "$lib/game-seed";
import { markRouteRendered } from "$lib/fallback-route";
import { SITE_ORIGIN } from "$lib/site";
import QueryState from "$lib/common/QueryState.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Button from "$lib/ui/Button.svelte";
import Seo from "$lib/common/Seo.svelte";
} from "#lib/utils.js";
import { reviewTone } from "#lib/games/columns.js";
import { extractAppid } from "#lib/data-store.js";
import { seedScript, toSeed, type GameSeed } from "#lib/game-seed.js";
import { markRouteRendered } from "#lib/fallback-route.js";
import { SITE_ORIGIN } from "#lib/site.js";
import QueryState from "#lib/common/QueryState.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Button from "#lib/ui/Button.svelte";
import Seo from "#lib/common/Seo.svelte";
import type { PageData } from "./$types";
let { data }: { data: PageData } = $props();
+10 -10
View File
@@ -7,16 +7,16 @@
import ShieldEllipsis from "@lucide/svelte/icons/shield-ellipsis";
import ArrowRight from "@lucide/svelte/icons/arrow-right";
import type { Component } from "svelte";
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { isEmpty, appidOf } from "$lib/data-store";
import { formatNumber, formatRelativeDate } from "$lib/utils";
import { safeClass } from "$lib/safety";
import type { GameRecord } from "$lib/schema";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { isEmpty, appidOf } from "#lib/data-store.js";
import { formatNumber, formatRelativeDate } from "#lib/utils.js";
import { safeClass } from "#lib/safety.js";
import type { GameRecord } from "#lib/schema.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+4 -4
View File
@@ -2,10 +2,10 @@
import ShieldCheck from "@lucide/svelte/icons/shield-check";
import FileText from "@lucide/svelte/icons/file-text";
import ChevronRight from "@lucide/svelte/icons/chevron-right";
import { i18n } from "$lib/i18n.svelte";
import { LEGAL_DOCS, legalDocSlug } from "$lib/legal";
import PageHeader from "$lib/common/PageHeader.svelte";
import Seo from "$lib/common/Seo.svelte";
import { i18n } from "#lib/i18n.svelte.js";
import { LEGAL_DOCS, legalDocSlug } from "#lib/legal.js";
import PageHeader from "#lib/common/PageHeader.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
@@ -1,6 +1,6 @@
import { error } from "@sveltejs/kit";
import { LEGAL_DOCS, legalDocSlug, legalDocUrl } from "$lib/legal";
import { renderRepoMarkdown } from "$lib/server/markdown";
import { LEGAL_DOCS, legalDocSlug, legalDocUrl } from "#lib/legal.js";
import { renderRepoMarkdown } from "#lib/server/markdown.js";
import type { EntryGenerator, PageServerLoad } from "./$types";
export const prerender = true;
@@ -1,10 +1,10 @@
<script lang="ts">
import ExternalLink from "@lucide/svelte/icons/external-link";
import ArrowLeft from "@lucide/svelte/icons/arrow-left";
import { i18n } from "$lib/i18n.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import { i18n } from "#lib/i18n.svelte.js";
import PageHeader from "#lib/common/PageHeader.svelte";
import type { PageData } from "./$types";
import Seo from "$lib/common/Seo.svelte";
import Seo from "#lib/common/Seo.svelte";
let { data }: { data: PageData } = $props();
+8 -8
View File
@@ -1,13 +1,13 @@
<script lang="ts">
import Building2 from "@lucide/svelte/icons/building-2";
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { countBy } from "$lib/stats";
import { formatNumber } from "$lib/utils";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Input from "$lib/ui/Input.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { countBy } from "#lib/stats.js";
import { formatNumber } from "#lib/utils.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import Input from "#lib/ui/Input.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+12 -12
View File
@@ -1,18 +1,18 @@
<script lang="ts">
import ArrowLeft from "@lucide/svelte/icons/arrow-left";
import { page } from "$app/state";
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { appidOf } from "$lib/data-store";
import { headerToCapsule, thumbFallback } from "$lib/image";
import { imgFallback } from "$lib/img-fallback";
import { formatNumber, parseReviewPercent } from "$lib/utils";
import { reviewTone } from "$lib/games/columns";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Seo from "$lib/common/Seo.svelte";
import { markRouteRendered } from "$lib/fallback-route";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { appidOf } from "#lib/data-store.js";
import { headerToCapsule, thumbFallback } from "#lib/image.js";
import { imgFallback } from "#lib/img-fallback.js";
import { formatNumber, parseReviewPercent } from "#lib/utils.js";
import { reviewTone } from "#lib/games/columns.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Seo from "#lib/common/Seo.svelte";
import { markRouteRendered } from "#lib/fallback-route.js";
const t = i18n.t;
+10 -10
View File
@@ -10,17 +10,17 @@
import EyeOff from "@lucide/svelte/icons/eye-off";
import Table from "@lucide/svelte/icons/table";
import MoveVertical from "@lucide/svelte/icons/move-vertical";
import { pwa } from "$lib/pwa-state.svelte";
import { isTauri } from "$lib/external-open";
import { pwa } from "#lib/pwa-state.svelte.js";
import { isTauri } from "#lib/external-open.js";
import { goto } from "$app/navigation";
import { i18n, LANGUAGE_NAMES, SUPPORTED_LANGUAGES } from "$lib/i18n.svelte";
import { scrollbars, theme, welcome, type ScrollbarMode, type Theme } from "$lib/prefs.svelte";
import { clearCache } from "$lib/cache";
import { games } from "$lib/games.svelte";
import { cn } from "$lib/utils";
import PageHeader from "$lib/common/PageHeader.svelte";
import Button from "$lib/ui/Button.svelte";
import Seo from "$lib/common/Seo.svelte";
import { i18n, LANGUAGE_NAMES, SUPPORTED_LANGUAGES } from "#lib/i18n.svelte.js";
import { scrollbars, theme, welcome, type ScrollbarMode, type Theme } from "#lib/prefs.svelte.js";
import { clearCache } from "#lib/cache.js";
import { games } from "#lib/games.svelte.js";
import { cn } from "#lib/utils.js";
import PageHeader from "#lib/common/PageHeader.svelte";
import Button from "#lib/ui/Button.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+2 -2
View File
@@ -1,4 +1,4 @@
import { SITE_ORIGIN } from "$lib/site";
import { SITE_ORIGIN } from "#lib/site.js";
import { seedAppids } from "virtual:game-seeds";
import { byCodeUnit } from "../../../shared/sort";
@@ -94,7 +94,7 @@ export async function GET() {
// claiming none. The daily data commits do not rebuild the site.
const lastmod = new Date().toISOString().slice(0, 10);
const { LEGAL_DOCS, legalDocSlug } = await import("$lib/legal");
const { LEGAL_DOCS, legalDocSlug } = await import("#lib/legal.js");
const urls = [
..._paths().map((loc) => ({ loc, ...(HINTS[loc] ?? DEFAULT_HINT) })),
...LEGAL_DOCS.map((d) => ({
+10 -10
View File
@@ -1,14 +1,14 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { chartTheme, gridBox } from "$lib/chart-theme";
import { computeKpis, countByMonth, monthLabel } from "$lib/stats";
import { safeClass } from "$lib/safety";
import { formatCompact, formatNumber, parseIntSafe, reviewLabel } from "$lib/utils";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import EChart from "$lib/charts/EChart.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import { computeKpis, countByMonth, monthLabel } from "#lib/stats.js";
import { safeClass } from "#lib/safety.js";
import { formatCompact, formatNumber, parseIntSafe, reviewLabel } from "#lib/utils.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import EChart from "#lib/charts/EChart.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
const records = $derived(games.data?.records ?? []);
+14 -14
View File
@@ -1,18 +1,18 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { topByPlayers } from "$lib/stats";
import { appidOf } from "$lib/data-store";
import { headerToCapsule, thumbFallback } from "$lib/image";
import { imgFallback } from "$lib/img-fallback";
import { formatNumber, parseReviewPercent } from "$lib/utils";
import { reviewTone } from "$lib/games/columns";
import { chartTheme, gridBox } from "$lib/chart-theme";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import EChart from "$lib/charts/EChart.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { topByPlayers } from "#lib/stats.js";
import { appidOf } from "#lib/data-store.js";
import { headerToCapsule, thumbFallback } from "#lib/image.js";
import { imgFallback } from "#lib/img-fallback.js";
import { formatNumber, parseReviewPercent } from "#lib/utils.js";
import { reviewTone } from "#lib/games/columns.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import EChart from "#lib/charts/EChart.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+14 -14
View File
@@ -1,18 +1,18 @@
<script lang="ts">
import { games } from "$lib/games.svelte";
import { i18n } from "$lib/i18n.svelte";
import { topByPlayers } from "$lib/stats";
import { appidOf } from "$lib/data-store";
import { headerToCapsule, thumbFallback } from "$lib/image";
import { imgFallback } from "$lib/img-fallback";
import { formatNumber, parseReviewPercent } from "$lib/utils";
import { reviewTone } from "$lib/games/columns";
import { chartTheme, gridBox } from "$lib/chart-theme";
import QueryState from "$lib/common/QueryState.svelte";
import PageHeader from "$lib/common/PageHeader.svelte";
import EChart from "$lib/charts/EChart.svelte";
import Badge from "$lib/ui/Badge.svelte";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { i18n } from "#lib/i18n.svelte.js";
import { topByPlayers } from "#lib/stats.js";
import { appidOf } from "#lib/data-store.js";
import { headerToCapsule, thumbFallback } from "#lib/image.js";
import { imgFallback } from "#lib/img-fallback.js";
import { formatNumber, parseReviewPercent } from "#lib/utils.js";
import { reviewTone } from "#lib/games/columns.js";
import { chartTheme, gridBox } from "#lib/chart-theme.js";
import QueryState from "#lib/common/QueryState.svelte";
import PageHeader from "#lib/common/PageHeader.svelte";
import EChart from "#lib/charts/EChart.svelte";
import Badge from "#lib/ui/Badge.svelte";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+6 -6
View File
@@ -16,12 +16,12 @@
import RefreshCw from "@lucide/svelte/icons/refresh-cw";
import Languages from "@lucide/svelte/icons/languages";
import ScrollText from "@lucide/svelte/icons/scroll-text";
import { games } from "$lib/games.svelte";
import { welcome } from "$lib/prefs.svelte";
import { i18n, LANGUAGE_NAMES, SUPPORTED_LANGUAGES } from "$lib/i18n.svelte";
import { CONSENT_DOCS, legalDocSlug } from "$lib/legal";
import { cn, formatNumber } from "$lib/utils";
import Seo from "$lib/common/Seo.svelte";
import { games } from "#lib/games.svelte.js";
import { welcome } from "#lib/prefs.svelte.js";
import { i18n, LANGUAGE_NAMES, SUPPORTED_LANGUAGES } from "#lib/i18n.svelte.js";
import { CONSENT_DOCS, legalDocSlug } from "#lib/legal.js";
import { cn, formatNumber } from "#lib/utils.js";
import Seo from "#lib/common/Seo.svelte";
const t = i18n.t;
+1 -1
View File
@@ -3,7 +3,7 @@
* Implementations: web/build/game-seeds.ts, web/build/legal-versions.ts.
*/
declare module "virtual:game-seeds" {
import type { GameSeed } from "$lib/game-seed";
import type { GameSeed } from "#lib/game-seed.js";
/** Every appid with a prerendered page. Empty in the browser and in Tauri. */
export function seedAppids(): string[];
+8 -7
View File
@@ -14,13 +14,14 @@
/*
# NO Content-Security-Policy here.
#
# SvelteKit owns it now, in svelte.config.js under kit.csp, and emits it as a
# <meta> tag carrying the sha256 of the one inline bootstrap script it
# generates per page. A CSP could not live in both places: browsers enforce
# the INTERSECTION of a header policy and a meta policy, so a
# `script-src 'self'` header kept blocking that script no matter what the
# meta allowed - and the whole app rendered its HTML and then failed to
# hydrate. See the comment on kit.csp for the full reasoning.
# SvelteKit owns it now (the `csp` option in build/sveltekit-config.ts)
# and emits it as a <meta> tag carrying the sha256 of the one inline
# bootstrap script it generates per page. A CSP could not live in both
# places: browsers enforce the INTERSECTION of a header policy and a meta
# policy, so a `script-src 'self'` header kept blocking that script no
# matter what the meta allowed - and the whole app rendered its HTML and
# then failed to hydrate. See the comment on that option for the full
# reasoning.
#
# X-Frame-Options below is now load-bearing rather than belt-and-braces:
# `frame-ancestors` is ignored in a meta CSP, so this is what stops framing.
+29 -19
View File
@@ -1,30 +1,40 @@
{
// Generated by SvelteKit from svelte.config.js. It supplies the $lib and
// $app aliases, the right module/target settings, and the include list -
// none of which should be restated here, because SvelteKit changes them
// between versions and a hand-written copy drifts silently.
"extends": "./.svelte-kit/tsconfig.json",
// SvelteKit generates the base config into node_modules/$app on every
// `svelte-kit sync` (which `npm run check` and `build:admin` run first). It
// supplies the $app types and the module/target settings, none of which
// should be restated here, because SvelteKit changes them between versions
// and a hand-written copy drifts silently.
//
// Since SvelteKit 3 the base no longer says WHICH files belong to the app,
// so `include` is ours. It is what SvelteKit 2 generated, minus the Worker:
// src and the Vite config (which pulls in build/), plus build/'s tests.
// worker/ has its own tsconfig.worker.json and must not be checked against
// the DOM lib here.
"extends": "$app/tsconfig",
"compilerOptions": {
// Restored deliberately. Two node_modules-internal clashes need it and
// neither is ours to fix:
// The base sets it as well; it stays here because two declaration-file
// clashes need it and neither is ours to fix (measured with it off,
// 2026-10-26):
// - src/workers/jsonl-parser.ts carries `/// <reference lib="webworker" />`,
// which puts lib.webworker.d.ts and lib.dom.d.ts in one program; they
// declare `self`, `onmessage` and friends with different types.
// - TypeScript resolves `cookie` to the HOISTED 1.1.1 (pulled in by
// wrangler -> miniflare -> youch) while @sveltejs/kit has its own
// nested cookie@0.7.x (package.json `overrides`) and uses that at
// runtime. The type error is a resolution artifact, not a real version
// conflict.
// - echarts-wordcloud's index.d.ts default-imports echarts, whose 6.x
// types have no default export (the package.json override that keeps
// it on echarts 6 is about its runtime, which works).
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
// No "paths" here. SvelteKit generates its own and warns that a
// hand-written one breaks intellisense; the "@" alias is declared in
// svelte.config.js under kit.alias instead, which feeds both the
// generated tsconfig and the bundler.
"types": ["node"]
}
// Replaces the base's list, so its $app/types has to be repeated.
"types": ["$app/types", "node"],
// The `imports` entry of package.json, repeated for `svelte-check --tsgo`.
// TypeScript resolves `#lib/...` through package.json on its own, but
// svelte-check redirects .svelte imports to the declarations it emits only
// through `paths`: without this, every component imported as
// `#lib/....svelte` fell back to the ambient `*.svelte` shim - its props
// unchecked, its module exports missing.
"paths": { "#lib/*": ["./src/lib/*"] }
},
"include": ["src/**/*.js", "src/**/*.ts", "src/**/*.svelte", "vite.config.ts", "build/**/*.test.ts"]
}
+16 -9
View File
@@ -1,7 +1,6 @@
/// <reference types="vitest/config" />
import { defineConfig, type Plugin } from "vite";
import { sveltekit } from "@sveltejs/kit/vite";
import { SvelteKitPWA } from "@vite-pwa/sveltekit";
// Tailwind 4 runs as a Vite plugin instead of a PostCSS plugin;
// tailwind.config.ts and postcss.config.js do not exist.
import tailwindcss from "@tailwindcss/vite";
@@ -10,6 +9,8 @@ import path from "node:path";
import { readFileSync } from "node:fs";
import { gameSeeds } from "./build/game-seeds";
import { legalVersions } from "./build/legal-versions";
import { svelteKitPWA } from "./build/pwa";
import { sveltekitConfig } from "./build/sveltekit-config";
// Version sourced from package.json (single source of truth, matches the Android
// versionName) and exposed to the bundle as `__APP_VERSION__` for the update check.
@@ -18,9 +19,11 @@ const appVersion = JSON.parse(
).version as string;
/**
* True while the Tauri CLI is driving this build. Tauri 2 sets TAURI_ENV_* for
* the process running beforeBuildCommand. Mirrors the same check in
* svelte.config.js.
* True while the Tauri CLI is driving this build.
*
* Tauri 2 sets TAURI_ENV_* for the process running beforeBuildCommand, so
* this needs no extra npm script and no cross-env - which matters, because
* `VAR=1 vite build` in package.json does not work on Windows.
*/
const IS_TAURI = Boolean(process.env.TAURI_ENV_PLATFORM);
@@ -51,8 +54,8 @@ function pwaVirtualStubs(): Plugin {
}
export default defineConfig(({ mode }) => ({
// No `base`. SvelteKit owns the base path (kit.paths), and setting Vite's
// would fight it.
// No `base`. SvelteKit owns the base path (its `paths` option), and setting
// Vite's would fight it.
define: {
__APP_VERSION__: JSON.stringify(appVersion),
// Read by routes/games/[appid]/+page.ts. A route file cannot read
@@ -68,7 +71,9 @@ export default defineConfig(({ mode }) => ({
// show what changed instead of asking for a second full read. Every
// flavour: the packaged apps run the same gate.
legalVersions(),
sveltekit(),
// Adapter, CSP, paths, prerender: build/sveltekit-config.ts (until
// SvelteKit 3, svelte.config.js).
sveltekit(sveltekitConfig(IS_TAURI)),
/**
* WEB ONLY. A service worker registered at tauri.localhost can never be
* updated - Tauri's custom protocol does not satisfy the update
@@ -84,8 +89,10 @@ export default defineConfig(({ mode }) => ({
* lib/pwa.ts removes any worker left behind by an older build.
*/
IS_TAURI && pwaVirtualStubs(),
// After sveltekit(): build/pwa.ts writes the service worker between
// SvelteKit's prerender and its adapter, and relies on this order.
!IS_TAURI &&
SvelteKitPWA({
svelteKitPWA({
// "prompt": a new version waits until the reader chooses to reload
// (lib/common/PwaIndicator.svelte), instead of the page reloading
// itself mid-read. injectRegister false: nothing was ever injected
@@ -125,7 +132,7 @@ export default defineConfig(({ mode }) => ({
maximumFileSizeToCacheInBytes: 6 * 1024 * 1024,
globPatterns: ["**/*.{js,css,html,svg,woff2}"],
// The social card is 145 KB that no VISITOR ever loads - it exists
// for crawlers. @vite-pwa/sveltekit adds every static asset to the
// for crawlers. build/pwa.ts adds every static asset to the
// precache on its own, regardless of globPatterns, so keeping it
// out of every install takes an explicit ignore.
// The prerendered game pages: ~3,650 HTML files, ~120 MB. The glob