Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions flow/react-native-host-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,35 @@ declare module 'UIManager' {
declare module 'View' {
declare var exports : typeof React$Component;
}

declare module 'RTManager' {
declare function createNode(
tag : number,
classType : string,
props : ?Object,
) : void;
declare function appendChildToDetachedParent(
parentTag : number,
childTag : number,
) : void;

declare function beginUpdates() : void;

declare function appendChild(
parentTag : number,
childTag : number,
) : void;
declare function prependChild(
childTag : number,
beforeTag : number,
) : void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No parentTag? (Is this inferred from the beforeTag?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

declare function deleteChild(
childTag : number,
) : void;
declare function updateNode(
tag : number,
props : ?Object,
) : void;

declare function completeUpdates() : void;
}
34 changes: 34 additions & 0 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,40 @@ const bundles = [
useFiber: true,
},

/******* React Native *******/
{
babelOpts: babelOptsReact,
bundleTypes: [RN_DEV, RN_PROD],
config: {
destDir: 'build/',
moduleName: 'ReactNativeRTFiber',
sourceMap: false,
},
entry: 'src/renderers/native-rt/ReactNativeRTFiberEntry',
externals: [
'ExceptionsManager',
'InitializeCore',
'Platform',
'RCTEventEmitter',
'RTManager',
'prop-types/checkPropTypes',
],
hasteName: 'ReactNativeRTFiber',
isRenderer: true,
label: 'native-rt-fiber',
manglePropertiesOnProd: false,
name: 'react-native-rt-renderer',
paths: [
'src/renderers/native/**/*.js', // This is used since we reuse the error dialog code
'src/renderers/native-rt/**/*.js',
'src/renderers/shared/**/*.js',

'src/ReactVersion.js',
'src/shared/**/*.js',
],
useFiber: true,
},

/******* React Test Renderer *******/
{
babelOpts: babelOptsReact,
Expand Down
62 changes: 35 additions & 27 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@
"gzip": 6703
},
"react-dom.development.js (UMD_DEV)": {
"size": 613875,
"gzip": 141842
"size": 614249,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update this file or leave it until the next release we build?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really matter. :-)

"gzip": 141958
},
"react-dom.production.min.js (UMD_PROD)": {
"size": 99469,
"gzip": 31443
"size": 99500,
"gzip": 31459
},
"react-dom.development.js (NODE_DEV)": {
"size": 576136,
"gzip": 133165
"size": 576510,
"gzip": 133279
},
"react-dom.production.min.js (NODE_PROD)": {
"size": 104422,
"gzip": 32815
"size": 104453,
"gzip": 32832
},
"ReactDOMFiber-dev.js (FB_DEV)": {
"size": 573085,
"gzip": 132629
"size": 573391,
"gzip": 132712
},
"ReactDOMFiber-prod.js (FB_PROD)": {
"size": 409433,
"gzip": 91568
"size": 409575,
"gzip": 91600
},
"react-dom-test-utils.development.js (NODE_DEV)": {
"size": 41660,
Expand Down Expand Up @@ -81,36 +81,36 @@
"gzip": 15465
},
"react-dom-server.browser.development.js (UMD_DEV)": {
"size": 129517,
"gzip": 33434
"size": 129604,
"gzip": 33468
},
"react-dom-server.browser.production.min.js (UMD_PROD)": {
"size": 14948,
"gzip": 5844
"size": 14959,
"gzip": 5848
},
"react-dom-server.browser.development.js (NODE_DEV)": {
"size": 99439,
"gzip": 26329
"size": 99526,
"gzip": 26362
},
"react-dom-server.browser.production.min.js (NODE_PROD)": {
"size": 14878,
"size": 14889,
"gzip": 5844
},
"ReactDOMServer-dev.js (FB_DEV)": {
"size": 98860,
"gzip": 26238
"size": 98947,
"gzip": 26272
},
"ReactDOMServer-prod.js (FB_PROD)": {
"size": 42180,
"gzip": 11786
"size": 42275,
"gzip": 11813
},
"react-dom-server.node.development.js (NODE_DEV)": {
"size": 101717,
"gzip": 26882
"size": 101804,
"gzip": 26916
},
"react-dom-server.node.production.min.js (NODE_PROD)": {
"size": 15803,
"gzip": 6168
"size": 15814,
"gzip": 6172
},
"react-art.development.js (UMD_DEV)": {
"size": 366731,
Expand Down Expand Up @@ -187,6 +187,14 @@
"react-dom-node-stream.production.min.js (NODE_PROD)": {
"size": 19585,
"gzip": 7520
},
"ReactNativeRTFiber-dev.js (RN_DEV)": {
"size": 218534,
"gzip": 37944
},
"ReactNativeRTFiber-prod.js (RN_PROD)": {
"size": 167912,
"gzip": 28774
}
}
}
26 changes: 26 additions & 0 deletions src/__mocks__/RTManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

// Mock of the Native Hooks

var RCTRTManager = {
createNode: jest.fn(function createView(tag, classType, props) {}),
appendChildToDetachedParent: jest.fn(function appendChildToDetachedParent(
parentTag,
childTag,
) {}),
beginUpdates: jest.fn(function beginUpdates() {}),
appendChild: jest.fn(function appendChild(parentTag, childTag) {}),
prependChild: jest.fn(function prependChild(childTag, beforeTag) {}),
deleteChild: jest.fn(function deleteChild(childTag) {}),
updateNode: jest.fn(function updateNode(tag, props) {}),
completeUpdates: jest.fn(function completeUpdates() {}),
};

module.exports = RCTRTManager;
47 changes: 47 additions & 0 deletions src/renderers/native-rt/ReactNativeRTComponentTree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ReactNativeRTComponentTree
* @flow
*/

'use strict';

import type {Fiber} from 'ReactFiber';

var instanceCache: {[key: number]: Fiber} = {};
var instanceProps: {[key: number]: Object} = {};

function precacheFiberNode(fiber: Fiber, tag: number): void {
instanceCache[tag] = fiber;
}

function getFiberFromTag(tag: number): null | Fiber {
return instanceCache[tag] || null;
}

function uncacheFiberNode(tag: number): void {
delete instanceCache[tag];
delete instanceProps[tag];
}

function getFiberCurrentPropsFromTag(tag: number): null | Object {
return instanceProps[tag] || null;
}

function updateFiberProps(tag: number, props: Object): void {
instanceProps[tag] = props;
}

var ReactNativeRTComponentTree = {
precacheFiberNode,
uncacheFiberNode,
getFiberFromTag,
getFiberCurrentPropsFromTag,
updateFiberProps,
};

module.exports = ReactNativeRTComponentTree;
45 changes: 45 additions & 0 deletions src/renderers/native-rt/ReactNativeRTEventEmitter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule ReactNativeRTEventEmitter
* @flow
*/
'use strict';

var ReactNativeRTComponentTree = require('ReactNativeRTComponentTree');
var ReactGenericBatching = require('ReactGenericBatching');

var ReactNativeRTEventEmitter = {
/**
* Publicly exposed method on module for native objc to invoke when a top
* level event is extracted.
* @param {rootNodeID} rootNodeID React root node ID that event occurred on.
* @param {TopLevelType} topLevelType Top level type of event.
* @param {object} nativeEventParam Object passed from native.
*/
receiveEvent: function(
rootNodeID: number,
topLevelType: string,
nativeEventParam: Object,
) {
var nativeEvent = nativeEventParam;
var props = ReactNativeRTComponentTree.getFiberCurrentPropsFromTag(
rootNodeID,
);
if (props == null) {
return;
}
var eventHandler = props[topLevelType];
if (typeof eventHandler !== 'function') {
return;
}
ReactGenericBatching.batchedUpdates(function() {
eventHandler(nativeEvent);
});
},
};

module.exports = ReactNativeRTEventEmitter;
Loading