Merge pull request #116 from poli0981/claude/xenodochial-goldstine-599ba3
feat: Playtest section + invalid-number validation (v0.30.0)
This commit is contained in:
36 files changed
+853
-17
No files matched your search
@@ -2,6 +2,23 @@
|
||||
|
||||
All notable changes to YTDescGen ship as tagged releases on `main`.
|
||||
|
||||
## v0.30.0 — 2026-06-27
|
||||
|
||||
A **feature** release adding two things creators kept doing by hand: advertising a
|
||||
game's **playtest / early-access signup**, and getting **stopped before a bad number**
|
||||
breaks a batch.
|
||||
|
||||
### Added
|
||||
|
||||
- **Playtest section** ([src/components/editor/PlaytestEditor.tsx](src/components/editor/PlaytestEditor.tsx), [src/config/playtest-platforms.ts](src/config/playtest-platforms.ts)) — a new entry in the **Store & Social** group: a signup link, a platform dropdown (Steam Playtest, Epic, itch.io, Discord / Community, Other), and an invite count. The invite input maxes out at the selected platform's cap (≤ 100); switching to a lower-cap platform clamps an over-budget count down. It renders into the description **only when a link is entered** — no toggle, no video-type gating — exactly like Store Links. The description block ([src/engine/description-builder.ts](src/engine/description-builder.ts)) is a localized `🧪 PLAYTEST / EARLY ACCESS` heading, the platform-labelled link, and an optional `🎟️ N invites available` line (emitted only for a positive whole number, so a stray decimal / negative can never produce a broken line).
|
||||
- **Invalid-number guarding** ([src/utils/validation.ts](src/utils/validation.ts)) — two pure validators (`validateIntegerInRange`, `validateBatchRange`) now reject negative, decimal, out-of-range, and `end < start` / over-100-span inputs. The **Batch** ([src/pages/BatchPage.tsx](src/pages/BatchPage.tsx)) and **Social bulk** ([src/pages/SocialPage.tsx](src/pages/SocialPage.tsx)) part-range inputs **disable the Generate button** and show a warning when the range is invalid; **Playlist** "Total videos" ([src/pages/PlaylistPage.tsx](src/pages/PlaylistPage.tsx)) and the new Playtest invite count warn inline and guard the output. The `Input` primitive ([src/components/ui/Input.tsx](src/components/ui/Input.tsx)) gained optional `errorText` / `helpText` props (backward-compatible).
|
||||
|
||||
### Under the hood
|
||||
|
||||
- Three editor fields (`playtestLink`, `playtestPlatform`, `playtestInvites`) thread through the store (persist **v14 → v15** migration: unknown platform → default, invite count clamped to an integer in `[0, 100]`), `GeneratorInput`, and the editor → engine mapping — guarded by the existing parity test.
|
||||
- 60 new i18n strings across all six locales (validator **948 ui / 544 templates**). typecheck, lint, locale validation, and **544 tests** (517 + 27: playtest block, validators, v15 migration, mapping parity) pass; verified live — the block renders and localizes (EN / JA), the itch.io cap clamps invites 80 → 50, decimals warn, and Batch generation blocks on `end < start` and over-100 ranges.
|
||||
- Five manifests bumped 0.29.3 → 0.30.0.
|
||||
|
||||
## v0.29.3 — 2026-06-20
|
||||
|
||||
A follow-up **hotfix** to v0.29.2. Forwarding the always-English `tEn` translator
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "yt-desc-gen",
|
||||
"version": "0.29.3",
|
||||
"version": "0.30.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "yt-desc-gen",
|
||||
"version": "0.29.3",
|
||||
"version": "0.30.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.11.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yt-desc-gen",
|
||||
"version": "0.29.3",
|
||||
"version": "0.30.0",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
|
||||
Generated
+1
-1
@@ -5535,7 +5535,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "yt-desc-gen"
|
||||
version = "0.29.3"
|
||||
version = "0.30.0"
|
||||
dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "yt-desc-gen"
|
||||
version = "0.29.3"
|
||||
version = "0.30.0"
|
||||
description = "YouTube Gameplay Description Generator"
|
||||
authors = ["poli0981"]
|
||||
edition = "2021"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
|
||||
"productName": "YTDescGen",
|
||||
"version": "0.29.3",
|
||||
"version": "0.30.0",
|
||||
"identifier": "com.skullmute.ytdescgen",
|
||||
"build": {
|
||||
"beforeBuildCommand": "npm run build",
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ValidatedInput } from "@components/ui/ValidatedInput";
|
||||
import { Input } from "@components/ui/Input";
|
||||
import { Select } from "@components/ui/Select";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import {
|
||||
validateUrl,
|
||||
validateUrlWithPattern,
|
||||
validateIntegerInRange,
|
||||
} from "@utils/validation";
|
||||
import {
|
||||
PLAYTEST_PLATFORMS,
|
||||
maxInvitesForPlatform,
|
||||
} from "@config/playtest-platforms";
|
||||
|
||||
/**
|
||||
* Playtest section (v0.30.0). One signup link + the platform it lives on +
|
||||
* an optional invite count. Mirrors {@link StoreLinkEditor} but is a single
|
||||
* entry rather than one-per-platform. The invite-count input maxes out at
|
||||
* the selected platform's cap (≤100); switching to a lower-cap platform
|
||||
* clamps an over-budget count down. Renders into the description only when
|
||||
* a link is entered — no settings toggle gates it.
|
||||
*/
|
||||
export function PlaytestEditor() {
|
||||
const { t } = useTranslation("ui");
|
||||
const playtestLink = useEditorStore((s) => s.playtestLink);
|
||||
const playtestPlatform = useEditorStore((s) => s.playtestPlatform);
|
||||
const playtestInvites = useEditorStore((s) => s.playtestInvites);
|
||||
const setField = useEditorStore((s) => s.set);
|
||||
|
||||
const platform =
|
||||
PLAYTEST_PLATFORMS.find((p) => p.id === playtestPlatform) ?? PLAYTEST_PLATFORMS[0];
|
||||
const cap = maxInvitesForPlatform(playtestPlatform);
|
||||
|
||||
const platformOptions = PLAYTEST_PLATFORMS.map((p) => ({
|
||||
value: p.id,
|
||||
label: p.label,
|
||||
}));
|
||||
|
||||
// The store holds the invite count as a number; the input edits raw text
|
||||
// so a mid-edit "2.5" / "-1" can show a warning without snapping back.
|
||||
// Invalid text is NOT committed, so the description stays clean.
|
||||
const [invitesText, setInvitesText] = useState(
|
||||
playtestInvites > 0 ? String(playtestInvites) : "",
|
||||
);
|
||||
|
||||
// Resync the text when the store value changes from outside this input
|
||||
// (platform clamp, profile / preset load, draft reset). Only fires on a
|
||||
// real store change, so it never clobbers an in-progress invalid edit.
|
||||
useEffect(() => {
|
||||
const current = invitesText.trim() === "" ? 0 : Number(invitesText);
|
||||
if (current !== playtestInvites) {
|
||||
setInvitesText(playtestInvites > 0 ? String(playtestInvites) : "");
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [playtestInvites]);
|
||||
|
||||
const handlePlatformChange = (id: string) => {
|
||||
setField("playtestPlatform", id);
|
||||
const newCap = maxInvitesForPlatform(id);
|
||||
if (playtestInvites > newCap) {
|
||||
setField("playtestInvites", newCap);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInvitesChange = (raw: string) => {
|
||||
setInvitesText(raw);
|
||||
const result = validateIntegerInRange(raw, { min: 1, max: cap, allowEmpty: true });
|
||||
if (result.valid) {
|
||||
setField("playtestInvites", raw.trim() === "" ? 0 : Number(raw));
|
||||
}
|
||||
};
|
||||
|
||||
const invitesValidation = validateIntegerInRange(invitesText, {
|
||||
min: 1,
|
||||
max: cap,
|
||||
allowEmpty: true,
|
||||
});
|
||||
const invitesError = invitesValidation.valid
|
||||
? undefined
|
||||
: t(invitesValidation.error ?? "", invitesValidation.errorParams);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<span className="text-sm font-medium text-text-secondary">
|
||||
{t("editor.playtest.heading")}
|
||||
</span>
|
||||
|
||||
<ValidatedInput
|
||||
label={t("editor.playtest.linkLabel")}
|
||||
placeholder={platform?.urlPrefix ?? "https://"}
|
||||
value={playtestLink}
|
||||
onChange={(v) => setField("playtestLink", v)}
|
||||
validate={(v) =>
|
||||
platform ? validateUrlWithPattern(v, platform.urlPattern) : validateUrl(v)
|
||||
}
|
||||
inputMode="url"
|
||||
autoComplete="off"
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-[1fr_9rem] items-start gap-2">
|
||||
<Select
|
||||
label={t("editor.playtest.platformLabel")}
|
||||
value={playtestPlatform}
|
||||
options={platformOptions}
|
||||
onChange={handlePlatformChange}
|
||||
/>
|
||||
<Input
|
||||
label={t("editor.playtest.invitesLabel", { max: cap })}
|
||||
type="number"
|
||||
min={1}
|
||||
max={cap}
|
||||
step={1}
|
||||
inputMode="numeric"
|
||||
value={invitesText}
|
||||
onChange={(e) => handleInvitesChange(e.target.value)}
|
||||
errorText={invitesError}
|
||||
helpText={t("editor.playtest.invitesHelp", { max: cap })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,11 +4,16 @@ import clsx from "clsx";
|
||||
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||
label?: string;
|
||||
error?: boolean;
|
||||
/** Inline error message shown below the input (also forces the red border). */
|
||||
errorText?: string;
|
||||
/** Inline hint shown below the input when there is no error. */
|
||||
helpText?: string;
|
||||
}
|
||||
|
||||
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
({ label, error, className, id, ...props }, ref) => {
|
||||
({ label, error, errorText, helpText, className, id, ...props }, ref) => {
|
||||
const inputId = id ?? label?.toLowerCase().replace(/\s+/g, "-");
|
||||
const isError = error || Boolean(errorText);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
@@ -20,13 +25,16 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
<input
|
||||
ref={ref}
|
||||
id={inputId}
|
||||
aria-invalid={isError || undefined}
|
||||
className={clsx(
|
||||
"min-h-touch rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary placeholder:text-text-muted transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 sm:text-sm",
|
||||
error ? "border-danger" : "border-border focus:border-accent",
|
||||
isError ? "border-danger" : "border-border focus:border-accent",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
{errorText && <p className="text-xs text-danger">{errorText}</p>}
|
||||
{helpText && !errorText && <p className="text-xs text-text-muted">{helpText}</p>}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
} from "./graphics-settings";
|
||||
import type { VideoStyleEra } from "./video-styles";
|
||||
import { DEFAULT_GACHA_QUEST_TYPE, type GachaQuestType } from "./gacha-quest-types";
|
||||
import { DEFAULT_PLAYTEST_PLATFORM } from "./playtest-platforms";
|
||||
import type {
|
||||
SupportedLanguage,
|
||||
StoreLinkType,
|
||||
@@ -131,6 +132,12 @@ export interface EditorDefaults {
|
||||
vnBankHolder: string;
|
||||
vnMomo: string;
|
||||
vnZalopay: string;
|
||||
/** Playtest signup link (v0.30.0). Empty string = no playtest block. */
|
||||
playtestLink: string;
|
||||
/** Playtest platform id (see `@config/playtest-platforms`). */
|
||||
playtestPlatform: string;
|
||||
/** Playtest invites available, 0..platform max (≤100). 0 = unset. */
|
||||
playtestInvites: number;
|
||||
}
|
||||
|
||||
export interface SettingsDefaults {
|
||||
@@ -208,6 +215,9 @@ export const DEFAULTS = {
|
||||
vnBankHolder: "",
|
||||
vnMomo: "",
|
||||
vnZalopay: "",
|
||||
playtestLink: "",
|
||||
playtestPlatform: DEFAULT_PLAYTEST_PLATFORM,
|
||||
playtestInvites: 0,
|
||||
} satisfies EditorDefaults,
|
||||
|
||||
settings: {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Playtest platform catalogue (v0.30.0).
|
||||
*
|
||||
* Drives the editor's Playtest section: the creator picks ONE platform
|
||||
* their playtest signup lives on, pastes the link, and optionally records
|
||||
* how many invites they have to give away. Mirrors the {@link PlatformConfig}
|
||||
* shape from `@config/platforms` (id / label / urlPrefix / urlPattern) and
|
||||
* adds a per-platform `maxInvites`.
|
||||
*
|
||||
* Why per-platform caps: a playtest's invite budget varies by storefront
|
||||
* (Steam Playtest grants, itch.io download keys, Discord closed-beta seats…),
|
||||
* so the editor's invite-count input maxes out at the selected platform's
|
||||
* cap rather than one flat number. The absolute ceiling is
|
||||
* {@link PLAYTEST_MAX_INVITES_CAP} (100) — no platform may exceed it.
|
||||
*
|
||||
* The `maxInvites` numbers below are sensible starting points, NOT hard
|
||||
* facts — they're plain constants and meant to be tuned freely.
|
||||
*/
|
||||
|
||||
/** Absolute hard cap on playtest invites, regardless of platform. */
|
||||
export const PLAYTEST_MAX_INVITES_CAP = 100;
|
||||
|
||||
export interface PlaytestPlatformConfig {
|
||||
readonly id: string;
|
||||
readonly label: string;
|
||||
/** Shown as the link input's placeholder / hint. */
|
||||
readonly urlPrefix: string;
|
||||
/** Authoritative validator. Must match the entire trimmed URL. */
|
||||
readonly urlPattern: RegExp;
|
||||
/** Per-platform invite ceiling. Always ≤ {@link PLAYTEST_MAX_INVITES_CAP}. */
|
||||
readonly maxInvites: number;
|
||||
}
|
||||
|
||||
export const PLAYTEST_PLATFORMS: readonly PlaytestPlatformConfig[] = [
|
||||
{
|
||||
id: "steam",
|
||||
label: "Steam Playtest",
|
||||
urlPrefix: "https://store.steampowered.com/app/",
|
||||
urlPattern: /^https:\/\/store\.steampowered\.com\/app\/\d+(?:\/[^\s]*)?$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
{
|
||||
id: "epic",
|
||||
label: "Epic Games Store",
|
||||
urlPrefix: "https://store.epicgames.com/",
|
||||
urlPattern: /^https:\/\/store\.epicgames\.com\/[^\s]+$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
{
|
||||
id: "itchio",
|
||||
label: "itch.io",
|
||||
urlPrefix: "https://<dev>.itch.io/<game>",
|
||||
urlPattern:
|
||||
/^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
|
||||
maxInvites: 50,
|
||||
},
|
||||
{
|
||||
id: "discord",
|
||||
label: "Discord / Community",
|
||||
urlPrefix: "https://discord.gg/",
|
||||
urlPattern: /^https:\/\/(?:discord\.gg|discord\.com\/invite)\/[^\s]+$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
{
|
||||
// Catch-all for signup forms, publisher beta pages, Google Forms, etc.
|
||||
// Pattern is intentionally loose (any HTTPS URL with a host).
|
||||
id: "other",
|
||||
label: "Other / Signup form",
|
||||
urlPrefix: "https://",
|
||||
urlPattern: /^https:\/\/[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+(?:\/[^\s]*)?$/i,
|
||||
maxInvites: 100,
|
||||
},
|
||||
] as const;
|
||||
|
||||
/** Default platform id used by a fresh draft / migration back-fill. */
|
||||
export const DEFAULT_PLAYTEST_PLATFORM = PLAYTEST_PLATFORMS[0]?.id ?? "steam";
|
||||
|
||||
/**
|
||||
* Invite ceiling for a platform id, capped at the absolute maximum.
|
||||
* Unknown ids (e.g. a hand-edited blob) fall back to the absolute cap.
|
||||
*/
|
||||
export function maxInvitesForPlatform(id: string): number {
|
||||
const found = PLAYTEST_PLATFORMS.find((p) => p.id === id);
|
||||
return Math.min(found?.maxInvites ?? PLAYTEST_MAX_INVITES_CAP, PLAYTEST_MAX_INVITES_CAP);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { GeneratorInput, TranslationFn, CharLimitWarning } from "./types";
|
||||
import { YT_LIMITS } from "./types";
|
||||
import { PLATFORMS } from "@config/platforms";
|
||||
import { PLAYTEST_PLATFORMS } from "@config/playtest-platforms";
|
||||
import { SOCIAL_FIELDS } from "@config/social-fields";
|
||||
import { formatRigValue } from "@config/rig-fields";
|
||||
import { DEFAULT_GACHA_QUEST_TYPE } from "@config/gacha-quest-types";
|
||||
@@ -414,6 +415,29 @@ export function buildDescription(
|
||||
);
|
||||
}
|
||||
|
||||
// 4.7 Playtest / early access — opt-in access block (v0.30.0). Always
|
||||
// available in the editor; renders only when a link is entered, so
|
||||
// it follows the Store Links convention (localized heading + plain
|
||||
// link line, NOT bilingual). The platform label prefixes the link;
|
||||
// the optional invites line is gated on a positive integer so a
|
||||
// stray decimal / negative that slipped past the editor can never
|
||||
// produce a broken line.
|
||||
if (input.playtestLink && input.playtestLink.trim()) {
|
||||
const link = input.playtestLink.trim();
|
||||
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) }),
|
||||
);
|
||||
}
|
||||
sections.push(`${t("description.sections.playtest")}\n${lines.join("\n")}`);
|
||||
}
|
||||
|
||||
// 5. Video Settings — skipped entirely for 2D / pixel-art / no-in-game-
|
||||
// settings games (the user toggles that explicitly; v0.8 phase 2 also
|
||||
// auto-suggests it on certain genres but the toggle is the source of
|
||||
|
||||
@@ -821,6 +821,18 @@ export interface GeneratorInput {
|
||||
vnBankHolder?: string;
|
||||
vnMomo?: string;
|
||||
vnZalopay?: string;
|
||||
/**
|
||||
* Playtest access (v0.30.0). When {@link playtestLink} is non-empty the
|
||||
* description emits a "🧪 PLAYTEST / EARLY ACCESS" block: a heading, the
|
||||
* link prefixed by the platform label, and an optional
|
||||
* "N invites available" line. {@link playtestPlatform} is a config id
|
||||
* (see `@config/playtest-platforms`); {@link playtestInvites} is
|
||||
* 0..100 (0 = unset → no count line). Always rendered when filled, like
|
||||
* store links — no settings toggle gates it.
|
||||
*/
|
||||
playtestLink?: string;
|
||||
playtestPlatform?: string;
|
||||
playtestInvites?: number;
|
||||
}
|
||||
|
||||
export interface GeneratorOutput {
|
||||
|
||||
@@ -94,6 +94,9 @@ export function buildGeneratorInputFromEditor(
|
||||
vnBankHolder: state.vnBankHolder,
|
||||
vnMomo: state.vnMomo,
|
||||
vnZalopay: state.vnZalopay,
|
||||
playtestLink: state.playtestLink,
|
||||
playtestPlatform: state.playtestPlatform,
|
||||
playtestInvites: state.playtestInvites,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
"gpuMissingSeries", "gpuMissingModel", "gpuCustomEmpty",
|
||||
"ramMissingDdr", "ramMissingSize", "ramCustomEmpty"
|
||||
],
|
||||
"editor.playtest": ["heading", "linkLabel", "platformLabel", "invitesLabel", "invitesHelp"],
|
||||
"editor.playthroughOptions": ["none", "blind", "replay", "newgame_plus", "postgame"],
|
||||
"editor.difficultyOptions": ["none", "easy", "normal", "hard", "nightmare", "custom"],
|
||||
"editor.playthroughNotes": [
|
||||
@@ -186,7 +187,7 @@
|
||||
"socialPost": ["title", "single", "bulk", "copyCaption", "emptyState", "trimmedHint", "overLimitHint", "exported", "exportFailed", "imported", "importFailed", "importedHeading"],
|
||||
"socialPost.platforms": ["tiktok", "instagram_reels", "facebook_reels"],
|
||||
"shortcuts": ["title", "generate", "copyAll", "saveDraft", "toggleSidebar", "help", "close", "searchPlaceholder", "noResults"],
|
||||
"validation": ["emailInvalid", "emailMaxExceeded", "urlInvalid", "urlPrefixMismatch", "playlistUrlInvalid"],
|
||||
"validation": ["emailInvalid", "emailMaxExceeded", "urlInvalid", "urlPrefixMismatch", "playlistUrlInvalid", "numberRequired", "numberInvalid", "numberNotInteger", "numberOutOfRange", "rangeEndBeforeStart", "rangeTooLarge"],
|
||||
"logs": ["title", "emptyState", "clearAll", "clearConfirm", "clearPersistedConfirm", "clearSession", "searchPlaceholder", "exportJson", "exportTxt", "sessionCurrent", "sessionLabel", "entriesShort"],
|
||||
"playlist": ["title", "status", "contentType", "totalVideos", "customNote", "generatePlaylist"]
|
||||
},
|
||||
@@ -214,7 +215,7 @@
|
||||
],
|
||||
"description": ["noCommentaryLine"],
|
||||
"description.sections": [
|
||||
"timestamps", "storeLinksBuy", "storeLinksDownload", "gameCopyright", "videoSettings", "rig",
|
||||
"timestamps", "storeLinksBuy", "storeLinksDownload", "gameCopyright", "playtest", "playtestInvites", "videoSettings", "rig",
|
||||
"modList", "vnDonate",
|
||||
"sponsorCredit", "thirdPartyAds", "music", "donate", "social",
|
||||
"playlist", "contact", "cta",
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
"demo": "free demo"
|
||||
},
|
||||
"sections": {
|
||||
"playtest": "🧪 PLAYTEST / EARLY ACCESS",
|
||||
"playtestInvites": "🎟️ {{count}} invites available — first come, first served",
|
||||
"timestamps": "⏱ TIMESTAMPS",
|
||||
"storeLinksBuy": "🎮 GET THE GAME (if you want to buy)",
|
||||
"storeLinksDownload": "⬇️ DOWNLOAD THE GAME (if you want to play)",
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"playtest": {
|
||||
"heading": "Playtest",
|
||||
"linkLabel": "Playtest link",
|
||||
"platformLabel": "Platform",
|
||||
"invitesLabel": "Invitations (max {{max}})",
|
||||
"invitesHelp": "How many playtest invites you have to give away (1–{{max}})."
|
||||
},
|
||||
"sections": {
|
||||
"gameInfo": "Game Info",
|
||||
"videoSettings": "Video Settings",
|
||||
@@ -1047,6 +1054,12 @@
|
||||
"noResults": "No matching shortcuts"
|
||||
},
|
||||
"validation": {
|
||||
"numberRequired": "Enter a number.",
|
||||
"numberInvalid": "Enter a valid number.",
|
||||
"numberNotInteger": "Enter a whole number (no decimals).",
|
||||
"numberOutOfRange": "Enter a number between {{min}} and {{max}}.",
|
||||
"rangeEndBeforeStart": "End part ({{end}}) must be ≥ start part ({{start}}).",
|
||||
"rangeTooLarge": "Range too large — generate at most {{maxSpan}} parts at once.",
|
||||
"emailInvalid": "Invalid email: {{email}}",
|
||||
"emailMaxExceeded": "Maximum {{max}} emails allowed (currently {{count}})",
|
||||
"urlInvalid": "Invalid URL. Must start with https://",
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
"demo": "demo gratis"
|
||||
},
|
||||
"sections": {
|
||||
"playtest": "🧪 PLAYTEST / ACCESO ANTICIPADO",
|
||||
"playtestInvites": "🎟️ {{count}} invitaciones disponibles — por orden de llegada",
|
||||
"timestamps": "⏱ MARCAS DE TIEMPO",
|
||||
"storeLinksBuy": "🎮 CONSIGUE EL JUEGO (si quieres comprarlo)",
|
||||
"storeLinksDownload": "⬇️ DESCARGA EL JUEGO (si quieres jugar)",
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"playtest": {
|
||||
"heading": "Playtest",
|
||||
"linkLabel": "Enlace de playtest",
|
||||
"platformLabel": "Plataforma",
|
||||
"invitesLabel": "Invitaciones (máx. {{max}})",
|
||||
"invitesHelp": "Cuántas invitaciones de playtest tienes para repartir (1–{{max}})."
|
||||
},
|
||||
"sections": {
|
||||
"gameInfo": "Info del Juego",
|
||||
"videoSettings": "Ajustes de Video",
|
||||
@@ -1047,6 +1054,12 @@
|
||||
"noResults": "No se encontraron atajos"
|
||||
},
|
||||
"validation": {
|
||||
"numberRequired": "Introduce un número.",
|
||||
"numberInvalid": "Introduce un número válido.",
|
||||
"numberNotInteger": "Introduce un número entero (sin decimales).",
|
||||
"numberOutOfRange": "Introduce un número entre {{min}} y {{max}}.",
|
||||
"rangeEndBeforeStart": "La parte final ({{end}}) debe ser ≥ la parte inicial ({{start}}).",
|
||||
"rangeTooLarge": "Rango demasiado grande: genera como máximo {{maxSpan}} partes a la vez.",
|
||||
"emailInvalid": "Email inválido: {{email}}",
|
||||
"emailMaxExceeded": "Máximo {{max}} emails permitidos (actualmente {{count}})",
|
||||
"urlInvalid": "URL inválida. Debe comenzar con https://",
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
"demo": "無料体験版"
|
||||
},
|
||||
"sections": {
|
||||
"playtest": "🧪 プレイテスト / 早期アクセス",
|
||||
"playtestInvites": "🎟️ 招待枠 残り {{count}} 件 — 先着順",
|
||||
"timestamps": "⏱ タイムスタンプ",
|
||||
"storeLinksBuy": "🎮 ゲームを購入 (応援したい方へ)",
|
||||
"storeLinksDownload": "⬇️ ゲームをダウンロード (遊びたい方へ)",
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"playtest": {
|
||||
"heading": "プレイテスト",
|
||||
"linkLabel": "プレイテストのリンク",
|
||||
"platformLabel": "プラットフォーム",
|
||||
"invitesLabel": "招待枠(最大 {{max}})",
|
||||
"invitesHelp": "配布できるプレイテスト招待の数(1〜{{max}})。"
|
||||
},
|
||||
"sections": {
|
||||
"gameInfo": "ゲーム情報",
|
||||
"videoSettings": "動画設定",
|
||||
@@ -1047,6 +1054,12 @@
|
||||
"noResults": "該当するショートカットはありません"
|
||||
},
|
||||
"validation": {
|
||||
"numberRequired": "数値を入力してください。",
|
||||
"numberInvalid": "正しい数値を入力してください。",
|
||||
"numberNotInteger": "整数を入力してください(小数は不可)。",
|
||||
"numberOutOfRange": "{{min}}〜{{max}}の数値を入力してください。",
|
||||
"rangeEndBeforeStart": "終了パート({{end}})は開始パート({{start}})以上にしてください。",
|
||||
"rangeTooLarge": "範囲が大きすぎます — 一度に生成できるのは最大{{maxSpan}}パートまでです。",
|
||||
"emailInvalid": "無効なメール: {{email}}",
|
||||
"emailMaxExceeded": "最大{{max}}件のメール (現在{{count}}件)",
|
||||
"urlInvalid": "無効なURL。https://で始める必要があります",
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
"demo": "무료 데모"
|
||||
},
|
||||
"sections": {
|
||||
"playtest": "🧪 플레이테스트 / 앞서 해보기",
|
||||
"playtestInvites": "🎟️ 초대 {{count}}개 남음 — 선착순",
|
||||
"timestamps": "⏱ 타임스탬프",
|
||||
"storeLinksBuy": "🎮 게임 구매 (구매하고 싶다면)",
|
||||
"storeLinksDownload": "⬇️ 게임 다운로드 (플레이하고 싶다면)",
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"playtest": {
|
||||
"heading": "플레이테스트",
|
||||
"linkLabel": "플레이테스트 링크",
|
||||
"platformLabel": "플랫폼",
|
||||
"invitesLabel": "초대 수 (최대 {{max}})",
|
||||
"invitesHelp": "나눠줄 수 있는 플레이테스트 초대 수 (1–{{max}})."
|
||||
},
|
||||
"sections": {
|
||||
"gameInfo": "게임 정보",
|
||||
"videoSettings": "비디오 설정",
|
||||
@@ -1047,6 +1054,12 @@
|
||||
"noResults": "일치하는 단축키 없음"
|
||||
},
|
||||
"validation": {
|
||||
"numberRequired": "숫자를 입력하세요.",
|
||||
"numberInvalid": "올바른 숫자를 입력하세요.",
|
||||
"numberNotInteger": "정수를 입력하세요 (소수 불가).",
|
||||
"numberOutOfRange": "{{min}}에서 {{max}} 사이의 숫자를 입력하세요.",
|
||||
"rangeEndBeforeStart": "끝 파트({{end}})는 시작 파트({{start}}) 이상이어야 합니다.",
|
||||
"rangeTooLarge": "범위가 너무 큽니다 — 한 번에 최대 {{maxSpan}}개 파트까지 생성할 수 있습니다.",
|
||||
"emailInvalid": "잘못된 이메일: {{email}}",
|
||||
"emailMaxExceeded": "최대 {{max}}개 이메일 허용 (현재 {{count}}개)",
|
||||
"urlInvalid": "잘못된 URL입니다. https://로 시작해야 합니다",
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
"demo": "demo miễn phí"
|
||||
},
|
||||
"sections": {
|
||||
"playtest": "🧪 PLAYTEST / TRẢI NGHIỆM SỚM",
|
||||
"playtestInvites": "🎟️ Còn {{count}} lời mời — ai nhanh tay người đó được",
|
||||
"timestamps": "⏱ MỐC THỜI GIAN",
|
||||
"storeLinksBuy": "🎮 MUA GAME (nếu bạn muốn ủng hộ)",
|
||||
"storeLinksDownload": "⬇️ TẢI GAME (nếu bạn muốn chơi)",
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"playtest": {
|
||||
"heading": "Playtest",
|
||||
"linkLabel": "Link playtest",
|
||||
"platformLabel": "Nền tảng",
|
||||
"invitesLabel": "Số lời mời (tối đa {{max}})",
|
||||
"invitesHelp": "Bạn có bao nhiêu lời mời playtest để tặng (1–{{max}})."
|
||||
},
|
||||
"sections": {
|
||||
"gameInfo": "Thông tin game",
|
||||
"videoSettings": "Cài đặt video",
|
||||
@@ -1047,6 +1054,12 @@
|
||||
"noResults": "Không có phím tắt phù hợp"
|
||||
},
|
||||
"validation": {
|
||||
"numberRequired": "Hãy nhập một số.",
|
||||
"numberInvalid": "Hãy nhập một số hợp lệ.",
|
||||
"numberNotInteger": "Hãy nhập số nguyên (không có số thập phân).",
|
||||
"numberOutOfRange": "Hãy nhập số trong khoảng {{min}} đến {{max}}.",
|
||||
"rangeEndBeforeStart": "Phần cuối ({{end}}) phải ≥ phần đầu ({{start}}).",
|
||||
"rangeTooLarge": "Khoảng quá lớn — chỉ tạo tối đa {{maxSpan}} phần mỗi lần.",
|
||||
"emailInvalid": "Email không hợp lệ: {{email}}",
|
||||
"emailMaxExceeded": "Tối đa {{max}} email (hiện tại {{count}})",
|
||||
"urlInvalid": "URL không hợp lệ. Phải bắt đầu bằng https://",
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
"demo": "免费试玩"
|
||||
},
|
||||
"sections": {
|
||||
"playtest": "🧪 试玩测试 / 抢先体验",
|
||||
"playtestInvites": "🎟️ 剩余 {{count}} 个名额 — 先到先得",
|
||||
"timestamps": "⏱ 时间戳",
|
||||
"storeLinksBuy": "🎮 获取游戏 (如果你想购买)",
|
||||
"storeLinksDownload": "⬇️ 下载游戏 (如果你想游玩)",
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"playtest": {
|
||||
"heading": "试玩测试",
|
||||
"linkLabel": "试玩测试链接",
|
||||
"platformLabel": "平台",
|
||||
"invitesLabel": "邀请数量(最多 {{max}})",
|
||||
"invitesHelp": "你有多少个试玩测试邀请可以送出(1–{{max}})。"
|
||||
},
|
||||
"sections": {
|
||||
"gameInfo": "游戏信息",
|
||||
"videoSettings": "视频设置",
|
||||
@@ -1047,6 +1054,12 @@
|
||||
"noResults": "未找到快捷键"
|
||||
},
|
||||
"validation": {
|
||||
"numberRequired": "请输入一个数字。",
|
||||
"numberInvalid": "请输入有效的数字。",
|
||||
"numberNotInteger": "请输入整数(不能有小数)。",
|
||||
"numberOutOfRange": "请输入 {{min}} 到 {{max}} 之间的数字。",
|
||||
"rangeEndBeforeStart": "结束分集({{end}})必须 ≥ 起始分集({{start}})。",
|
||||
"rangeTooLarge": "范围太大 — 每次最多生成 {{maxSpan}} 个分集。",
|
||||
"emailInvalid": "无效邮箱: {{email}}",
|
||||
"emailMaxExceeded": "最多允许{{max}}个邮箱 (当前{{count}}个)",
|
||||
"urlInvalid": "无效URL。必须以https://开头",
|
||||
|
||||
+30
-2
@@ -14,6 +14,7 @@ import { buildPinnedComment } from "@engine/pinned-comment-builder";
|
||||
import { YT_LIMITS } from "@engine/types";
|
||||
import type { GeneratorOutput, SupportedLanguage } from "@engine/types";
|
||||
import { useCurrentGeneratorInput } from "@hooks/use-current-generator-input";
|
||||
import { validateBatchRange } from "@utils/validation";
|
||||
import clsx from "clsx";
|
||||
|
||||
interface BatchLanguageRow {
|
||||
@@ -53,6 +54,16 @@ export function BatchPage() {
|
||||
const [results, setResults] = useState<BatchResult[]>([]);
|
||||
const [generating, setGenerating] = useState(false);
|
||||
|
||||
// Block generation on an invalid part range: negative / decimal / NaN
|
||||
// endpoints, end < start, or a span over 100 parts (the loop's hard cap).
|
||||
const rangeResult = useMemo(
|
||||
() => validateBatchRange(startPart, endPart, { maxSpan: 100 }),
|
||||
[startPart, endPart],
|
||||
);
|
||||
const rangeError = rangeResult.valid
|
||||
? undefined
|
||||
: t(rangeResult.error ?? "", rangeResult.errorParams);
|
||||
|
||||
const toggleLang = (lang: SupportedLanguage) => {
|
||||
setSelectedLangs((prev) => {
|
||||
if (prev.includes(lang)) {
|
||||
@@ -163,27 +174,44 @@ export function BatchPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:gap-4">
|
||||
<div className="mb-2 flex flex-col gap-3 sm:flex-row sm:items-end sm:gap-4">
|
||||
<Input
|
||||
label={t("batch.startPart")}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
inputMode="numeric"
|
||||
error={!rangeResult.valid}
|
||||
value={startPart}
|
||||
onChange={(e) => setStartPart(e.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("batch.endPart")}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
inputMode="numeric"
|
||||
error={!rangeResult.valid}
|
||||
value={endPart}
|
||||
onChange={(e) => setEndPart(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
className="w-full sm:w-auto"
|
||||
onClick={() => void handleGenerate()}
|
||||
disabled={!state.gameName || generating}
|
||||
disabled={!state.gameName || generating || !rangeResult.valid}
|
||||
>
|
||||
{t("batch.generateBatch")}
|
||||
</Button>
|
||||
</div>
|
||||
{rangeError && (
|
||||
<p
|
||||
role="alert"
|
||||
className="mb-6 rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning"
|
||||
>
|
||||
{rangeError}
|
||||
</p>
|
||||
)}
|
||||
{!rangeError && <div className="mb-6" />}
|
||||
|
||||
{results.length === 0 ? (
|
||||
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ExtraFieldsInput } from "@components/editor/ExtraFieldsInput";
|
||||
import { VideoSettingsForm } from "@components/editor/VideoSettingsForm";
|
||||
import { TimestampEditor } from "@components/editor/TimestampEditor";
|
||||
import { StoreLinkEditor } from "@components/editor/StoreLinkEditor";
|
||||
import { PlaytestEditor } from "@components/editor/PlaytestEditor";
|
||||
import { RigEditor } from "@components/editor/RigEditor";
|
||||
import { SocialEditor } from "@components/editor/SocialEditor";
|
||||
import { VietnameseDonateEditor } from "@components/editor/VietnameseDonateEditor";
|
||||
@@ -152,6 +153,7 @@ export function EditorPage() {
|
||||
onToggle={() => toggleAccordion("storeAndSocial")}
|
||||
>
|
||||
<StoreLinkEditor />
|
||||
<PlaytestEditor />
|
||||
<SocialEditor />
|
||||
<VietnameseDonateEditor />
|
||||
</Accordion>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ChipGroup } from "@components/ui/ChipGroup";
|
||||
import { Select } from "@components/ui/Select";
|
||||
import { CopyButton } from "@components/output/CopyButton";
|
||||
import { useEditorStore } from "@store/editor-store";
|
||||
import { validateIntegerInRange } from "@utils/validation";
|
||||
import { SUPPORTED_LANGUAGES } from "@i18n/index";
|
||||
import { useLanguagesReady } from "@hooks/use-languages-ready";
|
||||
import {
|
||||
@@ -54,17 +55,41 @@ export function PlaylistPage() {
|
||||
label: `${l.flag} ${l.nativeName}`,
|
||||
}));
|
||||
|
||||
// Guard the output: only forward a valid whole number in range so a
|
||||
// negative / decimal / out-of-range entry simply omits the count line
|
||||
// instead of producing a broken "X videos" string.
|
||||
const totalVideosValidation = validateIntegerInRange(totalVideos, {
|
||||
min: 1,
|
||||
max: 1000,
|
||||
allowEmpty: true,
|
||||
});
|
||||
const totalVideosError = totalVideosValidation.valid
|
||||
? undefined
|
||||
: t(totalVideosValidation.error ?? "", totalVideosValidation.errorParams);
|
||||
|
||||
const playlistInput: PlaylistInput = useMemo(
|
||||
() => ({
|
||||
gameName: editor.gameName,
|
||||
channelName: editor.channelName,
|
||||
status,
|
||||
contentType,
|
||||
totalVideos: totalVideos ? parseInt(totalVideos) : undefined,
|
||||
totalVideos:
|
||||
totalVideosValidation.valid && totalVideos.trim()
|
||||
? parseInt(totalVideos)
|
||||
: undefined,
|
||||
storeLinks: editor.storeLinks,
|
||||
playlistNote: customNote,
|
||||
}),
|
||||
[editor.gameName, editor.channelName, status, contentType, totalVideos, editor.storeLinks, customNote],
|
||||
[
|
||||
editor.gameName,
|
||||
editor.channelName,
|
||||
status,
|
||||
contentType,
|
||||
totalVideos,
|
||||
totalVideosValidation.valid,
|
||||
editor.storeLinks,
|
||||
customNote,
|
||||
],
|
||||
);
|
||||
|
||||
// Lazy-loaded locales (v0.26): the dropdown can pick a language whose
|
||||
@@ -110,8 +135,12 @@ export function PlaylistPage() {
|
||||
<Input
|
||||
label={t("playlist.totalVideos")}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
inputMode="numeric"
|
||||
placeholder="e.g. 25"
|
||||
value={totalVideos}
|
||||
errorText={totalVideosError}
|
||||
onChange={(e) => setTotalVideos(e.target.value)}
|
||||
/>
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
type SocialPostOutput,
|
||||
} from "@engine/social-post-builder";
|
||||
import { useCurrentGeneratorInput } from "@hooks/use-current-generator-input";
|
||||
import { validateBatchRange } from "@utils/validation";
|
||||
import {
|
||||
exportTypedToJsonFile,
|
||||
importTypedFromJsonFile,
|
||||
@@ -75,6 +76,15 @@ export function SocialPage() {
|
||||
const [bulkResults, setBulkResults] = useState<BulkRow[]>([]);
|
||||
const [generating, setGenerating] = useState(false);
|
||||
|
||||
// Block bulk generation on an invalid part range (mirrors BatchPage).
|
||||
const rangeResult = useMemo(
|
||||
() => validateBatchRange(startPart, endPart, { maxSpan: 100 }),
|
||||
[startPart, endPart],
|
||||
);
|
||||
const rangeError = rangeResult.valid
|
||||
? undefined
|
||||
: t(rangeResult.error ?? "", rangeResult.errorParams);
|
||||
|
||||
// Import display (read-only)
|
||||
const [imported, setImported] = useState<SocialExportBundle | null>(null);
|
||||
|
||||
@@ -380,22 +390,38 @@ export function SocialPage() {
|
||||
<Input
|
||||
label={t("batch.startPart")}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
inputMode="numeric"
|
||||
error={!rangeResult.valid}
|
||||
value={startPart}
|
||||
onChange={(e) => setStartPart(e.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("batch.endPart")}
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
inputMode="numeric"
|
||||
error={!rangeResult.valid}
|
||||
value={endPart}
|
||||
onChange={(e) => setEndPart(e.target.value)}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => void handleBulkGenerate()}
|
||||
disabled={!gameName || generating}
|
||||
disabled={!gameName || generating || !rangeResult.valid}
|
||||
>
|
||||
{t("common.generate")}
|
||||
</Button>
|
||||
</div>
|
||||
{rangeError && (
|
||||
<p
|
||||
role="alert"
|
||||
className="rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning"
|
||||
>
|
||||
{rangeError}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{bulkResults.length === 0 ? (
|
||||
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
|
||||
|
||||
@@ -38,6 +38,11 @@ import {
|
||||
DEFAULT_GACHA_QUEST_TYPE,
|
||||
type GachaQuestType,
|
||||
} from "@config/gacha-quest-types";
|
||||
import {
|
||||
PLAYTEST_PLATFORMS,
|
||||
PLAYTEST_MAX_INVITES_CAP,
|
||||
DEFAULT_PLAYTEST_PLATFORM,
|
||||
} from "@config/playtest-platforms";
|
||||
import { DEFAULTS } from "@config/defaults";
|
||||
|
||||
export interface EditorData {
|
||||
@@ -168,6 +173,12 @@ export interface EditorData {
|
||||
vnBankHolder: string;
|
||||
vnMomo: string;
|
||||
vnZalopay: string;
|
||||
/** Playtest signup link (v0.30.0). Empty = no Playtest description block. */
|
||||
playtestLink: string;
|
||||
/** Playtest platform id (see `@config/playtest-platforms`). */
|
||||
playtestPlatform: string;
|
||||
/** Playtest invites available — 0 = unset; clamped to the platform max (≤100). */
|
||||
playtestInvites: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,6 +359,9 @@ const initialState: EditorData = {
|
||||
vnBankHolder: DEFAULTS.editor.vnBankHolder,
|
||||
vnMomo: DEFAULTS.editor.vnMomo,
|
||||
vnZalopay: DEFAULTS.editor.vnZalopay,
|
||||
playtestLink: DEFAULTS.editor.playtestLink,
|
||||
playtestPlatform: DEFAULTS.editor.playtestPlatform,
|
||||
playtestInvites: DEFAULTS.editor.playtestInvites,
|
||||
};
|
||||
|
||||
export const useEditorStore = create<EditorState>()(
|
||||
@@ -465,7 +479,14 @@ export const useEditorStore = create<EditorState>()(
|
||||
// migration defensively coerces unrecognised values to `""`
|
||||
// so a hand-edited blob or downgrade from a future version
|
||||
// can't leave the Select stuck on a missing option.
|
||||
version: 14,
|
||||
// v14 → v15: v0.30.0. Playtest section — `playtestLink`,
|
||||
// `playtestPlatform`, `playtestInvites` joined the schema.
|
||||
// Additive: empty link / default platform / 0 invites
|
||||
// back-fill. The migration coerces an unknown platform id to
|
||||
// the default and clamps the invite count to an integer in
|
||||
// [0, 100], so a hand-edited blob can't strand the editor's
|
||||
// platform Select or number input on a bad value.
|
||||
version: 15,
|
||||
migrate: (persistedState, version) =>
|
||||
migrateEditorState(persistedState, version),
|
||||
partialize: (state) => ({
|
||||
@@ -537,6 +558,9 @@ export const useEditorStore = create<EditorState>()(
|
||||
vnBankHolder: state.vnBankHolder,
|
||||
vnMomo: state.vnMomo,
|
||||
vnZalopay: state.vnZalopay,
|
||||
playtestLink: state.playtestLink,
|
||||
playtestPlatform: state.playtestPlatform,
|
||||
playtestInvites: state.playtestInvites,
|
||||
}),
|
||||
},
|
||||
),
|
||||
@@ -759,6 +783,21 @@ export function migrateEditorState(
|
||||
? state.videoStyleEra
|
||||
: "";
|
||||
}
|
||||
if (version < 15) {
|
||||
// v0.30.0 Playtest section. Additive back-fill + defensive coercion.
|
||||
if (typeof state.playtestLink !== "string") state.playtestLink = "";
|
||||
if (
|
||||
typeof state.playtestPlatform !== "string" ||
|
||||
!PLAYTEST_PLATFORMS.some((p) => p.id === state.playtestPlatform)
|
||||
) {
|
||||
state.playtestPlatform = DEFAULT_PLAYTEST_PLATFORM;
|
||||
}
|
||||
const inv = state.playtestInvites;
|
||||
state.playtestInvites =
|
||||
typeof inv === "number" && Number.isInteger(inv) && inv >= 0
|
||||
? Math.min(inv, PLAYTEST_MAX_INVITES_CAP)
|
||||
: 0;
|
||||
}
|
||||
return { ...initialState, ...state } as EditorData;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,3 +136,86 @@ export function validatePlaylistUrl(input: string): ValidationResult {
|
||||
|
||||
return { valid: true };
|
||||
}
|
||||
|
||||
export interface IntRangeOptions {
|
||||
min: number;
|
||||
max: number;
|
||||
/** When true, an empty / whitespace-only string is valid (the field is
|
||||
* optional). When false, blank is rejected as `validation.numberRequired`. */
|
||||
allowEmpty?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a string holds a whole number within `[min, max]`.
|
||||
* Rejects (in order) blank-when-required, non-numeric, decimals /
|
||||
* non-integers, and out-of-range values — covering every "invalid number"
|
||||
* case the editor needs to warn on (v0.30.0). Pure; returns the shared
|
||||
* {@link ValidationResult} so it slots into the existing inline-error UI.
|
||||
*/
|
||||
export function validateIntegerInRange(
|
||||
input: string,
|
||||
{ min, max, allowEmpty = false }: IntRangeOptions,
|
||||
): ValidationResult {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) {
|
||||
return allowEmpty ? { valid: true } : { valid: false, error: "validation.numberRequired" };
|
||||
}
|
||||
|
||||
const n = Number(trimmed);
|
||||
if (!Number.isFinite(n)) {
|
||||
return { valid: false, error: "validation.numberInvalid" };
|
||||
}
|
||||
if (!Number.isInteger(n)) {
|
||||
return { valid: false, error: "validation.numberNotInteger" };
|
||||
}
|
||||
if (n < min || n > max) {
|
||||
return {
|
||||
valid: false,
|
||||
error: "validation.numberOutOfRange",
|
||||
errorParams: { min, max },
|
||||
};
|
||||
}
|
||||
|
||||
return { valid: true };
|
||||
}
|
||||
|
||||
export interface BatchRangeOptions {
|
||||
/** Maximum number of parts allowed in a single batch (inclusive span). */
|
||||
maxSpan: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a Batch / Social-bulk "start → end part" range. Both endpoints
|
||||
* must be whole numbers ≥ 1, `end ≥ start`, and the inclusive span must not
|
||||
* exceed `maxSpan`. Returns the first failing reason so the caller can both
|
||||
* block generation (disable the button) and surface the message. v0.30.0.
|
||||
*/
|
||||
export function validateBatchRange(
|
||||
startStr: string,
|
||||
endStr: string,
|
||||
{ maxSpan }: BatchRangeOptions,
|
||||
): ValidationResult {
|
||||
const startResult = validateIntegerInRange(startStr, { min: 1, max: Number.MAX_SAFE_INTEGER });
|
||||
if (!startResult.valid) return startResult;
|
||||
const endResult = validateIntegerInRange(endStr, { min: 1, max: Number.MAX_SAFE_INTEGER });
|
||||
if (!endResult.valid) return endResult;
|
||||
|
||||
const start = Number(startStr.trim());
|
||||
const end = Number(endStr.trim());
|
||||
if (end < start) {
|
||||
return {
|
||||
valid: false,
|
||||
error: "validation.rangeEndBeforeStart",
|
||||
errorParams: { start, end },
|
||||
};
|
||||
}
|
||||
if (end - start + 1 > maxSpan) {
|
||||
return {
|
||||
valid: false,
|
||||
error: "validation.rangeTooLarge",
|
||||
errorParams: { maxSpan },
|
||||
};
|
||||
}
|
||||
|
||||
return { valid: true };
|
||||
}
|
||||
@@ -163,6 +163,90 @@ describe("buildDescription", () => {
|
||||
expect(result).not.toContain("(free)");
|
||||
});
|
||||
|
||||
it("includes the playtest block with platform label + link when a link is set (v0.30.0)", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({
|
||||
playtestLink: "https://store.steampowered.com/app/1245620",
|
||||
playtestPlatform: "steam",
|
||||
playtestInvites: 25,
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain("🧪 PLAYTEST / EARLY ACCESS");
|
||||
expect(result).toContain(
|
||||
"🧪 Steam Playtest: https://store.steampowered.com/app/1245620",
|
||||
);
|
||||
expect(result).toContain("25 invites available");
|
||||
});
|
||||
|
||||
it("omits the playtest block entirely when no link is set", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({ playtestPlatform: "steam", playtestInvites: 25 }),
|
||||
t,
|
||||
);
|
||||
expect(result).not.toContain("PLAYTEST / EARLY ACCESS");
|
||||
});
|
||||
|
||||
it("omits the invites line when the count is 0", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({
|
||||
playtestLink: "https://dev.itch.io/my-game",
|
||||
playtestPlatform: "itchio",
|
||||
playtestInvites: 0,
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain("🧪 PLAYTEST / EARLY ACCESS");
|
||||
expect(result).not.toContain("invites available");
|
||||
});
|
||||
|
||||
it("guards the invites line against non-integer / negative counts", () => {
|
||||
const t = createMockT("en");
|
||||
const decimal = buildDescription(
|
||||
makeInput({
|
||||
playtestLink: "https://store.steampowered.com/app/1",
|
||||
playtestInvites: 2.5,
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(decimal).not.toContain("invites available");
|
||||
const negative = buildDescription(
|
||||
makeInput({
|
||||
playtestLink: "https://store.steampowered.com/app/1",
|
||||
playtestInvites: -3,
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(negative).not.toContain("invites available");
|
||||
});
|
||||
|
||||
it("falls back to the raw platform id when the platform is unknown", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
makeInput({
|
||||
playtestLink: "https://example.com/signup",
|
||||
playtestPlatform: "mystery",
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain("🧪 mystery: https://example.com/signup");
|
||||
});
|
||||
|
||||
it("renders the localized playtest heading in Vietnamese", () => {
|
||||
const t = createMockT("vi");
|
||||
const result = buildDescription(
|
||||
makeInput({
|
||||
language: "vi",
|
||||
playtestLink: "https://store.steampowered.com/app/1",
|
||||
}),
|
||||
t,
|
||||
);
|
||||
expect(result).toContain("🧪 PLAYTEST / TRẢI NGHIỆM SỚM");
|
||||
});
|
||||
|
||||
it("includes video settings with the v0.8-polish multi-line block", () => {
|
||||
const t = createMockT("en");
|
||||
const result = buildDescription(
|
||||
|
||||
@@ -102,6 +102,9 @@ function makeEditorData(overrides: Partial<EditorData> = {}): EditorData {
|
||||
vnBankHolder: DEFAULTS.editor.vnBankHolder,
|
||||
vnMomo: DEFAULTS.editor.vnMomo,
|
||||
vnZalopay: DEFAULTS.editor.vnZalopay,
|
||||
playtestLink: DEFAULTS.editor.playtestLink,
|
||||
playtestPlatform: DEFAULTS.editor.playtestPlatform,
|
||||
playtestInvites: DEFAULTS.editor.playtestInvites,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -149,6 +152,19 @@ describe("buildGeneratorInputFromEditor — v0.12 fields propagation (regression
|
||||
]);
|
||||
});
|
||||
|
||||
it("passes through the playtest fields (v0.30.0)", () => {
|
||||
const input = buildGeneratorInputFromEditor(
|
||||
makeEditorData({
|
||||
playtestLink: "https://store.steampowered.com/app/1245620",
|
||||
playtestPlatform: "steam",
|
||||
playtestInvites: 25,
|
||||
}),
|
||||
);
|
||||
expect(input.playtestLink).toBe("https://store.steampowered.com/app/1245620");
|
||||
expect(input.playtestPlatform).toBe("steam");
|
||||
expect(input.playtestInvites).toBe(25);
|
||||
});
|
||||
|
||||
it("respects languageOverride for batch / multi-language rendering", () => {
|
||||
const input = buildGeneratorInputFromEditor(
|
||||
makeEditorData({ language: "en" }),
|
||||
|
||||
@@ -202,3 +202,63 @@ describe("migrateEditorState — v10 → v11 (v0.13)", () => {
|
||||
expect(result.gachaVersion).toBe("4.2");
|
||||
});
|
||||
});
|
||||
|
||||
describe("migrateEditorState — v14 → v15 (v0.30.0 Playtest)", () => {
|
||||
// Build a pre-v15 blob by routing v9 through every prior migration, then
|
||||
// strip the playtest keys so the v15 block is what supplies them.
|
||||
function makeV14Persisted(
|
||||
overrides: Record<string, unknown> = {},
|
||||
): Record<string, unknown> {
|
||||
const full = migrateEditorState(makeV9Persisted(), 9) as unknown as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
delete full.playtestLink;
|
||||
delete full.playtestPlatform;
|
||||
delete full.playtestInvites;
|
||||
return { ...full, ...overrides };
|
||||
}
|
||||
|
||||
it("back-fills the playtest fields with safe defaults", () => {
|
||||
const result = migrateEditorState(makeV14Persisted(), 14);
|
||||
expect(result.playtestLink).toBe("");
|
||||
expect(result.playtestPlatform).toBe("steam");
|
||||
expect(result.playtestInvites).toBe(0);
|
||||
});
|
||||
|
||||
it("clamps an over-cap persisted invite count to 100", () => {
|
||||
const result = migrateEditorState(makeV14Persisted({ playtestInvites: 250 }), 14);
|
||||
expect(result.playtestInvites).toBe(100);
|
||||
});
|
||||
|
||||
it("coerces a decimal or negative invite count to 0", () => {
|
||||
expect(
|
||||
migrateEditorState(makeV14Persisted({ playtestInvites: 2.5 }), 14).playtestInvites,
|
||||
).toBe(0);
|
||||
expect(
|
||||
migrateEditorState(makeV14Persisted({ playtestInvites: -3 }), 14).playtestInvites,
|
||||
).toBe(0);
|
||||
});
|
||||
|
||||
it("coerces an unknown persisted platform to the default", () => {
|
||||
const result = migrateEditorState(
|
||||
makeV14Persisted({ playtestPlatform: "mystery" }),
|
||||
14,
|
||||
);
|
||||
expect(result.playtestPlatform).toBe("steam");
|
||||
});
|
||||
|
||||
it("preserves valid persisted playtest values", () => {
|
||||
const result = migrateEditorState(
|
||||
makeV14Persisted({
|
||||
playtestLink: "https://dev.itch.io/my-game",
|
||||
playtestPlatform: "itchio",
|
||||
playtestInvites: 40,
|
||||
}),
|
||||
14,
|
||||
);
|
||||
expect(result.playtestLink).toBe("https://dev.itch.io/my-game");
|
||||
expect(result.playtestPlatform).toBe("itchio");
|
||||
expect(result.playtestInvites).toBe(40);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,10 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { validateUrlWithPattern, validatePlaylistUrl } from "@utils/validation";
|
||||
import {
|
||||
validateUrlWithPattern,
|
||||
validatePlaylistUrl,
|
||||
validateIntegerInRange,
|
||||
validateBatchRange,
|
||||
} from "@utils/validation";
|
||||
import { PLATFORMS } from "@config/platforms";
|
||||
|
||||
function platform(id: string) {
|
||||
@@ -238,3 +243,93 @@ describe("validatePlaylistUrl", () => {
|
||||
expect(validatePlaylistUrl("https://example.com/playlist").valid).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("validateIntegerInRange", () => {
|
||||
it("accepts a whole number within range", () => {
|
||||
expect(validateIntegerInRange("5", { min: 1, max: 10 }).valid).toBe(true);
|
||||
expect(validateIntegerInRange("1", { min: 1, max: 10 }).valid).toBe(true);
|
||||
expect(validateIntegerInRange("10", { min: 1, max: 10 }).valid).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects a blank value when allowEmpty is off", () => {
|
||||
const result = validateIntegerInRange("", { min: 1, max: 10 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.numberRequired");
|
||||
});
|
||||
|
||||
it("accepts a blank value when allowEmpty is on", () => {
|
||||
expect(validateIntegerInRange("", { min: 1, max: 10, allowEmpty: true }).valid).toBe(true);
|
||||
expect(validateIntegerInRange(" ", { min: 1, max: 10, allowEmpty: true }).valid).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-numeric input", () => {
|
||||
const result = validateIntegerInRange("abc", { min: 1, max: 10 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.numberInvalid");
|
||||
});
|
||||
|
||||
it("rejects a decimal / non-integer value", () => {
|
||||
const result = validateIntegerInRange("2.5", { min: 1, max: 10 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.numberNotInteger");
|
||||
});
|
||||
|
||||
it("rejects a negative value below the minimum", () => {
|
||||
const result = validateIntegerInRange("-3", { min: 1, max: 10 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.numberOutOfRange");
|
||||
expect(result.errorParams).toEqual({ min: 1, max: 10 });
|
||||
});
|
||||
|
||||
it("rejects zero when the minimum is 1", () => {
|
||||
expect(validateIntegerInRange("0", { min: 1, max: 10 }).valid).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects a value above the maximum", () => {
|
||||
const result = validateIntegerInRange("11", { min: 1, max: 10 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.numberOutOfRange");
|
||||
});
|
||||
});
|
||||
|
||||
describe("validateBatchRange", () => {
|
||||
it("accepts a valid ascending range within the span", () => {
|
||||
expect(validateBatchRange("1", "5", { maxSpan: 100 }).valid).toBe(true);
|
||||
expect(validateBatchRange("3", "3", { maxSpan: 100 }).valid).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts a range exactly at the max span", () => {
|
||||
expect(validateBatchRange("1", "100", { maxSpan: 100 }).valid).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects an end part before the start", () => {
|
||||
const result = validateBatchRange("5", "2", { maxSpan: 100 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.rangeEndBeforeStart");
|
||||
expect(result.errorParams).toEqual({ start: 5, end: 2 });
|
||||
});
|
||||
|
||||
it("rejects a range that exceeds the max span", () => {
|
||||
const result = validateBatchRange("1", "101", { maxSpan: 100 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.rangeTooLarge");
|
||||
expect(result.errorParams).toEqual({ maxSpan: 100 });
|
||||
});
|
||||
|
||||
it("rejects a decimal endpoint", () => {
|
||||
const result = validateBatchRange("1", "5.5", { maxSpan: 100 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.numberNotInteger");
|
||||
});
|
||||
|
||||
it("rejects a non-positive start", () => {
|
||||
expect(validateBatchRange("-1", "5", { maxSpan: 100 }).valid).toBe(false);
|
||||
expect(validateBatchRange("0", "5", { maxSpan: 100 }).valid).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects a blank endpoint", () => {
|
||||
const result = validateBatchRange("", "5", { maxSpan: 100 });
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.error).toBe("validation.numberRequired");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user