react-native-macos/React/CoreModules/RCTDeviceInfo.mm

229 строки
7.5 KiB
Plaintext
Исходник Обычный вид История

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "RCTDeviceInfo.h"
#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <React/RCTAccessibilityManager.h>
#import <React/RCTAssert.h>
#import <React/RCTConstants.h>
#import <React/RCTEventDispatcherProtocol.h>
#import <React/RCTUIUtils.h>
#import <React/RCTUtils.h>
#import "CoreModulesPlugins.h"
using namespace facebook::react;
@interface RCTDeviceInfo () <NativeDeviceInfoSpec>
@end
@implementation RCTDeviceInfo {
UIInterfaceOrientation _currentInterfaceOrientation;
NSDictionary *_currentInterfaceDimensions;
}
@synthesize bridge = _bridge;
@synthesize moduleRegistry = _moduleRegistry;
@synthesize turboModuleRegistry = _turboModuleRegistry;
RCT_EXPORT_MODULE()
+ (BOOL)requiresMainQueueSetup
{
return YES;
}
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
- (void)setBridge:(RCTBridge *)bridge
{
_bridge = bridge;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveNewContentSizeMultiplier)
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
object:_bridge.accessibilityManager];
remove most of tvOS remnants from the code (#29407) Summary: Refs: [0.62 release](https://reactnative.dev/blog/#moving-apple-tv-to-react-native-tvos), https://github.com/facebook/react-native/issues/28706, https://github.com/facebook/react-native/issues/28743, https://github.com/facebook/react-native/issues/29018 This PR removes most of the tvOS remnants in the code. Most of the changes are related to the tvOS platform removal from `.podspec` files, tvOS specific conditionals removal (Obj-C + JS) or tvOS CI/testing pipeline related code. In addition to the changes listed above I have removed the deprecated `Platform.isTVOS` method. I'm not sure how `Platform.isTV` method is correlated with Android TV devices support which is technically not deprecated in the core so I left this method untouched for now. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> * **[Internal] [Removed]** - remove most of tvOS remnants from the code: * `TVEventHandler`, `TVTouchable`, `RCTTVView`, `RCTTVRemoteHandler` and `RCTTVNavigationEventEmitter` * **[Internal] [Removed]** - remove `TARGET_TV_OS` flag and all the usages * **[iOS] [Removed]** - remove deprecated `Platform.isTVOS` method * **[iOS] [Removed]** - remove deprecated and TV related props from View: * `isTVSelectable`, `hasTVPreferredFocus` and `tvParallaxProperties` * **[iOS] [Removed]** - remove `BackHandler` utility implementation Pull Request resolved: https://github.com/facebook/react-native/pull/29407 Test Plan: Local tests (and iOS CI run) do not yield any errors, but I'm not sure how the CI pipeline would react to those changes. That is the reason why this PR is being posted as Draft. Some tweaks and code adjustment could be required. Reviewed By: PeteTheHeat Differential Revision: D22619441 Pulled By: shergin fbshipit-source-id: 9aaf3840c5e8bd469c2cfcfa7c5b441ef71b30b6
2020-09-29 07:24:45 +03:00
_currentInterfaceOrientation = [RCTSharedApplication() statusBarOrientation];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(interfaceOrientationDidChange)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
_currentInterfaceDimensions = RCTExportedDimensions(_bridge, _turboModuleRegistry);
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(interfaceFrameDidChange)
name:UIApplicationDidBecomeActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(interfaceFrameDidChange)
name:RCTUserInterfaceStyleDidChangeNotification
object:nil];
}
static BOOL RCTIsIPhoneX()
{
static BOOL isIPhoneX = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
RCTAssertMainQueue();
CGSize screenSize = [UIScreen mainScreen].nativeBounds.size;
CGSize iPhoneXScreenSize = CGSizeMake(1125, 2436);
CGSize iPhoneXMaxScreenSize = CGSizeMake(1242, 2688);
CGSize iPhoneXRScreenSize = CGSizeMake(828, 1792);
CGSize iPhone12ScreenSize = CGSizeMake(1170, 2532);
CGSize iPhone12MiniScreenSize = CGSizeMake(1080, 2340);
CGSize iPhone12ProMaxScreenSize = CGSizeMake(1284, 2778);
isIPhoneX = CGSizeEqualToSize(screenSize, iPhoneXScreenSize) ||
CGSizeEqualToSize(screenSize, iPhoneXMaxScreenSize) || CGSizeEqualToSize(screenSize, iPhoneXRScreenSize) ||
CGSizeEqualToSize(screenSize, iPhone12ScreenSize) || CGSizeEqualToSize(screenSize, iPhone12MiniScreenSize) ||
CGSizeEqualToSize(screenSize, iPhone12ProMaxScreenSize);
;
});
return isIPhoneX;
}
static NSDictionary *RCTExportedDimensions(RCTBridge *bridge, id<RCTTurboModuleRegistry> turboModuleRegistry)
{
RCTAssertMainQueue();
RCTDimensions dimensions;
if (bridge) {
dimensions = RCTGetDimensions(bridge.accessibilityManager.multiplier ?: 1.0);
} else if (turboModuleRegistry) {
dimensions = RCTGetDimensions(
((RCTAccessibilityManager *)[turboModuleRegistry moduleForName:"RCTAccessibilityManager"]).multiplier ?: 1.0);
} else {
RCTAssert(false, @"Bridge or TurboModuleRegistry must be set to properly init dimensions.");
}
__typeof(dimensions.window) window = dimensions.window;
NSDictionary<NSString *, NSNumber *> *dimsWindow = @{
@"width" : @(window.width),
@"height" : @(window.height),
@"scale" : @(window.scale),
@"fontScale" : @(window.fontScale)
};
__typeof(dimensions.screen) screen = dimensions.screen;
NSDictionary<NSString *, NSNumber *> *dimsScreen = @{
@"width" : @(screen.width),
@"height" : @(screen.height),
@"scale" : @(screen.scale),
@"fontScale" : @(screen.fontScale)
};
return @{@"window" : dimsWindow, @"screen" : dimsScreen};
}
- (NSDictionary<NSString *, id> *)constantsToExport
Start using getConstants Summary: TurboModules depend on a getConstants method. Existing ObjectiveC modules do not have this method. Therefore, I moved the contents of `constantsToExport` to `getConstants` and then had `constantsToExports` call `getConstants`. facebook Since all NativeModules will eventually need to be migrated to the TurboModule system, I didn't restrict this to just the NativeModules in Marketplace. ``` const fs = require('fs'); if (process.argv.length < 3) { throw new Error('Expected a file containing a list of native modules as the third param'); } function read(filename) { return fs.readFileSync(filename, 'utf8'); } const nativeModuleFilenames = read(process.argv[2]).split('\n').filter(Boolean); nativeModuleFilenames.forEach((fileName) => { if (fileName.endsWith('.h')) { return; } const absPath = `${process.env.HOME}/${fileName}`; const fileSource = read(absPath); if (/(\n|^)-\s*\((.+)\)getConstants/.test(fileSource)) { return; } const constantsToExportRegex = /(\n|^)-\s*\((.+)\)constantsToExport/; const result = constantsToExportRegex.exec(fileSource); if (result == null) { throw new Error(`Didn't find a constantsToExport function inside NativeModule ${fileName}`); } const returnType = result[2]; const newFileSource = fileSource.replace( constantsToExportRegex, '$1- ($2)constantsToExport\n' + '{\n' + ` return ${returnType.includes('ModuleConstants') ? '($2)' : ''}[self getConstants];\n` + '}\n' + '\n' + '- ($2)getConstants' ); fs.writeFileSync(absPath, newFileSource); }); ``` ``` > xbgs -l ')constantsToExport' ``` Reviewed By: fkgozali Differential Revision: D13951197 fbshipit-source-id: 394a319d42aff466c56a3d748e17c335307a8f47
2019-02-05 04:41:36 +03:00
{
return [self getConstants];
}
- (NSDictionary<NSString *, id> *)getConstants
{
Run getConstants method statements on main queue Summary: If a NativeModule requires main queue setup, its `getConstants()` method must be executed on the main thead. The legacy NativeModule infra takes care of this for us. With TurboModules, however, all synchronous methods, including `getConstants()`, execute on the JS thread. Therefore, if a TurboModule requires main queue setup, and exports constants, we must execute its `getConstants()` method body on the main queue explicitly. **Notes:** - The changes in this diff should be a noop when TurboModules is off, because `RCTUnsafeExecuteOnMainQueueSync` synchronously execute its block on the current thread if the current thread is the main thread. - If a NativeModule doens't have the `requiresMainQueueSetup` method, but has the `constantsToExport` method, both NativeModules and TurboModules assume that it requires main queue setup. ## Script ``` 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 constantsToExport") .split("\n") .filter(Boolean); const filesWithoutConstantsToExport = []; const filesWithConstantsToExportButNotGetConstants = []; const filesExplicitlyNotRequiringMainQueueSetup = []; tmFiles .filter((filename) => { if (filename.includes("microsoft-fork-of-react-native")) { return false; } return /\.mm?$/.test(filename); }) .map(abspath) .forEach((filename) => { const code = readFile(filename); const relFilename = relpath(filename); if (!/constantsToExport\s*{/.test(code)) { filesWithoutConstantsToExport.push(relFilename); return; } if (!/getConstants\s*{/.test(code)) { filesWithConstantsToExportButNotGetConstants.push(relFilename); return; } if (/requiresMainQueueSetup\s*{/.test(code)) { const requiresMainQueueSetupRegex = /requiresMainQueueSetup\s*{\s*return\s+(?<requiresMainQueueSetup>YES|NO)/; const requiresMainQueueSetupRegexMatch = requiresMainQueueSetupRegex.exec( code ); if (!requiresMainQueueSetupRegexMatch) { throw new Error( "Detected requiresMainQueueSetup method in file " + relFilename + " but was unable to parse the method return value" ); } const { requiresMainQueueSetup, } = requiresMainQueueSetupRegexMatch.groups; if (requiresMainQueueSetup == "NO") { filesExplicitlyNotRequiringMainQueueSetup.push(relFilename); return; } } const getConstantsTypeRegex = () => /-\s*\((?<type>.*)\)getConstants\s*{/; const getConstantsTypeRegexMatch = getConstantsTypeRegex().exec(code); if (!getConstantsTypeRegexMatch) { throw new Error( `Failed to parse return type of getConstants method in file ${relFilename}` ); } const getConstantsType = getConstantsTypeRegexMatch.groups.type; const getConstantsBody = code .split(getConstantsTypeRegex())[2] .split("\n}")[0]; const newGetConstantsBody = ` __block ${getConstantsType} constants; RCTUnsafeExecuteOnMainQueueSync(^{${getConstantsBody .replace(/\n/g, "\n ") .replace(/_bridge/g, "self->_bridge") .replace(/return /g, "constants = ")} }); return constants; `; writeFile( filename, code .replace(getConstantsBody, newGetConstantsBody) .replace("#import", "#import <React/RCTUtils.h>\n#import") ); }); console.log("Files without constantsToExport: "); filesWithoutConstantsToExport.forEach((file) => console.log(file)); console.log(); console.log("Files with constantsToExport but no getConstants: "); filesWithConstantsToExportButNotGetConstants.forEach((file) => console.log(file) ); console.log(); console.log("Files with requiresMainQueueSetup = NO: "); filesExplicitlyNotRequiringMainQueueSetup.forEach((file) => console.log(file) ); } if (!module.parent) { main(); } ``` Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D21797048 fbshipit-source-id: a822a858fecdbe976e6197f8339e509dc7cd917f
2020-06-03 08:58:04 +03:00
__block NSDictionary<NSString *, id> *constants;
RCTUnsafeExecuteOnMainQueueSync(^{
constants = @{
@"Dimensions" : RCTExportedDimensions(self->_bridge, self->_turboModuleRegistry),
Run getConstants method statements on main queue Summary: If a NativeModule requires main queue setup, its `getConstants()` method must be executed on the main thead. The legacy NativeModule infra takes care of this for us. With TurboModules, however, all synchronous methods, including `getConstants()`, execute on the JS thread. Therefore, if a TurboModule requires main queue setup, and exports constants, we must execute its `getConstants()` method body on the main queue explicitly. **Notes:** - The changes in this diff should be a noop when TurboModules is off, because `RCTUnsafeExecuteOnMainQueueSync` synchronously execute its block on the current thread if the current thread is the main thread. - If a NativeModule doens't have the `requiresMainQueueSetup` method, but has the `constantsToExport` method, both NativeModules and TurboModules assume that it requires main queue setup. ## Script ``` 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 constantsToExport") .split("\n") .filter(Boolean); const filesWithoutConstantsToExport = []; const filesWithConstantsToExportButNotGetConstants = []; const filesExplicitlyNotRequiringMainQueueSetup = []; tmFiles .filter((filename) => { if (filename.includes("microsoft-fork-of-react-native")) { return false; } return /\.mm?$/.test(filename); }) .map(abspath) .forEach((filename) => { const code = readFile(filename); const relFilename = relpath(filename); if (!/constantsToExport\s*{/.test(code)) { filesWithoutConstantsToExport.push(relFilename); return; } if (!/getConstants\s*{/.test(code)) { filesWithConstantsToExportButNotGetConstants.push(relFilename); return; } if (/requiresMainQueueSetup\s*{/.test(code)) { const requiresMainQueueSetupRegex = /requiresMainQueueSetup\s*{\s*return\s+(?<requiresMainQueueSetup>YES|NO)/; const requiresMainQueueSetupRegexMatch = requiresMainQueueSetupRegex.exec( code ); if (!requiresMainQueueSetupRegexMatch) { throw new Error( "Detected requiresMainQueueSetup method in file " + relFilename + " but was unable to parse the method return value" ); } const { requiresMainQueueSetup, } = requiresMainQueueSetupRegexMatch.groups; if (requiresMainQueueSetup == "NO") { filesExplicitlyNotRequiringMainQueueSetup.push(relFilename); return; } } const getConstantsTypeRegex = () => /-\s*\((?<type>.*)\)getConstants\s*{/; const getConstantsTypeRegexMatch = getConstantsTypeRegex().exec(code); if (!getConstantsTypeRegexMatch) { throw new Error( `Failed to parse return type of getConstants method in file ${relFilename}` ); } const getConstantsType = getConstantsTypeRegexMatch.groups.type; const getConstantsBody = code .split(getConstantsTypeRegex())[2] .split("\n}")[0]; const newGetConstantsBody = ` __block ${getConstantsType} constants; RCTUnsafeExecuteOnMainQueueSync(^{${getConstantsBody .replace(/\n/g, "\n ") .replace(/_bridge/g, "self->_bridge") .replace(/return /g, "constants = ")} }); return constants; `; writeFile( filename, code .replace(getConstantsBody, newGetConstantsBody) .replace("#import", "#import <React/RCTUtils.h>\n#import") ); }); console.log("Files without constantsToExport: "); filesWithoutConstantsToExport.forEach((file) => console.log(file)); console.log(); console.log("Files with constantsToExport but no getConstants: "); filesWithConstantsToExportButNotGetConstants.forEach((file) => console.log(file) ); console.log(); console.log("Files with requiresMainQueueSetup = NO: "); filesExplicitlyNotRequiringMainQueueSetup.forEach((file) => console.log(file) ); } if (!module.parent) { main(); } ``` Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D21797048 fbshipit-source-id: a822a858fecdbe976e6197f8339e509dc7cd917f
2020-06-03 08:58:04 +03:00
// Note:
// This prop is deprecated and will be removed in a future release.
// Please use this only for a quick and temporary solution.
// Use <SafeAreaView> instead.
@"isIPhoneX_deprecated" : @(RCTIsIPhoneX()),
};
});
return constants;
}
- (void)didReceiveNewContentSizeMultiplier
{
RCTBridge *bridge = _bridge;
RCTModuleRegistry *moduleRegistry = _moduleRegistry;
RCTExecuteOnMainQueue(^{
// Report the event across the bridge.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[moduleRegistry moduleForName:"EventDispatcher"]
sendDeviceEventWithName:@"didUpdateDimensions"
body:RCTExportedDimensions(bridge, self->_turboModuleRegistry)];
#pragma clang diagnostic pop
});
}
- (void)interfaceOrientationDidChange
{
__weak __typeof(self) weakSelf = self;
RCTExecuteOnMainQueue(^{
[weakSelf _interfaceOrientationDidChange];
});
}
- (void)_interfaceOrientationDidChange
{
UIInterfaceOrientation nextOrientation = [RCTSharedApplication() statusBarOrientation];
// Update when we go from portrait to landscape, or landscape to portrait
if ((UIInterfaceOrientationIsPortrait(_currentInterfaceOrientation) &&
!UIInterfaceOrientationIsPortrait(nextOrientation)) ||
(UIInterfaceOrientationIsLandscape(_currentInterfaceOrientation) &&
!UIInterfaceOrientationIsLandscape(nextOrientation))) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[_moduleRegistry moduleForName:"EventDispatcher"]
sendDeviceEventWithName:@"didUpdateDimensions"
body:RCTExportedDimensions(_bridge, _turboModuleRegistry)];
#pragma clang diagnostic pop
}
_currentInterfaceOrientation = nextOrientation;
}
- (void)interfaceFrameDidChange
{
__weak __typeof(self) weakSelf = self;
RCTExecuteOnMainQueue(^{
[weakSelf _interfaceFrameDidChange];
});
}
- (void)_interfaceFrameDidChange
{
NSDictionary *nextInterfaceDimensions = RCTExportedDimensions(_bridge, _turboModuleRegistry);
if (!([nextInterfaceDimensions isEqual:_currentInterfaceDimensions])) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"didUpdateDimensions"
body:nextInterfaceDimensions];
#pragma clang diagnostic pop
}
_currentInterfaceDimensions = nextInterfaceDimensions;
}
Part 2: Update ObjC++ codegen classes to use ObjCTurboModule::InitParams Summary: ## Summary Please check out D21035209. ## Changes - Codemod all ObjC NativeModule `getTurboModuleWithJsInvoker:nativeInvoker:perfLogger` methods to `getTurboModule:(const ObjCTurboModule::Args)` ## Script ``` var withSpaces = (...args) => args.join('\s*') var regexString = withSpaces( '-', '\(', 'std::shared_ptr', '<', '(?<turboModuleClass>(facebook::react::|react::|::|)TurboModule)', '>', '\)', 'getTurboModuleWithJsInvoker', ':', '\(', 'std::shared_ptr', '<', '(?<fbNamespace>(facebook::react::|react::|::|))CallInvoker', '>', '\)', '(?<jsInvokerInstance>[A-Za-z0-9]+)', 'nativeInvoker', ':', '\(', 'std::shared_ptr', '<', '(facebook::react::|react::|::|)CallInvoker', '>', '\)', '(?<nativeInvokerInstance>[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<nativeInvokerInstance>', ',', '\k<perfLoggerInstance>', '\)', ';', '}', ) var replaceString = `- (std::shared_ptr<$<turboModuleClass>>) getTurboModule:(const $<fbNamespace>ObjCTurboModule::InitParams &)params { return std::make_shared<$<specName>>(params); }` 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(); } ``` ## Re-generating diff ``` > hg revert -r .^ --all > node index.js # run script ``` Changelog: [iOS][Changed] - Make all ObjC NativeModules create TurboModules using ObjCTurboModule::Args Reviewed By: PeteTheHeat Differential Revision: D21036265 fbshipit-source-id: 404bcc548d1775ef23d793527606d02fe384a0a2
2020-04-17 03:23:39 +03:00
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
{
Part 2: Update ObjC++ codegen classes to use ObjCTurboModule::InitParams Summary: ## Summary Please check out D21035209. ## Changes - Codemod all ObjC NativeModule `getTurboModuleWithJsInvoker:nativeInvoker:perfLogger` methods to `getTurboModule:(const ObjCTurboModule::Args)` ## Script ``` var withSpaces = (...args) => args.join('\s*') var regexString = withSpaces( '-', '\(', 'std::shared_ptr', '<', '(?<turboModuleClass>(facebook::react::|react::|::|)TurboModule)', '>', '\)', 'getTurboModuleWithJsInvoker', ':', '\(', 'std::shared_ptr', '<', '(?<fbNamespace>(facebook::react::|react::|::|))CallInvoker', '>', '\)', '(?<jsInvokerInstance>[A-Za-z0-9]+)', 'nativeInvoker', ':', '\(', 'std::shared_ptr', '<', '(facebook::react::|react::|::|)CallInvoker', '>', '\)', '(?<nativeInvokerInstance>[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<nativeInvokerInstance>', ',', '\k<perfLoggerInstance>', '\)', ';', '}', ) var replaceString = `- (std::shared_ptr<$<turboModuleClass>>) getTurboModule:(const $<fbNamespace>ObjCTurboModule::InitParams &)params { return std::make_shared<$<specName>>(params); }` 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(); } ``` ## Re-generating diff ``` > hg revert -r .^ --all > node index.js # run script ``` Changelog: [iOS][Changed] - Make all ObjC NativeModules create TurboModules using ObjCTurboModule::Args Reviewed By: PeteTheHeat Differential Revision: D21036265 fbshipit-source-id: 404bcc548d1775ef23d793527606d02fe384a0a2
2020-04-17 03:23:39 +03:00
return std::make_shared<NativeDeviceInfoSpecJSI>(params);
}
@end
Class RCTDeviceInfoCls(void)
{
return RCTDeviceInfo.class;
}