Skip to content

Commit

Permalink
Move codegen root directory from Libraries to src
Browse files Browse the repository at this point in the history
Differential Revision: D52919566

fbshipit-source-id: 474c812a4669f661b3f2d8056d50c4e1ffad6190
  • Loading branch information
rubennorte authored and facebook-github-bot committed Jan 21, 2024
1 parent 0f6dbc1 commit 6e1f917
Show file tree
Hide file tree
Showing 149 changed files with 3,598 additions and 3,827 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
+getConstants: () => {||};
+showActionSheetWithOptions: (
options: {|
+title?: ?string,
+message?: ?string,
+options: ?Array<string>,
+destructiveButtonIndices?: ?Array<number>,
+cancelButtonIndex?: ?number,
+anchor?: ?number,
+tintColor?: ?number,
+cancelButtonTintColor?: ?number,
+userInterfaceStyle?: ?string,
+disabledButtonIndices?: Array<number>,
|},
callback: (buttonIndex: number) => void,
) => void;
+showShareActionSheetWithOptions: (
options: {|
+message?: ?string,
+url?: ?string,
+subject?: ?string,
+anchor?: ?number,
+tintColor?: ?number,
+cancelButtonTintColor?: ?number,
+excludedActivityTypes?: ?Array<string>,
+userInterfaceStyle?: ?string,
|},
failureCallback: (error: {|
+domain: string,
+code: string,
+userInfo?: ?Object,
+message: string,
|}) => void,
successCallback: (completed: boolean, activityType: ?string) => void,
) => void;
+dismissActionSheet?: () => void;
}

export default (TurboModuleRegistry.get<Spec>('ActionSheetManager'): ?Spec);
export * from '../../src/private/specs/modules/NativeActionSheetManager';
import NativeActionSheetManager from '../../src/private/specs/modules/NativeActionSheetManager';
export default NativeActionSheetManager;
30 changes: 4 additions & 26 deletions packages/react-native/Libraries/Alert/NativeAlertManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export type Args = {|
title?: string,
message?: string,
buttons?: Array<Object>, // TODO(T67565166): have a better type
type?: string,
defaultValue?: string,
cancelButtonKey?: string,
destructiveButtonKey?: string,
preferredButtonKey?: string,
keyboardType?: string,
userInterfaceStyle?: string,
|};

export interface Spec extends TurboModule {
+alertWithArgs: (
args: Args,
callback: (id: number, value: string) => void,
) => void;
}

export default (TurboModuleRegistry.get<Spec>('AlertManager'): ?Spec);
export * from '../../src/private/specs/modules/NativeAlertManager';
import NativeAlertManager from '../../src/private/specs/modules/NativeAlertManager';
export default NativeAlertManager;
72 changes: 4 additions & 68 deletions packages/react-native/Libraries/Animated/NativeAnimatedModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
import shouldUseTurboAnimatedModule from './shouldUseTurboAnimatedModule';

type EndResult = {finished: boolean, value?: number, ...};
type EndCallback = (result: EndResult) => void;
type SaveValueCallback = (value: number) => void;

export type EventMapping = {|
nativeEventPath: Array<string>,
animatedValueTag: ?number,
|};

// The config has different keys depending on the type of the Node
// TODO(T54896888): Make these types strict
export type AnimatedNodeConfig = Object;
export type AnimatingNodeConfig = Object;

export interface Spec extends TurboModule {
+startOperationBatch: () => void;
+finishOperationBatch: () => void;
+createAnimatedNode: (tag: number, config: AnimatedNodeConfig) => void;
+updateAnimatedNodeConfig?: (tag: number, config: AnimatedNodeConfig) => void;
+getValue: (tag: number, saveValueCallback: SaveValueCallback) => void;
+startListeningToAnimatedNodeValue: (tag: number) => void;
+stopListeningToAnimatedNodeValue: (tag: number) => void;
+connectAnimatedNodes: (parentTag: number, childTag: number) => void;
+disconnectAnimatedNodes: (parentTag: number, childTag: number) => void;
+startAnimatingNode: (
animationId: number,
nodeTag: number,
config: AnimatingNodeConfig,
endCallback: EndCallback,
) => void;
+stopAnimation: (animationId: number) => void;
+setAnimatedNodeValue: (nodeTag: number, value: number) => void;
+setAnimatedNodeOffset: (nodeTag: number, offset: number) => void;
+flattenAnimatedNodeOffset: (nodeTag: number) => void;
+extractAnimatedNodeOffset: (nodeTag: number) => void;
+connectAnimatedNodeToView: (nodeTag: number, viewTag: number) => void;
+disconnectAnimatedNodeFromView: (nodeTag: number, viewTag: number) => void;
+restoreDefaultValues: (nodeTag: number) => void;
+dropAnimatedNode: (tag: number) => void;
+addAnimatedEventToView: (
viewTag: number,
eventName: string,
eventMapping: EventMapping,
) => void;
+removeAnimatedEventFromView: (
viewTag: number,
eventName: string,
animatedNodeTag: number,
) => void;

// Events
+addListener: (eventName: string) => void;
+removeListeners: (count: number) => void;

// All of the above in a batched mode
+queueAndExecuteBatchedOperations?: (operationsAndArgs: Array<any>) => void;
}

const NativeModule: ?Spec = !shouldUseTurboAnimatedModule()
? TurboModuleRegistry.get<Spec>('NativeAnimatedModule')
: null;
export default NativeModule;
export * from '../../src/private/specs/modules/NativeAnimatedModule';
import NativeAnimatedModule from '../../src/private/specs/modules/NativeAnimatedModule';
export default NativeAnimatedModule;
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
import shouldUseTurboAnimatedModule from './shouldUseTurboAnimatedModule';

type EndResult = {finished: boolean, value?: number, ...};
type EndCallback = (result: EndResult) => void;
type SaveValueCallback = (value: number) => void;

export type EventMapping = {|
nativeEventPath: Array<string>,
animatedValueTag: ?number,
|};

// The config has different keys depending on the type of the Node
// TODO(T54896888): Make these types strict
export type AnimatedNodeConfig = Object;
export type AnimatingNodeConfig = Object;

export interface Spec extends TurboModule {
+startOperationBatch: () => void;
+finishOperationBatch: () => void;
+createAnimatedNode: (tag: number, config: AnimatedNodeConfig) => void;
+updateAnimatedNodeConfig?: (tag: number, config: AnimatedNodeConfig) => void;
+getValue: (tag: number, saveValueCallback: SaveValueCallback) => void;
+startListeningToAnimatedNodeValue: (tag: number) => void;
+stopListeningToAnimatedNodeValue: (tag: number) => void;
+connectAnimatedNodes: (parentTag: number, childTag: number) => void;
+disconnectAnimatedNodes: (parentTag: number, childTag: number) => void;
+startAnimatingNode: (
animationId: number,
nodeTag: number,
config: AnimatingNodeConfig,
endCallback: EndCallback,
) => void;
+stopAnimation: (animationId: number) => void;
+setAnimatedNodeValue: (nodeTag: number, value: number) => void;
+setAnimatedNodeOffset: (nodeTag: number, offset: number) => void;
+flattenAnimatedNodeOffset: (nodeTag: number) => void;
+extractAnimatedNodeOffset: (nodeTag: number) => void;
+connectAnimatedNodeToView: (nodeTag: number, viewTag: number) => void;
+disconnectAnimatedNodeFromView: (nodeTag: number, viewTag: number) => void;
+restoreDefaultValues: (nodeTag: number) => void;
+dropAnimatedNode: (tag: number) => void;
+addAnimatedEventToView: (
viewTag: number,
eventName: string,
eventMapping: EventMapping,
) => void;
+removeAnimatedEventFromView: (
viewTag: number,
eventName: string,
animatedNodeTag: number,
) => void;

// Events
+addListener: (eventName: string) => void;
+removeListeners: (count: number) => void;

// All of the above in a batched mode
+queueAndExecuteBatchedOperations?: (operationsAndArgs: Array<any>) => void;
}

const NativeModule: ?Spec = shouldUseTurboAnimatedModule()
? TurboModuleRegistry.get<Spec>('NativeAnimatedTurboModule')
: null;

export default NativeModule;
export * from '../../src/private/specs/modules/NativeAnimatedTurboModule';
import NativeAnimatedTurboModule from '../../src/private/specs/modules/NativeAnimatedTurboModule';
export default NativeAnimatedTurboModule;
28 changes: 4 additions & 24 deletions packages/react-native/Libraries/AppState/NativeAppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export type AppStateConstants = {|
initialAppState: string,
|};

export type AppState = {|app_state: string|};

export interface Spec extends TurboModule {
+getConstants: () => AppStateConstants;
+getCurrentAppState: (
success: (appState: AppState) => void,
error: (error: Object) => void,
) => void;

// Events
+addListener: (eventName: string) => void;
+removeListeners: (count: number) => void;
}

export default (TurboModuleRegistry.getEnforcing<Spec>('AppState'): Spec);
export * from '../../src/private/specs/modules/NativeAppState';
import NativeAppState from '../../src/private/specs/modules/NativeAppState';
export default NativeAppState;
54 changes: 4 additions & 50 deletions packages/react-native/Libraries/Blob/NativeBlobModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
+getConstants: () => {|BLOB_URI_SCHEME: ?string, BLOB_URI_HOST: ?string|};
+addNetworkingHandler: () => void;
+addWebSocketHandler: (id: number) => void;
+removeWebSocketHandler: (id: number) => void;
+sendOverSocket: (blob: Object, socketID: number) => void;
+createFromParts: (parts: Array<Object>, withId: string) => void;
+release: (blobId: string) => void;
}

const NativeModule = TurboModuleRegistry.get<Spec>('BlobModule');

let constants = null;
let NativeBlobModule = null;

if (NativeModule != null) {
NativeBlobModule = {
getConstants(): {|BLOB_URI_SCHEME: ?string, BLOB_URI_HOST: ?string|} {
if (constants == null) {
constants = NativeModule.getConstants();
}
return constants;
},
addNetworkingHandler(): void {
NativeModule.addNetworkingHandler();
},
addWebSocketHandler(id: number): void {
NativeModule.addWebSocketHandler(id);
},
removeWebSocketHandler(id: number): void {
NativeModule.removeWebSocketHandler(id);
},
sendOverSocket(blob: Object, socketID: number): void {
NativeModule.sendOverSocket(blob, socketID);
},
createFromParts(parts: Array<Object>, withId: string): void {
NativeModule.createFromParts(parts, withId);
},
release(blobId: string): void {
NativeModule.release(blobId);
},
};
}

export default (NativeBlobModule: ?Spec);
export * from '../../src/private/specs/modules/NativeBlobModule';
import NativeBlobModule from '../../src/private/specs/modules/NativeBlobModule';
export default NativeBlobModule;
17 changes: 4 additions & 13 deletions packages/react-native/Libraries/Blob/NativeFileReaderModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
+readAsDataURL: (data: Object) => Promise<string>;
+readAsText: (data: Object, encoding: string) => Promise<string>;
}

export default (TurboModuleRegistry.getEnforcing<Spec>(
'FileReaderModule',
): Spec);
export * from '../../src/private/specs/modules/NativeFileReaderModule';
import NativeFileReaderModule from '../../src/private/specs/modules/NativeFileReaderModule';
export default NativeFileReaderModule;
15 changes: 4 additions & 11 deletions packages/react-native/Libraries/BugReporting/NativeBugReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@
* 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
* @flow
*/

import type {TurboModule} from '../TurboModule/RCTExport';

import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
+startReportAProblemFlow: () => void;
+setExtraData: (extraData: Object, extraFiles: Object) => void;
}

export default (TurboModuleRegistry.get<Spec>('BugReporting'): ?Spec);
export * from '../../src/private/specs/modules/NativeBugReporting';
import NativeBugReporting from '../../src/private/specs/modules/NativeBugReporting';
export default NativeBugReporting;
Loading

0 comments on commit 6e1f917

Please sign in to comment.