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  };
44}
45