first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export interface TurboModule {
getConstants?(): {};
}

View File

@@ -0,0 +1,38 @@
/**
* Copyright (c) Meta Platforms, Inc. and 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> {}
export type {RootTag} from '../Types/RootTagTypes.js';

View File

@@ -0,0 +1,13 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {TurboModule} from './RCTExport';
export function get<T extends TurboModule>(name: string): T | null;
export function getEnforcing<T extends TurboModule>(name: string): T;

View File

@@ -0,0 +1,47 @@
/**
* Copyright (c) Meta Platforms, Inc. and 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
*/
import type {TurboModule} from './RCTExport';
import invariant from 'invariant';
const NativeModules = require('../BatchedBridge/NativeModules').default;
const turboModuleProxy = global.__turboModuleProxy;
function requireModule<T: TurboModule>(name: string): ?T {
if (turboModuleProxy != null) {
const module: ?T = turboModuleProxy(name);
if (module != null) {
return module;
}
}
const legacyModule: ?T = NativeModules[name];
if (legacyModule != null) {
return legacyModule;
}
return null;
}
export function get<T: TurboModule>(name: string): ?T {
return requireModule<T>(name);
}
export function getEnforcing<T: TurboModule>(name: string): T {
const module = requireModule<T>(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;
}

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and 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-local
* @format
*/
export * from '../../../src/private/specs_DEPRECATED/modules/NativeSampleTurboModule';
import NativeSampleTurboModule from '../../../src/private/specs_DEPRECATED/modules/NativeSampleTurboModule';
export default NativeSampleTurboModule;