Move React Native platform files back
These files are really only related to the platform itself and not the React integration so I'll move them back.
Sebastian Markbage committed
Mar 24, 2016 at 16:08 UTC
fe395def652b65847de3912d64181b24f96f70fe
7 files changed
-879
src/renderers/native/ReactIOS/YellowBox.js
deleted
-364
@@ -1,364 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule YellowBox
10
- * @flow
11
- */
12
-
13
-'use strict';
14
-
15
-const EventEmitter = require('EventEmitter');
16
-import type EmitterSubscription from 'EmitterSubscription';
17
-const Platform = require('Platform');
18
-const React = require('React');
19
-const StyleSheet = require('StyleSheet');
20
-
21
-const _warningEmitter = new EventEmitter();
22
-const _warningMap = new Map();
23
-
24
-/**
25
- * YellowBox renders warnings at the bottom of the app being developed.
26
- *
27
- * Warnings help guard against subtle yet significant issues that can impact the
28
- * quality of the app. This "in your face" style of warning allows developers to
29
- * notice and correct these issues as quickly as possible.
30
- *
31
- * By default, the warning box is enabled in `__DEV__`. Set the following flag
32
- * to disable it (and call `console.warn` to update any rendered <YellowBox>):
33
- *
34
- * console.disableYellowBox = true;
35
- * console.warn('YellowBox is disabled.');
36
- *
37
- * Warnings can be ignored programmatically by setting the array:
38
- *
39
- * console.ignoredYellowBox = ['Warning: ...'];
40
- *
41
- * Strings in `console.ignoredYellowBox` can be a prefix of the warning that
42
- * should be ignored.
43
- */
44
-
45
-if (__DEV__) {
46
- const {error, warn} = console;
47
- console.error = function() {
48
- error.apply(console, arguments);
49
- // Show yellow box for the `warning` module.
50
- if (typeof arguments[0] === 'string' &&
51
- arguments[0].startsWith('Warning: ')) {
52
- updateWarningMap.apply(null, arguments);
53
- }
54
- };
55
- console.warn = function() {
56
- warn.apply(console, arguments);
57
- updateWarningMap.apply(null, arguments);
58
- };
59
-}
60
-
61
-/**
62
- * Simple function for formatting strings.
63
- *
64
- * Replaces placeholders with values passed as extra arguments
65
- *
66
- * @param {string} format the base string
67
- * @param ...args the values to insert
68
- * @return {string} the replaced string
69
- */
70
-function sprintf(format, ...args) {
71
- var index = 0;
72
- return format.replace(/%s/g, match => args[index++]);
73
-}
74
-
75
-function updateWarningMap(format, ...args): void {
76
- const stringifySafe = require('stringifySafe');
77
-
78
- format = String(format);
79
- const argCount = (format.match(/%s/g) || []).length;
80
- const warning = [
81
- sprintf(format, ...args.slice(0, argCount)),
82
- ...args.slice(argCount).map(stringifySafe),
83
- ].join(' ');
84
-
85
- const count = _warningMap.has(warning) ? _warningMap.get(warning) : 0;
86
- _warningMap.set(warning, count + 1);
87
- _warningEmitter.emit('warning', _warningMap);
88
-}
89
-
90
-function isWarningIgnored(warning: string): boolean {
91
- return (
92
- Array.isArray(console.ignoredYellowBox) &&
93
- console.ignoredYellowBox.some(
94
- ignorePrefix => warning.startsWith(ignorePrefix)
95
- )
96
- );
97
-}
98
-
99
-const WarningRow = ({count, warning, onPress}) => {
100
- const Text = require('Text');
101
- const TouchableHighlight = require('TouchableHighlight');
102
- const View = require('View');
103
-
104
- const countText = count > 1 ?
105
- <Text style={styles.listRowCount}>{'(' + count + ') '}</Text> :
106
- null;
107
-
108
- return (
109
- <View style={styles.listRow}>
110
- <TouchableHighlight
111
- activeOpacity={0.5}
112
- onPress={onPress}
113
- style={styles.listRowContent}
114
- underlayColor="transparent">
115
- <Text style={styles.listRowText} numberOfLines={2}>
116
- {countText}
117
- {warning}
118
- </Text>
119
- </TouchableHighlight>
120
- </View>
121
- );
122
-};
123
-
124
-const WarningInspector = ({
125
- count,
126
- warning,
127
- onClose,
128
- onDismiss,
129
- onDismissAll,
130
-}) => {
131
- const ScrollView = require('ScrollView');
132
- const Text = require('Text');
133
- const TouchableHighlight = require('TouchableHighlight');
134
- const View = require('View');
135
-
136
- const countSentence =
137
- 'Warning encountered ' + count + ' time' + (count - 1 ? 's' : '') + '.';
138
-
139
- return (
140
- <TouchableHighlight
141
- activeOpacity={0.95}
142
- underlayColor={backgroundColor(0.8)}
143
- onPress={onClose}
144
- style={styles.inspector}>
145
- <View style={styles.inspectorContent}>
146
- <View style={styles.inspectorCount}>
147
- <Text style={styles.inspectorCountText}>{countSentence}</Text>
148
- </View>
149
- <ScrollView style={styles.inspectorWarning}>
150
- <Text style={styles.inspectorWarningText}>{warning}</Text>
151
- </ScrollView>
152
- <View style={styles.inspectorButtons}>
153
- <TouchableHighlight
154
- activeOpacity={0.5}
155
- onPress={onDismiss}
156
- style={styles.inspectorButton}
157
- underlayColor="transparent">
158
- <Text style={styles.inspectorButtonText}>
159
- Dismiss
160
- </Text>
161
- </TouchableHighlight>
162
- <TouchableHighlight
163
- activeOpacity={0.5}
164
- onPress={onDismissAll}
165
- style={styles.inspectorButton}
166
- underlayColor="transparent">
167
- <Text style={styles.inspectorButtonText}>
168
- Dismiss All
169
- </Text>
170
- </TouchableHighlight>
171
- </View>
172
- </View>
173
- </TouchableHighlight>
174
- );
175
-};
176
-
177
-class YellowBox extends React.Component {
178
- state: {
179
- inspecting: ?string;
180
- warningMap: Map;
181
- };
182
- _listener: ?EmitterSubscription;
183
-
184
- constructor(props: mixed, context: mixed) {
185
- super(props, context);
186
- this.state = {
187
- inspecting: null,
188
- warningMap: _warningMap,
189
- };
190
- this.dismissWarning = warning => {
191
- const {inspecting, warningMap} = this.state;
192
- if (warning) {
193
- warningMap.delete(warning);
194
- } else {
195
- warningMap.clear();
196
- }
197
- this.setState({
198
- inspecting: (warning && inspecting !== warning) ? inspecting : null,
199
- warningMap,
200
- });
201
- };
202
- }
203
-
204
- componentDidMount() {
205
- let scheduled = null;
206
- this._listener = _warningEmitter.addListener('warning', warningMap => {
207
- // Use `setImmediate` because warnings often happen during render, but
208
- // state cannot be set while rendering.
209
- scheduled = scheduled || setImmediate(() => {
210
- scheduled = null;
211
- this.setState({
212
- warningMap,
213
- });
214
- });
215
- });
216
- }
217
-
218
- componentWillUnmount() {
219
- if (this._listener) {
220
- this._listener.remove();
221
- }
222
- }
223
-
224
- render() {
225
- if (console.disableYellowBox || this.state.warningMap.size === 0) {
226
- return null;
227
- }
228
- const ScrollView = require('ScrollView');
229
- const View = require('View');
230
-
231
- const inspecting = this.state.inspecting;
232
- const inspector = inspecting !== null ?
233
- <WarningInspector
234
- count={this.state.warningMap.get(inspecting)}
235
- warning={inspecting}
236
- onClose={() => this.setState({inspecting: null})}
237
- onDismiss={() => this.dismissWarning(inspecting)}
238
- onDismissAll={() => this.dismissWarning(null)}
239
- /> :
240
- null;
241
-
242
- const rows = [];
243
- this.state.warningMap.forEach((count, warning) => {
244
- if (!isWarningIgnored(warning)) {
245
- rows.push(
246
- <WarningRow
247
- key={warning}
248
- count={count}
249
- warning={warning}
250
- onPress={() => this.setState({inspecting: warning})}
251
- onDismiss={() => this.dismissWarning(warning)}
252
- />
253
- );
254
- }
255
- });
256
-
257
- const listStyle = [
258
- styles.list,
259
- // Additional `0.4` so the 5th row can peek into view.
260
- {height: Math.min(rows.length, 4.4) * (rowGutter + rowHeight)},
261
- ];
262
- return (
263
- <View style={inspector ? styles.fullScreen : listStyle}>
264
- <ScrollView style={listStyle} scrollsToTop={false}>
265
- {rows}
266
- </ScrollView>
267
- {inspector}
268
- </View>
269
- );
270
- }
271
-}
272
-
273
-const backgroundColor = opacity => 'rgba(250, 186, 48, ' + opacity + ')';
274
-const textColor = 'white';
275
-const rowGutter = 1;
276
-const rowHeight = 46;
277
-
278
-var styles = StyleSheet.create({
279
- fullScreen: {
280
- backgroundColor: 'transparent',
281
- position: 'absolute',
282
- left: 0,
283
- right: 0,
284
- top: 0,
285
- bottom: 0,
286
- },
287
- inspector: {
288
- backgroundColor: backgroundColor(0.95),
289
- flex: 1,
290
- },
291
- inspectorContainer: {
292
- flex: 1,
293
- },
294
- inspectorButtons: {
295
- flexDirection: 'row',
296
- position: 'absolute',
297
- left: 0,
298
- right: 0,
299
- bottom: 0,
300
- },
301
- inspectorButton: {
302
- flex: 1,
303
- padding: 22,
304
- },
305
- inspectorButtonText: {
306
- color: textColor,
307
- fontSize: 14,
308
- opacity: 0.8,
309
- textAlign: 'center',
310
- },
311
- inspectorContent: {
312
- flex: 1,
313
- paddingTop: 5,
314
- },
315
- inspectorCount: {
316
- padding: 15,
317
- paddingBottom: 0,
318
- },
319
- inspectorCountText: {
320
- color: textColor,
321
- fontSize: 14,
322
- },
323
- inspectorWarning: {
324
- padding: 15,
325
- position: 'absolute',
326
- top: 39,
327
- bottom: 60,
328
- },
329
- inspectorWarningText: {
330
- color: textColor,
331
- fontSize: 16,
332
- fontWeight: '600',
333
- },
334
- list: {
335
- backgroundColor: 'transparent',
336
- position: 'absolute',
337
- left: 0,
338
- right: 0,
339
- bottom: 0,
340
- },
341
- listRow: {
342
- position: 'relative',
343
- backgroundColor: backgroundColor(0.95),
344
- flex: 1,
345
- height: rowHeight,
346
- marginTop: rowGutter,
347
- },
348
- listRowContent: {
349
- flex: 1,
350
- },
351
- listRowCount: {
352
- color: 'rgba(255, 255, 255, 0.5)',
353
- },
354
- listRowText: {
355
- color: textColor,
356
- position: 'absolute',
357
- left: 0,
358
- top: Platform.OS === 'android' ? 5 : 7,
359
- marginLeft: 15,
360
- marginRight: 15,
361
- },
362
-});
363
-
364
-module.exports = YellowBox;
src/renderers/native/ReactIOS/renderApplication.android.js
deleted
-139
@@ -1,139 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule renderApplication
10
- */
11
-
12
-'use strict';
13
-
14
-var Inspector = require('Inspector');
15
-var Portal = require('Portal');
16
-var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
17
-var React = require('React');
18
-var StyleSheet = require('StyleSheet');
19
-var Subscribable = require('Subscribable');
20
-var View = require('View');
21
-
22
-var invariant = require('fbjs/lib/invariant');
23
-
24
-var YellowBox = __DEV__ ? require('YellowBox') : null;
25
-
26
-// require BackAndroid so it sets the default handler that exits the app if no listeners respond
27
-require('BackAndroid');
28
-
29
-var AppContainer = React.createClass({
30
- mixins: [Subscribable.Mixin],
31
-
32
- getInitialState: function() {
33
- return {
34
- enabled: __DEV__,
35
- inspectorVisible: false,
36
- rootNodeHandle: null,
37
- rootImportanceForAccessibility: 'auto',
38
- };
39
- },
40
-
41
- toggleElementInspector: function() {
42
- this.setState({
43
- inspectorVisible: !this.state.inspectorVisible,
44
- rootNodeHandle: React.findNodeHandle(this.refs.main),
45
- });
46
- },
47
-
48
- componentDidMount: function() {
49
- this.addListenerOn(
50
- RCTDeviceEventEmitter,
51
- 'toggleElementInspector',
52
- this.toggleElementInspector
53
- );
54
-
55
- this._unmounted = false;
56
- },
57
-
58
- renderInspector: function() {
59
- return this.state.inspectorVisible ?
60
- <Inspector
61
- rootTag={this.props.rootTag}
62
- inspectedViewTag={this.state.rootNodeHandle}
63
- /> :
64
- null;
65
- },
66
-
67
- componentWillUnmount: function() {
68
- this._unmounted = true;
69
- },
70
-
71
- setRootAccessibility: function(modalVisible) {
72
- if (this._unmounted) {
73
- return;
74
- }
75
-
76
- this.setState({
77
- rootImportanceForAccessibility: modalVisible ? 'no-hide-descendants' : 'auto',
78
- });
79
- },
80
-
81
- render: function() {
82
- var RootComponent = this.props.rootComponent;
83
- var appView =
84
- <View
85
- ref="main"
86
- collapsable={!this.state.inspectorVisible}
87
- style={styles.appContainer}>
88
- <RootComponent
89
- {...this.props.initialProps}
90
- rootTag={this.props.rootTag}
91
- importantForAccessibility={this.state.rootImportanceForAccessibility}/>
92
- <Portal
93
- onModalVisibilityChanged={this.setRootAccessibility}/>
94
- </View>;
95
- let yellowBox = null;
96
- if (__DEV__) {
97
- yellowBox = <YellowBox />;
98
- }
99
- return this.state.enabled ?
100
- <View style={styles.appContainer}>
101
- {appView}
102
- {yellowBox}
103
- {this.renderInspector()}
104
- </View> :
105
- appView;
106
- }
107
-});
108
-
109
-function renderApplication<D, P, S>(
110
- RootComponent: ReactClass<P>,
111
- initialProps: P,
112
- rootTag: any
113
-) {
114
- invariant(
115
- rootTag,
116
- 'Expect to have a valid rootTag, instead got ', rootTag
117
- );
118
- React.render(
119
- <AppContainer
120
- rootComponent={RootComponent}
121
- initialProps={initialProps}
122
- rootTag={rootTag} />,
123
- rootTag
124
- );
125
-}
126
-
127
-var styles = StyleSheet.create({
128
- // This is needed so the application covers the whole screen
129
- // and therefore the contents of the Portal are not clipped.
130
- appContainer: {
131
- position: 'absolute',
132
- left: 0,
133
- top: 0,
134
- right: 0,
135
- bottom: 0,
136
- },
137
-});
138
-
139
-module.exports = renderApplication;
src/renderers/native/ReactIOS/renderApplication.ios.js
deleted
-96
@@ -1,96 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule renderApplication
10
- * @noflow
11
- */
12
-
13
-'use strict';
14
-
15
-var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
16
-var React = require('React');
17
-var StyleSheet = require('StyleSheet');
18
-var Subscribable = require('Subscribable');
19
-var View = require('View');
20
-
21
-var invariant = require('fbjs/lib/invariant');
22
-
23
-var Inspector = __DEV__ ? require('Inspector') : null;
24
-var YellowBox = __DEV__ ? require('YellowBox') : null;
25
-
26
-var AppContainer = React.createClass({
27
- mixins: [Subscribable.Mixin],
28
-
29
- getInitialState: function() {
30
- return { inspector: null };
31
- },
32
-
33
- toggleElementInspector: function() {
34
- var inspector = !__DEV__ || this.state.inspector
35
- ? null
36
- : <Inspector
37
- rootTag={this.props.rootTag}
38
- inspectedViewTag={React.findNodeHandle(this.refs.main)}
39
- />;
40
- this.setState({inspector});
41
- },
42
-
43
- componentDidMount: function() {
44
- this.addListenerOn(
45
- RCTDeviceEventEmitter,
46
- 'toggleElementInspector',
47
- this.toggleElementInspector
48
- );
49
- },
50
-
51
- render: function() {
52
- let yellowBox = null;
53
- if (__DEV__) {
54
- yellowBox = <YellowBox />;
55
- }
56
- return (
57
- <View style={styles.appContainer}>
58
- <View collapsible={false} style={styles.appContainer} ref="main">
59
- {this.props.children}
60
- </View>
61
- {yellowBox}
62
- {this.state.inspector}
63
- </View>
64
- );
65
- }
66
-});
67
-
68
-function renderApplication<D, P, S>(
69
- RootComponent: ReactClass<P>,
70
- initialProps: P,
71
- rootTag: any
72
-) {
73
- invariant(
74
- rootTag,
75
- 'Expect to have a valid rootTag, instead got ', rootTag
76
- );
77
- /* eslint-disable jsx-no-undef-with-namespace */
78
- React.render(
79
- <AppContainer rootTag={rootTag}>
80
- <RootComponent
81
- {...initialProps}
82
- rootTag={rootTag}
83
- />
84
- </AppContainer>,
85
- rootTag
86
- );
87
- /* eslint-enable jsx-no-undef-with-namespace */
88
-}
89
-
90
-var styles = StyleSheet.create({
91
- appContainer: {
92
- flex: 1,
93
- },
94
-});
95
-
96
-module.exports = renderApplication;
src/renderers/native/ReactIOS/requireNativeComponent.js
deleted
-127
@@ -1,127 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule requireNativeComponent
10
- * @flow
11
- */
12
-'use strict';
13
-
14
-var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
15
-var UIManager = require('UIManager');
16
-var UnimplementedView = require('UnimplementedView');
17
-
18
-var createReactNativeComponentClass = require('createReactNativeComponentClass');
19
-
20
-var insetsDiffer = require('insetsDiffer');
21
-var pointsDiffer = require('pointsDiffer');
22
-var matricesDiffer = require('matricesDiffer');
23
-var processColor = require('processColor');
24
-var resolveAssetSource = require('resolveAssetSource');
25
-var sizesDiffer = require('sizesDiffer');
26
-var verifyPropTypes = require('verifyPropTypes');
27
-var warning = require('fbjs/lib/warning');
28
-
29
-/**
30
- * Used to create React components that directly wrap native component
31
- * implementations. Config information is extracted from data exported from the
32
- * UIManager module. You should also wrap the native component in a
33
- * hand-written component with full propTypes definitions and other
34
- * documentation - pass the hand-written component in as `componentInterface` to
35
- * verify all the native props are documented via `propTypes`.
36
- *
37
- * If some native props shouldn't be exposed in the wrapper interface, you can
38
- * pass null for `componentInterface` and call `verifyPropTypes` directly
39
- * with `nativePropsToIgnore`;
40
- *
41
- * Common types are lined up with the appropriate prop differs with
42
- * `TypeToDifferMap`. Non-scalar types not in the map default to `deepDiffer`.
43
- */
44
-import type { ComponentInterface } from 'verifyPropTypes';
45
-
46
-function requireNativeComponent(
47
- viewName: string,
48
- componentInterface?: ?ComponentInterface,
49
- extraConfig?: ?{nativeOnly?: Object},
50
-): Function {
51
- var viewConfig = UIManager[viewName];
52
- if (!viewConfig || !viewConfig.NativeProps) {
53
- warning(false, 'Native component for "%s" does not exist', viewName);
54
- return UnimplementedView;
55
- }
56
- var nativeProps = {
57
- ...UIManager.RCTView.NativeProps,
58
- ...viewConfig.NativeProps,
59
- };
60
- viewConfig.uiViewClassName = viewName;
61
- viewConfig.validAttributes = {};
62
- viewConfig.propTypes = componentInterface && componentInterface.propTypes;
63
- for (var key in nativeProps) {
64
- var useAttribute = false;
65
- var attribute = {};
66
-
67
- var differ = TypeToDifferMap[nativeProps[key]];
68
- if (differ) {
69
- attribute.diff = differ;
70
- useAttribute = true;
71
- }
72
-
73
- var processor = TypeToProcessorMap[nativeProps[key]];
74
- if (processor) {
75
- attribute.process = processor;
76
- useAttribute = true;
77
- }
78
-
79
- viewConfig.validAttributes[key] = useAttribute ? attribute : true;
80
- }
81
-
82
- // Unfortunately, the current set up puts the style properties on the top
83
- // level props object. We also need to add the nested form for API
84
- // compatibility. This allows these props on both the top level and the
85
- // nested style level. TODO: Move these to nested declarations on the
86
- // native side.
87
- viewConfig.validAttributes.style = ReactNativeStyleAttributes;
88
-
89
- if (__DEV__) {
90
- componentInterface && verifyPropTypes(
91
- componentInterface,
92
- viewConfig,
93
- extraConfig && extraConfig.nativeOnly
94
- );
95
- }
96
- return createReactNativeComponentClass(viewConfig);
97
-}
98
-
99
-var TypeToDifferMap = {
100
- // iOS Types
101
- CATransform3D: matricesDiffer,
102
- CGPoint: pointsDiffer,
103
- CGSize: sizesDiffer,
104
- UIEdgeInsets: insetsDiffer,
105
- // Android Types
106
- // (not yet implemented)
107
-};
108
-
109
-function processColorArray(colors: []): [] {
110
- return colors && colors.map(processColor);
111
-}
112
-
113
-var TypeToProcessorMap = {
114
- // iOS Types
115
- CGColor: processColor,
116
- CGColorArray: processColorArray,
117
- UIColor: processColor,
118
- UIColorArray: processColorArray,
119
- CGImage: resolveAssetSource,
120
- UIImage: resolveAssetSource,
121
- RCTImageSource: resolveAssetSource,
122
- // Android Types
123
- Color: processColor,
124
- ColorArray: processColorArray,
125
-};
126
-
127
-module.exports = requireNativeComponent;
src/renderers/native/ReactIOS/verifyPropTypes.js
deleted
-61
@@ -1,61 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule verifyPropTypes
10
- * @flow
11
- */
12
-'use strict';
13
-
14
-var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
15
-
16
-export type ComponentInterface = ReactClass<any> | {
17
- name?: string;
18
- displayName?: string;
19
- propTypes: Object;
20
-};
21
-
22
-function verifyPropTypes(
23
- componentInterface: ComponentInterface,
24
- viewConfig: Object,
25
- nativePropsToIgnore?: ?Object
26
-) {
27
- if (!viewConfig) {
28
- return; // This happens for UnimplementedView.
29
- }
30
- var componentName = componentInterface.name ||
31
- componentInterface.displayName ||
32
- 'unknown';
33
- if (!componentInterface.propTypes) {
34
- throw new Error(
35
- '`' + componentName + '` has no propTypes defined`'
36
- );
37
- }
38
-
39
- var nativeProps = viewConfig.NativeProps;
40
- for (var prop in nativeProps) {
41
- if (!componentInterface.propTypes[prop] &&
42
- !ReactNativeStyleAttributes[prop] &&
43
- (!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
44
- var message;
45
- if (componentInterface.propTypes.hasOwnProperty(prop)) {
46
- message = '`' + componentName + '` has incorrectly defined propType for native prop `' +
47
- viewConfig.uiViewClassName + '.' + prop + '` of native type `' + nativeProps[prop];
48
- } else {
49
- message = '`' + componentName + '` has no propType for native prop `' +
50
- viewConfig.uiViewClassName + '.' + prop + '` of native type `' +
51
- nativeProps[prop] + '`';
52
- };
53
- message += '\nIf you haven\'t changed this prop yourself, this usually means that ' +
54
- 'your versions of the native code and JavaScript code are out of sync. Updating both ' +
55
- 'should make this error go away.';
56
- throw new Error(message);
57
- }
58
- }
59
-}
60
-
61
-module.exports = verifyPropTypes;
src/renderers/native/ReactNative/UIManagerStatTracker.js
deleted
-57
@@ -1,57 +0,0 @@
1
-/**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule UIManagerStatTracker
10
- * @flow
11
- */
12
-'use strict';
13
-
14
-var UIManager = require('UIManager');
15
-
16
-var installed = false;
17
-var UIManagerStatTracker = {
18
- install: function() {
19
- if (installed) {
20
- return;
21
- }
22
- installed = true;
23
- var statLogHandle;
24
- var stats = {};
25
- function printStats() {
26
- console.log({UIManagerStatTracker: stats});
27
- statLogHandle = null;
28
- }
29
- function incStat(key: string, increment: number) {
30
- stats[key] = (stats[key] || 0) + increment;
31
- if (!statLogHandle) {
32
- statLogHandle = setImmediate(printStats);
33
- }
34
- }
35
- var createViewOrig = UIManager.createView;
36
- UIManager.createView = function(tag, className, rootTag, props) {
37
- incStat('createView', 1);
38
- incStat('setProp', Object.keys(props || []).length);
39
- createViewOrig(tag, className, rootTag, props);
40
- };
41
- var updateViewOrig = UIManager.updateView;
42
- UIManager.updateView = function(tag, className, props) {
43
- incStat('updateView', 1);
44
- incStat('setProp', Object.keys(props || []).length);
45
- updateViewOrig(tag, className, props);
46
- };
47
- var manageChildrenOrig = UIManager.manageChildren;
48
- UIManager.manageChildren = function(tag, moveFrom, moveTo, addTags, addIndices, remove) {
49
- incStat('manageChildren', 1);
50
- incStat('move', Object.keys(moveFrom || []).length);
51
- incStat('remove', Object.keys(remove || []).length);
52
- manageChildrenOrig(tag, moveFrom, moveTo, addTags, addIndices, remove);
53
- };
54
- },
55
-};
56
-
57
-module.exports = UIManagerStatTracker;
src/renderers/native/vendor/react/core/clamp.js
deleted
-35
@@ -1,35 +0,0 @@
1
-/**
2
- * @generated SignedSource<<ec51291ea6059cf23faa74f8644d17b1>>
3
- *
4
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5
- * !! This file is a check-in of a static_upstream project! !!
6
- * !! !!
7
- * !! You should not modify this file directly. Instead: !!
8
- * !! 1) Use `fjs use-upstream` to temporarily replace this with !!
9
- * !! the latest version from upstream. !!
10
- * !! 2) Make your changes, test them, etc. !!
11
- * !! 3) Use `fjs push-upstream` to copy your changes back to !!
12
- * !! static_upstream. !!
13
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
- *
15
- * @providesModule clamp
16
- * @typechecks
17
- */
18
-
19
- /**
20
- * @param {number} value
21
- * @param {number} min
22
- * @param {number} max
23
- * @return {number}
24
- */
25
-function clamp(min, value, max) {
26
- if (value < min) {
27
- return min;
28
- }
29
- if (value > max) {
30
- return max;
31
- }
32
- return value;
33
-}
34
-
35
-module.exports = clamp;