1a1142e8bSTomasz Sapetaimport { FileTransforms } from '../../../Transforms.types';
2a1142e8bSTomasz Sapeta
3a1142e8bSTomasz Sapetatype Config = {
4a1142e8bSTomasz Sapeta  [key: string]: FileTransforms;
5a1142e8bSTomasz Sapeta};
6a1142e8bSTomasz Sapeta
7a1142e8bSTomasz Sapetaexport default function vendoredModulesTransformsFactory(prefix: string): Config {
8a1142e8bSTomasz Sapeta  return {
9981467a3SCharlie Cruzan    '@stripe/stripe-react-native': {
10f3798cd2SCharlie Cruzan      content: [
11f3798cd2SCharlie Cruzan        {
12bd7d249bSCharlie Cruzan          paths: '',
13bd7d249bSCharlie Cruzan          find: /\.reactFocus\(/,
14bd7d249bSCharlie Cruzan          replaceWith: `.${prefix.toLowerCase()}ReactFocus(`,
15bd7d249bSCharlie Cruzan        },
16f3798cd2SCharlie Cruzan      ],
17f3798cd2SCharlie Cruzan    },
18a1142e8bSTomasz Sapeta    'lottie-react-native': {
19a1142e8bSTomasz Sapeta      content: [
20a1142e8bSTomasz Sapeta        {
21a1142e8bSTomasz Sapeta          paths: 'ContainerView.swift',
22a1142e8bSTomasz Sapeta          find: /\breactSetFrame/g,
23a1142e8bSTomasz Sapeta          replaceWith: `${prefix.toLowerCase()}ReactSetFrame`,
24a1142e8bSTomasz Sapeta        },
25a1142e8bSTomasz Sapeta      ],
26a1142e8bSTomasz Sapeta    },
27e3857a00STomasz Sapeta    'react-native-webview': {
28e3857a00STomasz Sapeta      content: [
29e3857a00STomasz Sapeta        {
30*453643feSKudo Chien          paths: 'RNCWebViewImpl.m',
31e3857a00STomasz Sapeta          find: /\b(_SwizzleHelperWK)\b/g,
32e3857a00STomasz Sapeta          replaceWith: `${prefix}$1`,
33e3857a00STomasz Sapeta        },
34e3857a00STomasz Sapeta        {
35e3857a00STomasz Sapeta          // see issue: https://github.com/expo/expo/issues/4463
36*453643feSKudo Chien          paths: 'RNCWebViewImpl.m',
37e3857a00STomasz Sapeta          find: /MessageHandlerName = @"ABI\d+_\d+_\d+ReactNativeWebView";/,
38e3857a00STomasz Sapeta          replaceWith: `MessageHandlerName = @"ReactNativeWebView";`,
39e3857a00STomasz Sapeta        },
40153a65cbSTomasz Sapeta        {
41*453643feSKudo Chien          paths: 'RNCWebViewImpl.m',
42153a65cbSTomasz Sapeta          find: 'NSString *const CUSTOM_SELECTOR',
43153a65cbSTomasz Sapeta          replaceWith: 'static NSString *const CUSTOM_SELECTOR',
44a272999eSBartosz Kaszubowski        },
45e3857a00STomasz Sapeta      ],
46e3857a00STomasz Sapeta    },
4732f98261SEric Samelson    'react-native-reanimated': {
486c286483STomasz Sapeta      path: [
496c286483STomasz Sapeta        {
506c286483STomasz Sapeta          find: /\b(ReanimatedSensor)/g,
516c286483STomasz Sapeta          replaceWith: `${prefix}$1`,
526c286483STomasz Sapeta        },
536c286483STomasz Sapeta      ],
5432f98261SEric Samelson      content: [
5532f98261SEric Samelson        {
5632f98261SEric Samelson          find: 'namespace reanimated',
5732f98261SEric Samelson          replaceWith: `namespace ${prefix}reanimated`,
5832f98261SEric Samelson        },
5932f98261SEric Samelson        {
6032f98261SEric Samelson          find: /\breanimated::/g,
6132f98261SEric Samelson          replaceWith: `${prefix}reanimated::`,
6232f98261SEric Samelson        },
6332f98261SEric Samelson        {
6432f98261SEric Samelson          paths: '*.h',
656a1ccd08SBrent Vatne          find: new RegExp(`ReactCommon/(?!${prefix})`, 'g'),
6632f98261SEric Samelson          replaceWith: `ReactCommon/${prefix}`,
6732f98261SEric Samelson        },
6832f98261SEric Samelson        {
6932f98261SEric Samelson          paths: '**/Transitioning/*.m',
7032f98261SEric Samelson          find: `RCTConvert+${prefix}REATransition.h`,
7132f98261SEric Samelson          replaceWith: 'RCTConvert+REATransition.h',
7232f98261SEric Samelson        },
7332f98261SEric Samelson        {
746a1ccd08SBrent Vatne          paths: 'REAUIManager.{h,mm}',
756a1ccd08SBrent Vatne          find: /(blockSetter|_toBeRemovedRegister|_parentMapper|_animationsManager|_scheduler)/g,
7632f98261SEric Samelson          replaceWith: `${prefix}$1`,
7732f98261SEric Samelson        },
7832f98261SEric Samelson        {
7932f98261SEric Samelson          paths: 'REATransitionAnimation.m',
8032f98261SEric Samelson          find: /(SimAnimationDragCoefficient)\(/g,
8132f98261SEric Samelson          replaceWith: `${prefix}$1(`,
8232f98261SEric Samelson        },
836a1ccd08SBrent Vatne        {
846a1ccd08SBrent Vatne          paths: 'REAAnimationsManager.m',
856a1ccd08SBrent Vatne          find: /^(#import <.*React)\/UIView\+(.+)\.h>/gm,
866a1ccd08SBrent Vatne          replaceWith: `$1/${prefix}UIView+$2.h>`,
876a1ccd08SBrent Vatne        },
886a1ccd08SBrent Vatne        {
896a1ccd08SBrent Vatne          paths: 'REAAnimationsManager.m',
90874f7bdcSKudo Chien          // `dataComponenetsByName[@"ABI44_0_0RCTView"];` -> `dataComponenetsByName[@"RCTView"];`
91874f7bdcSKudo Chien          // the RCTComponentData internal view name is not versioned
92874f7bdcSKudo Chien          find: new RegExp(`(RCTComponentData .+)\\[@"${prefix}(RCT.+)"\\];`, 'g'),
93a272999eSBartosz Kaszubowski          replaceWith: '$1[@"$2"];',
94a272999eSBartosz Kaszubowski        },
956c286483STomasz Sapeta        {
966c286483STomasz Sapeta          paths: ['**/sensor/**', 'NativeProxy.mm'],
976c286483STomasz Sapeta          find: /\b(ReanimatedSensor)/g,
986c286483STomasz Sapeta          replaceWith: `${prefix}$1`,
996c286483STomasz Sapeta        },
1006c286483STomasz Sapeta        {
101*453643feSKudo Chien          paths: 'REANodesManager.mm',
1026c286483STomasz Sapeta          find: /\b(ComponentUpdate)\b/g,
1036c286483STomasz Sapeta          replaceWith: `${prefix}$1`,
1046c286483STomasz Sapeta        },
1059eae8a6aSKudo Chien        {
106*453643feSKudo Chien          paths: 'REASnapshot.m',
107*453643feSKudo Chien          find: /^(const int (ScreenStackPresentationModal|DEFAULT_MODAL_TOP_OFFSET))/gm,
108*453643feSKudo Chien          replaceWith: `static $1`,
1099eae8a6aSKudo Chien        },
1107d56b193SKudo Chien        {
111*453643feSKudo Chien          paths: [
112*453643feSKudo Chien            'NativeProxy.mm',
113*453643feSKudo Chien            'ReanimatedRuntime.h',
114*453643feSKudo Chien            'ReanimatedRuntime.cpp',
115*453643feSKudo Chien            'ReanimatedHermesRuntime.h',
116*453643feSKudo Chien            'ReanimatedHermesRuntime.cpp',
117*453643feSKudo Chien            'REAMessageThread.h',
118*453643feSKudo Chien          ],
119*453643feSKudo Chien          find: new RegExp(
120*453643feSKudo Chien            `(__has_include\\(|#import\\s+|#include\\s+)<(cxxreact|reacthermes)\\/(${prefix})?(MessageQueueThread|HermesExecutorFactory)(\\.h>\\)?)`,
121*453643feSKudo Chien            'g'
122*453643feSKudo Chien          ),
123*453643feSKudo Chien          replaceWith: `$1<${prefix}$2/${prefix}$4$5`,
124*453643feSKudo Chien        },
125*453643feSKudo Chien        {
126*453643feSKudo Chien          paths: ['ReanimatedRuntime.h', 'ReanimatedHermesRuntime.h'],
127*453643feSKudo Chien          find: `        <reacthermes/${prefix}HermesExecutorFactory.h>) || __has_include(<hermes/hermes.h>))`,
128*453643feSKudo Chien          replaceWith: `        <${prefix}reacthermes/${prefix}HermesExecutorFactory.h>) || __has_include(<hermes/hermes.h>))`,
129*453643feSKudo Chien        },
130*453643feSKudo Chien        {
131*453643feSKudo Chien          paths: ['ReanimatedHermesRuntime.h', 'ReanimatedHermesRuntime.cpp'],
132*453643feSKudo Chien          find: /^((#if __has_include|#include).+\/)(RuntimeAdapter|Registration)(\.h>)$/gm,
133*453643feSKudo Chien          replaceWith: `$1${prefix}$3$4`,
134*453643feSKudo Chien        },
135*453643feSKudo Chien        {
136*453643feSKudo Chien          paths: 'RCTAppDelegate+Reanimated.h',
137*453643feSKudo Chien          find: new RegExp(`<${prefix}React-${prefix}RCTAppDelegate/`, 'g'),
138*453643feSKudo Chien          replaceWith: `<${prefix}React-RCTAppDelegate/`,
139*453643feSKudo Chien        },
140*453643feSKudo Chien        {
141*453643feSKudo Chien          paths: 'RCTAppDelegate+Reanimated.h',
142*453643feSKudo Chien          find: new RegExp(
143*453643feSKudo Chien            `(#if __has_include\\(|#import )<${prefix}React-cxxreact/cxxreact/JSExecutor\\.h>`,
144*453643feSKudo Chien            'g'
145*453643feSKudo Chien          ),
146*453643feSKudo Chien          replaceWith: `$1<${prefix}React-cxxreact/${prefix}cxxreact/${prefix}JSExecutor.h>`,
147*453643feSKudo Chien        },
148*453643feSKudo Chien        {
149*453643feSKudo Chien          // Workaround for jsi somehow be transformed back to unversioned path
150*453643feSKudo Chien          find: /^#include <jsi\/jsi\.h>/gm,
151*453643feSKudo Chien          replaceWith: `#include <${prefix}jsi/${prefix}jsi.h>`,
1527d56b193SKudo Chien        },
1536185d13dSKudo Chien        {
1546185d13dSKudo Chien          paths: 'RNReanimated.podspec.json',
155*453643feSKudo Chien          find: /(REACT_NATIVE_MINOR_VERSION|REANIMATED_VERSION)/g,
1566185d13dSKudo Chien          replaceWith: `${prefix}$1`,
1576185d13dSKudo Chien        },
158*453643feSKudo Chien        {
159*453643feSKudo Chien          paths: 'RNReanimated.podspec.json',
160*453643feSKudo Chien          find: new RegExp(
161*453643feSKudo Chien            `\\/react-native-lab\\/react-native\\/packages\\/react-native\\/${prefix}ReactCommon`,
162*453643feSKudo Chien            'g'
163*453643feSKudo Chien          ),
164*453643feSKudo Chien          replaceWith: `/ios/versioned-react-native/${prefix}/ReactNative/ReactCommon`,
165*453643feSKudo Chien        },
16632f98261SEric Samelson      ],
16732f98261SEric Samelson    },
16832f98261SEric Samelson    'react-native-gesture-handler': {
16932f98261SEric Samelson      path: [
17032f98261SEric Samelson        {
1716cd584bfSTomasz Sapeta          find: /\bRN(\w+?)\.(h|m|mm)/,
1726cd584bfSTomasz Sapeta          replaceWith: `${prefix}RN$1.$2`,
17332f98261SEric Samelson        },
17432f98261SEric Samelson      ],
17532f98261SEric Samelson      content: [
17632f98261SEric Samelson        {
1776cd584bfSTomasz Sapeta          // `RNG*` symbols are already prefixed at this point,
1786cd584bfSTomasz Sapeta          // but there are some new symbols in RNGH that don't have "G".
1790e34784dSTomasz Sapeta          paths: '*.{h,m,mm}',
1806cd584bfSTomasz Sapeta          find: /\bRN(\w+?)\b/g,
1816cd584bfSTomasz Sapeta          replaceWith: `${prefix}RN$1`,
18232f98261SEric Samelson        },
183561190a1SŁukasz Kosmaty        {
184561190a1SŁukasz Kosmaty          paths: 'RNGestureHandler.m',
185561190a1SŁukasz Kosmaty          find: /UIGestureRecognizer \(GestureHandler\)/g,
186561190a1SŁukasz Kosmaty          replaceWith: `UIGestureRecognizer (${prefix}GestureHandler)`,
187561190a1SŁukasz Kosmaty        },
188561190a1SŁukasz Kosmaty        {
189561190a1SŁukasz Kosmaty          paths: 'RNGestureHandler.m',
190561190a1SŁukasz Kosmaty          find: /gestureHandler/g,
191561190a1SŁukasz Kosmaty          replaceWith: `${prefix}gestureHandler`,
192561190a1SŁukasz Kosmaty        },
19332f98261SEric Samelson      ],
19432f98261SEric Samelson    },
195eb2c86e3SCharlie Cruzan    'react-native-pager-view': {
196eb2c86e3SCharlie Cruzan      path: [
197eb2c86e3SCharlie Cruzan        {
198eb2c86e3SCharlie Cruzan          find: /(ReactNativePageView|ReactViewPagerManager)\.(h|m)/,
199eb2c86e3SCharlie Cruzan          replaceWith: `${prefix}$1.$2`,
200eb2c86e3SCharlie Cruzan        },
201eb2c86e3SCharlie Cruzan      ],
202eb2c86e3SCharlie Cruzan      content: [
203eb2c86e3SCharlie Cruzan        {
204eb2c86e3SCharlie Cruzan          find: `${prefix}JKBigInteger.h`,
205eb2c86e3SCharlie Cruzan          replaceWith: `JKBigInteger.h`,
206eb2c86e3SCharlie Cruzan        },
207eb2c86e3SCharlie Cruzan      ],
208eb2c86e3SCharlie Cruzan    },
20932f98261SEric Samelson    'react-native-screens': {
21032f98261SEric Samelson      content: [],
21132f98261SEric Samelson    },
212a1a2c328SKudo Chien    '@shopify/react-native-skia': {
213a1a2c328SKudo Chien      path: [
214a1a2c328SKudo Chien        {
215*453643feSKudo Chien          find: /\b(DisplayLink|PlatformContext|SkiaDrawView|SkiaDrawViewManager|SkiaManager|SkiaUIView|SkiaPictureViewManager|SkiaDomViewManager|ViewScreenshotService)/g,
216a1a2c328SKudo Chien          replaceWith: `${prefix}$1`,
217a1a2c328SKudo Chien        },
218a1a2c328SKudo Chien      ],
219a1a2c328SKudo Chien      content: [
220a1a2c328SKudo Chien        {
221a1a2c328SKudo Chien          paths: '*.h',
222a1a2c328SKudo Chien          find: new RegExp(`ReactCommon/(?!${prefix})`, 'g'),
223a1a2c328SKudo Chien          replaceWith: `ReactCommon/${prefix}`,
224a1a2c328SKudo Chien        },
225a1a2c328SKudo Chien        {
226*453643feSKudo Chien          find: /\b(DisplayLink|PlatformContext|SkiaDrawView|SkiaDrawViewManager|SkiaManager|RNJsi|SkiaUIView|SkiaPictureViewManager|SkiaDomViewManager|ViewScreenshotService)/g,
227a1a2c328SKudo Chien          replaceWith: `${prefix}$1`,
228a1a2c328SKudo Chien        },
229a1a2c328SKudo Chien        {
2306185d13dSKudo Chien          find: /RCT_EXPORT_MODULE\((SkiaDomView)\)/g,
2316185d13dSKudo Chien          replaceWith: `RCT_EXPORT_MODULE(${prefix}$1)`,
2326185d13dSKudo Chien        },
2336185d13dSKudo Chien        {
234a1a2c328SKudo Chien          // The module name in bridge should be unversioned `RNSkia`
235fe5cfb17STomasz Sapeta          paths: '*.mm',
236a1a2c328SKudo Chien          find: new RegExp(`(\\smoduleForName:@")${prefix}(RNSkia")`, 'g'),
237a1a2c328SKudo Chien          replaceWith: '$1$2',
238a1a2c328SKudo Chien        },
239a1a2c328SKudo Chien        {
240a1a2c328SKudo Chien          // __typename__ exposed to js should be unversioned
241a1a2c328SKudo Chien          find: new RegExp(
242a1a2c328SKudo Chien            `(\\bJSI_PROPERTY_GET\\(__typename__\\) \\{\\n\\s*return jsi::String::createFromUtf8\\(runtime, ")${prefix}(.*")`,
243a1a2c328SKudo Chien            'gm'
244a1a2c328SKudo Chien          ),
245a1a2c328SKudo Chien          replaceWith: '$1$2',
246a1a2c328SKudo Chien        },
247a1a2c328SKudo Chien      ],
248a1a2c328SKudo Chien    },
24980d17c75SKudo Chien    'react-native-svg': {
25080d17c75SKudo Chien      content: [
25180d17c75SKudo Chien        {
25280d17c75SKudo Chien          find: new RegExp(`\\b(${prefix}RCTConvert)\\+${prefix}(RNSVG\.h)`, 'g'),
25380d17c75SKudo Chien          replaceWith: `$1+$2`,
25480d17c75SKudo Chien        },
25580d17c75SKudo Chien        {
25680d17c75SKudo Chien          paths: 'RNSVGRenderable.mm',
25780d17c75SKudo Chien          find: /\b(saturate)\(/g,
25880d17c75SKudo Chien          replaceWith: `${prefix}$1(`,
25980d17c75SKudo Chien        },
26080d17c75SKudo Chien        {
26180d17c75SKudo Chien          paths: 'RNSVGPainter.mm',
26280d17c75SKudo Chien          find: /\b(PatternFunction)\b/g,
26380d17c75SKudo Chien          replaceWith: `${prefix}$1`,
26480d17c75SKudo Chien        },
26580d17c75SKudo Chien        {
26680d17c75SKudo Chien          paths: 'RNSVGFontData.mm',
26780d17c75SKudo Chien          find: /\b(AbsoluteFontWeight|bolder|lighter|nearestFontWeight)\(/gi,
26880d17c75SKudo Chien          replaceWith: `${prefix}$1(`,
26980d17c75SKudo Chien        },
27080d17c75SKudo Chien        {
27180d17c75SKudo Chien          paths: 'RNSVGTSpan.mm',
27280d17c75SKudo Chien          find: new RegExp(`\\b(${prefix}RNSVGTopAlignedLabel\\s*\\*\\s*label)\\b`, 'gi'),
27380d17c75SKudo Chien          replaceWith: 'static $1',
27480d17c75SKudo Chien        },
27580d17c75SKudo Chien        {
27680d17c75SKudo Chien          paths: 'RNSVGMarker.mm',
27780d17c75SKudo Chien          find: /\b(deg2rad)\b/g,
27880d17c75SKudo Chien          replaceWith: `${prefix}$1`,
27980d17c75SKudo Chien        },
28080d17c75SKudo Chien        {
28180d17c75SKudo Chien          paths: 'RNSVGMarkerPosition.mm',
28280d17c75SKudo Chien          find: /\b(PathIsDone|rad2deg|SlopeAngleRadians|CurrentAngle|subtract|ExtractPathElementFeatures|UpdateFromPathElement)\b/g,
28380d17c75SKudo Chien          replaceWith: `${prefix}$1`,
28480d17c75SKudo Chien        },
28580d17c75SKudo Chien        {
28680d17c75SKudo Chien          paths: 'RNSVGMarkerPosition.mm',
28780d17c75SKudo Chien          find: /\b(positions_|element_index_|origin_|subpath_start_|in_slope_|out_slope_|auto_start_reverse_)\b/g,
28880d17c75SKudo Chien          replaceWith: `${prefix}$1`,
28980d17c75SKudo Chien        },
29080d17c75SKudo Chien        {
29180d17c75SKudo Chien          paths: 'RNSVGPathMeasure.mm',
29280d17c75SKudo Chien          find: /\b(distance|subdivideBezierAtT)\b/g,
29380d17c75SKudo Chien          replaceWith: `${prefix}$1`,
29480d17c75SKudo Chien        },
29580d17c75SKudo Chien      ],
29680d17c75SKudo Chien    },
297a1142e8bSTomasz Sapeta  };
298a1142e8bSTomasz Sapeta}
299