Merge pull request #135 from poli0981/chore/security-and-format
ci: enforce existing checks, patch advisories, backfill CHANGELOG
This commit is contained in:
114 files changed
+1488
-1603
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,6 +6,20 @@ 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
|
||||
@@ -16,8 +30,40 @@ jobs:
|
||||
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
|
||||
@@ -35,6 +35,55 @@ and **Facebook Group** moved in from the generic Social list.
|
||||
- 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
|
||||
|
||||
@@ -15,6 +15,17 @@ export default tseslint.config(
|
||||
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
||||
},
|
||||
},
|
||||
{
|
||||
// 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",
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ["dist/", "node_modules/", "*.config.*"],
|
||||
},
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"ignoreExportsUsedInFile": true,
|
||||
"ignoreDependencies": [
|
||||
"@tauri-apps/plugin-fs",
|
||||
"@tauri-apps/plugin-opener",
|
||||
"@tauri-apps/plugin-shell",
|
||||
"@testing-library/jest-dom",
|
||||
"@testing-library/react"
|
||||
|
||||
Generated
+21
-3
@@ -29,6 +29,7 @@
|
||||
"@eslint/js": "^9.0.0",
|
||||
"@testing-library/jest-dom": "^6.4.0",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/node": "^26.2.0",
|
||||
"@types/react": "^18.3.0",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
@@ -2327,6 +2328,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "26.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.2.0.tgz",
|
||||
"integrity": "sha512-5IviulTZeRNp2vAJ514cc/HUlY5nZ9fCbq9DMyC52BrhFZACo3nI0R7qBxhQmo/d27NFe96ur/b7Wwxklda+kg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~8.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/prop-types": {
|
||||
"version": "15.7.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
|
||||
@@ -4657,9 +4668,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.16",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz",
|
||||
"integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==",
|
||||
"version": "3.3.18",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
|
||||
"integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -5989,6 +6000,13 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
|
||||
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/update-browserslist-db": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
|
||||
|
||||
+7
-3
@@ -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",
|
||||
@@ -43,6 +46,7 @@
|
||||
"@eslint/js": "^9.0.0",
|
||||
"@testing-library/jest-dom": "^6.4.0",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/node": "^26.2.0",
|
||||
"@types/react": "^18.3.0",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 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 };
|
||||
}
|
||||
let version: string | null = null;
|
||||
try {
|
||||
version = source.extract(raw);
|
||||
} catch {
|
||||
version = null;
|
||||
}
|
||||
return { label: source.label, version };
|
||||
});
|
||||
|
||||
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(", ")}`);
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
+44
-20
@@ -24,21 +24,13 @@ 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>;
|
||||
@@ -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
|
||||
|
||||
@@ -42,9 +42,7 @@ export function CommunityEditor() {
|
||||
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.community")}
|
||||
</span>
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.community")}</span>
|
||||
<p className="text-xs text-text-muted">{t("editor.communityHelp")}</p>
|
||||
</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,13 +66,9 @@ 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-sm font-medium text-text-secondary">{t("editor.warnings")}</span>
|
||||
{selected.length > 0 && (
|
||||
<span className="text-xs text-text-muted">
|
||||
{selected.length} selected
|
||||
</span>
|
||||
<span className="text-xs text-text-muted">{selected.length} selected</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -108,9 +101,7 @@ export function ContentWarningChecklist() {
|
||||
<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}
|
||||
@@ -131,7 +122,7 @@ 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 rounded-full px-2 py-0.5 text-[10px] font-medium text-accent">
|
||||
{groupSelectedCount}
|
||||
</span>
|
||||
)}
|
||||
@@ -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 h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-border text-accent focus:ring-1"
|
||||
/>
|
||||
<span>{t(`editor.contentWarningOptions.${id}`)}</span>
|
||||
</label>
|
||||
|
||||
@@ -4,10 +4,7 @@ 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";
|
||||
@@ -78,7 +75,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 +86,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 +116,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,9 +201,7 @@ export function EndingsEditor() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{count === 0 && (
|
||||
<p className="text-xs text-text-muted">{t("editor.endings.emptyHint")}</p>
|
||||
)}
|
||||
{count === 0 && <p className="text-xs text-text-muted">{t("editor.endings.emptyHint")}</p>}
|
||||
|
||||
{/* CASE A: single ending — number + name pair, with preview. */}
|
||||
{count === 1 && endings[0] && (
|
||||
@@ -297,7 +290,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 flex items-start gap-1.5 rounded border p-2 text-xs text-warning">
|
||||
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
|
||||
<span>
|
||||
{t("editor.endings.warnings.timelineShort", {
|
||||
@@ -321,16 +314,12 @@ export function EndingsEditor() {
|
||||
/>
|
||||
{isMultiVideo && (
|
||||
<>
|
||||
<p className="text-xs text-text-muted">
|
||||
{t("editor.endings.videoRangeHint")}
|
||||
</p>
|
||||
<p className="text-xs text-text-muted">{t("editor.endings.videoRangeHint")}</p>
|
||||
<div className="overflow-hidden rounded border border-border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-surface-2 text-xs uppercase text-text-muted">
|
||||
<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>
|
||||
@@ -345,9 +334,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 +343,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 +352,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 flex flex-col gap-1 rounded border p-2 text-xs text-warning">
|
||||
{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 +379,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-xs text-text-muted">{t("editor.endings.videoIndexHint")}</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -32,9 +32,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 +55,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-sm font-medium text-text-secondary">
|
||||
{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 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"
|
||||
>
|
||||
{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}`)}
|
||||
@@ -96,22 +86,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-sm font-medium text-text-secondary">
|
||||
{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 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"
|
||||
>
|
||||
<option value="">—</option>
|
||||
{ANNIVERSARY_YEARS.map((y) => (
|
||||
@@ -212,7 +196,7 @@ export function ExtraFieldsInput() {
|
||||
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 rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors placeholder:text-text-muted focus:border-accent focus:outline-none focus:ring-2"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -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,9 +50,7 @@ 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-sm font-medium text-text-secondary">{t("editor.genre")}</span>
|
||||
<span className="text-xs text-text-muted">
|
||||
{genres.length}/{MAX_GENRES}
|
||||
</span>
|
||||
@@ -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 rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors placeholder:text-text-muted focus:border-accent focus:outline-none focus:ring-2"
|
||||
/>
|
||||
{visibleOptions.length === 0 ? (
|
||||
<p className="py-2 text-sm text-text-muted">
|
||||
{t("editor.genreSearchNoResults")}
|
||||
</p>
|
||||
<p className="py-2 text-sm text-text-muted">{t("editor.genreSearchNoResults")}</p>
|
||||
) : (
|
||||
<ChipGroup
|
||||
multiple
|
||||
@@ -95,7 +86,7 @@ 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 flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-xs text-text-secondary">
|
||||
<span>{t("editor.skipGraphicsHintLabel")}</span>
|
||||
<div className="flex shrink-0 gap-2">
|
||||
<button
|
||||
|
||||
@@ -4,15 +4,8 @@ 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 { validateUrl, validateUrlWithPattern, validateIntegerInRange } from "@utils/validation";
|
||||
import { PLAYTEST_PLATFORMS, maxInvitesForPlatform } from "@config/playtest-platforms";
|
||||
|
||||
/**
|
||||
* Playtest section (v0.30.0). One signup link + the platform it lives on +
|
||||
|
||||
@@ -11,12 +11,8 @@ export function QuickPreview() {
|
||||
|
||||
<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-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>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -32,9 +28,7 @@ export function QuickPreview() {
|
||||
<span className="text-xs font-medium uppercase text-text-muted">
|
||||
{t("output.tags")} ({output.tags.length})
|
||||
</span>
|
||||
<p className="mt-1 line-clamp-2 text-xs text-text-muted">
|
||||
{output.tagString || "..."}
|
||||
</p>
|
||||
<p className="mt-1 line-clamp-2 text-xs text-text-muted">{output.tagString || "..."}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -66,10 +66,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,11 +81,7 @@ 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 (
|
||||
@@ -141,9 +134,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
|
||||
@@ -181,9 +172,7 @@ 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>
|
||||
<div className="grid grid-cols-2 gap-2">{renderedParts}</div>
|
||||
{renderValidationBadge(issue)}
|
||||
</div>
|
||||
);
|
||||
@@ -247,8 +236,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);
|
||||
};
|
||||
|
||||
|
||||
@@ -7,10 +7,7 @@ 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";
|
||||
|
||||
const STORE_LINK_TYPE_VALUES: readonly StoreLinkType[] = ["paid", "free", "demo"];
|
||||
@@ -30,9 +27,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,
|
||||
@@ -135,10 +132,7 @@ 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
|
||||
label={platform.label}
|
||||
placeholder={platform.urlPrefix}
|
||||
|
||||
@@ -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,13 +67,9 @@ 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-sm font-medium text-text-secondary">{t("editor.techNotes")}</span>
|
||||
{selected.length > 0 && (
|
||||
<span className="text-xs text-text-muted">
|
||||
{selected.length} selected
|
||||
</span>
|
||||
<span className="text-xs text-text-muted">{selected.length} selected</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -102,16 +95,12 @@ export function TechNotesChecklist() {
|
||||
</div>
|
||||
|
||||
{isFiltering && totalMatching === 0 ? (
|
||||
<p className="py-2 text-center text-xs text-text-muted">
|
||||
{t("editor.techNoteEmpty")}
|
||||
</p>
|
||||
<p className="py-2 text-center text-xs text-text-muted">{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}
|
||||
@@ -132,7 +121,7 @@ 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 rounded-full px-2 py-0.5 text-[10px] font-medium text-accent">
|
||||
{groupSelectedCount}
|
||||
</span>
|
||||
)}
|
||||
@@ -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 h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-border text-accent focus:ring-1"
|
||||
/>
|
||||
<span>{t(`editor.techNoteOptions.${id}`)}</span>
|
||||
</label>
|
||||
|
||||
@@ -48,11 +48,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,9 +60,7 @@ 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>
|
||||
<span className="text-sm font-medium text-text-secondary">{t("editor.vnDonate")}</span>
|
||||
<p className="text-xs text-text-muted">{t("editor.vnDonateHelp")}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ function FullscreenError({ kind }: ErrorPageProps) {
|
||||
<div className="flex min-h-screen flex-col items-center justify-center gap-6 bg-surface-0 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 font-bold tabular-nums leading-none", colour)}>
|
||||
{meta.code}
|
||||
</p>
|
||||
)}
|
||||
@@ -99,7 +99,7 @@ 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 w-full max-w-md rounded-lg border bg-surface-2 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>
|
||||
@@ -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 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",
|
||||
sizeClass,
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -35,7 +35,7 @@ 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 fixed inset-x-0 bottom-0 z-50 flex items-center justify-center gap-3 border-t bg-surface-2 px-4 py-2 text-sm text-text-primary shadow-md shadow-black/20"
|
||||
>
|
||||
<WifiOff className="h-4 w-4 shrink-0 text-warning" aria-hidden />
|
||||
<span>{t("errorPages.offlineBanner.message")}</span>
|
||||
|
||||
@@ -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 rounded-lg border border-border-strong bg-surface-2 shadow-md shadow-black/10 transition-colors">
|
||||
<div
|
||||
className="flex cursor-pointer items-center justify-between p-3"
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
|
||||
@@ -37,9 +37,7 @@ 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="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">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
{onOpenMobileNav && (
|
||||
<button
|
||||
@@ -55,9 +53,7 @@ export function Header({ onOpenMobileNav }: HeaderProps) {
|
||||
<h1 className="truncate text-base font-bold text-text-primary sm:text-lg">
|
||||
{t("app.title")}
|
||||
</h1>
|
||||
<p className="hidden truncate text-xs text-text-muted sm:block">
|
||||
{t("app.subtitle")}
|
||||
</p>
|
||||
<p className="hidden truncate text-xs text-text-muted sm:block">{t("app.subtitle")}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
@@ -79,11 +75,7 @@ export function Header({ onOpenMobileNav }: HeaderProps) {
|
||||
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
|
||||
@@ -97,7 +89,7 @@ export function Header({ onOpenMobileNav }: HeaderProps) {
|
||||
<ChevronDown className="h-3.5 w-3.5 text-text-muted" />
|
||||
</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="absolute right-0 top-full z-50 mt-1 min-w-[200px] max-w-[calc(100vw-2rem)] rounded-lg border border-border bg-surface-1 py-1 shadow-xl">
|
||||
{SUPPORTED_LANGUAGES.map((lang) => (
|
||||
<button
|
||||
key={lang.id}
|
||||
|
||||
@@ -50,9 +50,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" });
|
||||
}
|
||||
|
||||
|
||||
@@ -121,11 +121,7 @@ export function Sidebar() {
|
||||
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"
|
||||
>
|
||||
{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>
|
||||
|
||||
@@ -19,10 +19,10 @@ 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",
|
||||
!isOver && !isWarning && "font-normal text-text-muted",
|
||||
)}
|
||||
>
|
||||
{count}/{limit}
|
||||
|
||||
@@ -48,11 +48,7 @@ export function CopyAllBar({ extraText }: CopyAllBarProps) {
|
||||
|
||||
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"
|
||||
>
|
||||
<Button onClick={handleCopyAll} size="lg" className="text-sm sm:text-base">
|
||||
<ClipboardCopy className="h-4 w-4" />
|
||||
{t("output.copyAll")}
|
||||
</Button>
|
||||
|
||||
@@ -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,9 +73,7 @@ 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-sm font-semibold text-text-primary">{t("output.thumbnailText")}</h3>
|
||||
<CopyButton text={thumbnailText} label={t("output.copyThumbnailText")} />
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
@@ -91,9 +87,7 @@ 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-sm font-semibold text-text-primary">{t("output.pinnedComment")}</h3>
|
||||
<CopyButton text={pinnedComment} label={t("output.copyPinnedComment")} />
|
||||
</div>
|
||||
<div className="rounded-lg border border-border bg-surface-1 p-3">
|
||||
|
||||
@@ -42,7 +42,9 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold text-text-primary">{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")}
|
||||
|
||||
@@ -82,7 +82,12 @@ 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">
|
||||
|
||||
@@ -46,7 +46,7 @@ export function PresetCard({ preset }: PresetCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="hover:border-accent/30 flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 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-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">
|
||||
@@ -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} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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} />
|
||||
);
|
||||
}
|
||||
@@ -45,10 +45,12 @@ export function ProfileCard({ profile }: ProfileCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="hover:border-accent/30 flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 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-sm font-semibold text-text-primary">{profile.name}</h3>
|
||||
<p className="mt-0.5 text-xs text-text-secondary">{profile.channelName || "No channel"}</p>
|
||||
<p className="mt-0.5 text-xs text-text-secondary">
|
||||
{profile.channelName || "No channel"}
|
||||
</p>
|
||||
<div className="mt-1.5 flex flex-wrap gap-3 text-xs text-text-muted">
|
||||
{socialCount > 0 && <span>{socialCount} social links</span>}
|
||||
{rigCount > 0 && <span>{rigCount} rig fields</span>}
|
||||
@@ -81,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} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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,7 +37,7 @@ export function TemplateCard({ template }: TemplateCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="hover:border-accent/30 flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 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-sm font-semibold text-text-primary">{template.name}</h3>
|
||||
<div className="mt-1.5 flex flex-wrap items-center gap-2 text-xs text-text-muted">
|
||||
|
||||
@@ -23,15 +23,7 @@ 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}
|
||||
@@ -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="flex flex-col gap-3 border-t border-border 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:outline-none focus:ring-2 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 flex min-h-touch cursor-pointer items-start gap-3 text-left",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<input
|
||||
id={inputId}
|
||||
@@ -38,7 +41,7 @@ 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",
|
||||
|
||||
@@ -52,8 +52,7 @@ 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)}>
|
||||
|
||||
@@ -36,7 +36,7 @@ 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>
|
||||
|
||||
@@ -43,11 +43,7 @@ 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"
|
||||
@@ -55,11 +51,7 @@ export function Drawer({
|
||||
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",
|
||||
open ? "translate-x-0" : side === "left" ? "-translate-x-full" : "translate-x-full",
|
||||
className,
|
||||
)}
|
||||
style={{
|
||||
|
||||
@@ -27,7 +27,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
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",
|
||||
"focus:ring-accent/50 min-h-touch rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary transition-colors placeholder:text-text-muted focus:outline-none focus:ring-2 sm:text-sm",
|
||||
isError ? "border-danger" : "border-border focus:border-accent",
|
||||
className,
|
||||
)}
|
||||
|
||||
@@ -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 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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -45,13 +45,11 @@ export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
|
||||
value={query}
|
||||
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 rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors placeholder:text-text-muted focus:border-accent focus:outline-none focus:ring-2"
|
||||
autoFocus
|
||||
/>
|
||||
{filtered.length === 0 ? (
|
||||
<p className="py-2 text-sm text-text-muted">
|
||||
{t("shortcuts.noResults")}
|
||||
</p>
|
||||
<p className="py-2 text-sm text-text-muted">{t("shortcuts.noResults")}</p>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
{filtered.map((s) => (
|
||||
@@ -59,9 +57,7 @@ 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>
|
||||
<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">
|
||||
{s.keys}
|
||||
</kbd>
|
||||
|
||||
@@ -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 min-h-[96px] resize-y rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary transition-colors placeholder:text-text-muted focus:outline-none focus:ring-2 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:outline-none focus:ring-2",
|
||||
checked ? "bg-accent" : "bg-surface-3",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -78,7 +78,7 @@ export function ValidatedInput({
|
||||
autoComplete={autoComplete}
|
||||
enterKeyHint={enterKeyHint}
|
||||
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",
|
||||
"focus:ring-accent/50 min-h-touch rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary transition-colors placeholder:text-text-muted focus:outline-none focus:ring-2 sm:text-sm",
|
||||
touched && error ? "border-danger" : "border-border focus:border-accent",
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -140,10 +140,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",
|
||||
|
||||
@@ -50,8 +50,7 @@ export const PLAYTEST_PLATFORMS: readonly PlaytestPlatformConfig[] = [
|
||||
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,
|
||||
urlPattern: /^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
|
||||
maxInvites: 50,
|
||||
},
|
||||
{
|
||||
|
||||
+21
-15
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
GPU_CATALOG,
|
||||
GPU_CUSTOM_BRAND_ID,
|
||||
findGpuBrand,
|
||||
type GpuCatalog,
|
||||
} from "./gpu-catalog";
|
||||
import { GPU_CATALOG, GPU_CUSTOM_BRAND_ID, findGpuBrand, type GpuCatalog } from "./gpu-catalog";
|
||||
|
||||
/**
|
||||
* Supported rig field input types.
|
||||
@@ -25,11 +20,7 @@ import {
|
||||
* may opt into a free-text "Custom" override; the stored format is
|
||||
* pipe-delimited in the order parts are declared.
|
||||
*/
|
||||
type RigFieldType =
|
||||
| "text"
|
||||
| "dropdown_with_version"
|
||||
| "cascading_dropdown"
|
||||
| "composite_dropdown";
|
||||
type RigFieldType = "text" | "dropdown_with_version" | "cascading_dropdown" | "composite_dropdown";
|
||||
|
||||
interface RigFieldOption {
|
||||
readonly value: string;
|
||||
@@ -344,7 +335,12 @@ const OS_COMPOSITE: CompositeFieldSpec = {
|
||||
|
||||
export const RIG_FIELDS: readonly RigField[] = [
|
||||
{ id: "os", labelKey: "rig.os", type: "composite_dropdown", composite: OS_COMPOSITE },
|
||||
{ id: "cpu", labelKey: "rig.cpu", type: "text", placeholder: "Intel i9-14900K / AMD Ryzen 9 7950X" },
|
||||
{
|
||||
id: "cpu",
|
||||
labelKey: "rig.cpu",
|
||||
type: "text",
|
||||
placeholder: "Intel i9-14900K / AMD Ryzen 9 7950X",
|
||||
},
|
||||
{
|
||||
id: "gpu",
|
||||
labelKey: "rig.gpu",
|
||||
@@ -358,10 +354,20 @@ export const RIG_FIELDS: readonly RigField[] = [
|
||||
composite: RAM_COMPOSITE,
|
||||
},
|
||||
{ id: "storage", labelKey: "rig.storage", type: "text", placeholder: "2TB Samsung 990 PRO NVMe" },
|
||||
{ id: "monitor", labelKey: "rig.monitor", type: "text", placeholder: "LG 27GP950 27\" 4K 144Hz" },
|
||||
{ id: "monitor", labelKey: "rig.monitor", type: "text", placeholder: 'LG 27GP950 27" 4K 144Hz' },
|
||||
{ id: "capture", labelKey: "rig.capture", type: "text", placeholder: "OBS Studio 30.x" },
|
||||
{ id: "motherboard", labelKey: "rig.motherboard", type: "text", placeholder: "ASUS ROG Maximus Z790 Hero" },
|
||||
{ id: "controller", labelKey: "rig.controller", type: "text", placeholder: "DualSense / Xbox Elite Series 2" },
|
||||
{
|
||||
id: "motherboard",
|
||||
labelKey: "rig.motherboard",
|
||||
type: "text",
|
||||
placeholder: "ASUS ROG Maximus Z790 Hero",
|
||||
},
|
||||
{
|
||||
id: "controller",
|
||||
labelKey: "rig.controller",
|
||||
type: "text",
|
||||
placeholder: "DualSense / Xbox Elite Series 2",
|
||||
},
|
||||
{
|
||||
id: "video_editor",
|
||||
labelKey: "rig.video_editor",
|
||||
|
||||
+119
-17
@@ -1,23 +1,125 @@
|
||||
export const SOCIAL_FIELDS = [
|
||||
// Donate
|
||||
{ id: "kofi", label: "Ko-fi", labelKey: "social.kofi", urlPrefix: "https://ko-fi.com/", category: "donate" },
|
||||
{ id: "patreon", label: "Patreon", labelKey: "social.patreon", urlPrefix: "https://patreon.com/", category: "donate" },
|
||||
{ id: "buymeacoffee", label: "Buy Me a Coffee", labelKey: "social.buymeacoffee", urlPrefix: "https://buymeacoffee.com/", category: "donate" },
|
||||
{ id: "paypal", label: "PayPal", labelKey: "social.paypal", urlPrefix: "https://paypal.me/", category: "donate" },
|
||||
{ id: "streamlabs", label: "Streamlabs", labelKey: "social.streamlabs", urlPrefix: "https://streamlabs.com/", category: "donate" },
|
||||
{
|
||||
id: "kofi",
|
||||
label: "Ko-fi",
|
||||
labelKey: "social.kofi",
|
||||
urlPrefix: "https://ko-fi.com/",
|
||||
category: "donate",
|
||||
},
|
||||
{
|
||||
id: "patreon",
|
||||
label: "Patreon",
|
||||
labelKey: "social.patreon",
|
||||
urlPrefix: "https://patreon.com/",
|
||||
category: "donate",
|
||||
},
|
||||
{
|
||||
id: "buymeacoffee",
|
||||
label: "Buy Me a Coffee",
|
||||
labelKey: "social.buymeacoffee",
|
||||
urlPrefix: "https://buymeacoffee.com/",
|
||||
category: "donate",
|
||||
},
|
||||
{
|
||||
id: "paypal",
|
||||
label: "PayPal",
|
||||
labelKey: "social.paypal",
|
||||
urlPrefix: "https://paypal.me/",
|
||||
category: "donate",
|
||||
},
|
||||
{
|
||||
id: "streamlabs",
|
||||
label: "Streamlabs",
|
||||
labelKey: "social.streamlabs",
|
||||
urlPrefix: "https://streamlabs.com/",
|
||||
category: "donate",
|
||||
},
|
||||
// Social
|
||||
{ id: "github", label: "GitHub", labelKey: "social.github", urlPrefix: "https://github.com/", category: "social" },
|
||||
{ id: "twitter", label: "Twitter / X", labelKey: "social.twitter", urlPrefix: "https://x.com/", category: "social" },
|
||||
{ id: "discord", label: "Discord", labelKey: "social.discord", urlPrefix: "https://discord.gg/", category: "social" },
|
||||
{ id: "twitch", label: "Twitch", labelKey: "social.twitch", urlPrefix: "https://twitch.tv/", category: "social" },
|
||||
{ id: "tiktok", label: "TikTok", labelKey: "social.tiktok", urlPrefix: "https://tiktok.com/@", category: "social" },
|
||||
{ id: "instagram", label: "Instagram", labelKey: "social.instagram", urlPrefix: "https://instagram.com/", category: "social" },
|
||||
{ id: "bluesky", label: "Bluesky", labelKey: "social.bluesky", urlPrefix: "https://bsky.app/profile/", category: "social" },
|
||||
{ id: "mastodon", label: "Mastodon", labelKey: "social.mastodon", urlPrefix: "", category: "social" },
|
||||
{ id: "facebook", label: "Facebook", labelKey: "social.facebook", urlPrefix: "https://facebook.com/", category: "social" },
|
||||
{ id: "fb_page", label: "Facebook Page", labelKey: "social.fb_page", urlPrefix: "https://facebook.com/", category: "social" },
|
||||
{
|
||||
id: "github",
|
||||
label: "GitHub",
|
||||
labelKey: "social.github",
|
||||
urlPrefix: "https://github.com/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "twitter",
|
||||
label: "Twitter / X",
|
||||
labelKey: "social.twitter",
|
||||
urlPrefix: "https://x.com/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "discord",
|
||||
label: "Discord",
|
||||
labelKey: "social.discord",
|
||||
urlPrefix: "https://discord.gg/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "twitch",
|
||||
label: "Twitch",
|
||||
labelKey: "social.twitch",
|
||||
urlPrefix: "https://twitch.tv/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "tiktok",
|
||||
label: "TikTok",
|
||||
labelKey: "social.tiktok",
|
||||
urlPrefix: "https://tiktok.com/@",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "instagram",
|
||||
label: "Instagram",
|
||||
labelKey: "social.instagram",
|
||||
urlPrefix: "https://instagram.com/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "bluesky",
|
||||
label: "Bluesky",
|
||||
labelKey: "social.bluesky",
|
||||
urlPrefix: "https://bsky.app/profile/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "mastodon",
|
||||
label: "Mastodon",
|
||||
labelKey: "social.mastodon",
|
||||
urlPrefix: "",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "facebook",
|
||||
label: "Facebook",
|
||||
labelKey: "social.facebook",
|
||||
urlPrefix: "https://facebook.com/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "fb_page",
|
||||
label: "Facebook Page",
|
||||
labelKey: "social.fb_page",
|
||||
urlPrefix: "https://facebook.com/",
|
||||
category: "social",
|
||||
},
|
||||
// Facebook Group moved to the Community section in v0.33.0 — it's now a
|
||||
// dedicated `facebookGroupLink` editor field (see CommunityEditor).
|
||||
{ id: "telegram", label: "Telegram", labelKey: "social.telegram", urlPrefix: "https://t.me/", category: "social" },
|
||||
{ id: "website", label: "Website", labelKey: "social.website", urlPrefix: "", category: "social" },
|
||||
{
|
||||
id: "telegram",
|
||||
label: "Telegram",
|
||||
labelKey: "social.telegram",
|
||||
urlPrefix: "https://t.me/",
|
||||
category: "social",
|
||||
},
|
||||
{
|
||||
id: "website",
|
||||
label: "Website",
|
||||
labelKey: "social.website",
|
||||
urlPrefix: "",
|
||||
category: "social",
|
||||
},
|
||||
] as const;
|
||||
@@ -34,21 +34,12 @@ export const TECH_NOTE_GROUPS: readonly TechNoteGroup[] = [
|
||||
{
|
||||
id: "video_quality",
|
||||
labelKey: "editor.techNoteGroups.video_quality",
|
||||
items: [
|
||||
"low_resolution_hardware",
|
||||
"low_graphics_performance",
|
||||
"fps_drops_hardware",
|
||||
],
|
||||
items: ["low_resolution_hardware", "low_graphics_performance", "fps_drops_hardware"],
|
||||
},
|
||||
{
|
||||
id: "recording_issues",
|
||||
labelKey: "editor.techNoteGroups.recording_issues",
|
||||
items: [
|
||||
"bug_from_game",
|
||||
"crash_kept_transparency",
|
||||
"loading_cut",
|
||||
"obs_artifacts_possible",
|
||||
],
|
||||
items: ["bug_from_game", "crash_kept_transparency", "loading_cut", "obs_artifacts_possible"],
|
||||
},
|
||||
{
|
||||
id: "playstyle",
|
||||
|
||||
@@ -32,9 +32,9 @@ export const VIDEO_STYLE_ERAS = [
|
||||
export type VideoStyleEra = (typeof VIDEO_STYLE_ERAS)[number];
|
||||
|
||||
/** Subset minus the empty sentinel — used by the form to render options. */
|
||||
export const VIDEO_STYLE_ERA_IDS = VIDEO_STYLE_ERAS.filter(
|
||||
(id) => id !== "",
|
||||
) as ReadonlyArray<Exclude<VideoStyleEra, "">>;
|
||||
export const VIDEO_STYLE_ERA_IDS = VIDEO_STYLE_ERAS.filter((id) => id !== "") as ReadonlyArray<
|
||||
Exclude<VideoStyleEra, "">
|
||||
>;
|
||||
|
||||
/**
|
||||
* Type guard so the engine + migration can coerce unrecognised values
|
||||
@@ -42,8 +42,5 @@ export const VIDEO_STYLE_ERA_IDS = VIDEO_STYLE_ERAS.filter(
|
||||
* eras) back to the empty sentinel without crashing.
|
||||
*/
|
||||
export function isVideoStyleEra(value: unknown): value is VideoStyleEra {
|
||||
return (
|
||||
typeof value === "string" &&
|
||||
(VIDEO_STYLE_ERAS as readonly string[]).includes(value)
|
||||
);
|
||||
return typeof value === "string" && (VIDEO_STYLE_ERAS as readonly string[]).includes(value);
|
||||
}
|
||||
@@ -40,12 +40,7 @@ const TRANSLATION_TRUSTED: readonly string[] = ["vi", "en"];
|
||||
|
||||
/** Caveat bullet ids for the Translation Quality section, resolved against
|
||||
* `description.translationQuality.items.<id>` (v0.24.0). */
|
||||
const TRANSLATION_QUALITY_ITEMS = [
|
||||
"accuracy",
|
||||
"phrasing",
|
||||
"localStyle",
|
||||
"corrections",
|
||||
] as const;
|
||||
const TRANSLATION_QUALITY_ITEMS = ["accuracy", "phrasing", "localStyle", "corrections"] as const;
|
||||
|
||||
function hasEntries(obj: Partial<Record<string, string>>): boolean {
|
||||
return Object.values(obj).some((v) => v && v.trim() !== "");
|
||||
@@ -87,14 +82,12 @@ function formatScheduledTime(iso: string, language: string): string {
|
||||
* is similarly fixed: "Frame Generation" (NVIDIA), "Fluid Motion Frames"
|
||||
* (AMD's official term), "XeFG" (Intel's announced FG tech).
|
||||
*/
|
||||
const VENDOR_GFX_BRANDS: Record<
|
||||
"nvidia" | "amd" | "intel",
|
||||
{ upscale: string; framegen: string }
|
||||
> = {
|
||||
nvidia: { upscale: "NVIDIA DLSS", framegen: "NVIDIA Frame Generation" },
|
||||
amd: { upscale: "AMD FSR", framegen: "AMD Fluid Motion Frames" },
|
||||
intel: { upscale: "Intel XeSS", framegen: "Intel XeFG" },
|
||||
};
|
||||
const VENDOR_GFX_BRANDS: Record<"nvidia" | "amd" | "intel", { upscale: string; framegen: string }> =
|
||||
{
|
||||
nvidia: { upscale: "NVIDIA DLSS", framegen: "NVIDIA Frame Generation" },
|
||||
amd: { upscale: "AMD FSR", framegen: "AMD Fluid Motion Frames" },
|
||||
intel: { upscale: "Intel XeSS", framegen: "Intel XeFG" },
|
||||
};
|
||||
|
||||
/**
|
||||
* Compose the value half of the "In-game Setting:" line — e.g.
|
||||
@@ -125,13 +118,9 @@ function composeGraphicsPart(input: GeneratorInput, t: TranslationFn): string {
|
||||
// 2. Modifier (upscale + frame-gen). Vendor gates the whole clause —
|
||||
// upscaling/frame-gen quality without a vendor is meaningless.
|
||||
const vendor =
|
||||
input.frameGenVendor && input.frameGenVendor !== "none"
|
||||
? input.frameGenVendor
|
||||
: null;
|
||||
input.frameGenVendor && input.frameGenVendor !== "none" ? input.frameGenVendor : null;
|
||||
const upscaleQ =
|
||||
input.upscaleQuality && input.upscaleQuality !== "none"
|
||||
? input.upscaleQuality
|
||||
: null;
|
||||
input.upscaleQuality && input.upscaleQuality !== "none" ? input.upscaleQuality : null;
|
||||
const fgMul =
|
||||
input.frameGenMultiplier && input.frameGenMultiplier !== "none"
|
||||
? input.frameGenMultiplier
|
||||
@@ -219,10 +208,7 @@ function composeVideoStyleLine(input: GeneratorInput, t: TranslationFn): string
|
||||
const eraLabel = t(eraKey);
|
||||
if (!eraLabel || eraLabel === eraKey) return "";
|
||||
|
||||
const editor = formatRigValue(
|
||||
"video_editor",
|
||||
input.rig?.video_editor ?? "",
|
||||
).trim();
|
||||
const editor = formatRigValue("video_editor", input.rig?.video_editor ?? "").trim();
|
||||
|
||||
if (editor) {
|
||||
return t("description.videoSettings.styleLine", { era: eraLabel, editor });
|
||||
@@ -295,8 +281,7 @@ export function buildDescription(
|
||||
// The translation-quality disclaimer keeps the raw `tEn` and stays bilingual.
|
||||
const contentBlockTEn = bilingualContentBlocks ? tEn : undefined;
|
||||
const sections: string[] = [];
|
||||
const gameName =
|
||||
input.gameNameLocalized?.[input.language] ?? input.gameName;
|
||||
const gameName = input.gameNameLocalized?.[input.language] ?? input.gameName;
|
||||
|
||||
// 1. Intro. Gacha videos dispatch on `gachaQuestType` so each of the
|
||||
// 17 patterns can frame the description with its own opening line
|
||||
@@ -323,8 +308,7 @@ export function buildDescription(
|
||||
questName: input.questName ?? "",
|
||||
characterName: input.characterName ?? "",
|
||||
anniversaryYear: input.anniversaryYear != null ? String(input.anniversaryYear) : "",
|
||||
ordinalSuffix:
|
||||
input.anniversaryYear != null ? ordinalSuffix(input.anniversaryYear) : "",
|
||||
ordinalSuffix: input.anniversaryYear != null ? ordinalSuffix(input.anniversaryYear) : "",
|
||||
gachaVersion: input.gachaVersion ?? "",
|
||||
versionLabel,
|
||||
});
|
||||
@@ -372,8 +356,9 @@ export function buildDescription(
|
||||
// 4. Store Links (heading + per-link suffix by pricing category)
|
||||
if (hasEntries(input.storeLinks)) {
|
||||
const entries = Object.entries(input.storeLinks)
|
||||
.filter((entry): entry is [string, string] =>
|
||||
typeof entry[1] === "string" && entry[1].trim() !== "",
|
||||
.filter(
|
||||
(entry): entry is [string, string] =>
|
||||
typeof entry[1] === "string" && entry[1].trim() !== "",
|
||||
)
|
||||
.map(([id, url]) => ({
|
||||
id,
|
||||
@@ -429,16 +414,11 @@ export function buildDescription(
|
||||
// produce a broken line.
|
||||
if (input.playtestLink && input.playtestLink.trim()) {
|
||||
const link = input.playtestLink.trim();
|
||||
const platformLabel = getLabelForId(
|
||||
input.playtestPlatform ?? "",
|
||||
PLAYTEST_PLATFORMS,
|
||||
);
|
||||
const platformLabel = getLabelForId(input.playtestPlatform ?? "", PLAYTEST_PLATFORMS);
|
||||
const lines = [`🧪 ${platformLabel}: ${link}`];
|
||||
const invites = input.playtestInvites ?? 0;
|
||||
if (Number.isInteger(invites) && invites > 0) {
|
||||
lines.push(
|
||||
t("description.sections.playtestInvites", { count: String(invites) }),
|
||||
);
|
||||
lines.push(t("description.sections.playtestInvites", { count: String(invites) }));
|
||||
}
|
||||
sections.push(`${t("description.sections.playtest")}\n${lines.join("\n")}`);
|
||||
}
|
||||
@@ -527,14 +507,8 @@ export function buildDescription(
|
||||
// Vortex, Mod Organizer…). The single-line `modName` field stays in the
|
||||
// title / intro for short identification; this block lists the full
|
||||
// load order for the description.
|
||||
if (
|
||||
input.videoType === "mods" &&
|
||||
input.modList &&
|
||||
input.modList.trim()
|
||||
) {
|
||||
sections.push(
|
||||
`${t("description.sections.modList")}\n${input.modList.trim()}`,
|
||||
);
|
||||
if (input.videoType === "mods" && input.modList && input.modList.trim()) {
|
||||
sections.push(`${t("description.sections.modList")}\n${input.modList.trim()}`);
|
||||
}
|
||||
|
||||
// 7. Content warnings — unified bilingual checklist (v0.11). Header +
|
||||
@@ -606,22 +580,14 @@ export function buildDescription(
|
||||
// verbatim. Gated on settings toggle AND profile field non-empty;
|
||||
// partial state is a no-op so flipping the toggle without filling
|
||||
// the profile doesn't sneak an empty section into the description.
|
||||
if (
|
||||
showThirdPartyAds &&
|
||||
input.thirdPartyAdText &&
|
||||
input.thirdPartyAdText.trim()
|
||||
) {
|
||||
sections.push(
|
||||
`${t("description.sections.thirdPartyAds")}\n${input.thirdPartyAdText.trim()}`,
|
||||
);
|
||||
if (showThirdPartyAds && input.thirdPartyAdText && input.thirdPartyAdText.trim()) {
|
||||
sections.push(`${t("description.sections.thirdPartyAds")}\n${input.thirdPartyAdText.trim()}`);
|
||||
}
|
||||
|
||||
// 8.5. Music / sound attribution — sits right before the donate
|
||||
// block because both are "credits"-adjacent sections.
|
||||
if (input.musicAttribution && input.musicAttribution.trim()) {
|
||||
sections.push(
|
||||
`${t("description.sections.music")}\n${input.musicAttribution.trim()}`,
|
||||
);
|
||||
sections.push(`${t("description.sections.music")}\n${input.musicAttribution.trim()}`);
|
||||
}
|
||||
|
||||
// 9. Donate Links (use proper labels + icons)
|
||||
@@ -691,9 +657,7 @@ export function buildDescription(
|
||||
const zalo = input.zaloGroupLink?.trim() ?? "";
|
||||
if (zalo && input.language === "vi") communityLines.push(`💙 Zalo: ${zalo}`);
|
||||
if (communityLines.length > 0) {
|
||||
sections.push(
|
||||
`${t("description.sections.community")}\n${communityLines.join("\n")}`,
|
||||
);
|
||||
sections.push(`${t("description.sections.community")}\n${communityLines.join("\n")}`);
|
||||
}
|
||||
|
||||
// 11. Playlist
|
||||
@@ -719,9 +683,7 @@ export function buildDescription(
|
||||
emailLines.push(t("description.sections.emailGameKeys", { email: input.gameKeyEmail }));
|
||||
}
|
||||
if (emailLines.length > 0) {
|
||||
sections.push(
|
||||
`${t("description.sections.contactHeader")}\n${emailLines.join("\n")}`,
|
||||
);
|
||||
sections.push(`${t("description.sections.contactHeader")}\n${emailLines.join("\n")}`);
|
||||
}
|
||||
} else if (input.contactEmail && input.contactEmail.trim()) {
|
||||
sections.push(t("description.sections.contact", { email: input.contactEmail }));
|
||||
@@ -793,19 +755,13 @@ function buildPlaythroughNotesSection(
|
||||
* in bilingual mode and `Label: Value` otherwise. Returns null when the
|
||||
* value is empty (caller filters these out).
|
||||
*/
|
||||
function bullet(
|
||||
labelKey: string,
|
||||
valueEn: string,
|
||||
valueLocal: string,
|
||||
): string | null {
|
||||
function bullet(labelKey: string, valueEn: string, valueLocal: string): string | null {
|
||||
const trimmedEn = valueEn.trim();
|
||||
const trimmedLocal = valueLocal.trim();
|
||||
if (!trimmedEn && !trimmedLocal) return null;
|
||||
const labelEn = tEnUse(labelKey);
|
||||
const labelLocal = t(labelKey);
|
||||
const labelLine = renderBilingual
|
||||
? `${labelEn} · ${labelLocal}`
|
||||
: labelEn;
|
||||
const labelLine = renderBilingual ? `${labelEn} · ${labelLocal}` : labelEn;
|
||||
const valueLine = renderBilingual
|
||||
? `${trimmedEn || trimmedLocal} · ${trimmedLocal || trimmedEn}`
|
||||
: trimmedEn || trimmedLocal;
|
||||
@@ -867,11 +823,7 @@ function buildPlaythroughNotesSection(
|
||||
valueEn = en === key ? input.difficulty : en;
|
||||
valueLocal = local === key ? input.difficulty : local;
|
||||
}
|
||||
const b = bullet(
|
||||
"description.playthroughNotes.labels.difficulty",
|
||||
valueEn,
|
||||
valueLocal,
|
||||
);
|
||||
const b = bullet("description.playthroughNotes.labels.difficulty", valueEn, valueLocal);
|
||||
if (b) bullets.push(b);
|
||||
}
|
||||
|
||||
@@ -892,26 +844,16 @@ function buildPlaythroughNotesSection(
|
||||
const structured = Array.isArray(input.endings) ? input.endings : [];
|
||||
const sliced = sliceEndingsForVideo(structured, input);
|
||||
if (sliced.length > 0) {
|
||||
const formatted = sliced
|
||||
.map(formatEndingEntry)
|
||||
.filter((s): s is string => !!s);
|
||||
const formatted = sliced.map(formatEndingEntry).filter((s): s is string => !!s);
|
||||
if (formatted.length > 0) {
|
||||
const joined = formatted.join(", ");
|
||||
const b = bullet(
|
||||
"description.playthroughNotes.labels.endings",
|
||||
joined,
|
||||
joined,
|
||||
);
|
||||
const b = bullet("description.playthroughNotes.labels.endings", joined, joined);
|
||||
if (b) bullets.push(b);
|
||||
}
|
||||
} else {
|
||||
const legacy = (input.endingsShown ?? "").trim();
|
||||
if (legacy) {
|
||||
const b = bullet(
|
||||
"description.playthroughNotes.labels.endings",
|
||||
legacy,
|
||||
legacy,
|
||||
);
|
||||
const b = bullet("description.playthroughNotes.labels.endings", legacy, legacy);
|
||||
if (b) bullets.push(b);
|
||||
}
|
||||
}
|
||||
@@ -931,11 +873,7 @@ function buildPlaythroughNotesSection(
|
||||
valueEn = resolved.en;
|
||||
valueLocal = resolved.local;
|
||||
}
|
||||
const b = bullet(
|
||||
"description.playthroughNotes.labels.languagePatch",
|
||||
valueEn,
|
||||
valueLocal,
|
||||
);
|
||||
const b = bullet("description.playthroughNotes.labels.languagePatch", valueEn, valueLocal);
|
||||
if (b) bullets.push(b);
|
||||
}
|
||||
|
||||
@@ -949,19 +887,11 @@ function buildPlaythroughNotesSection(
|
||||
valueEn = custom;
|
||||
valueLocal = custom;
|
||||
} else {
|
||||
const resolved = resolveEnum(
|
||||
"gameVersionOptions",
|
||||
input.gameVersion,
|
||||
"full_release",
|
||||
);
|
||||
const resolved = resolveEnum("gameVersionOptions", input.gameVersion, "full_release");
|
||||
valueEn = resolved.en;
|
||||
valueLocal = resolved.local;
|
||||
}
|
||||
const b = bullet(
|
||||
"description.playthroughNotes.labels.gameVersion",
|
||||
valueEn,
|
||||
valueLocal,
|
||||
);
|
||||
const b = bullet("description.playthroughNotes.labels.gameVersion", valueEn, valueLocal);
|
||||
if (b) bullets.push(b);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,8 @@ import type { EndingEntry, EndingVideoRange, GeneratorInput } from "./types";
|
||||
* Pure — exported for unit tests + direct use from React components.
|
||||
*/
|
||||
export function formatEndingEntry(entry: EndingEntry): string | null {
|
||||
const num = typeof entry.number === "number" && Number.isFinite(entry.number)
|
||||
? entry.number
|
||||
: null;
|
||||
const num =
|
||||
typeof entry.number === "number" && Number.isFinite(entry.number) ? entry.number : null;
|
||||
const name = (entry.name ?? "").trim();
|
||||
if (num !== null && name) return `Ending ${num}: ${name}`;
|
||||
if (num !== null) return `Ending ${num}`;
|
||||
@@ -66,10 +65,7 @@ export function sliceEndingsForVideo(
|
||||
* a creator who shrank `endings[]` without re-deriving ranges still
|
||||
* gets a sane slice instead of an empty / over-shot one. Pure.
|
||||
*/
|
||||
export function clampRange(
|
||||
range: EndingVideoRange,
|
||||
length: number,
|
||||
): EndingVideoRange {
|
||||
export function clampRange(range: EndingVideoRange, length: number): EndingVideoRange {
|
||||
const from = Math.max(1, Math.min(range.from, length));
|
||||
const to = Math.max(from, Math.min(range.to, length));
|
||||
return { from, to };
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import type {
|
||||
FrameGenVendor,
|
||||
FrameGenMultiplier,
|
||||
UpscaleQuality,
|
||||
} from "@config/graphics-settings";
|
||||
import type { FrameGenVendor, FrameGenMultiplier, UpscaleQuality } from "@config/graphics-settings";
|
||||
|
||||
/**
|
||||
* Vendor-aware filtering for upscaling-quality and frame-generation
|
||||
@@ -21,19 +17,10 @@ import type {
|
||||
* and by description-builder / editor-store / template-store to coerce
|
||||
* invalid vendor×quality combos back to `"none"` on rehydrate.
|
||||
*/
|
||||
export function getValidUpscaleQualities(
|
||||
vendor: FrameGenVendor,
|
||||
): readonly UpscaleQuality[] {
|
||||
export function getValidUpscaleQualities(vendor: FrameGenVendor): readonly UpscaleQuality[] {
|
||||
switch (vendor) {
|
||||
case "nvidia":
|
||||
return [
|
||||
"none",
|
||||
"dlaa",
|
||||
"quality",
|
||||
"balanced",
|
||||
"performance",
|
||||
"ultra_performance",
|
||||
] as const;
|
||||
return ["none", "dlaa", "quality", "balanced", "performance", "ultra_performance"] as const;
|
||||
case "amd":
|
||||
return [
|
||||
"none",
|
||||
@@ -65,9 +52,7 @@ export function getValidUpscaleQualities(
|
||||
}
|
||||
}
|
||||
|
||||
export function getValidFrameGenMultipliers(
|
||||
vendor: FrameGenVendor,
|
||||
): readonly FrameGenMultiplier[] {
|
||||
export function getValidFrameGenMultipliers(vendor: FrameGenVendor): readonly FrameGenMultiplier[] {
|
||||
switch (vendor) {
|
||||
case "nvidia":
|
||||
return ["none", "x2", "x3", "x4"] as const;
|
||||
|
||||
@@ -75,10 +75,7 @@ function dedupeHashtags(tags: readonly string[]): string[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
function buildHashtagLine(
|
||||
input: GeneratorInput,
|
||||
popular: readonly string[],
|
||||
): string {
|
||||
function buildHashtagLine(input: GeneratorInput, popular: readonly string[]): string {
|
||||
const gameName = input.gameNameLocalized?.[input.language] ?? input.gameName;
|
||||
const primaryGenre = input.genres[0];
|
||||
const derived = [
|
||||
@@ -94,8 +91,7 @@ export function buildSocialPost(
|
||||
t: TranslationFn,
|
||||
options: SocialPostOptions,
|
||||
): SocialPostOutput {
|
||||
const { charLimit, popularHashtags, showCopyright, showSponsorCredit, tEn } =
|
||||
options;
|
||||
const { charLimit, popularHashtags, showCopyright, showSponsorCredit, tEn } = options;
|
||||
|
||||
// Title — short-form, so the `[2K 60FPS]` badge is suppressed.
|
||||
const title = buildTitle(input, t, { showQualityBadge: false });
|
||||
@@ -111,9 +107,7 @@ export function buildSocialPost(
|
||||
tEn,
|
||||
) ?? "",
|
||||
thanks:
|
||||
showSponsorCredit &&
|
||||
input.sponsorName?.trim() &&
|
||||
input.sponsorPlatform?.trim()
|
||||
showSponsorCredit && input.sponsorName?.trim() && input.sponsorPlatform?.trim()
|
||||
? t("description.sections.sponsorCredit", {
|
||||
sponsor: input.sponsorName.trim(),
|
||||
platform: input.sponsorPlatform.trim(),
|
||||
@@ -132,9 +126,7 @@ export function buildSocialPost(
|
||||
|
||||
// Track which optional blocks are still present; drop in priority order
|
||||
// until the caption fits. Title + hashtags are always kept.
|
||||
const present = new Set<BlockId>(
|
||||
DISPLAY_ORDER.filter((id) => blocks[id].trim() !== ""),
|
||||
);
|
||||
const present = new Set<BlockId>(DISPLAY_ORDER.filter((id) => blocks[id].trim() !== ""));
|
||||
|
||||
const assemble = (): string => {
|
||||
const parts: string[] = [title];
|
||||
|
||||
+112
-44
@@ -23,11 +23,7 @@ const QUALIFIER_SUFFIX_RE =
|
||||
* Pure — exported for testing.
|
||||
*/
|
||||
export function sanitizeForTag(name: string): string {
|
||||
return name
|
||||
.replace(/[™®©]/g, "")
|
||||
.replace(/[,;|]/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
return name.replace(/[™®©]/g, "").replace(/[,;|]/g, " ").replace(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,13 +75,45 @@ export function tagFriendlyGameName(name: string, budget: number): string {
|
||||
* MULTILINGUAL_TAGS.
|
||||
*/
|
||||
const GENRE_TAG_REGISTRY: Record<string, (gameName: string) => string[]> = {
|
||||
action: (g) => [`${g} action`, "action game no commentary", "action adventure gameplay", `${g} combat`],
|
||||
horror: (g) => [`${g} horror`, "horror game no commentary", "survival horror gameplay", `${g} scary`],
|
||||
rpg: (g) => [`${g} RPG`, "RPG no commentary", "RPG gameplay", "JRPG no commentary", `${g} role playing`],
|
||||
action: (g) => [
|
||||
`${g} action`,
|
||||
"action game no commentary",
|
||||
"action adventure gameplay",
|
||||
`${g} combat`,
|
||||
],
|
||||
horror: (g) => [
|
||||
`${g} horror`,
|
||||
"horror game no commentary",
|
||||
"survival horror gameplay",
|
||||
`${g} scary`,
|
||||
],
|
||||
rpg: (g) => [
|
||||
`${g} RPG`,
|
||||
"RPG no commentary",
|
||||
"RPG gameplay",
|
||||
"JRPG no commentary",
|
||||
`${g} role playing`,
|
||||
],
|
||||
fps: (g) => [`${g} FPS`, "FPS no commentary", "shooter gameplay no commentary", `${g} shooter`],
|
||||
openworld: (g) => [`${g} open world`, "open world no commentary", "free roam gameplay", `${g} exploration`],
|
||||
indie: (g) => [`${g} indie`, `${g} indie game`, "indie game no commentary", "indie gameplay", "best indie games"],
|
||||
soulslike: (g) => [`${g} souls like`, "soulsborne no commentary", "souls like gameplay", `${g} hardcore`],
|
||||
openworld: (g) => [
|
||||
`${g} open world`,
|
||||
"open world no commentary",
|
||||
"free roam gameplay",
|
||||
`${g} exploration`,
|
||||
],
|
||||
indie: (g) => [
|
||||
`${g} indie`,
|
||||
`${g} indie game`,
|
||||
"indie game no commentary",
|
||||
"indie gameplay",
|
||||
"best indie games",
|
||||
],
|
||||
soulslike: (g) => [
|
||||
`${g} souls like`,
|
||||
"soulsborne no commentary",
|
||||
"souls like gameplay",
|
||||
`${g} hardcore`,
|
||||
],
|
||||
racing: (g) => [`${g} racing`, "racing game no commentary", "racing gameplay", `${g} cars`],
|
||||
story: (g) => [
|
||||
`${g} story`,
|
||||
@@ -94,9 +122,19 @@ const GENRE_TAG_REGISTRY: Record<string, (gameName: string) => string[]> = {
|
||||
"narrative gameplay",
|
||||
"cinematic adventure no commentary",
|
||||
],
|
||||
simulation: (g) => [`${g} simulation`, "simulation game no commentary", "strategy gameplay", `${g} sim`],
|
||||
simulation: (g) => [
|
||||
`${g} simulation`,
|
||||
"simulation game no commentary",
|
||||
"strategy gameplay",
|
||||
`${g} sim`,
|
||||
],
|
||||
fighting: (g) => [`${g} fighting`, "fighting game no commentary", "combo gameplay", `${g} fight`],
|
||||
stealth: (g) => [`${g} stealth`, "stealth game no commentary", "stealth gameplay", `${g} ghost run`],
|
||||
stealth: (g) => [
|
||||
`${g} stealth`,
|
||||
"stealth game no commentary",
|
||||
"stealth gameplay",
|
||||
`${g} ghost run`,
|
||||
],
|
||||
survival_craft: (g) => [
|
||||
`${g} survival`,
|
||||
"survival crafting no commentary",
|
||||
@@ -112,15 +150,45 @@ const GENRE_TAG_REGISTRY: Record<string, (gameName: string) => string[]> = {
|
||||
],
|
||||
mmo: (g) => [`${g} MMO`, "MMO no commentary", "MMORPG gameplay", `${g} online`],
|
||||
rhythm: (g) => [`${g} rhythm`, "rhythm game no commentary", "music game gameplay", `${g} music`],
|
||||
puzzle: (g) => [`${g} puzzle`, "puzzle game no commentary", "brain teaser gameplay", `${g} logic`],
|
||||
tower_defense: (g) => [`${g} tower defense`, "tower defense no commentary", "TD gameplay", `${g} strategy`],
|
||||
card_game: (g) => [`${g} card game`, "deck builder no commentary", "card game gameplay", `${g} TCG`],
|
||||
battle_royale: (g) => [`${g} battle royale`, "battle royale no commentary", "BR gameplay", `${g} solo`],
|
||||
puzzle: (g) => [
|
||||
`${g} puzzle`,
|
||||
"puzzle game no commentary",
|
||||
"brain teaser gameplay",
|
||||
`${g} logic`,
|
||||
],
|
||||
tower_defense: (g) => [
|
||||
`${g} tower defense`,
|
||||
"tower defense no commentary",
|
||||
"TD gameplay",
|
||||
`${g} strategy`,
|
||||
],
|
||||
card_game: (g) => [
|
||||
`${g} card game`,
|
||||
"deck builder no commentary",
|
||||
"card game gameplay",
|
||||
`${g} TCG`,
|
||||
],
|
||||
battle_royale: (g) => [
|
||||
`${g} battle royale`,
|
||||
"battle royale no commentary",
|
||||
"BR gameplay",
|
||||
`${g} solo`,
|
||||
],
|
||||
crpg: (g) => [`${g} CRPG`, "CRPG no commentary", "isometric RPG gameplay", `${g} party`],
|
||||
tactical: (g) => [`${g} tactical`, "tactical game no commentary", "turn based strategy", `${g} tactics`],
|
||||
tactical: (g) => [
|
||||
`${g} tactical`,
|
||||
"tactical game no commentary",
|
||||
"turn based strategy",
|
||||
`${g} tactics`,
|
||||
],
|
||||
space: (g) => [`${g} space`, "space game no commentary", "sci-fi gameplay", `${g} sci fi`],
|
||||
farming: (g) => [`${g} farming`, "farming sim no commentary", "cozy game gameplay", `${g} cozy`],
|
||||
fmv: (g) => [`${g} FMV`, "FMV game no commentary", "interactive movie gameplay", `${g} live action`],
|
||||
fmv: (g) => [
|
||||
`${g} FMV`,
|
||||
"FMV game no commentary",
|
||||
"interactive movie gameplay",
|
||||
`${g} live action`,
|
||||
],
|
||||
visual_novel: (g) => [
|
||||
`${g} visual novel`,
|
||||
`${g} VN no commentary`,
|
||||
@@ -158,12 +226,7 @@ const GENRE_TAG_REGISTRY: Record<string, (gameName: string) => string[]> = {
|
||||
`${g} atmospheric horror`,
|
||||
"mind bending horror gameplay",
|
||||
],
|
||||
jrpg: (g) => [
|
||||
`${g} JRPG`,
|
||||
"JRPG no commentary",
|
||||
`${g} japanese RPG`,
|
||||
"turn based JRPG gameplay",
|
||||
],
|
||||
jrpg: (g) => [`${g} JRPG`, "JRPG no commentary", `${g} japanese RPG`, "turn based JRPG gameplay"],
|
||||
action_rpg: (g) => [
|
||||
`${g} action RPG`,
|
||||
"action RPG no commentary",
|
||||
@@ -194,12 +257,7 @@ const GENRE_TAG_REGISTRY: Record<string, (gameName: string) => string[]> = {
|
||||
`${g} loot and extract`,
|
||||
"extraction FPS gameplay",
|
||||
],
|
||||
shmup: (g) => [
|
||||
`${g} shmup`,
|
||||
`${g} bullet hell`,
|
||||
"shoot em up no commentary",
|
||||
"danmaku gameplay",
|
||||
],
|
||||
shmup: (g) => [`${g} shmup`, `${g} bullet hell`, "shoot em up no commentary", "danmaku gameplay"],
|
||||
city_builder: (g) => [
|
||||
`${g} city builder`,
|
||||
"city builder no commentary",
|
||||
@@ -259,13 +317,7 @@ const VIDEO_TYPE_TAGS: Record<string, (gameName: string) => string[]> = {
|
||||
`${g} completionist no commentary`,
|
||||
`${g} achievement guide`,
|
||||
],
|
||||
livestream: (g) => [
|
||||
"livestream",
|
||||
"live gameplay",
|
||||
`${g} live`,
|
||||
`${g} stream`,
|
||||
`${g} livestream`,
|
||||
],
|
||||
livestream: (g) => ["livestream", "live gameplay", `${g} live`, `${g} stream`, `${g} livestream`],
|
||||
// One pool for the whole gacha bucket — quest-type-specific tags
|
||||
// would balloon the pool and rarely surface in YouTube search anyway.
|
||||
// The intro / title / hashtags already carry the per-quest framing.
|
||||
@@ -317,8 +369,22 @@ const CORE_TAGS_BY_LANG: Record<SupportedLanguage, (gameName: string) => string[
|
||||
`${g} guía`,
|
||||
`${g} español`,
|
||||
],
|
||||
ko: (g) => [`${g} 게임플레이`, `${g} 무편집`, "게임플레이 무편집", `${g} 공략`, `${g} 플레이`, `${g} 한국어`],
|
||||
zh: (g) => [`${g} 游戏实况`, `${g} 无解说`, "游戏实况 无解说", `${g} 攻略`, `${g} 流程`, `${g} 通关`],
|
||||
ko: (g) => [
|
||||
`${g} 게임플레이`,
|
||||
`${g} 무편집`,
|
||||
"게임플레이 무편집",
|
||||
`${g} 공략`,
|
||||
`${g} 플레이`,
|
||||
`${g} 한국어`,
|
||||
],
|
||||
zh: (g) => [
|
||||
`${g} 游戏实况`,
|
||||
`${g} 无解说`,
|
||||
"游戏实况 无解说",
|
||||
`${g} 攻略`,
|
||||
`${g} 流程`,
|
||||
`${g} 通关`,
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -362,7 +428,11 @@ function getQualityTags(gameName: string, resolution?: string, fps?: string): st
|
||||
function getTrendingTags(gameName: string, genre: string): string[] {
|
||||
const year = new Date().getFullYear().toString();
|
||||
const genreLabel = humanizeId(genre);
|
||||
return [`${gameName} ${year}`, `best ${genreLabel} games ${year}`, `${genreLabel} gameplay ${year}`];
|
||||
return [
|
||||
`${gameName} ${year}`,
|
||||
`best ${genreLabel} games ${year}`,
|
||||
`${genreLabel} gameplay ${year}`,
|
||||
];
|
||||
}
|
||||
|
||||
export interface TagOptions {
|
||||
@@ -372,9 +442,7 @@ export interface TagOptions {
|
||||
|
||||
export function generateTags(input: GeneratorInput, options?: TagOptions): string[] {
|
||||
const { includeMultilingualTags = true, includeTrendingTags = true } = options ?? {};
|
||||
const rawName = sanitizeForTag(
|
||||
input.gameNameLocalized?.[input.language] ?? input.gameName,
|
||||
);
|
||||
const rawName = sanitizeForTag(input.gameNameLocalized?.[input.language] ?? input.gameName);
|
||||
|
||||
// Two friendly forms of the game name:
|
||||
// • bareNameTag — fits the per-tag 30-char limit; always added so the
|
||||
|
||||
@@ -198,10 +198,7 @@ export function buildGachaPartSuffix(
|
||||
* endings. The Output page passes the index when looping over
|
||||
* `endingVideoCount`; bare generation (no index) sees the union.
|
||||
*/
|
||||
function buildStructuredEndingLabel(
|
||||
input: GeneratorInput,
|
||||
t: TranslationFn,
|
||||
): string | null {
|
||||
function buildStructuredEndingLabel(input: GeneratorInput, t: TranslationFn): string | null {
|
||||
const endings: EndingEntry[] = input.endings ?? [];
|
||||
if (endings.length === 0) return null;
|
||||
|
||||
@@ -209,8 +206,7 @@ function buildStructuredEndingLabel(
|
||||
// Drop entries that have neither number nor a non-empty name — they
|
||||
// produce no visible label and would dilute the comma-join / count.
|
||||
const usable = sliced.filter((e) => {
|
||||
const hasNumber =
|
||||
typeof e.number === "number" && Number.isFinite(e.number);
|
||||
const hasNumber = typeof e.number === "number" && Number.isFinite(e.number);
|
||||
const hasName = (e.name ?? "").trim().length > 0;
|
||||
return hasNumber || hasName;
|
||||
});
|
||||
@@ -235,9 +231,7 @@ function buildStructuredEndingLabel(
|
||||
.filter((n): n is number => typeof n === "number" && Number.isFinite(n));
|
||||
if (numbers.length === usable.length) {
|
||||
const sorted = [...numbers].sort((a, b) => a - b);
|
||||
const isContiguous = sorted.every(
|
||||
(n, i) => i === 0 || n === (sorted[i - 1] as number) + 1,
|
||||
);
|
||||
const isContiguous = sorted.every((n, i) => i === 0 || n === (sorted[i - 1] as number) + 1);
|
||||
if (isContiguous) {
|
||||
const from = sorted[0] as number;
|
||||
const to = sorted[sorted.length - 1] as number;
|
||||
@@ -271,8 +265,7 @@ export function buildTitle(
|
||||
|
||||
const suffix = t("title.suffix");
|
||||
|
||||
const gameName =
|
||||
input.gameNameLocalized?.[input.language] ?? input.gameName;
|
||||
const gameName = input.gameNameLocalized?.[input.language] ?? input.gameName;
|
||||
|
||||
let badge = opts.showQualityBadge ? buildQualityBadge(input.resolution, input.fps) : "";
|
||||
if (badge && opts.badgeCase === "lower") badge = badge.toLowerCase();
|
||||
|
||||
+15
-8
@@ -8,6 +8,20 @@ import type {
|
||||
} from "@config/graphics-settings";
|
||||
import type { GachaQuestType } from "@config/gacha-quest-types";
|
||||
|
||||
// `GeneratorInput` exposes all of these on its own fields, so anyone typing a
|
||||
// value to hand to the engine needs them too. Re-exported here so `@engine/types`
|
||||
// is a complete public surface and callers don't have to reach into `@config/*`
|
||||
// for a type the engine already speaks.
|
||||
export type {
|
||||
GraphicsPreset,
|
||||
RTMode,
|
||||
FrameGenVendor,
|
||||
FrameGenMultiplier,
|
||||
UpscaleQuality,
|
||||
ArtStyle,
|
||||
GachaQuestType,
|
||||
};
|
||||
|
||||
export type VideoType =
|
||||
| "full"
|
||||
| "part"
|
||||
@@ -114,14 +128,7 @@ export type PlaythroughStatus = (typeof PLAYTHROUGH_STATUSES)[number];
|
||||
* difficulty names don't fit (e.g. "Lethal", "Fromsoft default").
|
||||
* `"none"` → skip the section.
|
||||
*/
|
||||
export const DIFFICULTY_LEVELS = [
|
||||
"none",
|
||||
"easy",
|
||||
"normal",
|
||||
"hard",
|
||||
"nightmare",
|
||||
"custom",
|
||||
] as const;
|
||||
export const DIFFICULTY_LEVELS = ["none", "easy", "normal", "hard", "nightmare", "custom"] as const;
|
||||
export type DifficultyLevel = (typeof DIFFICULTY_LEVELS)[number];
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,8 +79,7 @@ export function buildGeneratorInputFromEditor(
|
||||
// means the engine should see the union (the slice helpers
|
||||
// already short-circuit on `videoCount <= 1`, but skipping the
|
||||
// pass-through here keeps the input cleaner for tests).
|
||||
endingVideoIndex:
|
||||
state.endingVideoCount > 1 ? state.endingVideoIndex : undefined,
|
||||
endingVideoIndex: state.endingVideoCount > 1 ? state.endingVideoIndex : undefined,
|
||||
languagePatch: state.languagePatch,
|
||||
languagePatchCustom: state.languagePatchCustom,
|
||||
gameVersion: state.gameVersion,
|
||||
|
||||
@@ -9,10 +9,7 @@ interface ShortcutOptions {
|
||||
onToggleSidebar: () => void;
|
||||
}
|
||||
|
||||
export function useKeyboardShortcuts({
|
||||
onToggleHelp,
|
||||
onToggleSidebar,
|
||||
}: ShortcutOptions) {
|
||||
export function useKeyboardShortcuts({ onToggleHelp, onToggleSidebar }: ShortcutOptions) {
|
||||
const navigate = useNavigate();
|
||||
const output = useGeneratedOutput();
|
||||
const { copy } = useClipboard();
|
||||
@@ -52,14 +49,7 @@ export function useKeyboardShortcuts({
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [
|
||||
navigate,
|
||||
output.title,
|
||||
output.description,
|
||||
copy,
|
||||
onToggleHelp,
|
||||
onToggleSidebar,
|
||||
]);
|
||||
}, [navigate, output.title, output.description, copy, onToggleHelp, onToggleSidebar]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,9 +12,7 @@ import type { SupportedLanguage } from "@engine/types";
|
||||
* deploy): `ensureLanguagesLoaded` logs the failure and the app degrades
|
||||
* to English rather than hanging the UI.
|
||||
*/
|
||||
export function useLanguagesReady(
|
||||
langs: readonly SupportedLanguage[],
|
||||
): boolean {
|
||||
export function useLanguagesReady(langs: readonly SupportedLanguage[]): boolean {
|
||||
const joined = langs.join(",");
|
||||
// Stable identity for the requested set — callers pass fresh array
|
||||
// literals on every render.
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import i18n from "i18next";
|
||||
import { useSettingsStore } from "@store/settings-store";
|
||||
import {
|
||||
buildAllSocialPosts,
|
||||
type SocialPostOutput,
|
||||
} from "@engine/social-post-builder";
|
||||
import { buildAllSocialPosts, type SocialPostOutput } from "@engine/social-post-builder";
|
||||
import { SOCIAL_PLATFORMS } from "@config/social-platforms";
|
||||
import type { SupportedLanguage } from "@engine/types";
|
||||
import { useCurrentGeneratorInput } from "./use-current-generator-input";
|
||||
@@ -27,10 +24,7 @@ export function useSocialPosts(
|
||||
// bundle is in memory — SocialPage renders nothing for an empty record.
|
||||
const ready = useLanguagesReady([input.language]);
|
||||
|
||||
const t = useMemo(
|
||||
() => i18n.getFixedT(input.language, "templates"),
|
||||
[input.language],
|
||||
);
|
||||
const t = useMemo(() => i18n.getFixedT(input.language, "templates"), [input.language]);
|
||||
// Always-English `t` for the bilingual content-warnings block, built
|
||||
// once so the engine receives a stable ref.
|
||||
const tEn = useMemo(() => i18n.getFixedT("en", "templates"), []);
|
||||
|
||||
+2
-6
@@ -24,9 +24,7 @@ i18n
|
||||
// imported above, so Rollup keeps it in the main chunk — and i18next
|
||||
// never asks the backend for it because bundled namespaces are served
|
||||
// from `resources` (see `partialBundledLanguages`).
|
||||
resourcesToBackend(
|
||||
(lng: string, ns: string) => import(`./locales/${lng}/${ns}.json`),
|
||||
),
|
||||
resourcesToBackend((lng: string, ns: string) => import(`./locales/${lng}/${ns}.json`)),
|
||||
)
|
||||
.init({
|
||||
resources: { en: { ui: enUI, templates: enTemplates } },
|
||||
@@ -61,9 +59,7 @@ export function hasLanguageBundles(lang: string): boolean {
|
||||
* Never rejects: a language whose chunk cannot be fetched (offline, stale
|
||||
* deploy HTML) is logged and left to the `fallbackLng` English degrade.
|
||||
*/
|
||||
export async function ensureLanguagesLoaded(
|
||||
langs: readonly SupportedLanguage[],
|
||||
): Promise<void> {
|
||||
export async function ensureLanguagesLoaded(langs: readonly SupportedLanguage[]): Promise<void> {
|
||||
const wanted = [...new Set(langs)].filter((l) => !hasLanguageBundles(l));
|
||||
if (wanted.length === 0) return;
|
||||
await i18n.loadLanguages(wanted);
|
||||
|
||||
+58
-43
@@ -48,20 +48,55 @@ export function AboutPage() {
|
||||
{ id: "youtube", url: ABOUT.socials.youtube, icon: Youtube, labelKey: "about.socials.youtube" },
|
||||
{ id: "x", url: ABOUT.socials.x, icon: Twitter, labelKey: "about.socials.x" },
|
||||
{ id: "bluesky", url: ABOUT.socials.bluesky, icon: Cloud, labelKey: "about.socials.bluesky" },
|
||||
{ id: "mastodon", url: ABOUT.socials.mastodon, icon: MessageSquare, labelKey: "about.socials.mastodon" },
|
||||
{ id: "discord", url: ABOUT.socials.discord, icon: MessageCircle, labelKey: "about.socials.discord" },
|
||||
{ id: "discordGame", url: ABOUT.socials.discordGame, icon: Gamepad2, labelKey: "about.socials.discordGame" },
|
||||
{
|
||||
id: "mastodon",
|
||||
url: ABOUT.socials.mastodon,
|
||||
icon: MessageSquare,
|
||||
labelKey: "about.socials.mastodon",
|
||||
},
|
||||
{
|
||||
id: "discord",
|
||||
url: ABOUT.socials.discord,
|
||||
icon: MessageCircle,
|
||||
labelKey: "about.socials.discord",
|
||||
},
|
||||
{
|
||||
id: "discordGame",
|
||||
url: ABOUT.socials.discordGame,
|
||||
icon: Gamepad2,
|
||||
labelKey: "about.socials.discordGame",
|
||||
},
|
||||
{ id: "steam", url: ABOUT.socials.steam, icon: Gamepad2, labelKey: "about.socials.steam" },
|
||||
{ id: "telegramBot", url: ABOUT.socials.telegramBot, icon: Send, labelKey: "about.socials.telegramBot" },
|
||||
{ id: "telegramUser", url: ABOUT.socials.telegramUser, icon: Send, labelKey: "about.socials.telegramUser" },
|
||||
{
|
||||
id: "telegramBot",
|
||||
url: ABOUT.socials.telegramBot,
|
||||
icon: Send,
|
||||
labelKey: "about.socials.telegramBot",
|
||||
},
|
||||
{
|
||||
id: "telegramUser",
|
||||
url: ABOUT.socials.telegramUser,
|
||||
icon: Send,
|
||||
labelKey: "about.socials.telegramUser",
|
||||
},
|
||||
{ id: "email", url: ABOUT.socials.email, icon: Mail, labelKey: "about.socials.email" },
|
||||
];
|
||||
const socials = allSocials.filter((s) => s.url.trim().length > 0);
|
||||
|
||||
const donateLinks: readonly DonateLinkConfig[] = [
|
||||
{ id: "githubSponsors", url: DONATE.githubSponsors, icon: Sparkles, labelKey: "about.donate.githubSponsors" },
|
||||
{
|
||||
id: "githubSponsors",
|
||||
url: DONATE.githubSponsors,
|
||||
icon: Sparkles,
|
||||
labelKey: "about.donate.githubSponsors",
|
||||
},
|
||||
{ id: "kofi", url: DONATE.kofi, icon: Coffee, labelKey: "about.donate.kofi" },
|
||||
{ id: "buyMeACoffee", url: DONATE.buyMeACoffee, icon: Coffee, labelKey: "about.donate.buyMeACoffee" },
|
||||
{
|
||||
id: "buyMeACoffee",
|
||||
url: DONATE.buyMeACoffee,
|
||||
icon: Coffee,
|
||||
labelKey: "about.donate.buyMeACoffee",
|
||||
},
|
||||
{ id: "patreon", url: DONATE.patreon, icon: Heart, labelKey: "about.donate.patreon" },
|
||||
{ id: "paypal", url: DONATE.paypal, icon: DollarSign, labelKey: "about.donate.paypal" },
|
||||
];
|
||||
@@ -70,9 +105,7 @@ export function AboutPage() {
|
||||
<div className="mx-auto flex max-w-3xl flex-col gap-8 p-6">
|
||||
<header className="flex flex-col gap-2">
|
||||
<div className="flex items-baseline gap-3">
|
||||
<h1 className="text-2xl font-bold text-text-primary">
|
||||
{ABOUT.appName}
|
||||
</h1>
|
||||
<h1 className="text-2xl font-bold text-text-primary">{ABOUT.appName}</h1>
|
||||
<span className="rounded bg-surface-2 px-2 py-0.5 font-mono text-xs text-text-secondary">
|
||||
v{ABOUT.version}
|
||||
</span>
|
||||
@@ -85,26 +118,14 @@ export function AboutPage() {
|
||||
{t("about.repoHeading")}
|
||||
</h2>
|
||||
<div className="grid gap-2 sm:grid-cols-2">
|
||||
<ExternalLinkRow
|
||||
href={ABOUT.repo}
|
||||
icon={Github}
|
||||
label={t("about.repoLabel")}
|
||||
/>
|
||||
<ExternalLinkRow
|
||||
href={ABOUT.bugReportUrl}
|
||||
icon={Bug}
|
||||
label={t("about.reportBugLabel")}
|
||||
/>
|
||||
<ExternalLinkRow href={ABOUT.repo} icon={Github} label={t("about.repoLabel")} />
|
||||
<ExternalLinkRow href={ABOUT.bugReportUrl} icon={Bug} label={t("about.reportBugLabel")} />
|
||||
<ExternalLinkRow
|
||||
href={ABOUT.discussionsUrl}
|
||||
icon={MessageSquare}
|
||||
label={t("about.discussionsLabel")}
|
||||
/>
|
||||
<ExternalLinkRow
|
||||
href={ABOUT.githubAuthor}
|
||||
icon={Github}
|
||||
label={t("about.authorLabel")}
|
||||
/>
|
||||
<ExternalLinkRow href={ABOUT.githubAuthor} icon={Github} label={t("about.authorLabel")} />
|
||||
<ExternalLinkRow
|
||||
href={ABOUT.licenseUrl}
|
||||
icon={ExternalLink}
|
||||
@@ -136,13 +157,7 @@ export function AboutPage() {
|
||||
<p className="text-xs text-text-muted">{t("about.donateHelp")}</p>
|
||||
<div className="grid gap-2 sm:grid-cols-2">
|
||||
{donateLinks.map((d) => (
|
||||
<ExternalLinkRow
|
||||
key={d.id}
|
||||
href={d.url}
|
||||
icon={d.icon}
|
||||
label={t(d.labelKey)}
|
||||
accent
|
||||
/>
|
||||
<ExternalLinkRow key={d.id} href={d.url} icon={d.icon} label={t(d.labelKey)} accent />
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
@@ -154,12 +169,7 @@ export function AboutPage() {
|
||||
</h2>
|
||||
<div className="grid gap-2 sm:grid-cols-2">
|
||||
{socials.map((s) => (
|
||||
<ExternalLinkRow
|
||||
key={s.id}
|
||||
href={s.url}
|
||||
icon={s.icon}
|
||||
label={t(s.labelKey)}
|
||||
/>
|
||||
<ExternalLinkRow key={s.id} href={s.url} icon={s.icon} label={t(s.labelKey)} />
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
@@ -172,7 +182,10 @@ export function AboutPage() {
|
||||
<p className="text-xs text-text-muted">{t("about.thirdPartyHelp")}</p>
|
||||
<ul className="grid gap-1.5 sm:grid-cols-2">
|
||||
{THIRD_PARTY.map((entry) => (
|
||||
<li key={entry.name} className="flex items-center justify-between rounded-lg border border-border bg-surface-1 px-3 py-2">
|
||||
<li
|
||||
key={entry.name}
|
||||
className="flex items-center justify-between rounded-lg border border-border bg-surface-1 px-3 py-2"
|
||||
>
|
||||
<a
|
||||
href={entry.url}
|
||||
target="_blank"
|
||||
@@ -180,9 +193,7 @@ export function AboutPage() {
|
||||
className="flex items-center gap-2 text-sm text-text-primary hover:text-accent"
|
||||
>
|
||||
<span className="font-medium">{entry.name}</span>
|
||||
<span className="font-mono text-xs text-text-muted">
|
||||
{entry.version}
|
||||
</span>
|
||||
<span className="font-mono text-xs text-text-muted">{entry.version}</span>
|
||||
</a>
|
||||
<span className="text-xs text-text-muted">{entry.license}</span>
|
||||
</li>
|
||||
@@ -212,7 +223,11 @@ function ExternalLinkRow({ href, icon: Icon, label, accent }: ExternalLinkRowPro
|
||||
: "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"
|
||||
}
|
||||
>
|
||||
<Icon className={accent ? "h-4 w-4 shrink-0 text-pink-300" : "h-4 w-4 shrink-0 text-text-secondary"} />
|
||||
<Icon
|
||||
className={
|
||||
accent ? "h-4 w-4 shrink-0 text-pink-300" : "h-4 w-4 shrink-0 text-text-secondary"
|
||||
}
|
||||
/>
|
||||
<span className="flex-1 truncate">{label}</span>
|
||||
<ExternalLink className="h-3.5 w-3.5 shrink-0 text-text-muted" />
|
||||
</a>
|
||||
|
||||
@@ -206,7 +206,7 @@ export function BatchPage() {
|
||||
{rangeError && (
|
||||
<p
|
||||
role="alert"
|
||||
className="mb-6 rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning"
|
||||
className="border-warning/40 bg-warning/10 mb-6 rounded-lg border px-3 py-2 text-xs text-warning"
|
||||
>
|
||||
{rangeError}
|
||||
</p>
|
||||
@@ -227,7 +227,10 @@ export function BatchPage() {
|
||||
</div>
|
||||
<div className="flex flex-col gap-4">
|
||||
{results.map((result) => (
|
||||
<div key={result.partNumber} className="rounded-lg border border-border bg-surface-1 p-4">
|
||||
<div
|
||||
key={result.partNumber}
|
||||
className="rounded-lg border border-border bg-surface-1 p-4"
|
||||
>
|
||||
<h3 className="mb-3 text-sm font-semibold text-text-primary">
|
||||
Part {result.partNumber}
|
||||
</h3>
|
||||
@@ -250,7 +253,10 @@ export function BatchPage() {
|
||||
{lang.output.description.slice(0, 200)}...
|
||||
</pre>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<CopyButton text={lang.output.description} label={t("output.copyDescription")} />
|
||||
<CopyButton
|
||||
text={lang.output.description}
|
||||
label={t("output.copyDescription")}
|
||||
/>
|
||||
<CopyButton text={lang.output.tagString} label={t("output.copyTags")} />
|
||||
{lang.pinnedComment && (
|
||||
<CopyButton
|
||||
|
||||
+4
-13
@@ -192,10 +192,7 @@ export function LogPage() {
|
||||
: !collapsedSessions.has(`__expanded__${session.id}`);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={session.id}
|
||||
className="rounded-lg border border-border bg-surface-1"
|
||||
>
|
||||
<div key={session.id} className="rounded-lg border border-border bg-surface-1">
|
||||
<div
|
||||
className="flex cursor-pointer items-center gap-2 px-3 py-2"
|
||||
onClick={() => {
|
||||
@@ -204,9 +201,7 @@ export function LogPage() {
|
||||
// collapsed" semantic from leaking into the set.
|
||||
setCollapsedSessions((prev) => {
|
||||
const next = new Set(prev);
|
||||
const key = session.isCurrent
|
||||
? session.id
|
||||
: `__expanded__${session.id}`;
|
||||
const key = session.isCurrent ? session.id : `__expanded__${session.id}`;
|
||||
if (next.has(key)) next.delete(key);
|
||||
else next.add(key);
|
||||
return next;
|
||||
@@ -230,14 +225,10 @@ export function LogPage() {
|
||||
· {session.entries.length} {t("logs.entriesShort")}
|
||||
</span>
|
||||
{session.errorCount > 0 && (
|
||||
<span className="text-xs text-red-400">
|
||||
· {session.errorCount} errors
|
||||
</span>
|
||||
<span className="text-xs text-red-400">· {session.errorCount} errors</span>
|
||||
)}
|
||||
{session.warnCount > 0 && (
|
||||
<span className="text-xs text-yellow-400">
|
||||
· {session.warnCount} warnings
|
||||
</span>
|
||||
<span className="text-xs text-yellow-400">· {session.warnCount} warnings</span>
|
||||
)}
|
||||
<div className="flex-1" />
|
||||
<button
|
||||
|
||||
@@ -76,7 +76,17 @@ export function OutputPage() {
|
||||
},
|
||||
historyLimit,
|
||||
);
|
||||
}, [gameName, videoType, language, genres, defaultOutput.title, defaultOutput.description, defaultOutput.tagString, addEntry, historyLimit]);
|
||||
}, [
|
||||
gameName,
|
||||
videoType,
|
||||
language,
|
||||
genres,
|
||||
defaultOutput.title,
|
||||
defaultOutput.description,
|
||||
defaultOutput.tagString,
|
||||
addEntry,
|
||||
historyLimit,
|
||||
]);
|
||||
|
||||
const allLangsCombined = useMemo(() => {
|
||||
if (!isMultiLang) return "";
|
||||
@@ -115,11 +125,21 @@ export function OutputPage() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button variant="ghost" size="sm" onClick={() => setShowVariants(true)} disabled={!gameName}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setShowVariants(true)}
|
||||
disabled={!gameName}
|
||||
>
|
||||
<Shuffle className="h-3.5 w-3.5" />
|
||||
{t("output.generateAlternatives")}
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => setShowSaveTemplate(true)} disabled={!gameName}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setShowSaveTemplate(true)}
|
||||
disabled={!gameName}
|
||||
>
|
||||
<Bookmark className="h-3.5 w-3.5" />
|
||||
{t("output.saveAsTemplate")}
|
||||
</Button>
|
||||
@@ -146,7 +166,7 @@ export function OutputPage() {
|
||||
)}
|
||||
|
||||
{isMultiVideoEnding && (
|
||||
<div className="mb-4 flex items-center gap-2 rounded-lg border border-accent/40 bg-accent/10 px-3 py-2 text-xs text-text-secondary">
|
||||
<div className="border-accent/40 bg-accent/10 mb-4 flex items-center gap-2 rounded-lg border px-3 py-2 text-xs text-text-secondary">
|
||||
<Film className="h-3.5 w-3.5 shrink-0 text-accent" />
|
||||
<span>
|
||||
{t("output.previewingVideo", {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
type PlaylistContentType,
|
||||
type PlaylistInput,
|
||||
} from "@engine/playlist-builder";
|
||||
import { DROPPED_REASONS } from "@config/dropped-reasons";
|
||||
import { DROPPED_REASONS, type DroppedReasonId } from "@config/dropped-reasons";
|
||||
import type { SupportedLanguage } from "@engine/types";
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
@@ -50,7 +50,7 @@ export function PlaylistPage() {
|
||||
const [contentType, setContentType] = useState<PlaylistContentType>("full_gameplay");
|
||||
const [totalVideos, setTotalVideos] = useState("");
|
||||
const [customNote, setCustomNote] = useState("");
|
||||
const [droppedReasons, setDroppedReasons] = useState<string[]>([]);
|
||||
const [droppedReasons, setDroppedReasons] = useState<DroppedReasonId[]>([]);
|
||||
const [droppedReasonCustom, setDroppedReasonCustom] = useState("");
|
||||
const [language, setLanguage] = useState<SupportedLanguage>(editor.language);
|
||||
|
||||
@@ -78,9 +78,7 @@ export function PlaylistPage() {
|
||||
status,
|
||||
contentType,
|
||||
totalVideos:
|
||||
totalVideosValidation.valid && totalVideos.trim()
|
||||
? parseInt(totalVideos)
|
||||
: undefined,
|
||||
totalVideosValidation.valid && totalVideos.trim() ? parseInt(totalVideos) : undefined,
|
||||
storeLinks: editor.storeLinks,
|
||||
playlistNote: customNote,
|
||||
droppedReasons,
|
||||
@@ -147,7 +145,10 @@ export function PlaylistPage() {
|
||||
icon: r.icon,
|
||||
}))}
|
||||
value={droppedReasons}
|
||||
onChange={setDroppedReasons}
|
||||
// ChipGroup is id-agnostic (`string[]`); the options come straight
|
||||
// from DROPPED_REASONS, so every id it hands back is a
|
||||
// DroppedReasonId. Narrowing here keeps the state typed.
|
||||
onChange={(v) => setDroppedReasons(v as DroppedReasonId[])}
|
||||
/>
|
||||
<Textarea
|
||||
label={t("playlist.droppedReasonCustomLabel")}
|
||||
|
||||
@@ -77,15 +77,11 @@ export function ProfilesPage() {
|
||||
const suggestedTab = TYPE_TO_TAB[failure.actual];
|
||||
const label = failure.actual.charAt(0).toUpperCase() + failure.actual.slice(1);
|
||||
if (suggestedTab) {
|
||||
toast.error(
|
||||
`This file looks like a ${label} export. Switching tabs…`,
|
||||
{ duration: 4000 },
|
||||
);
|
||||
toast.error(`This file looks like a ${label} export. Switching tabs…`, {
|
||||
duration: 4000,
|
||||
});
|
||||
setTab(suggestedTab);
|
||||
logger.info(
|
||||
"import",
|
||||
`auto-switched tab from ${expected} to ${failure.actual}`,
|
||||
);
|
||||
logger.info("import", `auto-switched tab from ${expected} to ${failure.actual}`);
|
||||
return;
|
||||
}
|
||||
toast.error(`This file is a ${label} export, not ${expected}.`);
|
||||
@@ -185,9 +181,7 @@ export function ProfilesPage() {
|
||||
onClick={() => setTab(t2)}
|
||||
className={clsx(
|
||||
"rounded-md px-4 py-1.5 text-sm font-medium transition-colors",
|
||||
tab === t2
|
||||
? "bg-accent text-white"
|
||||
: "text-text-muted hover:text-text-primary",
|
||||
tab === t2 ? "bg-accent text-white" : "text-text-muted hover:text-text-primary",
|
||||
)}
|
||||
>
|
||||
{t(`${t2}.title`)}
|
||||
|
||||
+15
-30
@@ -11,10 +11,7 @@ import { GENRES } from "@config/genres";
|
||||
import { useSettingsStore, healSettings, extractData } from "@store/settings-store";
|
||||
import { validatePlaylistUrl } from "@utils/validation";
|
||||
import { IS_TAURI } from "@utils/platform";
|
||||
import {
|
||||
exportTypedToJsonFile,
|
||||
importParsedFromJsonFile,
|
||||
} from "@utils/import-export";
|
||||
import { exportTypedToJsonFile, importParsedFromJsonFile } from "@utils/import-export";
|
||||
import { resolveForType } from "@utils/file-schema";
|
||||
import {
|
||||
type SupportedLanguage,
|
||||
@@ -125,9 +122,7 @@ async function importSettingsFromFile() {
|
||||
if (!resolved.ok) {
|
||||
switch (resolved.reason.kind) {
|
||||
case "wrong-type":
|
||||
toast.error(
|
||||
`This file looks like a ${resolved.reason.actual} export, not settings.`,
|
||||
);
|
||||
toast.error(`This file looks like a ${resolved.reason.actual} export, not settings.`);
|
||||
logger.warn(
|
||||
"settings",
|
||||
`Refused wrong-type file on settings import (got ${resolved.reason.actual})`,
|
||||
@@ -246,7 +241,9 @@ export function SettingsPage() {
|
||||
|
||||
{/* 3. Editor — UI knobs that affect the editor page itself. */}
|
||||
<section className="flex flex-col gap-3">
|
||||
<h2 className="text-sm font-semibold text-text-secondary">{t("settings.editorSettings")}</h2>
|
||||
<h2 className="text-sm font-semibold text-text-secondary">
|
||||
{t("settings.editorSettings")}
|
||||
</h2>
|
||||
<Toggle
|
||||
label={t("settings.showCharCount")}
|
||||
checked={settings.showCharCount}
|
||||
@@ -273,25 +270,19 @@ export function SettingsPage() {
|
||||
label={t("settings.badgePosition")}
|
||||
options={badgePositionOptions}
|
||||
value={settings.titleFormat.badgePosition}
|
||||
onChange={(v) =>
|
||||
settings.setTitleFormat({ badgePosition: v as TitleBadgePosition })
|
||||
}
|
||||
onChange={(v) => settings.setTitleFormat({ badgePosition: v as TitleBadgePosition })}
|
||||
/>
|
||||
<Select
|
||||
label={t("settings.titleSeparator")}
|
||||
options={titleSeparatorOptions}
|
||||
value={settings.titleFormat.separator}
|
||||
onChange={(v) =>
|
||||
settings.setTitleFormat({ separator: v as TitleSeparatorId })
|
||||
}
|
||||
onChange={(v) => settings.setTitleFormat({ separator: v as TitleSeparatorId })}
|
||||
/>
|
||||
<Select
|
||||
label={t("settings.badgeCase")}
|
||||
options={badgeCaseOptions}
|
||||
value={settings.titleFormat.badgeCase}
|
||||
onChange={(v) =>
|
||||
settings.setTitleFormat({ badgeCase: v as TitleBadgeCase })
|
||||
}
|
||||
onChange={(v) => settings.setTitleFormat({ badgeCase: v as TitleBadgeCase })}
|
||||
/>
|
||||
</section>
|
||||
|
||||
@@ -329,9 +320,7 @@ export function SettingsPage() {
|
||||
onChange={(v) => settings.setSetting("showThirdPartyAds", v)}
|
||||
/>
|
||||
{settings.showThirdPartyAds && (
|
||||
<p className="-mt-1 ml-14 text-xs text-text-muted">
|
||||
{t("settings.thirdPartyAdsHint")}
|
||||
</p>
|
||||
<p className="-mt-1 ml-14 text-xs text-text-muted">{t("settings.thirdPartyAdsHint")}</p>
|
||||
)}
|
||||
<Toggle
|
||||
label={t("settings.splitContactEmail")}
|
||||
@@ -361,16 +350,12 @@ export function SettingsPage() {
|
||||
<Toggle
|
||||
label={t("settings.pinnedCommentIncludeAskNextGame")}
|
||||
checked={settings.pinnedCommentIncludeAskNextGame}
|
||||
onChange={(v) =>
|
||||
settings.setSetting("pinnedCommentIncludeAskNextGame", v)
|
||||
}
|
||||
onChange={(v) => settings.setSetting("pinnedCommentIncludeAskNextGame", v)}
|
||||
/>
|
||||
<Toggle
|
||||
label={t("settings.pinnedCommentIncludeGenrePlaylist")}
|
||||
checked={settings.pinnedCommentIncludeGenrePlaylist}
|
||||
onChange={(v) =>
|
||||
settings.setSetting("pinnedCommentIncludeGenrePlaylist", v)
|
||||
}
|
||||
onChange={(v) => settings.setSetting("pinnedCommentIncludeGenrePlaylist", v)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -425,9 +410,7 @@ export function SettingsPage() {
|
||||
// map stays sparse. Filter pattern instead of `delete`
|
||||
// satisfies @typescript-eslint/no-dynamic-delete.
|
||||
const next = Object.fromEntries(
|
||||
Object.entries(settings.genrePlaylists).filter(
|
||||
([k]) => k !== g.id,
|
||||
),
|
||||
Object.entries(settings.genrePlaylists).filter(([k]) => k !== g.id),
|
||||
);
|
||||
settings.setSetting("genrePlaylists", next);
|
||||
}
|
||||
@@ -440,7 +423,9 @@ export function SettingsPage() {
|
||||
|
||||
{/* 7. History. */}
|
||||
<section className="flex flex-col gap-3">
|
||||
<h2 className="text-sm font-semibold text-text-secondary">{t("settings.historySettings")}</h2>
|
||||
<h2 className="text-sm font-semibold text-text-secondary">
|
||||
{t("settings.historySettings")}
|
||||
</h2>
|
||||
<Input
|
||||
label={t("settings.historyLimit")}
|
||||
type="number"
|
||||
|
||||
+15
-49
@@ -12,16 +12,10 @@ import { useSettingsStore } from "@store/settings-store";
|
||||
import { SUPPORTED_LANGUAGES, ensureLanguagesLoaded } from "@i18n/index";
|
||||
import { SOCIAL_PLATFORMS } from "@config/social-platforms";
|
||||
import { useSocialPosts } from "@hooks/use-social-posts";
|
||||
import {
|
||||
buildAllSocialPosts,
|
||||
type SocialPostOutput,
|
||||
} from "@engine/social-post-builder";
|
||||
import { buildAllSocialPosts, type SocialPostOutput } from "@engine/social-post-builder";
|
||||
import { useCurrentGeneratorInput } from "@hooks/use-current-generator-input";
|
||||
import { validateBatchRange } from "@utils/validation";
|
||||
import {
|
||||
exportTypedToJsonFile,
|
||||
importTypedFromJsonFile,
|
||||
} from "@utils/import-export";
|
||||
import { exportTypedToJsonFile, importTypedFromJsonFile } from "@utils/import-export";
|
||||
import type { SupportedLanguage } from "@engine/types";
|
||||
import toast from "react-hot-toast";
|
||||
import { logger } from "@utils/logger";
|
||||
@@ -63,16 +57,12 @@ export function SocialPage() {
|
||||
|
||||
const posts = useSocialPosts();
|
||||
const [mode, setMode] = useState<"single" | "bulk">("single");
|
||||
const [activePlatform, setActivePlatform] = useState<string>(
|
||||
SOCIAL_PLATFORMS[0]?.id ?? "tiktok",
|
||||
);
|
||||
const [activePlatform, setActivePlatform] = useState<string>(SOCIAL_PLATFORMS[0]?.id ?? "tiktok");
|
||||
|
||||
// Bulk state
|
||||
const [startPart, setStartPart] = useState("1");
|
||||
const [endPart, setEndPart] = useState("5");
|
||||
const [selectedLangs, setSelectedLangs] = useState<SupportedLanguage[]>([
|
||||
language,
|
||||
]);
|
||||
const [selectedLangs, setSelectedLangs] = useState<SupportedLanguage[]>([language]);
|
||||
const [bulkResults, setBulkResults] = useState<BulkRow[]>([]);
|
||||
const [generating, setGenerating] = useState(false);
|
||||
|
||||
@@ -88,8 +78,7 @@ export function SocialPage() {
|
||||
// Import display (read-only)
|
||||
const [imported, setImported] = useState<SocialExportBundle | null>(null);
|
||||
|
||||
const activeConfig =
|
||||
SOCIAL_PLATFORMS.find((p) => p.id === activePlatform) ?? SOCIAL_PLATFORMS[0];
|
||||
const activeConfig = SOCIAL_PLATFORMS.find((p) => p.id === activePlatform) ?? SOCIAL_PLATFORMS[0];
|
||||
const activePost = posts[activePlatform];
|
||||
|
||||
const platformLabel = (id: string) =>
|
||||
@@ -135,8 +124,7 @@ export function SocialPage() {
|
||||
setImported({
|
||||
gameName: typeof data.gameName === "string" ? data.gameName : "",
|
||||
language: (data.language ?? "en") as SupportedLanguage,
|
||||
partNumber:
|
||||
typeof data.partNumber === "string" ? data.partNumber : undefined,
|
||||
partNumber: typeof data.partNumber === "string" ? data.partNumber : undefined,
|
||||
posts: data.posts as SocialPostExport[],
|
||||
});
|
||||
toast.success(t("socialPost.imported"));
|
||||
@@ -216,9 +204,7 @@ export function SocialPage() {
|
||||
return (
|
||||
<div className="mx-auto max-w-4xl p-6">
|
||||
<div className="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<h1 className="text-lg font-bold text-text-primary">
|
||||
{t("socialPost.title")}
|
||||
</h1>
|
||||
<h1 className="text-lg font-bold text-text-primary">{t("socialPost.title")}</h1>
|
||||
<div className="flex gap-1 rounded-lg bg-surface-1 p-1">
|
||||
{(["single", "bulk"] as const).map((m) => (
|
||||
<button
|
||||
@@ -226,9 +212,7 @@ export function SocialPage() {
|
||||
onClick={() => setMode(m)}
|
||||
className={clsx(
|
||||
"rounded-md px-3 py-1 text-sm font-medium transition-colors",
|
||||
mode === m
|
||||
? "bg-accent text-white"
|
||||
: "text-text-muted hover:text-text-primary",
|
||||
mode === m ? "bg-accent text-white" : "text-text-muted hover:text-text-primary",
|
||||
)}
|
||||
>
|
||||
{t(`socialPost.${m}`)}
|
||||
@@ -260,12 +244,7 @@ export function SocialPage() {
|
||||
);
|
||||
})}
|
||||
<div className="ml-auto flex gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={handleExport}
|
||||
disabled={!gameName}
|
||||
>
|
||||
<Button variant="ghost" size="sm" onClick={handleExport} disabled={!gameName}>
|
||||
<Download className="h-3.5 w-3.5" />
|
||||
{t("common.export")}
|
||||
</Button>
|
||||
@@ -291,10 +270,7 @@ export function SocialPage() {
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<CharCounter
|
||||
text={activePost.text}
|
||||
limit={activeConfig.charLimit}
|
||||
/>
|
||||
<CharCounter text={activePost.text} limit={activeConfig.charLimit} />
|
||||
<CopyButton
|
||||
text={activePost.text}
|
||||
label={t("socialPost.copyCaption")}
|
||||
@@ -325,17 +301,13 @@ export function SocialPage() {
|
||||
)}
|
||||
|
||||
{imported && (
|
||||
<div className="mt-6 rounded-lg border border-accent/40 bg-accent/5 p-4">
|
||||
<div className="border-accent/40 bg-accent/5 mt-6 rounded-lg border p-4">
|
||||
<div className="mb-3 flex items-center justify-between">
|
||||
<h2 className="text-sm font-semibold text-text-primary">
|
||||
{t("socialPost.importedHeading")}
|
||||
{imported.gameName ? ` — ${imported.gameName}` : ""}
|
||||
</h2>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setImported(null)}
|
||||
>
|
||||
<Button variant="ghost" size="sm" onClick={() => setImported(null)}>
|
||||
{t("common.dismiss")}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -417,7 +389,7 @@ export function SocialPage() {
|
||||
{rangeError && (
|
||||
<p
|
||||
role="alert"
|
||||
className="rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning"
|
||||
className="border-warning/40 bg-warning/10 rounded-lg border px-3 py-2 text-xs text-warning"
|
||||
>
|
||||
{rangeError}
|
||||
</p>
|
||||
@@ -449,19 +421,13 @@ export function SocialPage() {
|
||||
const post = row.posts[p.id];
|
||||
if (!post) return null;
|
||||
return (
|
||||
<div
|
||||
key={p.id}
|
||||
className="rounded-lg bg-surface-2 p-3"
|
||||
>
|
||||
<div key={p.id} className="rounded-lg bg-surface-2 p-3">
|
||||
<div className="mb-1 flex items-center justify-between">
|
||||
<span className="text-xs font-medium uppercase text-text-muted">
|
||||
{t(p.labelKey)}
|
||||
</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<CharCounter
|
||||
text={post.text}
|
||||
limit={p.charLimit}
|
||||
/>
|
||||
<CharCounter text={post.text} limit={p.charLimit} />
|
||||
<CopyButton
|
||||
text={post.text}
|
||||
label={t("socialPost.copyCaption")}
|
||||
|
||||
+14
-42
@@ -14,11 +14,7 @@ import type {
|
||||
EndingEntry,
|
||||
EndingVideoRange,
|
||||
} from "@engine/types";
|
||||
import {
|
||||
LANGUAGE_PATCH_OPTIONS,
|
||||
GAME_VERSION_OPTIONS,
|
||||
TECH_NOTES,
|
||||
} from "@engine/types";
|
||||
import { LANGUAGE_PATCH_OPTIONS, GAME_VERSION_OPTIONS, TECH_NOTES } from "@engine/types";
|
||||
import {
|
||||
GRAPHICS_PRESETS,
|
||||
type GraphicsPreset,
|
||||
@@ -29,10 +25,7 @@ import {
|
||||
type ArtStyle,
|
||||
} from "@config/graphics-settings";
|
||||
import { isVideoStyleEra, type VideoStyleEra } from "@config/video-styles";
|
||||
import {
|
||||
coerceUpscaleQuality,
|
||||
coerceFrameGenMultiplier,
|
||||
} from "@engine/graphics-vendor";
|
||||
import { coerceUpscaleQuality, coerceFrameGenMultiplier } from "@engine/graphics-vendor";
|
||||
import {
|
||||
GACHA_QUEST_TYPES,
|
||||
DEFAULT_GACHA_QUEST_TYPE,
|
||||
@@ -210,9 +203,7 @@ export function legacyGraphicsPresetToEnum(legacy: string): {
|
||||
const trimmed = legacy.trim();
|
||||
if (!trimmed) return { preset: "medium", custom: "" };
|
||||
const normalised = trimmed.toLowerCase();
|
||||
const known = GRAPHICS_PRESETS.find(
|
||||
(p) => p !== "custom" && p.replace(/_/g, " ") === normalised,
|
||||
);
|
||||
const known = GRAPHICS_PRESETS.find((p) => p !== "custom" && p.replace(/_/g, " ") === normalised);
|
||||
if (known) return { preset: known, custom: "" };
|
||||
return { preset: "custom", custom: trimmed };
|
||||
}
|
||||
@@ -226,9 +217,7 @@ export function legacyGraphicsPresetToEnum(legacy: string): {
|
||||
* accepts via structural compatibility — we sniff the runtime value here
|
||||
* via an `unknown` cast.
|
||||
*/
|
||||
function normalizeEditorPatch(
|
||||
patch: Partial<EditorData> | null | undefined,
|
||||
): Partial<EditorData> {
|
||||
function normalizeEditorPatch(patch: Partial<EditorData> | null | undefined): Partial<EditorData> {
|
||||
// v0.15.0: guard against malformed input. Previously a `null` patch
|
||||
// — typically from an imported template whose `snapshot` field was
|
||||
// null/undefined — reached the spread on the next line and threw
|
||||
@@ -251,8 +240,7 @@ function normalizeEditorPatch(
|
||||
// (DLSS lost `native_aa`, FSR lost `dlaa`, etc.), coerce to "none" so
|
||||
// the editor doesn't end up with a Select stuck on a value missing
|
||||
// from its options. The vendor itself is left as-is.
|
||||
const vendor =
|
||||
typeof patch.frameGenVendor === "string" ? patch.frameGenVendor : undefined;
|
||||
const vendor = typeof patch.frameGenVendor === "string" ? patch.frameGenVendor : undefined;
|
||||
if (vendor) {
|
||||
if (typeof patch.upscaleQuality === "string") {
|
||||
out.upscaleQuality = coerceUpscaleQuality(vendor, patch.upscaleQuality);
|
||||
@@ -427,11 +415,9 @@ export const useEditorStore = create<EditorState>()(
|
||||
// rather than crashing the render. The action signature still
|
||||
// requires a non-null patch in TypeScript — runtime safety covers
|
||||
// the persisted-blob case where types lie.
|
||||
loadProfile: (profile) =>
|
||||
set((state) => ({ ...state, ...normalizeEditorPatch(profile) })),
|
||||
loadProfile: (profile) => set((state) => ({ ...state, ...normalizeEditorPatch(profile) })),
|
||||
|
||||
loadPreset: (preset) =>
|
||||
set((state) => ({ ...state, ...normalizeEditorPatch(preset) })),
|
||||
loadPreset: (preset) => set((state) => ({ ...state, ...normalizeEditorPatch(preset) })),
|
||||
|
||||
reset: () => set(initialState),
|
||||
}),
|
||||
@@ -549,8 +535,7 @@ export const useEditorStore = create<EditorState>()(
|
||||
// Non-string values coerce to "". The existing `contactEmail`
|
||||
// is reused as the general-contact line, so no data moves.
|
||||
version: 18,
|
||||
migrate: (persistedState, version) =>
|
||||
migrateEditorState(persistedState, version),
|
||||
migrate: (persistedState, version) => migrateEditorState(persistedState, version),
|
||||
partialize: (state) => ({
|
||||
videoType: state.videoType,
|
||||
language: state.language,
|
||||
@@ -642,10 +627,7 @@ export const useEditorStore = create<EditorState>()(
|
||||
* tests can feed in a known persisted blob and assert the migrated
|
||||
* result without going through localStorage.
|
||||
*/
|
||||
export function migrateEditorState(
|
||||
persistedState: unknown,
|
||||
version: number,
|
||||
): EditorData {
|
||||
export function migrateEditorState(persistedState: unknown, version: number): EditorData {
|
||||
if (!persistedState || typeof persistedState !== "object") {
|
||||
return { ...initialState };
|
||||
}
|
||||
@@ -705,10 +687,7 @@ export function migrateEditorState(
|
||||
}
|
||||
if (version < 7) {
|
||||
const gqt = state.gachaQuestType;
|
||||
if (
|
||||
typeof gqt !== "string" ||
|
||||
!(GACHA_QUEST_TYPES as readonly string[]).includes(gqt)
|
||||
) {
|
||||
if (typeof gqt !== "string" || !(GACHA_QUEST_TYPES as readonly string[]).includes(gqt)) {
|
||||
state.gachaQuestType = DEFAULT_GACHA_QUEST_TYPE;
|
||||
}
|
||||
if (typeof state.chapterName !== "string") state.chapterName = "";
|
||||
@@ -739,14 +718,10 @@ export function migrateEditorState(
|
||||
|
||||
// 3. Coerce vendor-incompatible upscale / frame-gen combos.
|
||||
const persistedVendor =
|
||||
typeof state.frameGenVendor === "string"
|
||||
? (state.frameGenVendor as FrameGenVendor)
|
||||
: "none";
|
||||
typeof state.frameGenVendor === "string" ? (state.frameGenVendor as FrameGenVendor) : "none";
|
||||
state.upscaleQuality = coerceUpscaleQuality(
|
||||
persistedVendor,
|
||||
typeof state.upscaleQuality === "string"
|
||||
? (state.upscaleQuality as UpscaleQuality)
|
||||
: "none",
|
||||
typeof state.upscaleQuality === "string" ? (state.upscaleQuality as UpscaleQuality) : "none",
|
||||
);
|
||||
state.frameGenMultiplier = coerceFrameGenMultiplier(
|
||||
persistedVendor,
|
||||
@@ -784,8 +759,7 @@ export function migrateEditorState(
|
||||
} else {
|
||||
state.techNotes = (state.techNotes as unknown[]).filter(
|
||||
(id): id is TechNote =>
|
||||
typeof id === "string" &&
|
||||
(TECH_NOTES as readonly string[]).includes(id),
|
||||
typeof id === "string" && (TECH_NOTES as readonly string[]).includes(id),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -848,9 +822,7 @@ export function migrateEditorState(
|
||||
// v0.22.0 video-style era. Coerce any unrecognised value back to ""
|
||||
// so the form Select never lands on an option that doesn't exist —
|
||||
// covers both pre-v0.22 drafts (no key) and hand-edited blobs.
|
||||
state.videoStyleEra = isVideoStyleEra(state.videoStyleEra)
|
||||
? state.videoStyleEra
|
||||
: "";
|
||||
state.videoStyleEra = isVideoStyleEra(state.videoStyleEra) ? state.videoStyleEra : "";
|
||||
}
|
||||
if (version < 15) {
|
||||
// v0.30.0 Playtest section. Additive back-fill + defensive coercion.
|
||||
|
||||
@@ -111,9 +111,7 @@ export async function hydrateLogStore(retentionDays: number): Promise<void> {
|
||||
// Sort by timestamp descending so the newest is first
|
||||
// (matches `addEntry`'s prepend semantics). Filter out anything
|
||||
// already in memory by id to keep hydration idempotent.
|
||||
const sorted = [...prior].sort(
|
||||
(a, b) => Date.parse(b.timestamp) - Date.parse(a.timestamp),
|
||||
);
|
||||
const sorted = [...prior].sort((a, b) => Date.parse(b.timestamp) - Date.parse(a.timestamp));
|
||||
useLogStore.setState((state) => {
|
||||
const existing = new Set(state.entries.map((e) => e.id));
|
||||
const fresh = sorted.filter((e) => !existing.has(e.id));
|
||||
|
||||
@@ -41,7 +41,10 @@ export interface Profile {
|
||||
interface ProfileState {
|
||||
profiles: Profile[];
|
||||
addProfile: (data: Omit<Profile, "id" | "createdAt" | "updatedAt">) => string;
|
||||
updateProfile: (id: string, data: Partial<Omit<Profile, "id" | "createdAt" | "updatedAt">>) => void;
|
||||
updateProfile: (
|
||||
id: string,
|
||||
data: Partial<Omit<Profile, "id" | "createdAt" | "updatedAt">>,
|
||||
) => void;
|
||||
deleteProfile: (id: string) => void;
|
||||
getProfile: (id: string) => Profile | undefined;
|
||||
importProfiles: (profiles: Profile[]) => void;
|
||||
|
||||
@@ -220,10 +220,7 @@ export function healSettings(raw: unknown): SettingsData {
|
||||
// to [1, 90] so an extreme value can't either spam the disk or
|
||||
// wipe everything on boot.
|
||||
if (typeof incoming.logRetentionDays === "number") {
|
||||
incoming.logRetentionDays = Math.max(
|
||||
1,
|
||||
Math.min(90, Math.floor(incoming.logRetentionDays)),
|
||||
);
|
||||
incoming.logRetentionDays = Math.max(1, Math.min(90, Math.floor(incoming.logRetentionDays)));
|
||||
}
|
||||
|
||||
// v0.28.0: `legalConsentVersion` added. A non-number / non-finite / negative
|
||||
|
||||
@@ -24,10 +24,7 @@ import type {
|
||||
UpscaleQuality,
|
||||
ArtStyle,
|
||||
} from "@config/graphics-settings";
|
||||
import {
|
||||
coerceUpscaleQuality,
|
||||
coerceFrameGenMultiplier,
|
||||
} from "@engine/graphics-vendor";
|
||||
import { coerceUpscaleQuality, coerceFrameGenMultiplier } from "@engine/graphics-vendor";
|
||||
import type { GachaQuestType } from "@config/gacha-quest-types";
|
||||
|
||||
/**
|
||||
@@ -235,10 +232,7 @@ export const useTemplateStore = create<TemplateState>()(
|
||||
snap.upscaleQuality = coerceUpscaleQuality(vendor, snap.upscaleQuality);
|
||||
}
|
||||
if (snap.frameGenMultiplier) {
|
||||
snap.frameGenMultiplier = coerceFrameGenMultiplier(
|
||||
vendor,
|
||||
snap.frameGenMultiplier,
|
||||
);
|
||||
snap.frameGenMultiplier = coerceFrameGenMultiplier(vendor, snap.frameGenMultiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,7 @@ export const APP_MARKER = "ytdescgen" as const;
|
||||
/** Kinds of payload the app can round-trip via JSON files. The string
|
||||
* literal IS the on-disk discriminator — don't rename without writing
|
||||
* a back-compat alias. */
|
||||
export type ExportType =
|
||||
| "profile"
|
||||
| "preset"
|
||||
| "template"
|
||||
| "settings"
|
||||
| "history"
|
||||
| "social";
|
||||
export type ExportType = "profile" | "preset" | "template" | "settings" | "history" | "social";
|
||||
|
||||
/** Versioned wrapper written by every v0.15+ export. */
|
||||
export interface ExportEnvelope<T = unknown> {
|
||||
@@ -108,16 +102,11 @@ export function detectShape(parsed: unknown): DetectedShape {
|
||||
|
||||
// 1. Envelope path.
|
||||
const maybe = parsed as Partial<ExportEnvelope>;
|
||||
if (
|
||||
maybe._app === APP_MARKER &&
|
||||
typeof maybe._type === "string" &&
|
||||
isExportType(maybe._type)
|
||||
) {
|
||||
if (maybe._app === APP_MARKER && typeof maybe._type === "string" && isExportType(maybe._type)) {
|
||||
return {
|
||||
kind: "envelope",
|
||||
type: maybe._type,
|
||||
schemaVersion:
|
||||
typeof maybe._schemaVersion === "number" ? maybe._schemaVersion : 0,
|
||||
schemaVersion: typeof maybe._schemaVersion === "number" ? maybe._schemaVersion : 0,
|
||||
data: maybe.data,
|
||||
};
|
||||
}
|
||||
@@ -177,10 +166,7 @@ function guessArrayType(arr: unknown[]): ExportType | null {
|
||||
return "profile";
|
||||
}
|
||||
// Presets carry game-level data (gameName + storeLinks).
|
||||
if (
|
||||
typeof sample.gameName === "string" &&
|
||||
typeof sample.storeLinks === "object"
|
||||
) {
|
||||
if (typeof sample.gameName === "string" && typeof sample.storeLinks === "object") {
|
||||
return "preset";
|
||||
}
|
||||
// History entries always have a `createdAt` + (title|description|tags).
|
||||
|
||||
@@ -44,11 +44,7 @@ export type ImportResult<T> =
|
||||
* envelope marker lets a later import auto-detect the file's type
|
||||
* (see {@link importTypedFromJsonFile}).
|
||||
*/
|
||||
export function exportTypedToJsonFile<T>(
|
||||
type: ExportType,
|
||||
data: T,
|
||||
filename: string,
|
||||
): void {
|
||||
export function exportTypedToJsonFile<T>(type: ExportType, data: T, filename: string): void {
|
||||
const envelope = wrapEnvelope(type, data);
|
||||
const json = JSON.stringify(envelope, null, 2);
|
||||
triggerDownload(json, filename);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// The `typeof` guard keeps this module importable outside a browser
|
||||
// context (vitest's node environment) — no `window` means no Tauri.
|
||||
export const IS_TAURI =
|
||||
typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
||||
export const IS_TAURI = typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
||||
|
||||
// True inside the Android WebView. On Android, Tauri still injects
|
||||
// `__TAURI_INTERNALS__` (so `IS_TAURI` is true), but the desktop file-save
|
||||
@@ -9,5 +8,4 @@ export const IS_TAURI =
|
||||
// scoped storage. Use this to route file EXPORT through the in-WebView blob
|
||||
// download instead. Desktop and web both report false here, so existing
|
||||
// branches are unaffected. iOS is out of scope (we only ship Android).
|
||||
export const IS_MOBILE =
|
||||
typeof navigator !== "undefined" && /Android/i.test(navigator.userAgent);
|
||||
export const IS_MOBILE = typeof navigator !== "undefined" && /Android/i.test(navigator.userAgent);
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
parseCascadingValue,
|
||||
parseCompositeValue,
|
||||
} from "@config/rig-fields";
|
||||
import { parseCascadingValue, parseCompositeValue } from "@config/rig-fields";
|
||||
import { GPU_CUSTOM_BRAND_ID } from "@config/gpu-catalog";
|
||||
|
||||
/**
|
||||
@@ -90,9 +87,6 @@ export function validateRamValue(raw: string): RigValidationIssue | null {
|
||||
* Only RAM has DDR/size semantics; the OS composite has no validator, so
|
||||
* it (and any future composite) returns `null` until one is added here.
|
||||
*/
|
||||
export function validateCompositeField(
|
||||
fieldId: string,
|
||||
raw: string,
|
||||
): RigValidationIssue | null {
|
||||
export function validateCompositeField(fieldId: string, raw: string): RigValidationIssue | null {
|
||||
return fieldId === "ram" ? validateRamValue(raw) : null;
|
||||
}
|
||||
@@ -66,19 +66,15 @@ const PLATFORM_NAME_EXTRACTORS: readonly NameExtractor[] = [
|
||||
// Epic Games Store. Path is locale-prefixed (`en-US`, `de`, `fr`,
|
||||
// …) and ends with `/p/<slug>` where the slug carries a 6+-char
|
||||
// hex product hash like `-aa04de` we strip before display.
|
||||
pattern:
|
||||
/^https:\/\/store\.epicgames\.com\/[a-z]{2}(?:-[a-z]{2})?\/p\/([a-z0-9-]+)/i,
|
||||
humanize: (s) =>
|
||||
titleCase(s.replace(/-[a-f0-9]{6,}$/i, "").replace(/-+/g, " ")),
|
||||
pattern: /^https:\/\/store\.epicgames\.com\/[a-z]{2}(?:-[a-z]{2})?\/p\/([a-z0-9-]+)/i,
|
||||
humanize: (s) => titleCase(s.replace(/-[a-f0-9]{6,}$/i, "").replace(/-+/g, " ")),
|
||||
},
|
||||
{
|
||||
// Nintendo US store (`/us/store/products/<slug>`). Slugs frequently
|
||||
// carry a `-switch` or `-switch-2` platform suffix that we strip
|
||||
// for a cleaner display name.
|
||||
pattern:
|
||||
/^https:\/\/www\.nintendo\.com\/us\/store\/products\/([^/?#\s]+)/i,
|
||||
humanize: (s) =>
|
||||
titleCase(s.replace(/-switch(?:-2)?$/i, "").replace(/-+/g, " ")),
|
||||
pattern: /^https:\/\/www\.nintendo\.com\/us\/store\/products\/([^/?#\s]+)/i,
|
||||
humanize: (s) => titleCase(s.replace(/-switch(?:-2)?$/i, "").replace(/-+/g, " ")),
|
||||
},
|
||||
{
|
||||
// Nintendo EU store (`/<locale>/Games/<segment>/<slug>-<id>.html`).
|
||||
|
||||
+1
-2
@@ -11,8 +11,7 @@
|
||||
* `Math.random` only if even that is missing.
|
||||
*/
|
||||
export function generateId(): string {
|
||||
const c: Crypto | undefined =
|
||||
typeof globalThis !== "undefined" ? globalThis.crypto : undefined;
|
||||
const c: Crypto | undefined = typeof globalThis !== "undefined" ? globalThis.crypto : undefined;
|
||||
|
||||
if (c && typeof c.randomUUID === "function") {
|
||||
return c.randomUUID();
|
||||
|
||||
@@ -56,10 +56,7 @@ export function validateUrl(input: string): ValidationResult {
|
||||
return { valid: true };
|
||||
}
|
||||
|
||||
export function validateUrlWithPrefix(
|
||||
input: string,
|
||||
expectedPrefix: string,
|
||||
): ValidationResult {
|
||||
export function validateUrlWithPrefix(input: string, expectedPrefix: string): ValidationResult {
|
||||
const baseResult = validateUrl(input);
|
||||
if (!baseResult.valid) return baseResult;
|
||||
|
||||
@@ -82,10 +79,7 @@ export function validateUrlWithPrefix(
|
||||
* validateUrlWithPrefix, prefix-style mismatches are treated as hard
|
||||
* errors so invalid links can be kept out of the output.
|
||||
*/
|
||||
export function validateUrlWithPattern(
|
||||
input: string,
|
||||
pattern: RegExp,
|
||||
): ValidationResult {
|
||||
export function validateUrlWithPattern(input: string, pattern: RegExp): ValidationResult {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) return { valid: true };
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@ describe("CONTENT_WARNING_GROUPS ↔ CONTENT_WARNINGS parity", () => {
|
||||
});
|
||||
|
||||
it("covers every engine warning id exactly (none missing, none extra)", () => {
|
||||
const missingFromGroups = CONTENT_WARNINGS.filter(
|
||||
(id) => !grouped.includes(id),
|
||||
);
|
||||
const missingFromGroups = CONTENT_WARNINGS.filter((id) => !grouped.includes(id));
|
||||
const unknownInGroups = grouped.filter(
|
||||
(id) => !(CONTENT_WARNINGS as readonly string[]).includes(id),
|
||||
);
|
||||
|
||||
@@ -33,10 +33,7 @@ describe("buildDescription", () => {
|
||||
|
||||
it("sanitises hashtags for game names with special characters", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ gameName: "S.T.A.L.K.E.R. 2" }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ gameName: "S.T.A.L.K.E.R. 2" }), t);
|
||||
expect(result).toContain("#STALKER2");
|
||||
expect(result).not.toMatch(/#\s?S\./);
|
||||
});
|
||||
@@ -61,10 +58,7 @@ describe("buildDescription", () => {
|
||||
|
||||
it("includes timestamps when provided", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ timestamps: "0:00 Intro\n5:30 Boss" }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ timestamps: "0:00 Intro\n5:30 Boss" }), t);
|
||||
expect(result).toContain("TIMESTAMPS");
|
||||
expect(result).toContain("0:00 Intro");
|
||||
expect(result).toContain("5:30 Boss");
|
||||
@@ -132,22 +126,22 @@ describe("buildDescription", () => {
|
||||
|
||||
it("adds (free) suffix to free links but not paid ones", () => {
|
||||
const t = createMockT("en");
|
||||
const steamUrl = "https://store.steampowered.com/app/1";
|
||||
const itchUrl = "https://dev.itch.io/game";
|
||||
const result = buildDescription(
|
||||
makeInput({
|
||||
storeLinks: {
|
||||
steam: "https://store.steampowered.com/app/1",
|
||||
itchio: "https://dev.itch.io/game",
|
||||
},
|
||||
storeLinks: { steam: steamUrl, itchio: itchUrl },
|
||||
storeLinkTypes: { steam: "paid", itchio: "free" },
|
||||
}),
|
||||
t,
|
||||
);
|
||||
// Find the itchio line and make sure it has (free), Steam line does not
|
||||
const lines = result.split("\n");
|
||||
const itchLine = lines.find((l) => l.includes("itch.io"));
|
||||
const steamLine = lines.find((l) => l.includes("steampowered"));
|
||||
expect(itchLine).toContain("(free)");
|
||||
expect(steamLine).not.toContain("(free)");
|
||||
// A store line renders as `🎮 {label}{suffix}: {url}`, so the suffix sits
|
||||
// immediately before `: <url>`. Asserting that adjacency is stricter than
|
||||
// locating the line by a host substring — `includes("itch.io")` would also
|
||||
// match a decoy like `https://itch.io.example.com/`, which is exactly why
|
||||
// CodeQL flags that shape as js/incomplete-url-substring-sanitization.
|
||||
expect(result).toContain(`(free): ${itchUrl}`);
|
||||
expect(result).not.toContain(`(free): ${steamUrl}`);
|
||||
});
|
||||
|
||||
it("defaults unspecified link types to paid", () => {
|
||||
@@ -174,9 +168,7 @@ describe("buildDescription", () => {
|
||||
t,
|
||||
);
|
||||
expect(result).toContain("🧪 PLAYTEST / EARLY ACCESS");
|
||||
expect(result).toContain(
|
||||
"🧪 Steam Playtest: https://store.steampowered.com/app/1245620",
|
||||
);
|
||||
expect(result).toContain("🧪 Steam Playtest: https://store.steampowered.com/app/1245620");
|
||||
expect(result).toContain("25 invites available");
|
||||
});
|
||||
|
||||
@@ -328,9 +320,7 @@ describe("buildDescription", () => {
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain(
|
||||
"In-game Setting: High - Intel XeSS Ultra Quality + Intel XeFG x2",
|
||||
);
|
||||
expect(result).toContain("In-game Setting: High - Intel XeSS Ultra Quality + Intel XeFG x2");
|
||||
});
|
||||
|
||||
it("emits multiple RT modes joined with commas", () => {
|
||||
@@ -344,9 +334,7 @@ describe("buildDescription", () => {
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain(
|
||||
"In-game Setting: High with Path Tracing, Ray Reconstruction",
|
||||
);
|
||||
expect(result).toContain("In-game Setting: High with Path Tracing, Ray Reconstruction");
|
||||
});
|
||||
|
||||
it("uses the user's free-form label when graphicsPreset is custom", () => {
|
||||
@@ -448,9 +436,7 @@ describe("buildDescription", () => {
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain(
|
||||
"Live stream of Elden Ring on TestChannel",
|
||||
);
|
||||
expect(result).toContain("Live stream of Elden Ring on TestChannel");
|
||||
expect(result).toContain("🔴 LIVE on");
|
||||
expect(result).toContain("Watch / replay: https://www.youtube.com/watch?v=live123");
|
||||
});
|
||||
@@ -657,9 +643,7 @@ describe("buildDescription", () => {
|
||||
t,
|
||||
);
|
||||
const iCommunity = result.indexOf("💬 COMMUNITY / JOIN THE GROUP");
|
||||
const iFacebook = result.indexOf(
|
||||
"👥 Facebook Group: https://facebook.com/groups/mygroup",
|
||||
);
|
||||
const iFacebook = result.indexOf("👥 Facebook Group: https://facebook.com/groups/mygroup");
|
||||
expect(iCommunity).toBeGreaterThan(-1);
|
||||
expect(iFacebook).toBeGreaterThan(iCommunity);
|
||||
// The FB group line appears exactly once — only under Community, never
|
||||
@@ -720,10 +704,7 @@ describe("buildDescription", () => {
|
||||
|
||||
it("includes rig info when provided", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ rig: { CPU: "i9-14900K", GPU: "RTX 4090" } }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ rig: { CPU: "i9-14900K", GPU: "RTX 4090" } }), t);
|
||||
expect(result).toContain("MY RIG");
|
||||
expect(result).toContain("CPU: i9-14900K");
|
||||
expect(result).toContain("GPU: RTX 4090");
|
||||
@@ -801,22 +782,18 @@ describe("buildDescription", () => {
|
||||
|
||||
it("skips the sponsor credit when sponsorName is blank even if toggle is on", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ sponsorName: "", sponsorPlatform: "Steam" }),
|
||||
t,
|
||||
{ showSponsorCredit: true },
|
||||
);
|
||||
const result = buildDescription(makeInput({ sponsorName: "", sponsorPlatform: "Steam" }), t, {
|
||||
showSponsorCredit: true,
|
||||
});
|
||||
expect(result).not.toContain("🎁");
|
||||
expect(result).not.toContain("Steam key of this game");
|
||||
});
|
||||
|
||||
it("skips the sponsor credit when sponsorPlatform is blank even if toggle is on", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ sponsorName: "Ubisoft", sponsorPlatform: "" }),
|
||||
t,
|
||||
{ showSponsorCredit: true },
|
||||
);
|
||||
const result = buildDescription(makeInput({ sponsorName: "Ubisoft", sponsorPlatform: "" }), t, {
|
||||
showSponsorCredit: true,
|
||||
});
|
||||
expect(result).not.toContain("🎁");
|
||||
expect(result).not.toContain("Thanks to Ubisoft");
|
||||
});
|
||||
@@ -945,32 +922,26 @@ describe("buildDescription", () => {
|
||||
it("preserves multi-line third-party ad text verbatim (v0.11)", () => {
|
||||
const t = createMockT("en");
|
||||
const adText = "Sponsored by ChairCo — link below\nUse code SAVE10 for 10% off";
|
||||
const result = buildDescription(
|
||||
makeInput({ thirdPartyAdText: adText }),
|
||||
t,
|
||||
{ showThirdPartyAds: true },
|
||||
);
|
||||
const result = buildDescription(makeInput({ thirdPartyAdText: adText }), t, {
|
||||
showThirdPartyAds: true,
|
||||
});
|
||||
expect(result).toContain(adText);
|
||||
});
|
||||
|
||||
it("skips ads block when toggle is off, even with non-empty text (v0.11)", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ thirdPartyAdText: "Sponsor copy" }),
|
||||
t,
|
||||
{ showThirdPartyAds: false },
|
||||
);
|
||||
const result = buildDescription(makeInput({ thirdPartyAdText: "Sponsor copy" }), t, {
|
||||
showThirdPartyAds: false,
|
||||
});
|
||||
expect(result).not.toContain("SPONSORS & PARTNERS");
|
||||
expect(result).not.toContain("Sponsor copy");
|
||||
});
|
||||
|
||||
it("skips ads block when toggle is on but text is empty (v0.11)", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ thirdPartyAdText: " " }),
|
||||
t,
|
||||
{ showThirdPartyAds: true },
|
||||
);
|
||||
const result = buildDescription(makeInput({ thirdPartyAdText: " " }), t, {
|
||||
showThirdPartyAds: true,
|
||||
});
|
||||
expect(result).not.toContain("SPONSORS & PARTNERS");
|
||||
});
|
||||
|
||||
@@ -1005,10 +976,7 @@ describe("buildDescription", () => {
|
||||
|
||||
it("includes contact email when provided", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ contactEmail: "test@example.com" }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ contactEmail: "test@example.com" }), t);
|
||||
expect(result).toContain("Business inquiries: test@example.com");
|
||||
});
|
||||
|
||||
@@ -1080,19 +1048,13 @@ describe("buildDescription", () => {
|
||||
|
||||
it("generates part description correctly", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ videoType: "part", partNumber: "5" }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ videoType: "part", partNumber: "5" }), t);
|
||||
expect(result).toContain("Part 5 of Elden Ring");
|
||||
});
|
||||
|
||||
it("generates boss description correctly", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ videoType: "boss", bossName: "Margit" }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ videoType: "boss", bossName: "Margit" }), t);
|
||||
expect(result).toContain("Margit boss fight");
|
||||
});
|
||||
|
||||
@@ -1107,10 +1069,7 @@ describe("buildDescription", () => {
|
||||
describe("buildDescription — v0.12 Playthrough Notes consolidation", () => {
|
||||
it("renders run type as a bullet of the unified PLAYTHROUGH NOTES block", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ playthroughStatus: "blind" }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ playthroughStatus: "blind" }), t);
|
||||
expect(result).toContain("▸ 🎮 PLAYTHROUGH NOTES");
|
||||
expect(result).toContain("• Run type: Blind run (first time playing)");
|
||||
// The block sits between the intro and No Commentary, replacing the
|
||||
@@ -1201,9 +1160,7 @@ describe("buildDescription — v0.12 Playthrough Notes consolidation", () => {
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain(
|
||||
"• Endings shown: Ending 1: True End, Ending 3: Bad End, Hidden",
|
||||
);
|
||||
expect(result).toContain("• Endings shown: Ending 1: True End, Ending 3: Bad End, Hidden");
|
||||
});
|
||||
|
||||
it("falls back to legacy endingsShown when endings[] is empty (v0.16.0)", () => {
|
||||
@@ -1308,16 +1265,12 @@ describe("buildDescription — v0.12 Playthrough Notes consolidation", () => {
|
||||
t,
|
||||
{ tEn },
|
||||
);
|
||||
expect(result).toContain(
|
||||
"▸ 🎮 PLAYTHROUGH NOTES / ▸ 🎮 GHI CHÚ LƯỢT CHƠI",
|
||||
);
|
||||
expect(result).toContain("▸ 🎮 PLAYTHROUGH NOTES / ▸ 🎮 GHI CHÚ LƯỢT CHƠI");
|
||||
expect(result).toContain(
|
||||
"• Run type · Kiểu chơi: Blind run (first time playing) · Chơi lần đầu (blind run)",
|
||||
);
|
||||
expect(result).toContain("• Difficulty · Độ khó: Hard · Khó");
|
||||
expect(result).toContain(
|
||||
"• Language patch · Bản dịch: Fan translation · Bản dịch của fan",
|
||||
);
|
||||
expect(result).toContain("• Language patch · Bản dịch: Fan translation · Bản dịch của fan");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1331,15 +1284,9 @@ describe("buildDescription — v0.12 Tech Notes", () => {
|
||||
t,
|
||||
);
|
||||
expect(result).toContain("▸ 🛠 TECH NOTES");
|
||||
expect(result).toContain(
|
||||
"Production and playstyle notes for transparency.",
|
||||
);
|
||||
expect(result).toContain(
|
||||
"• Some sections muted due to YouTube copyright",
|
||||
);
|
||||
expect(result).toContain(
|
||||
"• FPS drops — caused by hardware (FPS counter visible top-left)",
|
||||
);
|
||||
expect(result).toContain("Production and playstyle notes for transparency.");
|
||||
expect(result).toContain("• Some sections muted due to YouTube copyright");
|
||||
expect(result).toContain("• FPS drops — caused by hardware (FPS counter visible top-left)");
|
||||
expect(result).not.toContain("• Game music replaced");
|
||||
});
|
||||
|
||||
@@ -1353,11 +1300,7 @@ describe("buildDescription — v0.12 Tech Notes", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({
|
||||
techNotes: [
|
||||
"not_no_hit_run",
|
||||
"support_developers",
|
||||
"loading_cut",
|
||||
],
|
||||
techNotes: ["not_no_hit_run", "support_developers", "loading_cut"],
|
||||
}),
|
||||
t,
|
||||
);
|
||||
@@ -1384,9 +1327,7 @@ describe("buildDescription — v0.12 Tech Notes", () => {
|
||||
expect(result).toContain(
|
||||
"• Some sections muted due to YouTube copyright · Một số đoạn tắt tiếng do bản quyền YouTube",
|
||||
);
|
||||
expect(result).toContain(
|
||||
"• Casual play, no commentary · Chơi giải trí, không bình luận",
|
||||
);
|
||||
expect(result).toContain("• Casual play, no commentary · Chơi giải trí, không bình luận");
|
||||
});
|
||||
|
||||
it("renders bilingual EN · JA tech-note bullets in Japanese mode", () => {
|
||||
@@ -1418,9 +1359,7 @@ describe("buildDescription — v0.12 Tech Notes", () => {
|
||||
// No `· ` separator since tEn isn't passed.
|
||||
expect(result).not.toContain(" · ");
|
||||
expect(result).toContain("▸ 🛠 GHI CHÚ KỸ THUẬT");
|
||||
expect(result).toContain(
|
||||
"• Có sụt FPS — do phần cứng (xem FPS góc trái video)",
|
||||
);
|
||||
expect(result).toContain("• Có sụt FPS — do phần cứng (xem FPS góc trái video)");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1435,9 +1374,7 @@ describe("buildDescription — v0.7 content fields (legacy)", () => {
|
||||
expect(result).toContain(
|
||||
"This video contains the following content. Viewer discretion advised.",
|
||||
);
|
||||
expect(result).toContain(
|
||||
"• Flashing lights — photosensitive viewers take care",
|
||||
);
|
||||
expect(result).toContain("• Flashing lights — photosensitive viewers take care");
|
||||
expect(result).toContain("• Loud / sudden sounds");
|
||||
expect(result).not.toContain("• Jumpscares");
|
||||
});
|
||||
@@ -1566,10 +1503,7 @@ describe("buildDescription — v0.25.0 dialogue / internet / suggestive warnings
|
||||
|
||||
it("renders color phobias without dragging in siblings (en)", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ contentWarnings: ["erythrophobia"] }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ contentWarnings: ["erythrophobia"] }), t);
|
||||
expect(result).toContain("• Red / all-red scenes (erythrophobia)");
|
||||
expect(result).not.toContain("(leukophobia)");
|
||||
});
|
||||
@@ -1582,9 +1516,7 @@ describe("buildDescription — v0.25.0 dialogue / internet / suggestive warnings
|
||||
t,
|
||||
{ tEn },
|
||||
);
|
||||
expect(result).toContain(
|
||||
"• Sexualized character designs · Tạo hình nhân vật bị t*nh d*c hóa",
|
||||
);
|
||||
expect(result).toContain("• Sexualized character designs · Tạo hình nhân vật bị t*nh d*c hóa");
|
||||
});
|
||||
|
||||
it("masks YouTube-flag-prone Vietnamese terms on the new suggestive warnings", () => {
|
||||
@@ -1593,11 +1525,7 @@ describe("buildDescription — v0.25.0 dialogue / internet / suggestive warnings
|
||||
const result = buildDescription(
|
||||
makeInput({
|
||||
language: "vi",
|
||||
contentWarnings: [
|
||||
"sexual_innuendo",
|
||||
"partial_nudity",
|
||||
"sexualized_characters",
|
||||
],
|
||||
contentWarnings: ["sexual_innuendo", "partial_nudity", "sexualized_characters"],
|
||||
}),
|
||||
t,
|
||||
{ tEn },
|
||||
@@ -1665,9 +1593,7 @@ describe("buildDescription — gacha_quest video type (v0.9)", () => {
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain(
|
||||
'Endgame mode "Memory of Chaos" in Honkai: Star Rail on TestChannel.',
|
||||
);
|
||||
expect(result).toContain('Endgame mode "Memory of Chaos" in Honkai: Star Rail on TestChannel.');
|
||||
});
|
||||
|
||||
it("falls back to main_story intro when gachaQuestType is missing", () => {
|
||||
@@ -1680,9 +1606,7 @@ describe("buildDescription — gacha_quest video type (v0.9)", () => {
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain(
|
||||
"Welcome to Chapter 1 of Wuthering Waves on TestChannel!",
|
||||
);
|
||||
expect(result).toContain("Welcome to Chapter 1 of Wuthering Waves on TestChannel!");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1702,17 +1626,12 @@ describe("video style era line (v0.22.0)", () => {
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain(
|
||||
"Edited in 1990s VHS style using DaVinci Resolve Studio 19.1",
|
||||
);
|
||||
expect(result).toContain("Edited in 1990s VHS style using DaVinci Resolve Studio 19.1");
|
||||
});
|
||||
|
||||
it("falls back to the editor-less template when rig.video_editor is missing", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ videoStyleEra: "cinematic" }),
|
||||
t,
|
||||
);
|
||||
const result = buildDescription(makeInput({ videoStyleEra: "cinematic" }), t);
|
||||
expect(result).toContain("Edited in cinematic style");
|
||||
expect(result).not.toContain(" using ");
|
||||
});
|
||||
@@ -1806,15 +1725,11 @@ describe("buildDescription — bilingualContentBlocks gate (v0.29.3)", () => {
|
||||
// Content warnings: JA-only header + no EN pairing.
|
||||
expect(result).toContain("▸ ⚠️ コンテンツ警告");
|
||||
expect(result).not.toContain("▸ ⚠️ CONTENT WARNINGS");
|
||||
expect(result).not.toContain(
|
||||
"Flashing lights — photosensitive viewers take care",
|
||||
);
|
||||
expect(result).not.toContain("Flashing lights — photosensitive viewers take care");
|
||||
// Tech notes: JA-only header + no EN pairing.
|
||||
expect(result).toContain("▸ 🛠 技術メモ");
|
||||
expect(result).not.toContain("▸ 🛠 TECH NOTES");
|
||||
expect(result).not.toContain(
|
||||
"FPS drops — caused by hardware (FPS counter visible top-left)",
|
||||
);
|
||||
expect(result).not.toContain("FPS drops — caused by hardware (FPS counter visible top-left)");
|
||||
// Playthrough notes: JA-only header + no EN pairing.
|
||||
expect(result).toContain("▸ 🎮 プレイ情報");
|
||||
expect(result).not.toContain("▸ 🎮 PLAYTHROUGH NOTES");
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
formatEndingEntry,
|
||||
sliceEndingsForVideo,
|
||||
clampRange,
|
||||
} from "@engine/endings-format";
|
||||
import { formatEndingEntry, sliceEndingsForVideo, clampRange } from "@engine/endings-format";
|
||||
import type { EndingEntry } from "@engine/types";
|
||||
|
||||
describe("formatEndingEntry", () => {
|
||||
it("renders 'Ending {n}: {name}' when both are filled", () => {
|
||||
expect(formatEndingEntry({ number: 3, name: "Best End" })).toBe(
|
||||
"Ending 3: Best End",
|
||||
);
|
||||
expect(formatEndingEntry({ number: 3, name: "Best End" })).toBe("Ending 3: Best End");
|
||||
});
|
||||
|
||||
it("renders 'Ending {n}' when only the number is filled", () => {
|
||||
@@ -18,9 +12,7 @@ describe("formatEndingEntry", () => {
|
||||
});
|
||||
|
||||
it("renders just the name when only the name is filled", () => {
|
||||
expect(formatEndingEntry({ number: null, name: "True Ending" })).toBe(
|
||||
"True Ending",
|
||||
);
|
||||
expect(formatEndingEntry({ number: null, name: "True Ending" })).toBe("True Ending");
|
||||
});
|
||||
|
||||
it("returns null when neither is filled (drop signal)", () => {
|
||||
@@ -29,16 +21,12 @@ describe("formatEndingEntry", () => {
|
||||
});
|
||||
|
||||
it("trims whitespace from the name", () => {
|
||||
expect(formatEndingEntry({ number: 2, name: " Bad End " })).toBe(
|
||||
"Ending 2: Bad End",
|
||||
);
|
||||
expect(formatEndingEntry({ number: 2, name: " Bad End " })).toBe("Ending 2: Bad End");
|
||||
});
|
||||
|
||||
it("rejects NaN / Infinity numbers as if missing", () => {
|
||||
expect(formatEndingEntry({ number: NaN, name: "True End" })).toBe("True End");
|
||||
expect(
|
||||
formatEndingEntry({ number: Infinity, name: "X" }),
|
||||
).toBe("X");
|
||||
expect(formatEndingEntry({ number: Infinity, name: "X" })).toBe("X");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,9 +53,7 @@ describe("sliceEndingsForVideo", () => {
|
||||
],
|
||||
};
|
||||
expect(sliceEndingsForVideo(endings, input)).toEqual(endings);
|
||||
expect(
|
||||
sliceEndingsForVideo(endings, { ...input, endingVideoIndex: 99 }),
|
||||
).toEqual(endings);
|
||||
expect(sliceEndingsForVideo(endings, { ...input, endingVideoIndex: 99 })).toEqual(endings);
|
||||
});
|
||||
|
||||
it("returns the slice for video 1 when indexed", () => {
|
||||
|
||||
@@ -43,17 +43,13 @@ describe("buildPinnedComment", () => {
|
||||
|
||||
it("includes the genre-playlist suggestion when option + URL + label all present", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildPinnedComment(
|
||||
makeInput({ genres: ["horror"] }),
|
||||
t,
|
||||
{
|
||||
includeGenrePlaylist: true,
|
||||
genrePlaylists: {
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
genreLabels: { horror: "Horror" },
|
||||
const result = buildPinnedComment(makeInput({ genres: ["horror"] }), t, {
|
||||
includeGenrePlaylist: true,
|
||||
genrePlaylists: {
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
);
|
||||
genreLabels: { horror: "Horror" },
|
||||
});
|
||||
expect(result).toContain(
|
||||
"📺 More Horror gameplay on the channel: https://www.youtube.com/playlist?list=PLhorror",
|
||||
);
|
||||
@@ -61,51 +57,39 @@ describe("buildPinnedComment", () => {
|
||||
|
||||
it("omits the genre-playlist line when the option is off", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildPinnedComment(
|
||||
makeInput({ genres: ["horror"] }),
|
||||
t,
|
||||
{
|
||||
includeGenrePlaylist: false,
|
||||
genrePlaylists: {
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
genreLabels: { horror: "Horror" },
|
||||
const result = buildPinnedComment(makeInput({ genres: ["horror"] }), t, {
|
||||
includeGenrePlaylist: false,
|
||||
genrePlaylists: {
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
);
|
||||
genreLabels: { horror: "Horror" },
|
||||
});
|
||||
expect(result).not.toContain("More Horror gameplay");
|
||||
});
|
||||
|
||||
it("omits the genre-playlist line when no URL is configured for the primary genre", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildPinnedComment(
|
||||
makeInput({ genres: ["rpg"] }),
|
||||
t,
|
||||
{
|
||||
includeGenrePlaylist: true,
|
||||
genrePlaylists: {
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
genreLabels: { horror: "Horror", rpg: "RPG" },
|
||||
const result = buildPinnedComment(makeInput({ genres: ["rpg"] }), t, {
|
||||
includeGenrePlaylist: true,
|
||||
genrePlaylists: {
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
);
|
||||
genreLabels: { horror: "Horror", rpg: "RPG" },
|
||||
});
|
||||
expect(result).not.toContain("More");
|
||||
expect(result).not.toContain("playlist?list=PLhorror");
|
||||
});
|
||||
|
||||
it("uses the primary (first) genre, ignoring secondary genres", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildPinnedComment(
|
||||
makeInput({ genres: ["action", "horror"] }),
|
||||
t,
|
||||
{
|
||||
includeGenrePlaylist: true,
|
||||
genrePlaylists: {
|
||||
action: "https://www.youtube.com/playlist?list=PLaction",
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
genreLabels: { action: "Action", horror: "Horror" },
|
||||
const result = buildPinnedComment(makeInput({ genres: ["action", "horror"] }), t, {
|
||||
includeGenrePlaylist: true,
|
||||
genrePlaylists: {
|
||||
action: "https://www.youtube.com/playlist?list=PLaction",
|
||||
horror: "https://www.youtube.com/playlist?list=PLhorror",
|
||||
},
|
||||
);
|
||||
genreLabels: { action: "Action", horror: "Horror" },
|
||||
});
|
||||
expect(result).toContain("More Action gameplay");
|
||||
expect(result).not.toContain("More Horror gameplay");
|
||||
});
|
||||
@@ -163,10 +147,7 @@ describe("buildPinnedComment", () => {
|
||||
it("picks the per-video-type greeting when available", () => {
|
||||
const t = createMockT("en");
|
||||
const bossResult = buildPinnedComment(makeInput({ videoType: "boss" }), t);
|
||||
const speedrunResult = buildPinnedComment(
|
||||
makeInput({ videoType: "speedrun" }),
|
||||
t,
|
||||
);
|
||||
const speedrunResult = buildPinnedComment(makeInput({ videoType: "speedrun" }), t);
|
||||
expect(bossResult).toContain("boss was a ride");
|
||||
expect(speedrunResult).toContain("Speedrun attempt complete");
|
||||
});
|
||||
@@ -200,10 +181,7 @@ describe("buildPinnedComment", () => {
|
||||
if (key === "pinnedComment.askNextGame") return "Next game?";
|
||||
return key;
|
||||
};
|
||||
const result = buildPinnedComment(
|
||||
makeInput({ videoType: "part" }),
|
||||
noGreetingT,
|
||||
);
|
||||
const result = buildPinnedComment(makeInput({ videoType: "part" }), noGreetingT);
|
||||
// Ensure no raw "pinnedComment.greetings.…" key leaks into the
|
||||
// output — we drop the line rather than render the key.
|
||||
expect(result).not.toContain("pinnedComment.greetings");
|
||||
@@ -212,10 +190,7 @@ describe("buildPinnedComment", () => {
|
||||
|
||||
it("interpolates channelName into the part greeting", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildPinnedComment(
|
||||
makeInput({ channelName: "NoCommentarySan" }),
|
||||
t,
|
||||
);
|
||||
const result = buildPinnedComment(makeInput({ channelName: "NoCommentarySan" }), t);
|
||||
expect(result).toContain("NoCommentarySan");
|
||||
});
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@ describe("buildPlaylistTitle", () => {
|
||||
expect(buildPlaylistTitle(makeInput({ status: "completed" }), t)).toBe(
|
||||
"✅ Completed - Elden Ring",
|
||||
);
|
||||
expect(buildPlaylistTitle(makeInput({ status: "dropped" }), t)).toBe(
|
||||
"❌ Dropped - Elden Ring",
|
||||
);
|
||||
expect(buildPlaylistTitle(makeInput({ status: "dropped" }), t)).toBe("❌ Dropped - Elden Ring");
|
||||
expect(buildPlaylistTitle(makeInput({ status: "incomplete" }), t)).toBe(
|
||||
"🔄 Incomplete - Elden Ring",
|
||||
);
|
||||
@@ -46,9 +44,7 @@ describe("buildPlaylistDescription", () => {
|
||||
});
|
||||
|
||||
it("includes a video-count line when totalVideos is set", () => {
|
||||
expect(buildPlaylistDescription(makeInput({ totalVideos: 25 }), t)).toContain(
|
||||
"📹 25 video(s)",
|
||||
);
|
||||
expect(buildPlaylistDescription(makeInput({ totalVideos: 25 }), t)).toContain("📹 25 video(s)");
|
||||
expect(buildPlaylistDescription(makeInput(), t)).not.toContain("📹");
|
||||
});
|
||||
|
||||
@@ -117,15 +113,11 @@ describe("buildPlaylistComment", () => {
|
||||
expect(buildPlaylistComment(makeInput({ status: "completed" }), t)).toContain(
|
||||
"series is complete",
|
||||
);
|
||||
expect(buildPlaylistComment(makeInput({ status: "in_progress" }), t)).toContain(
|
||||
"part is live",
|
||||
);
|
||||
expect(buildPlaylistComment(makeInput({ status: "in_progress" }), t)).toContain("part is live");
|
||||
expect(buildPlaylistComment(makeInput({ status: "incomplete" }), t)).toContain(
|
||||
"playthrough continues",
|
||||
);
|
||||
expect(buildPlaylistComment(makeInput({ status: "dropped" }), t)).toContain(
|
||||
"decided to drop",
|
||||
);
|
||||
expect(buildPlaylistComment(makeInput({ status: "dropped" }), t)).toContain("decided to drop");
|
||||
});
|
||||
|
||||
it("always ends with the engagement call-to-action", () => {
|
||||
@@ -140,15 +132,11 @@ describe("buildPlaylistComment", () => {
|
||||
expect(withLink).toContain("Watch the full playlist here:");
|
||||
expect(withLink).toContain("https://youtube.com/playlist?list=abc");
|
||||
|
||||
expect(buildPlaylistComment(makeInput(), t)).not.toContain(
|
||||
"Watch the full playlist here:",
|
||||
);
|
||||
expect(buildPlaylistComment(makeInput(), t)).not.toContain("Watch the full playlist here:");
|
||||
});
|
||||
|
||||
it("includes the video-count line only when totalVideos is set", () => {
|
||||
expect(buildPlaylistComment(makeInput({ totalVideos: 12 }), t)).toContain(
|
||||
"📹 12 video(s)",
|
||||
);
|
||||
expect(buildPlaylistComment(makeInput({ totalVideos: 12 }), t)).toContain("📹 12 video(s)");
|
||||
expect(buildPlaylistComment(makeInput(), t)).not.toContain("📹");
|
||||
});
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ describe("formatRigValue", () => {
|
||||
});
|
||||
|
||||
it("falls back to the raw option id when unknown", () => {
|
||||
expect(formatRigValue("video_editor", "unknown_tool|1.0")).toBe(
|
||||
"unknown_tool 1.0",
|
||||
);
|
||||
expect(formatRigValue("video_editor", "unknown_tool|1.0")).toBe("unknown_tool 1.0");
|
||||
});
|
||||
|
||||
it("includes a video_editor entry in RIG_FIELDS", () => {
|
||||
@@ -59,9 +57,7 @@ describe("formatRigValue", () => {
|
||||
|
||||
it("passes legacy free-text values through unchanged", () => {
|
||||
// Pre-v0.13 rigs persisted GPU as plain text. Round-trip those.
|
||||
expect(formatRigValue("gpu", "NVIDIA GeForce RTX 4090")).toBe(
|
||||
"NVIDIA GeForce RTX 4090",
|
||||
);
|
||||
expect(formatRigValue("gpu", "NVIDIA GeForce RTX 4090")).toBe("NVIDIA GeForce RTX 4090");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
buildSocialPost,
|
||||
buildAllSocialPosts,
|
||||
} from "@engine/social-post-builder";
|
||||
import { buildSocialPost, buildAllSocialPosts } from "@engine/social-post-builder";
|
||||
import { SOCIAL_PLATFORMS } from "@config/social-platforms";
|
||||
import { createMockT } from "../helpers/mock-t";
|
||||
import type { GeneratorInput } from "@engine/types";
|
||||
@@ -43,11 +40,7 @@ describe("buildSocialPost", () => {
|
||||
|
||||
it("suppresses the quality badge (short-form title)", () => {
|
||||
const t = createMockT("en");
|
||||
const { text } = buildSocialPost(
|
||||
makeInput({ resolution: "4K", fps: "120" }),
|
||||
t,
|
||||
baseOpts,
|
||||
);
|
||||
const { text } = buildSocialPost(makeInput({ resolution: "4K", fps: "120" }), t, baseOpts);
|
||||
expect(text).not.toContain("[4K");
|
||||
expect(text).not.toContain("120FPS");
|
||||
});
|
||||
@@ -65,11 +58,7 @@ describe("buildSocialPost", () => {
|
||||
|
||||
it("uses only the first genre for the hashtag", () => {
|
||||
const t = createMockT("en");
|
||||
const { text } = buildSocialPost(
|
||||
makeInput({ genres: ["hack_slash", "action"] }),
|
||||
t,
|
||||
baseOpts,
|
||||
);
|
||||
const { text } = buildSocialPost(makeInput({ genres: ["hack_slash", "action"] }), t, baseOpts);
|
||||
expect(text).toContain("#hackslash");
|
||||
expect(text).not.toContain("#action");
|
||||
});
|
||||
@@ -130,17 +119,15 @@ describe("buildSocialPost", () => {
|
||||
|
||||
it("adds the sponsor thanks only when enabled and both fields are set", () => {
|
||||
const t = createMockT("en");
|
||||
const on = buildSocialPost(
|
||||
makeInput({ sponsorName: "Ubisoft", sponsorPlatform: "Steam" }),
|
||||
t,
|
||||
{ ...baseOpts, showSponsorCredit: true },
|
||||
);
|
||||
const on = buildSocialPost(makeInput({ sponsorName: "Ubisoft", sponsorPlatform: "Steam" }), t, {
|
||||
...baseOpts,
|
||||
showSponsorCredit: true,
|
||||
});
|
||||
expect(on.text).toContain("Ubisoft");
|
||||
const partial = buildSocialPost(
|
||||
makeInput({ sponsorName: "Ubisoft", sponsorPlatform: "" }),
|
||||
t,
|
||||
{ ...baseOpts, showSponsorCredit: true },
|
||||
);
|
||||
const partial = buildSocialPost(makeInput({ sponsorName: "Ubisoft", sponsorPlatform: "" }), t, {
|
||||
...baseOpts,
|
||||
showSponsorCredit: true,
|
||||
});
|
||||
expect(partial.text).not.toContain("Thanks to Ubisoft");
|
||||
});
|
||||
|
||||
|
||||
@@ -72,10 +72,9 @@ describe("generateTags", () => {
|
||||
});
|
||||
|
||||
it("humanises snake_case genres in trending tags (fixes visual_novel leak)", () => {
|
||||
const tags = generateTags(
|
||||
makeInput({ genres: ["visual_novel"] }),
|
||||
{ includeTrendingTags: true },
|
||||
);
|
||||
const tags = generateTags(makeInput({ genres: ["visual_novel"] }), {
|
||||
includeTrendingTags: true,
|
||||
});
|
||||
// No tag should contain the raw underscore form
|
||||
expect(tags.every((t) => !t.includes("visual_novel"))).toBe(true);
|
||||
// The humanised form should be present in the trending tags
|
||||
@@ -162,17 +161,12 @@ describe("tagFriendlyGameName", () => {
|
||||
});
|
||||
|
||||
it("strips a trailing 'Definitive Edition' qualifier", () => {
|
||||
expect(tagFriendlyGameName("Some Game: Definitive Edition", 30)).toBe(
|
||||
"Some Game",
|
||||
);
|
||||
expect(tagFriendlyGameName("Some Game: Definitive Edition", 30)).toBe("Some Game");
|
||||
});
|
||||
|
||||
it("iteratively strips multiple trailing qualifiers", () => {
|
||||
expect(
|
||||
tagFriendlyGameName(
|
||||
"Tony Hawk's Pro Skater 1+2 Remastered: Definitive Edition",
|
||||
30,
|
||||
),
|
||||
tagFriendlyGameName("Tony Hawk's Pro Skater 1+2 Remastered: Definitive Edition", 30),
|
||||
).toBe("Tony Hawk's Pro Skater 1+2");
|
||||
});
|
||||
|
||||
@@ -181,28 +175,21 @@ describe("tagFriendlyGameName", () => {
|
||||
});
|
||||
|
||||
it("falls back to the head before a colon when stripping qualifiers isn't enough", () => {
|
||||
expect(
|
||||
tagFriendlyGameName(
|
||||
"A Very Long Subtitle: That Keeps Going Forever Indeed",
|
||||
25,
|
||||
),
|
||||
).toBe("A Very Long Subtitle");
|
||||
expect(tagFriendlyGameName("A Very Long Subtitle: That Keeps Going Forever Indeed", 25)).toBe(
|
||||
"A Very Long Subtitle",
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to leading-words truncation for unstoppably long names", () => {
|
||||
expect(
|
||||
tagFriendlyGameName(
|
||||
"An Extremely Verbose Name Without Any Qualifiers Whatsoever",
|
||||
20,
|
||||
),
|
||||
tagFriendlyGameName("An Extremely Verbose Name Without Any Qualifiers Whatsoever", 20),
|
||||
).toBe("An Extremely Verbose");
|
||||
});
|
||||
});
|
||||
|
||||
describe("generateTags — long game names (regression for v0.7 silent drop)", () => {
|
||||
it("includes a friendly form of long game names in the tag list", () => {
|
||||
const longName =
|
||||
"Tony Hawk's Pro Skater 1+2 Remastered: Definitive Edition";
|
||||
const longName = "Tony Hawk's Pro Skater 1+2 Remastered: Definitive Edition";
|
||||
const tags = generateTags(makeInput({ gameName: longName }));
|
||||
const lowered = tags.map((t) => t.toLowerCase());
|
||||
|
||||
@@ -247,9 +234,7 @@ describe("generateTags — long game names (regression for v0.7 silent drop)", (
|
||||
// sponsorName itself isn't tagged, so this guards against future
|
||||
// reintroduction: a user typing the same publisher in both fields
|
||||
// should see exactly one bare tag for that name.
|
||||
const tags = generateTags(
|
||||
makeInput({ sponsorName: "Acme Inc", pubDevName: "ACME INC" }),
|
||||
);
|
||||
const tags = generateTags(makeInput({ sponsorName: "Acme Inc", pubDevName: "ACME INC" }));
|
||||
const acme = tags.filter((t) => t.toLowerCase() === "acme inc");
|
||||
expect(acme.length).toBe(1);
|
||||
});
|
||||
@@ -292,17 +277,13 @@ describe("generateTags — game names with tag-delimiter punctuation (v0.20.0)",
|
||||
});
|
||||
|
||||
it("emits clean composite tags for comma-bearing names", () => {
|
||||
const tags = generateTags(
|
||||
makeInput({ gameName: "Hello, World", genres: ["action"] }),
|
||||
);
|
||||
const tags = generateTags(makeInput({ gameName: "Hello, World", genres: ["action"] }));
|
||||
expect(tags).toContain("Hello World gameplay");
|
||||
expect(tags.some((t) => t === "Hello World action")).toBe(true);
|
||||
});
|
||||
|
||||
it("strips semicolons inside the game name path", () => {
|
||||
const tags = generateTags(
|
||||
makeInput({ gameName: "Crypt of the NecroDancer; Reaper Edition" }),
|
||||
);
|
||||
const tags = generateTags(makeInput({ gameName: "Crypt of the NecroDancer; Reaper Edition" }));
|
||||
// Semicolon stripped, edition qualifier still peeled off, no semicolon in any tag.
|
||||
expect(tags.every((t) => !t.includes(";"))).toBe(true);
|
||||
expect(tags.some((t) => t.toLowerCase().includes("necrodancer"))).toBe(true);
|
||||
|
||||
Loaded 100 of 114 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user