Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f156d1f2c | ||
|
|
79be06b804 | ||
|
|
b4e32eac63 | ||
|
|
f8ada5944a | ||
|
|
ca0b795a0d | ||
|
|
89c0e76c2c | ||
|
|
61281c5815 | ||
|
|
7caf4180e9 | ||
|
|
521ca559d5 | ||
|
|
2f84586cf1 | ||
|
|
6f95d292e6 | ||
|
|
9554dcc7af |
No files matched your search
@@ -0,0 +1,89 @@
|
||||
name: Release Android
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Tag to build (e.g. v0.29.0). The manifests must already carry this version."
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.event.inputs.tag || github.ref }}
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "17"
|
||||
|
||||
- uses: android-actions/setup-android@v3
|
||||
|
||||
- name: Install Android NDK (r27 LTS)
|
||||
run: sdkmanager "ndk;27.3.13750724"
|
||||
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
|
||||
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
src-tauri/target
|
||||
key: ${{ runner.os }}-android-cargo-${{ hashFiles('src-tauri/Cargo.lock') }}
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- name: Install Tauri CLI
|
||||
run: cargo install tauri-cli --version "^2" --locked
|
||||
|
||||
- name: Decode keystore
|
||||
env:
|
||||
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||
run: echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.jks"
|
||||
|
||||
- name: Write keystore.properties
|
||||
env:
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
|
||||
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
|
||||
run: |
|
||||
{
|
||||
echo "storeFile=$RUNNER_TEMP/release.jks"
|
||||
echo "storePassword=$ANDROID_STORE_PASSWORD"
|
||||
echo "keyAlias=$ANDROID_KEY_ALIAS"
|
||||
echo "keyPassword=$ANDROID_KEY_PASSWORD"
|
||||
} > src-tauri/gen/android/keystore.properties
|
||||
|
||||
- name: Build signed APK
|
||||
env:
|
||||
# Pin NDK_HOME to the exact version we installed above — the runner may
|
||||
# ship a different default NDK that ANDROID_NDK_ROOT would point at.
|
||||
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.3.13750724
|
||||
run: cargo tauri android build --apk
|
||||
|
||||
- name: Upload APK to draft release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
|
||||
draft: true
|
||||
files: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -11,3 +11,14 @@ coverage/
|
||||
.claude/
|
||||
src-tauri/target/
|
||||
app-icon.png
|
||||
|
||||
# Android (Tauri gen) — the generated Gradle project source IS committed, but
|
||||
# never the signing secrets, machine-local files, or build artifacts.
|
||||
*.jks
|
||||
*.keystore
|
||||
src-tauri/gen/android/keystore.properties
|
||||
src-tauri/gen/android/local.properties
|
||||
src-tauri/gen/android/.gradle/
|
||||
src-tauri/gen/android/.idea/
|
||||
src-tauri/gen/android/build/
|
||||
src-tauri/gen/android/app/build/
|
||||
@@ -2,6 +2,139 @@
|
||||
|
||||
All notable changes to YTDescGen ship as tagged releases on `main`.
|
||||
|
||||
## v0.29.1 — 2026-06-17
|
||||
|
||||
A UI/UX hotfix for **mobile viewport overflow**. On Android and narrow web
|
||||
mobile (~360–400px) the **Batch** and **Profile** screens overran the viewport
|
||||
horizontally — rows laid out side-by-side on desktop never collapsed to a stack
|
||||
on small screens. This release makes those rows responsive and sweeps a few
|
||||
adjacent overflow spots. Layout-only: no logic, store, or i18n changes, and
|
||||
desktop layout is byte-for-byte unchanged (every change is gated behind the
|
||||
`sm` breakpoint).
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Batch page fits mobile** ([src/pages/BatchPage.tsx](src/pages/BatchPage.tsx)) — the part-range row (Start / End / Generate) stacks vertically below `sm` with a full-width Generate button, and the result-card copy-button rows wrap instead of overflowing.
|
||||
- **Profile page fits mobile** ([src/pages/ProfilesPage.tsx](src/pages/ProfilesPage.tsx)) — the tab pill and the Export/Import buttons drop onto separate rows below `sm`; the Profile / Preset / Template cards ([ProfileCard](src/components/profiles/ProfileCard.tsx), [PresetCard](src/components/presets/PresetCard.tsx), [TemplateCard](src/components/templates/TemplateCard.tsx)) move their action buttons below the content and let long names wrap (`min-w-0`) instead of shoving the buttons off-screen.
|
||||
- **Adjacent mobile overflow swept** — responsive padding + a wrapping header on [Settings](src/pages/SettingsPage.tsx) (its Import/Export row shows on Android, where `IS_TAURI` is true), the video-settings selector grid collapses to one column below `sm` ([VideoSettingsForm](src/components/editor/VideoSettingsForm.tsx)), and modals are pinned to `calc(100% - 2rem)` so they never exceed the viewport ([Modal](src/components/ui/Modal.tsx)).
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Layout-only className changes across 8 components. typecheck, lint, locale validation (937/542), all **513 tests**, and the production build pass; verified live at 375 px and 1280 px with zero horizontal overflow on Batch, Profiles, Settings, and Editor.
|
||||
- Five manifests bumped 0.29.0 → 0.29.1 (`package-lock.json`, which had drifted at 0.28.0, is resynced to 0.29.1).
|
||||
|
||||
## v0.29.0 — 2026-06-15
|
||||
|
||||
Adds an **Android build** — an installable, sideloadable signed `.apk` built
|
||||
from the same Tauri 2 codebase as the desktop apps. No app rewrite: Tauri 2
|
||||
ships Android support, the crate was already `cdylib`/`staticlib` with a
|
||||
`#[cfg_attr(mobile, …)]` entry point, and the Android launcher icons were
|
||||
already in the repo. The work was making the Rust shell compile for mobile,
|
||||
routing file export through the WebView on Android, and wiring a signed-APK CI
|
||||
job that publishes the APK alongside the desktop binaries.
|
||||
|
||||
### Added
|
||||
|
||||
- **Android APK target** — `cargo tauri android init` + `cargo tauri android build --apk` produce a signed, sideloadable APK. The generated Gradle project lives at [src-tauri/gen/android](src-tauri/gen/android) (committed so signing/manifest edits persist); secrets (`keystore.properties`, `*.jks`) and build artifacts are gitignored.
|
||||
- **Requires Android 11+ (minSdk 30)** ([src-tauri/tauri.conf.json](src-tauri/tauri.conf.json) `bundle.android.minSdkVersion`, [build.gradle.kts](src-tauri/gen/android/app/build.gradle.kts)) — raised from Tauri's default 24 (Android 7) to API 30. Android 11+ covers the large majority of active devices and keeps a modern, auto-updating System WebView plus Google Play system/Play-services security updates — even though Google's OS-level security bulletins for Android 11–13 have now ended (12 in 2025, 13 in early 2026). `targetSdk` stays at 36 (Android 16).
|
||||
- **APK signing config** ([src-tauri/gen/android/app/build.gradle.kts](src-tauri/gen/android/app/build.gradle.kts)) — a `release` `signingConfigs` block reads `keystore.properties`, guarded by `if (exists())` so keystore-less debug / contributor builds still work (they produce an unsigned release build instead of failing).
|
||||
- **Android release CI** ([.github/workflows/release-android.yml](.github/workflows/release-android.yml)) — on a `v*` tag (or `workflow_dispatch`), an `ubuntu-latest` job sets up JDK 17 + Android SDK/NDK + the four Rust android targets, decodes the keystore from repo secrets, builds the signed APK, and uploads it to the same draft release as the desktop binaries. Needs four secrets: `ANDROID_KEYSTORE_BASE64`, `ANDROID_STORE_PASSWORD`, `ANDROID_KEY_PASSWORD`, `ANDROID_KEY_ALIAS`.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Rust shell is now mobile-aware** ([src-tauri/src/lib.rs](src-tauri/src/lib.rs)) — the tray icon, single-instance plugin, hide-to-tray and exit-prevention logic are gated behind `#[cfg(desktop)]`; the four cross-platform plugins (dialog / fs / opener / shell) and all six file commands register on every platform. Desktop behaviour is byte-for-byte unchanged (`cargo check` clean).
|
||||
- **`tauri-plugin-single-instance` is desktop-only** ([src-tauri/Cargo.toml](src-tauri/Cargo.toml)) — moved under `[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]` so it is never compiled into the Android library.
|
||||
- **File export is mobile-aware** ([src/utils/platform.ts](src/utils/platform.ts), [src/utils/file-ops.ts](src/utils/file-ops.ts)) — a new `IS_MOBILE` flag routes `saveFile()` (log export) through the in-WebView blob download on Android (lands in Downloads), since the native save dialog + `std::fs` path write is unreliable under Android scoped storage. Settings / profile / preset JSON export + import already use blob download / `<input type=file>`, which work as-is in the Android WebView.
|
||||
|
||||
### Fixed
|
||||
|
||||
These two surfaced during on-device testing of the Android build:
|
||||
|
||||
- **External links now open on Android** ([src/utils/open-external.ts](src/utils/open-external.ts), [src/main.tsx](src/main.tsx)) — legal-doc / donate / repo / social links did nothing on a real device. On-device debugging showed why: a real tap on `<a target="_blank">` makes the Android WebView fire its native `onCreateWindow`, which Tauri tries to satisfy via the shell plugin's `open` — there is no such binary on Android, so it throws an uncaught *"Scoped shell IO error"* and nothing opens (JS `preventDefault` does **not** stop that native path). Fix (Tauri-only; the web build keeps native `target="_blank"`): strip `target="_blank"` from external anchors (a `MutationObserver` covers React re-renders) so `onCreateWindow` never fires, and intercept the click in the **capture** phase, routing the URL through the `opener` plugin (`openUrl` → system browser). `opener:default` already grants `allow-open-url`, so no capability change was needed. Verified end-to-end on an Android 13 emulator (tap → Chrome opens, no shell error).
|
||||
- **No more black screen on older Android WebViews** ([src/utils/uuid.ts](src/utils/uuid.ts)) — `generateId()` called `crypto.randomUUID()`, which only exists in Chromium/WebView **92+**. It runs at module load (the log store's `CURRENT_SESSION_ID`), so on a stale WebView (e.g. the Chromium 91 some emulator images ship) it threw during boot and black-screened the whole app. It now falls back to a manual RFC 4122 v4 built on `crypto.getRandomValues`. As defence-in-depth, Tauri builds also set `build.target: "es2020"` ([vite.config.ts](vite.config.ts)) so the bundle's *syntax* stays within reach of older WebViews (the web build keeps Vite's modern default).
|
||||
|
||||
### Under the hood
|
||||
|
||||
- **+4 tests (509 → 513)** — [tests/utils/uuid.test.ts](tests/utils/uuid.test.ts) locks down the `generateId()` v4 shape and both fallback paths (no `randomUUID`, no `crypto` at all) so the WebView-91 black screen can't regress. The rest is build/infra plus small guards. Storage (`appDataDir()` via the six file commands) and localStorage persistence both work unchanged on Android (the app's private data dir is writable with `std::fs`).
|
||||
- Five manifests bumped 0.28.0 → 0.29.0.
|
||||
|
||||
## v0.28.0 — 2026-06-13
|
||||
|
||||
Adds a first-run **legal consent gate**. Before the app is usable, the user
|
||||
reviews the Terms of Use, Privacy Policy, Disclaimer, and License (all already
|
||||
published at the repo root) and ticks a single "I agree" box. Acceptance is
|
||||
recorded and only re-prompts when the terms version changes — so it is a
|
||||
one-time step in normal use, and naturally re-appears in a fresh / incognito
|
||||
browser. On Windows desktop, the installer additionally shows a license page.
|
||||
|
||||
### Added
|
||||
|
||||
- **Legal consent gate** ([src/components/ConsentGate.tsx](src/components/ConsentGate.tsx), [src/config/legal.ts](src/config/legal.ts)) — a full-screen, non-dismissible screen rendered in place of the router until consent is recorded. Lists the four legal docs as links (open in the browser) + one combined agree checkbox; Continue is disabled until checked. Version-based re-prompt via `CURRENT_TERMS_VERSION` + `needsConsent()`; acceptance persists in the existing settings record (`legalConsentVersion` + timestamp) — **no cookie, no new storage key**.
|
||||
- **About → Legal section** ([src/pages/AboutPage.tsx](src/pages/AboutPage.tsx)) — the License/Terms/Privacy/Disclaimer docs are now linked in-app (previously only the License was), reusing the shared `LEGAL_DOCS` list.
|
||||
- **Windows installer license page** ([src-tauri/tauri.conf.json](src-tauri/tauri.conf.json), [src-tauri/installer-license.txt](src-tauri/installer-license.txt)) — `bundle.licenseFile` shows an "accept the terms" page in the MSI/NSIS installers. (macOS `.app`/Linux packages have no interactive license step — they rely on the in-app gate.)
|
||||
- **Accessible `Checkbox` primitive** ([src/components/ui/Checkbox.tsx](src/components/ui/Checkbox.tsx)) — a real `<input type="checkbox">` styled with theme tokens, distinct from the existing on/off `Toggle`.
|
||||
- **60 new locale strings** (10 keys × 6 languages: `consentGate.*` + `about.legalHeading`) + [`_schema.json`](src/i18n/locales/_schema.json); validator now expects 937 ui keys per locale (927 → 937).
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Persisted theme is now applied on boot** ([src/main.tsx](src/main.tsx)) — `index.html` hardcodes `class="dark"`, and previously only the Header toggle wrote the theme class, so a light-theme user saw a brief dark flash on every cold start (and the new gate, which renders before the app shell, would have shown in the wrong theme). The persisted theme is now applied synchronously before first paint.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- **+9 tests (500 → 509)** — [tests/config/legal.test.ts](tests/config/legal.test.ts) (the `needsConsent` version logic + `LEGAL_DOCS` shape; a `NaN`/Infinity version re-shows the gate) and two `legalConsentVersion` back-fill / coercion cases in [tests/store/settings-heal.test.ts](tests/store/settings-heal.test.ts).
|
||||
- Consent state is **additive** — `legalConsentVersion` / `legalConsentAt` join `SettingsData`, `initialSettings`, `extractData`, and `healSettings` (which coerces a malformed value to `0` so a corrupt file re-shows the gate, never skips it). **No persist version bump** (stays at 10).
|
||||
- The gate is a boot-time blocker but stays inside the root `ErrorBoundary`, behind a single boolean — a render error degrades to the designed error page, not a black screen.
|
||||
- Web bundle: the gate + Checkbox + legal config + English strings add ~4 kB min to the main chunk (local Rollup measure); the shipped size comes from CI's vite 8 / Rolldown build.
|
||||
- Five manifests bumped 0.27.1 → 0.28.0.
|
||||
|
||||
## v0.27.1 — 2026-06-13
|
||||
|
||||
Security/dependency release. Resolves the 4 high-severity `esbuild` advisories
|
||||
deferred from v0.27.0 by upgrading `vite` 7 → 8. The advisories
|
||||
([GHSA-gv7w-rqvm-qjhr](https://github.com/advisories/GHSA-gv7w-rqvm-qjhr),
|
||||
[GHSA-g7r4-m6w7-qqqr](https://github.com/advisories/GHSA-g7r4-m6w7-qqqr)) affect
|
||||
`esbuild` `0.17.0 – 0.28.0`; the fix lives in `esbuild` 0.28.1, which only
|
||||
`vite` 8 pulls (`vite` 7.3.3 pins `esbuild ^0.27.0` and cannot reach it). They
|
||||
only ever affected the local dev server, never the shipped static bundle. No
|
||||
feature or behaviour changes — `npm audit` now reports **0 vulnerabilities**.
|
||||
|
||||
### Security / dependencies
|
||||
|
||||
- **`vite` `^7.3.3` → `^8.0.16`** — the only release line whose `esbuild`
|
||||
constraint reaches the patched 0.28.1.
|
||||
- **`@vitejs/plugin-react` `^4.3.0` → `^5.2.0`** — the vite-8-compatible major.
|
||||
Stays on the 5.x line (peer `vite: ^4 || ^5 || ^6 || ^7 || ^8`); 6.x is the
|
||||
Rolldown/react-compiler variant and would pull extra peers, so it was avoided.
|
||||
- **`tsx` `^4.16.0` → `^4.22.4`** — 4.22+ is the first `tsx` on patched
|
||||
`esbuild ~0.28.0` (resolves to 0.28.1). Used only by `validate:locales` /
|
||||
`generate:locale`.
|
||||
- `vitest` 4.1.8 already supports `vite` 8 (peer `^6 || ^7 || ^8`) — unchanged.
|
||||
- The tree now hoists a single `esbuild@0.28.1`; `npm audit` → 0 high.
|
||||
|
||||
### Changed
|
||||
|
||||
- **`manualChunks` object form → function form** ([vite.config.ts](vite.config.ts))
|
||||
— **vite 8 bundles with Rolldown** (replacing Rollup), which only accepts the
|
||||
function form of `manualChunks` (the object form was a Rollup-only API). The
|
||||
same three vendor chunks (`react`, `router`, `i18n`) are reproduced via
|
||||
anchored `[\\/]node_modules[\\/]…` regexes so `react-router*` and
|
||||
`react-i18next` don't get swept into the `react` chunk. This is the only
|
||||
source change the upgrade required.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Full gate chain green on vite 8: `typecheck`, `lint`, `knip`,
|
||||
`validate:locales` (927/542), `test:run` (**500/500**), `build`. `npm run dev`
|
||||
(port 5173, matching the Tauri `devUrl`) and `npm run preview` (4173) both
|
||||
serve. The Tauri-context frontend build (`TAURI_ENV_PLATFORM` set) still
|
||||
switches `base` to `/` correctly; `tauri.conf.json` `devUrl`/`frontendDist`
|
||||
are unchanged and compatible.
|
||||
- Web bundle (Rolldown): entry chunk 165.3 kB / 46.3 kB gzip, `react` 133.4 kB,
|
||||
`i18n` 57.9 kB, `router` 23.4 kB — all well under the 500 kB budget. Chunk
|
||||
sizes are not directly comparable to the v0.27.0 Rollup numbers (different
|
||||
bundler, different chunking heuristics).
|
||||
- Five manifests bumped 0.27.0 → 0.27.1.
|
||||
|
||||
## v0.27.0 — 2026-06-13
|
||||
|
||||
Adds a designed, internationalized **error-page system**. A mistyped hash
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
- **Repository**: `github.com/poli0981/youtube-generator`
|
||||
- **License**: Apache-2.0 (see `LICENSE` + `NOTICE`)
|
||||
- **Primary Language**: TypeScript
|
||||
- **Stack**: React 18 + Vite 7 + Tailwind CSS 3 + Zustand + Tauri 2 (desktop)
|
||||
- **Stack**: React 18 + Vite 8 + Tailwind CSS 3 + Zustand + Tauri 2 (desktop)
|
||||
- **Target Platforms**: Web (GitHub Pages), Desktop (Windows/macOS/Linux via Tauri)
|
||||
|
||||
## Tech Stack
|
||||
@@ -15,7 +15,7 @@
|
||||
| Layer | Technology | Why |
|
||||
|-------|-----------|-----|
|
||||
| Framework | React 18 | Familiar from F2P tracker dashboard |
|
||||
| Build | Vite 5 | Fast HMR, clean config |
|
||||
| Build | Vite 8 | Fast HMR, Rolldown bundler |
|
||||
| Language | TypeScript (strict) | Type safety for template engine |
|
||||
| Styling | Tailwind CSS 3 | Utility-first, fast iteration |
|
||||
| State | Zustand + persist middleware | Simple, localStorage/file persistence |
|
||||
|
||||
@@ -50,6 +50,8 @@ YouTube oEmbed, the Steam store API, Twitch helix, and similar services are **no
|
||||
|
||||
The web version uses **`localStorage`**, not cookies. No cookie is set by the application. GitHub Pages itself may issue a session cookie at the platform level — that is GitHub's, not ours, and is governed by [GitHub's Privacy Statement](https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement).
|
||||
|
||||
The first-run consent acknowledgement (added in v0.28.0) is recorded **inside the existing settings record** — a `legalConsentVersion` number plus a local timestamp — not as a separate cookie or storage key. It never leaves your device.
|
||||
|
||||
## Children's Privacy
|
||||
|
||||
This application is not directed at children under 13 and does not knowingly process any personal data from anyone.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
**YouTube Gameplay Description Generator** — an offline-first template engine for Gameplay No Commentary YouTube channels.
|
||||
|
||||
Generate YouTube titles, descriptions, and tags in six languages with one click. Save channel, rig, and game presets to skip repetitive data entry. Works in the browser (GitHub Pages) or as a ~8 MB native desktop app (Tauri).
|
||||
Generate YouTube titles, descriptions, and tags in six languages with one click. Save channel, rig, and game presets to skip repetitive data entry. Works in the browser (GitHub Pages), as a ~8 MB native desktop app (Windows / macOS / Linux), or as an installable Android APK — all from one Tauri 2 codebase.
|
||||
|
||||
[](./LICENSE)
|
||||
[](./docs/DEVELOPMENT.md)
|
||||
@@ -33,6 +33,7 @@ Built for the gameplay no-commentary niche — especially horror / scary games
|
||||
- **Batch mode** — generate metadata for all parts of a series in one pass.
|
||||
- **Cross-post captions** — a dedicated **Social** tab re-packages the same YouTube source into short-form captions for **TikTok** (4,000-char), **Instagram Reels**, and **Facebook Reels** — title, rig, content warnings, copyright, thanks, and hashtags (game + genre + curated per-platform popular tags). Single + bulk modes, per-platform character limits with smart overflow trimming, and JSON import/export.
|
||||
- **Desktop app** — Windows, macOS & Linux native binaries via Tauri (~8 MB).
|
||||
- **Android app** — installable, sideloadable `.apk` built from the same Tauri 2 codebase. **Requires Android 11+** (tested 11–16; real-device test on Android 12). Grab it from [Releases](https://github.com/poli0981/youtube-generator/releases) and enable "Install unknown apps" to sideload.
|
||||
- **Mobile-responsive web** — drawer navigation, touch-sized controls, iOS-safe text-input behavior. Tested down to 360 × 640.
|
||||
- **100% offline** — no server, no telemetry, no account. See [PRIVACY.md](./PRIVACY.md).
|
||||
|
||||
@@ -52,6 +53,16 @@ npm run tauri:build
|
||||
# Output: src-tauri/target/release/bundle/{msi,deb,dmg,app}
|
||||
```
|
||||
|
||||
Android build (`.apk`) — requires the Android SDK + NDK + a JDK:
|
||||
|
||||
```bash
|
||||
cargo tauri android init # one-time; generates src-tauri/gen/android
|
||||
cargo tauri android build --apk
|
||||
# Output: src-tauri/gen/android/app/build/outputs/apk/universal/release/
|
||||
```
|
||||
|
||||
See [`docs/PACKAGING.md`](./docs/PACKAGING.md#android-apk-packaging) for the SDK/NDK setup and signing steps.
|
||||
|
||||
Full development setup, IDE config, and troubleshooting: see [`docs/DEVELOPMENT.md`](./docs/DEVELOPMENT.md). Vietnamese version: [`docs/i18n/vi/DEVELOPMENT.md`](./docs/i18n/vi/DEVELOPMENT.md).
|
||||
|
||||
## Use Cases
|
||||
@@ -68,7 +79,7 @@ Nothing leaves your device. No analytics, no telemetry, no tracking. The web ver
|
||||
|
||||
## Tech Stack
|
||||
|
||||
React 18 · TypeScript (strict) · Vite 7 · Tailwind CSS 3 · Zustand · i18next · Tauri 2 (Rust stable).
|
||||
React 18 · TypeScript (strict) · Vite 8 · Tailwind CSS 3 · Zustand · i18next · Tauri 2 (Rust stable).
|
||||
|
||||
Architecture overview: [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md).
|
||||
|
||||
@@ -83,7 +94,7 @@ Architecture overview: [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md).
|
||||
| [Roadmap](./docs/ROADMAP.md) | Development phases. |
|
||||
| [Tech Spec](./docs/TECH-SPEC.md) | Implementation details and configs. |
|
||||
| [i18n Guide](./docs/I18N.md) | Adding new locales. |
|
||||
| [Packaging](./docs/PACKAGING.md) | Tauri release builds and signing. |
|
||||
| [Packaging](./docs/PACKAGING.md) | Tauri desktop + Android release builds and signing. |
|
||||
| [Contributing](./CONTRIBUTING.md) | PR process, commit conventions, auto-ignore rules. |
|
||||
| [Security](./SECURITY.md) | Reporting vulnerabilities. |
|
||||
| [Privacy](./PRIVACY.md) | Data handling (TL;DR: none). |
|
||||
|
||||
@@ -23,7 +23,7 @@ Install in this order:
|
||||
|
||||
| Tool | Version | Why |
|
||||
| --- | --- | --- |
|
||||
| **Node.js** | `>= 22.0.0` | Vite 7 dropped support for older Node. Use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm). |
|
||||
| **Node.js** | `>= 22.12.0` | Vite 8 requires Node `^20.19` or `>= 22.12`. Use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm). |
|
||||
| **npm** | bundled with Node 22 | The project uses npm; `pnpm` and `yarn` are not tested. |
|
||||
| **Rust** | stable, `>= 1.78` | Required for the Tauri desktop build. Install via [rustup](https://rustup.rs/). |
|
||||
| **Python** | `3.12` | Optional — only needed for some Tauri platform tooling on Windows. |
|
||||
|
||||
@@ -250,6 +250,23 @@ interface HistoryEntry {
|
||||
| Offline | Full functionality without internet |
|
||||
| Global Hotkey | System-wide hotkey to open app (optional) |
|
||||
|
||||
## 📱 Android App (v0.29)
|
||||
|
||||
An installable, sideloadable `.apk` built from the same Tauri 2 codebase — no
|
||||
separate mobile project. Build with `cargo tauri android build --apk`; see
|
||||
[PACKAGING.md](./PACKAGING.md#android-apk-packaging).
|
||||
|
||||
| Feature | Description |
|
||||
|---------|-------------|
|
||||
| Same codebase | One Tauri 2 project produces web, desktop, and Android |
|
||||
| Min version | Android 11+ (minSdk 30); `targetSdk` 36 (Android 16) |
|
||||
| Tested | Android 11 → 16 (emulators); real device on Android 12 |
|
||||
| Signed APK | Self-signed release APK for sideloading; CI publishes it to GitHub Releases |
|
||||
| Responsive UI | Drawer navigation, touch-sized controls, safe-area insets |
|
||||
| File export | Routed through the WebView download (lands in Downloads) on Android |
|
||||
| Persistence | App-private data dir (`appDataDir()`) + localStorage; works offline |
|
||||
| No tray | Desktop-only tray / single-instance are `#[cfg(desktop)]`-gated out |
|
||||
|
||||
## 🚦 Error Pages & Offline (v0.27)
|
||||
|
||||
A single reusable, fully-localized `ErrorPage` component (`src/components/errors/`)
|
||||
@@ -270,6 +287,21 @@ in every locale (en/vi/ja/es/ko/zh).
|
||||
- **Non-blocking offline banner** — a dismissible bottom strip; the app stays
|
||||
fully usable offline, and a toast confirms when the connection returns.
|
||||
|
||||
## ⚖️ Legal & Consent (v0.28)
|
||||
|
||||
A first-run **consent gate** (`src/components/ConsentGate.tsx`, backed by the
|
||||
pure `src/config/legal.ts`) blocks the app until the user reviews the legal
|
||||
documents and ticks one "I agree" checkbox.
|
||||
|
||||
| Aspect | Behaviour |
|
||||
|--------|-----------|
|
||||
| Documents | Terms of Use, Privacy Policy, Disclaimer, License — linked to the GitHub-hosted copies (open in the browser); also surfaced in About → Legal |
|
||||
| Acceptance | One combined checkbox; Continue disabled until checked |
|
||||
| Persistence | Stored in the existing settings record (`legalConsentVersion` + timestamp) — **no cookie, no new storage key** |
|
||||
| Re-prompt | Version-based — only when `CURRENT_TERMS_VERSION` is raised (terms changed); also re-shows in fresh / incognito storage |
|
||||
| Desktop | Same in-app gate on Windows/macOS/Linux, **plus** a license-acceptance page in the Windows MSI/NSIS installer (`bundle.licenseFile`) |
|
||||
| Layout | Full-screen, non-dismissible, theme- and locale-aware (all 6 languages) |
|
||||
|
||||
## 🔌 Future Extension Points
|
||||
|
||||
| Extension | Description | Effort |
|
||||
|
||||
@@ -108,6 +108,15 @@ This creates `src-tauri/` directory.
|
||||
}
|
||||
```
|
||||
|
||||
> **Installer license page (v0.28).** The real `src-tauri/tauri.conf.json`
|
||||
> sets `bundle.licenseFile: "installer-license.txt"` (path relative to
|
||||
> `src-tauri/`). Tauri shows that file as an "accept the terms" page in the
|
||||
> **Windows MSI/NSIS** installers. macOS `.app`/`.dmg` and the Linux packages
|
||||
> have no interactive license step, so they rely on the app's first-run
|
||||
> consent gate instead. If a WiX/MSI build ever rejects the `.txt`, switch to
|
||||
> the per-bundler keys (`bundle.windows.wix.licenseFile` wants `.rtf`,
|
||||
> `bundle.windows.nsis.licenseFile` accepts `.txt`).
|
||||
|
||||
### 3. Rust Backend (src-tauri/src/main.rs)
|
||||
|
||||
```rust
|
||||
@@ -265,6 +274,142 @@ Linux runners install `libwebkit2gtk-4.1-dev`, `libgtk-3-dev`, `libayatana-appin
|
||||
|
||||
**Backfill for pre-workflow tags:** `v0.8.0` and `v0.8.1` predate the multi-platform matrix and only have local Windows builds. To attach binaries retroactively, build manually then `gh release create v0.8.0 --notes-file CHANGELOG.md path/to/*.msi …`.
|
||||
|
||||
## Android (.apk) Packaging
|
||||
|
||||
YTDescGen also builds an installable Android APK from the **same** Tauri 2
|
||||
codebase — there is no separate mobile project. Tauri 2 ships Android support;
|
||||
the crate is already `cdylib`/`staticlib` with a `#[cfg_attr(mobile, …)]` entry
|
||||
point, and the Android launcher icons live in `src-tauri/icons/android/`. The
|
||||
desktop-only tray / single-instance / hide-to-tray logic in `src-tauri/src/lib.rs`
|
||||
is gated behind `#[cfg(desktop)]` so the library compiles for Android.
|
||||
|
||||
### Requirements & tested versions
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Minimum OS** | **Android 11** (API level 30, `minSdk 30`). The APK will not install below this. |
|
||||
| **Target OS** | **Android 16** (API level 36, `targetSdk 36`). |
|
||||
| **Architectures** | Universal APK — `arm64-v8a`, `armeabi-v7a`, `x86`, `x86_64`. |
|
||||
| **Tested** | **Android 11 → 16.** The v0.29.0 build was verified on Android emulators across this range **and on a real device running Android 12** (the maintainer's phone). |
|
||||
|
||||
Where the value lives: `bundle.android.minSdkVersion` in
|
||||
[`src-tauri/tauri.conf.json`](../src-tauri/tauri.conf.json) is the source of
|
||||
truth used by `tauri android init`; the generated
|
||||
`gen/android/app/build.gradle.kts` carries the baked `minSdk = 30` — edit that
|
||||
directly if you change the floor without re-running `init`.
|
||||
|
||||
**Why Android 11 is the floor (rationale):**
|
||||
|
||||
- **Coverage.** Android 11+ accounts for the large majority of active devices in
|
||||
2026 (Android 14/15 alone are the two biggest slices, and 11–13 together still
|
||||
hold a sizeable share). Going lower buys few extra users at growing compat cost.
|
||||
- **A modern, patched WebView.** The app renders entirely in the system WebView,
|
||||
whose minimum is Android 10. On Android 11+ the WebView auto-updates via Google
|
||||
Play, so the rendering/JS engine stays current and patched. This is exactly why
|
||||
the **real-device test on Android 12 worked**, while a *stale* Android-12
|
||||
emulator stuck on WebView 91 showed a black screen (the `crypto.randomUUID`
|
||||
boot crash) — that class of bug is fixed in v0.29.0 and is moot on an
|
||||
up-to-date WebView.
|
||||
- **Security upkeep.** Even though Google's *OS-level* monthly security bulletins
|
||||
for Android 11–13 have ended (Android 12 in 2025, Android 13 in early 2026),
|
||||
Android 11+ keeps receiving security updates for the components that matter to a
|
||||
sandboxed WebView app: Google Play system updates (Project Mainline), Google
|
||||
Play services, and System WebView. Requiring strict OS-bulletin support would
|
||||
mean Android 14+, which would drop more than half of users.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Android SDK** — platform-tools, a platform (e.g. `android-34`/`android-36`), build-tools. Install via Android Studio or the command-line tools.
|
||||
- **Android NDK** — r27 LTS recommended (e.g. `27.3.13750724`).
|
||||
- **JDK 17** — Android Studio's bundled JBR works (`…/Android Studio/jbr`).
|
||||
- **Rust android targets**:
|
||||
```bash
|
||||
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
|
||||
```
|
||||
|
||||
Set these environment variables before any `android` command (PowerShell shown):
|
||||
|
||||
```powershell
|
||||
$env:ANDROID_HOME = "C:\Users\<you>\AppData\Local\Android\Sdk"
|
||||
$env:NDK_HOME = "C:\Users\<you>\AppData\Local\Android\Sdk\ndk\27.3.13750724"
|
||||
$env:JAVA_HOME = "C:\Jetbrains\Android Studio\jbr" # or any JDK 17
|
||||
```
|
||||
|
||||
### Initialize (one-time)
|
||||
|
||||
```bash
|
||||
cargo tauri android init
|
||||
```
|
||||
|
||||
Generates the Gradle project under `src-tauri/gen/android/` — **committed** to
|
||||
the repo so the signing block and any manifest edits persist. It pulls launcher
|
||||
icons from `src-tauri/icons/android/` and sets `applicationId =
|
||||
com.skullmute.ytdescgen`. Treat `init` as a one-time step: re-running it
|
||||
overwrites hand edits like the signing config below, so only re-run it if a
|
||||
Tauri upgrade requires regenerating the project (then re-apply the signing edit).
|
||||
|
||||
### Signing (one-time)
|
||||
|
||||
Sideloaded APKs must be signed. Create a self-signed release keystore and keep
|
||||
it **outside** the repo:
|
||||
|
||||
```powershell
|
||||
& "$env:JAVA_HOME\bin\keytool.exe" -genkeypair -v `
|
||||
-keystore C:\keys\ytdescgen-release.jks `
|
||||
-keyalg RSA -keysize 2048 -validity 10000 -alias ytdescgen
|
||||
```
|
||||
|
||||
> ⚠️ **Back this keystore up.** If you lose it you can never publish an update
|
||||
> that installs over an existing copy — Android rejects a changed signature.
|
||||
|
||||
Create `src-tauri/gen/android/keystore.properties` (gitignored):
|
||||
|
||||
```properties
|
||||
storeFile=C:/keys/ytdescgen-release.jks
|
||||
storePassword=<store-password>
|
||||
keyAlias=ytdescgen
|
||||
keyPassword=<key-password>
|
||||
```
|
||||
|
||||
`app/build.gradle.kts` carries a `release` `signingConfigs` block that reads this
|
||||
file, guarded by `if (exists())` — a missing keystore yields an *unsigned*
|
||||
release build rather than a hard failure (handy for contributors).
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
cargo tauri android build --apk
|
||||
# → src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
|
||||
```
|
||||
|
||||
- `--apk` produces an APK. **Without it Tauri builds an `.aab`** App Bundle for the Play Store, which cannot be sideloaded.
|
||||
- `cargo tauri android build --apk --target aarch64` builds an arm64-only APK (smaller download; covers virtually all modern phones).
|
||||
- The build runs `npm run build` first (the `beforeBuildCommand`), then Gradle. The first build takes several minutes (Rust × up to 4 ABIs + a cold Gradle).
|
||||
- For on-device iteration with hot reload: `cargo tauri android dev`.
|
||||
|
||||
Install on a device: copy the APK over (or `adb install -r <apk>`) and enable
|
||||
"Install unknown apps" for the source app.
|
||||
|
||||
### CI
|
||||
|
||||
[.github/workflows/release-android.yml](../.github/workflows/release-android.yml)
|
||||
builds and signs the APK on a `v*` tag (or `workflow_dispatch`) and attaches it
|
||||
to the same draft GitHub Release as the desktop binaries. It needs four repo
|
||||
secrets:
|
||||
|
||||
| Secret | Value |
|
||||
|---|---|
|
||||
| `ANDROID_KEYSTORE_BASE64` | base64 of the `.jks` (`base64 -w0 ytdescgen-release.jks`) |
|
||||
| `ANDROID_STORE_PASSWORD` | keystore store password |
|
||||
| `ANDROID_KEY_PASSWORD` | key password |
|
||||
| `ANDROID_KEY_ALIAS` | `ytdescgen` |
|
||||
|
||||
### App-level changes for Android
|
||||
|
||||
- **`src-tauri/src/lib.rs`** — tray / single-instance / hide-to-tray / exit-prevention are `#[cfg(desktop)]`; the dialog/fs/opener/shell plugins and the six file commands run on every platform.
|
||||
- **`src-tauri/Cargo.toml`** — `tauri-plugin-single-instance` lives in a desktop-only `[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]` table.
|
||||
- **`src/utils/platform.ts` / `file-ops.ts`** — `IS_MOBILE` routes file export through the WebView blob download on Android (the native save dialog is unreliable under scoped storage). Settings persist via `appDataDir()` (app-private storage) **and** localStorage, both of which work on Android.
|
||||
|
||||
## Auto-Update Flow
|
||||
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@ Cài theo thứ tự:
|
||||
|
||||
| Công cụ | Phiên bản | Lý do |
|
||||
| --- | --- | --- |
|
||||
| **Node.js** | `>= 22.0.0` | Vite 7 đã bỏ hỗ trợ Node cũ. Dùng [nvm](https://github.com/nvm-sh/nvm) hoặc [fnm](https://github.com/Schniz/fnm). |
|
||||
| **Node.js** | `>= 22.12.0` | Vite 8 yêu cầu Node `^20.19` hoặc `>= 22.12`. Dùng [nvm](https://github.com/nvm-sh/nvm) hoặc [fnm](https://github.com/Schniz/fnm). |
|
||||
| **npm** | đi kèm Node 22 | Dự án dùng npm; `pnpm` và `yarn` chưa test. |
|
||||
| **Rust** | stable, `>= 1.78` | Bắt buộc cho build Tauri. Cài qua [rustup](https://rustup.rs/). |
|
||||
| **Python** | `3.12` | Tùy chọn — chỉ cần cho một số tooling Tauri trên Windows. |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yt-desc-gen",
|
||||
"version": "0.27.0",
|
||||
"version": "0.29.1",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
@@ -45,7 +45,7 @@
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/react": "^18.3.0",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@vitejs/plugin-react": "^4.3.0",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"autoprefixer": "^10.4.0",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
@@ -54,10 +54,10 @@
|
||||
"prettier": "^3.3.0",
|
||||
"prettier-plugin-tailwindcss": "^0.6.0",
|
||||
"tailwindcss": "^3.4.0",
|
||||
"tsx": "^4.16.0",
|
||||
"tsx": "^4.22.4",
|
||||
"typescript": "^5.5.0",
|
||||
"typescript-eslint": "^8.0.0",
|
||||
"vite": "^7.3.3",
|
||||
"vite": "^8.0.16",
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
}
|
||||
@@ -5535,7 +5535,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "yt-desc-gen"
|
||||
version = "0.27.0"
|
||||
version = "0.29.1"
|
||||
dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "yt-desc-gen"
|
||||
version = "0.27.0"
|
||||
version = "0.29.1"
|
||||
description = "YouTube Gameplay Description Generator"
|
||||
authors = ["poli0981"]
|
||||
edition = "2021"
|
||||
@@ -19,4 +19,9 @@ tauri-plugin-dialog = "2"
|
||||
tauri-plugin-fs = "2"
|
||||
tauri-plugin-opener = "2"
|
||||
tauri-plugin-shell = "2"
|
||||
|
||||
# Desktop-only: single-instance is unsupported on mobile and must not be
|
||||
# compiled into the Android/iOS library. cfg(not(any(android, ios))) is the
|
||||
# canonical Tauri "desktop" target table.
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-single-instance = "2"
|
||||
@@ -0,0 +1,12 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
@@ -0,0 +1,19 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
key.properties
|
||||
|
||||
/.tauri
|
||||
/tauri.settings.gradle
|
||||
@@ -0,0 +1,6 @@
|
||||
/src/main/**/generated
|
||||
/src/main/jniLibs/**/*.so
|
||||
/src/main/assets/tauri.conf.json
|
||||
/tauri.build.gradle.kts
|
||||
/proguard-tauri.pro
|
||||
/tauri.properties
|
||||
@@ -0,0 +1,92 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("rust")
|
||||
}
|
||||
|
||||
val tauriProperties = Properties().apply {
|
||||
val propFile = file("tauri.properties")
|
||||
if (propFile.exists()) {
|
||||
propFile.inputStream().use { load(it) }
|
||||
}
|
||||
}
|
||||
|
||||
// Release signing. `keystore.properties` is gitignored and created out-of-band
|
||||
// (locally by the maintainer, or written from CI secrets). When it is absent
|
||||
// the release build is left unsigned instead of failing, so debug builds and
|
||||
// contributor checkouts without a keystore still work.
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties().apply {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystorePropertiesFile.inputStream().use { load(it) }
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 36
|
||||
namespace = "com.skullmute.ytdescgen"
|
||||
defaultConfig {
|
||||
manifestPlaceholders["usesCleartextTraffic"] = "false"
|
||||
applicationId = "com.skullmute.ytdescgen"
|
||||
minSdk = 30
|
||||
targetSdk = 36
|
||||
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||||
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
||||
}
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
getByName("debug") {
|
||||
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||||
isDebuggable = true
|
||||
isJniDebuggable = true
|
||||
isMinifyEnabled = false
|
||||
packaging { jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
|
||||
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
|
||||
jniLibs.keepDebugSymbols.add("*/x86/*.so")
|
||||
jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
|
||||
}
|
||||
}
|
||||
getByName("release") {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
*fileTree(".") { include("**/*.pro") }
|
||||
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||
.toList().toTypedArray()
|
||||
)
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
rust {
|
||||
rootDirRel = "../../../"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.webkit:webkit:1.14.0")
|
||||
implementation("androidx.appcompat:appcompat:1.7.1")
|
||||
implementation("androidx.activity:activity-ktx:1.10.1")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.4")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||
}
|
||||
|
||||
apply(from = "tauri.build.gradle.kts")
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- AndroidTV support -->
|
||||
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||
|
||||
<application
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.yt_desc_gen"
|
||||
android:usesCleartextTraffic="${usesCleartextTraffic}">
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
|
||||
android:launchMode="singleTask"
|
||||
android:label="@string/main_activity_title"
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<!-- AndroidTV support -->
|
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.skullmute.ytdescgen
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
|
||||
class MainActivity : TauriActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.yt_desc_gen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">YTDescGen</string>
|
||||
<string name="main_activity_title">YTDescGen</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.yt_desc_gen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="my_images" path="." />
|
||||
<cache-path name="my_cache_images" path="." />
|
||||
</paths>
|
||||
@@ -0,0 +1,22 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:8.11.0")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("clean").configure {
|
||||
delete("build")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("pluginsForCoolKids") {
|
||||
id = "rust"
|
||||
implementationClass = "RustPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(gradleApi())
|
||||
implementation("com.android.tools.build:gradle:8.11.0")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import java.io.File
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
open class BuildTask : DefaultTask() {
|
||||
@Input
|
||||
var rootDirRel: String? = null
|
||||
@Input
|
||||
var target: String? = null
|
||||
@Input
|
||||
var release: Boolean? = null
|
||||
|
||||
@TaskAction
|
||||
fun assemble() {
|
||||
val executable = """cargo""";
|
||||
try {
|
||||
runTauriCli(executable)
|
||||
} catch (e: Exception) {
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
// Try different Windows-specific extensions
|
||||
val fallbacks = listOf(
|
||||
"$executable.exe",
|
||||
"$executable.cmd",
|
||||
"$executable.bat",
|
||||
)
|
||||
|
||||
var lastException: Exception = e
|
||||
for (fallback in fallbacks) {
|
||||
try {
|
||||
runTauriCli(fallback)
|
||||
return
|
||||
} catch (fallbackException: Exception) {
|
||||
lastException = fallbackException
|
||||
}
|
||||
}
|
||||
throw lastException
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun runTauriCli(executable: String) {
|
||||
val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null")
|
||||
val target = target ?: throw GradleException("target cannot be null")
|
||||
val release = release ?: throw GradleException("release cannot be null")
|
||||
val args = listOf("tauri", "android", "android-studio-script");
|
||||
|
||||
project.exec {
|
||||
workingDir(File(project.projectDir, rootDirRel))
|
||||
executable(executable)
|
||||
args(args)
|
||||
if (project.logger.isEnabled(LogLevel.DEBUG)) {
|
||||
args("-vv")
|
||||
} else if (project.logger.isEnabled(LogLevel.INFO)) {
|
||||
args("-v")
|
||||
}
|
||||
if (release) {
|
||||
args("--release")
|
||||
}
|
||||
args(listOf("--target", target))
|
||||
}.assertNormalExitValue()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import com.android.build.api.dsl.ApplicationExtension
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.get
|
||||
|
||||
const val TASK_GROUP = "rust"
|
||||
|
||||
open class Config {
|
||||
lateinit var rootDirRel: String
|
||||
}
|
||||
|
||||
open class RustPlugin : Plugin<Project> {
|
||||
private lateinit var config: Config
|
||||
|
||||
override fun apply(project: Project) = with(project) {
|
||||
config = extensions.create("rust", Config::class.java)
|
||||
|
||||
val defaultAbiList = listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64");
|
||||
val abiList = (findProperty("abiList") as? String)?.split(',') ?: defaultAbiList
|
||||
|
||||
val defaultArchList = listOf("arm64", "arm", "x86", "x86_64");
|
||||
val archList = (findProperty("archList") as? String)?.split(',') ?: defaultArchList
|
||||
|
||||
val targetsList = (findProperty("targetList") as? String)?.split(',') ?: listOf("aarch64", "armv7", "i686", "x86_64")
|
||||
|
||||
extensions.configure<ApplicationExtension> {
|
||||
@Suppress("UnstableApiUsage")
|
||||
flavorDimensions.add("abi")
|
||||
productFlavors {
|
||||
create("universal") {
|
||||
dimension = "abi"
|
||||
ndk {
|
||||
abiFilters += abiList
|
||||
}
|
||||
}
|
||||
defaultArchList.forEachIndexed { index, arch ->
|
||||
create(arch) {
|
||||
dimension = "abi"
|
||||
ndk {
|
||||
abiFilters.add(defaultAbiList[index])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
for (profile in listOf("debug", "release")) {
|
||||
val profileCapitalized = profile.replaceFirstChar { it.uppercase() }
|
||||
val buildTask = tasks.maybeCreate(
|
||||
"rustBuildUniversal$profileCapitalized",
|
||||
DefaultTask::class.java
|
||||
).apply {
|
||||
group = TASK_GROUP
|
||||
description = "Build dynamic library in $profile mode for all targets"
|
||||
}
|
||||
|
||||
tasks["mergeUniversal${profileCapitalized}JniLibFolders"].dependsOn(buildTask)
|
||||
|
||||
for (targetPair in targetsList.withIndex()) {
|
||||
val targetName = targetPair.value
|
||||
val targetArch = archList[targetPair.index]
|
||||
val targetArchCapitalized = targetArch.replaceFirstChar { it.uppercase() }
|
||||
val targetBuildTask = project.tasks.maybeCreate(
|
||||
"rustBuild$targetArchCapitalized$profileCapitalized",
|
||||
BuildTask::class.java
|
||||
).apply {
|
||||
group = TASK_GROUP
|
||||
description = "Build dynamic library in $profile mode for $targetArch"
|
||||
rootDirRel = config.rootDirRel
|
||||
target = targetName
|
||||
release = profile == "release"
|
||||
}
|
||||
|
||||
buildTask.dependsOn(targetBuildTask)
|
||||
tasks["merge$targetArchCapitalized${profileCapitalized}JniLibFolders"].dependsOn(
|
||||
targetBuildTask
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app"s APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonFinalResIds=false
|
||||
@@ -0,0 +1,6 @@
|
||||
#Tue May 10 19:22:52 CST 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,3 @@
|
||||
include ':app'
|
||||
|
||||
apply from: 'tauri.settings.gradle'
|
||||
@@ -0,0 +1,30 @@
|
||||
YTDescGen — Installation & Terms Notice
|
||||
=======================================
|
||||
|
||||
By installing and using YTDescGen, you confirm that you have read and agree
|
||||
to the following documents:
|
||||
|
||||
Terms of Use: https://github.com/poli0981/youtube-generator/blob/main/TERMS.md
|
||||
Privacy Policy: https://github.com/poli0981/youtube-generator/blob/main/PRIVACY.md
|
||||
Disclaimer: https://github.com/poli0981/youtube-generator/blob/main/DISCLAIMER.md
|
||||
License: https://github.com/poli0981/youtube-generator/blob/main/LICENSE
|
||||
|
||||
In short:
|
||||
|
||||
* YTDescGen is free, open-source software, provided AS IS, WITHOUT WARRANTY
|
||||
OF ANY KIND. You use it at your own risk (see the Disclaimer and License
|
||||
sections 7-8).
|
||||
* It works fully offline. It does not collect, transmit, or sell any
|
||||
personal data; your profiles, history, and generated text stay on your
|
||||
device (see the Privacy Policy).
|
||||
* You are responsible for ensuring the titles, descriptions, and tags you
|
||||
generate comply with YouTube's policies and applicable law (see the
|
||||
Terms of Use).
|
||||
* YTDescGen is an independent project and is not affiliated with, endorsed
|
||||
by, or sponsored by YouTube, Google, or any game publisher.
|
||||
|
||||
The software itself is licensed under the Apache License, Version 2.0. The
|
||||
full license text is included with this distribution and is available at the
|
||||
License URL above.
|
||||
|
||||
If you do not agree to these terms, do not install or use the software.
|
||||
@@ -1,6 +1,13 @@
|
||||
// The tray icon, single-instance enforcement, hide-to-tray and
|
||||
// exit-prevention machinery below are desktop-only. None of these APIs exist
|
||||
// (or make sense) on mobile, so gate the imports too — otherwise the Android
|
||||
// build fails with unresolved imports / unused-import warnings.
|
||||
#[cfg(desktop)]
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
#[cfg(desktop)]
|
||||
use std::sync::Arc;
|
||||
|
||||
#[cfg(desktop)]
|
||||
use tauri::{
|
||||
menu::{Menu, MenuItem},
|
||||
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
||||
@@ -91,83 +98,16 @@ fn delete_file(path: String) -> Result<(), String> {
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// Flag that signals the user has requested a full quit (via tray menu).
|
||||
// When false, closing the window hides it to the tray; when true,
|
||||
// the app is allowed to exit.
|
||||
let quitting = Arc::new(AtomicBool::new(false));
|
||||
let quitting_menu = quitting.clone();
|
||||
let quitting_window = quitting.clone();
|
||||
let quitting_run = quitting.clone();
|
||||
|
||||
tauri::Builder::default()
|
||||
// Single-instance MUST be the first plugin registered (v0.12). Without
|
||||
// it, every launch spawns a fresh process — which then builds its own
|
||||
// tray icon in `setup()`, stacking duplicates in the system tray and
|
||||
// leaving orphan processes in Task Manager. The callback runs in the
|
||||
// *first* (already-running) instance when a second launch is attempted:
|
||||
// we surface its window instead of letting the second process boot.
|
||||
.plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}))
|
||||
// Plugins and commands shared by every platform (desktop + Android). The
|
||||
// dialog/fs/opener/shell plugins all support mobile, and the six file
|
||||
// commands use std::fs which works against the app's private data dir on
|
||||
// Android. Desktop-only pieces (single-instance, tray, hide-to-tray,
|
||||
// exit-prevention) are layered on below behind #[cfg(desktop)].
|
||||
let builder = tauri::Builder::default()
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.setup(move |app| {
|
||||
let show = MenuItem::with_id(app, "show", "Show YTDescGen", true, None::<&str>)?;
|
||||
let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
|
||||
let menu = Menu::with_items(app, &[&show, &quit])?;
|
||||
|
||||
let _tray = TrayIconBuilder::with_id("ytdescgen-tray")
|
||||
.tooltip("YTDescGen — YouTube Description Generator")
|
||||
.menu(&menu)
|
||||
.on_menu_event(move |app, event| match event.id.as_ref() {
|
||||
"show" => {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
"quit" => {
|
||||
quitting_menu.store(true, Ordering::SeqCst);
|
||||
app.exit(0);
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.on_tray_icon_event(|tray, event| {
|
||||
if let TrayIconEvent::Click {
|
||||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Up,
|
||||
..
|
||||
} = event
|
||||
{
|
||||
let app = tray.app_handle();
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
})
|
||||
.build(app)?;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(move |window, event| {
|
||||
if let WindowEvent::CloseRequested { api, .. } = event {
|
||||
// If the user asked to quit via the tray menu, let the
|
||||
// window close normally so the app can exit.
|
||||
if !quitting_window.load(Ordering::SeqCst) {
|
||||
let _ = window.hide();
|
||||
api.prevent_close();
|
||||
}
|
||||
}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
save_to_file,
|
||||
read_from_file,
|
||||
@@ -175,15 +115,98 @@ pub fn run() {
|
||||
append_to_file,
|
||||
list_dir,
|
||||
delete_file
|
||||
])
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
.run(move |_app_handle, event| {
|
||||
if let RunEvent::ExitRequested { api, .. } = event {
|
||||
// Only prevent exit when the user hasn't explicitly asked to quit.
|
||||
if !quitting_run.load(Ordering::SeqCst) {
|
||||
api.prevent_exit();
|
||||
]);
|
||||
|
||||
#[cfg(desktop)]
|
||||
{
|
||||
// Flag that signals the user has requested a full quit (via tray menu).
|
||||
// When false, closing the window hides it to the tray; when true,
|
||||
// the app is allowed to exit.
|
||||
let quitting = Arc::new(AtomicBool::new(false));
|
||||
let quitting_menu = quitting.clone();
|
||||
let quitting_window = quitting.clone();
|
||||
let quitting_run = quitting.clone();
|
||||
|
||||
builder
|
||||
// Single-instance MUST be the first desktop plugin registered (v0.12).
|
||||
// Without it, every launch spawns a fresh process — which then builds
|
||||
// its own tray icon in `setup()`, stacking duplicates in the system
|
||||
// tray and leaving orphan processes in Task Manager. The callback runs
|
||||
// in the *first* (already-running) instance when a second launch is
|
||||
// attempted: we surface its window instead of letting the second boot.
|
||||
.plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
}))
|
||||
.setup(move |app| {
|
||||
let show = MenuItem::with_id(app, "show", "Show YTDescGen", true, None::<&str>)?;
|
||||
let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
|
||||
let menu = Menu::with_items(app, &[&show, &quit])?;
|
||||
|
||||
let _tray = TrayIconBuilder::with_id("ytdescgen-tray")
|
||||
.tooltip("YTDescGen — YouTube Description Generator")
|
||||
.menu(&menu)
|
||||
.on_menu_event(move |app, event| match event.id.as_ref() {
|
||||
"show" => {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
"quit" => {
|
||||
quitting_menu.store(true, Ordering::SeqCst);
|
||||
app.exit(0);
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.on_tray_icon_event(|tray, event| {
|
||||
if let TrayIconEvent::Click {
|
||||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Up,
|
||||
..
|
||||
} = event
|
||||
{
|
||||
let app = tray.app_handle();
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.unminimize();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
})
|
||||
.build(app)?;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(move |window, event| {
|
||||
if let WindowEvent::CloseRequested { api, .. } = event {
|
||||
// If the user asked to quit via the tray menu, let the
|
||||
// window close normally so the app can exit.
|
||||
if !quitting_window.load(Ordering::SeqCst) {
|
||||
let _ = window.hide();
|
||||
api.prevent_close();
|
||||
}
|
||||
}
|
||||
})
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
.run(move |_app_handle, event| {
|
||||
if let RunEvent::ExitRequested { api, .. } = event {
|
||||
// Only prevent exit when the user hasn't explicitly asked to quit.
|
||||
if !quitting_run.load(Ordering::SeqCst) {
|
||||
api.prevent_exit();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Mobile (Android): no tray, single-instance, or hide-to-tray — just run.
|
||||
#[cfg(not(desktop))]
|
||||
builder
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while building tauri application");
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
|
||||
"productName": "YTDescGen",
|
||||
"version": "0.27.0",
|
||||
"version": "0.29.1",
|
||||
"identifier": "com.skullmute.ytdescgen",
|
||||
"build": {
|
||||
"beforeBuildCommand": "npm run build",
|
||||
@@ -35,6 +35,7 @@
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"licenseFile": "installer-license.txt",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
@@ -43,6 +44,9 @@
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"targets": "all",
|
||||
"android": {
|
||||
"minSdkVersion": 30
|
||||
},
|
||||
"windows": {
|
||||
"webviewInstallMode": {
|
||||
"type": "downloadBootstrapper"
|
||||
|
||||
@@ -6,6 +6,8 @@ import { AppShell } from "@components/layout/AppShell";
|
||||
import { ErrorBoundary } from "@components/ErrorBoundary";
|
||||
import { ErrorPage } from "@components/errors/ErrorPage";
|
||||
import { OfflineBanner } from "@components/errors/OfflineBanner";
|
||||
import { ConsentGate } from "@components/ConsentGate";
|
||||
import { needsConsent } from "@config/legal";
|
||||
import { EditorPage } from "@pages/EditorPage";
|
||||
import { OutputPage } from "@pages/OutputPage";
|
||||
import { checkDataFileHealth } from "@utils/storage-adapter";
|
||||
@@ -103,6 +105,30 @@ export default function App() {
|
||||
return () => unsub();
|
||||
}, []);
|
||||
|
||||
// v0.28.0: first-run legal consent gate. Until the user accepts the current
|
||||
// terms version, render the gate INSTEAD of the router so nothing in the app
|
||||
// is reachable. The whole tree stays inside the root ErrorBoundary
|
||||
// (main.tsx), so a gate render error still degrades to the error page.
|
||||
const legalConsentVersion = useSettingsStore((s) => s.legalConsentVersion);
|
||||
|
||||
if (needsConsent(legalConsentVersion)) {
|
||||
return (
|
||||
<>
|
||||
<ConsentGate />
|
||||
<Toaster
|
||||
position="bottom-right"
|
||||
toastOptions={{
|
||||
style: {
|
||||
background: "var(--surface-2)",
|
||||
color: "var(--text-primary)",
|
||||
border: "1px solid var(--border)",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<HashRouter>
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ExternalLink, ShieldCheck } from "lucide-react";
|
||||
import { Button } from "@components/ui/Button";
|
||||
import { Checkbox } from "@components/ui/Checkbox";
|
||||
import { useDocumentTitle } from "@hooks/use-document-title";
|
||||
import { useSettingsStore } from "@store/settings-store";
|
||||
import { LEGAL_DOCS } from "@config/legal";
|
||||
|
||||
/**
|
||||
* First-run legal consent gate. Rendered full-screen and **non-dismissible**
|
||||
* (no ESC / backdrop / X — deliberately NOT the {@link import("@components/ui/Modal").Modal})
|
||||
* in place of the router until the user accepts the current terms version.
|
||||
*
|
||||
* Layout mirrors the v0.27.0 ErrorPage fullscreen pattern. Acceptance is
|
||||
* recorded in the settings store (`acceptLegalConsent`), which dual-writes to
|
||||
* localStorage + the Tauri settings file; the gate then yields to the app.
|
||||
* Re-shows automatically when CURRENT_TERMS_VERSION is bumped, and in fresh /
|
||||
* incognito storage.
|
||||
*/
|
||||
export function ConsentGate() {
|
||||
const { t } = useTranslation("ui");
|
||||
const [agreed, setAgreed] = useState(false);
|
||||
useDocumentTitle(t("consentGate.title"));
|
||||
|
||||
const onContinue = (): void => {
|
||||
if (!agreed) return;
|
||||
useSettingsStore.getState().acceptLegalConsent();
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="consent-title"
|
||||
className="flex min-h-screen flex-col items-center justify-center gap-6 bg-surface-0 px-6 py-12 text-center"
|
||||
>
|
||||
<ShieldCheck className="h-14 w-14 text-accent" aria-hidden />
|
||||
|
||||
<div className="max-w-md space-y-2">
|
||||
<h1 id="consent-title" className="text-2xl font-semibold text-text-primary">
|
||||
{t("consentGate.title")}
|
||||
</h1>
|
||||
<p className="text-sm text-text-secondary">{t("consentGate.intro")}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid w-full max-w-md gap-2 sm:grid-cols-2">
|
||||
{LEGAL_DOCS.map((doc) => (
|
||||
<a
|
||||
key={doc.id}
|
||||
href={doc.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-3 rounded-lg border border-border bg-surface-1 px-3 py-2.5 text-sm text-text-primary transition-colors hover:border-accent hover:bg-surface-2"
|
||||
>
|
||||
<span className="flex-1 truncate text-left">{t(doc.labelKey)}</span>
|
||||
<ExternalLink className="h-3.5 w-3.5 shrink-0 text-text-muted" />
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="w-full max-w-md rounded-lg border border-border bg-surface-1 p-4">
|
||||
<Checkbox checked={agreed} onChange={setAgreed} label={t("consentGate.agreeLabel")} />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<Button variant="primary" onClick={onContinue} disabled={!agreed}>
|
||||
{t("consentGate.continue")}
|
||||
</Button>
|
||||
{!agreed && <p className="text-xs text-text-muted">{t("consentGate.mustAgree")}</p>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export function VideoSettingsForm() {
|
||||
<div className="flex flex-col gap-3">
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.videoSettings")}</span>
|
||||
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
||||
<Select
|
||||
label={t("editor.resolution")}
|
||||
options={RESOLUTION_OPTIONS}
|
||||
|
||||
@@ -46,8 +46,8 @@ export function PresetCard({ preset }: PresetCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-between rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30">
|
||||
<div className="flex-1">
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="text-sm font-semibold text-text-primary">{preset.gameName}</h3>
|
||||
<div className="mt-1.5 flex flex-wrap items-center gap-1.5 text-xs text-text-muted">
|
||||
{genreDefs.map((g) => (
|
||||
@@ -58,7 +58,7 @@ export function PresetCard({ preset }: PresetCardProps) {
|
||||
<span>{preset.platform}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
<Button variant="primary" size="sm" onClick={handleLoad}>
|
||||
<Upload className="h-3.5 w-3.5" />
|
||||
{t("presets.loadPreset")}
|
||||
|
||||
@@ -43,16 +43,16 @@ export function ProfileCard({ profile }: ProfileCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-between rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30">
|
||||
<div className="flex-1">
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="text-sm font-semibold text-text-primary">{profile.name}</h3>
|
||||
<p className="mt-0.5 text-xs text-text-secondary">{profile.channelName || "No channel"}</p>
|
||||
<div className="mt-1.5 flex gap-3 text-xs text-text-muted">
|
||||
<div className="mt-1.5 flex flex-wrap gap-3 text-xs text-text-muted">
|
||||
{socialCount > 0 && <span>{socialCount} social links</span>}
|
||||
{rigCount > 0 && <span>{rigCount} rig fields</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
<Button variant="primary" size="sm" onClick={handleLoad}>
|
||||
<Upload className="h-3.5 w-3.5" />
|
||||
{t("profiles.loadProfile")}
|
||||
|
||||
@@ -35,16 +35,16 @@ export function TemplateCard({ template }: TemplateCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-between rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30">
|
||||
<div className="flex-1">
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="text-sm font-semibold text-text-primary">{template.name}</h3>
|
||||
<div className="mt-1.5 flex items-center gap-2 text-xs text-text-muted">
|
||||
<div className="mt-1.5 flex flex-wrap items-center gap-2 text-xs text-text-muted">
|
||||
<span>{template.snapshot.gameName || "—"}</span>
|
||||
<span>·</span>
|
||||
<span>{date}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
<Button variant="primary" size="sm" onClick={handleApply}>
|
||||
<Upload className="h-3.5 w-3.5" />
|
||||
{t("templates.loadTemplate")}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { type ReactNode, useId } from "react";
|
||||
import { Check } from "lucide-react";
|
||||
import clsx from "clsx";
|
||||
|
||||
interface CheckboxProps {
|
||||
checked: boolean;
|
||||
onChange: (checked: boolean) => void;
|
||||
/** Visible label — accepts rich content (e.g. inline links). */
|
||||
label: ReactNode;
|
||||
className?: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessible square checkbox. A real `<input type="checkbox">` (visually
|
||||
* hidden as a `peer`) keeps native keyboard + screen-reader semantics, while
|
||||
* the styled box mirrors its state. Tailwind tokens only, so it tracks the
|
||||
* dark/light theme. Distinct from {@link import("./Toggle").Toggle}, which is
|
||||
* a `role="switch"` on/off pill — a checkbox is the right control for a
|
||||
* one-time "I agree" acknowledgement.
|
||||
*/
|
||||
export function Checkbox({ checked, onChange, label, className, id }: CheckboxProps) {
|
||||
const autoId = useId();
|
||||
const inputId = id ?? autoId;
|
||||
return (
|
||||
<label
|
||||
htmlFor={inputId}
|
||||
className={clsx("group flex min-h-touch cursor-pointer items-start gap-3 text-left", className)}
|
||||
>
|
||||
<input
|
||||
id={inputId}
|
||||
type="checkbox"
|
||||
checked={checked}
|
||||
onChange={(e) => onChange(e.target.checked)}
|
||||
className="peer sr-only"
|
||||
/>
|
||||
<span
|
||||
aria-hidden
|
||||
className={clsx(
|
||||
"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded border transition-colors",
|
||||
"peer-focus-visible:ring-2 peer-focus-visible:ring-accent/50",
|
||||
checked
|
||||
? "border-accent bg-accent text-white"
|
||||
: "border-border bg-surface-1 text-transparent group-hover:border-border-strong",
|
||||
)}
|
||||
>
|
||||
<Check className="h-3.5 w-3.5" strokeWidth={3} />
|
||||
</span>
|
||||
<span className="text-sm leading-snug text-text-primary">{label}</span>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export function Modal({ open, onClose, title, children, footer, className }: Mod
|
||||
>
|
||||
<div
|
||||
className={clsx(
|
||||
"mx-4 flex max-h-[85vh] w-full max-w-lg flex-col rounded-xl border border-border bg-surface-1 shadow-2xl",
|
||||
"mx-4 flex max-h-[85vh] w-[calc(100%-2rem)] max-w-lg flex-col rounded-xl border border-border bg-surface-1 shadow-2xl",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
const DOC_BASE = "https://github.com/poli0981/youtube-generator/blob/main";
|
||||
|
||||
export interface LegalDoc {
|
||||
readonly id: "terms" | "privacy" | "disclaimer" | "license";
|
||||
/** i18n key under the `consentGate` ui section. */
|
||||
readonly labelKey: string;
|
||||
/** Absolute GitHub blob URL — opens in the system browser via target="_blank". */
|
||||
readonly url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The legal-terms version the user must accept. Bump this whenever the
|
||||
* Terms / Privacy / Disclaimer change materially — every user whose stored
|
||||
* `legalConsentVersion` is below this re-sees the first-run consent gate.
|
||||
*
|
||||
* v0.28.0 ships the first gate at version 1 (docs dated 2026-05-14).
|
||||
*/
|
||||
export const CURRENT_TERMS_VERSION = 1;
|
||||
|
||||
/**
|
||||
* The documents surfaced on the consent gate and the About → Legal section.
|
||||
* Stored at the repo root and served from GitHub so they are always current;
|
||||
* the in-app links open them in the browser (Tauri routes target="_blank" to
|
||||
* the system browser). Order = display order.
|
||||
*/
|
||||
export const LEGAL_DOCS: readonly LegalDoc[] = [
|
||||
{ id: "terms", labelKey: "consentGate.docTerms", url: `${DOC_BASE}/TERMS.md` },
|
||||
{ id: "privacy", labelKey: "consentGate.docPrivacy", url: `${DOC_BASE}/PRIVACY.md` },
|
||||
{ id: "disclaimer", labelKey: "consentGate.docDisclaimer", url: `${DOC_BASE}/DISCLAIMER.md` },
|
||||
{ id: "license", labelKey: "consentGate.docLicense", url: `${DOC_BASE}/LICENSE` },
|
||||
];
|
||||
|
||||
/**
|
||||
* True when the consent gate must be shown — the user has not yet accepted the
|
||||
* current terms version. A non-finite value (NaN / Infinity / non-number from a
|
||||
* corrupt or legacy payload) is treated as "not accepted" so a bad value
|
||||
* re-shows the gate rather than slipping past `<` comparison.
|
||||
*/
|
||||
export function needsConsent(acceptedVersion: number): boolean {
|
||||
return !Number.isFinite(acceptedVersion) || acceptedVersion < CURRENT_TERMS_VERSION;
|
||||
}
|
||||
@@ -9,7 +9,8 @@
|
||||
"repoHeading", "repoLabel", "issuesLabel", "reportBugLabel", "discussionsLabel", "authorLabel", "licenseLabel",
|
||||
"donateHeading", "donateHelp",
|
||||
"connectHeading",
|
||||
"thirdPartyHeading", "thirdPartyHelp"
|
||||
"thirdPartyHeading", "thirdPartyHelp",
|
||||
"legalHeading"
|
||||
],
|
||||
"about.donate": ["githubSponsors", "kofi", "buyMeACoffee", "patreon", "paypal"],
|
||||
"about.socials": ["youtube", "x", "bluesky", "mastodon", "discord", "discordGame", "steam", "telegramBot", "telegramUser", "email"],
|
||||
@@ -169,6 +170,7 @@
|
||||
"errorPages.serverError": ["title", "description"],
|
||||
"errorPages.offline": ["title", "description"],
|
||||
"errorPages.runtime": ["title", "description"],
|
||||
"consentGate": ["title", "intro", "agreeLabel", "continue", "mustAgree", "docTerms", "docPrivacy", "docDisclaimer", "docLicense"],
|
||||
"videoTypes": ["full", "part", "full_demo", "demo_part", "boss", "boss_nohit", "ending", "speedrun", "100percent", "dlc", "newgame_plus", "challenge", "side_quest", "secret", "comparison", "guide", "mods", "collectibles", "livestream", "gacha_quest"],
|
||||
"genres": ["action", "hack_slash", "beatemup", "platformer", "horror", "survival_horror", "psychological_horror", "rpg", "jrpg", "action_rpg", "crpg", "fps", "arena_shooter", "tactical_fps", "boomer_shooter", "extraction_shooter", "shmup", "openworld", "indie", "soulslike", "racing", "story", "simulation", "city_builder", "fighting", "stealth", "survival_craft", "roguelike", "metroidvania", "mmo", "rhythm", "puzzle", "tower_defense", "card_game", "deck_builder", "auto_battler", "battle_royale", "tactical", "space", "farming", "fmv", "visual_novel"],
|
||||
"rig": ["os", "cpu", "gpu", "ram", "storage", "monitor", "capture", "motherboard", "controller", "video_editor"],
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"licenseLabel": "License",
|
||||
"donateHeading": "Donate / Support",
|
||||
"donateHelp": "If YTDescGen saves you time, consider buying me a coffee. Every bit helps keep the project going.",
|
||||
"legalHeading": "Legal",
|
||||
"donate": {
|
||||
"githubSponsors": "GitHub Sponsors",
|
||||
"kofi": "Ko-fi",
|
||||
@@ -787,6 +788,17 @@
|
||||
"description": "The app caught a render error before it could crash the page. Your data is safe — the error was logged to the Logs tab."
|
||||
}
|
||||
},
|
||||
"consentGate": {
|
||||
"title": "Before you start",
|
||||
"intro": "YTDescGen is a free, offline-first tool. Please review the documents below. By continuing, you confirm you have read and agree to them.",
|
||||
"agreeLabel": "I have read and agree to the Terms of Use, Privacy Policy, Disclaimer, and License.",
|
||||
"continue": "Continue",
|
||||
"mustAgree": "Please check the box to continue.",
|
||||
"docTerms": "Terms of Use",
|
||||
"docPrivacy": "Privacy Policy",
|
||||
"docDisclaimer": "Disclaimer",
|
||||
"docLicense": "License (Apache-2.0)"
|
||||
},
|
||||
"videoTypes": {
|
||||
"full": "Full Gameplay",
|
||||
"part": "Gameplay Part",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"licenseLabel": "Licencia",
|
||||
"donateHeading": "Donar / Apoyar",
|
||||
"donateHelp": "Si YTDescGen te ahorra tiempo, considera invitarme un café. Cada aporte ayuda al proyecto.",
|
||||
"legalHeading": "Legal",
|
||||
"donate": {
|
||||
"githubSponsors": "GitHub Sponsors",
|
||||
"kofi": "Ko-fi",
|
||||
@@ -787,6 +788,17 @@
|
||||
"description": "La aplicación detectó un error de renderizado antes de que la página fallara. Tus datos están a salvo — el error se registró en la pestaña Registros."
|
||||
}
|
||||
},
|
||||
"consentGate": {
|
||||
"title": "Antes de empezar",
|
||||
"intro": "YTDescGen es una herramienta gratuita y con prioridad sin conexión. Revisa los documentos siguientes. Al continuar, confirmas que los has leído y los aceptas.",
|
||||
"agreeLabel": "He leído y acepto los Términos de Uso, la Política de Privacidad, el Aviso Legal y la Licencia.",
|
||||
"continue": "Continuar",
|
||||
"mustAgree": "Marca la casilla para continuar.",
|
||||
"docTerms": "Términos de Uso",
|
||||
"docPrivacy": "Política de Privacidad",
|
||||
"docDisclaimer": "Aviso Legal",
|
||||
"docLicense": "Licencia (Apache-2.0)"
|
||||
},
|
||||
"videoTypes": {
|
||||
"full": "Gameplay Completo",
|
||||
"part": "Gameplay Parte",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"licenseLabel": "ライセンス",
|
||||
"donateHeading": "寄付 / サポート",
|
||||
"donateHelp": "YTDescGenが時短に役立ったら、コーヒー一杯分でも支援していただけると嬉しいです。",
|
||||
"legalHeading": "法的事項",
|
||||
"donate": {
|
||||
"githubSponsors": "GitHub Sponsors",
|
||||
"kofi": "Ko-fi",
|
||||
@@ -787,6 +788,17 @@
|
||||
"description": "ページがクラッシュする前にレンダリングエラーを検出しました。データは安全です — エラーはログタブに記録されました。"
|
||||
}
|
||||
},
|
||||
"consentGate": {
|
||||
"title": "始める前に",
|
||||
"intro": "YTDescGen は無料・オフライン優先のツールです。下記の文書をご確認ください。続行すると、これらを読み同意したことになります。",
|
||||
"agreeLabel": "利用規約、プライバシーポリシー、免責事項、およびライセンスを読み、同意します。",
|
||||
"continue": "続行",
|
||||
"mustAgree": "続行するにはチェックを入れてください。",
|
||||
"docTerms": "利用規約",
|
||||
"docPrivacy": "プライバシーポリシー",
|
||||
"docDisclaimer": "免責事項",
|
||||
"docLicense": "ライセンス (Apache-2.0)"
|
||||
},
|
||||
"videoTypes": {
|
||||
"full": "フルゲームプレイ",
|
||||
"part": "ゲームプレイ パート",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"licenseLabel": "라이선스",
|
||||
"donateHeading": "후원 / 지원",
|
||||
"donateHelp": "YTDescGen이 시간을 아껴드렸다면 커피 한 잔으로 응원 부탁드립니다.",
|
||||
"legalHeading": "법적 고지",
|
||||
"donate": {
|
||||
"githubSponsors": "GitHub Sponsors",
|
||||
"kofi": "Ko-fi",
|
||||
@@ -787,6 +788,17 @@
|
||||
"description": "페이지가 충돌하기 전에 앱이 렌더링 오류를 잡아냈습니다. 데이터는 안전합니다 — 오류는 로그 탭에 기록되었습니다."
|
||||
}
|
||||
},
|
||||
"consentGate": {
|
||||
"title": "시작하기 전에",
|
||||
"intro": "YTDescGen은 무료이며 오프라인을 우선하는 도구입니다. 아래 문서를 검토해 주세요. 계속하면 문서를 읽고 동의한 것으로 간주됩니다.",
|
||||
"agreeLabel": "이용약관, 개인정보 처리방침, 면책 조항 및 라이선스를 읽고 동의합니다.",
|
||||
"continue": "계속",
|
||||
"mustAgree": "계속하려면 체크박스를 선택하세요.",
|
||||
"docTerms": "이용약관",
|
||||
"docPrivacy": "개인정보 처리방침",
|
||||
"docDisclaimer": "면책 조항",
|
||||
"docLicense": "라이선스 (Apache-2.0)"
|
||||
},
|
||||
"videoTypes": {
|
||||
"full": "전체 게임플레이",
|
||||
"part": "게임플레이 파트",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"licenseLabel": "Giấy phép",
|
||||
"donateHeading": "Ủng hộ / Donate",
|
||||
"donateHelp": "Nếu YTDescGen giúp bạn tiết kiệm thời gian, mời mình một ly cà phê nhé. Mọi ủng hộ đều giúp dự án tiếp tục.",
|
||||
"legalHeading": "Pháp lý",
|
||||
"donate": {
|
||||
"githubSponsors": "GitHub Sponsors",
|
||||
"kofi": "Ko-fi",
|
||||
@@ -787,6 +788,17 @@
|
||||
"description": "Ứng dụng đã bắt được lỗi hiển thị trước khi trang bị treo. Dữ liệu của bạn vẫn an toàn — lỗi đã được ghi vào tab Nhật ký."
|
||||
}
|
||||
},
|
||||
"consentGate": {
|
||||
"title": "Trước khi bắt đầu",
|
||||
"intro": "YTDescGen là công cụ miễn phí, ưu tiên hoạt động ngoại tuyến. Vui lòng xem các tài liệu bên dưới. Khi tiếp tục, bạn xác nhận đã đọc và đồng ý với chúng.",
|
||||
"agreeLabel": "Tôi đã đọc và đồng ý với Điều khoản Sử dụng, Chính sách Bảo mật, Tuyên bố Miễn trừ và Giấy phép.",
|
||||
"continue": "Tiếp tục",
|
||||
"mustAgree": "Vui lòng tích vào ô để tiếp tục.",
|
||||
"docTerms": "Điều khoản Sử dụng",
|
||||
"docPrivacy": "Chính sách Bảo mật",
|
||||
"docDisclaimer": "Tuyên bố Miễn trừ",
|
||||
"docLicense": "Giấy phép (Apache-2.0)"
|
||||
},
|
||||
"videoTypes": {
|
||||
"full": "Full Gameplay",
|
||||
"part": "Gameplay Phần",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"licenseLabel": "许可证",
|
||||
"donateHeading": "赞助 / 支持",
|
||||
"donateHelp": "如果 YTDescGen 帮你省下了时间,欢迎请我喝一杯咖啡。每份支持都让项目走得更远。",
|
||||
"legalHeading": "法律",
|
||||
"donate": {
|
||||
"githubSponsors": "GitHub Sponsors",
|
||||
"kofi": "Ko-fi",
|
||||
@@ -787,6 +788,17 @@
|
||||
"description": "应用在页面崩溃前捕获了一个渲染错误。您的数据是安全的 — 错误已记录到日志标签页。"
|
||||
}
|
||||
},
|
||||
"consentGate": {
|
||||
"title": "开始之前",
|
||||
"intro": "YTDescGen 是一款免费、离线优先的工具。请查看以下文档。继续即表示您已阅读并同意这些文档。",
|
||||
"agreeLabel": "我已阅读并同意《使用条款》《隐私政策》《免责声明》和《许可证》。",
|
||||
"continue": "继续",
|
||||
"mustAgree": "请勾选复选框以继续。",
|
||||
"docTerms": "使用条款",
|
||||
"docPrivacy": "隐私政策",
|
||||
"docDisclaimer": "免责声明",
|
||||
"docLicense": "许可证 (Apache-2.0)"
|
||||
},
|
||||
"videoTypes": {
|
||||
"full": "完整游戏实况",
|
||||
"part": "游戏实况分集",
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ErrorBoundary } from "./components/ErrorBoundary";
|
||||
import i18n, { ensureLanguagesLoaded } from "@i18n/index";
|
||||
import { useSettingsStore } from "@store/settings-store";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { installExternalLinkHandler } from "@utils/open-external";
|
||||
import "./styles/globals.css";
|
||||
|
||||
const root = document.getElementById("root");
|
||||
@@ -34,12 +35,31 @@ async function preloadLocales(): Promise<void> {
|
||||
]).catch(() => undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the persisted theme class to <html> at boot. `index.html` hardcodes
|
||||
* `class="dark"`, and `setTheme` (the Header toggle) is the only other place
|
||||
* that touches the class — so before v0.28.0 a light-theme user saw a dark
|
||||
* flash until they interacted. zustand persist has already hydrated from
|
||||
* localStorage at module load, so `getState().theme` is the user's value.
|
||||
* Runs before first paint so the consent gate (and AppShell) render in the
|
||||
* right theme.
|
||||
*/
|
||||
function applyPersistedTheme(): void {
|
||||
const { theme } = useSettingsStore.getState();
|
||||
document.documentElement.classList.toggle("dark", theme === "dark");
|
||||
document.documentElement.classList.toggle("light", theme === "light");
|
||||
}
|
||||
|
||||
// Top-level safety net. Per-route boundaries in App.tsx catch most
|
||||
// errors with route-specific labels; this outer one only fires if
|
||||
// something explodes *before* the router mounts (e.g. i18n init, store
|
||||
// rehydrate). Without it, a top-level crash still produces a black
|
||||
// page — defeating the point of per-route boundaries.
|
||||
void preloadLocales().finally(() => {
|
||||
applyPersistedTheme();
|
||||
// In a Tauri webview, `<a target="_blank">` is inert — route external links
|
||||
// through the OS via the opener plugin. No-op on the web build.
|
||||
installExternalLinkHandler();
|
||||
createRoot(root).render(
|
||||
<StrictMode>
|
||||
<ErrorBoundary label="app">
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
import { ABOUT, type AboutSocialId } from "@config/about";
|
||||
import { DONATE, type DonateId } from "@config/donate";
|
||||
import { THIRD_PARTY } from "@config/third-party";
|
||||
import { LEGAL_DOCS } from "@config/legal";
|
||||
import { useDocumentTitle } from "@hooks/use-document-title";
|
||||
|
||||
interface SocialLinkConfig {
|
||||
@@ -112,6 +113,22 @@ export function AboutPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col gap-3">
|
||||
<h2 className="text-sm font-semibold uppercase tracking-wide text-text-muted">
|
||||
{t("about.legalHeading")}
|
||||
</h2>
|
||||
<div className="grid gap-2 sm:grid-cols-2">
|
||||
{LEGAL_DOCS.map((doc) => (
|
||||
<ExternalLinkRow
|
||||
key={doc.id}
|
||||
href={doc.url}
|
||||
icon={ExternalLink}
|
||||
label={t(doc.labelKey)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col gap-3">
|
||||
<h2 className="text-sm font-semibold uppercase tracking-wide text-text-muted">
|
||||
{t("about.donateHeading")}
|
||||
|
||||
@@ -137,7 +137,7 @@ export function BatchPage() {
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-4xl p-6">
|
||||
<div className="mx-auto max-w-4xl p-4 sm:p-6">
|
||||
<h1 className="mb-4 text-lg font-bold text-text-primary">{t("batch.title")}</h1>
|
||||
|
||||
{/* Language selector */}
|
||||
@@ -163,7 +163,7 @@ export function BatchPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mb-6 flex items-end gap-4">
|
||||
<div className="mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:gap-4">
|
||||
<Input
|
||||
label={t("batch.startPart")}
|
||||
type="number"
|
||||
@@ -177,6 +177,7 @@ export function BatchPage() {
|
||||
onChange={(e) => setEndPart(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
className="w-full sm:w-auto"
|
||||
onClick={() => void handleGenerate()}
|
||||
disabled={!state.gameName || generating}
|
||||
>
|
||||
@@ -190,7 +191,7 @@ export function BatchPage() {
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<div className="mb-4 flex flex-wrap items-center justify-between gap-2">
|
||||
<span className="text-sm text-text-secondary">
|
||||
{results.length} parts x {selectedLangs.length} languages
|
||||
</span>
|
||||
@@ -205,7 +206,7 @@ export function BatchPage() {
|
||||
<div className="flex flex-col gap-3">
|
||||
{result.languages.map((lang) => (
|
||||
<div key={lang.language} className="rounded-lg bg-surface-2 p-3">
|
||||
<div className="mb-1 flex items-center justify-between">
|
||||
<div className="mb-1 flex flex-wrap items-center justify-between gap-2">
|
||||
<span className="text-xs font-medium uppercase text-text-muted">
|
||||
{lang.language.toUpperCase()}
|
||||
</span>
|
||||
@@ -220,7 +221,7 @@ export function BatchPage() {
|
||||
<pre className="mb-2 max-h-20 overflow-y-auto whitespace-pre-wrap font-sans text-xs text-text-secondary">
|
||||
{lang.output.description.slice(0, 200)}...
|
||||
</pre>
|
||||
<div className="flex gap-2">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<CopyButton text={lang.output.description} label={t("output.copyDescription")} />
|
||||
<CopyButton text={lang.output.tagString} label={t("output.copyTags")} />
|
||||
{lang.pinnedComment && (
|
||||
|
||||
@@ -176,8 +176,8 @@ export function ProfilesPage() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-3xl p-6">
|
||||
<div className="mb-6 flex items-center justify-between">
|
||||
<div className="mx-auto max-w-3xl p-4 sm:p-6">
|
||||
<div className="mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="flex gap-1 rounded-lg bg-surface-1 p-1">
|
||||
{(["profiles", "presets", "templates"] as const).map((t2) => (
|
||||
<button
|
||||
@@ -194,7 +194,7 @@ export function ProfilesPage() {
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{tab === "profiles" && (
|
||||
<>
|
||||
<Button variant="ghost" size="sm" onClick={handleExportProfiles}>
|
||||
|
||||
@@ -196,8 +196,8 @@ export function SettingsPage() {
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-2xl p-6">
|
||||
<div className="mb-6 flex items-center justify-between">
|
||||
<div className="mx-auto max-w-2xl p-4 sm:p-6">
|
||||
<div className="mb-6 flex flex-wrap items-center justify-between gap-2">
|
||||
<h1 className="text-lg font-bold text-text-primary">{t("settings.title")}</h1>
|
||||
{IS_TAURI && (
|
||||
<div className="flex gap-2">
|
||||
|
||||
@@ -97,6 +97,18 @@ export interface SettingsData {
|
||||
* by `healSettings`.
|
||||
*/
|
||||
logRetentionDays: number;
|
||||
/**
|
||||
* v0.28.0 legal consent. The `CURRENT_TERMS_VERSION` (see
|
||||
* `@config/legal`) the user last accepted on the first-run consent gate.
|
||||
* `0` = never accepted → the gate shows. Bumped via `acceptLegalConsent`;
|
||||
* re-shows whenever `CURRENT_TERMS_VERSION` is raised (terms changed).
|
||||
* Persisted inside the existing `ytdescgen-settings` record — no cookie,
|
||||
* no new storage key. A malformed value is coerced to `0` by
|
||||
* {@link healSettings} so a corrupt file re-shows the gate, never skips it.
|
||||
*/
|
||||
legalConsentVersion: number;
|
||||
/** ISO timestamp of the most recent acceptance, or `null`. Audit-only. */
|
||||
legalConsentAt: string | null;
|
||||
}
|
||||
|
||||
function detectBrowserLanguage(): SupportedLanguage {
|
||||
@@ -148,6 +160,8 @@ export const initialSettings: SettingsData = {
|
||||
},
|
||||
sidebarCollapsed: false,
|
||||
logRetentionDays: 7,
|
||||
legalConsentVersion: 0,
|
||||
legalConsentAt: null,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -202,5 +216,18 @@ export function healSettings(raw: unknown): SettingsData {
|
||||
);
|
||||
}
|
||||
|
||||
// v0.28.0: `legalConsentVersion` added. A non-number / non-finite / negative
|
||||
// value must fall through to "never accepted" (0) so a corrupt or
|
||||
// hand-edited file re-shows the consent gate rather than silently skipping
|
||||
// it. (Additive — the trailing spread back-fills legacy payloads to 0.)
|
||||
if (
|
||||
typeof incoming.legalConsentVersion !== "number" ||
|
||||
!Number.isFinite(incoming.legalConsentVersion)
|
||||
) {
|
||||
incoming.legalConsentVersion = initialSettings.legalConsentVersion;
|
||||
} else {
|
||||
incoming.legalConsentVersion = Math.max(0, Math.floor(incoming.legalConsentVersion));
|
||||
}
|
||||
|
||||
return { ...initialSettings, ...incoming } as SettingsData;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { create } from "zustand";
|
||||
import { persist, createJSONStorage } from "zustand/middleware";
|
||||
import type { SupportedLanguage } from "@engine/types";
|
||||
import { CURRENT_TERMS_VERSION } from "@config/legal";
|
||||
import { saveSettings, loadSettings } from "@utils/storage-adapter";
|
||||
import {
|
||||
healSettings,
|
||||
@@ -19,6 +20,8 @@ interface SettingsState extends SettingsData {
|
||||
setSetting: <K extends keyof SettingsData>(key: K, value: SettingsData[K]) => void;
|
||||
setTitleFormat: (patch: Partial<TitleFormatConfig>) => void;
|
||||
toggleEditorAccordion: (id: string) => void;
|
||||
/** Record acceptance of the current legal terms (dismisses the consent gate). */
|
||||
acceptLegalConsent: () => void;
|
||||
}
|
||||
|
||||
const STORE_KEY = "ytdescgen-settings";
|
||||
@@ -50,6 +53,12 @@ export const useSettingsStore = create<SettingsState>()(
|
||||
[id]: !state.editorAccordionState[id],
|
||||
},
|
||||
})),
|
||||
|
||||
acceptLegalConsent: () =>
|
||||
set({
|
||||
legalConsentVersion: CURRENT_TERMS_VERSION,
|
||||
legalConsentAt: new Date().toISOString(),
|
||||
}),
|
||||
}),
|
||||
{
|
||||
name: STORE_KEY,
|
||||
@@ -116,6 +125,8 @@ export function extractData(state: SettingsData): SettingsData {
|
||||
editorAccordionState: state.editorAccordionState,
|
||||
sidebarCollapsed: state.sidebarCollapsed,
|
||||
logRetentionDays: state.logRetentionDays,
|
||||
legalConsentVersion: state.legalConsentVersion,
|
||||
legalConsentAt: state.legalConsentAt,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { IS_TAURI } from "./platform";
|
||||
import { IS_TAURI, IS_MOBILE } from "./platform";
|
||||
|
||||
export async function saveFile(content: string, filename: string): Promise<void> {
|
||||
if (IS_TAURI) {
|
||||
// On Android `IS_TAURI` is true, but the native save dialog + std::fs path
|
||||
// write doesn't work under scoped storage — fall through to the blob
|
||||
// download (lands in Downloads). Desktop keeps the native "Save As" dialog.
|
||||
if (IS_TAURI && !IS_MOBILE) {
|
||||
const { save } = await import("@tauri-apps/plugin-dialog");
|
||||
const { invoke } = await import("@tauri-apps/api/core");
|
||||
const path = await save({ defaultPath: filename });
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import { IS_TAURI } from "./platform";
|
||||
import { logger } from "./logger";
|
||||
|
||||
const EXTERNAL_SCHEME = /^(https?|mailto|tel):/i;
|
||||
|
||||
function isExternalHref(href: string | null | undefined): href is string {
|
||||
return !!href && EXTERNAL_SCHEME.test(href);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open an external URL from any platform.
|
||||
*
|
||||
* In a Tauri webview (desktop **and** Android) a plain `<a target="_blank">`
|
||||
* does nothing useful — the webview has no tab/window manager. Route through
|
||||
* the opener plugin instead, which dispatches the URL to the OS (system browser
|
||||
* for http/https, mail client for mailto, dialer for tel). On the web build
|
||||
* there is no Tauri runtime, so fall back to a normal new tab.
|
||||
*/
|
||||
export async function openExternal(url: string): Promise<void> {
|
||||
if (IS_TAURI) {
|
||||
try {
|
||||
const { openUrl } = await import("@tauri-apps/plugin-opener");
|
||||
await openUrl(url);
|
||||
return;
|
||||
} catch (e) {
|
||||
logger.error("opener", `Failed to open external URL: ${url}`, String(e));
|
||||
}
|
||||
}
|
||||
window.open(url, "_blank", "noopener,noreferrer");
|
||||
}
|
||||
|
||||
/** Drop `target="_blank"` from an external anchor (see installExternalLinkHandler). */
|
||||
function stripBlankTarget(el: Element): void {
|
||||
if (
|
||||
el.tagName === "A" &&
|
||||
el.getAttribute("target") === "_blank" &&
|
||||
isExternalHref(el.getAttribute("href"))
|
||||
) {
|
||||
el.removeAttribute("target");
|
||||
}
|
||||
}
|
||||
|
||||
function stripWithin(root: ParentNode): void {
|
||||
if (root instanceof Element) stripBlankTarget(root);
|
||||
root.querySelectorAll?.('a[target="_blank"]').forEach(stripBlankTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make external links work inside a Tauri (especially Android) webview.
|
||||
*
|
||||
* Two Android problems, both verified on a device:
|
||||
* 1. A real tap on `<a target="_blank">` triggers the webview's native
|
||||
* `onCreateWindow`, which Tauri tries to satisfy via the shell plugin's
|
||||
* `open` — and there is no such binary on Android, so it throws an uncaught
|
||||
* "Scoped shell IO error". JS `preventDefault` does NOT stop this native
|
||||
* path, so we remove the `target="_blank"` attribute entirely (links are
|
||||
* re-rendered by React, hence the MutationObserver).
|
||||
* 2. Without `target="_blank"`, a click would navigate the app's *own*
|
||||
* webview away from the UI — so we intercept the click in the **capture**
|
||||
* phase (before the webview's default handling) and hand the URL to the
|
||||
* opener plugin, which opens the system browser.
|
||||
*
|
||||
* No-op on the web build, where native `target="_blank"` already opens a new
|
||||
* tab correctly.
|
||||
*/
|
||||
export function installExternalLinkHandler(): void {
|
||||
if (!IS_TAURI) return;
|
||||
|
||||
// React mounts/re-renders links after this runs, so strip on every change.
|
||||
stripWithin(document);
|
||||
new MutationObserver((mutations) => {
|
||||
for (const m of mutations) {
|
||||
m.addedNodes.forEach((node) => {
|
||||
if (node instanceof Element) stripWithin(node);
|
||||
});
|
||||
}
|
||||
}).observe(document.documentElement, { childList: true, subtree: true });
|
||||
|
||||
// Capture phase: run before the webview's own navigation / new-window logic.
|
||||
document.addEventListener(
|
||||
"click",
|
||||
(e) => {
|
||||
if (e.defaultPrevented || e.button !== 0) return;
|
||||
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
||||
const anchor = (e.target as Element | null)?.closest?.("a") ?? null;
|
||||
const href = anchor?.getAttribute("href") ?? null;
|
||||
if (!isExternalHref(href)) return;
|
||||
e.preventDefault();
|
||||
void openExternal(href);
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
@@ -2,3 +2,12 @@
|
||||
// context (vitest's node environment) — no `window` means no Tauri.
|
||||
export const IS_TAURI =
|
||||
typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
||||
|
||||
// True inside the Android WebView. On Android, Tauri still injects
|
||||
// `__TAURI_INTERNALS__` (so `IS_TAURI` is true), but the desktop file-save
|
||||
// dialog + `std::fs` write to an arbitrary path is unreliable under Android's
|
||||
// scoped storage. Use this to route file EXPORT through the in-WebView blob
|
||||
// download instead. Desktop and web both report false here, so existing
|
||||
// branches are unaffected. iOS is out of scope (we only ship Android).
|
||||
export const IS_MOBILE =
|
||||
typeof navigator !== "undefined" && /Android/i.test(navigator.userAgent);
|
||||
@@ -1,3 +1,34 @@
|
||||
/**
|
||||
* Generate a RFC 4122 v4 UUID.
|
||||
*
|
||||
* `crypto.randomUUID()` is the fast path, but it only exists in Chrome/WebView
|
||||
* **92+** — older Android System WebViews (e.g. the Chromium 91 that ships with
|
||||
* some emulator images, or any device whose WebView hasn't been updated) don't
|
||||
* have it. Because `generateId()` runs at module load (e.g. the log store's
|
||||
* `CURRENT_SESSION_ID`), an unguarded `crypto.randomUUID()` would throw during
|
||||
* boot and black-screen the whole app on those WebViews. Fall back to a manual
|
||||
* v4 built on `crypto.getRandomValues` (present since Chrome 11), and finally
|
||||
* `Math.random` only if even that is missing.
|
||||
*/
|
||||
export function generateId(): string {
|
||||
return crypto.randomUUID();
|
||||
const c: Crypto | undefined =
|
||||
typeof globalThis !== "undefined" ? globalThis.crypto : undefined;
|
||||
|
||||
if (c && typeof c.randomUUID === "function") {
|
||||
return c.randomUUID();
|
||||
}
|
||||
|
||||
const bytes = new Uint8Array(16);
|
||||
if (c && typeof c.getRandomValues === "function") {
|
||||
c.getRandomValues(bytes);
|
||||
} else {
|
||||
for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
|
||||
}
|
||||
// RFC 4122 §4.4: set the version (4) and variant (10xx) bits.
|
||||
// (`?? 0` only satisfies noUncheckedIndexedAccess — index 6/8 always exist.)
|
||||
bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;
|
||||
bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;
|
||||
|
||||
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { needsConsent, CURRENT_TERMS_VERSION, LEGAL_DOCS } from "@config/legal";
|
||||
|
||||
/**
|
||||
* Guards for the pure legal config driving the v0.28.0 consent gate. The gate
|
||||
* is a boot-time blocker, so the version logic must be exactly right: anything
|
||||
* below the current version (or a non-number) re-shows the gate; the current
|
||||
* version (or higher) lets the app through.
|
||||
*/
|
||||
describe("needsConsent", () => {
|
||||
it("requires consent at version 0 (never accepted)", () => {
|
||||
expect(needsConsent(0)).toBe(true);
|
||||
});
|
||||
|
||||
it("requires consent below the current version (terms changed)", () => {
|
||||
expect(needsConsent(CURRENT_TERMS_VERSION - 1)).toBe(true);
|
||||
});
|
||||
|
||||
it("passes once the current version is accepted", () => {
|
||||
expect(needsConsent(CURRENT_TERMS_VERSION)).toBe(false);
|
||||
});
|
||||
|
||||
it("passes for a future stored version (never downgrades)", () => {
|
||||
expect(needsConsent(CURRENT_TERMS_VERSION + 5)).toBe(false);
|
||||
});
|
||||
|
||||
it("treats a non-number as needing consent", () => {
|
||||
expect(needsConsent(undefined as unknown as number)).toBe(true);
|
||||
expect(needsConsent(NaN)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("LEGAL_DOCS", () => {
|
||||
it("covers all four documents with absolute https GitHub URLs + consentGate label keys", () => {
|
||||
expect(LEGAL_DOCS.map((d) => d.id)).toEqual(["terms", "privacy", "disclaimer", "license"]);
|
||||
for (const doc of LEGAL_DOCS) {
|
||||
expect(doc.url).toMatch(/^https:\/\/github\.com\/poli0981\/youtube-generator\/blob\/main\//);
|
||||
expect(doc.labelKey).toMatch(/^consentGate\.doc/);
|
||||
}
|
||||
});
|
||||
|
||||
it("has a unique id and url per doc", () => {
|
||||
expect(new Set(LEGAL_DOCS.map((d) => d.id)).size).toBe(LEGAL_DOCS.length);
|
||||
expect(new Set(LEGAL_DOCS.map((d) => d.url)).size).toBe(LEGAL_DOCS.length);
|
||||
});
|
||||
});
|
||||
@@ -92,6 +92,8 @@ describe("healSettings", () => {
|
||||
editorAccordionState: { gameInfo: false, videoSettings: true },
|
||||
sidebarCollapsed: true,
|
||||
logRetentionDays: 14,
|
||||
legalConsentVersion: 1,
|
||||
legalConsentAt: "2026-06-13T00:00:00.000Z",
|
||||
};
|
||||
const healed = healSettings(complete);
|
||||
expect(healed).toEqual(complete);
|
||||
@@ -214,4 +216,21 @@ describe("healSettings", () => {
|
||||
expect(healed.genrePlaylists).toEqual({});
|
||||
}
|
||||
});
|
||||
|
||||
it("back-fills legalConsentVersion 0 + legalConsentAt null for a legacy payload (pre-v0.28)", () => {
|
||||
// A settings file written before the consent gate existed has neither
|
||||
// key — it must heal to "never accepted" so the gate shows on first run.
|
||||
const healed = healSettings({ theme: "dark" as const, hashtagCount: 3 });
|
||||
expect(healed.legalConsentVersion).toBe(0);
|
||||
expect(healed.legalConsentAt).toBeNull();
|
||||
});
|
||||
|
||||
it("preserves a stored legalConsentVersion and coerces malformed/negative values to 0", () => {
|
||||
expect(healSettings({ legalConsentVersion: 1 }).legalConsentVersion).toBe(1);
|
||||
expect(
|
||||
healSettings({ legalConsentVersion: "nope" as unknown as number }).legalConsentVersion,
|
||||
).toBe(0);
|
||||
expect(healSettings({ legalConsentVersion: -3 }).legalConsentVersion).toBe(0);
|
||||
expect(healSettings({ legalConsentVersion: 2.9 }).legalConsentVersion).toBe(2);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
import { describe, it, expect, afterEach, vi } from "vitest";
|
||||
import { generateId } from "@utils/uuid";
|
||||
|
||||
// RFC 4122 v4: 8-4-4-4-12 hex, version nibble "4", variant nibble 8/9/a/b.
|
||||
const V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
||||
|
||||
describe("generateId", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("returns a valid v4 UUID via the native crypto.randomUUID path", () => {
|
||||
expect(generateId()).toMatch(V4);
|
||||
});
|
||||
|
||||
it("falls back to a valid v4 UUID when crypto.randomUUID is missing (Android WebView < 92)", () => {
|
||||
// Chromium 91 has getRandomValues but not randomUUID — the exact gap that
|
||||
// black-screened the app at boot before the fallback existed.
|
||||
const real = globalThis.crypto;
|
||||
vi.stubGlobal("crypto", {
|
||||
getRandomValues: (a: Uint8Array) => real.getRandomValues(a),
|
||||
});
|
||||
expect(generateId()).toMatch(V4);
|
||||
});
|
||||
|
||||
it("falls back to a valid v4 UUID when crypto is entirely absent", () => {
|
||||
vi.stubGlobal("crypto", undefined);
|
||||
expect(generateId()).toMatch(V4);
|
||||
});
|
||||
|
||||
it("produces unique values across many calls", () => {
|
||||
const ids = new Set(Array.from({ length: 1000 }, () => generateId()));
|
||||
expect(ids.size).toBe(1000);
|
||||
});
|
||||
});
|
||||
@@ -21,12 +21,31 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
build: {
|
||||
// Tauri ships the *system* WebView. On Android that can be an old, frozen
|
||||
// Chromium (e.g. some emulator system images sit at ~91 until the user
|
||||
// updates Android System WebView), which chokes on Vite's modern default
|
||||
// target and renders a blank/black screen. Downlevel the bundle for Tauri
|
||||
// builds so it runs on those older WebViews; the web (GitHub Pages) build
|
||||
// keeps Vite's modern default. Desktop WebViews are evergreen, so a lower
|
||||
// target is a harmless no-op there.
|
||||
target: isTauri ? "es2020" : undefined,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: {
|
||||
react: ["react", "react-dom"],
|
||||
router: ["react-router-dom"],
|
||||
i18n: ["i18next", "react-i18next", "i18next-resources-to-backend"],
|
||||
// Vite 8 bundles with Rolldown, which only accepts the function form of
|
||||
// manualChunks (the object form is a Rollup-only API). Anchored [\\/]
|
||||
// regexes keep each vendor in its own chunk without cross-matching —
|
||||
// react-router* and react-i18next must not fall into the "react" chunk.
|
||||
manualChunks(id) {
|
||||
if (/[\\/]node_modules[\\/]react(-dom)?[\\/]/.test(id)) return "react";
|
||||
if (/[\\/]node_modules[\\/]react-router(-dom)?[\\/]/.test(id))
|
||||
return "router";
|
||||
if (
|
||||
/[\\/]node_modules[\\/](i18next|react-i18next|i18next-resources-to-backend)[\\/]/.test(
|
||||
id,
|
||||
)
|
||||
)
|
||||
return "i18n";
|
||||
return undefined;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||