Updates from Wed July 15th

This commit is contained in:
Spencer Ahrens 2015-07-15 19:05:08 +02:00
commit 902ffbbfb8
54 changed files with 632 additions and 573 deletions

View File

@ -21,10 +21,41 @@ var {
StyleSheet,
Text,
View,
ActivityIndicatorIOS
} = React;
var ImageCapInsetsExample = require('./ImageCapInsetsExample');
var NetworkImageExample = React.createClass({
watchID: (null: ?number),
getInitialState: function() {
return {
error: false,
loading: true,
progress: 0
};
},
render: function() {
var loader = this.state.loading ?
<View style={styles.progress}>
<Text>{this.state.progress}%</Text>
<ActivityIndicatorIOS style={{marginLeft:5}}/>
</View> : null;
return this.state.error ?
<Text>{this.state.error}</Text> :
<Image
source={this.props.source}
style={[styles.base, {overflow: 'visible'}]}
onLoadError={(e) => this.setState({error: e.nativeEvent.error})}
onLoadProgress={(e) => this.setState({progress: Math.max(0, Math.round(100 * e.nativeEvent.written / e.nativeEvent.total))}) }
onLoadEnd={() => this.setState({loading: false, error: false})}
onLoadAbort={() => this.setState({error: 'Loading has aborted'})} >
{loader}
</Image>;
}
});
exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '<Image>';
@ -59,6 +90,22 @@ exports.examples = [
);
},
},
{
title: 'Error Handler',
render: function() {
return (
<NetworkImageExample source={{uri: 'http://TYPO_ERROR_facebook.github.io/react/img/logo_og.png'}} />
);
},
},
{
title: 'Image Download Progress',
render: function() {
return (
<NetworkImageExample source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1'}}/>
);
},
},
{
title: 'Border Color',
render: function() {
@ -300,6 +347,12 @@ var styles = StyleSheet.create({
width: 38,
height: 38,
},
progress: {
flex: 1,
alignItems: 'center',
flexDirection: 'row',
width: 100
},
leftMargin: {
marginLeft: 10,
},

View File

@ -369,25 +369,6 @@ exports.examples = [
</View>
);
},
}, {
title: 'allowFontScaling attribute',
render: function() {
return (
<View>
<Text>
By default, text will respect Text Size accessibility setting on iOS.
It means that all font sizes will be increased or descreased depending on the value of Text Size setting in
{" "}<Text style={{fontWeight: 'bold'}}>Settings.app - Display & Brightness - Text Size</Text>
</Text>
<Text style={{marginTop: 10}}>
You can disable scaling for your Text component by passing {"\""}allowFontScaling={"{"}false{"}\""} prop.
</Text>
<Text allowFontScaling={false} style={{marginTop: 20}}>
This text will not scale.
</Text>
</View>
);
},
}];
var styles = StyleSheet.create({

View File

@ -1,61 +1,85 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* @providesModule TransformExample
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
'use strict';
var React = require('React');
var React = require('react-native');
var {
Animated,
StyleSheet,
Text,
View,
} = React;
var TimerMixin = require('react-timer-mixin');
var UIExplorerBlock = require('./UIExplorerBlock');
var UIExplorerPage = require('./UIExplorerPage');
var TransformExample = React.createClass({
mixins: [TimerMixin],
var Flip = React.createClass({
getInitialState() {
return {
interval: this.setInterval(this._update, 800),
pulse: false,
theta: new Animated.Value(45),
};
},
componentDidMount() {
this._animate();
},
_animate() {
this.state.theta.setValue(0);
Animated.timing(this.state.theta, {
toValue: 360,
duration: 5000,
}).start(this._animate);
},
render() {
return (
<UIExplorerPage title="Transforms">
<UIExplorerBlock title="foo bar">
<View style={{height: 500}}>
<View style={styles.box1} />
<View style={styles.box2} />
<View style={styles.box3step1} />
<View style={styles.box3step2} />
<View style={styles.box3step3} />
<View style={styles.box4} />
<View style={[
styles.box5,
this.state.pulse ? styles.box5Transform : null
]} />
<View style={styles.flipCardContainer}>
<Animated.View style={[
styles.flipCard,
{transform: [
{perspective: 850},
{rotateX: this.state.theta.interpolate({
inputRange: [0, 180],
outputRange: ['0deg', '180deg']
})},
]}]}>
<Text style={styles.flipText}>
This text is flipping great.
</Text>
</Animated.View>
<Animated.View style={[styles.flipCard, {
position: 'absolute',
top: 0,
backgroundColor: 'red',
transform: [
{perspective: 850},
{rotateX: this.state.theta.interpolate({
inputRange: [0, 180],
outputRange: ['180deg', '360deg']
})},
]}]}>
<Text style={styles.flipText}>
On the flip side...
</Text>
</Animated.View>
</View>
</UIExplorerBlock>
</UIExplorerPage>
);
},
_update() {
this.setState({
pulse: !this.state.pulse,
});
},
}
});
var styles = StyleSheet.create({
container: {
height: 500,
},
box1: {
left: 0,
backgroundColor: 'green',
@ -88,7 +112,7 @@ var styles = StyleSheet.create({
},
box3step1: {
left: 0,
backgroundColor: '#ffb6c1', // lightpink
backgroundColor: 'lightpink',
height: 50,
position: 'absolute',
top: 0,
@ -99,7 +123,7 @@ var styles = StyleSheet.create({
},
box3step2: {
left: 0,
backgroundColor: '#ff69b4', //hotpink
backgroundColor: 'hotpink',
height: 50,
opacity: 0.5,
position: 'absolute',
@ -113,7 +137,7 @@ var styles = StyleSheet.create({
},
box3step3: {
left: 0,
backgroundColor: '#ff1493', // deeppink
backgroundColor: 'deeppink',
height: 50,
opacity: 0.5,
position: 'absolute',
@ -129,7 +153,7 @@ var styles = StyleSheet.create({
},
box4: {
left: 0,
backgroundColor: '#ff8c00', // darkorange
backgroundColor: 'darkorange',
height: 50,
position: 'absolute',
top: 0,
@ -141,7 +165,7 @@ var styles = StyleSheet.create({
width: 100,
},
box5: {
backgroundColor: '#800000', // maroon
backgroundColor: 'maroon',
height: 50,
position: 'absolute',
right: 0,
@ -155,7 +179,110 @@ var styles = StyleSheet.create({
{scale: 2},
],
},
flipCardContainer: {
marginVertical: 40,
flex: 1,
alignSelf: 'center',
},
flipCard: {
width: 200,
height: 200,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'blue',
backfaceVisibility: 'hidden',
},
flipText: {
width: 90,
fontSize: 20,
color: 'white',
fontWeight: 'bold',
}
});
module.exports = TransformExample;
exports.title = 'Transforms';
exports.description = 'View transforms';
exports.examples = [
{
title: 'Perspective',
description: 'perspective: 850, rotateX: Animated.timing(0 -> 360)',
render(): ReactElement { return <Flip />; }
},
{
title: 'Translate, Rotate, Scale',
description: "translateX: 100, translateY: 50, rotate: '30deg', scaleX: 2, scaleY: 2",
render() {
return (
<View style={styles.container}>
<View style={styles.box1} />
</View>
);
}
},
{
title: 'Scale, Translate, Rotate, ',
description: "scaleX: 2, scaleY: 2, translateX: 100, translateY: 50, rotate: '30deg'",
render() {
return (
<View style={styles.container}>
<View style={styles.box2} />
</View>
);
}
},
{
title: 'Rotate',
description: "rotate: '30deg'",
render() {
return (
<View style={styles.container}>
<View style={styles.box3step1} />
</View>
);
}
},
{
title: 'Rotate, Scale',
description: "rotate: '30deg', scaleX: 2, scaleY: 2",
render() {
return (
<View style={styles.container}>
<View style={styles.box3step2} />
</View>
);
}
},
{
title: 'Rotate, Scale, Translate ',
description: "rotate: '30deg', scaleX: 2, scaleY: 2, translateX: 100, translateY: 50",
render() {
return (
<View style={styles.container}>
<View style={styles.box3step3} />
</View>
);
}
},
{
title: 'Translate, Scale, Rotate',
description: "translate: [200, 350], scale: 2.5, rotate: '-0.2rad'",
render() {
return (
<View style={styles.container}>
<View style={styles.box4} />
</View>
);
}
},
{
title: 'Translate, Rotate, Scale',
description: "translate: [-50, 35], rotate: '50deg', scale: 2",
render() {
return (
<View style={styles.container}>
<View style={[styles.box5, styles.box5Transform]} />
</View>
);
}
}
];

View File

@ -43,7 +43,7 @@
* Load from pre-bundled file on disk. To re-generate the static bundle, `cd`
* to your Xcode project folder and run
*
* $ curl 'http://localhost:8081/Examples/UIExplorer/UIExplorerApp.includeRequire.runModule.bundle' -o main.jsbundle
* $ curl 'http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.includeRequire.runModule.bundle' -o main.jsbundle
*
* then add the `main.jsbundle` file to your project and uncomment this line:
*/

View File

@ -80,6 +80,7 @@ if (Platform.OS === 'ios') {
require('./AlertIOSExample'),
require('./AppStateIOSExample'),
require('./AsyncStorageExample'),
require('./TransformExample'),
require('./BorderExample'),
require('./CameraRollExample.ios'),
require('./NetInfoExample'),

View File

@ -24,7 +24,7 @@
@property (nonatomic, strong, readonly) RCTBridge *batchedBridge;
- (void)_handleBuffer:(id)buffer context:(NSNumber *)context;
- (void)_handleBuffer:(id)buffer;
- (void)setUp;
@end
@ -57,7 +57,6 @@ RCT_EXPORT_MODULE()
- (void)executeJSCall:(__unused NSString *)name
method:(__unused NSString *)method
arguments:(__unused NSArray *)arguments
context:(__unused NSNumber *)executorID
callback:(RCTJavaScriptCallback)onComplete
{
onComplete(nil, nil);
@ -155,7 +154,7 @@ RCT_EXPORT_MODULE(TestModule)
NSArray *args = @[@1234, @5678, @"stringy", @{@"a": @1}, @42];
NSArray *buffer = @[@[testModuleID], @[testMethodID], @[args], @[], @1234567];
[_bridge.batchedBridge _handleBuffer:buffer context:RCTGetExecutorID(executor)];
[_bridge.batchedBridge _handleBuffer:buffer];
dispatch_sync(_methodQueue, ^{
// clear the queue

View File

@ -33,7 +33,6 @@
{
[super setUp];
_executor = [[RCTContextExecutor alloc] init];
RCTSetExecutorID(_executor);
[_executor setUp];
}
@ -139,7 +138,6 @@ static uint64_t _get_time_nanoseconds(void)
[_executor executeJSCall:@"module"
method:@"method"
arguments:params
context:RCTGetExecutorID(_executor)
callback:^(id json, __unused NSError *unused) {
XCTAssert([json isEqual:@YES], @"Invalid return");
}];

View File

@ -87,7 +87,7 @@ RCT_ENUM_CONVERTER(CTTextAlignment, (@{
}
NSDictionary *fontDict = dict[@"font"];
CTFontRef font = (__bridge CTFontRef)[self UIFont:nil withFamily:fontDict[@"fontFamily"] size:fontDict[@"fontSize"] weight:fontDict[@"fontWeight"] style:fontDict[@"fontStyle"] scaleMultiplier:1.0];
CTFontRef font = (__bridge CTFontRef)[self UIFont:nil withFamily:fontDict[@"fontFamily"] size:fontDict[@"fontSize"] weight:fontDict[@"fontWeight"] style:fontDict[@"fontStyle"]];
if (!font) {
return frame;
}

View File

@ -411,7 +411,7 @@ var TextInput = React.createClass({
_renderIOS: function() {
var textContainer;
var props = this.props;
var props = Object.assign({},this.props);
props.style = [styles.input, this.props.style];
if (!props.multiline) {

View File

@ -21,6 +21,7 @@ var TransformPropTypes = require('TransformPropTypes');
var ViewStylePropTypes = {
...LayoutPropTypes,
...TransformPropTypes,
backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']),
backgroundColor: ReactPropTypes.string,
borderColor: ReactPropTypes.string,
borderTopColor: ReactPropTypes.string,

View File

@ -220,11 +220,6 @@ var Navigator = React.createClass({
*/
onDidFocus: PropTypes.func,
/**
* Will be called with (ref, indexInStack, route) when the scene ref changes
*/
onItemRef: PropTypes.func,
/**
* Optionally provide a navigation bar that persists across scene
* transitions
@ -318,7 +313,6 @@ var Navigator = React.createClass({
onPanResponderMove: this._handlePanResponderMove,
onPanResponderTerminate: this._handlePanResponderTerminate,
});
this._itemRefs = {};
this._interactionHandle = null;
this._emitWillFocus(this.state.routeStack[this.state.presentedIndex]);
},
@ -1006,22 +1000,10 @@ var Navigator = React.createClass({
return this.state.routeStack.slice();
},
_handleItemRef: function(itemId, route, ref) {
this._itemRefs[itemId] = ref;
var itemIndex = this.state.idStack.indexOf(itemId);
if (itemIndex === -1) {
return;
}
this.props.onItemRef && this.props.onItemRef(ref, itemIndex, route);
},
_cleanScenesPastIndex: function(index) {
var newStackLength = index + 1;
// Remove any unneeded rendered routes.
if (newStackLength < this.state.routeStack.length) {
this.state.idStack.slice(newStackLength).map((removingId) => {
this._itemRefs[removingId] = null;
});
this.setState({
sceneConfigStack: this.state.sceneConfigStack.slice(0, newStackLength),
idStack: this.state.idStack.slice(0, newStackLength),
@ -1031,38 +1013,22 @@ var Navigator = React.createClass({
},
_renderScene: function(route, i) {
var child = this.props.renderScene(
route,
this
);
var disabledSceneStyle = null;
if (i !== this.state.presentedIndex) {
disabledSceneStyle = styles.disabledScene;
}
var originalRef = child.ref;
if (originalRef != null && typeof originalRef !== 'function') {
console.warn(
'String refs are not supported for navigator scenes. Use a callback ' +
'ref instead. Ignoring ref: ' + originalRef
);
originalRef = null;
}
return (
<View
key={this.state.idStack[i]}
key={'scene_' + i}
ref={'scene_' + i}
onStartShouldSetResponderCapture={() => {
return (this.state.transitionFromIndex != null) || (this.state.transitionFromIndex != null);
}}
style={[styles.baseScene, this.props.sceneStyle, disabledSceneStyle]}>
{React.cloneElement(child, {
ref: component => {
this._handleItemRef(this.state.idStack[i], route, component);
if (originalRef) {
originalRef(component);
}
}
})}
{this.props.renderScene(
route,
this
)}
</View>
);
},

View File

@ -66,7 +66,6 @@ static void *const RCTDownloadTaskWrapperProgressBlockKey = (void *)&RCTDownload
task.rct_completionBlock = completionBlock;
task.rct_progressBlock = progressBlock;
[task resume];
return task;
}

View File

@ -14,7 +14,8 @@
#import "RCTLog.h"
#import "RCTUtils.h"
typedef void (^RCTCachedDataDownloadBlock)(BOOL cached, NSData *data, NSError *error);
typedef void (^RCTCachedDataDownloadBlock)(BOOL cached, NSURLResponse *response,
NSData *data, NSError *error);
CGSize RCTTargetSizeForClipRect(CGRect);
CGRect RCTClipRect(CGSize, CGFloat, CGSize, CGFloat, UIViewContentMode);
@ -80,24 +81,36 @@ CGRect RCTClipRect(CGSize, CGFloat, CGSize, CGFloat, UIViewContentMode);
_pendingBlocks[cacheKey] = [NSMutableArray arrayWithObject:block];
__weak RCTImageDownloader *weakSelf = self;
RCTCachedDataDownloadBlock runBlocks = ^(BOOL cached, NSData *data, NSError *error) {
RCTCachedDataDownloadBlock runBlocks = ^(BOOL cached, NSURLResponse *response, NSData *data, NSError *error) {
if (!error && [response isKindOfClass:[NSHTTPURLResponse class]]) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if (httpResponse.statusCode != 200) {
data = nil;
error = [[NSError alloc] initWithDomain:NSURLErrorDomain
code:httpResponse.statusCode
userInfo:nil];
}
}
dispatch_async(_processingQueue, ^{
RCTImageDownloader *strongSelf = weakSelf;
NSArray *blocks = strongSelf->_pendingBlocks[cacheKey];
[strongSelf->_pendingBlocks removeObjectForKey:cacheKey];
for (RCTCachedDataDownloadBlock downloadBlock in blocks) {
downloadBlock(cached, data, error);
downloadBlock(cached, response, data, error);
}
});
};
NSURLRequest *request = [NSURLRequest requestWithURL:url];
task = [_downloadTaskWrapper downloadData:url progressBlock:progressBlock completionBlock:^(NSURLResponse *response, NSData *data, NSError *error) {
if (!cancelled) {
runBlocks(NO, data, error);
runBlocks(NO, response, data, error);
}
if (response) {
if (response && !error) {
RCTImageDownloader *strongSelf = weakSelf;
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data userInfo:nil storagePolicy:NSURLCacheStorageAllowed];
[strongSelf->_cache storeCachedResponse:cachedResponse forRequest:request];
@ -111,7 +124,7 @@ CGRect RCTClipRect(CGSize, CGFloat, CGSize, CGFloat, UIViewContentMode);
}
if (cachedResponse) {
runBlocks(YES, cachedResponse.data, nil);
runBlocks(YES, cachedResponse.response, cachedResponse.data, nil);
} else {
[task resume];
}
@ -123,7 +136,7 @@ CGRect RCTClipRect(CGSize, CGFloat, CGSize, CGFloat, UIViewContentMode);
- (RCTImageDownloadCancellationBlock)downloadDataForURL:(NSURL *)url progressBlock:(RCTDataProgressBlock)progressBlock block:(RCTDataDownloadBlock)block
{
return [self _downloadDataForURL:url progressBlock:progressBlock block:^(BOOL cached, NSData *data, NSError *error) {
return [self _downloadDataForURL:url progressBlock:progressBlock block:^(BOOL cached, NSURLResponse *response, NSData *data, NSError *error) {
block(data, error);
}];
}

View File

@ -86,6 +86,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
{
if (![_imageURL isEqual:imageURL] && _downloadToken) {
[_imageDownloader cancelDownload:_downloadToken];
NSDictionary *event = @{ @"target": self.reactTag };
[_eventDispatcher sendInputEventWithName:@"loadAbort" body:event];
_downloadToken = nil;
}
@ -146,7 +148,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
loadEndHandler();
});
} else if (error) {
errorHandler([error description]);
errorHandler([error localizedDescription]);
}
}];
} else {
@ -170,7 +172,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
loadEndHandler();
});
} else if (error) {
errorHandler([error description]);
errorHandler([error localizedDescription]);
}
}];
}

View File

@ -47,7 +47,7 @@ RCT_CUSTOM_VIEW_PROPERTY(tintColor, UIColor, RCTNetworkImageView)
return @{
@"loadStart": @{ @"registrationName": @"onLoadStart" },
@"loadProgress": @{ @"registrationName": @"onLoadProgress" },
@"loaded": @{ @"registrationName": @"onLoaded" },
@"loaded": @{ @"registrationName": @"onLoadEnd" },
@"loadError": @{ @"registrationName": @"onLoadError" },
@"loadAbort": @{ @"registrationName": @"onLoadAbort" },
};

View File

@ -20,10 +20,21 @@ var StyleSheet = require('StyleSheet');
var UIManager = require('NativeModules').UIManager;
var View = require('View');
var REACT_DEVTOOLS_HOOK: ?Object = typeof window !== 'undefined' ? window.__REACT_DEVTOOLS_BACKEND__ : null;
if (REACT_DEVTOOLS_HOOK) {
// required for devtools to be able to edit react native styles
REACT_DEVTOOLS_HOOK.resolveRNStyle = require('flattenStyle');
}
class Inspector extends React.Component {
_subs: ?Array<() => void>;
constructor(props: Object) {
super(props);
this.state = {
devtoolsBackend: null,
panelPos: 'bottom',
inspecting: true,
perfing: false,
@ -31,6 +42,63 @@ class Inspector extends React.Component {
};
}
componentDidMount() {
if (REACT_DEVTOOLS_HOOK) {
this.attachToDevtools = this.attachToDevtools.bind(this);
REACT_DEVTOOLS_HOOK.addStartupListener(this.attachToDevtools);
// if devtools is already started
// TODO(jared): should addStartupListener just go ahead and call the
// listener if the devtools is already started? might be unexpected...
// is there some name other than `addStartupListener` that would be
// better?
if (REACT_DEVTOOLS_HOOK.backend) {
this.attachToDevtools(REACT_DEVTOOLS_HOOK.backend);
}
}
}
componentWillUnmount() {
if (this._subs) {
this._subs.map(fn => fn());
}
if (REACT_DEVTOOLS_HOOK) {
REACT_DEVTOOLS_HOOK.removeStartupListener(this.attachToDevtools);
}
}
attachToDevtools(backend: Object) {
var _hideWait = null;
var hlSub = backend.sub('highlight', ({node, name, props}) => {
clearTimeout(_hideWait);
UIManager.measure(node, (x, y, width, height, left, top) => {
this.setState({
hierarchy: [],
inspected: {
frame: {left, top, width, height},
style: props ? props.style : {},
},
});
});
});
var hideSub = backend.sub('hideHighlight', () => {
// we wait to actually hide in order to avoid flicker
_hideWait = setTimeout(() => {
this.setState({
inspected: null,
});
}, 100);
});
this._subs = [hlSub, hideSub];
backend.on('shutdown', () => {
this.setState({devtoolsBackend: null});
this._subs = null;
});
this.setState({
devtoolsBackend: backend,
});
}
setSelection(i: number) {
var instance = this.state.hierarchy[i];
var publicInstance = instance.getPublicInstance();
@ -46,6 +114,9 @@ class Inspector extends React.Component {
}
onTouchInstance(instance: Object, frame: Object, pointerY: number) {
if (this.state.devtoolsBackend) {
this.state.devtoolsBackend.selectFromReactInstance(instance, true);
}
var hierarchy = InspectorUtils.getOwnerHierarchy(instance);
var publicInstance = instance.getPublicInstance();
var props = publicInstance.props || {};
@ -88,6 +159,7 @@ class Inspector extends React.Component {
/>}
<View style={[styles.panelContainer, panelContainerStyle]}>
<InspectorPanel
devtoolsIsOpen={!!this.state.devtoolsBackend}
inspecting={this.state.inspecting}
perfing={this.state.perfing}
setPerfing={this.setPerfing.bind(this)}

View File

@ -27,7 +27,11 @@ type EventLike = {
var InspectorOverlay = React.createClass({
propTypes: {
inspectedViewTag: PropTypes.object,
inspected: PropTypes.shape({
frame: PropTypes.object,
style: PropTypes.any,
}),
inspectedViewTag: PropTypes.number,
onTouchInstance: PropTypes.func.isRequired,
},

View File

@ -58,7 +58,7 @@ class InspectorPanel extends React.Component {
}
return (
<View style={styles.container}>
{contents}
{!this.props.devtoolsIsOpen && contents}
<View style={styles.buttonRow}>
<Button
title={'Inspect'}
@ -76,6 +76,7 @@ class InspectorPanel extends React.Component {
}
InspectorPanel.propTypes = {
devtoolsIsOpen: PropTypes.bool,
inspecting: PropTypes.bool,
setInspecting: PropTypes.func,
inspected: PropTypes.object,

View File

@ -25,13 +25,16 @@ type Exception = {
message: string;
}
var exceptionID = 0;
function reportException(e: Exception, isFatal: bool, stack?: any) {
var currentExceptionID = ++exceptionID;
if (RCTExceptionsManager) {
if (!stack) {
stack = parseErrorStack(e);
}
if (isFatal) {
RCTExceptionsManager.reportFatalException(e.message, stack);
RCTExceptionsManager.reportFatalException(e.message, stack, currentExceptionID);
} else {
RCTExceptionsManager.reportSoftException(e.message, stack);
}
@ -39,7 +42,7 @@ function reportException(e: Exception, isFatal: bool, stack?: any) {
(sourceMapPromise = sourceMapPromise || loadSourceMap())
.then(map => {
var prettyStack = parseErrorStack(e, map);
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack);
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack, currentExceptionID);
})
.catch(error => {
// This can happen in a variety of normal situations, such as

View File

@ -0,0 +1,150 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*/
'use strict';
jest.dontMock('diffRawProperties');
jest.dontMock('deepDiffer');
var diffRawProperties = require('diffRawProperties');
describe('diffRawProperties', function() {
it('should work with simple example', () => {
expect(diffRawProperties(
null,
{a: 1, c: 3},
{b: 2, c: 3},
{a: true, b: true}
)).toEqual({a: null, b: 2});
});
it('should skip fields that are equal', () => {
expect(diffRawProperties(
null,
{a: 1, b: 'two', c: true, d: false, e: undefined, f: 0},
{a: 1, b: 'two', c: true, d: false, e: undefined, f: 0},
{a: true, b: true, c: true, d: true, e: true, f: true}
)).toEqual(null);
});
it('should remove fields', () => {
expect(diffRawProperties(
null,
{a: 1},
{},
{a: true}
)).toEqual({a: null});
});
it('should ignore invalid fields', () => {
expect(diffRawProperties(
null,
{a: 1},
{b: 2},
{}
)).toEqual(null);
});
it('should override the updatePayload argument', () => {
var updatePayload = {a: 1};
var result = diffRawProperties(
updatePayload,
{},
{b: 2},
{b: true}
);
expect(result).toBe(updatePayload);
expect(result).toEqual({a: 1, b: 2});
});
it('should use the diff attribute', () => {
var diffA = jest.genMockFunction().mockImpl((a, b) => true);
var diffB = jest.genMockFunction().mockImpl((a, b) => false);
expect(diffRawProperties(
null,
{a: [1], b: [3]},
{a: [2], b: [4]},
{a: {diff: diffA}, b: {diff: diffB}}
)).toEqual({a: [2]});
expect(diffA).toBeCalledWith([1], [2]);
expect(diffB).toBeCalledWith([3], [4]);
});
it('should not use the diff attribute on addition/removal', () => {
var diffA = jest.genMockFunction();
var diffB = jest.genMockFunction();
expect(diffRawProperties(
null,
{a: [1]},
{b: [2]},
{a: {diff: diffA}, b: {diff: diffB}}
)).toEqual({a: null, b: [2]});
expect(diffA).not.toBeCalled();
expect(diffB).not.toBeCalled();
});
it('should do deep diffs of Objects by default', () => {
expect(diffRawProperties(
null,
{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]}});
});
it('should work with undefined styles', () => {
expect(diffRawProperties(
null,
{a: 1, c: 3},
undefined,
{a: true, b: true}
)).toEqual({a: null});
expect(diffRawProperties(
null,
undefined,
{a: 1, c: 3},
{a: true, b: true}
)).toEqual({a: 1});
expect(diffRawProperties(
null,
undefined,
undefined,
{a: true, b: true}
)).toEqual(null);
});
it('should work with empty styles', () => {
expect(diffRawProperties(
null,
{a: 1, c: 3},
{},
{a: true, b: true}
)).toEqual({a: null});
expect(diffRawProperties(
null,
{},
{a: 1, c: 3},
{a: true, b: true}
)).toEqual({a: 1});
expect(diffRawProperties(
null,
{},
{},
{a: true, b: true}
)).toEqual(null);
});
// Function properties are just markers to native that events should be sent.
it('should convert functions to booleans', () => {
// Note that if the property changes from one function to another, we don't
// need to send an update.
expect(diffRawProperties(
null,
{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});
});
});

View File

@ -11,6 +11,8 @@
*/
'use strict';
var deepDiffer = require('deepDiffer');
/**
* diffRawProperties takes two sets of props and a set of valid attributes
* and write to updatePayload the values that changed or were deleted
@ -33,6 +35,7 @@ function diffRawProperties(
var prevProp;
var isScalar;
var shouldUpdate;
var differ;
if (nextProps) {
for (var propKey in nextProps) {
@ -53,16 +56,11 @@ function diffRawProperties(
}
if (prevProp !== nextProp) {
// If you want a property's diff to be detected, you must configure it
// to be so - *or* it must be a scalar property. For now, we'll allow
// creation with any attribute that is not scalar, but we should
// eventually even reject those unless they are properly configured.
// Scalars and new props are always updated. Objects use deepDiffer by
// default, but can be optimized with custom differs.
differ = validAttributeConfig.diff || deepDiffer;
isScalar = typeof nextProp !== 'object' || nextProp === null;
shouldUpdate = isScalar ||
!prevProp ||
validAttributeConfig.diff &&
validAttributeConfig.diff(prevProp, nextProp);
shouldUpdate = isScalar || !prevProp || differ(prevProp, nextProp);
if (shouldUpdate) {
updatePayload = updatePayload || {};
updatePayload[propKey] = nextProp;
@ -99,14 +97,14 @@ function diffRawProperties(
if (nextProp === undefined) {
nextProp = null; // null is a sentinel we explicitly send to native
}
// If you want a property's diff to be detected, you must configure it
// to be so - *or* it must be a scalar property. For now, we'll allow
// creation with any attribute that is not scalar, but we should
// eventually even reject those unless they are properly configured.
// Scalars and new props are always updated. Objects use deepDiffer by
// default, but can be optimized with custom differs.
differ = validAttributeConfig.diff || deepDiffer;
isScalar = typeof nextProp !== 'object' || nextProp === null;
shouldUpdate = isScalar && prevProp !== nextProp ||
validAttributeConfig.diff &&
validAttributeConfig.diff(prevProp, nextProp);
shouldUpdate =
isScalar &&
prevProp !== nextProp ||
differ(prevProp, nextProp);
if (shouldUpdate) {
updatePayload = updatePayload || {};
updatePayload[propKey] = nextProp;

View File

@ -15,7 +15,6 @@ var RCTUIManager = require('NativeModules').UIManager;
var UnimplementedView = require('UnimplementedView');
var createReactNativeComponentClass = require('createReactNativeComponentClass');
var deepDiffer = require('deepDiffer');
var insetsDiffer = require('insetsDiffer');
var pointsDiffer = require('pointsDiffer');
var matricesDiffer = require('matricesDiffer');
@ -54,9 +53,8 @@ function requireNativeComponent(
viewConfig.uiViewClassName = viewName;
viewConfig.validAttributes = {};
for (var key in nativeProps) {
// TODO: deep diff by default in diffRawProperties instead of setting it here
var differ = TypeToDifferMap[nativeProps[key]] || deepDiffer;
viewConfig.validAttributes[key] = {diff: differ};
var differ = TypeToDifferMap[nativeProps[key]];
viewConfig.validAttributes[key] = differ ? {diff: differ} : true;
}
if (__DEV__) {
wrapperComponent && verifyPropTypes(wrapperComponent, viewConfig);

View File

@ -79,6 +79,12 @@ var ReactNativeMount = {
_instancesByContainerID: {},
// these two functions are needed by React Devtools
findNodeHandle: require('findNodeHandle'),
nativeTagToRootNodeID: function (nativeTag: number): string {
return ReactNativeTagHandles.tagToRootNodeID[nativeTag];
},
/**
* @param {ReactComponent} instance Instance to render.
* @param {containerTag} containerView Handle to native view tag

View File

@ -16,7 +16,12 @@ var ReactPropTypes = require('ReactPropTypes');
var TransformPropTypes = {
transform: ReactPropTypes.arrayOf(
ReactPropTypes.oneOfType([
ReactPropTypes.shape({perspective: ReactPropTypes.number}),
ReactPropTypes.shape({rotate: ReactPropTypes.string}),
ReactPropTypes.shape({rotateX: ReactPropTypes.string}),
ReactPropTypes.shape({rotateY: ReactPropTypes.string}),
ReactPropTypes.shape({rotateZ: ReactPropTypes.string}),
ReactPropTypes.shape({scale: ReactPropTypes.number}),
ReactPropTypes.shape({scaleX: ReactPropTypes.number}),
ReactPropTypes.shape({scaleY: ReactPropTypes.number}),
ReactPropTypes.shape({translateX: ReactPropTypes.number}),

View File

@ -58,7 +58,17 @@ function _precomputeTransforms(style: Object): Object {
case 'matrix':
MatrixMath.multiplyInto(result, result, value);
break;
case 'perspective':
_multiplyTransform(result, MatrixMath.reusePerspectiveCommand, [value]);
break;
case 'rotateX':
_multiplyTransform(result, MatrixMath.reuseRotateXCommand, [_convertToRadians(value)]);
break;
case 'rotateY':
_multiplyTransform(result, MatrixMath.reuseRotateYCommand, [_convertToRadians(value)]);
break;
case 'rotate':
case 'rotateZ':
_multiplyTransform(result, MatrixMath.reuseRotateZCommand, [_convertToRadians(value)]);
break;
case 'scale':
@ -156,6 +166,9 @@ function _validateTransform(key, value, transformation) {
break;
case 'translate':
break;
case 'rotateX':
case 'rotateY':
case 'rotateZ':
case 'rotate':
invariant(
typeof value === 'string',

View File

@ -9,32 +9,8 @@
#import "RCTShadowRawText.h"
#import "RCTUIManager.h"
@implementation RCTShadowRawText
- (instancetype)init
{
if ((self = [super init])) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentSizeMultiplierDidChange:)
name:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification
object:nil];
}
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)contentSizeMultiplierDidChange:(NSNotification *)note
{
[self dirtyLayout];
[self dirtyText];
}
- (void)setText:(NSString *)text
{
if (_text != text) {

View File

@ -30,8 +30,6 @@ extern NSString *const RCTReactTagAttributeName;
@property (nonatomic, strong) UIColor *textDecorationColor;
@property (nonatomic, assign) NSUnderlineStyle textDecorationStyle;
@property (nonatomic, assign) RCTTextDecorationLineType textDecorationLine;
@property (nonatomic, assign) CGFloat fontSizeMultiplier;
@property (nonatomic, assign) BOOL allowFontScaling;
- (void)recomputeText;

View File

@ -9,9 +9,6 @@
#import "RCTShadowText.h"
#import "RCTAccessibilityManager.h"
#import "RCTUIManager.h"
#import "RCTBridge.h"
#import "RCTConvert.h"
#import "RCTLog.h"
#import "RCTShadowRawText.h"
@ -54,31 +51,16 @@ static css_dim_t RCTMeasure(void *context, float width)
_letterSpacing = NAN;
_isHighlighted = NO;
_textDecorationStyle = NSUnderlineStyleSingle;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentSizeMultiplierDidChange:)
name:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification
object:nil];
}
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (NSString *)description
{
NSString *superDescription = super.description;
return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; text: %@>", [self attributedString].string];
}
- (void)contentSizeMultiplierDidChange:(NSNotification *)note
{
[self dirtyLayout];
[self dirtyText];
}
- (NSDictionary *)processUpdatedProperties:(NSMutableSet *)applierBlocks
parentProperties:(NSDictionary *)parentProperties
{
@ -208,9 +190,7 @@ static css_dim_t RCTMeasure(void *context, float width)
[self _addAttribute:NSBackgroundColorAttributeName withValue:self.backgroundColor toAttributedString:attributedString];
}
UIFont *font = [RCTConvert UIFont:nil withFamily:fontFamily
size:fontSize weight:fontWeight style:fontStyle
scaleMultiplier:(_allowFontScaling && _fontSizeMultiplier > 0.0 ? _fontSizeMultiplier : 1.0)];
UIFont *font = [RCTConvert UIFont:nil withFamily:fontFamily size:fontSize weight:fontWeight style:fontStyle];
[self _addAttribute:NSFontAttributeName withValue:font toAttributedString:attributedString];
[self _addAttribute:NSKernAttributeName withValue:letterSpacing toAttributedString:attributedString];
[self _addAttribute:RCTReactTagAttributeName withValue:self.reactTag toAttributedString:attributedString];
@ -267,9 +247,8 @@ static css_dim_t RCTMeasure(void *context, float width)
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = _textAlign;
paragraphStyle.baseWritingDirection = _writingDirection;
CGFloat lineHeight = round(_lineHeight * self.fontSizeMultiplier);
paragraphStyle.minimumLineHeight = lineHeight;
paragraphStyle.maximumLineHeight = lineHeight;
paragraphStyle.minimumLineHeight = _lineHeight;
paragraphStyle.maximumLineHeight = _lineHeight;
[attributedString addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle
range:(NSRange){0, attributedString.length}];
@ -342,26 +321,4 @@ RCT_TEXT_PROPERTY(TextDecorationLine, _textDecorationLine, RCTTextDecorationLine
RCT_TEXT_PROPERTY(TextDecorationStyle, _textDecorationStyle, NSUnderlineStyle);
RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection)
- (void)setAllowFontScaling:(BOOL)allowFontScaling
{
_allowFontScaling = allowFontScaling;
for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)child setAllowFontScaling:allowFontScaling];
}
}
[self dirtyText];
}
- (void)setFontSizeMultiplier:(CGFloat)fontSizeMultiplier
{
_fontSizeMultiplier = fontSizeMultiplier;
for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)child setFontSizeMultiplier:fontSizeMultiplier];
}
}
[self dirtyText];
}
@end

View File

@ -9,7 +9,6 @@
#import "RCTTextManager.h"
#import "RCTAccessibilityManager.h"
#import "RCTAssert.h"
#import "RCTConvert.h"
#import "RCTLog.h"
@ -50,7 +49,6 @@ RCT_EXPORT_SHADOW_PROPERTY(textDecorationStyle, NSUnderlineStyle)
RCT_EXPORT_SHADOW_PROPERTY(textDecorationColor, UIColor)
RCT_EXPORT_SHADOW_PROPERTY(textDecorationLine, RCTTextDecorationLineType)
RCT_EXPORT_SHADOW_PROPERTY(writingDirection, NSWritingDirection)
RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL)
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry
{
@ -71,7 +69,6 @@ RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL)
RCTAssert([shadowView isTextDirty], @"Don't process any nodes that don't have dirty text");
if ([shadowView isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)shadowView setFontSizeMultiplier:self.bridge.accessibilityManager.multiplier];
[(RCTShadowText *)shadowView recomputeText];
} else if ([shadowView isKindOfClass:[RCTShadowRawText class]]) {
RCTLogError(@"Raw text cannot be used outside of a <Text> tag. Not rendering string: '%@'",

View File

@ -30,7 +30,6 @@ var viewConfig = {
validAttributes: merge(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
numberOfLines: true,
allowFontScaling: true,
}),
uiViewClassName: 'RCTText',
};
@ -101,27 +100,16 @@ var Text = React.createClass({
* {nativeEvent: {layout: {x, y, width, height}}}.
*/
onLayout: React.PropTypes.func,
/**
* Specifies should fonts scale to respect Text Size accessibility setting.
*/
allowFontScaling: React.PropTypes.bool,
},
viewConfig: viewConfig,
getInitialState: function(): Object {
getInitialState: function() {
return merge(this.touchableGetInitialState(), {
isHighlighted: false,
});
},
getDefaultProps: function(): Object {
return {
numberOfLines: 0,
allowFontScaling: true,
};
},
onStartShouldSetResponder: function(): bool {
var shouldSetFromProps = this.props.onStartShouldSetResponder &&
this.props.onStartShouldSetResponder();
@ -243,7 +231,6 @@ if (Platform.OS === 'android') {
RCTVirtualText = createReactNativeComponentClass({
validAttributes: merge(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
allowFontScaling: false,
}),
uiViewClassName: 'RCTVirtualText',
});

View File

@ -65,6 +65,10 @@ var MatrixMath = {
matrixCommand[10] = z;
},
reusePerspectiveCommand: function(matrixCommand, p) {
matrixCommand[11] = -1 / p;
},
reuseScaleXCommand(matrixCommand, factor) {
matrixCommand[0] = factor;
},

View File

@ -97,7 +97,7 @@ RCT_EXPORT_MODULE()
{
__block NSError *initError;
dispatch_semaphore_t s = dispatch_semaphore_create(0);
[self sendMessage:@{@"method": @"prepareJSRuntime"} context:nil waitForReply:^(NSError *error, NSDictionary *reply) {
[self sendMessage:@{@"method": @"prepareJSRuntime"} waitForReply:^(NSError *error, NSDictionary *reply) {
initError = error;
dispatch_semaphore_signal(s);
}];
@ -126,7 +126,7 @@ RCT_EXPORT_MODULE()
RCTLogError(@"WebSocket connection failed with error %@", error);
}
- (void)sendMessage:(NSDictionary *)message context:(NSNumber *)executorID waitForReply:(RCTWSMessageCallback)callback
- (void)sendMessage:(NSDictionary *)message waitForReply:(RCTWSMessageCallback)callback
{
static NSUInteger lastID = 10000;
@ -137,8 +137,6 @@ RCT_EXPORT_MODULE()
}];
callback(error, nil);
return;
} else if (executorID && ![RCTGetExecutorID(self) isEqualToNumber:executorID]) {
return;
}
NSNumber *expectedID = @(lastID++);
@ -152,12 +150,12 @@ RCT_EXPORT_MODULE()
- (void)executeApplicationScript:(NSString *)script sourceURL:(NSURL *)URL onComplete:(RCTJavaScriptCompleteBlock)onComplete
{
NSDictionary *message = @{@"method": @"executeApplicationScript", @"url": [URL absoluteString], @"inject": _injectedObjects};
[self sendMessage:message context:nil waitForReply:^(NSError *error, NSDictionary *reply) {
[self sendMessage:message waitForReply:^(NSError *error, NSDictionary *reply) {
onComplete(error);
}];
}
- (void)executeJSCall:(NSString *)name method:(NSString *)method arguments:(NSArray *)arguments context:(NSNumber *)executorID callback:(RCTJavaScriptCallback)onComplete
- (void)executeJSCall:(NSString *)name method:(NSString *)method arguments:(NSArray *)arguments callback:(RCTJavaScriptCallback)onComplete
{
RCTAssert(onComplete != nil, @"callback was missing for exec JS call");
NSDictionary *message = @{
@ -166,7 +164,7 @@ RCT_EXPORT_MODULE()
@"moduleMethod": method,
@"arguments": arguments
};
[self sendMessage:message context:executorID waitForReply:^(NSError *socketError, NSDictionary *reply) {
[self sendMessage:message waitForReply:^(NSError *socketError, NSDictionary *reply) {
if (socketError) {
onComplete(nil, socketError);
return;

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "React"
s.version = "0.4.4"
s.version = "0.8.0"
s.summary = "Build high quality mobile apps using React."
s.description = <<-DESC
React Native apps are built using the React JS

View File

@ -200,7 +200,6 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
*/
_javaScriptExecutor = _modulesByName[RCTBridgeModuleNameForClass(self.executorClass)];
RCTLatestExecutor = _javaScriptExecutor;
RCTSetExecutorID(_javaScriptExecutor);
[_javaScriptExecutor setUp];
@ -239,7 +238,11 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[_javaScriptExecutor injectJSONText:configJSON
asGlobalObjectNamed:@"__fbBatchedBridgeConfig" callback:
^(__unused id err) {
^(NSError *error) {
if (error) {
[[RCTRedBox sharedInstance] showError:error];
}
dispatch_semaphore_signal(semaphore);
}];
@ -302,7 +305,10 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
[self enqueueApplicationScript:script url:bundleURL onComplete:^(NSError *loadError) {
if (!loadError) {
if (loadError) {
[[RCTRedBox sharedInstance] showError:loadError];
return;
}
/**
* Register the display link to start sending js calls after everything
@ -314,10 +320,6 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification
object:_parentBridge
userInfo:@{ @"bridge": self }];
} else {
[[RCTRedBox sharedInstance] showErrorMessage:[loadError localizedDescription]
withDetails:[loadError localizedFailureReason]];
}
}];
}
}];
@ -407,8 +409,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
[self _invokeAndProcessModule:@"BatchedBridge"
method:@"callFunctionReturnFlushedQueue"
arguments:@[ids[0], ids[1], args ?: @[]]
context:RCTGetExecutorID(_javaScriptExecutor)];
arguments:@[ids[0], ids[1], args ?: @[]]];
}
/**
@ -421,8 +422,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
dispatch_block_t block = ^{
[self _actuallyInvokeAndProcessModule:@"BatchedBridge"
method:@"callFunctionReturnFlushedQueue"
arguments:@[@"JSTimersExecution", @"callTimers", @[@[timer]]]
context:RCTGetExecutorID(_javaScriptExecutor)];
arguments:@[@"JSTimersExecution", @"callTimers", @[@[timer]]]];
};
if ([_javaScriptExecutor respondsToSelector:@selector(executeAsyncBlockOnJavaScriptQueue:)]) {
@ -447,18 +447,16 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
}
RCTProfileBeginEvent();
NSNumber *context = RCTGetExecutorID(_javaScriptExecutor);
[_javaScriptExecutor executeJSCall:@"BatchedBridge"
method:@"flushedQueue"
arguments:@[]
context:context
callback:^(id json, NSError *error) {
RCTProfileEndEvent(@"FetchApplicationScriptCallbacks", @"js_call,init", @{
@"json": RCTNullIfNil(json),
@"error": RCTNullIfNil(error),
});
[self _handleBuffer:json context:context];
[self _handleBuffer:json];
onComplete(error);
}];
@ -467,22 +465,11 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
#pragma mark - Payload Generation
/**
* TODO: Completely remove `context` - no longer needed
*/
- (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args
{
[self _invokeAndProcessModule:module
method:method
arguments:args
context:RCTGetExecutorID(_javaScriptExecutor)];
}
/**
* Called by enqueueJSCall from any thread, or from _immediatelyCallTimer,
* on the JS thread, but only in non-batched mode.
*/
- (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args context:(NSNumber *)context
- (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args
{
/**
* AnyThread
@ -508,7 +495,6 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
@"method": method,
@"args": args,
},
@"context": context ?: @0,
RCT_IF_DEV(@"call_id": callID,)
};
if ([method isEqualToString:@"invokeCallbackAndReturnFlushedQueue"]) {
@ -521,30 +507,33 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
}];
}
- (void)_actuallyInvokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args context:(NSNumber *)context
- (void)_actuallyInvokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args
{
RCTAssertJSThread();
[[NSNotificationCenter defaultCenter] postNotificationName:RCTEnqueueNotification object:nil userInfo:nil];
RCTJavaScriptCallback processResponse = ^(id json, __unused NSError *error) {
RCTJavaScriptCallback processResponse = ^(id json, NSError *error) {
if (error) {
[[RCTRedBox sharedInstance] showError:error];
}
if (!self.isValid) {
return;
}
[[NSNotificationCenter defaultCenter] postNotificationName:RCTDequeueNotification object:nil userInfo:nil];
[self _handleBuffer:json context:context];
[self _handleBuffer:json];
};
[_javaScriptExecutor executeJSCall:module
method:method
arguments:args
context:context
callback:processResponse];
}
#pragma mark - Payload Processing
- (void)_handleBuffer:(id)buffer context:(NSNumber *)context
- (void)_handleBuffer:(id)buffer
{
RCTAssertJSThread();
@ -607,8 +596,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
[self _handleRequestNumber:index
moduleID:[moduleIDs[index] integerValue]
methodID:[methodIDs[index] integerValue]
params:paramsArrays[index]
context:context];
params:paramsArrays[index]];
}
}
RCTProfileEndEvent(RCTCurrentThreadName(), @"objc_call,dispatch_async", @{ @"calls": @(calls.count) });
@ -629,7 +617,6 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
moduleID:(NSUInteger)moduleID
methodID:(NSUInteger)methodID
params:(NSArray *)params
context:(NSNumber *)context
{
if (!self.isValid) {
return NO;
@ -656,7 +643,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
}
@try {
[method invokeWithBridge:self module:moduleData.instance arguments:params context:context];
[method invokeWithBridge:self module:moduleData.instance arguments:params];
}
@catch (NSException *exception) {
RCTLogError(@"Exception thrown while invoking %@ on target %@ with params %@: %@", method.JSMethodName, moduleData.name, params, exception);
@ -697,12 +684,6 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
}
NSArray *calls = [_scheduledCallbacks.allObjects arrayByAddingObjectsFromArray:_scheduledCalls];
NSNumber *currentExecutorID = RCTGetExecutorID(_javaScriptExecutor);
calls = [calls filteredArrayUsingPredicate:
[NSPredicate predicateWithBlock:
^BOOL(NSDictionary *call, __unused NSDictionary *bindings) {
return [call[@"context"] isEqualToNumber:currentExecutorID];
}]];
RCT_IF_DEV(
RCTProfileImmediateEvent(@"JS Thread Tick", displayLink.timestamp, @"g");
@ -717,8 +698,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
_scheduledCallbacks = [[RCTSparseArray alloc] init];
[self _actuallyInvokeAndProcessModule:@"BatchedBridge"
method:@"processBatch"
arguments:@[[calls valueForKey:@"js_args"]]
context:RCTGetExecutorID(_javaScriptExecutor)];
arguments:@[[calls valueForKey:@"js_args"]]];
}
RCTProfileEndEvent(@"DispatchFrameUpdate", @"objc_call", nil);

View File

@ -230,7 +230,6 @@ RCT_NOT_IMPLEMENTED(-init)
[RCTGetLatestExecutor() executeJSCall:@"RCTLog"
method:@"logIfNoNativeHook"
arguments:@[level, message]
context:RCTGetExecutorID(RCTGetLatestExecutor())
callback:^(__unused id json, __unused NSError *error) {}];
});
}
@ -254,7 +253,6 @@ RCT_NOT_IMPLEMENTED(-init)
RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(__unused NSString *)module
method:(__unused NSString *)method
arguments:(__unused NSArray *)args
context:(__unused NSNumber *)context)
arguments:(__unused NSArray *)args);
@end

View File

@ -91,8 +91,7 @@ typedef NSURL RCTFileURL;
+ (UIFont *)UIFont:(UIFont *)font withStyle:(id)json;
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)json;
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)family
size:(id)size weight:(id)weight style:(id)style
scaleMultiplier:(CGFloat)scaleMultiplier;
size:(id)size weight:(id)weight style:(id)style;
typedef NSArray NSStringArray;
+ (NSStringArray *)NSStringArray:(id)json;
@ -121,8 +120,9 @@ typedef NSArray CGColorArray;
typedef id NSPropertyList;
+ (NSPropertyList)NSPropertyList:(id)json;
typedef BOOL css_clip_t;
typedef BOOL css_clip_t, css_backface_visibility_t;
+ (css_clip_t)css_clip_t:(id)json;
+ (css_backface_visibility_t)css_backface_visibility_t:(id)json;
+ (css_flex_direction_t)css_flex_direction_t:(id)json;
+ (css_justify_t)css_justify_t:(id)json;
+ (css_align_t)css_align_t:(id)json;

View File

@ -779,33 +779,31 @@ static BOOL RCTFontIsCondensed(UIFont *font)
withFamily:json[@"fontFamily"]
size:json[@"fontSize"]
weight:json[@"fontWeight"]
style:json[@"fontStyle"]
scaleMultiplier:1.0f];
style:json[@"fontStyle"]];
}
+ (UIFont *)UIFont:(UIFont *)font withSize:(id)json
{
return [self UIFont:font withFamily:nil size:json weight:nil style:nil scaleMultiplier:1.0];
return [self UIFont:font withFamily:nil size:json weight:nil style:nil];
}
+ (UIFont *)UIFont:(UIFont *)font withWeight:(id)json
{
return [self UIFont:font withFamily:nil size:nil weight:json style:nil scaleMultiplier:1.0];
return [self UIFont:font withFamily:nil size:nil weight:json style:nil];
}
+ (UIFont *)UIFont:(UIFont *)font withStyle:(id)json
{
return [self UIFont:font withFamily:nil size:nil weight:nil style:json scaleMultiplier:1.0];
return [self UIFont:font withFamily:nil size:nil weight:nil style:json];
}
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)json
{
return [self UIFont:font withFamily:json size:nil weight:nil style:nil scaleMultiplier:1.0];
return [self UIFont:font withFamily:json size:nil weight:nil style:nil];
}
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)family
size:(id)size weight:(id)weight style:(id)style
scaleMultiplier:(CGFloat)scaleMultiplier
{
// Defaults
NSString *const RCTDefaultFontFamily = @"System";
@ -830,9 +828,6 @@ static BOOL RCTFontIsCondensed(UIFont *font)
// Get font attributes
fontSize = [self CGFloat:size] ?: fontSize;
if (scaleMultiplier > 0.0 && scaleMultiplier != 1.0) {
fontSize = round(fontSize * scaleMultiplier);
}
familyName = [self NSString:family] ?: familyName;
isItalic = style ? [self RCTFontStyle:style] : isItalic;
fontWeight = weight ? [self RCTFontWeight:weight] : fontWeight;
@ -998,6 +993,11 @@ static id RCTConvertPropertyListValue(id json)
return RCTConvertPropertyListValue(json);
}
RCT_ENUM_CONVERTER(css_backface_visibility_t, (@{
@"hidden": @NO,
@"visible": @YES
}), YES, boolValue)
RCT_ENUM_CONVERTER(css_clip_t, (@{
@"hidden": @YES,
@"visible": @NO

View File

@ -36,7 +36,6 @@ typedef void (^RCTJavaScriptCallback)(id json, NSError *error);
- (void)executeJSCall:(NSString *)name
method:(NSString *)method
arguments:(NSArray *)arguments
context:(NSNumber *)executorID
callback:(RCTJavaScriptCallback)onComplete;
/**
@ -66,6 +65,3 @@ typedef void (^RCTJavaScriptCallback)(id json, NSError *error);
- (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block;
@end
void RCTSetExecutorID(id<RCTJavaScriptExecutor> executor);
NSNumber *RCTGetExecutorID(id<RCTJavaScriptExecutor> executor);

View File

@ -1,26 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTJavaScriptExecutor.h"
static const char *RCTJavaScriptExecutorID = "RCTJavaScriptExecutorID";
void RCTSetExecutorID(id<RCTJavaScriptExecutor> executor)
{
static NSUInteger executorID = 0;
if (executor) {
objc_setAssociatedObject(executor, RCTJavaScriptExecutorID, @(++executorID), OBJC_ASSOCIATION_RETAIN);
}
}
NSNumber *RCTGetExecutorID(id<RCTJavaScriptExecutor> executor)
{
return executor ? objc_getAssociatedObject(executor, RCTJavaScriptExecutorID) : @0;
}

View File

@ -29,7 +29,6 @@ typedef NS_ENUM(NSUInteger, RCTJavaScriptFunctionKind) {
- (void)invokeWithBridge:(RCTBridge *)bridge
module:(id)module
arguments:(NSArray *)arguments
context:(NSNumber *)context;
arguments:(NSArray *)arguments;
@end

View File

@ -88,7 +88,7 @@ RCT_NOT_IMPLEMENTED(-init)
NSMutableArray *argumentBlocks = [[NSMutableArray alloc] initWithCapacity:numberOfArguments - 2];
#define RCT_ARG_BLOCK(_logic) \
[argumentBlocks addObject:^(__unused RCTBridge *bridge, __unused NSNumber *context, NSInvocation *invocation, NSUInteger index, id json) { \
[argumentBlocks addObject:^(__unused RCTBridge *bridge, NSInvocation *invocation, NSUInteger index, id json) { \
_logic \
[invocation setArgument:&value atIndex:index]; \
}]; \
@ -154,7 +154,7 @@ case _value: { \
RCT_CONVERT_CASE('^', void *)
case '{': {
[argumentBlocks addObject:^(__unused RCTBridge *bridge, __unused NSNumber *context, NSInvocation *invocation, NSUInteger index, id json) {
[argumentBlocks addObject:^(__unused RCTBridge *bridge, NSInvocation *invocation, NSUInteger index, id json) {
NSMethodSignature *methodSignature = [RCTConvert methodSignatureForSelector:selector];
void *returnValue = malloc(methodSignature.methodReturnLength);
NSInvocation *_invocation = [NSInvocation invocationWithMethodSignature:methodSignature];
@ -249,7 +249,6 @@ case _value: { \
- (void)invokeWithBridge:(RCTBridge *)bridge
module:(id)module
arguments:(NSArray *)arguments
context:(NSNumber *)context
{
if (RCT_DEBUG) {
@ -284,8 +283,8 @@ case _value: { \
NSUInteger index = 0;
for (id json in arguments) {
id arg = RCTNilIfNull(json);
void (^block)(RCTBridge *, NSNumber *, NSInvocation *, NSUInteger, id) = _argumentBlocks[index];
block(bridge, context, invocation, index + 2, arg);
void (^block)(RCTBridge *, NSInvocation *, NSUInteger, id) = _argumentBlocks[index];
block(bridge, invocation, index + 2, arg);
index++;
}

View File

@ -13,6 +13,7 @@
+ (instancetype)sharedInstance;
- (void)showError:(NSError *)error;
- (void)showErrorMessage:(NSString *)message;
- (void)showErrorMessage:(NSString *)message withDetails:(NSString *)details;
- (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack;

View File

@ -283,6 +283,11 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
_nextBackgroundColor = color;
}
- (void)showError:(NSError *)error
{
[self showErrorMessage:error.localizedDescription withDetails:error.localizedFailureReason];
}
- (void)showErrorMessage:(NSString *)message
{
[self showErrorMessage:message withStack:nil showIfHidden:YES];
@ -342,6 +347,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
@implementation RCTRedBox
+ (instancetype)sharedInstance { return nil; }
- (void)showError:(NSError *)message {}
- (void)showErrorMessage:(NSString *)message {}
- (void)showErrorMessage:(NSString *)message withDetails:(NSString *)details {}
- (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack {}

View File

@ -330,14 +330,13 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
- (void)executeJSCall:(NSString *)name
method:(NSString *)method
arguments:(NSArray *)arguments
context:(NSNumber *)executorID
callback:(RCTJavaScriptCallback)onComplete
{
RCTAssert(onComplete != nil, @"onComplete block should not be nil");
__weak RCTContextExecutor *weakSelf = self;
[self executeBlockOnJavaScriptQueue:RCTProfileBlock((^{
RCTContextExecutor *strongSelf = weakSelf;
if (!strongSelf || !strongSelf.isValid || ![RCTGetExecutorID(strongSelf) isEqualToNumber:executorID]) {
if (!strongSelf || !strongSelf.isValid) {
return;
}
NSError *error;

View File

@ -92,12 +92,11 @@ RCT_EXPORT_MODULE()
- (void)executeJSCall:(NSString *)name
method:(NSString *)method
arguments:(NSArray *)arguments
context:(NSNumber *)executorID
callback:(RCTJavaScriptCallback)onComplete
{
RCTAssert(onComplete != nil, @"");
[self executeBlockOnJavaScriptQueue:^{
if (!self.isValid || ![RCTGetExecutorID(self) isEqualToNumber:executorID]) {
if (!self.isValid) {
return;
}

View File

@ -1,27 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#import "RCTBridge.h"
extern NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification; // posted when multiplier is changed
@interface RCTAccessibilityManager : NSObject <RCTBridgeModule>
@property (nonatomic, readonly) CGFloat multiplier;
@end
@interface RCTBridge (RCTAccessibilityManager)
@property (nonatomic, readonly) RCTAccessibilityManager *accessibilityManager;
@end

View File

@ -1,144 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTAccessibilityManager.h"
#import "RCTLog.h"
NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAccessibilityManagerDidUpdateMultiplierNotification";
@interface RCTAccessibilityManager ()
@property (nonatomic, copy) NSDictionary *multipliers;
@property (nonatomic, copy) NSString *contentSizeCategory;
@property (nonatomic, assign) CGFloat multiplier;
@end
@implementation RCTAccessibilityManager
@synthesize bridge = _bridge;
RCT_EXPORT_MODULE()
+ (NSDictionary *)JSToUIKitMap
{
static NSDictionary *map = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
map = @{@"extraSmall": UIContentSizeCategoryExtraSmall,
@"small": UIContentSizeCategorySmall,
@"medium": UIContentSizeCategoryMedium,
@"large": UIContentSizeCategoryLarge,
@"extraLarge": UIContentSizeCategoryExtraLarge,
@"extraExtraLarge": UIContentSizeCategoryExtraExtraLarge,
@"extraExtraExtraLarge": UIContentSizeCategoryExtraExtraExtraLarge,
@"accessibilityMedium": UIContentSizeCategoryAccessibilityMedium,
@"accessibilityLarge": UIContentSizeCategoryAccessibilityLarge,
@"accessibilityExtraLarge": UIContentSizeCategoryAccessibilityExtraLarge,
@"accessibilityExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraLarge,
@"accessibilityExtraExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraExtraLarge};
});
return map;
}
+ (NSString *)UIKitCategoryFromJSCategory:(NSString *)JSCategory
{
return self.JSToUIKitMap[JSCategory];
}
- (instancetype)init
{
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveNewContentSizeCategory:)
name:UIContentSizeCategoryDidChangeNotification
object:[UIApplication sharedApplication]];
self.contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
}
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)didReceiveNewContentSizeCategory:(NSNotification *)note
{
self.contentSizeCategory = note.userInfo[UIContentSizeCategoryNewValueKey];
}
- (void)setContentSizeCategory:(NSString *)contentSizeCategory
{
if (_contentSizeCategory != contentSizeCategory) {
_contentSizeCategory = [contentSizeCategory copy];
self.multiplier = [self multiplierForContentSizeCategory:_contentSizeCategory];
[[NSNotificationCenter defaultCenter] postNotificationName:RCTAccessibilityManagerDidUpdateMultiplierNotification object:self];
}
}
- (CGFloat)multiplierForContentSizeCategory:(NSString *)category
{
NSNumber *m = self.multipliers[category];
if (m.doubleValue <= 0.0) {
RCTLogError(@"Can't determinte multiplier for category %@. Using 1.0.", category);
m = @1.0;
}
return m.doubleValue;
}
- (NSDictionary *)multipliers
{
if (_multipliers == nil) {
_multipliers = @{UIContentSizeCategoryExtraSmall: @0.823,
UIContentSizeCategorySmall: @0.882,
UIContentSizeCategoryMedium: @0.941,
UIContentSizeCategoryLarge: @1.0,
UIContentSizeCategoryExtraLarge: @1.118,
UIContentSizeCategoryExtraExtraLarge: @1.235,
UIContentSizeCategoryExtraExtraExtraLarge: @1.353,
UIContentSizeCategoryAccessibilityMedium: @1.786,
UIContentSizeCategoryAccessibilityLarge: @2.143,
UIContentSizeCategoryAccessibilityExtraLarge: @2.643,
UIContentSizeCategoryAccessibilityExtraExtraLarge: @3.143,
UIContentSizeCategoryAccessibilityExtraExtraExtraLarge: @3.571};
}
return _multipliers;
}
RCT_EXPORT_METHOD(setAccessibilityContentSizeMultipliers:(NSDictionary *)JSMultipliers)
{
NSMutableDictionary *multipliers = [[NSMutableDictionary alloc] init];
for (NSString *__nonnull JSCategory in JSMultipliers) {
NSNumber *m = JSMultipliers[JSCategory];
NSString *UIKitCategory = [self.class UIKitCategoryFromJSCategory:JSCategory];
multipliers[UIKitCategory] = m;
}
self.multipliers = multipliers;
}
RCT_EXPORT_METHOD(getMultiplier:(RCTResponseSenderBlock)callback)
{
if (callback) {
callback(@[ @(self.multiplier) ]);
}
}
@end
@implementation RCTBridge (RCTAccessibilityManager)
- (RCTAccessibilityManager *)accessibilityManager
{
return self.modules[RCTBridgeModuleNameForClass([RCTAccessibilityManager class])];
}
@end

View File

@ -48,7 +48,8 @@ RCT_EXPORT_METHOD(reportSoftException:(NSString *)message
}
RCT_EXPORT_METHOD(reportFatalException:(NSString *)message
stack:(NSArray *)stack)
stack:(NSArray *)stack
exceptionId:(__unused NSNumber *)exceptionId)
{
if (_delegate) {
[_delegate handleFatalJSExceptionWithMessage:message stack:stack];
@ -86,7 +87,8 @@ RCT_EXPORT_METHOD(reportFatalException:(NSString *)message
}
RCT_EXPORT_METHOD(updateExceptionMessage:(NSString *)message
stack:(NSArray *)stack)
stack:(NSArray *)stack
exceptionId:(__unused NSNumber *)exceptionId)
{
if (_delegate) {
[_delegate updateJSExceptionWithMessage:message stack:stack];
@ -100,6 +102,6 @@ RCT_EXPORT_METHOD(updateExceptionMessage:(NSString *)message
RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message
stack:(NSArray *)stack)
{
[self reportFatalException:message stack:stack];
[self reportFatalException:message stack:stack exceptionId:nil];
}
@end

View File

@ -14,12 +14,6 @@
#import "RCTInvalidating.h"
#import "RCTViewManager.h"
/**
* Posted right before re-render happens. This is a chance for views to invalidate their state so
* next render cycle will pick up updated views and layout appropriately.
*/
extern NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification;
@protocol RCTScrollableProtocol;
/**

View File

@ -14,7 +14,6 @@
#import <AVFoundation/AVFoundation.h>
#import "Layout.h"
#import "RCTAccessibilityManager.h"
#import "RCTAnimationType.h"
#import "RCTAssert.h"
#import "RCTBridge.h"
@ -36,8 +35,6 @@
static void RCTTraverseViewNodes(id<RCTViewNodeProtocol> view, void (^block)(id<RCTViewNodeProtocol>));
static NSDictionary *RCTPropsMerge(NSDictionary *beforeProps, NSDictionary *newProps);
NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification = @"RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification";
@interface RCTAnimation : NSObject
@property (nonatomic, readonly) NSTimeInterval duration;
@ -265,33 +262,10 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass)
_rootViewTags = [[NSMutableSet alloc] init];
_bridgeTransactionListeners = [[NSMutableSet alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveNewContentSizeMultiplier)
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
object:nil];
}
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)didReceiveNewContentSizeMultiplier
{
__weak RCTUIManager *weakSelf = self;
dispatch_async(self.methodQueue, ^{
__weak RCTUIManager *strongSelf = weakSelf;
if (strongSelf) {
[[NSNotificationCenter defaultCenter] postNotificationName:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification
object:strongSelf];
[strongSelf batchDidComplete];
}
});
}
- (BOOL)isValid
{
return _viewRegistry != nil;
@ -1351,7 +1325,9 @@ RCT_EXPORT_METHOD(measure:(NSNumber *)reactTag
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
UIView *view = viewRegistry[reactTag];
if (!view) {
RCTLogError(@"measure cannot find view with tag #%@", reactTag);
// this view was probably collapsed out
RCTLogWarn(@"measure cannot find view with tag #%@", reactTag);
callback(@[]);
return;
}
CGRect frame = view.frame;

View File

@ -64,7 +64,6 @@
58114A501AAE93D500E7D092 /* RCTAsyncLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */; };
58C571C11AA56C1900CDF9C8 /* RCTDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */; };
63F014C01B02080B003B75D2 /* RCTPointAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F014BF1B02080B003B75D2 /* RCTPointAnnotation.m */; };
783ABB351B38A9D3003FFD95 /* RCTJavaScriptExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 783ABB341B38A9D3003FFD95 /* RCTJavaScriptExecutor.m */; };
830A229E1A66C68A008503DA /* RCTRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 830A229D1A66C68A008503DA /* RCTRootView.m */; };
832348161A77A5AA00B55238 /* Layout.c in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FC71A68125100A75B9A /* Layout.c */; };
83CBBA511A601E3B00E9B192 /* RCTAssert.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CBBA4B1A601E3B00E9B192 /* RCTAssert.m */; };
@ -75,7 +74,6 @@
83CBBA691A601EF300E9B192 /* RCTEventDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CBBA661A601EF300E9B192 /* RCTEventDispatcher.m */; };
83CBBA981A6020BB00E9B192 /* RCTTouchHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CBBA971A6020BB00E9B192 /* RCTTouchHandler.m */; };
83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CBBACB1A6023D300E9B192 /* RCTConvert.m */; };
E9B20B7B1B500126007A2DA7 /* RCTAccessibilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -214,7 +212,6 @@
58C571C01AA56C1900CDF9C8 /* RCTDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDatePickerManager.h; sourceTree = "<group>"; };
63F014BE1B02080B003B75D2 /* RCTPointAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPointAnnotation.h; sourceTree = "<group>"; };
63F014BF1B02080B003B75D2 /* RCTPointAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPointAnnotation.m; sourceTree = "<group>"; };
783ABB341B38A9D3003FFD95 /* RCTJavaScriptExecutor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTJavaScriptExecutor.m; sourceTree = "<group>"; };
830213F31A654E0800B993E6 /* RCTBridgeModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTBridgeModule.h; sourceTree = "<group>"; };
830A229C1A66C68A008503DA /* RCTRootView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootView.h; sourceTree = "<group>"; };
830A229D1A66C68A008503DA /* RCTRootView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootView.m; sourceTree = "<group>"; };
@ -240,8 +237,6 @@
83CBBACA1A6023D300E9B192 /* RCTConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTConvert.h; sourceTree = "<group>"; };
83CBBACB1A6023D300E9B192 /* RCTConvert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert.m; sourceTree = "<group>"; };
E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTextDecorationLineType.h; sourceTree = "<group>"; };
E9B20B791B500126007A2DA7 /* RCTAccessibilityManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAccessibilityManager.h; sourceTree = "<group>"; };
E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAccessibilityManager.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -278,8 +273,6 @@
13B07FE01A69315300A75B9A /* Modules */ = {
isa = PBXGroup;
children = (
E9B20B791B500126007A2DA7 /* RCTAccessibilityManager.h */,
E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */,
13B07FE71A69327A00A75B9A /* RCTAlertManager.h */,
13B07FE81A69327A00A75B9A /* RCTAlertManager.m */,
1372B7081AB030C200659ED6 /* RCTAppState.h */,
@ -436,7 +429,6 @@
14C2CA751B3AC64F00E6CBB2 /* RCTFrameUpdate.m */,
83CBBA4C1A601E3B00E9B192 /* RCTInvalidating.h */,
83CBBA631A601ECA00E9B192 /* RCTJavaScriptExecutor.h */,
783ABB341B38A9D3003FFD95 /* RCTJavaScriptExecutor.m */,
14200DA81AC179B3008EE6BA /* RCTJavaScriptLoader.h */,
14200DA91AC179B3008EE6BA /* RCTJavaScriptLoader.m */,
13A1F71C1A75392D00D3D453 /* RCTKeyCommands.h */,
@ -572,13 +564,11 @@
137327EA1AA5CF210034F82E /* RCTTabBarManager.m in Sources */,
13B080261A694A8400A75B9A /* RCTWrapperViewController.m in Sources */,
13B080051A6947C200A75B9A /* RCTScrollView.m in Sources */,
E9B20B7B1B500126007A2DA7 /* RCTAccessibilityManager.m in Sources */,
13B07FF21A69327A00A75B9A /* RCTTiming.m in Sources */,
1372B70A1AB030C200659ED6 /* RCTAppState.m in Sources */,
134FCB3D1A6E7F0800051CC8 /* RCTContextExecutor.m in Sources */,
14C2CA781B3ACB0400E6CBB2 /* RCTBatchedBridge.m in Sources */,
13E067591A70F44B002CDEE1 /* UIView+React.m in Sources */,
783ABB351B38A9D3003FFD95 /* RCTJavaScriptExecutor.m in Sources */,
14F484561AABFCE100FDF6B9 /* RCTSliderManager.m in Sources */,
14C2CA741B3AC64300E6CBB2 /* RCTModuleData.m in Sources */,
142014191B32094000CC17BA /* RCTPerformanceLogger.m in Sources */,

View File

@ -96,6 +96,7 @@ RCT_EXPORT_VIEW_PROPERTY(accessibilityTraits, UIAccessibilityTraits)
RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
RCT_REMAP_VIEW_PROPERTY(accessible, isAccessibilityElement, BOOL)
RCT_REMAP_VIEW_PROPERTY(testID, accessibilityIdentifier, NSString)
RCT_REMAP_VIEW_PROPERTY(backfaceVisibility, layer.doubleSided, css_backface_visibility_t)
RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor, CGColor);
RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset, CGSize);

View File

@ -1,6 +1,6 @@
{
"name": "react-native",
"version": "0.6.0",
"version": "0.8.0",
"description": "A framework for building native apps using React",
"license": "BSD-3-Clause",
"repository": {

View File

@ -150,7 +150,16 @@ class DependencyGraph {
getOrderedDependencies(entryPath) {
return this.load().then(() => {
const absolutePath = path.resolve(this._getAbsolutePath(entryPath));
const absPath = this._getAbsolutePath(entryPath);
if (absPath == null) {
throw new NotFoundError(
'Could not find source file at %s',
entryPath
);
}
const absolutePath = path.resolve(absPath);
if (absolutePath == null) {
throw new NotFoundError(