Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ jobs:
CI: true
EXPO_NO_TELEMETRY: 1

- name: 🧪 Run expo prebuild
run: pnpm exec expo prebuild

- name: 🧪 Run TypeScript check
run: pnpm tsc

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ expo-env.d.ts
.metro-health-check*

.env.*
!.env.example
!.env.example

# Generated web UI embed
src/api/local-server/web-ui.ts
9 changes: 7 additions & 2 deletions app.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Register ts-node so Expo can evaluate this ESM config file at prebuild time.
import 'tsx/cjs';
import { ExpoConfig, ConfigContext } from 'expo/config';
const packageJson = require('./package.json');
import type { ExpoConfig, ConfigContext } from 'expo/config';
import packageJson from './package.json' with { type: 'json' };

export default ({ config }: ConfigContext): ExpoConfig => {
const appBackgroundColor = '#181A20';
Expand Down Expand Up @@ -85,6 +86,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
project: process.env.SENTRY_PROJECT ?? 'dodostream',
},
],
'./plugins/withRemoteUIBuild',
'./plugins/withReactNativeTVOSPnpmFix',
'./plugins/withAndroidBuildOptimizations',
'./plugins/withAndroidConfigChanges',
Expand Down Expand Up @@ -118,6 +120,9 @@ export default ({ config }: ConfigContext): ExpoConfig => {
permissions: [
'android.permission.FOREGROUND_SERVICE',
'android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK',
'android.permission.INTERNET',
'android.permission.ACCESS_NETWORK_STATE',
'android.permission.ACCESS_WIFI_STATE'
],
},
extra: {
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = defineConfig([
expoConfig,
reactCompiler.configs.recommended,
{
ignores: ['dist/*', '.expo/**'],
ignores: ['dist/*', '.expo/**', 'remote-ui/**'],
},
{
rules: {
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"build:production_apk:local": "eas build --profile production_apk --local",
"build:production_apk:tv": "eas build --profile production_tv_apk",
"build:production_apk:tv:local": "eas build --profile production_tv_apk --local",
"build:ui": "pnpm --filter remote-ui build && node scripts/embed-web-ui.mjs",
"prebuild": "expo prebuild",
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
"format": "eslint \"**/*.{js,jsx,ts,tsx}\" --fix && prettier \"**/*.{js,jsx,ts,tsx,json}\" --write",
Expand Down Expand Up @@ -56,6 +57,7 @@
"expo-linear-gradient": "~15.0.8",
"expo-linking": "~8.0.12",
"expo-localization": "~17.0.8",
"expo-network": "~8.0.8",
"expo-router": "~6.0.23",
"expo-splash-screen": "~31.0.13",
"expo-sqlite": "~16.0.10",
Expand All @@ -71,6 +73,8 @@
"react-native": "npm:react-native-tvos@0.81-stable",
"react-native-gesture-handler": "~2.28.0",
"react-native-immersive-mode": "^2.0.2",
"react-native-nitro-http-server": "^1.8.1",
"react-native-qrcode-svg": "^6.3.21",
"react-native-reanimated": "~4.1.6",
"react-native-safe-area-context": "~5.6.2",
"react-native-screens": "~4.16.0",
Expand Down Expand Up @@ -101,6 +105,7 @@
"jest-expo": "^54.0.17",
"prettier": "^3.2.5",
"react-test-renderer": "19.1.0",
"ts-node": "^10.9.2",
"tsx": "^4.21.0",
"typescript": "~5.9.2"
},
Expand Down
56 changes: 56 additions & 0 deletions plugins/withRemoteUIBuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ConfigPlugin, withDangerousMod } from 'expo/config-plugins';
import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';

/**
* Expo config plugin that builds the remote-ui SPA and embeds it
* into src/api/local-server/web-ui.ts before native project generation.
*
* Registered on both platforms so it runs regardless of which platform
* is being prebuilt. A module-level flag ensures the build only executes once
* when both platforms are built together.
*
* Runs: pnpm --filter remote-ui build && node scripts/embed-web-ui.mjs
*/

let built = false;

function buildRemoteUI(projectRoot: string): void {
if (built) return;
built = true;

const webUiPath = path.join(projectRoot, 'src/api/local-server/web-ui.ts');

console.log('🌐 Building remote-ui SPA...');
try {
execSync('pnpm --filter remote-ui build', { cwd: projectRoot, stdio: 'inherit' });
execSync('node scripts/embed-web-ui.mjs', { cwd: projectRoot, stdio: 'inherit' });
console.log('✓ Remote UI embedded successfully');
} catch (error) {
console.error('⚠️ Failed to build remote-ui:', error);
// Don't fail the prebuild — write a stub if the file is missing
if (!fs.existsSync(webUiPath)) {
fs.writeFileSync(
webUiPath,
"// AUTO-GENERATED — do not edit. Run pnpm build:ui to regenerate.\nexport const WEB_UI_HTML = '';\n",
'utf-8'
);
}
}
}

const withRemoteUIBuild: ConfigPlugin = (config) => {
for (const platform of ['ios', 'android'] as const) {
config = withDangerousMod(config, [
platform,
(modConfig) => {
buildRemoteUI(modConfig.modRequest.projectRoot);
return modConfig;
},
]);
}
return config;
};

export default withRemoteUIBuild;
Loading
Loading