mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
d504fb4145
Summary: Changelog: [Internal] - Remove all imports back to CJS for changelog in 0.72 We are reverting these imports as it may regress perf as we don't have a recommended inlining solution for ES modules at the current time. Reviewed By: NickGerleman Differential Revision: D43630911 fbshipit-source-id: ff3bb80009f327c4d51dad21f2cd287ce46d5964
111 lines
2.9 KiB
JavaScript
111 lines
2.9 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
const NOT_A_NATIVE_COMPONENT = `
|
|
const requireNativeComponent = require('requireNativeComponent').default;
|
|
|
|
export default 'Not a view config'
|
|
`;
|
|
|
|
const FULL_NATIVE_COMPONENT = `
|
|
// @flow
|
|
|
|
const codegenNativeCommands = require('codegenNativeCommands');
|
|
const codegenNativeComponent = require('codegenNativeComponent');
|
|
|
|
import type {
|
|
Int32,
|
|
BubblingEventHandler,
|
|
DirectEventHandler,
|
|
WithDefault,
|
|
} from 'CodegenFlowtypes';
|
|
import type {NativeComponentType} from 'codegenNativeComponent';
|
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
|
|
type ModuleProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
|
|
// Props
|
|
boolean_default_true_optional_both?: WithDefault<boolean, true>,
|
|
|
|
// Events
|
|
onDirectEventDefinedInlineNull: DirectEventHandler<null>,
|
|
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
|
|
|}>;
|
|
|
|
type NativeType = NativeComponentType<ModuleProps>;
|
|
|
|
interface NativeCommands {
|
|
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;
|
|
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void;
|
|
}
|
|
|
|
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
supportedCommands: ['hotspotUpdate', 'scrollTo'],
|
|
});
|
|
|
|
export default codegenNativeComponent<ModuleProps>('Module', {
|
|
interfaceOnly: true,
|
|
paperComponentName: 'RCTModule',
|
|
});
|
|
`;
|
|
|
|
const FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT = `
|
|
// @flow
|
|
|
|
const codegenNativeCommands = require('codegenNativeCommands');
|
|
const codegenNativeComponent = require('codegenNativeComponent');
|
|
import type {NativeComponentType} from 'codegenNativeComponent';
|
|
|
|
import type {
|
|
Int32,
|
|
BubblingEventHandler,
|
|
DirectEventHandler,
|
|
WithDefault,
|
|
} from 'CodegenFlowtypes';
|
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
|
|
type ModuleProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
|
|
// Props
|
|
boolean_default_true_optional_both?: WithDefault<boolean, true>,
|
|
|
|
// Events
|
|
onDirectEventDefinedInlineNull: DirectEventHandler<null>,
|
|
onBubblingEventDefinedInlineNull: BubblingEventHandler<null>,
|
|
|}>;
|
|
|
|
type NativeType = NativeComponentType<ModuleProps>;
|
|
|
|
interface NativeCommands {
|
|
+hotspotUpdate: (viewRef: React.ElementRef<NativeType>, x: Int32, y: Int32) => void;
|
|
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void;
|
|
}
|
|
|
|
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
supportedCommands: ['hotspotUpdate', 'scrollTo'],
|
|
});
|
|
|
|
export default (codegenNativeComponent<ModuleProps>('Module', {
|
|
interfaceOnly: true,
|
|
paperComponentName: 'RCTModule',
|
|
}): NativeType);
|
|
`;
|
|
|
|
module.exports = {
|
|
'NotANativeComponent.js': NOT_A_NATIVE_COMPONENT,
|
|
'FullNativeComponent.js': FULL_NATIVE_COMPONENT,
|
|
'FullTypedNativeComponent.js': FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT,
|
|
};
|