Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move React Core Integration and Injection to the Core Repo #6338

Merged
merged 20 commits into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f463b73
Copy files from the react-native repo
sebmarkbage Mar 24, 2016
6c885d2
Remove duplicates and move files out of native/vendor
sebmarkbage Mar 24, 2016
fe395de
Move React Native platform files back
sebmarkbage Mar 24, 2016
8806463
Add Object Spread Support to Our Babel Config
sebmarkbage Mar 24, 2016
caa6aba
Build an dedicated npm package for react-native-renderer
sebmarkbage Aug 12, 2015
240dfae
Add React Native Modules to module map + fix fbjs
sebmarkbage Mar 25, 2016
91e62c7
Strip isomorphic stuff from the ReactNative module
sebmarkbage Aug 12, 2015
d8e8ea5
Add test and mocks
sebmarkbage Mar 25, 2016
f833516
Fix 0.15 compatibility
sebmarkbage Mar 25, 2016
97b079b
Fix ReactNativeComponentEnvironment providesModule
sebmarkbage Mar 25, 2016
75cec60
Get rid of rootNodeIDs they're just tags now
sebmarkbage Mar 29, 2016
3287d93
Build up a native component cache for event dispatching
sebmarkbage Mar 30, 2016
4fcdf02
Listeners are not attached by ID in the API
sebmarkbage Apr 5, 2016
dc188dd
Update ReactNativeDOMIDOperations to deal with a single parent node
sebmarkbage Apr 5, 2016
0640921
Bump package versions
sebmarkbage Apr 13, 2016
22a8f99
Don't try to get the target node for responder if there is no listener
sebmarkbage Apr 13, 2016
c7d90e2
Ensure react-native-renderer package gets copied
sebmarkbage Apr 13, 2016
5470972
Update devtools injection
sebmarkbage Apr 18, 2016
744548a
Fix lint for moved ReactNative
sebmarkbage Apr 18, 2016
ada60c4
Remove ReactDOM.native shim
sebmarkbage Apr 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix lint for moved ReactNative
  • Loading branch information
sebmarkbage committed Apr 20, 2016
commit 744548ad143b7350e7e1d7d39e72bf2f4108fee6
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

var IOSDefaultEventPluginOrder = [
'ResponderEventPlugin',
'IOSNativeBridgeEventPlugin'
'IOSNativeBridgeEventPlugin',
];

module.exports = IOSDefaultEventPluginOrder;
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var IOSNativeBridgeEventPlugin = {
return null;
}
return event;
}
},
};

module.exports = IOSNativeBridgeEventPlugin;
8 changes: 4 additions & 4 deletions src/renderers/native/ReactIOS/NativeMethodsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ var NativeMethodsMixin = {
*/
blur: function() {
TextInputState.blurTextInput(findNodeHandle(this));
}
},
};

function throwOnStylesProp(component, props) {
Expand All @@ -195,10 +195,10 @@ if (__DEV__) {
!NativeMethodsMixin_DEV.componentWillReceiveProps,
'Do not override existing functions.'
);
NativeMethodsMixin_DEV.componentWillMount = function () {
NativeMethodsMixin_DEV.componentWillMount = function() {
throwOnStylesProp(this, this.props);
};
NativeMethodsMixin_DEV.componentWillReceiveProps = function (newProps) {
NativeMethodsMixin_DEV.componentWillReceiveProps = function(newProps) {
throwOnStylesProp(this, newProps);
};
}
Expand All @@ -210,7 +210,7 @@ if (__DEV__) {
var mountSafeCallback = function(context: ReactComponent, callback: ?Function): any {
return function() {
if (!callback || (context.isMounted && !context.isMounted())) {
return;
return undefined;
}
return callback.apply(context, arguments);
};
Expand Down
12 changes: 0 additions & 12 deletions src/renderers/native/ReactNative/ReactNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
var ReactNativeComponentTree = require('ReactNativeComponentTree');
var ReactNativeDefaultInjection = require('ReactNativeDefaultInjection');

var ReactCurrentOwner = require('ReactCurrentOwner');
var ReactElement = require('ReactElement');
var ReactInstanceHandles = require('ReactInstanceHandles');
var ReactNativeMount = require('ReactNativeMount');
var ReactUpdates = require('ReactUpdates');

Expand All @@ -45,16 +43,6 @@ var ReactNative = {
/* eslint-enable camelcase */

unmountComponentAtNodeAndRemoveContainer: ReactNativeMount.unmountComponentAtNodeAndRemoveContainer,

// Deprecations (remove for 0.13)
renderComponent: function(
element: ReactElement,
mountInto: number,
callback?: ?(() => void)
): ?ReactComponent {
warning('Use React.render instead of React.renderComponent');
return ReactNative.render(element, mountInto, callback);
},
};

// Inject the runtime into a devtools global hook regardless of browser.
Expand Down
10 changes: 5 additions & 5 deletions src/renderers/native/ReactNative/ReactNativeAttributePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ function diffProperties(
defaultDiffer(prevProp, nextProp)
);
if (shouldUpdate) {
var nextValue = typeof attributeConfig.process === 'function' ?
attributeConfig.process(nextProp) :
nextProp;
nextValue = typeof attributeConfig.process === 'function' ?
attributeConfig.process(nextProp) :
nextProp;
(updatePayload || (updatePayload = {}))[altKey] = nextValue;
}
} else {
Expand All @@ -437,7 +437,7 @@ function diffProperties(
// Also iterate through all the previous props to catch any that have been
// removed and make sure native gets the signal so it can reset them to the
// default.
for (var propKey in prevProps) {
for (propKey in prevProps) {
if (nextProps[propKey] !== undefined) {
continue; // we've already covered this key in the previous pass
}
Expand Down Expand Up @@ -539,7 +539,7 @@ var ReactNativeAttributePayload = {
nextProps,
validAttributes
);
}
},

};

Expand Down
4 changes: 1 addition & 3 deletions src/renderers/native/ReactNative/ReactNativeBaseComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ var ReactMultiChild = require('ReactMultiChild');
var UIManager = require('UIManager');

var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev');
var invariant = require('invariant');
var warning = require('warning');

var registrationNames = ReactNativeEventEmitter.registrationNames;
var putListener = ReactNativeEventEmitter.putListener;
Expand Down Expand Up @@ -215,7 +213,7 @@ ReactNativeBaseComponent.Mixin = {
context
);
return tag;
}
},
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

function ReactNativeContainerInfo(tag) {
var info = {
_tag: tag
_tag: tag,
};
return info;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
'use strict';

var ReactNativeComponentTree = require('ReactNativeComponentTree');
var ReactNativeTagHandles = require('ReactNativeTagHandles');
var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
var ReactPerf = require('ReactPerf');
var UIManager = require('UIManager');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function inject() {
*/
EventPluginHub.injection.injectEventPluginsByName({
'ResponderEventPlugin': ResponderEventPlugin,
'IOSNativeBridgeEventPlugin': IOSNativeBridgeEventPlugin
'IOSNativeBridgeEventPlugin': IOSNativeBridgeEventPlugin,
});

ReactUpdates.injection.injectReconcileTransaction(
Expand All @@ -87,7 +87,7 @@ function inject() {
return new ReactSimpleEmptyComponent(
ReactElement.createElement(View, {
collapsable: true,
style: { position: 'absolute' }
style: { position: 'absolute' },
}),
instantiate
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ var ReactNativeEventEmitter = merge(ReactEventEmitterMixin, {
nativeEvent
);
}
}
},
});

module.exports = ReactNativeEventEmitter;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var ReactNativeGlobalInteractionHandler = {
} else if (!interactionHandle) {
interactionHandle = InteractionManager.createInteractionHandle();
}
}
},
};

module.exports = ReactNativeGlobalInteractionHandler;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
'use strict';

var ReactNativeTagHandles = require('ReactNativeTagHandles');
var UIManager = require('UIManager');

var ReactNativeGlobalResponderHandler = {
Expand All @@ -23,7 +22,7 @@ var ReactNativeGlobalResponderHandler = {
} else {
UIManager.clearJSResponder();
}
}
},
};

module.exports = ReactNativeGlobalResponderHandler;
4 changes: 2 additions & 2 deletions src/renderers/native/ReactNative/ReactNativeMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var ReactNativeMount = {

if (!ReactNativeTagHandles.reactTagIsNativeTopRootID(containerTag)) {
console.error('You cannot render into anything but a top root');
return;
return null;
}

ReactNativeTagHandles.assertRootTag(containerTag);
Expand Down Expand Up @@ -225,7 +225,7 @@ var ReactNativeMount = {
// Call back into native to remove all of the subviews from this container
ReactReconciler.unmountComponent(instance);
UIManager.removeSubviewsFromContainerWithID(containerID);
}
},

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var ON_DOM_READY_QUEUEING = {
*/
close: function() {
this.reactMountReady.notifyAll();
}
},
};

/**
Expand Down Expand Up @@ -88,7 +88,7 @@ var Mixin = {
destructor: function() {
CallbackQueue.release(this.reactMountReady);
this.reactMountReady = null;
}
},
};

Object.assign(
Expand Down
6 changes: 2 additions & 4 deletions src/renderers/native/ReactNative/ReactNativeTagHandles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
'use strict';

var invariant = require('invariant');
var warning = require('warning');

/**
* Keeps track of allocating and associating native "tags" which are numeric,
Expand All @@ -28,7 +27,6 @@ var warning = require('warning');
* unmount a component with a `rootNodeID`, then mount a new one in its place,
*/
var INITIAL_TAG_COUNT = 1;
var NATIVE_TOP_ROOT_ID_SEPARATOR = '{TOP_LEVEL}';
var ReactNativeTagHandles = {
tagsStartAt: INITIAL_TAG_COUNT,
tagCount: INITIAL_TAG_COUNT,
Expand All @@ -46,14 +44,14 @@ var ReactNativeTagHandles = {
assertRootTag: function(tag: number): void {
invariant(
this.reactTagIsNativeTopRootID(tag),
'Expect a native root tag, instead got ', tag
'Expect a native root tag, instead got %s', tag
);
},

reactTagIsNativeTopRootID: function(reactTag: number): bool {
// We reserve all tags that are 1 mod 10 for native root views
return reactTag % 10 === 1;
}
},
};

module.exports = ReactNativeTagHandles;
6 changes: 3 additions & 3 deletions src/renderers/native/ReactNative/ReactNativeTextComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Object.assign(ReactNativeTextComponent.prototype, {
// TODO: nativeParent should have this context already. Stop abusing context.
invariant(
context.isInAParentText,
'RawText "' + this._stringText + '" must be wrapped in an explicit ' +
'<Text> component.'
'RawText "%s" must be wrapped in an explicit <Text> component.',
this._stringText
);
this._nativeParent = nativeParent;
var tag = ReactNativeTagHandles.allocateTag();
Expand Down Expand Up @@ -74,7 +74,7 @@ Object.assign(ReactNativeTextComponent.prototype, {
this._currentElement = null;
this._stringText = null;
this._rootNodeID = null;
}
},

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ describe('ReactNativeAttributePayload', function() {

it('should do deep diffs of Objects by default', () => {
expect(diff(
{a: [1], b: {k: [3,4]}, c: {k: [4,4]} },
{a: [2], b: {k: [3,4]}, c: {k: [4,5]} },
{a: [1], b: {k: [3, 4]}, c: {k: [4, 4]} },
{a: [2], b: {k: [3, 4]}, c: {k: [4, 5]} },
{a: true, b: true, c: true}
)).toEqual({a: [2], c: {k: [4,5]}});
)).toEqual({a: [2], c: {k: [4, 5]}});
});

it('should work with undefined styles', () => {
Expand Down Expand Up @@ -222,10 +222,25 @@ describe('ReactNativeAttributePayload', function() {
// Note that if the property changes from one function to another, we don't
// need to send an update.
expect(diff(
{a: function() { return 1; }, b: function() { return 2; }, c: 3},
{b: function() { return 9; }, c: function() { return 3; }, },
{
a: function() {
return 1;
},
b: function() {
return 2;
},
c: 3,
},
{
b: function() {
return 9;
},
c: function() {
return 3;
},
},
{a: true, b: true, c: true}
)).toEqual({a: null, c: true});
});

});
});
1 change: 0 additions & 1 deletion src/renderers/native/ReactNative/findNodeHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

var ReactCurrentOwner = require('ReactCurrentOwner');
var ReactInstanceMap = require('ReactInstanceMap');
var ReactNativeTagHandles = require('ReactNativeTagHandles');

var invariant = require('invariant');
var warning = require('warning');
Expand Down
17 changes: 9 additions & 8 deletions src/renderers/shared/event/eventPlugins/PanResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @providesModule PanResponder
*/

"use strict";
'use strict';

var TouchHistoryMath = require('TouchHistoryMath');

Expand Down Expand Up @@ -320,25 +320,25 @@ var PanResponder = {
gestureState.y0 = currentCentroidY(e.touchHistory);
gestureState.dx = 0;
gestureState.dy = 0;
config.onPanResponderGrant && config.onPanResponderGrant(e, gestureState);
if (config.onPanResponderGrant) config.onPanResponderGrant(e, gestureState);
// TODO: t7467124 investigate if this can be removed
return config.onShouldBlockNativeResponder === undefined ? true :
config.onShouldBlockNativeResponder();
},

onResponderReject: function(e) {
config.onPanResponderReject && config.onPanResponderReject(e, gestureState);
if (config.onPanResponderReject) config.onPanResponderReject(e, gestureState);
},

onResponderRelease: function(e) {
config.onPanResponderRelease && config.onPanResponderRelease(e, gestureState);
if (config.onPanResponderRelease) config.onPanResponderRelease(e, gestureState);
PanResponder._initializeGestureState(gestureState);
},

onResponderStart: function(e) {
var touchHistory = e.touchHistory;
gestureState.numberActiveTouches = touchHistory.numberActiveTouches;
config.onPanResponderStart && config.onPanResponderStart(e, gestureState);
if (config.onPanResponderStart) config.onPanResponderStart(e, gestureState);
},

onResponderMove: function(e) {
Expand All @@ -351,18 +351,19 @@ var PanResponder = {
// Filter out any touch moves past the first one - we would have
// already processed multi-touch geometry during the first event.
PanResponder._updateGestureStateOnMove(gestureState, touchHistory);
config.onPanResponderMove && config.onPanResponderMove(e, gestureState);
if (config.onPanResponderMove) config.onPanResponderMove(e, gestureState);
},

onResponderEnd: function(e) {
var touchHistory = e.touchHistory;
gestureState.numberActiveTouches = touchHistory.numberActiveTouches;
config.onPanResponderEnd && config.onPanResponderEnd(e, gestureState);
if (config.onPanResponderEnd) config.onPanResponderEnd(e, gestureState);
},

onResponderTerminate: function(e) {
config.onPanResponderTerminate &&
if (config.onPanResponderTerminate) {
config.onPanResponderTerminate(e, gestureState);
}
PanResponder._initializeGestureState(gestureState);
},

Expand Down
Loading