mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix: Codegen template error in RCTThirdPartyFabricComponentsProvider (#34738)
Summary:
When `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` generates `RCTThirdPartyFabricComponentsProvider.mm` an edge case happens in the following situation:
- The same library exports multiple modules with one component each (i.e. one component per file);
- The **first component** is excluded for iOS via the `excludedPlatforms` property in *codegenNativeComponent*.
A "loose" comma appears in the generated template, breaking the code.
```c++
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
, // <-- the offending comma
{"NativeComponent2", NativeComponent2Cls}, // rnmylibrary
};
}
```
At some point, `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` does not properly filter out empty arrays resulting from excluded components. This does not seem to be a problem when the excluded component is not the first being processed, as the comma gets added at the end of the previous line, after the comment with the name of the library.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[iOS] [Fixed] - Fix error in the Codegen template for ThirdPartyFabricComponentsProvider
Pull Request resolved: https://github.com/facebook/react-native/pull/34738
Test Plan:
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. -->
This is the schema that leads to the bug. Notice that the first component was excluded for iOS.
```json
{
"modules": {
"ComponentFile1": {
"type": "Component",
"components": {
"NativeComponent1": {
"excludedPlatforms": ["iOS"]
"extendsProps": [
{
"type": "ReactNativeBuiltInType",
"knownTypeName": "ReactNativeCoreViewProps"
}
],
"events": [],
"props": [],
"commands": []
}
}
},
"ComponentFile2": {
"type": "Component",
"components": {
"NativeComponent2": {
"extendsProps": [
{
"type": "ReactNativeBuiltInType",
"knownTypeName": "ReactNativeCoreViewProps"
}
],
"events": [],
"props": [],
"commands": []
}
}
}
}
```
`GenerateRCTThirdPartyFabricComponentsProviderCpp.js` should generate a template without the comma in the wrong position (before NativeComponent2).
I also added an additional test case to cover this problem. All the other tests passed.
Reviewed By: sammy-SC
Differential Revision: D39686573
Pulled By: cipolleschi
fbshipit-source-id: 6054464d024218eb0b2e02974aa5cc7c8aebbbc9
This commit is contained in:
committed by
Dmitry Rykun
parent
917e97b996
commit
c4b094fd24
+3
-1
@@ -75,7 +75,7 @@ module.exports = {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Object.keys(components)
|
||||
const componentTemplates = Object.keys(components)
|
||||
.filter(componentName => {
|
||||
const component = components[componentName];
|
||||
return !(
|
||||
@@ -91,6 +91,8 @@ module.exports = {
|
||||
|
||||
return replacedTemplate;
|
||||
});
|
||||
|
||||
return componentTemplates.length > 0 ? componentTemplates : null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
})
|
||||
|
||||
+48
@@ -1594,6 +1594,53 @@ const EXCLUDE_ANDROID_IOS: SchemaType = {
|
||||
},
|
||||
};
|
||||
|
||||
const EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES: SchemaType = {
|
||||
modules: {
|
||||
ComponentFile1: {
|
||||
type: 'Component',
|
||||
components: {
|
||||
ExcludedIosComponent: {
|
||||
excludedPlatforms: ['iOS'],
|
||||
extendsProps: [
|
||||
{
|
||||
type: 'ReactNativeBuiltInType',
|
||||
knownTypeName: 'ReactNativeCoreViewProps',
|
||||
},
|
||||
],
|
||||
events: [],
|
||||
props: [],
|
||||
commands: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
ComponentFile2: {
|
||||
type: 'Component',
|
||||
components: {
|
||||
MultiFileIncludedNativeComponent: {
|
||||
extendsProps: [
|
||||
{
|
||||
type: 'ReactNativeBuiltInType',
|
||||
knownTypeName: 'ReactNativeCoreViewProps',
|
||||
},
|
||||
],
|
||||
events: [],
|
||||
props: [
|
||||
{
|
||||
name: 'disabled',
|
||||
optional: true,
|
||||
typeAnnotation: {
|
||||
type: 'BooleanTypeAnnotation',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
commands: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
NO_PROPS_NO_EVENTS,
|
||||
INTERFACE_ONLY,
|
||||
@@ -1621,4 +1668,5 @@ module.exports = {
|
||||
COMMANDS_AND_PROPS,
|
||||
EXCLUDE_ANDROID,
|
||||
EXCLUDE_ANDROID_IOS,
|
||||
EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES,
|
||||
};
|
||||
|
||||
+29
@@ -336,6 +336,35 @@ using ExcludedAndroidIosComponentComponentDescriptor = ConcreteComponentDescript
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateComponentDescriptorH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"ComponentDescriptors.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: GenerateComponentDescriptorH.js
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/ShadowNodes.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
using ExcludedIosComponentComponentDescriptor = ConcreteComponentDescriptor<ExcludedIosComponentShadowNode>;
|
||||
using MultiFileIncludedNativeComponentComponentDescriptor = ConcreteComponentDescriptor<MultiFileIncludedNativeComponentShadowNode>;
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateComponentDescriptorH can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"ComponentDescriptors.h" => "
|
||||
|
||||
+25
@@ -430,6 +430,31 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateComponentHObjCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"RCTComponentViewHelpers.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: GenerateComponentHObjCpp.js
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <React/RCTDefines.h>
|
||||
#import <React/RCTLog.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol RCTMultiFileIncludedNativeComponentViewProtocol <NSObject>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END",
|
||||
}
|
||||
`;
|
||||
|
||||
+26
@@ -351,6 +351,32 @@ namespace react {
|
||||
|
||||
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateEventEmitterCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"EventEmitters.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: GenerateEventEmitterCpp.js
|
||||
*/
|
||||
|
||||
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/EventEmitters.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
|
||||
+27
@@ -390,6 +390,33 @@ namespace react {
|
||||
|
||||
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateEventEmitterH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"EventEmitters.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: GenerateEventEmitterH.js
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <react/renderer/components/view/ViewEventEmitter.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
|
||||
+40
@@ -412,6 +412,46 @@ ExcludedAndroidIosComponentProps::ExcludedAndroidIosComponentProps(
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GeneratePropsCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"Props.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: GeneratePropsCpp.js
|
||||
*/
|
||||
|
||||
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/Props.h>
|
||||
#include <react/renderer/core/PropsParserContext.h>
|
||||
#include <react/renderer/core/propsConversions.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ExcludedIosComponentProps::ExcludedIosComponentProps(
|
||||
const PropsParserContext &context,
|
||||
const ExcludedIosComponentProps &sourceProps,
|
||||
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps)
|
||||
|
||||
|
||||
{}
|
||||
MultiFileIncludedNativeComponentProps::MultiFileIncludedNativeComponentProps(
|
||||
const PropsParserContext &context,
|
||||
const MultiFileIncludedNativeComponentProps &sourceProps,
|
||||
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
||||
|
||||
disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true}))
|
||||
{}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GeneratePropsCpp can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"Props.cpp" => "
|
||||
|
||||
+46
@@ -660,6 +660,52 @@ class JSI_EXPORT ExcludedAndroidIosComponentProps final : public ViewProps {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GeneratePropsH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"Props.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: GeneratePropsH.js
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/renderer/components/view/ViewProps.h>
|
||||
#include <react/renderer/core/PropsParserContext.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class JSI_EXPORT ExcludedIosComponentProps final : public ViewProps {
|
||||
public:
|
||||
ExcludedIosComponentProps() = default;
|
||||
ExcludedIosComponentProps(const PropsParserContext& context, const ExcludedIosComponentProps &sourceProps, const RawProps &rawProps);
|
||||
|
||||
#pragma mark - Props
|
||||
|
||||
|
||||
};
|
||||
|
||||
class JSI_EXPORT MultiFileIncludedNativeComponentProps final : public ViewProps {
|
||||
public:
|
||||
MultiFileIncludedNativeComponentProps() = default;
|
||||
MultiFileIncludedNativeComponentProps(const PropsParserContext& context, const MultiFileIncludedNativeComponentProps &sourceProps, const RawProps &rawProps);
|
||||
|
||||
#pragma mark - Props
|
||||
|
||||
bool disabled{true};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GeneratePropsH can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"Props.h" => "
|
||||
|
||||
+63
@@ -436,6 +436,69 @@ exports[`GeneratePropsJavaDelegate can generate fixture EXCLUDE_ANDROID 1`] = `M
|
||||
|
||||
exports[`GeneratePropsJavaDelegate can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`;
|
||||
|
||||
exports[`GeneratePropsJavaDelegate can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"java/com/facebook/react/viewmanagers/ExcludedIosComponentManagerDelegate.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: GeneratePropsJavaDelegate.js
|
||||
*/
|
||||
|
||||
package com.facebook.react.viewmanagers;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
||||
import com.facebook.react.uimanager.BaseViewManagerInterface;
|
||||
|
||||
public class ExcludedIosComponentManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & ExcludedIosComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
||||
public ExcludedIosComponentManagerDelegate(U viewManager) {
|
||||
super(viewManager);
|
||||
}
|
||||
@Override
|
||||
public void setProperty(T view, String propName, @Nullable Object value) {
|
||||
super.setProperty(view, propName, value);
|
||||
}
|
||||
}
|
||||
",
|
||||
"java/com/facebook/react/viewmanagers/MultiFileIncludedNativeComponentManagerDelegate.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: GeneratePropsJavaDelegate.js
|
||||
*/
|
||||
|
||||
package com.facebook.react.viewmanagers;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
||||
import com.facebook.react.uimanager.BaseViewManagerInterface;
|
||||
|
||||
public class MultiFileIncludedNativeComponentManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & MultiFileIncludedNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
||||
public MultiFileIncludedNativeComponentManagerDelegate(U viewManager) {
|
||||
super(viewManager);
|
||||
}
|
||||
@Override
|
||||
public void setProperty(T view, String propName, @Nullable Object value) {
|
||||
switch (propName) {
|
||||
case \\"disabled\\":
|
||||
mViewManager.setDisabled(view, value == null ? true : (boolean) value);
|
||||
break;
|
||||
default:
|
||||
super.setProperty(view, propName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GeneratePropsJavaDelegate can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"java/com/facebook/react/viewmanagers/FloatPropNativeComponentManagerDelegate.java" => "/**
|
||||
|
||||
+39
@@ -249,6 +249,45 @@ exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_ANDROID 1`] = `
|
||||
|
||||
exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`;
|
||||
|
||||
exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"java/com/facebook/react/viewmanagers/ExcludedIosComponentManagerInterface.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: GeneratePropsJavaInterface.js
|
||||
*/
|
||||
|
||||
package com.facebook.react.viewmanagers;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public interface ExcludedIosComponentManagerInterface<T extends View> {
|
||||
// No props
|
||||
}
|
||||
",
|
||||
"java/com/facebook/react/viewmanagers/MultiFileIncludedNativeComponentManagerInterface.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: GeneratePropsJavaInterface.js
|
||||
*/
|
||||
|
||||
package com.facebook.react.viewmanagers;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public interface MultiFileIncludedNativeComponentManagerInterface<T extends View> {
|
||||
void setDisabled(T view, boolean value);
|
||||
}
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GeneratePropsJavaInterface can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"java/com/facebook/react/viewmanagers/FloatPropNativeComponentManagerInterface.java" => "/**
|
||||
|
||||
+46
@@ -474,6 +474,52 @@ exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_ANDROID 1`] = `Map {
|
||||
|
||||
exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`;
|
||||
|
||||
exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"java/com/facebook/react/viewmanagers/ComponentFile1/ExcludedIosComponentProps.java" => "/**
|
||||
* 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.
|
||||
*
|
||||
* @generated by codegen project: GeneratePropsJavaPojo.js
|
||||
*/
|
||||
|
||||
package com.facebook.react.viewmanagers.ComponentFile1;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
@DoNotStrip
|
||||
public class ExcludedIosComponentProps {
|
||||
|
||||
|
||||
}
|
||||
",
|
||||
"java/com/facebook/react/viewmanagers/ComponentFile2/MultiFileIncludedNativeComponentProps.java" => "/**
|
||||
* 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.
|
||||
*
|
||||
* @generated by codegen project: GeneratePropsJavaPojo.js
|
||||
*/
|
||||
|
||||
package com.facebook.react.viewmanagers.ComponentFile2;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
@DoNotStrip
|
||||
public class MultiFileIncludedNativeComponentProps {
|
||||
private boolean mDisabled;
|
||||
@DoNotStrip
|
||||
public boolean getDisabled() {
|
||||
return mDisabled;
|
||||
}
|
||||
}
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GeneratePropsJavaPojo can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"java/com/facebook/react/viewmanagers/Switch/FloatPropNativeComponentProps.java" => "/**
|
||||
|
||||
+26
@@ -300,6 +300,32 @@ extern const char ExcludedAndroidIosComponentComponentName[] = \\"ExcludedAndroi
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateShadowNodeCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"ShadowNodes.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: GenerateShadowNodeCpp.js
|
||||
*/
|
||||
|
||||
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/ShadowNodes.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
extern const char ExcludedIosComponentComponentName[] = \\"ExcludedIosComponent\\";
|
||||
extern const char MultiFileIncludedNativeComponentComponentName[] = \\"MultiFileIncludedNativeComponent\\";
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateShadowNodeCpp can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"ShadowNodes.cpp" => "
|
||||
|
||||
+45
@@ -429,6 +429,51 @@ using ExcludedAndroidIosComponentShadowNode = ConcreteViewShadowNode<
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateShadowNodeH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"ShadowNodes.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: GenerateShadowNodeH.js
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/Props.h>
|
||||
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
JSI_EXPORT extern const char ExcludedIosComponentComponentName[];
|
||||
|
||||
/*
|
||||
* \`ShadowNode\` for <ExcludedIosComponent> component.
|
||||
*/
|
||||
using ExcludedIosComponentShadowNode = ConcreteViewShadowNode<
|
||||
ExcludedIosComponentComponentName,
|
||||
ExcludedIosComponentProps>;
|
||||
|
||||
JSI_EXPORT extern const char MultiFileIncludedNativeComponentComponentName[];
|
||||
|
||||
/*
|
||||
* \`ShadowNode\` for <MultiFileIncludedNativeComponent> component.
|
||||
*/
|
||||
using MultiFileIncludedNativeComponentShadowNode = ConcreteViewShadowNode<
|
||||
MultiFileIncludedNativeComponentComponentName,
|
||||
MultiFileIncludedNativeComponentProps>;
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateShadowNodeH can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"ShadowNodes.h" => "
|
||||
|
||||
+61
@@ -486,6 +486,67 @@ TEST(ExcludedAndroidIosComponentProps_DoesNotDie, etc) {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateTests can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"Tests.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: GenerateTests.js
|
||||
* */
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <react/renderer/core/PropsParserContext.h>
|
||||
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/Props.h>
|
||||
#include <react/renderer/core/RawProps.h>
|
||||
#include <react/renderer/core/RawPropsParser.h>
|
||||
#include <react/renderer/core/propsConversions.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
TEST(ExcludedIosComponentProps_DoesNotDie, etc) {
|
||||
auto propParser = RawPropsParser();
|
||||
propParser.prepare<ExcludedIosComponentProps>();
|
||||
auto const &sourceProps = ExcludedIosComponentProps();
|
||||
auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\"));
|
||||
|
||||
ContextContainer contextContainer{};
|
||||
PropsParserContext parserContext{-1, contextContainer};
|
||||
|
||||
rawProps.parse(propParser, parserContext);
|
||||
ExcludedIosComponentProps(parserContext, sourceProps, rawProps);
|
||||
}
|
||||
|
||||
TEST(MultiFileIncludedNativeComponentProps_DoesNotDie, etc) {
|
||||
auto propParser = RawPropsParser();
|
||||
propParser.prepare<MultiFileIncludedNativeComponentProps>();
|
||||
auto const &sourceProps = MultiFileIncludedNativeComponentProps();
|
||||
auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\"));
|
||||
|
||||
ContextContainer contextContainer{};
|
||||
PropsParserContext parserContext{-1, contextContainer};
|
||||
|
||||
rawProps.parse(propParser, parserContext);
|
||||
MultiFileIncludedNativeComponentProps(parserContext, sourceProps, rawProps);
|
||||
}
|
||||
|
||||
TEST(MultiFileIncludedNativeComponentProps_disabled, etc) {
|
||||
auto propParser = RawPropsParser();
|
||||
propParser.prepare<MultiFileIncludedNativeComponentProps>();
|
||||
auto const &sourceProps = MultiFileIncludedNativeComponentProps();
|
||||
auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", true));
|
||||
|
||||
ContextContainer contextContainer{};
|
||||
PropsParserContext parserContext{-1, contextContainer};
|
||||
|
||||
rawProps.parse(propParser, parserContext);
|
||||
MultiFileIncludedNativeComponentProps(parserContext, sourceProps, rawProps);
|
||||
}",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateTests can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"Tests.cpp" => "/**
|
||||
|
||||
+1
@@ -51,6 +51,7 @@ Class<RCTComponentViewProtocol> CommandNativeComponentCls(void) __attribute__((u
|
||||
Class<RCTComponentViewProtocol> CommandNativeComponentCls(void) __attribute__((used)); // COMMANDS_AND_PROPS
|
||||
Class<RCTComponentViewProtocol> ExcludedAndroidComponentCls(void) __attribute__((used)); // EXCLUDE_ANDROID
|
||||
|
||||
Class<RCTComponentViewProtocol> MultiFileIncludedNativeComponentCls(void) __attribute__((used)); // EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+2
@@ -74,6 +74,8 @@ Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char
|
||||
|
||||
{\\"ExcludedAndroidComponent\\", ExcludedAndroidComponentCls}, // EXCLUDE_ANDROID
|
||||
|
||||
|
||||
{\\"MultiFileIncludedNativeComponent\\", MultiFileIncludedNativeComponentCls}, // EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES
|
||||
};
|
||||
|
||||
auto p = sFabricComponentsClassMap.find(name);
|
||||
|
||||
+44
@@ -509,6 +509,50 @@ export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateViewConfigJs can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
|
||||
Map {
|
||||
"EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILESNativeViewConfig.js" => "
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
*
|
||||
* @generated by codegen project: GenerateViewConfigJs.js
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
|
||||
let nativeComponentName = 'ExcludedIosComponent';
|
||||
|
||||
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: 'ExcludedIosComponent',
|
||||
validAttributes: {},
|
||||
};
|
||||
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
|
||||
let nativeComponentName = 'MultiFileIncludedNativeComponent';
|
||||
|
||||
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: 'MultiFileIncludedNativeComponent',
|
||||
|
||||
validAttributes: {
|
||||
disabled: true,
|
||||
},
|
||||
};
|
||||
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`GenerateViewConfigJs can generate fixture FLOAT_PROPS 1`] = `
|
||||
Map {
|
||||
"FLOAT_PROPSNativeViewConfig.js" => "
|
||||
|
||||
Reference in New Issue
Block a user