11833af43SKudo Chienimport { FileTransforms, StringTransform } from '../../../Transforms.types'; 21833af43SKudo Chien 31833af43SKudo Chienexport function vendoredModulesTransforms(prefix: string): Record<string, FileTransforms> { 46239b2d0SKudo Chien const sdkVersion = prefix.replace(/abi(\d+)_0_0/, 'sdk$1'); 51833af43SKudo Chien return { 61833af43SKudo Chien '@shopify/react-native-skia': { 71833af43SKudo Chien content: [ 81833af43SKudo Chien { 91833af43SKudo Chien paths: 'build.gradle', 1071ea6032SKudo Chien find: `def nodeModules = Paths.get(projectDir.getPath(), '../../../../../..', 'react-native-lab/versioned-react-native/packages/react-native/packages').toString()`, 111833af43SKudo Chien replaceWith: `def nodeModules = Paths.get(projectDir.getPath(), '../../../../..').toString()`, 121833af43SKudo Chien }, 131833af43SKudo Chien { 141833af43SKudo Chien paths: 'build.gradle', 151833af43SKudo Chien find: 'sourceBuild = true', 161833af43SKudo Chien replaceWith: 'sourceBuild = false', 171833af43SKudo Chien }, 181833af43SKudo Chien { 1971a4a097SKudo Chien paths: 'build.gradle', 2071a4a097SKudo Chien // The `android/versioned-react-native/ReactAndroid/gradle.properties` is not committed to git, 2122b45c56SKudo Chien // we use the `ReactAndroid/gradle.properties` for versioned skia instead. 2271a4a097SKudo Chien // Even though it not always correct, e.g. when ReactAndroid upgrades to newer version, the versions are inconsistent. 2371a4a097SKudo Chien // Since skia current only uses the `REACT_NATIVE_VERSION` property, 2471a4a097SKudo Chien // after we prebuild the lib and cleanup CMakeLists.txt, these properties are actually not be used. 25*4440fb50SKudo Chien find: '$nodeModules/versioned-react-native/packages/react-native/ReactAndroid/gradle.properties', 2622b45c56SKudo Chien replaceWith: '$defaultDir/gradle.properties', 2771a4a097SKudo Chien }, 28*4440fb50SKudo Chien { 29*4440fb50SKudo Chien paths: 'build.gradle', 30*4440fb50SKudo Chien find: /( prefab\s*\{)([\s\S]*?)(^ \}\s)/gm, 31*4440fb50SKudo Chien replaceWith: (_, p1, p2, p3) => 32*4440fb50SKudo Chien [p1, p2.replace('rnskia', `rnskia_${prefix}`), p3].join(''), 33*4440fb50SKudo Chien }, 346239b2d0SKudo Chien ], 356239b2d0SKudo Chien }, 366239b2d0SKudo Chien 'react-native-svg': { 376239b2d0SKudo Chien content: [ 3871a4a097SKudo Chien { 396239b2d0SKudo Chien paths: 'build.gradle', 406239b2d0SKudo Chien find: /(implementation 'host.exp:reactandroid-abi\d+_0_0:1\.0\.0')/g, 416239b2d0SKudo Chien replaceWith: 426239b2d0SKudo Chien '$1\n' + 436239b2d0SKudo Chien " compileOnly 'com.facebook.fresco:fresco:+'\n" + 446239b2d0SKudo Chien " compileOnly 'com.facebook.fresco:imagepipeline-okhttp3:+'\n" + 45*4440fb50SKudo Chien " compileOnly 'com.facebook.fresco:ui-common:+'\n" + 46*4440fb50SKudo Chien " compileOnly 'javax.inject:javax.inject:+'", 476239b2d0SKudo Chien }, 486239b2d0SKudo Chien { 496239b2d0SKudo Chien find: /\b(import (static )?)(com.horcrux.)/g, 506239b2d0SKudo Chien replaceWith: `$1${prefix}.$3`, 516239b2d0SKudo Chien }, 526239b2d0SKudo Chien ], 536239b2d0SKudo Chien }, 546239b2d0SKudo Chien 'react-native-gesture-handler': { 556239b2d0SKudo Chien content: [ 566239b2d0SKudo Chien { 576239b2d0SKudo Chien paths: 'build.gradle', 586239b2d0SKudo Chien find: /vendored_unversioned_react-native-reanimated/g, 596239b2d0SKudo Chien replaceWith: `vendored_${sdkVersion}_react-native-reanimated`, 606239b2d0SKudo Chien }, 616239b2d0SKudo Chien ], 626239b2d0SKudo Chien }, 636239b2d0SKudo Chien 'react-native-reanimated': { 646239b2d0SKudo Chien content: [ 656239b2d0SKudo Chien { 666239b2d0SKudo Chien paths: 'build.gradle', 6771ea6032SKudo Chien find: `def reactNativeRootDir = Paths.get(projectDir.getPath(), '../../../../../react-native-lab/versioned-react-native/packages/react-native/packages/react-native').toFile()`, 6871ea6032SKudo Chien replaceWith: `def reactNativeRootDir = Paths.get(projectDir.getPath(), '../../../../versioned-react-native/packages/react-native').toFile()`, 696239b2d0SKudo Chien }, 706239b2d0SKudo Chien { 716239b2d0SKudo Chien paths: 'build.gradle', 725ff37293SKudo Chien find: `compileOnly "com.facebook.react:hermes-android:\${REACT_NATIVE_VERSION}"`, 736239b2d0SKudo Chien replaceWith: 746239b2d0SKudo Chien `if (file("\${reactNativeRootDir}/ReactAndroid/hermes-engine/build/outputs/aar/hermes-engine-release.aar").exists()) {\n` + 756239b2d0SKudo Chien ` compileOnly(files("\${reactNativeRootDir}/ReactAndroid/hermes-engine/build/outputs/aar/hermes-engine-release.aar"))\n` + 766239b2d0SKudo Chien ` }\n` + 776239b2d0SKudo Chien ` compileOnly 'androidx.swiperefreshlayout:swiperefreshlayout:+'`, 786239b2d0SKudo Chien }, 796239b2d0SKudo Chien { 806239b2d0SKudo Chien paths: 'build.gradle', 816239b2d0SKudo Chien transform: (text: string) => 826239b2d0SKudo Chien text + `\nandroid.packagingOptions.excludes.add("**/libhermes*.so")`, 836239b2d0SKudo Chien }, 846239b2d0SKudo Chien { 85ab11e3c9SKudo Chien paths: 'build.gradle', 86ab11e3c9SKudo Chien // The `android/versioned-react-native/ReactAndroid/gradle.properties` is not committed to git, 87ab11e3c9SKudo Chien // we use the `ReactAndroid/gradle.properties` for versioned reanimated instead. 88ab11e3c9SKudo Chien // Even though it not always correct, e.g. when ReactAndroid upgrades to newer version, the versions are inconsistent. 89ab11e3c9SKudo Chien // Since reanimated doesn't use these properties for react-native 0.71, that should be safe. 90ab11e3c9SKudo Chien find: '$reactNativeRootDir/ReactAndroid/gradle.properties', 9171ea6032SKudo Chien replaceWith: 9271ea6032SKudo Chien '$rootDir/../react-native-lab/react-native/packages/react-native/ReactAndroid/gradle.properties', 93ab11e3c9SKudo Chien }, 94ab11e3c9SKudo Chien { 956239b2d0SKudo Chien paths: 'CMakeLists.txt', 966239b2d0SKudo Chien find: /\b(hermes-engine::libhermes)/g, 976239b2d0SKudo Chien replaceWith: `$1_${prefix}`, 986239b2d0SKudo Chien }, 996239b2d0SKudo Chien { 10071ea6032SKudo Chien paths: 'NativeProxyCommon.java', 1016239b2d0SKudo Chien find: new RegExp(`\\b(?<!${prefix}\\.)(com.swmansion.gesturehandler.)`, 'g'), 1026239b2d0SKudo Chien replaceWith: `${prefix}.$1`, 1036239b2d0SKudo Chien }, 1046239b2d0SKudo Chien { 1056239b2d0SKudo Chien paths: '**/*.{java,kt}', 1066239b2d0SKudo Chien find: new RegExp(`\\b(?<!${prefix}\\.)(com.swmansion.reanimated.R\\.)`, 'g'), 1076239b2d0SKudo Chien replaceWith: `${prefix}.$1`, 1086239b2d0SKudo Chien }, 1095ff37293SKudo Chien ], 1105ff37293SKudo Chien }, 1115ff37293SKudo Chien '@react-native-async-storage/async-storage': { 1125ff37293SKudo Chien content: [ 1136239b2d0SKudo Chien { 1145ff37293SKudo Chien find: /\b(import (static )?)(com.reactnativecommunity.asyncstorage.)/g, 1155ff37293SKudo Chien replaceWith: `$1${prefix}.$3`, 1165ff37293SKudo Chien }, 1175ff37293SKudo Chien ], 1185ff37293SKudo Chien }, 1195ff37293SKudo Chien 'react-native-pager-view': { 1205ff37293SKudo Chien content: [ 1215ff37293SKudo Chien { 1225ff37293SKudo Chien find: /\b(import (static )?)(com.reactnativepagerview.)/g, 1235ff37293SKudo Chien replaceWith: `$1${prefix}.$3`, 1241833af43SKudo Chien }, 1251833af43SKudo Chien ], 1261833af43SKudo Chien }, 1271833af43SKudo Chien }; 1281833af43SKudo Chien} 1291833af43SKudo Chien 1301833af43SKudo Chienexport function exponentPackageTransforms(prefix: string): Record<string, StringTransform[]> { 1311833af43SKudo Chien return { 1321833af43SKudo Chien '@shopify/react-native-skia': [ 1331833af43SKudo Chien { 1345d0ad635SKudo Chien find: /\bimport (com.shopify.reactnative.skia.RNSkiaPackage)/g, 1355d0ad635SKudo Chien replaceWith: `import ${prefix}.$1`, 1365d0ad635SKudo Chien }, 1375d0ad635SKudo Chien ], 1385d0ad635SKudo Chien '@shopify/flash-list': [ 1395d0ad635SKudo Chien { 1405d0ad635SKudo Chien find: /\bimport (com.shopify.reactnative.flash_list.ReactNativeFlashListPackage)/g, 1415d0ad635SKudo Chien replaceWith: `import ${prefix}.$1`, 1421833af43SKudo Chien }, 1431833af43SKudo Chien ], 1446239b2d0SKudo Chien '@react-native-community/slider': [ 1456239b2d0SKudo Chien { 1466239b2d0SKudo Chien find: /\bimport (com\.reactnativecommunity\.slider)/g, 1476239b2d0SKudo Chien replaceWith: `import ${prefix}.$1`, 1486239b2d0SKudo Chien }, 1496239b2d0SKudo Chien ], 1506239b2d0SKudo Chien 'react-native-gesture-handler': [ 1516239b2d0SKudo Chien { 1526239b2d0SKudo Chien find: /\bimport (com.swmansion.gesturehandler)/g, 1536239b2d0SKudo Chien replaceWith: `import ${prefix}.$1`, 1546239b2d0SKudo Chien }, 1556239b2d0SKudo Chien ], 1566239b2d0SKudo Chien 'react-native-screens': [ 1576239b2d0SKudo Chien { 1586239b2d0SKudo Chien find: /\bimport (com.swmansion.rnscreens)/g, 1596239b2d0SKudo Chien replaceWith: `import ${prefix}.$1`, 1606239b2d0SKudo Chien }, 1616239b2d0SKudo Chien ], 1626239b2d0SKudo Chien 'react-native-svg': [ 1636239b2d0SKudo Chien { 1646239b2d0SKudo Chien find: /\bimport (com.horcrux.svg)/g, 1656239b2d0SKudo Chien replaceWith: `import ${prefix}.$1`, 1666239b2d0SKudo Chien }, 1676239b2d0SKudo Chien ], 1685ff37293SKudo Chien '@react-native-async-storage/async-storage': [ 1695ff37293SKudo Chien { 1705ff37293SKudo Chien find: /\bimport (com.reactnativecommunity.asyncstorage.)/g, 1715ff37293SKudo Chien replaceWith: `import ${prefix}.$1`, 1725ff37293SKudo Chien }, 1735ff37293SKudo Chien ], 1745ff37293SKudo Chien 'react-native-pager-view': [ 1755ff37293SKudo Chien { 1765ff37293SKudo Chien find: /\bimport (com.reactnativepagerview.)/g, 1775ff37293SKudo Chien replaceWith: `import ${prefix}.$1`, 1785ff37293SKudo Chien }, 1795ff37293SKudo Chien ], 1801833af43SKudo Chien }; 1811833af43SKudo Chien} 182