react-native-macos/Libraries
Ramanpreet Nara 69698b25fc Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker
Summary:
To make iOS TurboModules integrate with the bridge's onBatchComplete event, they need to use a native CallInvoker. This call invoker is created by the `NativeToJsBridge`, and ObjCTurboModule will use this native CallInvoker to dispatch TurboModule method calls. This diff makes sure that ObjCTurboModules are created with that native CallInvoker.

## Script
```
var withSpaces = (...args) => args.join('\s*')

var regexString = withSpaces(
  '-',
  '\(',
  'std::shared_ptr',
  '<',
  '(?<turboModuleClass>(facebook::react::|react::|::|)TurboModule)',
  '>',
  '\)',
  'getTurboModuleWithJsInvoker',
  ':',
  '\(',
  'std::shared_ptr',
  '<',
  '(?<callInvokerClass>(facebook::react::|react::|::|)CallInvoker)',
  '>',
  '\)',
  '(?<jsInvokerInstance>[A-Za-z0-9]+)',
  'perfLogger',
  ':',
  '\(',
  'id',
  '<',
  'RCTTurboModulePerformanceLogger',
  '>',
  '\)',
  '(?<perfLoggerInstance>[A-Za-z0-9]+)',
  '{',
  'return',
  'std::make_shared',
  '<',
  '(?<specName>(facebook::react::|react::|::|)Native[%A-Za-z0-9]+SpecJSI)',
  '>',
  '\(',
  'self',
  ',',
  '\k<jsInvokerInstance>',
  ',',
  '\k<perfLoggerInstance>',
  '\)',
  ';',
  '}',
)

var replaceString = `- (std::shared_ptr<$<turboModuleClass>>)
    getTurboModuleWithJsInvoker:(std::shared_ptr<$<callInvokerClass>>)$<jsInvokerInstance>
                  nativeInvoker:(std::shared_ptr<$<callInvokerClass>>)nativeInvoker
                     perfLogger:(id<RCTTurboModulePerformanceLogger>)$<perfLoggerInstance>
{
  return std::make_shared<$<specName>>(self, $<jsInvokerInstance>, nativeInvoker, $<perfLoggerInstance>);
}`

const exec = require('../lib/exec');
const abspath = require('../lib/abspath');
const relpath = require('../lib/relpath');
const readFile = (filename) => require('fs').readFileSync(filename, 'utf8');
const writeFile = (filename, content) => require('fs').writeFileSync(filename, content);

function main() {
  const tmFiles = exec('cd ~/fbsource && xbgs -n 10000 -l getTurboModuleWithJsInvoker:').split('\n').filter(Boolean);

  tmFiles
    .filter((filename) => !filename.includes('microsoft-fork-of-react-native'))
    .map(abspath)
    .forEach((filename) => {
      const source = readFile(filename);
      const newSource = source.replace(new RegExp(regexString, 'g'), replaceString);

      if (source == newSource) {
        console.log(relpath(filename));
      }

      writeFile(filename, newSource);
    });
}

if (!module.parent) {
  main();
}
```

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20809202

fbshipit-source-id: 5d39b3cacdaa5681b70ce1803351d0432dd74550
2020-04-03 02:27:10 -07:00
..
ART PlatformColor implementations for iOS and Android (#27908) 2020-03-02 15:12:09 -08:00
ActionSheetIOS Back out "Moving towards UIWindowScene support" 2020-03-05 15:58:44 -08:00
Alert Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Animated Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
AppState Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
BatchedBridge Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Blob Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
BugReporting Convert easy files to flow strict-local 2019-12-05 16:06:46 -08:00
CameraRoll Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
Components Remove console warnings from ScrollView methods 2020-03-27 15:28:48 -07:00
Core Implement nativePerformanceNow to improve Profiler API results (#27885) 2020-03-31 10:23:51 -07:00
DeprecatedPropTypes Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
EventEmitter Exact-by-default codemod for react-native-github 2019-11-21 09:42:57 -08:00
FBLazyVector make RN infra labels public 2020-02-28 12:46:49 -08:00
FBReactNativeSpec Manual changes required to make ObjCTurboModule accept native CallInvoker 2020-04-03 02:27:10 -07:00
HeapCapture Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Image Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
Inspector Enable inspector for Fabric 2020-03-30 14:05:27 -07:00
Interaction Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
JSInspector Exact-by-default codemod for react-native-github 2019-11-21 09:42:57 -08:00
LayoutAnimation Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Linking Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
LinkingIOS Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
Lists Fix issue with onEndReached 2020-03-27 03:58:39 -07:00
LogBox Improve component stack parsing 2020-04-01 16:43:15 -07:00
Modal Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
NativeAnimation Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
NativeModules/specs Add missing NativeEventListener methods to NativeDevSettings (#27838) 2020-01-23 13:20:53 -08:00
Network Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
NewAppScreen Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
Performance Implement nativePerformanceNow to improve Profiler API results (#27885) 2020-03-31 10:23:51 -07:00
PermissionsAndroid Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
Pressability Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
PushNotificationIOS Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
RCTRequired make RN infra labels public 2020-02-28 12:46:49 -08:00
ReactNative Enable inspector for Fabric 2020-03-30 14:05:27 -07:00
ReactPrivate Do not explicitly include ".js" in Library imports (#28311) 2020-03-17 02:11:53 -07:00
Renderer Partial React Sync for Inspector 2020-03-30 14:05:26 -07:00
Settings Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
Share Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Storage Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
StyleSheet Add ES Lint rules for `DynamicColorIOS()`and `ColorAndroid()` (#28398) 2020-03-27 23:02:15 -07:00
SurfaceBackedComponent Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
SurfaceHostingComponent Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
Text Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
TurboModule chore: fix typo in comments (#28269) 2020-03-09 15:37:33 -07:00
TypeSafety Guard against null values in object parameters for bridged methods 2020-03-23 17:21:00 -07:00
Types Convert easy files to flow strict-local 2019-12-05 16:06:46 -08:00
Utilities Update PixelRatio 'getFontScale' method description (#28407) 2020-03-30 16:37:18 -07:00
Vibration Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker 2020-04-03 02:27:10 -07:00
WebSocket Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Wrapper Back out "Rename measure to measureContent and pass it LayoutContext" 2020-03-04 05:01:53 -08:00
YellowBox Delete YellowBox 2020-02-21 10:34:40 -08:00
__flowtests__ Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
polyfills Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
vendor Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
.npmignore npmignore: ignore tests and fixtures 2018-02-27 08:42:14 -08:00
Promise.js Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
UTFSequence.js Clean-up $TEMPORARY$object in xplat/js/react-native-github 2019-08-21 09:58:24 -07:00
promiseRejectionIsError.js Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00