diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 8b8673f0e5d..241017d53c0 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -50,7 +50,7 @@ export type VoidTypeAnnotation = $ReadOnly<{ type: 'VoidTypeAnnotation', }>; -type ObjectTypeAnnotation<+T> = $ReadOnly<{ +export type ObjectTypeAnnotation<+T> = $ReadOnly<{ type: 'ObjectTypeAnnotation', properties: $ReadOnlyArray>, }>; @@ -176,7 +176,7 @@ export type PropTypeAnnotation = }>, }>; -type ReservedPropTypeAnnotation = $ReadOnly<{ +export type ReservedPropTypeAnnotation = $ReadOnly<{ type: 'ReservedPropTypeAnnotation', name: | 'ColorPrimitive' diff --git a/packages/react-native-codegen/src/generators/Utils.js b/packages/react-native-codegen/src/generators/Utils.js new file mode 100644 index 00000000000..68c128360e1 --- /dev/null +++ b/packages/react-native-codegen/src/generators/Utils.js @@ -0,0 +1,19 @@ +/** + * 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'; + +function capitalize(string: string): string { + return string.charAt(0).toUpperCase() + string.slice(1); +} + +module.exports = { + capitalize, +}; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js new file mode 100644 index 00000000000..ab75b7f3ff5 --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/PojoCollector.js @@ -0,0 +1,186 @@ +/** + * 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'; + +import type { + ReservedPropTypeAnnotation, + NamedShape, + ObjectTypeAnnotation, + BooleanTypeAnnotation, + StringTypeAnnotation, + DoubleTypeAnnotation, + FloatTypeAnnotation, + Int32TypeAnnotation, + PropTypeAnnotation, +} from '../../../CodegenSchema'; + +const {capitalize} = require('../../Utils'); + +export type Pojo = { + name: string, + namespace: string, + properties: $ReadOnlyArray, +}; + +export type PojoProperty = NamedShape; + +export type PojoTypeAliasAnnotation = { + type: 'PojoTypeAliasTypeAnnotation', + name: string, +}; + +export type PojoTypeAnnotation = + | $ReadOnly<{ + type: 'BooleanTypeAnnotation', + default: boolean | null, + }> + | $ReadOnly<{ + type: 'StringTypeAnnotation', + default: string | null, + }> + | $ReadOnly<{ + type: 'DoubleTypeAnnotation', + default: number, + }> + | $ReadOnly<{ + type: 'FloatTypeAnnotation', + default: number | null, + }> + | $ReadOnly<{ + type: 'Int32TypeAnnotation', + default: number, + }> + | $ReadOnly<{ + type: 'StringEnumTypeAnnotation', + default: string, + options: $ReadOnlyArray, + }> + | $ReadOnly<{ + type: 'Int32EnumTypeAnnotation', + default: number, + options: $ReadOnlyArray, + }> + | ReservedPropTypeAnnotation + | PojoTypeAliasAnnotation + | $ReadOnly<{ + type: 'ArrayTypeAnnotation', + elementType: + | BooleanTypeAnnotation + | StringTypeAnnotation + | DoubleTypeAnnotation + | FloatTypeAnnotation + | Int32TypeAnnotation + | $ReadOnly<{ + type: 'StringEnumTypeAnnotation', + default: string, + options: $ReadOnlyArray, + }> + | PojoTypeAliasAnnotation + | ReservedPropTypeAnnotation + | $ReadOnly<{ + type: 'ArrayTypeAnnotation', + elementType: PojoTypeAliasAnnotation, + }>, + }>; + +class PojoCollector { + _pojos: Map = new Map(); + process( + namespace: string, + pojoName: string, + typeAnnotation: PropTypeAnnotation, + ): PojoTypeAnnotation { + switch (typeAnnotation.type) { + case 'ObjectTypeAnnotation': { + this._insertPojo(namespace, pojoName, typeAnnotation); + return { + type: 'PojoTypeAliasTypeAnnotation', + name: pojoName, + }; + } + case 'ArrayTypeAnnotation': { + const arrayTypeAnnotation = typeAnnotation; + // TODO: Flow assumes elementType can be any. Fix this. + const elementType: $PropertyType< + typeof arrayTypeAnnotation, + 'elementType', + > = arrayTypeAnnotation.elementType; + + const pojoElementType = (() => { + switch (elementType.type) { + case 'ObjectTypeAnnotation': { + this._insertPojo(namespace, `${pojoName}Element`, elementType); + return { + type: 'PojoTypeAliasTypeAnnotation', + name: `${pojoName}Element`, + }; + } + case 'ArrayTypeAnnotation': { + const {elementType: objectTypeAnnotation} = elementType; + this._insertPojo( + namespace, + `${pojoName}ElementElement`, + objectTypeAnnotation, + ); + return { + type: 'ArrayTypeAnnotation', + elementType: { + type: 'PojoTypeAliasTypeAnnotation', + name: `${pojoName}ElementElement`, + }, + }; + } + default: { + return elementType; + } + } + })(); + + return { + type: 'ArrayTypeAnnotation', + elementType: pojoElementType, + }; + } + default: + return typeAnnotation; + } + } + _insertPojo( + namespace: string, + pojoName: string, + objectTypeAnnotation: ObjectTypeAnnotation, + ) { + const properties = objectTypeAnnotation.properties.map(property => { + const propertyPojoName = pojoName + capitalize(property.name); + + return { + ...property, + typeAnnotation: this.process( + namespace, + propertyPojoName, + property.typeAnnotation, + ), + }; + }); + + this._pojos.set(pojoName, { + name: pojoName, + namespace, + properties, + }); + } + + getAllPojos(): $ReadOnlyArray { + return [...this._pojos.values()]; + } +} + +module.exports = PojoCollector; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/index.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/index.js new file mode 100644 index 00000000000..f5fa8c77f01 --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/index.js @@ -0,0 +1,80 @@ +/** + * 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'; + +import type {SchemaType} from '../../../CodegenSchema'; + +const PojoCollector = require('./PojoCollector'); +const {capitalize} = require('../../Utils'); +const {serializePojo} = require('./serializePojo'); + +type FilesOutput = Map; + +module.exports = { + generate( + libraryName: string, + schema: SchemaType, + packageName?: string, + ): FilesOutput { + const pojoCollector = new PojoCollector(); + const basePackageName = 'com.facebook.react.viewmanagers'; + + Object.keys(schema.modules).forEach(hasteModuleName => { + const module = schema.modules[hasteModuleName]; + if (module.type !== 'Component') { + return; + } + + const {components} = module; + // No components in this module + if (components == null) { + return null; + } + + Object.keys(components) + .filter(componentName => { + const component = components[componentName]; + return !( + component.excludedPlatforms && + component.excludedPlatforms.includes('android') + ); + }) + .forEach(componentName => { + const component = components[componentName]; + if (component == null) { + return; + } + + const {props} = component; + + pojoCollector.process( + capitalize(hasteModuleName), + `${capitalize(componentName)}Props`, + { + type: 'ObjectTypeAnnotation', + properties: props, + }, + ); + }); + }); + + const pojoDir = basePackageName.split('.').join('/'); + + return new Map( + pojoCollector.getAllPojos().map(pojo => { + return [ + `java/${pojoDir}/${pojo.namespace}/${pojo.name}.java`, + serializePojo(pojo, basePackageName), + ]; + }), + ); + }, +}; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js new file mode 100644 index 00000000000..a105cccf4c7 --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaPojo/serializePojo.js @@ -0,0 +1,285 @@ +/** + * 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'; + +import type {Pojo, PojoProperty, PojoTypeAnnotation} from './PojoCollector'; +const {capitalize} = require('../../Utils'); + +type ImportCollector = ($import: string) => void; + +function toJavaType( + typeAnnotation: PojoTypeAnnotation, + addImport: ImportCollector, +): string { + const importNullable = () => addImport('androidx.annotation.Nullable'); + const importReadableMap = () => + addImport('com.facebook.react.bridge.ReadableMap'); + const importArrayList = () => addImport('java.util.ArrayList'); + switch (typeAnnotation.type) { + /** + * Primitives + */ + case 'BooleanTypeAnnotation': { + if (typeAnnotation.default === null) { + importNullable(); + return '@Nullable Boolean'; + } else { + return 'boolean'; + } + } + case 'StringTypeAnnotation': { + importNullable(); + return '@Nullable String'; + } + case 'DoubleTypeAnnotation': { + return 'double'; + } + case 'FloatTypeAnnotation': { + if (typeAnnotation.default === null) { + importNullable(); + return '@Nullable Float'; + } else { + return 'float'; + } + } + case 'Int32TypeAnnotation': { + return 'int'; + } + + /** + * Enums + */ + // TODO: Make StringEnumTypeAnnotation type-safe? + case 'StringEnumTypeAnnotation': + importNullable(); + return '@Nullable String'; + // TODO: Make Int32EnumTypeAnnotation type-safe? + case 'Int32EnumTypeAnnotation': + importNullable(); + return '@Nullable Integer'; + + /** + * Reserved types + */ + case 'ReservedPropTypeAnnotation': { + switch (typeAnnotation.name) { + case 'ColorPrimitive': + importNullable(); + return '@Nullable Integer'; + + // TODO: Make ImageSourcePrimitive type-safe + case 'ImageSourcePrimitive': + importNullable(); + importReadableMap(); + return '@Nullable ReadableMap'; + + // TODO: Make PointPrimitive type-safe + case 'PointPrimitive': + importNullable(); + importReadableMap(); + return '@Nullable ReadableMap'; + + // TODO: Make EdgeInsetsPrimitive type-safe + case 'EdgeInsetsPrimitive': + importNullable(); + importReadableMap(); + return '@Nullable ReadableMap'; + default: + (typeAnnotation.name: empty); + throw new Error( + `Received unknown ReservedPropTypeAnnotation ${typeAnnotation.name}`, + ); + } + } + + /** + * Other Pojo objects + */ + case 'PojoTypeAliasTypeAnnotation': { + return typeAnnotation.name; + } + + /** + * Arrays + */ + case 'ArrayTypeAnnotation': { + const {elementType} = typeAnnotation; + + const elementTypeString = (() => { + switch (elementType.type) { + /** + * Primitives + */ + case 'BooleanTypeAnnotation': { + return 'Boolean'; + } + case 'StringTypeAnnotation': { + importNullable(); + return '@Nullable String'; + } + case 'DoubleTypeAnnotation': { + return 'Double'; + } + case 'FloatTypeAnnotation': { + return 'Float'; + } + case 'Int32TypeAnnotation': { + return 'Integer'; + } + + /** + * Enums + */ + // TODO: Make StringEnums type-safe in Pojos + case 'StringEnumTypeAnnotation': { + importNullable(); + return '@Nullable String'; + } + + /** + * Other Pojo objects + */ + case 'PojoTypeAliasTypeAnnotation': { + return elementType.name; + } + + /** + * Reserved types + */ + case 'ReservedPropTypeAnnotation': { + switch (elementType.name) { + case 'ColorPrimitive': + importNullable(); + return '@Nullable Integer'; + + // TODO: Make ImageSourcePrimitive type-safe + case 'ImageSourcePrimitive': + importNullable(); + importReadableMap(); + return '@Nullable ReadableMap'; + + // TODO: Make PointPrimitive type-safe + case 'PointPrimitive': + importNullable(); + importReadableMap(); + return '@Nullable ReadableMap'; + + // TODO: Make EdgeInsetsPrimitive type-safe + case 'EdgeInsetsPrimitive': + importNullable(); + importReadableMap(); + return '@Nullable ReadableMap'; + default: + (elementType.name: empty); + throw new Error( + `Received unknown ReservedPropTypeAnnotation ${elementType.name}`, + ); + } + } + + // Arrays + case 'ArrayTypeAnnotation': { + const {elementType: pojoTypeAliasTypeAnnotation} = elementType; + + importArrayList(); + return `ArrayList<${pojoTypeAliasTypeAnnotation.name}>`; + } + default: { + (elementType.type: empty); + throw new Error( + `Unrecognized PojoTypeAnnotation Array element type annotation '${typeAnnotation.type}'`, + ); + } + } + })(); + + importArrayList(); + return `ArrayList<${elementTypeString}>`; + } + + default: { + (typeAnnotation.type: empty); + throw new Error( + `Unrecognized PojoTypeAnnotation '${typeAnnotation.type}'`, + ); + } + } +} + +function toJavaMemberName(property: PojoProperty): string { + return `m${capitalize(property.name)}`; +} + +function toJavaMemberDeclaration( + property: PojoProperty, + addImport: ImportCollector, +): string { + const type = toJavaType(property.typeAnnotation, addImport); + const memberName = toJavaMemberName(property); + return `private ${type} ${memberName};`; +} + +function toJavaGetter(property: PojoProperty, addImport: ImportCollector) { + const type = toJavaType(property.typeAnnotation, addImport); + const getterName = `get${capitalize(property.name)}`; + const memberName = toJavaMemberName(property); + return `public ${type} ${getterName}() { + return ${memberName}; +}`; +} + +function serializePojo(pojo: Pojo, basePackageName: string): string { + const importSet: Set = new Set(); + const addImport = ($import: string) => { + importSet.add($import); + }; + + const indent = ' '.repeat(2); + + const members = pojo.properties + .map(property => toJavaMemberDeclaration(property, addImport)) + .map(member => `${indent}${member}`) + .join('\n'); + + const getters = pojo.properties + .map(property => toJavaGetter(property, addImport)) + .map(getter => + getter + .split('\n') + .map(line => `${indent}${line}`) + .join('\n'), + ) + .join('\n'); + + const imports = [...importSet] + .map($import => `import ${$import};`) + .sort() + .join('\n'); + + return `/** +* 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. +* +* ${'@'}generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package ${basePackageName}.${pojo.namespace}; +${imports === '' ? '' : `\n${imports}\n`} +public class ${pojo.name} { +${members} +${getters} +} +`; +} + +module.exports = {serializePojo}; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaPojo-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaPojo-test.js new file mode 100644 index 00000000000..80b2df4dd04 --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsJavaPojo-test.js @@ -0,0 +1,27 @@ +/** + * 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. + * + * @emails oncall+react_native + * @flow strict-local + * @format + */ + +'use strict'; + +const fixtures = require('../__test_fixtures__/fixtures.js'); +const generator = require('../GeneratePropsJavaPojo'); + +describe('GeneratePropsJavaPojo', () => { + Object.keys(fixtures) + .sort() + .forEach(fixtureName => { + const fixture = fixtures[fixtureName]; + + it(`can generate fixture ${fixtureName}`, () => { + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); + }); + }); +}); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap new file mode 100644 index 00000000000..d2647e05abd --- /dev/null +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaPojo-test.js.snap @@ -0,0 +1,1015 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`GeneratePropsJavaPojo can generate fixture ARRAY_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsObjectElement.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import androidx.annotation.Nullable; + +public class ArrayPropsNativeComponentPropsObjectElement { + private @Nullable String mStringProp; + public @Nullable String getStringProp() { + return mStringProp; + } +} +", + "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsArrayElementObjectElement.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import androidx.annotation.Nullable; + +public class ArrayPropsNativeComponentPropsArrayElementObjectElement { + private @Nullable String mStringProp; + public @Nullable String getStringProp() { + return mStringProp; + } +} +", + "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsArrayElement.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import java.util.ArrayList; + +public class ArrayPropsNativeComponentPropsArrayElement { + private ArrayList mObject; + public ArrayList getObject() { + return mObject; + } +} +", + "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsArrayOfArrayOfObjectElementElement.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import androidx.annotation.Nullable; + +public class ArrayPropsNativeComponentPropsArrayOfArrayOfObjectElementElement { + private @Nullable String mStringProp; + public @Nullable String getStringProp() { + return mStringProp; + } +} +", + "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableMap; +import java.util.ArrayList; + +public class ArrayPropsNativeComponentProps { + private ArrayList<@Nullable String> mNames; + private ArrayList mDisableds; + private ArrayList mProgress; + private ArrayList mRadii; + private ArrayList<@Nullable Integer> mColors; + private ArrayList<@Nullable ReadableMap> mSrcs; + private ArrayList<@Nullable ReadableMap> mPoints; + private ArrayList<@Nullable String> mSizes; + private ArrayList mObject; + private ArrayList mArray; + private ArrayList> mArrayOfArrayOfObject; + public ArrayList<@Nullable String> getNames() { + return mNames; + } + public ArrayList getDisableds() { + return mDisableds; + } + public ArrayList getProgress() { + return mProgress; + } + public ArrayList getRadii() { + return mRadii; + } + public ArrayList<@Nullable Integer> getColors() { + return mColors; + } + public ArrayList<@Nullable ReadableMap> getSrcs() { + return mSrcs; + } + public ArrayList<@Nullable ReadableMap> getPoints() { + return mPoints; + } + public ArrayList<@Nullable String> getSizes() { + return mSizes; + } + public ArrayList getObject() { + return mObject; + } + public ArrayList getArray() { + return mArray; + } + public ArrayList> getArrayOfArrayOfObject() { + return mArrayOfArrayOfObject; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture ARRAY_PROPS_WITH_NESTED_OBJECT 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentPropsNativePrimitivesElement.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableMap; +import java.util.ArrayList; + +public class ArrayPropsNativeComponentPropsNativePrimitivesElement { + private ArrayList<@Nullable Integer> mColors; + private ArrayList<@Nullable ReadableMap> mSrcs; + private ArrayList<@Nullable ReadableMap> mPoints; + public ArrayList<@Nullable Integer> getColors() { + return mColors; + } + public ArrayList<@Nullable ReadableMap> getSrcs() { + return mSrcs; + } + public ArrayList<@Nullable ReadableMap> getPoints() { + return mPoints; + } +} +", + "java/com/facebook/react/viewmanagers/Slider/ArrayPropsNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import java.util.ArrayList; + +public class ArrayPropsNativeComponentProps { + private ArrayList mNativePrimitives; + public ArrayList getNativePrimitives() { + return mNativePrimitives; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture BOOLEAN_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/BooleanPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class BooleanPropNativeComponentProps { + private boolean mDisabled; + public boolean getDisabled() { + return mDisabled; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COLOR_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/ColorPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +import androidx.annotation.Nullable; + +public class ColorPropNativeComponentProps { + private @Nullable Integer mTintColor; + public @Nullable Integer getTintColor() { + return mTintColor; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMMANDS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/CommandNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class CommandNativeComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture COMMANDS_AND_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/CommandNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +import androidx.annotation.Nullable; + +public class CommandNativeComponentProps { + private @Nullable String mAccessibilityHint; + public @Nullable String getAccessibilityHint() { + return mAccessibilityHint; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture DOUBLE_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/DoublePropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class DoublePropNativeComponentProps { + private double mBlurRadius; + private double mBlurRadius2; + private double mBlurRadius3; + private double mBlurRadius4; + private double mBlurRadius5; + private double mBlurRadius6; + public double getBlurRadius() { + return mBlurRadius; + } + public double getBlurRadius2() { + return mBlurRadius2; + } + public double getBlurRadius3() { + return mBlurRadius3; + } + public double getBlurRadius4() { + return mBlurRadius4; + } + public double getBlurRadius5() { + return mBlurRadius5; + } + public double getBlurRadius6() { + return mBlurRadius6; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/EventsNestedObjectNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class EventsNestedObjectNativeComponentProps { + private boolean mDisabled; + public boolean getDisabled() { + return mDisabled; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture EVENT_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/EventsNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class EventsNativeComponentProps { + private boolean mDisabled; + public boolean getDisabled() { + return mDisabled; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture EVENTS_WITH_PAPER_NAME 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/InterfaceOnlyComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class InterfaceOnlyComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_ANDROID 1`] = `Map {}`; + +exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`; + +exports[`GeneratePropsJavaPojo can generate fixture FLOAT_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/FloatPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class FloatPropNativeComponentProps { + private float mBlurRadius; + private float mBlurRadius2; + private float mBlurRadius3; + private float mBlurRadius4; + private float mBlurRadius5; + private float mBlurRadius6; + public float getBlurRadius() { + return mBlurRadius; + } + public float getBlurRadius2() { + return mBlurRadius2; + } + public float getBlurRadius3() { + return mBlurRadius3; + } + public float getBlurRadius4() { + return mBlurRadius4; + } + public float getBlurRadius5() { + return mBlurRadius5; + } + public float getBlurRadius6() { + return mBlurRadius6; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture IMAGE_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Slider/ImagePropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableMap; + +public class ImagePropNativeComponentProps { + private @Nullable ReadableMap mThumbImage; + public @Nullable ReadableMap getThumbImage() { + return mThumbImage; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture INSETS_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/ScrollView/InsetsPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ScrollView; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableMap; + +public class InsetsPropNativeComponentProps { + private @Nullable ReadableMap mContentInset; + public @Nullable ReadableMap getContentInset() { + return mContentInset; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/Int32EnumPropsNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +import androidx.annotation.Nullable; + +public class Int32EnumPropsNativeComponentProps { + private @Nullable Integer mMaxInterval; + public @Nullable Integer getMaxInterval() { + return mMaxInterval; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture INTEGER_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/IntegerPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +public class IntegerPropNativeComponentProps { + private int mProgress1; + private int mProgress2; + private int mProgress3; + public int getProgress1() { + return mProgress1; + } + public int getProgress2() { + return mProgress2; + } + public int getProgress3() { + return mProgress3; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture INTERFACE_ONLY 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/InterfaceOnlyComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +import androidx.annotation.Nullable; + +public class InterfaceOnlyComponentProps { + private @Nullable String mAccessibilityHint; + public @Nullable String getAccessibilityHint() { + return mAccessibilityHint; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture MULTI_NATIVE_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Slider/ImageColorPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Slider; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableMap; + +public class ImageColorPropNativeComponentProps { + private @Nullable ReadableMap mThumbImage; + private @Nullable Integer mColor; + private @Nullable Integer mThumbTintColor; + private @Nullable ReadableMap mPoint; + public @Nullable ReadableMap getThumbImage() { + return mThumbImage; + } + public @Nullable Integer getColor() { + return mColor; + } + public @Nullable Integer getThumbTintColor() { + return mThumbTintColor; + } + public @Nullable ReadableMap getPoint() { + return mPoint; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture NO_PROPS_NO_EVENTS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/NoPropsNoEvents/NoPropsNoEventsComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.NoPropsNoEvents; + +public class NoPropsNoEventsComponentProps { + + +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture OBJECT_PROPS 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropObjectArrayProp.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +import androidx.annotation.Nullable; +import java.util.ArrayList; + +public class ObjectPropsPropsObjectPropObjectArrayProp { + private ArrayList<@Nullable String> mArray; + public ArrayList<@Nullable String> getArray() { + return mArray; + } +} +", + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropObjectPrimitiveRequiredProp.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableMap; + +public class ObjectPropsPropsObjectPropObjectPrimitiveRequiredProp { + private @Nullable ReadableMap mImage; + private @Nullable Integer mColor; + private @Nullable ReadableMap mPoint; + public @Nullable ReadableMap getImage() { + return mImage; + } + public @Nullable Integer getColor() { + return mColor; + } + public @Nullable ReadableMap getPoint() { + return mPoint; + } +} +", + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedPropANestedPropB.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +import androidx.annotation.Nullable; + +public class ObjectPropsPropsObjectPropNestedPropANestedPropB { + private @Nullable String mNestedPropC; + public @Nullable String getNestedPropC() { + return mNestedPropC; + } +} +", + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedPropA.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +public class ObjectPropsPropsObjectPropNestedPropA { + private ObjectPropsPropsObjectPropNestedPropANestedPropB mNestedPropB; + public ObjectPropsPropsObjectPropNestedPropANestedPropB getNestedPropB() { + return mNestedPropB; + } +} +", + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedArrayAsPropertyArrayPropElement.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +import androidx.annotation.Nullable; + +public class ObjectPropsPropsObjectPropNestedArrayAsPropertyArrayPropElement { + private @Nullable String mStringProp; + public @Nullable String getStringProp() { + return mStringProp; + } +} +", + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectPropNestedArrayAsProperty.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +import java.util.ArrayList; + +public class ObjectPropsPropsObjectPropNestedArrayAsProperty { + private ArrayList mArrayProp; + public ArrayList getArrayProp() { + return mArrayProp; + } +} +", + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsPropsObjectProp.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +import androidx.annotation.Nullable; + +public class ObjectPropsPropsObjectProp { + private @Nullable String mStringProp; + private boolean mBooleanProp; + private float mFloatProp; + private int mIntProp; + private @Nullable String mStringEnumProp; + private @Nullable Integer mIntEnumProp; + private ObjectPropsPropsObjectPropObjectArrayProp mObjectArrayProp; + private ObjectPropsPropsObjectPropObjectPrimitiveRequiredProp mObjectPrimitiveRequiredProp; + private ObjectPropsPropsObjectPropNestedPropA mNestedPropA; + private ObjectPropsPropsObjectPropNestedArrayAsProperty mNestedArrayAsProperty; + public @Nullable String getStringProp() { + return mStringProp; + } + public boolean getBooleanProp() { + return mBooleanProp; + } + public float getFloatProp() { + return mFloatProp; + } + public int getIntProp() { + return mIntProp; + } + public @Nullable String getStringEnumProp() { + return mStringEnumProp; + } + public @Nullable Integer getIntEnumProp() { + return mIntEnumProp; + } + public ObjectPropsPropsObjectPropObjectArrayProp getObjectArrayProp() { + return mObjectArrayProp; + } + public ObjectPropsPropsObjectPropObjectPrimitiveRequiredProp getObjectPrimitiveRequiredProp() { + return mObjectPrimitiveRequiredProp; + } + public ObjectPropsPropsObjectPropNestedPropA getNestedPropA() { + return mNestedPropA; + } + public ObjectPropsPropsObjectPropNestedArrayAsProperty getNestedArrayAsProperty() { + return mNestedArrayAsProperty; + } +} +", + "java/com/facebook/react/viewmanagers/ObjectPropsNativeComponent/ObjectPropsProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ObjectPropsNativeComponent; + +public class ObjectPropsProps { + private ObjectPropsPropsObjectProp mObjectProp; + public ObjectPropsPropsObjectProp getObjectProp() { + return mObjectProp; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture POINT_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/PointPropNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReadableMap; + +public class PointPropNativeComponentProps { + private @Nullable ReadableMap mStartPoint; + public @Nullable ReadableMap getStartPoint() { + return mStartPoint; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/StringEnumPropsNativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +import androidx.annotation.Nullable; + +public class StringEnumPropsNativeComponentProps { + private @Nullable String mAlignment; + public @Nullable String getAlignment() { + return mAlignment; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture STRING_PROP 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/Switch/StringPropComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.Switch; + +import androidx.annotation.Nullable; + +public class StringPropComponentProps { + private @Nullable String mAccessibilityHint; + private @Nullable String mAccessibilityRole; + public @Nullable String getAccessibilityHint() { + return mAccessibilityHint; + } + public @Nullable String getAccessibilityRole() { + return mAccessibilityRole; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/ComponentFile1/MultiFile1NativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ComponentFile1; + +public class MultiFile1NativeComponentProps { + private boolean mDisabled; + public boolean getDisabled() { + return mDisabled; + } +} +", + "java/com/facebook/react/viewmanagers/ComponentFile2/MultiFile2NativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.ComponentFile2; + +public class MultiFile2NativeComponentProps { + private boolean mDisabled; + public boolean getDisabled() { + return mDisabled; + } +} +", +} +`; + +exports[`GeneratePropsJavaPojo can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` +Map { + "java/com/facebook/react/viewmanagers/MyComponents/MultiComponent1NativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponents; + +public class MultiComponent1NativeComponentProps { + private boolean mDisabled; + public boolean getDisabled() { + return mDisabled; + } +} +", + "java/com/facebook/react/viewmanagers/MyComponents/MultiComponent2NativeComponentProps.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaPojo.js +*/ + +package com.facebook.react.viewmanagers.MyComponents; + +public class MultiComponent2NativeComponentProps { + private boolean mDisabled; + public boolean getDisabled() { + return mDisabled; + } +} +", +} +`; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js index fda5f8466a7..a4377a64e4e 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/StructCollector.js @@ -28,7 +28,7 @@ import type { import type {AliasResolver} from '../Utils'; -const {capitalize} = require('./Utils'); +const {capitalize} = require('../../Utils'); const { unwrapNullable, wrapNullable, diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js index c596cebbd11..ffbfea1b8cc 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/Utils.js @@ -12,9 +12,6 @@ import type {StructProperty} from './StructCollector'; -function capitalize(string: string): string { - return string.charAt(0).toUpperCase() + string.slice(1); -} function getSafePropertyName(property: StructProperty): string { if (property.name === 'id') { return `${property.name}_`; @@ -30,7 +27,6 @@ function getNamespacedStructName( } module.exports = { - capitalize, getSafePropertyName, getNamespacedStructName, }; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js index 7a1772ad363..d11a5a8c23d 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeConstantsStruct.js @@ -10,11 +10,8 @@ 'use strict'; -const { - capitalize, - getSafePropertyName, - getNamespacedStructName, -} = require('../Utils'); +const {getSafePropertyName, getNamespacedStructName} = require('../Utils'); +const {capitalize} = require('../../../Utils'); import type {Nullable} from '../../../../CodegenSchema'; import type {StructTypeAnnotation, ConstantsStruct} from '../StructCollector'; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js index 168afa44ebd..90b4c7f114c 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/header/serializeRegularStruct.js @@ -10,11 +10,8 @@ 'use strict'; -const { - capitalize, - getSafePropertyName, - getNamespacedStructName, -} = require('../Utils'); +const {getSafePropertyName, getNamespacedStructName} = require('../Utils'); +const {capitalize} = require('../../../Utils'); import type {Nullable} from '../../../../CodegenSchema'; import type {StructTypeAnnotation, RegularStruct} from '../StructCollector'; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js index 5858765778a..4d948b6f6ec 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleObjCpp/serializeMethod.js @@ -22,7 +22,8 @@ import type {AliasResolver} from '../Utils'; const invariant = require('invariant'); const {StructCollector} = require('./StructCollector'); -const {capitalize, getNamespacedStructName} = require('./Utils'); +const {getNamespacedStructName} = require('./Utils'); +const {capitalize} = require('../../Utils'); const { wrapNullable, unwrapNullable,