Hardware
- GPU catalog rewritten with stable ids and official names: descriptions
read "NVIDIA GeForce RTX 5080", "AMD Radeon RX 9070 XT", "Apple M4 Pro"
instead of "NVIDIA RTX 5080" / "AMD RX 9070 XT" / "Apple Silicon M4 Pro".
Cards that never shipped (RX 9080, RX 9090 XT, Arc B380) are gone;
RTX 50/40/30 laptop GPUs, RX 9070 GRE, VRAM variants, Radeon/Intel
integrated graphics, handheld APUs and Apple M5 (Pro/Max/Ultra) added.
One searchable picker ("5080", "rog ally") replaces Brand › Series ›
Model, with free text for anything else.
- Old `brand|series|model` values are migrated (editor v19, profiles v3,
templates v2, and on load/import); unknown cards keep their full name.
- RAM: 24/48/192 GB, LPDDR4/4X/5/5X, optional speed ("32 GB DDR5-6000");
no DDR6/DDR7; plain "DDR"; "48GB GB" fixed; changing the size no longer
clears the type. OS: SteamOS, Bazzite, CachyOS, Nobara, openSUSE,
Fedora 43/44; Linux reads "Ubuntu 24.04 LTS". CPU: suggestions, and
Windows' "Intel(R) Core(TM) … CPU @ 3.60GHz" is tidied on blur.
- The rig block uses translated labels in a fixed order (CPU, GPU, RAM…)
in both the description and the social captions.
Tags
- Measured the way YouTube counts (quotes around multi-word tags, one
comma between): 15 of 51 real tag sets were over 500 by YouTube's count
while showing under. Counters and the limit warning use the same count.
- Trimming keeps trying shorter tags after one that doesn't fit.
- "Elden Ring Steam", "itch.io gameplay" (was STEAM / ITCHIO); no platform
tags for a publisher site; "best open world games" (was "openworld");
RPG/simulation/card pools no longer carry other genres' tags.
Timestamps
- Keywords need a word boundary: "Final Fantasy VII" stays a title (was
"Ending Fantasy VII"), "Introduction" stays whole.
- Accepts [0:00], 0:00 - label and editor frame counts; pt-BR and
Indonesian keywords; a Tidy up button; a live check of YouTube's
chapter rules (0:00 first, 3+, 10 s apart, in order).
Output and data
- History keeps one entry per video (updated in place) instead of one per
Output visit; existing duplicates are folded (history v3). The History
Limit is healed on every load.
- A field over its limit blocks only its own copy button (Copy All: title
or description); a warning when YouTube would reject "<" or ">".
- Validation: Steam /sub/, /bundle/ and s.team links, GOG/Humble/xbox.com
without www, regional Nintendo sites, Microsoft Store, Luna; social
links with www./m./twitter.com; phone, YouTube Music and
video-in-playlist links (normalised); email domains need a TLD; the live
URL is validated; no bare "#" hashtag.
- The engine takes the year from the caller; "Ending N" follows the output
language.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
619 lines
21 KiB
TypeScript
619 lines
21 KiB
TypeScript
import { formatGpuValue, migrateGpuValue } from "./gpu-catalog";
|
|
|
|
/**
|
|
* Supported rig field input types.
|
|
*
|
|
* - `text`: plain text input, optionally with suggestions.
|
|
* - `dropdown_with_version`: a dropdown of preset options paired with a
|
|
* free-form version text input. The stored value is
|
|
* `"<option_value>|<version>"` so we don't break the flat
|
|
* `Partial<Record<string, string>>` rig shape in the editor store.
|
|
* - `gpu` (v1.0.0): the searchable GPU catalog (`@config/gpu-catalog`).
|
|
* Stores `gpu:<model id>`, or the user's own text for anything else.
|
|
* - `composite_dropdown`: two-or-more dropdowns combined into one logical
|
|
* field (RAM: size + type + speed; OS: name + version + edition). Each
|
|
* part 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" | "gpu" | "composite_dropdown";
|
|
|
|
interface RigFieldOption {
|
|
readonly value: string;
|
|
/** Display label (not translated — product names are brand-preserved). */
|
|
readonly label: string;
|
|
}
|
|
|
|
/**
|
|
* A composite part's options are either a static array or a function of
|
|
* the previously-selected parts (the OS cascade, where the version list
|
|
* depends on the OS name).
|
|
*/
|
|
type RigFieldOptionResolver =
|
|
readonly RigFieldOption[] | ((previousParts: readonly string[]) => readonly RigFieldOption[]);
|
|
|
|
export interface CompositePart {
|
|
/** Stable id, used to assemble the storage tuple in declaration order. */
|
|
readonly id: string;
|
|
readonly labelKey: string;
|
|
readonly options: RigFieldOptionResolver;
|
|
/** When true, the part renders an extra free-text input when value === `"custom"`. */
|
|
readonly allowCustom?: boolean;
|
|
/** Suffix shown after the custom input (e.g. " GB"). */
|
|
readonly customSuffix?: string;
|
|
/** Optional placeholder for the custom input. */
|
|
readonly customPlaceholder?: string;
|
|
/**
|
|
* Dynamic label key override. Lets a single part show "Distro" when
|
|
* OS = Linux but "Version" when OS = Windows / macOS.
|
|
*/
|
|
readonly labelKeyResolver?: (previousParts: readonly string[]) => string;
|
|
/**
|
|
* Hide this part entirely when the resolver returns `true` (macOS has no
|
|
* edition slot). `formatRigValue` skips hidden parts too.
|
|
*/
|
|
readonly hiddenWhen?: (previousParts: readonly string[]) => boolean;
|
|
}
|
|
|
|
/**
|
|
* Helper for {@link CompositePart.options} — call sites get a plain
|
|
* `RigFieldOption[]` whether the part declares a static array or a
|
|
* function-of-previous-parts resolver.
|
|
*/
|
|
export function resolveCompositeOptions(
|
|
opts: RigFieldOptionResolver,
|
|
previousParts: readonly string[],
|
|
): readonly RigFieldOption[] {
|
|
return typeof opts === "function" ? opts(previousParts) : opts;
|
|
}
|
|
|
|
/** The part's label key — dynamic when it declares a resolver. */
|
|
export function resolveCompositeLabelKey(
|
|
part: CompositePart,
|
|
previousParts: readonly string[],
|
|
): string {
|
|
return part.labelKeyResolver?.(previousParts) ?? part.labelKey;
|
|
}
|
|
|
|
interface CompositeFieldSpec {
|
|
readonly parts: readonly CompositePart[];
|
|
/**
|
|
* Whether changing a part clears the parts after it. True where later
|
|
* option lists depend on earlier choices (OS: Windows → macOS must drop
|
|
* "Pro"); false where parts are independent (RAM: picking 32 GB must
|
|
* not wipe the DDR5 already chosen).
|
|
*/
|
|
readonly cascade: boolean;
|
|
/**
|
|
* Format the stored parts into the description-output string. Receives
|
|
* resolved labels (not raw ids) — for `custom` parts the resolved value
|
|
* is the free text the user typed.
|
|
*/
|
|
readonly format: (resolvedParts: readonly string[]) => string;
|
|
}
|
|
|
|
export interface RigField {
|
|
readonly id: string;
|
|
readonly labelKey: string;
|
|
readonly type: RigFieldType;
|
|
readonly placeholder?: string;
|
|
readonly options?: readonly RigFieldOption[];
|
|
readonly versionPlaceholder?: string;
|
|
/** Set when {@link type} is `"composite_dropdown"`. */
|
|
readonly composite?: CompositeFieldSpec;
|
|
/** `text` fields: values offered while typing (the user may type anything). */
|
|
readonly suggestions?: readonly string[];
|
|
}
|
|
|
|
/**
|
|
* Dropdown options for the video editing software field.
|
|
*
|
|
* Order loosely reflects popularity among no-commentary gameplay
|
|
* creators. Add new entries here — the UI picks them up automatically.
|
|
*/
|
|
const VIDEO_EDITOR_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "davinci_resolve", label: "DaVinci Resolve" },
|
|
{ value: "davinci_resolve_studio", label: "DaVinci Resolve Studio" },
|
|
{ value: "premiere", label: "Adobe Premiere Pro" },
|
|
{ value: "after_effects", label: "Adobe After Effects" },
|
|
{ value: "capcut", label: "CapCut" },
|
|
{ value: "vegas", label: "Vegas Pro" },
|
|
{ value: "final_cut", label: "Final Cut Pro" },
|
|
{ value: "kdenlive", label: "Kdenlive" },
|
|
{ value: "shotcut", label: "Shotcut" },
|
|
{ value: "filmora", label: "Wondershare Filmora" },
|
|
{ value: "other", label: "Other" },
|
|
];
|
|
|
|
/** RAM size options in GB. `custom` opens a free-text input. */
|
|
const RAM_SIZE_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "4", label: "4 GB" },
|
|
{ value: "6", label: "6 GB" },
|
|
{ value: "8", label: "8 GB" },
|
|
{ value: "12", label: "12 GB" },
|
|
{ value: "16", label: "16 GB" },
|
|
{ value: "24", label: "24 GB" },
|
|
{ value: "32", label: "32 GB" },
|
|
{ value: "48", label: "48 GB" },
|
|
{ value: "64", label: "64 GB" },
|
|
{ value: "96", label: "96 GB" },
|
|
{ value: "128", label: "128 GB" },
|
|
{ value: "192", label: "192 GB" },
|
|
{ value: "256", label: "256 GB" },
|
|
{ value: "custom", label: "Custom…" },
|
|
];
|
|
|
|
/**
|
|
* Memory type. Desktop DDR plus the LPDDR generations laptops, handhelds
|
|
* and Macs use. There is no DDR6/DDR7 system memory (GDDR7 is graphics
|
|
* memory), so those entries are gone; the first generation is plain "DDR"
|
|
* (value kept as "DDR1" so old drafts still resolve).
|
|
*/
|
|
const RAM_TYPE_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "DDR5", label: "DDR5" },
|
|
{ value: "DDR4", label: "DDR4" },
|
|
{ value: "DDR3", label: "DDR3" },
|
|
{ value: "DDR2", label: "DDR2" },
|
|
{ value: "DDR1", label: "DDR" },
|
|
{ value: "LPDDR5X", label: "LPDDR5X" },
|
|
{ value: "LPDDR5", label: "LPDDR5" },
|
|
{ value: "LPDDR4X", label: "LPDDR4X" },
|
|
{ value: "LPDDR4", label: "LPDDR4" },
|
|
];
|
|
|
|
/** Data rate in MT/s (what the "DDR5-6000" number means). */
|
|
const RAM_SPEED_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
...[
|
|
"2133",
|
|
"2400",
|
|
"2666",
|
|
"3000",
|
|
"3200",
|
|
"3600",
|
|
"4000",
|
|
"4266",
|
|
"4800",
|
|
"5200",
|
|
"5600",
|
|
"6000",
|
|
"6400",
|
|
"6800",
|
|
"7200",
|
|
"7500",
|
|
"8000",
|
|
"8533",
|
|
].map((v) => ({ value: v, label: v })),
|
|
{ value: "custom", label: "Custom…" },
|
|
];
|
|
|
|
const RAM_COMPOSITE: CompositeFieldSpec = {
|
|
cascade: false,
|
|
parts: [
|
|
{
|
|
id: "size",
|
|
labelKey: "editor.ram_size",
|
|
options: RAM_SIZE_OPTIONS,
|
|
allowCustom: true,
|
|
customSuffix: " GB",
|
|
customPlaceholder: "40",
|
|
},
|
|
{ id: "ddr", labelKey: "editor.ram_ddr", options: RAM_TYPE_OPTIONS },
|
|
{
|
|
id: "speed",
|
|
labelKey: "editor.ram_speed",
|
|
options: RAM_SPEED_OPTIONS,
|
|
allowCustom: true,
|
|
customPlaceholder: "6200",
|
|
},
|
|
],
|
|
// "32 GB DDR5-6000" — the way RAM kits are named. Without a type the
|
|
// speed gets its unit: "32 GB 6000 MT/s".
|
|
format: ([size = "", type = "", speed = ""]) => {
|
|
const memory = type && speed ? `${type}-${speed}` : type || (speed ? `${speed} MT/s` : "");
|
|
return [size, memory].filter(Boolean).join(" ");
|
|
},
|
|
};
|
|
|
|
/**
|
|
* OS composite. The slot semantics adapt to the chosen OS family:
|
|
*
|
|
* - Windows: name → version (10/11) → edition (Home/Pro/…)
|
|
* - macOS: name → version → (hidden — Apple has no editions)
|
|
* - Linux: name → distro → version (per distro)
|
|
*/
|
|
const OS_NAME_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "windows", label: "Windows" },
|
|
{ value: "macos", label: "macOS" },
|
|
{ value: "linux", label: "Linux" },
|
|
];
|
|
|
|
const WINDOWS_VERSION_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "11", label: "11" },
|
|
{ value: "10", label: "10" },
|
|
];
|
|
|
|
/**
|
|
* macOS versions. Apple jumped from 15 (Sequoia, 2024) to 26 (Tahoe, 2025)
|
|
* to year-align the number, so the list is intentionally non-contiguous.
|
|
* "10" is the pre-v1.0 catch-all for the 10.x era, kept so old drafts
|
|
* still resolve.
|
|
*/
|
|
const MACOS_VERSION_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "26 Tahoe", label: "26 Tahoe" },
|
|
{ value: "15 Sequoia", label: "15 Sequoia" },
|
|
{ value: "14 Sonoma", label: "14 Sonoma" },
|
|
{ value: "13 Ventura", label: "13 Ventura" },
|
|
{ value: "12 Monterey", label: "12 Monterey" },
|
|
{ value: "11 Big Sur", label: "11 Big Sur" },
|
|
{ value: "10.15 Catalina", label: "10.15 Catalina" },
|
|
{ value: "10", label: "10.x" },
|
|
];
|
|
|
|
/** Linux distros gameplay creators actually use (Proton, handhelds). */
|
|
const LINUX_DISTRO_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "steamos", label: "SteamOS" },
|
|
{ value: "bazzite", label: "Bazzite" },
|
|
{ value: "cachyos", label: "CachyOS" },
|
|
{ value: "nobara", label: "Nobara" },
|
|
{ value: "ubuntu", label: "Ubuntu" },
|
|
{ value: "fedora", label: "Fedora" },
|
|
{ value: "debian", label: "Debian" },
|
|
{ value: "arch", label: "Arch Linux" },
|
|
{ value: "manjaro", label: "Manjaro" },
|
|
{ value: "popos", label: "Pop!_OS" },
|
|
{ value: "mint", label: "Linux Mint" },
|
|
{ value: "opensuse", label: "openSUSE" },
|
|
];
|
|
|
|
const ROLLING = [
|
|
{ value: "", label: "—" },
|
|
{ value: "rolling", label: "rolling" },
|
|
] as const;
|
|
|
|
const LATEST = [
|
|
{ value: "", label: "—" },
|
|
{ value: "latest", label: "latest stable" },
|
|
] as const;
|
|
|
|
/**
|
|
* Per-distro version lists. The map key matches the distro id from
|
|
* {@link LINUX_DISTRO_OPTIONS}; values are stored verbatim. Rolling or
|
|
* image-based distros get a single placeholder so the dropdown isn't empty.
|
|
*/
|
|
const LINUX_VERSION_BY_DISTRO: Record<string, readonly RigFieldOption[]> = {
|
|
steamos: [
|
|
{ value: "", label: "—" },
|
|
{ value: "3", label: "3" },
|
|
],
|
|
bazzite: LATEST,
|
|
cachyos: ROLLING,
|
|
nobara: [
|
|
{ value: "", label: "—" },
|
|
{ value: "42", label: "42" },
|
|
{ value: "41", label: "41" },
|
|
],
|
|
ubuntu: [
|
|
{ value: "", label: "—" },
|
|
{ value: "26.04 LTS", label: "26.04 LTS" },
|
|
{ value: "24.04 LTS", label: "24.04 LTS" },
|
|
{ value: "22.04 LTS", label: "22.04 LTS" },
|
|
{ value: "20.04 LTS", label: "20.04 LTS" },
|
|
],
|
|
fedora: [
|
|
{ value: "", label: "—" },
|
|
{ value: "44", label: "44" },
|
|
{ value: "43", label: "43" },
|
|
{ value: "42", label: "42" },
|
|
{ value: "41", label: "41" },
|
|
{ value: "40", label: "40" },
|
|
],
|
|
debian: [
|
|
{ value: "", label: "—" },
|
|
{ value: "13 Trixie", label: "13 Trixie" },
|
|
{ value: "12 Bookworm", label: "12 Bookworm" },
|
|
],
|
|
arch: ROLLING,
|
|
manjaro: LATEST,
|
|
popos: [
|
|
{ value: "", label: "—" },
|
|
{ value: "24.04 LTS", label: "24.04 LTS" },
|
|
{ value: "22.04 LTS", label: "22.04 LTS" },
|
|
],
|
|
mint: [
|
|
{ value: "", label: "—" },
|
|
{ value: "22", label: "22" },
|
|
{ value: "21", label: "21" },
|
|
],
|
|
opensuse: [
|
|
{ value: "", label: "—" },
|
|
{ value: "Tumbleweed", label: "Tumbleweed" },
|
|
{ value: "Leap 16", label: "Leap 16" },
|
|
{ value: "Leap 15.6", label: "Leap 15.6" },
|
|
],
|
|
};
|
|
|
|
const OS_EDITION_OPTIONS: readonly RigFieldOption[] = [
|
|
{ value: "", label: "—" },
|
|
{ value: "home", label: "Home" },
|
|
{ value: "pro", label: "Pro" },
|
|
{ value: "enterprise", label: "Enterprise" },
|
|
{ value: "education", label: "Education" },
|
|
{ value: "iot", label: "IoT Enterprise" },
|
|
];
|
|
|
|
const EMPTY_OPTIONS: readonly RigFieldOption[] = [{ value: "", label: "—" }];
|
|
|
|
const OS_COMPOSITE: CompositeFieldSpec = {
|
|
cascade: true,
|
|
parts: [
|
|
{ id: "name", labelKey: "editor.os_name", options: OS_NAME_OPTIONS },
|
|
{
|
|
// Slot 2: Windows/macOS use this as "Version", Linux re-purposes it
|
|
// as "Distro".
|
|
id: "version_or_distro",
|
|
labelKey: "editor.os_version",
|
|
labelKeyResolver: ([name = ""]) =>
|
|
name === "linux" ? "editor.os_distro" : "editor.os_version",
|
|
options: ([name = ""]) => {
|
|
if (name === "windows") return WINDOWS_VERSION_OPTIONS;
|
|
if (name === "macos") return MACOS_VERSION_OPTIONS;
|
|
if (name === "linux") return LINUX_DISTRO_OPTIONS;
|
|
return EMPTY_OPTIONS;
|
|
},
|
|
},
|
|
{
|
|
// Slot 3: Windows uses "Edition"; Linux re-purposes it as "Version"
|
|
// (per distro). macOS doesn't have a third slot at all — hidden.
|
|
id: "edition_or_linux_version",
|
|
labelKey: "editor.os_edition",
|
|
labelKeyResolver: ([name = ""]) =>
|
|
name === "linux" ? "editor.os_version" : "editor.os_edition",
|
|
hiddenWhen: ([name = ""]) => name === "macos",
|
|
options: ([name = "", distro = ""]) => {
|
|
if (name === "windows") return OS_EDITION_OPTIONS;
|
|
if (name === "linux") return LINUX_VERSION_BY_DISTRO[distro] ?? EMPTY_OPTIONS;
|
|
return EMPTY_OPTIONS;
|
|
},
|
|
},
|
|
],
|
|
// "Windows 11 Pro", "macOS 26 Tahoe" — and for Linux just the distro,
|
|
// the way people name it: "Ubuntu 24.04 LTS", "Arch Linux (rolling)".
|
|
format: ([name = "", second = "", third = ""]) => {
|
|
if (name === "Linux" && second) {
|
|
if (third === "rolling" || third === "latest stable") return `${second} (${third})`;
|
|
return [second, third].filter(Boolean).join(" ");
|
|
}
|
|
return [name, second, third].filter((p) => p.trim() !== "").join(" ");
|
|
},
|
|
};
|
|
|
|
/** Suggestions for the CPU field; any other text is accepted as typed. */
|
|
export const CPU_SUGGESTIONS: readonly string[] = [
|
|
"AMD Ryzen 7 9800X3D",
|
|
"AMD Ryzen 9 9950X3D",
|
|
"AMD Ryzen 9 9950X",
|
|
"AMD Ryzen 9 9900X",
|
|
"AMD Ryzen 7 9700X",
|
|
"AMD Ryzen 5 9600X",
|
|
"AMD Ryzen 7 7800X3D",
|
|
"AMD Ryzen 9 7950X3D",
|
|
"AMD Ryzen 9 7950X",
|
|
"AMD Ryzen 9 7900X",
|
|
"AMD Ryzen 7 7700X",
|
|
"AMD Ryzen 5 7600X",
|
|
"AMD Ryzen 5 7600",
|
|
"AMD Ryzen 7 5800X3D",
|
|
"AMD Ryzen 7 5700X3D",
|
|
"AMD Ryzen 9 5950X",
|
|
"AMD Ryzen 9 5900X",
|
|
"AMD Ryzen 7 5800X",
|
|
"AMD Ryzen 7 5700X",
|
|
"AMD Ryzen 5 5600X",
|
|
"AMD Ryzen 5 5600",
|
|
"AMD Ryzen 7 3700X",
|
|
"AMD Ryzen 5 3600",
|
|
"AMD Ryzen AI 9 HX 370",
|
|
"AMD Ryzen AI Max+ 395",
|
|
"AMD Ryzen 7 8845HS",
|
|
"AMD Ryzen 7 7840HS",
|
|
"Intel Core Ultra 9 285K",
|
|
"Intel Core Ultra 7 265K",
|
|
"Intel Core Ultra 5 245K",
|
|
"Intel Core i9-14900K",
|
|
"Intel Core i7-14700K",
|
|
"Intel Core i5-14600K",
|
|
"Intel Core i5-14400F",
|
|
"Intel Core i9-13900K",
|
|
"Intel Core i7-13700K",
|
|
"Intel Core i5-13600K",
|
|
"Intel Core i5-13400F",
|
|
"Intel Core i9-12900K",
|
|
"Intel Core i7-12700K",
|
|
"Intel Core i5-12600K",
|
|
"Intel Core i5-12400F",
|
|
"Intel Core i7-11700K",
|
|
"Intel Core i5-11400F",
|
|
"Intel Core i9-10900K",
|
|
"Intel Core i7-10700K",
|
|
"Intel Core i5-10400F",
|
|
"Intel Core i9-9900K",
|
|
"Intel Core i7-9700K",
|
|
"Intel Core i7-8700K",
|
|
"Intel Core Ultra 7 258V",
|
|
"Intel Core Ultra 7 155H",
|
|
"Apple M5",
|
|
"Apple M4 Pro",
|
|
"Apple M4",
|
|
];
|
|
|
|
/**
|
|
* Tidy a CPU name pasted from Windows or a spec sheet:
|
|
* `"12th Gen Intel(R) Core(TM) i7-12700K"` → `"Intel Core i7-12700K"`,
|
|
* `"AMD Ryzen 7 7800X3D 8-Core Processor"` → `"AMD Ryzen 7 7800X3D"`,
|
|
* `"Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz"` → `"Intel Core i9-9900K"`.
|
|
* Text it doesn't recognise is only trimmed and de-duplicated of spaces.
|
|
*/
|
|
export function cleanCpuName(raw: string): string {
|
|
return raw
|
|
.replace(/\((?:R|TM|C)\)|[®™©]/gi, "")
|
|
.replace(/^\s*\d{1,2}(?:st|nd|rd|th)\s+Gen\s+/i, "")
|
|
.replace(/\s+CPU\s*@\s*[\d.]+\s*[GM]Hz\b/i, "")
|
|
.replace(/\s+@\s*[\d.]+\s*[GM]Hz\b/i, "")
|
|
.replace(/\s+\d{1,3}-Core\s+Processor\b/i, "")
|
|
.replace(/\s+(?:with\s+Radeon(?:\s+\w+)?\s+Graphics|Processor)\s*$/i, "")
|
|
.replace(/\s{2,}/g, " ")
|
|
.trim();
|
|
}
|
|
|
|
/**
|
|
* The rig fields, in the order both the editor and the description show
|
|
* them: the parts a viewer compares first (CPU, GPU, RAM), then the rest.
|
|
*/
|
|
export const RIG_FIELDS: readonly RigField[] = [
|
|
{
|
|
id: "cpu",
|
|
labelKey: "rig.cpu",
|
|
type: "text",
|
|
placeholder: "AMD Ryzen 7 9800X3D",
|
|
suggestions: CPU_SUGGESTIONS,
|
|
},
|
|
{ id: "gpu", labelKey: "rig.gpu", type: "gpu" },
|
|
{ id: "ram", labelKey: "rig.ram", type: "composite_dropdown", composite: RAM_COMPOSITE },
|
|
{
|
|
id: "motherboard",
|
|
labelKey: "rig.motherboard",
|
|
type: "text",
|
|
placeholder: "ASUS ROG Strix X870E-E Gaming",
|
|
},
|
|
{ id: "storage", labelKey: "rig.storage", type: "text", placeholder: "2TB Samsung 990 PRO NVMe" },
|
|
{ id: "os", labelKey: "rig.os", type: "composite_dropdown", composite: OS_COMPOSITE },
|
|
{ id: "monitor", labelKey: "rig.monitor", type: "text", placeholder: 'LG 27GP950 27" 4K 144Hz' },
|
|
{ id: "capture", labelKey: "rig.capture", type: "text", placeholder: "OBS Studio 31" },
|
|
{
|
|
id: "controller",
|
|
labelKey: "rig.controller",
|
|
type: "text",
|
|
placeholder: "DualSense / Xbox Wireless Controller",
|
|
},
|
|
{
|
|
id: "video_editor",
|
|
labelKey: "rig.video_editor",
|
|
type: "dropdown_with_version",
|
|
options: VIDEO_EDITOR_OPTIONS,
|
|
versionPlaceholder: "20 / 2026 / v25",
|
|
},
|
|
];
|
|
|
|
/**
|
|
* A stored rig object brought up to date: string values only (an imported
|
|
* profile may carry `rig: null` or numbers) and the GPU in the v1.0
|
|
* catalog format. Idempotent — used by the store migrations and imports.
|
|
*/
|
|
export function migrateRig(rig: unknown): Record<string, string> {
|
|
if (!rig || typeof rig !== "object") return {};
|
|
const out: Record<string, string> = {};
|
|
for (const [key, value] of Object.entries(rig as Record<string, unknown>)) {
|
|
if (typeof value !== "string") continue;
|
|
out[key] = key === "gpu" ? migrateGpuValue(value) : value;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
/**
|
|
* Parse a composite-dropdown stored value into its segments. The order
|
|
* matches the parts declared on the field's {@link CompositeFieldSpec}.
|
|
* Pipeless legacy values are returned as a single-element tuple so the
|
|
* caller can render them as a fallback string.
|
|
*/
|
|
export function parseCompositeValue(raw: string): {
|
|
parts: readonly string[];
|
|
isLegacy: boolean;
|
|
} {
|
|
if (!raw) return { parts: [], isLegacy: false };
|
|
if (!raw.includes("|")) return { parts: [raw], isLegacy: true };
|
|
return { parts: raw.split("|"), isLegacy: false };
|
|
}
|
|
|
|
const escapeRegExp = (text: string): string => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
|
|
/** Custom text plus the part's unit, unless the user typed it ("48GB" → "48 GB"). */
|
|
function withSuffix(text: string, suffix: string): string {
|
|
const unit = suffix.trim();
|
|
if (!unit) return text;
|
|
const bare = text.replace(new RegExp(`\\s*${escapeRegExp(unit)}$`, "i"), "");
|
|
return bare ? `${bare}${suffix}` : "";
|
|
}
|
|
|
|
/**
|
|
* Format a stored rig value for display in the description output.
|
|
*
|
|
* - `gpu` ("gpu:nvidia-rtx-5080") → "NVIDIA GeForce RTX 5080"; the
|
|
* pre-v1.0 `brand|series|model` values are converted on the fly; free
|
|
* text passes through.
|
|
* - `dropdown_with_version` ("davinci_resolve_studio|19.1") →
|
|
* "DaVinci Resolve Studio 19.1".
|
|
* - `composite_dropdown` ("32|DDR5|6000", "custom:48|DDR5|") →
|
|
* "32 GB DDR5-6000" / "48 GB DDR5" via the field's
|
|
* {@link CompositeFieldSpec.format}.
|
|
* - All other field types pass the raw value through.
|
|
*/
|
|
export function formatRigValue(fieldId: string, raw: string): string {
|
|
const field = RIG_FIELDS.find((f) => f.id === fieldId);
|
|
if (!field) return raw;
|
|
|
|
if (field.type === "gpu") return formatGpuValue(raw);
|
|
|
|
if (field.type === "dropdown_with_version") {
|
|
const [value = "", version = ""] = raw.split("|");
|
|
const trimmedVersion = version.trim();
|
|
if (!value && !trimmedVersion) return "";
|
|
|
|
let label = "";
|
|
if (value) {
|
|
const option = field.options?.find((o) => o.value === value);
|
|
label = option?.label ?? value;
|
|
}
|
|
|
|
if (!label) return trimmedVersion;
|
|
return trimmedVersion ? `${label} ${trimmedVersion}` : label;
|
|
}
|
|
|
|
if (field.type === "composite_dropdown" && field.composite) {
|
|
const { parts, isLegacy } = parseCompositeValue(raw);
|
|
if (isLegacy) return raw;
|
|
if (parts.length === 0) return "";
|
|
|
|
// Walk parts in order so each resolver sees the previously-stored
|
|
// values; hidden parts contribute nothing; `custom:<text>` collapses to
|
|
// the text (plus the part's unit).
|
|
const previousStored: string[] = [];
|
|
const resolved = field.composite.parts.map((spec, i) => {
|
|
const stored = (parts[i] ?? "").trim();
|
|
if (!stored || spec.hiddenWhen?.(previousStored)) {
|
|
previousStored.push("");
|
|
return "";
|
|
}
|
|
if (spec.allowCustom && stored.startsWith("custom:")) {
|
|
const txt = stored.slice("custom:".length).trim();
|
|
previousStored.push(stored);
|
|
return txt ? withSuffix(txt, spec.customSuffix ?? "") : "";
|
|
}
|
|
const opts = resolveCompositeOptions(spec.options, previousStored);
|
|
const opt = opts.find((o) => o.value === stored);
|
|
previousStored.push(stored);
|
|
return opt?.label ?? stored;
|
|
});
|
|
|
|
return field.composite.format(resolved);
|
|
}
|
|
|
|
return raw;
|
|
}
|