Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

mobile-showcase.config.ts

230 lines7.3 KB

1import {
2 MOBILE_DEFAULT_THEME_ID,
3 MOBILE_THEME_IDS,
4 type MobileThemeId,
5} from "@t3tools/shared/themePalettes";
6​
7import { SHOWCASE_SCENES, type ShowcaseScene } from "./mobile-showcase-environment.ts";
8​
9export { SHOWCASE_SCENES };
10export type { ShowcaseScene };
11​
12export type ShowcaseAppearance = "light" | "dark";
13​
14/** Every palette the mobile appearance settings can select. */
15export const SHOWCASE_THEMES = MOBILE_THEME_IDS;
16export const DEFAULT_SHOWCASE_THEME = MOBILE_DEFAULT_THEME_ID;
17export type ShowcaseTheme = MobileThemeId;
18​
19export interface ShowcaseStoreAssetSpec {
20 readonly store: "apple" | "google-play";
21 /** Device directory relative to ShowcaseConfig.outputDirectory. */
22 readonly directory: string;
23 readonly width: number;
24 readonly height: number;
25 readonly minimumUploadCount: number;
26 readonly maximumUploadCount: number;
27 readonly maximumFileSizeBytes?: number;
29​
30export interface ShowcaseIosDevice {
31 readonly id: string;
32 readonly platform: "ios";
33 /** Exact name from `xcrun simctl list devices available`. */
34 readonly simulator: string;
35 /** Device type used to create a disposable simulator when the named one is absent. */
36 readonly simulatorDeviceType?: string;
37 /** Appearance used when the CLI does not pass --appearance. */
38 readonly appearance: ShowcaseAppearance;
39 /** Palette used when the CLI does not pass --theme. */
40 readonly theme: ShowcaseTheme;
41 /** Orientation applied by the capture harness. Defaults to portrait. */
42 readonly orientation?: "portrait" | "landscape";
43 readonly scenes: ReadonlyArray<ShowcaseScene>;
44 readonly storeAsset: ShowcaseStoreAssetSpec;
46​
47export interface ShowcaseAndroidDevice {
48 readonly id: string;
49 readonly platform: "android";
50 /** Exact name from `emulator -list-avds`. */
51 readonly avd: string;
52 /** Appearance used when the CLI does not pass --appearance. */
53 readonly appearance: ShowcaseAppearance;
54 /** Palette used when the CLI does not pass --theme. */
55 readonly theme: ShowcaseTheme;
56 /** Native ABI used by the AVD, from its config.ini `abi.type`. */
57 readonly abi?: "arm64-v8a" | "x86_64" | "x86" | "armeabi-v7a";
58 readonly scenes: ReadonlyArray<ShowcaseScene>;
59 /** Optional capture viewport. Omit to use the AVD's native size and density. */
60 readonly viewport?: {
61 readonly width: number;
62 readonly height: number;
63 readonly density?: number;
64 };
65 readonly storeAsset: ShowcaseStoreAssetSpec;
67​
68export type ShowcaseDevice = ShowcaseIosDevice | ShowcaseAndroidDevice;
69​
70export interface ShowcaseConfig {
71 readonly outputDirectory: string;
72 readonly metroPort: number;
73 readonly settleDelayMs: number;
74 readonly devices: ReadonlyArray<ShowcaseDevice>;
76​
77const ANDROID_ABIS = ["arm64-v8a", "x86_64", "x86", "armeabi-v7a"] as const;
78​
79export function resolveShowcaseAndroidAbi(
80 value: string | undefined,
81): NonNullable<ShowcaseAndroidDevice["abi"]> {
82 if (!value) return "arm64-v8a";
83 if (ANDROID_ABIS.some((abi) => abi === value)) {
84 return value as NonNullable<ShowcaseAndroidDevice["abi"]>;
85 }
86 throw new Error(
87 `Unsupported T3_SHOWCASE_ANDROID_ABI '${value}'. Use ${ANDROID_ABIS.join(", ")}.`,
88 );
90​
91/**
92 * The defaults cover every App Store Connect and Google Play upload slot used
93 * by the mobile app. Edit this matrix (or pass --device / --scene) without
94 * changing the runner. Every target declares and validates its exact upload
95 * dimensions so SDK or emulator changes cannot silently produce invalid files.
96 */
97const config: ShowcaseConfig = {
98 outputDirectory: "artifacts/app-store/screenshots",
99 // Dedicated port so the harness cannot attach to a normal mobile dev server
100 // (or a second worktree) and capture the wrong bundle.
101 metroPort: 8199,
102 settleDelayMs: 2_500,
103 devices: [
104 {
105 id: "iphone-6.9",
106 platform: "ios",
107 simulator: "iPhone 17 Pro Max",
108 simulatorDeviceType: "com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro-Max",
109 appearance: "dark",
110 theme: DEFAULT_SHOWCASE_THEME,
111 scenes: ["thread", "terminal", "review", "threads", "environments"],
112 storeAsset: {
113 store: "apple",
114 directory: "apple/iphone-6.9",
115 width: 1320,
116 height: 2868,
117 minimumUploadCount: 1,
118 maximumUploadCount: 10,
119 },
120 },
121 {
122 id: "iphone-6.5",
123 platform: "ios",
124 simulator: "T3 Showcase iPhone 14 Plus",
125 simulatorDeviceType: "com.apple.CoreSimulator.SimDeviceType.iPhone-14-Plus",
126 appearance: "dark",
127 theme: DEFAULT_SHOWCASE_THEME,
128 scenes: ["thread", "terminal", "review", "threads", "environments"],
129 storeAsset: {
130 store: "apple",
131 directory: "apple/iphone-6.5",
132 width: 1284,
133 height: 2778,
134 minimumUploadCount: 1,
135 maximumUploadCount: 10,
136 },
137 },
138 {
139 id: "ipad-13",
140 platform: "ios",
141 simulator: "iPad Pro 13-inch (M5)",
142 simulatorDeviceType: "com.apple.CoreSimulator.SimDeviceType.iPad-Pro-13-inch-M5-16GB",
143 appearance: "dark",
144 theme: DEFAULT_SHOWCASE_THEME,
145 orientation: "landscape",
146 scenes: ["thread", "terminal", "review", "threads", "environments"],
147 storeAsset: {
148 store: "apple",
149 directory: "apple/ipad-13",
150 width: 2752,
151 height: 2064,
152 minimumUploadCount: 1,
153 maximumUploadCount: 10,
154 },
155 },
156 {
157 id: "pixel",
158 platform: "android",
159 avd: "Pixel_10_Pro",
160 // Apple Silicon uses ARM64 locally; CI overrides this with x86_64 so its
161 // Blacksmith Linux runner can use KVM acceleration.
162 abi: resolveShowcaseAndroidAbi(process.env.T3_SHOWCASE_ANDROID_ABI),
163 appearance: "dark",
164 theme: DEFAULT_SHOWCASE_THEME,
165 viewport: {
166 width: 1080,
167 height: 1920,
168 density: 420,
169 },
170 scenes: ["thread", "terminal", "review", "threads", "environments"],
171 storeAsset: {
172 store: "google-play",
173 directory: "google-play/phone",
174 width: 1080,
175 height: 1920,
176 minimumUploadCount: 2,
177 maximumUploadCount: 8,
178 maximumFileSizeBytes: 8 * 1024 * 1024,
179 },
180 },
181 {
182 id: "android-tablet-7",
183 platform: "android",
184 avd: "Pixel_10_Pro",
185 abi: resolveShowcaseAndroidAbi(process.env.T3_SHOWCASE_ANDROID_ABI),
186 appearance: "dark",
187 theme: DEFAULT_SHOWCASE_THEME,
188 viewport: {
189 width: 1080,
190 height: 1920,
191 density: 288,
192 },
193 scenes: ["thread", "terminal", "review", "threads", "environments"],
194 storeAsset: {
195 store: "google-play",
196 directory: "google-play/tablet-7",
197 width: 1080,
198 height: 1920,
199 minimumUploadCount: 4,
200 maximumUploadCount: 8,
201 maximumFileSizeBytes: 8 * 1024 * 1024,
202 },
203 },
204 {
205 id: "android-tablet-10",
206 platform: "android",
207 avd: "Pixel_10_Pro",
208 abi: resolveShowcaseAndroidAbi(process.env.T3_SHOWCASE_ANDROID_ABI),
209 appearance: "dark",
210 theme: DEFAULT_SHOWCASE_THEME,
211 viewport: {
212 width: 1440,
213 height: 2560,
214 density: 288,
215 },
216 scenes: ["thread", "terminal", "review", "threads", "environments"],
217 storeAsset: {
218 store: "google-play",
219 directory: "google-play/tablet-10",
220 width: 1440,
221 height: 2560,
222 minimumUploadCount: 4,
223 maximumUploadCount: 8,
224 maximumFileSizeBytes: 8 * 1024 * 1024,
225 },
226 },
227 ],
228};
229​
230export default config;