diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js index 4d9a5aac0c..18dde67c9b 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js @@ -14,6 +14,8 @@ import type {SchemaType} from '../../CodegenSchema'; type FilesOutput = Map; +const {getModules} = require('./Utils'); + const moduleTemplate = `/** * JNI C++ class for module '::_MODULE_NAME_::' */ @@ -23,8 +25,9 @@ public: }; `; -const template = `/** - * Copyright (c) Facebook, Inc. and its affiliates. +const template = ` +/** + * ${'C'}opyright (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. @@ -84,19 +87,7 @@ module.exports = { schema: SchemaType, moduleSpecName: string, ): FilesOutput { - const nativeModules = Object.keys(schema.modules) - .sort() - .map(moduleName => { - const modules = schema.modules[moduleName].nativeModules; - if (modules == null) { - return null; - } - - return modules; - }) - .filter(Boolean) - .reduce((acc, components) => Object.assign(acc, components), {}); - + const nativeModules = getModules(schema); const modules = Object.keys(nativeModules) .map(name => moduleTemplate.replace(/::_MODULE_NAME_::/g, name)) .join('\n'); 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 efe0828382..64cbc779b3 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 @@ -2,7 +2,8 @@ exports[`GenerateModuleJniH can generate fixture COMPLEX_OBJECTS 1`] = ` Map { - "SampleSpec.h" => "/** + "SampleSpec.h" => " +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -67,7 +68,8 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture EMPTY_NATIVE_MODULES 1`] = ` Map { - "SampleSpec.h" => "/** + "SampleSpec.h" => " +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -132,7 +134,8 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = ` Map { - "SampleSpec.h" => "/** + "SampleSpec.h" => " +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -197,7 +200,8 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture REAL_MODULE_EXAMPLE 1`] = ` Map { - "SampleSpec.h" => "/** + "SampleSpec.h" => " +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -223,14 +227,6 @@ public: NativeCameraRollManagerSpecJSI(const JavaTurboModule::InitParams ¶ms); }; -/** - * JNI C++ class for module 'ExceptionsManager' - */ -class JSI_EXPORT NativeExceptionsManagerSpecJSI : public JavaTurboModule { -public: - NativeExceptionsManagerSpecJSI(const JavaTurboModule::InitParams ¶ms); -}; - /** * JNI C++ class for module 'ImagePickerIOS' */ @@ -239,6 +235,14 @@ public: NativeImagePickerIOSSpecJSI(const JavaTurboModule::InitParams ¶ms); }; +/** + * JNI C++ class for module 'ExceptionsManager' + */ +class JSI_EXPORT NativeExceptionsManagerSpecJSI : public JavaTurboModule { +public: + NativeExceptionsManagerSpecJSI(const JavaTurboModule::InitParams ¶ms); +}; + std::shared_ptr REAL_MODULE_EXAMPLE_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); @@ -278,7 +282,8 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture SIMPLE_NATIVE_MODULES 1`] = ` Map { - "SampleSpec.h" => "/** + "SampleSpec.h" => " +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -343,7 +348,8 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = ` Map { - "SampleSpec.h" => "/** + "SampleSpec.h" => " +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the @@ -416,7 +422,8 @@ include $(BUILD_SHARED_LIBRARY) exports[`GenerateModuleJniH can generate fixture TWO_MODULES_SAME_FILE 1`] = ` Map { - "SampleSpec.h" => "/** + "SampleSpec.h" => " +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the