Screenshot pipeline groundwork: capture source config, device builders, store specs, checks, variants, video builders
Salvaged from wip/shots-pipeline. Pure modules (spec, devices, report, video, check), variant support in render / lib, 13" iPad size and 3:4 template layout. Not all of it is wired into the CLI yet.
This commit is contained in:
parent
9be0556685
commit
bd89eb748a
12 changed files with 1141 additions and 73 deletions
|
|
@ -2,6 +2,7 @@
|
|||
// do (see credentials.ts). The file default-exports a plain object; `import type { ShipConfig }` is optional.
|
||||
import { existsSync } from 'node:fs';
|
||||
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
||||
import { validateCapture } from '../shots/devices';
|
||||
|
||||
export type ProductType = 'consumable' | 'non_consumable';
|
||||
|
||||
|
|
@ -89,13 +90,100 @@ export interface ShotsConfig {
|
|||
/** Phone screen size of the raw frames in CSS px (default 440 x 902, iPhone 6.9" minus the 54 px status bar). */
|
||||
phone?: { w: number; h: number; dpr?: number };
|
||||
tablet?: { w: number; h: number; dpr?: number };
|
||||
/** Optional capture of raw frames from a running build of your game. */
|
||||
capture?: {
|
||||
baseUrl: string;
|
||||
/** Appended to every URL, e.g. "noads=1&noanalytics=1". "{lang}" is replaced. */
|
||||
query?: string;
|
||||
shots: Record<string, { path: string; waitFor?: string; delayMs?: number; eval?: string[]; device?: 'phone' | 'tablet' | 'both' }>;
|
||||
/** Optional capture of raw frames (web build, iOS Simulator, Android emulator / device, or your own folder). */
|
||||
capture?: ShotsCapture;
|
||||
/** A/B variants: other scene orders / copy, rendered into <out>/<variant>/<lang>/... (`shots render --variant b`). */
|
||||
variants?: Record<string, ShotVariant>;
|
||||
/** App preview / promo video from gameplay clips (`shots record`, `shots video`). */
|
||||
video?: VideoConfig;
|
||||
}
|
||||
|
||||
/** One raw frame. Web: `path` (+ query). Simulator / emulator: `url` deep link and / or `args` / `extras`. */
|
||||
export interface ShotSpec {
|
||||
/** Web: URL path after baseUrl, "{lang}" replaced. */
|
||||
path?: string;
|
||||
/** ios-sim / android-emu: deep link opened after launch, e.g. "mygame://shot/{shot}?lang={lang}". */
|
||||
url?: string;
|
||||
/** Web: JS expression polled until true. */
|
||||
waitFor?: string;
|
||||
/** Wait before the screenshot (ms). Default 1000 (web) / 2500 (simulator, emulator). */
|
||||
delayMs?: number;
|
||||
/** Web: JS run in the page before the screenshot. */
|
||||
eval?: string[];
|
||||
device?: 'phone' | 'tablet' | 'both';
|
||||
/** ios-sim: extra launch arguments, e.g. ["-shotScene", "{shot}", "-seed", "1"] (read them with UserDefaults / your engine). */
|
||||
args?: string[];
|
||||
/** android-emu: intent extras for `am start` (string / int / float / boolean), "{lang}" replaced in strings. */
|
||||
extras?: Record<string, string | number | boolean>;
|
||||
}
|
||||
|
||||
export interface ShotsCapture {
|
||||
/** Where frames come from. Default "web". */
|
||||
source?: 'web' | 'ios-sim' | 'android-emu' | 'folder';
|
||||
/** web: URL of the running game, e.g. http://127.0.0.1:5173 */
|
||||
baseUrl?: string;
|
||||
/** web: appended to every URL, e.g. "lang={lang}&noads=1". */
|
||||
query?: string;
|
||||
ios?: {
|
||||
/** Simulator name or UDID for phone shots, e.g. "iPhone 17 Pro Max" (6.9"). */
|
||||
device?: string;
|
||||
devices?: { phone?: string; tablet?: string };
|
||||
bundleId: string;
|
||||
/** Optional .app to install first (a Simulator build: xcodebuild -sdk iphonesimulator, Unity / Godot / Flutter export). */
|
||||
app?: string;
|
||||
/** Launch arguments for every shot ("{lang}", "{shot}" replaced). */
|
||||
args?: string[];
|
||||
/** Status bar override 9:41, full battery and signal. Default true. */
|
||||
statusBar?: boolean;
|
||||
};
|
||||
android?: {
|
||||
/** adb serial (adb devices); default: the only device. */
|
||||
serial?: string;
|
||||
serials?: { phone?: string; tablet?: string };
|
||||
package: string;
|
||||
/** Launch activity when a shot has no deep link. Default ".MainActivity". */
|
||||
activity?: string;
|
||||
/** Optional APK to install first. */
|
||||
apk?: string;
|
||||
/** System UI demo mode (clean status bar). Default true. */
|
||||
demoMode?: boolean;
|
||||
/** Per-app language via `cmd locale set-app-locales` (Android 13+). Default true. */
|
||||
appLocale?: boolean;
|
||||
};
|
||||
/** folder: where your frames are (default shots.frames): <dir>/<lang>/<phone|tablet>/<name>.png */
|
||||
folder?: string;
|
||||
/** Rows cut from the top of a simulator / emulator screenshot (its status bar; the template draws one). Default: about 5.6 % of the height. */
|
||||
cropTop?: number;
|
||||
shots: Record<string, ShotSpec>;
|
||||
}
|
||||
|
||||
export interface ShotVariant {
|
||||
/** Scene ids in the order this variant shows them (a subset is fine). Default: the base order. */
|
||||
scenes?: string[];
|
||||
/** Copy file merged over the base copy per language and scene (only the scenes / fields that change). */
|
||||
copy?: string;
|
||||
/** Palette per scene id. */
|
||||
palettes?: Record<string, string | Palette>;
|
||||
}
|
||||
|
||||
export interface VideoConfig {
|
||||
/** Gameplay clips: <clips>/<lang>/*.mp4|mov, or <clips>/*.mp4|mov shared by every language. Default store/video/clips. */
|
||||
clips?: string;
|
||||
/** Target length in seconds (15-30 for App Store previews). Default 25. */
|
||||
seconds?: number;
|
||||
/** Outputs: iphone (886x1920), ipad (1200x1600, iPad apps), youtube (1080x1920), youtube-landscape (1920x1080). */
|
||||
targets?: string[];
|
||||
/** Caption overlays from the screenshot copy (scene titles), one per clip. Default true. */
|
||||
captions?: boolean;
|
||||
/** Scene ids whose titles caption the clips, in order. Default: the scene order. */
|
||||
captionScenes?: string[];
|
||||
/** Music / sound file mixed in (looped, faded out). Default: a silent stereo track (Apple wants an audio track). */
|
||||
audio?: string;
|
||||
/** Poster frame time in seconds (App Store shows it before playback). Default 5. */
|
||||
poster?: number;
|
||||
/** cover (crop to fill, default) or contain (letterbox on `background`). */
|
||||
fit?: 'cover' | 'contain';
|
||||
background?: string;
|
||||
}
|
||||
|
||||
export interface IconsConfig {
|
||||
|
|
@ -140,7 +228,11 @@ export interface ShipConfig {
|
|||
contactEmail: string;
|
||||
};
|
||||
languages: Language[];
|
||||
play?: { packageName: string; defaultLanguage?: string; listing?: string; icon?: string };
|
||||
play?: {
|
||||
packageName: string; defaultLanguage?: string; listing?: string; icon?: string;
|
||||
/** Promo video: a YouTube URL (public or unlisted, ads off, embeddable). Play takes no video upload. Sent by `play listing`. */
|
||||
video?: string;
|
||||
};
|
||||
apple?: {
|
||||
bundleId: string; appId?: string; primaryLocale?: string; listing?: string; info?: AppleAppInfo; reviewShots?: string;
|
||||
/**
|
||||
|
|
@ -149,8 +241,10 @@ export interface ShipConfig {
|
|||
* to skip the question: a wrong answer is a legal problem, not a store one. Unset = storebound will not answer.
|
||||
*/
|
||||
usesNonExemptEncryption?: boolean;
|
||||
/** Screenshot display types every locale must have (validate). Default ["APP_IPHONE_67"]; add "APP_IPAD_PRO_3GEN_129" for iPad apps. */
|
||||
/** Screenshot display types every locale must have (validate). Default ["APP_IPHONE_67"] (+ "APP_IPAD_PRO_3GEN_129" with ipad). */
|
||||
screenshotTypes?: string[];
|
||||
/** The app runs on iPad: renders, checks and uploads 13" iPad screenshots (2064 x 2752) and iPad app previews. */
|
||||
ipad?: boolean;
|
||||
};
|
||||
products?: Product[];
|
||||
dataSafety?: DataSafety;
|
||||
|
|
@ -191,6 +285,8 @@ export function validateConfig(c: unknown): string[] {
|
|||
ids.add(l.id);
|
||||
}
|
||||
if (cfg.play && !ID_RE.test(cfg.play.packageName ?? '')) e.push('play.packageName: not a package name (com.example.game)');
|
||||
if (cfg.play?.video && !/^https:\/\/(www\.youtube\.com\/watch\?v=[\w-]{6,}|youtu\.be\/[\w-]{6,})$/.test(cfg.play.video))
|
||||
e.push('play.video: a plain YouTube video URL (https://www.youtube.com/watch?v=... or https://youtu.be/...), no playlist, channel or extra parameters');
|
||||
if (cfg.apple) {
|
||||
if (!ID_RE.test(cfg.apple.bundleId ?? '')) e.push('apple.bundleId: not a bundle id (com.example.game)');
|
||||
if (cfg.apple.appId && !/^\d+$/.test(cfg.apple.appId)) e.push('apple.appId: numeric Apple ID of the app (App Store Connect > App Information)');
|
||||
|
|
@ -233,6 +329,21 @@ export function validateConfig(c: unknown): string[] {
|
|||
for (const k of ['copy', 'frames', 'out'] as const) if (!s[k]) e.push(`shots.${k}: missing`);
|
||||
if (!s.scenes?.length) e.push('shots.scenes: at least one scene');
|
||||
for (const sc of s.scenes ?? []) if (!sc.frames?.length) e.push(`shots.scenes[${sc.id}].frames: at least one frame`);
|
||||
e.push(...validateCapture(s.capture));
|
||||
const sceneIds = new Set((s.scenes ?? []).map(x => x.id));
|
||||
for (const [k, v] of Object.entries(s.variants ?? {})) {
|
||||
if (!/^[a-z0-9][a-z0-9-]*$/.test(k)) e.push(`shots.variants.${k}: lowercase letters, digits, "-" (it is a folder name)`);
|
||||
if (cfg.languages?.some(l => l.id === k)) e.push(`shots.variants.${k}: same name as a language id`);
|
||||
for (const id of v.scenes ?? []) if (!sceneIds.has(id)) e.push(`shots.variants.${k}.scenes: unknown scene "${id}"`);
|
||||
for (const id of Object.keys(v.palettes ?? {})) if (!sceneIds.has(id)) e.push(`shots.variants.${k}.palettes: unknown scene "${id}"`);
|
||||
}
|
||||
if (s.video) {
|
||||
const v = s.video;
|
||||
if (v.seconds !== undefined && !(v.seconds >= 15 && v.seconds <= 30)) e.push('shots.video.seconds: 15-30 (App Store app preview length)');
|
||||
for (const t of v.targets ?? []) if (!['iphone', 'ipad', 'youtube', 'youtube-landscape'].includes(t)) e.push(`shots.video.targets: unknown "${t}" (iphone, ipad, youtube, youtube-landscape)`);
|
||||
if (v.fit && !['cover', 'contain'].includes(v.fit)) e.push('shots.video.fit: cover | contain');
|
||||
for (const id of v.captionScenes ?? []) if (!sceneIds.has(id)) e.push(`shots.video.captionScenes: unknown scene "${id}"`);
|
||||
}
|
||||
}
|
||||
if (cfg.icons) {
|
||||
if (!cfg.icons.composite) e.push('icons.composite: missing');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue