Files
poli0981andClaude Opus 5.5 3c985a07d6 feat(editor): quick start, next part, store links pasted anywhere, more stores and platforms
Editor:
- Quick start at the top: pick the channel profile and the game preset
  (remembered per device); replacing fields that hold something else asks
  first, everything offers Undo; "Update profile / preset" appears when the
  editor drifts from the one in use.
- Next part (number + 1) and New video (same game) clear what belonged to
  the last video: boss, timestamps, endings, pinned comment, sponsor…
  Applying a preset for another game or a template does the same first.
- Start over replaces Clear Draft and keeps the channel (profile fields);
  a new draft starts in the Default Output Language (it was always "en").
- A store link pasted anywhere — the page, the Game name field, another
  store's field — lands in the right store field, sets the platform for a
  game's first link and names the game from it (Roman numerals and
  well-known possessives restored: "Final Fantasy VII", "Baldur's Gate 3").
  Steam links keep their name slug and drop tracking parameters.
- Game-name suggestions from presets and history.

Catalogs:
- Stores: EA app, Ubisoft, Battle.net, Google Play, App Store, Meta Quest.
- Social: YouTube, Threads, Kick, Reddit, Bilibili; "X (Twitter)" with the
  X mark; threads.net and youtu.be links accepted.
- Cross-posting: YouTube Shorts, X (counted the way X counts — CJK,
  Vietnamese letters with diacritics and emoji count twice), Threads (one
  topic tag), Bluesky; hashtag caps per platform.
- Banks: MBV, VCBNeo, Vikki Bank (renamed OceanBank, CBBank, DongA Bank —
  saved old names get a one-click switch), Cake by VPBank, Timo.

Output:
- An empty channel name no longer leaves "…of Hades on ." — the channel
  phrase is dropped per language (8 locales, every template tested).
- Title alternatives are real title shapes with the user's separator and
  badge case; "Use this shape" sets them (new Title order setting:
  game first / video first); over-long ones can't be copied.
- Copy All can include the tags (setting); Batch picks Part or Demo part
  and continues from the editor's part number; Ctrl/Cmd+S saves the
  output to History.
- Social editor headings and hints translated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 22:29:44 +07:00

179 lines
6.5 KiB
TypeScript

import type {
GeneratorInput,
GeneratorOutput,
TranslationFn,
CharLimitWarning,
TitleFormatConfig,
} from "./types";
import { buildTitle, checkTitleWarning } from "./title-builder";
import { buildDescription, checkDescriptionWarning } from "./description-builder";
import { generateTags, formatTagString, youtubeTagsLength, type TagOptions } from "./tag-generator";
import { YT_LIMITS } from "./types";
/**
* Every {@link RenderOptions} knob that comes from the user's Settings.
*
* Split out from the per-caller knobs deliberately. Before v0.35.0 each of the
* three `renderAll` call sites hand-copied this list out of the settings store,
* and BatchPage's copy was missing `splitContactEmail` and `showThirdPartyAds`
* — so a creator with the split-email toggle on saw all three contact lines on
* the Output tab and only the old single "Business inquiries" line in Batch.
*
* Naming the set lets `buildRenderOptions` return `Required<SettingsRenderOptions>`,
* which makes a forgotten key a compile error rather than a silent omission.
* See `src/hooks/use-render-options.ts` and its parity test.
*/
export interface SettingsRenderOptions extends Omit<TagOptions, "year"> {
hashtagCount?: number;
/**
* When true, buildTitle appends a `[2K 60FPS]`-style badge to the
* video-type segment whenever resolution/fps are above the defaults.
* Defaults to true at the engine level; callers override with the
* user's setting.
*/
showQualityBadge?: boolean;
/**
* Title formatting knobs (badge position, separator, badge case).
* Partial — any omitted sub-key falls back to the v0.6 default inside
* buildTitle. Flowed from the user's Settings.
*/
titleFormat?: Partial<TitleFormatConfig>;
/**
* When true (and channelName is non-empty), the description ends with
* an auto-generated `© <year> <channelName>. All rights reserved.` line.
*/
showCopyright?: boolean;
/**
* When true, the description appends a localised "usage policy" block
* (📋 USAGE POLICY) after the copyright line.
*/
showUsagePolicy?: boolean;
/**
* When true and both `sponsorName` and `sponsorPlatform` are set on
* the input, the description emits a "🎁 Thanks to …" credit line
* above the music / donate block.
*/
showSponsorCredit?: boolean;
/**
* When true and the active profile's `thirdPartyAdText` is non-empty,
* the description emits a "🤝 SPONSORS & PARTNERS" block above the
* music section (v0.11).
*/
showThirdPartyAds?: boolean;
/**
* When true, the description's contact block splits into up to three
* labeled lines by purpose (general / advertising / game keys &
* playtest) instead of the single "📧 Business inquiries" line. v0.34.0.
*/
splitContactEmail?: boolean;
/**
* When true and the editor's `pubDevName` is non-empty, the description
* emits a `© {publisher}. All rights reserved.` line right after the
* Store Links block (v0.21.0). Opt-in — meant for games whose
* dev/publisher contractually requires attribution in the description.
*/
showGameCopyright?: boolean;
/**
* When true, the description appends an AI-translation disclaimer block
* for output languages outside the trusted set (English / Vietnamese).
* v0.24.0.
*/
showTranslationQuality?: boolean;
}
/**
* The knobs a *caller* decides, not the user. These vary by render surface —
* the Output tab wants bilingual content blocks, the multi-language tabs and
* Batch do not — so they are supplied per call site rather than read from
* Settings.
*/
export interface RenderOptionOverrides {
/**
* Optional English-fixed translation function. Used by the v0.11
* unified content-warnings block to render bilingual lines
* `EN · output-language`. When omitted, the warnings block falls back
* to single-language output via `t`.
*/
tEn?: TranslationFn;
/**
* When false, the three "video" content blocks (content warnings, tech
* notes, playthrough notes) render single-language even though `tEn` is
* supplied — used by the multi-language Output tabs, where each tab is
* already a single target language. The AI-translation disclaimer is
* unaffected and stays bilingual. Defaults to true. v0.29.3.
*/
bilingualContentBlocks?: boolean;
/**
* The year for the copyright line and the trending tags. Passed in so the
* engine never reads the clock itself (and tests are deterministic); the
* current year when omitted.
*/
year?: number;
}
export interface RenderOptions extends SettingsRenderOptions, RenderOptionOverrides {}
export function renderAll(
input: GeneratorInput,
t: TranslationFn,
options?: RenderOptions,
): GeneratorOutput {
const title = buildTitle(input, t, {
showQualityBadge: options?.showQualityBadge ?? true,
badgePosition: options?.titleFormat?.badgePosition,
separator: options?.titleFormat?.separator,
badgeCase: options?.titleFormat?.badgeCase,
order: options?.titleFormat?.order,
});
const description = buildDescription(input, t, {
hashtagCount: options?.hashtagCount,
showCopyright: options?.showCopyright,
showUsagePolicy: options?.showUsagePolicy,
showSponsorCredit: options?.showSponsorCredit,
showThirdPartyAds: options?.showThirdPartyAds,
splitContactEmail: options?.splitContactEmail,
showGameCopyright: options?.showGameCopyright,
showTranslationQuality: options?.showTranslationQuality,
tEn: options?.tEn,
bilingualContentBlocks: options?.bilingualContentBlocks,
year: options?.year,
});
const tags = generateTags(input, options);
const tagString = formatTagString(tags);
// YouTube's own count (quotes around multi-word tags, one comma between
// tags) — not the length of the ", "-joined string we hand to the clipboard.
const tagsLength = youtubeTagsLength(tags);
const charCounts = {
title: title.length,
description: description.length,
tags: tagsLength,
};
const warnings: CharLimitWarning[] = [];
const titleWarning = checkTitleWarning(title);
if (titleWarning) warnings.push(titleWarning);
const descWarning = checkDescriptionWarning(description);
if (descWarning) warnings.push(descWarning);
if (tagsLength > YT_LIMITS.TAGS_MAX) {
warnings.push({
field: "tags",
current: tagsLength,
limit: YT_LIMITS.TAGS_MAX,
message: `Tags exceed ${YT_LIMITS.TAGS_MAX} characters (${tagsLength}/${YT_LIMITS.TAGS_MAX})`,
});
}
return {
title,
description,
tags,
tagString,
charCounts,
warnings,
};
}