mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Remove deep imports from generated Codegen modules (#58603)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/58603 Generate view configs and Codegen fixtures using supported React Native entry points or values derived from their exports. Generated view config modules can be emitted into arbitrary consumer package locations, so they cannot use a package-relative path back into React Native. Keep `ConditionallyIgnoredEventHandlers` centralized and expose it from the explicitly unstable compatibility entry point instead of duplicating its platform-specific semantics in generated output. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D120717571 fbshipit-source-id: 9f3ea06d393eb8702bbb3ef2767c2d7c5fde1315
This commit is contained in:
1 parent
ee4fc1d7ea
commit
e0a6a9f465
14 files changed
+187
-185
No files matched your search
@@ -15,7 +15,9 @@ interface NativeCommands {
|
||||
+seek: (viewRef: React.ElementRef<NativeType>, position: number) => void,
|
||||
+stop: (viewRef: React.ElementRef<NativeType>) => void,
|
||||
}
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {
|
||||
NativeComponentRegistry
|
||||
} = require('react-native');
|
||||
let nativeComponentName = 'Module';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"Module\\",
|
||||
@@ -39,7 +41,9 @@ interface NativeCommands {
|
||||
+pause: (viewRef: React.ElementRef<NativeType>) => void,
|
||||
+play: (viewRef: React.ElementRef<NativeType>) => void,
|
||||
}
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {
|
||||
NativeComponentRegistry
|
||||
} = require('react-native');
|
||||
let nativeComponentName = 'Module';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"Module\\",
|
||||
@@ -63,7 +67,9 @@ interface NativeCommands {
|
||||
+mute: (viewRef: React.ElementRef<NativeType>) => void,
|
||||
+unmute: (viewRef: React.ElementRef<NativeType>) => void,
|
||||
}
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {
|
||||
NativeComponentRegistry
|
||||
} = require('react-native');
|
||||
let nativeComponentName = 'Module';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"Module\\",
|
||||
@@ -93,13 +99,15 @@ interface NativeCommands {
|
||||
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void,
|
||||
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,
|
||||
}
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {
|
||||
ConditionallyIgnoredEventHandlers
|
||||
} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
} = require('react-native/unstable-internals-do-not-use');
|
||||
const {
|
||||
dispatchCommand
|
||||
} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
|
||||
NativeComponentRegistry
|
||||
} = require('react-native');
|
||||
const {
|
||||
Renderer
|
||||
} = require(\\"react-native/unstable-internals-do-not-use\\");
|
||||
let nativeComponentName = 'RCTModule';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"RCTModule\\",
|
||||
@@ -127,10 +135,10 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
export const Commands = {
|
||||
hotspotUpdate(ref, x, y) {
|
||||
dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]);
|
||||
Renderer.dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]);
|
||||
},
|
||||
scrollTo(ref, y, animated) {
|
||||
dispatchCommand(ref, \\"scrollTo\\", [y, animated]);
|
||||
Renderer.dispatchCommand(ref, \\"scrollTo\\", [y, animated]);
|
||||
}
|
||||
};"
|
||||
`;
|
||||
@@ -156,13 +164,15 @@ interface NativeCommands {
|
||||
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void,
|
||||
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,
|
||||
}
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {
|
||||
ConditionallyIgnoredEventHandlers
|
||||
} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
} = require('react-native/unstable-internals-do-not-use');
|
||||
const {
|
||||
dispatchCommand
|
||||
} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
|
||||
NativeComponentRegistry
|
||||
} = require('react-native');
|
||||
const {
|
||||
Renderer
|
||||
} = require(\\"react-native/unstable-internals-do-not-use\\");
|
||||
let nativeComponentName = 'RCTModule';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"RCTModule\\",
|
||||
@@ -190,10 +200,10 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
export const Commands = {
|
||||
hotspotUpdate(ref, x, y) {
|
||||
dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]);
|
||||
Renderer.dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]);
|
||||
},
|
||||
scrollTo(ref, y, animated) {
|
||||
dispatchCommand(ref, \\"scrollTo\\", [y, animated]);
|
||||
Renderer.dispatchCommand(ref, \\"scrollTo\\", [y, animated]);
|
||||
}
|
||||
};"
|
||||
`;
|
||||
|
||||
@@ -20,11 +20,10 @@ const eslintTester = new ESLintTester();
|
||||
const VALID_SPECS = [
|
||||
{
|
||||
code: `
|
||||
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
||||
import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes';
|
||||
import {TurboModuleRegistry, type CodegenTypes, type TurboModule} from 'react-native';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
func1(a: string): UnsafeObject,
|
||||
func1(a: string): CodegenTypes.UnsafeObject,
|
||||
}
|
||||
export default TurboModuleRegistry.get<Spec>('XYZ');
|
||||
`,
|
||||
|
||||
@@ -18,13 +18,13 @@ module.exports = {
|
||||
platforms: ['android', 'ios', 'native'],
|
||||
},
|
||||
moduleNameMapper: {
|
||||
// `setup-env` and `react-private-interface` are secondary entry points
|
||||
// exposed via the package's `exports`, but `./jest/resolver.js` strips
|
||||
// `exports` and the generic mapper below resolves subpaths as literal
|
||||
// directory paths. Alias them explicitly so they resolve to their `src/`
|
||||
// implementations.
|
||||
// These secondary entry points are exposed via the package's `exports`,
|
||||
// but `./jest/resolver.js` strips `exports` and the generic mapper below
|
||||
// resolves subpaths as literal directory paths. Alias them explicitly so
|
||||
// they resolve to their `src/` implementations.
|
||||
'^react-native/react-private-interface$': `${path.dirname(require.resolve('react-native'))}/src/react-private-interface.js`,
|
||||
'^react-native/setup-env$': `${path.dirname(require.resolve('react-native'))}/src/setup-env.js`,
|
||||
'^react-native/unstable-internals-do-not-use$': `${path.dirname(require.resolve('react-native'))}/src/unstable-internals-do-not-use.js`,
|
||||
'^react-native($|/.*)': `${path.dirname(require.resolve('react-native'))}/$1`,
|
||||
},
|
||||
resolver: require.resolve('./jest/resolver.js'),
|
||||
|
||||
+5
-3
@@ -316,9 +316,11 @@ describe('react-native-babel-preset transform snapshots', () => {
|
||||
it('runs codegen when the type arguments are separated by trivia', () => {
|
||||
const code = `
|
||||
// @flow strict-local
|
||||
import type {ViewProps} from 'react-native';
|
||||
import type {HostComponent} from 'react-native';
|
||||
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
||||
import {
|
||||
codegenNativeComponent,
|
||||
type HostComponent,
|
||||
type ViewProps,
|
||||
} from 'react-native';
|
||||
|
||||
type NativeProps = Readonly<{
|
||||
...ViewProps,
|
||||
|
||||
+29
-29
@@ -16,7 +16,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -27,7 +27,7 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
progress: true,
|
||||
radii: true,
|
||||
colors: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray'))
|
||||
process: require('react-native/unstable-internals-do-not-use').processColorArray
|
||||
},
|
||||
srcs: true,
|
||||
points: true,
|
||||
@@ -60,7 +60,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'BooleanPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -91,13 +91,13 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ColorPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"ColorPropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute
|
||||
tintColor: require('react-native/unstable-internals-do-not-use').colorAttribute
|
||||
}
|
||||
};
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
@@ -121,7 +121,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'DimensionPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -151,7 +151,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EdgeInsetsPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -179,7 +179,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EnumPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -210,8 +210,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EventNestedObjectPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -252,8 +252,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EventPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -322,7 +322,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'FloatPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -358,14 +358,14 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ImagePropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"ImagePropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
thumbImage: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
|
||||
process: require('react-native').Image.resolveAssetSource
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -390,7 +390,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'IntegerPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -422,8 +422,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'RCTInterfaceOnlyComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -464,7 +464,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'MixedPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -494,19 +494,19 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'MultiNativePropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"MultiNativePropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
thumbImage: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
|
||||
process: require('react-native').Image.resolveAssetSource
|
||||
},
|
||||
color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
|
||||
thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
|
||||
color: require('react-native/unstable-internals-do-not-use').colorAttribute,
|
||||
thumbTintColor: require('react-native/unstable-internals-do-not-use').colorAttribute,
|
||||
point: {
|
||||
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
|
||||
diff: require('react-native/unstable-internals-do-not-use').pointsDiffer
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -531,7 +531,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'NoPropsNoEventsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -559,7 +559,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ObjectPropsNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -591,14 +591,14 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'PointPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"PointPropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
startPoint: {
|
||||
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
|
||||
diff: require('react-native/unstable-internals-do-not-use').pointsDiffer
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -623,7 +623,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'StringPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
|
||||
+29
-29
@@ -16,7 +16,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -27,7 +27,7 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
progress: true,
|
||||
radii: true,
|
||||
colors: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray'))
|
||||
process: require('react-native/unstable-internals-do-not-use').processColorArray
|
||||
},
|
||||
srcs: true,
|
||||
points: true,
|
||||
@@ -60,7 +60,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'BooleanPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -91,13 +91,13 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ColorPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"ColorPropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute
|
||||
tintColor: require('react-native/unstable-internals-do-not-use').colorAttribute
|
||||
}
|
||||
};
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
@@ -121,7 +121,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'DimensionPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -151,7 +151,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EdgeInsetsPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -179,7 +179,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EnumPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -210,8 +210,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EventNestedObjectPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -252,8 +252,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EventPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -322,7 +322,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'FloatPropsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -358,14 +358,14 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ImagePropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"ImagePropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
thumbImage: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
|
||||
process: require('react-native').Image.resolveAssetSource
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -390,7 +390,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'IntegerPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -422,8 +422,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'RCTInterfaceOnlyComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -464,7 +464,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'MixedPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -494,19 +494,19 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'MultiNativePropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"MultiNativePropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
thumbImage: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
|
||||
process: require('react-native').Image.resolveAssetSource
|
||||
},
|
||||
color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
|
||||
thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
|
||||
color: require('react-native/unstable-internals-do-not-use').colorAttribute,
|
||||
thumbTintColor: require('react-native/unstable-internals-do-not-use').colorAttribute,
|
||||
point: {
|
||||
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
|
||||
diff: require('react-native/unstable-internals-do-not-use').pointsDiffer
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -531,7 +531,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'NoPropsNoEventsNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -559,7 +559,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ObjectPropsNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -591,14 +591,14 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'PointPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"PointPropNativeComponentView\\",
|
||||
validAttributes: {
|
||||
startPoint: {
|
||||
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
|
||||
diff: require('react-native/unstable-internals-do-not-use').pointsDiffer
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -623,7 +623,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'StringPropNativeComponentView';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
|
||||
+17
-12
@@ -55,7 +55,9 @@ ${componentConfig}
|
||||
|
||||
// We use this to add to a set. Need to make sure we aren't importing
|
||||
// this multiple times.
|
||||
const UIMANAGER_IMPORT = 'const {UIManager} = require("react-native")';
|
||||
const UIMANAGER_IMPORT = 'const {UIManager} = require("react-native");';
|
||||
const RENDERER_IMPORT =
|
||||
'const {Renderer} = require("react-native/unstable-internals-do-not-use");';
|
||||
|
||||
function expression(input: string) {
|
||||
return core.template.expression(input)();
|
||||
@@ -77,21 +79,21 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) {
|
||||
switch (typeAnnotation.name) {
|
||||
case 'ColorPrimitive':
|
||||
return expression(
|
||||
"require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute",
|
||||
"require('react-native/unstable-internals-do-not-use').colorAttribute",
|
||||
);
|
||||
case 'ImageSourcePrimitive':
|
||||
return expression(
|
||||
"{ process: ((req) => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource')) }",
|
||||
"{ process: require('react-native').Image.resolveAssetSource }",
|
||||
);
|
||||
case 'ImageRequestPrimitive':
|
||||
throw new Error('ImageRequest should not be used in props');
|
||||
case 'PointPrimitive':
|
||||
return expression(
|
||||
"{ diff: ((req) => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer')) }",
|
||||
"{ diff: require('react-native/unstable-internals-do-not-use').pointsDiffer }",
|
||||
);
|
||||
case 'EdgeInsetsPrimitive':
|
||||
return expression(
|
||||
"{ diff: ((req) => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/insetsDiffer')) }",
|
||||
"{ diff: require('react-native/unstable-internals-do-not-use').insetsDiffer }",
|
||||
);
|
||||
case 'DimensionPrimitive':
|
||||
return t.booleanLiteral(true);
|
||||
@@ -106,7 +108,7 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) {
|
||||
switch (typeAnnotation.elementType.name) {
|
||||
case 'ColorPrimitive':
|
||||
return expression(
|
||||
"{ process: ((req) => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray')) }",
|
||||
"{ process: require('react-native/unstable-internals-do-not-use').processColorArray }",
|
||||
);
|
||||
case 'ImageSourcePrimitive':
|
||||
case 'PointPrimitive':
|
||||
@@ -192,8 +194,10 @@ function getValidAttributesForEvents(
|
||||
events: ReadonlyArray<EventTypeShape>,
|
||||
imports: Set<string>,
|
||||
) {
|
||||
// Generated files can live outside the React Native package, so they cannot
|
||||
// use a relative import for this implementation detail.
|
||||
imports.add(
|
||||
"const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');",
|
||||
"const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');",
|
||||
);
|
||||
|
||||
const validAttributes = t.objectExpression(
|
||||
@@ -264,7 +268,7 @@ function buildViewConfig(
|
||||
switch (extendProps.knownTypeName) {
|
||||
case 'ReactNativeCoreViewProps':
|
||||
imports.add(
|
||||
"const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');",
|
||||
"const {NativeComponentRegistry} = require('react-native');",
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -366,9 +370,7 @@ function buildCommands(
|
||||
return null;
|
||||
}
|
||||
|
||||
imports.add(
|
||||
'const {dispatchCommand} = require("react-native/Libraries/ReactNative/RendererProxy");',
|
||||
);
|
||||
imports.add(RENDERER_IMPORT);
|
||||
|
||||
const commandsObject = t.objectExpression(
|
||||
commands.map(command => {
|
||||
@@ -376,7 +378,10 @@ function buildCommands(
|
||||
const params = command.typeAnnotation.params;
|
||||
|
||||
const dispatchCommandCall = t.callExpression(
|
||||
t.identifier('dispatchCommand'),
|
||||
t.memberExpression(
|
||||
t.identifier('Renderer'),
|
||||
t.identifier('dispatchCommand'),
|
||||
),
|
||||
[
|
||||
t.identifier('ref'),
|
||||
t.stringLiteral(commandName),
|
||||
|
||||
+62
-62
@@ -16,7 +16,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'AllProp';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -62,7 +62,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'AllPropWithOptionalGen';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -108,7 +108,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'AllPropWithOptionalObjectGen';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -154,7 +154,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -165,7 +165,7 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
progress: true,
|
||||
radii: true,
|
||||
colors: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray'))
|
||||
process: require('react-native/unstable-internals-do-not-use').processColorArray
|
||||
},
|
||||
srcs: true,
|
||||
points: true,
|
||||
@@ -198,7 +198,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -228,7 +228,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsOptionalGenNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -258,7 +258,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsOptionalObjectGenNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -288,7 +288,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsWithOptionalGenNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -299,7 +299,7 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
progress: true,
|
||||
radii: true,
|
||||
colors: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray'))
|
||||
process: require('react-native/unstable-internals-do-not-use').processColorArray
|
||||
},
|
||||
srcs: true,
|
||||
points: true,
|
||||
@@ -332,7 +332,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ArrayPropsWithOptionalObjectGenNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -343,7 +343,7 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
progress: true,
|
||||
radii: true,
|
||||
colors: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray'))
|
||||
process: require('react-native/unstable-internals-do-not-use').processColorArray
|
||||
},
|
||||
srcs: true,
|
||||
points: true,
|
||||
@@ -376,7 +376,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'BooleanPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -406,13 +406,13 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ColorPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"ColorPropNativeComponent\\",
|
||||
validAttributes: {
|
||||
tintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute
|
||||
tintColor: require('react-native/unstable-internals-do-not-use').colorAttribute
|
||||
}
|
||||
};
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
@@ -436,8 +436,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {dispatchCommand} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
const {Renderer} = require(\\"react-native/unstable-internals-do-not-use\\");
|
||||
|
||||
let nativeComponentName = 'CommandNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -447,10 +447,10 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
export const Commands = {
|
||||
flashScrollIndicators(ref) {
|
||||
dispatchCommand(ref, \\"flashScrollIndicators\\", []);
|
||||
Renderer.dispatchCommand(ref, \\"flashScrollIndicators\\", []);
|
||||
},
|
||||
allTypes(ref, x, y, z, message, animated, locations) {
|
||||
dispatchCommand(ref, \\"allTypes\\", [x, y, z, message, animated, locations]);
|
||||
Renderer.dispatchCommand(ref, \\"allTypes\\", [x, y, z, message, animated, locations]);
|
||||
}
|
||||
};
|
||||
",
|
||||
@@ -473,8 +473,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {dispatchCommand} = require(\\"react-native/Libraries/ReactNative/RendererProxy\\");
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
const {Renderer} = require(\\"react-native/unstable-internals-do-not-use\\");
|
||||
|
||||
let nativeComponentName = 'CommandNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -486,13 +486,13 @@ export const __INTERNAL_VIEW_CONFIG = {
|
||||
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
|
||||
export const Commands = {
|
||||
handleRootTag(ref, rootTag) {
|
||||
dispatchCommand(ref, \\"handleRootTag\\", [rootTag]);
|
||||
Renderer.dispatchCommand(ref, \\"handleRootTag\\", [rootTag]);
|
||||
},
|
||||
hotspotUpdate(ref, x, y) {
|
||||
dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]);
|
||||
Renderer.dispatchCommand(ref, \\"hotspotUpdate\\", [x, y]);
|
||||
},
|
||||
addItems(ref, items) {
|
||||
dispatchCommand(ref, \\"addItems\\", [items]);
|
||||
Renderer.dispatchCommand(ref, \\"addItems\\", [items]);
|
||||
}
|
||||
};
|
||||
",
|
||||
@@ -515,7 +515,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'DimensionPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -545,7 +545,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'DoublePropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -580,8 +580,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EventsNestedObjectNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -622,8 +622,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'EventsNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -692,8 +692,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'RCTInterfaceOnlyComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -739,7 +739,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ExcludedAndroidComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -767,7 +767,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ExcludedAndroidIosComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -795,7 +795,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ExcludedIosComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -832,7 +832,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'FloatPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -867,14 +867,14 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ImagePropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"ImagePropNativeComponent\\",
|
||||
validAttributes: {
|
||||
thumbImage: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
|
||||
process: require('react-native').Image.resolveAssetSource
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -899,14 +899,14 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'InsetsPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"InsetsPropNativeComponent\\",
|
||||
validAttributes: {
|
||||
contentInset: {
|
||||
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/insetsDiffer'))
|
||||
diff: require('react-native/unstable-internals-do-not-use').insetsDiffer
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -931,7 +931,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'Int32EnumPropsNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -961,7 +961,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'IntegerPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -993,8 +993,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');
|
||||
const {ConditionallyIgnoredEventHandlers} = require('react-native/unstable-internals-do-not-use');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'RCTInterfaceOnlyComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1035,7 +1035,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'MixedPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1065,19 +1065,19 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ImageColorPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"ImageColorPropNativeComponent\\",
|
||||
validAttributes: {
|
||||
thumbImage: {
|
||||
process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))
|
||||
process: require('react-native').Image.resolveAssetSource
|
||||
},
|
||||
color: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
|
||||
thumbTintColor: require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute,
|
||||
color: require('react-native/unstable-internals-do-not-use').colorAttribute,
|
||||
thumbTintColor: require('react-native/unstable-internals-do-not-use').colorAttribute,
|
||||
point: {
|
||||
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
|
||||
diff: require('react-native/unstable-internals-do-not-use').pointsDiffer
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1102,7 +1102,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'NoPropsNoEventsComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1130,7 +1130,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ObjectProps';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1160,7 +1160,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ObjectPropsWithOptionalGen';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1190,7 +1190,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'ObjectPropsWithOptionalObjectGen';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1220,14 +1220,14 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'PointPropNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
uiViewClassName: \\"PointPropNativeComponent\\",
|
||||
validAttributes: {
|
||||
startPoint: {
|
||||
diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))
|
||||
diff: require('react-native/unstable-internals-do-not-use').pointsDiffer
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1252,7 +1252,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'StringEnumPropsNativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1282,7 +1282,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'StringPropComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1313,7 +1313,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'MultiFile1NativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1352,7 +1352,7 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
|
||||
let nativeComponentName = 'MultiComponent1NativeComponent';
|
||||
export const __INTERNAL_VIEW_CONFIG = {
|
||||
@@ -1391,8 +1391,8 @@ Map {
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
|
||||
const {UIManager} = require(\\"react-native\\")
|
||||
const {NativeComponentRegistry} = require('react-native');
|
||||
const {UIManager} = require(\\"react-native\\");
|
||||
|
||||
let nativeComponentName = 'NativeComponentName';
|
||||
if (UIManager.hasViewManagerConfig('NativeComponentName')) {
|
||||
|
||||
+4
-8
@@ -801,8 +801,7 @@ describe('buildSchema', () => {
|
||||
|
||||
describe('when there is a TurboModule', () => {
|
||||
const contents = `
|
||||
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
||||
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+getArray: (a: Array<any>) => Array<string>;
|
||||
@@ -1094,8 +1093,7 @@ describe('buildModuleSchema', () => {
|
||||
const [, tryParse] = createParserErrorCapturer();
|
||||
const language = flowParser.language();
|
||||
const NATIVE_MODULE = `
|
||||
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
||||
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+getArray: (a: Array<any>) => Array<string>;
|
||||
@@ -1144,8 +1142,7 @@ describe('buildModuleSchema', () => {
|
||||
describe('throwIfMoreThanOneModuleInterfaceParser', () => {
|
||||
it('should throw an error if mulitple module interfaces are found', () => {
|
||||
const contents = `
|
||||
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
||||
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+getBool: (arg: boolean) => boolean; }
|
||||
@@ -1194,8 +1191,7 @@ describe('buildModuleSchema', () => {
|
||||
describe('throwIfModuleInterfaceIsMisnamed', () => {
|
||||
it('should throw an error if module interface is misnamed', () => {
|
||||
const contents = `
|
||||
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
||||
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
||||
|
||||
export interface MisnamedSpec extends TurboModule {
|
||||
+getArray: (a: Array<any>) => Array<string>;
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
*/
|
||||
|
||||
import type {RefObject} from 'react';
|
||||
import type {HostInstance} from 'react-native';
|
||||
import type {NativeSyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes';
|
||||
import type {HostInstance, NativeSyntheticEvent} from 'react-native';
|
||||
|
||||
import PopupMenuAndroidNativeComponent, {
|
||||
Commands,
|
||||
|
||||
+5
-11
@@ -8,19 +8,13 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {HostComponent} from 'react-native';
|
||||
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
|
||||
import type {
|
||||
DirectEventHandler,
|
||||
Int32,
|
||||
} from 'react-native/Libraries/Types/CodegenTypes';
|
||||
import type {CodegenTypes, HostComponent, ViewProps} from 'react-native';
|
||||
|
||||
import * as React from 'react';
|
||||
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
||||
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
||||
import {codegenNativeCommands, codegenNativeComponent} from 'react-native';
|
||||
|
||||
type PopupMenuSelectionEvent = Readonly<{
|
||||
item: Int32,
|
||||
item: CodegenTypes.Int32,
|
||||
}>;
|
||||
|
||||
type PopupMenuDismissEvent = Readonly<{}>;
|
||||
@@ -31,8 +25,8 @@ type NativeProps = Readonly<{
|
||||
//Props
|
||||
menuItems?: ?ReadonlyArray<string>,
|
||||
|
||||
onPopupMenuSelectionChange?: DirectEventHandler<PopupMenuSelectionEvent>,
|
||||
onPopupMenuDismiss?: DirectEventHandler<PopupMenuDismissEvent>,
|
||||
onPopupMenuSelectionChange?: CodegenTypes.DirectEventHandler<PopupMenuSelectionEvent>,
|
||||
onPopupMenuDismiss?: CodegenTypes.DirectEventHandler<PopupMenuDismissEvent>,
|
||||
}>;
|
||||
|
||||
type ComponentType = HostComponent<NativeProps>;
|
||||
|
||||
+1
-2
@@ -7,8 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {NativeSyntheticEvent} from 'react-native';
|
||||
import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
||||
import type {EventSubscription, NativeSyntheticEvent} from 'react-native';
|
||||
|
||||
// Event types
|
||||
// We're not using the PaperName, it is only used to codegen view config settings
|
||||
|
||||
@@ -40,8 +40,7 @@ declare module 'react-native/Libraries/Utilities/codegenNativeComponent' {
|
||||
}
|
||||
|
||||
declare module 'react-native/Libraries/Types/CodegenTypes' {
|
||||
import type {NativeSyntheticEvent} from 'react-native';
|
||||
import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
||||
import type {EventSubscription, NativeSyntheticEvent} from 'react-native';
|
||||
|
||||
// Event types
|
||||
// We're not using the PaperName, it is only used to codegen view config settings
|
||||
|
||||
+1
-2
@@ -13,8 +13,7 @@ import {TypeScriptParser} from '@react-native/codegen/lib/parsers/typescript/par
|
||||
|
||||
test(`@rn/codegen should parse an empty TypeScript module`, () => {
|
||||
const tsInput = `
|
||||
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
||||
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
|
||||
import {TurboModuleRegistry, type TurboModule} from 'react-native';
|
||||
|
||||
export interface Spec extends TurboModule {}
|
||||
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
||||
|
||||
Reference in new issue
Block a user