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

app.config.ts

462 lines16.5 KB

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