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