13" iPad end to end: frame defaults with apple.ipad, per-device crop, iPad display set, simulator warm-up

- Tablet frames default to the 13" iPad screen (1032 x 1352 @2x below a 24 px bar) when apple.ipad is set
- shots.capture.cropTop takes a number or { phone, tablet }; default is the frame's bar share per device class
- capture warns when a cropped frame does not match the frame aspect
- apple screenshots uploads ipad13 as APP_IPAD_PRO_3GEN_129 only with apple.ipad; validate requires it then
- ios-sim: one warm-up launch after a cold boot (ios.warmupMs, default 8000) so the first frame is not blank
This commit is contained in:
CRTkafa 2026-10-10 21:54:47 +08:00
parent 4755ab4e30
commit 3d257402cc
7 changed files with 86 additions and 26 deletions

View file

@ -1,8 +1,10 @@
// Store screenshots of every locale on the editable App Store version (idempotent: a set whose files already match // Store screenshots of every locale on the editable App Store version (idempotent: a set whose files already match
// by MD5 and order is left alone, otherwise it is emptied and re-uploaded). // by MD5 and order is left alone, otherwise it is emptied and re-uploaded).
// storebound apple screenshots [--src store/renders] [--only en-US,tr] [--jobs 4] // storebound apple screenshots [--src store/renders] [--only en-US,tr] [--jobs 4]
// Source per language: <renders>/<language id>/ios69/NN.png (6.9", 1320 x 2868 -> APP_IPHONE_67) and // Source per language: <renders>/<language id>/ios69/NN.png (6.9", 1320 x 2868 -> APP_IPHONE_67),
// ios65/NN.png (6.5", 1284 x 2778 -> APP_IPHONE_65). Up to 10 per set. Apple processes uploads asynchronously; failed // ios65/NN.png (6.5", 1284 x 2778 -> APP_IPHONE_65) and, only with apple.ipad, ipad13/NN.png (13" iPad, 2064 x 2752 ->
// APP_IPAD_PRO_3GEN_129: the API has no "13 inch" value, the 13" display set keeps the 3rd gen 12.9" name). Up to 10
// per set. Apple processes uploads asynchronously; failed
// ones are reported at the end. Long: run in the background with a log file. // ones are reported at the end. Long: run in the background with a log file.
import { existsSync, readFileSync } from 'node:fs'; import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path'; import { join } from 'node:path';
@ -12,7 +14,17 @@ import { done, log, warn } from '../lib/log';
import { numberedImages } from '../play/images'; import { numberedImages } from '../play/images';
import { ascClient, md5, type J } from './asc'; import { ascClient, md5, type J } from './asc';
/** Render size key -> ASC screenshotDisplayType (iPhone sets). */
export const DISPLAY: Record<string, string> = { ios69: 'APP_IPHONE_67', ios65: 'APP_IPHONE_65' }; export const DISPLAY: Record<string, string> = { ios69: 'APP_IPHONE_67', ios65: 'APP_IPHONE_65' };
/** 13" iPad set, uploaded only when apple.ipad is true. */
export const IPAD_DISPLAY: Record<string, string> = { ipad13: 'APP_IPAD_PRO_3GEN_129' };
/** Display sets this project uploads: the iPhone sets, plus the 13" iPad set with apple.ipad. */
export const displaySets = (apple: { ipad?: boolean } | undefined): Record<string, string> => ({ ...DISPLAY, ...(apple?.ipad ? IPAD_DISPLAY : {}) });
/** Display types `validate` requires on every locale: apple.screenshotTypes, else 6.9" iPhone (+ 13" iPad with ipad). */
export const requiredDisplayTypes = (apple: { ipad?: boolean; screenshotTypes?: string[] } | undefined): string[] =>
apple?.screenshotTypes ?? ['APP_IPHONE_67', ...(apple?.ipad ? ['APP_IPAD_PRO_3GEN_129'] : [])];
export async function run(ctx: Ctx): Promise<void> { export async function run(ctx: Ctx): Promise<void> {
const { config, root, resolve } = ctx.loaded; const { config, root, resolve } = ctx.loaded;
@ -48,7 +60,7 @@ export async function run(ctx: Ctx): Promise<void> {
if (!lang) { warn('apple', `${locale}: no language with apple: "${locale}", skipped`); continue; } if (!lang) { warn('apple', `${locale}: no language with apple: "${locale}", skipped`); continue; }
tasks.push(async () => { tasks.push(async () => {
const sets = await c.all(`/v1/appStoreVersionLocalizations/${loc.id}/appScreenshotSets`); const sets = await c.all(`/v1/appStoreVersionLocalizations/${loc.id}/appScreenshotSets`);
for (const [dir, type] of Object.entries(DISPLAY)) { for (const [dir, type] of Object.entries(displaySets(config.apple))) {
const d = join(src, lang.id, dir); const d = join(src, lang.id, dir);
const files = numberedImages(d).filter(f => f.endsWith('.png')).slice(0, 10); const files = numberedImages(d).filter(f => f.endsWith('.png')).slice(0, 10);
if (!existsSync(d) || !files.length) { warn('apple', `${locale}: nothing in ${d}, skipped`); continue; } if (!existsSync(d) || !files.length) { warn('apple', `${locale}: nothing in ${d}, skipped`); continue; }

View file

@ -87,9 +87,11 @@ export interface ShotsConfig {
fonts?: { title?: string; body?: string }; fonts?: { title?: string; body?: string };
scenes: ShotScene[]; scenes: ShotScene[];
feature?: { frame: string; palette?: string | Palette }; feature?: { frame: string; palette?: string | Palette };
/** Phone screen size of the raw frames in CSS px (default 440 x 902, iPhone 6.9" minus the 54 px status bar). */ /** Phone screen size of the raw frames in CSS px (default 440 x 902 @3x, iPhone 6.9" minus the 54 px status bar).
phone?: { w: number; h: number; dpr?: number }; * `bar` = status bar height the template draws above the frame (and that capture crops off). */
tablet?: { w: number; h: number; dpr?: number }; phone?: { w: number; h: number; dpr?: number; bar?: number };
/** Tablet frames: default 1032 x 1352 @2x (13" iPad minus its 24 px bar) with apple.ipad, else 800 x 1240 @2x. */
tablet?: { w: number; h: number; dpr?: number; bar?: number };
/** Optional capture of raw frames (web build, iOS Simulator, Android emulator / device, or your own folder). */ /** Optional capture of raw frames (web build, iOS Simulator, Android emulator / device, or your own folder). */
capture?: ShotsCapture; capture?: ShotsCapture;
/** A/B variants: other scene orders / copy, rendered into <out>/<variant>/<lang>/... (`shots render --variant b`). */ /** A/B variants: other scene orders / copy, rendered into <out>/<variant>/<lang>/... (`shots render --variant b`). */
@ -135,6 +137,9 @@ export interface ShotsCapture {
args?: string[]; args?: string[];
/** Status bar override 9:41, full battery and signal. Default true. */ /** Status bar override 9:41, full battery and signal. Default true. */
statusBar?: boolean; statusBar?: boolean;
/** After storebound boots a simulator: launch the app once and wait this long before the first shot (a cold
* first launch is much slower than the next ones). Default 8000 ms; 0 turns it off. */
warmupMs?: number;
}; };
android?: { android?: {
/** adb serial (adb devices); default: the only device. */ /** adb serial (adb devices); default: the only device. */
@ -152,8 +157,10 @@ export interface ShotsCapture {
}; };
/** folder: where your frames are (default shots.frames): <dir>/<lang>/<phone|tablet>/<name>.png */ /** folder: where your frames are (default shots.frames): <dir>/<lang>/<phone|tablet>/<name>.png */
folder?: string; 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. */ /** Rows cut from the top of a simulator / emulator screenshot (its status bar; the template draws one). A number for
cropTop?: number; * every device, or per device class. Default: the frame's bar share of the height (phone 54 / 956 = 162 px on a 6.9"
* iPhone, 13" iPad 24 / 1376 = 48 px). */
cropTop?: number | { phone?: number; tablet?: number };
shots: Record<string, ShotSpec>; shots: Record<string, ShotSpec>;
} }

View file

@ -7,8 +7,9 @@
// { path, waitFor?: JS expression that turns true, eval?: [JS], delayMs?, device? }; URL = baseUrl + path + // { path, waitFor?: JS expression that turns true, eval?: [JS], delayMs?, device? }; URL = baseUrl + path +
// query, "{lang}" replaced. // query, "{lang}" replaced.
// ios-sim xcrun simctl: boots the simulator (ios.device / ios.devices.tablet), optional install of ios.app, status // ios-sim xcrun simctl: boots the simulator (ios.device / ios.devices.tablet), optional install of ios.app, status
// bar 9:41 / full battery / full bars, then per shot: launch ios.bundleId with -AppleLanguages (xx) // bar 9:41 / full battery / full bars, one warm-up launch after a cold boot (ios.warmupMs), then per shot:
// -AppleLocale + ios.args + shot.args, open shot.url (deep link) if given, wait, `simctl io screenshot`. // launch ios.bundleId with -AppleLanguages (xx) -AppleLocale + ios.args + shot.args, open shot.url
// (deep link) if given, wait, `simctl io screenshot`.
// android-emu adb: demo mode status bar, per-app language (Android 13+, `cmd locale set-app-locales`), then per shot // android-emu adb: demo mode status bar, per-app language (Android 13+, `cmd locale set-app-locales`), then per shot
// force-stop + `am start` with shot.url (VIEW intent) or the launch activity + shot.extras, wait, // force-stop + `am start` with shot.url (VIEW intent) or the launch activity + shot.extras, wait,
// `exec-out screencap -p`. Works on an emulator or a USB device. Nothing is wiped or rebooted. // `exec-out screencap -p`. Works on an emulator or a USB device. Nothing is wiped or rebooted.
@ -16,22 +17,23 @@
// right aspect ratio and resolution. // right aspect ratio and resolution.
// A simulator storebound booted itself is shut down at the end (--keep-booted keeps it); one that was already running is // A simulator storebound booted itself is shut down at the end (--keep-booted keeps it); one that was already running is
// left running with its status bar restored. --dry prints the simctl / adb commands without running them. // left running with its status bar restored. --dry prints the simctl / adb commands without running them.
// Simulator / emulator screenshots are full screen: cropTop rows (the status bar) are cut so the frame fits the template. // Simulator / emulator screenshots are full screen: cropTop rows (the status bar) are cut so the frame fits the template
// (default per device class from the frame dims: phone 162 px of a 6.9" iPhone, tablet 48 px of a 13" iPad with apple.ipad).
// The game needs switches for this: language, scene, fixed seed, no ads / tutorial, freeze. See the store-screenshots skill. // The game needs switches for this: language, scene, fixed seed, no ads / tutorial, freeze. See the store-screenshots skill.
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os'; import { homedir } from 'node:os';
import { join } from 'node:path'; import { join } from 'node:path';
import { spawnSync } from 'node:child_process'; import { spawnSync } from 'node:child_process';
import type { ShipConfig } from '../lib/config'; import type { ShipConfig, ShotsCapture } from '../lib/config';
import type { Ctx } from '../lib/ctx'; import type { Ctx } from '../lib/ctx';
import { need } from '../lib/ctx'; import { need } from '../lib/ctx';
import { done, log, step, warn } from '../lib/log'; import { done, log, step, warn } from '../lib/log';
import { launch } from './browser'; import { launch } from './browser';
import { checkFrameFolder } from './check'; import { checkFrameFolder } from './check';
import { adbAppLocaleArgs, adbDemoExitArgs, adbDemoModeArgs, adbForceStopArgs, adbInstallArgs, adbScreencapArgs, adbStartArgs, adbStateArgs, adbTarget, import { adbAppLocaleArgs, adbDemoExitArgs, adbDemoModeArgs, adbForceStopArgs, adbInstallArgs, adbScreencapArgs, adbStartArgs, adbStateArgs, adbTarget,
cropArgs, defaultCropTop, fill, pickSimulator, shotsFor, simBootArgs, simBootStatusArgs, simInstallArgs, simLaunchArgs, simOpenUrlArgs, cropArgs, cropTopFor, fill, pickSimulator, shotsFor, simBootArgs, simBootStatusArgs, simInstallArgs, simLaunchArgs, simOpenUrlArgs,
simScreenshotArgs, simShutdownArgs, simStatusBarArgs, simStatusBarClearArgs, simTarget, SOURCES, type Source, TOOL_HINTS, validateCapture } from './devices'; simScreenshotArgs, simShutdownArgs, simStatusBarArgs, simStatusBarClearArgs, simTarget, SOURCES, type Source, TOOL_HINTS, validateCapture } from './devices';
import { DEFAULT_PHONE, DEFAULT_TABLET } from './lib'; import { type FrameDims, frameDims } from './lib';
import { imageInfo } from './spec'; import { imageInfo } from './spec';
type Device = 'phone' | 'tablet'; type Device = 'phone' | 'tablet';
@ -65,11 +67,15 @@ function localeOf(config: ShipConfig, lang: string, source: Source): string {
} }
/** Crop the status bar off a full-screen capture and store it as a 24-bit RGB frame. */ /** Crop the status bar off a full-screen capture and store it as a 24-bit RGB frame. */
function storeFrame(tmp: string, out: string, cropTop: number | undefined): void { function storeFrame(tmp: string, out: string, cropTop: ShotsCapture['cropTop'], device: Device, dims: FrameDims): void {
const h = imageInfo(readFileSync(tmp)).h; const { w, h } = imageInfo(readFileSync(tmp));
if (!h) throw new Error('screenshot is not a PNG'); if (!h) throw new Error('screenshot is not a PNG');
sh('ffmpeg', cropArgs(tmp, out, cropTop ?? defaultCropTop(h))); const top = cropTopFor(cropTop, device, h, dims);
sh('ffmpeg', cropArgs(tmp, out, top));
rmSync(tmp, { force: true }); rmSync(tmp, { force: true });
const want = dims.w / dims.h, got = w / (h - top);
if (Math.abs(got / want - 1) > 0.03)
warn('shots', `${out}: ${w}x${h - top} after cropping ${top} rows has aspect ${got.toFixed(3)}, ${device} frames want ${want.toFixed(3)} (set shots.${device} to this device's screen in pt, or shots.capture.cropTop)`);
} }
export async function run(ctx: Ctx): Promise<void> { export async function run(ctx: Ctx): Promise<void> {
@ -87,6 +93,7 @@ export async function run(ctx: Ctx): Promise<void> {
const devices: Device[] = a.get('device') ? [a.get('device') as Device] : ['phone', 'tablet']; const devices: Device[] = a.get('device') ? [a.get('device') as Device] : ['phone', 'tablet'];
if (devices.some(d => d !== 'phone' && d !== 'tablet')) throw new Error('--device: phone | tablet'); if (devices.some(d => d !== 'phone' && d !== 'tablet')) throw new Error('--device: phone | tablet');
const framesDir = resolve(shots.frames); const framesDir = resolve(shots.frames);
const dims = frameDims(config);
const tmpDir = join(root, '.storebound', 'tmp'); const tmpDir = join(root, '.storebound', 'tmp');
const target = (lang: string, device: Device, name: string) => { const d = join(framesDir, lang, device); if (!dry) mkdirSync(d, { recursive: true }); return join(d, `${name}.png`); }; const target = (lang: string, device: Device, name: string) => { const d = join(framesDir, lang, device); if (!dry) mkdirSync(d, { recursive: true }); return join(d, `${name}.png`); };
const total = langs.length * devices.reduce((t, d) => t + shotsFor(cap, d, only).length, 0); const total = langs.length * devices.reduce((t, d) => t + shotsFor(cap, d, only).length, 0);
@ -113,7 +120,6 @@ export async function run(ctx: Ctx): Promise<void> {
for (const lang of langs) for (const device of devices) for (const [name, s] of shotsFor(cap, device, only)) progress(`${lang}/${device}/${name}.png <- ${cap.baseUrl}${(s.path ?? '/').replaceAll('{lang}', lang)}`); for (const lang of langs) for (const device of devices) for (const [name, s] of shotsFor(cap, device, only)) progress(`${lang}/${device}/${name}.png <- ${cap.baseUrl}${(s.path ?? '/').replaceAll('{lang}', lang)}`);
return done('shots', `capture planned (dry run): ${total} frames from web`); return done('shots', `capture planned (dry run): ${total} frames from web`);
} }
const dims = { phone: { ...DEFAULT_PHONE, ...shots.phone }, tablet: { ...DEFAULT_TABLET, ...shots.tablet } };
const browser = await launch(root, { headless: true, args: ['--mute-audio', '--ignore-gpu-blocklist', '--enable-webgl', '--enable-gpu'] }); const browser = await launch(root, { headless: true, args: ['--mute-audio', '--ignore-gpu-blocklist', '--enable-webgl', '--enable-gpu'] });
try { try {
for (const lang of langs) for (const device of devices) for (const [name, s] of shotsFor(cap, device, only)) { for (const lang of langs) for (const device of devices) for (const [name, s] of shotsFor(cap, device, only)) {
@ -159,6 +165,12 @@ export async function run(ctx: Ctx): Promise<void> {
try { try {
if (ios.app) { log('shots', `installing ${ios.app}`); exec('xcrun', simInstallArgs(sim.udid, resolve(ios.app)), { timeout: 300_000 }); } if (ios.app) { log('shots', `installing ${ios.app}`); exec('xcrun', simInstallArgs(sim.udid, resolve(ios.app)), { timeout: 300_000 }); }
if (ios.statusBar !== false) exec('xcrun', simStatusBarArgs(sim.udid)); if (ios.statusBar !== false) exec('xcrun', simStatusBarArgs(sim.udid));
const warmup = ios.warmupMs ?? 8000;
if (bootedByUs && warmup > 0) {
log('shots', `warming up ${ios.bundleId} (first launch after boot, ${warmup} ms; shots.capture.ios.warmupMs)`);
exec('xcrun', simLaunchArgs(sim.udid, ios.bundleId, { lang: langs[0]!, locale: localeOf(config, langs[0]!, 'ios-sim'), shot: '', baseArgs: ios.args }));
if (!dry) await Bun.sleep(warmup);
}
for (const lang of langs) for (const [name, s] of todo) { for (const lang of langs) for (const [name, s] of todo) {
try { try {
const locale = localeOf(config, lang, 'ios-sim'); const locale = localeOf(config, lang, 'ios-sim');
@ -169,7 +181,7 @@ export async function run(ctx: Ctx): Promise<void> {
await Bun.sleep(s.delayMs ?? 2500); await Bun.sleep(s.delayMs ?? 2500);
const tmp = join(tmpDir, `sim-${name}.png`); const tmp = join(tmpDir, `sim-${name}.png`);
sh('xcrun', simScreenshotArgs(sim.udid, tmp)); sh('xcrun', simScreenshotArgs(sim.udid, tmp));
storeFrame(tmp, out, cap.cropTop); storeFrame(tmp, out, cap.cropTop, device, dims[device]);
n++; n++;
progress(`${lang}/${device}/${name}.png (${sim.name})`); progress(`${lang}/${device}/${name}.png (${sim.name})`);
} catch (e) { failed++; i++; warn('shots', `${lang}/${device}/${name}: ${(e as Error).message.slice(0, 300)}`); } } catch (e) { failed++; i++; warn('shots', `${lang}/${device}/${name}: ${(e as Error).message.slice(0, 300)}`); }
@ -210,7 +222,7 @@ export async function run(ctx: Ctx): Promise<void> {
await Bun.sleep(s.delayMs ?? 2500); await Bun.sleep(s.delayMs ?? 2500);
const tmp = join(tmpDir, `adb-${name}.png`); const tmp = join(tmpDir, `adb-${name}.png`);
writeFileSync(tmp, sh(adb, adbScreencapArgs(serial)).out); writeFileSync(tmp, sh(adb, adbScreencapArgs(serial)).out);
storeFrame(tmp, out, cap.cropTop); storeFrame(tmp, out, cap.cropTop, device, dims[device]);
n++; n++;
progress(`${lang}/${device}/${name}.png${serial ? ` (${serial})` : ''}`); progress(`${lang}/${device}/${name}.png${serial ? ` (${serial})` : ''}`);
} catch (e) { failed++; i++; warn('shots', `${lang}/${device}/${name}: ${(e as Error).message.slice(0, 300)}`); } } catch (e) { failed++; i++; warn('shots', `${lang}/${device}/${name}: ${(e as Error).message.slice(0, 300)}`); }

View file

@ -27,6 +27,7 @@ export function validateCapture(c: ShotsCapture | undefined): string[] {
if (!c.ios?.bundleId) e.push('shots.capture.ios.bundleId: bundle id of the app on the simulator (source ios-sim)'); if (!c.ios?.bundleId) e.push('shots.capture.ios.bundleId: bundle id of the app on the simulator (source ios-sim)');
if (!c.ios?.device && !c.ios?.devices?.phone) e.push('shots.capture.ios.device: simulator name or UDID, e.g. "iPhone 17 Pro Max"'); if (!c.ios?.device && !c.ios?.devices?.phone) e.push('shots.capture.ios.device: simulator name or UDID, e.g. "iPhone 17 Pro Max"');
} }
if (c.ios?.warmupMs !== undefined && !(Number.isInteger(c.ios.warmupMs) && c.ios.warmupMs >= 0)) e.push('shots.capture.ios.warmupMs: milliseconds (integer >= 0)');
if (src === 'android-emu' && !c.android?.package) e.push('shots.capture.android.package: application id (source android-emu)'); if (src === 'android-emu' && !c.android?.package) e.push('shots.capture.android.package: application id (source android-emu)');
if (src !== 'folder' && (!c.shots || !Object.keys(c.shots).length)) e.push('shots.capture.shots: at least one shot'); if (src !== 'folder' && (!c.shots || !Object.keys(c.shots).length)) e.push('shots.capture.shots: at least one shot');
for (const [name, s] of Object.entries(c.shots ?? {})) { for (const [name, s] of Object.entries(c.shots ?? {})) {
@ -39,7 +40,13 @@ export function validateCapture(c: ShotsCapture | undefined): string[] {
if (!['string', 'number', 'boolean'].includes(typeof v)) e.push(`shots.capture.shots.${name}.extras.${k}: string | number | boolean`); if (!['string', 'number', 'boolean'].includes(typeof v)) e.push(`shots.capture.shots.${name}.extras.${k}: string | number | boolean`);
} }
} }
if (c.cropTop !== undefined && !(Number.isInteger(c.cropTop) && c.cropTop >= 0)) e.push('shots.capture.cropTop: pixels (integer >= 0)'); const px = (v: unknown) => Number.isInteger(v) && (v as number) >= 0;
if (typeof c.cropTop === 'object' && c.cropTop !== null) {
for (const [k, v] of Object.entries(c.cropTop)) {
if (k !== 'phone' && k !== 'tablet') e.push(`shots.capture.cropTop.${k}: phone | tablet`);
else if (!px(v)) e.push(`shots.capture.cropTop.${k}: pixels (integer >= 0)`);
}
} else if (c.cropTop !== undefined && !px(c.cropTop)) e.push('shots.capture.cropTop: pixels (integer >= 0), or { phone, tablet }');
return e; return e;
} }
@ -164,6 +171,13 @@ export const adbRecordArgs = (remote: string, seconds: number, serial?: string):
* Default: the same share of the height the default phone frame uses (54 of 956 px on a 6.9" iPhone). */ * Default: the same share of the height the default phone frame uses (54 of 956 px on a 6.9" iPhone). */
export const defaultCropTop = (h: number, bar = 54, screen = 956): number => Math.round(h * bar / screen); export const defaultCropTop = (h: number, bar = 54, screen = 956): number => Math.round(h * bar / screen);
/** Rows to crop for a capture `h` px tall on a device class: shots.capture.cropTop (number or per device), else the
* bar share of that device's frame (bar / (frame height + bar)). */
export function cropTopFor(cropTop: ShotsCapture['cropTop'], device: 'phone' | 'tablet', h: number, dims: { h: number; bar: number }): number {
const set = typeof cropTop === 'number' ? cropTop : cropTop?.[device];
return set ?? defaultCropTop(h, dims.bar, dims.h + dims.bar);
}
/** ffmpeg argv: crop `top` rows, write 24-bit RGB PNG. */ /** ffmpeg argv: crop `top` rows, write 24-bit RGB PNG. */
export const cropArgs = (inp: string, out: string, top: number): string[] => export const cropArgs = (inp: string, out: string, top: number): string[] =>
['-v', 'error', '-y', '-i', inp, ...(top > 0 ? ['-vf', `crop=iw:ih-${top}:0:${top}`] : []), '-pix_fmt', 'rgb24', out]; ['-v', 'error', '-y', '-i', inp, ...(top > 0 ? ['-vf', `crop=iw:ih-${top}:0:${top}`] : []), '-pix_fmt', 'rgb24', out];

View file

@ -74,8 +74,21 @@ export function validateCopy(copy: CopyFile, shots: ShotsConfig, langs: string[]
return e; return e;
} }
export const DEFAULT_PHONE = { w: 440, h: 902, dpr: 3, bar: 54 }; export interface FrameDims { w: number; h: number; dpr: number; bar: number }
export const DEFAULT_TABLET = { w: 800, h: 1240, dpr: 2, bar: 40 };
/** Raw frame size in CSS px below the status bar (bar = status bar height in CSS px, drawn by the template).
* Phone: 6.9" iPhone (440 x 956 pt, 54 pt bar). Tablet: a generic Android tablet (Play 7" / 10"). */
export const DEFAULT_PHONE: FrameDims = { w: 440, h: 902, dpr: 3, bar: 54 };
export const DEFAULT_TABLET: FrameDims = { w: 800, h: 1240, dpr: 2, bar: 40 };
/** 13" iPad (iPad Pro M4 / M5, iPad Air 13" M2+): 1032 x 1376 pt @2x = 2064 x 2752 px, 24 pt status bar. The tablet
* default when apple.ipad is set, so a simulator screenshot of a 13" iPad fits the frame after cropping the bar. */
export const DEFAULT_IPAD: FrameDims = { w: 1032, h: 1352, dpr: 2, bar: 24 };
/** Phone / tablet frame dims for a project: defaults (tablet follows the 13" iPad when apple.ipad) + shots.phone / tablet. */
export function frameDims(config: Pick<ShipConfig, 'apple' | 'shots'>): Record<'phone' | 'tablet', FrameDims> {
const tablet = config.apple?.ipad ? DEFAULT_IPAD : DEFAULT_TABLET;
return { phone: { ...DEFAULT_PHONE, ...config.shots?.phone }, tablet: { ...tablet, ...config.shots?.tablet } };
}
/** Size keys this project renders by default: Apple sizes only with an apple section (iPad only with apple.ipad), /** Size keys this project renders by default: Apple sizes only with an apple section (iPad only with apple.ipad),
* Play sizes only with a play section (both when neither is configured). */ * Play sizes only with a play section (both when neither is configured). */

View file

@ -12,7 +12,7 @@ import type { Ctx } from '../lib/ctx';
import { need } from '../lib/ctx'; import { need } from '../lib/ctx';
import { done, log, warn } from '../lib/log'; import { done, log, warn } from '../lib/log';
import { launch } from './browser'; import { launch } from './browser';
import { type CopyFile, DEFAULT_PHONE, DEFAULT_TABLET, SIZES, copyText, defaultSizes, mergeCopy, palette, renderDir, scriptFont, validateCopy, variantScenes } from './lib'; import { type CopyFile, SIZES, copyText, defaultSizes, frameDims, mergeCopy, palette, renderDir, scriptFont, validateCopy, variantScenes } from './lib';
import { type RenderReport, mergeReport, readReport } from './report'; import { type RenderReport, mergeReport, readReport } from './report';
const TYPES: Record<string, string> = { html: 'text/html; charset=utf-8', png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', const TYPES: Record<string, string> = { html: 'text/html; charset=utf-8', png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg',
@ -39,7 +39,7 @@ export async function run(ctx: Ctx): Promise<void> {
const framesDir = resolve(shots.frames), outDir = resolve(shots.out); const framesDir = resolve(shots.frames), outDir = resolve(shots.out);
const fontsDir = join(root, '.storebound', 'fonts'); const fontsDir = join(root, '.storebound', 'fonts');
if (!existsSync(join(fontsDir, 'fonts.css'))) warn('shots', 'no .storebound/fonts/fonts.css: run `storebound shots fonts` first (falling back to system fonts)'); if (!existsSync(join(fontsDir, 'fonts.css'))) warn('shots', 'no .storebound/fonts/fonts.css: run `storebound shots fonts` first (falling back to system fonts)');
const phone = { ...DEFAULT_PHONE, ...shots.phone }, tablet = { ...DEFAULT_TABLET, ...shots.tablet }; const { phone, tablet } = frameDims(config);
const rtl = new Map(config.languages.map(l => [l.id, !!l.rtl] as const)); const rtl = new Map(config.languages.map(l => [l.id, !!l.rtl] as const));
const fonts = { title: shots.fonts?.title ?? 'Lilita One', body: shots.fonts?.body ?? 'Montserrat' }; const fonts = { title: shots.fonts?.title ?? 'Lilita One', body: shots.fonts?.body ?? 'Montserrat' };
const tpl = import.meta.dir; const tpl = import.meta.dir;

View file

@ -39,7 +39,8 @@ const config: ShipConfig = {
// Export compliance (export-compliance skill). false ONLY if the game uses no encryption beyond the OS (HTTPS through // Export compliance (export-compliance skill). false ONLY if the game uses no encryption beyond the OS (HTTPS through
// the system). Left unset on purpose: decide it, then uncomment. Same answer as ITSAppUsesNonExemptEncryption. // the system). Left unset on purpose: decide it, then uncomment. Same answer as ITSAppUsesNonExemptEncryption.
// usesNonExemptEncryption: false, // usesNonExemptEncryption: false,
// screenshotTypes: ['APP_IPHONE_67'], // what `storebound validate` requires per locale; iPad apps add APP_IPAD_PRO_3GEN_129 // ipad: true, // the app runs on iPad: 13" iPad screenshots (2064 x 2752, ipad13) are rendered, checked and uploaded
// screenshotTypes: ['APP_IPHONE_67'], // what `storebound validate` requires per locale (default; + APP_IPAD_PRO_3GEN_129 with ipad)
info: { info: {
categories: { primary: 'GAMES', primarySubOne: 'GAMES_CASUAL', primarySubTwo: 'GAMES_PUZZLE', secondary: 'ENTERTAINMENT' }, categories: { primary: 'GAMES', primarySubOne: 'GAMES_CASUAL', primarySubTwo: 'GAMES_PUZZLE', secondary: 'ENTERTAINMENT' },
ageRating: { advertising: true }, // everything else NONE / false ageRating: { advertising: true }, // everything else NONE / false
@ -106,6 +107,7 @@ const config: ShipConfig = {
logo: 'store/shots/logo.png', // optional: hero scene + feature graphic logo: 'store/shots/logo.png', // optional: hero scene + feature graphic
fonts: { title: 'Lilita One', body: 'Montserrat' }, fonts: { title: 'Lilita One', body: 'Montserrat' },
// phone: { w: 440, h: 902, dpr: 3 }, // raw frame size in CSS px (screen below a 54 px status bar) // phone: { w: 440, h: 902, dpr: 3 }, // raw frame size in CSS px (screen below a 54 px status bar)
// tablet: { w: 1032, h: 1352, dpr: 2 }, // default with apple.ipad (13" iPad below its 24 px bar), else 800 x 1240
scenes: [ scenes: [
{ id: 'hero', palette: 'fire', hero: true, over: 34, frames: [{ src: 'hero.png', rotate: -4 }], { id: 'hero', palette: 'fire', hero: true, over: 34, frames: [{ src: 'hero.png', rotate: -4 }],
badges: [{ y: 0.42, side: 'l', icon: 'flag', iconBg: 'red', rot: -4 }, { y: 0.66, side: 'r', icon: 'offline', iconBg: 'red', rot: 3 }] }, badges: [{ y: 0.42, side: 'l', icon: 'flag', iconBg: 'red', rot: -4 }, { y: 0.66, side: 'r', icon: 'offline', iconBg: 'red', rot: 3 }] },