@@ -42,6 +42,10 @@ const EXPO_PREVIEW_BROWNFIELD_CONFIG_PATH = path.join(
4242 EXPO_PREVIEW_APP_DIR ,
4343 'brownfield.config.json'
4444) ;
45+ const EXPO_PREVIEW_NAVIGATION_SPEC_PATH = path . join (
46+ EXPO_PREVIEW_APP_DIR ,
47+ 'brownfield.navigation.ts'
48+ ) ;
4549const EXPO_NPM_REGISTRY_URL = 'https://registry.npmjs.org/expo' ;
4650
4751function parseArgs ( argv : string [ ] ) : CliOptions {
@@ -176,6 +180,29 @@ export function replaceHomeScreenTitle(
176180 . replaceAll ( `Expo ${ version } ` , 'Expo Preview' ) ;
177181}
178182
183+ const CONSUMER_ROAD_TEST_NAVIGATION_METHODS = `
184+ /**
185+ * Ask the native host to confirm an action. Resolves with the user's choice.
186+ */
187+ requestNativeConfirmation(title: string): Promise<boolean>;
188+
189+ /**
190+ * Show a native banner. The native host calls onDismiss when the banner is dismissed.
191+ */
192+ showNativeBanner(message: string, onDismiss: () => void): void;
193+ ` ;
194+
195+ export function ensureConsumerNavigationSpec ( contents : string ) : string {
196+ if ( contents . includes ( 'requestNativeConfirmation' ) ) {
197+ return contents ;
198+ }
199+
200+ return contents . replace (
201+ ' navigateToReferrals(userId: string): void;\n}' ,
202+ ` navigateToReferrals(userId: string): void;${ CONSUMER_ROAD_TEST_NAVIGATION_METHODS } \n}`
203+ ) ;
204+ }
205+
179206function generateExpoPreviewApp ( ) : void {
180207 const templateApp = getExpoTemplateApp ( ) ;
181208 const replaceReferences = ( contents : string ) =>
@@ -197,6 +224,10 @@ function generateExpoPreviewApp(): void {
197224 updateFileContents ( EXPO_PREVIEW_BROWNFIELD_CONFIG_PATH , replaceReferences ) ;
198225 }
199226
227+ if ( existsSync ( EXPO_PREVIEW_NAVIGATION_SPEC_PATH ) ) {
228+ updateFileContents ( EXPO_PREVIEW_NAVIGATION_SPEC_PATH , ensureConsumerNavigationSpec ) ;
229+ }
230+
200231 const testPath = path . join (
201232 EXPO_PREVIEW_APP_DIR ,
202233 '__tests__' ,
0 commit comments