release(v3.5.2): dead-code cleanup + knip/vulture tooling (#52)

- Wire in knip (webapp) and vulture (Python) as dead-code detectors
- Remove 8 unused deps, the unwired Tauri scrape-preview scaffold, and
  ~20 unused exports/types across the webapp
- Add docs/THIRD_PARTY.md attributing the dev tooling; trim TAURI.md
- Bump version badges, about.ts, and CHANGELOG to 3.5.2

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 4.7 authored and GitHub committed 2026-05-23 00:42:36 +07:00
1 parent f55eb92fd4
commit 199497a5a6
29 files changed
+1057 -395

No files matched your search

+45
View File
@@ -2,6 +2,51 @@
All notable changes to this project will be documented here.
## [3.5.2] - 2026-05-23 (Dead-code cleanup — knip + vulture)
### Added
- **knip** (v6) wired into the webapp as the unused-files / exports /
dependencies detector — config in [`webapp/knip.json`](webapp/knip.json),
run via `cd webapp && npm run knip`.
- **vulture** configured for the Python pipeline (`[tool.vulture]` in
[`pyproject.toml`](pyproject.toml)) — it catches dead functions, classes, and
attributes that ruff's `F` rules don't.
- **[`docs/THIRD_PARTY.md`](docs/THIRD_PARTY.md)** — a new doc attributing the
dev-only tooling (knip, vulture, ruff, ESLint, TypeScript), cross-linked from
[`docs/ACKNOWLEDGEMENTS.md`](docs/ACKNOWLEDGEMENTS.md).
### Removed
- **8 unused webapp dependencies**: `react-hook-form`, `@hookform/resolvers`,
`zod`, `idb-keyval`, `@radix-ui/react-dropdown-menu`,
`@radix-ui/react-tooltip`, `@tauri-apps/plugin-http`, `@tauri-apps/api`.
- **The unwired Tauri Phase-8b scrape-preview scaffold** —
`webapp/src/lib/tauri-scrape.ts` and `getRuntimeInfo` / `RuntimeInfo` in
[`runtime.ts`](webapp/src/lib/runtime.ts). It was documented but never wired
into any UI; [`webapp/TAURI.md`](webapp/TAURI.md) was trimmed to match.
- **~20 unused webapp exports / types** — dead helpers (`findChunkFor`,
`indexByUrl`, `rawUrl`, `useIndex`, `isIdleExpired`, …), the unused
`EDITABLE_FIELDS` / `READONLY_FIELDS` constants, and 7 unused shadcn/ui
primitive exports. Exports used only inside their own module were demoted
from `export` rather than deleted.
### Changed
- `webapp/src/lib/about.ts` `THIRD_PARTY` array trimmed to match the removed
dependencies.
### Notes
- DX / code-quality only — no runtime behaviour change. `isIdleExpired` was
already dead (nothing called it), so PAT idle auto-lock is unchanged — still
not enforced.
- No Tauri / Rust binary boundary change — `Cargo.toml` and `tauri.conf.json`
stay at `0.1.1`. The Rust `tauri-plugin-http` crate is now unreferenced from
the front-end — a candidate for a future Rust-side cleanup.
- knip + vulture join `npm run lint`, `ruff check`, and `npm audit` as the
standing pre-release QA pass.
## [3.5.1] - 2026-05-20 (Lint cleanup — zero ESLint problems)
### Changed
+1 -1
View File
@@ -1,6 +1,6 @@
# Free Itch.io Games List
[![Version](https://img.shields.io/badge/version-3.5.1-blue.svg)](https://github.com/poli0981/free-games-itchio-list/)
[![Version](https://img.shields.io/badge/version-3.5.2-blue.svg)](https://github.com/poli0981/free-games-itchio-list/)
[![Stars](https://img.shields.io/github/stars/poli0981/free-games-itchio-list?style=social)](https://github.com/poli0981/free-games-itchio-list/stargazers)
[![Forks](https://img.shields.io/github/forks/poli0981/free-games-itchio-list?style=social)](https://github.com/poli0981/free-games-itchio-list/network/members)
[![Last Updated](https://img.shields.io/github/last-commit/poli0981/free-games-itchio-list?label=last%20updated)](https://github.com/poli0981/free-games-itchio-list/commits/main)
+1 -1
View File
@@ -1,6 +1,6 @@
# Danh sách Game Itch.io Miễn Phí
[![Version](https://img.shields.io/badge/version-3.5.1-blue.svg)](https://github.com/poli0981/free-games-itchio-list/)
[![Version](https://img.shields.io/badge/version-3.5.2-blue.svg)](https://github.com/poli0981/free-games-itchio-list/)
[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![English](https://img.shields.io/badge/lang-English-blue.svg)](README.md)
+5 -3
View File
@@ -15,13 +15,15 @@ This repo wouldn't exist without a lot of help — mostly from tools and platfor
The webapp + Tauri desktop build on a stack of open-source libraries — full versioned list with licenses lives on the [About page](https://poli0981.github.io/free-games-itchio-list/app/#/about) and in [`webapp/src/lib/about.ts`](../webapp/src/lib/about.ts) (the `THIRD_PARTY` array). Highlights:
- **Core**: React 19, TypeScript 6, Vite 8, React Router 7, Zustand 5, Zod 4
- **Core**: React 19, TypeScript 6, Vite 8, React Router 7, Zustand 5
- **UI**: Tailwind CSS 3, shadcn/ui (pattern), Radix UI primitives, lucide-react, sonner, class-variance-authority, tailwind-merge, clsx, Recharts
- **Data**: TanStack Query / Table / Virtual, react-hook-form + `@hookform/resolvers`, `@octokit/rest`, `idb-keyval`, `openpgp` (lazy-loaded for in-browser commit signing)
- **Desktop**: Tauri 2, `@tauri-apps/api`, `tauri-plugin-http`, `tauri-plugin-opener`
- **Data**: TanStack Query / Table / Virtual, `@octokit/rest`, `openpgp` (lazy-loaded for in-browser commit signing)
- **Desktop**: Tauri 2, `tauri-plugin-opener`
When you add a new dep to `webapp/package.json`, also add it to the `THIRD_PARTY` array so the About page lists it. House rule documented in [CONTRIBUTING.md §8](../CONTRIBUTING.md#8-webapp-changes-react--ts).
Dev-only tooling — linters and dead-code detectors that never ship in a build — is tracked separately in [`THIRD_PARTY.md`](THIRD_PARTY.md).
## Telegram bot — ingest path
[poli0981/telegram-scraper-bot](https://github.com/poli0981/telegram-scraper-bot) is the operator-side bot that lets contributors batch-submit itch.io URLs through Telegram (see [USER_GUIDE.md](https://github.com/poli0981/telegram-scraper-bot/blob/main/docs/USER_GUIDE.md)). It dispatches the [`bot-ingest.yml`](../.github/workflows/bot-ingest.yml) workflow in this repo — same daily-scrape pipeline, different entry point.
+39
View File
@@ -0,0 +1,39 @@
# Third-party development tooling
Runtime libraries the webapp + desktop app ship with are listed on the
[About page](https://poli0981.github.io/free-games-itchio-list/app/#/about)
and in [`webapp/src/lib/about.ts`](../webapp/src/lib/about.ts) (the
`THIRD_PARTY` array). This file covers the **dev-only** tooling — stuff that
never lands in a build but keeps the code honest.
## Dead-code detection
The tools that stop unused code from quietly piling up:
- **[knip](https://knip.dev)** — MIT. Finds unused files, exports, and
dependencies across the React + TypeScript webapp.
Config: [`webapp/knip.json`](../webapp/knip.json) · Run: `cd webapp && npm run knip`
- **[vulture](https://github.com/jendrikseipp/vulture)** — MIT. Finds dead
code (unused functions, classes, attributes) in the Python pipeline.
Config: `[tool.vulture]` in [`pyproject.toml`](../pyproject.toml) · Run: `vulture`
## Linting & types
Already on the job — and they catch a slice of dead code too:
- **[ruff](https://github.com/astral-sh/ruff)** — MIT. Python linter + import
sorter; flags unused imports and variables.
Config: `[tool.ruff]` in [`pyproject.toml`](../pyproject.toml) · Run: `ruff check scripts/`
- **[ESLint](https://eslint.org)** + **[typescript-eslint](https://typescript-eslint.io)**
— MIT. Webapp linting.
Config: [`webapp/eslint.config.js`](../webapp/eslint.config.js) · Run: `cd webapp && npm run lint`
- **[TypeScript](https://www.typescriptlang.org)** — Apache-2.0. `noUnusedLocals`
and `noUnusedParameters` reject unused locals and parameters at build time.
The rest of the webapp build tooling (Vite, Tailwind, PostCSS, …) lives in
[`webapp/package.json`](../webapp/package.json) under `devDependencies`.
---
Adding a new dev tool? Drop it here so the next person — or AI buddy — knows
what's keeping an eye on the code.
+11 -3
View File
@@ -1,8 +1,9 @@
# Project tooling configuration.
#
# Ruff is the only tool configured here: the repo has no Python build
# system — the scraper pipeline runs the scripts/ modules directly.
# Run it with: ruff check scripts/
# The repo has no Python build system — the scraper pipeline runs the
# scripts/ modules directly. Lint + dead-code tools configured here:
# ruff check scripts/ — style, unused imports/variables
# vulture — dead code (unused functions, classes, attributes)
[tool.ruff]
line-length = 100
@@ -10,3 +11,10 @@ target-version = "py310"
[tool.ruff.lint]
select = ["E", "F", "I", "W", "UP", "B"]
[tool.vulture]
paths = ["scripts", "webapp/scripts"]
min_confidence = 60
# requests.Response.encoding is assigned to force UTF-8 decoding but is read
# internally by requests, so vulture flags the assignment as an unused attribute.
ignore_names = ["encoding"]
+2 -15
View File
@@ -6,10 +6,6 @@ opt-in and skipped when running as a plain web SPA.
## What desktop adds over web
- **No CORS** — `tauri-plugin-http` lets the renderer fetch any whitelisted
URL (itch.io, GitHub API, raw.githubusercontent.com) directly. The
`tauri-scrape.ts` helper uses this to preview a game record without
dispatching the workflow (~5 s vs ~75–120 s).
- **Smaller footprint than Electron** — installer is ~10 MB.
- **Native window chrome** — system tray, OS notifications, etc. (not
enabled yet; can be added in a follow-up).
@@ -60,10 +56,10 @@ installers to a draft GitHub Release. Bump `webapp/package.json` and
## Detecting Tauri at runtime
```ts
import { isTauri, getRuntimeInfo } from '@/lib/runtime'
import { isTauri } from '@/lib/runtime'
if (isTauri()) {
const info = await getRuntimeInfo() // { platform: 'windows', version: '0.1.0' }
// running inside the native desktop shell
}
```
@@ -87,12 +83,3 @@ Then call from the frontend:
const { invoke } = await import('@tauri-apps/api/core')
await invoke<string>('my_thing', { arg: 'hello' })
```
## Roadmap (Phase 8b)
The current scrape preview parses `og:title` / `og:description` / `og:image`
from the HTML in TS. The full 23-field extraction (genre, tags, platforms,
languages, made_with, …) still lives in `scripts/scraper.py` and runs in
CI. Porting that to Rust (using `scraper` crate) is tracked as Phase 8b
and would make the desktop app fully autonomous (no workflow_dispatch
needed for adds).
+7
View File
@@ -0,0 +1,7 @@
{
"$schema": "https://unpkg.com/knip@6/schema.json",
"project": ["src/**/*.{ts,tsx}"],
"paths": {
"@/*": ["./src/*"]
}
}
+929 -193
View File
File diff suppressed because it is too large. Load diff
+2 -8
View File
@@ -7,17 +7,16 @@
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"knip": "knip",
"preview": "vite preview",
"tauri": "tauri",
"tauri:dev": "tauri dev",
"tauri:build": "tauri build"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",
"@octokit/rest": "^22.0.1",
"@radix-ui/react-checkbox": "^1.3.3",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-label": "^2.1.8",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-select": "^2.2.6",
@@ -25,27 +24,21 @@
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-switch": "^1.2.6",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-tooltip": "^1.2.8",
"@tanstack/react-query": "^5.100.9",
"@tanstack/react-query-devtools": "^5.100.9",
"@tanstack/react-table": "^8.21.3",
"@tanstack/react-virtual": "^3.13.24",
"@tauri-apps/api": "^2.11.0",
"@tauri-apps/plugin-http": "^2.5.9",
"@tauri-apps/plugin-opener": "^2.0.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"idb-keyval": "^6.2.2",
"lucide-react": "^1.14.0",
"openpgp": "^6.3.0",
"react": "^19.2.5",
"react-dom": "^19.2.5",
"react-hook-form": "^7.75.0",
"react-router-dom": "^7.14.2",
"recharts": "^3.8.1",
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"zod": "^4.4.2",
"zustand": "^5.0.12"
},
"devDependencies": {
@@ -60,6 +53,7 @@
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-react-refresh": "^0.5.2",
"globals": "^17.5.0",
"knip": "^6.14.2",
"postcss": "^8.5.13",
"tailwindcss": "^3.4.19",
"tailwindcss-animate": "^1.0.7",
-2
View File
@@ -48,5 +48,3 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
},
)
Button.displayName = 'Button'
export { buttonVariants }
-14
View File
@@ -30,23 +30,9 @@ export const CardTitle = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElemen
)
CardTitle.displayName = 'CardTitle'
export const CardDescription = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
),
)
CardDescription.displayName = 'CardDescription'
export const CardContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
),
)
CardContent.displayName = 'CardContent'
export const CardFooter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={cn('flex items-center p-6 pt-0', className)} {...props} />
),
)
CardFooter.displayName = 'CardFooter'
+2 -4
View File
@@ -4,11 +4,9 @@ import { forwardRef, type ComponentPropsWithoutRef, type ElementRef, type HTMLAt
import { cn } from '@/lib/utils'
export const Dialog = DialogPrimitive.Root
export const DialogTrigger = DialogPrimitive.Trigger
export const DialogPortal = DialogPrimitive.Portal
export const DialogClose = DialogPrimitive.Close
const DialogPortal = DialogPrimitive.Portal
export const DialogOverlay = forwardRef<
const DialogOverlay = forwardRef<
ElementRef<typeof DialogPrimitive.Overlay>,
ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
-1
View File
@@ -4,7 +4,6 @@ import { cn } from '@/lib/utils'
export const Popover = PopoverPrimitive.Root
export const PopoverTrigger = PopoverPrimitive.Trigger
export const PopoverAnchor = PopoverPrimitive.Anchor
export const PopoverContent = forwardRef<
ElementRef<typeof PopoverPrimitive.Content>,
-1
View File
@@ -4,7 +4,6 @@ import { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from 'reac
import { cn } from '@/lib/utils'
export const Select = SelectPrimitive.Root
export const SelectGroup = SelectPrimitive.Group
export const SelectValue = SelectPrimitive.Value
export const SelectTrigger = forwardRef<
+3 -8
View File
@@ -1,15 +1,14 @@
import * as DialogPrimitive from '@radix-ui/react-dialog'
import { X } from 'lucide-react'
import { forwardRef, type ComponentPropsWithoutRef, type ElementRef, type HTMLAttributes } from 'react'
import { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from 'react'
import { cva, type VariantProps } from 'class-variance-authority'
import { cn } from '@/lib/utils'
export const Sheet = DialogPrimitive.Root
export const SheetTrigger = DialogPrimitive.Trigger
export const SheetClose = DialogPrimitive.Close
export const SheetPortal = DialogPrimitive.Portal
const SheetPortal = DialogPrimitive.Portal
export const SheetOverlay = forwardRef<
const SheetOverlay = forwardRef<
ElementRef<typeof DialogPrimitive.Overlay>,
ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
@@ -64,10 +63,6 @@ export const SheetContent = forwardRef<
))
SheetContent.displayName = 'SheetContent'
export const SheetHeader = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
<div className={cn('flex flex-col space-y-1 px-4 pb-2 pt-3 text-left', className)} {...props} />
)
export const SheetTitle = forwardRef<
ElementRef<typeof DialogPrimitive.Title>,
ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
-8
View File
@@ -1,18 +1,10 @@
import { useQuery } from '@tanstack/react-query'
import {
loadAllGames,
loadIndex,
loadDeletedLog,
loadCountHistory,
} from '@/lib/github/data-store'
export function useIndex() {
return useQuery({
queryKey: ['db', 'index'],
queryFn: loadIndex,
})
}
export function useAllGames() {
return useQuery({
queryKey: ['db', 'all'],
+1 -7
View File
@@ -8,7 +8,7 @@ export interface ThirdParty {
export const APP = {
name: 'Itch.io Free Games DB',
version: '3.5.1',
version: '3.5.2',
repo: 'https://github.com/poli0981/free-games-itchio-list',
license: 'MIT',
buildDate: typeof __BUILD_DATE__ !== 'undefined' ? __BUILD_DATE__ : 'dev',
@@ -137,7 +137,6 @@ export const THIRD_PARTY: ThirdParty[] = [
{ name: 'Vite', version: '8.0', license: 'MIT', url: 'https://vite.dev', category: 'core' },
{ name: 'React Router', version: '7.14', license: 'MIT', url: 'https://reactrouter.com', category: 'core' },
{ name: 'Zustand', version: '5.0', license: 'MIT', url: 'https://github.com/pmndrs/zustand', category: 'core' },
{ name: 'Zod', version: '4.4', license: 'MIT', url: 'https://zod.dev', category: 'core' },
// UI
{ name: 'Tailwind CSS', version: '3.4', license: 'MIT', url: 'https://tailwindcss.com', category: 'ui' },
@@ -154,16 +153,11 @@ export const THIRD_PARTY: ThirdParty[] = [
{ name: 'TanStack Query', version: '5.100', license: 'MIT', url: 'https://tanstack.com/query', category: 'data' },
{ name: 'TanStack Table', version: '8.21', license: 'MIT', url: 'https://tanstack.com/table', category: 'data' },
{ name: 'TanStack Virtual', version: '3.13', license: 'MIT', url: 'https://tanstack.com/virtual', category: 'data' },
{ name: 'react-hook-form', version: '7.75', license: 'MIT', url: 'https://react-hook-form.com', category: 'data' },
{ name: '@hookform/resolvers', version: '5.2', license: 'MIT', url: 'https://github.com/react-hook-form/resolvers', category: 'data' },
{ name: '@octokit/rest', version: '22.0', license: 'MIT', url: 'https://github.com/octokit/octokit.js', category: 'data' },
{ name: 'idb-keyval', version: '6.2', license: 'Apache-2.0', url: 'https://github.com/jakearchibald/idb-keyval', category: 'data' },
{ name: 'OpenPGP.js', version: '6.3', license: 'LGPL-3.0', url: 'https://openpgpjs.org', category: 'data' },
// Desktop
{ name: 'Tauri', version: '2.x', license: 'Apache-2.0 OR MIT', url: 'https://tauri.app', category: 'desktop' },
{ name: '@tauri-apps/api', version: '2.11', license: 'Apache-2.0 OR MIT', url: 'https://tauri.app', category: 'desktop' },
{ name: 'tauri-plugin-http', version: '2', license: 'Apache-2.0 OR MIT', url: 'https://tauri.app', category: 'desktop' },
{ name: 'tauri-plugin-opener', version: '2', license: 'Apache-2.0 OR MIT', url: 'https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/opener', category: 'desktop' },
{ name: 'tauri-plugin-single-instance', version: '2', license: 'Apache-2.0 OR MIT', url: 'https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/single-instance', category: 'desktop' },
]
+1 -1
View File
@@ -10,7 +10,7 @@ interface FileWithSha {
sha: string
}
export async function readFileWithSha(octokit: Octokit, path: string): Promise<FileWithSha> {
async function readFileWithSha(octokit: Octokit, path: string): Promise<FileWithSha> {
const { data } = await octokit.repos.getContent({
owner: REPO.owner,
repo: REPO.name,
+2 -18
View File
@@ -8,11 +8,11 @@ import type {
import { MAX_PER_FILE, PATHS } from '../config'
import { fetchRaw } from './raw'
export async function loadIndex(): Promise<GameDbIndex> {
async function loadIndex(): Promise<GameDbIndex> {
return fetchRaw<GameDbIndex>(PATHS.index)
}
export async function loadChunk(filename: string): Promise<Game[]> {
async function loadChunk(filename: string): Promise<Game[]> {
return fetchRaw<Game[]>(PATHS.chunk(filename))
}
@@ -46,19 +46,3 @@ export function rebalance(games: Game[]): ChunkPlan[] {
games: games.slice(i * MAX_PER_FILE, (i + 1) * MAX_PER_FILE),
}))
}
export function findChunkFor(games: Game[], url: string): {
chunkIndex: number
inChunkIndex: number
} | null {
const allIndex = games.findIndex((g) => g.url === url)
if (allIndex === -1) return null
return {
chunkIndex: Math.floor(allIndex / MAX_PER_FILE),
inChunkIndex: allIndex % MAX_PER_FILE,
}
}
export function indexByUrl(games: Game[]): Map<string, Game> {
return new Map(games.map((g) => [g.url, g]))
}
-4
View File
@@ -8,7 +8,3 @@ export async function fetchRaw<T>(path: string): Promise<T> {
}
return res.json() as Promise<T>
}
export function rawUrl(path: string): string {
return `${RAW_BASE}/${path}`
}
+2 -2
View File
@@ -3,7 +3,7 @@ import { useAuth } from '@/stores/auth'
import { useGpg } from '@/stores/gpg'
import { usePrefs } from '@/stores/prefs'
export interface CommitIdentity {
interface CommitIdentity {
name: string
email: string
}
@@ -24,7 +24,7 @@ export interface CommitSigner {
* For GPG-signed commits to show as "Verified" on GitHub, the email MUST match a UID in the
* uploaded public key — that's why we prefer the GPG key's email over the GitHub noreply.
*/
export function resolveCommitIdentity(): CommitIdentity {
function resolveCommitIdentity(): CommitIdentity {
const prefs = usePrefs.getState()
const gpg = useGpg.getState()
const user = useAuth.getState().user
+1 -1
View File
@@ -1,4 +1,4 @@
export interface CommitIdentity {
interface CommitIdentity {
name: string
email: string
}
-11
View File
@@ -6,14 +6,3 @@ export function isTauri(): boolean {
if (typeof window === 'undefined') return false
return '__TAURI_INTERNALS__' in (window as unknown as TauriInternals)
}
export interface RuntimeInfo {
platform: string
version: string
}
export async function getRuntimeInfo(): Promise<RuntimeInfo | null> {
if (!isTauri()) return null
const { invoke } = await import('@tauri-apps/api/core')
return invoke<RuntimeInfo>('runtime_info')
}
-54
View File
@@ -1,54 +0,0 @@
import { isTauri } from './runtime'
import type { Game } from '@/types/game'
export interface ScrapeResult {
partial: Partial<Game>
raw_html_length: number
}
/**
* Tauri-only: fetch an itch.io page directly (no CORS) via tauri-plugin-http
* and extract a partial Game record.
*
* The full 23-field extraction lives in Python (scripts/scraper.py); this is
* a minimal "preview" so the desktop user sees something before dispatching
* the workflow. Phase 8b can port the rest of scraper.py to Rust.
*/
export async function tauriScrapePreview(url: string): Promise<ScrapeResult> {
if (!isTauri()) throw new Error('Tauri-only feature (run via npm run tauri dev)')
const { fetch } = await import('@tauri-apps/plugin-http')
const res = await fetch(url, {
method: 'GET',
headers: { 'User-Agent': 'Mozilla/5.0 (free-games-itchio-webapp)' },
})
if (!res.ok) throw new Error(`Fetch failed: ${res.status} ${res.statusText}`)
const html = await res.text()
return { partial: parsePartial(html, url), raw_html_length: html.length }
}
function pickMeta(html: string, property: string): string | undefined {
const re = new RegExp(`<meta[^>]+property=["']${property}["'][^>]+content=["']([^"']+)["']`, 'i')
const m = html.match(re)
return m?.[1]
}
function pickJsonLdName(html: string): string | undefined {
const m = html.match(/<script[^>]+type=["']application\/ld\+json["'][^>]*>([\s\S]+?)<\/script>/i)
if (!m) return undefined
try {
const data = JSON.parse(m[1])
if (Array.isArray(data)) return data[0]?.name
return data.name
} catch {
return undefined
}
}
function parsePartial(html: string, url: string): Partial<Game> {
return {
url,
name: pickJsonLdName(html) ?? pickMeta(html, 'og:title') ?? '',
description: pickMeta(html, 'og:description') ?? '',
thumbnail: pickMeta(html, 'og:image') ?? '',
}
}
+1 -8
View File
@@ -1,9 +1,8 @@
import { create } from 'zustand'
import { usePrefs } from './prefs'
const PAT_STORAGE_KEY = 'webapp.pat.encrypted'
export interface GitHubUserInfo {
interface GitHubUserInfo {
login: string
avatar_url: string
name?: string | null
@@ -32,12 +31,6 @@ export const useAuth = create<AuthState>()((set) => ({
set({ hasStoredPat: !!localStorage.getItem(PAT_STORAGE_KEY) }),
}))
export function isIdleExpired(unlockedAt: number | null): boolean {
if (unlockedAt === null) return true
const timeoutMs = usePrefs.getState().idleTimeoutMs
return Date.now() - unlockedAt > timeoutMs
}
export function readEncryptedPat(): string | null {
return localStorage.getItem(PAT_STORAGE_KEY)
}
+1 -2
View File
@@ -1,10 +1,9 @@
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
export type Density = 'compact' | 'normal'
type Density = 'compact' | 'normal'
export const IDLE_TIMEOUT_OPTIONS = [5, 15, 30, 60, 120] as const
export type IdleTimeoutMin = (typeof IDLE_TIMEOUT_OPTIONS)[number]
export const NOTIFICATION_DURATION_OPTIONS = [2_000, 4_000, 6_000, 10_000] as const
+1 -1
View File
@@ -1,6 +1,6 @@
import { create } from 'zustand'
export interface UndoEntry {
interface UndoEntry {
id: string
label: string
timestamp: number
-24
View File
@@ -47,27 +47,3 @@ export interface ChunkPlan {
name: string
games: Game[]
}
export const EDITABLE_FIELDS = ['safe_virus', 'notes', 'nsfw'] as const
export type EditableField = (typeof EDITABLE_FIELDS)[number]
export const READONLY_FIELDS = [
'url',
'name',
'dev',
'description',
'genre',
'status',
'publisher',
'release_date',
'rating',
'rating_count',
'average_session',
'thumbnail',
'tags',
'platforms',
'languages',
'inputs',
'made_with',
] as const
export type ReadonlyField = (typeof READONLY_FIELDS)[number]