Add webapp Phase 8: Tauri 2 desktop wrapper scaffold

The same React build can now ship as a native Win/macOS/Linux app via
Tauri 2. Web users still get the GitHub Pages SPA; desktop users get
a ~10 MB installer that can scrape itch.io directly without CORS.

src-tauri/:
- Cargo.toml: tauri 2 + tauri-plugin-http 2, edition 2021. Release
  profile uses panic=abort, lto=true, opt-level='s', strip — minimizes
  the bundled binary.
- tauri.conf.json: window 1280x800 (min 900x600), bundle targets all
  platforms, identifier com.poli0981.free-games-itchio-webapp.
- src/main.rs + src/lib.rs: minimal builder + one Tauri command
  (runtime_info) so the frontend can confirm desktop mode.
- capabilities/default.json: scopes the http plugin to itch.io,
  img.itch.zone, api.github.com, raw.githubusercontent.com.

Frontend plumbing:
- lib/runtime.ts: isTauri() probes window.__TAURI_INTERNALS__ to
  branch features at runtime. getRuntimeInfo() lazy-imports
  @tauri-apps/api/core only on desktop, so web bundles aren't bloated.
- lib/tauri-scrape.ts: tauriScrapePreview(url) uses the http plugin to
  fetch an itch.io page and pulls og:title / og:description / og:image
  out of the HTML. Full 23-field extraction stays in scripts/scraper.py
  and runs in CI; porting to Rust is tracked as Phase 8b in TAURI.md.
- Sidebar gains a small "Desktop mode (Tauri)" badge above the theme
  toggle when running native.
- vite.config.ts: when TAURI_ENV_PLATFORM is set, build to ./dist (not
  ../docs/app), drop sourcemaps, and target ES2022 — the bundled
  WebView2/WKWebView/WebKitGTK all support modern JS.
- package.json scripts: tauri / tauri:dev / tauri:build.

CI:
- .github/workflows/release_desktop.yml: builds for macOS (universal),
  Ubuntu 22.04, and Windows on tag v* via tauri-apps/tauri-action,
  caches cargo with Swatinem/rust-cache, installs Linux WebKit deps,
  and uploads the bundle to a draft GitHub Release.

Docs:
- webapp/TAURI.md: prereqs (rustup + platform deps), how to dev, how
  to build installers, how to add new Rust commands, roadmap to a
  full Rust scrape (Phase 8b).

.gitignore picks up the Cargo target/, generated gen/, and Cargo.lock
under src-tauri.

Note: Local `npm run tauri:dev` requires a Rust toolchain
(https://rustup.rs); the GitHub Actions workflow installs it
automatically. The web build still works without Rust installed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 4.7 committed 2026-05-04 09:00:37 +07:00
1 parent d89955013e
commit 91afd4ecf9
16 files changed
+641 -2

No files matched your search

+71
View File
@@ -0,0 +1,71 @@
name: Release desktop installers (Tauri)
on:
push:
tags: ['v*']
workflow_dispatch:
jobs:
build-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest'
args: '--target universal-apple-darwin'
- platform: 'ubuntu-22.04'
args: ''
- platform: 'windows-latest'
args: ''
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
cache-dependency-path: webapp/package-lock.json
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: webapp/src-tauri
- name: Install Linux deps
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
build-essential \
libssl-dev
- name: Install npm deps
working-directory: webapp
run: npm ci
- name: Build Tauri app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: webapp
tagName: ${{ github.ref_name }}
releaseName: 'Itch.io Free Games DB ${{ github.ref_name }}'
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}
+3
View File
@@ -1,6 +1,9 @@
/docs/app/
/webapp/node_modules/
/webapp/dist/
/webapp/src-tauri/target/
/webapp/src-tauri/gen/
/webapp/src-tauri/Cargo.lock
.idea/*
cmake-build-*/
+98
View File
@@ -0,0 +1,98 @@
# Tauri desktop wrapper
The webapp can also ship as a native desktop app (Windows / macOS / Linux)
through Tauri 2. The same React build is reused; the desktop runtime is
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).
## Local prerequisites
1. **Rust toolchain** (stable). Install via <https://rustup.rs>.
2. **Platform deps**:
- **Windows**: WebView2 ships with Windows 11 already. On Windows 10
install via <https://developer.microsoft.com/microsoft-edge/webview2/>.
- **macOS**: Xcode Command Line Tools (`xcode-select --install`).
- **Linux** (Debian/Ubuntu):
```sh
sudo apt install libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
```
## Run dev mode
```sh
cd webapp
npm install
npm run tauri:dev
```
This starts the Vite dev server and launches a native window pointing at it.
HMR works the same as plain web dev.
## Build native installers
```sh
cd webapp
npm run tauri:build
```
Outputs:
- Windows: `webapp/src-tauri/target/release/bundle/msi/*.msi` and `nsis/*.exe`
- macOS: `webapp/src-tauri/target/release/bundle/dmg/*.dmg`
- Linux: `webapp/src-tauri/target/release/bundle/{appimage,deb}/*`
## CI builds
`.github/workflows/release_desktop.yml` builds for all three platforms when
a `v*` tag is pushed (or via `workflow_dispatch`) and attaches the
installers to a draft GitHub Release. Bump `webapp/package.json` and
`webapp/src-tauri/Cargo.toml` together, tag, and push.
## Detecting Tauri at runtime
```ts
import { isTauri, getRuntimeInfo } from '@/lib/runtime'
if (isTauri()) {
const info = await getRuntimeInfo() // { platform: 'windows', version: '0.1.0' }
}
```
The sidebar shows a small "Desktop mode (Tauri)" badge when running native.
## Adding new Rust commands
`src-tauri/src/lib.rs` already exposes `runtime_info`. To add another:
```rust
#[tauri::command]
fn my_thing(arg: String) -> String { ... }
// inside run():
.invoke_handler(tauri::generate_handler![runtime_info, my_thing])
```
Then call from the frontend:
```ts
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).
+254
View File
@@ -25,6 +25,8 @@
"@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",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"idb-keyval": "^6.2.2",
@@ -41,6 +43,7 @@
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@tauri-apps/cli": "^2.11.0",
"@types/node": "^24.12.2",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
@@ -2338,6 +2341,257 @@
"url": "https://github.com/sponsors/tannerlinsley"
}
},
"node_modules/@tauri-apps/api": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.11.0.tgz",
"integrity": "sha512-7CinYODhky9lmO23xHnUFv0Xt43fbtWMyxZcLcRBlFkcgXKuEirBvHpmtJ89YMhyeGcq20Wuc47Fa4XjyniywA==",
"license": "Apache-2.0 OR MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
}
},
"node_modules/@tauri-apps/cli": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.11.0.tgz",
"integrity": "sha512-W5Wbuqsb2pHFPTj4TaRNKTj5rwXhDShPiLSY9T18y4ouSR/NNCptAEFxFsBtyNRgL6Vs1a/q9LzfqqYzEwC+Jw==",
"dev": true,
"license": "Apache-2.0 OR MIT",
"bin": {
"tauri": "tauri.js"
},
"engines": {
"node": ">= 10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
},
"optionalDependencies": {
"@tauri-apps/cli-darwin-arm64": "2.11.0",
"@tauri-apps/cli-darwin-x64": "2.11.0",
"@tauri-apps/cli-linux-arm-gnueabihf": "2.11.0",
"@tauri-apps/cli-linux-arm64-gnu": "2.11.0",
"@tauri-apps/cli-linux-arm64-musl": "2.11.0",
"@tauri-apps/cli-linux-riscv64-gnu": "2.11.0",
"@tauri-apps/cli-linux-x64-gnu": "2.11.0",
"@tauri-apps/cli-linux-x64-musl": "2.11.0",
"@tauri-apps/cli-win32-arm64-msvc": "2.11.0",
"@tauri-apps/cli-win32-ia32-msvc": "2.11.0",
"@tauri-apps/cli-win32-x64-msvc": "2.11.0"
}
},
"node_modules/@tauri-apps/cli-darwin-arm64": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.11.0.tgz",
"integrity": "sha512-UfMeDNlgIP252rm/KSTuu8yHatPua5TjtUEUf+jyIzVwBNcIl7Ywkdpfj+e5jVVg3EfCTp+4gwuL1dNpgF8clg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-darwin-x64": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.11.0.tgz",
"integrity": "sha512-lY1+aPlgyMN7vgjtCdQ3+WODfZkebAcxnrCrO0HjqDpKSXieDkrJbimqeaoM4RwhTSrCLRHfVYiYrfE5E131tg==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.11.0.tgz",
"integrity": "sha512-5uCP0AusgN3NrKC8EpkuJwjek1k8pEffBdugJSpXPey/QGbPEb8vZ542n/giJ2mZPjMSllDkdhG2QIDpBY4PpQ==",
"cpu": [
"arm"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-gnu": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.11.0.tgz",
"integrity": "sha512-loDPqtRHMSbIcrH2VBd4GgHoQlF7jJnrZj7MxA2lj1cixS/jEgMAPFqj83U6Wvjete4HfYplbE/gCpSFifA9jw==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-musl": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.11.0.tgz",
"integrity": "sha512-DtSE8ZBlB9H+L+eHkfZ3myt00EVEyAB3e41juEHoE2qT88fgVlJvyrwa9SZYc/xTwCS9TnmK+R84tpg+ZsAg7Q==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-riscv64-gnu": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-riscv64-gnu/-/cli-linux-riscv64-gnu-2.11.0.tgz",
"integrity": "sha512-5QdgS4LD+kntClI1aj2JmwjW38LosNXxwCe8viIHEwqYIWuMPdNEIau6/cLogI38Yzx9DnfCPRfEWLyI+5li8Q==",
"cpu": [
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-gnu": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.11.0.tgz",
"integrity": "sha512-5UynPXo3Zq9khjVdAbD+YogeLltdVUeOah2ioSIM3tu6H7wY9vMy6rgGJhv9r5R8ZXmk9GttMippdqYJWrnLnA==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-musl": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.11.0.tgz",
"integrity": "sha512-CNz7fHbApz1Zyhhq73jtGn9JqgNEV/lIWnTnUo6h6ujw+mHsTmkLszvJSM8W6JBaDjNpTTFr/RSNoVL5FMwcTg==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-arm64-msvc": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.11.0.tgz",
"integrity": "sha512-K+br+VXZ+Xx0n/9FdWohpW5Ugq+2FQUpJScqcPl1hTxXfh3fgjYgt4qA2NgrjlJo+zZPNrmUMl+NLvm0ufEqBQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-ia32-msvc": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.11.0.tgz",
"integrity": "sha512-OFV+s3MLZnd75zl0ZAFU5riMpGK4waUEA8ZDuijDsnkU0btz/gHhqh5jVlOn8thyvgdtT3Xyoxqo099MMifH3g==",
"cpu": [
"ia32"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-x64-msvc": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.11.0.tgz",
"integrity": "sha512-AeDTWBd2cOZ6TX133BWsoo+LutG9o0JRcgjMsIfLE13ZugpgCMv/2dJbUiBGeRvbPOGin5A3aYmsArPVV6ZSHQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/plugin-http": {
"version": "2.5.9",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-http/-/plugin-http-2.5.9.tgz",
"integrity": "sha512-lCiY0+vs4HvIUSvZrBs8TC3TiCB0MOPRmiUjTq4prW7SlcJE2jdLeT6KBsJrT9Tlplufl7W1pY6SFAO3gCWxDA==",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.11.0"
}
},
"node_modules/@tybys/wasm-util": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz",
+7 -1
View File
@@ -7,7 +7,10 @@
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
"preview": "vite preview",
"tauri": "tauri",
"tauri:dev": "tauri dev",
"tauri:build": "tauri build"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",
@@ -27,6 +30,8 @@
"@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",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"idb-keyval": "^6.2.2",
@@ -43,6 +48,7 @@
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@tauri-apps/cli": "^2.11.0",
"@types/node": "^24.12.2",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
+3
View File
@@ -0,0 +1,3 @@
/target/
/gen/
Cargo.lock
+30
View File
@@ -0,0 +1,30 @@
[package]
name = "free-games-itchio-webapp"
version = "0.1.0"
description = "Itch.io free games catalog browser & editor"
authors = ["poli0981"]
license = "MIT"
repository = "https://github.com/poli0981/free-games-itchio-list"
edition = "2021"
rust-version = "1.77"
[lib]
name = "free_games_itchio_webapp_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-http = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
[profile.release]
panic = "abort"
codegen-units = 1
lto = true
incremental = false
opt-level = "s"
strip = true
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
@@ -0,0 +1,19 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Default capabilities for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"http:default",
{
"identifier": "http:default",
"allow": [
{ "url": "https://*.itch.io/*" },
{ "url": "https://img.itch.zone/*" },
{ "url": "https://api.github.com/*" },
{ "url": "https://raw.githubusercontent.com/*" }
]
}
]
}
+24
View File
@@ -0,0 +1,24 @@
use serde::Serialize;
#[derive(Serialize)]
struct RuntimeInfo {
platform: String,
version: String,
}
#[tauri::command]
fn runtime_info() -> RuntimeInfo {
RuntimeInfo {
platform: std::env::consts::OS.to_string(),
version: env!("CARGO_PKG_VERSION").to_string(),
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_http::init())
.invoke_handler(tauri::generate_handler![runtime_info])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
+6
View File
@@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
free_games_itchio_webapp_lib::run();
}
+42
View File
@@ -0,0 +1,42 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Itch.io Free Games DB",
"version": "0.1.0",
"identifier": "com.poli0981.free-games-itchio-webapp",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:5173",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "Itch.io Free Games DB",
"width": 1280,
"height": 800,
"minWidth": 900,
"minHeight": 600,
"resizable": true,
"fullscreen": false
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"category": "Utility",
"shortDescription": "Browse and edit the free Itch.io games catalog",
"longDescription": "Desktop wrapper for the free-games-itchio-list webapp. Adds local-network scrape (no CORS) and works offline-first."
}
}
+6
View File
@@ -12,6 +12,7 @@ import {
} from 'lucide-react'
import { ThemeToggle } from '@/components/theme-toggle'
import { useAuth } from '@/stores/auth'
import { isTauri } from '@/lib/runtime'
import { cn } from '@/lib/utils'
interface NavItem {
@@ -73,6 +74,11 @@ export function Sidebar() {
))}
</nav>
<div className="space-y-2 border-t p-3">
{isTauri() && (
<div className="rounded-md bg-secondary px-2 py-1 text-xs text-secondary-foreground">
Desktop mode (Tauri)
</div>
)}
<ThemeToggle />
<a
href="https://github.com/poli0981/free-games-itchio-list"
+19
View File
@@ -0,0 +1,19 @@
interface TauriInternals {
__TAURI_INTERNALS__?: unknown
}
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
@@ -0,0 +1,54 @@
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') ?? '',
}
}
+2 -1
View File
@@ -10,7 +10,8 @@ export default defineConfig({
build: {
outDir: isTauri ? 'dist' : '../docs/app',
emptyOutDir: true,
sourcemap: true,
sourcemap: !isTauri,
target: isTauri ? 'es2022' : 'es2020',
chunkSizeWarningLimit: 600,
rollupOptions: {
output: {