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