1import { FileTransforms } from '../../../Transforms.types';
2
3type Config = {
4  [key: string]: FileTransforms;
5};
6
7export default function vendoredModulesTransformsFactory(prefix: string): Config {
8  return {
9    '@stripe/stripe-react-native': {
10      content: [
11        {
12          paths: '*.m',
13          find: /RCT_EXTERN_MODULE\((ApplePayButtonManager|CardFieldManager|AuBECSDebitFormManager|StripeSdk|StripeContainerManager|CardFormManager)/,
14          replaceWith: `RCT_EXTERN_REMAP_MODULE($1, ${prefix}$1`,
15        },
16        {
17          paths: '',
18          find: /\.reactFocus\(/,
19          replaceWith: `.${prefix.toLowerCase()}ReactFocus(`,
20        },
21      ],
22    },
23    'lottie-react-native': {
24      content: [
25        {
26          paths: 'LRNAnimationViewManagerObjC.m',
27          find: /RCT_EXTERN_MODULE\(/,
28          replaceWith: `RCT_EXTERN_REMAP_MODULE(LottieAnimationView, ${prefix}`,
29        },
30        {
31          paths: 'ContainerView.swift',
32          find: /\breactSetFrame/g,
33          replaceWith: `${prefix.toLowerCase()}ReactSetFrame`,
34        },
35      ],
36    },
37    'react-native-webview': {
38      content: [
39        {
40          paths: 'RNCWebView.m',
41          find: new RegExp(`#import "objc/${prefix}runtime\\.h"`, ''),
42          replaceWith: '#import "objc/runtime.h"',
43        },
44        {
45          paths: 'RNCWebView.m',
46          find: /\b(_SwizzleHelperWK)\b/g,
47          replaceWith: `${prefix}$1`,
48        },
49        {
50          // see issue: https://github.com/expo/expo/issues/4463
51          paths: 'RNCWebView.m',
52          find: /MessageHandlerName = @"ABI\d+_\d+_\d+ReactNativeWebView";/,
53          replaceWith: `MessageHandlerName = @"ReactNativeWebView";`,
54        },
55        {
56          paths: 'RNCWebView.m',
57          find: 'NSString *const CUSTOM_SELECTOR',
58          replaceWith: 'static NSString *const CUSTOM_SELECTOR',
59        }
60      ],
61    },
62    'react-native-reanimated': {
63      content: [
64        {
65          find: 'namespace reanimated',
66          replaceWith: `namespace ${prefix}reanimated`,
67        },
68        {
69          find: /\breanimated::/g,
70          replaceWith: `${prefix}reanimated::`,
71        },
72        {
73          paths: '*.h',
74          find: /ReactCommon\//g,
75          replaceWith: `ReactCommon/${prefix}`,
76        },
77        {
78          paths: '**/Transitioning/*.m',
79          find: `RCTConvert+${prefix}REATransition.h`,
80          replaceWith: 'RCTConvert+REATransition.h',
81        },
82        {
83          find: /(_bridge_reanimated)/g,
84          replaceWith: `${prefix}$1`,
85        },
86        {
87          paths: 'REATransitionAnimation.m',
88          find: /(SimAnimationDragCoefficient)\(/g,
89          replaceWith: `${prefix}$1(`,
90        },
91      ],
92    },
93    'react-native-gesture-handler': {
94      path: [
95        {
96          find: /\bRN(\w+?)\.(h|m|mm)/,
97          replaceWith: `${prefix}RN$1.$2`,
98        },
99      ],
100      content: [
101        {
102          find: `UIView+${prefix}React.h`,
103          replaceWith: `${prefix}UIView+React.h`,
104        },
105        {
106          // `RNG*` symbols are already prefixed at this point,
107          // but there are some new symbols in RNGH that don't have "G".
108          paths: '*.{h,m}',
109          find: /\bRN(\w+?)\b/g,
110          replaceWith: `${prefix}RN$1`,
111        },
112      ],
113    },
114    'react-native-pager-view': {
115      path: [
116        {
117          find: /(ReactNativePageView|ReactViewPagerManager)\.(h|m)/,
118          replaceWith: `${prefix}$1.$2`,
119        },
120      ],
121      content: [
122        {
123          find: `UIView+${prefix}React.h`,
124          replaceWith: `${prefix}UIView+React.h`,
125        },
126        {
127          find: `${prefix}JKBigInteger.h`,
128          replaceWith: `JKBigInteger.h`,
129        },
130      ],
131    },
132    '@react-native-segmented-control/segmented-control': {
133      content: [
134        {
135          find: `UIView+${prefix}React.h`,
136          replaceWith: `${prefix}UIView+React.h`,
137        },
138      ],
139    },
140    'react-native-screens': {
141      content: [],
142    },
143  };
144}
145