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 case undefined:
112 return "production";
113 default:
114 throw new Error("APP_VARIANT must be development, preview, or production.");
115 }
116}
117
118const variant = VARIANT_CONFIG[APP_VARIANT];
119// Copied thread links open the app. app.t3.codes/.well-known lists every variant's identifiers.
120const HOSTED_APP_HOST = "app.t3.codes";
121const iosBundleIdentifier = isIosPersonalTeamBuild
122 ? personalTeamBundleIdentifier!
123 : variant.iosBundleIdentifier;
124
125const dmSansFonts = {
126 regular: "@expo-google-fonts/dm-sans/400Regular/DMSans_400Regular.ttf",
127 medium: "@expo-google-fonts/dm-sans/500Medium/DMSans_500Medium.ttf",
128 bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
129} as const;
130
131const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
132 "expo-widgets",
133 {
134 bundleIdentifier: `${iosBundleIdentifier}.widgets`,
135 groupIdentifier: `group.${iosBundleIdentifier}`,
136 enablePushNotifications: true,
137 // Frequent updates need the iOS entitlement to avoid early throttling.
138 frequentUpdates: true,
139 enableAndroid: true,
140 widgets: [
141 {
142 name: "SubscriptionUsage",
143 displayName: "Subscription usage",
144 description: "Subscription quotas from your connected T3 Code environments.",
145 ios: {
146 configuration: {
147 title: "Subscription usage",
148 description:
149 "Both shows Session and Weekly when available. The Lock Screen shows the tightest selected limit.",
150 parameters: {
151 codexPeriod: {
152 title: "Codex limits",
153 type: "enum",
154 default: "auto",
155 values: [
156 { name: "Both", value: "auto" },
157 { name: "Session", value: "session" },
158 { name: "Weekly", value: "weekly" },
159 ],
160 },
161 claudePeriod: {
162 title: "Claude limits",
163 type: "enum",
164 default: "auto",
165 values: [
166 { name: "Both", value: "auto" },
167 { name: "Session", value: "session" },
168 { name: "Weekly", value: "weekly" },
169 ],
170 },
171 },
172 },
173 supportedFamilies: [
174 "systemSmall",
175 "systemMedium",
176 "systemLarge",
177 "systemExtraLarge",
178 "accessoryRectangular",
179 ],
180 },
181 android: {
182 minWidth: 250,
183 minHeight: 180,
184 targetCellWidth: 4,
185 targetCellHeight: 3,
186 resizeMode: "both",
187 // The embedded layout renders before first launch; publishing replaces it with stored props.
188 initialLayout: "./src/widgets/SubscriptionUsage.android.tsx",
189 },
190 },
191 {
192 name: "AgentActivity",
193 displayName: "Agent Activity",
194 description: "Shows the current state of active T3 Code agents.",
195 android: null,
196 ios: { supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"] },
197 },
198 ],
199 },
200];
201
202const sharingPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
203 "expo-sharing",
204 {
205 ios: {
206 // Personal Teams cannot sign App Groups or extension targets; keep local builds usable.
207 enabled: !isIosPersonalTeamBuild,
208 extensionBundleIdentifier: `${iosBundleIdentifier}.sharing`,
209 appGroupId: `group.${iosBundleIdentifier}`,
210 activationRule: {
211 supportsText: true,
212 supportsWebUrlWithMaxCount: 1,
213 supportsImageWithMaxCount: 8,
214 supportsMovieWithMaxCount: 8,
215 supportsFileWithMaxCount: 8,
216 },
217 },
218 android: {
219 enabled: true,
220 singleShareMimeTypes: ["*/*"],
221 multipleShareMimeTypes: ["*/*"],
222 },
223 },
224];
225
226// Match iOS PostScript names on Android so RN and the native composer share fonts before runtime loading.
227
228const config: ExpoConfig = {
229 name: variant.appName,
230 slug: "t3-code",
231 platforms: ["ios", "android"],
232 scheme: variant.scheme,
233 version: repoEnv.T3CODE_MOBILE_VERSION ?? "2.2.0",
234 runtimeVersion: {
235 // Skip costly fingerprinting on dev launches; preview and production OTAs require matching native projects.
236 policy: runtimeVersionPolicy,
237 },
238 orientation: "portrait",
239 icon: variant.assets.appIcon,
240 userInterfaceStyle: "automatic",
241 updates: {
242 enabled: repoEnv.T3CODE_MOBILE_UPDATES_ENABLED !== "0",
243 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
244 checkAutomatically: "ON_LOAD",
245 fallbackToCacheTimeout: 0,
246 },
247 ios: {
248 icon: variant.assets.iosIcon,
249 supportsTablet: true,
250 requireFullScreen: process.env.T3_SHOWCASE_CAPTURE_BUILD === "1",
251 bundleIdentifier: iosBundleIdentifier,
252 // Avoid Personal Team fallback: it cannot sign App Groups, Apple sign-in or push entitlements.
253 appleTeamId: "ARK85ZXQ4Z",
254 associatedDomains: [
255 `applinks:${variant.relyingParty}`,
256 `webcredentials:${variant.relyingParty}`,
257 `applinks:${HOSTED_APP_HOST}`,
258 ],
259 entitlements: {
260 "keychain-access-groups": [`$(AppIdentifierPrefix)${variant.iosBundleIdentifier}`],
261 },
262 infoPlist: {
263 UISupportedInterfaceOrientations: [
264 "UIInterfaceOrientationPortrait",
265 "UIInterfaceOrientationLandscapeLeft",
266 "UIInterfaceOrientationLandscapeRight",
267 ],
268 NSAppTransportSecurity: {
269 NSAllowsArbitraryLoads: true,
270 },
271 NSLocalNetworkUsageDescription:
272 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
273 NSPhotoLibraryAddUsageDescription: "Allow T3 Code to save images to your photo library.",
274 // System picture in picture needs background audio to start and survive outside the app.
275 UIBackgroundModes: ["audio"],
276 ITSAppUsesNonExemptEncryption: false,
277 // Capture builds disable multitasking because iPadOS otherwise ignores orientation requests.
278 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
279 ? {
280 "UISupportedInterfaceOrientations~ipad": [
281 "UIInterfaceOrientationPortrait",
282 "UIInterfaceOrientationPortraitUpsideDown",
283 "UIInterfaceOrientationLandscapeLeft",
284 "UIInterfaceOrientationLandscapeRight",
285 ],
286 }
287 : {}),
288 },
289 },
290 android: {
291 icon: variant.assets.appIcon,
292 package: variant.androidPackage,
293 ...(repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE
294 ? { googleServicesFile: repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE }
295 : {}),
296 adaptiveIcon: {
297 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
298 ...(variant.assets.androidAdaptiveBackgroundImage
299 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
300 : {}),
301 foregroundImage: variant.assets.androidAdaptiveForeground,
302 monochromeImage: variant.assets.androidMonochromeIcon,
303 },
304 // JS back dispatch needs RN's Android 16 shim and withAndroidPredictiveBackCompat on Android 13-15.
305 predictiveBackGestureEnabled: true,
306 // expo-sensors declares this for its pedometer, which the app does not use.
307 blockedPermissions: ["android.permission.ACTIVITY_RECOGNITION"],
308 intentFilters: [
309 {
310 action: "VIEW",
311 autoVerify: true,
312 data: [{ scheme: "https", host: HOSTED_APP_HOST, pathPrefix: "/threads/" }],
313 category: ["BROWSABLE", "DEFAULT"],
314 },
315 ],
316 },
317 web: {
318 favicon: variant.assets.appIcon,
319 },
320 plugins: [
321 "expo-asset",
322 "react-native-pdf-jsi",
323 [
324 "expo-font",
325 {
326 ios: {
327 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
328 },
329 android: {
330 fonts: [
331 {
332 fontFamily: "DMSans-Regular",
333 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
334 },
335 {
336 fontFamily: "DMSans-Medium",
337 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
338 },
339 {
340 fontFamily: "DMSans-Bold",
341 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
342 },
343 ],
344 },
345 },
346 ],
347 "expo-secure-store",
348 "expo-sqlite",
349 ...(isIosPersonalTeamBuild
350 ? [sharingPlugin]
351 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
352 [
353 "expo-notifications",
354 {
355 icon: variant.assets.androidNotificationIcon,
356 color: variant.assets.androidNotificationColor,
357 mode: APP_VARIANT === "development" ? "development" : "production",
358 },
359 ],
360 // Gate Clerk here: withoutIosPersonalTeamCapabilities runs too early to strip its entitlement.
361 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
362 "expo-web-browser",
363 [
364 "expo-quick-actions",
365 {
366 androidIcons: {
367 shortcut_icon: {
368 foregroundImage: variant.assets.androidAdaptiveForeground,
369 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
370 ...(variant.assets.androidAdaptiveBackgroundImage
371 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
372 : {}),
373 },
374 },
375 },
376 ],
377 [
378 "expo-audio",
379 {
380 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
381 recordAudioAndroid: true,
382 enableBackgroundPlayback: false,
383 enableBackgroundRecording: false,
384 },
385 ],
386 [
387 "expo-camera",
388 {
389 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
390 microphonePermission: false,
391 barcodeScannerEnabled: true,
392 recordAudioAndroid: false,
393 },
394 ],
395 [
396 "expo-image-picker",
397 {
398 photosPermission: false,
399 // `false` makes this plugin add RECORD_AUDIO to blockedPermissions, breaking Android dictation.
400 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
401 },
402 ],
403 [
404 "expo-splash-screen",
405 {
406 image: variant.assets.splashIcon,
407 resizeMode: "contain",
408 backgroundColor: "#ffffff",
409 imageWidth: 220,
410 dark: {
411 image: variant.assets.splashIcon,
412 backgroundColor: "#0a0a0a",
413 },
414 android: {
415 // Android 12+ masks the central two thirds of the 288dp canvas; adaptive layers avoid clipped corners.
416 image: variant.assets.androidSplashIcon,
417 imageWidth: 288,
418 dark: { image: variant.assets.androidSplashIcon },
419 },
420 },
421 ],
422 [
423 "expo-build-properties",
424 {
425 android: {
426 minSdkVersion: 24,
427 // SDK 58 lacks Kotlin 2.3's runtime-inert annotation. R8 needs explicit InputMerger constructors for widgets.
428 extraProguardRules: [
429 "-dontwarn kotlin.MustUseReturnValues",
430 "-keep class * extends androidx.work.InputMerger { <init>(); }",
431 ].join("\n"),
432 },
433 ios: {
434 deploymentTarget: "18.0",
435 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
436 extraPods: [
437 { name: "GoogleUtilities", modular_headers: true },
438 { name: "RecaptchaInterop", modular_headers: true },
439 ],
440 },
441 },
442 ],
443 "./plugins/withIosCocoaPodsUuidCache.cjs",
444 // Compile out the unused pedometer to avoid an iOS motion purpose string.
445 ["expo-sensors", { motionPermission: false }],
446 // Mods run in reverse order; expo-widgets must create and wipe the target before assets are added.
447 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
448 "./plugins/withAndroidNetworkSecurityConfig.cjs",
449 "./plugins/withAndroidGradleHeap.cjs",
450 "./plugins/withAndroidInputBackground.cjs",
451 "./plugins/withAndroidModernPopupMenu.cjs",
452 "./plugins/withAndroidModernAlertDialog.cjs",
453 "./plugins/withAndroidPredictiveBackCompat.cjs",
454 "./plugins/withAndroidTabletOrientation.cjs",
455 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
456 ],
457 extra: {
458 appVariant: APP_VARIANT,
459 iosPersonalTeamBuild: isIosPersonalTeamBuild,
460 relay: {
461 url: repoEnv.T3CODE_RELAY_URL ?? null,
462 },
463 clerk: {
464 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
465 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
466 },
467 // Clerk reads these exact names at prebuild. Omit unset values: manifest null becomes truthy {}.
468 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
469 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
470 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
471 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
472 observability: {
473 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
474 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
475 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
476 },
477 eas: {
478 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
479 observe: { endpointUrl: observeEndpointUrl },
480 },
481 },
482 owner: "pingdotgg",
483 experiments: {
484 // Metro only runs babel-plugin-react-compiler when this is set; see src/reactCompilerCoverage.test.ts.
485 reactCompiler: true,
486 },
487};
488
489export default config;