Compare commits
59
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5edd0d6bfd | ||
|
|
b920d3567e | ||
|
|
3b0db9a95f | ||
|
|
bbf201c30f | ||
|
|
e56c32e76a | ||
|
|
841df7d246 | ||
|
|
b244063555 | ||
|
|
bb0a40cfae | ||
|
|
0c7fb31165 | ||
|
|
11a822a881 | ||
|
|
08be7d1ff8 | ||
|
|
03174084cf | ||
|
|
d6de8764f1 | ||
|
|
ff8c1133e6 | ||
|
|
c9facc59ec | ||
|
|
b8f245dee4 | ||
|
|
8c32435d8a | ||
|
|
1f9621b5cd | ||
|
|
f69941aae3 | ||
|
|
913e82f6b5 | ||
|
|
6e0b02a050 | ||
|
|
6b6613cca0 | ||
|
|
31fa18627e | ||
|
|
7b0189a1f9 | ||
|
|
d2100d2d40 | ||
|
|
48d5bb035c | ||
|
|
86c5dec087 | ||
|
|
216eabcec8 | ||
|
|
69f6e32ebf | ||
|
|
779aa1943e | ||
|
|
1a67dc6901 | ||
|
|
967c0c4024 | ||
|
|
2408c40e50 | ||
|
|
d955d045f0 | ||
|
|
8c064ebd98 | ||
|
|
e138758656 | ||
|
|
9671bca9c4 | ||
|
|
633298c049 | ||
|
|
938d35b613 | ||
|
|
43d850d1d4 | ||
|
|
10ef68bfdc | ||
|
|
7e31791439 | ||
|
|
2d92d5ba81 | ||
|
|
fdb55f3018 | ||
|
|
12b0099238 | ||
|
|
e5776fa38c | ||
|
|
fe7e89d57e | ||
|
|
f637d89aae | ||
|
|
1e5720eecc | ||
|
|
08ebae0416 | ||
|
|
546802210e | ||
|
|
da22625178 | ||
|
|
f53b7df65b | ||
|
|
303f978a60 | ||
|
|
8405c6fa49 | ||
|
|
7ea308293a | ||
|
|
9f156d1f2c | ||
|
|
79be06b804 | ||
|
|
b4e32eac63 |
No files matched your search
+47
-5
@@ -1,10 +1,11 @@
|
||||
# Dependabot configuration.
|
||||
#
|
||||
# This file exists only to configure SECURITY updates for cargo in /src-tauri.
|
||||
# Version updates stay disabled (open-pull-requests-limit: 0); npm and
|
||||
# GitHub Actions keep GitHub's default security-update behavior.
|
||||
# Three ecosystems: npm (the app), cargo (the Tauri shell), and github-actions
|
||||
# (the workflows). Security updates are on repo-wide by default; the entries
|
||||
# below add scheduled VERSION updates so the tree does not silently rot between
|
||||
# advisories, and carry the ignore rules that keep unfixable alerts quiet.
|
||||
#
|
||||
# Why the ignores: `rand` and `glib` are transitive dependencies of tauri,
|
||||
# Why the cargo ignores: `rand` and `glib` are transitive dependencies of tauri,
|
||||
# and their security fixes require semver-major bumps that the dependency
|
||||
# tree does not allow, so every Dependabot security-update job for them
|
||||
# fails with `security_update_not_possible` (runs 27387346373, 27387346324):
|
||||
@@ -20,12 +21,53 @@
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 5
|
||||
commit-message:
|
||||
prefix: "chore(deps)"
|
||||
prefix-development: "chore(deps-dev)"
|
||||
groups:
|
||||
# One PR per family instead of one per package. A split React or
|
||||
# typescript-eslint bump is never independently mergeable anyway, and
|
||||
# CI has to run for each PR.
|
||||
react:
|
||||
patterns: ["react", "react-dom", "@types/react", "@types/react-dom"]
|
||||
i18n:
|
||||
patterns: ["i18next*", "react-i18next"]
|
||||
tauri:
|
||||
patterns: ["@tauri-apps/*"]
|
||||
lint-and-format:
|
||||
patterns: ["eslint*", "@eslint/*", "typescript-eslint", "prettier*", "knip"]
|
||||
build-tooling:
|
||||
patterns: ["vite", "vitest", "@vitejs/*", "tailwindcss", "postcss", "autoprefixer", "tsx"]
|
||||
ignore:
|
||||
# Majors land in their own planned release (see docs/ROADMAP.md) because
|
||||
# each one needs a real migration — React 19, Tailwind 4 and ESLint 10 all
|
||||
# change APIs the app uses directly. Dependabot handles minor + patch.
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major"]
|
||||
|
||||
- package-ecosystem: "cargo"
|
||||
directory: "/src-tauri"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
# No version-update PRs; this entry only feeds ignore rules to security updates.
|
||||
# No version-update PRs; this entry only feeds ignore rules to security
|
||||
# updates. The Rust side is pinned to whatever tauri's tree allows.
|
||||
open-pull-requests-limit: 0
|
||||
ignore:
|
||||
- dependency-name: "rand"
|
||||
- dependency-name: "glib"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 3
|
||||
commit-message:
|
||||
prefix: "ci"
|
||||
groups:
|
||||
actions:
|
||||
patterns: ["*"]
|
||||
@@ -6,18 +6,64 @@ on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
# Least privilege. The job only reads the repo — it publishes nothing, comments
|
||||
# nowhere. Declaring it explicitly also silences CodeQL's
|
||||
# `actions/missing-workflow-permissions`, which otherwise flags the implicit
|
||||
# (and much wider) default token scope.
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# A force-push or a quick follow-up commit makes the older run worthless. Cancel
|
||||
# it instead of paying for both — except on `main`, where every commit's result
|
||||
# is a historical record the release process reads back.
|
||||
concurrency:
|
||||
group: ci-${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-node@v6
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run typecheck
|
||||
- run: npm run lint
|
||||
- run: npm run validate:locales
|
||||
- run: npm run test:run
|
||||
- run: npm run build
|
||||
|
||||
# --- correctness ------------------------------------------------------
|
||||
# `typecheck` covers src/ (what Vite actually builds); `typecheck:all`
|
||||
# adds tests/ and scripts/, which went unchecked until v0.35.0 and were
|
||||
# hiding three silently-stale fixture fields.
|
||||
- name: Type check (src)
|
||||
run: npm run typecheck
|
||||
- name: Type check (tests + scripts)
|
||||
run: npm run typecheck:all
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
- name: Validate locales
|
||||
run: npm run validate:locales
|
||||
- name: Test
|
||||
run: npm run test:run
|
||||
|
||||
# --- consistency ------------------------------------------------------
|
||||
- name: Check formatting
|
||||
run: npm run format:check
|
||||
- name: Check dead code
|
||||
run: npm run knip
|
||||
# The release ritual bumps SIX version fields by hand. This is the only
|
||||
# thing that notices when one is missed — see scripts/check-version-sync.ts.
|
||||
- name: Check version sync
|
||||
run: npm run check:version
|
||||
|
||||
# --- security ---------------------------------------------------------
|
||||
# Advisory-only: a fresh high-severity advisory in a transitive dep must
|
||||
# not turn every unrelated PR red before Dependabot has had a chance to
|
||||
# open its fix PR. The Dependabot alerts tab is the source of truth.
|
||||
- name: Audit dependencies
|
||||
run: npm audit --audit-level=high
|
||||
continue-on-error: true
|
||||
|
||||
# --- build ------------------------------------------------------------
|
||||
- name: Build
|
||||
run: npm run build
|
||||
@@ -16,8 +16,8 @@ jobs:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-node@v6
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
@@ -17,21 +17,21 @@ jobs:
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
ref: ${{ github.event.inputs.tag || github.ref }}
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
- uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "17"
|
||||
|
||||
- uses: android-actions/setup-android@v3
|
||||
- uses: android-actions/setup-android@v4
|
||||
|
||||
- name: Install Android NDK (r27 LTS)
|
||||
run: sdkmanager "ndk;27.3.13750724"
|
||||
@@ -41,7 +41,7 @@ jobs:
|
||||
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
|
||||
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
@@ -79,11 +79,30 @@ jobs:
|
||||
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
|
||||
# Keep the APK regardless of whether the release upload works, so a
|
||||
# broken upload never costs a 20-minute rebuild.
|
||||
- name: Upload APK as workflow artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
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
|
||||
name: ytdescgen-android-apk
|
||||
path: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
|
||||
if-no-files-found: error
|
||||
|
||||
# Uses `gh` (pre-installed on every runner) rather than a third-party
|
||||
# action. `softprops/action-gh-release@v3` resolved the target release
|
||||
# from GITHUB_REF instead of the `tag_name` it was given, so on a tag push
|
||||
# it looked for a release tagged `refs/tags/v0.35.0` and on a
|
||||
# workflow_dispatch it looked for one tagged `refs/heads/main` — neither
|
||||
# exists, so it tried to CREATE a release on a branch ref and got
|
||||
# "Resource not accessible by integration". The v0.35.0 APK was built
|
||||
# three times before this was pinned down.
|
||||
#
|
||||
# `gh release upload` takes the tag as a positional argument and cannot
|
||||
# make that mistake. `--clobber` makes a re-run idempotent.
|
||||
- name: Upload APK to draft release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ github.event.inputs.tag || github.ref_name }}
|
||||
APK: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
|
||||
run: |
|
||||
gh release upload "$TAG" "$APK" --clobber --repo "${{ github.repository }}"
|
||||
@@ -52,12 +52,12 @@ jobs:
|
||||
bundleArgs: ""
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
# On `workflow_dispatch` checkout the requested tag; on a
|
||||
# tag push we already get the tag commit by default.
|
||||
ref: ${{ github.event.inputs.tag || github.ref }}
|
||||
- uses: actions/setup-node@v6
|
||||
- uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
librsvg2-dev \
|
||||
patchelf
|
||||
- run: npm ci
|
||||
- uses: tauri-apps/tauri-action@v0
|
||||
- uses: tauri-apps/tauri-action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# AppImage bundling on hosted runners flakes: linuxdeploy (itself
|
||||
|
||||
+246
@@ -2,6 +2,252 @@
|
||||
|
||||
All notable changes to YTDescGen ship as tagged releases on `main`.
|
||||
|
||||
## v0.38.0 — 2026-08-17
|
||||
|
||||
Two new languages: **Portuguese (Brazil)** and **Indonesian**. Brazil is a
|
||||
top-three market for gameplay viewing and Indonesia the largest in Southeast
|
||||
Asia; both use Latin script, so neither needed font or layout work.
|
||||
|
||||
### Added
|
||||
|
||||
- **`pt-BR` and `id` locales** — 1,562 strings each. Both are complete: titles, every description block, all 248 content warnings, tech notes, playthrough notes, pinned comments, playlist copy, and the whole interface from the editor through Settings, Batch, Social and Logs.
|
||||
- **Per-language tag pools** ([src/engine/tag-generator.ts](src/engine/tag-generator.ts)) — `CORE_TAGS_BY_LANG` and `MULTILINGUAL_TAGS` gained entries for both, so a Brazilian video gets `gameplay sem comentários` and `detonado` rather than falling back to English tags.
|
||||
- **Region-aware browser detection** ([src/store/settings-heal.ts](src/store/settings-heal.ts)) — `detectBrowserLanguage` now matches the full BCP-47 tag before the bare language, or `pt-BR` would be reduced to `pt` and never found. Any other Portuguese variant also resolves to `pt-BR` rather than falling through to English.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **`docs/I18N.md` was wrong about what registering a locale takes.** It said `SUPPORTED_LANGUAGES` was "the only registration step". It is one of four, and they fail differently: the `SupportedLanguage` union and the two tag-pool records are compile errors, but `detectBrowserLanguage`'s own hardcoded copy of the list fails **silently** — the language works and simply never auto-selects for a visitor whose browser is set to it. `SUPPORTED_LANGUAGES` is also not type-bound to the union, and every consumer casts, so a mismatch between the first two compiles cleanly. Corrected, and `SUPPORTED_LANGUAGES` now carries a `satisfies` clause that binds it to the union.
|
||||
- **`__dirname` in the Vite and Vitest configs** replaced with `import.meta.dirname`. Vite 8's native config loader — planned to become the default — doesn't provide the CJS global, and warned on every run.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- **New guard: [tests/i18n/locale-registration.test.ts](tests/i18n/locale-registration.test.ts)** checks the picker list against the locale directories on disk *in both directions*, plus namespace files, flags, native names and tag pools. It exists specifically to close the two registration gaps that fail silently.
|
||||
- 115 UI keys were not hand-translated at all — their English text is byte-identical to a string already translated in `templates.json` (graphics presets, ray-tracing modes, difficulty names, content-warning labels), so they are copied across. Translating those twice risks a checkbox and the rendered description disagreeing about what the same option is called.
|
||||
- Left as English on purpose, matching what the Spanish locale already does: vendor product names (NVIDIA DLSS, AMD FSR, Intel XeSS, Fluid Motion Frames), platform brands (Ko-fi, Patreon, Discord, Steam, TikTok), hardware acronyms (CPU, GPU, RAM), genre terms that are loanwords in both languages (RPG, FPS, MMO, Indie, Metroidvania, Roguelike, Battle Royale), and example URLs / emails in placeholders. **pt-BR 1,344 / 1,562 and id 1,308 / 1,562 strings differ from English**; the remainder are those pass-throughs, not gaps.
|
||||
- Both are **AI-translated and not native-reviewed** — recorded in [DISCLAIMER.md](DISCLAIMER.md) alongside JA / ES / KO / ZH. Native-speaker corrections are the most welcome contribution to this project; `src/i18n/locales/<code>/*.json` can be edited straight from GitHub's web UI.
|
||||
- Validator now **1,562 keys × 8 locales**. typecheck, typecheck:all, lint, format:check, validate:locales, knip, check:version, **698 tests** and build all pass; verified live in the browser — both languages appear in every picker, generate correctly translated titles and descriptions, and translate the interface itself.
|
||||
- Six manifests bumped 0.37.0 → 0.38.0. (v0.36.0 was skipped: the dependency release shipped first and had already taken 0.37.0.)
|
||||
|
||||
## v0.37.0 — 2026-08-17
|
||||
|
||||
A **dependency modernization** release. No user-facing feature changes; the app
|
||||
should behave identically. Every major the project had been sitting on is now
|
||||
current, and the two new lint rules that came with them found four real
|
||||
performance bugs.
|
||||
|
||||
### Changed
|
||||
|
||||
- **React 18 → 19**, `@types/react` 19, `@vitejs/plugin-react` 6. One source change: React 19 types `useRef<T>(null)` as `RefObject<T | null>` rather than `RefObject<T>` — the old type quietly claimed a ref was non-null before its element mounted. [ScrollToTopButton](src/components/layout/ScrollToTopButton.tsx) now matches, which keeps its existing null check honest.
|
||||
- **Tailwind 3 → 4** ([src/styles/globals.css](src/styles/globals.css)) — configuration moves from `tailwind.config.ts` (deleted) into CSS. The design tokens live in an `@theme` block that maps Tailwind's names onto the existing `:root` / `.light` variables, so the runtime theme toggle keeps working exactly as before. `darkMode: "class"` becomes `@custom-variant dark`, because the app toggles a class on `<html>` rather than following the OS. PostCSS now loads `@tailwindcss/postcss`. Verified in the browser in both themes.
|
||||
- **ESLint 9 → 10** + `eslint-plugin-react-hooks` 5 → 7, which enables the React Compiler diagnostics.
|
||||
- **Zustand 4 → 5**, **i18next 23 → 26**, **react-i18next 15 → 17**, `@testing-library/*`, `typescript-eslint` 8.67, plus the Vite / Vitest / tsx / knip / Tauri-plugin patch line.
|
||||
|
||||
### Fixed
|
||||
|
||||
The new `react-hooks/set-state-in-effect` rule flagged seven call sites. Four were real extra render passes and are fixed:
|
||||
|
||||
- **[use-online-status](src/hooks/use-online-status.ts)** rewritten to `useSyncExternalStore`. It was re-reading `navigator.onLine` inside an effect to close the gap between the first render and the listeners attaching — subscribing properly removes the gap rather than patching it, and costs one render fewer on every mount.
|
||||
- **[ShortcutHelpModal](src/components/ui/ShortcutHelpModal.tsx)** derives its filter from `open` instead of resetting state in an effect, so a modal that spends most of its life closed no longer schedules work on unrelated parent updates.
|
||||
- **[DraftIndicator](src/components/editor/DraftIndicator.tsx)** and **[use-languages-ready](src/hooks/use-languages-ready.ts)** now guard their setters.
|
||||
|
||||
Three remain as **warnings**, deliberately: they genuinely sync state *from* an external source (i18next bundle readiness, a text mirror of a numeric store field, and a `useMemo` the compiler can't preserve). Each needs a restructure rather than a guard, so they are recorded in [eslint.config.js](eslint.config.js) rather than silenced or used as a reason to hold back the upgrade.
|
||||
|
||||
### Not upgraded
|
||||
|
||||
- **`lucide-react` stays at 0.577.0.** 1.x removes every brand icon (Instagram, Facebook, GitHub, YouTube, X) — upstream dropped them for trademark reasons. Taking 1.x would mean either a generic globe next to a Facebook link, or re-adding the marks ourselves and inheriting the exposure lucide just shed. Neither is worth it: 0.577 already delivered the win, cutting the main bundle **175 kB → 137 kB**.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- `knip` now ignores `tailwindcss`, whose only reference after the migration is `@import "tailwindcss"` in CSS — which knip doesn't follow.
|
||||
- Full gate green: typecheck, typecheck:all, lint, format:check, validate:locales, knip, check:version, **692 tests**, build. Verified live in the browser: both themes render, icons intact, editor and batch functional.
|
||||
- Six manifests bumped 0.35.0 → 0.37.0. (0.36.0 is reserved for the two new locales.)
|
||||
|
||||
## v0.35.0 — 2026-08-17
|
||||
|
||||
A **guardrails** release. Four things the app quietly let you do wrong — publish
|
||||
a Batch description missing its contact block, copy output YouTube would reject,
|
||||
paste a novel into a field, and export a file without being asked where to put
|
||||
it — now can't happen.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Split contact emails now render in Batch** ([src/hooks/use-render-options.ts](src/hooks/use-render-options.ts), [src/pages/BatchPage.tsx](src/pages/BatchPage.tsx)) — with **Settings → Split contact email** on, the Batch tab showed only the legacy single `📧 Business inquiries:` line while the Output tab correctly showed the grouped `📧 BUSINESS / CONTACT` block. The engine was never at fault: `renderAll` had three call sites each hand-copying the same twelve settings fields, and BatchPage's copy was missing `splitContactEmail` and `showThirdPartyAds`. An absent flag defaults to `false`, so the wrong branch ran silently. The mapping now lives in one hook, guarded from both sides — a missing key is a compile error (`Required<SettingsRenderOptions>`) *and* a named test failure. **The SPONSORS & PARTNERS block was being dropped in Batch for the same reason and now renders too, so Batch descriptions get longer if you had either toggle on.**
|
||||
- **Exports ask where to save** ([src/utils/file-ops.ts](src/utils/file-ops.ts)) — every JSON export (Settings, Profiles, Presets, Templates, Social, Log) bypassed the one writer that branched per platform and dumped straight into `Downloads`, even on desktop where a native Save As dialog was available the whole time. One writer now serves all seven: native **Save As** on Tauri desktop, the **file picker** on Chromium browsers, and the download fallback on Android / Firefox / Safari. Cancelling is silent — dismissing a dialog is a decision, not a failure. Settings Import/Export is also no longer desktop-only.
|
||||
- **`ValidatedInput` no longer destroys good input** ([src/components/ui/ValidatedInput.tsx](src/components/ui/ValidatedInput.tsx)) — on an invalid value it called `onChange("")`, wiping the stored value while the box still showed your text. Backspacing one character out of a complete URL silently emptied the field, and autosave persisted the empty. It now simply doesn't commit, keeping the last valid value. Separately, the box never re-synced when the value changed underneath it, so applying a profile or preset left stale text on screen disagreeing with the store.
|
||||
|
||||
### Added
|
||||
|
||||
- **Over-limit output can't be copied** ([src/engine/limits.ts](src/engine/limits.ts)) — if any one of title / description / tags is over its YouTube limit, none of them can be copied, on **Output and Batch**. The engine has returned `warnings` since v0.5 and nothing ever read it; three ad-hoc checks had grown up instead, and the one in `CopyAllBar` skipped every check whenever more than one output language was selected. Batch also gained the description and tag counters it never had. Scoped sensibly: one over-limit part blocks itself and Copy All Batch, not the other 99.
|
||||
- **Strict Mode** ([src/utils/editor-issues.ts](src/utils/editor-issues.ts)) — a **Settings → Guardrails** toggle, off by default. When on, Generate / Copy / Export are blocked while any field has a hard error, with a banner naming each one. Errors only: a working link that merely doesn't match a platform's usual prefix stays a warning, because blocking it would strand anyone on a vanity domain. Derived from state rather than from mounted inputs, so it works from any page and also catches bad data that arrived by import. The log export stays ungated — a debugging export shouldn't be held hostage by an unrelated bad URL.
|
||||
- **Field length caps** ([src/config/field-limits.ts](src/config/field-limits.ts)) — `maxLength` appeared nowhere in the codebase before this release. Caps are grouped by what a field holds (URL 200, email 320, short name 100, label 300, long text 2000, timestamps 5000) and wired at 53 call sites. Imports are clamped too, since `maxLength` only constrains typing.
|
||||
- **Emails hard-stop at three per field** ([src/utils/validation.ts](src/utils/validation.ts)) — typing a fourth is refused outright instead of wiping the field. Enforced on the *increase*, so a field that already holds four (from an older profile) stays editable down to three, and a half-typed `a@b.com,c@` is never punished.
|
||||
- **Collapsible Settings sections** ([src/pages/settings/GenrePlaylistsSection.tsx](src/pages/settings/GenrePlaylistsSection.tsx)) — **Genre Playlists** renders one input per genre (42 of them) and was the tallest block on the page. It now ships collapsed with a filled-count badge. The other eight sections became accordions too, defaulting open.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Settings persist **v11 → v12** (`strictMode`, `settingsAccordionState`), with `SCHEMA_VERSIONS.settings` bumped in lockstep. Both are *coerced*, not merely back-filled — a hand-edited `"strictMode": "yes"` is truthy in JS, and switching a seatbelt on by accident is the opposite of an opt-in. `SCHEMA_VERSIONS.profile` corrected 1 → 2, left behind when profile-store bumped in v0.34.0.
|
||||
- `SettingsPage` split 544 → 347 lines, extracting the import/export IO and the Genre Playlists section.
|
||||
- 16 i18n keys per locale across all six locales (validator **999 ui / 563 templates**). typecheck, lint, locale validation, dead-code, formatting, version-sync and **692 tests** (621 + 71) pass; verified live in the browser — Batch renders all three contact lines, a bad Steam URL disables Batch generation and names the field, a fourth email is refused with the three intact, and Genre Playlists opens to 42 inputs behind a `0/42` badge.
|
||||
- Six manifests bumped 0.34.0 → 0.35.0.
|
||||
|
||||
## v0.34.0 — 2026-07-20
|
||||
|
||||
A **feature** release that lets creators publish a different email per purpose instead of a
|
||||
single catch-all address — so viewers, sponsors, and studios each reach the right inbox.
|
||||
|
||||
### Added
|
||||
|
||||
- **Split contact email by purpose** ([src/pages/SettingsPage.tsx](src/pages/SettingsPage.tsx), [src/components/editor/ContactEmailEditor.tsx](src/components/editor/ContactEmailEditor.tsx)) — a new **Settings → Description** toggle (off by default). Off keeps today's single `📧 Business inquiries:` line, unchanged. On splits the editor's Contact Email field into three: **Contact** (general), **Advertising / sponsorship**, and **Game keys & playtest** — each accepting up to 3 comma-separated addresses via the existing email validator.
|
||||
- **Grouped contact block** ([src/engine/description-builder.ts](src/engine/description-builder.ts)) — when the toggle is on, the description renders a localized `📧 BUSINESS / CONTACT` block with one labeled line per non-empty field (`📧 Contact:`, `🤝 Advertising:`, `🎮 Game keys & playtest:`). Empty fields are skipped and the whole block drops when all three are empty — same skip logic as the Community block. The existing `contactEmail` is reused as the Contact line, so no saved data moves.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Two editor fields (`adEmail`, `gameKeyEmail`) thread through defaults, the store (persist **v17 → v18**), `GeneratorInput`, the editor → engine mapping, template snapshots, and Profiles (persist **v1 → v2**) — guarded by the existing parity test. The `splitContactEmail` toggle mirrors `showThirdPartyAds` end-to-end: the settings store (persist **v10 → v11**, `SCHEMA_VERSIONS.settings` in lockstep), both output hooks, and the render options. Both migrations are additive `""` / `false` back-fills, so existing drafts, profiles, and settings upgrade untouched.
|
||||
- Twelve i18n keys per locale added (8 ui + 4 templates) across all six locales (validator **983 ui / 563 templates**). typecheck, lint, locale validation, and **621 tests** (613 + 8: split render on/off/partial/empty, v18 migration back-fill/coerce/preserve) pass; verified live.
|
||||
- Five manifests bumped 0.33.0 → 0.34.0.
|
||||
|
||||
## v0.33.0 — 2026-07-13
|
||||
|
||||
A **feature** release that turns the description's Community block into the channel's
|
||||
full "join the chat" hub: two new invite links (**Signal**, **Instagram group chat**)
|
||||
and **Facebook Group** moved in from the generic Social list.
|
||||
|
||||
### Added
|
||||
|
||||
- **Signal + Instagram community invites** ([src/components/editor/CommunityEditor.tsx](src/components/editor/CommunityEditor.tsx), [src/utils/validation.ts](src/utils/validation.ts)) — two new inputs in the **Community** section that feed the `💬 COMMUNITY` description block for **every** output language (like Messenger). Signal expects `https://signal.group/#<id>`; Instagram expects the group-chat invite `https://www.instagram.com/j/<id>` or the short `https://ig.me/j/<id>` (distinct from the Instagram **profile** link, which stays in Social). Both hard-reject anything off-format via `ValidatedInput`, so a broken invite never reaches the description.
|
||||
- **Facebook Group moved into Community** ([src/config/social-fields.ts](src/config/social-fields.ts), [src/engine/description-builder.ts](src/engine/description-builder.ts)) — the old generic `fb_group` Social entry is now a dedicated `facebookGroupLink` community field with its own strict `https://facebook.com/groups/<id>` validator (tolerating `www.` / `m.` / `web.` and a trailing slash). It renders in the Community block for all languages. The block order is Messenger → Signal → Instagram → Facebook Group → Zalo (Vietnamese-only).
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Three editor fields (`signalGroupLink`, `instagramGroupLink`, `facebookGroupLink`) thread through defaults, the store (persist **v16 → v17**), `GeneratorInput`, the editor → engine mapping, and template snapshots — guarded by the existing parity test. The v17 migration **lifts** a legacy `social.fb_group` value into `facebookGroupLink` and drops the dead key; `normalizeEditorPatch` does the same when a pre-move profile / preset / template is applied. Consequence: like the other community links, Facebook Group is no longer stored inside Profiles.
|
||||
- Nine i18n keys per locale added, one (`social.fb_group`) removed, across all six locales (validator **975 ui / 559 templates**). typecheck, lint, locale validation, and **613 tests** (583 + 30: three new validators, v17 migration incl. the fb_group lift, community render/order/all-language cases, mapping parity) pass; verified live — Vietnamese output shows all five lines in order with a localized heading, English output drops the Zalo line while keeping the rest, and a malformed Signal link surfaces an inline hard-reject error.
|
||||
- Five manifests bumped 0.32.1 → 0.33.0.
|
||||
|
||||
## v0.32.1 — 2026-07-12
|
||||
|
||||
A **hotfix** to v0.32.0. The Messenger Community field accepted the wrong link
|
||||
shape: `https://m.me/[id]` is a personal-page link, while a community/channel
|
||||
invite is `https://m.me/ch/[id]` (e.g. `https://m.me/ch/Abb1hmBhU_97UMCF/`).
|
||||
Creators following the in-app example published a link that did not open the
|
||||
community.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Messenger community link format** ([src/utils/validation.ts](src/utils/validation.ts)) — `MESSENGER_URL_REGEX` now requires the `/ch/` segment (trailing slash optional) and hard-rejects the old bare form, so a wrong link can no longer reach the description. The shown example (`MESSENGER_URL_EXPECTED`) and the placeholder in all six locales moved to `https://m.me/ch/yourid`; stale doc comments were refreshed alongside.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Engine and store are untouched — the link is printed verbatim and the field's type and persist shape are unchanged, so no migration was needed. Validation, engine, and migration tests updated, with new trailing-slash-accept and bare-form-reject cases.
|
||||
- Five manifests bumped 0.32.0 → 0.32.1.
|
||||
|
||||
## v0.32.0 — 2026-07-08
|
||||
|
||||
A **feature** release adding the first two "join the chat" community links, in a
|
||||
single `💬 COMMUNITY` description block — the block that v0.33.0 later grew to
|
||||
five entries.
|
||||
|
||||
### Added
|
||||
|
||||
- **Messenger community + Zalo group** ([src/components/editor/CommunityEditor.tsx](src/components/editor/CommunityEditor.tsx), [src/utils/validation.ts](src/utils/validation.ts)) — a new **Community** section feeding a localized `💬 COMMUNITY` block. Messenger renders for **every** output language. Zalo is a Vietnam-audience app, so its input only appears — and its line only renders — when the output language is Vietnamese, mirroring the existing VN donate block; a value entered while in Vietnamese survives a language switch. Both links are hard-validated (`validateMessengerUrl` / `validateZaloGroupUrl`) so a malformed URL never reaches the output.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Two editor fields (`messengerCommunityLink`, `zaloGroupLink`) thread through defaults, the store (persist **v15 → v16**, an additive back-fill), `GeneratorInput`, the editor → engine mapping, and template snapshots — guarded by the existing parity test.
|
||||
- i18n across all six locales (validator **967 ui / 559 templates**). typecheck, lint, locale validation, and **581 tests** (560 + 21: two new validators, the v16 migration, and community render/language-gating cases) pass.
|
||||
- Five manifests bumped 0.31.0 → 0.32.0.
|
||||
|
||||
## v0.31.0 — 2026-06-28
|
||||
|
||||
A **feature** release for the Playlist Generator: the pinned comment a series
|
||||
needs on its latest video, and an honest answer to "why did this playlist stop?"
|
||||
|
||||
### Added
|
||||
|
||||
- **Status-adaptive playlist pinned comment** ([src/engine/playlist-builder.ts](src/engine/playlist-builder.ts)) — a new `buildPlaylistComment` engine function produces a pinned comment for the series' latest video whose wording follows the playlist status (completed / dropped / incomplete / in progress), rather than one generic template for all four.
|
||||
- **Dropped reasons** ([src/config/dropped-reasons.ts](src/config/dropped-reasons.ts), [src/pages/PlaylistPage.tsx](src/pages/PlaylistPage.tsx)) — when a series is marked **dropped**, a multi-select of six predefined reasons (`😴 boring`, `🐌 performance`, `🐛 bugs`, `🗑️ delisted`, `📉 low views`, `⏳ time`) plus a free-text "other reason" field. Selected reasons render in **both** the playlist description and the pinned comment. Reason labels are localized in both namespaces — `ui` for the selection chips, `templates` for the rendered output — the same split content warnings use.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Playlist state stays local to the page; nothing was added to the editor store, so there is no migration in this release.
|
||||
- i18n across all six locales (validator **959 ui / 558 templates**). `playlist-builder` gained its first test file — **197 lines** covering comment generation per status and dropped-reason rendering.
|
||||
- Five manifests bumped 0.30.0 → 0.31.0.
|
||||
|
||||
## v0.30.0 — 2026-06-27
|
||||
|
||||
A **feature** release adding two things creators kept doing by hand: advertising a
|
||||
game's **playtest / early-access signup**, and getting **stopped before a bad number**
|
||||
breaks a batch.
|
||||
|
||||
### Added
|
||||
|
||||
- **Playtest section** ([src/components/editor/PlaytestEditor.tsx](src/components/editor/PlaytestEditor.tsx), [src/config/playtest-platforms.ts](src/config/playtest-platforms.ts)) — a new entry in the **Store & Social** group: a signup link, a platform dropdown (Steam Playtest, Epic, itch.io, Discord / Community, Other), and an invite count. The invite input maxes out at the selected platform's cap (≤ 100); switching to a lower-cap platform clamps an over-budget count down. It renders into the description **only when a link is entered** — no toggle, no video-type gating — exactly like Store Links. The description block ([src/engine/description-builder.ts](src/engine/description-builder.ts)) is a localized `🧪 PLAYTEST / EARLY ACCESS` heading, the platform-labelled link, and an optional `🎟️ N invites available` line (emitted only for a positive whole number, so a stray decimal / negative can never produce a broken line).
|
||||
- **Invalid-number guarding** ([src/utils/validation.ts](src/utils/validation.ts)) — two pure validators (`validateIntegerInRange`, `validateBatchRange`) now reject negative, decimal, out-of-range, and `end < start` / over-100-span inputs. The **Batch** ([src/pages/BatchPage.tsx](src/pages/BatchPage.tsx)) and **Social bulk** ([src/pages/SocialPage.tsx](src/pages/SocialPage.tsx)) part-range inputs **disable the Generate button** and show a warning when the range is invalid; **Playlist** "Total videos" ([src/pages/PlaylistPage.tsx](src/pages/PlaylistPage.tsx)) and the new Playtest invite count warn inline and guard the output. The `Input` primitive ([src/components/ui/Input.tsx](src/components/ui/Input.tsx)) gained optional `errorText` / `helpText` props (backward-compatible).
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Three editor fields (`playtestLink`, `playtestPlatform`, `playtestInvites`) thread through the store (persist **v14 → v15** migration: unknown platform → default, invite count clamped to an integer in `[0, 100]`), `GeneratorInput`, and the editor → engine mapping — guarded by the existing parity test.
|
||||
- 60 new i18n strings across all six locales (validator **948 ui / 544 templates**). typecheck, lint, locale validation, and **544 tests** (517 + 27: playtest block, validators, v15 migration, mapping parity) pass; verified live — the block renders and localizes (EN / JA), the itch.io cap clamps invites 80 → 50, decimals warn, and Batch generation blocks on `end < start` and over-100 ranges.
|
||||
- Five manifests bumped 0.29.3 → 0.30.0.
|
||||
|
||||
## v0.29.3 — 2026-06-20
|
||||
|
||||
A follow-up **hotfix** to v0.29.2. Forwarding the always-English `tEn` translator
|
||||
to multi-language Output (so the AI-translation disclaimer could render `EN · LOCAL`)
|
||||
also turned the **content-warnings, tech-notes, and playthrough-notes** blocks
|
||||
bilingual in every multi-language tab — because `tEn` was the single shared signal
|
||||
for bilingual rendering. Each multi-language tab is already a dedicated single
|
||||
language, so those "video" blocks should be that language only; only the
|
||||
translation disclaimer is meant to stay bilingual.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Multi-language tabs render content blocks single-language again** ([src/hooks/use-multilang-output.ts](src/hooks/use-multilang-output.ts), [src/engine/description-builder.ts](src/engine/description-builder.ts), [src/engine/template-renderer.ts](src/engine/template-renderer.ts)) — a new `bilingualContentBlocks` render option (default `true`) gates the three video blocks. The multi-language hook passes `false`, so content warnings / tech notes / playthrough notes show the target language only, while the `▸ 🌐 ABOUT THIS TRANSLATION` disclaimer keeps the raw `tEn` and stays bilingual `EN · LOCAL`. Single-language output is unchanged (default `true` preserves the v0.11/v0.12 bilingual blocks).
|
||||
|
||||
### Under the hood
|
||||
|
||||
- The Social / cross-post path ([src/engine/social-post-builder.ts](src/engine/social-post-builder.ts)) is intentionally left as-is — it is driven by separate hooks, never wired through the multi-language Output tabs, and its bilingual content warnings are long-standing v0.24.0 behavior. The asymmetry is deliberate.
|
||||
- Additive, default-preserving change: the engine option defaults to the old behavior, so every existing caller and test is unaffected. typecheck, lint, locale validation (937/542), and all **517 tests** (513 + 4 new `bilingualContentBlocks` gate tests) pass; verified live — multi-language JA tab shows JA-only content blocks with a bilingual disclaimer, the EN tab omits the disclaimer, and single-language JA still renders content warnings bilingually.
|
||||
- Five manifests bumped 0.29.2 → 0.29.3.
|
||||
|
||||
## v0.29.2 — 2026-06-20
|
||||
|
||||
A one-line **hotfix**. The opt-in *"Show translation-quality notice"* setting
|
||||
(the AI-translation disclaimer, v0.24.0) had no effect when the Output page was
|
||||
showing **two or more languages at once** — the multi-language output hook had
|
||||
drifted out of sync with the single-language one and never forwarded the setting
|
||||
to the engine.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **AI-translation disclaimer now appears in multi-language Output** ([src/hooks/use-multilang-output.ts](src/hooks/use-multilang-output.ts)) — the multi-language hook now forwards `showTranslationQuality` to `renderAll`, matching [useGeneratedOutput](src/hooks/use-generated-output.ts). The same patch also restores `showThirdPartyAds` (an identical latent gap — its disclaimer was dropped in multi-language mode too) and the always-English `tEn` translator, so the bilingual blocks render `EN · LOCAL` instead of target-language-only. Selecting 2+ languages and viewing a non-English/Vietnamese tab now shows the `▸ 🌐 ABOUT THIS TRANSLATION` block. Single-language output and the Batch page were already correct.
|
||||
|
||||
### Under the hood
|
||||
|
||||
- One-file fix; no engine, store, config, or i18n changes (the `translationQuality` template keys already exist in all six locales). typecheck, lint, locale validation (937/542), all **513 tests**, and the production build pass; verified live — the JA tab renders the block bilingually while the EN/VI tabs correctly omit it.
|
||||
- This hook has drifted out of sync before (a prior `showSponsorCredit` miss), so the recurrence is a known class of bug.
|
||||
- Five manifests bumped 0.29.1 → 0.29.2.
|
||||
|
||||
## 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
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ Use the templates in `.github/ISSUE_TEMPLATE/`:
|
||||
If your change adds or removes any user-facing string:
|
||||
|
||||
1. Update the locale schema at `src/i18n/locales/_schema.json` first.
|
||||
2. Add the key to **all 6 locales** (`en` / `vi` / `ja` / `es` / `ko` / `zh`).
|
||||
2. Add the key to **all 8 locales** (`en` / `vi` / `ja` / `es` / `ko` / `zh` / `pt-BR` / `id`).
|
||||
3. `npm run validate:locales` must pass.
|
||||
|
||||
Native-speaker corrections to AI-translated locales (JA / ES / KO / ZH) are especially welcome — see [DISCLAIMER.md](./DISCLAIMER.md) for the current translation-quality status.
|
||||
|
||||
+3
-1
@@ -17,7 +17,7 @@ See also: [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) § "AI-Assisted D
|
||||
|
||||
## Translation quality
|
||||
|
||||
The application UI ships in six languages. Authoring quality varies:
|
||||
The application UI ships in eight languages. Authoring quality varies:
|
||||
|
||||
| Locale | Authoring | Notes |
|
||||
| --- | --- | --- |
|
||||
@@ -27,6 +27,8 @@ The application UI ships in six languages. Authoring quality varies:
|
||||
| Spanish (`es`) | AI-translated | Not native-reviewed. Regional voice (LatAm vs. Castilian) not specifically targeted. |
|
||||
| Korean (`ko`) | AI-translated | Not native-reviewed. Honorific register chosen for neutrality, not specific cultural fit. |
|
||||
| Chinese (`zh`) | AI-translated | Simplified Chinese only. Not native-reviewed. |
|
||||
| Portuguese, Brazil (`pt-BR`) | AI-translated | Not native-reviewed. Brazilian Portuguese specifically — European Portuguese is not separately targeted. |
|
||||
| Indonesian (`id`) | AI-translated | Not native-reviewed. Standard Indonesian; gaming loanwords kept in English where that is the common usage. |
|
||||
|
||||
If you're a native speaker and spot mistranslations, please open an issue or PR — see [CONTRIBUTING.md](./CONTRIBUTING.md) § "i18n Contributions".
|
||||
|
||||
|
||||
@@ -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), as a ~8 MB native desktop app (Windows / macOS / Linux), or as an installable Android APK — all from one Tauri 2 codebase.
|
||||
Generate YouTube titles, descriptions, and tags in eight 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)
|
||||
@@ -22,14 +22,15 @@ Built for the gameplay no-commentary niche — especially horror / scary games
|
||||
## Features
|
||||
|
||||
- **20 video types** — Full Gameplay, Part, Boss Fight, Boss No-Hit, Ending, Speedrun, 100%, DLC, NG+, Challenge, Side Quest, Secret, Comparison, Guide, Mods, Collectibles, Livestream, Gacha Quest, Demo, Demo Part.
|
||||
- **6 UI languages** — English, Vietnamese, Japanese, Spanish, Korean, Chinese. *(VI authored by a native speaker; JA / ES / KO / ZH AI-translated — see [DISCLAIMER.md](./DISCLAIMER.md).)*
|
||||
- **8 UI languages** — English, Vietnamese, Japanese, Spanish, Korean, Chinese, Portuguese (Brazil), Indonesian. *(VI authored by a native speaker; JA / ES / KO / ZH / PT-BR / ID AI-translated — see [DISCLAIMER.md](./DISCLAIMER.md).)*
|
||||
- **40+ game genres** — across action, RPG, FPS, horror, soulslike, indie, simulation, fighting, and more.
|
||||
- **248 content-warning IDs** across 12 groups — spoilers, photosensitive/VFX, audio, dialogue/language, phobias (incl. color phobias), mental health, social phenomena, internet/digital life, sensitive themes (incl. method-specific death/violence and suggestive imagery), horror-specific, playstyle, and gameplay disclosure (mods / cheats / glitches / guide-assisted / educational purpose). Sets viewer expectations before they hit play.
|
||||
- **Profile system** — save channel / social / rig info once, reuse across every video.
|
||||
- **Game presets** — save game name + store links once, reuse across the entire part series.
|
||||
- **Snapshot templates** — save full-form configurations and recall in one click.
|
||||
- **Smart tag generation** — combines genre pool, platform, quality tier, multilingual hooks, and trending terms; auto-dedup and 500-char-limit aware.
|
||||
- **Character counters** — real-time limits for title (100), description (5000), tags (500).
|
||||
- **Character counters** — real-time limits for title (100), description (5000), tags (500). If **any one** is over, no field can be copied — partial copying is how a half-finished description gets published.
|
||||
- **Guardrails** — hard length caps on every input field, a three-address cap per email field, and an opt-in **Strict Mode** that blocks Generate / Copy / Export while any field holds an error.
|
||||
- **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).
|
||||
@@ -87,6 +88,7 @@ Architecture overview: [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md).
|
||||
|
||||
| Document | What's in it |
|
||||
| --- | --- |
|
||||
| **[Wiki](https://github.com/poli0981/youtube-generator/wiki)** | **User documentation** — quick start, glossary, every field and its limit, guardrails, troubleshooting, FAQ. Start here if you're using the app rather than building it. |
|
||||
| [Development Guide](./docs/DEVELOPMENT.md) | Toolchain, IDE setup, build commands, troubleshooting. *(Also: [Vietnamese](./docs/i18n/vi/DEVELOPMENT.md).)* |
|
||||
| [Architecture](./docs/ARCHITECTURE.md) | Layer model, data flow, engine design. |
|
||||
| [Features](./docs/FEATURES.md) | Full feature matrix. |
|
||||
|
||||
+44
-2
@@ -261,13 +261,55 @@ Zustand Stores:
|
||||
├───────────────────────────────────────────────┤
|
||||
│ SettingsStore │
|
||||
│ - theme: "dark" | "light" │
|
||||
│ - defaultLanguage: SupportedLanguage │
|
||||
│ - defaultGenres: GenreId[] │
|
||||
│ - appLanguage / defaultOutputLanguage │
|
||||
│ - strictMode, settingsAccordionState (v12) │
|
||||
│ - (flags: quality badge / copyright / ...) │
|
||||
│ Middleware: persist (localStorage + file) │
|
||||
├───────────────────────────────────────────────┤
|
||||
│ PendingInvalidStore (0.35) │
|
||||
│ - entries: Record<fieldId, PendingInvalid> │
|
||||
│ Middleware: NONE — in-flight typing, not data │
|
||||
└───────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Settings → engine options
|
||||
|
||||
`renderAll` is called from three places (the Output hook, the multi-language
|
||||
Output hook, BatchPage). Each used to hand-copy the same twelve settings fields
|
||||
into an options object, and they had drifted — BatchPage's copy silently omitted
|
||||
`splitContactEmail` and `showThirdPartyAds`, so Batch rendered a different
|
||||
description than Output from identical data.
|
||||
|
||||
`src/hooks/use-render-options.ts` is now the single mapping, with two guards:
|
||||
|
||||
- **Compile-time** — `buildRenderOptions` builds a
|
||||
`Required<SettingsRenderOptions>`, so omitting a key is a type error.
|
||||
- **Runtime** — `tests/hooks/render-options-parity.test.ts` diffs the produced
|
||||
keys against `SETTINGS_DERIVED_RENDER_KEYS` in both directions.
|
||||
|
||||
`RenderOptions` is split accordingly: `SettingsRenderOptions` (from the user)
|
||||
plus `RenderOptionOverrides` (`tEn`, `bilingualContentBlocks` — decided per call
|
||||
site, since Output wants bilingual content blocks and Batch does not).
|
||||
|
||||
### Validation state
|
||||
|
||||
Two sources, unioned by `useStrictBlock`, because neither alone is sufficient:
|
||||
|
||||
| Source | Catches | Why it's needed |
|
||||
|---|---|---|
|
||||
| `collectEditorIssues` (pure, over `EditorData`) | Saved values that fail validation | Bad data from imports — `ValidatedInput` refuses to commit invalid text, so imports are the main way it gets in |
|
||||
| `PendingInvalidStore` | Typed text that is invalid and therefore **not** saved | Otherwise a field showing a red error is invisible to every gate, because the store behind it holds the last good value |
|
||||
|
||||
Both are filtered through `isRelevantIssueId`, so a field that isn't currently
|
||||
shown (`adEmail` with split-email off, `zaloGroupLink` outside Vietnamese
|
||||
output) can never block on a value with no visible input to fix it.
|
||||
|
||||
The first implementation registered issues from the inputs themselves and
|
||||
cleared on unmount. It typechecked and had passing tests, and did nothing: the
|
||||
fields live on the Editor page while the gates live on Batch / Social / Output,
|
||||
so navigating away cleared every issue. Deriving from state removes the mount
|
||||
coupling entirely.
|
||||
|
||||
## 4. i18n Architecture
|
||||
|
||||
```
|
||||
|
||||
+9
-5
@@ -86,14 +86,18 @@ npm run dev
|
||||
| `npm run dev` | Vite dev server, hot reload, web only. |
|
||||
| `npm run build` | Production web bundle into `dist/`. |
|
||||
| `npm run preview` | Serve the production bundle for sanity-testing. |
|
||||
| `npm run typecheck` | `tsc --noEmit`. Run before every PR. |
|
||||
| `npm run typecheck` | `tsc --noEmit` over `src/` — what Vite actually builds. |
|
||||
| `npm run typecheck:all` | Same, plus `tests/` and `scripts/`, which the base config deliberately excludes. Added in v0.35.0 after it turned out they had **never** been type-checked — and immediately found three fields silently missing from the editor→engine parity fixture. |
|
||||
| `npm run lint` | ESLint. Use `npm run lint:fix` to autofix. |
|
||||
| `npm run format` | Prettier write across `src/`. |
|
||||
| `npm run format` | Prettier write across `src/`, `tests/`, `scripts/`. |
|
||||
| `npm run format:check` | Same, read-only. CI gate. Markdown and the locale JSON are deliberately out of scope — Prettier reflows prose and expands the schema's compact arrays by ~1600 lines for no benefit. |
|
||||
| `npm run knip` | Dead-code / unused-dependency check. CI gate. |
|
||||
| `npm run check:version` | Asserts all **six** version fields agree (`package.json`, both `package-lock.json` entries, `tauri.conf.json`, `Cargo.toml`, `Cargo.lock`). The only thing that notices a missed one. |
|
||||
| `npm run test` | Vitest watch mode. |
|
||||
| `npm run test:run` | Vitest single-run (for CI / pre-commit). |
|
||||
| `npm run test:coverage` | Coverage report into `coverage/`. |
|
||||
| `npm run validate:locales` | Enforces all 6 locales match `_schema.json` exactly. **Must pass before any locale-touching PR merges.** |
|
||||
| `npm run generate:locale` | Scaffold an empty locale from `_schema.json` for a new language. |
|
||||
| `npm run validate:locales` | Enforces all 8 locales match `_schema.json` exactly. **Must pass before any locale-touching PR merges.** |
|
||||
| `npm run generate:locale` | Scaffold a locale from the English source. `--lang <code>`, plus optional `--copy-english` / `--force`. (Advertised since v0.1 but only actually written in v0.35.0.) |
|
||||
| `npm run tauri:dev` | Tauri desktop in dev mode (auto-restarts on Rust or frontend changes). |
|
||||
| `npm run tauri:build` | Tauri release binary for the current platform. |
|
||||
|
||||
@@ -136,7 +140,7 @@ docs/I18N.md). The restart advice above still applies to all of them.
|
||||
|
||||
### Pre-commit hook fails on `validate:locales` but I didn't touch locales
|
||||
|
||||
You probably added a new key to `_schema.json` indirectly via the engine types (`src/engine/types.ts` → `CONTENT_WARNINGS`). New IDs require translations in all 6 locales.
|
||||
You probably added a new key to `_schema.json` indirectly via the engine types (`src/engine/types.ts` → `CONTENT_WARNINGS`). New IDs require translations in all 8 locales.
|
||||
|
||||
## See Also
|
||||
|
||||
|
||||
+39
-10
@@ -11,9 +11,9 @@ structure, and tag bias. The complete table — every type with its icon and
|
||||
the extra fields the editor reveals — is in
|
||||
[Content Inventory](./CONTENT-INVENTORY.md).
|
||||
|
||||
## 🌐 Languages (6 shipped)
|
||||
## 🌐 Languages (8 shipped)
|
||||
|
||||
All six locales ship today — UI strings and description templates fully
|
||||
All eight locales ship today — UI strings and description templates fully
|
||||
translated and parity-validated by `npm run validate:locales`.
|
||||
|
||||
| Code | Language | Native Name | Status |
|
||||
@@ -24,9 +24,12 @@ translated and parity-validated by `npm run validate:locales`.
|
||||
| `es` | Spanish | Español | ✅ Shipped |
|
||||
| `ko` | Korean | 한국어 | ✅ Shipped |
|
||||
| `zh` | Chinese (Simplified) | 简体中文 | ✅ Shipped |
|
||||
| `pt-BR` | Portuguese (Brazil) | Português (BR) | ✅ Shipped |
|
||||
| `id` | Indonesian | Bahasa Indonesia | ✅ Shipped |
|
||||
|
||||
Further locales (French, German, Portuguese, Russian, Thai, Arabic) are
|
||||
tracked in [Roadmap § 5.3](./ROADMAP.md).
|
||||
Further locales (French, German, Russian, Thai, Arabic) are tracked in
|
||||
[Roadmap § 5.3](./ROADMAP.md). Arabic additionally needs RTL layout work —
|
||||
see [I18N.md](./I18N.md).
|
||||
|
||||
Each language requires:
|
||||
- `ui.json` — UI labels, buttons, placeholders, error messages
|
||||
@@ -227,16 +230,42 @@ interface HistoryEntry {
|
||||
| Setting | Type | Default | Description |
|
||||
|---------|------|---------|-------------|
|
||||
| Theme | dark / light | dark | App color theme |
|
||||
| Default UI Language | SupportedLanguage | en | Language for app interface |
|
||||
| Default Output Language | SupportedLanguage | en | Default language for generated output |
|
||||
| Default Genre | Genre | action | Pre-selected genre on new session |
|
||||
| Auto-save Draft | boolean | true | Auto-save form state to localStorage |
|
||||
| Show Character Count | boolean | true | Display char counters on output |
|
||||
| App Language | SupportedLanguage | browser-detected | Language of the interface |
|
||||
| Default Output Language | SupportedLanguage | en | Pre-selected for new drafts |
|
||||
| Show Character Count | boolean | true | Display char counters on output. **Does not** affect copy blocking |
|
||||
| Compact Tag Display | boolean | false | Tags as comma list vs chip display |
|
||||
| **Strict Mode** | boolean | **false** | v0.35.0. Blocks Generate / Copy / Export while any field has a hard error |
|
||||
| History Limit | number | 100 | Max history entries to keep |
|
||||
| Include Multilingual Tags | boolean | true | Add JA/VI tags to tag output |
|
||||
| Log Retention | 1–90 days | 7 | Log files older than this are deleted at boot |
|
||||
| Include Multilingual Tags | boolean | true | Add per-language tags to tag output |
|
||||
| Include Trending Tags | boolean | true | Add year-based trending tags |
|
||||
| Hashtag Count | 1-3 | 3 | Number of hashtags to generate |
|
||||
| Genre Playlists | map | `{}` | One playlist URL per genre (42), collapsed by default |
|
||||
|
||||
`Default Genre` and `Auto-save Draft` were removed in v0.22.0 and v0.3
|
||||
respectively — the draft autosaves unconditionally, so the toggle was dead.
|
||||
|
||||
### Description toggles
|
||||
|
||||
`showCopyright` · `showUsagePolicy` · `showSponsorCredit` · `showGameCopyright`
|
||||
· `showThirdPartyAds` · `showTranslationQuality` · `splitContactEmail` ·
|
||||
`showPinnedCommentTemplate` · `pinnedCommentIncludeAskNextGame` ·
|
||||
`pinnedCommentIncludeGenrePlaylist`
|
||||
|
||||
## 🛡 Guardrails (v0.35.0)
|
||||
|
||||
Three independent mechanisms. The first two are always on.
|
||||
|
||||
| Mechanism | Scope |
|
||||
|---|---|
|
||||
| **Character limits** | Title 100 / description 5,000 / tags 500. If **any one** is over, **no** field can be copied — on Output and Batch. Batch scopes per part; Copy All Batch blocks if any part is over |
|
||||
| **Field limits** | Hard `maxLength` per category: URL 200, email 320, short name 100, label 300, long text 2,000, timestamps 5,000, numeric 10. Imported values are clamped too |
|
||||
| **Strict Mode** | Opt-in. Blocks Generate / Copy / Export on hard errors only; warnings (e.g. a working link on a non-standard prefix) never block. Log export is exempt |
|
||||
|
||||
Emails are capped at **three per field**, enforced on the increase so an
|
||||
over-cap legacy value stays editable. Invalid input is never committed to the
|
||||
store, so a malformed URL cannot reach the generated description whether Strict
|
||||
Mode is on or off.
|
||||
|
||||
## 🖥 Desktop App Features (Tauri)
|
||||
|
||||
|
||||
+32
-1
@@ -45,8 +45,18 @@ npm run generate:locale -- --lang es
|
||||
# This creates:
|
||||
# src/i18n/locales/es/ui.json (all keys, empty values)
|
||||
# src/i18n/locales/es/templates.json (all keys, empty values)
|
||||
|
||||
# Prefer editing in place over working from blanks? Pre-fill with English:
|
||||
npm run generate:locale -- --lang es --copy-english
|
||||
|
||||
# Overwrite an existing locale directory:
|
||||
npm run generate:locale -- --lang es --force
|
||||
```
|
||||
|
||||
The output is key-for-key identical to English, so `npm run validate:locales`
|
||||
passes the moment the files are written — it checks key parity, not whether the
|
||||
values were actually translated.
|
||||
|
||||
Or copy from English and translate:
|
||||
|
||||
```bash
|
||||
@@ -205,16 +215,37 @@ cp -r src/i18n/locales/en src/i18n/locales/es
|
||||
|
||||
### Step 4: Register the language
|
||||
|
||||
**Four edits, not one.** This section previously claimed `SUPPORTED_LANGUAGES`
|
||||
was the only registration step; it isn't, and the missing edits fail in
|
||||
different ways — one at compile time, one silently at runtime.
|
||||
|
||||
```typescript
|
||||
// src/i18n/index.ts — add to SUPPORTED_LANGUAGES (the only registration step)
|
||||
// 1. src/i18n/index.ts — the flag + native name shown in every language picker
|
||||
export const SUPPORTED_LANGUAGES = [
|
||||
{ id: "en", label: "English", flag: "🇬🇧", nativeName: "English" },
|
||||
{ id: "vi", label: "Vietnamese", flag: "🇻🇳", nativeName: "Tiếng Việt" },
|
||||
{ id: "ja", label: "Japanese", flag: "🇯🇵", nativeName: "日本語" },
|
||||
{ id: "es", label: "Spanish", flag: "🇪🇸", nativeName: "Español" }, // ← Add here
|
||||
] as const;
|
||||
|
||||
// 2. src/engine/types.ts — the union the whole engine is typed against
|
||||
export type SupportedLanguage = "en" | "vi" | "ja" | "es" | "ko" | "zh";
|
||||
|
||||
// 3. src/store/settings-heal.ts — detectBrowserLanguage's own hardcoded copy.
|
||||
// Miss this and the language works, but is never auto-selected for a
|
||||
// first-time visitor whose browser is set to it.
|
||||
const supported: SupportedLanguage[] = ["en", "vi", "ja", "es", "ko", "zh"];
|
||||
|
||||
// 4. src/engine/tag-generator.ts — MULTILINGUAL_TAGS (see Step 5).
|
||||
// Typed `Record<SupportedLanguage, …>`, so TypeScript catches this one.
|
||||
```
|
||||
|
||||
> `SUPPORTED_LANGUAGES` is **not** type-bound to `SupportedLanguage`, and every
|
||||
> consumer casts (`lang.id as SupportedLanguage`). A mismatch between edits 1
|
||||
> and 2 therefore compiles cleanly and fails at runtime. Do both.
|
||||
|
||||
`npm run generate:locale` prints this checklist on success.
|
||||
|
||||
No import or `resources` edits needed (v0.26+): locales are lazy-loaded
|
||||
through a dynamic `import("./locales/<code>/<ns>.json")`, so Vite picks the
|
||||
new files up automatically as async chunks — **the file names must stay
|
||||
|
||||
+67
-1
@@ -323,13 +323,40 @@ jobs:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run typecheck
|
||||
|
||||
# correctness
|
||||
- run: npm run typecheck # src/
|
||||
- run: npm run typecheck:all # + tests/ and scripts/
|
||||
- run: npm run lint
|
||||
- run: npm run validate:locales
|
||||
- run: npm run test:run
|
||||
|
||||
# consistency
|
||||
- run: npm run format:check
|
||||
- run: npm run knip
|
||||
- run: npm run check:version
|
||||
|
||||
# security (advisory — a fresh transitive advisory must not redden
|
||||
# every unrelated PR before Dependabot opens its fix)
|
||||
- run: npm audit --audit-level=high
|
||||
continue-on-error: true
|
||||
|
||||
- run: npm run build
|
||||
```
|
||||
|
||||
The workflow also declares `permissions: contents: read` (least privilege, and
|
||||
it clears CodeQL's `actions/missing-workflow-permissions` alert) and a
|
||||
`concurrency` group that cancels superseded runs everywhere except `main`, where
|
||||
each commit's result is a historical record the release process reads back.
|
||||
|
||||
**Why these gates exist.** Every one of them was already installed and
|
||||
configured before v0.35.0, and none of them ran. `knip` was in `package.json`
|
||||
with a `knip.json` beside it. Prettier had a config and a `format` script.
|
||||
Turning them on found real problems immediately — most notably that
|
||||
`tsconfig.json` covers only `src/`, so `tests/` and `scripts/` had **never** been
|
||||
type-checked, which was hiding three fields silently missing from the
|
||||
editor→engine parity fixture whose entire job is catching that class of drift.
|
||||
|
||||
```yaml
|
||||
# .github/workflows/deploy-web.yml
|
||||
name: Deploy to GitHub Pages
|
||||
@@ -418,3 +445,42 @@ describe("buildTitle", () => {
|
||||
| Single Tag | 30 chars | YouTube rejects that tag |
|
||||
| Hashtags in description | 60 max, 3 shown | First 3 shown above title |
|
||||
| Playlist title | 150 chars | Truncated |
|
||||
|
||||
### Enforcement (v0.35.0)
|
||||
|
||||
`renderAll` has always returned `warnings: CharLimitWarning[]`; until v0.35.0
|
||||
nothing in the UI read it. `src/engine/limits.ts` is now the single derivation,
|
||||
consumed by `useOutputLimits` on Output and precomputed per row in Batch.
|
||||
|
||||
The rule is **all-or-nothing per output**: one over-limit field disables every
|
||||
copy button for that output. `checkTitleWarning` / `checkDescriptionWarning`
|
||||
only fire when a field is *strictly over*, never at the 80 % counter threshold,
|
||||
so a non-empty `warnings` array is an exact "YouTube will reject this" signal.
|
||||
|
||||
Deliberately not gated by `YT_LIMITS`: thumbnail text and the pinned comment
|
||||
(different surfaces), the Playlist tab (150-char title, not 100), and social
|
||||
captions (per-platform caps in `SOCIAL_PLATFORMS`).
|
||||
|
||||
## 7. Field Limits (v0.35.0)
|
||||
|
||||
`src/config/field-limits.ts` — caps on what can be *typed*, distinct from
|
||||
YouTube's caps on what is *generated*.
|
||||
|
||||
```typescript
|
||||
export const FIELD_LIMITS = {
|
||||
URL: 200,
|
||||
EMAIL_FIELD: 320, // 3 addresses; RFC 5321 caps a single one at 254
|
||||
SHORT_NAME: 100,
|
||||
LABEL: 300,
|
||||
LONG_TEXT: 2000,
|
||||
TIMESTAMPS: YT_LIMITS.DESCRIPTION_MAX,
|
||||
NUMERIC: 10,
|
||||
} as const;
|
||||
```
|
||||
|
||||
Values are UTF-16 code units, matching the DOM `maxLength` attribute — an emoji
|
||||
costs 2. Grapheme counting would be more correct but cannot be enforced by the
|
||||
browser, and these are ceilings against absurd input, not a character budget.
|
||||
|
||||
`maxLength` only constrains typing and pasting, so `clampField` is applied in
|
||||
`normalizeEditorPatch` to cover profile / preset / template imports.
|
||||
@@ -13,6 +13,35 @@ export default tseslint.config(
|
||||
...reactHooks.configs.recommended.rules,
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
||||
|
||||
// eslint-plugin-react-hooks 7 turned on the React Compiler diagnostics.
|
||||
// They are worth having — four of the seven they flagged on arrival were
|
||||
// real extra render passes and were fixed (use-online-status moved to
|
||||
// `useSyncExternalStore`, ShortcutHelpModal now derives instead of
|
||||
// resetting in an effect, DraftIndicator and use-languages-ready were
|
||||
// guarded).
|
||||
//
|
||||
// Three remain, all genuinely syncing state FROM an external source:
|
||||
// src/hooks/use-languages-ready.ts — i18next bundle readiness
|
||||
// src/components/editor/PlaytestEditor.tsx — text mirror of a store number
|
||||
// src/components/editor/StoreLinkEditor.tsx — compiler can't preserve a useMemo
|
||||
//
|
||||
// Each needs a real restructure, not a guard, so they are warnings rather
|
||||
// than a reason to hold back the ESLint 10 upgrade or to delete the rule.
|
||||
// Downgrade — do not remove: the signal is the point.
|
||||
"react-hooks/set-state-in-effect": "warn",
|
||||
"react-hooks/preserve-manual-memoization": "warn",
|
||||
},
|
||||
},
|
||||
{
|
||||
// Tests index into fixture arrays constantly, and `noUncheckedIndexedAccess`
|
||||
// makes every one of those reads `T | undefined`. A `!` there asserts the
|
||||
// fixture the test itself just built — the alternative is a guard clause per
|
||||
// lookup that can only ever fail if the test is already broken. Production
|
||||
// code keeps the rule.
|
||||
files: ["tests/**/*.ts", "tests/**/*.tsx"],
|
||||
rules: {
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
"ignoreExportsUsedInFile": true,
|
||||
"ignoreDependencies": [
|
||||
"@tauri-apps/plugin-fs",
|
||||
"@tauri-apps/plugin-opener",
|
||||
"@tauri-apps/plugin-shell",
|
||||
"tailwindcss",
|
||||
"@testing-library/jest-dom",
|
||||
"@testing-library/react"
|
||||
],
|
||||
|
||||
Generated
+1506
-2037
File diff suppressed because it is too large.
Load diff
+42
-37
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yt-desc-gen",
|
||||
"version": "0.29.0",
|
||||
"version": "0.38.0",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
@@ -11,11 +11,14 @@
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"lint": "eslint src/",
|
||||
"lint:fix": "eslint src/ --fix",
|
||||
"lint": "eslint src/ tests/ scripts/",
|
||||
"lint:fix": "eslint src/ tests/ scripts/ --fix",
|
||||
"knip": "knip",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"format": "prettier --write \"src/**/*.{ts,tsx,json,css}\"",
|
||||
"typecheck:all": "tsc --noEmit -p tsconfig.check.json",
|
||||
"format": "prettier --write \"{src,tests,scripts}/**/*.{ts,tsx,css}\"",
|
||||
"format:check": "prettier --check \"{src,tests,scripts}/**/*.{ts,tsx,css}\"",
|
||||
"check:version": "tsx scripts/check-version-sync.ts",
|
||||
"validate:locales": "tsx scripts/validate-locales.ts",
|
||||
"generate:locale": "tsx scripts/generate-locale-template.ts",
|
||||
"tauri": "tauri",
|
||||
@@ -23,41 +26,43 @@
|
||||
"tauri:build": "tauri build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.11.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.0.0",
|
||||
"@tauri-apps/plugin-fs": "^2.0.0",
|
||||
"@tauri-apps/plugin-opener": "^2.0.0",
|
||||
"@tauri-apps/plugin-shell": "^2.0.0",
|
||||
"clsx": "^2.1.0",
|
||||
"i18next": "^23.15.0",
|
||||
"i18next-resources-to-backend": "^1.2.1",
|
||||
"lucide-react": "^0.400.0",
|
||||
"react": "^18.3.0",
|
||||
"react-dom": "^18.3.0",
|
||||
"react-hot-toast": "^2.4.0",
|
||||
"react-i18next": "^15.0.0",
|
||||
"react-router-dom": "^6.26.0",
|
||||
"zustand": "^4.5.0"
|
||||
"@tauri-apps/api": "^2.11.1",
|
||||
"@tauri-apps/plugin-dialog": "^2.7.2",
|
||||
"@tauri-apps/plugin-fs": "^2.5.1",
|
||||
"@tauri-apps/plugin-opener": "^2.5.4",
|
||||
"@tauri-apps/plugin-shell": "^2.3.5",
|
||||
"clsx": "^2.1.1",
|
||||
"i18next": "^26.3.6",
|
||||
"i18next-resources-to-backend": "^1.2.3",
|
||||
"lucide-react": "^0.577.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"react-hot-toast": "^2.6.0",
|
||||
"react-i18next": "^17.0.11",
|
||||
"react-router-dom": "^7.18.2",
|
||||
"zustand": "^5.0.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.0.0",
|
||||
"@testing-library/jest-dom": "^6.4.0",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/react": "^18.3.0",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"autoprefixer": "^10.4.0",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
"knip": "^6.14.1",
|
||||
"postcss": "^8.5.14",
|
||||
"prettier": "^3.3.0",
|
||||
"prettier-plugin-tailwindcss": "^0.6.0",
|
||||
"tailwindcss": "^3.4.0",
|
||||
"tsx": "^4.22.4",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@tailwindcss/postcss": "^4.3.3",
|
||||
"@testing-library/jest-dom": "^7.0.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
"@types/node": "^26.2.0",
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4",
|
||||
"@vitejs/plugin-react": "^6.0.5",
|
||||
"autoprefixer": "^10.5.4",
|
||||
"eslint": "^10.8.1",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"knip": "^6.32.2",
|
||||
"postcss": "^8.5.26",
|
||||
"prettier": "^3.9.6",
|
||||
"prettier-plugin-tailwindcss": "^0.8.1",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"tsx": "^4.23.12",
|
||||
"typescript": "^5.5.0",
|
||||
"typescript-eslint": "^8.0.0",
|
||||
"vite": "^8.0.16",
|
||||
"vitest": "^4.1.8"
|
||||
"typescript-eslint": "^8.67.0",
|
||||
"vite": "^8.2.1",
|
||||
"vitest": "^4.1.10"
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
// Tailwind 4 ships its PostCSS plugin as a separate package.
|
||||
"@tailwindcss/postcss": {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Verify that every manifest carrying the app version agrees.
|
||||
*
|
||||
* A release bumps SIX places, and nothing but this script notices when one is
|
||||
* missed. A stale `tauri.conf.json` ships an installer whose About screen and
|
||||
* updater metadata disagree with the tag; a stale `Cargo.lock` self-entry makes
|
||||
* the next `cargo build` rewrite the lockfile mid-release.
|
||||
*
|
||||
* Run via `npm run check:version`. Exits non-zero (and prints every mismatch,
|
||||
* not just the first) so CI fails the PR rather than the release.
|
||||
*/
|
||||
import { readFileSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
|
||||
interface VersionSource {
|
||||
/** Human-readable location, printed on mismatch. */
|
||||
label: string;
|
||||
/** Repo-relative path. */
|
||||
file: string;
|
||||
/** Pull the version out of the file's raw text. */
|
||||
extract: (raw: string) => string | null;
|
||||
}
|
||||
|
||||
/** Read `version` from a top-level JSON object. */
|
||||
function jsonVersion(raw: string): string | null {
|
||||
const parsed: unknown = JSON.parse(raw);
|
||||
if (typeof parsed !== "object" || parsed === null) return null;
|
||||
const version = (parsed as Record<string, unknown>).version;
|
||||
return typeof version === "string" ? version : null;
|
||||
}
|
||||
|
||||
const SOURCES: VersionSource[] = [
|
||||
{
|
||||
label: "package.json → version",
|
||||
file: "package.json",
|
||||
extract: jsonVersion,
|
||||
},
|
||||
{
|
||||
label: "package-lock.json → version",
|
||||
file: "package-lock.json",
|
||||
extract: jsonVersion,
|
||||
},
|
||||
{
|
||||
label: 'package-lock.json → packages[""].version',
|
||||
file: "package-lock.json",
|
||||
extract: (raw) => {
|
||||
const parsed: unknown = JSON.parse(raw);
|
||||
if (typeof parsed !== "object" || parsed === null) return null;
|
||||
const packages = (parsed as Record<string, unknown>).packages;
|
||||
if (typeof packages !== "object" || packages === null) return null;
|
||||
const root = (packages as Record<string, unknown>)[""];
|
||||
if (typeof root !== "object" || root === null) return null;
|
||||
const version = (root as Record<string, unknown>).version;
|
||||
return typeof version === "string" ? version : null;
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "src-tauri/tauri.conf.json → version",
|
||||
file: "src-tauri/tauri.conf.json",
|
||||
extract: jsonVersion,
|
||||
},
|
||||
{
|
||||
label: "src-tauri/Cargo.toml → [package] version",
|
||||
file: "src-tauri/Cargo.toml",
|
||||
// Anchor on the [package] table so a dependency's `version = "…"` in the
|
||||
// same file can never be picked up instead.
|
||||
extract: (raw) => /^\[package\][\s\S]*?^version\s*=\s*"([^"]+)"/m.exec(raw)?.[1] ?? null,
|
||||
},
|
||||
{
|
||||
label: "src-tauri/Cargo.lock → yt-desc-gen entry",
|
||||
file: "src-tauri/Cargo.lock",
|
||||
extract: (raw) => /^name = "yt-desc-gen"\r?\nversion = "([^"]+)"/m.exec(raw)?.[1] ?? null,
|
||||
},
|
||||
];
|
||||
|
||||
function main(): void {
|
||||
const found: { label: string; version: string | null }[] = SOURCES.map((source) => {
|
||||
let raw: string;
|
||||
try {
|
||||
raw = readFileSync(resolve(source.file), "utf8");
|
||||
} catch {
|
||||
return { label: source.label, version: null };
|
||||
}
|
||||
try {
|
||||
return { label: source.label, version: source.extract(raw) };
|
||||
} catch {
|
||||
return { label: source.label, version: null };
|
||||
}
|
||||
});
|
||||
|
||||
const missing = found.filter((entry) => entry.version === null);
|
||||
const versions = [...new Set(found.map((entry) => entry.version).filter(Boolean))];
|
||||
|
||||
if (missing.length === 0 && versions.length === 1) {
|
||||
console.log(`✓ All ${found.length} manifests agree on version ${versions[0]}`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error("✗ Version manifests are out of sync.\n");
|
||||
for (const entry of found) {
|
||||
const mark = entry.version === null ? "?" : entry.version === versions[0] ? " " : "!";
|
||||
console.error(` ${mark} ${entry.version ?? "<not found>"} ${entry.label}`);
|
||||
}
|
||||
console.error(
|
||||
"\nBump every manifest to the same version before tagging. `npm version --no-git-tag-version <v>`",
|
||||
);
|
||||
console.error("covers package.json + package-lock.json; the three Rust/Tauri files are manual.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* Scaffold a new locale directory from the English source.
|
||||
*
|
||||
* `package.json` has advertised `npm run generate:locale` since v0.1, and
|
||||
* `docs/I18N.md` step 1 tells contributors to run it — but the script was never
|
||||
* committed, so the documented first step of adding a language failed outright.
|
||||
* This is that script.
|
||||
*
|
||||
* Usage:
|
||||
* npm run generate:locale -- --lang pt-BR # empty values to translate
|
||||
* npm run generate:locale -- --lang id --copy-english # pre-fill with EN text
|
||||
* npm run generate:locale -- --lang id --force # overwrite an existing dir
|
||||
*
|
||||
* Output mirrors `src/i18n/locales/en/{ui,templates}.json` key-for-key, so
|
||||
* `npm run validate:locales` passes the moment the files are written (it checks
|
||||
* key parity, not whether the values were actually translated).
|
||||
*
|
||||
* Registering the locale in code is NOT done here — see the checklist printed
|
||||
* on success, and docs/I18N.md.
|
||||
*/
|
||||
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
||||
import { join, resolve } from "path";
|
||||
|
||||
const LOCALES_DIR = resolve("src/i18n/locales");
|
||||
const SOURCE_LOCALE = "en";
|
||||
const NAMESPACES = ["ui", "templates"] as const;
|
||||
|
||||
/** BCP-47-ish: `pt`, `pt-BR`, `zh-Hant`. Keeps a typo from creating a junk dir. */
|
||||
const LANG_PATTERN = /^[a-z]{2,3}(-[A-Za-z]{2,8})*$/;
|
||||
|
||||
interface Options {
|
||||
lang: string;
|
||||
copyEnglish: boolean;
|
||||
force: boolean;
|
||||
}
|
||||
|
||||
function parseArgs(argv: string[]): Options {
|
||||
let lang = "";
|
||||
let copyEnglish = false;
|
||||
let force = false;
|
||||
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const arg = argv[i];
|
||||
if (arg === "--lang" || arg === "-l") {
|
||||
lang = argv[++i] ?? "";
|
||||
} else if (arg?.startsWith("--lang=")) {
|
||||
lang = arg.slice("--lang=".length);
|
||||
} else if (arg === "--copy-english") {
|
||||
copyEnglish = true;
|
||||
} else if (arg === "--force") {
|
||||
force = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!lang) {
|
||||
console.error("Missing --lang.\n\n npm run generate:locale -- --lang pt-BR\n");
|
||||
process.exit(1);
|
||||
}
|
||||
if (!LANG_PATTERN.test(lang)) {
|
||||
console.error(`Invalid language code "${lang}". Expected e.g. "id", "pt-BR", "zh-Hant".\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
return { lang, copyEnglish, force };
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the tree with every leaf replaced by `""`, preserving key order so
|
||||
* the generated file diffs cleanly against the English source.
|
||||
*/
|
||||
function blankLeaves(value: unknown): unknown {
|
||||
if (Array.isArray(value)) return value.map(blankLeaves);
|
||||
if (typeof value === "object" && value !== null) {
|
||||
const out: Record<string, unknown> = {};
|
||||
for (const [key, child] of Object.entries(value as Record<string, unknown>)) {
|
||||
out[key] = blankLeaves(child);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function countLeaves(value: unknown): number {
|
||||
if (Array.isArray(value)) return value.reduce<number>((n, v) => n + countLeaves(v), 0);
|
||||
if (typeof value === "object" && value !== null) {
|
||||
return Object.values(value as Record<string, unknown>).reduce<number>(
|
||||
(n, v) => n + countLeaves(v),
|
||||
0,
|
||||
);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function main(): void {
|
||||
const { lang, copyEnglish, force } = parseArgs(process.argv.slice(2));
|
||||
const targetDir = join(LOCALES_DIR, lang);
|
||||
|
||||
if (existsSync(targetDir) && !force) {
|
||||
console.error(`✗ ${targetDir} already exists. Pass --force to overwrite.\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
mkdirSync(targetDir, { recursive: true });
|
||||
|
||||
let total = 0;
|
||||
for (const ns of NAMESPACES) {
|
||||
const sourcePath = join(LOCALES_DIR, SOURCE_LOCALE, `${ns}.json`);
|
||||
if (!existsSync(sourcePath)) {
|
||||
console.error(`✗ Source locale missing: ${sourcePath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const source: unknown = JSON.parse(readFileSync(sourcePath, "utf-8"));
|
||||
const output = copyEnglish ? source : blankLeaves(source);
|
||||
const outPath = join(targetDir, `${ns}.json`);
|
||||
// Two-space indent + trailing newline matches the existing locale files.
|
||||
writeFileSync(outPath, `${JSON.stringify(output, null, 2)}\n`, "utf-8");
|
||||
const leaves = countLeaves(source);
|
||||
total += leaves;
|
||||
console.log(
|
||||
`✓ ${lang}/${ns}.json — ${leaves} keys${copyEnglish ? " (English text)" : " (empty)"}`,
|
||||
);
|
||||
}
|
||||
|
||||
console.log(`\n${total} strings to translate. Remaining steps to register "${lang}":
|
||||
|
||||
1. src/i18n/index.ts — add to SUPPORTED_LANGUAGES (flag + nativeName)
|
||||
2. src/engine/types.ts — add to the SupportedLanguage union
|
||||
3. src/store/settings-heal.ts — add to detectBrowserLanguage's supported list
|
||||
4. src/engine/tag-generator.ts— add a MULTILINGUAL_TAGS entry (TS enforces this)
|
||||
5. npm run validate:locales — must pass before committing
|
||||
|
||||
See docs/I18N.md for the full checklist.`);
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -74,9 +74,7 @@ function validate(): void {
|
||||
console.log(`✓ ${locale}/${filename} — ${actualKeys.length}/${expectedKeys.length} keys`);
|
||||
} else {
|
||||
hasErrors = true;
|
||||
console.error(
|
||||
`✗ ${locale}/${filename} — ${actualKeys.length}/${expectedKeys.length} keys`,
|
||||
);
|
||||
console.error(`✗ ${locale}/${filename} — ${actualKeys.length}/${expectedKeys.length} keys`);
|
||||
if (missing.length > 0) {
|
||||
console.error(` Missing: ${missing.join(", ")}`);
|
||||
}
|
||||
|
||||
Generated
+41
-47
@@ -307,6 +307,15 @@ dependencies = [
|
||||
"alloc-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bs58"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.2"
|
||||
@@ -1629,7 +1638,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core 0.62.2",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3389,11 +3398,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_with"
|
||||
version = "3.18.0"
|
||||
version = "3.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd5414fad8e6907dbdd5bc441a50ae8d6e26151a03b1de04d89a5576de61d01f"
|
||||
checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bs58",
|
||||
"chrono",
|
||||
"hex",
|
||||
"indexmap 1.9.3",
|
||||
@@ -3408,9 +3418,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "3.18.0"
|
||||
version = "3.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3db8978e608f1fe7357e211969fd9abdcae80bac1ba7a3369bb7eb6b404eb65"
|
||||
checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
@@ -3768,7 +3778,7 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
"url",
|
||||
"windows",
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
"windows-version",
|
||||
"x11-dl",
|
||||
]
|
||||
@@ -4237,6 +4247,21 @@ dependencies = [
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec_macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.51.0"
|
||||
@@ -4862,7 +4887,7 @@ dependencies = [
|
||||
"webview2-com-macros",
|
||||
"webview2-com-sys",
|
||||
"windows",
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
]
|
||||
@@ -4886,7 +4911,7 @@ checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c"
|
||||
dependencies = [
|
||||
"thiserror 2.0.18",
|
||||
"windows",
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4942,7 +4967,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
|
||||
dependencies = [
|
||||
"windows-collections",
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
"windows-future",
|
||||
"windows-link 0.1.3",
|
||||
"windows-numerics",
|
||||
@@ -4954,7 +4979,7 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4966,21 +4991,8 @@ dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link 0.1.3",
|
||||
"windows-result 0.3.4",
|
||||
"windows-strings 0.4.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link 0.2.1",
|
||||
"windows-result 0.4.1",
|
||||
"windows-strings 0.5.1",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4989,7 +5001,7 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
"windows-link 0.1.3",
|
||||
"windows-threading",
|
||||
]
|
||||
@@ -5034,7 +5046,7 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
"windows-link 0.1.3",
|
||||
]
|
||||
|
||||
@@ -5047,15 +5059,6 @@ dependencies = [
|
||||
"windows-link 0.1.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||
dependencies = [
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.4.2"
|
||||
@@ -5065,15 +5068,6 @@ dependencies = [
|
||||
"windows-link 0.1.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||
dependencies = [
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
@@ -5484,7 +5478,7 @@ dependencies = [
|
||||
"webkit2gtk-sys",
|
||||
"webview2-com",
|
||||
"windows",
|
||||
"windows-core 0.61.2",
|
||||
"windows-core",
|
||||
"windows-version",
|
||||
"x11-dl",
|
||||
]
|
||||
@@ -5535,7 +5529,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "yt-desc-gen"
|
||||
version = "0.29.0"
|
||||
version = "0.38.0"
|
||||
dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "yt-desc-gen"
|
||||
version = "0.29.0"
|
||||
version = "0.38.0"
|
||||
description = "YouTube Gameplay Description Generator"
|
||||
authors = ["poli0981"]
|
||||
edition = "2021"
|
||||
|
||||
@@ -11,14 +11,6 @@
|
||||
"fs:allow-read-text-file",
|
||||
"fs:allow-write-text-file",
|
||||
"shell:default",
|
||||
"opener:default",
|
||||
{
|
||||
"identifier": "opener:allow-open-path",
|
||||
"allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }]
|
||||
},
|
||||
{
|
||||
"identifier": "opener:allow-reveal-item-in-dir",
|
||||
"allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }]
|
||||
}
|
||||
"opener:default"
|
||||
]
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
{"default":{"identifier":"default","description":"Default capabilities for YTDescGen","local":true,"windows":["main"],"permissions":["core:default","dialog:default","dialog:allow-save","dialog:allow-open","fs:default","fs:allow-read-text-file","fs:allow-write-text-file","shell:default","opener:default",{"identifier":"opener:allow-open-path","allow":[{"path":"$APPDATA"},{"path":"$APPDATA/**"}]},{"identifier":"opener:allow-reveal-item-in-dir","allow":[{"path":"$APPDATA"},{"path":"$APPDATA/**"}]}]}}
|
||||
{"default":{"identifier":"default","description":"Default capabilities for YTDescGen","local":true,"windows":["main"],"permissions":["core:default","dialog:default","dialog:allow-save","dialog:allow-open","fs:default","fs:allow-read-text-file","fs:allow-write-text-file","shell:default","opener:default"]}}
|
||||
@@ -27,19 +27,6 @@ fn read_from_file(path: String) -> Result<String, String> {
|
||||
std::fs::read_to_string(&path).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Ensure a directory exists on disk, creating it (and any missing
|
||||
/// parents) if necessary. No-op when the path already exists as a
|
||||
/// directory. Fixes the "Windows cannot find ... AppData\Roaming\
|
||||
/// com.skullmute.ytdescgen" Explorer error on first launch — see
|
||||
/// `openSettingsFolder()` in `SettingsPage.tsx`, where this is called
|
||||
/// before `openPath(dir)` so the OS shell never sees a non-existent
|
||||
/// path. Returns the OS error string on failure (e.g. permission
|
||||
/// denied) so the caller can surface it via the in-app log.
|
||||
#[tauri::command]
|
||||
fn ensure_dir(path: String) -> Result<(), String> {
|
||||
std::fs::create_dir_all(&path).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Append `content` to the file at `path`, creating the file (and any
|
||||
/// missing parent directories) if necessary. Used by the v0.17.0 log
|
||||
/// persistence pipeline to write JSONL entries one line at a time,
|
||||
@@ -111,7 +98,6 @@ pub fn run() {
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
save_to_file,
|
||||
read_from_file,
|
||||
ensure_dir,
|
||||
append_to_file,
|
||||
list_dir,
|
||||
delete_file
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
|
||||
"productName": "YTDescGen",
|
||||
"version": "0.29.0",
|
||||
"version": "0.38.0",
|
||||
"identifier": "com.skullmute.ytdescgen",
|
||||
"build": {
|
||||
"beforeBuildCommand": "npm run build",
|
||||
|
||||
+45
-21
@@ -24,24 +24,16 @@ const HistoryPage = lazy(() =>
|
||||
const SettingsPage = lazy(() =>
|
||||
import("@pages/SettingsPage").then((m) => ({ default: m.SettingsPage })),
|
||||
);
|
||||
const BatchPage = lazy(() =>
|
||||
import("@pages/BatchPage").then((m) => ({ default: m.BatchPage })),
|
||||
);
|
||||
const SocialPage = lazy(() =>
|
||||
import("@pages/SocialPage").then((m) => ({ default: m.SocialPage })),
|
||||
);
|
||||
const BatchPage = lazy(() => import("@pages/BatchPage").then((m) => ({ default: m.BatchPage })));
|
||||
const SocialPage = lazy(() => import("@pages/SocialPage").then((m) => ({ default: m.SocialPage })));
|
||||
const PlaylistPage = lazy(() =>
|
||||
import("@pages/PlaylistPage").then((m) => ({ default: m.PlaylistPage })),
|
||||
);
|
||||
const LogPage = lazy(() =>
|
||||
import("@pages/LogPage").then((m) => ({ default: m.LogPage })),
|
||||
);
|
||||
const AboutPage = lazy(() =>
|
||||
import("@pages/AboutPage").then((m) => ({ default: m.AboutPage })),
|
||||
);
|
||||
const LogPage = lazy(() => import("@pages/LogPage").then((m) => ({ default: m.LogPage })));
|
||||
const AboutPage = lazy(() => import("@pages/AboutPage").then((m) => ({ default: m.AboutPage })));
|
||||
|
||||
function PageLoader() {
|
||||
return <div className="flex items-center justify-center p-12 text-text-muted">Loading...</div>;
|
||||
return <div className="text-text-muted flex items-center justify-center p-12">Loading...</div>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,35 +144,67 @@ export default function App() {
|
||||
/>
|
||||
<Route
|
||||
path="profiles"
|
||||
element={<PageBoundary label="Profiles"><ProfilesPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="Profiles">
|
||||
<ProfilesPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="history"
|
||||
element={<PageBoundary label="History"><HistoryPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="History">
|
||||
<HistoryPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="settings"
|
||||
element={<PageBoundary label="Settings"><SettingsPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="Settings">
|
||||
<SettingsPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="batch"
|
||||
element={<PageBoundary label="Batch"><BatchPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="Batch">
|
||||
<BatchPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="social"
|
||||
element={<PageBoundary label="Social"><SocialPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="Social">
|
||||
<SocialPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="playlist"
|
||||
element={<PageBoundary label="Playlist"><PlaylistPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="Playlist">
|
||||
<PlaylistPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="logs"
|
||||
element={<PageBoundary label="Logs"><LogPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="Logs">
|
||||
<LogPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="about"
|
||||
element={<PageBoundary label="About"><AboutPage /></PageBoundary>}
|
||||
element={
|
||||
<PageBoundary label="About">
|
||||
<AboutPage />
|
||||
</PageBoundary>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
{/* Designed error pages — siblings of the AppShell group so they
|
||||
|
||||
@@ -33,15 +33,15 @@ export function ConsentGate() {
|
||||
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"
|
||||
className="bg-surface-0 flex min-h-screen flex-col items-center justify-center gap-6 px-6 py-12 text-center"
|
||||
>
|
||||
<ShieldCheck className="h-14 w-14 text-accent" aria-hidden />
|
||||
<ShieldCheck className="text-accent h-14 w-14" aria-hidden />
|
||||
|
||||
<div className="max-w-md space-y-2">
|
||||
<h1 id="consent-title" className="text-2xl font-semibold text-text-primary">
|
||||
<h1 id="consent-title" className="text-text-primary text-2xl font-semibold">
|
||||
{t("consentGate.title")}
|
||||
</h1>
|
||||
<p className="text-sm text-text-secondary">{t("consentGate.intro")}</p>
|
||||
<p className="text-text-secondary text-sm">{t("consentGate.intro")}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid w-full max-w-md gap-2 sm:grid-cols-2">
|
||||
@@ -51,15 +51,15 @@ export function ConsentGate() {
|
||||
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"
|
||||
className="border-border bg-surface-1 text-text-primary hover:border-accent hover:bg-surface-2 flex items-center gap-3 rounded-lg border px-3 py-2.5 text-sm transition-colors"
|
||||
>
|
||||
<span className="flex-1 truncate text-left">{t(doc.labelKey)}</span>
|
||||
<ExternalLink className="h-3.5 w-3.5 shrink-0 text-text-muted" />
|
||||
<ExternalLink className="text-text-muted h-3.5 w-3.5 shrink-0" />
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="w-full max-w-md rounded-lg border border-border bg-surface-1 p-4">
|
||||
<div className="border-border bg-surface-1 w-full max-w-md rounded-lg border p-4">
|
||||
<Checkbox checked={agreed} onChange={setAgreed} label={t("consentGate.agreeLabel")} />
|
||||
</div>
|
||||
|
||||
@@ -67,7 +67,7 @@ export function ConsentGate() {
|
||||
<Button variant="primary" onClick={onContinue} disabled={!agreed}>
|
||||
{t("consentGate.continue")}
|
||||
</Button>
|
||||
{!agreed && <p className="text-xs text-text-muted">{t("consentGate.mustAgree")}</p>}
|
||||
{!agreed && <p className="text-text-muted text-xs">{t("consentGate.mustAgree")}</p>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ValidatedInput } from "@components/ui/ValidatedInput";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import {
|
||||
validateMessengerUrl,
|
||||
validateZaloGroupUrl,
|
||||
validateSignalGroupUrl,
|
||||
validateInstagramInviteUrl,
|
||||
validateFacebookGroupUrl,
|
||||
} from "@utils/validation";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Community invite links. A single section for "join the chat" links that
|
||||
* feed the description's "💬 COMMUNITY" block:
|
||||
*
|
||||
* - Messenger community (`https://m.me/ch/<id>`), Signal group
|
||||
* (`https://signal.group/#<id>`), Instagram group chat
|
||||
* (`https://www.instagram.com/j/<id>` or `https://ig.me/j/<id>`), and
|
||||
* Facebook Group (`https://facebook.com/groups/<id>`) — all shown for
|
||||
* every output language (v0.32.0 Messenger; v0.33.0 the rest, with
|
||||
* Facebook Group moved here from the Social section).
|
||||
* - Zalo group (`https://zalo.me/g/<code>`) — Zalo is a Vietnam-audience
|
||||
* app, so the input only appears (and the description line only renders)
|
||||
* when the output language is Vietnamese. A value entered while in
|
||||
* Vietnamese is preserved if the creator later switches language.
|
||||
*
|
||||
* Every input hard-rejects malformed links via {@link ValidatedInput}, so a
|
||||
* bad URL never reaches the generated description.
|
||||
*/
|
||||
export function CommunityEditor() {
|
||||
const { t } = useTranslation("ui");
|
||||
const messengerCommunityLink = useEditorStore((s) => s.messengerCommunityLink);
|
||||
const signalGroupLink = useEditorStore((s) => s.signalGroupLink);
|
||||
const instagramGroupLink = useEditorStore((s) => s.instagramGroupLink);
|
||||
const facebookGroupLink = useEditorStore((s) => s.facebookGroupLink);
|
||||
const zaloGroupLink = useEditorStore((s) => s.zaloGroupLink);
|
||||
const language = useEditorStore((s) => s.language);
|
||||
const setField = useEditorStore((s) => s.set);
|
||||
|
||||
const isVi = language === "vi";
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.community")}</span>
|
||||
<p className="text-text-muted text-xs">{t("editor.communityHelp")}</p>
|
||||
</div>
|
||||
|
||||
<ValidatedInput
|
||||
fieldId="messengerCommunityLink"
|
||||
labelKey="editor.messengerCommunityLink"
|
||||
label={t("editor.messengerCommunityLink")}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
placeholder={t("editor.messengerCommunityLinkPlaceholder")}
|
||||
value={messengerCommunityLink}
|
||||
onChange={(v) => setField("messengerCommunityLink", v)}
|
||||
validate={validateMessengerUrl}
|
||||
inputMode="url"
|
||||
autoComplete="off"
|
||||
/>
|
||||
|
||||
<ValidatedInput
|
||||
fieldId="signalGroupLink"
|
||||
labelKey="editor.signalGroupLink"
|
||||
label={t("editor.signalGroupLink")}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
placeholder={t("editor.signalGroupLinkPlaceholder")}
|
||||
value={signalGroupLink}
|
||||
onChange={(v) => setField("signalGroupLink", v)}
|
||||
validate={validateSignalGroupUrl}
|
||||
inputMode="url"
|
||||
autoComplete="off"
|
||||
/>
|
||||
|
||||
<ValidatedInput
|
||||
fieldId="instagramGroupLink"
|
||||
labelKey="editor.instagramGroupLink"
|
||||
label={t("editor.instagramGroupLink")}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
placeholder={t("editor.instagramGroupLinkPlaceholder")}
|
||||
value={instagramGroupLink}
|
||||
onChange={(v) => setField("instagramGroupLink", v)}
|
||||
validate={validateInstagramInviteUrl}
|
||||
inputMode="url"
|
||||
autoComplete="off"
|
||||
/>
|
||||
|
||||
<ValidatedInput
|
||||
fieldId="facebookGroupLink"
|
||||
labelKey="editor.facebookGroupLink"
|
||||
label={t("editor.facebookGroupLink")}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
placeholder={t("editor.facebookGroupLinkPlaceholder")}
|
||||
value={facebookGroupLink}
|
||||
onChange={(v) => setField("facebookGroupLink", v)}
|
||||
validate={validateFacebookGroupUrl}
|
||||
inputMode="url"
|
||||
autoComplete="off"
|
||||
/>
|
||||
|
||||
{isVi && (
|
||||
<ValidatedInput
|
||||
fieldId="zaloGroupLink"
|
||||
labelKey="editor.zaloGroupLink"
|
||||
label={t("editor.zaloGroupLink")}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
placeholder={t("editor.zaloGroupLinkPlaceholder")}
|
||||
value={zaloGroupLink}
|
||||
onChange={(v) => setField("zaloGroupLink", v)}
|
||||
validate={validateZaloGroupUrl}
|
||||
inputMode="url"
|
||||
autoComplete="off"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ValidatedInput } from "@components/ui/ValidatedInput";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { useSettingsStore } from "@store/settings-store";
|
||||
import { validateEmails, canAcceptEmailInput, MAX_EMAILS } from "@utils/validation";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Contact email input(s). Two modes, driven by the `splitContactEmail`
|
||||
* settings toggle:
|
||||
*
|
||||
* - off (default) — a single "Contact Email" field, exactly as before.
|
||||
* Feeds the description's single "📧 Business inquiries" line.
|
||||
* - on — three purpose fields (general / advertising / game keys &
|
||||
* playtest) that feed the grouped "📧 BUSINESS / CONTACT" block. The
|
||||
* general field reuses the existing `contactEmail`, so a value entered
|
||||
* before the toggle was flipped carries over as the Contact address.
|
||||
*
|
||||
* Every input allows up to 3 comma-separated addresses via
|
||||
* {@link validateEmails}, and a malformed value never reaches the
|
||||
* generated description ({@link ValidatedInput} clears it on error).
|
||||
*/
|
||||
export function ContactEmailEditor() {
|
||||
const { t } = useTranslation("ui");
|
||||
const contactEmail = useEditorStore((s) => s.contactEmail);
|
||||
const adEmail = useEditorStore((s) => s.adEmail);
|
||||
const gameKeyEmail = useEditorStore((s) => s.gameKeyEmail);
|
||||
const setField = useEditorStore((s) => s.set);
|
||||
const splitContactEmail = useSettingsStore((s) => s.splitContactEmail);
|
||||
|
||||
// Shared by all three fields. The cap is per field, not across the split:
|
||||
// each one renders its own labelled description line, so filling the
|
||||
// advertising address must not retroactively invalidate the contact one.
|
||||
const emailGuard = {
|
||||
validate: validateEmails,
|
||||
// Accept the change verbatim, or reject the keystroke with `null` so the
|
||||
// three addresses already typed survive untouched.
|
||||
beforeChange: (next: string, prev: string): string | null =>
|
||||
canAcceptEmailInput(next, prev) ? next : null,
|
||||
blockedMessage: t("validation.emailMaxReached", { max: MAX_EMAILS }),
|
||||
maxLength: FIELD_LIMITS.EMAIL_FIELD,
|
||||
inputMode: "email" as const,
|
||||
autoComplete: "email",
|
||||
};
|
||||
|
||||
if (!splitContactEmail) {
|
||||
return (
|
||||
<ValidatedInput
|
||||
fieldId="contactEmail"
|
||||
labelKey="editor.contactEmail"
|
||||
label={t("editor.contactEmail")}
|
||||
placeholder={t("editor.contactEmailPlaceholder")}
|
||||
value={contactEmail ?? ""}
|
||||
onChange={(v) => setField("contactEmail", v)}
|
||||
helpText={t("editor.contactEmailHelp")}
|
||||
{...emailGuard}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<ValidatedInput
|
||||
fieldId="contactEmail"
|
||||
labelKey="editor.contactEmail"
|
||||
label={t("editor.contactEmail")}
|
||||
placeholder={t("editor.contactEmailPlaceholder")}
|
||||
value={contactEmail ?? ""}
|
||||
onChange={(v) => setField("contactEmail", v)}
|
||||
helpText={t("editor.contactEmailHelp")}
|
||||
{...emailGuard}
|
||||
/>
|
||||
<ValidatedInput
|
||||
fieldId="adEmail"
|
||||
labelKey="editor.adEmail"
|
||||
label={t("editor.adEmail")}
|
||||
placeholder={t("editor.adEmailPlaceholder")}
|
||||
value={adEmail ?? ""}
|
||||
onChange={(v) => setField("adEmail", v)}
|
||||
helpText={t("editor.adEmailHelp")}
|
||||
{...emailGuard}
|
||||
/>
|
||||
<ValidatedInput
|
||||
fieldId="gameKeyEmail"
|
||||
labelKey="editor.gameKeyEmail"
|
||||
label={t("editor.gameKeyEmail")}
|
||||
placeholder={t("editor.gameKeyEmailPlaceholder")}
|
||||
value={gameKeyEmail ?? ""}
|
||||
onChange={(v) => setField("gameKeyEmail", v)}
|
||||
helpText={t("editor.gameKeyEmailHelp")}
|
||||
{...emailGuard}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,10 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { ChevronDown, ChevronRight, Search, X } from "lucide-react";
|
||||
import clsx from "clsx";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import {
|
||||
CONTENT_WARNING_GROUPS,
|
||||
type ContentWarningGroup,
|
||||
} from "@config/content-warning-groups";
|
||||
import { CONTENT_WARNING_GROUPS, type ContentWarningGroup } from "@config/content-warning-groups";
|
||||
import type { ContentWarning } from "@engine/types";
|
||||
|
||||
/**
|
||||
@@ -69,30 +66,26 @@ export function ContentWarningChecklist() {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-sm font-medium text-text-secondary">
|
||||
{t("editor.warnings")}
|
||||
</span>
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.warnings")}</span>
|
||||
{selected.length > 0 && (
|
||||
<span className="text-xs text-text-muted">
|
||||
{selected.length} selected
|
||||
</span>
|
||||
<span className="text-text-muted text-xs">{selected.length} selected</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="relative">
|
||||
<Search className="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-text-muted" />
|
||||
<Search className="text-text-muted pointer-events-none absolute top-1/2 left-2.5 h-3.5 w-3.5 -translate-y-1/2" />
|
||||
<input
|
||||
type="text"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={t("editor.contentWarningSearchPlaceholder")}
|
||||
className="w-full rounded-md border border-border bg-surface-1 py-1.5 pl-8 pr-7 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"
|
||||
className="border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent w-full rounded-md border py-1.5 pr-7 pl-8 text-sm focus:outline-none"
|
||||
/>
|
||||
{query && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setQuery("")}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary"
|
||||
className="text-text-muted hover:text-text-primary absolute top-1/2 right-2 -translate-y-1/2"
|
||||
aria-label="Clear search"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
@@ -101,25 +94,23 @@ export function ContentWarningChecklist() {
|
||||
</div>
|
||||
|
||||
{isFiltering && totalMatching === 0 ? (
|
||||
<p className="py-2 text-center text-xs text-text-muted">
|
||||
<p className="text-text-muted py-2 text-center text-xs">
|
||||
{t("editor.contentWarningEmpty")}
|
||||
</p>
|
||||
) : (
|
||||
<div className="flex flex-col gap-1">
|
||||
{filteredGroups.map((group) => {
|
||||
const isOpen = isFiltering || openGroups[group.id];
|
||||
const groupSelectedCount = group.items.filter((id) =>
|
||||
selected.includes(id),
|
||||
).length;
|
||||
const groupSelectedCount = group.items.filter((id) => selected.includes(id)).length;
|
||||
return (
|
||||
<div
|
||||
key={group.id}
|
||||
className="overflow-hidden rounded-md border border-border bg-surface-1"
|
||||
className="border-border bg-surface-1 overflow-hidden rounded-md border"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => toggleGroup(group.id)}
|
||||
className="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium text-text-secondary hover:bg-surface-2"
|
||||
className="text-text-secondary hover:bg-surface-2 flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium"
|
||||
aria-expanded={isOpen}
|
||||
>
|
||||
<span className="flex items-center gap-1.5">
|
||||
@@ -131,13 +122,13 @@ export function ContentWarningChecklist() {
|
||||
{t(group.labelKey)}
|
||||
</span>
|
||||
{groupSelectedCount > 0 && (
|
||||
<span className="rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent">
|
||||
<span className="bg-accent/15 text-accent rounded-full px-2 py-0.5 text-[10px] font-medium">
|
||||
{groupSelectedCount}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
{isOpen && (
|
||||
<div className="grid grid-cols-1 gap-x-3 gap-y-1 border-t border-border bg-surface-1 px-3 py-2 sm:grid-cols-2">
|
||||
<div className="border-border bg-surface-1 grid grid-cols-1 gap-x-3 gap-y-1 border-t px-3 py-2 sm:grid-cols-2">
|
||||
{group.items.map((id) => {
|
||||
const checked = selected.includes(id);
|
||||
return (
|
||||
@@ -154,7 +145,7 @@ export function ContentWarningChecklist() {
|
||||
type="checkbox"
|
||||
checked={checked}
|
||||
onChange={() => toggleItem(id)}
|
||||
className="h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-border text-accent focus:ring-1 focus:ring-accent/40"
|
||||
className="focus:ring-accent/40 border-border text-accent h-3.5 w-3.5 shrink-0 cursor-pointer rounded focus:ring-1"
|
||||
/>
|
||||
<span>{t(`editor.contentWarningOptions.${id}`)}</span>
|
||||
</label>
|
||||
|
||||
@@ -10,15 +10,22 @@ export function DraftIndicator() {
|
||||
const videoType = useEditorStore((s) => s.videoType);
|
||||
|
||||
useEffect(() => {
|
||||
setShowSaved(true);
|
||||
const timer = setTimeout(() => setShowSaved(false), 2000);
|
||||
return () => clearTimeout(timer);
|
||||
// Show, then hide 2s later. Both transitions go through the timer rather
|
||||
// than one synchronous `setShowSaved(true)` on every dependency change,
|
||||
// which cost an extra render pass each keystroke-driven update
|
||||
// (react-hooks/set-state-in-effect).
|
||||
const show = setTimeout(() => setShowSaved(true), 0);
|
||||
const hide = setTimeout(() => setShowSaved(false), 2000);
|
||||
return () => {
|
||||
clearTimeout(show);
|
||||
clearTimeout(hide);
|
||||
};
|
||||
}, [gameName, videoType]);
|
||||
|
||||
if (!showSaved) return null;
|
||||
|
||||
return (
|
||||
<span className="flex items-center gap-1 text-xs text-success">
|
||||
<span className="text-success flex items-center gap-1 text-xs">
|
||||
<Check className="h-3 w-3" />
|
||||
{t("editor.draftSaved")}
|
||||
</span>
|
||||
|
||||
@@ -4,13 +4,11 @@ import { Plus, Minus, AlertTriangle } from "lucide-react";
|
||||
import { Input } from "@components/ui/Input";
|
||||
import { Button } from "@components/ui/Button";
|
||||
import { Select } from "@components/ui/Select";
|
||||
import {
|
||||
useEditorStore,
|
||||
computeContiguousRanges,
|
||||
} from "@store/editor-store";
|
||||
import { useEditorStore, computeContiguousRanges } from "@store/editor-store";
|
||||
import { parseTimeline } from "@engine/timeline-parser";
|
||||
import { formatEndingEntry } from "@engine/endings-format";
|
||||
import type { EndingEntry, EndingVideoRange } from "@engine/types";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/** Editor cap, matching the original spec ("Giá trị từ 1 - 100"). */
|
||||
const MAX_ENDINGS = 100;
|
||||
@@ -78,7 +76,10 @@ export function EndingsEditor() {
|
||||
const nextEndings: EndingEntry[] =
|
||||
clamped <= count
|
||||
? endings.slice(0, clamped)
|
||||
: [...endings, ...Array.from({ length: clamped - count }, () => ({ number: null, name: "" }))];
|
||||
: [
|
||||
...endings,
|
||||
...Array.from({ length: clamped - count }, () => ({ number: null, name: "" })),
|
||||
];
|
||||
set("endings", nextEndings);
|
||||
|
||||
// Re-derive endingVideoCount + ranges so the schema invariants
|
||||
@@ -86,10 +87,7 @@ export function EndingsEditor() {
|
||||
// stay true after a shrink/grow.
|
||||
const nextVideoCount = clamped === 0 ? 1 : Math.min(endingVideoCount, clamped);
|
||||
set("endingVideoCount", nextVideoCount);
|
||||
set(
|
||||
"endingVideoRanges",
|
||||
clamped === 0 ? [] : computeContiguousRanges(clamped, nextVideoCount),
|
||||
);
|
||||
set("endingVideoRanges", clamped === 0 ? [] : computeContiguousRanges(clamped, nextVideoCount));
|
||||
};
|
||||
|
||||
/** Update one ending row's number / name. */
|
||||
@@ -119,9 +117,7 @@ export function EndingsEditor() {
|
||||
* configurations after the fact, since mid-edit overlaps are
|
||||
* expected. */
|
||||
const updateRange = (i: number, patch: Partial<EndingVideoRange>) => {
|
||||
const next = endingVideoRanges.map((r, idx) =>
|
||||
idx === i ? { ...r, ...patch } : r,
|
||||
);
|
||||
const next = endingVideoRanges.map((r, idx) => (idx === i ? { ...r, ...patch } : r));
|
||||
set("endingVideoRanges", next);
|
||||
};
|
||||
|
||||
@@ -206,13 +202,11 @@ export function EndingsEditor() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{count === 0 && (
|
||||
<p className="text-xs text-text-muted">{t("editor.endings.emptyHint")}</p>
|
||||
)}
|
||||
{count === 0 && <p className="text-text-muted text-xs">{t("editor.endings.emptyHint")}</p>}
|
||||
|
||||
{/* CASE A: single ending — number + name pair, with preview. */}
|
||||
{count === 1 && endings[0] && (
|
||||
<div className="flex flex-col gap-2 rounded-lg border border-border bg-surface-1 p-3">
|
||||
<div className="border-border bg-surface-1 flex flex-col gap-2 rounded-lg border p-3">
|
||||
<div className="grid grid-cols-[100px_1fr] gap-2">
|
||||
<Input
|
||||
label={t("editor.endings.numberLabel")}
|
||||
@@ -228,17 +222,18 @@ export function EndingsEditor() {
|
||||
/>
|
||||
<Input
|
||||
label={t("editor.endings.nameLabel")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.endings.namePlaceholder")}
|
||||
value={endings[0].name}
|
||||
onChange={(e) => updateEnding(0, { name: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-xs text-text-muted">
|
||||
<p className="text-text-muted text-xs">
|
||||
{t("editor.endings.previewLabel")}:{" "}
|
||||
<span className="font-mono text-text-secondary">{previewFor(endings[0])}</span>
|
||||
<span className="text-text-secondary font-mono">{previewFor(endings[0])}</span>
|
||||
</p>
|
||||
{!endings[0].number && !endings[0].name.trim() && (
|
||||
<p className="flex items-center gap-1.5 text-xs text-warning">
|
||||
<p className="text-warning flex items-center gap-1.5 text-xs">
|
||||
<AlertTriangle className="h-3 w-3" />
|
||||
{t("editor.endings.warnings.singleEmpty")}
|
||||
</p>
|
||||
@@ -249,9 +244,9 @@ export function EndingsEditor() {
|
||||
{/* CASE B / C: multi-ending table. */}
|
||||
{count >= 2 && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="overflow-hidden rounded-lg border border-border">
|
||||
<div className="border-border overflow-hidden rounded-lg border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-surface-1 text-xs uppercase text-text-muted">
|
||||
<thead className="bg-surface-1 text-text-muted text-xs uppercase">
|
||||
<tr>
|
||||
<th className="px-2 py-1.5 text-left">#</th>
|
||||
<th className="w-[100px] px-2 py-1.5 text-left">
|
||||
@@ -263,8 +258,8 @@ export function EndingsEditor() {
|
||||
</thead>
|
||||
<tbody>
|
||||
{endings.map((entry, i) => (
|
||||
<tr key={i} className="border-t border-border">
|
||||
<td className="px-2 py-1.5 text-text-muted">{i + 1}</td>
|
||||
<tr key={i} className="border-border border-t">
|
||||
<td className="text-text-muted px-2 py-1.5">{i + 1}</td>
|
||||
<td className="px-2 py-1.5">
|
||||
<Input
|
||||
type="number"
|
||||
@@ -284,7 +279,7 @@ export function EndingsEditor() {
|
||||
onChange={(e) => updateEnding(i, { name: e.target.value })}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-2 py-1.5 font-mono text-xs text-text-muted">
|
||||
<td className="text-text-muted px-2 py-1.5 font-mono text-xs">
|
||||
{previewFor(entry)}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -297,7 +292,7 @@ export function EndingsEditor() {
|
||||
|
||||
{/* Case B: timeline gate banner. */}
|
||||
{isMultiEnding && !isMultiVideo && timelineEndingCount < count && (
|
||||
<p className="flex items-start gap-1.5 rounded border border-warning/40 bg-warning/10 p-2 text-xs text-warning">
|
||||
<p className="border-warning/40 bg-warning/10 text-warning flex items-start gap-1.5 rounded border p-2 text-xs">
|
||||
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
|
||||
<span>
|
||||
{t("editor.endings.warnings.timelineShort", {
|
||||
@@ -310,7 +305,7 @@ export function EndingsEditor() {
|
||||
|
||||
{/* CASE C: video-count input + per-video ranges. */}
|
||||
{isMultiEnding && (
|
||||
<div className="flex flex-col gap-2 rounded-lg border border-border bg-surface-1 p-3">
|
||||
<div className="border-border bg-surface-1 flex flex-col gap-2 rounded-lg border p-3">
|
||||
<Input
|
||||
label={t("editor.endings.videoCountLabel")}
|
||||
type="number"
|
||||
@@ -321,23 +316,19 @@ export function EndingsEditor() {
|
||||
/>
|
||||
{isMultiVideo && (
|
||||
<>
|
||||
<p className="text-xs text-text-muted">
|
||||
{t("editor.endings.videoRangeHint")}
|
||||
</p>
|
||||
<div className="overflow-hidden rounded border border-border">
|
||||
<p className="text-text-muted text-xs">{t("editor.endings.videoRangeHint")}</p>
|
||||
<div className="border-border overflow-hidden rounded border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-surface-2 text-xs uppercase text-text-muted">
|
||||
<thead className="bg-surface-2 text-text-muted text-xs uppercase">
|
||||
<tr>
|
||||
<th className="px-2 py-1.5 text-left">
|
||||
{t("editor.endings.videoLabel")}
|
||||
</th>
|
||||
<th className="px-2 py-1.5 text-left">{t("editor.endings.videoLabel")}</th>
|
||||
<th className="px-2 py-1.5 text-left">From</th>
|
||||
<th className="px-2 py-1.5 text-left">To</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{endingVideoRanges.map((r, i) => (
|
||||
<tr key={i} className="border-t border-border">
|
||||
<tr key={i} className="border-border border-t">
|
||||
<td className="px-2 py-1.5">{i + 1}</td>
|
||||
<td className="px-2 py-1.5">
|
||||
<Input
|
||||
@@ -345,9 +336,7 @@ export function EndingsEditor() {
|
||||
min={1}
|
||||
max={count}
|
||||
value={String(r.from)}
|
||||
onChange={(e) =>
|
||||
updateRange(i, { from: Number(e.target.value) || 1 })
|
||||
}
|
||||
onChange={(e) => updateRange(i, { from: Number(e.target.value) || 1 })}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-2 py-1.5">
|
||||
@@ -356,9 +345,7 @@ export function EndingsEditor() {
|
||||
min={1}
|
||||
max={count}
|
||||
value={String(r.to)}
|
||||
onChange={(e) =>
|
||||
updateRange(i, { to: Number(e.target.value) || 1 })
|
||||
}
|
||||
onChange={(e) => updateRange(i, { to: Number(e.target.value) || 1 })}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -367,7 +354,7 @@ export function EndingsEditor() {
|
||||
</table>
|
||||
</div>
|
||||
{rangeWarnings.length > 0 && (
|
||||
<ul className="flex flex-col gap-1 rounded border border-warning/40 bg-warning/10 p-2 text-xs text-warning">
|
||||
<ul className="border-warning/40 bg-warning/10 text-warning flex flex-col gap-1 rounded border p-2 text-xs">
|
||||
{rangeWarnings.map((w, i) => (
|
||||
<li key={i} className="flex items-start gap-1.5">
|
||||
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
|
||||
@@ -394,9 +381,7 @@ export function EndingsEditor() {
|
||||
value={String(Math.min(endingVideoIndex, endingVideoCount))}
|
||||
onChange={(v) => set("endingVideoIndex", Number(v) || 1)}
|
||||
/>
|
||||
<p className="text-xs text-text-muted">
|
||||
{t("editor.endings.videoIndexHint")}
|
||||
</p>
|
||||
<p className="text-text-muted text-xs">{t("editor.endings.videoIndexHint")}</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type GachaQuestType,
|
||||
} from "@config/gacha-quest-types";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
const ANNIVERSARY_YEARS = Array.from({ length: 20 }, (_, i) => i + 1);
|
||||
|
||||
@@ -32,9 +33,7 @@ export function ExtraFieldsInput() {
|
||||
const visibility = GACHA_QUEST_FIELD_VISIBILITY[questType];
|
||||
const placeholders = GACHA_QUEST_PLACEHOLDERS[questType];
|
||||
|
||||
const placeholderFor = (
|
||||
field: "chapterName" | "questName" | "partNumber",
|
||||
): string => {
|
||||
const placeholderFor = (field: "chapterName" | "questName" | "partNumber"): string => {
|
||||
const key = `editor.placeholders.questType.${questType}.${field}`;
|
||||
const localised = t(key);
|
||||
if (localised && localised !== key) return localised;
|
||||
@@ -57,25 +56,17 @@ export function ExtraFieldsInput() {
|
||||
<div className="flex flex-col gap-3">
|
||||
{extraFields.includes("gachaQuestType") && (
|
||||
<div className="flex flex-col gap-1">
|
||||
<label
|
||||
htmlFor="gacha-quest-type"
|
||||
className="text-sm font-medium text-text-secondary"
|
||||
>
|
||||
<label htmlFor="gacha-quest-type" className="text-text-secondary text-sm font-medium">
|
||||
{t("editor.gachaQuestType")}
|
||||
</label>
|
||||
<select
|
||||
id="gacha-quest-type"
|
||||
value={store.gachaQuestType ?? "main_story"}
|
||||
onChange={(e) =>
|
||||
store.set("gachaQuestType", e.target.value as GachaQuestType)
|
||||
}
|
||||
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
|
||||
onChange={(e) => store.set("gachaQuestType", e.target.value as GachaQuestType)}
|
||||
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
|
||||
>
|
||||
{GACHA_QUEST_TYPE_GROUPS.map((g) => (
|
||||
<optgroup
|
||||
key={g.group}
|
||||
label={t(`editor.gachaQuestTypeGroups.${g.group}`)}
|
||||
>
|
||||
<optgroup key={g.group} label={t(`editor.gachaQuestTypeGroups.${g.group}`)}>
|
||||
{g.members.map((m) => (
|
||||
<option key={m} value={m}>
|
||||
{t(`editor.gachaQuestTypeOptions.${m}`)}
|
||||
@@ -89,6 +80,7 @@ export function ExtraFieldsInput() {
|
||||
{isGacha && visibility.characterName && (
|
||||
<Input
|
||||
label={t("editor.characterName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.characterNamePlaceholder")}
|
||||
value={store.characterName ?? ""}
|
||||
onChange={(e) => store.set("characterName", e.target.value)}
|
||||
@@ -96,22 +88,16 @@ export function ExtraFieldsInput() {
|
||||
)}
|
||||
{isGacha && visibility.anniversaryYear && (
|
||||
<div className="flex flex-col gap-1">
|
||||
<label
|
||||
htmlFor="anniversary-year"
|
||||
className="text-sm font-medium text-text-secondary"
|
||||
>
|
||||
<label htmlFor="anniversary-year" className="text-text-secondary text-sm font-medium">
|
||||
{t("editor.anniversaryYear")}
|
||||
</label>
|
||||
<select
|
||||
id="anniversary-year"
|
||||
value={store.anniversaryYear ?? ""}
|
||||
onChange={(e) =>
|
||||
store.set(
|
||||
"anniversaryYear",
|
||||
e.target.value === "" ? null : Number(e.target.value),
|
||||
)
|
||||
store.set("anniversaryYear", e.target.value === "" ? null : Number(e.target.value))
|
||||
}
|
||||
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
|
||||
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
|
||||
>
|
||||
<option value="">—</option>
|
||||
{ANNIVERSARY_YEARS.map((y) => (
|
||||
@@ -125,6 +111,7 @@ export function ExtraFieldsInput() {
|
||||
{showField("chapterName") && (
|
||||
<Input
|
||||
label={t("editor.chapterName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={isGacha ? placeholderFor("chapterName") : t("editor.chapterNamePlaceholder")}
|
||||
value={store.chapterName ?? ""}
|
||||
onChange={(e) => store.set("chapterName", e.target.value)}
|
||||
@@ -133,6 +120,7 @@ export function ExtraFieldsInput() {
|
||||
{showField("questName") && (
|
||||
<Input
|
||||
label={t("editor.questName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={isGacha ? placeholderFor("questName") : t("editor.questNamePlaceholder")}
|
||||
value={store.questName ?? ""}
|
||||
onChange={(e) => store.set("questName", e.target.value)}
|
||||
@@ -141,6 +129,7 @@ export function ExtraFieldsInput() {
|
||||
{showField("partNumber") && (
|
||||
<Input
|
||||
label={t("editor.partNumber")}
|
||||
maxLength={FIELD_LIMITS.NUMERIC}
|
||||
placeholder={isGacha ? placeholderFor("partNumber") : t("editor.partNumberPlaceholder")}
|
||||
value={store.partNumber ?? ""}
|
||||
onChange={(e) => store.set("partNumber", e.target.value)}
|
||||
@@ -149,6 +138,7 @@ export function ExtraFieldsInput() {
|
||||
{isGacha && (
|
||||
<Input
|
||||
label={t("editor.gachaVersion")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.gachaVersionPlaceholder")}
|
||||
value={store.gachaVersion ?? ""}
|
||||
onChange={(e) => store.set("gachaVersion", e.target.value)}
|
||||
@@ -157,6 +147,7 @@ export function ExtraFieldsInput() {
|
||||
{extraFields.includes("bossName") && (
|
||||
<Input
|
||||
label={t("editor.bossName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.bossNamePlaceholder")}
|
||||
value={store.bossName ?? ""}
|
||||
onChange={(e) => store.set("bossName", e.target.value)}
|
||||
@@ -165,6 +156,7 @@ export function ExtraFieldsInput() {
|
||||
{extraFields.includes("dlcName") && (
|
||||
<Input
|
||||
label={t("editor.dlcName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.dlcNamePlaceholder")}
|
||||
value={store.dlcName ?? ""}
|
||||
onChange={(e) => store.set("dlcName", e.target.value)}
|
||||
@@ -173,6 +165,7 @@ export function ExtraFieldsInput() {
|
||||
{extraFields.includes("challengeName") && (
|
||||
<Input
|
||||
label={t("editor.challengeName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.challengeNamePlaceholder")}
|
||||
value={store.challengeName ?? ""}
|
||||
onChange={(e) => store.set("challengeName", e.target.value)}
|
||||
@@ -182,12 +175,14 @@ export function ExtraFieldsInput() {
|
||||
<>
|
||||
<Input
|
||||
label={t("editor.modName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.modNamePlaceholder")}
|
||||
value={store.modName ?? ""}
|
||||
onChange={(e) => store.set("modName", e.target.value)}
|
||||
/>
|
||||
<Textarea
|
||||
label={t("editor.modList")}
|
||||
maxLength={FIELD_LIMITS.LONG_TEXT}
|
||||
placeholder={t("editor.modListPlaceholder")}
|
||||
value={store.modList ?? ""}
|
||||
onChange={(e) => store.set("modList", e.target.value)}
|
||||
@@ -198,6 +193,7 @@ export function ExtraFieldsInput() {
|
||||
{extraFields.includes("liveUrl") && (
|
||||
<Input
|
||||
label={t("editor.liveUrl")}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
placeholder={t("editor.liveUrlPlaceholder")}
|
||||
value={store.liveUrl ?? ""}
|
||||
onChange={(e) => store.set("liveUrl", e.target.value)}
|
||||
@@ -205,14 +201,14 @@ export function ExtraFieldsInput() {
|
||||
)}
|
||||
{extraFields.includes("scheduledTime") && (
|
||||
<div className="flex flex-col gap-1">
|
||||
<label className="text-sm font-medium text-text-secondary">
|
||||
<label className="text-text-secondary text-sm font-medium">
|
||||
{t("editor.scheduledTime")}
|
||||
</label>
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={store.scheduledTime ?? ""}
|
||||
onChange={(e) => store.set("scheduledTime", e.target.value)}
|
||||
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
|
||||
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Input } from "@components/ui/Input";
|
||||
import { Select } from "@components/ui/Select";
|
||||
import { PLATFORMS } from "@config/platforms";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Core identity fields for the video (game name, channel, platform).
|
||||
@@ -19,6 +20,7 @@ export function GameInfoForm() {
|
||||
<div className="flex flex-col gap-3">
|
||||
<Input
|
||||
label={t("editor.gameName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.gameNamePlaceholder")}
|
||||
value={store.gameName}
|
||||
onChange={(e) => store.set("gameName", e.target.value)}
|
||||
@@ -27,6 +29,7 @@ export function GameInfoForm() {
|
||||
/>
|
||||
<Input
|
||||
label={t("editor.channelName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.channelNamePlaceholder")}
|
||||
value={store.channelName}
|
||||
onChange={(e) => store.set("channelName", e.target.value)}
|
||||
@@ -49,6 +52,7 @@ export function GameInfoForm() {
|
||||
*/}
|
||||
<Input
|
||||
label={t("editor.pubDevName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.pubDevNamePlaceholder")}
|
||||
value={store.pubDevName ?? ""}
|
||||
onChange={(e) => store.set("pubDevName", e.target.value)}
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ChipGroup } from "@components/ui/ChipGroup";
|
||||
import {
|
||||
GENRES,
|
||||
GENRE_GROUPS,
|
||||
GENRE_GROUP_IDS,
|
||||
type GenreGroupId,
|
||||
} from "@config/genres";
|
||||
import { GENRES, GENRE_GROUPS, GENRE_GROUP_IDS, type GenreGroupId } from "@config/genres";
|
||||
import { GENRES_WITHOUT_GRAPHICS_SETTINGS } from "@config/graphics-settings";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { MAX_GENRES, type Genre } from "@engine/types";
|
||||
@@ -55,10 +50,8 @@ export function GenreSelector() {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<span className="text-sm font-medium text-text-secondary">
|
||||
{t("editor.genre")}
|
||||
</span>
|
||||
<span className="text-xs text-text-muted">
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.genre")}</span>
|
||||
<span className="text-text-muted text-xs">
|
||||
{genres.length}/{MAX_GENRES}
|
||||
</span>
|
||||
</div>
|
||||
@@ -68,7 +61,7 @@ export function GenreSelector() {
|
||||
key={groupId}
|
||||
type="button"
|
||||
onClick={() => applyGroup(groupId)}
|
||||
className="rounded-lg border border-border bg-surface-1 px-2.5 py-1 text-xs font-medium text-text-secondary transition-colors hover:border-accent hover:text-text-primary"
|
||||
className="border-border bg-surface-1 text-text-secondary hover:border-accent hover:text-text-primary rounded-lg border px-2.5 py-1 text-xs font-medium transition-colors"
|
||||
>
|
||||
{t(`editor.genreGroups.${groupId}`)}
|
||||
</button>
|
||||
@@ -79,12 +72,10 @@ export function GenreSelector() {
|
||||
value={filter}
|
||||
onChange={(e) => setFilter(e.target.value)}
|
||||
placeholder={t("editor.genreSearchPlaceholder")}
|
||||
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
|
||||
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
|
||||
/>
|
||||
{visibleOptions.length === 0 ? (
|
||||
<p className="py-2 text-sm text-text-muted">
|
||||
{t("editor.genreSearchNoResults")}
|
||||
</p>
|
||||
<p className="text-text-muted py-2 text-sm">{t("editor.genreSearchNoResults")}</p>
|
||||
) : (
|
||||
<ChipGroup
|
||||
multiple
|
||||
@@ -95,12 +86,12 @@ export function GenreSelector() {
|
||||
/>
|
||||
)}
|
||||
{showHint && (
|
||||
<div className="flex items-center justify-between gap-3 rounded-lg border border-accent/40 bg-accent/5 px-3 py-2 text-xs text-text-secondary">
|
||||
<div className="border-accent/40 bg-accent/5 text-text-secondary flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-xs">
|
||||
<span>{t("editor.skipGraphicsHintLabel")}</span>
|
||||
<div className="flex shrink-0 gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className="rounded bg-accent px-2 py-1 font-medium text-white"
|
||||
className="bg-accent rounded px-2 py-1 font-medium text-white"
|
||||
onClick={() => {
|
||||
set("skipGraphicsSettings", true);
|
||||
setHintDismissed(true);
|
||||
@@ -110,7 +101,7 @@ export function GenreSelector() {
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="rounded px-2 py-1 font-medium text-text-secondary hover:bg-surface-2"
|
||||
className="text-text-secondary hover:bg-surface-2 rounded px-2 py-1 font-medium"
|
||||
onClick={() => setHintDismissed(true)}
|
||||
>
|
||||
{t("editor.skipGraphicsHintKeep")}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Textarea } from "@components/ui/Textarea";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Music / sound attribution credit. When non-empty, the engine adds a
|
||||
@@ -14,6 +15,7 @@ export function MusicAttributionEditor() {
|
||||
return (
|
||||
<Textarea
|
||||
label={t("editor.musicAttribution")}
|
||||
maxLength={FIELD_LIMITS.LONG_TEXT}
|
||||
placeholder={t("editor.musicAttributionPlaceholder")}
|
||||
value={musicAttribution ?? ""}
|
||||
onChange={(e) => set("musicAttribution", e.target.value)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Textarea } from "@components/ui/Textarea";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Template for the pinned comment a creator posts under their own
|
||||
@@ -15,6 +16,7 @@ export function PinnedCommentEditor() {
|
||||
return (
|
||||
<Textarea
|
||||
label={t("editor.pinnedComment")}
|
||||
maxLength={FIELD_LIMITS.LONG_TEXT}
|
||||
placeholder={t("editor.pinnedCommentPlaceholder")}
|
||||
value={pinnedComment ?? ""}
|
||||
onChange={(e) => set("pinnedComment", e.target.value)}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ValidatedInput } from "@components/ui/ValidatedInput";
|
||||
import { Input } from "@components/ui/Input";
|
||||
import { Select } from "@components/ui/Select";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { validateUrl, validateUrlWithPattern, validateIntegerInRange } from "@utils/validation";
|
||||
import { PLAYTEST_PLATFORMS, maxInvitesForPlatform } from "@config/playtest-platforms";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Playtest section (v0.30.0). One signup link + the platform it lives on +
|
||||
* an optional invite count. Mirrors {@link StoreLinkEditor} but is a single
|
||||
* entry rather than one-per-platform. The invite-count input maxes out at
|
||||
* the selected platform's cap (≤100); switching to a lower-cap platform
|
||||
* clamps an over-budget count down. Renders into the description only when
|
||||
* a link is entered — no settings toggle gates it.
|
||||
*/
|
||||
export function PlaytestEditor() {
|
||||
const { t } = useTranslation("ui");
|
||||
const playtestLink = useEditorStore((s) => s.playtestLink);
|
||||
const playtestPlatform = useEditorStore((s) => s.playtestPlatform);
|
||||
const playtestInvites = useEditorStore((s) => s.playtestInvites);
|
||||
const setField = useEditorStore((s) => s.set);
|
||||
|
||||
const platform =
|
||||
PLAYTEST_PLATFORMS.find((p) => p.id === playtestPlatform) ?? PLAYTEST_PLATFORMS[0];
|
||||
const cap = maxInvitesForPlatform(playtestPlatform);
|
||||
|
||||
const platformOptions = PLAYTEST_PLATFORMS.map((p) => ({
|
||||
value: p.id,
|
||||
label: p.label,
|
||||
}));
|
||||
|
||||
// The store holds the invite count as a number; the input edits raw text
|
||||
// so a mid-edit "2.5" / "-1" can show a warning without snapping back.
|
||||
// Invalid text is NOT committed, so the description stays clean.
|
||||
const [invitesText, setInvitesText] = useState(
|
||||
playtestInvites > 0 ? String(playtestInvites) : "",
|
||||
);
|
||||
|
||||
// Resync the text when the store value changes from outside this input
|
||||
// (platform clamp, profile / preset load, draft reset). Only fires on a
|
||||
// real store change, so it never clobbers an in-progress invalid edit.
|
||||
useEffect(() => {
|
||||
const next = playtestInvites > 0 ? String(playtestInvites) : "";
|
||||
// Functional form so the comparison happens against the *current* text
|
||||
// without depending on it, and so an unchanged value returns the same
|
||||
// reference instead of scheduling a render (react-hooks/set-state-in-effect).
|
||||
setInvitesText((prev) => {
|
||||
const current = prev.trim() === "" ? 0 : Number(prev);
|
||||
return current === playtestInvites ? prev : next;
|
||||
});
|
||||
}, [playtestInvites]);
|
||||
|
||||
const handlePlatformChange = (id: string) => {
|
||||
setField("playtestPlatform", id);
|
||||
const newCap = maxInvitesForPlatform(id);
|
||||
if (playtestInvites > newCap) {
|
||||
setField("playtestInvites", newCap);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInvitesChange = (raw: string) => {
|
||||
setInvitesText(raw);
|
||||
const result = validateIntegerInRange(raw, { min: 1, max: cap, allowEmpty: true });
|
||||
if (result.valid) {
|
||||
setField("playtestInvites", raw.trim() === "" ? 0 : Number(raw));
|
||||
}
|
||||
};
|
||||
|
||||
const invitesValidation = validateIntegerInRange(invitesText, {
|
||||
min: 1,
|
||||
max: cap,
|
||||
allowEmpty: true,
|
||||
});
|
||||
const invitesError = invitesValidation.valid
|
||||
? undefined
|
||||
: t(invitesValidation.error ?? "", invitesValidation.errorParams);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<span className="text-text-secondary text-sm font-medium">
|
||||
{t("editor.playtest.heading")}
|
||||
</span>
|
||||
|
||||
<ValidatedInput
|
||||
fieldId="playtestLink"
|
||||
labelKey="editor.playtest.linkLabel"
|
||||
label={t("editor.playtest.linkLabel")}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
placeholder={platform?.urlPrefix ?? "https://"}
|
||||
value={playtestLink}
|
||||
onChange={(v) => setField("playtestLink", v)}
|
||||
validate={(v) =>
|
||||
platform ? validateUrlWithPattern(v, platform.urlPattern) : validateUrl(v)
|
||||
}
|
||||
inputMode="url"
|
||||
autoComplete="off"
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-[1fr_9rem] items-start gap-2">
|
||||
<Select
|
||||
label={t("editor.playtest.platformLabel")}
|
||||
value={playtestPlatform}
|
||||
options={platformOptions}
|
||||
onChange={handlePlatformChange}
|
||||
/>
|
||||
<Input
|
||||
label={t("editor.playtest.invitesLabel", { max: cap })}
|
||||
type="number"
|
||||
min={1}
|
||||
max={cap}
|
||||
step={1}
|
||||
inputMode="numeric"
|
||||
value={invitesText}
|
||||
onChange={(e) => handleInvitesChange(e.target.value)}
|
||||
errorText={invitesError}
|
||||
helpText={t("editor.playtest.invitesHelp", { max: cap })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { Select } from "@components/ui/Select";
|
||||
import { Input } from "@components/ui/Input";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { EndingsEditor } from "./EndingsEditor";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
import {
|
||||
PLAYTHROUGH_STATUSES,
|
||||
DIFFICULTY_LEVELS,
|
||||
@@ -62,7 +63,7 @@ export function PlaythroughNotesForm() {
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-sm font-medium text-text-secondary">
|
||||
<span className="text-text-secondary text-sm font-medium">
|
||||
{t("editor.playthroughNotes.title")}
|
||||
</span>
|
||||
</div>
|
||||
@@ -83,6 +84,7 @@ export function PlaythroughNotesForm() {
|
||||
{store.difficulty === "custom" && (
|
||||
<Input
|
||||
label={t("editor.difficultyCustomLabel")}
|
||||
maxLength={FIELD_LIMITS.LABEL}
|
||||
placeholder={t("editor.difficultyCustomPlaceholder")}
|
||||
value={store.difficultyCustomLabel}
|
||||
onChange={(e) => store.set("difficultyCustomLabel", e.target.value)}
|
||||
@@ -105,6 +107,7 @@ export function PlaythroughNotesForm() {
|
||||
{languagePatchHasCustomSlot(store.languagePatch) && (
|
||||
<Input
|
||||
label={t("editor.playthroughNotes.languagePatchCustomLabel")}
|
||||
maxLength={FIELD_LIMITS.LABEL}
|
||||
placeholder={t("editor.playthroughNotes.languagePatchCustomPlaceholder")}
|
||||
value={store.languagePatchCustom}
|
||||
onChange={(e) => store.set("languagePatchCustom", e.target.value)}
|
||||
@@ -120,6 +123,7 @@ export function PlaythroughNotesForm() {
|
||||
{gameVersionHasCustomSlot(store.gameVersion) && (
|
||||
<Input
|
||||
label={t("editor.playthroughNotes.gameVersionCustomLabel")}
|
||||
maxLength={FIELD_LIMITS.LABEL}
|
||||
placeholder={t("editor.playthroughNotes.gameVersionCustomPlaceholder")}
|
||||
value={store.gameVersionCustom}
|
||||
onChange={(e) => store.set("gameVersionCustom", e.target.value)}
|
||||
|
||||
@@ -6,35 +6,29 @@ export function QuickPreview() {
|
||||
const output = useGeneratedOutput();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-border bg-surface-1 p-4">
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.quickPreview")}</span>
|
||||
<div className="border-border bg-surface-1 flex flex-col gap-3 rounded-lg border p-4">
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.quickPreview")}</span>
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<div>
|
||||
<span className="text-xs font-medium uppercase text-text-muted">
|
||||
{t("output.title")}
|
||||
</span>
|
||||
<p className="mt-1 text-sm font-medium text-text-primary">
|
||||
{output.title || "..."}
|
||||
</p>
|
||||
<span className="text-text-muted text-xs font-medium uppercase">{t("output.title")}</span>
|
||||
<p className="text-text-primary mt-1 text-sm font-medium">{output.title || "..."}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span className="text-xs font-medium uppercase text-text-muted">
|
||||
<span className="text-text-muted text-xs font-medium uppercase">
|
||||
{t("output.description")}
|
||||
</span>
|
||||
<p className="mt-1 line-clamp-3 whitespace-pre-wrap text-xs text-text-secondary">
|
||||
<p className="text-text-secondary mt-1 line-clamp-3 text-xs whitespace-pre-wrap">
|
||||
{output.description || "..."}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span className="text-xs font-medium uppercase text-text-muted">
|
||||
<span className="text-text-muted text-xs font-medium uppercase">
|
||||
{t("output.tags")} ({output.tags.length})
|
||||
</span>
|
||||
<p className="mt-1 line-clamp-2 text-xs text-text-muted">
|
||||
{output.tagString || "..."}
|
||||
</p>
|
||||
<p className="text-text-muted mt-1 line-clamp-2 text-xs">{output.tagString || "..."}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
} from "@config/rig-fields";
|
||||
import { GPU_CUSTOM_BRAND_ID, findGpuBrand } from "@config/gpu-catalog";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
import {
|
||||
validateGpuValue,
|
||||
validateCompositeField,
|
||||
@@ -39,7 +40,7 @@ export function RigEditor() {
|
||||
const renderValidationBadge = (issue: RigValidationIssue | null) => {
|
||||
if (!issue) return null;
|
||||
return (
|
||||
<div className="flex items-center gap-1 text-xs text-warning">
|
||||
<div className="text-warning flex items-center gap-1 text-xs">
|
||||
<AlertTriangle className="h-3 w-3" />
|
||||
<span>{t(issue.messageKey)}</span>
|
||||
</div>
|
||||
@@ -66,10 +67,7 @@ export function RigEditor() {
|
||||
: [{ value: "", label: "—" }];
|
||||
const currentSeries = currentBrand?.series.find((s) => s.id === series);
|
||||
const modelOptions = currentSeries
|
||||
? [
|
||||
{ value: "", label: "—" },
|
||||
...currentSeries.models.map((m) => ({ value: m, label: m })),
|
||||
]
|
||||
? [{ value: "", label: "—" }, ...currentSeries.models.map((m) => ({ value: m, label: m }))]
|
||||
: [{ value: "", label: "—" }];
|
||||
|
||||
const setBrand = (next: string) => {
|
||||
@@ -84,16 +82,12 @@ export function RigEditor() {
|
||||
setNested("rig", field.id, joinCascading(brand, series, next));
|
||||
};
|
||||
const setCustomText = (text: string) => {
|
||||
setNested(
|
||||
"rig",
|
||||
field.id,
|
||||
text ? joinCascading(GPU_CUSTOM_BRAND_ID, "", text) : "",
|
||||
);
|
||||
setNested("rig", field.id, text ? joinCascading(GPU_CUSTOM_BRAND_ID, "", text) : "");
|
||||
};
|
||||
|
||||
return (
|
||||
<div key={field.id} className="col-span-2 flex flex-col gap-2">
|
||||
<span className="text-sm font-medium text-text-secondary">{t(field.labelKey)}</span>
|
||||
<span className="text-text-secondary text-sm font-medium">{t(field.labelKey)}</span>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
<Select
|
||||
label={t("editor.gpu_brand")}
|
||||
@@ -105,6 +99,7 @@ export function RigEditor() {
|
||||
<div className="col-span-2">
|
||||
<Input
|
||||
label={t("editor.gpu_custom")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder="e.g. RTX 4090 (custom OC)"
|
||||
value={model}
|
||||
onChange={(e) => setCustomText(e.target.value)}
|
||||
@@ -141,9 +136,7 @@ export function RigEditor() {
|
||||
// Validate per field — only RAM has size/DDR semantics. Running the
|
||||
// RAM validator on the OS composite mis-fired "Pick a DDR generation."
|
||||
const issue = validateCompositeField(field.id, raw);
|
||||
const partValues = field.composite.parts.map(
|
||||
(_p, i) => storedParts[i] ?? "",
|
||||
);
|
||||
const partValues = field.composite.parts.map((_p, i) => storedParts[i] ?? "");
|
||||
|
||||
// v0.23.0: setting a part also resets all downstream parts to "" so
|
||||
// a cascading parent change can't leave the form with a stale child
|
||||
@@ -180,10 +173,8 @@ export function RigEditor() {
|
||||
|
||||
return (
|
||||
<div key={field.id} className="col-span-2 flex flex-col gap-2">
|
||||
<span className="text-sm font-medium text-text-secondary">{t(field.labelKey)}</span>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{renderedParts}
|
||||
</div>
|
||||
<span className="text-text-secondary text-sm font-medium">{t(field.labelKey)}</span>
|
||||
<div className="grid grid-cols-2 gap-2">{renderedParts}</div>
|
||||
{renderValidationBadge(issue)}
|
||||
</div>
|
||||
);
|
||||
@@ -232,7 +223,7 @@ export function RigEditor() {
|
||||
onChange={(e) => onCustomChange(e.target.value)}
|
||||
/>
|
||||
{part.customSuffix && (
|
||||
<span className="text-sm text-text-muted">{part.customSuffix.trim()}</span>
|
||||
<span className="text-text-muted text-sm">{part.customSuffix.trim()}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
@@ -247,8 +238,7 @@ export function RigEditor() {
|
||||
|
||||
const commit = (nextValue: string, nextVersion: string) => {
|
||||
// Keep the stored form compact: drop the pipe when empty.
|
||||
const next =
|
||||
!nextValue && !nextVersion ? "" : `${nextValue}|${nextVersion}`;
|
||||
const next = !nextValue && !nextVersion ? "" : `${nextValue}|${nextVersion}`;
|
||||
setNested("rig", field.id, next);
|
||||
};
|
||||
|
||||
@@ -262,6 +252,7 @@ export function RigEditor() {
|
||||
/>
|
||||
<Input
|
||||
label={t("editor.version")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={field.versionPlaceholder}
|
||||
value={version}
|
||||
onChange={(e) => commit(value, e.target.value)}
|
||||
@@ -272,7 +263,7 @@ export function RigEditor() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.rig")}</span>
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.rig")}</span>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{RIG_FIELDS.map((field) => {
|
||||
if (field.type === "cascading_dropdown") return renderCascading(field);
|
||||
@@ -282,6 +273,7 @@ export function RigEditor() {
|
||||
<Input
|
||||
key={field.id}
|
||||
label={t(field.labelKey)}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={field.placeholder}
|
||||
value={rig[field.id] ?? ""}
|
||||
onChange={(e) => setNested("rig", field.id, e.target.value)}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ValidatedInput } from "@components/ui/ValidatedInput";
|
||||
import { SOCIAL_FIELDS } from "@config/social-fields";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { validateUrl, validateUrlWithPrefix } from "@utils/validation";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
export function SocialEditor() {
|
||||
const { t } = useTranslation("ui");
|
||||
@@ -14,15 +15,18 @@ export function SocialEditor() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.social")}</span>
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.social")}</span>
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-xs font-medium uppercase text-text-muted">Donate</span>
|
||||
<span className="text-text-muted text-xs font-medium uppercase">Donate</span>
|
||||
{donateFields.map((field) => (
|
||||
<ValidatedInput
|
||||
key={field.id}
|
||||
fieldId={`social.${field.id}`}
|
||||
labelKey={field.labelKey}
|
||||
label={t(field.labelKey)}
|
||||
placeholder={field.urlPrefix || "URL"}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
value={social[field.id] ?? ""}
|
||||
onChange={(v) => setNested("social", field.id, v)}
|
||||
validate={(v) =>
|
||||
@@ -33,12 +37,15 @@ export function SocialEditor() {
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-xs font-medium uppercase text-text-muted">Social</span>
|
||||
<span className="text-text-muted text-xs font-medium uppercase">Social</span>
|
||||
{socialFields.map((field) => (
|
||||
<ValidatedInput
|
||||
key={field.id}
|
||||
fieldId={`social.${field.id}`}
|
||||
labelKey={field.labelKey}
|
||||
label={t(field.labelKey)}
|
||||
placeholder={field.urlPrefix || "URL"}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
value={social[field.id] ?? ""}
|
||||
onChange={(v) => setNested("social", field.id, v)}
|
||||
validate={(v) =>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Input } from "@components/ui/Input";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Publisher/developer + platform pair for the "🎁 Thanks to …" credit
|
||||
@@ -17,12 +18,14 @@ export function SponsorCreditEditor() {
|
||||
<div className="flex flex-col gap-2">
|
||||
<Input
|
||||
label={t("editor.sponsorName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.sponsorNamePlaceholder")}
|
||||
value={sponsorName ?? ""}
|
||||
onChange={(e) => set("sponsorName", e.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("editor.sponsorPlatform")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.sponsorPlatformPlaceholder")}
|
||||
value={sponsorPlatform ?? ""}
|
||||
onChange={(e) => set("sponsorPlatform", e.target.value)}
|
||||
|
||||
@@ -7,11 +7,9 @@ import { Select } from "@components/ui/Select";
|
||||
import { PLATFORMS } from "@config/platforms";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { validateUrlWithPattern } from "@utils/validation";
|
||||
import {
|
||||
extractGameNameFromUrl,
|
||||
isLinkNameMismatch,
|
||||
} from "@utils/url-extractors";
|
||||
import { extractGameNameFromUrl, isLinkNameMismatch } from "@utils/url-extractors";
|
||||
import type { StoreLinkType } from "@engine/types";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
const STORE_LINK_TYPE_VALUES: readonly StoreLinkType[] = ["paid", "free", "demo"];
|
||||
|
||||
@@ -30,9 +28,9 @@ export function StoreLinkEditor() {
|
||||
const setNested = useEditorStore((s) => s.setNested);
|
||||
const setStoreLinkType = useEditorStore((s) => s.setStoreLinkType);
|
||||
|
||||
const [dismissedFingerprints, setDismissedFingerprints] = useState<
|
||||
ReadonlySet<string>
|
||||
>(new Set());
|
||||
const [dismissedFingerprints, setDismissedFingerprints] = useState<ReadonlySet<string>>(
|
||||
new Set(),
|
||||
);
|
||||
|
||||
const typeOptions = STORE_LINK_TYPE_VALUES.map((value) => ({
|
||||
value,
|
||||
@@ -79,11 +77,11 @@ export function StoreLinkEditor() {
|
||||
setField("gameName", extracted);
|
||||
toast.custom(
|
||||
(item) => (
|
||||
<div className="flex items-center gap-3 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary shadow">
|
||||
<div className="border-border bg-surface-2 text-text-primary flex items-center gap-3 rounded-lg border px-3 py-2 text-sm shadow">
|
||||
<span>{t("editor.toast.urlAutoFilled", { name: extracted })}</span>
|
||||
<button
|
||||
type="button"
|
||||
className="rounded px-2 py-0.5 text-xs font-medium text-accent hover:bg-surface-1"
|
||||
className="text-accent hover:bg-surface-1 rounded px-2 py-0.5 text-xs font-medium"
|
||||
onClick={() => {
|
||||
setField("gameName", "");
|
||||
toast.dismiss(item.id);
|
||||
@@ -99,10 +97,10 @@ export function StoreLinkEditor() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.storeLinks")}</span>
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.storeLinks")}</span>
|
||||
{mismatch && (
|
||||
<div className="flex items-start gap-2 rounded-lg border border-warning bg-surface-2 px-3 py-2 text-sm">
|
||||
<span className="flex-1 text-text-primary">
|
||||
<div className="border-warning bg-surface-2 flex items-start gap-2 rounded-lg border px-3 py-2 text-sm">
|
||||
<span className="text-text-primary flex-1">
|
||||
{t("editor.warning.linkNameMismatch", {
|
||||
host: mismatch.host,
|
||||
suggestedName: mismatch.suggestedName,
|
||||
@@ -112,7 +110,7 @@ export function StoreLinkEditor() {
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t("common.dismiss")}
|
||||
className="shrink-0 rounded px-2 py-0.5 text-base leading-none text-text-secondary hover:bg-surface-1"
|
||||
className="text-text-secondary hover:bg-surface-1 shrink-0 rounded px-2 py-0.5 text-base leading-none"
|
||||
onClick={() =>
|
||||
setDismissedFingerprints((prev) => {
|
||||
const next = new Set(prev);
|
||||
@@ -135,13 +133,12 @@ export function StoreLinkEditor() {
|
||||
// the optional game-copyright description line independently
|
||||
// of whether the publisher URL is filled.
|
||||
return (
|
||||
<div
|
||||
key={platform.id}
|
||||
className="grid grid-cols-[1fr_9rem] items-end gap-2"
|
||||
>
|
||||
<div key={platform.id} className="grid grid-cols-[1fr_9rem] items-end gap-2">
|
||||
<ValidatedInput
|
||||
fieldId={`storeLinks.${platform.id}`}
|
||||
label={platform.label}
|
||||
placeholder={platform.urlPrefix}
|
||||
maxLength={FIELD_LIMITS.URL}
|
||||
value={url}
|
||||
onChange={(v) => {
|
||||
const final = v && platform.normalize ? platform.normalize(v) : v;
|
||||
|
||||
@@ -3,10 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { ChevronDown, ChevronRight, Search, X } from "lucide-react";
|
||||
import clsx from "clsx";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import {
|
||||
TECH_NOTE_GROUPS,
|
||||
type TechNoteGroup,
|
||||
} from "@config/tech-note-groups";
|
||||
import { TECH_NOTE_GROUPS, type TechNoteGroup } from "@config/tech-note-groups";
|
||||
import type { TechNote } from "@engine/types";
|
||||
|
||||
/**
|
||||
@@ -70,30 +67,26 @@ export function TechNotesChecklist() {
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-sm font-medium text-text-secondary">
|
||||
{t("editor.techNotes")}
|
||||
</span>
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.techNotes")}</span>
|
||||
{selected.length > 0 && (
|
||||
<span className="text-xs text-text-muted">
|
||||
{selected.length} selected
|
||||
</span>
|
||||
<span className="text-text-muted text-xs">{selected.length} selected</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="relative">
|
||||
<Search className="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-text-muted" />
|
||||
<Search className="text-text-muted pointer-events-none absolute top-1/2 left-2.5 h-3.5 w-3.5 -translate-y-1/2" />
|
||||
<input
|
||||
type="text"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={t("editor.techNoteSearchPlaceholder")}
|
||||
className="w-full rounded-md border border-border bg-surface-1 py-1.5 pl-8 pr-7 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"
|
||||
className="border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent w-full rounded-md border py-1.5 pr-7 pl-8 text-sm focus:outline-none"
|
||||
/>
|
||||
{query && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setQuery("")}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary"
|
||||
className="text-text-muted hover:text-text-primary absolute top-1/2 right-2 -translate-y-1/2"
|
||||
aria-label="Clear search"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
@@ -102,25 +95,21 @@ export function TechNotesChecklist() {
|
||||
</div>
|
||||
|
||||
{isFiltering && totalMatching === 0 ? (
|
||||
<p className="py-2 text-center text-xs text-text-muted">
|
||||
{t("editor.techNoteEmpty")}
|
||||
</p>
|
||||
<p className="text-text-muted py-2 text-center text-xs">{t("editor.techNoteEmpty")}</p>
|
||||
) : (
|
||||
<div className="flex flex-col gap-1">
|
||||
{filteredGroups.map((group) => {
|
||||
const isOpen = isFiltering || openGroups[group.id];
|
||||
const groupSelectedCount = group.items.filter((id) =>
|
||||
selected.includes(id),
|
||||
).length;
|
||||
const groupSelectedCount = group.items.filter((id) => selected.includes(id)).length;
|
||||
return (
|
||||
<div
|
||||
key={group.id}
|
||||
className="overflow-hidden rounded-md border border-border bg-surface-1"
|
||||
className="border-border bg-surface-1 overflow-hidden rounded-md border"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => toggleGroup(group.id)}
|
||||
className="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium text-text-secondary hover:bg-surface-2"
|
||||
className="text-text-secondary hover:bg-surface-2 flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium"
|
||||
aria-expanded={isOpen}
|
||||
>
|
||||
<span className="flex items-center gap-1.5">
|
||||
@@ -132,13 +121,13 @@ export function TechNotesChecklist() {
|
||||
{t(group.labelKey)}
|
||||
</span>
|
||||
{groupSelectedCount > 0 && (
|
||||
<span className="rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent">
|
||||
<span className="bg-accent/15 text-accent rounded-full px-2 py-0.5 text-[10px] font-medium">
|
||||
{groupSelectedCount}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
{isOpen && (
|
||||
<div className="grid grid-cols-1 gap-x-3 gap-y-1 border-t border-border bg-surface-1 px-3 py-2 sm:grid-cols-2">
|
||||
<div className="border-border bg-surface-1 grid grid-cols-1 gap-x-3 gap-y-1 border-t px-3 py-2 sm:grid-cols-2">
|
||||
{group.items.map((id) => {
|
||||
const checked = selected.includes(id);
|
||||
return (
|
||||
@@ -155,7 +144,7 @@ export function TechNotesChecklist() {
|
||||
type="checkbox"
|
||||
checked={checked}
|
||||
onChange={() => toggleItem(id)}
|
||||
className="h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-border text-accent focus:ring-1 focus:ring-accent/40"
|
||||
className="focus:ring-accent/40 border-border text-accent h-3.5 w-3.5 shrink-0 cursor-pointer rounded focus:ring-1"
|
||||
/>
|
||||
<span>{t(`editor.techNoteOptions.${id}`)}</span>
|
||||
</label>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Textarea } from "@components/ui/Textarea";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
/**
|
||||
* Free-form draft for the thumbnail text overlay. Never lands in the
|
||||
@@ -15,6 +16,7 @@ export function ThumbnailHelper() {
|
||||
return (
|
||||
<Textarea
|
||||
label={t("editor.thumbnailText")}
|
||||
maxLength={FIELD_LIMITS.LONG_TEXT}
|
||||
placeholder={t("editor.thumbnailTextPlaceholder")}
|
||||
value={thumbnailText ?? ""}
|
||||
onChange={(e) => set("thumbnailText", e.target.value)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Textarea } from "@components/ui/Textarea";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
export function TimestampEditor() {
|
||||
const { t } = useTranslation("ui");
|
||||
@@ -10,6 +11,7 @@ export function TimestampEditor() {
|
||||
return (
|
||||
<Textarea
|
||||
label={t("editor.timestamps")}
|
||||
maxLength={FIELD_LIMITS.TIMESTAMPS}
|
||||
placeholder={t("editor.timestampsPlaceholder")}
|
||||
value={timestamps ?? ""}
|
||||
onChange={(e) => set("timestamps", e.target.value)}
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
coerceFrameGenMultiplier,
|
||||
} from "@engine/graphics-vendor";
|
||||
import { VIDEO_STYLE_ERA_IDS, type VideoStyleEra } from "@config/video-styles";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
const RESOLUTION_OPTIONS = [
|
||||
{ value: "720p", label: "720p" },
|
||||
@@ -111,9 +112,9 @@ export function VideoSettingsForm() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.videoSettings")}</span>
|
||||
<span className="text-text-secondary text-sm font-medium">{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}
|
||||
@@ -137,6 +138,7 @@ export function VideoSettingsForm() {
|
||||
{store.graphicsPreset === "custom" && (
|
||||
<Input
|
||||
label={t("editor.graphicsPresetCustom")}
|
||||
maxLength={FIELD_LIMITS.LABEL}
|
||||
placeholder={t("editor.graphicsPresetCustomPlaceholder")}
|
||||
value={store.graphicsPresetCustom}
|
||||
onChange={(e) => store.set("graphicsPresetCustom", e.target.value)}
|
||||
@@ -149,14 +151,14 @@ export function VideoSettingsForm() {
|
||||
value={store.videoStyleEra}
|
||||
onChange={(v) => store.set("videoStyleEra", v as VideoStyleEra)}
|
||||
/>
|
||||
<p className="-mt-1 text-xs text-text-muted">{t("editor.videoStyleHelp")}</p>
|
||||
<p className="text-text-muted -mt-1 text-xs">{t("editor.videoStyleHelp")}</p>
|
||||
|
||||
<Toggle
|
||||
label={t("editor.skipGraphicsSettings")}
|
||||
checked={store.skipGraphicsSettings}
|
||||
onChange={(v) => store.set("skipGraphicsSettings", v)}
|
||||
/>
|
||||
<p className="-mt-1 text-xs text-text-muted">{t("editor.skipGraphicsSettingsHelp")}</p>
|
||||
<p className="text-text-muted -mt-1 text-xs">{t("editor.skipGraphicsSettingsHelp")}</p>
|
||||
|
||||
{!store.skipGraphicsSettings && (
|
||||
<>
|
||||
@@ -200,6 +202,7 @@ export function VideoSettingsForm() {
|
||||
|
||||
<Input
|
||||
label={t("editor.versionInfo")}
|
||||
maxLength={FIELD_LIMITS.LABEL}
|
||||
placeholder={t("editor.versionInfoPlaceholder")}
|
||||
value={store.versionInfo}
|
||||
onChange={(e) => store.set("versionInfo", e.target.value)}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { Input } from "@components/ui/Input";
|
||||
import { Select } from "@components/ui/Select";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
import {
|
||||
VIETNAMESE_BANKS,
|
||||
VIETNAMESE_BANK_OTHER,
|
||||
@@ -48,11 +49,8 @@ export function VietnameseDonateEditor() {
|
||||
() => isVi && isCustomVietnameseBank(vnBankName ?? ""),
|
||||
);
|
||||
|
||||
const customMode =
|
||||
isVi && (otherSticky || isCustomVietnameseBank(vnBankName ?? ""));
|
||||
const selectValue = customMode
|
||||
? VIETNAMESE_BANK_OTHER
|
||||
: (vnBankName ?? "");
|
||||
const customMode = isVi && (otherSticky || isCustomVietnameseBank(vnBankName ?? ""));
|
||||
const selectValue = customMode ? VIETNAMESE_BANK_OTHER : (vnBankName ?? "");
|
||||
|
||||
const bankOptions = [
|
||||
{ value: "", label: t("editor.vnBankNameSelectPlaceholder") },
|
||||
@@ -63,10 +61,8 @@ export function VietnameseDonateEditor() {
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium text-text-secondary">
|
||||
{t("editor.vnDonate")}
|
||||
</span>
|
||||
<p className="text-xs text-text-muted">{t("editor.vnDonateHelp")}</p>
|
||||
<span className="text-text-secondary text-sm font-medium">{t("editor.vnDonate")}</span>
|
||||
<p className="text-text-muted text-xs">{t("editor.vnDonateHelp")}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
@@ -98,6 +94,7 @@ export function VietnameseDonateEditor() {
|
||||
) : (
|
||||
<Input
|
||||
label={t("editor.vnBankName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.vnBankNamePlaceholder")}
|
||||
value={vnBankName ?? ""}
|
||||
onChange={(e) => store.set("vnBankName", e.target.value)}
|
||||
@@ -105,6 +102,7 @@ export function VietnameseDonateEditor() {
|
||||
)}
|
||||
<Input
|
||||
label={t("editor.vnBankAccount")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.vnBankAccountPlaceholder")}
|
||||
value={store.vnBankAccount ?? ""}
|
||||
onChange={(e) => store.set("vnBankAccount", e.target.value)}
|
||||
@@ -113,6 +111,7 @@ export function VietnameseDonateEditor() {
|
||||
|
||||
<Input
|
||||
label={t("editor.vnBankHolder")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.vnBankHolderPlaceholder")}
|
||||
value={store.vnBankHolder ?? ""}
|
||||
onChange={(e) => store.set("vnBankHolder", e.target.value)}
|
||||
@@ -121,12 +120,14 @@ export function VietnameseDonateEditor() {
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<Input
|
||||
label={t("editor.vnMomo")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.vnMomoPlaceholder")}
|
||||
value={store.vnMomo ?? ""}
|
||||
onChange={(e) => store.set("vnMomo", e.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("editor.vnZalopay")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.vnZalopayPlaceholder")}
|
||||
value={store.vnZalopay ?? ""}
|
||||
onChange={(e) => store.set("vnZalopay", e.target.value)}
|
||||
|
||||
@@ -52,16 +52,16 @@ function FullscreenError({ kind }: ErrorPageProps) {
|
||||
useDocumentTitle(title);
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col items-center justify-center gap-6 bg-surface-0 px-6 py-12 text-center">
|
||||
<div className="bg-surface-0 flex min-h-screen flex-col items-center justify-center gap-6 px-6 py-12 text-center">
|
||||
<Icon className={clsx("h-16 w-16", colour)} aria-hidden />
|
||||
{meta.code !== null && (
|
||||
<p className={clsx("font-mono text-6xl font-bold leading-none tabular-nums", colour)}>
|
||||
<p className={clsx("font-mono text-6xl leading-none font-bold tabular-nums", colour)}>
|
||||
{meta.code}
|
||||
</p>
|
||||
)}
|
||||
<div className="max-w-md space-y-2">
|
||||
<h1 className="text-2xl font-semibold text-text-primary">{title}</h1>
|
||||
<p className="text-sm text-text-secondary">{description}</p>
|
||||
<h1 className="text-text-primary text-2xl font-semibold">{title}</h1>
|
||||
<p className="text-text-secondary text-sm">{description}</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-center gap-3">
|
||||
<Button
|
||||
@@ -99,14 +99,14 @@ function ContainedError({ kind, onReset, detail }: ErrorPageProps) {
|
||||
|
||||
return (
|
||||
<div className="flex min-h-[200px] items-center justify-center p-6">
|
||||
<div className="w-full max-w-md rounded-lg border border-danger/40 bg-surface-2 p-5 shadow-md shadow-black/10">
|
||||
<div className="border-danger/40 bg-surface-2 w-full max-w-md rounded-lg border p-5 shadow-md shadow-black/10">
|
||||
<div className={clsx("mb-3 flex items-center gap-2", colour)}>
|
||||
<Icon className="h-4 w-4" />
|
||||
<h2 className="text-sm font-semibold">{title}</h2>
|
||||
</div>
|
||||
<p className="mb-3 text-xs text-text-secondary">{description}</p>
|
||||
<p className="text-text-secondary mb-3 text-xs">{description}</p>
|
||||
{detail && (
|
||||
<pre className="mb-4 max-h-32 overflow-auto whitespace-pre-wrap rounded bg-surface-3 p-2 text-[11px] text-text-muted">
|
||||
<pre className="bg-surface-3 text-text-muted mb-4 max-h-32 overflow-auto rounded p-2 text-[11px] whitespace-pre-wrap">
|
||||
{detail}
|
||||
</pre>
|
||||
)}
|
||||
@@ -140,7 +140,7 @@ function ReportBugLink({ size = "md" }: { size?: "sm" | "md" }) {
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={clsx(
|
||||
"inline-flex items-center justify-center gap-2 rounded-lg font-medium text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary focus:outline-none focus:ring-2 focus:ring-accent/50",
|
||||
"focus:ring-accent/50 text-text-secondary hover:bg-surface-2 hover:text-text-primary inline-flex items-center justify-center gap-2 rounded-lg font-medium transition-colors focus:ring-2 focus:outline-none",
|
||||
sizeClass,
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -35,18 +35,18 @@ export function OfflineBanner() {
|
||||
return (
|
||||
<div
|
||||
role="status"
|
||||
className="fixed inset-x-0 bottom-0 z-50 flex items-center justify-center gap-3 border-t border-warning/40 bg-surface-2 px-4 py-2 text-sm text-text-primary shadow-md shadow-black/20"
|
||||
className="border-warning/40 bg-surface-2 text-text-primary fixed inset-x-0 bottom-0 z-50 flex items-center justify-center gap-3 border-t px-4 py-2 text-sm shadow-md shadow-black/20"
|
||||
>
|
||||
<WifiOff className="h-4 w-4 shrink-0 text-warning" aria-hidden />
|
||||
<WifiOff className="text-warning h-4 w-4 shrink-0" aria-hidden />
|
||||
<span>{t("errorPages.offlineBanner.message")}</span>
|
||||
<Link to="/offline" className="font-medium text-accent hover:text-accent-hover">
|
||||
<Link to="/offline" className="text-accent hover:text-accent-hover font-medium">
|
||||
{t("errorPages.offlineBanner.details")}
|
||||
</Link>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setDismissed(true)}
|
||||
aria-label={t("common.dismiss")}
|
||||
className="ml-1 rounded p-1 text-text-muted transition-colors hover:bg-surface-3 hover:text-text-primary"
|
||||
className="text-text-muted hover:bg-surface-3 hover:text-text-primary ml-1 rounded p-1 transition-colors"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
|
||||
@@ -19,7 +19,7 @@ export function HistoryCard({ entry }: HistoryCardProps) {
|
||||
const date = new Date(entry.createdAt).toLocaleDateString();
|
||||
|
||||
return (
|
||||
<div className="rounded-lg border border-border-strong bg-surface-2 shadow-md shadow-black/10 transition-colors hover:border-accent/30">
|
||||
<div className="hover:border-accent/30 border-border-strong bg-surface-2 rounded-lg border shadow-md shadow-black/10 transition-colors">
|
||||
<div
|
||||
className="flex cursor-pointer items-center justify-between p-3"
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
@@ -27,9 +27,9 @@ export function HistoryCard({ entry }: HistoryCardProps) {
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-2">
|
||||
{videoType && <span>{videoType.icon}</span>}
|
||||
<span className="text-sm font-medium text-text-primary">{entry.title}</span>
|
||||
<span className="text-text-primary text-sm font-medium">{entry.title}</span>
|
||||
</div>
|
||||
<div className="mt-1 flex gap-2 text-xs text-text-muted">
|
||||
<div className="text-text-muted mt-1 flex gap-2 text-xs">
|
||||
<span>{entry.gameName}</span>
|
||||
<span>{entry.language.toUpperCase()}</span>
|
||||
<span>{date}</span>
|
||||
@@ -44,24 +44,24 @@ export function HistoryCard({ entry }: HistoryCardProps) {
|
||||
deleteEntry(entry.id);
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5 text-danger" />
|
||||
<Trash2 className="text-danger h-3.5 w-3.5" />
|
||||
</Button>
|
||||
{expanded ? (
|
||||
<ChevronUp className="h-4 w-4 text-text-muted" />
|
||||
<ChevronUp className="text-text-muted h-4 w-4" />
|
||||
) : (
|
||||
<ChevronDown className="h-4 w-4 text-text-muted" />
|
||||
<ChevronDown className="text-text-muted h-4 w-4" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{expanded && (
|
||||
<div className="border-t border-border p-3">
|
||||
<div className="border-border border-t p-3">
|
||||
<div className="mb-2 flex gap-2">
|
||||
<CopyButton text={entry.title} label={t("output.copyTitle")} />
|
||||
<CopyButton text={entry.description} label={t("output.copyDescription")} />
|
||||
<CopyButton text={entry.tags} label={t("output.copyTags")} />
|
||||
</div>
|
||||
<pre className="max-h-48 overflow-y-auto whitespace-pre-wrap rounded bg-surface-2 p-2 font-sans text-xs text-text-secondary">
|
||||
<pre className="bg-surface-2 text-text-secondary max-h-48 overflow-y-auto rounded p-2 font-sans text-xs whitespace-pre-wrap">
|
||||
{entry.description}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,7 @@ export function AppShell() {
|
||||
useGlobalErrorHandler();
|
||||
|
||||
return (
|
||||
<div className="flex h-screen overflow-hidden bg-surface-0">
|
||||
<div className="bg-surface-0 flex h-screen overflow-hidden">
|
||||
<Sidebar />
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<Header onOpenMobileNav={() => setMobileNavOpen(true)} />
|
||||
|
||||
@@ -37,27 +37,23 @@ export function Header({ onOpenMobileNav }: HeaderProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<header
|
||||
className="flex items-center justify-between gap-2 border-b border-border bg-surface-1 px-3 py-3 pt-[max(0.75rem,env(safe-area-inset-top))] sm:px-6"
|
||||
>
|
||||
<header className="border-border bg-surface-1 flex items-center justify-between gap-2 border-b px-3 py-3 pt-[max(0.75rem,env(safe-area-inset-top))] sm:px-6">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
{onOpenMobileNav && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpenMobileNav}
|
||||
aria-label="Open navigation menu"
|
||||
className="-ml-1 rounded-lg p-2 text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary md:hidden"
|
||||
className="text-text-secondary hover:bg-surface-2 hover:text-text-primary -ml-1 rounded-lg p-2 transition-colors md:hidden"
|
||||
>
|
||||
<Menu className="h-5 w-5" />
|
||||
</button>
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<h1 className="truncate text-base font-bold text-text-primary sm:text-lg">
|
||||
<h1 className="text-text-primary truncate text-base font-bold sm:text-lg">
|
||||
{t("app.title")}
|
||||
</h1>
|
||||
<p className="hidden truncate text-xs text-text-muted sm:block">
|
||||
{t("app.subtitle")}
|
||||
</p>
|
||||
<p className="text-text-muted hidden truncate text-xs sm:block">{t("app.subtitle")}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
@@ -75,35 +71,31 @@ export function Header({ onOpenMobileNav }: HeaderProps) {
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
|
||||
className="rounded-lg p-2 text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary"
|
||||
className="text-text-secondary hover:bg-surface-2 hover:text-text-primary rounded-lg p-2 transition-colors"
|
||||
title={t("header.toggleTheme")}
|
||||
aria-label={t("header.toggleTheme")}
|
||||
>
|
||||
{theme === "dark" ? (
|
||||
<Moon className="h-4 w-4" />
|
||||
) : (
|
||||
<Sun className="h-4 w-4" />
|
||||
)}
|
||||
{theme === "dark" ? <Moon className="h-4 w-4" /> : <Sun className="h-4 w-4" />}
|
||||
</button>
|
||||
<div className="relative" ref={dropdownRef}>
|
||||
<button
|
||||
onClick={() => setOpen(!open)}
|
||||
className="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm transition-colors hover:bg-surface-2 sm:px-3"
|
||||
className="hover:bg-surface-2 flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm transition-colors sm:px-3"
|
||||
aria-haspopup="listbox"
|
||||
aria-expanded={open}
|
||||
>
|
||||
<span>{current?.flag}</span>
|
||||
<span className="hidden text-text-primary sm:inline">{current?.nativeName}</span>
|
||||
<ChevronDown className="h-3.5 w-3.5 text-text-muted" />
|
||||
<span className="text-text-primary hidden sm:inline">{current?.nativeName}</span>
|
||||
<ChevronDown className="text-text-muted h-3.5 w-3.5" />
|
||||
</button>
|
||||
{open && (
|
||||
<div className="absolute right-0 top-full z-50 mt-1 max-w-[calc(100vw-2rem)] min-w-[200px] rounded-lg border border-border bg-surface-1 py-1 shadow-xl">
|
||||
<div className="border-border bg-surface-1 absolute top-full right-0 z-50 mt-1 max-w-[calc(100vw-2rem)] min-w-[200px] rounded-lg border py-1 shadow-xl">
|
||||
{SUPPORTED_LANGUAGES.map((lang) => (
|
||||
<button
|
||||
key={lang.id}
|
||||
onClick={() => handleSwitch(lang.id as SupportedLanguage)}
|
||||
className={clsx(
|
||||
"flex w-full items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-surface-2",
|
||||
"hover:bg-surface-2 flex w-full items-center gap-2 px-3 py-2 text-sm transition-colors",
|
||||
lang.id === appLanguage ? "bg-accent-muted text-accent" : "text-text-primary",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -6,7 +6,13 @@ import clsx from "clsx";
|
||||
|
||||
interface ScrollToTopButtonProps {
|
||||
/** The scrollable container to watch and scroll back to the top. */
|
||||
scrollRef: RefObject<HTMLElement>;
|
||||
/**
|
||||
* React 19 types `useRef<T>(null)` as `RefObject<T | null>` rather than
|
||||
* `RefObject<T>` — the ref genuinely is null before the element mounts, and
|
||||
* the old type quietly lied about it. Matching that here rather than casting
|
||||
* at the call site keeps the null-check below honest.
|
||||
*/
|
||||
scrollRef: RefObject<HTMLElement | null>;
|
||||
}
|
||||
|
||||
/** Scroll distance (px) past which the button fades in. */
|
||||
@@ -50,9 +56,7 @@ export function ScrollToTopButton({ scrollRef }: ScrollToTopButtonProps) {
|
||||
function scrollToTop() {
|
||||
const el = scrollRef.current;
|
||||
if (!el) return;
|
||||
const reduceMotion = window.matchMedia(
|
||||
"(prefers-reduced-motion: reduce)",
|
||||
).matches;
|
||||
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
el.scrollTo({ top: 0, behavior: reduceMotion ? "auto" : "smooth" });
|
||||
}
|
||||
|
||||
@@ -64,10 +68,10 @@ export function ScrollToTopButton({ scrollRef }: ScrollToTopButtonProps) {
|
||||
aria-hidden={!visible}
|
||||
tabIndex={visible ? 0 : -1}
|
||||
className={clsx(
|
||||
"fixed bottom-6 right-6 z-40 flex h-touch w-touch items-center justify-center",
|
||||
"rounded-full border border-border bg-surface-1 text-text-primary shadow-lg",
|
||||
"transition-opacity duration-200 hover:bg-surface-2",
|
||||
"focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
|
||||
"h-touch w-touch fixed right-6 bottom-6 z-40 flex items-center justify-center",
|
||||
"border-border bg-surface-1 text-text-primary rounded-full border shadow-lg",
|
||||
"hover:bg-surface-2 transition-opacity duration-200",
|
||||
"focus-visible:ring-accent focus:outline-none focus-visible:ring-2",
|
||||
visible ? "opacity-100" : "pointer-events-none opacity-0",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -110,7 +110,7 @@ export function Sidebar() {
|
||||
return (
|
||||
<aside
|
||||
className={clsx(
|
||||
"hidden shrink-0 flex-col border-r border-border bg-surface-1 transition-[width] duration-200 md:flex",
|
||||
"border-border bg-surface-1 hidden shrink-0 flex-col border-r transition-[width] duration-200 md:flex",
|
||||
collapsed ? "w-14" : "w-56",
|
||||
)}
|
||||
>
|
||||
@@ -119,13 +119,9 @@ export function Sidebar() {
|
||||
onClick={toggle}
|
||||
aria-label={t(collapsed ? "sidebar.expand" : "sidebar.collapse")}
|
||||
title={t(collapsed ? "sidebar.expand" : "sidebar.collapse")}
|
||||
className="flex h-12 items-center justify-center border-b border-border text-text-muted transition-colors hover:bg-surface-2 hover:text-text-primary"
|
||||
className="border-border text-text-muted hover:bg-surface-2 hover:text-text-primary flex h-12 items-center justify-center border-b transition-colors"
|
||||
>
|
||||
{collapsed ? (
|
||||
<PanelLeftOpen className="h-5 w-5" />
|
||||
) : (
|
||||
<PanelLeftClose className="h-5 w-5" />
|
||||
)}
|
||||
{collapsed ? <PanelLeftOpen className="h-5 w-5" /> : <PanelLeftClose className="h-5 w-5" />}
|
||||
</button>
|
||||
<SidebarNavList collapsed={collapsed} />
|
||||
</aside>
|
||||
|
||||
@@ -33,7 +33,7 @@ export function LogEntryCard({ entry }: LogEntryProps) {
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
"rounded-lg border bg-surface-2 transition-colors",
|
||||
"bg-surface-2 rounded-lg border transition-colors",
|
||||
entry.level === "error" ? "border-red-500/30" : "border-border",
|
||||
)}
|
||||
>
|
||||
@@ -49,39 +49,39 @@ export function LogEntryCard({ entry }: LogEntryProps) {
|
||||
>
|
||||
{entry.level}
|
||||
</span>
|
||||
<span className="shrink-0 rounded bg-surface-3 px-1.5 py-0.5 text-[10px] text-text-muted">
|
||||
<span className="bg-surface-3 text-text-muted shrink-0 rounded px-1.5 py-0.5 text-[10px]">
|
||||
{entry.source}
|
||||
</span>
|
||||
<span className="min-w-0 flex-1 truncate text-xs text-text-primary">{entry.message}</span>
|
||||
<span className="shrink-0 text-[10px] text-text-muted">{time}</span>
|
||||
<span className="text-text-primary min-w-0 flex-1 truncate text-xs">{entry.message}</span>
|
||||
<span className="text-text-muted shrink-0 text-[10px]">{time}</span>
|
||||
<div className="flex shrink-0 items-center gap-0.5">
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="rounded p-1 text-text-muted hover:bg-surface-3 hover:text-text-primary"
|
||||
className="text-text-muted hover:bg-surface-3 hover:text-text-primary rounded p-1"
|
||||
>
|
||||
{copied ? <Check className="h-3 w-3 text-success" /> : <Copy className="h-3 w-3" />}
|
||||
{copied ? <Check className="text-success h-3 w-3" /> : <Copy className="h-3 w-3" />}
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
deleteEntry(entry.id);
|
||||
}}
|
||||
className="rounded p-1 text-text-muted hover:bg-surface-3 hover:text-danger"
|
||||
className="text-text-muted hover:bg-surface-3 hover:text-danger rounded p-1"
|
||||
>
|
||||
<Trash2 className="h-3 w-3" />
|
||||
</button>
|
||||
{entry.details &&
|
||||
(expanded ? (
|
||||
<ChevronUp className="h-3.5 w-3.5 text-text-muted" />
|
||||
<ChevronUp className="text-text-muted h-3.5 w-3.5" />
|
||||
) : (
|
||||
<ChevronDown className="h-3.5 w-3.5 text-text-muted" />
|
||||
<ChevronDown className="text-text-muted h-3.5 w-3.5" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{expanded && entry.details && (
|
||||
<div className="border-t border-border px-3 py-2">
|
||||
<pre className="max-h-40 overflow-auto whitespace-pre-wrap font-mono text-[11px] text-text-secondary">
|
||||
<div className="border-border border-t px-3 py-2">
|
||||
<pre className="text-text-secondary max-h-40 overflow-auto font-mono text-[11px] whitespace-pre-wrap">
|
||||
{entry.details}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@ export function CharCounter({ text, limit }: CharCounterProps) {
|
||||
return (
|
||||
<span
|
||||
className={clsx(
|
||||
"text-xs font-mono font-semibold transition-colors",
|
||||
"font-mono text-xs font-semibold transition-colors",
|
||||
isOver && "text-danger",
|
||||
isWarning && "text-warning",
|
||||
!isOver && !isWarning && "text-text-muted font-normal",
|
||||
|
||||
@@ -1,61 +1,48 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import toast from "react-hot-toast";
|
||||
import { ClipboardCopy } from "lucide-react";
|
||||
import { Button } from "@components/ui/Button";
|
||||
import { useGeneratedOutput } from "@hooks/use-generated-output";
|
||||
import { useClipboard } from "@hooks/use-clipboard";
|
||||
import { YT_LIMITS } from "@engine/types";
|
||||
import { LimitBlockBanner } from "./LimitBlockBanner";
|
||||
import type { OutputLimitStatus } from "@engine/limits";
|
||||
|
||||
interface CopyAllBarProps {
|
||||
extraText?: string;
|
||||
/** Exactly what gets copied — the caller decides single vs multi-language. */
|
||||
text: string;
|
||||
/**
|
||||
* Over-limit status of every output contributing to `text`. The bar copies a
|
||||
* concatenation, so one offending language blocks the blob.
|
||||
*/
|
||||
status: OutputLimitStatus;
|
||||
}
|
||||
|
||||
export function CopyAllBar({ extraText }: CopyAllBarProps) {
|
||||
/**
|
||||
* Sticky "copy everything" bar.
|
||||
*
|
||||
* Before v0.35.0 this owned its own over-limit check — which skipped tags, and
|
||||
* more importantly bailed out entirely when an `extraText` prop was present.
|
||||
* That prop was set by exactly one caller: OutputPage, whenever more than one
|
||||
* language was selected. So selecting a second language silently turned off
|
||||
* every limit check on the primary copy path. The bar no longer decides
|
||||
* anything; it renders the status the page computes.
|
||||
*/
|
||||
export function CopyAllBar({ text, status }: CopyAllBarProps) {
|
||||
const { t } = useTranslation("ui");
|
||||
const output = useGeneratedOutput();
|
||||
const { copy } = useClipboard();
|
||||
|
||||
const handleCopyAll = () => {
|
||||
if (extraText) {
|
||||
copy(extraText);
|
||||
return;
|
||||
}
|
||||
const overflows: string[] = [];
|
||||
if (output.title.length > YT_LIMITS.TITLE_MAX) {
|
||||
overflows.push(
|
||||
t("output.copy.overLimit", {
|
||||
field: t("output.title"),
|
||||
count: output.title.length,
|
||||
limit: YT_LIMITS.TITLE_MAX,
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (output.description.length > YT_LIMITS.DESCRIPTION_MAX) {
|
||||
overflows.push(
|
||||
t("output.copy.overLimit", {
|
||||
field: t("output.description"),
|
||||
count: output.description.length,
|
||||
limit: YT_LIMITS.DESCRIPTION_MAX,
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (overflows.length > 0) {
|
||||
toast.error(overflows.join("\n"));
|
||||
return;
|
||||
}
|
||||
copy(`${output.title}\n\n${output.description}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="sticky bottom-0 flex items-center justify-end border-t border-border bg-surface-0 px-3 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-4">
|
||||
<Button
|
||||
onClick={handleCopyAll}
|
||||
size="lg"
|
||||
className="text-sm sm:text-base"
|
||||
>
|
||||
<ClipboardCopy className="h-4 w-4" />
|
||||
{t("output.copyAll")}
|
||||
</Button>
|
||||
<div className="border-border bg-surface-0 sticky bottom-0 flex flex-col gap-2 border-t px-3 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-4">
|
||||
<LimitBlockBanner status={status} />
|
||||
<div className="flex items-center justify-end">
|
||||
<Button
|
||||
onClick={() => void copy(text)}
|
||||
disabled={status.blocked || !text}
|
||||
size="lg"
|
||||
className="text-sm sm:text-base"
|
||||
>
|
||||
<ClipboardCopy className="h-4 w-4" />
|
||||
{t("output.copyAll")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Copy, Check, AlertTriangle } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import clsx from "clsx";
|
||||
import { Button } from "@components/ui/Button";
|
||||
import { useClipboard } from "@hooks/use-clipboard";
|
||||
@@ -8,29 +9,45 @@ interface CopyButtonProps {
|
||||
label: string;
|
||||
limit?: number;
|
||||
fieldLabel?: string;
|
||||
/**
|
||||
* Disable the button because *some* field in this output is over its limit —
|
||||
* not necessarily this one.
|
||||
*
|
||||
* The rule is all-or-nothing per output: if the description is 200 characters
|
||||
* too long, copying the title is blocked too. Copying two of three fields and
|
||||
* silently leaving the third behind is how a half-populated video description
|
||||
* gets published.
|
||||
*/
|
||||
blocked?: boolean;
|
||||
}
|
||||
|
||||
export function CopyButton({ text, label, limit, fieldLabel }: CopyButtonProps) {
|
||||
export function CopyButton({ text, label, limit, fieldLabel, blocked }: CopyButtonProps) {
|
||||
const { t } = useTranslation("ui");
|
||||
const { copy, copied } = useClipboard();
|
||||
const isOver = limit !== undefined && text.length > limit;
|
||||
const disabled = !text || blocked;
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => copy(text, { limit, fieldLabel })}
|
||||
disabled={!text}
|
||||
className={clsx(isOver && "text-danger hover:bg-surface-2 hover:text-danger")}
|
||||
title={isOver ? `${text.length}/${limit}` : undefined}
|
||||
// `useClipboard` still re-checks `limit` as a backstop, for any call site
|
||||
// that passes a limit without wiring `blocked`.
|
||||
onClick={() => void copy(text, { limit, fieldLabel })}
|
||||
disabled={disabled}
|
||||
className={clsx((isOver || blocked) && "text-danger hover:bg-surface-2 hover:text-danger")}
|
||||
title={
|
||||
blocked ? t("output.limits.copyBlocked") : isOver ? `${text.length}/${limit}` : undefined
|
||||
}
|
||||
>
|
||||
{isOver ? (
|
||||
{isOver || blocked ? (
|
||||
<AlertTriangle className="h-4 w-4" />
|
||||
) : copied ? (
|
||||
<Check className="h-4 w-4" />
|
||||
) : (
|
||||
<Copy className="h-4 w-4" />
|
||||
)}
|
||||
{copied ? "Copied!" : label}
|
||||
{copied ? t("output.copied") : label}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { AlertTriangle } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { OutputLimitStatus } from "@engine/limits";
|
||||
|
||||
interface LimitBlockBannerProps {
|
||||
status: OutputLimitStatus;
|
||||
/** Optional override for the heading — Batch uses a Copy-All-specific one. */
|
||||
titleKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explains why copying is disabled, naming each offending field with its count.
|
||||
*
|
||||
* Without this, a disabled Copy button is just a dead control. The counts come
|
||||
* from the engine's warnings rather than `CharLimitWarning.message`, which is a
|
||||
* hardcoded English string.
|
||||
*/
|
||||
export function LimitBlockBanner({ status, titleKey }: LimitBlockBannerProps) {
|
||||
const { t } = useTranslation("ui");
|
||||
if (!status.blocked) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
role="alert"
|
||||
className="border-danger/40 bg-danger/10 text-danger flex flex-col gap-1 rounded-lg border px-3 py-2 text-xs"
|
||||
>
|
||||
<span className="flex items-center gap-1.5 font-semibold">
|
||||
<AlertTriangle className="h-3.5 w-3.5 shrink-0" />
|
||||
{t(titleKey ?? "output.limits.bannerTitle")}
|
||||
</span>
|
||||
<ul className="flex flex-col gap-0.5 pl-5">
|
||||
{status.overflows.map((o) => (
|
||||
<li key={o.field}>
|
||||
{t("output.limits.fieldLine", {
|
||||
field: t(`output.${o.field}`),
|
||||
count: o.current,
|
||||
limit: o.limit,
|
||||
})}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<span className="text-text-muted">{t("output.limits.bannerHint")}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -27,9 +27,7 @@ export function OutputExtras() {
|
||||
const pinnedComment = useEditorStore((s) => s.pinnedComment);
|
||||
const showPinnedCommentTemplate = useSettingsStore((s) => s.showPinnedCommentTemplate);
|
||||
const includeAskNextGame = useSettingsStore((s) => s.pinnedCommentIncludeAskNextGame);
|
||||
const includeGenrePlaylist = useSettingsStore(
|
||||
(s) => s.pinnedCommentIncludeGenrePlaylist,
|
||||
);
|
||||
const includeGenrePlaylist = useSettingsStore((s) => s.pinnedCommentIncludeGenrePlaylist);
|
||||
const genrePlaylists = useSettingsStore((s) => s.genrePlaylists);
|
||||
const input = useCurrentGeneratorInput();
|
||||
|
||||
@@ -75,13 +73,11 @@ export function OutputExtras() {
|
||||
{hasThumbnail && (
|
||||
<section className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-text-primary">
|
||||
{t("output.thumbnailText")}
|
||||
</h3>
|
||||
<h3 className="text-text-primary text-sm font-semibold">{t("output.thumbnailText")}</h3>
|
||||
<CopyButton text={thumbnailText} label={t("output.copyThumbnailText")} />
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
|
||||
<div className="border-border bg-surface-1 rounded-lg border p-3">
|
||||
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
|
||||
{thumbnailText}
|
||||
</pre>
|
||||
</div>
|
||||
@@ -91,13 +87,11 @@ export function OutputExtras() {
|
||||
{hasPinned && (
|
||||
<section className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-text-primary">
|
||||
{t("output.pinnedComment")}
|
||||
</h3>
|
||||
<h3 className="text-text-primary text-sm font-semibold">{t("output.pinnedComment")}</h3>
|
||||
<CopyButton text={pinnedComment} label={t("output.copyPinnedComment")} />
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
|
||||
<div className="border-border bg-surface-1 rounded-lg border p-3">
|
||||
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
|
||||
{pinnedComment}
|
||||
</pre>
|
||||
</div>
|
||||
@@ -107,13 +101,13 @@ export function OutputExtras() {
|
||||
{hasTemplate && (
|
||||
<section className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-text-primary">
|
||||
<h3 className="text-text-primary text-sm font-semibold">
|
||||
{t("output.pinnedCommentTemplate")}
|
||||
</h3>
|
||||
<CopyButton text={templateText} label={t("output.copyPinnedCommentTemplate")} />
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
|
||||
<div className="border-border bg-surface-1 rounded-lg border p-3">
|
||||
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
|
||||
{templateText}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@@ -5,12 +5,19 @@ import { CopyButton } from "./CopyButton";
|
||||
import { CharCounter } from "./CharCounter";
|
||||
import { YT_LIMITS } from "@engine/types";
|
||||
import type { GeneratorOutput } from "@engine/types";
|
||||
import type { OutputLimitStatus } from "@engine/limits";
|
||||
|
||||
interface OutputPreviewProps {
|
||||
output?: GeneratorOutput;
|
||||
/**
|
||||
* Over-limit status of the output actually shown. All three copy buttons are
|
||||
* gated on it together — see `CopyButton.blocked` for why it is
|
||||
* all-or-nothing rather than per field.
|
||||
*/
|
||||
status: OutputLimitStatus;
|
||||
}
|
||||
|
||||
export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
|
||||
export function OutputPreview({ output: outputProp, status }: OutputPreviewProps) {
|
||||
const { t } = useTranslation("ui");
|
||||
const defaultOutput = useGeneratedOutput();
|
||||
const { showCharCount, compactTagDisplay } = useSettingsStore();
|
||||
@@ -21,7 +28,7 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
|
||||
{/* Title */}
|
||||
<section className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-text-primary">{t("output.title")}</h3>
|
||||
<h3 className="text-text-primary text-sm font-semibold">{t("output.title")}</h3>
|
||||
<div className="flex items-center gap-3">
|
||||
{showCharCount && <CharCounter text={output.title} limit={YT_LIMITS.TITLE_MAX} />}
|
||||
<CopyButton
|
||||
@@ -29,30 +36,34 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
|
||||
label={t("output.copyTitle")}
|
||||
limit={YT_LIMITS.TITLE_MAX}
|
||||
fieldLabel={t("output.title")}
|
||||
blocked={status.blocked}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
<p className="text-sm font-medium text-text-primary">{output.title}</p>
|
||||
<div className="border-border bg-surface-1 rounded-lg border p-3">
|
||||
<p className="text-text-primary text-sm font-medium">{output.title}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Description */}
|
||||
<section className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-text-primary">{t("output.description")}</h3>
|
||||
<h3 className="text-text-primary text-sm font-semibold">{t("output.description")}</h3>
|
||||
<div className="flex items-center gap-3">
|
||||
{showCharCount && <CharCounter text={output.description} limit={YT_LIMITS.DESCRIPTION_MAX} />}
|
||||
{showCharCount && (
|
||||
<CharCounter text={output.description} limit={YT_LIMITS.DESCRIPTION_MAX} />
|
||||
)}
|
||||
<CopyButton
|
||||
text={output.description}
|
||||
label={t("output.copyDescription")}
|
||||
limit={YT_LIMITS.DESCRIPTION_MAX}
|
||||
fieldLabel={t("output.description")}
|
||||
blocked={status.blocked}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="max-h-[60vh] overflow-y-auto rounded-lg border border-border bg-surface-1 p-3 sm:max-h-[400px]">
|
||||
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
|
||||
<div className="border-border bg-surface-1 max-h-[60vh] overflow-y-auto rounded-lg border p-3 sm:max-h-[400px]">
|
||||
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
|
||||
{output.description}
|
||||
</pre>
|
||||
</div>
|
||||
@@ -61,7 +72,7 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
|
||||
{/* Tags */}
|
||||
<section className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-text-primary">
|
||||
<h3 className="text-text-primary text-sm font-semibold">
|
||||
{t("output.tags")} ({output.tags.length})
|
||||
</h3>
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -71,18 +82,19 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
|
||||
label={t("output.copyTags")}
|
||||
limit={YT_LIMITS.TAGS_MAX}
|
||||
fieldLabel={t("output.tags")}
|
||||
blocked={status.blocked}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
<div className="border-border bg-surface-1 rounded-lg border p-3">
|
||||
{compactTagDisplay ? (
|
||||
<p className="text-xs text-text-secondary">{output.tagString}</p>
|
||||
<p className="text-text-secondary text-xs">{output.tagString}</p>
|
||||
) : (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{output.tags.map((tag, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className="rounded-md bg-surface-2 px-2 py-0.5 text-xs text-text-secondary"
|
||||
className="bg-surface-2 text-text-secondary rounded-md px-2 py-0.5 text-xs"
|
||||
>
|
||||
{tag}
|
||||
</span>
|
||||
|
||||
@@ -82,12 +82,17 @@ export function VariantPicker({ open, onClose }: VariantPickerProps) {
|
||||
]);
|
||||
|
||||
return (
|
||||
<Modal open={open} onClose={onClose} title={t("output.generateAlternatives")} className="max-w-2xl">
|
||||
<Modal
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
title={t("output.generateAlternatives")}
|
||||
className="max-w-2xl"
|
||||
>
|
||||
<div className="flex flex-col gap-4">
|
||||
{variants.map((variant) => (
|
||||
<section key={variant.id} className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wide text-text-muted">
|
||||
<h3 className="text-text-muted text-xs font-semibold tracking-wide uppercase">
|
||||
{t(variant.labelKey)}
|
||||
</h3>
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -95,8 +100,8 @@ export function VariantPicker({ open, onClose }: VariantPickerProps) {
|
||||
<CopyButton text={variant.title} label={t("output.copyTitle")} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
<p className="text-sm font-medium text-text-primary">{variant.title}</p>
|
||||
<div className="border-border bg-surface-1 rounded-lg border p-3">
|
||||
<p className="text-text-primary text-sm font-medium">{variant.title}</p>
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
|
||||
@@ -46,19 +46,19 @@ 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">
|
||||
<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">
|
||||
<div className="hover:border-accent/30 border-border-strong bg-surface-2 flex flex-col gap-3 rounded-lg border p-4 shadow-md shadow-black/10 transition-colors sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="text-text-primary text-sm font-semibold">{preset.gameName}</h3>
|
||||
<div className="text-text-muted mt-1.5 flex flex-wrap items-center gap-1.5 text-xs">
|
||||
{genreDefs.map((g) => (
|
||||
<span key={g.id} className="rounded bg-surface-2 px-1.5 py-0.5">
|
||||
<span key={g.id} className="bg-surface-2 rounded px-1.5 py-0.5">
|
||||
{g.icon} {t(g.labelKey)}
|
||||
</span>
|
||||
))}
|
||||
<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")}
|
||||
@@ -67,7 +67,7 @@ export function PresetCard({ preset }: PresetCardProps) {
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => setShowDelete(true)}>
|
||||
<Trash2 className="h-3.5 w-3.5 text-danger" />
|
||||
<Trash2 className="text-danger h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,11 +85,7 @@ export function PresetCard({ preset }: PresetCardProps) {
|
||||
variant="danger"
|
||||
/>
|
||||
|
||||
<PresetSaveForm
|
||||
open={showEdit}
|
||||
onClose={() => setShowEdit(false)}
|
||||
editPreset={preset}
|
||||
/>
|
||||
<PresetSaveForm open={showEdit} onClose={() => setShowEdit(false)} editPreset={preset} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export function PresetList() {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="text-base font-semibold text-text-primary">{t("presets.title")}</h2>
|
||||
<h2 className="text-text-primary text-base font-semibold">{t("presets.title")}</h2>
|
||||
<Button size="sm" onClick={() => setShowCreate(true)}>
|
||||
<Plus className="h-4 w-4" />
|
||||
{t("presets.createNew")}
|
||||
@@ -22,7 +22,7 @@ export function PresetList() {
|
||||
</div>
|
||||
|
||||
{presets.length === 0 ? (
|
||||
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
|
||||
<p className="border-border text-text-muted rounded-lg border border-dashed py-8 text-center text-sm">
|
||||
{t("presets.emptyState")}
|
||||
</p>
|
||||
) : (
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Input } from "@components/ui/Input";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { useSettingsStore } from "@store/settings-store";
|
||||
import { usePresetStore, type GamePreset } from "@store/preset-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
interface PresetSaveFormProps {
|
||||
open: boolean;
|
||||
@@ -59,12 +60,13 @@ export function PresetSaveForm({ open, onClose, editPreset }: PresetSaveFormProp
|
||||
<div className="flex flex-col gap-3">
|
||||
<Input
|
||||
label={t("editor.gameName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("editor.gameNamePlaceholder")}
|
||||
value={gameName}
|
||||
onChange={(e) => setGameName(e.target.value)}
|
||||
autoFocus
|
||||
/>
|
||||
<p className="text-xs text-text-muted">
|
||||
<p className="text-text-muted text-xs">
|
||||
{editPreset
|
||||
? "Update the game name. Other fields are saved from the editor."
|
||||
: "Preset will save your current game name, genre, platform, store links, and warning settings."}
|
||||
|
||||
@@ -40,5 +40,7 @@ export function PresetSelector() {
|
||||
}
|
||||
};
|
||||
|
||||
return <Select label={t("presets.selectPreset")} options={options} value="" onChange={handleSelect} />;
|
||||
return (
|
||||
<Select label={t("presets.selectPreset")} options={options} value="" onChange={handleSelect} />
|
||||
);
|
||||
}
|
||||
@@ -27,6 +27,8 @@ export function ProfileCard({ profile }: ProfileCardProps) {
|
||||
loadProfile({
|
||||
channelName: profile.channelName,
|
||||
contactEmail: profile.contactEmail,
|
||||
adEmail: profile.adEmail ?? "",
|
||||
gameKeyEmail: profile.gameKeyEmail ?? "",
|
||||
social: { ...(profile.social ?? {}) },
|
||||
rig: { ...(profile.rig ?? {}) },
|
||||
resolution: profile.resolution,
|
||||
@@ -43,16 +45,18 @@ 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">
|
||||
<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="hover:border-accent/30 border-border-strong bg-surface-2 flex flex-col gap-3 rounded-lg border p-4 shadow-md shadow-black/10 transition-colors sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="text-text-primary text-sm font-semibold">{profile.name}</h3>
|
||||
<p className="text-text-secondary mt-0.5 text-xs">
|
||||
{profile.channelName || "No channel"}
|
||||
</p>
|
||||
<div className="text-text-muted mt-1.5 flex flex-wrap gap-3 text-xs">
|
||||
{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")}
|
||||
@@ -61,7 +65,7 @@ export function ProfileCard({ profile }: ProfileCardProps) {
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => setShowDelete(true)}>
|
||||
<Trash2 className="h-3.5 w-3.5 text-danger" />
|
||||
<Trash2 className="text-danger h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,11 +83,7 @@ export function ProfileCard({ profile }: ProfileCardProps) {
|
||||
variant="danger"
|
||||
/>
|
||||
|
||||
<ProfileSaveForm
|
||||
open={showEdit}
|
||||
onClose={() => setShowEdit(false)}
|
||||
editProfile={profile}
|
||||
/>
|
||||
<ProfileSaveForm open={showEdit} onClose={() => setShowEdit(false)} editProfile={profile} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export function ProfileList() {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="text-base font-semibold text-text-primary">{t("profiles.title")}</h2>
|
||||
<h2 className="text-text-primary text-base font-semibold">{t("profiles.title")}</h2>
|
||||
<Button size="sm" onClick={() => setShowCreate(true)}>
|
||||
<Plus className="h-4 w-4" />
|
||||
{t("profiles.createNew")}
|
||||
@@ -22,7 +22,7 @@ export function ProfileList() {
|
||||
</div>
|
||||
|
||||
{profiles.length === 0 ? (
|
||||
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
|
||||
<p className="border-border text-text-muted rounded-lg border border-dashed py-8 text-center text-sm">
|
||||
{t("profiles.emptyState")}
|
||||
</p>
|
||||
) : (
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Input } from "@components/ui/Input";
|
||||
import { Textarea } from "@components/ui/Textarea";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { useProfileStore, type Profile } from "@store/profile-store";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
interface ProfileSaveFormProps {
|
||||
open: boolean;
|
||||
@@ -34,6 +35,8 @@ export function ProfileSaveForm({ open, onClose, editProfile }: ProfileSaveFormP
|
||||
name: name.trim() || "Unnamed Profile",
|
||||
channelName: editProfile?.channelName ?? editor.channelName,
|
||||
contactEmail: editProfile?.contactEmail ?? editor.contactEmail,
|
||||
adEmail: editProfile?.adEmail ?? editor.adEmail,
|
||||
gameKeyEmail: editProfile?.gameKeyEmail ?? editor.gameKeyEmail,
|
||||
social: editProfile?.social ?? { ...editor.social },
|
||||
rig: editProfile?.rig ?? { ...editor.rig },
|
||||
resolution: editProfile?.resolution ?? editor.resolution,
|
||||
@@ -67,6 +70,7 @@ export function ProfileSaveForm({ open, onClose, editProfile }: ProfileSaveFormP
|
||||
<div className="flex flex-col gap-3">
|
||||
<Input
|
||||
label={t("profiles.profileName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("profiles.profileNamePlaceholder")}
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
@@ -74,13 +78,14 @@ export function ProfileSaveForm({ open, onClose, editProfile }: ProfileSaveFormP
|
||||
/>
|
||||
<Textarea
|
||||
label={t("profiles.thirdPartyAdText")}
|
||||
maxLength={FIELD_LIMITS.LONG_TEXT}
|
||||
placeholder={t("profiles.thirdPartyAdTextPlaceholder")}
|
||||
value={adText}
|
||||
onChange={(e) => setAdText(e.target.value)}
|
||||
rows={4}
|
||||
/>
|
||||
<p className="text-xs text-text-muted">{t("profiles.thirdPartyAdTextHelp")}</p>
|
||||
<p className="text-xs text-text-muted">
|
||||
<p className="text-text-muted text-xs">{t("profiles.thirdPartyAdTextHelp")}</p>
|
||||
<p className="text-text-muted text-xs">
|
||||
{editProfile
|
||||
? "Update this profile's name and ad copy. Other fields are saved from the editor."
|
||||
: "Profile will save your current channel name, social links, rig info, and video settings."}
|
||||
|
||||
@@ -24,7 +24,9 @@ export function TemplateCard({ template }: TemplateCardProps) {
|
||||
// patch via `normalizeEditorPatch`, but checking here lets us
|
||||
// surface a clearer toast and skip the no-op success message.
|
||||
if (!template.snapshot || typeof template.snapshot !== "object") {
|
||||
toast.error(t("templates.applyFailed", { defaultValue: "Template is corrupt — cannot apply" }));
|
||||
toast.error(
|
||||
t("templates.applyFailed", { defaultValue: "Template is corrupt — cannot apply" }),
|
||||
);
|
||||
return;
|
||||
}
|
||||
loadProfile(template.snapshot);
|
||||
@@ -35,22 +37,22 @@ 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">
|
||||
<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="hover:border-accent/30 border-border-strong bg-surface-2 flex flex-col gap-3 rounded-lg border p-4 shadow-md shadow-black/10 transition-colors sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="text-text-primary text-sm font-semibold">{template.name}</h3>
|
||||
<div className="text-text-muted mt-1.5 flex flex-wrap items-center gap-2 text-xs">
|
||||
<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")}
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => setShowDelete(true)}>
|
||||
<Trash2 className="h-3.5 w-3.5 text-danger" />
|
||||
<Trash2 className="text-danger h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ export function TemplateList() {
|
||||
|
||||
if (templates.length === 0) {
|
||||
return (
|
||||
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
|
||||
<p className="border-border text-text-muted rounded-lg border border-dashed py-8 text-center text-sm">
|
||||
{t("templates.emptyState")}
|
||||
</p>
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Input } from "@components/ui/Input";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { useTemplateStore, type TemplateSnapshot } from "@store/template-store";
|
||||
import toast from "react-hot-toast";
|
||||
import { FIELD_LIMITS } from "@config/field-limits";
|
||||
|
||||
interface TemplateSaveFormProps {
|
||||
open: boolean;
|
||||
@@ -56,6 +57,8 @@ export function TemplateSaveForm({ open, onClose }: TemplateSaveFormProps) {
|
||||
timestamps: editor.timestamps,
|
||||
playlistLink: editor.playlistLink,
|
||||
contactEmail: editor.contactEmail,
|
||||
adEmail: editor.adEmail,
|
||||
gameKeyEmail: editor.gameKeyEmail,
|
||||
musicAttribution: editor.musicAttribution,
|
||||
thumbnailText: editor.thumbnailText,
|
||||
pinnedComment: editor.pinnedComment,
|
||||
@@ -80,6 +83,11 @@ export function TemplateSaveForm({ open, onClose }: TemplateSaveFormProps) {
|
||||
vnBankHolder: editor.vnBankHolder,
|
||||
vnMomo: editor.vnMomo,
|
||||
vnZalopay: editor.vnZalopay,
|
||||
messengerCommunityLink: editor.messengerCommunityLink,
|
||||
zaloGroupLink: editor.zaloGroupLink,
|
||||
signalGroupLink: editor.signalGroupLink,
|
||||
instagramGroupLink: editor.instagramGroupLink,
|
||||
facebookGroupLink: editor.facebookGroupLink,
|
||||
};
|
||||
addTemplate(name, snapshot);
|
||||
toast.success(t("templates.savedAs", { name: name.trim() || "Untitled" }));
|
||||
@@ -104,12 +112,13 @@ export function TemplateSaveForm({ open, onClose }: TemplateSaveFormProps) {
|
||||
<div className="flex flex-col gap-3">
|
||||
<Input
|
||||
label={t("templates.templateName")}
|
||||
maxLength={FIELD_LIMITS.SHORT_NAME}
|
||||
placeholder={t("templates.templateNamePlaceholder")}
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
autoFocus
|
||||
/>
|
||||
<p className="text-xs text-text-muted">{t("templates.saveHint")}</p>
|
||||
<p className="text-text-muted text-xs">{t("templates.saveHint")}</p>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@@ -23,34 +23,26 @@ interface AccordionProps {
|
||||
* sections are open and persists that choice. Height animates via a
|
||||
* grid-rows trick so content can be any height without measurement.
|
||||
*/
|
||||
export function Accordion({
|
||||
id,
|
||||
title,
|
||||
icon,
|
||||
badge,
|
||||
open,
|
||||
onToggle,
|
||||
children,
|
||||
}: AccordionProps) {
|
||||
export function Accordion({ id, title, icon, badge, open, onToggle, children }: AccordionProps) {
|
||||
return (
|
||||
<section
|
||||
data-accordion-id={id}
|
||||
className="overflow-hidden rounded-lg border border-border bg-surface-1"
|
||||
className="border-border bg-surface-1 overflow-hidden rounded-lg border"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggle}
|
||||
aria-expanded={open}
|
||||
className="flex w-full items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-surface-2"
|
||||
className="hover:bg-surface-2 flex w-full items-center justify-between gap-3 px-4 py-3 text-left transition-colors"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
{icon && <span className="text-base leading-none">{icon}</span>}
|
||||
<span className="text-sm font-semibold text-text-primary">{title}</span>
|
||||
<span className="text-text-primary text-sm font-semibold">{title}</span>
|
||||
{badge}
|
||||
</div>
|
||||
<ChevronDown
|
||||
className={clsx(
|
||||
"h-4 w-4 text-text-muted transition-transform duration-200",
|
||||
"text-text-muted h-4 w-4 transition-transform duration-200",
|
||||
open && "rotate-180",
|
||||
)}
|
||||
/>
|
||||
@@ -62,9 +54,7 @@ export function Accordion({
|
||||
)}
|
||||
>
|
||||
<div className="overflow-hidden">
|
||||
<div className="flex flex-col gap-3 border-t border-border px-4 py-4">
|
||||
{children}
|
||||
</div>
|
||||
<div className="border-border flex flex-col gap-3 border-t px-4 py-4">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -23,7 +23,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
<button
|
||||
ref={ref}
|
||||
className={clsx(
|
||||
"inline-flex items-center justify-center gap-2 rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 disabled:cursor-not-allowed disabled:opacity-50",
|
||||
"focus:ring-accent/50 inline-flex items-center justify-center gap-2 rounded-lg font-medium transition-colors focus:ring-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
||||
variantClasses[variant],
|
||||
sizeClasses[size],
|
||||
className,
|
||||
|
||||
@@ -25,7 +25,10 @@ export function Checkbox({ checked, onChange, label, className, id }: CheckboxPr
|
||||
return (
|
||||
<label
|
||||
htmlFor={inputId}
|
||||
className={clsx("group flex min-h-touch cursor-pointer items-start gap-3 text-left", className)}
|
||||
className={clsx(
|
||||
"group min-h-touch flex cursor-pointer items-start gap-3 text-left",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<input
|
||||
id={inputId}
|
||||
@@ -38,15 +41,15 @@ export function Checkbox({ checked, onChange, label, className, id }: CheckboxPr
|
||||
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",
|
||||
"peer-focus-visible:ring-accent/50 peer-focus-visible:ring-2",
|
||||
checked
|
||||
? "border-accent bg-accent text-white"
|
||||
: "border-border bg-surface-1 text-transparent group-hover:border-border-strong",
|
||||
: "border-border bg-surface-1 group-hover:border-border-strong text-transparent",
|
||||
)}
|
||||
>
|
||||
<Check className="h-3.5 w-3.5" strokeWidth={3} />
|
||||
</span>
|
||||
<span className="text-sm leading-snug text-text-primary">{label}</span>
|
||||
<span className="text-text-primary text-sm leading-snug">{label}</span>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
@@ -52,15 +52,14 @@ export function ChipGroup(props: ChipGroupProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const counter =
|
||||
props.multiple && props.max != null ? `${props.value.length}/${props.max}` : null;
|
||||
const counter = props.multiple && props.max != null ? `${props.value.length}/${props.max}` : null;
|
||||
|
||||
return (
|
||||
<div className={clsx("flex flex-col gap-2", className)}>
|
||||
{(label || counter) && (
|
||||
<div className="flex items-center justify-between">
|
||||
{label && <span className="text-sm font-medium text-text-secondary">{label}</span>}
|
||||
{counter && <span className="text-xs text-text-muted">{counter}</span>}
|
||||
{label && <span className="text-text-secondary text-sm font-medium">{label}</span>}
|
||||
{counter && <span className="text-text-muted text-xs">{counter}</span>}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-2">
|
||||
@@ -78,7 +77,7 @@ export function ChipGroup(props: ChipGroupProps) {
|
||||
selected
|
||||
? "bg-accent text-white"
|
||||
: disabled
|
||||
? "cursor-not-allowed bg-surface-2 text-text-muted opacity-40"
|
||||
? "bg-surface-2 text-text-muted cursor-not-allowed opacity-40"
|
||||
: "bg-surface-2 text-text-secondary hover:bg-surface-3 hover:text-text-primary",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -36,14 +36,14 @@ export function ConfirmDialog({
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={onConfirm}
|
||||
className={variant === "danger" ? "bg-danger hover:bg-danger/80" : ""}
|
||||
className={variant === "danger" ? "hover:bg-danger/80 bg-danger" : ""}
|
||||
>
|
||||
{confirmLabel ?? t("common.confirm")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<p className="text-sm text-text-secondary">{message}</p>
|
||||
<p className="text-text-secondary text-sm">{message}</p>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -43,23 +43,15 @@ export function Drawer({
|
||||
)}
|
||||
aria-hidden={!open}
|
||||
>
|
||||
<div
|
||||
className="absolute inset-0 bg-black/60"
|
||||
onClick={onClose}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-black/60" onClick={onClose} aria-hidden="true" />
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={ariaLabel ?? title}
|
||||
className={clsx(
|
||||
"absolute bottom-0 top-0 flex w-64 max-w-[85vw] flex-col bg-surface-1 shadow-2xl transition-transform duration-200",
|
||||
side === "left" ? "left-0 border-r border-border" : "right-0 border-l border-border",
|
||||
open
|
||||
? "translate-x-0"
|
||||
: side === "left"
|
||||
? "-translate-x-full"
|
||||
: "translate-x-full",
|
||||
"bg-surface-1 absolute top-0 bottom-0 flex w-64 max-w-[85vw] flex-col shadow-2xl transition-transform duration-200",
|
||||
side === "left" ? "border-border left-0 border-r" : "border-border right-0 border-l",
|
||||
open ? "translate-x-0" : side === "left" ? "-translate-x-full" : "translate-x-full",
|
||||
className,
|
||||
)}
|
||||
style={{
|
||||
@@ -68,12 +60,12 @@ export function Drawer({
|
||||
}}
|
||||
>
|
||||
{title && (
|
||||
<div className="flex items-center justify-between border-b border-border px-4 py-3">
|
||||
<h2 className="text-base font-semibold text-text-primary">{title}</h2>
|
||||
<div className="border-border flex items-center justify-between border-b px-4 py-3">
|
||||
<h2 className="text-text-primary text-base font-semibold">{title}</h2>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-2 text-text-muted hover:bg-surface-2 hover:text-text-primary"
|
||||
className="text-text-muted hover:bg-surface-2 hover:text-text-primary rounded-lg p-2"
|
||||
aria-label="Close"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
|
||||
@@ -4,29 +4,37 @@ import clsx from "clsx";
|
||||
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||
label?: string;
|
||||
error?: boolean;
|
||||
/** Inline error message shown below the input (also forces the red border). */
|
||||
errorText?: string;
|
||||
/** Inline hint shown below the input when there is no error. */
|
||||
helpText?: string;
|
||||
}
|
||||
|
||||
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
({ label, error, className, id, ...props }, ref) => {
|
||||
({ label, error, errorText, helpText, className, id, ...props }, ref) => {
|
||||
const inputId = id ?? label?.toLowerCase().replace(/\s+/g, "-");
|
||||
const isError = error || Boolean(errorText);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
{label && (
|
||||
<label htmlFor={inputId} className="text-sm font-medium text-text-secondary">
|
||||
<label htmlFor={inputId} className="text-text-secondary text-sm font-medium">
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
<input
|
||||
ref={ref}
|
||||
id={inputId}
|
||||
aria-invalid={isError || undefined}
|
||||
className={clsx(
|
||||
"min-h-touch rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary placeholder:text-text-muted transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 sm:text-sm",
|
||||
error ? "border-danger" : "border-border focus:border-accent",
|
||||
"focus:ring-accent/50 min-h-touch bg-surface-1 text-text-primary placeholder:text-text-muted rounded-lg border px-3 py-2.5 text-base transition-colors focus:ring-2 focus:outline-none sm:text-sm",
|
||||
isError ? "border-danger" : "border-border focus:border-accent",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
{errorText && <p className="text-danger text-xs">{errorText}</p>}
|
||||
{helpText && !errorText && <p className="text-text-muted text-xs">{helpText}</p>}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -35,16 +35,16 @@ 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",
|
||||
"border-border bg-surface-1 mx-4 flex max-h-[85vh] w-[calc(100%-2rem)] max-w-lg flex-col rounded-xl border shadow-2xl",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{title && (
|
||||
<div className="flex items-center justify-between border-b border-border px-5 py-4">
|
||||
<h2 className="text-base font-semibold text-text-primary">{title}</h2>
|
||||
<div className="border-border flex items-center justify-between border-b px-5 py-4">
|
||||
<h2 className="text-text-primary text-base font-semibold">{title}</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-1 text-text-muted hover:bg-surface-2 hover:text-text-primary"
|
||||
className="text-text-muted hover:bg-surface-2 hover:text-text-primary rounded-lg p-1"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
@@ -52,7 +52,7 @@ export function Modal({ open, onClose, title, children, footer, className }: Mod
|
||||
)}
|
||||
<div className="flex-1 overflow-y-auto px-5 py-4">{children}</div>
|
||||
{footer && (
|
||||
<div className="flex justify-end gap-2 border-t border-border px-5 py-3">{footer}</div>
|
||||
<div className="border-border flex justify-end gap-2 border-t px-5 py-3">{footer}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
{label && (
|
||||
<label htmlFor={selectId} className="text-sm font-medium text-text-secondary">
|
||||
<label htmlFor={selectId} className="text-text-secondary text-sm font-medium">
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
@@ -29,7 +29,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className={clsx(
|
||||
"rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 focus:border-accent",
|
||||
"focus:ring-accent/50 border-border bg-surface-1 text-text-primary focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Modal } from "./Modal";
|
||||
|
||||
@@ -22,36 +22,33 @@ export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
|
||||
const { t } = useTranslation("ui");
|
||||
const [query, setQuery] = useState("");
|
||||
|
||||
// Reset the filter every time the modal closes so a re-open starts
|
||||
// fresh — otherwise the previous filter persists invisibly.
|
||||
useEffect(() => {
|
||||
if (!open) setQuery("");
|
||||
}, [open]);
|
||||
// A closed modal has no filter. Deriving this rather than resetting `query`
|
||||
// in an effect means a re-open always starts fresh without an extra render
|
||||
// pass on every parent update while the modal is closed.
|
||||
const activeQuery = open ? query : "";
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
const trimmed = query.trim().toLowerCase();
|
||||
const trimmed = activeQuery.trim().toLowerCase();
|
||||
if (!trimmed) return SHORTCUTS;
|
||||
return SHORTCUTS.filter((s) => {
|
||||
const label = t(s.labelKey).toLowerCase();
|
||||
return label.includes(trimmed) || s.keys.toLowerCase().includes(trimmed);
|
||||
});
|
||||
}, [query, t]);
|
||||
}, [activeQuery, t]);
|
||||
|
||||
return (
|
||||
<Modal open={open} onClose={onClose} title={t("shortcuts.title")}>
|
||||
<div className="flex flex-col gap-3">
|
||||
<input
|
||||
type="text"
|
||||
value={query}
|
||||
value={activeQuery}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={t("shortcuts.searchPlaceholder")}
|
||||
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
|
||||
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
|
||||
autoFocus
|
||||
/>
|
||||
{filtered.length === 0 ? (
|
||||
<p className="py-2 text-sm text-text-muted">
|
||||
{t("shortcuts.noResults")}
|
||||
</p>
|
||||
<p className="text-text-muted py-2 text-sm">{t("shortcuts.noResults")}</p>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
{filtered.map((s) => (
|
||||
@@ -59,10 +56,8 @@ export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
|
||||
key={`${s.keys}-${s.labelKey}`}
|
||||
className="flex items-center justify-between py-1"
|
||||
>
|
||||
<span className="text-sm text-text-secondary">
|
||||
{t(s.labelKey)}
|
||||
</span>
|
||||
<kbd className="rounded bg-surface-2 px-2 py-0.5 font-mono text-xs text-text-primary">
|
||||
<span className="text-text-secondary text-sm">{t(s.labelKey)}</span>
|
||||
<kbd className="bg-surface-2 text-text-primary rounded px-2 py-0.5 font-mono text-xs">
|
||||
{s.keys}
|
||||
</kbd>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { ShieldAlert } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useSettingsStore } from "@store/settings-store";
|
||||
import { useEditorIssues } from "@hooks/use-strict-block";
|
||||
|
||||
/**
|
||||
* Lists the fields Strict Mode is blocking on.
|
||||
*
|
||||
* A disabled Generate button with no explanation is worse than no gate at all,
|
||||
* so this always names the offending field and its error. Renders nothing when
|
||||
* Strict Mode is off or nothing is wrong.
|
||||
*/
|
||||
export function StrictModeBanner() {
|
||||
const { t } = useTranslation("ui");
|
||||
const strictMode = useSettingsStore((s) => s.strictMode);
|
||||
const issues = useEditorIssues();
|
||||
const errors = issues.filter((i) => i.severity === "error");
|
||||
|
||||
if (!strictMode || errors.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
role="alert"
|
||||
className="border-danger/40 bg-danger/10 text-danger flex flex-col gap-1 rounded-lg border px-3 py-2 text-xs"
|
||||
>
|
||||
<span className="flex items-center gap-1.5 font-semibold">
|
||||
<ShieldAlert className="h-3.5 w-3.5 shrink-0" />
|
||||
{t("strict.blockedTitle", { count: errors.length })}
|
||||
</span>
|
||||
<ul className="flex flex-col gap-0.5 pl-5">
|
||||
{errors.map((issue) => (
|
||||
<li key={issue.id}>
|
||||
<span className="font-medium">{t(issue.labelKey)}</span>
|
||||
{" — "}
|
||||
{t(issue.messageKey, issue.params as Record<string, string>)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<span className="text-text-muted">{t("strict.fixHint")}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
{label && (
|
||||
<label htmlFor={inputId} className="text-sm font-medium text-text-secondary">
|
||||
<label htmlFor={inputId} className="text-text-secondary text-sm font-medium">
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
@@ -21,7 +21,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||
ref={ref}
|
||||
id={inputId}
|
||||
className={clsx(
|
||||
"min-h-[96px] rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary placeholder:text-text-muted transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 resize-y sm:text-sm",
|
||||
"focus:ring-accent/50 bg-surface-1 text-text-primary placeholder:text-text-muted min-h-[96px] resize-y rounded-lg border px-3 py-2.5 text-base transition-colors focus:ring-2 focus:outline-none sm:text-sm",
|
||||
error ? "border-danger" : "border-border focus:border-accent",
|
||||
className,
|
||||
)}
|
||||
|
||||
@@ -16,7 +16,7 @@ export function Toggle({ label, checked, onChange, className }: ToggleProps) {
|
||||
aria-checked={checked}
|
||||
onClick={() => onChange(!checked)}
|
||||
className={clsx(
|
||||
"relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50",
|
||||
"focus:ring-accent/50 relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors focus:ring-2 focus:outline-none",
|
||||
checked ? "bg-accent" : "bg-surface-3",
|
||||
)}
|
||||
>
|
||||
@@ -27,7 +27,7 @@ export function Toggle({ label, checked, onChange, className }: ToggleProps) {
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
<span className="text-sm text-text-primary">{label}</span>
|
||||
<span className="text-text-primary text-sm">{label}</span>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,20 @@
|
||||
import { useState, useCallback, type ClipboardEvent } from "react";
|
||||
import { useState, useCallback, useEffect, useRef, type ClipboardEvent } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { ValidationResult } from "@utils/validation";
|
||||
import { usePendingInvalidStore } from "@store/pending-invalid-store";
|
||||
import clsx from "clsx";
|
||||
|
||||
interface ValidatedInputProps {
|
||||
label: string;
|
||||
/**
|
||||
* Stable id matching the one `collectEditorIssues` uses for the same field
|
||||
* (`storeLinks.steam`, `contactEmail`). Supplying it lets Strict Mode see
|
||||
* text that is invalid *and therefore never committed to the editor store* —
|
||||
* without it, such a field is invisible to every gate outside this page.
|
||||
*/
|
||||
fieldId?: string;
|
||||
/** i18n key naming the field in the Strict Mode banner. */
|
||||
labelKey?: string;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
validate: (value: string) => ValidationResult;
|
||||
@@ -13,6 +23,24 @@ interface ValidatedInputProps {
|
||||
inputMode?: "text" | "email" | "url" | "numeric" | "tel" | "search" | "decimal";
|
||||
autoComplete?: string;
|
||||
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
|
||||
/**
|
||||
* Hard cap on typed/pasted length — see `src/config/field-limits.ts`. This
|
||||
* component does not spread props onto the input, so unlike `Input` it needs
|
||||
* the prop declared explicitly.
|
||||
*/
|
||||
maxLength?: number;
|
||||
/**
|
||||
* Veto or rewrite a change before it is validated or committed. Return the
|
||||
* (possibly adjusted) next value to accept it, or `null` to reject the
|
||||
* keystroke outright, leaving the field exactly as it was.
|
||||
*
|
||||
* Used for constraints a validator cannot express without destroying data —
|
||||
* the three-address email cap, where rejecting the 4th address must not
|
||||
* disturb the three already typed.
|
||||
*/
|
||||
beforeChange?: (next: string, prev: string) => string | null;
|
||||
/** Shown instead of `helpText` when `beforeChange` rejects a change. */
|
||||
blockedMessage?: string;
|
||||
/**
|
||||
* Forwarded to the inner `<input>`. Used by StoreLinkEditor to sniff a
|
||||
* pasted URL and auto-fill the Game Name field — see
|
||||
@@ -24,6 +52,8 @@ interface ValidatedInputProps {
|
||||
|
||||
export function ValidatedInput({
|
||||
label,
|
||||
fieldId,
|
||||
labelKey,
|
||||
value,
|
||||
onChange,
|
||||
validate,
|
||||
@@ -32,41 +62,109 @@ export function ValidatedInput({
|
||||
inputMode,
|
||||
autoComplete,
|
||||
enterKeyHint,
|
||||
maxLength,
|
||||
beforeChange,
|
||||
blockedMessage,
|
||||
onPaste,
|
||||
}: ValidatedInputProps) {
|
||||
const { t } = useTranslation("ui");
|
||||
const [displayValue, setDisplayValue] = useState(value);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [touched, setTouched] = useState(false);
|
||||
const [blocked, setBlocked] = useState(false);
|
||||
|
||||
// Re-sync when the value changes underneath us — applying a profile, preset
|
||||
// or template, or resetting the editor. Without this the box kept showing
|
||||
// whatever was typed first and silently disagreed with the store, because
|
||||
// `useState(value)` only reads the prop on mount.
|
||||
//
|
||||
// Guarded on `displayValue` so it never fights the user's own typing: while
|
||||
// they type, `value` and `displayValue` already agree (or `value` is the last
|
||||
// valid one, in which case an external change is what we want to adopt).
|
||||
const lastExternalValue = useRef(value);
|
||||
useEffect(() => {
|
||||
if (value !== lastExternalValue.current) {
|
||||
lastExternalValue.current = value;
|
||||
setDisplayValue(value);
|
||||
setError(null);
|
||||
setBlocked(false);
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(newValue: string) => {
|
||||
setDisplayValue(newValue);
|
||||
const result = validate(newValue);
|
||||
(rawValue: string) => {
|
||||
const next = beforeChange ? beforeChange(rawValue, displayValue) : rawValue;
|
||||
if (next === null) {
|
||||
// Rejected outright — leave both the display and the committed value
|
||||
// untouched so nothing already entered is lost.
|
||||
setBlocked(true);
|
||||
setTouched(true);
|
||||
return;
|
||||
}
|
||||
setBlocked(false);
|
||||
setDisplayValue(next);
|
||||
lastExternalValue.current = next;
|
||||
|
||||
const result = validate(next);
|
||||
if (result.valid && !result.error) {
|
||||
// Fully valid: commit the value to the store.
|
||||
setError(null);
|
||||
onChange(newValue);
|
||||
onChange(next);
|
||||
} else if (result.valid && result.error) {
|
||||
// Warning (e.g. prefix mismatch from validateUrlWithPrefix).
|
||||
// Surface the warning but still commit so the user can decide.
|
||||
setError(t(result.error, result.errorParams as Record<string, string>));
|
||||
onChange(newValue);
|
||||
onChange(next);
|
||||
} else {
|
||||
// Invalid: show the error and CLEAR the committed value so the
|
||||
// bad input never reaches the generated description/tags. The
|
||||
// local displayValue is preserved so the user can keep editing.
|
||||
// Invalid: surface the error and DON'T commit, so the bad input never
|
||||
// reaches the generated description/tags.
|
||||
//
|
||||
// Before v0.35.0 this branch called `onChange("")`, which wiped the
|
||||
// stored value while the box still showed the user's text — so
|
||||
// backspacing one character out of a complete URL silently emptied the
|
||||
// field, and autosave/profile-save then persisted the empty value with
|
||||
// no visible signal. Leaving the last valid value in place keeps bad
|
||||
// input out just as effectively without destroying good input.
|
||||
setError(t(result.error ?? "", result.errorParams as Record<string, string>));
|
||||
onChange("");
|
||||
}
|
||||
setTouched(true);
|
||||
},
|
||||
[validate, onChange, t],
|
||||
[validate, onChange, t, beforeChange, displayValue],
|
||||
);
|
||||
|
||||
const message = blocked ? (blockedMessage ?? error) : error;
|
||||
|
||||
// Publish "this field currently holds text that will not be saved" so gates
|
||||
// on other pages can see it. Keyed on the raw validation result rather than
|
||||
// the rendered message, which is already translated and would re-publish on
|
||||
// every UI-language change.
|
||||
const liveResult = validate(displayValue);
|
||||
const isInvalid = blocked || (!liveResult.valid && displayValue.trim() !== "");
|
||||
const invalidKey = blocked ? "validation.emailMaxReached" : (liveResult.error ?? "");
|
||||
const invalidParams = JSON.stringify(liveResult.errorParams ?? null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!fieldId) return;
|
||||
const { markInvalid, clearInvalid } = usePendingInvalidStore.getState();
|
||||
if (isInvalid) {
|
||||
const parsed = JSON.parse(invalidParams) as Record<string, string | number> | null;
|
||||
markInvalid({
|
||||
id: fieldId,
|
||||
labelKey: labelKey ?? label,
|
||||
messageKey: invalidKey,
|
||||
...(parsed ? { params: parsed } : {}),
|
||||
});
|
||||
} else {
|
||||
clearInvalid(fieldId);
|
||||
}
|
||||
// Deliberately NO cleanup on unmount — see the store's doc comment. An
|
||||
// entry lives until the field is valid again, so navigating to Batch does
|
||||
// not silently clear the very thing Strict Mode is supposed to catch.
|
||||
}, [fieldId, labelKey, label, isInvalid, invalidKey, invalidParams]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<label className="text-sm font-medium text-text-secondary">{label}</label>
|
||||
<label className="text-text-secondary text-sm font-medium">{label}</label>
|
||||
<input
|
||||
type="text"
|
||||
value={displayValue}
|
||||
@@ -77,13 +175,15 @@ export function ValidatedInput({
|
||||
inputMode={inputMode}
|
||||
autoComplete={autoComplete}
|
||||
enterKeyHint={enterKeyHint}
|
||||
maxLength={maxLength}
|
||||
aria-invalid={touched && Boolean(message) ? true : undefined}
|
||||
className={clsx(
|
||||
"min-h-touch rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary placeholder:text-text-muted transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 sm:text-sm",
|
||||
touched && error ? "border-danger" : "border-border focus:border-accent",
|
||||
"focus:ring-accent/50 min-h-touch bg-surface-1 text-text-primary placeholder:text-text-muted rounded-lg border px-3 py-2.5 text-base transition-colors focus:ring-2 focus:outline-none sm:text-sm",
|
||||
touched && message ? "border-danger" : "border-border focus:border-accent",
|
||||
)}
|
||||
/>
|
||||
{touched && error && <p className="text-xs text-danger">{error}</p>}
|
||||
{helpText && !error && <p className="text-xs text-text-muted">{helpText}</p>}
|
||||
{touched && message && <p className="text-danger text-xs">{message}</p>}
|
||||
{helpText && !message && <p className="text-text-muted text-xs">{helpText}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
} from "./graphics-settings";
|
||||
import type { VideoStyleEra } from "./video-styles";
|
||||
import { DEFAULT_GACHA_QUEST_TYPE, type GachaQuestType } from "./gacha-quest-types";
|
||||
import { DEFAULT_PLAYTEST_PLATFORM } from "./playtest-platforms";
|
||||
import type {
|
||||
SupportedLanguage,
|
||||
StoreLinkType,
|
||||
@@ -70,6 +71,17 @@ export interface EditorDefaults {
|
||||
timestamps: string;
|
||||
playlistLink: string;
|
||||
contactEmail: string;
|
||||
/**
|
||||
* v0.34.0 email-split fields. When the `splitContactEmail` settings
|
||||
* toggle is on, the description's contact block renders a labeled line
|
||||
* per purpose: `contactEmail` (general), `adEmail` (advertising /
|
||||
* sponsorship inquiries — distinct from the video-sponsor-credit
|
||||
* fields `sponsorName` / `sponsorPlatform`), and `gameKeyEmail` (game
|
||||
* keys & playtest invites). Each holds up to 3 comma-separated emails
|
||||
* (same `validateEmails` cap as `contactEmail`). Empty by default.
|
||||
*/
|
||||
adEmail: string;
|
||||
gameKeyEmail: string;
|
||||
musicAttribution: string;
|
||||
sponsorName: string;
|
||||
sponsorPlatform: string;
|
||||
@@ -131,6 +143,22 @@ export interface EditorDefaults {
|
||||
vnBankHolder: string;
|
||||
vnMomo: string;
|
||||
vnZalopay: string;
|
||||
/** Playtest signup link (v0.30.0). Empty string = no playtest block. */
|
||||
playtestLink: string;
|
||||
/** Playtest platform id (see `@config/playtest-platforms`). */
|
||||
playtestPlatform: string;
|
||||
/** Playtest invites available, 0..platform max (≤100). 0 = unset. */
|
||||
playtestInvites: number;
|
||||
/** Messenger community invite link (v0.32.0). `https://m.me/ch/<id>`. Empty = no community line. */
|
||||
messengerCommunityLink: string;
|
||||
/** Zalo group invite link (v0.32.0). `https://zalo.me/g/<code>`. Rendered only for Vietnamese output. */
|
||||
zaloGroupLink: string;
|
||||
/** Signal group invite link (v0.33.0). `https://signal.group/#<id>`. Rendered for all languages. Empty = no line. */
|
||||
signalGroupLink: string;
|
||||
/** Instagram group-chat invite link (v0.33.0). `https://www.instagram.com/j/<id>` or `https://ig.me/j/<id>`. All languages. */
|
||||
instagramGroupLink: string;
|
||||
/** Facebook group invite link (v0.33.0). `https://facebook.com/groups/<id>`. Moved from the generic Social list; all languages. */
|
||||
facebookGroupLink: string;
|
||||
}
|
||||
|
||||
export interface SettingsDefaults {
|
||||
@@ -176,6 +204,8 @@ export const DEFAULTS = {
|
||||
timestamps: "",
|
||||
playlistLink: "",
|
||||
contactEmail: "",
|
||||
adEmail: "",
|
||||
gameKeyEmail: "",
|
||||
musicAttribution: "",
|
||||
sponsorName: "",
|
||||
sponsorPlatform: "",
|
||||
@@ -208,6 +238,14 @@ export const DEFAULTS = {
|
||||
vnBankHolder: "",
|
||||
vnMomo: "",
|
||||
vnZalopay: "",
|
||||
playtestLink: "",
|
||||
playtestPlatform: DEFAULT_PLAYTEST_PLATFORM,
|
||||
playtestInvites: 0,
|
||||
messengerCommunityLink: "",
|
||||
zaloGroupLink: "",
|
||||
signalGroupLink: "",
|
||||
instagramGroupLink: "",
|
||||
facebookGroupLink: "",
|
||||
} satisfies EditorDefaults,
|
||||
|
||||
settings: {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Predefined "why was this playlist dropped" reasons (v0.31.0).
|
||||
*
|
||||
* Drives the Playlist Generator's dropped-reason multi-select, shown only
|
||||
* when the playlist status is "dropped". Each id maps to a localized label
|
||||
* under `playlist.droppedReasons.<id>` in BOTH the `ui` namespace (the
|
||||
* selection chips) and the `templates` namespace (the rendered output) —
|
||||
* the same split used by content warnings. The list is a starting point,
|
||||
* just plain constants free to tune; the editor's free-text "other reason"
|
||||
* field covers anything not listed here.
|
||||
*/
|
||||
export const DROPPED_REASONS = [
|
||||
{ id: "boring", icon: "😴" },
|
||||
{ id: "performance", icon: "🐌" },
|
||||
{ id: "bugs", icon: "🐛" },
|
||||
{ id: "delisted", icon: "🗑️" },
|
||||
{ id: "low_views", icon: "📉" },
|
||||
{ id: "time", icon: "⏳" },
|
||||
] as const;
|
||||
|
||||
export type DroppedReasonId = (typeof DROPPED_REASONS)[number]["id"];
|
||||
@@ -21,12 +21,7 @@ import {
|
||||
* - `runtime` — a render crash caught by ErrorBoundary
|
||||
*/
|
||||
export type ErrorKind =
|
||||
| "notFound"
|
||||
| "forbidden"
|
||||
| "expired"
|
||||
| "serverError"
|
||||
| "offline"
|
||||
| "runtime";
|
||||
"notFound" | "forbidden" | "expired" | "serverError" | "offline" | "runtime";
|
||||
|
||||
type ErrorSeverity = "accent" | "danger" | "warning";
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { YT_LIMITS } from "@engine/types";
|
||||
|
||||
/**
|
||||
* Maximum length of every free-text field in the editor.
|
||||
*
|
||||
* Until v0.35.0 no input in the app had a cap at all: `maxLength` appeared
|
||||
* nowhere in the codebase. A pasted novel in the game-name field produced a
|
||||
* title YouTube would reject, and a 4 KB "URL" silently rode along into the
|
||||
* description.
|
||||
*
|
||||
* Caps are grouped by the *kind* of thing a field holds, not per field, so a
|
||||
* new input inherits a sensible limit by picking the closest category instead
|
||||
* of inventing a number. All values are UTF-16 code units, matching the DOM
|
||||
* `maxLength` attribute — an emoji costs 2 and a flag emoji 4. That is a
|
||||
* deliberate simplification: grapheme counting would be more "correct" but
|
||||
* cannot be enforced by the browser, and these are generous ceilings meant to
|
||||
* stop absurd input, not to budget characters precisely.
|
||||
*/
|
||||
export const FIELD_LIMITS = {
|
||||
/**
|
||||
* Store pages, social profiles, playlists, community invites. The longest
|
||||
* realistic value in the app's own inventory is a Signal group invite
|
||||
* (`https://signal.group/#<base64>`) at roughly 120 characters.
|
||||
*/
|
||||
URL: 200,
|
||||
|
||||
/**
|
||||
* Up to three comma-separated addresses. RFC 5321 caps a single address at
|
||||
* 254, so 200 would be too tight for even one worst-case address; 320 fits
|
||||
* three ordinary ones with room to spare while still rejecting a paste of
|
||||
* an entire contact list.
|
||||
*/
|
||||
EMAIL_FIELD: 320,
|
||||
|
||||
/**
|
||||
* Game names, channel names, boss / chapter / DLC names, sponsor names,
|
||||
* hardware model strings, profile and preset names. The longest real game
|
||||
* titles run to roughly 50 characters.
|
||||
*/
|
||||
SHORT_NAME: 100,
|
||||
|
||||
/** Custom labels and version strings — a phrase, not a sentence. */
|
||||
LABEL: 300,
|
||||
|
||||
/**
|
||||
* Music attribution, mod lists, pinned comments, thumbnail text, sponsor
|
||||
* blurbs, playlist notes. Long enough for a real credits block, short
|
||||
* enough that no single field can consume the whole description budget.
|
||||
*/
|
||||
LONG_TEXT: 2000,
|
||||
|
||||
/**
|
||||
* The timestamps field is the one input that legitimately holds a whole
|
||||
* chapter list. Capped at the YouTube description limit because a longer
|
||||
* value could only ever produce a description that is already over budget
|
||||
* and blocked from copying.
|
||||
*/
|
||||
TIMESTAMPS: YT_LIMITS.DESCRIPTION_MAX,
|
||||
|
||||
/** Part numbers, years, counts. Ten digits is already absurd for these. */
|
||||
NUMERIC: 10,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Truncate a value to `max`.
|
||||
*
|
||||
* The DOM `maxLength` attribute only constrains *typing and pasting*. Values
|
||||
* arriving programmatically — a profile / preset / template import, a
|
||||
* store-link paste that auto-fills the game name, a hand-edited settings JSON
|
||||
* — bypass it entirely. Run those through here, or the cap is decorative.
|
||||
*/
|
||||
export function clampField(value: string, max: number): string {
|
||||
return value.length > max ? value.slice(0, max) : value;
|
||||
}
|
||||
@@ -42,11 +42,7 @@ export type GachaQuestType = (typeof GACHA_QUEST_TYPES)[number];
|
||||
export const DEFAULT_GACHA_QUEST_TYPE: GachaQuestType = "main_story";
|
||||
|
||||
export type GachaQuestTypeGroup =
|
||||
| "story"
|
||||
| "events"
|
||||
| "tutorial_trial"
|
||||
| "endgame_multiplayer"
|
||||
| "showcase";
|
||||
"story" | "events" | "tutorial_trial" | "endgame_multiplayer" | "showcase";
|
||||
|
||||
/**
|
||||
* Display-order grouping for the quest-type dropdown. Each group
|
||||
@@ -140,10 +136,7 @@ const DEFAULT_FIELD_VISIBILITY: GachaQuestFieldVisibility = {
|
||||
anniversaryYear: false,
|
||||
};
|
||||
|
||||
export const GACHA_QUEST_FIELD_VISIBILITY: Record<
|
||||
GachaQuestType,
|
||||
GachaQuestFieldVisibility
|
||||
> = {
|
||||
export const GACHA_QUEST_FIELD_VISIBILITY: Record<GachaQuestType, GachaQuestFieldVisibility> = {
|
||||
main_story: { ...DEFAULT_FIELD_VISIBILITY, questName: false },
|
||||
world_quest: { ...DEFAULT_FIELD_VISIBILITY, chapterName: false, partNumber: false },
|
||||
side_quest: { ...DEFAULT_FIELD_VISIBILITY, chapterName: false, partNumber: false },
|
||||
|
||||
@@ -44,7 +44,15 @@ const NVIDIA_SERIES: readonly GpuSeries[] = [
|
||||
{
|
||||
id: "rtx_50",
|
||||
label: "RTX 50 Series",
|
||||
models: ["RTX 5050", "RTX 5060", "RTX 5060 Ti", "RTX 5070", "RTX 5070 Ti", "RTX 5080", "RTX 5090"],
|
||||
models: [
|
||||
"RTX 5050",
|
||||
"RTX 5060",
|
||||
"RTX 5060 Ti",
|
||||
"RTX 5070",
|
||||
"RTX 5070 Ti",
|
||||
"RTX 5080",
|
||||
"RTX 5090",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "rtx_40",
|
||||
@@ -185,12 +193,32 @@ const AMD_SERIES: readonly GpuSeries[] = [
|
||||
{
|
||||
id: "r9_300",
|
||||
label: "Radeon R7/R9 300",
|
||||
models: ["R7 360", "R7 370", "R9 380", "R9 380X", "R9 390", "R9 390X", "R9 Fury", "R9 Fury X", "R9 Nano"],
|
||||
models: [
|
||||
"R7 360",
|
||||
"R7 370",
|
||||
"R9 380",
|
||||
"R9 380X",
|
||||
"R9 390",
|
||||
"R9 390X",
|
||||
"R9 Fury",
|
||||
"R9 Fury X",
|
||||
"R9 Nano",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "r9_200",
|
||||
label: "Radeon R7/R9 200",
|
||||
models: ["R7 250", "R7 260", "R7 260X", "R9 270", "R9 270X", "R9 280", "R9 280X", "R9 290", "R9 290X"],
|
||||
models: [
|
||||
"R7 250",
|
||||
"R7 260",
|
||||
"R7 260X",
|
||||
"R9 270",
|
||||
"R9 270X",
|
||||
"R9 280",
|
||||
"R9 280X",
|
||||
"R9 290",
|
||||
"R9 290X",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "hd_7000",
|
||||
@@ -253,4 +281,4 @@ export const GPU_CUSTOM_BRAND_ID = "custom";
|
||||
*/
|
||||
export function findGpuBrand(brandId: string): GpuBrand | undefined {
|
||||
return GPU_CATALOG.find((b) => b.id === brandId);
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,7 @@ export type GraphicsPreset = (typeof GRAPHICS_PRESETS)[number];
|
||||
* of these layered (e.g. Path Tracing + Ray Reconstruction + Frame
|
||||
* Generation). Empty array → no RT clause in the description.
|
||||
*/
|
||||
export const RT_MODES = [
|
||||
"ray_tracing",
|
||||
"full_rt",
|
||||
"path_tracing",
|
||||
"ray_reconstruction",
|
||||
] as const;
|
||||
export const RT_MODES = ["ray_tracing", "full_rt", "path_tracing", "ray_reconstruction"] as const;
|
||||
export type RTMode = (typeof RT_MODES)[number];
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,9 +21,7 @@ export interface PlatformConfig {
|
||||
* numeric id, yielding the canonical `.../app/<id>` form.
|
||||
*/
|
||||
function normalizeSteamUrl(url: string): string {
|
||||
const match = url.match(
|
||||
/^(https:\/\/store\.steampowered\.com\/app\/\d+)(?:\/.*)?$/i,
|
||||
);
|
||||
const match = url.match(/^(https:\/\/store\.steampowered\.com\/app\/\d+)(?:\/.*)?$/i);
|
||||
return match?.[1] ?? url;
|
||||
}
|
||||
|
||||
@@ -72,8 +70,7 @@ export const PLATFORMS: readonly PlatformConfig[] = [
|
||||
urlPrefix: "https://<dev>.itch.io/<game>",
|
||||
// itch.io games live at https://<dev>.itch.io/<game>, where <dev>
|
||||
// is a user subdomain. Reject the bare https://itch.io/... host.
|
||||
urlPattern:
|
||||
/^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
|
||||
urlPattern: /^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
|
||||
},
|
||||
{
|
||||
id: "humble",
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Playtest platform catalogue (v0.30.0).
|
||||
*
|
||||
* Drives the editor's Playtest section: the creator picks ONE platform
|
||||
* their playtest signup lives on, pastes the link, and optionally records
|
||||
* how many invites they have to give away. Mirrors the {@link PlatformConfig}
|
||||
* shape from `@config/platforms` (id / label / urlPrefix / urlPattern) and
|
||||
* adds a per-platform `maxInvites`.
|
||||
*
|
||||
* Why per-platform caps: a playtest's invite budget varies by storefront
|
||||
* (Steam Playtest grants, itch.io download keys, Discord closed-beta seats…),
|
||||
* so the editor's invite-count input maxes out at the selected platform's
|
||||
* cap rather than one flat number. The absolute ceiling is
|
||||
* {@link PLAYTEST_MAX_INVITES_CAP} (100) — no platform may exceed it.
|
||||
*
|
||||
* The `maxInvites` numbers below are sensible starting points, NOT hard
|
||||
* facts — they're plain constants and meant to be tuned freely.
|
||||
*/
|
||||
|
||||
/** Absolute hard cap on playtest invites, regardless of platform. */
|
||||
export const PLAYTEST_MAX_INVITES_CAP = 100;
|
||||
|
||||
export interface PlaytestPlatformConfig {
|
||||
readonly id: string;
|
||||
readonly label: string;
|
||||
/** Shown as the link input's placeholder / hint. */
|
||||
readonly urlPrefix: string;
|
||||
/** Authoritative validator. Must match the entire trimmed URL. */
|
||||
readonly urlPattern: RegExp;
|
||||
/** Per-platform invite ceiling. Always ≤ {@link PLAYTEST_MAX_INVITES_CAP}. */
|
||||
readonly maxInvites: number;
|
||||
}
|
||||
|
||||
export const PLAYTEST_PLATFORMS: readonly PlaytestPlatformConfig[] = [
|
||||
{
|
||||
id: "steam",
|
||||
label: "Steam Playtest",
|
||||
urlPrefix: "https://store.steampowered.com/app/",
|
||||
urlPattern: /^https:\/\/store\.steampowered\.com\/app\/\d+(?:\/[^\s]*)?$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
{
|
||||
id: "epic",
|
||||
label: "Epic Games Store",
|
||||
urlPrefix: "https://store.epicgames.com/",
|
||||
urlPattern: /^https:\/\/store\.epicgames\.com\/[^\s]+$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
{
|
||||
id: "itchio",
|
||||
label: "itch.io",
|
||||
urlPrefix: "https://<dev>.itch.io/<game>",
|
||||
urlPattern: /^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
|
||||
maxInvites: 50,
|
||||
},
|
||||
{
|
||||
id: "discord",
|
||||
label: "Discord / Community",
|
||||
urlPrefix: "https://discord.gg/",
|
||||
urlPattern: /^https:\/\/(?:discord\.gg|discord\.com\/invite)\/[^\s]+$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
{
|
||||
// Catch-all for signup forms, publisher beta pages, Google Forms, etc.
|
||||
// Pattern is intentionally loose (any HTTPS URL with a host).
|
||||
id: "other",
|
||||
label: "Other / Signup form",
|
||||
urlPrefix: "https://",
|
||||
urlPattern: /^https:\/\/[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+(?:\/[^\s]*)?$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
] as const;
|
||||
|
||||
/** Default platform id used by a fresh draft / migration back-fill. */
|
||||
export const DEFAULT_PLAYTEST_PLATFORM = PLAYTEST_PLATFORMS[0]?.id ?? "steam";
|
||||
|
||||
/**
|
||||
* Invite ceiling for a platform id, capped at the absolute maximum.
|
||||
* Unknown ids (e.g. a hand-edited blob) fall back to the absolute cap.
|
||||
*/
|
||||
export function maxInvitesForPlatform(id: string): number {
|
||||
const found = PLAYTEST_PLATFORMS.find((p) => p.id === id);
|
||||
return Math.min(found?.maxInvites ?? PLAYTEST_MAX_INVITES_CAP, PLAYTEST_MAX_INVITES_CAP);
|
||||
}
|
||||
Loaded 100 of 204 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user