@@ -103,32 +103,44 @@ function getReactDiffProcessValue(typeAnnotation) {
103
103
}
104
104
105
105
const ComponentTemplate = ( {
106
- componentNameWithCompatSupport,
107
- deprecationCheck,
106
+ componentName,
107
+ paperComponentName,
108
+ paperComponentNameDeprecated,
108
109
} : {
109
- componentNameWithCompatSupport : string ,
110
- deprecationCheck : string ,
111
- } ) =>
112
- `
113
- let nativeComponentName = '${ componentNameWithCompatSupport } ';
114
- ${ deprecationCheck }
110
+ componentName : string ,
111
+ paperComponentName : ?string ,
112
+ paperComponentNameDeprecated : ?string ,
113
+ } ) => {
114
+ const nativeComponentName = paperComponentName ?? componentName ;
115
+
116
+ return `
117
+ let nativeComponentName = '${ nativeComponentName } ';
118
+ ${
119
+ paperComponentNameDeprecated != null
120
+ ? DeprecatedComponentNameCheckTemplate ( {
121
+ componentName,
122
+ paperComponentNameDeprecated,
123
+ } )
124
+ : ''
125
+ }
115
126
export default NativeComponentRegistry.get(nativeComponentName, () => VIEW_CONFIG);
116
127
` . trim ( ) ;
128
+ } ;
117
129
118
- const DeprecatedComponentTemplate = ( {
130
+ const DeprecatedComponentNameCheckTemplate = ( {
119
131
componentName,
120
- componentNameDeprecated ,
132
+ paperComponentNameDeprecated ,
121
133
} : {
122
134
componentName : string ,
123
- componentNameDeprecated : string ,
135
+ paperComponentNameDeprecated : string ,
124
136
} ) =>
125
137
`
126
138
if (UIManager.getViewManagerConfig('${ componentName } ')) {
127
139
nativeComponentName = '${ componentName } ';
128
- } else if (UIManager.getViewManagerConfig('${ componentNameDeprecated } ')) {
129
- nativeComponentName = '${ componentNameDeprecated } ';
140
+ } else if (UIManager.getViewManagerConfig('${ paperComponentNameDeprecated } ')) {
141
+ nativeComponentName = '${ paperComponentNameDeprecated } ';
130
142
} else {
131
- throw new Error('Failed to find native component for either "${ componentName } " or "${ componentNameDeprecated } "');
143
+ throw new Error('Failed to find native component for either "${ componentName } " or "${ paperComponentNameDeprecated } "');
132
144
}
133
145
` . trim ( ) ;
134
146
@@ -365,29 +377,22 @@ module.exports = {
365
377
. map ( ( componentName : string ) => {
366
378
const component = components [ componentName ] ;
367
379
368
- const paperComponentName = component . paperComponentName
369
- ? component . paperComponentName
370
- : componentName ;
371
-
372
380
if ( component . paperComponentNameDeprecated ) {
373
381
imports . add ( UIMANAGER_IMPORT ) ;
374
382
}
375
383
376
- const deprecatedCheckBlock = component . paperComponentNameDeprecated
377
- ? DeprecatedComponentTemplate ( {
378
- componentName,
379
- componentNameDeprecated :
380
- component . paperComponentNameDeprecated || '' ,
381
- } )
382
- : '' ;
383
-
384
384
const replacedTemplate = ComponentTemplate ( {
385
- componentNameWithCompatSupport : paperComponentName ,
386
- deprecationCheck : deprecatedCheckBlock ,
385
+ componentName,
386
+ paperComponentName : component . paperComponentName ,
387
+ paperComponentNameDeprecated :
388
+ component . paperComponentNameDeprecated ,
387
389
} ) ;
388
390
389
391
const replacedSourceRoot = j . withParser ( 'flow' ) ( replacedTemplate ) ;
390
392
393
+ const paperComponentName =
394
+ component . paperComponentName ?? componentName ;
395
+
391
396
replacedSourceRoot
392
397
. find ( j . Identifier , {
393
398
name : 'VIEW_CONFIG' ,
0 commit comments