Back out "Back out "[TM][JS] Forward NativeModule schema to __turboModuleProxy""
Summary:
**Note:** This is a carbon copy of D22832730 (3df6f5fb2c
). The fixes are stacked on top of this diff, in D22888030.
Changelog: [Internal]
Reviewed By: fkgozali
Differential Revision: D22888032
fbshipit-source-id: 2f1b7ecd39437a3c5ee9c3214419716fde2bbdff
This commit is contained in:
Родитель
df66b7a4d2
Коммит
b5097c8dcd
|
@ -16,7 +16,7 @@ import invariant from 'invariant';
|
|||
|
||||
const turboModuleProxy = global.__turboModuleProxy;
|
||||
|
||||
export function get<T: TurboModule>(name: string): ?T {
|
||||
function requireModule<T: TurboModule>(name: string, schema?: ?$FlowFixMe): ?T {
|
||||
// Bridgeless mode requires TurboModules
|
||||
if (!global.RN$Bridgeless) {
|
||||
// Backward compatibility layer during migration.
|
||||
|
@ -27,15 +27,39 @@ export function get<T: TurboModule>(name: string): ?T {
|
|||
}
|
||||
|
||||
if (turboModuleProxy != null) {
|
||||
const module: ?T = turboModuleProxy(name);
|
||||
const module: ?T = turboModuleProxy(name, schema);
|
||||
return module;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function get<T: TurboModule>(name: string): ?T {
|
||||
/**
|
||||
* What is Schema?
|
||||
*
|
||||
* @react-native/babel-plugin-codegen will parse the NativeModule
|
||||
* spec, and pass in the generated schema as the second argument
|
||||
* to this function. The schem will then be used to perform method
|
||||
* dispatch on, and translate arguments/return to and from the Native
|
||||
* TurboModule object.
|
||||
*/
|
||||
const schema = arguments.length === 2 ? arguments[1] : undefined;
|
||||
return requireModule<T>(name, schema);
|
||||
}
|
||||
|
||||
export function getEnforcing<T: TurboModule>(name: string): T {
|
||||
const module = get(name);
|
||||
/**
|
||||
* What is Schema?
|
||||
*
|
||||
* @react-native/babel-plugin-codegen will parse the NativeModule
|
||||
* spec, and pass in the generated schema as the second argument
|
||||
* to this function. The schem will then be used to perform method
|
||||
* dispatch on, and translate arguments/return to and from the Native
|
||||
* TurboModule object.
|
||||
*/
|
||||
const schema = arguments.length === 2 ? arguments[1] : undefined;
|
||||
const module = requireModule<T>(name, schema);
|
||||
invariant(
|
||||
module != null,
|
||||
`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. ` +
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
* @flow strict
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
|
Загрузка…
Ссылка в новой задаче