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: '', 13 find: /\.reactFocus\(/, 14 replaceWith: `.${prefix.toLowerCase()}ReactFocus(`, 15 }, 16 ], 17 }, 18 'lottie-react-native': { 19 content: [ 20 { 21 paths: 'ContainerView.swift', 22 find: /\breactSetFrame/g, 23 replaceWith: `${prefix.toLowerCase()}ReactSetFrame`, 24 }, 25 ], 26 }, 27 'react-native-webview': { 28 content: [ 29 { 30 paths: 'RNCWebView.m', 31 find: new RegExp(`#import "objc/${prefix}runtime\\.h"`, ''), 32 replaceWith: '#import "objc/runtime.h"', 33 }, 34 { 35 paths: 'RNCWebView.m', 36 find: /\b(_SwizzleHelperWK)\b/g, 37 replaceWith: `${prefix}$1`, 38 }, 39 { 40 // see issue: https://github.com/expo/expo/issues/4463 41 paths: 'RNCWebView.m', 42 find: /MessageHandlerName = @"ABI\d+_\d+_\d+ReactNativeWebView";/, 43 replaceWith: `MessageHandlerName = @"ReactNativeWebView";`, 44 }, 45 { 46 paths: 'RNCWebView.m', 47 find: 'NSString *const CUSTOM_SELECTOR', 48 replaceWith: 'static NSString *const CUSTOM_SELECTOR', 49 }, 50 ], 51 }, 52 'react-native-reanimated': { 53 path: [ 54 { 55 find: /\b(ReanimatedSensor)/g, 56 replaceWith: `${prefix}$1`, 57 }, 58 ], 59 content: [ 60 { 61 find: 'namespace reanimated', 62 replaceWith: `namespace ${prefix}reanimated`, 63 }, 64 { 65 find: /\breanimated::/g, 66 replaceWith: `${prefix}reanimated::`, 67 }, 68 { 69 paths: '*.h', 70 find: new RegExp(`ReactCommon/(?!${prefix})`, 'g'), 71 replaceWith: `ReactCommon/${prefix}`, 72 }, 73 { 74 paths: '**/Transitioning/*.m', 75 find: `RCTConvert+${prefix}REATransition.h`, 76 replaceWith: 'RCTConvert+REATransition.h', 77 }, 78 { 79 paths: 'REAUIManager.{h,mm}', 80 find: /(blockSetter|_toBeRemovedRegister|_parentMapper|_animationsManager|_scheduler)/g, 81 replaceWith: `${prefix}$1`, 82 }, 83 { 84 paths: 'REATransitionAnimation.m', 85 find: /(SimAnimationDragCoefficient)\(/g, 86 replaceWith: `${prefix}$1(`, 87 }, 88 { 89 paths: 'REAAnimationsManager.m', 90 find: /^(#import <.*React)\/UIView\+(.+)\.h>/gm, 91 replaceWith: `$1/${prefix}UIView+$2.h>`, 92 }, 93 { 94 paths: 'REAAnimationsManager.m', 95 find: `UIView+${prefix}React.h`, 96 replaceWith: `UIView+React.h`, 97 }, 98 { 99 paths: 'REAAnimationsManager.m', 100 // `dataComponenetsByName[@"ABI44_0_0RCTView"];` -> `dataComponenetsByName[@"RCTView"];` 101 // the RCTComponentData internal view name is not versioned 102 find: new RegExp(`(RCTComponentData .+)\\[@"${prefix}(RCT.+)"\\];`, 'g'), 103 replaceWith: '$1[@"$2"];', 104 }, 105 { 106 paths: ['**/sensor/**', 'NativeProxy.mm'], 107 find: /\b(ReanimatedSensor)/g, 108 replaceWith: `${prefix}$1`, 109 }, 110 { 111 paths: 'REANodesManager.m', 112 find: /\b(ComponentUpdate)\b/g, 113 replaceWith: `${prefix}$1`, 114 }, 115 ], 116 }, 117 'react-native-gesture-handler': { 118 path: [ 119 { 120 find: /\bRN(\w+?)\.(h|m|mm)/, 121 replaceWith: `${prefix}RN$1.$2`, 122 }, 123 ], 124 content: [ 125 { 126 find: `UIView+${prefix}React.h`, 127 replaceWith: `${prefix}UIView+React.h`, 128 }, 129 { 130 // `RNG*` symbols are already prefixed at this point, 131 // but there are some new symbols in RNGH that don't have "G". 132 paths: '*.{h,m,mm}', 133 find: /\bRN(\w+?)\b/g, 134 replaceWith: `${prefix}RN$1`, 135 }, 136 { 137 paths: 'RNGestureHandler.m', 138 find: /UIGestureRecognizer \(GestureHandler\)/g, 139 replaceWith: `UIGestureRecognizer (${prefix}GestureHandler)`, 140 }, 141 { 142 paths: 'RNGestureHandler.m', 143 find: /gestureHandler/g, 144 replaceWith: `${prefix}gestureHandler`, 145 }, 146 ], 147 }, 148 'react-native-pager-view': { 149 path: [ 150 { 151 find: /(ReactNativePageView|ReactViewPagerManager)\.(h|m)/, 152 replaceWith: `${prefix}$1.$2`, 153 }, 154 ], 155 content: [ 156 { 157 find: `UIView+${prefix}React.h`, 158 replaceWith: `${prefix}UIView+React.h`, 159 }, 160 { 161 find: `${prefix}JKBigInteger.h`, 162 replaceWith: `JKBigInteger.h`, 163 }, 164 ], 165 }, 166 '@react-native-segmented-control/segmented-control': { 167 content: [ 168 { 169 find: `UIView+${prefix}React.h`, 170 replaceWith: `${prefix}UIView+React.h`, 171 }, 172 ], 173 }, 174 'react-native-screens': { 175 content: [], 176 }, 177 '@shopify/react-native-skia': { 178 path: [ 179 { 180 find: /\b(DisplayLink|PlatformContext|SkiaDrawView|SkiaDrawViewManager|SkiaManager)/g, 181 replaceWith: `${prefix}$1`, 182 }, 183 ], 184 content: [ 185 { 186 paths: '*.h', 187 find: new RegExp(`ReactCommon/(?!${prefix})`, 'g'), 188 replaceWith: `ReactCommon/${prefix}`, 189 }, 190 { 191 find: /\b(DisplayLink|PlatformContext|SkiaDrawView|SkiaDrawViewManager|SkiaManager|RNJsi)/g, 192 replaceWith: `${prefix}$1`, 193 }, 194 { 195 // The module name in bridge should be unversioned `RNSkia` 196 paths: 'SkiaDrawViewManager.mm', 197 find: new RegExp(`(\\smoduleForName:@")${prefix}(RNSkia")`, 'g'), 198 replaceWith: '$1$2', 199 }, 200 { 201 // __typename__ exposed to js should be unversioned 202 find: new RegExp( 203 `(\\bJSI_PROPERTY_GET\\(__typename__\\) \\{\\n\\s*return jsi::String::createFromUtf8\\(runtime, ")${prefix}(.*")`, 204 'gm' 205 ), 206 replaceWith: '$1$2', 207 }, 208 ], 209 }, 210 }; 211} 212