Open History to see the last commit
1import type { ExpoConfig } from "expo/config";
2
3import { BRAND_ASSET_PATHS } from "../../scripts/lib/brand-assets.ts";
4import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
5
6type AppVariant = "development" | "preview" | "production";
7
8const repoEnv = loadRepoEnv();
9Object.assign(process.env, repoEnv);
10
11const APP_VARIANT = resolveAppVariant(repoEnv.APP_VARIANT);
12const isIosPersonalTeamBuild = repoEnv.T3CODE_IOS_PERSONAL_TEAM === "1";
13const runtimeVersionPolicy =
14 process.env.MOBILE_VERSION_POLICY ??
15 (APP_VARIANT === "development" ? "appVersion" : "fingerprint");
16
17const personalTeamBundleIdentifier = repoEnv.T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID?.trim();
18const IOS_BUNDLE_IDENTIFIER_PATTERN = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
19
20// Compiled into the native project. Without a relay, Observe's native side could dispatch to
21// Expo's own ingest before observe.ts turns it off; `.invalid` never resolves (RFC 6761).
22const observeEndpointUrl = repoEnv.T3CODE_RELAY_URL?.trim()
23 ? new URL("/v1/mobile/observe", repoEnv.T3CODE_RELAY_URL.trim()).toString()
24 : "https://observe.invalid";
25
26const fromRepoRoot = (relativePath: string) => `../../${relativePath}`;
27const androidAdaptiveForeground = "./assets/android-icon-foreground.png";
28
29if (
30 isIosPersonalTeamBuild &&
31 (!personalTeamBundleIdentifier ||
32 !IOS_BUNDLE_IDENTIFIER_PATTERN.test(personalTeamBundleIdentifier))
33) {
34 throw new Error(
35 "T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID must be a reverse-DNS identifier such as com.example.t3code when T3CODE_IOS_PERSONAL_TEAM=1.",
36 );
37}
38
39const DEVELOPMENT_ASSETS = {
40 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
41 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIconComposerProject),
42 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
43 androidAdaptiveForeground,
44 androidAdaptiveBackgroundColor: "#347FF8",
45 androidAdaptiveBackgroundImage: "./assets/android-icon-background-dev.png",
46 androidSplashIcon: "./assets/android-splash-icon-dev.png",
47 androidMonochromeIcon: "./assets/android-icon-mark.png",
48 androidNotificationIcon: "./assets/android-notification-icon.png",
49 androidNotificationColor: "#00639B",
50} as const;
51
52const PREVIEW_ASSETS = {
53 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
54 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIconComposerProject),
55 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
56 androidAdaptiveForeground,
57 androidAdaptiveBackgroundColor: "#111533",
58 androidAdaptiveBackgroundImage: "./assets/android-icon-background-nightly.png",
59 androidSplashIcon: "./assets/android-splash-icon-nightly.png",
60 androidMonochromeIcon: "./assets/android-icon-mark.png",
61 androidNotificationIcon: "./assets/android-notification-icon.png",
62 androidNotificationColor: "#7565C7",
63} as const;
64
65const RELEASE_ASSETS = {
66 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
67 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIconComposerProject),
68 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
69 androidAdaptiveForeground,
70 androidAdaptiveBackgroundColor: "#000000",
71 androidAdaptiveBackgroundImage: undefined,
72 androidSplashIcon: "./assets/android-splash-icon-prod.png",
73 androidMonochromeIcon: "./assets/android-icon-mark.png",
74 androidNotificationIcon: "./assets/android-notification-icon.png",
75 androidNotificationColor: "#FFFFFF",
76} as const;
77
78const VARIANT_CONFIG = {
79 development: {
80 appName: "T3 Code Dev",
81 scheme: "t3code-dev",
82 iosBundleIdentifier: "com.t3tools.t3code.dev",
83 androidPackage: "com.t3tools.t3code.dev",
84 relyingParty: "clerk.t3.codes",
85 assets: DEVELOPMENT_ASSETS,
86 },
87 preview: {
88 appName: "T3 Code Preview",
89 scheme: "t3code-preview",
90 iosBundleIdentifier: "com.t3tools.t3code.preview",
91 androidPackage: "com.t3tools.t3code.preview",
92 relyingParty: "clerk.t3.codes",
93 assets: PREVIEW_ASSETS,
94 },
95 production: {
96 appName: "T3 Code",
97 scheme: "t3code",
98 iosBundleIdentifier: "com.t3tools.t3code",
99 androidPackage: "com.t3tools.t3code",
100 relyingParty: "clerk.t3.codes",
101 assets: RELEASE_ASSETS,
102 },
103} as const;
104
105function resolveAppVariant(value: string | undefined): AppVariant {
106 switch (value) {
107 case "development":
108 case "preview":
109 case "production":
110 return value;
111 default:
112 return "production";
113 }
114}
115
116const variant = VARIANT_CONFIG[APP_VARIANT];
117const iosBundleIdentifier = isIosPersonalTeamBuild
118 ? personalTeamBundleIdentifier!
119 : variant.iosBundleIdentifier;
120
121const dmSansFonts = {
122 regular: "@expo-google-fonts/dm-sans/400Regular/DMSans_400Regular.ttf",
123 medium: "@expo-google-fonts/dm-sans/500Medium/DMSans_500Medium.ttf",
124 bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
125} as const;
126
127const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
128 "expo-widgets",
129 {
130 bundleIdentifier: `${iosBundleIdentifier}.widgets`,
131 groupIdentifier: `group.${iosBundleIdentifier}`,
132 enablePushNotifications: true,
133 // Frequent updates need the iOS entitlement to avoid early throttling.
134 frequentUpdates: true,
135 enableAndroid: true,
136 widgets: [
137 {
138 name: "SubscriptionUsage",
139 displayName: "Subscription usage",
140 description: "Subscription quotas from your connected T3 Code environments.",
141 ios: {
142 configuration: {
143 title: "Subscription usage",
144 description:
145 "Both shows Session and Weekly when available. The Lock Screen shows the tightest selected limit.",
146 parameters: {
147 codexPeriod: {
148 title: "Codex limits",
149 type: "enum",
150 default: "auto",
151 values: [
152 { name: "Both", value: "auto" },
153 { name: "Session", value: "session" },
154 { name: "Weekly", value: "weekly" },
155 ],
156 },
157 claudePeriod: {
158 title: "Claude limits",
159 type: "enum",
160 default: "auto",
161 values: [
162 { name: "Both", value: "auto" },
163 { name: "Session", value: "session" },
164 { name: "Weekly", value: "weekly" },
165 ],
166 },
167 },
168 },
169 supportedFamilies: [
170 "systemSmall",
171 "systemMedium",
172 "systemLarge",
173 "systemExtraLarge",
174 "accessoryRectangular",
175 ],
176 },
177 android: {
178 minWidth: 250,
179 minHeight: 180,
180 targetCellWidth: 4,
181 targetCellHeight: 3,
182 resizeMode: "both",
183 // The embedded layout renders before first launch; publishing replaces it with stored props.
184 initialLayout: "./src/widgets/SubscriptionUsage.android.tsx",
185 },
186 },
187 {
188 name: "AgentActivity",
189 displayName: "Agent Activity",
190 description: "Shows the current state of active T3 Code agents.",
191 android: null,
192 ios: { supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"] },
193 },
194 ],
195 },
196];
197
198const sharingPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
199 "expo-sharing",
200 {
201 ios: {
202 // Personal Teams cannot sign App Groups or extension targets; keep local builds usable.
203 enabled: !isIosPersonalTeamBuild,
204 extensionBundleIdentifier: `${iosBundleIdentifier}.sharing`,
205 appGroupId: `group.${iosBundleIdentifier}`,
206 activationRule: {
207 supportsText: true,
208 supportsWebUrlWithMaxCount: 1,
209 supportsImageWithMaxCount: 8,
210 supportsMovieWithMaxCount: 8,
211 supportsFileWithMaxCount: 8,
212 },
213 },
214 android: {
215 enabled: true,
216 singleShareMimeTypes: ["*/*"],
217 multipleShareMimeTypes: ["*/*"],
218 },
219 },
220];
221
222// Match iOS PostScript names on Android so RN and the native composer share fonts before runtime loading.
223
224const config: ExpoConfig = {
225 name: variant.appName,
226 slug: "t3-code",
227 platforms: ["ios", "android"],
228 scheme: variant.scheme,
229 version: repoEnv.T3CODE_MOBILE_VERSION ?? "2.2.0",
230 runtimeVersion: {
231 // Skip costly fingerprinting on dev launches; preview and production OTAs require matching native projects.
232 policy: runtimeVersionPolicy,
233 },
234 orientation: "portrait",
235 icon: variant.assets.appIcon,
236 userInterfaceStyle: "automatic",
237 updates: {
238 enabled: repoEnv.T3CODE_MOBILE_UPDATES_ENABLED !== "0",
239 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
240 checkAutomatically: "ON_LOAD",
241 fallbackToCacheTimeout: 0,
242 },
243 ios: {
244 icon: variant.assets.iosIcon,
245 supportsTablet: true,
246 requireFullScreen: process.env.T3_SHOWCASE_CAPTURE_BUILD === "1",
247 bundleIdentifier: iosBundleIdentifier,
248 // Avoid Personal Team fallback: it cannot sign App Groups, Apple sign-in or push entitlements.
249 appleTeamId: "ARK85ZXQ4Z",
250 associatedDomains: [
251 `applinks:${variant.relyingParty}`,
252 `webcredentials:${variant.relyingParty}`,
253 ],
254 entitlements: {
255 "keychain-access-groups": [`$(AppIdentifierPrefix)${variant.iosBundleIdentifier}`],
256 },
257 infoPlist: {
258 UISupportedInterfaceOrientations: [
259 "UIInterfaceOrientationPortrait",
260 "UIInterfaceOrientationLandscapeLeft",
261 "UIInterfaceOrientationLandscapeRight",
262 ],
263 NSAppTransportSecurity: {
264 NSAllowsArbitraryLoads: true,
265 },
266 NSLocalNetworkUsageDescription:
267 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
268 NSPhotoLibraryAddUsageDescription: "Allow T3 Code to save images to your photo library.",
269 // System picture in picture needs background audio to start and survive outside the app.
270 UIBackgroundModes: ["audio"],
271 ITSAppUsesNonExemptEncryption: false,
272 // Capture builds disable multitasking because iPadOS otherwise ignores orientation requests.
273 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
274 ? {
275 "UISupportedInterfaceOrientations~ipad": [
276 "UIInterfaceOrientationPortrait",
277 "UIInterfaceOrientationPortraitUpsideDown",
278 "UIInterfaceOrientationLandscapeLeft",
279 "UIInterfaceOrientationLandscapeRight",
280 ],
281 }
282 : {}),
283 },
284 },
285 android: {
286 icon: variant.assets.appIcon,
287 package: variant.androidPackage,
288 ...(repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE
289 ? { googleServicesFile: repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE }
290 : {}),
291 adaptiveIcon: {
292 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
293 ...(variant.assets.androidAdaptiveBackgroundImage
294 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
295 : {}),
296 foregroundImage: variant.assets.androidAdaptiveForeground,
297 monochromeImage: variant.assets.androidMonochromeIcon,
298 },
299 // JS back dispatch needs RN's Android 16 shim and withAndroidPredictiveBackCompat on Android 13-15.
300 predictiveBackGestureEnabled: true,
301 // expo-sensors declares this for its pedometer, which the app does not use.
302 blockedPermissions: ["android.permission.ACTIVITY_RECOGNITION"],
303 },
304 web: {
305 favicon: variant.assets.appIcon,
306 },
307 plugins: [
308 "expo-asset",
309 "react-native-pdf-jsi",
310 [
311 "expo-font",
312 {
313 ios: {
314 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
315 },
316 android: {
317 fonts: [
318 {
319 fontFamily: "DMSans-Regular",
320 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
321 },
322 {
323 fontFamily: "DMSans-Medium",
324 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
325 },
326 {
327 fontFamily: "DMSans-Bold",
328 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
329 },
330 ],
331 },
332 },
333 ],
334 "expo-secure-store",
335 "expo-sqlite",
336 ...(isIosPersonalTeamBuild
337 ? [sharingPlugin]
338 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
339 [
340 "expo-notifications",
341 {
342 icon: variant.assets.androidNotificationIcon,
343 color: variant.assets.androidNotificationColor,
344 mode: APP_VARIANT === "development" ? "development" : "production",
345 },
346 ],
347 // Gate Clerk here: withoutIosPersonalTeamCapabilities runs too early to strip its entitlement.
348 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
349 "expo-web-browser",
350 [
351 "expo-quick-actions",
352 {
353 androidIcons: {
354 shortcut_icon: {
355 foregroundImage: variant.assets.androidAdaptiveForeground,
356 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
357 ...(variant.assets.androidAdaptiveBackgroundImage
358 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
359 : {}),
360 },
361 },
362 },
363 ],
364 [
365 "expo-audio",
366 {
367 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
368 recordAudioAndroid: false,
369 enableBackgroundPlayback: false,
370 enableBackgroundRecording: false,
371 },
372 ],
373 [
374 "expo-camera",
375 {
376 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
377 microphonePermission: false,
378 barcodeScannerEnabled: true,
379 recordAudioAndroid: false,
380 },
381 ],
382 ["expo-image-picker", { photosPermission: false, microphonePermission: false }],
383 [
384 "expo-splash-screen",
385 {
386 image: variant.assets.splashIcon,
387 resizeMode: "contain",
388 backgroundColor: "#ffffff",
389 imageWidth: 220,
390 dark: {
391 image: variant.assets.splashIcon,
392 backgroundColor: "#0a0a0a",
393 },
394 android: {
395 // Android 12+ masks the central two thirds of the 288dp canvas; adaptive layers avoid clipped corners.
396 image: variant.assets.androidSplashIcon,
397 imageWidth: 288,
398 dark: { image: variant.assets.androidSplashIcon },
399 },
400 },
401 ],
402 [
403 "expo-build-properties",
404 {
405 android: {
406 minSdkVersion: 24,
407 // SDK 58 lacks Kotlin 2.3's runtime-inert annotation. R8 needs explicit InputMerger constructors for widgets.
408 extraProguardRules: [
409 "-dontwarn kotlin.MustUseReturnValues",
410 "-keep class * extends androidx.work.InputMerger { <init>(); }",
411 ].join("\n"),
412 },
413 ios: {
414 deploymentTarget: "18.0",
415 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
416 extraPods: [
417 { name: "GoogleUtilities", modular_headers: true },
418 { name: "RecaptchaInterop", modular_headers: true },
419 ],
420 },
421 },
422 ],
423 "./plugins/withIosCocoaPodsUuidCache.cjs",
424 // Compile out the unused pedometer to avoid an iOS motion purpose string.
425 ["expo-sensors", { motionPermission: false }],
426 // Mods run in reverse order; expo-widgets must create and wipe the target before assets are added.
427 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
428 "./plugins/withAndroidNetworkSecurityConfig.cjs",
429 "./plugins/withAndroidGradleHeap.cjs",
430 "./plugins/withAndroidInputBackground.cjs",
431 "./plugins/withAndroidModernPopupMenu.cjs",
432 "./plugins/withAndroidModernAlertDialog.cjs",
433 "./plugins/withAndroidPredictiveBackCompat.cjs",
434 "./plugins/withAndroidTabletOrientation.cjs",
435 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
436 ],
437 extra: {
438 appVariant: APP_VARIANT,
439 iosPersonalTeamBuild: isIosPersonalTeamBuild,
440 relay: {
441 url: repoEnv.T3CODE_RELAY_URL ?? null,
442 },
443 clerk: {
444 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
445 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
446 },
447 // Clerk reads these exact names at prebuild. Omit unset values: manifest null becomes truthy {}.
448 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
449 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
450 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
451 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
452 observability: {
453 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
454 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
455 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
456 },
457 eas: {
458 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
459 observe: { endpointUrl: observeEndpointUrl },
460 },
461 },
462 owner: "pingdotgg",
463 experiments: {
464 // Metro only runs babel-plugin-react-compiler when this is set; see src/reactCompilerCoverage.test.ts.
465 reactCompiler: true,
466 },
467};
468
469export default config;