Merge pull request #1283 from vjeux/Updates_Thu_14_May_3

Updates Thu 14 May
This commit is contained in:
Christopher Chedeau 2015-05-14 15:39:25 -07:00
commit 1f8b97aeff
56 changed files with 2380 additions and 2391 deletions

View File

@ -16,6 +16,7 @@
"document": false,
"escape": false,
"exports": false,
"fetch": false,
"global": false,
"jest": false,
"Map": true,

View File

@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
00481BE81AC0C86700671115 /* libRCTWebSocketDebugger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00481BE61AC0C7FA00671115 /* libRCTWebSocketDebugger.a */; };
008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 008F07F21AC5B25A0029DE68 /* main.jsbundle */; };
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */; };
@ -27,13 +26,6 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
00481BE51AC0C7FA00671115 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 832C81801AAF6DEF007FA2F7;
remoteInfo = RCTWebSocketDebugger;
};
00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
@ -114,7 +106,6 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocketDebugger.xcodeproj; path = ../../Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj; sourceTree = "<group>"; };
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = iOS/main.jsbundle; sourceTree = "<group>"; };
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../../Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAdSupport.xcodeproj; path = ../../Libraries/AdSupport/RCTAdSupport.xcodeproj; sourceTree = "<group>"; };
@ -151,30 +142,21 @@
buildActionMask = 2147483647;
files = (
146834051AC3E58100842450 /* libReact.a in Frameworks */,
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
00481BE81AC0C86700671115 /* libRCTWebSocketDebugger.a in Frameworks */,
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */,
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
00481BDC1AC0C7FA00671115 /* Products */ = {
isa = PBXGroup;
children = (
00481BE61AC0C7FA00671115 /* libRCTWebSocketDebugger.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302A81ABCB8CE00DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
@ -291,7 +273,6 @@
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */,
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
@ -426,10 +407,6 @@
ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */;
ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */;
},
{
ProductGroup = 00481BDC1AC0C7FA00671115 /* Products */;
ProjectRef = 00481BDB1AC0C7FA00671115 /* RCTWebSocketDebugger.xcodeproj */;
},
{
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
@ -444,13 +421,6 @@
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
00481BE61AC0C7FA00671115 /* libRCTWebSocketDebugger.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTWebSocketDebugger.a;
remoteRef = 00481BE51AC0C7FA00671115 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;

View File

@ -27,4 +27,3 @@ export type ExampleModule = {
examples: Array<Example>;
external?: bool;
};

View File

@ -29,7 +29,7 @@ var regionText = {
longitude: '0',
latitudeDelta: '0',
longitudeDelta: '0',
}
};
var MapRegionInput = React.createClass({

View File

@ -45,7 +45,7 @@ var NavigatorIOSColors = React.createClass({
render: function() {
// Set StatusBar with light contents to get better contrast
StatusBarIOS.setStyle(StatusBarIOS.Style['lightContent']);
StatusBarIOS.setStyle(StatusBarIOS.Style.lightContent);
return (
<NavigatorIOS

View File

@ -78,7 +78,7 @@ var TabBarExample = React.createClass({
this.setState({
selectedTab: 'greenTab',
presses: this.state.presses + 1
});
});
}}>
{this._renderContent('#21551C', 'Green Tab')}
</TabBarIOS.Item>

View File

@ -387,7 +387,7 @@ exports.examples = [
<View style={styles.multilineChild}/>
</TextInput>
</View>
)
);
}
}
];

View File

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
004D28A31AAF61C70097A701 /* UIExplorerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 004D28A21AAF61C70097A701 /* UIExplorerTests.m */; };
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00D277131AB8C2C700DC1E48 /* libRCTWebSocketDebugger.a */; };
13417FE91AA91432003F314A /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FE81AA91428003F314A /* libRCTImage.a */; };
134180011AA9153C003F314A /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13417FEF1AA914B8003F314A /* libRCTText.a */; };
1341802C1AA9178B003F314A /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1341802B1AA91779003F314A /* libRCTNetwork.a */; };
@ -34,13 +33,6 @@
remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
remoteInfo = UIExplorer;
};
00D277121AB8C2C700DC1E48 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00D2770E1AB8C2C700DC1E48 /* RCTWebSocketDebugger.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 832C81801AAF6DEF007FA2F7;
remoteInfo = RCTWebSocketDebugger;
};
13417FE71AA91428003F314A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 13417FE31AA91428003F314A /* RCTImage.xcodeproj */;
@ -124,7 +116,6 @@
004D289E1AAF61C70097A701 /* UIExplorerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIExplorerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
004D28A11AAF61C70097A701 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
004D28A21AAF61C70097A701 /* UIExplorerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIExplorerTests.m; sourceTree = "<group>"; };
00D2770E1AB8C2C700DC1E48 /* RCTWebSocketDebugger.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocketDebugger.xcodeproj; path = ../../Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj; sourceTree = "<group>"; };
13417FE31AA91428003F314A /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../../Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
13417FEA1AA914B8003F314A /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = "<group>"; };
134180261AA91779003F314A /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../../Libraries/Network/RCTNetwork.xcodeproj; sourceTree = "<group>"; };
@ -159,7 +150,6 @@
files = (
834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */,
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */,
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */,
58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */,
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */,
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */,
@ -192,14 +182,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
00D2770F1AB8C2C700DC1E48 /* Products */ = {
isa = PBXGroup;
children = (
00D277131AB8C2C700DC1E48 /* libRCTWebSocketDebugger.a */,
);
name = Products;
sourceTree = "<group>";
};
1316A21D1AA397F400C0188E /* Libraries */ = {
isa = PBXGroup;
children = (
@ -213,7 +195,6 @@
13CC9D481AEED2B90020D1C2 /* RCTSettings.xcodeproj */,
58005BE41ABA80530062E044 /* RCTTest.xcodeproj */,
13417FEA1AA914B8003F314A /* RCTText.xcodeproj */,
00D2770E1AB8C2C700DC1E48 /* RCTWebSocketDebugger.xcodeproj */,
D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */,
);
name = Libraries;
@ -446,10 +427,6 @@
ProductGroup = D85B82921AB6D5CE003F4FE2 /* Products */;
ProjectRef = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
},
{
ProductGroup = 00D2770F1AB8C2C700DC1E48 /* Products */;
ProjectRef = 00D2770E1AB8C2C700DC1E48 /* RCTWebSocketDebugger.xcodeproj */;
},
{
ProductGroup = 14AADF001AC3DB95002390C9 /* Products */;
ProjectRef = 14AADEFF1AC3DB95002390C9 /* React.xcodeproj */;
@ -464,13 +441,6 @@
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
00D277131AB8C2C700DC1E48 /* libRCTWebSocketDebugger.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTWebSocketDebugger.a;
remoteRef = 00D277121AB8C2C700DC1E48 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
13417FE81AA91428003F314A /* libRCTImage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;

View File

@ -3,37 +3,37 @@
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "uie_icon@2x.png",
"filename" : "Icon-Small@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "uie_icon@2x-1.png",
"filename" : "Icon-Small@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "uie_icon@2x-2.png",
"filename" : "Icon-40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "uie_icon@2x-3.png",
"filename" : "Icon-40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "uie_icon@2x-5.png",
"filename" : "Icon-60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "uie_icon@2x-4.png",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
}
],
@ -41,4 +41,4 @@
"version" : 1,
"author" : "xcode"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

View File

@ -6,7 +6,7 @@
* 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.
*
* @provides StaticRenderer
* @providesModule StaticRenderer
* @flow
*/
'use strict';

View File

@ -87,7 +87,7 @@ var SCROLLVIEW_REF = 'listviewscroll';
* smoothly while dynamically loading potentially very large (or conceptually
* infinite) data sets:
*
* * Only re-render changed rows - the hasRowChanged function provided to the
* * Only re-render changed rows - the rowHasChanged function provided to the
* data source tells the ListView if it needs to re-render a row because the
* source data has changed - see ListViewDataSource for more details.
*

View File

@ -1173,7 +1173,11 @@ var Navigator = React.createClass({
resetTo: function(route) {
invariant(!!route, 'Must supply route to push');
this.replaceAtIndex(route, 0, () => {
this.popToRoute(route);
// Do not use popToRoute here, because race conditions could prevent the
// route from existing at this time. Instead, just go to index 0
if (this.state.presentedIndex > 0) {
this._popN(this.state.presentedIndex);
}
});
},

View File

@ -48,8 +48,10 @@ function reportException(e: Exception, isFatal: bool, stack?: any) {
var prettyStack = parseErrorStack(e, map);
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack);
})
.then(null, error => {
console.error('#CLOWNTOWN (error while displaying error): ' + error.message);
.catch(error => {
// This can happen in a variety of normal situations, such as
// Network module not being available, or when running locally
console.warn('Unable to load source map: ' + error.message);
});
}
}

View File

@ -33,39 +33,6 @@ if (typeof window === 'undefined') {
window = GLOBAL;
}
/**
* The document must be shimmed before anything else that might define the
* `ExecutionEnvironment` module (which checks for `document.createElement`).
*/
function setupDocumentShim() {
// The browser defines Text and Image globals by default. If you forget to
// require them, then the error message is very confusing.
function getInvalidGlobalUseError(name) {
return new Error(
'You are trying to render the global ' + name + ' variable as a ' +
'React element. You probably forgot to require ' + name + '.'
);
}
GLOBAL.Text = {
get defaultProps() {
throw getInvalidGlobalUseError('Text');
}
};
GLOBAL.Image = {
get defaultProps() {
throw getInvalidGlobalUseError('Image');
}
};
// Force `ExecutionEnvironment.canUseDOM` to be false.
if (GLOBAL.document) {
GLOBAL.document.createElement = null;
}
// There is no DOM so MutationObserver doesn't make sense. It is used
// as feature detection in Bluebird Promise implementation
GLOBAL.MutationObserver = undefined;
}
function handleErrorWithRedBox(e, isFatal) {
try {
require('ExceptionsManager').handleException(e, isFatal);
@ -74,12 +41,12 @@ function handleErrorWithRedBox(e, isFatal) {
}
}
function setupRedBoxErrorHandler() {
function setUpRedBoxErrorHandler() {
var ErrorUtils = require('ErrorUtils');
ErrorUtils.setGlobalHandler(handleErrorWithRedBox);
}
function setupRedBoxConsoleErrorHandler() {
function setUpRedBoxConsoleErrorHandler() {
// ExceptionsManager transitively requires Promise so we install it after
var ExceptionsManager = require('ExceptionsManager');
var Platform = require('Platform');
@ -96,7 +63,7 @@ function setupRedBoxConsoleErrorHandler() {
* implement our own custom timing bridge that should be immune to
* unexplainably dropped timing signals.
*/
function setupTimers() {
function setUpTimers() {
var JSTimers = require('JSTimers');
GLOBAL.setTimeout = JSTimers.setTimeout;
GLOBAL.setInterval = JSTimers.setInterval;
@ -111,7 +78,7 @@ function setupTimers() {
};
}
function setupAlert() {
function setUpAlert() {
var RCTAlertManager = require('NativeModules').AlertManager;
if (!GLOBAL.alert) {
GLOBAL.alert = function(text) {
@ -125,13 +92,13 @@ function setupAlert() {
}
}
function setupPromise() {
function setUpPromise() {
// The native Promise implementation throws the following error:
// ERROR: Event loop not supported.
GLOBAL.Promise = require('Promise');
}
function setupXHR() {
function setUpXHR() {
// The native XMLHttpRequest in Chrome dev tools is CORS aware and won't
// let you fetch anything from the internet
GLOBAL.XMLHttpRequest = require('XMLHttpRequest');
@ -143,16 +110,20 @@ function setupXHR() {
GLOBAL.Response = fetchPolyfill.Response;
}
function setupGeolocation() {
function setUpGeolocation() {
GLOBAL.navigator = GLOBAL.navigator || {};
GLOBAL.navigator.geolocation = require('Geolocation');
}
setupDocumentShim();
setupRedBoxErrorHandler();
setupTimers();
setupAlert();
setupPromise();
setupXHR();
setupRedBoxConsoleErrorHandler();
setupGeolocation();
function setUpWebSockets() {
GLOBAL.WebSocket = require('WebSocket');
}
setUpRedBoxErrorHandler();
setUpTimers();
setUpAlert();
setUpPromise();
setUpXHR();
setUpRedBoxConsoleErrorHandler();
setUpGeolocation();
setUpWebSockets();

View File

@ -13,10 +13,13 @@
'use strict';
var Promise = require('Promise');
var RCTSourceCode = require('NativeModules').SourceCode;
var NativeModules = require('NativeModules');
var SourceMapConsumer = require('SourceMap').SourceMapConsumer;
var SourceMapURL = require('./source-map-url');
var RCTSourceCode = NativeModules.SourceCode;
var RCTDataManager = NativeModules.DataManager;
function loadSourceMap(): Promise {
return fetchSourceMap()
.then(map => new SourceMapConsumer(map));
@ -31,17 +34,31 @@ function fetchSourceMap(): Promise {
return Promise.reject(new Error('RCTSourceCode module is not available'));
}
if (!RCTDataManager) {
// Used internally by fetch
return Promise.reject(new Error('RCTDataManager module is not available'));
}
return new Promise(RCTSourceCode.getScriptText)
.then(extractSourceMapURL)
.then((url) => {
if (url === null) {
return Promise.reject(new Error('No source map URL found. May be running from bundled file.'));
}
return Promise.resolve(url);
})
.then(fetch)
.then(response => response.text())
}
function extractSourceMapURL({url, text, fullSourceMappingURL}): string {
function extractSourceMapURL({url, text, fullSourceMappingURL}): ?string {
if (fullSourceMappingURL) {
return fullSourceMappingURL;
}
var mapURL = SourceMapURL.getFrom(text);
if (!mapURL) {
return null;
}
var baseURL = url.match(/(.+:\/\/.*?)\//)[1];
return baseURL + mapURL;
}

View File

@ -0,0 +1,34 @@
/* eslint global-strict: 0 */
(function(GLOBAL) {
/**
* The document must be shimmed before anything else that might define the
* `ExecutionEnvironment` module (which checks for `document.createElement`).
*/
// The browser defines Text and Image globals by default. If you forget to
// require them, then the error message is very confusing.
function getInvalidGlobalUseError(name) {
return new Error(
'You are trying to render the global ' + name + ' variable as a ' +
'React element. You probably forgot to require ' + name + '.'
);
}
GLOBAL.Text = {
get defaultProps() {
throw getInvalidGlobalUseError('Text');
}
};
GLOBAL.Image = {
get defaultProps() {
throw getInvalidGlobalUseError('Image');
}
};
// Force `ExecutionEnvironment.canUseDOM` to be false.
if (GLOBAL.document) {
GLOBAL.document.createElement = null;
}
// There is no DOM so MutationObserver doesn't make sense. It is used
// as feature detection in Bluebird Promise implementation
GLOBAL.MutationObserver = undefined;
})(this);

View File

@ -1,275 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00D277161AB8C32C00DC1E48 /* RCTWebSocketExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 00D277151AB8C32C00DC1E48 /* RCTWebSocketExecutor.m */; };
13AF20421AE707C5005F5298 /* SRWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 13AF20411AE707C5005F5298 /* SRWebSocket.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
832C817E1AAF6DEF007FA2F7 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
00D277141AB8C32C00DC1E48 /* RCTWebSocketExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebSocketExecutor.h; sourceTree = "<group>"; };
00D277151AB8C32C00DC1E48 /* RCTWebSocketExecutor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWebSocketExecutor.m; sourceTree = "<group>"; };
13AF20401AE707C5005F5298 /* SRWebSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRWebSocket.h; sourceTree = "<group>"; };
13AF20411AE707C5005F5298 /* SRWebSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRWebSocket.m; sourceTree = "<group>"; };
832C81801AAF6DEF007FA2F7 /* libRCTWebSocketDebugger.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWebSocketDebugger.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
832C817D1AAF6DEF007FA2F7 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
832C81771AAF6DEF007FA2F7 = {
isa = PBXGroup;
children = (
13AF20401AE707C5005F5298 /* SRWebSocket.h */,
13AF20411AE707C5005F5298 /* SRWebSocket.m */,
00D277141AB8C32C00DC1E48 /* RCTWebSocketExecutor.h */,
00D277151AB8C32C00DC1E48 /* RCTWebSocketExecutor.m */,
832C81811AAF6DEF007FA2F7 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
832C81811AAF6DEF007FA2F7 /* Products */ = {
isa = PBXGroup;
children = (
832C81801AAF6DEF007FA2F7 /* libRCTWebSocketDebugger.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
832C817F1AAF6DEF007FA2F7 /* RCTWebSocketDebugger */ = {
isa = PBXNativeTarget;
buildConfigurationList = 832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTWebSocketDebugger" */;
buildPhases = (
832C817C1AAF6DEF007FA2F7 /* Sources */,
832C817D1AAF6DEF007FA2F7 /* Frameworks */,
832C817E1AAF6DEF007FA2F7 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = RCTWebSocketDebugger;
productName = RCTWebSocketDebugger;
productReference = 832C81801AAF6DEF007FA2F7 /* libRCTWebSocketDebugger.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
832C81781AAF6DEF007FA2F7 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0620;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
832C817F1AAF6DEF007FA2F7 = {
CreatedOnToolsVersion = 6.2;
};
};
};
buildConfigurationList = 832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTWebSocketDebugger" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 832C81771AAF6DEF007FA2F7;
productRefGroup = 832C81811AAF6DEF007FA2F7 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
832C817F1AAF6DEF007FA2F7 /* RCTWebSocketDebugger */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
832C817C1AAF6DEF007FA2F7 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13AF20421AE707C5005F5298 /* SRWebSocket.m in Sources */,
00D277161AB8C32C00DC1E48 /* RCTWebSocketExecutor.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
832C81921AAF6DF0007FA2F7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
832C81931AAF6DF0007FA2F7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
832C81951AAF6DF0007FA2F7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_STATIC_ANALYZER_MODE = deep;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
OTHER_LDFLAGS = (
"-ObjC",
"-llibicucore",
);
PRODUCT_NAME = "$(TARGET_NAME)";
RUN_CLANG_STATIC_ANALYZER = YES;
SKIP_INSTALL = YES;
};
name = Debug;
};
832C81961AAF6DF0007FA2F7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_STATIC_ANALYZER_MODE = deep;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
OTHER_LDFLAGS = (
"-ObjC",
"-llibicucore",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTWebSocketDebugger" */ = {
isa = XCConfigurationList;
buildConfigurations = (
832C81921AAF6DF0007FA2F7 /* Debug */,
832C81931AAF6DF0007FA2F7 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTWebSocketDebugger" */ = {
isa = XCConfigurationList;
buildConfigurations = (
832C81951AAF6DF0007FA2F7 /* Debug */,
832C81961AAF6DF0007FA2F7 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 832C81781AAF6DEF007FA2F7 /* Project object */;
}

View File

@ -1,132 +0,0 @@
//
// Copyright 2012 Square Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
#import <Security/SecCertificate.h>
typedef enum {
SR_CONNECTING = 0,
SR_OPEN = 1,
SR_CLOSING = 2,
SR_CLOSED = 3,
} SRReadyState;
typedef enum SRStatusCode : NSInteger {
SRStatusCodeNormal = 1000,
SRStatusCodeGoingAway = 1001,
SRStatusCodeProtocolError = 1002,
SRStatusCodeUnhandledType = 1003,
// 1004 reserved.
SRStatusNoStatusReceived = 1005,
// 1004-1006 reserved.
SRStatusCodeInvalidUTF8 = 1007,
SRStatusCodePolicyViolated = 1008,
SRStatusCodeMessageTooBig = 1009,
} SRStatusCode;
@class SRWebSocket;
extern NSString *const SRWebSocketErrorDomain;
extern NSString *const SRHTTPResponseErrorKey;
#pragma mark - SRWebSocketDelegate
@protocol SRWebSocketDelegate;
#pragma mark - SRWebSocket
@interface SRWebSocket : NSObject <NSStreamDelegate>
@property (nonatomic, weak) id <SRWebSocketDelegate> delegate;
@property (nonatomic, readonly) SRReadyState readyState;
@property (nonatomic, readonly, retain) NSURL *url;
// This returns the negotiated protocol.
// It will be nil until after the handshake completes.
@property (nonatomic, readonly, copy) NSString *protocol;
// Protocols should be an array of strings that turn into Sec-WebSocket-Protocol.
- (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols;
- (id)initWithURLRequest:(NSURLRequest *)request;
// Some helper constructors.
- (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols;
- (id)initWithURL:(NSURL *)url;
// Delegate queue will be dispatch_main_queue by default.
// You cannot set both OperationQueue and dispatch_queue.
- (void)setDelegateOperationQueue:(NSOperationQueue*) queue;
- (void)setDelegateDispatchQueue:(dispatch_queue_t) queue;
// By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using defaultModes.
- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode;
- (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode;
// SRWebSockets are intended for one-time-use only. Open should be called once and only once.
- (void)open;
- (void)close;
- (void)closeWithCode:(NSInteger)code reason:(NSString *)reason;
// Send a UTF8 String or Data.
- (void)send:(id)data;
// Send Data (can be nil) in a ping message.
- (void)sendPing:(NSData *)data;
@end
#pragma mark - SRWebSocketDelegate
@protocol SRWebSocketDelegate <NSObject>
// message will either be an NSString if the server is using text
// or NSData if the server is using binary.
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message;
@optional
- (void)webSocketDidOpen:(SRWebSocket *)webSocket;
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error;
- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;
- (void)webSocket:(SRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload;
@end
#pragma mark - NSURLRequest (CertificateAdditions)
@interface NSURLRequest (CertificateAdditions)
@property (nonatomic, retain, readonly) NSArray *SR_SSLPinnedCertificates;
@end
#pragma mark - NSMutableURLRequest (CertificateAdditions)
@interface NSMutableURLRequest (CertificateAdditions)
@property (nonatomic, retain) NSArray *SR_SSLPinnedCertificates;
@end
#pragma mark - NSRunLoop (SRWebSocket)
@interface NSRunLoop (SRWebSocket)
+ (NSRunLoop *)SR_networkRunLoop;
@end

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@ var findNodeHandle = require('findNodeHandle');
var flattenStyle = require('flattenStyle');
var invariant = require('invariant');
var mergeFast = require('mergeFast');
var mountSafeCallback = require('mountSafeCallback');
var precomputeStyle = require('precomputeStyle');
type MeasureOnSuccessCallback = (
@ -52,7 +53,11 @@ var animationIDInvariant = function(
var NativeMethodsMixin = {
addAnimation: function(anim: number, callback?: (finished: bool) => void) {
animationIDInvariant('addAnimation', anim);
RCTPOPAnimationManager.addAnimation(findNodeHandle(this), anim, callback);
RCTPOPAnimationManager.addAnimation(
findNodeHandle(this),
anim,
mountSafeCallback(this, callback)
);
},
removeAnimation: function(anim: number) {
@ -61,7 +66,10 @@ var NativeMethodsMixin = {
},
measure: function(callback: MeasureOnSuccessCallback) {
RCTUIManager.measure(findNodeHandle(this), callback);
RCTUIManager.measure(
findNodeHandle(this),
mountSafeCallback(this, callback)
);
},
measureLayout: function(
@ -72,8 +80,8 @@ var NativeMethodsMixin = {
RCTUIManager.measureLayout(
findNodeHandle(this),
relativeToNativeNode,
onFail,
onSuccess
mountSafeCallback(this, onFail),
mountSafeCallback(this, onSuccess)
);
},

View File

@ -12,7 +12,6 @@
'use strict';
var NativeMethodsMixin = require('NativeMethodsMixin');
var ReactNativeComponentMixin = require('ReactNativeComponentMixin');
var ReactNativeEventEmitter = require('ReactNativeEventEmitter');
var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
var ReactNativeTagHandles = require('ReactNativeTagHandles');
@ -275,8 +274,7 @@ Object.assign(
ReactNativeBaseComponent.prototype,
ReactMultiChild.Mixin,
ReactNativeBaseComponent.Mixin,
NativeMethodsMixin,
ReactNativeComponentMixin
NativeMethodsMixin
);
module.exports = ReactNativeBaseComponent;

View File

@ -1,32 +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.
*
* @providesModule ReactNativeComponentMixin
* @flow
*/
'use strict';
var findNodeHandle = require('findNodeHandle');
var ReactNativeComponentMixin = {
/**
* This method is deprecated; use `React.findNodeHandle` instead.
*/
getNativeNode: function() {
return findNodeHandle(this);
},
/**
* This method is deprecated; use `React.findNodeHandle` instead.
*/
getNodeHandle: function() {
return findNodeHandle(this);
}
};
module.exports = ReactNativeComponentMixin;

View File

@ -27,7 +27,6 @@ var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
var ReactEmptyComponent = require('ReactEmptyComponent');
var ReactInstanceHandles = require('ReactInstanceHandles');
var ReactNativeComponentEnvironment = require('ReactNativeComponentEnvironment');
var ReactNativeComponentMixin = require('ReactNativeComponentMixin');
var ReactNativeGlobalInteractionHandler = require('ReactNativeGlobalInteractionHandler');
var ReactNativeGlobalResponderHandler = require('ReactNativeGlobalResponderHandler');
var ReactNativeMount = require('ReactNativeMount');
@ -90,8 +89,6 @@ function inject() {
EventPluginUtils.injection.injectMount(ReactNativeMount);
ReactClass.injection.injectMixin(ReactNativeComponentMixin);
ReactNativeComponent.injection.injectTextComponentClass(
ReactNativeTextComponent
);

View File

@ -25,6 +25,9 @@
if ((self = [super initWithFrame:frame])) {
_textStorage = [[NSTextStorage alloc] init];
self.isAccessibilityElement = YES;
self.accessibilityTraits |= UIAccessibilityTraitStaticText;
self.opaque = NO;
self.contentMode = UIViewContentModeRedraw;
}
@ -127,4 +130,11 @@
return reactTag ?: self.reactTag;
}
#pragma mark - Accessibility
- (NSString *)accessibilityLabel
{
return _textStorage.string;
}
@end

View File

@ -21,8 +21,10 @@
@property (nonatomic, assign) BOOL selectTextOnFocus;
@property (nonatomic, assign) UIEdgeInsets contentInset;
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
@property (nonatomic, copy) NSString *text;
@property (nonatomic, strong) UIColor *textColor;
@property (nonatomic, strong) UIColor *placeholderTextColor;
@property (nonatomic, assign) UIFont *font;
@property (nonatomic, strong) UIFont *font;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;

View File

@ -72,13 +72,22 @@
}
}
- (UIFont *)font
{
return _textView.font;
}
- (void)setFont:(UIFont *)font
{
_font = font;
_textView.font = _font;
_textView.font = font;
[self updatePlaceholder];
}
- (UIColor *)textColor
{
return _textView.textColor;
}
- (void)setTextColor:(UIColor *)textColor
{
_textView.textColor = textColor;
@ -106,6 +115,11 @@
[self updateFrames];
}
- (NSString *)text
{
return _textView.text;
}
- (void)setText:(NSString *)text
{
if (![text isEqualToString:_textView.text]) {
@ -146,7 +160,6 @@
- (void)textViewDidBeginEditing:(UITextView *)textView
{
if (_clearTextOnFocus) {
[_textView setText:@""];
_textView.text = @"";
[self _setPlaceholderVisibility];
}

View File

@ -0,0 +1,23 @@
/**
* 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.
*
* @providesModule mountSafeCallback
* @flow
*/
'use strict';
var mountSafeCallback = function(context: ReactComponent, callback: ?Function): any {
return function() {
if (!callback || !context.isMounted()) {
return;
}
return callback.apply(context, arguments);
};
};
module.exports = mountSafeCallback;

View File

@ -0,0 +1,132 @@
//
// Copyright 2012 Square Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
#import <Security/SecCertificate.h>
typedef enum {
RCTSR_CONNECTING = 0,
RCTSR_OPEN = 1,
RCTSR_CLOSING = 2,
RCTSR_CLOSED = 3,
} RCTSRReadyState;
typedef enum RCTSRStatusCode : NSInteger {
RCTSRStatusCodeNormal = 1000,
RCTSRStatusCodeGoingAway = 1001,
RCTSRStatusCodeProtocolError = 1002,
RCTSRStatusCodeUnhandledType = 1003,
// 1004 reserved.
RCTSRStatusNoStatusReceived = 1005,
// 1004-1006 reserved.
RCTSRStatusCodeInvalidUTF8 = 1007,
RCTSRStatusCodePolicyViolated = 1008,
RCTSRStatusCodeMessageTooBig = 1009,
} RCTSRStatusCode;
@class RCTSRWebSocket;
extern NSString *const RCTSRWebSocketErrorDomain;
extern NSString *const RCTSRHTTPResponseErrorKey;
#pragma mark - RCTSRWebSocketDelegate
@protocol RCTSRWebSocketDelegate;
#pragma mark - RCTSRWebSocket
@interface RCTSRWebSocket : NSObject <NSStreamDelegate>
@property (nonatomic, weak) id<RCTSRWebSocketDelegate> delegate;
@property (nonatomic, readonly) RCTSRReadyState readyState;
@property (nonatomic, readonly, strong) NSURL *url;
// This returns the negotiated protocol.
// It will be nil until after the handshake completes.
@property (nonatomic, readonly, copy) NSString *protocol;
// Protocols should be an array of strings that turn into Sec-WebSocket-Protocol.
- (instancetype)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithURLRequest:(NSURLRequest *)request;
// Some helper constructors.
- (instancetype)initWithURL:(NSURL *)url protocols:(NSArray *)protocols;
- (instancetype)initWithURL:(NSURL *)url;
// Delegate queue will be dispatch_main_queue by default.
// You cannot set both OperationQueue and dispatch_queue.
- (void)setDelegateOperationQueue:(NSOperationQueue*) queue;
- (void)setDelegateDispatchQueue:(dispatch_queue_t) queue;
// By default, it will schedule itself on +[NSRunLoop RCTSR_networkRunLoop] using defaultModes.
- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode;
- (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode;
// RCTSRWebSockets are intended for one-time-use only. Open should be called once and only once.
- (void)open;
- (void)close;
- (void)closeWithCode:(NSInteger)code reason:(NSString *)reason;
// Send a UTF8 String or Data.
- (void)send:(id)data;
// Send Data (can be nil) in a ping message.
- (void)sendPing:(NSData *)data;
@end
#pragma mark - RCTSRWebSocketDelegate
@protocol RCTSRWebSocketDelegate <NSObject>
// message will either be an NSString if the server is using text
// or NSData if the server is using binary.
- (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message;
@optional
- (void)webSocketDidOpen:(RCTSRWebSocket *)webSocket;
- (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error;
- (void)webSocket:(RCTSRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;
- (void)webSocket:(RCTSRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload;
@end
#pragma mark - NSURLRequest (CertificateAdditions)
@interface NSURLRequest (CertificateAdditions)
@property (nonatomic, readonly, copy) NSArray *RCTSR_SSLPinnedCertificates;
@end
#pragma mark - NSMutableURLRequest (CertificateAdditions)
@interface NSMutableURLRequest (CertificateAdditions)
@property (nonatomic, copy) NSArray *RCTSR_SSLPinnedCertificates;
@end
#pragma mark - NSRunLoop (RCTSRWebSocket)
@interface NSRunLoop (RCTSRWebSocket)
+ (NSRunLoop *)RCTSR_networkRunLoop;
@end

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
@interface RCTWebSocketExecutor : NSObject <RCTJavaScriptExecutor>
- (instancetype)initWithURL:(NSURL *)URL;
- (instancetype)initWithURL:(NSURL *)URL NS_DESIGNATED_INITIALIZER;
@end

View File

@ -16,16 +16,17 @@
#import "RCTLog.h"
#import "RCTSparseArray.h"
#import "RCTUtils.h"
#import "SRWebSocket.h"
#import "RCTSRWebSocket.h"
typedef void (^WSMessageCallback)(NSError *error, NSDictionary *reply);
typedef void (^RCTWSMessageCallback)(NSError *error, NSDictionary *reply);
@interface RCTWebSocketExecutor () <RCTSRWebSocketDelegate>
@interface RCTWebSocketExecutor () <SRWebSocketDelegate>
@end
@implementation RCTWebSocketExecutor
{
SRWebSocket *_socket;
RCTSRWebSocket *_socket;
dispatch_queue_t _jsQueue;
RCTSparseArray *_callbacks;
dispatch_semaphore_t _socketOpenSemaphore;
@ -42,7 +43,7 @@ typedef void (^WSMessageCallback)(NSError *error, NSDictionary *reply);
if (self = [super init]) {
_jsQueue = dispatch_queue_create("com.facebook.React.WebSocketExecutor", DISPATCH_QUEUE_SERIAL);
_socket = [[SRWebSocket alloc] initWithURL:URL];
_socket = [[RCTSRWebSocket alloc] initWithURL:URL];
_socket.delegate = self;
_callbacks = [[RCTSparseArray alloc] init];
_injectedObjects = [[NSMutableDictionary alloc] init];
@ -95,28 +96,28 @@ typedef void (^WSMessageCallback)(NSError *error, NSDictionary *reply);
return runtimeIsReady == 0 && initError == nil;
}
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message
- (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message
{
NSError *error = nil;
NSDictionary *reply = RCTJSONParse(message, &error);
NSNumber *messageID = reply[@"replyID"];
WSMessageCallback callback = _callbacks[messageID];
RCTWSMessageCallback callback = _callbacks[messageID];
if (callback) {
callback(error, reply);
}
}
- (void)webSocketDidOpen:(SRWebSocket *)webSocket
- (void)webSocketDidOpen:(RCTSRWebSocket *)webSocket
{
dispatch_semaphore_signal(_socketOpenSemaphore);
}
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error
- (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error
{
RCTLogError(@"WebSocket connection failed with error %@", error);
}
- (void)sendMessage:(NSDictionary *)message context:(NSNumber *)executorID waitForReply:(WSMessageCallback)callback
- (void)sendMessage:(NSDictionary *)message context:(NSNumber *)executorID waitForReply:(RCTWSMessageCallback)callback
{
static NSUInteger lastID = 10000;
@ -190,7 +191,7 @@ typedef void (^WSMessageCallback)(NSError *error, NSDictionary *reply);
- (BOOL)isValid
{
return _socket != nil && _socket.readyState == SR_OPEN;
return _socket != nil && _socket.readyState == RCTSR_OPEN;
}
- (void)dealloc

View File

@ -0,0 +1,14 @@
/**
* 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 "RCTBridgeModule.h"
@interface RCTWebSocketManager : NSObject <RCTBridgeModule>
@end

View File

@ -0,0 +1,116 @@
/**
* 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 "RCTWebSocketManager.h"
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
#import "RCTSRWebSocket.h"
#import "RCTSparseArray.h"
@implementation RCTSRWebSocket (React)
- (NSNumber *)reactTag
{
return objc_getAssociatedObject(self, _cmd);
}
- (void)setReactTag:(NSNumber *)reactTag
{
objc_setAssociatedObject(self, @selector(reactTag), reactTag, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
@end
@interface RCTWebSocketManager () <RCTSRWebSocketDelegate>
@end
@implementation RCTWebSocketManager
{
RCTSparseArray *_sockets;
}
RCT_EXPORT_MODULE()
@synthesize bridge = _bridge;
- (instancetype)init
{
if ((self = [super init])) {
_sockets = [[RCTSparseArray alloc] init];
}
return self;
}
- (void)dealloc
{
for (RCTSRWebSocket *socket in _sockets.allObjects) {
socket.delegate = nil;
[socket close];
}
}
RCT_EXPORT_METHOD(connect:(NSURL *)URL socketID:(NSNumber *)socketID)
{
RCTSRWebSocket *webSocket = [[RCTSRWebSocket alloc] initWithURL:URL];
webSocket.delegate = self;
webSocket.reactTag = socketID;
_sockets[socketID] = webSocket;
[webSocket open];
}
RCT_EXPORT_METHOD(send:(NSString *)message socketID:(NSNumber *)socketID)
{
[_sockets[socketID] send:message];
}
RCT_EXPORT_METHOD(close:(NSNumber *)socketID)
{
[_sockets[socketID] close];
_sockets[socketID] = nil;
}
#pragma mark - RCTSRWebSocketDelegate methods
- (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message
{
[_bridge.eventDispatcher sendDeviceEventWithName:@"websocketMessage" body:@{
@"data": message,
@"id": webSocket.reactTag
}];
}
- (void)webSocketDidOpen:(RCTSRWebSocket *)webSocket
{
[_bridge.eventDispatcher sendDeviceEventWithName:@"websocketOpen" body:@{
@"id": webSocket.reactTag
}];
}
- (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error
{
[_bridge.eventDispatcher sendDeviceEventWithName:@"websocketFailed" body:@{
@"message":[error localizedDescription],
@"id": webSocket.reactTag
}];
}
- (void)webSocket:(RCTSRWebSocket *)webSocket didCloseWithCode:(NSInteger)code
reason:(NSString *)reason wasClean:(BOOL)wasClean
{
[_bridge.eventDispatcher sendDeviceEventWithName:@"websocketClosed" body:@{
@"code": @(code),
@"reason": reason,
@"clean": @(wasClean),
@"id": webSocket.reactTag
}];
}
@end

View File

@ -0,0 +1,39 @@
/**
* 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.
*
* @providesModule WebSocket
*
*/
'use strict';
var WebSocketBase = require('WebSocketBase');
class WebSocket extends WebSocketBase {
connectToSocketImpl(url: string): void {
console.warn('WebSocket is not yet supported on Android');
}
closeConnectionImpl(): void{
console.warn('WebSocket is not yet supported on Android');
}
cancelConnectionImpl(): void {
console.warn('WebSocket is not yet supported on Android');
}
sendStringImpl(message: string): void {
console.warn('WebSocket is not yet supported on Android');
}
sendArrayBufferImpl(): void {
console.warn('WebSocket is not yet supported on Android');
}
}
module.exports = WebSocket;

View File

@ -0,0 +1,104 @@
/**
* 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.
*
* @providesModule WebSocket
*
*/
'use strict';
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var RCTWebSocketManager = require('NativeModules').WebSocketManager;
var WebSocketBase = require('WebSocketBase');
var WebSocketId = 0;
class WebSocket extends WebSocketBase {
_socketId: number;
_subs: any;
connectToSocketImpl(url: string): void {
this._socketId = WebSocketId++;
RCTWebSocketManager.connect(url, this._socketId);
this._registerEvents(this._socketId);
}
closeConnectionImpl(): void {
RCTWebSocketManager.close(this._socketId);
}
cancelConnectionImpl(): void {
RCTWebSocketManager.close(this._socketId);
}
sendStringImpl(message: string): void {
RCTWebSocketManager.send(message, this._socketId);
}
sendArrayBufferImpl(): void {
// TODO
console.warn('Sending ArrayBuffers is not yet supported');
}
_unregisterEvents(): void {
this._subs.forEach(e => e.remove());
this._subs = [];
}
_registerEvents(id: number): void {
this._subs = [
RCTDeviceEventEmitter.addListener(
'websocketMessage',
function(ev) {
if (ev.id !== id) {
return;
}
this.onmessage && this.onmessage({
data: ev.data
});
}.bind(this)
),
RCTDeviceEventEmitter.addListener(
'websocketOpen',
function(ev) {
if (ev.id !== id) {
return;
}
this.readyState = this.OPEN;
this.onopen && this.onopen();
}.bind(this)
),
RCTDeviceEventEmitter.addListener(
'websocketClosed',
function(ev) {
if (ev.id !== id) {
return;
}
this.readyState = this.CLOSED;
this.onclose && this.onclose(ev);
this._unregisterEvents();
RCTWebSocketManager.close(id);
}.bind(this)
),
RCTDeviceEventEmitter.addListener(
'websocketFailed',
function(ev) {
if (ev.id !== id) {
return;
}
this.onerror && this.onerror(new Error(ev.message));
this._unregisterEvents();
RCTWebSocketManager.close(id);
}.bind(this)
)
];
}
}
module.exports = WebSocket;

View File

@ -0,0 +1,97 @@
/**
* 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.
*
* @providesModule WebSocketBase
*
*/
'use strict';
/**
* Shared base for platform-specific WebSocket implementations.
*/
class WebSocketBase {
CONNECTING: number;
OPEN: number;
CLOSING: number;
CLOSED: number;
onclose: ?Function;
onerror: ?Function;
onmessage: ?Function;
onopen: ?Function;
binaryType: ?string;
bufferedAmount: number;
extension: ?string;
protocol: ?string;
readyState: number;
url: ?string;
constructor(url: string, protocols: ?any) {
this.CONNECTING = 0;
this.OPEN = 1;
this.CLOSING = 2;
this.CLOSED = 3;
if (!protocols) {
protocols = [];
}
this.connectToSocketImpl(url);
}
close(): void {
if (this.readyState === WebSocketBase.CLOSING ||
this.readyState === WebSocketBase.CLOSED) {
return;
}
if (this.readyState === WebSocketBase.CONNECTING) {
this.cancelConnectionImpl();
}
this.closeConnectionImpl();
}
send(data: any): void {
if (this.readyState === WebSocketBase.CONNECTING) {
throw new Error('INVALID_STATE_ERR');
}
if (typeof data === 'string') {
this.sendStringImpl(data);
} else if (data instanceof ArrayBuffer) {
this.sendArrayBufferImpl(data);
} else {
throw new Error('Not supported data type');
}
}
closeConnectionImpl(): void {
throw new Error('Subclass must define closeConnectionImpl method');
}
connectToSocketImpl(): void {
throw new Error('Subclass must define connectToSocketImpl method');
}
cancelConnectionImpl(): void {
throw new Error('Subclass must define cancelConnectionImpl method');
}
sendStringImpl(): void {
throw new Error('Subclass must define sendStringImpl method');
}
sendArrayBufferImpl(): void {
throw new Error('Subclass must define sendArrayBufferImpl method');
}
}
module.exports = WebSocketBase;

View File

@ -80,10 +80,10 @@ Pod::Spec.new do |s|
ss.preserve_paths = "Libraries/PushNotificationIOS/*.js"
end
s.subspec 'RCTWebSocketDebugger' do |ss|
s.subspec 'RCTSettings' do |ss|
ss.dependency 'React/Core'
ss.libraries = 'icucore'
ss.source_files = "Libraries/RCTWebSocketDebugger/*.{h,m}"
ss.source_files = "Libraries/Settings/*.{h,m}"
ss.preserve_paths = "Libraries/Settings/*.js"
end
s.subspec 'RCTText' do |ss|
@ -97,4 +97,10 @@ Pod::Spec.new do |s|
ss.source_files = "Libraries/Vibration/*.{h,m}"
ss.preserve_paths = "Libraries/Vibration/*.js"
end
s.subspec 'RCTWebSocket' do |ss|
ss.dependency 'React/Core'
ss.source_files = "Libraries/WebSocket/*.{h,m}"
ss.preserve_paths = "Libraries/WebSocket/*.js"
end
end

View File

@ -81,7 +81,7 @@ RCT_EXPORT_MODULE()
object:nil];
[notificationCenter addObserver:self
selector:@selector(updateSettings)
selector:@selector(settingsDidChange)
name:NSUserDefaultsDidChangeNotification
object:nil];
@ -94,13 +94,11 @@ RCT_EXPORT_MODULE()
_settings = [[NSMutableDictionary alloc] init];
// Delay setup until after Bridge init
__weak RCTDevMenu *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf updateSettings];
});
[self settingsDidChange];
#if TARGET_IPHONE_SIMULATOR
__weak RCTDevMenu *weakSelf = self;
RCTKeyCommands *commands = [RCTKeyCommands sharedInstance];
// Toggle debug menu
@ -127,6 +125,15 @@ RCT_EXPORT_MODULE()
return dispatch_get_main_queue();
}
- (void)settingsDidChange
{
// Needed to prevent a race condition when reloading
__weak RCTDevMenu *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf updateSettings];
});
}
- (void)updateSettings
{
NSDictionary *settings = [_defaults objectForKey:RCTDevMenuSettingsKey];
@ -269,6 +276,14 @@ RCT_EXPORT_METHOD(reload)
}
case 1: {
Class cls = NSClassFromString(@"RCTWebSocketExecutor");
if (!cls) {
[[[UIAlertView alloc] initWithTitle:@"Chrome Debugger Unavailable"
message:@"You need to include the RCTWebSocket library to enable Chrome debugging"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
return;
}
self.executorClass = (_executorClass == cls) ? Nil : cls;
break;
}

View File

@ -56,7 +56,7 @@
- (void)setLeftButtonIcon:(UIImage *)leftButtonIcon
{
_leftButtonIcon = leftButtonIcon;
_leftButtonIcon = nil;
_leftButtonItem = nil;
}
- (UIBarButtonItem *)leftButtonItem

View File

@ -1,6 +1,6 @@
{
"name": "react-native",
"version": "0.4.2",
"version": "0.4.1",
"description": "A framework for building native apps using React",
"repository": {
"type": "git",

View File

@ -25,7 +25,7 @@
},
"dependencies": {},
"devDependencies": {
"jest-cli": "0.2.1",
"jest-cli": "0.4.3",
"eslint": "0.9.2"
}
}

View File

@ -200,7 +200,12 @@ function getAppMiddleware(options) {
cacheVersion: '2',
transformModulePath: require.resolve('./transformer.js'),
assetRoots: options.assetRoots,
assetExts: ['png', 'jpeg', 'jpg']
assetExts: ['png', 'jpeg', 'jpg'],
polyfillModuleNames: [
require.resolve(
'../Libraries/JavaScriptAppEngine/polyfills/document.js'
),
],
});
}

View File

@ -31,6 +31,10 @@ var validateOpts = declareOpts({
type: 'array',
required: true,
},
transformModulePath: {
type:'string',
required: true,
},
});
module.exports = Cache;
@ -162,6 +166,8 @@ function cacheFilePath(options) {
var cacheVersion = options.cacheVersion || '0';
hash.update(cacheVersion);
hash.update(options.transformModulePath);
var name = 'react-packager-cache-' + hash.digest('hex');
return path.join(tmpdir, name);
}

View File

@ -32,10 +32,14 @@ describe('JSTransformer Cache', function() {
describe('getting/setting', function() {
it('calls loader callback for uncached file', function() {
var cache = new Cache({projectRoots: ['/rootDir']});
var cache = new Cache({
projectRoots: ['/rootDir'],
transformModulePath: 'x.js',
});
var loaderCb = jest.genMockFn().mockImpl(function() {
return Promise.resolve();
});
cache.get('/rootDir/someFile', loaderCb);
expect(loaderCb).toBeCalledWith('/rootDir/someFile');
});
@ -48,10 +52,15 @@ describe('JSTransformer Cache', function() {
}
});
});
var cache = new Cache({projectRoots: ['/rootDir']});
var cache = new Cache({
projectRoots: ['/rootDir'],
transformModulePath: 'x.js',
});
var loaderCb = jest.genMockFn().mockImpl(function() {
return Promise.resolve('lol');
});
return cache.get('/rootDir/someFile', loaderCb).then(function(value) {
expect(value).toBe('lol');
});
@ -65,10 +74,15 @@ describe('JSTransformer Cache', function() {
}
});
});
var cache = new Cache({projectRoots: ['/rootDir']});
var cache = new Cache({
projectRoots: ['/rootDir'],
transformModulePath: 'x.js',
});
var loaderCb = jest.genMockFn().mockImpl(function() {
return Promise.resolve('lol');
});
return cache.get('/rootDir/someFile', loaderCb).then(function() {
var shouldNotBeCalled = jest.genMockFn();
return cache.get('/rootDir/someFile', shouldNotBeCalled)
@ -126,8 +140,12 @@ describe('JSTransformer Cache', function() {
});
pit('should load cache from disk', function() {
var cache = new Cache({projectRoots: ['/rootDir']});
var cache = new Cache({
projectRoots: ['/rootDir'],
transformModulePath: 'x.js',
});
var loaderCb = jest.genMockFn();
return cache.get('/rootDir/someFile', loaderCb).then(function(value) {
expect(loaderCb).not.toBeCalled();
expect(value).toBe('oh hai');
@ -152,7 +170,10 @@ describe('JSTransformer Cache', function() {
return 123;
};
var cache = new Cache({projectRoots: ['/rootDir']});
var cache = new Cache({
projectRoots: ['/rootDir'],
transformModulePath: 'x.js',
});
var loaderCb = jest.genMockFn().mockImpl(function() {
return Promise.resolve('new value');
});
@ -193,7 +214,11 @@ describe('JSTransformer Cache', function() {
});
});
var cache = new Cache({projectRoots: ['/rootDir']});
var cache = new Cache({
projectRoots: ['/rootDir'],
transformModulePath: 'x.js',
});
cache.get('/rootDir/bar', function() {
return Promise.resolve('bar value');
});

View File

@ -60,6 +60,7 @@ function Transformer(options) {
resetCache: options.resetCache,
cacheVersion: options.cacheVersion,
projectRoots: options.projectRoots,
transformModulePath: options.transformModulePath,
});
if (options.transformModulePath != null) {