diff --git a/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap b/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap index 273e8469a7f545..c622d24a2357f3 100644 --- a/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/__tests__/modules/__snapshots__/GenerateModuleObjCpp-test.js.snap @@ -44,6 +44,7 @@ exports[`GenerateModuleObjCpp can generate a header file NativeModule specs 1`] @end @interface NativeArrayTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -64,6 +65,7 @@ namespace facebook::react { @end @interface NativeBooleanTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -84,6 +86,7 @@ namespace facebook::react { @end @interface NativeCallbackTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -144,6 +147,7 @@ namespace JS { @end @interface NativeEnumTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -169,6 +173,7 @@ namespace facebook::react { @end @interface NativeNullableTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -189,6 +194,7 @@ namespace facebook::react { @end @interface NativeNumberTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -362,6 +368,7 @@ namespace JS { @end @interface NativeObjectTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -498,6 +505,7 @@ namespace JS { @end @interface NativeOptionalObjectTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -568,6 +576,7 @@ namespace JS { @end @interface NativePartialAnnotationTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -592,6 +601,7 @@ namespace facebook::react { @end @interface NativePromiseTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -686,6 +696,7 @@ getValuegetValuegetValuegetValuegetValuey:(NSString *)getValuegetValuegetValuege @end @interface NativeSampleTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -778,6 +789,7 @@ namespace JS { @end @interface NativeSampleTurboModuleArraysSpec : RCTTurboModule + @end namespace facebook::react { @@ -872,6 +884,7 @@ namespace JS { @end @interface NativeSampleTurboModuleNullableSpec : RCTTurboModule + @end namespace facebook::react { @@ -966,6 +979,7 @@ namespace JS { @end @interface NativeSampleTurboModuleNullableAndOptionalSpec : RCTTurboModule + @end namespace facebook::react { @@ -1060,6 +1074,7 @@ namespace JS { @end @interface NativeSampleTurboModuleOptionalSpec : RCTTurboModule + @end namespace facebook::react { @@ -1080,6 +1095,7 @@ namespace facebook::react { @end @interface NativeStringTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1460,6 +1476,7 @@ NS_ASSUME_NONNULL_BEGIN @end @interface NativeArrayTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1480,6 +1497,7 @@ namespace facebook::react { @end @interface NativeBooleanTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1500,6 +1518,7 @@ namespace facebook::react { @end @interface NativeCallbackTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1560,6 +1579,7 @@ namespace JS { @end @interface NativeEnumTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1585,6 +1605,7 @@ namespace facebook::react { @end @interface NativeNullableTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1605,6 +1626,7 @@ namespace facebook::react { @end @interface NativeNumberTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1778,6 +1800,7 @@ namespace JS { @end @interface NativeObjectTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1914,6 +1937,7 @@ namespace JS { @end @interface NativeOptionalObjectTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1984,6 +2008,7 @@ namespace JS { @end @interface NativePartialAnnotationTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -2008,6 +2033,7 @@ namespace facebook::react { @end @interface NativePromiseTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -2102,6 +2128,7 @@ getValuegetValuegetValuegetValuegetValuey:(NSString *)getValuegetValuegetValuege @end @interface NativeSampleTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -2194,6 +2221,7 @@ namespace JS { @end @interface NativeSampleTurboModuleArraysSpec : RCTTurboModule + @end namespace facebook::react { @@ -2288,6 +2316,7 @@ namespace JS { @end @interface NativeSampleTurboModuleNullableSpec : RCTTurboModule + @end namespace facebook::react { @@ -2382,6 +2411,7 @@ namespace JS { @end @interface NativeSampleTurboModuleNullableAndOptionalSpec : RCTTurboModule + @end namespace facebook::react { @@ -2476,6 +2506,7 @@ namespace JS { @end @interface NativeSampleTurboModuleOptionalSpec : RCTTurboModule + @end namespace facebook::react { @@ -2496,6 +2527,7 @@ namespace facebook::react { @end @interface NativeStringTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -2849,6 +2881,7 @@ exports[`GenerateModuleObjCpp can generate an implementation file NativeModule s @implementation NativeArrayTurboModuleSpec + @end @@ -2881,6 +2914,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeBooleanTurboModuleSpec + @end @@ -2906,6 +2940,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeCallbackTurboModuleSpec + @end @@ -2931,6 +2966,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeEnumTurboModuleSpec + @end @implementation RCTCxxConvert (NativeEnumTurboModule_StateType) @@ -2995,6 +3031,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeNullableTurboModuleSpec + @end @@ -3048,6 +3085,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeNumberTurboModuleSpec + @end @@ -3073,6 +3111,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeObjectTurboModuleSpec + @end @implementation RCTCxxConvert (NativeObjectTurboModule_SpecDifficultObjectAE) @@ -3130,6 +3169,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeOptionalObjectTurboModuleSpec + @end @@ -3148,6 +3188,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativePartialAnnotationTurboModuleSpec + @end @implementation RCTCxxConvert (NativePartialAnnotationTurboModule_SpecGetSomeObjFromPartialSomeObjValue) @@ -3205,6 +3246,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativePromiseTurboModuleSpec + @end @@ -3230,6 +3272,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeSampleTurboModuleSpec + @end @implementation RCTCxxConvert (NativeSampleTurboModule_SpecGetObjectShapeArg) @@ -3343,6 +3386,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeSampleTurboModuleArraysSpec + @end @@ -3445,6 +3489,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeSampleTurboModuleNullableSpec + @end @implementation RCTCxxConvert (NativeSampleTurboModuleNullable_SpecGetObjectShapeArg) @@ -3558,6 +3603,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeSampleTurboModuleNullableAndOptionalSpec + @end @implementation RCTCxxConvert (NativeSampleTurboModuleNullableAndOptional_SpecGetObjectShapeArg) @@ -3671,6 +3717,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeSampleTurboModuleOptionalSpec + @end @implementation RCTCxxConvert (NativeSampleTurboModuleOptional_SpecGetObjectShapeArg) @@ -3784,6 +3831,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeStringTurboModuleSpec + @end diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js index ee3237d5d8c0cf..39064dbb1c9dcd 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js @@ -12,6 +12,7 @@ import type { NamedShape, + NativeModuleEventEmitterShape, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, NativeModulePropertyShape, @@ -23,6 +24,7 @@ import type {AliasResolver} from './Utils'; const {unwrapNullable} = require('../../parsers/parsers-commons'); const {wrapOptional} = require('../TypeUtils/Java'); +const {toPascalCase} = require('../Utils'); const {createAliasResolver, getModules} = require('./Utils'); type FilesOutput = Map; @@ -32,11 +34,13 @@ function FileTemplate( packageName: string, className: string, jsName: string, + eventEmitters: string, methods: string, imports: string, }>, ): string { - const {packageName, className, jsName, methods, imports} = config; + const {packageName, className, jsName, eventEmitters, methods, imports} = + config; return ` /** * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). @@ -65,11 +69,28 @@ public abstract class ${className} extends ReactContextBaseJavaModule implements return NAME; } -${methods} +${eventEmitters}${eventEmitters.length > 0 ? '\n\n' : ''}${methods} } `; } +function EventEmitterTemplate( + eventEmitter: NativeModuleEventEmitterShape, + imports: Set, +): string { + return ` protected final void emit${toPascalCase(eventEmitter.name)}(${ + eventEmitter.typeAnnotation.typeAnnotation.type !== 'VoidTypeAnnotation' + ? `${translateEventEmitterTypeToJavaType(eventEmitter, imports)} value` + : '' + }) { + mEventEmitterCallback.invoke("${eventEmitter.name}"${ + eventEmitter.typeAnnotation.typeAnnotation.type !== 'VoidTypeAnnotation' + ? ', value' + : '' + }); + }`; +} + function MethodTemplate( config: $ReadOnly<{ abstract: boolean, @@ -102,6 +123,33 @@ function MethodTemplate( type Param = NamedShape>; +function translateEventEmitterTypeToJavaType( + eventEmitter: NativeModuleEventEmitterShape, + imports: Set, +): string { + switch (eventEmitter.typeAnnotation.typeAnnotation.type) { + case 'StringTypeAnnotation': + return 'String'; + case 'NumberTypeAnnotation': + case 'FloatTypeAnnotation': + case 'DoubleTypeAnnotation': + case 'Int32TypeAnnotation': + return 'double'; + case 'BooleanTypeAnnotation': + return 'boolean'; + case 'ObjectTypeAnnotation': + imports.add('com.facebook.react.bridge.ReadableMap'); + return 'ReadableMap'; + case 'ArrayTypeAnnotation': + imports.add('com.facebook.react.bridge.ReadableArray'); + return 'ReadableArray'; + default: + throw new Error( + `Unsupported eventType for ${eventEmitter.name}. Found: ${eventEmitter.typeAnnotation.typeAnnotation.type}`, + ); + } +} + function translateFunctionParamToJavaType( param: Param, createErrorMessage: (typeName: string) => string, @@ -533,6 +581,9 @@ module.exports = { packageName: normalizedPackageName, className, jsName: moduleName, + eventEmitters: spec.eventEmitters + .map(eventEmitter => EventEmitterTemplate(eventEmitter, imports)) + .join('\n\n'), methods: methods.filter(Boolean).join('\n\n'), imports: Array.from(imports) .sort() diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index 2930ab1be9a0be..92e642118d1b01 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -12,6 +12,7 @@ import type { NamedShape, + NativeModuleEventEmitterShape, NativeModuleFunctionTypeAnnotation, NativeModuleParamTypeAnnotation, NativeModulePropertyShape, @@ -54,9 +55,11 @@ const HostFunctionTemplate = ({ const ModuleClassConstructorTemplate = ({ hasteModuleName, + eventEmitters, methods, }: $ReadOnly<{ hasteModuleName: string, + eventEmitters: $ReadOnlyArray, methods: $ReadOnlyArray<{ propertyName: string, argCount: number, @@ -69,7 +72,21 @@ ${methods .map(({propertyName, argCount}) => { return ` methodMap_["${propertyName}"] = MethodMetadata {${argCount}, __hostFunction_${hasteModuleName}SpecJSI_${propertyName}};`; }) - .join('\n')} + .join('\n')}${ + eventEmitters.length > 0 + ? eventEmitters + .map(eventEmitter => { + return ` + eventEmitterMap_["${eventEmitter.name}"] = std::make_shared>();`; + }) + .join('') + : '' + }${ + eventEmitters.length > 0 + ? ` + setEventEmitterCallback(params.instance);` + : '' + } }`.trim(); }; @@ -438,7 +455,7 @@ module.exports = { .map(hasteModuleName => { const { aliasMap, - spec: {methods}, + spec: {eventEmitters, methods}, } = nativeModules[hasteModuleName]; const resolveAlias = createAliasResolver(aliasMap); @@ -457,6 +474,7 @@ module.exports = { '\n\n' + ModuleClassConstructorTemplate({ hasteModuleName, + eventEmitters, methods: methods .map(({name: propertyName, typeAnnotation}) => { const [{returnTypeAnnotation, params}] = diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js index 56cf4c3bb04de2..7904640479e224 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/index.js @@ -15,6 +15,7 @@ import type {MethodSerializationOutput} from './serializeMethod'; const {createAliasResolver, getModules} = require('../Utils'); const {serializeStruct} = require('./header/serializeStruct'); +const {EventEmitterHeaderTemplate} = require('./serializeEventEmitter'); const {serializeMethod} = require('./serializeMethod'); const {serializeModuleSource} = require('./source/serializeModule'); const {StructCollector} = require('./StructCollector'); @@ -24,10 +25,12 @@ type FilesOutput = Map; const ModuleDeclarationTemplate = ({ hasteModuleName, structDeclarations, + eventEmitters, protocolMethods, }: $ReadOnly<{ hasteModuleName: string, structDeclarations: string, + eventEmitters: string, protocolMethods: string, }>) => `${structDeclarations} @protocol ${hasteModuleName}Spec @@ -37,6 +40,7 @@ ${protocolMethods} @end @interface ${hasteModuleName}Spec : RCTTurboModule +${eventEmitters} @end namespace facebook::react { @@ -191,6 +195,9 @@ module.exports = { ModuleDeclarationTemplate({ hasteModuleName: hasteModuleName, structDeclarations: structStrs.join('\n'), + eventEmitters: spec.eventEmitters + .map(eventEmitter => EventEmitterHeaderTemplate(eventEmitter)) + .join('\n'), protocolMethods: methodSerializations .map(({protocolMethod}) => protocolMethod) .join('\n'), @@ -204,6 +211,7 @@ module.exports = { hasteModuleName, generatedStructs, hasteModuleName, + spec.eventEmitters, methodSerializations.filter( ({selector}) => selector !== '@selector(constantsToExport)', ), diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeEventEmitter.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeEventEmitter.js new file mode 100644 index 00000000000000..31baaead607287 --- /dev/null +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeEventEmitter.js @@ -0,0 +1,72 @@ +/** + * 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 {NativeModuleEventEmitterShape} from '../../../CodegenSchema'; + +const {toPascalCase} = require('../../Utils'); + +function getEventEmitterTypeObjCType( + eventEmitter: NativeModuleEventEmitterShape, +): string { + switch (eventEmitter.typeAnnotation.typeAnnotation.type) { + case 'StringTypeAnnotation': + return 'NSString *'; + case 'NumberTypeAnnotation': + return 'double'; + case 'FloatTypeAnnotation': + return 'float'; + case 'DoubleTypeAnnotation': + return 'double'; + case 'Int32TypeAnnotation': + return 'NSInteger'; + case 'BooleanTypeAnnotation': + return 'BOOL'; + case 'ObjectTypeAnnotation': + return 'NSDictionary *'; + case 'ArrayTypeAnnotation': + return 'NSArray> *'; + default: + throw new Error( + `Unsupported eventType for ${eventEmitter.name}. Found: ${eventEmitter.typeAnnotation.typeAnnotation.type}`, + ); + } +} + +function EventEmitterHeaderTemplate( + eventEmitter: NativeModuleEventEmitterShape, +): string { + return `- (void)emit${toPascalCase(eventEmitter.name)}${ + eventEmitter.typeAnnotation.typeAnnotation.type !== 'VoidTypeAnnotation' + ? `:(${getEventEmitterTypeObjCType(eventEmitter)})value` + : '' + };`; +} + +function EventEmitterImplementationTemplate( + eventEmitter: NativeModuleEventEmitterShape, +): string { + return `- (void)emit${toPascalCase(eventEmitter.name)}${ + eventEmitter.typeAnnotation.typeAnnotation.type !== 'VoidTypeAnnotation' + ? `:(${getEventEmitterTypeObjCType(eventEmitter)})value` + : '' + } +{ + _eventEmitterCallback("${eventEmitter.name}", ${ + eventEmitter.typeAnnotation.typeAnnotation.type !== 'VoidTypeAnnotation' + ? 'value' + : 'nil' + }); +}`; +} + +module.exports = { + EventEmitterHeaderTemplate, + EventEmitterImplementationTemplate, +}; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js index 6789157ac8bc6b..97e165b2cd0473 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/source/serializeModule.js @@ -10,24 +10,34 @@ 'use strict'; +import type {NativeModuleEventEmitterShape} from '../../../../CodegenSchema'; import type { MethodSerializationOutput, StructParameterRecord, } from '../serializeMethod'; import type {Struct} from '../StructCollector'; +const { + EventEmitterImplementationTemplate, +} = require('./../serializeEventEmitter'); + const ModuleTemplate = ({ hasteModuleName, structs, moduleName, + eventEmitters, methodSerializationOutputs, }: $ReadOnly<{ hasteModuleName: string, structs: $ReadOnlyArray, moduleName: string, + eventEmitters: $ReadOnlyArray, methodSerializationOutputs: $ReadOnlyArray, }>) => ` @implementation ${hasteModuleName}Spec +${eventEmitters + .map(eventEmitter => EventEmitterImplementationTemplate(eventEmitter)) + .join('\n')} @end ${structs @@ -58,7 +68,23 @@ namespace facebook::react { argCount, }), ) - .join('\n' + ' '.repeat(8))} + .join('\n' + ' '.repeat(8))}${ + eventEmitters.length > 0 + ? eventEmitters + .map(eventEmitter => { + return ` + eventEmitterMap_["${eventEmitter.name}"] = std::make_shared>();`; + }) + .join('') + : '' +}${ + eventEmitters.length > 0 + ? ` + setEventEmitterCallback([&](const std::string &name, id value) { + static_cast &>(*eventEmitterMap_[name]).emit(value); + });` + : '' +} } } // namespace facebook::react`; @@ -112,12 +138,14 @@ function serializeModuleSource( hasteModuleName: string, structs: $ReadOnlyArray, moduleName: string, + eventEmitters: $ReadOnlyArray, methodSerializationOutputs: $ReadOnlyArray, ): string { return ModuleTemplate({ hasteModuleName, structs: structs.filter(({context}) => context !== 'CONSTANTS'), moduleName, + eventEmitters, methodSerializationOutputs, }); } diff --git a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js index aea2ffbcfbaccd..5249e5edc94011 100644 --- a/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/modules/__test_fixtures__/fixtures.js @@ -27,6 +27,95 @@ const EMPTY_NATIVE_MODULES: SchemaType = { }, }; +const EVENT_EMITTER_MODULES: SchemaType = { + modules: { + NativeSampleTurboModule: { + type: 'NativeModule', + aliasMap: {}, + enumMap: {}, + spec: { + eventEmitters: [ + { + name: 'onEvent1', + optional: false, + typeAnnotation: { + type: 'EventEmitterTypeAnnotation', + typeAnnotation: { + type: 'VoidTypeAnnotation', + }, + }, + }, + { + name: 'onEvent2', + optional: false, + typeAnnotation: { + type: 'EventEmitterTypeAnnotation', + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }, + }, + { + name: 'onEvent3', + optional: false, + typeAnnotation: { + type: 'EventEmitterTypeAnnotation', + typeAnnotation: { + type: 'NumberTypeAnnotation', + }, + }, + }, + { + name: 'onEvent4', + optional: false, + typeAnnotation: { + type: 'EventEmitterTypeAnnotation', + typeAnnotation: { + type: 'BooleanTypeAnnotation', + }, + }, + }, + { + name: 'onEvent5', + optional: false, + typeAnnotation: { + type: 'EventEmitterTypeAnnotation', + typeAnnotation: { + type: 'ObjectTypeAnnotation', + }, + }, + }, + { + name: 'onEvent6', + optional: false, + typeAnnotation: { + type: 'EventEmitterTypeAnnotation', + typeAnnotation: { + type: 'ArrayTypeAnnotation', + elementType: 'ObjectStruct', + }, + }, + }, + ], + methods: [ + { + name: 'voidFunc', + optional: false, + typeAnnotation: { + type: 'FunctionTypeAnnotation', + returnTypeAnnotation: { + type: 'VoidTypeAnnotation', + }, + params: [], + }, + }, + ], + }, + moduleName: 'SampleTurboModule', + }, + }, +}; + const SIMPLE_NATIVE_MODULES: SchemaType = { modules: { NativeSampleTurboModule: { @@ -2435,6 +2524,7 @@ module.exports = { complex_objects: COMPLEX_OBJECTS, two_modules_different_files: TWO_MODULES_DIFFERENT_FILES, empty_native_modules: EMPTY_NATIVE_MODULES, + event_emitter_module: EVENT_EMITTER_MODULES, simple_native_modules: SIMPLE_NATIVE_MODULES, native_modules_with_type_aliases: NATIVE_MODULES_WITH_TYPE_ALIASES, real_module_example: REAL_MODULE_EXAMPLE, diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap index dcfbcaa3e16023..8e0045608a7ed4 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleCpp-test.js.snap @@ -352,6 +352,39 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared } +} // namespace facebook::react +", +} +`; + +exports[`GenerateModuleCpp can generate fixture event_emitter_module 1`] = ` +Map { + "event_emitter_moduleJSI-generated.cpp" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleCpp.js + */ + +#include \\"event_emitter_moduleJSI.h\\" + +namespace facebook::react { + +static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFunc(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->voidFunc( + rt + ); + return jsi::Value::undefined(); +} + +NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule(\\"SampleTurboModule\\", jsInvoker) { + methodMap_[\\"voidFunc\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_voidFunc}; +} + + } // namespace facebook::react ", } diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap index ad2183e4e3d30a..2460b782dd0182 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleH-test.js.snap @@ -1019,6 +1019,122 @@ private: } `; +exports[`GenerateModuleH can generate fixture event_emitter_module 1`] = ` +Map { + "event_emitter_moduleJSI.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleH.js + */ + +#pragma once + +#include +#include + +namespace facebook::react { + + + class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule { +protected: + NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual void voidFunc(jsi::Runtime &rt) = 0; + +}; + +template +class JSI_EXPORT NativeSampleTurboModuleCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + + static constexpr std::string_view kModuleName = \\"SampleTurboModule\\"; + +protected: + NativeSampleTurboModuleCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativeSampleTurboModuleCxxSpec::kModuleName}, jsInvoker), + delegate_(reinterpret_cast(this), jsInvoker) {} + + void emitOnEvent1() { + static_cast&>(*delegate_.eventEmitterMap_[\\"onEvent1\\"]).emit(); + } + + template void emitOnEvent2(OnEvent2Type value) { + static_assert(bridging::supportsFromJs, \\"value cannnot be converted to jsi::String\\"); + static_cast&>(*delegate_.eventEmitterMap_[\\"onEvent2\\"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value { + return bridging::toJs(rt, eventValue, jsInvoker); + }); + } + + template void emitOnEvent3(OnEvent3Type value) { + static_assert(bridging::supportsFromJs, \\"value cannnot be converted to double\\"); + static_cast&>(*delegate_.eventEmitterMap_[\\"onEvent3\\"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value { + return bridging::toJs(rt, eventValue, jsInvoker); + }); + } + + template void emitOnEvent4(OnEvent4Type value) { + static_assert(bridging::supportsFromJs, \\"value cannnot be converted to bool\\"); + static_cast&>(*delegate_.eventEmitterMap_[\\"onEvent4\\"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value { + return bridging::toJs(rt, eventValue, jsInvoker); + }); + } + + template void emitOnEvent5(OnEvent5Type value) { + static_assert(bridging::supportsFromJs, \\"value cannnot be converted to jsi::Object\\"); + static_cast&>(*delegate_.eventEmitterMap_[\\"onEvent5\\"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value { + return bridging::toJs(rt, eventValue, jsInvoker); + }); + } + + template void emitOnEvent6(std::vector value) { + static_assert(bridging::supportsFromJs, jsi::Array>, \\"value cannnot be converted to jsi::Array\\"); + static_cast&>(*delegate_.eventEmitterMap_[\\"onEvent6\\"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value { + return bridging::toJs(rt, eventValue, jsInvoker); + }); + } + +private: + class Delegate : public NativeSampleTurboModuleCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeSampleTurboModuleCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { + eventEmitterMap_[\\"onEvent1\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent2\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent3\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent4\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent5\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent6\\"] = std::make_shared>(); + } + + void voidFunc(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::voidFunc) == 1, + \\"Expected voidFunc(...) to have 1 parameters\\"); + + return bridging::callFromJs( + rt, &T::voidFunc, jsInvoker_, instance_); + } + + private: + friend class NativeSampleTurboModuleCxxSpec; + T *instance_; + }; + + Delegate delegate_; +}; + +} // namespace facebook::react +", +} +`; + exports[`GenerateModuleH can generate fixture native_modules_with_type_aliases 1`] = ` Map { "native_modules_with_type_aliasesJSI.h" => "/** diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap index 7f6f08fbf126e1..04d788cd56a1a8 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap @@ -42,6 +42,7 @@ Map { @end @interface NativeSampleTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -212,6 +213,7 @@ namespace JS { @end @interface NativeSampleTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -411,6 +413,7 @@ Map { @end @interface NativeSampleTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -428,6 +431,71 @@ namespace facebook::react { } `; +exports[`GenerateModuleHObjCpp can generate fixture event_emitter_module 1`] = ` +Map { + "event_emitter_module.h" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleObjCpp + * + * We create an umbrella header (and corresponding implementation) here since + * Cxx compilation in BUCK has a limitation: source-code producing genrule()s + * must have a single output. More files => more genrule()s => slower builds. + */ + +#ifndef __cplusplus +#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm. +#endif + +// Avoid multiple includes of event_emitter_module symbols +#ifndef event_emitter_module_H +#define event_emitter_module_H + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + + +@protocol NativeSampleTurboModuleSpec + +- (void)voidFunc; + +@end + +@interface NativeSampleTurboModuleSpec : RCTTurboModule +- (void)emitOnEvent1; +- (void)emitOnEvent2:(NSString *)value; +- (void)emitOnEvent3:(double)value; +- (void)emitOnEvent4:(BOOL)value; +- (void)emitOnEvent5:(NSDictionary *)value; +- (void)emitOnEvent6:(NSArray> *)value; +@end + +namespace facebook::react { + /** + * ObjC++ class for module 'NativeSampleTurboModule' + */ + class JSI_EXPORT NativeSampleTurboModuleSpecJSI : public ObjCTurboModule { + public: + NativeSampleTurboModuleSpecJSI(const ObjCTurboModule::InitParams ¶ms); + }; +} // namespace facebook::react + +#endif // event_emitter_module_H +", +} +`; + exports[`GenerateModuleHObjCpp can generate fixture native_modules_with_type_aliases 1`] = ` Map { "native_modules_with_type_aliases.h" => "/** @@ -536,6 +604,7 @@ namespace JS { @end @interface AliasTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -678,6 +747,7 @@ namespace JS { @end @interface NativeCameraRollManagerSpec : RCTTurboModule + @end namespace facebook::react { @@ -747,6 +817,7 @@ namespace JS { @end @interface NativeExceptionsManagerSpec : RCTTurboModule + @end namespace facebook::react { @@ -955,6 +1026,7 @@ namespace JS { @end @interface NativeSampleTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1026,6 +1098,7 @@ Map { @end @interface NativeSampleTurboModuleSpec : RCTTurboModule + @end namespace facebook::react { @@ -1045,6 +1118,7 @@ namespace facebook::react { @end @interface NativeSampleTurboModule2Spec : RCTTurboModule + @end namespace facebook::react { diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap index 875476d45acaae..4da79695dade85 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJavaSpec-test.js.snap @@ -157,6 +157,75 @@ public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaMo } `; +exports[`GenerateModuleJavaSpec can generate fixture event_emitter_module 1`] = ` +Map { + "java/com/facebook/fbreact/specs/NativeSampleTurboModuleSpec.java" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJavaSpec.js + * + * @nolint + */ + +package com.facebook.fbreact.specs; + +import com.facebook.proguard.annotations.DoNotStrip; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContextBaseJavaModule; +import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.turbomodule.core.interfaces.TurboModule; +import javax.annotation.Nonnull; + +public abstract class NativeSampleTurboModuleSpec extends ReactContextBaseJavaModule implements TurboModule { + public static final String NAME = \\"SampleTurboModule\\"; + + public NativeSampleTurboModuleSpec(ReactApplicationContext reactContext) { + super(reactContext); + } + + @Override + public @Nonnull String getName() { + return NAME; + } + + protected final void emitOnEvent1() { + mEventEmitterCallback.invoke(\\"onEvent1\\"); + } + + protected final void emitOnEvent2(String value) { + mEventEmitterCallback.invoke(\\"onEvent2\\", value); + } + + protected final void emitOnEvent3(double value) { + mEventEmitterCallback.invoke(\\"onEvent3\\", value); + } + + protected final void emitOnEvent4(boolean value) { + mEventEmitterCallback.invoke(\\"onEvent4\\", value); + } + + protected final void emitOnEvent5(ReadableMap value) { + mEventEmitterCallback.invoke(\\"onEvent5\\", value); + } + + protected final void emitOnEvent6(ReadableArray value) { + mEventEmitterCallback.invoke(\\"onEvent6\\", value); + } + + @ReactMethod + @DoNotStrip + public abstract void voidFunc(); +} +", +} +`; + exports[`GenerateModuleJavaSpec can generate fixture native_modules_with_type_aliases 1`] = ` Map { "java/com/facebook/fbreact/specs/AliasTurboModuleSpec.java" => " diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap index 27f98851161d91..c929bfd55c57b7 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniCpp-test.js.snap @@ -172,6 +172,51 @@ std::shared_ptr empty_native_modules_ModuleProvider(const std::stri } `; +exports[`GenerateModuleJniCpp can generate fixture event_emitter_module 1`] = ` +Map { + "jni/event_emitter_module-generated.cpp" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniCpp.js + */ + +#include \\"event_emitter_module.h\\" + +namespace facebook::react { + +static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + static jmethodID cachedMethodId = nullptr; + return static_cast(turboModule).invokeJavaMethod(rt, VoidKind, \\"voidFunc\\", \\"()V\\", args, count, cachedMethodId); +} + +NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms) + : JavaTurboModule(params) { + methodMap_[\\"voidFunc\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc}; + eventEmitterMap_[\\"onEvent1\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent2\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent3\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent4\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent5\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent6\\"] = std::make_shared>(); + setEventEmitterCallback(params.instance); +} + +std::shared_ptr event_emitter_module_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { + if (moduleName == \\"SampleTurboModule\\") { + return std::make_shared(params); + } + return nullptr; +} + +} // namespace facebook::react +", +} +`; + exports[`GenerateModuleJniCpp can generate fixture native_modules_with_type_aliases 1`] = ` Map { "jni/native_modules_with_type_aliases-generated.cpp" => " diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap index 72877187166bd8..ec844a0ccb92e3 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap @@ -341,6 +341,93 @@ target_compile_options( } `; +exports[`GenerateModuleJniH can generate fixture event_emitter_module 1`] = ` +Map { + "jni/event_emitter_module.h" => " +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniH.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +/** + * JNI C++ class for module 'NativeSampleTurboModule' + */ +class JSI_EXPORT NativeSampleTurboModuleSpecJSI : public JavaTurboModule { +public: + NativeSampleTurboModuleSpecJSI(const JavaTurboModule::InitParams ¶ms); +}; + + +JSI_EXPORT +std::shared_ptr event_emitter_module_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); + +} // namespace facebook::react +", + "jni/CMakeLists.txt" => "# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/event_emitter_module/*.cpp) + +add_library( + react_codegen_event_emitter_module + SHARED + \${react_codegen_SRCS} +) + +target_include_directories(react_codegen_event_emitter_module PUBLIC . react/renderer/components/event_emitter_module) + +target_link_libraries( + react_codegen_event_emitter_module + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_componentregistry + react_render_core + react_render_debug + react_render_graphics + react_render_imagemanager + react_render_mapbuffer + react_utils + rrc_image + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_event_emitter_module + PRIVATE + -DLOG_TAG=\\\\\\"ReactNative\\\\\\" + -fexceptions + -frtti + -std=c++20 + -Wall +) +", +} +`; + exports[`GenerateModuleJniH can generate fixture native_modules_with_type_aliases 1`] = ` Map { "jni/native_modules_with_type_aliases.h" => " diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap index 9a981f848713fc..c86f561dfe4121 100644 --- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap +++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleMm-test.js.snap @@ -19,6 +19,7 @@ Map { @implementation NativeSampleTurboModuleSpec + @end @@ -53,6 +54,7 @@ Map { @implementation NativeSampleTurboModuleSpec + @end @implementation RCTCxxConvert (NativeSampleTurboModule_SpecDifficultAE) @@ -191,6 +193,7 @@ Map { @implementation NativeSampleTurboModuleSpec + @end @@ -206,6 +209,78 @@ namespace facebook::react { } `; +exports[`GenerateModuleMm can generate fixture event_emitter_module 1`] = ` +Map { + "event_emitter_module-generated.mm" => "/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleObjCpp + * + * We create an umbrella header (and corresponding implementation) here since + * Cxx compilation in BUCK has a limitation: source-code producing genrule()s + * must have a single output. More files => more genrule()s => slower builds. + */ + +#import \\"event_emitter_module.h\\" + + +@implementation NativeSampleTurboModuleSpec +- (void)emitOnEvent1 +{ + _eventEmitterCallback(\\"onEvent1\\", nil); +} +- (void)emitOnEvent2:(NSString *)value +{ + _eventEmitterCallback(\\"onEvent2\\", value); +} +- (void)emitOnEvent3:(double)value +{ + _eventEmitterCallback(\\"onEvent3\\", value); +} +- (void)emitOnEvent4:(BOOL)value +{ + _eventEmitterCallback(\\"onEvent4\\", value); +} +- (void)emitOnEvent5:(NSDictionary *)value +{ + _eventEmitterCallback(\\"onEvent5\\", value); +} +- (void)emitOnEvent6:(NSArray> *)value +{ + _eventEmitterCallback(\\"onEvent6\\", value); +} +@end + + +namespace facebook::react { + + static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, \\"voidFunc\\", @selector(voidFunc), args, count); + } + + NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const ObjCTurboModule::InitParams ¶ms) + : ObjCTurboModule(params) { + + methodMap_[\\"voidFunc\\"] = MethodMetadata {0, __hostFunction_NativeSampleTurboModuleSpecJSI_voidFunc}; + + eventEmitterMap_[\\"onEvent1\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent2\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent3\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent4\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent5\\"] = std::make_shared>(); + eventEmitterMap_[\\"onEvent6\\"] = std::make_shared>(); + setEventEmitterCallback([&](const std::string &name, id value) { + static_cast &>(*eventEmitterMap_[name]).emit(value); + }); + } +} // namespace facebook::react +", +} +`; + exports[`GenerateModuleMm can generate fixture native_modules_with_type_aliases 1`] = ` Map { "native_modules_with_type_aliases-generated.mm" => "/** @@ -225,6 +300,7 @@ Map { @implementation AliasTurboModuleSpec + @end @implementation RCTCxxConvert (AliasTurboModule_OptionsOffset) @@ -287,6 +363,7 @@ Map { @implementation NativeCameraRollManagerSpec + @end @implementation RCTCxxConvert (NativeCameraRollManager_GetPhotosParams) @@ -324,6 +401,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeExceptionsManagerSpec + @end @implementation RCTCxxConvert (NativeExceptionsManager_StackFrame) @@ -402,6 +480,7 @@ Map { @implementation NativeSampleTurboModuleSpec + @end @@ -532,6 +611,7 @@ Map { @implementation NativeSampleTurboModuleSpec + @end @@ -550,6 +630,7 @@ namespace facebook::react { } // namespace facebook::react @implementation NativeSampleTurboModule2Spec + @end