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
20const fromRepoRoot = (relativePath: string) => `../../${relativePath}`;
21const androidAdaptiveForeground = "./assets/android-icon-foreground.png";
22
23if (
24 isIosPersonalTeamBuild &&
25 (!personalTeamBundleIdentifier ||
26 !IOS_BUNDLE_IDENTIFIER_PATTERN.test(personalTeamBundleIdentifier))
27) {
28 throw new Error(
29 "T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID must be a reverse-DNS identifier such as com.example.t3code when T3CODE_IOS_PERSONAL_TEAM=1.",
30 );
31}
32
33const DEVELOPMENT_ASSETS = {
34 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
35 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIconComposerProject),
36 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
37 androidAdaptiveForeground,
38 androidAdaptiveBackgroundColor: "#347FF8",
39 androidAdaptiveBackgroundImage: "./assets/android-icon-background-dev.png",
40 androidSplashIcon: "./assets/android-splash-icon-dev.png",
41 androidMonochromeIcon: "./assets/android-icon-mark.png",
42 androidNotificationIcon: "./assets/android-notification-icon.png",
43 androidNotificationColor: "#00639B",
44} as const;
45
46const PREVIEW_ASSETS = {
47 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
48 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIconComposerProject),
49 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
50 androidAdaptiveForeground,
51 androidAdaptiveBackgroundColor: "#111533",
52 androidAdaptiveBackgroundImage: "./assets/android-icon-background-nightly.png",
53 androidSplashIcon: "./assets/android-splash-icon-nightly.png",
54 androidMonochromeIcon: "./assets/android-icon-mark.png",
55 androidNotificationIcon: "./assets/android-notification-icon.png",
56 androidNotificationColor: "#7565C7",
57} as const;
58
59const RELEASE_ASSETS = {
60 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
61 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIconComposerProject),
62 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
63 androidAdaptiveForeground,
64 androidAdaptiveBackgroundColor: "#000000",
65 androidAdaptiveBackgroundImage: undefined,
66 androidSplashIcon: "./assets/android-splash-icon-prod.png",
67 androidMonochromeIcon: "./assets/android-icon-mark.png",
68 androidNotificationIcon: "./assets/android-notification-icon.png",
69 androidNotificationColor: "#FFFFFF",
70} as const;
71
72const VARIANT_CONFIG = {
73 development: {
74 appName: "T3 Code Dev",
75 scheme: "t3code-dev",
76 iosBundleIdentifier: "com.t3tools.t3code.dev",
77 androidPackage: "com.t3tools.t3code.dev",
78 relyingParty: "clerk.t3.codes",
79 assets: DEVELOPMENT_ASSETS,
80 },
81 preview: {
82 appName: "T3 Code Preview",
83 scheme: "t3code-preview",
84 iosBundleIdentifier: "com.t3tools.t3code.preview",
85 androidPackage: "com.t3tools.t3code.preview",
86 relyingParty: "clerk.t3.codes",
87 assets: PREVIEW_ASSETS,
88 },
89 production: {
90 appName: "T3 Code",
91 scheme: "t3code",
92 iosBundleIdentifier: "com.t3tools.t3code",
93 androidPackage: "com.t3tools.t3code",
94 relyingParty: "clerk.t3.codes",
95 assets: RELEASE_ASSETS,
96 },
97} as const;
98
99function resolveAppVariant(value: string | undefined): AppVariant {
100 switch (value) {
101 case "development":
102 case "preview":
103 case "production":
104 return value;
105 default:
106 return "production";
107 }
108}
109
110const variant = VARIANT_CONFIG[APP_VARIANT];
111const iosBundleIdentifier = isIosPersonalTeamBuild
112 ? personalTeamBundleIdentifier!
113 : variant.iosBundleIdentifier;
114
115const dmSansFonts = {
116 regular: "@expo-google-fonts/dm-sans/400Regular/DMSans_400Regular.ttf",
117 medium: "@expo-google-fonts/dm-sans/500Medium/DMSans_500Medium.ttf",
118 bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
119} as const;
120
121const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
122 "expo-widgets",
123 {
124 bundleIdentifier: `${iosBundleIdentifier}.widgets`,
125 groupIdentifier: `group.${iosBundleIdentifier}`,
126 enablePushNotifications: true,
127 // Agent activity can update many times an hour; without the
128 // frequent-updates entitlement iOS throttles the update budget sooner.
129 frequentUpdates: true,
130 enableAndroid: true,
131 widgets: [
132 {
133 name: "SubscriptionUsage",
134 displayName: "Subscription usage",
135 description: "Subscription quotas from your connected T3 Code environments.",
136 ios: {
137 configuration: {
138 title: "Subscription usage",
139 description:
140 "Both shows Session and Weekly when available. The Lock Screen shows the tightest selected limit.",
141 parameters: {
142 codexPeriod: {
143 title: "Codex limits",
144 type: "enum",
145 default: "auto",
146 values: [
147 { name: "Both", value: "auto" },
148 { name: "Session", value: "session" },
149 { name: "Weekly", value: "weekly" },
150 ],
151 },
152 claudePeriod: {
153 title: "Claude limits",
154 type: "enum",
155 default: "auto",
156 values: [
157 { name: "Both", value: "auto" },
158 { name: "Session", value: "session" },
159 { name: "Weekly", value: "weekly" },
160 ],
161 },
162 },
163 },
164 supportedFamilies: [
165 "systemSmall",
166 "systemMedium",
167 "systemLarge",
168 "systemExtraLarge",
169 "accessoryRectangular",
170 ],
171 },
172 android: {
173 minWidth: 250,
174 minHeight: 180,
175 targetCellWidth: 4,
176 targetCellHeight: 3,
177 resizeMode: "both",
178 // Embeds the layout in the APK so the widget renders before the app
179 // has run once; the app replaces it with stored props on publish.
180 initialLayout: "./src/widgets/SubscriptionUsage.android.tsx",
181 },
182 },
183 {
184 name: "AgentActivity",
185 displayName: "Agent Activity",
186 description: "Shows the current state of active T3 Code agents.",
187 android: null,
188 ios: { supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"] },
189 },
190 ],
191 },
192];
193
194const sharingPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
195 "expo-sharing",
196 {
197 ios: {
198 // Personal Teams cannot sign App Groups or extension targets. Keep the
199 // reduced-capability local build usable while release builds expose the
200 // real system share target.
201 enabled: !isIosPersonalTeamBuild,
202 extensionBundleIdentifier: `${iosBundleIdentifier}.sharing`,
203 appGroupId: `group.${iosBundleIdentifier}`,
204 activationRule: {
205 supportsText: true,
206 supportsWebUrlWithMaxCount: 1,
207 supportsImageWithMaxCount: 8,
208 supportsMovieWithMaxCount: 8,
209 supportsFileWithMaxCount: 8,
210 },
211 },
212 android: {
213 enabled: true,
214 singleShareMimeTypes: ["*/*"],
215 multipleShareMimeTypes: ["*/*"],
216 },
217 },
218];
219
220// These aliases match the fonts' PostScript names on iOS. Register the same
221// names on Android so React Native and the native composer use one set of
222// family names without waiting for runtime font 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.0.0",
230 runtimeVersion: {
231 // Development manifests resolve on every launch, so avoid fingerprint's
232 // expensive native-project calculation there. Preview and production stay
233 // fingerprinted so OTAs only reach binaries with matching native projects.
234 policy: runtimeVersionPolicy,
235 },
236 orientation: "portrait",
237 icon: variant.assets.appIcon,
238 userInterfaceStyle: "automatic",
239 updates: {
240 enabled: repoEnv.T3CODE_MOBILE_UPDATES_ENABLED !== "0",
241 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
242 checkAutomatically: "ON_LOAD",
243 fallbackToCacheTimeout: 0,
244 },
245 ios: {
246 icon: variant.assets.iosIcon,
247 supportsTablet: true,
248 requireFullScreen: process.env.T3_SHOWCASE_CAPTURE_BUILD === "1",
249 bundleIdentifier: iosBundleIdentifier,
250 // Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
251 // does not fall back to a personal team (which cannot sign app groups,
252 // Sign in with Apple, or push notification entitlements).
253 appleTeamId: "ARK85ZXQ4Z",
254 associatedDomains: [
255 `applinks:${variant.relyingParty}`,
256 `webcredentials:${variant.relyingParty}`,
257 ],
258 entitlements: {
259 "keychain-access-groups": [`$(AppIdentifierPrefix)${variant.iosBundleIdentifier}`],
260 },
261 infoPlist: {
262 UISupportedInterfaceOrientations: [
263 "UIInterfaceOrientationPortrait",
264 "UIInterfaceOrientationLandscapeLeft",
265 "UIInterfaceOrientationLandscapeRight",
266 ],
267 NSAppTransportSecurity: {
268 NSAllowsArbitraryLoads: true,
269 },
270 NSLocalNetworkUsageDescription:
271 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
272 NSPhotoLibraryAddUsageDescription: "Allow T3 Code to save images to your photo library.",
273 // "Audio, AirPlay, and Picture in Picture": the browser screen's system
274 // picture in picture needs it to start and to stay up outside the app.
275 UIBackgroundModes: ["audio"],
276 ITSAppUsesNonExemptEncryption: false,
277 // The App Store screenshot harness rotates the iPad interface from
278 // inside the app (CI denies osascript the Accessibility access that
279 // Simulator menu scripting needs), and iPadOS ignores programmatic
280 // orientation requests for multitasking-capable apps — so the capture
281 // build opts out of multitasking and declares landscape support.
282 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
283 ? {
284 "UISupportedInterfaceOrientations~ipad": [
285 "UIInterfaceOrientationPortrait",
286 "UIInterfaceOrientationPortraitUpsideDown",
287 "UIInterfaceOrientationLandscapeLeft",
288 "UIInterfaceOrientationLandscapeRight",
289 ],
290 }
291 : {}),
292 },
293 },
294 android: {
295 icon: variant.assets.appIcon,
296 package: variant.androidPackage,
297 ...(repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE
298 ? { googleServicesFile: repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE }
299 : {}),
300 adaptiveIcon: {
301 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
302 ...(variant.assets.androidAdaptiveBackgroundImage
303 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
304 : {}),
305 foregroundImage: variant.assets.androidAdaptiveForeground,
306 monochromeImage: variant.assets.androidMonochromeIcon,
307 },
308 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
309 // JS back handling survives it via react-native's Android 16 shim plus
310 // withAndroidPredictiveBackCompat on Android 13-15.
311 predictiveBackGestureEnabled: true,
312 // expo-sensors declares this for its pedometer, which the app does not use.
313 blockedPermissions: ["android.permission.ACTIVITY_RECOGNITION"],
314 },
315 web: {
316 favicon: variant.assets.appIcon,
317 },
318 plugins: [
319 "expo-asset",
320 "react-native-pdf-jsi",
321 [
322 "expo-font",
323 {
324 ios: {
325 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
326 },
327 android: {
328 fonts: [
329 {
330 fontFamily: "DMSans-Regular",
331 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
332 },
333 {
334 fontFamily: "DMSans-Medium",
335 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
336 },
337 {
338 fontFamily: "DMSans-Bold",
339 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
340 },
341 ],
342 },
343 },
344 ],
345 "expo-secure-store",
346 "expo-sqlite",
347 ...(isIosPersonalTeamBuild
348 ? [sharingPlugin]
349 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
350 [
351 "expo-notifications",
352 {
353 icon: variant.assets.androidNotificationIcon,
354 color: variant.assets.androidNotificationColor,
355 mode: APP_VARIANT === "development" ? "development" : "production",
356 },
357 ],
358 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
359 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
360 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
361 "expo-web-browser",
362 [
363 "expo-quick-actions",
364 {
365 // Adaptive launcher-shortcut icon; referenced by resource name from
366 // the shortcut items set in src/features/shortcuts.
367 androidIcons: {
368 shortcut_icon: {
369 foregroundImage: variant.assets.androidAdaptiveForeground,
370 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
371 ...(variant.assets.androidAdaptiveBackgroundImage
372 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
373 : {}),
374 },
375 },
376 },
377 ],
378 [
379 "expo-audio",
380 {
381 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
382 recordAudioAndroid: false,
383 enableBackgroundPlayback: false,
384 enableBackgroundRecording: false,
385 },
386 ],
387 [
388 "expo-camera",
389 {
390 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
391 microphonePermission: false,
392 barcodeScannerEnabled: true,
393 recordAudioAndroid: false,
394 },
395 ],
396 ["expo-image-picker", { photosPermission: false, microphonePermission: false }],
397 [
398 "expo-splash-screen",
399 {
400 image: variant.assets.splashIcon,
401 resizeMode: "contain",
402 backgroundColor: "#ffffff",
403 imageWidth: 220,
404 dark: {
405 image: variant.assets.splashIcon,
406 backgroundColor: "#0a0a0a",
407 },
408 android: {
409 // Android 12+ masks the splash icon to a circle over the central two thirds of
410 // its 288dp canvas, so the iOS export's corners get cut. A full-canvas image of
411 // the composed adaptive layers puts the wordmark in the same frame the launcher
412 // icon uses.
413 image: variant.assets.androidSplashIcon,
414 imageWidth: 288,
415 dark: { image: variant.assets.androidSplashIcon },
416 },
417 },
418 ],
419 [
420 "expo-build-properties",
421 {
422 android: {
423 minSdkVersion: 24,
424 // kotlinx-io uses Kotlin 2.3's return-value checker annotation, while
425 // SDK 58 builds with Kotlin 2.2. It has no runtime behavior.
426 // WorkManager 2.9 keeps InputMerger classes but not their constructors,
427 // and R8 full mode no longer keeps a default constructor implicitly.
428 // Without it no work request can start, so the Glance session behind
429 // the widget never renders and it stays on "Loading widget".
430 extraProguardRules: [
431 "-dontwarn kotlin.MustUseReturnValues",
432 "-keep class * extends androidx.work.InputMerger { <init>(); }",
433 ].join("\n"),
434 },
435 ios: {
436 deploymentTarget: "18.0",
437 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
438 extraPods: [
439 { name: "GoogleUtilities", modular_headers: true },
440 { name: "RecaptchaInterop", modular_headers: true },
441 ],
442 },
443 },
444 ],
445 "./plugins/withIosCocoaPodsUuidCache.cjs",
446 // Only the accelerometer is used (device viewer shake). Compile out the
447 // pedometer so iOS needs no motion purpose string.
448 ["expo-sensors", { motionPermission: false }],
449 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
450 // first, so registering earlier makes this plugin's mods run AFTER
451 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
452 // would delete the asset catalog) and its xcodeproj mod creates the widget
453 // target (which must exist before the compile phase can be attached).
454 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
455 "./plugins/withAndroidCleartextTraffic.cjs",
456 "./plugins/withAndroidGradleHeap.cjs",
457 "./plugins/withAndroidFbjniVersion.cjs",
458 "./plugins/withAndroidInputBackground.cjs",
459 "./plugins/withAndroidModernPopupMenu.cjs",
460 "./plugins/withAndroidModernAlertDialog.cjs",
461 "./plugins/withAndroidPredictiveBackCompat.cjs",
462 "./plugins/withAndroidTabletOrientation.cjs",
463 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
464 ],
465 extra: {
466 appVariant: APP_VARIANT,
467 iosPersonalTeamBuild: isIosPersonalTeamBuild,
468 relay: {
469 url: repoEnv.T3CODE_RELAY_URL ?? null,
470 },
471 clerk: {
472 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
473 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
474 },
475 // @clerk/expo reads these from `extra`
476 // under their exact env-var names (not nested), and its config plugin reads
477 // the iOS URL scheme at prebuild to register it in Info.plist.
478 // Unset values must be omitted (not null): the public manifest serializes
479 // null to {}, which is truthy and would defeat Clerk's fallback checks.
480 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
481 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
482 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
483 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
484 observability: {
485 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
486 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
487 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
488 },
489 eas: {
490 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
491 },
492 },
493 owner: "pingdotgg",
494 experiments: {
495 // Metro only runs babel-plugin-react-compiler when this is set; see src/reactCompilerCoverage.test.ts.
496 reactCompiler: true,
497 },
498};
499
500export default config;