Repository navigation
Expand file tree
/
Copy pathapp.config.ts
More file actions
271 lines (265 loc) · 11.5 KB
/
Copy pathapp.config.ts
File metadata and controls
271 lines (265 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import type { ExpoConfig } from 'expo/config';
// Expo's config loader executes the compiled app.config.js through Node, so the
// platform plugin modules stay CommonJS rather than relying on a TS loader.
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { withAndroidAppConfig } = require('./config/plugins/android.cjs') as {
withAndroidAppConfig: (
config: ExpoConfig,
options: { isDevelopmentVariant: boolean; isFossVariant: boolean },
) => ExpoConfig;
};
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { withoutPushEntitlement } = require('./config/plugins/ios.cjs') as {
withoutPushEntitlement: (config: ExpoConfig) => ExpoConfig;
};
function env(name: string) {
const value = process.env[name]?.trim();
return value ? value : undefined;
}
const appVariant = env('EXPO_APP_VARIANT') ?? 'production';
const isDevelopmentVariant = appVariant === 'development';
const isFossVariant = appVariant === 'foss' || env('EXPO_PUBLIC_FOSS') === '1';
const isE2EMode = env('EXPO_PUBLIC_E2E_MODE') === '1';
const e2eServerUrl = env('EXPO_PUBLIC_E2E_SERVER_URL');
// Free Apple "Personal Team" accounts cannot provision the Push Notifications
// capability, so `expo-notifications`'s aps-environment entitlement blocks
// on-device builds entirely for them. Strip it locally with this flag; CI and
// paid-team builds must leave it unset so push notifications keep working.
const disablePushEntitlement = env('EXPO_IOS_DISABLE_PUSH_ENTITLEMENT') === '1';
// Apple bundle identifiers are unique across every developer account, not just
// per team. The published "app.getopencode.mobile" (and its ".dev" variant)
// are already registered to the paid team, so a free "Personal Team" account
// can never register them. Override with a bundle id nobody else has claimed.
const iosBundleIdentifierOverride = env('EXPO_IOS_BUNDLE_ID');
const defaultAndroidPackage = isFossVariant ? 'app.getopencode.fdroid' : 'app.getopencode';
const releaseAndroidPackage = env('EXPO_ANDROID_PACKAGE') ?? defaultAndroidPackage;
const developmentAndroidPackage = env('EXPO_ANDROID_PACKAGE_DEV') ?? `${releaseAndroidPackage}.dev`;
const androidPackage = isDevelopmentVariant ? developmentAndroidPackage : releaseAndroidPackage;
const buildPropertiesPlugin: [string, {
android?: {
usesCleartextTraffic: boolean;
buildReactNativeFromSource?: boolean;
enableMinifyInReleaseBuilds?: boolean;
enableShrinkResourcesInReleaseBuilds?: boolean;
extraProguardRules?: string;
};
}] = [
'expo-build-properties',
{
android: { usesCleartextTraffic: true, buildReactNativeFromSource: true, ...(!isDevelopmentVariant ? {
enableMinifyInReleaseBuilds: true,
enableShrinkResourcesInReleaseBuilds: true,
// Expo modules convert JS objects into native records through the Pika
// introspection runtime and generated `$__Pika` classes, and load the
// headless app loader by class name. R8 sees no direct references and strips
// them, which crashed nested records (speech recognition's
// volumeChangeEventOptions -> NullPointerException) and the headless loader
// (ClassNotFoundException) in release builds.
// WorkManager also constructs the widget library's headless worker
// reflectively, so keep it and its base class for the same reason.
extraProguardRules: [
'-keep class **$__Pika { *; }',
'-keep class io.github.expo.pika.** { *; }',
'-keep class * implements io.github.expo.pika.Introspectable { *; }',
'-keep class expo.modules.kotlin.records.** { *; }',
'-keep class expo.modules.adapters.react.apploader.** { *; }',
'-keep class com.reactnativeandroidwidget.RNWidgetBackgroundTaskWorker { *; }',
'-keep class com.reactnativeandroidwidget.oss.HeadlessJsTaskWorker { *; }',
'-keep class com.rnllama.** { *; }',
// AGP 9 no longer retains this reflectively called Room constructor implicitly.
'-keep class androidx.work.impl.WorkDatabase_Impl { public <init>(); }',
].join('\n'),
} : {}) },
},
];
// The F-Droid/FOSS build drops the proprietary expo-camera (ML Kit barcode
// scanning) and expo-iap (Google Play Billing) plugins. Typed constants keep
// the tuple shape so `plugins` stays assignable to ExpoConfig.
type PluginList = NonNullable<ExpoConfig['plugins']>;
const cameraPlugin: PluginList = [['expo-camera', {
cameraPermission: 'Allow $(PRODUCT_NAME) to scan an OpenCode pairing QR code.',
recordAudioAndroid: false,
}]];
const imagePickerPlugin: PluginList = [['expo-image-picker', {
photosPermission: 'Allow OpenCode Mobile to access photos you choose to attach to chat messages.',
cameraPermission: isFossVariant ? false : 'Allow $(PRODUCT_NAME) to scan an OpenCode pairing QR code.',
microphonePermission: 'Allow $(PRODUCT_NAME) to access the microphone for voice input.',
}]];
const iapPlugin: PluginList = ['expo-iap'];
const config: ExpoConfig = {
name: isDevelopmentVariant ? 'OpenCode Mobile Dev' : 'OpenCode Mobile',
slug: 'opencode-mobile',
version: '1.0.178',
orientation: 'default',
icon: './assets/images/icon.png',
scheme: 'opencodemobile',
userInterfaceStyle: 'automatic',
android: {
package: androidPackage,
versionCode: 178,
...(isDevelopmentVariant ? {} : { blockedPermissions: ['android.permission.SYSTEM_ALERT_WINDOW'] }),
intentFilters: [{
action: 'VIEW',
category: ['DEFAULT', 'BROWSABLE'],
data: { scheme: 'opencode', host: 'session', pathPrefix: '/' },
}],
adaptiveIcon: {
foregroundImage: './assets/images/adaptive-icon.png',
backgroundColor: "#202020"
},
predictiveBackGestureEnabled: false,
softwareKeyboardLayoutMode: 'resize',
},
web: {
output: 'static',
favicon: './assets/images/favicon.png',
},
ios: {
bundleIdentifier: iosBundleIdentifierOverride ?? (isDevelopmentVariant ? 'app.getopencode.mobile.dev' : 'app.getopencode.mobile'),
buildNumber: '178',
scheme: 'opencode',
infoPlist: {
ITSAppUsesNonExemptEncryption: false,
NSPhotoLibraryUsageDescription: 'Allow OpenCode Mobile to access photos you choose to attach to chat messages.',
NSAppTransportSecurity: {
NSAllowsArbitraryLoads: true,
},
},
},
plugins: [
'expo-router',
'expo-font',
// Config-plugin mods compose in reverse of registration order (last
// registered runs first), so this must be registered before
// expo-notifications to run after it and strip the entitlement it sets.
...(disablePushEntitlement ? [withoutPushEntitlement as unknown as string] : []),
'expo-notifications',
'expo-background-task',
'expo-web-browser',
[
// Receiving shares into the app. Android share intents are enabled here;
// the iOS Share Extension is deferred and tracked in
// docs/product/parity/ios-share.md. The JS side stages payloads in
// features/sharing/state/use-share-state.ts and previews them in features/sharing/ui/share-screen.tsx.
'expo-sharing',
{
android: {
enabled: true,
singleShareMimeTypes: ['*/*'],
multipleShareMimeTypes: ['*/*'],
},
},
],
...imagePickerPlugin,
...(isFossVariant ? [] : cameraPlugin),
[
// Exposes the shipped app languages to the OS so iOS/Android surface the
// correct per-app language choices. Extend both lists with every language
// added under shared/i18n/locales.
'expo-localization',
{
supportsRTL: true,
supportedLocales: {
ios: ['en', 'ar', 'he', 'ru', 'es', 'hi', 'de', 'fr', 'zh', 'pt', 'ja'],
android: ['en', 'ar', 'he', 'ru', 'es', 'hi', 'de', 'fr', 'zh', 'pt', 'ja'],
},
},
],
buildPropertiesPlugin,
[
'expo-speech-recognition',
{
microphonePermission: 'Allow $(PRODUCT_NAME) to access the microphone for voice input.',
speechRecognitionPermission: 'Allow $(PRODUCT_NAME) to convert speech to text on your device.',
androidSpeechServicePackages: ['com.google.android.googlequicksearchbox', 'com.google.android.as', 'com.google.android.tts'],
},
],
// Optional on-device wake word and speaker models (sherpa-onnx). The
// wrapper ships prebuilt ONNX Runtime libraries, which F-Droid removes.
// FOSS hides the dependent controls and keeps system speech instead.
...(isFossVariant ? [] : ['@siteed/sherpa-onnx.rn']),
// On-device prompt classifier runtime. The model pack itself is downloaded
// separately; only the llama.cpp native libraries ship in the app.
['llama.rn', { enableEntitlements: true, entitlementsProfile: 'production', forceCxx20: true, enableOpenCLAndHexagon: false }],
[
'expo-splash-screen',
{
image: './assets/images/splash-icon.png',
imageWidth: 200,
resizeMode: 'contain',
backgroundColor: '#ffffff',
dark: {
backgroundColor: '#000000',
},
},
],
'expo-image',
'expo-video',
'expo-secure-store',
...(isFossVariant ? [] : iapPlugin),
'expo-status-bar',
[
// Android home-screen widget. Widget trees and the headless task handler
// live in features/widgets/; the provider publishes snapshots on confirmed state
// changes (features/widgets/state/use-widget-state.ts). The picker label and
// description are written to strings.xml as non-translatable by the
// plugin, so they stay English. iOS has no widget surface yet; see
// docs/product/parity/ios-widget.md. The library is MIT-licensed and pure
// Android, so the FOSS variant keeps it.
'react-native-android-widget',
{
widgets: [
{
name: 'SessionWidget',
label: 'OpenCode latest replies',
description: 'Latest assistant replies across recent chats.',
minWidth: '180dp',
minHeight: '140dp',
targetCellWidth: 4,
targetCellHeight: 3,
resizeMode: 'horizontal|vertical',
},
{
name: 'AttentionWidget', label: 'OpenCode awaiting actions',
description: 'Pending permissions and questions across projects.',
minWidth: '180dp', minHeight: '140dp', targetCellWidth: 4, targetCellHeight: 3,
resizeMode: 'horizontal|vertical',
},
{
name: 'PlanWidget', label: 'OpenCode plan progress',
description: 'Todo steps and progress in the current chat.',
minWidth: '180dp', minHeight: '140dp', targetCellWidth: 4, targetCellHeight: 3,
resizeMode: 'horizontal|vertical',
},
{
name: 'MissionControlWidget', label: 'OpenCode Mission Control',
description: 'Last checked activity across OpenCode servers.',
minWidth: '180dp', minHeight: '140dp', targetCellWidth: 4, targetCellHeight: 3,
resizeMode: 'horizontal|vertical',
},
],
},
],
((config: ExpoConfig) => withAndroidAppConfig(config, { isDevelopmentVariant, isFossVariant })) as unknown as string,
],
experiments: {
typedRoutes: true,
reactCompiler: true,
},
extra: {
router: {},
e2eMode: isE2EMode,
e2eServerUrl,
foss: isFossVariant,
updates: {
enabled: !isDevelopmentVariant && !isFossVariant && !isE2EMode,
testing: isDevelopmentVariant && isE2EMode,
appStoreId: env('EXPO_IOS_APP_STORE_ID'),
appStoreCountry: env('EXPO_IOS_APP_STORE_COUNTRY'),
},
connectPilot: {
testing: isDevelopmentVariant && isE2EMode,
},
},
};
export default config;