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-react-native': {
10      content: [
11        {
12          paths: '*.m',
13          find: /RCT_EXTERN_MODULE\((ApplePayButtonManager|CardFieldManager|AuBECSDebitFormManager|StripeSdk|StripeContainerManager)/,
14          replaceWith: `RCT_EXTERN_REMAP_MODULE($1, ${prefix}$1`,
15        },
16      ],
17    },
18    'lottie-react-native': {
19      content: [
20        {
21          paths: 'LRNAnimationViewManagerObjC.m',
22          find: /RCT_EXTERN_MODULE\(/,
23          replaceWith: `RCT_EXTERN_REMAP_MODULE(LottieAnimationView, ${prefix}`,
24        },
25        {
26          paths: 'ContainerView.swift',
27          find: /\breactSetFrame/g,
28          replaceWith: `${prefix.toLowerCase()}ReactSetFrame`,
29        },
30      ],
31    },
32    'react-native-webview': {
33      content: [
34        {
35          paths: 'RNCWebView.m',
36          find: new RegExp(`#import "objc/${prefix}runtime\\.h"`, ''),
37          replaceWith: '#import "objc/runtime.h"',
38        },
39        {
40          paths: 'RNCWebView.m',
41          find: /\b(_SwizzleHelperWK)\b/g,
42          replaceWith: `${prefix}$1`,
43        },
44        {
45          // see issue: https://github.com/expo/expo/issues/4463
46          paths: 'RNCWebView.m',
47          find: /MessageHandlerName = @"ABI\d+_\d+_\d+ReactNativeWebView";/,
48          replaceWith: `MessageHandlerName = @"ReactNativeWebView";`,
49        },
50      ],
51    },
52    'react-native-reanimated': {
53      content: [
54        {
55          find: 'namespace reanimated',
56          replaceWith: `namespace ${prefix}reanimated`,
57        },
58        {
59          find: /\breanimated::/g,
60          replaceWith: `${prefix}reanimated::`,
61        },
62        {
63          paths: '*.h',
64          find: /ReactCommon\//g,
65          replaceWith: `ReactCommon/${prefix}`,
66        },
67        {
68          paths: '**/Transitioning/*.m',
69          find: `RCTConvert+${prefix}REATransition.h`,
70          replaceWith: 'RCTConvert+REATransition.h',
71        },
72        {
73          find: /(_bridge_reanimated)/g,
74          replaceWith: `${prefix}$1`,
75        },
76        {
77          paths: 'REATransitionAnimation.m',
78          find: /(SimAnimationDragCoefficient)\(/g,
79          replaceWith: `${prefix}$1(`,
80        },
81      ],
82    },
83    'react-native-gesture-handler': {
84      path: [
85        {
86          find: /Handlers\/RN(\w+)Handler\.(h|m)/,
87          replaceWith: `Handlers/${prefix}RN$1Handler.$2`,
88        },
89      ],
90      content: [
91        {
92          find: `UIView+${prefix}React.h`,
93          replaceWith: `${prefix}UIView+React.h`,
94        },
95        {
96          paths: '*.{h,m}',
97          find: /\bRN(\w+)(Handler|GestureRecognizer)\b/g,
98          replaceWith: `${prefix}RN$1$2`,
99        },
100      ],
101    },
102    'react-native-screens': {
103      content: [],
104    },
105  };
106}
107