yeet
This commit is contained in:
36
node_modules/react-native/Libraries/TurboModule/RCTExport.js
generated
vendored
Normal file
36
node_modules/react-native/Libraries/TurboModule/RCTExport.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* NOTE: This is React Native specific export type.
|
||||
*
|
||||
* DEPRECATED_RCTExport is an interface type that allows native code generation
|
||||
* for React Native native modules. It exists as a hint to the codegen tool that
|
||||
* any interface that extends it needs to be codegen'ed. Example usage:
|
||||
*
|
||||
* export interface RCTFoobar extends DEPRECATED_RCTExport<void> {}
|
||||
*
|
||||
* Native definition for RCTFoobar will then be generated.
|
||||
*
|
||||
* The type param T is a placeholder for future codegen hinting, like versioning
|
||||
* information, native base classes, etc. For now, simply use `void` type as
|
||||
* there's nothing to give hint about.
|
||||
*
|
||||
* NOTE: This export is deprecated. Please use TurboModule.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
export interface DEPRECATED_RCTExport<T: void = void> {
|
||||
+getConstants?: () => {...};
|
||||
}
|
||||
|
||||
export interface TurboModule extends DEPRECATED_RCTExport<void> {}
|
45
node_modules/react-native/Libraries/TurboModule/TurboModuleRegistry.js
generated
vendored
Normal file
45
node_modules/react-native/Libraries/TurboModule/TurboModuleRegistry.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeModules = require('../BatchedBridge/NativeModules');
|
||||
import type {TurboModule} from './RCTExport';
|
||||
import invariant from 'invariant';
|
||||
|
||||
const turboModuleProxy = global.__turboModuleProxy;
|
||||
|
||||
export function get<T: TurboModule>(name: string): ?T {
|
||||
// Bridgeless mode requires TurboModules
|
||||
if (!global.RN$Bridgeless) {
|
||||
// Backward compatibility layer during migration.
|
||||
const legacyModule = NativeModules[name];
|
||||
if (legacyModule != null) {
|
||||
return ((legacyModule: any): T);
|
||||
}
|
||||
}
|
||||
|
||||
if (turboModuleProxy != null) {
|
||||
const module: ?T = turboModuleProxy(name);
|
||||
return module;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getEnforcing<T: TurboModule>(name: string): T {
|
||||
const module = get(name);
|
||||
invariant(
|
||||
module != null,
|
||||
`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. ` +
|
||||
'Verify that a module by this name is registered in the native binary.',
|
||||
);
|
||||
return module;
|
||||
}
|
36
node_modules/react-native/Libraries/TurboModule/samples/NativeSampleTurboModule.js
generated
vendored
Normal file
36
node_modules/react-native/Libraries/TurboModule/samples/NativeSampleTurboModule.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import type {TurboModule} from '../RCTExport';
|
||||
import * as TurboModuleRegistry from '../TurboModuleRegistry';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
// Exported methods.
|
||||
+getConstants: () => {|
|
||||
const1: boolean,
|
||||
const2: number,
|
||||
const3: string,
|
||||
|};
|
||||
+voidFunc: () => void;
|
||||
+getBool: (arg: boolean) => boolean;
|
||||
+getNumber: (arg: number) => number;
|
||||
+getString: (arg: string) => string;
|
||||
+getArray: (arg: Array<any>) => Array<any>;
|
||||
+getObject: (arg: Object) => Object;
|
||||
+getValue: (x: number, y: string, z: Object) => Object;
|
||||
+getValueWithCallback: (callback: (value: string) => void) => void;
|
||||
+getValueWithPromise: (error: boolean) => Promise<string>;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.getEnforcing<Spec>(
|
||||
'SampleTurboModule',
|
||||
): Spec);
|
Reference in New Issue
Block a user