From 5de06a7aa86318ad38720728022b80e5cf98a2ab Mon Sep 17 00:00:00 2001 From: yuji Date: Wed, 29 Apr 2015 02:28:34 +0800 Subject: [PATCH] fixes #3 & supports react-native 0.4.1 --- dist/index.js | 11 +- examples/examples/index.js | 11 +- examples/examples/swiper_number.js | 71 +++ examples/index.ios.js | 1 + .../contents.xcworkspacedata | 7 + .../Examples/SampleApp/iOS/AppDelegate.m | 41 +- .../Examples/SampleApp/iOS/main.jsbundle | 7 +- .../RCTActionSheet.xcodeproj/project.pbxproj | 4 + .../xcschemes/RCTActionSheet.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTActionSheet.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../ActionSheetIOS/RCTActionSheetManager.m | 125 ++--- .../RCTAdSupport.xcodeproj/project.pbxproj | 3 + .../xcschemes/RCTAdSupport.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTAdSupport.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../Libraries/Animation/AnimationUtils.js | 3 + .../xcschemes/RCTAnimation.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 22 - .../RCTAnimationExperimental.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 22 - .../RCTAnimationExperimentalManager.m | 9 +- .../__mocks__/NativeModules.js | 44 ++ .../ActivityIndicatorIOS.ios.js | 26 +- .../DatePicker/DatePickerIOS.ios.js | 19 +- .../Libraries/Components/MapView/MapView.js | 68 ++- .../Components/Navigation/NavigatorIOS.ios.js | 14 +- .../Components/ScrollView/ScrollView.js | 4 - .../Components/SliderIOS/SliderIOS.js | 35 +- .../Components/SwitchIOS/SwitchIOS.ios.js | 27 +- .../Components/TabBarIOS/TabBarIOS.ios.js | 9 +- .../Components/TabBarIOS/TabBarItemIOS.ios.js | 19 +- .../Components/TextInput/TextInput.js | 3 + .../Libraries/Components/View/View.js | 30 +- .../Components/View/ViewStylePropTypes.js | 3 + .../Components/WebView/WebView.ios.js | 27 +- .../CustomComponents/Navigator/Navigator.js | 120 ++++- .../NavigatorBreadcrumbNavigationBar.js | 33 +- ...igatorBreadcrumbNavigationBarStyles.ios.js | 9 +- .../Navigator/NavigatorNavigationBar.js | 2 +- .../NavigatorNavigationBarStyles.ios.js | 1 - .../{Geolocation.ios.js => Geolocation.js} | 0 .../RCTGeolocation.xcodeproj/project.pbxproj | 3 + .../xcschemes/RCTGeolocation.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTGeolocation.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../GeoLocation/RCTLocationObserver.m | 130 +++--- .../react-native/Libraries/Image/Image.ios.js | 54 +-- .../Libraries/Image/ImageResizeMode.js | 4 +- .../Libraries/Image/RCTGIFImage.m | 1 - .../Image/RCTImage.xcodeproj/project.pbxproj | 4 + .../xcschemes/RCTImage.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTImage.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../xcschemes/RCTNetworkImage.xcscheme | 110 ----- .../xcschemes/xcschememanagement.plist | 27 -- .../__tests__/resolveAssetSource-test.js | 135 ++++++ .../Libraries/Image/resolveAssetSource.js | 101 +++++ .../Initialization/ExceptionsManager.js | 2 +- .../Initialization/loadSourceMap.js | 8 +- .../Libraries/LinkingIOS/LinkingIOS.js | 4 + .../xcschemes/RCTLinking.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTLinking.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../Libraries/LinkingIOS/RCTLinkingManager.h | 2 +- .../Libraries/LinkingIOS/RCTLinkingManager.m | 7 + .../react-native/Libraries/Network/NetInfo.js | 4 +- .../xcschemes/RCTDataManager.xcscheme | 110 ----- .../xcschemes/xcschememanagement.plist | 27 -- .../RCTNetwork.xcodeproj/project.pbxproj | 3 + .../xcschemes/RCTNetwork.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTNetwork.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../Libraries/Network/RCTReachability.m | 6 +- .../Libraries/Network/XMLHttpRequestBase.js | 20 +- .../project.pbxproj | 3 + .../xcschemes/RCTPushNotification.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 22 - .../RCTPushNotificationManager.h | 2 +- .../RCTPushNotificationManager.m | 2 +- .../RCTTest/RCTTest.xcodeproj/project.pbxproj | 3 + .../xcschemes/RCTTest.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 22 - .../Libraries/RCTTest/RCTTestModule.h | 23 +- .../Libraries/RCTTest/RCTTestModule.m | 41 +- .../Libraries/RCTTest/RCTTestRunner.m | 47 +- .../project.pbxproj | 15 +- .../xcschemes/RCTWebSocketDebugger.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTWebSocketDebugger.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../RCTWebSocketExecutor.h | 6 + .../RCTWebSocketExecutor.m | 27 +- .../RCTWebSocketDebugger/SRWebSocket.m | 4 +- .../Libraries/ReactIOS/NativeMethodsMixin.js | 3 +- .../Libraries/ReactIOS/ReactIOSMount.js | 2 +- .../ReactIOS/ReactIOSNativeComponent.js | 3 +- .../ReactIOS/requireNativeComponent.js | 9 +- .../Libraries/ReactIOS/verifyPropTypes.js | 2 +- .../Libraries/StyleSheet/precomputeStyle.js | 161 +++++++ .../Libraries/Text/RCTShadowText.m | 8 +- .../react-native/Libraries/Text/RCTText.m | 20 +- .../Text/RCTText.xcodeproj/project.pbxproj | 3 + .../xcschemes/RCTText.xcscheme | 35 +- .../xcschemes/xcschememanagement.plist | 5 - .../xcschemes/RCTText.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - .../Libraries/Text/RCTTextManager.m | 2 +- .../Libraries/Utilities/AlertIOS.js | 2 +- .../Libraries/Utilities/MatrixMath.js | 131 ++++++ .../Libraries/Utilities/MessageQueue.js | 32 +- .../Libraries/Utilities/PixelRatio.js | 15 +- .../Utilities/__mocks__/ErrorUtils.js | 23 + .../Utilities/__mocks__/PixelRatio.js | 20 + .../differ/__tests__/deepDiffer-test.js | 102 +++++ .../Libraries/Utilities/differ/deepDiffer.js | 29 +- .../RCTVibration.xcodeproj/project.pbxproj | 3 + .../xcschemes/RCTVibration.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/RCTVibration.xcscheme | 77 ---- .../xcschemes/xcschememanagement.plist | 8 - examples/node_modules/react-native/README.md | 24 +- .../react-native/React/Base/RCTAssert.h | 31 +- .../react-native/React/Base/RCTBridge.h | 25 +- .../react-native/React/Base/RCTBridge.m | 429 ++++++++++-------- .../react-native/React/Base/RCTBridgeModule.h | 90 +++- .../react-native/React/Base/RCTConvert.h | 67 ++- .../react-native/React/Base/RCTConvert.m | 143 +++--- .../react-native/React/Base/RCTDefines.h | 55 +++ .../react-native/React/Base/RCTDevMenu.h | 45 +- .../react-native/React/Base/RCTDevMenu.m | 233 +++++++--- .../React/Base/RCTJavaScriptExecutor.h | 26 ++ .../React/Base/RCTJavaScriptLoader.h | 9 +- .../React/Base/RCTJavaScriptLoader.m | 16 +- .../react-native/React/Base/RCTLog.h | 30 +- .../react-native/React/Base/RCTLog.m | 57 +-- .../react-native/React/Base/RCTProfile.h | 105 +++++ .../react-native/React/Base/RCTProfile.m | 174 +++++++ .../react-native/React/Base/RCTRedBox.h | 6 + .../react-native/React/Base/RCTRedBox.m | 21 +- .../react-native/React/Base/RCTRootView.h | 6 - .../react-native/React/Base/RCTRootView.m | 22 +- .../react-native/React/Base/RCTUtils.h | 39 +- .../React/Executors/RCTContextExecutor.h | 2 +- .../React/Executors/RCTContextExecutor.m | 83 ++-- .../React/Executors/RCTWebViewExecutor.h | 6 + .../React/Executors/RCTWebViewExecutor.m | 18 +- .../react-native/React/Layout/Layout.c | 15 +- .../React/Modules/RCTAlertManager.m | 58 +-- .../React/Modules/RCTAsyncLocalStorage.m | 155 +++---- .../React/Modules/RCTExceptionsManager.m | 54 ++- .../React/Modules/RCTSourceCode.m | 8 + .../React/Modules/RCTStatusBarManager.m | 39 +- .../react-native/React/Modules/RCTTiming.m | 23 +- .../react-native/React/Modules/RCTUIManager.h | 8 +- .../react-native/React/Modules/RCTUIManager.m | 131 +++--- .../React/React.xcodeproj/project.pbxproj | 18 + .../xcschemes/React.xcscheme | 2 +- .../xcschemes/xcschememanagement.plist | 2 +- .../xcschemes/xcschememanagement.plist | 8 - .../react-native/React/Views/RCTMapManager.m | 16 +- .../react-native/React/Views/RCTScrollView.m | 8 +- .../react-native/React/Views/RCTShadowView.h | 3 +- .../react-native/React/Views/RCTSlider.h | 14 + .../react-native/React/Views/RCTSlider.m | 35 ++ .../React/Views/RCTSliderManager.m | 22 +- .../React/Views/RCTSwitchManager.m | 11 +- .../React/Views/RCTTabBarItemManager.m | 2 +- .../react-native/React/Views/RCTViewManager.h | 29 +- .../react-native/React/Views/RCTViewManager.m | 6 + .../react-native/React/Views/RCTWebView.m | 13 + .../React/Views/RCTWebViewManager.m | 2 + .../React/Views/RCTWrapperViewController.m | 5 +- .../react-native/local-cli/bundle.js | 65 +++ .../react-native/local-cli/cli.js | 7 +- .../node_modules/absolute-path/package.json | 5 +- .../node_modules/bluebird/changelog.md | 6 + .../bluebird/js/browser/bluebird.js | 46 +- .../bluebird/js/browser/bluebird.min.js | 8 +- .../node_modules/bluebird/js/main/async.js | 44 +- .../node_modules/bluebird/package.json | 15 +- .../node_modules/ansi-regex/package.json | 2 +- .../node_modules/ansi-regex/package.json | 2 +- .../node_modules/buffer-crc32/package.json | 8 +- .../connect/node_modules/bytes/package.json | 3 +- .../cookie-signature/package.json | 3 +- .../node_modules/formidable/package.json | 3 +- .../connect/node_modules/methods/package.json | 3 +- .../connect/node_modules/pause/package.json | 3 +- .../send/node_modules/mime/package.json | 27 +- .../node_modules/image-size/package.json | 5 +- .../node_modules/base62/package.json | 7 +- .../node_modules/jsonparse/package.json | 10 +- .../node_modules/duplexer2/package.json | 3 +- .../node_modules/shallow-copy/package.json | 3 +- .../node_modules/subarg/package.json | 3 +- .../node_modules/promise/build.js | 2 +- .../node_modules/promise/domains/core.js | 155 ++++--- .../node_modules/promise/domains/done.js | 14 +- .../promise/domains/es6-extensions.js | 116 ++--- .../node_modules/promise/domains/finally.js | 16 +- .../node_modules/promise/domains/index.js | 10 +- .../promise/domains/node-extensions.js | 60 ++- .../node_modules/promise/lib/core.js | 155 ++++--- .../node_modules/promise/lib/done.js | 14 +- .../promise/lib/es6-extensions.js | 116 ++--- .../node_modules/promise/lib/finally.js | 16 +- .../node_modules/promise/lib/index.js | 10 +- .../promise/lib/node-extensions.js | 60 ++- .../promise/node_modules/asap/CHANGES.md | 64 +++ .../promise/node_modules/asap/LICENSE.md | 21 + .../promise/node_modules/asap/browser-raw.js | 3 +- .../promise/node_modules/asap/package.json | 20 +- .../promise/node_modules/asap/raw.js | 5 +- .../node_modules/promise/package.json | 22 +- .../node_modules/promise/setimmediate/core.js | 153 ++++--- .../node_modules/promise/setimmediate/done.js | 14 +- .../promise/setimmediate/es6-extensions.js | 114 ++--- .../promise/setimmediate/finally.js | 16 +- .../promise/setimmediate/index.js | 10 +- .../promise/setimmediate/node-extensions.js | 58 ++- .../node_modules/promise/src/core.js | 149 +++--- .../node_modules/promise/src/done.js | 14 +- .../promise/src/es6-extensions.js | 116 ++--- .../node_modules/promise/src/finally.js | 16 +- .../node_modules/promise/src/index.js | 10 +- .../promise/src/node-extensions.js | 60 ++- .../minimatch/node_modules/lru-cache/bar.js | 1 + .../minimatch/node_modules/lru-cache/foo.js | 1 + .../node_modules/lru-cache/lib/lru-cache.js | 1 - .../node_modules/lru-cache/package.json | 16 +- .../node_modules/lru-cache/test/timeout.js | 21 - .../commoner/node_modules/mkdirp/package.json | 23 +- .../node_modules/react-tools/package.json | 5 +- .../node_modules/json-stream/package.json | 5 +- .../node_modules/fb-watchman/package.json | 5 +- .../minimatch/node_modules/lru-cache/bar.js | 1 + .../minimatch/node_modules/lru-cache/foo.js | 1 + .../node_modules/lru-cache/lib/lru-cache.js | 1 - .../node_modules/lru-cache/package.json | 16 +- .../node_modules/lru-cache/test/timeout.js | 21 - .../node_modules/sane/package.json | 5 +- .../node_modules/stacktrace-parser/README.md | 6 - .../lib/stacktrace-parser.js | 2 +- .../stacktrace-parser/package.json | 25 +- .../test/stacktrace_parser_test.js | 24 + .../node_modules/worker-farm/package.json | 5 +- .../react-native/node_modules/ws/package.json | 16 +- .../node_modules/react-native/package.json | 37 +- .../react-native/packager/debugger.html | 4 +- .../packager/getFlowTypeCheckMiddleware.js | 19 +- .../react-native/packager/launchEditor.js | 45 +- .../react-native/packager/packager.js | 1 + .../react-native/packager/packager.sh | 6 + .../src/Activity/__mocks__/chalk.js | 13 + .../react-packager/src/Activity/index.js | 12 +- .../AssetServer/__tests__/AssetServer-test.js | 158 ++++--- .../react-packager/src/AssetServer/index.js | 63 ++- .../DependencyResolver/ModuleDescriptor.js | 2 + .../__tests__/DependencyGraph-test.js | 49 +- .../haste/DependencyGraph/index.js | 23 +- .../react-packager/src/FileWatcher/index.js | 4 +- .../react-packager/src/Packager/Package.js | 11 + .../src/Packager/__tests__/Package-test.js | 12 + .../src/Packager/__tests__/Packager-test.js | 72 ++- .../react-packager/src/Packager/index.js | 100 ++-- .../react-packager/src/Server/index.js | 21 +- .../react-packager/src/__mocks__/fs.js | 12 +- .../__tests__/extractAssetResolution-test.js | 24 +- ...tResolution.js => getAssetDataFromName.js} | 9 +- examples/package.json | 2 +- src/index.js | 9 +- 278 files changed, 4803 insertions(+), 3969 deletions(-) create mode 100644 examples/examples/swiper_number.js create mode 100644 examples/node_modules/react-native/Examples/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTActionSheet.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTAdSupport.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimation.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist delete mode 100644 examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimationExperimental.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js rename examples/node_modules/react-native/Libraries/GeoLocation/{Geolocation.ios.js => Geolocation.js} (100%) delete mode 100644 examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTGeolocation.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTImage.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetworkImage.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 examples/node_modules/react-native/Libraries/Image/__tests__/resolveAssetSource-test.js create mode 100644 examples/node_modules/react-native/Libraries/Image/resolveAssetSource.js delete mode 100644 examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTLinking.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTDataManager.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist delete mode 100644 examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTNetwork.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTPushNotification.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist delete mode 100644 examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTTest.xcscheme delete mode 100644 examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist delete mode 100644 examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme create mode 100644 examples/node_modules/react-native/Libraries/StyleSheet/precomputeStyle.js delete mode 100644 examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTText.xcscheme create mode 100755 examples/node_modules/react-native/Libraries/Utilities/MatrixMath.js create mode 100644 examples/node_modules/react-native/Libraries/Utilities/__mocks__/ErrorUtils.js create mode 100644 examples/node_modules/react-native/Libraries/Utilities/__mocks__/PixelRatio.js create mode 100644 examples/node_modules/react-native/Libraries/Utilities/differ/__tests__/deepDiffer-test.js delete mode 100644 examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTVibration.xcscheme create mode 100644 examples/node_modules/react-native/React/Base/RCTDefines.h create mode 100644 examples/node_modules/react-native/React/Base/RCTProfile.h create mode 100644 examples/node_modules/react-native/React/Base/RCTProfile.m create mode 100644 examples/node_modules/react-native/React/Views/RCTSlider.h create mode 100644 examples/node_modules/react-native/React/Views/RCTSlider.m create mode 100644 examples/node_modules/react-native/local-cli/bundle.js create mode 100644 examples/node_modules/react-native/node_modules/promise/node_modules/asap/CHANGES.md create mode 100644 examples/node_modules/react-native/node_modules/promise/node_modules/asap/LICENSE.md create mode 100644 examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/bar.js create mode 100644 examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/foo.js delete mode 100644 examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/test/timeout.js create mode 100644 examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/bar.js create mode 100644 examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/foo.js delete mode 100644 examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/timeout.js create mode 100644 examples/node_modules/react-native/packager/react-packager/src/Activity/__mocks__/chalk.js rename examples/node_modules/react-native/packager/react-packager/src/lib/{extractAssetResolution.js => getAssetDataFromName.js} (63%) diff --git a/dist/index.js b/dist/index.js index e1858ccf..00b1c24f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -138,7 +138,8 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d autoplay: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool, autoplayTimeout: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number, autoplayDirection: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool, - index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number }, + index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number, + renderPagination: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes['function'] }, mixins: [_TimerMixin2['default']], @@ -268,7 +269,11 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d * @return {object} react-dom */ renderPagination: function renderPagination() { - var dots = []; + + // By default, dots only show when `total` > 2 + if (this.state.total <= 1) { + return null; + }var dots = []; for (var i = 0; i < this.state.total; i++) { dots.push(i === this.state.index ? this.props.activeDot || _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].createElement(_React$StyleSheet$Text$View$ScrollView$TouchableOpacity.View, { style: { backgroundColor: '#007aff', @@ -409,7 +414,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d }, props), pages ), - props.showsPagination && total > 1 && this.renderPagination(), + props.showsPagination && (props.renderPagination ? this.props.renderPagination(state.index, state.total) : this.renderPagination()), this.renderTitle(), this.props.showsButtons && this.renderButtons() ); diff --git a/examples/examples/index.js b/examples/examples/index.js index e1858ccf..00b1c24f 100644 --- a/examples/examples/index.js +++ b/examples/examples/index.js @@ -138,7 +138,8 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d autoplay: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool, autoplayTimeout: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number, autoplayDirection: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool, - index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number }, + index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number, + renderPagination: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes['function'] }, mixins: [_TimerMixin2['default']], @@ -268,7 +269,11 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d * @return {object} react-dom */ renderPagination: function renderPagination() { - var dots = []; + + // By default, dots only show when `total` > 2 + if (this.state.total <= 1) { + return null; + }var dots = []; for (var i = 0; i < this.state.total; i++) { dots.push(i === this.state.index ? this.props.activeDot || _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].createElement(_React$StyleSheet$Text$View$ScrollView$TouchableOpacity.View, { style: { backgroundColor: '#007aff', @@ -409,7 +414,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d }, props), pages ), - props.showsPagination && total > 1 && this.renderPagination(), + props.showsPagination && (props.renderPagination ? this.props.renderPagination(state.index, state.total) : this.renderPagination()), this.renderTitle(), this.props.showsButtons && this.renderButtons() ); diff --git a/examples/examples/swiper_number.js b/examples/examples/swiper_number.js new file mode 100644 index 00000000..86aed02f --- /dev/null +++ b/examples/examples/swiper_number.js @@ -0,0 +1,71 @@ +var React = require('react-native') +var Swiper = require('./') +var { + StyleSheet, + Text, + View, + Image, +} = React + +var styles = StyleSheet.create({ + wrapper: { + }, + slide: { + flex: 1, + justifyContent: 'center', + backgroundColor: 'transparent', + }, + text: { + color: '#fff', + fontSize: 30, + fontWeight: 'bold', + }, + image: { + flex: 1, + } +}) + +var renderPagination = function (index, total) { + return ( + + {index + 1}/{total} + + ) +} + +var swiper = React.createClass({ + render: function() { + return ( + + + Aussie tourist dies at Bali hotel}> + + + Big lie behind Nine’s new show}> + + + Why Stone split from Garfield}> + + + Learn from Kim K to land that job}> + + + + + ) + } +}) + +module.exports = swiper + diff --git a/examples/index.ios.js b/examples/index.ios.js index 60560a6a..aec7f45d 100644 --- a/examples/index.ios.js +++ b/examples/index.ios.js @@ -7,6 +7,7 @@ var { // var swiper = require('./examples/basic') var swiper = require('./examples/swiper') +// var swiper = require('./examples/swiper_number') // var swiper = require('./examples/phone') AppRegistry.registerComponent('swiper', () => swiper) diff --git a/examples/node_modules/react-native/Examples/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/examples/node_modules/react-native/Examples/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/examples/node_modules/react-native/Examples/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/examples/node_modules/react-native/Examples/SampleApp/iOS/AppDelegate.m b/examples/node_modules/react-native/Examples/SampleApp/iOS/AppDelegate.m index 5b6cc2d5..7e8d5fec 100644 --- a/examples/node_modules/react-native/Examples/SampleApp/iOS/AppDelegate.m +++ b/examples/node_modules/react-native/Examples/SampleApp/iOS/AppDelegate.m @@ -17,24 +17,33 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( { NSURL *jsCodeLocation; - // Loading JavaScript code - uncomment the one you want. - - // OPTION 1 - // Load from development server. Start the server from the repository root: - // - // $ npm start - // - // To run on device, change `localhost` to the IP address of your computer, and make sure your computer and - // iOS device are on the same Wi-Fi network. + /** + * Loading JavaScript code - uncomment the one you want. + * + * OPTION 1 + * Load from development server. Start the server from the repository root: + * + * $ npm start + * + * To run on device, change `localhost` to the IP address of your computer + * (you can get this by typing `ifconfig` into the terminal and selecting the + * `inet` value under `en0:`) and make sure your computer and iOS device are + * on the same Wi-Fi network. + */ + jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/Examples/SampleApp/index.ios.bundle"]; - // OPTION 2 - // Load from pre-bundled file on disk. To re-generate the static bundle, run - // - // $ curl 'http://localhost:8081/Examples/SampleApp/index.ios.bundle?dev=false&minify=true' -o iOS/main.jsbundle - // - // and uncomment the next following line - // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; + /** + * OPTION 2 + * Load from pre-bundled file on disk. To re-generate the static bundle + * from the root of your project directory, run + * + * $ react-native bundle --minify + * + * see http://facebook.github.io/react-native/docs/runningondevice.html + */ + +// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"SampleApp" diff --git a/examples/node_modules/react-native/Examples/SampleApp/iOS/main.jsbundle b/examples/node_modules/react-native/Examples/SampleApp/iOS/main.jsbundle index 7cc6a2ad..b702b30c 100644 --- a/examples/node_modules/react-native/Examples/SampleApp/iOS/main.jsbundle +++ b/examples/node_modules/react-native/Examples/SampleApp/iOS/main.jsbundle @@ -1,5 +1,8 @@ // Offline JS -// To re-generate the offline bundle, run this from root of your project -// $ curl 'http://localhost:8081/Examples/SampleApp/index.ios.bundle?dev=false&minify=true' -o iOS/main.jsbundle +// To re-generate the offline bundle, run this from the root of your project: +// +// $ react-native bundle --minify +// +// See http://facebook.github.io/react-native/docs/runningondevice.html for more details. throw new Error('Offline JS file is empty. See iOS/main.jsbundle for instructions'); diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj index 7e420235..8434df87 100644 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj @@ -198,6 +198,7 @@ 58B511F01A9E6C8500147676 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -206,6 +207,7 @@ LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTActionSheet; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -213,6 +215,7 @@ 58B511F11A9E6C8500147676 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -221,6 +224,7 @@ LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTActionSheet; + RUN_CLANG_STATIC_ANALYZER = NO; SKIP_INSTALL = YES; }; name = Release; diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTActionSheet.xcscheme b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTActionSheet.xcscheme index 08ac8988..e81bd9b4 100644 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTActionSheet.xcscheme +++ b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTActionSheet.xcscheme @@ -1,6 +1,6 @@ RCTActionSheet.xcscheme orderHint - 68 + 4 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTActionSheet.xcscheme b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTActionSheet.xcscheme deleted file mode 100644 index e81bd9b4..00000000 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTActionSheet.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 0fb69c04..fbf5b0be 100644 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTActionSheet.xcscheme - - orderHint - 4 - - SuppressBuildableAutocreation 58B511DA1A9E6C8500147676 diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m index c6d6e404..75798efa 100644 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -30,96 +30,97 @@ - (instancetype)init return self; } +- (dispatch_queue_t)methodQueue +{ + return dispatch_get_main_queue(); +} + RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options failureCallback:(RCTResponseSenderBlock)failureCallback successCallback:(RCTResponseSenderBlock)successCallback) { - dispatch_async(dispatch_get_main_queue(), ^{ - UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; + UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; - actionSheet.title = options[@"title"]; + actionSheet.title = options[@"title"]; - for (NSString *option in options[@"options"]) { - [actionSheet addButtonWithTitle:option]; - } + for (NSString *option in options[@"options"]) { + [actionSheet addButtonWithTitle:option]; + } - if (options[@"destructiveButtonIndex"]) { - actionSheet.destructiveButtonIndex = [options[@"destructiveButtonIndex"] integerValue]; - } - if (options[@"cancelButtonIndex"]) { - actionSheet.cancelButtonIndex = [options[@"cancelButtonIndex"] integerValue]; - } + if (options[@"destructiveButtonIndex"]) { + actionSheet.destructiveButtonIndex = [options[@"destructiveButtonIndex"] integerValue]; + } + if (options[@"cancelButtonIndex"]) { + actionSheet.cancelButtonIndex = [options[@"cancelButtonIndex"] integerValue]; + } - actionSheet.delegate = self; + actionSheet.delegate = self; - _callbacks[keyForInstance(actionSheet)] = successCallback; + _callbacks[RCTKeyForInstance(actionSheet)] = successCallback; - UIWindow *appWindow = [[[UIApplication sharedApplication] delegate] window]; - if (appWindow == nil) { - RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); - return; - } - [actionSheet showInView:appWindow]; - }); + UIWindow *appWindow = [[[UIApplication sharedApplication] delegate] window]; + if (appWindow == nil) { + RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); + return; + } + [actionSheet showInView:appWindow]; } RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options failureCallback:(RCTResponseSenderBlock)failureCallback successCallback:(RCTResponseSenderBlock)successCallback) { - dispatch_async(dispatch_get_main_queue(), ^{ - NSMutableArray *items = [NSMutableArray array]; - id message = options[@"message"]; - id url = options[@"url"]; - if ([message isKindOfClass:[NSString class]]) { - [items addObject:message]; - } - if ([url isKindOfClass:[NSString class]]) { - [items addObject:[NSURL URLWithString:url]]; - } - if ([items count] == 0) { - failureCallback(@[@"No `url` or `message` to share"]); - return; - } - UIActivityViewController *share = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; - UIViewController *ctrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; - if ([share respondsToSelector:@selector(setCompletionWithItemsHandler:)]) { - share.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { - if (activityError) { - failureCallback(@[[activityError localizedDescription]]); - } else { - successCallback(@[@(completed), (activityType ?: [NSNull null])]); - } - }; - } else { + NSMutableArray *items = [NSMutableArray array]; + id message = options[@"message"]; + id url = options[@"url"]; + if ([message isKindOfClass:[NSString class]]) { + [items addObject:message]; + } + if ([url isKindOfClass:[NSString class]]) { + [items addObject:[NSURL URLWithString:url]]; + } + if ([items count] == 0) { + failureCallback(@[@"No `url` or `message` to share"]); + return; + } + UIActivityViewController *share = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; + UIViewController *ctrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; + if ([share respondsToSelector:@selector(setCompletionWithItemsHandler:)]) { + share.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { + if (activityError) { + failureCallback(@[[activityError localizedDescription]]); + } else { + successCallback(@[@(completed), (activityType ?: [NSNull null])]); + } + }; + } else { #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 - if (![UIActivityViewController instancesRespondToSelector:@selector(completionWithItemsHandler)]) { - // Legacy iOS 7 implementation - share.completionHandler = ^(NSString *activityType, BOOL completed) { - successCallback(@[@(completed), (activityType ?: [NSNull null])]); - }; - } else + if (![UIActivityViewController instancesRespondToSelector:@selector(completionWithItemsHandler)]) { + // Legacy iOS 7 implementation + share.completionHandler = ^(NSString *activityType, BOOL completed) { + successCallback(@[@(completed), (activityType ?: [NSNull null])]); + }; + } else #endif - { - // iOS 8 version - share.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { - successCallback(@[@(completed), (activityType ?: [NSNull null])]); - }; - } + { + // iOS 8 version + share.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { + successCallback(@[@(completed), (activityType ?: [NSNull null])]); + }; } - [ctrl presentViewController:share animated:YES completion:nil]; - }); + } + [ctrl presentViewController:share animated:YES completion:nil]; } #pragma mark UIActionSheetDelegate Methods - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { - NSString *key = keyForInstance(actionSheet); + NSString *key = RCTKeyForInstance(actionSheet); RCTResponseSenderBlock callback = _callbacks[key]; if (callback) { callback(@[@(buttonIndex)]); @@ -133,7 +134,7 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger #pragma mark Private -NS_INLINE NSString *keyForInstance(id instance) +static NSString *RCTKeyForInstance(id instance) { return [NSString stringWithFormat:@"%p", instance]; } diff --git a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj index 811d25e6..1b89d7bf 100644 --- a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj @@ -208,6 +208,7 @@ 832C81951AAF6DF0007FA2F7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -215,6 +216,7 @@ ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -222,6 +224,7 @@ 832C81961AAF6DF0007FA2F7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAdSupport.xcscheme b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAdSupport.xcscheme index fb3af7c5..3dc7dafa 100644 --- a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAdSupport.xcscheme +++ b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAdSupport.xcscheme @@ -1,6 +1,6 @@ RCTAdSupport.xcscheme orderHint - 66 + 5 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTAdSupport.xcscheme b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTAdSupport.xcscheme deleted file mode 100644 index 3dc7dafa..00000000 --- a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTAdSupport.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 3317ad41..1c95f28d 100644 --- a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTAdSupport.xcscheme - - orderHint - 5 - - SuppressBuildableAutocreation 832C817F1AAF6DEF007FA2F7 diff --git a/examples/node_modules/react-native/Libraries/Animation/AnimationUtils.js b/examples/node_modules/react-native/Libraries/Animation/AnimationUtils.js index d6d95f62..ac62465a 100644 --- a/examples/node_modules/react-native/Libraries/Animation/AnimationUtils.js +++ b/examples/node_modules/react-native/Libraries/Animation/AnimationUtils.js @@ -20,6 +20,9 @@ type EasingFunction = (t: number) => number; var defaults = { + linear: function(t: number): number { + return t; + }, easeInQuad: function(t: number): number { return t * t; }, diff --git a/examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimation.xcscheme b/examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimation.xcscheme deleted file mode 100644 index af8d8b5c..00000000 --- a/examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimation.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 7e8a1a5e..00000000 --- a/examples/node_modules/react-native/Libraries/Animation/RCTAnimation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTAnimation.xcscheme - - orderHint - 77 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimationExperimental.xcscheme b/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimationExperimental.xcscheme deleted file mode 100644 index ea465c76..00000000 --- a/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTAnimationExperimental.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index be4e1d9e..00000000 --- a/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimental.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTAnimationExperimental.xcscheme - - orderHint - 74 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimentalManager.m b/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimentalManager.m index eb2ddd1c..64ee577f 100644 --- a/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimentalManager.m +++ b/examples/node_modules/react-native/Libraries/Animation/RCTAnimationExperimentalManager.m @@ -68,6 +68,11 @@ - (instancetype)init return self; } +- (dispatch_queue_t)methodQueue +{ + return _bridge.uiManager.methodQueue; +} + - (id (^)(CGFloat))interpolateFrom:(CGFloat[])fromArray to:(CGFloat[])toArray count:(NSUInteger)count typeName:(const char *)typeName { if (count == 1) { @@ -259,7 +264,9 @@ static void RCTInvalidAnimationProp(RCTSparseArray *callbacks, NSNumber *tag, NS RCTAnimationExperimentalManager *strongSelf = weakSelf; NSNumber *reactTag = strongSelf->_animationRegistry[animationTag]; - if (!reactTag) return; + if (!reactTag) { + return; + } UIView *view = viewRegistry[reactTag]; for (NSString *animationKey in view.layer.animationKeys) { diff --git a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js b/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js new file mode 100644 index 00000000..28da1bc3 --- /dev/null +++ b/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js @@ -0,0 +1,44 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + */ +'use strict'; + +var NativeModules = { + I18n: { + translationsDictionary: { + 'Good bye, {name}!|Bye message': '¡Adiós {name}!', + }, + }, + Timing: { + createTimer: jest.genMockFunction(), + deleteTimer: jest.genMockFunction(), + }, + GraphPhotoUpload: { + upload: jest.genMockFunction(), + }, + FacebookSDK: { + login: jest.genMockFunction(), + logout: jest.genMockFunction(), + queryGraphPath: jest.genMockFunction().mockImpl( + (path, method, params, callback) => callback() + ), + }, + DataManager: { + queryData: jest.genMockFunction(), + }, + UIManager: { + customBubblingEventTypes: {}, + customDirectEventTypes: {}, + }, + AsyncLocalStorage: { + getItem: jest.genMockFunction(), + setItem: jest.genMockFunction(), + removeItem: jest.genMockFunction(), + clear: jest.genMockFunction(), + }, + SourceCode: { + scriptURL: null, + }, +}; + +module.exports = NativeModules; diff --git a/examples/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js index f2bcbfd5..3a44020a 100644 --- a/examples/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js +++ b/examples/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js @@ -15,13 +15,12 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var NativeModules = require('NativeModules'); var PropTypes = require('ReactPropTypes'); var React = require('React'); -var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var StyleSheet = require('StyleSheet'); var View = require('View'); -var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); var keyMirror = require('keyMirror'); -var merge = require('merge'); +var requireNativeComponent = require('requireNativeComponent'); +var verifyPropTypes = require('verifyPropTypes'); var SpinnerSize = keyMirror({ large: null, @@ -100,14 +99,17 @@ var styles = StyleSheet.create({ } }); -var UIActivityIndicatorView = createReactIOSNativeComponentClass({ - validAttributes: merge( - ReactIOSViewAttributes.UIView, { - activityIndicatorViewStyle: true, // UIActivityIndicatorViewStyle=UIActivityIndicatorViewStyleWhite - animating: true, - color: true, - }), - uiViewClassName: 'UIActivityIndicatorView', -}); +var UIActivityIndicatorView = requireNativeComponent( + 'UIActivityIndicatorView', + null +); +if (__DEV__) { + var nativeOnlyProps = {activityIndicatorViewStyle: true}; + verifyPropTypes( + ActivityIndicatorIOS, + UIActivityIndicatorView.viewConfig, + nativeOnlyProps + ); +} module.exports = ActivityIndicatorIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js index 9bd0a2ac..41fc9b87 100644 --- a/examples/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/examples/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -16,14 +16,11 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var PropTypes = require('ReactPropTypes'); var React = require('React'); -var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var RCTDatePickerIOSConsts = require('NativeModules').UIManager.RCTDatePicker.Constants; var StyleSheet = require('StyleSheet'); var View = require('View'); -var createReactIOSNativeComponentClass = - require('createReactIOSNativeComponentClass'); -var merge = require('merge'); +var requireNativeComponent = require('requireNativeComponent'); var DATEPICKER = 'datepicker'; @@ -148,18 +145,6 @@ var styles = StyleSheet.create({ }, }); -var rkDatePickerIOSAttributes = merge(ReactIOSViewAttributes.UIView, { - date: true, - maximumDate: true, - minimumDate: true, - mode: true, - minuteInterval: true, - timeZoneOffsetInMinutes: true, -}); - -var RCTDatePickerIOS = createReactIOSNativeComponentClass({ - validAttributes: rkDatePickerIOSAttributes, - uiViewClassName: 'RCTDatePicker', -}); +var RCTDatePickerIOS = requireNativeComponent('RCTDatePicker', DatePickerIOS); module.exports = DatePickerIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/MapView/MapView.js b/examples/node_modules/react-native/Libraries/Components/MapView/MapView.js index 7beeabbe..e38dd956 100644 --- a/examples/node_modules/react-native/Libraries/Components/MapView/MapView.js +++ b/examples/node_modules/react-native/Libraries/Components/MapView/MapView.js @@ -13,6 +13,7 @@ var EdgeInsetsPropType = require('EdgeInsetsPropType'); var NativeMethodsMixin = require('NativeMethodsMixin'); +var Platform = require('Platform'); var React = require('React'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var View = require('View'); @@ -21,8 +22,15 @@ var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentC var deepDiffer = require('deepDiffer'); var insetsDiffer = require('insetsDiffer'); var merge = require('merge'); +var requireNativeComponent = require('requireNativeComponent'); type Event = Object; +type MapRegion = { + latitude: number; + longitude: number; + latitudeDelta: number; + longitudeDelta: number; +}; var MapView = React.createClass({ mixins: [NativeMethodsMixin], @@ -150,46 +158,30 @@ var MapView = React.createClass({ }, render: function() { - return ( - - ); + return ; }, - }); -var RCTMap = createReactIOSNativeComponentClass({ - validAttributes: merge( - ReactIOSViewAttributes.UIView, { - showsUserLocation: true, - zoomEnabled: true, - rotateEnabled: true, - pitchEnabled: true, - scrollEnabled: true, - region: {diff: deepDiffer}, - annotations: {diff: deepDiffer}, - maxDelta: true, - minDelta: true, - legalLabelInsets: {diff: insetsDiffer}, - } - ), - uiViewClassName: 'RCTMap', -}); +if (Platform.OS === 'android') { + var RCTMap = createReactIOSNativeComponentClass({ + validAttributes: merge( + ReactIOSViewAttributes.UIView, { + showsUserLocation: true, + zoomEnabled: true, + rotateEnabled: true, + pitchEnabled: true, + scrollEnabled: true, + region: {diff: deepDiffer}, + annotations: {diff: deepDiffer}, + maxDelta: true, + minDelta: true, + legalLabelInsets: {diff: insetsDiffer}, + } + ), + uiViewClassName: 'RCTMap', + }); +} else { + var RCTMap = requireNativeComponent('RCTMap', MapView); +} module.exports = MapView; diff --git a/examples/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js index fd90847f..3babd140 100644 --- a/examples/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js +++ b/examples/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js @@ -252,6 +252,16 @@ var NavigatorIOS = React.createClass({ */ tintColor: PropTypes.string, + /** + * The background color of the navigation bar + */ + barTintColor: PropTypes.string, + + /** + * The text color of the navigation bar title + */ + titleTextColor: PropTypes.string, + }, navigator: (undefined: ?Object), @@ -554,7 +564,9 @@ var NavigatorIOS = React.createClass({ rightButtonTitle={route.rightButtonTitle} onNavRightButtonTap={route.onRightButtonPress} navigationBarHidden={this.props.navigationBarHidden} - tintColor={this.props.tintColor}> + tintColor={this.props.tintColor} + barTintColor={this.props.barTintColor} + titleTextColor={this.props.titleTextColor}> ); @@ -98,20 +107,6 @@ var styles = StyleSheet.create({ }, }); -if (Platform.OS === 'ios') { - var RCTSlider = requireNativeComponent('RCTSlider', SliderIOS); -} else { - var validAttributes = { - ...ReactIOSViewAttributes.UIView, - value: true, - minimumValue: true, - maximumValue: true, - }; - - var RCTSlider = createReactIOSNativeComponentClass({ - validAttributes: validAttributes, - uiViewClassName: 'RCTSlider', - }); -} +var RCTSlider = requireNativeComponent('RCTSlider', SliderIOS); module.exports = SliderIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js index 70222794..5a56e36b 100644 --- a/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js +++ b/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js @@ -16,11 +16,9 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var PropTypes = require('ReactPropTypes'); var React = require('React'); -var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var StyleSheet = require('StyleSheet'); -var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); -var merge = require('merge'); +var requireNativeComponent = require('requireNativeComponent'); var SWITCH = 'switch'; @@ -88,20 +86,16 @@ var SwitchIOS = React.createClass({ // The underlying switch might have changed, but we're controlled, // and so want to ensure it represents our value. - this.refs[SWITCH].setNativeProps({on: this.props.value}); + this.refs[SWITCH].setNativeProps({value: this.props.value}); }, render: function() { return ( ); } @@ -114,17 +108,6 @@ var styles = StyleSheet.create({ }, }); -var rkSwitchAttributes = merge(ReactIOSViewAttributes.UIView, { - onTintColor: true, - tintColor: true, - thumbTintColor: true, - on: true, - enabled: true, -}); - -var RCTSwitch = createReactIOSNativeComponentClass({ - validAttributes: rkSwitchAttributes, - uiViewClassName: 'RCTSwitch', -}); +var RCTSwitch = requireNativeComponent('RCTSwitch', SwitchIOS); module.exports = SwitchIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js index 05ac37c7..4163b2d7 100644 --- a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js @@ -12,12 +12,11 @@ 'use strict'; var React = require('React'); -var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var StyleSheet = require('StyleSheet'); var TabBarItemIOS = require('TabBarItemIOS'); var View = require('View'); -var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); +var requireNativeComponent = require('requireNativeComponent'); var TabBarIOS = React.createClass({ statics: { @@ -43,10 +42,6 @@ var styles = StyleSheet.create({ } }); -var config = { - validAttributes: ReactIOSViewAttributes.UIView, - uiViewClassName: 'RCTTabBar', -}; -var RCTTabBar = createReactIOSNativeComponentClass(config); +var RCTTabBar = requireNativeComponent('RCTTabBar', TabBarIOS); module.exports = TabBarIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index 86b38a8c..2baaee21 100644 --- a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js @@ -13,13 +13,11 @@ var Image = require('Image'); var React = require('React'); -var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var StaticContainer = require('StaticContainer.react'); var StyleSheet = require('StyleSheet'); var View = require('View'); -var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); -var merge = require('merge'); +var requireNativeComponent = require('requireNativeComponent'); var TabBarItemIOS = React.createClass({ propTypes: { @@ -88,7 +86,7 @@ var TabBarItemIOS = React.createClass({ } }, - componentWillReceiveProps: function(nextProps: { selected: boolean }) { + componentWillReceiveProps: function(nextProps: { selected?: boolean }) { if (this.state.hasBeenSelected || nextProps.selected) { this.setState({hasBeenSelected: true}); } @@ -121,7 +119,7 @@ var TabBarItemIOS = React.createClass({ selectedIcon={this.props.selectedIcon && this.props.selectedIcon.uri} onPress={this.props.onPress} selected={this.props.selected} - badgeValue={badge} + badge={badge} title={this.props.title} style={[styles.tab, this.props.style]}> {tabContents} @@ -140,15 +138,6 @@ var styles = StyleSheet.create({ } }); -var RCTTabBarItem = createReactIOSNativeComponentClass({ - validAttributes: merge(ReactIOSViewAttributes.UIView, { - title: true, - icon: true, - selectedIcon: true, - selected: true, - badgeValue: true, - }), - uiViewClassName: 'RCTTabBarItem', -}); +var RCTTabBarItem = requireNativeComponent('RCTTabBarItem', TabBarItemIOS); module.exports = TabBarItemIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/TextInput/TextInput.js b/examples/node_modules/react-native/Libraries/Components/TextInput/TextInput.js index fb5f9994..dfd3ab1a 100644 --- a/examples/node_modules/react-native/Libraries/Components/TextInput/TextInput.js +++ b/examples/node_modules/react-native/Libraries/Components/TextInput/TextInput.js @@ -350,6 +350,9 @@ var TextInput = React.createClass({ componentWillUnmount: function() { this._focusSubscription && this._focusSubscription.remove(); + if (this.isFocused()) { + this.blur(); + } }, _bufferTimeout: (undefined: ?number), diff --git a/examples/node_modules/react-native/Libraries/Components/View/View.js b/examples/node_modules/react-native/Libraries/Components/View/View.js index c981e412..0da57f55 100644 --- a/examples/node_modules/react-native/Libraries/Components/View/View.js +++ b/examples/node_modules/react-native/Libraries/Components/View/View.js @@ -13,12 +13,13 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var PropTypes = require('ReactPropTypes'); +var RCTUIManager = require('NativeModules').UIManager; var React = require('React'); +var ReactIOSStyleAttributes = require('ReactIOSStyleAttributes'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var StyleSheetPropType = require('StyleSheetPropType'); var ViewStylePropTypes = require('ViewStylePropTypes'); - var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); var stylePropType = StyleSheetPropType(ViewStylePropTypes); @@ -136,6 +137,20 @@ var View = React.createClass({ * (or one of its superviews). */ removeClippedSubviews: PropTypes.bool, + + /** + * Whether this view should render itself (and all of its children) into a + * single hardware texture on the GPU. + * + * On Android, this is useful for animations and interactions that only + * modify opacity, rotation, translation, and/or scale: in those cases, the + * view doesn't have to be redrawn and display lists don't need to be + * re-executed. The texture can just be re-used and re-composited with + * different parameters. The downside is that this can use up limited video + * memory, so this prop should be set back to false at the end of the + * interaction/animation. + */ + renderToHardwareTextureAndroid: PropTypes.bool, }, render: function() { @@ -143,17 +158,26 @@ var View = React.createClass({ }, }); - var RCTView = createReactIOSNativeComponentClass({ validAttributes: ReactIOSViewAttributes.RCTView, uiViewClassName: 'RCTView', }); RCTView.propTypes = View.propTypes; +if (__DEV__) { + var viewConfig = RCTUIManager.viewConfigs && RCTUIManager.viewConfigs.RCTView || {}; + for (var prop in viewConfig.nativeProps) { + var viewAny: any = View; // Appease flow + if (!viewAny.propTypes[prop] && !ReactIOSStyleAttributes[prop]) { + throw new Error( + 'View is missing propType for native prop `' + prop + '`' + ); + } + } +} var ViewToExport = RCTView; if (__DEV__) { ViewToExport = View; } - module.exports = ViewToExport; diff --git a/examples/node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js b/examples/node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js index bb22c6b2..7bb795f1 100644 --- a/examples/node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js +++ b/examples/node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js @@ -34,7 +34,10 @@ var ViewStylePropTypes = { ), shadowOpacity: ReactPropTypes.number, shadowRadius: ReactPropTypes.number, + transform: ReactPropTypes.arrayOf(ReactPropTypes.object), transformMatrix: ReactPropTypes.arrayOf(ReactPropTypes.number), + + // DEPRECATED rotation: ReactPropTypes.number, scaleX: ReactPropTypes.number, scaleY: ReactPropTypes.number, diff --git a/examples/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js b/examples/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js index 83c90a1f..c4e4fbcd 100644 --- a/examples/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js +++ b/examples/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js @@ -19,16 +19,13 @@ var StyleSheet = require('StyleSheet'); var Text = require('Text'); var View = require('View'); -var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); +var invariant = require('invariant'); var keyMirror = require('keyMirror'); -var insetsDiffer = require('insetsDiffer'); -var merge = require('merge'); +var requireNativeComponent = require('requireNativeComponent'); var PropTypes = React.PropTypes; var RCTWebViewManager = require('NativeModules').WebViewManager; -var invariant = require('invariant'); - var BGWASH = 'rgba(255,255,255,0.8)'; var RCT_WEBVIEW_REF = 'webview'; @@ -87,6 +84,8 @@ var WebView = React.createClass({ html: PropTypes.string, renderError: PropTypes.func, // view to show if there's an error renderLoading: PropTypes.func, // loading indicator to show + bounces: PropTypes.bool, + scrollEnabled: PropTypes.bool, automaticallyAdjustContentInsets: PropTypes.bool, shouldInjectAJAXHandler: PropTypes.bool, contentInset: EdgeInsetsPropType, @@ -131,7 +130,7 @@ var WebView = React.createClass({ ); } - var webViewStyles = [styles.container, this.props.style]; + var webViewStyles = [styles.container, styles.webView, this.props.style]; if (this.state.viewState === WebViewState.LOADING || this.state.viewState === WebViewState.ERROR) { // if we're in either LOADING or ERROR states, don't show the webView @@ -145,6 +144,8 @@ var WebView = React.createClass({ style={webViewStyles} url={this.props.url} html={this.props.html} + bounces={this.props.bounces} + scrollEnabled={this.props.scrollEnabled} shouldInjectAJAXHandler={this.props.shouldInjectAJAXHandler} contentInset={this.props.contentInset} automaticallyAdjustContentInsets={this.props.automaticallyAdjustContentInsets} @@ -209,16 +210,7 @@ var WebView = React.createClass({ }, }); -var RCTWebView = createReactIOSNativeComponentClass({ - validAttributes: merge(ReactIOSViewAttributes.UIView, { - url: true, - html: true, - contentInset: {diff: insetsDiffer}, - automaticallyAdjustContentInsets: true, - shouldInjectAJAXHandler: true - }), - uiViewClassName: 'RCTWebView', -}); +var RCTWebView = requireNativeComponent('RCTWebView', WebView); var styles = StyleSheet.create({ container: { @@ -250,6 +242,9 @@ var styles = StyleSheet.create({ justifyContent: 'center', alignItems: 'center', }, + webView: { + backgroundColor: '#ffffff', + } }); module.exports = WebView; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js index f783c34e..da4d2ab1 100644 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js +++ b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js @@ -135,11 +135,12 @@ var GESTURE_ACTIONS = [ * /> * ``` * - * ### Navigation Methods + * ### Navigator Methods * - * `Navigator` can be told to navigate in two ways. If you have a ref to - * the element, you can invoke several methods on it to trigger navigation: + * If you have a ref to the Navigator element, you can invoke several methods + * on it to trigger navigation: * + * - `getCurrentRoutes()` - returns the current list of routes * - `jumpBack()` - Jump backward without unmounting the current scene * - `jumpForward()` - Jump forward to the next scene in the route stack * - `jumpTo(route)` - Transition to an existing scene without unmounting @@ -156,18 +157,39 @@ var GESTURE_ACTIONS = [ * - `popToTop()` - Pop to the first scene in the stack, unmounting every * other scene * - * ### Navigator Object + * ### Navigation Context * - * The navigator object is made available to scenes through the `renderScene` - * function. The object has all of the navigation methods on it, as well as a - * few utilities: + * The navigator context object is made available to scenes through the + * `renderScene` function. Alternatively, any scene or component inside a + * Navigator can get the navigation context by calling + * `Navigator.getContext(this)`. * - * - `parentNavigator` - a refrence to the parent navigator object that was - * passed in through props.navigator - * - `onWillFocus` - used to pass a navigation focus event up to the parent - * navigator - * - `onDidFocus` - used to pass a navigation focus event up to the parent - * navigator + * Unlike the Navigator methods, the functions in navigation context do not + * directly control a specific navigator. Instead, the navigator context allows + * a scene to request navigation from its parents. Navigation requests will + * travel up through the hierarchy of Navigators, and will be resolved by the + * deepest active navigator. + * + * Navigation context objects contain the following: + * + * - `getCurrentRoutes()` - returns the routes for the closest navigator + * - `jumpBack()` - Jump backward without unmounting the current scene + * - `jumpForward()` - Jump forward to the next scene in the route stack + * - `jumpTo(route)` - Transition to an existing scene without unmounting + * - `parentNavigator` - a refrence to the parent navigation context + * - `push(route)` - Navigate forward to a new scene, squashing any scenes + * that you could `jumpForward` to + * - `pop()` - Transition back and unmount the current scene + * - `replace(route)` - Replace the current scene with a new route + * - `replaceAtIndex(route, index)` - Replace a scene as specified by an index + * - `replacePrevious(route)` - Replace the previous scene + * - `route` - The route that was used to render the scene with this context + * - `immediatelyResetRouteStack(routeStack)` - Reset every scene with an + * array of routes + * - `popToRoute(route)` - Pop to a particular scene, as specified by it's + * route. All scenes after it will be unmounted + * - `popToTop()` - Pop to the first scene in the stack, unmounting every + * other scene * */ var Navigator = React.createClass({ @@ -306,25 +328,30 @@ var Navigator = React.createClass({ this.parentNavigator = getNavigatorContext(this) || this.props.navigator; this._subRouteFocus = []; this.navigatorContext = { + // Actions for child navigators or interceptors: setHandlerForRoute: this.setHandlerForRoute, request: this.request, + // Contextual utilities parentNavigator: this.parentNavigator, getCurrentRoutes: this.getCurrentRoutes, + // `route` is injected by NavigatorStaticContextContainer + + // Contextual nav actions + pop: this.requestPop, + popToRoute: this.requestPopTo, - // Legacy, imperitive nav actions. Use request when possible. + // Legacy, imperitive nav actions. Will transition these to contextual actions jumpBack: this.jumpBack, jumpForward: this.jumpForward, jumpTo: this.jumpTo, push: this.push, - pop: this.pop, replace: this.replace, replaceAtIndex: this.replaceAtIndex, replacePrevious: this.replacePrevious, replacePreviousAndPop: this.replacePreviousAndPop, immediatelyResetRouteStack: this.immediatelyResetRouteStack, resetTo: this.resetTo, - popToRoute: this.popToRoute, popToTop: this.popToTop, }; this._handlers = {}; @@ -349,6 +376,14 @@ var Navigator = React.createClass({ return this._handleRequest.apply(null, arguments); }, + requestPop: function() { + return this.request('pop'); + }, + + requestPopTo: function(route) { + return this.request('pop', route); + }, + _handleRequest: function(action, arg1, arg2) { var childHandler = this._handlers[this.state.presentedIndex]; if (childHandler && childHandler(action, arg1, arg2)) { @@ -356,7 +391,7 @@ var Navigator = React.createClass({ } switch (action) { case 'pop': - return this._handlePop(); + return this._handlePop(arg1); case 'push': return this._handlePush(arg1); default: @@ -365,11 +400,20 @@ var Navigator = React.createClass({ } }, - _handlePop: function() { + _handlePop: function(route) { + if (route) { + var hasRoute = this.state.routeStack.indexOf(route) !== -1; + if (hasRoute) { + this.popToRoute(route); + return true; + } else { + return false; + } + } if (this.state.presentedIndex === 0) { return false; } - this._popN(1); + this.pop(); return true; }, @@ -415,7 +459,7 @@ var Navigator = React.createClass({ }, _handleAndroidBackPress: function() { - var didPop = this.pop(); + var didPop = this.requestPop(); if (!didPop) { BackAndroid.exitApp(); } @@ -494,6 +538,7 @@ var Navigator = React.createClass({ _completeTransition: function() { if (this.spring.getCurrentValue() === 1) { + this._onAnimationEnd(); var presentedIndex = this.state.toIndex; this.state.presentedIndex = presentedIndex; this.state.fromIndex = presentedIndex; @@ -515,6 +560,7 @@ var Navigator = React.createClass({ // For visual consistency, the from index is always used to configure the spring this.state.sceneConfigStack[this.state.fromIndex] ); + this._onAnimationStart(); this.state.isAnimating = true; this.spring.setVelocity(v); this.spring.setEndValue(1); @@ -573,6 +619,34 @@ var Navigator = React.createClass({ } }, + _onAnimationStart: function() { + this._setRenderSceneToHarwareTextureAndroid(this.state.fromIndex, true); + this._setRenderSceneToHarwareTextureAndroid(this.state.toIndex, true); + + var navBar = this._navBar; + if (navBar && navBar.onAnimationStart) { + navBar.onAnimationStart(this.state.fromIndex, this.state.toIndex); + } + }, + + _onAnimationEnd: function() { + this._setRenderSceneToHarwareTextureAndroid(this.state.fromIndex, false); + this._setRenderSceneToHarwareTextureAndroid(this.state.toIndex, false); + + var navBar = this._navBar; + if (navBar && navBar.onAnimationEnd) { + navBar.onAnimationEnd(this.state.fromIndex, this.state.toIndex); + } + }, + + _setRenderSceneToHarwareTextureAndroid: function(sceneIndex, shouldRenderToHardwareTexture) { + var viewAtIndex = this.refs['scene_' + sceneIndex]; + if (viewAtIndex === null || viewAtIndex === undefined) { + return; + } + viewAtIndex.setNativeProps({renderToHardwareTextureAndroid: shouldRenderToHardwareTexture}); + }, + /** * Becomes the responder on touch start (capture) while animating so that it * blocks all touch interactions inside of it. However, this responder lock @@ -610,6 +684,7 @@ var Navigator = React.createClass({ this.state.fromIndex = this.state.presentedIndex; var gestureSceneDelta = this._deltaForGestureAction(this._activeGestureAction); this.state.toIndex = this.state.presentedIndex + gestureSceneDelta; + this._onAnimationStart(); } }, @@ -873,7 +948,7 @@ var Navigator = React.createClass({ }, pop: function() { - return this.request('pop'); + this._popN(1); }, /** @@ -1004,8 +1079,7 @@ var Navigator = React.createClass({ // To avoid visual glitches, we never re-render scenes during a transition. // We assume that `state.updatingRangeLength` will have a length during the // initial render of any scene - var shouldRenderScenes = !this.state.isAnimating && - this.state.updatingRangeLength !== 0; + var shouldRenderScenes = this.state.updatingRangeLength !== 0; if (shouldRenderScenes) { return ( diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js index b4bad998..fa62b3f4 100644 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js +++ b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js @@ -138,6 +138,37 @@ var NavigatorBreadcrumbNavigationBar = React.createClass({ } }, + onAnimationStart: function(fromIndex, toIndex) { + var max = Math.max(fromIndex, toIndex); + var min = Math.min(fromIndex, toIndex); + for (var index = min; index <= max; index++) { + this._setRenderViewsToHardwareTextureAndroid(index, true); + } + }, + + onAnimationEnd: function(fromIndex, toIndex) { + var max = Math.max(fromIndex, toIndex); + var min = Math.min(fromIndex, toIndex); + for (var index = min; index <= max; index++) { + this._setRenderViewsToHardwareTextureAndroid(index, false); + } + }, + + _setRenderViewsToHardwareTextureAndroid: function(index, renderToHardwareTexture) { + var props = { + renderToHardwareTextureAndroid: renderToHardwareTexture, + }; + + this.refs['crumb_' + index].setNativeProps(props); + this.refs['icon_' + index].setNativeProps(props); + this.refs['separator_' + index].setNativeProps(props); + this.refs['title_' + index].setNativeProps(props); + var right = this.refs['right_' + index]; + if (right) { + right.setNativeProps(props); + } + }, + render: function() { var navState = this.props.navState; var icons = navState && navState.routeStack.map(this._renderOrReturnBreadcrumb); @@ -260,7 +291,7 @@ var styles = StyleSheet.create({ height: NavigatorNavigationBarStyles.General.TotalNavHeight, top: 0, left: 0, - width: NavigatorNavigationBarStyles.General.ScreenWidth, + right: 0, }, }); diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js index 7bc78ee9..69d0d52a 100644 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js +++ b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js @@ -26,12 +26,13 @@ */ 'use strict'; +var Dimensions = require('Dimensions'); var NavigatorNavigationBarStyles = require('NavigatorNavigationBarStyles'); var buildStyleInterpolator = require('buildStyleInterpolator'); var merge = require('merge'); -var SCREEN_WIDTH = NavigatorNavigationBarStyles.General.ScreenWidth; +var SCREEN_WIDTH = Dimensions.get('window').width; var STATUS_BAR_HEIGHT = NavigatorNavigationBarStyles.General.StatusBarHeight; var NAV_BAR_HEIGHT = NavigatorNavigationBarStyles.General.NavBarHeight; @@ -39,7 +40,6 @@ var SPACING = 4; var ICON_WIDTH = 40; var SEPARATOR_WIDTH = 9; var CRUMB_WIDTH = ICON_WIDTH + SEPARATOR_WIDTH; -var RIGHT_BUTTON_WIDTH = 58; var OPACITY_RATIO = 100; var ICON_INACTIVE_OPACITY = 0.6; @@ -74,18 +74,17 @@ var TITLE_BASE = { // For first title styles, make sure first title is centered var FIRST_TITLE_BASE = merge(TITLE_BASE, { left: 0, + right: 0, alignItems: 'center', - width: SCREEN_WIDTH, height: NAV_BAR_HEIGHT, }); var RIGHT_BUTTON_BASE = { position: 'absolute', top: STATUS_BAR_HEIGHT, - left: SCREEN_WIDTH - SPACING - RIGHT_BUTTON_WIDTH, + right: SPACING, overflow: 'hidden', opacity: 1, - width: RIGHT_BUTTON_WIDTH, height: NAV_BAR_HEIGHT, backgroundColor: 'transparent', }; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js index 20c43a94..172819de 100644 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js +++ b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js @@ -192,7 +192,7 @@ var styles = StyleSheet.create({ height: NavigatorNavigationBarStyles.General.TotalNavHeight, top: 0, left: 0, - width: NavigatorNavigationBarStyles.General.ScreenWidth, + right: 0, backgroundColor: 'transparent', }, }); diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBarStyles.ios.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBarStyles.ios.js index 266c5df2..fff11674 100644 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBarStyles.ios.js +++ b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBarStyles.ios.js @@ -169,7 +169,6 @@ module.exports = { NavBarHeight: NAV_BAR_HEIGHT, StatusBarHeight: STATUS_BAR_HEIGHT, TotalNavHeight: NAV_HEIGHT, - ScreenWidth: SCREEN_WIDTH, }, Interpolators, Stages, diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/Geolocation.ios.js b/examples/node_modules/react-native/Libraries/GeoLocation/Geolocation.js similarity index 100% rename from examples/node_modules/react-native/Libraries/GeoLocation/Geolocation.ios.js rename to examples/node_modules/react-native/Libraries/GeoLocation/Geolocation.js diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/project.pbxproj index dd17e580..ee79e757 100644 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/project.pbxproj @@ -198,6 +198,7 @@ 58B511F01A9E6C8500147676 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -206,6 +207,7 @@ LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTGeolocation; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -213,6 +215,7 @@ 58B511F11A9E6C8500147676 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTGeolocation.xcscheme b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTGeolocation.xcscheme index daa66f94..21390451 100644 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTGeolocation.xcscheme +++ b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTGeolocation.xcscheme @@ -1,6 +1,6 @@ RCTGeolocation.xcscheme orderHint - 65 + 6 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTGeolocation.xcscheme b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTGeolocation.xcscheme deleted file mode 100644 index 21390451..00000000 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTGeolocation.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 1ced75d1..fbf5b0be 100644 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTGeolocation.xcscheme - - orderHint - 6 - - SuppressBuildableAutocreation 58B511DA1A9E6C8500147676 diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.m b/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.m index 6bb95acb..5d56cacc 100644 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.m +++ b/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.m @@ -33,7 +33,9 @@ typedef NS_ENUM(NSInteger, RCTPositionErrorCode) { CLLocationAccuracy accuracy; } RCTLocationOptions; -static RCTLocationOptions RCTLocationOptionsWithJSON(id json) +@implementation RCTConvert (RCTLocationOptions) + ++ (RCTLocationOptions)RCTLocationOptions:(id)json { NSDictionary *options = [RCTConvert NSDictionary:json]; return (RCTLocationOptions){ @@ -43,6 +45,8 @@ static RCTLocationOptions RCTLocationOptionsWithJSON(id json) }; } +@end + static NSDictionary *RCTPositionError(RCTPositionErrorCode code, NSString *msg /* nil for default */) { if (!msg) { @@ -121,6 +125,12 @@ - (instancetype)init - (void)dealloc { [_locationManager stopUpdatingLocation]; + _locationManager.delegate = nil; +} + +- (dispatch_queue_t)methodQueue +{ + return dispatch_get_main_queue(); } #pragma mark - Private API @@ -157,34 +167,26 @@ - (void)timeout:(NSTimer *)timer { [self checkLocationConfig]; - dispatch_async(dispatch_get_main_queue(), ^{ - - // Select best options - _observerOptions = RCTLocationOptionsWithJSON(optionsJSON); - for (RCTLocationRequest *request in _pendingRequests) { - _observerOptions.accuracy = MIN(_observerOptions.accuracy, request.options.accuracy); - } - - _locationManager.desiredAccuracy = _observerOptions.accuracy; - [self beginLocationUpdates]; - _observingLocation = YES; + // Select best options + _observerOptions = [RCTConvert RCTLocationOptions:optionsJSON]; + for (RCTLocationRequest *request in _pendingRequests) { + _observerOptions.accuracy = MIN(_observerOptions.accuracy, request.options.accuracy); + } - }); + _locationManager.desiredAccuracy = _observerOptions.accuracy; + [self beginLocationUpdates]; + _observingLocation = YES; } RCT_EXPORT_METHOD(stopObserving) { - dispatch_async(dispatch_get_main_queue(), ^{ - - // Stop observing - _observingLocation = NO; - - // Stop updating if no pending requests - if (_pendingRequests.count == 0) { - [_locationManager stopUpdatingLocation]; - } + // Stop observing + _observingLocation = NO; - }); + // Stop updating if no pending requests + if (_pendingRequests.count == 0) { + [_locationManager stopUpdatingLocation]; + } } RCT_EXPORT_METHOD(getCurrentPosition:(NSDictionary *)optionsJSON @@ -198,56 +200,50 @@ - (void)timeout:(NSTimer *)timer return; } - dispatch_async(dispatch_get_main_queue(), ^{ - - if (![CLLocationManager locationServicesEnabled]) { - if (errorBlock) { - errorBlock(@[ - RCTPositionError(RCTPositionErrorUnavailable, @"Location services disabled.") - ]); - return; - } + if (![CLLocationManager locationServicesEnabled]) { + if (errorBlock) { + errorBlock(@[ + RCTPositionError(RCTPositionErrorUnavailable, @"Location services disabled.") + ]); + return; } + } - if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) { - if (errorBlock) { - errorBlock(@[ - RCTPositionError(RCTPositionErrorDenied, nil) - ]); - return; - } + if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) { + if (errorBlock) { + errorBlock(@[ + RCTPositionError(RCTPositionErrorDenied, nil) + ]); + return; } + } - // Get options - RCTLocationOptions options = RCTLocationOptionsWithJSON(optionsJSON); - - // Check if previous recorded location exists and is good enough - if (_lastLocationEvent && - CFAbsoluteTimeGetCurrent() - [RCTConvert NSTimeInterval:_lastLocationEvent[@"timestamp"]] < options.maximumAge && - [_lastLocationEvent[@"coords"][@"accuracy"] doubleValue] >= options.accuracy) { + // Check if previous recorded location exists and is good enough + RCTLocationOptions options = [RCTConvert RCTLocationOptions:optionsJSON]; + if (_lastLocationEvent && + CFAbsoluteTimeGetCurrent() - [RCTConvert NSTimeInterval:_lastLocationEvent[@"timestamp"]] < options.maximumAge && + [_lastLocationEvent[@"coords"][@"accuracy"] doubleValue] >= options.accuracy) { - // Call success block with most recent known location - successBlock(@[_lastLocationEvent]); - return; - } + // Call success block with most recent known location + successBlock(@[_lastLocationEvent]); + return; + } - // Create request - RCTLocationRequest *request = [[RCTLocationRequest alloc] init]; - request.successBlock = successBlock; - request.errorBlock = errorBlock ?: ^(NSArray *args){}; - request.options = options; - request.timeoutTimer = [NSTimer scheduledTimerWithTimeInterval:options.timeout - target:self - selector:@selector(timeout:) - userInfo:request - repeats:NO]; - [_pendingRequests addObject:request]; - - // Configure location manager and begin updating location - _locationManager.desiredAccuracy = MIN(_locationManager.desiredAccuracy, options.accuracy); - [self beginLocationUpdates]; - - }); + // Create request + RCTLocationRequest *request = [[RCTLocationRequest alloc] init]; + request.successBlock = successBlock; + request.errorBlock = errorBlock ?: ^(NSArray *args){}; + request.options = options; + request.timeoutTimer = [NSTimer scheduledTimerWithTimeInterval:options.timeout + target:self + selector:@selector(timeout:) + userInfo:request + repeats:NO]; + [_pendingRequests addObject:request]; + + // Configure location manager and begin updating location + _locationManager.desiredAccuracy = MIN(_locationManager.desiredAccuracy, options.accuracy); + [self beginLocationUpdates]; } #pragma mark - CLLocationManagerDelegate diff --git a/examples/node_modules/react-native/Libraries/Image/Image.ios.js b/examples/node_modules/react-native/Libraries/Image/Image.ios.js index fed358e1..e917b6b6 100644 --- a/examples/node_modules/react-native/Libraries/Image/Image.ios.js +++ b/examples/node_modules/react-native/Libraries/Image/Image.ios.js @@ -12,25 +12,23 @@ 'use strict'; var EdgeInsetsPropType = require('EdgeInsetsPropType'); +var ImageResizeMode = require('ImageResizeMode'); +var ImageStylePropTypes = require('ImageStylePropTypes'); var NativeMethodsMixin = require('NativeMethodsMixin'); var NativeModules = require('NativeModules'); -var Platform = require('Platform'); var PropTypes = require('ReactPropTypes'); -var ImageResizeMode = require('ImageResizeMode'); -var ImageStylePropTypes = require('ImageStylePropTypes'); var React = require('React'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); var StyleSheet = require('StyleSheet'); var StyleSheetPropType = require('StyleSheetPropType'); -var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); var flattenStyle = require('flattenStyle'); -var insetsDiffer = require('insetsDiffer'); var invariant = require('invariant'); var merge = require('merge'); var requireNativeComponent = require('requireNativeComponent'); -var warning = require('warning'); +var resolveAssetSource = require('resolveAssetSource'); var verifyPropTypes = require('verifyPropTypes'); +var warning = require('warning'); /** * A react component for displaying different types of images, @@ -125,10 +123,13 @@ var Image = React.createClass({ 'not be set directly on Image.'); } } - var style = flattenStyle([styles.base, this.props.style]); - invariant(style, "style must be initialized"); - var source = this.props.source; - invariant(source, "source must be initialized"); + var source = resolveAssetSource(this.props.source); + invariant(source, 'source must be initialized'); + + var {width, height} = source; + var style = flattenStyle([{width, height}, styles.base, this.props.style]); + invariant(style, 'style must be initialized'); + var isNetwork = source.uri && source.uri.match(/^https?:/); invariant( !(isNetwork && source.isStatic), @@ -156,12 +157,6 @@ var Image = React.createClass({ contentMode, tintColor: style.tintColor, }); - if (Platform.OS === 'android') { - // TODO: update android native code to not need this - nativeProps.resizeMode = contentMode; - delete nativeProps.contentMode; - } - if (isStored) { nativeProps.imageTag = source.uri; } else { @@ -180,30 +175,9 @@ var styles = StyleSheet.create({ }, }); -if (Platform.OS === 'android') { - var CommonImageViewAttributes = merge(ReactIOSViewAttributes.UIView, { - accessible: true, - accessibilityLabel: true, - capInsets: {diff: insetsDiffer}, // UIEdgeInsets=UIEdgeInsetsZero - imageTag: true, - resizeMode: true, - src: true, - testID: PropTypes.string, - }); - - var RCTStaticImage = createReactIOSNativeComponentClass({ - validAttributes: merge(CommonImageViewAttributes, { tintColor: true }), - uiViewClassName: 'RCTStaticImage', - }); - - var RCTNetworkImage = createReactIOSNativeComponentClass({ - validAttributes: merge(CommonImageViewAttributes, { defaultImageSrc: true }), - uiViewClassName: 'RCTNetworkImageView', - }); -} else { - var RCTStaticImage = requireNativeComponent('RCTStaticImage', null); - var RCTNetworkImage = requireNativeComponent('RCTNetworkImageView', null); -} +var RCTNetworkImage = requireNativeComponent('RCTNetworkImageView', null); +var RCTStaticImage = requireNativeComponent('RCTStaticImage', null); + var nativeOnlyProps = { src: true, defaultImageSrc: true, diff --git a/examples/node_modules/react-native/Libraries/Image/ImageResizeMode.js b/examples/node_modules/react-native/Libraries/Image/ImageResizeMode.js index 9a7a2f95..b947b952 100644 --- a/examples/node_modules/react-native/Libraries/Image/ImageResizeMode.js +++ b/examples/node_modules/react-native/Libraries/Image/ImageResizeMode.js @@ -30,8 +30,8 @@ var ImageResizeMode = keyMirror({ cover: null, /** * stretch - The image will be stretched to fill the entire frame of the - * view without clipping. This may change the aspect ratio of the image, - * distoring it. Only supported on iOS. + * view without clipping. This may change the aspect ratio of the image, + * distoring it. */ stretch: null, }); diff --git a/examples/node_modules/react-native/Libraries/Image/RCTGIFImage.m b/examples/node_modules/react-native/Libraries/Image/RCTGIFImage.m index e0975f4a..99704e30 100644 --- a/examples/node_modules/react-native/Libraries/Image/RCTGIFImage.m +++ b/examples/node_modules/react-native/Libraries/Image/RCTGIFImage.m @@ -14,7 +14,6 @@ static CAKeyframeAnimation *RCTGIFImageWithImageSource(CGImageSourceRef imageSource) { if (!UTTypeConformsTo(CGImageSourceGetType(imageSource), kUTTypeGIF)) { - CFRelease(imageSource); return nil; } diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/project.pbxproj index 33a5a65a..3431def5 100644 --- a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/project.pbxproj @@ -240,6 +240,7 @@ 58B511721A9E6B3D00147676 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -251,6 +252,7 @@ ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTImage; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -258,6 +260,7 @@ 58B511731A9E6B3D00147676 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -269,6 +272,7 @@ ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTImage; + RUN_CLANG_STATIC_ANALYZER = NO; SKIP_INSTALL = YES; }; name = Release; diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTImage.xcscheme b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTImage.xcscheme index 14d873e8..12d51914 100644 --- a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTImage.xcscheme +++ b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTImage.xcscheme @@ -1,6 +1,6 @@ RCTImage.xcscheme orderHint - 9 + 7 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTImage.xcscheme b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTImage.xcscheme deleted file mode 100644 index 12d51914..00000000 --- a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTImage.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 2a3c3981..264567ac 100644 --- a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTImage.xcscheme - - orderHint - 7 - - SuppressBuildableAutocreation 58B5115C1A9E6B3D00147676 diff --git a/examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetworkImage.xcscheme b/examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetworkImage.xcscheme deleted file mode 100644 index 241d1356..00000000 --- a/examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetworkImage.xcscheme +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 3a9f6580..00000000 --- a/examples/node_modules/react-native/Libraries/Image/RCTNetworkImage.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - SchemeUserState - - RCTNetworkImage.xcscheme - - orderHint - 52 - - - SuppressBuildableAutocreation - - 58B5115C1A9E6B3D00147676 - - primary - - - 58B511671A9E6B3D00147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Image/__tests__/resolveAssetSource-test.js b/examples/node_modules/react-native/Libraries/Image/__tests__/resolveAssetSource-test.js new file mode 100644 index 00000000..26f3c9ea --- /dev/null +++ b/examples/node_modules/react-native/Libraries/Image/__tests__/resolveAssetSource-test.js @@ -0,0 +1,135 @@ +/** + * 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. + */ +'use strict'; + +jest.dontMock('../resolveAssetSource'); + +var resolveAssetSource; +var SourceCode; + +function expectResolvesAsset(input, expectedSource) { + expect(resolveAssetSource(input)).toEqual(expectedSource); +} + +describe('resolveAssetSource', () => { + beforeEach(() => { + jest.resetModuleRegistry(); + SourceCode = require('NativeModules').SourceCode; + resolveAssetSource = require('../resolveAssetSource'); + }); + + it('returns same source for simple static and network images', () => { + var source1 = {uri: 'https://www.facebook.com/logo'}; + expect(resolveAssetSource(source1)).toBe(source1); + + var source2 = {isStatic: true, uri: 'logo'}; + expect(resolveAssetSource(source2)).toBe(source2); + }); + + describe('bundle was loaded from network', () => { + beforeEach(() => { + SourceCode.scriptURL = 'http://10.0.0.1:8081/main.bundle'; + }); + + it('uses network image', () => { + expectResolvesAsset({ + __packager_asset: true, + fileSystemLocation: '/root/app/module/a', + httpServerLocation: '/assets/module/a', + width: 100, + height: 200, + scales: [1], + hash: '5b6f00f', + name: 'logo', + type: 'png', + }, { + isStatic: false, + width: 100, + height: 200, + uri: 'http://10.0.0.1:8081/assets/module/a/logo.png?hash=5b6f00f', + }); + }); + + it('picks matching scale', () => { + expectResolvesAsset({ + __packager_asset: true, + fileSystemLocation: '/root/app/module/a', + httpServerLocation: '/assets/module/a', + width: 100, + height: 200, + scales: [1, 2, 3], + hash: '5b6f00f', + name: 'logo', + type: 'png', + }, { + isStatic: false, + width: 100, + height: 200, + uri: 'http://10.0.0.1:8081/assets/module/a/logo@2x.png?hash=5b6f00f', + }); + }); + + it('does not change deprecated assets', () => { + expectResolvesAsset({ + __packager_asset: true, + deprecated: true, + fileSystemLocation: '/root/app/module/a', + httpServerLocation: '/assets/module/a', + width: 100, + height: 200, + scales: [1], + hash: '5b6f00f', + name: 'logo', + type: 'png', + }, { + isStatic: true, + width: 100, + height: 200, + uri: 'logo', + }); + }); + }); + + describe('bundle was loaded from file', () => { + beforeEach(() => { + SourceCode.scriptURL = 'file:///Path/To/Simulator/main.bundle'; + }); + + it('uses pre-packed image', () => { + expectResolvesAsset({ + __packager_asset: true, + fileSystemLocation: '/root/app/module/a', + httpServerLocation: '/assets/module/a', + width: 100, + height: 200, + scales: [1], + hash: '5b6f00f', + name: 'logo', + type: 'png', + }, { + isStatic: true, + width: 100, + height: 200, + uri: 'assets/module/a/logo.png', + }); + }); + }); + +}); + +describe('resolveAssetSource.pickScale', () => { + it('picks matching scale', () => { + expect(resolveAssetSource.pickScale([1], 2)).toBe(1); + expect(resolveAssetSource.pickScale([1, 2, 3], 2)).toBe(2); + expect(resolveAssetSource.pickScale([1, 2], 3)).toBe(2); + expect(resolveAssetSource.pickScale([1, 2, 3, 4], 3.5)).toBe(4); + expect(resolveAssetSource.pickScale([3, 4], 2)).toBe(3); + expect(resolveAssetSource.pickScale([], 2)).toBe(1); + }); +}); diff --git a/examples/node_modules/react-native/Libraries/Image/resolveAssetSource.js b/examples/node_modules/react-native/Libraries/Image/resolveAssetSource.js new file mode 100644 index 00000000..da136e9a --- /dev/null +++ b/examples/node_modules/react-native/Libraries/Image/resolveAssetSource.js @@ -0,0 +1,101 @@ +/** + * 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 resolveAssetSource + */ +'use strict'; + +var PixelRatio = require('PixelRatio'); +var SourceCode = require('NativeModules').SourceCode; + +var _serverURL; + +function getServerURL() { + if (_serverURL === undefined) { + var scriptURL = SourceCode.scriptURL; + var match = scriptURL && scriptURL.match(/^https?:\/\/.*?\//); + if (match) { + _serverURL = match[0]; + } else { + _serverURL = null; + } + } + + return _serverURL; +} + +function pickScale(scales, deviceScale) { + // Packager guarantees that `scales` array is sorted + for (var i = 0; i < scales.length; i++) { + if (scales[i] >= deviceScale) { + return scales[i]; + } + } + + // If nothing matches, device scale is larger than any available + // scales, so we return the biggest one. Unless the array is empty, + // in which case we default to 1 + return scales[scales.length - 1] || 1; +} + +// TODO(frantic): +// * Pick best scale and append @Nx to file path +// * We are currently using httpServerLocation for both http and in-app bundle +function resolveAssetSource(source) { + if (!source.__packager_asset) { + return source; + } + + // Deprecated assets are managed by Xcode for now, + // just returning image name as `uri` + // Examples: + // require('image!deprecatd_logo_example') + // require('./new-hotness-logo-example.png') + if (source.deprecated) { + return { + width: source.width, + height: source.height, + isStatic: true, + uri: source.name || source.uri, // TODO(frantic): remove uri + }; + } + + // TODO(frantic): currently httpServerLocation is used both as + // path in http URL and path within IPA. Should we have zipArchiveLocation? + var path = source.httpServerLocation; + if (path[0] === '/') { + path = path.substr(1); + } + + var scale = pickScale(source.scales, PixelRatio.get()); + var scaleSuffix = scale === 1 ? '' : '@' + scale + 'x'; + + var fileName = source.name + scaleSuffix + '.' + source.type; + var serverURL = getServerURL(); + if (serverURL) { + return { + width: source.width, + height: source.height, + uri: serverURL + path + '/' + fileName + + '?hash=' + source.hash, + isStatic: false, + }; + } else { + return { + width: source.width, + height: source.height, + uri: path + '/' + fileName, + isStatic: true, + }; + } + + return source; +} + +module.exports = resolveAssetSource; +module.exports.pickScale = pickScale; diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js index d9118b74..c5476eaa 100644 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js +++ b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js @@ -28,7 +28,7 @@ type Exception = { function handleException(e: Exception) { var stack = parseErrorStack(e); console.error( - 'Error: ' + + 'Err0r: ' + '\n stack: \n' + stackToString(stack) + '\n URL: ' + e.sourceURL + '\n line: ' + e.line + diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js index e168daae..4d4d21e2 100644 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js +++ b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js @@ -7,8 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule loadSourceMap - * - * -- disabled flow due to mysterious validation errors -- + * @flow */ 'use strict'; @@ -40,7 +39,10 @@ function fetchSourceMap(): Promise { .then(response => response.text()) } -function extractSourceMapURL({url, text}): string { +function extractSourceMapURL({url, text, fullSourceMappingURL}): string { + if (fullSourceMappingURL) { + return fullSourceMappingURL; + } var mapURL = SourceMapURL.getFrom(text); var baseURL = url.match(/(.+:\/\/.*?)\//)[1]; return baseURL + mapURL; diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/LinkingIOS.js b/examples/node_modules/react-native/Libraries/LinkingIOS/LinkingIOS.js index d3a84501..7bd5c008 100644 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/LinkingIOS.js +++ b/examples/node_modules/react-native/Libraries/LinkingIOS/LinkingIOS.js @@ -80,6 +80,10 @@ var DEVICE_NOTIF_EVENT = 'openURL'; * } * }); * ``` + * + * _The iOS simulator does not support the `mailto:` and `tel:` schemas + * because the Mail and Phone apps are not installed - you will need to test + * them on a device._ */ class LinkingIOS { /** diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTLinking.xcscheme b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTLinking.xcscheme index c8f5b051..dedb7fea 100644 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTLinking.xcscheme +++ b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTLinking.xcscheme @@ -1,6 +1,6 @@ RCTLinking.xcscheme orderHint - 73 + 1 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTLinking.xcscheme b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTLinking.xcscheme deleted file mode 100644 index dedb7fea..00000000 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTLinking.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 58c71f2e..fbf5b0be 100644 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTLinking.xcscheme - - orderHint - 1 - - SuppressBuildableAutocreation 58B511DA1A9E6C8500147676 diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.h b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.h index 81680f05..caa3aa2a 100644 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.h +++ b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.h @@ -9,7 +9,7 @@ #import -#import "../../React/Base/RCTBridgeModule.h" +#import "RCTBridgeModule.h" @interface RCTLinkingManager : NSObject diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m index 990c5900..eec17a01 100644 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m +++ b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m @@ -36,6 +36,11 @@ - (void)dealloc [[NSNotificationCenter defaultCenter] removeObserver:self]; } +- (dispatch_queue_t)methodQueue +{ + return dispatch_queue_create("com.facebook.React.LinkingManager", DISPATCH_QUEUE_SERIAL); +} + + (BOOL)application:(UIApplication *)application openURL:(NSURL *)URL sourceApplication:(NSString *)sourceApplication @@ -56,12 +61,14 @@ - (void)handleOpenURLNotification:(NSNotification *)notification RCT_EXPORT_METHOD(openURL:(NSURL *)URL) { + // Doesn't really matter what thread we call this on since it exits the app [[UIApplication sharedApplication] openURL:URL]; } RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL callback:(RCTResponseSenderBlock)callback) { + // This can be expensive, so we deliberately don't call on main thread BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:URL]; callback(@[@(canOpen)]); } diff --git a/examples/node_modules/react-native/Libraries/Network/NetInfo.js b/examples/node_modules/react-native/Libraries/Network/NetInfo.js index d98b997c..2b65671a 100644 --- a/examples/node_modules/react-native/Libraries/Network/NetInfo.js +++ b/examples/node_modules/react-native/Libraries/Network/NetInfo.js @@ -34,7 +34,7 @@ type ReachabilityStateIOS = $Enum<{ * * ### reachabilityIOS * - * Asyncronously determine if the device is online and on a cellular network. + * Asynchronously determine if the device is online and on a cellular network. * * - `none` - device is offline * - `wifi` - device is online and connected via wifi, or is the iOS simulator @@ -60,7 +60,7 @@ type ReachabilityStateIOS = $Enum<{ * * ### isConnected * - * Available on all platforms. Asyncronously fetch a boolean to determine + * Available on all platforms. Asynchronously fetch a boolean to determine * internet connectivity. * * ``` diff --git a/examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTDataManager.xcscheme b/examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTDataManager.xcscheme deleted file mode 100644 index 8fc0433b..00000000 --- a/examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTDataManager.xcscheme +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 8e8fd374..00000000 --- a/examples/node_modules/react-native/Libraries/Network/RCTDataManager.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - SchemeUserState - - RCTDataManager.xcscheme - - orderHint - 51 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - 58B511E51A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj index 65295299..1dca7fe6 100644 --- a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj @@ -204,6 +204,7 @@ 58B511F01A9E6C8500147676 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -212,6 +213,7 @@ LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTNetwork; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -219,6 +221,7 @@ 58B511F11A9E6C8500147676 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetwork.xcscheme b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetwork.xcscheme index c47bde9e..fa4aac38 100644 --- a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetwork.xcscheme +++ b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTNetwork.xcscheme @@ -1,6 +1,6 @@ RCTNetwork.xcscheme orderHint - 6 + 8 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTNetwork.xcscheme b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTNetwork.xcscheme deleted file mode 100644 index fa4aac38..00000000 --- a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTNetwork.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index c2c2470a..fbf5b0be 100644 --- a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTNetwork.xcscheme - - orderHint - 8 - - SuppressBuildableAutocreation 58B511DA1A9E6C8500147676 diff --git a/examples/node_modules/react-native/Libraries/Network/RCTReachability.m b/examples/node_modules/react-native/Libraries/Network/RCTReachability.m index b5f30de3..e0711571 100644 --- a/examples/node_modules/react-native/Libraries/Network/RCTReachability.m +++ b/examples/node_modules/react-native/Libraries/Network/RCTReachability.m @@ -25,6 +25,8 @@ @implementation RCTReachability @synthesize bridge = _bridge; +RCT_EXPORT_MODULE() + static void RCTReachabilityCallback(__unused SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) { RCTReachability *self = (__bridge id)info; @@ -53,8 +55,6 @@ static void RCTReachabilityCallback(__unused SCNetworkReachabilityRef target, SC } } -RCT_EXPORT_MODULE() - #pragma mark - Lifecycle - (instancetype)initWithHost:(NSString *)host @@ -71,7 +71,7 @@ - (instancetype)initWithHost:(NSString *)host - (instancetype)init { - return [self initWithHost:@"http://apple.com"]; + return [self initWithHost:@"apple.com"]; } - (void)dealloc diff --git a/examples/node_modules/react-native/Libraries/Network/XMLHttpRequestBase.js b/examples/node_modules/react-native/Libraries/Network/XMLHttpRequestBase.js index d7619d07..4a4f16ac 100644 --- a/examples/node_modules/react-native/Libraries/Network/XMLHttpRequestBase.js +++ b/examples/node_modules/react-native/Libraries/Network/XMLHttpRequestBase.js @@ -53,13 +53,23 @@ class XMLHttpRequestBase { } getAllResponseHeaders(): ?string { - /* Stub */ - return ''; + if (this.responseHeaders) { + var headers = []; + for (var headerName in this.responseHeaders) { + headers.push(headerName + ': ' + this.responseHeaders[headerName]); + } + return headers.join('\n'); + } + // according to the spec, return null <==> no response has been received + return null; } getResponseHeader(header: string): ?string { - /* Stub */ - return ''; + if (this.responseHeaders) { + var value = this.responseHeaders[header]; + return value !== undefined ? value : null; + } + return null; } setRequestHeader(header: string, value: any): void { @@ -122,7 +132,7 @@ class XMLHttpRequestBase { return; } this.status = status; - this.responseHeaders = responseHeaders; + this.responseHeaders = responseHeaders || {}; this.responseText = responseText; this._setReadyState(this.DONE); this._sendLoad(); diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj index 10d8ce16..c65b8d3c 100644 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj @@ -198,6 +198,7 @@ 58B511F01A9E6C8500147676 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -206,6 +207,7 @@ LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = RCTPushNotification; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -213,6 +215,7 @@ 58B511F11A9E6C8500147676 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTPushNotification.xcscheme b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTPushNotification.xcscheme deleted file mode 100644 index 907d5a29..00000000 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTPushNotification.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index fde17876..00000000 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTPushNotification.xcscheme - - orderHint - 71 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h index 4e791c68..b60a646e 100644 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h +++ b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h @@ -9,7 +9,7 @@ #import -#import "../../React/Base/RCTBridgeModule.h" +#import "RCTBridgeModule.h" @interface RCTPushNotificationManager : NSObject diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m index 90f2d878..c0bedee5 100644 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m +++ b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m @@ -113,7 +113,7 @@ - (void)handleRemoteNotificationReceived:(NSNotification *)notification #endif - NSUInteger types; + NSUInteger types = 0; if ([UIApplication instancesRespondToSelector:@selector(currentUserNotificationSettings)]) { types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types]; } else { diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj index d4945f46..6ab58a8a 100644 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj @@ -246,6 +246,7 @@ 580C37841AB104AF0015E709 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -257,6 +258,7 @@ XCTest, ); PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -264,6 +266,7 @@ 580C37851AB104AF0015E709 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTTest.xcscheme b/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTTest.xcscheme deleted file mode 100644 index 07516fee..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTTest.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index d70e4c09..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTTest.xcscheme - - orderHint - 64 - - - SuppressBuildableAutocreation - - 580C376E1AB104AF0015E709 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.h b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.h index 21ed60c6..f248cbfc 100644 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.h +++ b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.h @@ -10,19 +10,30 @@ #import #import "RCTBridgeModule.h" +#import "RCTDefines.h" @class FBSnapshotTestController; @interface RCTTestModule : NSObject -// This is typically polled while running the runloop until true -@property (nonatomic, readonly, getter=isDone) BOOL done; - -// This is used to give meaningful names to snapshot image files. -@property (nonatomic, assign) SEL testSelector; +/** + * The snapshot test controller for this module. + */ +@property (nonatomic, weak) FBSnapshotTestController *controller; +/** + * This is the view to be snapshotted. + */ @property (nonatomic, weak) UIView *view; -- (instancetype)initWithSnapshotController:(FBSnapshotTestController *)controller view:(UIView *)view; +/** + * This is used to give meaningful names to snapshot image files. + */ +@property (nonatomic, assign) SEL testSelector; + +/** + * This is typically polled while running the runloop until true. + */ +@property (nonatomic, readonly, getter=isDone) BOOL done; @end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.m b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.m index 58b6572f..33f56251 100644 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.m +++ b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.m @@ -12,21 +12,25 @@ #import "FBSnapshotTestController.h" #import "RCTAssert.h" #import "RCTLog.h" +#import "RCTUIManager.h" @implementation RCTTestModule { - __weak FBSnapshotTestController *_snapshotController; - __weak UIView *_view; NSMutableDictionary *_snapshotCounter; } +@synthesize bridge = _bridge; + RCT_EXPORT_MODULE() -- (instancetype)initWithSnapshotController:(FBSnapshotTestController *)controller view:(UIView *)view +- (dispatch_queue_t)methodQueue +{ + return _bridge.uiManager.methodQueue; +} + +- (instancetype)init { if ((self = [super init])) { - _snapshotController = controller; - _view = view; _snapshotCounter = [NSMutableDictionary new]; } return self; @@ -34,30 +38,29 @@ - (instancetype)initWithSnapshotController:(FBSnapshotTestController *)controlle RCT_EXPORT_METHOD(verifySnapshot:(RCTResponseSenderBlock)callback) { - if (!_snapshotController) { - RCTLogWarn(@"No snapshot controller configured."); - callback(@[]); - return; - } + RCTAssert(_controller != nil, @"No snapshot controller configured."); + + [_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) { - dispatch_async(dispatch_get_main_queue(), ^{ NSString *testName = NSStringFromSelector(_testSelector); - _snapshotCounter[testName] = @([_snapshotCounter[testName] integerValue] + 1); + _snapshotCounter[testName] = [@([_snapshotCounter[testName] integerValue] + 1) stringValue]; + NSError *error = nil; - BOOL success = [_snapshotController compareSnapshotOfView:_view - selector:_testSelector - identifier:[_snapshotCounter[testName] stringValue] - error:&error]; + BOOL success = [_controller compareSnapshotOfView:_view + selector:_testSelector + identifier:_snapshotCounter[testName] + error:&error]; + RCTAssert(success, @"Snapshot comparison failed: %@", error); callback(@[]); - }); + }]; } RCT_EXPORT_METHOD(markTestCompleted) { - dispatch_async(dispatch_get_main_queue(), ^{ + [_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) { _done = YES; - }); + }]; } @end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.m b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.m index 9b3a7d3c..4d596374 100644 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.m +++ b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.m @@ -10,6 +10,7 @@ #import "RCTTestRunner.h" #import "FBSnapshotTestController.h" +#import "RCTDefines.h" #import "RCTRedBox.h" #import "RCTRootView.h" #import "RCTTestModule.h" @@ -19,7 +20,7 @@ @implementation RCTTestRunner { - FBSnapshotTestController *_snapshotController; + FBSnapshotTestController *_testController; } - (instancetype)initWithApp:(NSString *)app referenceDir:(NSString *)referenceDir @@ -27,8 +28,8 @@ - (instancetype)initWithApp:(NSString *)app referenceDir:(NSString *)referenceDi if ((self = [super init])) { NSString *sanitizedAppName = [app stringByReplacingOccurrencesOfString:@"/" withString:@"-"]; sanitizedAppName = [sanitizedAppName stringByReplacingOccurrencesOfString:@"\\" withString:@"-"]; - _snapshotController = [[FBSnapshotTestController alloc] initWithTestName:sanitizedAppName]; - _snapshotController.referenceImagesDirectory = referenceDir; + _testController = [[FBSnapshotTestController alloc] initWithTestName:sanitizedAppName]; + _testController.referenceImagesDirectory = referenceDir; _scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.includeRequire.runModule.bundle?dev=true", app]]; } return self; @@ -36,12 +37,12 @@ - (instancetype)initWithApp:(NSString *)app referenceDir:(NSString *)referenceDi - (void)setRecordMode:(BOOL)recordMode { - _snapshotController.recordMode = recordMode; + _testController.recordMode = recordMode; } - (BOOL)recordMode { - return _snapshotController.recordMode; + return _testController.recordMode; } - (void)runTest:(SEL)test module:(NSString *)moduleName @@ -59,26 +60,23 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName - (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock { - UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; - if ([vc.view isKindOfClass:[RCTRootView class]]) { - [(RCTRootView *)vc.view invalidate]; // Make sure the normal app view doesn't interfere - } - vc.view = [[UIView alloc] init]; + RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:_scriptURL + moduleName:moduleName + launchOptions:nil]; + rootView.initialProperties = initialProps; + rootView.frame = CGRectMake(0, 0, 320, 2000); // Constant size for testing on multiple devices - RCTTestModule *testModule = [[RCTTestModule alloc] initWithSnapshotController:_snapshotController view:nil]; + NSString *testModuleName = RCTBridgeModuleNameForClass([RCTTestModule class]); + RCTTestModule *testModule = rootView.bridge.modules[testModuleName]; + testModule.controller = _testController; testModule.testSelector = test; - RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_scriptURL - moduleProvider:^(){ - return @[testModule]; - } - launchOptions:nil]; - - RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge - moduleName:moduleName]; testModule.view = rootView; + + UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController; + vc.view = [[UIView alloc] init]; [vc.view addSubview:rootView]; // Add as subview so it doesn't get resized - rootView.initialProperties = initialProps; - rootView.frame = CGRectMake(0, 0, 320, 2000); // Constant size for testing on multiple devices + +#if RCT_DEBUG // Prevents build errors, as RCTRedBox is underfined if RCT_DEBUG=0 NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; NSString *error = [[RCTRedBox sharedInstance] currentErrorMessage]; @@ -100,6 +98,13 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictiona } else { RCTAssert([testModule isDone], @"Test didn't finish within %d seconds", TIMEOUT_SECONDS); } + +#else + + expectErrorBlock(@"RCTRedBox unavailable. Set RCT_DEBUG=1 for testing."); + +#endif + } @end diff --git a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj index acb5daa3..38ac20c7 100644 --- a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 00D277161AB8C32C00DC1E48 /* RCTWebSocketExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 00D277151AB8C32C00DC1E48 /* RCTWebSocketExecutor.m */; }; - 00D277191AB8C35800DC1E48 /* SRWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 00D277181AB8C35800DC1E48 /* SRWebSocket.m */; }; + 13AF20421AE707C5005F5298 /* SRWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 13AF20411AE707C5005F5298 /* SRWebSocket.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -26,8 +26,8 @@ /* Begin PBXFileReference section */ 00D277141AB8C32C00DC1E48 /* RCTWebSocketExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebSocketExecutor.h; sourceTree = ""; }; 00D277151AB8C32C00DC1E48 /* RCTWebSocketExecutor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWebSocketExecutor.m; sourceTree = ""; }; - 00D277171AB8C35800DC1E48 /* SRWebSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRWebSocket.h; sourceTree = ""; }; - 00D277181AB8C35800DC1E48 /* SRWebSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRWebSocket.m; sourceTree = ""; }; + 13AF20401AE707C5005F5298 /* SRWebSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRWebSocket.h; sourceTree = ""; }; + 13AF20411AE707C5005F5298 /* SRWebSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRWebSocket.m; sourceTree = ""; }; 832C81801AAF6DEF007FA2F7 /* libRCTWebSocketDebugger.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWebSocketDebugger.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -45,8 +45,8 @@ 832C81771AAF6DEF007FA2F7 = { isa = PBXGroup; children = ( - 00D277171AB8C35800DC1E48 /* SRWebSocket.h */, - 00D277181AB8C35800DC1E48 /* SRWebSocket.m */, + 13AF20401AE707C5005F5298 /* SRWebSocket.h */, + 13AF20411AE707C5005F5298 /* SRWebSocket.m */, 00D277141AB8C32C00DC1E48 /* RCTWebSocketExecutor.h */, 00D277151AB8C32C00DC1E48 /* RCTWebSocketExecutor.m */, 832C81811AAF6DEF007FA2F7 /* Products */, @@ -119,7 +119,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 00D277191AB8C35800DC1E48 /* SRWebSocket.m in Sources */, + 13AF20421AE707C5005F5298 /* SRWebSocket.m in Sources */, 00D277161AB8C32C00DC1E48 /* RCTWebSocketExecutor.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -214,6 +214,7 @@ 832C81951AAF6DF0007FA2F7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -224,6 +225,7 @@ "-llibicucore", ); PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -231,6 +233,7 @@ 832C81961AAF6DF0007FA2F7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme index b91d8fd0..372ea7ac 100644 --- a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme +++ b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme @@ -1,6 +1,6 @@ RCTWebSocketDebugger.xcscheme orderHint - 69 + 10 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme deleted file mode 100644 index 372ea7ac..00000000 --- a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTWebSocketDebugger.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 9a26a86f..1c95f28d 100644 --- a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketDebugger.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTWebSocketDebugger.xcscheme - - orderHint - 10 - - SuppressBuildableAutocreation 832C817F1AAF6DEF007FA2F7 diff --git a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.h b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.h index 3fc062a3..9993cbc5 100644 --- a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.h +++ b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.h @@ -7,6 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import "RCTDefines.h" + +#if RCT_DEV // Debug executors are only supported in dev mode + #import "RCTJavaScriptExecutor.h" @interface RCTWebSocketExecutor : NSObject @@ -14,3 +18,5 @@ - (instancetype)initWithURL:(NSURL *)URL; @end + +#endif diff --git a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m index 784c91e1..753c8d76 100644 --- a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m +++ b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/RCTWebSocketExecutor.m @@ -7,6 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import "RCTDefines.h" + +#if RCT_DEV // Debug executors are only supported in dev mode + #import "RCTWebSocketExecutor.h" #import "RCTLog.h" @@ -82,7 +86,7 @@ - (BOOL)prepareJSRuntime { __block NSError *initError; dispatch_semaphore_t s = dispatch_semaphore_create(0); - [self sendMessage:@{@"method": @"prepareJSRuntime"} waitForReply:^(NSError *error, NSDictionary *reply) { + [self sendMessage:@{@"method": @"prepareJSRuntime"} context:nil waitForReply:^(NSError *error, NSDictionary *reply) { initError = error; dispatch_semaphore_signal(s); }]; @@ -111,7 +115,7 @@ - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error RCTLogError(@"WebSocket connection failed with error %@", error); } -- (void)sendMessage:(NSDictionary *)message waitForReply:(WSMessageCallback)callback +- (void)sendMessage:(NSDictionary *)message context:(NSNumber *)executorID waitForReply:(WSMessageCallback)callback { static NSUInteger lastID = 10000; @@ -122,6 +126,8 @@ - (void)sendMessage:(NSDictionary *)message waitForReply:(WSMessageCallback)call }]; callback(error, nil); return; + } else if (executorID && ![RCTGetExecutorID(self) isEqualToNumber:executorID]) { + return; } NSNumber *expectedID = @(lastID++); @@ -134,22 +140,22 @@ - (void)sendMessage:(NSDictionary *)message waitForReply:(WSMessageCallback)call - (void)executeApplicationScript:(NSString *)script sourceURL:(NSURL *)URL onComplete:(RCTJavaScriptCompleteBlock)onComplete { - NSDictionary *message = @{@"method": NSStringFromSelector(_cmd), @"url": [URL absoluteString], @"inject": _injectedObjects}; - [self sendMessage:message waitForReply:^(NSError *error, NSDictionary *reply) { + NSDictionary *message = @{@"method": @"executeApplicationScript", @"url": [URL absoluteString], @"inject": _injectedObjects}; + [self sendMessage:message context:nil waitForReply:^(NSError *error, NSDictionary *reply) { onComplete(error); }]; } -- (void)executeJSCall:(NSString *)name method:(NSString *)method arguments:(NSArray *)arguments callback:(RCTJavaScriptCallback)onComplete +- (void)executeJSCall:(NSString *)name method:(NSString *)method arguments:(NSArray *)arguments context:(NSNumber *)executorID callback:(RCTJavaScriptCallback)onComplete { RCTAssert(onComplete != nil, @"callback was missing for exec JS call"); NSDictionary *message = @{ - @"method": NSStringFromSelector(_cmd), + @"method": @"executeJSCall", @"moduleName": name, @"moduleMethod": method, @"arguments": arguments }; - [self sendMessage:message waitForReply:^(NSError *socketError, NSDictionary *reply) { + [self sendMessage:message context:executorID waitForReply:^(NSError *socketError, NSDictionary *reply) { if (socketError) { onComplete(nil, socketError); return; @@ -169,6 +175,11 @@ - (void)injectJSONText:(NSString *)script asGlobalObjectNamed:(NSString *)object }); } +- (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block +{ + dispatch_async(dispatch_get_main_queue(), block); +} + - (void)invalidate { _socket.delegate = nil; @@ -187,3 +198,5 @@ - (void)dealloc } @end + +#endif diff --git a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/SRWebSocket.m b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/SRWebSocket.m index 3fd67510..e98e9e45 100644 --- a/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/SRWebSocket.m +++ b/examples/node_modules/react-native/Libraries/RCTWebSocketDebugger/SRWebSocket.m @@ -19,6 +19,8 @@ #import +#pragma clang diagnostic ignored "-Wshadow" + //NOTE: libicucore ins't actually needed for the socket to function //and by commenting this out, we avoid the need to import it into every app. @@ -1702,7 +1704,7 @@ static inline int32_t validate_dispatch_data_partial_string(NSData *data) { for (int i = 0; i < maxCodepointSize; i++) { NSString *str = [[NSString alloc] initWithBytesNoCopy:(char *)data.bytes length:data.length - i encoding:NSUTF8StringEncoding freeWhenDone:NO]; if (str) { - return data.length - i; + return (int32_t)(data.length - i); } } diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js b/examples/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js index ec72a0b4..9d413e5c 100644 --- a/examples/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js +++ b/examples/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js @@ -19,6 +19,7 @@ var TextInputState = require('TextInputState'); var flattenStyle = require('flattenStyle'); var invariant = require('invariant'); var mergeFast = require('mergeFast'); +var precomputeStyle = require('precomputeStyle'); type MeasureOnSuccessCallback = ( x: number, @@ -93,7 +94,7 @@ var NativeMethodsMixin = { break; } } - var style = flattenStyle(nativeProps.style); + var style = precomputeStyle(flattenStyle(nativeProps.style)); var props = null; if (hasOnlyStyle) { diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSMount.js b/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSMount.js index 73003167..ab46d6fe 100644 --- a/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSMount.js +++ b/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSMount.js @@ -194,7 +194,7 @@ var ReactIOSMount = { unmountComponentAtNode: function(containerTag: number): bool { if (!ReactIOSTagHandles.reactTagIsNativeTopRootID(containerTag)) { console.error('You cannot render into anything but a top root'); - return; + return false; } var containerID = ReactIOSTagHandles.tagToRootNodeID[containerTag]; diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSNativeComponent.js b/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSNativeComponent.js index b9abd596..7f27ae0e 100644 --- a/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSNativeComponent.js +++ b/examples/node_modules/react-native/Libraries/ReactIOS/ReactIOSNativeComponent.js @@ -23,6 +23,7 @@ var styleDiffer = require('styleDiffer'); var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev'); var diffRawProperties = require('diffRawProperties'); var flattenStyle = require('flattenStyle'); +var precomputeStyle = require('precomputeStyle'); var warning = require('warning'); var registrationNames = ReactIOSEventEmitter.registrationNames; @@ -160,7 +161,7 @@ ReactIOSNativeComponent.Mixin = { // before actually doing the expensive flattening operation in order to // compute the diff. if (styleDiffer(nextProps.style, prevProps.style)) { - var nextFlattenedStyle = flattenStyle(nextProps.style); + var nextFlattenedStyle = precomputeStyle(flattenStyle(nextProps.style)); updatePayload = diffRawProperties( updatePayload, this.previousFlattenedStyle, diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/requireNativeComponent.js b/examples/node_modules/react-native/Libraries/ReactIOS/requireNativeComponent.js index 55ad8a6b..4d924185 100644 --- a/examples/node_modules/react-native/Libraries/ReactIOS/requireNativeComponent.js +++ b/examples/node_modules/react-native/Libraries/ReactIOS/requireNativeComponent.js @@ -41,18 +41,19 @@ function requireNativeComponent( viewName: string, wrapperComponent: ?Function ): Function { - var viewConfig = RCTUIManager.viewConfigs && RCTUIManager.viewConfigs[viewName]; - if (!viewConfig) { + var viewConfig = RCTUIManager[viewName]; + if (!viewConfig || !viewConfig.nativeProps) { return UnimplementedView; } var nativeProps = { - ...RCTUIManager.viewConfigs.RCTView.nativeProps, + ...RCTUIManager.RCTView.nativeProps, ...viewConfig.nativeProps, }; + 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].type] || deepDiffer; + var differ = TypeToDifferMap[nativeProps[key]] || deepDiffer; viewConfig.validAttributes[key] = {diff: differ}; } if (__DEV__) { diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js b/examples/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js index 032e572e..ab1d6172 100644 --- a/examples/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js +++ b/examples/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js @@ -23,7 +23,7 @@ function verifyPropTypes( return; // This happens for UnimplementedView. } var nativeProps = viewConfig.nativeProps; - for (var prop in viewConfig.nativeProps) { + for (var prop in nativeProps) { if (!component.propTypes[prop] && !View.propTypes[prop] && !ReactIOSStyleAttributes[prop] && diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/precomputeStyle.js b/examples/node_modules/react-native/Libraries/StyleSheet/precomputeStyle.js new file mode 100644 index 00000000..ea2990b9 --- /dev/null +++ b/examples/node_modules/react-native/Libraries/StyleSheet/precomputeStyle.js @@ -0,0 +1,161 @@ +/** + * 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 precomputeStyle + * @flow + */ +'use strict'; + +var MatrixMath = require('MatrixMath'); +var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev'); +var invariant = require('invariant'); + +/** + * This method provides a hook where flattened styles may be precomputed or + * otherwise prepared to become better input data for native code. + */ +function precomputeStyle(style: ?Object): ?Object { + if (!style || !style.transform) { + return style; + } + invariant( + !style.transformMatrix, + 'transformMatrix and transform styles cannot be used on the same component' + ); + var newStyle = _precomputeTransforms({...style}); + deepFreezeAndThrowOnMutationInDev(newStyle); + return newStyle; +} + +/** + * Generate a transform matrix based on the provided transforms, and use that + * within the style object instead. + * + * This allows us to provide an API that is similar to CSS and to have a + * universal, singular interface to native code. + */ +function _precomputeTransforms(style: Object): Object { + var {transform} = style; + var result = MatrixMath.createIdentityMatrix(); + + transform.forEach(transformation => { + var key = Object.keys(transformation)[0]; + var value = transformation[key]; + if (__DEV__) { + _validateTransform(key, value, transformation); + } + + switch (key) { + case 'matrix': + MatrixMath.multiplyInto(result, result, value); + break; + case 'rotate': + _multiplyTransform(result, MatrixMath.reuseRotateZCommand, [_convertToRadians(value)]); + break; + case 'scale': + _multiplyTransform(result, MatrixMath.reuseScaleCommand, [value]); + break; + case 'scaleX': + _multiplyTransform(result, MatrixMath.reuseScaleXCommand, [value]); + break; + case 'scaleY': + _multiplyTransform(result, MatrixMath.reuseScaleYCommand, [value]); + break; + case 'translate': + _multiplyTransform(result, MatrixMath.reuseTranslate3dCommand, [value[0], value[1], value[2] || 0]); + break; + case 'translateX': + _multiplyTransform(result, MatrixMath.reuseTranslate2dCommand, [value, 0]); + break; + case 'translateY': + _multiplyTransform(result, MatrixMath.reuseTranslate2dCommand, [0, value]); + break; + default: + throw new Error('Invalid transform name: ' + key); + } + }); + + return { + ...style, + transformMatrix: result, + }; +} + +/** + * Performs a destructive operation on a transform matrix. + */ +function _multiplyTransform( + result: Array, + matrixMathFunction: Function, + args: Array +): void { + var matrixToApply = MatrixMath.createIdentityMatrix(); + var argsWithIdentity = [matrixToApply].concat(args); + matrixMathFunction.apply(this, argsWithIdentity); + MatrixMath.multiplyInto(result, result, matrixToApply); +} + +/** + * Parses a string like '0.5rad' or '60deg' into radians expressed in a float. + * Note that validation on the string is done in `_validateTransform()`. + */ +function _convertToRadians(value: string): number { + var floatValue = parseFloat(value, 10); + return value.indexOf('rad') > -1 ? floatValue : floatValue * Math.PI / 180; +} + +function _validateTransform(key, value, transformation) { + var multivalueTransforms = [ + 'matrix', + 'translate', + ]; + if (multivalueTransforms.indexOf(key) !== -1) { + invariant( + Array.isArray(value), + 'Transform with key of %s must have an array as the value: %s', + key, + JSON.stringify(transformation) + ); + } + switch (key) { + case 'matrix': + invariant( + value.length === 9 || value.length === 16, + 'Matrix transform must have a length of 9 (2d) or 16 (3d). ' + + 'Provided matrix has a length of %s: %s', + value.length, + JSON.stringify(transformation) + ); + break; + case 'translate': + break; + case 'rotate': + invariant( + typeof value === 'string', + 'Transform with key of "%s" must be a string: %s', + key, + JSON.stringify(transformation) + ); + invariant( + value.indexOf('deg') > -1 || value.indexOf('rad') > -1, + 'Rotate transform must be expressed in degrees (deg) or radians ' + + '(rad): %s', + JSON.stringify(transformation) + ); + break; + default: + invariant( + typeof value === 'number', + 'Transform with key of "%s" must be a number: %s', + key, + JSON.stringify(transformation) + ); + } +} + +module.exports = precomputeStyle; diff --git a/examples/node_modules/react-native/Libraries/Text/RCTShadowText.m b/examples/node_modules/react-native/Libraries/Text/RCTShadowText.m index 4201b1b4..4ea9d3bd 100644 --- a/examples/node_modules/react-native/Libraries/Text/RCTShadowText.m +++ b/examples/node_modules/react-native/Libraries/Text/RCTShadowText.m @@ -22,15 +22,21 @@ static css_dim_t RCTMeasure(void *context, float width) RCTShadowText *shadowText = (__bridge RCTShadowText *)context; NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:[shadowText attributedString]]; + NSTextStorage *previousTextStorage = shadowText.layoutManager.textStorage; + if (previousTextStorage) { + [previousTextStorage removeLayoutManager:shadowText.layoutManager]; + } [textStorage addLayoutManager:shadowText.layoutManager]; shadowText.textContainer.size = CGSizeMake(isnan(width) ? CGFLOAT_MAX : width, CGFLOAT_MAX); - shadowText.layoutManager.textStorage = textStorage; [shadowText.layoutManager ensureLayoutForTextContainer:shadowText.textContainer]; CGSize computedSize = [shadowText.layoutManager usedRectForTextContainer:shadowText.textContainer].size; [textStorage removeLayoutManager:shadowText.layoutManager]; + if (previousTextStorage) { + [previousTextStorage addLayoutManager:shadowText.layoutManager]; + } css_dim_t result; result.dimensions[CSS_WIDTH] = RCTCeilPixelValue(computedSize.width); diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.m b/examples/node_modules/react-native/Libraries/Text/RCTText.m index 84f6b85e..9d2ade8e 100644 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.m +++ b/examples/node_modules/react-native/Libraries/Text/RCTText.m @@ -25,6 +25,7 @@ - (instancetype)initWithFrame:(CGRect)frame if ((self = [super initWithFrame:frame])) { _textStorage = [[NSTextStorage alloc] init]; + self.opaque = NO; self.contentMode = UIViewContentModeRedraw; } @@ -94,21 +95,18 @@ - (CGRect)textFrame return UIEdgeInsetsInsetRect(self.bounds, _contentInset); } -- (void)layoutSubviews +- (void)drawRect:(CGRect)rect { - [super layoutSubviews]; + CGRect textFrame = [self textFrame]; - // The header comment for `size` says that a height of 0.0 should be enough, - // but it isn't. - _textContainer.size = CGSizeMake([self textFrame].size.width, CGFLOAT_MAX); -} + // We reset the text container size every time because RCTShadowText's + // RCTMeasure overrides it. The header comment for `size` says that a height + // of 0.0 should be enough, but it isn't. + _textContainer.size = CGSizeMake(textFrame.size.width, CGFLOAT_MAX); -- (void)drawRect:(CGRect)rect -{ - CGPoint origin = [self textFrame].origin; NSRange glyphRange = [_layoutManager glyphRangeForTextContainer:_textContainer]; - [_layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:origin]; - [_layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:origin]; + [_layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:textFrame.origin]; + [_layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:textFrame.origin]; } - (NSNumber *)reactTagAtPoint:(CGPoint)point diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/project.pbxproj index 0304ef85..3c4bcf5b 100644 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/project.pbxproj @@ -222,6 +222,7 @@ 58B511B01A9E6C1300147676 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -229,6 +230,7 @@ ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -236,6 +238,7 @@ 58B511B11A9E6C1300147676 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTText.xcscheme b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTText.xcscheme index 994df316..4f26e615 100644 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTText.xcscheme +++ b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTText.xcscheme @@ -1,6 +1,6 @@ - - - - - - - - - - - - primary - 58B511A51A9E6C1300147676 - - primary - - diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTText.xcscheme b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTText.xcscheme deleted file mode 100644 index 4f26e615..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTText.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 3c9f074b..b2755fd6 100644 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTText.xcscheme - - orderHint - 3 - - SuppressBuildableAutocreation 58B5119A1A9E6C1200147676 diff --git a/examples/node_modules/react-native/Libraries/Text/RCTTextManager.m b/examples/node_modules/react-native/Libraries/Text/RCTTextManager.m index b8dabcf2..e5e9ad00 100644 --- a/examples/node_modules/react-native/Libraries/Text/RCTTextManager.m +++ b/examples/node_modules/react-native/Libraries/Text/RCTTextManager.m @@ -46,7 +46,7 @@ - (RCTShadowView *)shadowView RCT_EXPORT_SHADOW_PROPERTY(fontStyle, NSString) RCT_EXPORT_SHADOW_PROPERTY(isHighlighted, BOOL) RCT_EXPORT_SHADOW_PROPERTY(lineHeight, CGFloat) -RCT_EXPORT_SHADOW_PROPERTY(maxNumberOfLines, NSInteger) +RCT_EXPORT_SHADOW_PROPERTY(maximumNumberOfLines, NSInteger) RCT_EXPORT_SHADOW_PROPERTY(shadowOffset, CGSize) RCT_EXPORT_SHADOW_PROPERTY(textAlign, NSTextAlignment) RCT_REMAP_SHADOW_PROPERTY(backgroundColor, textBackgroundColor, UIColor) diff --git a/examples/node_modules/react-native/Libraries/Utilities/AlertIOS.js b/examples/node_modules/react-native/Libraries/Utilities/AlertIOS.js index de72d7b9..0d1612bc 100644 --- a/examples/node_modules/react-native/Libraries/Utilities/AlertIOS.js +++ b/examples/node_modules/react-native/Libraries/Utilities/AlertIOS.js @@ -37,7 +37,7 @@ var DEFAULT_BUTTON = { * {text: 'Foo', onPress: () => console.log('Foo Pressed!')}, * {text: 'Bar', onPress: () => console.log('Bar Pressed!')}, * ] - * )} + * ) * ``` */ diff --git a/examples/node_modules/react-native/Libraries/Utilities/MatrixMath.js b/examples/node_modules/react-native/Libraries/Utilities/MatrixMath.js new file mode 100755 index 00000000..7f3d17c4 --- /dev/null +++ b/examples/node_modules/react-native/Libraries/Utilities/MatrixMath.js @@ -0,0 +1,131 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * @providesModule MatrixMath + */ +'use strict'; + +/** + * Memory conservative (mutative) matrix math utilities. Uses "command" + * matrices, which are reusable. + */ +var MatrixMath = { + createIdentityMatrix: function() { + return [ + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1 + ]; + }, + + createCopy: function(m) { + return [ + m[0], m[1], m[2], m[3], + m[4], m[5], m[6], m[7], + m[8], m[9], m[10], m[11], + m[12], m[13], m[14], m[15], + ]; + }, + + createTranslate2d: function(x, y) { + var mat = MatrixMath.createIdentityMatrix(); + MatrixMath.reuseTranslate2dCommand(mat, x, y); + return mat; + }, + + reuseTranslate2dCommand: function(matrixCommand, x, y) { + matrixCommand[12] = x; + matrixCommand[13] = y; + }, + + reuseTranslate3dCommand: function(matrixCommand, x, y, z) { + matrixCommand[12] = x; + matrixCommand[13] = y; + matrixCommand[14] = z; + }, + + createScale: function(factor) { + var mat = MatrixMath.createIdentityMatrix(); + MatrixMath.reuseScaleCommand(mat, factor); + return mat; + }, + + reuseScaleCommand: function(matrixCommand, factor) { + matrixCommand[0] = factor; + matrixCommand[5] = factor; + }, + + reuseScale3dCommand: function(matrixCommand, x, y, z) { + matrixCommand[0] = x; + matrixCommand[5] = y; + matrixCommand[10] = z; + }, + + reuseScaleXCommand(matrixCommand, factor) { + matrixCommand[0] = factor; + }, + + reuseScaleYCommand(matrixCommand, factor) { + matrixCommand[5] = factor; + }, + + reuseScaleZCommand(matrixCommand, factor) { + matrixCommand[10] = factor; + }, + + reuseRotateYCommand: function(matrixCommand, amount) { + matrixCommand[0] = Math.cos(amount); + matrixCommand[2] = Math.sin(amount); + matrixCommand[8] = Math.sin(-amount); + matrixCommand[10] = Math.cos(amount); + }, + + createRotateZ: function(radians) { + var mat = MatrixMath.createIdentityMatrix(); + MatrixMath.reuseRotateZCommand(mat, radians); + return mat; + }, + + // http://www.w3.org/TR/css3-transforms/#recomposing-to-a-2d-matrix + reuseRotateZCommand: function(matrixCommand, radians) { + matrixCommand[0] = Math.cos(radians); + matrixCommand[1] = Math.sin(radians); + matrixCommand[4] = -Math.sin(radians); + matrixCommand[5] = Math.cos(radians); + }, + + multiplyInto: function(out, a, b) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], + a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], + a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; + out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; + out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; + out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + } + +}; + +module.exports = MatrixMath; diff --git a/examples/node_modules/react-native/Libraries/Utilities/MessageQueue.js b/examples/node_modules/react-native/Libraries/Utilities/MessageQueue.js index c047d06d..576aaa99 100644 --- a/examples/node_modules/react-native/Libraries/Utilities/MessageQueue.js +++ b/examples/node_modules/react-native/Libraries/Utilities/MessageQueue.js @@ -10,7 +10,9 @@ * @flow */ 'use strict'; + var ErrorUtils = require('ErrorUtils'); +var ReactUpdates = require('ReactUpdates'); var invariant = require('invariant'); var warning = require('warning'); @@ -307,21 +309,23 @@ var MessageQueueMixin = { ); }, - processBatch: function (batch) { + processBatch: function(batch) { var self = this; - batch.forEach(function (call) { - invariant( - call.module === 'BatchedBridge', - 'All the calls should pass through the BatchedBridge module' - ); - if (call.method === 'callFunctionReturnFlushedQueue') { - self.callFunction.apply(self, call.args); - } else if (call.method === 'invokeCallbackAndReturnFlushedQueue') { - self.invokeCallback.apply(self, call.args); - } else { - throw new Error( - 'Unrecognized method called on BatchedBridge: ' + call.method); - } + ReactUpdates.batchedUpdates(function() { + batch.forEach(function(call) { + invariant( + call.module === 'BatchedBridge', + 'All the calls should pass through the BatchedBridge module' + ); + if (call.method === 'callFunctionReturnFlushedQueue') { + self.callFunction.apply(self, call.args); + } else if (call.method === 'invokeCallbackAndReturnFlushedQueue') { + self.invokeCallback.apply(self, call.args); + } else { + throw new Error( + 'Unrecognized method called on BatchedBridge: ' + call.method); + } + }); }); return this.flushedQueue(); }, diff --git a/examples/node_modules/react-native/Libraries/Utilities/PixelRatio.js b/examples/node_modules/react-native/Libraries/Utilities/PixelRatio.js index f8e23398..e6c96b7f 100644 --- a/examples/node_modules/react-native/Libraries/Utilities/PixelRatio.js +++ b/examples/node_modules/react-native/Libraries/Utilities/PixelRatio.js @@ -36,8 +36,8 @@ var Dimensions = require('Dimensions'); * * ``` * var image = getImage({ - * width: 200 * PixelRatio.get(), - * height: 100 * PixelRatio.get() + * width: PixelRatio.getPixelSizeForLayoutSize(200), + * height: PixelRatio.getPixelSizeForLayoutSize(100), * }); * * ``` @@ -52,10 +52,21 @@ class PixelRatio { * - iPhone 6 * - PixelRatio.get() === 3 * - iPhone 6 plus + * - PixelRatio.get() === 3.5 + * - Nexus 6 */ static get(): number { return Dimensions.get('window').scale; } + + /** + * Converts a layout size (dp) to pixel size (px). + * + * Guaranteed to return an integer number. + */ + static getPixelSizeForLayoutSize(layoutSize: number): number { + return Math.round(layoutSize * PixelRatio.get()); + } } // No-op for iOS, but used on the web. Should not be documented. diff --git a/examples/node_modules/react-native/Libraries/Utilities/__mocks__/ErrorUtils.js b/examples/node_modules/react-native/Libraries/Utilities/__mocks__/ErrorUtils.js new file mode 100644 index 00000000..99db7917 --- /dev/null +++ b/examples/node_modules/react-native/Libraries/Utilities/__mocks__/ErrorUtils.js @@ -0,0 +1,23 @@ +// This mock only provides short-circuited methods of applyWithGuard and guard. +// A lot of modules rely on these two functions. This mock relieves their tests +// from depending on the real ErrorUtils module. If you need real error handling +// don't use this mock. +'use strict'; + +function execute(fun, context, args) { + return fun.apply(context, args); +}; + +function reportError(error) { + throw error; +} + +var ErrorUtils = { + apply: jest.genMockFunction().mockImplementation(execute), + applyWithGuard: jest.genMockFunction().mockImplementation(execute), + inGuard: jest.genMockFunction().mockReturnValue(true), + reportError: jest.genMockFunction().mockImplementation(reportError), + setGlobalHandler: jest.genMockFunction(), +}; + +module.exports = ErrorUtils; diff --git a/examples/node_modules/react-native/Libraries/Utilities/__mocks__/PixelRatio.js b/examples/node_modules/react-native/Libraries/Utilities/__mocks__/PixelRatio.js new file mode 100644 index 00000000..bcf04d7f --- /dev/null +++ b/examples/node_modules/react-native/Libraries/Utilities/__mocks__/PixelRatio.js @@ -0,0 +1,20 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + */ +'use strict'; + +var PixelRatio = { + startDetecting: function () { + // noop for our implementation + }, + + get: function() { + return 2; + }, + + getPixelSizeForLayoutSize: function (layoutSize) { + return Math.round(layoutSize * PixelRatio.get()); + } +}; + +module.exports = PixelRatio; diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/__tests__/deepDiffer-test.js b/examples/node_modules/react-native/Libraries/Utilities/differ/__tests__/deepDiffer-test.js new file mode 100644 index 00000000..745b83ab --- /dev/null +++ b/examples/node_modules/react-native/Libraries/Utilities/differ/__tests__/deepDiffer-test.js @@ -0,0 +1,102 @@ +/** + * 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. + */ +'use strict'; + +jest.dontMock('deepDiffer'); +var deepDiffer = require('deepDiffer'); + +describe('deepDiffer', function() { + it('should diff primitives of the same type', () => { + expect(deepDiffer(1, 2)).toBe(true); + expect(deepDiffer(42, 42)).toBe(false); + expect(deepDiffer('foo', 'bar')).toBe(true); + expect(deepDiffer('foo', 'foo')).toBe(false); + expect(deepDiffer(true, false)).toBe(true); + expect(deepDiffer(false, true)).toBe(true); + expect(deepDiffer(true, true)).toBe(false); + expect(deepDiffer(false, false)).toBe(false); + expect(deepDiffer(null, null)).toBe(false); + expect(deepDiffer(undefined, undefined)).toBe(false); + }); + it('should diff primitives of different types', () => { + expect(deepDiffer(1, '1')).toBe(true); + expect(deepDiffer(true, 'true')).toBe(true); + expect(deepDiffer(true, 1)).toBe(true); + expect(deepDiffer(false, 0)).toBe(true); + expect(deepDiffer(null, undefined)).toBe(true); + expect(deepDiffer(null, 0)).toBe(true); + expect(deepDiffer(null, false)).toBe(true); + expect(deepDiffer(null, '')).toBe(true); + expect(deepDiffer(undefined, 0)).toBe(true); + expect(deepDiffer(undefined, false)).toBe(true); + expect(deepDiffer(undefined, '')).toBe(true); + }); + it('should diff Objects', () => { + expect(deepDiffer({}, {})).toBe(false); + expect(deepDiffer({}, null)).toBe(true); + expect(deepDiffer(null, {})).toBe(true); + expect(deepDiffer({a: 1}, {a: 1})).toBe(false); + expect(deepDiffer({a: 1}, {a: 2})).toBe(true); + expect(deepDiffer({a: 1}, {a: 1, b: null})).toBe(true); + expect(deepDiffer({a: 1}, {a: 1, b: 1})).toBe(true); + expect(deepDiffer({a: 1, b: 1}, {a: 1})).toBe(true); + expect(deepDiffer({a: {A: 1}, b: 1}, {a: {A: 1}, b: 1})).toBe(false); + expect(deepDiffer({a: {A: 1}, b: 1}, {a: {A: 2}, b: 1})).toBe(true); + expect(deepDiffer( + {a: {A: {aA: 1, bB: 1}}, b: 1}, + {a: {A: {aA: 1, bB: 1}}, b: 1} + )).toBe(false); + expect(deepDiffer( + {a: {A: {aA: 1, bB: 1}}, b: 1}, + {a: {A: {aA: 1, cC: 1}}, b: 1} + )).toBe(true); + }); + it('should diff Arrays', () => { + expect(deepDiffer([], [])).toBe(false); + expect(deepDiffer([], null)).toBe(true); + expect(deepDiffer(null, [])).toBe(true); + expect(deepDiffer([42], [42])).toBe(false); + expect(deepDiffer([1], [2])).toBe(true); + expect(deepDiffer([1, 2, 3], [1, 2, 3])).toBe(false); + expect(deepDiffer([1, 2, 3], [1, 2, 4])).toBe(true); + expect(deepDiffer([1, 2, 3], [1, 4, 3])).toBe(true); + expect(deepDiffer([1, 2, 3, 4], [1, 2, 3])).toBe(true); + expect(deepDiffer([1, 2, 3], [1, 2, 3, 4])).toBe(true); + expect(deepDiffer([0, null, false, ''], [0, null, false, ''])).toBe(false); + expect(deepDiffer([0, null, false, ''], ['', false, null, 0])).toBe(true); + }); + it('should diff mixed types', () => { + expect(deepDiffer({}, [])).toBe(true); + expect(deepDiffer([], {})).toBe(true); + expect(deepDiffer( + {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, + {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]} + )).toBe(false); + expect(deepDiffer( + {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, + {a: [{A: {aA: 1, bB: 2}}, 'bar'], c: [1, [false]]} + )).toBe(true); + expect(deepDiffer( + {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, + {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false], null]} + )).toBe(true); + expect(deepDiffer( + {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, + {a: [{A: {aA: 1, bB: 1}}, ['bar']], c: [1, [false]]} + )).toBe(true); + }); + it('should distinguish between proper Array and Object', () => { + expect(deepDiffer(['a', 'b'], {0: 'a', 1: 'b', length: 2})).toBe(true); + expect(deepDiffer(['a', 'b'], {length: 2, 0: 'a', 1: 'b'})).toBe(true); + }); + it('should diff same object', () => { + var obj = [1,[2,3]]; + expect(deepDiffer(obj, obj)).toBe(false); + }); +}); diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js b/examples/node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js index 66dc7fa9..4dec6bd7 100644 --- a/examples/node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js +++ b/examples/node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js @@ -35,16 +35,29 @@ var deepDiffer = function(one: any, two: any): bool { if (one.constructor !== two.constructor) { return true; } - for (var key in one) { - if (deepDiffer(one[key], two[key])) { + if (Array.isArray(one)) { + // We know two is also an array because the constructors are equal + var len = one.length; + if (two.length !== len) { return true; } - } - for (var twoKey in two) { - // The only case we haven't checked yet is keys that are in two but aren't - // in one, which means they are different. - if (one[twoKey] === undefined && two[twoKey] !== undefined) { - return true; + for (var ii = 0; ii < len; ii++) { + if (deepDiffer(one[ii], two[ii])) { + return true; + } + } + } else { + for (var key in one) { + if (deepDiffer(one[key], two[key])) { + return true; + } + } + for (var twoKey in two) { + // The only case we haven't checked yet is keys that are in two but aren't + // in one, which means they are different. + if (one[twoKey] === undefined && two[twoKey] !== undefined) { + return true; + } } } return false; diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj index bc8a47cb..f8aec3fe 100644 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj @@ -208,6 +208,7 @@ 832C81951AAF6DF0007FA2F7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, @@ -215,6 +216,7 @@ ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -222,6 +224,7 @@ 832C81961AAF6DF0007FA2F7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; HEADER_SEARCH_PATHS = ( "$(inherited)", /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTVibration.xcscheme b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTVibration.xcscheme index 298a6c87..1bb60621 100644 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTVibration.xcscheme +++ b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTVibration.xcscheme @@ -1,6 +1,6 @@ RCTVibration.xcscheme orderHint - 67 + 9 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTVibration.xcscheme b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTVibration.xcscheme deleted file mode 100644 index 1bb60621..00000000 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTVibration.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index a7e4b7e6..1c95f28d 100644 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - RCTVibration.xcscheme - - orderHint - 9 - - SuppressBuildableAutocreation 832C817F1AAF6DEF007FA2F7 diff --git a/examples/node_modules/react-native/README.md b/examples/node_modules/react-native/README.md index e7921b38..68479541 100644 --- a/examples/node_modules/react-native/README.md +++ b/examples/node_modules/react-native/README.md @@ -138,6 +138,7 @@ RCT_EXPORT_METHOD(processString:(NSString *)input callback:(RCTResponseSenderBlo { callback(@[[input stringByReplacingOccurrencesOfString:@"Goodbye" withString:@"Hello"]]); } + @end ``` @@ -164,7 +165,7 @@ var Message = React.createClass({ }); ``` -Custom iOS views can be exposed by subclassing `RCTViewManager`, implementing a `-view` method, and exporting properties with the `RCT_EXPORT_VIEW_PROPERTY` macro. Then a simple JavaScript file connects the dots. +Custom iOS views can be exposed by subclassing `RCTViewManager`, implementing a `-view` method, and exporting properties with the `RCT_EXPORT_VIEW_PROPERTY` macro. Then use `requireNativeComponent` in JavaScript to use the component in your app. ```objc // Objective-C @@ -175,12 +176,13 @@ Custom iOS views can be exposed by subclassing `RCTViewManager`, implementing a @end @implementation MyCustomViewManager + - (UIView *)view { return [[MyCustomView alloc] init]; } -RCT_EXPORT_VIEW_PROPERTY(myCustomProperty); +RCT_EXPORT_VIEW_PROPERTY(myCustomProperty, NSString); @end ``` @@ -188,10 +190,20 @@ RCT_EXPORT_VIEW_PROPERTY(myCustomProperty); ```javascript // JavaScript -var MyCustomView = createReactIOSNativeComponentClass({ - validAttributes: { myCustomProperty: true }, - uiViewClassName: 'MyCustomView', -}); +var React = require('react-native'); +var { requireNativeComponent } = React; + +class MyCustomView extends React.Component { + render() { + return ; + } +} +MyCustomView.propTypes = { + myCustomProperty: React.PropTypes.oneOf(['a', 'b']), +}; + +var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView); +module.exports = MyCustomView; ``` ## Running the Examples diff --git a/examples/node_modules/react-native/React/Base/RCTAssert.h b/examples/node_modules/react-native/React/Base/RCTAssert.h index 7e73aed7..b0a3c5c5 100644 --- a/examples/node_modules/react-native/React/Base/RCTAssert.h +++ b/examples/node_modules/react-native/React/Base/RCTAssert.h @@ -9,21 +9,7 @@ #import -#ifdef __cplusplus -extern "C" { -#endif - -/** - * By default, only raise an NSAssertion in debug mode - * (custom assert functions will still be called). - */ -#ifndef RCT_ASSERT -#if DEBUG -#define RCT_ASSERT 1 -#else -#define RCT_ASSERT 0 -#endif -#endif +#import "RCTDefines.h" /** * The default error domain to be used for React errors. @@ -44,13 +30,14 @@ typedef void (^RCTAssertFunction)( /** * Private logging function - ignore this. */ -void _RCTAssertFormat(BOOL, const char *, int, const char *, NSString *, ...) NS_FORMAT_FUNCTION(5,6); +RCT_EXTERN void _RCTAssertFormat( + BOOL, const char *, int, const char *, NSString *, ...) NS_FORMAT_FUNCTION(5,6); /** * This is the main assert macro that you should use. */ #define RCTAssert(condition, ...) do { BOOL pass = ((condition) != 0); \ -if (RCT_ASSERT && !pass) { [[NSAssertionHandler currentHandler] handleFailureInFunction:@(__func__) \ +if (RCT_NSASSERT && !pass) { [[NSAssertionHandler currentHandler] handleFailureInFunction:@(__func__) \ file:@(__FILE__) lineNumber:__LINE__ description:__VA_ARGS__]; } \ _RCTAssertFormat(pass, __FILE__, __LINE__, __func__, __VA_ARGS__); \ } while (false) @@ -66,16 +53,12 @@ _RCTAssertFormat(pass, __FILE__, __LINE__, __func__, __VA_ARGS__); \ * macros. You can use these to replace the standard behavior with custom log * functionality. */ -void RCTSetAssertFunction(RCTAssertFunction assertFunction); -RCTAssertFunction RCTGetAssertFunction(void); +RCT_EXTERN void RCTSetAssertFunction(RCTAssertFunction assertFunction); +RCT_EXTERN RCTAssertFunction RCTGetAssertFunction(void); /** * This appends additional code to the existing assert function, without * replacing the existing functionality. Useful if you just want to forward * assert info to an extra service without changing the default behavior. */ -void RCTAddAssertFunction(RCTAssertFunction assertFunction); - -#ifdef __cplusplus -} -#endif +RCT_EXTERN void RCTAddAssertFunction(RCTAssertFunction assertFunction); diff --git a/examples/node_modules/react-native/React/Base/RCTBridge.h b/examples/node_modules/react-native/React/Base/RCTBridge.h index ab853851..6dfbe241 100644 --- a/examples/node_modules/react-native/React/Base/RCTBridge.h +++ b/examples/node_modules/react-native/React/Base/RCTBridge.h @@ -10,6 +10,7 @@ #import #import "RCTBridgeModule.h" +#import "RCTDefines.h" #import "RCTFrameUpdate.h" #import "RCTInvalidating.h" #import "RCTJavaScriptExecutor.h" @@ -40,7 +41,7 @@ typedef NSArray *(^RCTBridgeModuleProviderBlock)(void); /** * This function returns the module name for a given class. */ -extern NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass); +RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass); /** * Async batched bridge used to communicate with the JavaScript application. @@ -62,9 +63,9 @@ extern NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass); /** * This method is used to call functions in the JavaScript application context. * It is primarily intended for use by modules that require two-way communication - * with the JavaScript code. Method should be regsitered using the + * with the JavaScript code. Method should be registered using the * RCT_IMPORT_METHOD macro below. Attempting to call a method that has not been - * registered will result in an error. + * registered will result in an error. Safe to call from any thread. */ - (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args; @@ -88,6 +89,11 @@ static const char *__rct_import_##module##_##method##__ = #module"."#method; url:(NSURL *)url onComplete:(RCTJavaScriptCompleteBlock)onComplete; +/** + * URL of the script that was loaded into the bridge. + */ +@property (nonatomic, copy) NSURL *bundleURL; + @property (nonatomic, strong) Class executorClass; /** @@ -101,13 +107,6 @@ static const char *__rct_import_##module##_##method##__ = #module"."#method; */ @property (nonatomic, copy, readonly) NSDictionary *modules; -/** - * The shadow queue is used to execute callbacks from the JavaScript code. All - * native hooks (e.g. exported module methods) will be executed on the shadow - * queue. - */ -@property (nonatomic, readonly) dispatch_queue_t shadowQueue; - /** * The launch options that were used to initialize the bridge. */ @@ -119,17 +118,17 @@ static const char *__rct_import_##module##_##method##__ = #module"."#method; @property (nonatomic, readonly, getter=isLoading) BOOL loading; /** - * Reload the bundle and reset executor and modules. + * Reload the bundle and reset executor & modules. Safe to call from any thread. */ - (void)reload; /** - * Add a new observer that will be called on every screen refresh + * Add a new observer that will be called on every screen refresh. */ - (void)addFrameUpdateObserver:(id)observer; /** - * Stop receiving screen refresh updates for the given observer + * Stop receiving screen refresh updates for the given observer. */ - (void)removeFrameUpdateObserver:(id)observer; diff --git a/examples/node_modules/react-native/React/Base/RCTBridge.m b/examples/node_modules/react-native/React/Base/RCTBridge.m index 5c6bcf7c..48fd672a 100644 --- a/examples/node_modules/react-native/React/Base/RCTBridge.m +++ b/examples/node_modules/react-native/React/Base/RCTBridge.m @@ -22,6 +22,7 @@ #import "RCTJavaScriptLoader.h" #import "RCTKeyCommands.h" #import "RCTLog.h" +#import "RCTProfile.h" #import "RCTRedBox.h" #import "RCTRootView.h" #import "RCTSparseArray.h" @@ -48,39 +49,6 @@ typedef NS_ENUM(NSUInteger, RCTBridgeFields) { */ #define BATCHED_BRIDGE 1 -#ifdef DEBUG - -#define RCT_PROFILE_START() \ -_Pragma("clang diagnostic push") \ -_Pragma("clang diagnostic ignored \"-Wshadow\"") \ -NSTimeInterval __rct_profile_start = CACurrentMediaTime() \ -_Pragma("clang diagnostic pop") - -#define RCT_PROFILE_END(cat, args, profileName...) \ -do { \ -if (_profile) { \ - [_profileLock lock]; \ - [_profile addObject:@{ \ - @"name": [@[profileName] componentsJoinedByString: @"_"], \ - @"cat": @ #cat, \ - @"ts": @((NSUInteger)((__rct_profile_start - _startingTime) * 1e6)), \ - @"dur": @((NSUInteger)((CACurrentMediaTime() - __rct_profile_start) * 1e6)), \ - @"ph": @"X", \ - @"pid": @([[NSProcessInfo processInfo] processIdentifier]), \ - @"tid": [[NSThread currentThread] description], \ - @"args": args ?: [NSNull null], \ - }]; \ - [_profileLock unlock]; \ -} \ -} while(0) - -#else - -#define RCT_PROFILE_START(...) -#define RCT_PROFILE_END(...) - -#endif - #ifdef __LP64__ typedef uint64_t RCTHeaderValue; typedef struct section_64 RCTHeaderSection; @@ -175,7 +143,8 @@ typedef NS_ENUM(NSUInteger, RCTBridgeFields) { // Get data entry NSString *entry = @(*(const char **)(mach_header + addr)); - NSArray *parts = [[entry substringWithRange:(NSRange){2, entry.length - 3}] componentsSeparatedByString:@" "]; + NSArray *parts = [[entry substringWithRange:(NSRange){2, entry.length - 3}] + componentsSeparatedByString:@" "]; // Parse class name NSString *moduleClassName = parts[0]; @@ -196,33 +165,32 @@ typedef NS_ENUM(NSUInteger, RCTBridgeFields) { } } -#if DEBUG + if (RCT_DEBUG) { - // We may be able to get rid of this check in future, once people - // get used to the new registration system. That would potentially - // allow you to create modules that are not automatically registered + // We may be able to get rid of this check in future, once people + // get used to the new registration system. That would potentially + // allow you to create modules that are not automatically registered - static unsigned int classCount; - Class *classes = objc_copyClassList(&classCount); - for (unsigned int i = 0; i < classCount; i++) - { - Class cls = classes[i]; - Class superclass = cls; - while (superclass) + static unsigned int classCount; + Class *classes = objc_copyClassList(&classCount); + for (unsigned int i = 0; i < classCount; i++) { - if (class_conformsToProtocol(superclass, @protocol(RCTBridgeModule))) + Class cls = classes[i]; + Class superclass = cls; + while (superclass) { - if (![RCTModuleClassesByID containsObject:cls]) { - RCTLogError(@"Class %@ was not exported. Did you forget to use RCT_EXPORT_MODULE()?", NSStringFromClass(cls)); + if (class_conformsToProtocol(superclass, @protocol(RCTBridgeModule))) + { + if (![RCTModuleClassesByID containsObject:cls]) { + RCTLogError(@"Class %@ was not exported. Did you forget to use RCT_EXPORT_MODULE()?", NSStringFromClass(cls)); + } + break; } - break; + superclass = class_getSuperclass(superclass); } - superclass = class_getSuperclass(superclass); } } -#endif - }); return RCTModuleClassesByID; @@ -230,16 +198,15 @@ typedef NS_ENUM(NSUInteger, RCTBridgeFields) { @interface RCTBridge () -@property (nonatomic, copy, readonly) NSArray *profile; - - (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method - arguments:(NSArray *)args; + arguments:(NSArray *)args + context:(NSNumber *)context; - (void)_actuallyInvokeAndProcessModule:(NSString *)module method:(NSString *)method - arguments:(NSArray *)args; - + arguments:(NSArray *)args + context:(NSNumber *)context; @end /** @@ -249,6 +216,7 @@ @interface RCTModuleMethod : NSObject @property (nonatomic, copy, readonly) NSString *moduleClassName; @property (nonatomic, copy, readonly) NSString *JSMethodName; +@property (nonatomic, assign, readonly) SEL selector; @end @@ -260,6 +228,7 @@ @implementation RCTModuleMethod NSMethodSignature *_methodSignature; NSArray *_argumentBlocks; NSString *_methodName; + dispatch_block_t _methodQueue; } static Class _globalExecutorClass; @@ -320,13 +289,13 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName _isClassMethod = [reactMethodName characterAtIndex:0] == '+'; _moduleClass = NSClassFromString(_moduleClassName); -#if DEBUG + if (RCT_DEBUG) { - // Sanity check - RCTAssert([_moduleClass conformsToProtocol:@protocol(RCTBridgeModule)], - @"You are attempting to export the method %@, but %@ does not \ - conform to the RCTBridgeModule Protocol", objCMethodName, _moduleClassName); -#endif + // Sanity check + RCTAssert([_moduleClass conformsToProtocol:@protocol(RCTBridgeModule)], + @"You are attempting to export the method %@, but %@ does not \ + conform to the RCTBridgeModule Protocol", objCMethodName, _moduleClassName); + } // Get method signature _methodSignature = _isClassMethod ? @@ -338,14 +307,15 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName NSMutableArray *argumentBlocks = [[NSMutableArray alloc] initWithCapacity:numberOfArguments - 2]; #define RCT_ARG_BLOCK(_logic) \ - [argumentBlocks addObject:^(RCTBridge *bridge, NSInvocation *invocation, NSUInteger index, id json) { \ + [argumentBlocks addObject:^(RCTBridge *bridge, NSNumber *context, NSInvocation *invocation, NSUInteger index, id json) { \ _logic \ [invocation setArgument:&value atIndex:index]; \ }]; \ void (^addBlockArgument)(void) = ^{ RCT_ARG_BLOCK( - if (json && ![json isKindOfClass:[NSNumber class]]) { + + if (RCT_DEBUG && json && ![json isKindOfClass:[NSNumber class]]) { RCTLogError(@"Argument %tu (%@) of %@.%@ should be a number", index, json, RCTBridgeModuleNameForClass(_moduleClass), _JSMethodName); return; @@ -355,7 +325,8 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName __autoreleasing id value = (json ? ^(NSArray *args) { [bridge _invokeAndProcessModule:@"BatchedBridge" method:@"invokeCallbackAndReturnFlushedQueue" - arguments:@[json, args]]; + arguments:@[json, args] + context:context]; } : ^(NSArray *unused) {}); ) }; @@ -404,10 +375,14 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName RCT_CONVERT_CASE('B', BOOL) RCT_CONVERT_CASE('@', id) RCT_CONVERT_CASE('^', void *) - + case '{': + RCTAssert(NO, @"Argument %zd of %C[%@ %@] is defined as %@, however RCT_EXPORT_METHOD() " + "does not currently support struct-type arguments.", i - 2, + [reactMethodName characterAtIndex:0], _moduleClassName, + objCMethodName, argumentName); + break; default: defaultCase(argumentType); - break; } } else if ([argumentName isEqualToString:@"RCTResponseSenderBlock"]) { addBlockArgument(); @@ -421,7 +396,7 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName #define RCT_CASE(_value, _class, _logic) \ case _value: { \ RCT_ARG_BLOCK( \ - if (json && ![json isKindOfClass:[_class class]]) { \ + if (RCT_DEBUG && json && ![json isKindOfClass:[_class class]]) { \ RCTLogError(@"Argument %tu (%@) of %@.%@ should be of type %@", index, \ json, RCTBridgeModuleNameForClass(_moduleClass), _JSMethodName, [_class class]); \ return; \ @@ -437,7 +412,7 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName #define RCT_SIMPLE_CASE(_value, _type, _selector) \ case _value: { \ RCT_ARG_BLOCK( \ - if (json && ![json respondsToSelector:@selector(_selector)]) { \ + if (RCT_DEBUG && json && ![json respondsToSelector:@selector(_selector)]) { \ RCTLogError(@"Argument %tu (%@) of %@.%@ does not respond to selector: %@", \ index, json, RCTBridgeModuleNameForClass(_moduleClass), _JSMethodName, @#_selector); \ return; \ @@ -463,7 +438,6 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName default: defaultCase(argumentType); - break; } } } @@ -477,21 +451,21 @@ - (instancetype)initWithReactMethodName:(NSString *)reactMethodName - (void)invokeWithBridge:(RCTBridge *)bridge module:(id)module arguments:(NSArray *)arguments + context:(NSNumber *)context { + if (RCT_DEBUG) { -#if DEBUG - - // Sanity check - RCTAssert([module class] == _moduleClass, @"Attempted to invoke method \ - %@ on a module of class %@", _methodName, [module class]); -#endif - - // Safety check - if (arguments.count != _argumentBlocks.count) { - RCTLogError(@"%@.%@ was called with %zd arguments, but expects %zd", - RCTBridgeModuleNameForClass(_moduleClass), _JSMethodName, - arguments.count, _argumentBlocks.count); - return; + // Sanity check + RCTAssert([module class] == _moduleClass, @"Attempted to invoke method \ + %@ on a module of class %@", _methodName, [module class]); + + // Safety check + if (arguments.count != _argumentBlocks.count) { + RCTLogError(@"%@.%@ was called with %zd arguments, but expects %zd", + RCTBridgeModuleNameForClass(_moduleClass), _JSMethodName, + arguments.count, _argumentBlocks.count); + return; + } } // Create invocation (we can't re-use this as it wouldn't be thread-safe) @@ -503,8 +477,8 @@ - (void)invokeWithBridge:(RCTBridge *)bridge NSUInteger index = 0; for (id json in arguments) { id arg = (json == [NSNull null]) ? nil : json; - void (^block)(RCTBridge *, NSInvocation *, NSUInteger, id) = _argumentBlocks[index]; - block(bridge, invocation, index + 2, arg); + void (^block)(RCTBridge *, NSNumber *, NSInvocation *, NSUInteger, id) = _argumentBlocks[index]; + block(bridge, context, invocation, index + 2, arg); index++; } @@ -653,7 +627,6 @@ - (NSString *)description return moduleConfig; } - /** * As above, but for local modules/methods, which represent JS classes * and methods that will be called by the native code via the bridge. @@ -724,7 +697,7 @@ - (NSString *)description @interface RCTDisplayLink : NSObject -- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithBridge:(RCTBridge *)bridge selector:(SEL)selector NS_DESIGNATED_INITIALIZER; @end @@ -738,14 +711,16 @@ @implementation RCTDisplayLink { __weak RCTBridge *_bridge; CADisplayLink *_displayLink; + SEL _selector; } -- (instancetype)initWithBridge:(RCTBridge *)bridge +- (instancetype)initWithBridge:(RCTBridge *)bridge selector:(SEL)selector { if ((self = [super init])) { _bridge = bridge; + _selector = selector; _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_update:)]; - [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; + [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } return self; } @@ -765,7 +740,10 @@ - (void)invalidate - (void)_update:(CADisplayLink *)displayLink { - [_bridge _update:displayLink]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + [_bridge performSelector:_selector withObject:displayLink]; +#pragma clang diagnostic pop } @end @@ -792,20 +770,19 @@ - (instancetype)initWithDisplayLink:(CADisplayLink *)displayLink @implementation RCTBridge { RCTSparseArray *_modulesByID; + RCTSparseArray *_queuesByID; + dispatch_queue_t _methodQueue; NSDictionary *_modulesByName; id _javaScriptExecutor; Class _executorClass; NSURL *_bundleURL; RCTBridgeModuleProviderBlock _moduleProvider; RCTDisplayLink *_displayLink; + RCTDisplayLink *_vsyncDisplayLink; NSMutableSet *_frameUpdateObservers; NSMutableArray *_scheduledCalls; - NSMutableArray *_scheduledCallbacks; + RCTSparseArray *_scheduledCallbacks; BOOL _loading; - - NSUInteger _startingTime; - NSMutableArray *_profile; - NSLock *_profileLock; } static id _latestJSExecutor; @@ -821,20 +798,24 @@ - (instancetype)initWithBundleURL:(NSURL *)bundleURL [self setUp]; [self bindKeys]; } - return self; } + - (void)setUp { Class executorClass = _executorClass ?: _globalExecutorClass ?: [RCTContextExecutor class]; - _javaScriptExecutor = [[executorClass alloc] init]; + _javaScriptExecutor = RCTCreateExecutor(executorClass); _latestJSExecutor = _javaScriptExecutor; _eventDispatcher = [[RCTEventDispatcher alloc] initWithBridge:self]; - _shadowQueue = dispatch_queue_create("com.facebook.React.ShadowQueue", DISPATCH_QUEUE_SERIAL); - _displayLink = [[RCTDisplayLink alloc] initWithBridge:self]; + _methodQueue = dispatch_queue_create("com.facebook.React.BridgeMethodQueue", DISPATCH_QUEUE_SERIAL); _frameUpdateObservers = [[NSMutableSet alloc] init]; _scheduledCalls = [[NSMutableArray alloc] init]; - _scheduledCallbacks = [[NSMutableArray alloc] init]; + _scheduledCallbacks = [[RCTSparseArray alloc] init]; + + [_javaScriptExecutor executeBlockOnJavaScriptQueue:^{ + _displayLink = [[RCTDisplayLink alloc] initWithBridge:self selector:@selector(_jsThreadUpdate:)]; + }]; + _vsyncDisplayLink = [[RCTDisplayLink alloc] initWithBridge:self selector:@selector(_mainThreadUpdate:)]; // Register passed-in module instances NSMutableDictionary *preregisteredModules = [[NSMutableDictionary alloc] init]; @@ -848,21 +829,29 @@ - (void)setUp [RCTBridgeModuleClassesByModuleID() enumerateObjectsUsingBlock:^(Class moduleClass, NSUInteger moduleID, BOOL *stop) { NSString *moduleName = RCTModuleNamesByID[moduleID]; // Check if module instance has already been registered for this name - if ((_modulesByID[moduleID] = modulesByName[moduleName])) { + id module = modulesByName[moduleName]; + if (module) { // Preregistered instances takes precedence, no questions asked if (!preregisteredModules[moduleName]) { // It's OK to have a name collision as long as the second instance is nil RCTAssert([[moduleClass alloc] init] == nil, - @"Attempted to register RCTBridgeModule class %@ for the name '%@', \ - but name was already registered by class %@", moduleClass, + @"Attempted to register RCTBridgeModule class %@ for the name " + "'%@', but name was already registered by class %@", moduleClass, moduleName, [modulesByName[moduleName] class]); } + if ([module class] != moduleClass) { + RCTLogInfo(@"RCTBridgeModule of class %@ with name '%@' was encountered " + "in the project, but name was already registered by class %@." + "That's fine if it's intentional - just letting you know.", + moduleClass, moduleName, [modulesByName[moduleName] class]); + } } else { // Module name hasn't been used before, so go ahead and instantiate - id module = [[moduleClass alloc] init]; - if (module) { - _modulesByID[moduleID] = modulesByName[moduleName] = module; - } + module = [[moduleClass alloc] init]; + } + if (module) { + // Store module instance + _modulesByID[moduleID] = modulesByName[moduleName] = module; } }]; @@ -876,6 +865,17 @@ - (void)setUp } } + // Get method queues + _queuesByID = [[RCTSparseArray alloc] init]; + [_modulesByID enumerateObjectsUsingBlock:^(id module, NSNumber *moduleID, BOOL *stop) { + if ([module respondsToSelector:@selector(methodQueue)]) { + dispatch_queue_t queue = [module methodQueue]; + if (queue) { + _queuesByID[moduleID] = queue; + } + } + }]; + // Inject module data into JS context NSString *configJSON = RCTJSONStringify(@{ @"remoteModuleConfig": RCTRemoteModulesConfig(_modulesByName), @@ -902,6 +902,9 @@ - (void)setUp [loader loadBundleAtURL:_bundleURL onComplete:^(NSError *error) { _loading = NO; if (error != nil) { + +#if RCT_DEBUG // Red box is only available in debug mode + NSArray *stack = [[error userInfo] objectForKey:@"stack"]; if (stack) { [[RCTRedBox sharedInstance] showErrorMessage:[error localizedDescription] @@ -910,14 +913,13 @@ - (void)setUp [[RCTRedBox sharedInstance] showErrorMessage:[error localizedDescription] withDetails:[error localizedFailureReason]]; } + +#endif + } else { + [[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification object:self]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(reload) - name:RCTReloadNotification - object:nil]; } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reload) @@ -955,6 +957,9 @@ - (void)bindKeys strongSelf.executorClass = Nil; [strongSelf reload]; }]; + +#if RCT_DEV // Debug executors are only available in dev mode + // reload in debug mode [commands registerKeyCommandWithInput:@"d" modifierFlags:UIKeyModifierCommand @@ -971,10 +976,10 @@ - (void)bindKeys [strongSelf reload]; }]; #endif +#endif } - - (NSDictionary *)modules { RCTAssert(_modulesByName != nil, @"Bridge modules have not yet been initialized. " @@ -1016,6 +1021,7 @@ - (void)invalidate _javaScriptExecutor = nil; [_displayLink invalidate]; + [_vsyncDisplayLink invalidate]; _frameUpdateObservers = nil; // Invalidate modules @@ -1027,6 +1033,7 @@ - (void)invalidate // Release modules (breaks retain cycle if module has strong bridge reference) _modulesByID = nil; + _queuesByID = nil; _modulesByName = nil; } @@ -1054,7 +1061,8 @@ - (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args if (!_loading) { [self _invokeAndProcessModule:@"BatchedBridge" method:@"callFunctionReturnFlushedQueue" - arguments:@[moduleID, methodID, args ?: @[]]]; + arguments:@[moduleID, methodID, args ?: @[]] + context:RCTGetExecutorID(_javaScriptExecutor)]; } } @@ -1075,13 +1083,15 @@ - (void)_immediatelyCallTimer:(NSNumber *)timer #if BATCHED_BRIDGE [self _actuallyInvokeAndProcessModule:@"BatchedBridge" method:@"callFunctionReturnFlushedQueue" - arguments:@[moduleID, methodID, @[@[timer]]]]; + arguments:@[moduleID, methodID, @[@[timer]]] + context:RCTGetExecutorID(_javaScriptExecutor)]; #else [self _invokeAndProcessModule:@"BatchedBridge" method:@"callFunctionReturnFlushedQueue" - arguments:@[moduleID, methodID, @[@[timer]]]]; + arguments:@[moduleID, methodID, @[@[timer]]] + context:RCTGetExecutorID(_javaScriptExecutor)]; #endif } } @@ -1089,23 +1099,28 @@ - (void)_immediatelyCallTimer:(NSNumber *)timer - (void)enqueueApplicationScript:(NSString *)script url:(NSURL *)url onComplete:(RCTJavaScriptCompleteBlock)onComplete { RCTAssert(onComplete != nil, @"onComplete block passed in should be non-nil"); - RCT_PROFILE_START(); + RCTProfileBeginEvent(); [_javaScriptExecutor executeApplicationScript:script sourceURL:url onComplete:^(NSError *scriptLoadError) { - RCT_PROFILE_END(js_call, scriptLoadError, @"initial_script"); + RCTProfileEndEvent(@"ApplicationScript", @"js_call,init", scriptLoadError); if (scriptLoadError) { onComplete(scriptLoadError); return; } - RCT_PROFILE_START(); + RCTProfileBeginEvent(); + NSNumber *context = RCTGetExecutorID(_javaScriptExecutor); [_javaScriptExecutor executeJSCall:@"BatchedBridge" method:@"flushedQueue" arguments:@[] + context:context callback:^(id json, NSError *error) { - RCT_PROFILE_END(js_call, error, @"initial_call", @"BatchedBridge.flushedQueue"); - RCT_PROFILE_START(); - [self _handleBuffer:json]; - RCT_PROFILE_END(objc_call, json, @"batched_js_calls"); + RCTProfileEndEvent(@"FetchApplicationScriptCallbacks", @"js_call,init", @{ + @"json": json ?: [NSNull null], + @"error": error ?: [NSNull null], + }); + + [self _handleBuffer:json context:context]; + onComplete(error); }]; }]; @@ -1113,10 +1128,10 @@ - (void)enqueueApplicationScript:(NSString *)script url:(NSURL *)url onComplete: #pragma mark - Payload Generation -- (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args +- (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args context:(NSNumber *)context { #if BATCHED_BRIDGE - RCT_PROFILE_START(); + RCTProfileBeginEvent(); if ([module isEqualToString:@"RCTEventEmitter"]) { for (NSDictionary *call in _scheduledCalls) { @@ -1130,55 +1145,55 @@ - (void)_invokeAndProcessModule:(NSString *)module method:(NSString *)method arg @"module": module, @"method": method, @"args": args, + @"context": context ?: @0, }; if ([method isEqualToString:@"invokeCallbackAndReturnFlushedQueue"]) { - [_scheduledCallbacks addObject:call]; + _scheduledCallbacks[args[0]] = call; } else { [_scheduledCalls addObject:call]; } - RCT_PROFILE_END(js_call, args, @"schedule", module, method); + RCTProfileEndEvent(@"enqueue_call", @"objc_call", call); } -- (void)_actuallyInvokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args +- (void)_actuallyInvokeAndProcessModule:(NSString *)module method:(NSString *)method arguments:(NSArray *)args context:(NSNumber *)context { #endif [[NSNotificationCenter defaultCenter] postNotificationName:RCTEnqueueNotification object:nil userInfo:nil]; - NSString *moduleDotMethod = [NSString stringWithFormat:@"%@.%@", module, method]; - RCT_PROFILE_START(); RCTJavaScriptCallback processResponse = ^(id json, NSError *error) { [[NSNotificationCenter defaultCenter] postNotificationName:RCTDequeueNotification object:nil userInfo:nil]; - RCT_PROFILE_END(js_call, args, moduleDotMethod); - - RCT_PROFILE_START(); - [self _handleBuffer:json]; - RCT_PROFILE_END(objc_call, json, @"batched_js_calls"); + [self _handleBuffer:json context:context]; }; [_javaScriptExecutor executeJSCall:module method:method arguments:args + context:context callback:processResponse]; } #pragma mark - Payload Processing -- (void)_handleBuffer:(id)buffer +- (void)_handleBuffer:(id)buffer context:(NSNumber *)context { if (buffer == nil || buffer == (id)kCFNull) { return; } + NSArray *requestsArray = [RCTConvert NSArray:buffer]; + +#if RCT_DEBUG + if (![buffer isKindOfClass:[NSArray class]]) { RCTLogError(@"Buffer must be an instance of NSArray, got %@", NSStringFromClass([buffer class])); return; } - NSArray *requestsArray = (NSArray *)buffer; NSUInteger bufferRowCount = [requestsArray count]; NSUInteger expectedFieldsCount = RCTBridgeFieldResponseReturnValues + 1; + if (bufferRowCount != expectedFieldsCount) { RCTLogError(@"Must pass all fields to buffer - expected %zd, saw %zd", expectedFieldsCount, bufferRowCount); return; @@ -1192,56 +1207,75 @@ - (void)_handleBuffer:(id)buffer } } +#endif + NSArray *moduleIDs = requestsArray[RCTBridgeFieldRequestModuleIDs]; NSArray *methodIDs = requestsArray[RCTBridgeFieldMethodIDs]; NSArray *paramsArrays = requestsArray[RCTBridgeFieldParamss]; NSUInteger numRequests = [moduleIDs count]; - BOOL allSame = numRequests == [methodIDs count] && numRequests == [paramsArrays count]; - if (!allSame) { + + if (RCT_DEBUG && (numRequests != methodIDs.count || numRequests != paramsArrays.count)) { RCTLogError(@"Invalid data message - all must be length: %zd", numRequests); return; } + // TODO: if we sort the requests by module, we could dispatch once per + // module instead of per request, which would reduce the call overhead. for (NSUInteger i = 0; i < numRequests; i++) { @autoreleasepool { [self _handleRequestNumber:i moduleID:[moduleIDs[i] integerValue] methodID:[methodIDs[i] integerValue] - params:paramsArrays[i]]; + params:paramsArrays[i] + context:context]; } } - // TODO: only used by RCTUIManager - can we eliminate this special case? - dispatch_async(self.shadowQueue, ^{ - for (id module in _modulesByID.allObjects) { - if ([module respondsToSelector:@selector(batchDidComplete)]) { + // TODO: batchDidComplete is only used by RCTUIManager - can we eliminate this special case? + [_modulesByID enumerateObjectsUsingBlock:^(id module, NSNumber *moduleID, BOOL *stop) { + if ([module respondsToSelector:@selector(batchDidComplete)]) { + dispatch_queue_t queue = _queuesByID[moduleID]; + dispatch_async(queue ?: _methodQueue, ^{ [module batchDidComplete]; - } + }); } - }); + }]; } - (BOOL)_handleRequestNumber:(NSUInteger)i moduleID:(NSUInteger)moduleID methodID:(NSUInteger)methodID params:(NSArray *)params + context:(NSNumber *)context { - if (![params isKindOfClass:[NSArray class]]) { + + if (RCT_DEBUG && ![params isKindOfClass:[NSArray class]]) { RCTLogError(@"Invalid module/method/params tuple for request #%zd", i); return NO; } // Look up method NSArray *methods = RCTExportedMethodsByModuleID()[moduleID]; - if (methodID >= methods.count) { + + if (RCT_DEBUG && methodID >= methods.count) { RCTLogError(@"Unknown methodID: %zd for module: %zd (%@)", methodID, moduleID, RCTModuleNamesByID[moduleID]); return NO; } + RCTModuleMethod *method = methods[methodID]; + // Look up module + id module = self->_modulesByID[moduleID]; + if (RCT_DEBUG && !module) { + RCTLogError(@"No module found for name '%@'", RCTModuleNamesByID[moduleID]); + return NO; + } + __weak RCTBridge *weakSelf = self; - dispatch_async(self.shadowQueue, ^{ + dispatch_queue_t queue = _queuesByID[moduleID]; + dispatch_async(queue ?: _methodQueue, ^{ + RCTProfileBeginEvent(); __strong RCTBridge *strongSelf = weakSelf; if (!strongSelf.isValid) { @@ -1250,30 +1284,34 @@ - (BOOL)_handleRequestNumber:(NSUInteger)i return; } - // Look up module - id module = strongSelf->_modulesByID[moduleID]; - if (!module) { - RCTLogError(@"No module found for name '%@'", RCTModuleNamesByID[moduleID]); - return; - } - - @try { - [method invokeWithBridge:strongSelf module:module arguments:params]; - } - @catch (NSException *exception) { - RCTLogError(@"Exception thrown while invoking %@ on target %@ with params %@: %@", method.JSMethodName, module, params, exception); - if ([exception.name rangeOfString:@"Unhandled JS Exception"].location != NSNotFound) { - @throw; + if (!RCT_DEBUG) { + [method invokeWithBridge:strongSelf module:module arguments:params context:context]; + } else { + @try { + [method invokeWithBridge:strongSelf module:module arguments:params context:context]; + } + @catch (NSException *exception) { + RCTLogError(@"Exception thrown while invoking %@ on target %@ with params %@: %@", method.JSMethodName, module, params, exception); + if ([exception.name rangeOfString:@"Unhandled JS Exception"].location != NSNotFound) { + @throw; + } } } + + RCTProfileEndEvent(@"Invoke callback", @"objc_call", @{ + @"module": method.moduleClassName, + @"method": method.JSMethodName, + @"selector": NSStringFromSelector(method.selector), + }); }); return YES; } -- (void)_update:(CADisplayLink *)displayLink +- (void)_jsThreadUpdate:(CADisplayLink *)displayLink { - RCT_PROFILE_START(); + RCTProfileImmediateEvent(@"JS Thread Tick", displayLink.timestamp, @"g"); + RCTProfileBeginEvent(); RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink]; for (id observer in _frameUpdateObservers) { @@ -1282,25 +1320,30 @@ - (void)_update:(CADisplayLink *)displayLink } } - [self _runScheduledCalls]; - - RCT_PROFILE_END(display_link, nil, @"main_thread"); -} - -- (void)_runScheduledCalls -{ #if BATCHED_BRIDGE - NSArray *calls = [_scheduledCallbacks arrayByAddingObjectsFromArray:_scheduledCalls]; + NSArray *calls = [_scheduledCallbacks.allObjects arrayByAddingObjectsFromArray:_scheduledCalls]; + NSNumber *currentExecutorID = RCTGetExecutorID(_javaScriptExecutor); + calls = [calls filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSDictionary *call, NSDictionary *bindings) { + return [call[@"context"] isEqualToNumber:currentExecutorID]; + }]]; if (calls.count > 0) { _scheduledCalls = [[NSMutableArray alloc] init]; - _scheduledCallbacks = [[NSMutableArray alloc] init]; + _scheduledCallbacks = [[RCTSparseArray alloc] init]; [self _actuallyInvokeAndProcessModule:@"BatchedBridge" - method:@"processBatch" - arguments:@[calls]]; + method:@"processBatch" + arguments:@[calls] + context:RCTGetExecutorID(_javaScriptExecutor)]; } #endif + + RCTProfileEndEvent(@"DispatchFrameUpdate", @"objc_call", nil); +} + +- (void)_mainThreadUpdate:(CADisplayLink *)displayLink +{ + RCTProfileImmediateEvent(@"VSYNC", displayLink.timestamp, @"g"); } - (void)addFrameUpdateObserver:(id)observer @@ -1315,13 +1358,15 @@ - (void)removeFrameUpdateObserver:(id)observer - (void)reload { - if (!_loading) { - // If the bridge has not loaded yet, the context will be already invalid at - // the time the javascript gets executed. - // It will crash the javascript, and even the next `load` won't render. - [self invalidate]; - [self setUp]; - } + dispatch_async(dispatch_get_main_queue(), ^{ + if (!_loading) { + // If the bridge has not loaded yet, the context will be already invalid at + // the time the javascript gets executed. + // It will crash the javascript, and even the next `load` won't render. + [self invalidate]; + [self setUp]; + } + }); } + (void)logMessage:(NSString *)message level:(NSString *)level @@ -1335,6 +1380,7 @@ + (void)logMessage:(NSString *)message level:(NSString *)level [_latestJSExecutor executeJSCall:@"RCTLog" method:@"logIfNoNativeHook" arguments:@[level, message] + context:RCTGetExecutorID(_latestJSExecutor) callback:^(id json, NSError *error) {}]; } @@ -1344,23 +1390,12 @@ - (void)startProfiling RCTLogError(@"To run the profiler you must be running from the dev server"); return; } - _profileLock = [[NSLock alloc] init]; - _startingTime = CACurrentMediaTime(); - - [_profileLock lock]; - _profile = [[NSMutableArray alloc] init]; - [_profileLock unlock]; + RCTProfileInit(); } - (void)stopProfiling { - [_profileLock lock]; - NSArray *profile = _profile; - _profile = nil; - [_profileLock unlock]; - _profileLock = nil; - - NSString *log = RCTJSONStringify(profile, NULL); + NSString *log = RCTProfileEnd(); NSString *URLString = [NSString stringWithFormat:@"%@://%@:%@/profile", _bundleURL.scheme, _bundleURL.host, _bundleURL.port]; NSURL *URL = [NSURL URLWithString:URLString]; NSMutableURLRequest *URLRequest = [NSMutableURLRequest requestWithURL:URL]; diff --git a/examples/node_modules/react-native/React/Base/RCTBridgeModule.h b/examples/node_modules/react-native/React/Base/RCTBridgeModule.h index 70d5c76d..dd6f61e2 100644 --- a/examples/node_modules/react-native/React/Base/RCTBridgeModule.h +++ b/examples/node_modules/react-native/React/Base/RCTBridgeModule.h @@ -73,12 +73,67 @@ typedef void (^RCTResponseSenderBlock)(NSArray *response); * { ... } */ #define RCT_REMAP_METHOD(js_name, method) \ + RCT_EXTERN_REMAP_METHOD(js_name, method) \ + - (void)method + +/** + * Use this macro in a private Objective-C implementation file to automatically + * register an external module with the bridge when it loads. This allows you to + * register Swift or private Objective-C classes with the bridge. + * + * For example if one wanted to export a Swift class to the bridge: + * + * MyModule.swift: + * + * @objc(MyModule) class MyModule: NSObject { + * + * @objc func doSomething(string: String! withFoo a: Int, bar b: Int) { ... } + * + * } + * + * MyModuleExport.m: + * + * #import "RCTBridgeModule.h" + * + * @interface RCT_EXTERN_MODULE(MyModule, NSObject) + * + * RCT_EXTERN_METHOD(doSomething:(NSString *)string withFoo:(NSInteger)a bar:(NSInteger)b) + * + * @end + * + * This will now expose MyModule and the method to JavaScript via + * `NativeModules.MyModule.doSomething` + */ +#define RCT_EXTERN_MODULE(objc_name, objc_supername) \ + RCT_EXTERN_REMAP_MODULE(, objc_name, objc_supername) + +/** + * Similar to RCT_EXTERN_MODULE but allows setting a custom JavaScript name + */ +#define RCT_EXTERN_REMAP_MODULE(js_name, objc_name, objc_supername) \ + objc_name : objc_supername \ + @end \ + @interface objc_name (RCTExternModule) \ + @end \ + @implementation objc_name (RCTExternModule) \ + RCT_EXPORT_MODULE(js_name) + +/** + * Use this macro in accordance with RCT_EXTERN_MODULE to export methods + * of an external module. + */ +#define RCT_EXTERN_METHOD(method) \ + RCT_EXTERN_REMAP_METHOD(, method) + +/** + * Similar to RCT_EXTERN_REMAP_METHOD but allows setting a custom JavaScript name + */ +#define RCT_EXTERN_REMAP_METHOD(js_name, method) \ - (void)__rct_export__##method { \ __attribute__((used, section("__DATA,RCTExport"))) \ __attribute__((__aligned__(1))) \ static const char *__rct_export_entry__[] = { __func__, #method, #js_name }; \ - } \ - - (void)method + } /** * Deprecated, do not use. @@ -89,6 +144,37 @@ typedef void (^RCTResponseSenderBlock)(NSArray *response); __attribute__((__aligned__(1))) \ static const char *__rct_export_entry__[] = { __func__, #js_name, NULL } +/** + * The queue that will be used to call all exported methods. If omitted, this + * will call on the default background queue, which is avoids blocking the main + * thread. + * + * If the methods in your module need to interact with UIKit methods, they will + * probably need to call those on the main thread, as most of UIKit is main- + * thread-only. You can tell React Native to call your module methods on the + * main thread by returning a reference to the main queue, like this: + * + * - (dispatch_queue_t)methodQueue + * { + * return dispatch_get_main_queue(); + * } + * + * If your methods perform heavy work such as synchronous filesystem or network + * access, you probably don't want to block the default background queue, as + * this will stall other methods. Instead, you should return a custom serial + * queue, like this: + * + * - (dispatch_queue_t)methodQueue + * { + * return dispatch_queue_create("com.mydomain.FileQueue", DISPATCH_QUEUE_SERIAL); + * } + * + * Alternatively, if only some methods of the module should be executed on a + * particular queue you can leave this method unimplemented, and simply + * dispatch_async() to the required queue within the method itself. + */ +- (dispatch_queue_t)methodQueue; + /** * Injects constants into JS. These constants are made accessible via * NativeModules.ModuleName.X. This method is called when the module is diff --git a/examples/node_modules/react-native/React/Base/RCTConvert.h b/examples/node_modules/react-native/React/Base/RCTConvert.h index e3f5e859..eb81c167 100644 --- a/examples/node_modules/react-native/React/Base/RCTConvert.h +++ b/examples/node_modules/react-native/React/Base/RCTConvert.h @@ -7,16 +7,14 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import - #import #import -#import "../Layout/Layout.h" -#import "../Views/RCTAnimationType.h" -#import "../Views/RCTPointerEvents.h" - +#import "Layout.h" +#import "RCTAnimationType.h" +#import "RCTDefines.h" #import "RCTLog.h" +#import "RCTPointerEvents.h" /** * This class provides a collection of conversion functions for mapping @@ -116,33 +114,27 @@ typedef BOOL css_overflow; @end -#ifdef __cplusplus -extern "C" { -#endif - /** * This function will attempt to set a property using a json value by first * inferring the correct type from all available information, and then * applying an appropriate conversion method. If the property does not * exist, or the type cannot be inferred, the function will return NO. */ -BOOL RCTSetProperty(id target, NSString *keyPath, SEL type, id json); +RCT_EXTERN BOOL RCTSetProperty(id target, NSString *keyPath, SEL type, id json); /** * This function attempts to copy a property from the source object to the * destination object using KVC. If the property does not exist, or cannot * be set, it will do nothing and return NO. */ -BOOL RCTCopyProperty(id target, id source, NSString *keyPath); +RCT_EXTERN BOOL RCTCopyProperty(id target, id source, NSString *keyPath); /** - * Underlying implementation of RCT_ENUM_CONVERTER macro. Ignore this. + * Underlying implementations of RCT_XXX_CONVERTER macros. Ignore these. */ -NSNumber *RCTConverterEnumValue(const char *, NSDictionary *, NSNumber *, id); - -#ifdef __cplusplus -} -#endif +RCT_EXTERN NSNumber *RCTConvertEnumValue(const char *, NSDictionary *, NSNumber *, id); +RCT_EXTERN NSArray *RCTConvertArrayValue(SEL, id); +RCT_EXTERN void RCTLogConvertError(id, const char *); /** * This macro is used for creating simple converter functions that just call @@ -157,18 +149,19 @@ RCT_CUSTOM_CONVERTER(type, name, [json getter]) #define RCT_CUSTOM_CONVERTER(type, name, code) \ + (type)name:(id)json \ { \ - if (json == [NSNull null]) { \ - json = nil; \ - } \ - @try { \ + json = (json == (id)kCFNull) ? nil : json; \ + if (!RCT_DEBUG) { \ return code; \ + } else { \ + @try { \ + return code; \ + } \ + @catch (__unused NSException *e) { \ + RCTLogConvertError(json, #type); \ + json = nil; \ + return code; \ + } \ } \ - @catch (__unused NSException *e) { \ - RCTLogError(@"JSON value '%@' of type '%@' cannot be converted to '%s'", \ - json, [json classForCoder], #type); \ - json = nil; \ - return code; \ - } \ } /** @@ -190,22 +183,14 @@ RCT_CUSTOM_CONVERTER(type, type, [[self NSNumber:json] getter]) dispatch_once(&onceToken, ^{ \ mapping = values; \ }); \ - NSNumber *converted = RCTConverterEnumValue(#type, mapping, @(default), json); \ - return ((type(*)(id, SEL))objc_msgSend)(converted, @selector(getter)); \ + return [RCTConvertEnumValue(#type, mapping, @(default), json) getter]; \ } /** * This macro is used for creating converter functions for typed arrays. */ -#define RCT_ARRAY_CONVERTER(type) \ -+ (type##Array *)type##Array:(id)json \ -{ \ - NSMutableArray *values = [[NSMutableArray alloc] init]; \ - for (id jsonValue in [self NSArray:json]) { \ - id value = [self type:jsonValue]; \ - if (value) { \ - [values addObject:value]; \ - } \ - } \ - return values; \ +#define RCT_ARRAY_CONVERTER(type) \ ++ (NSArray *)type##Array:(id)json \ +{ \ + return RCTConvertArrayValue(@selector(type:), json); \ } diff --git a/examples/node_modules/react-native/React/Base/RCTConvert.m b/examples/node_modules/react-native/React/Base/RCTConvert.m index 25de2965..f1ed7729 100644 --- a/examples/node_modules/react-native/React/Base/RCTConvert.m +++ b/examples/node_modules/react-native/React/Base/RCTConvert.m @@ -11,8 +11,16 @@ #import +#import "RCTDefines.h" + @implementation RCTConvert +void RCTLogConvertError(id json, const char *type) +{ + RCTLogError(@"JSON value '%@' of type '%@' cannot be converted to %s", + json, [json classForCoder], type); +} + RCT_CONVERTER(BOOL, BOOL, boolValue) RCT_NUMBER_CONVERTER(double, doubleValue) RCT_NUMBER_CONVERTER(float, floatValue) @@ -58,6 +66,10 @@ + (NSData *)NSData:(id)json + (NSURL *)NSURL:(id)json { + if (!json || json == (id)kCFNull) { + return nil; + } + if (![json isKindOfClass:[NSString class]]) { RCTLogError(@"Expected NSString for NSURL, received %@: %@", [json classForCoder], json); return nil; @@ -115,7 +127,7 @@ + (NSDate *)NSDate:(id)json // JS standard for time zones is minutes. RCT_CUSTOM_CONVERTER(NSTimeZone *, NSTimeZone, [NSTimeZone timeZoneForSecondsFromGMT:[self double:json] * 60.0]) -NSNumber *RCTConverterEnumValue(const char *typeName, NSDictionary *mapping, NSNumber *defaultValue, id json) +NSNumber *RCTConvertEnumValue(const char *typeName, NSDictionary *mapping, NSNumber *defaultValue, id json) { if (!json || json == (id)kCFNull) { return defaultValue; @@ -224,57 +236,52 @@ + (NSDate *)NSDate:(id)json }), UIBarStyleDefault, integerValue) // TODO: normalise the use of w/width so we can do away with the alias values (#6566645) +static void RCTConvertCGStructValue(const char *type, NSArray *fields, NSDictionary *aliases, CGFloat *result, id json) +{ + NSUInteger count = fields.count; + if ([json isKindOfClass:[NSArray class]]) { + if (RCT_DEBUG && [json count] != count) { + RCTLogError(@"Expected array with count %zd, but count is %zd: %@", count, [json count], json); + } else { + for (NSUInteger i = 0; i < count; i++) { + result[i] = [RCTConvert CGFloat:json[i]]; + } + } + } else if ([json isKindOfClass:[NSDictionary class]]) { + if (aliases.count) { + json = [json mutableCopy]; + for (NSString *alias in aliases) { + NSString *key = aliases[alias]; + NSNumber *number = json[alias]; + if (number) { + RCTLogWarn(@"Using deprecated '%@' property for '%s'. Use '%@' instead.", alias, type, key); + ((NSMutableDictionary *)json)[key] = number; + } + } + } + for (NSUInteger i = 0; i < count; i++) { + result[i] = [RCTConvert CGFloat:json[fields[i]]]; + } + } else if (RCT_DEBUG && json && json != (id)kCFNull) { + RCTLogConvertError(json, type); + } +} + /** * This macro is used for creating converter functions for structs that consist * of a number of CGFloat properties, such as CGPoint, CGRect, etc. */ -#define RCT_CGSTRUCT_CONVERTER(type, values, _aliases) \ -+ (type)type:(id)json \ -{ \ - @try { \ - static NSArray *fields; \ - static NSUInteger count; \ - static dispatch_once_t onceToken; \ - dispatch_once(&onceToken, ^{ \ - fields = values; \ - count = [fields count]; \ - }); \ - type result; \ - if ([json isKindOfClass:[NSArray class]]) { \ - if ([json count] != count) { \ - RCTLogError(@"Expected array with count %zd, but count is %zd: %@", count, [json count], json); \ - } else { \ - for (NSUInteger i = 0; i < count; i++) { \ - ((CGFloat *)&result)[i] = [self CGFloat:json[i]]; \ - } \ - } \ - } else if ([json isKindOfClass:[NSDictionary class]]) { \ - NSDictionary *aliases = _aliases; \ - if (aliases.count) { \ - json = [json mutableCopy]; \ - for (NSString *alias in aliases) { \ - NSString *key = aliases[alias]; \ - NSNumber *number = json[alias]; \ - if (number) { \ - RCTLogWarn(@"Using deprecated '%@' property for '%s'. Use '%@' instead.", alias, #type, key); \ - ((NSMutableDictionary *)json)[key] = number; \ - } \ - } \ - } \ - for (NSUInteger i = 0; i < count; i++) { \ - ((CGFloat *)&result)[i] = [self CGFloat:json[fields[i]]]; \ - } \ - } else if (json && json != [NSNull null]) { \ - RCTLogError(@"Expected NSArray or NSDictionary for %s, received %@: %@", \ - #type, [json classForCoder], json); \ - } \ - return result; \ - } \ - @catch (__unused NSException *e) { \ - RCTLogError(@"JSON value '%@' cannot be converted to '%s'", json, #type); \ - type result; \ - return result; \ - } \ +#define RCT_CGSTRUCT_CONVERTER(type, values, aliases) \ ++ (type)type:(id)json \ +{ \ + static NSArray *fields; \ + static dispatch_once_t onceToken; \ + dispatch_once(&onceToken, ^{ \ + fields = values; \ + }); \ + type result; \ + RCTConvertCGStructValue(#type, fields, aliases, (CGFloat *)&result, json); \ + return result; \ } RCT_CUSTOM_CONVERTER(CGFloat, CGFloat, [self double:json]) @@ -521,9 +528,7 @@ + (UIColor *)UIColor:(id)json } else if ([json isKindOfClass:[NSArray class]]) { if ([json count] < 3 || [json count] > 4) { - RCTLogError(@"Expected array with count 3 or 4, but count is %zd: %@", [json count], json); - } else { // Color array @@ -541,10 +546,9 @@ + (UIColor *)UIColor:(id)json blue:[self double:json[@"b"]] alpha:[self double:json[@"a"] ?: @1]]; - } else if (json && ![json isKindOfClass:[NSNull class]]) { - - RCTLogError(@"Expected NSArray, NSDictionary or NSString for UIColor, received %@: %@", - [json classForCoder], json); + } + else if (RCT_DEBUG && json && json != (id)kCFNull) { + RCTLogConvertError(json, "a color"); } // Default color @@ -569,8 +573,12 @@ + (UIImage *)UIImage:(id)json // TODO: we might as well cache the result of these checks (and possibly the // image itself) so as to reduce overhead on subsequent checks of the same input - if (![json isKindOfClass:[NSString class]]) { - RCTLogError(@"Expected NSString for UIImage, received %@: %@", [json classForCoder], json); + if (!json || json == (id)kCFNull) { + return nil; + } + + if (RCT_DEBUG && ![json isKindOfClass:[NSString class]]) { + RCTLogConvertError(json, "an image"); return nil; } @@ -757,6 +765,29 @@ + (UIFont *)UIFont:(UIFont *)font withFamily:(id)family return bestMatch; } +NSArray *RCTConvertArrayValue(SEL type, id json) +{ + __block BOOL copy = NO; + __block NSArray *values = json = [RCTConvert NSArray:json]; + [json enumerateObjectsUsingBlock:^(id jsonValue, NSUInteger idx, BOOL *stop) { + id value = ((id(*)(Class, SEL, id))objc_msgSend)([RCTConvert class], type, jsonValue); + if (copy) { + if (value) { + [(NSMutableArray *)values addObject:value]; + } + } else if (value != jsonValue) { + // Converted value is different, so we'll need to copy the array + values = [[NSMutableArray alloc] initWithCapacity:values.count]; + for (NSInteger i = 0; i < idx; i++) { + [(NSMutableArray *)values addObject:json[i]]; + } + [(NSMutableArray *)values addObject:value]; + copy = YES; + } + }]; + return values; +} + RCT_ARRAY_CONVERTER(NSString) RCT_ARRAY_CONVERTER(NSDictionary) RCT_ARRAY_CONVERTER(NSURL) diff --git a/examples/node_modules/react-native/React/Base/RCTDefines.h b/examples/node_modules/react-native/React/Base/RCTDefines.h new file mode 100644 index 00000000..71550a30 --- /dev/null +++ b/examples/node_modules/react-native/React/Base/RCTDefines.h @@ -0,0 +1,55 @@ +/** + * 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 + +/** + * Make global functions usable in C++ + */ +#if defined(__cplusplus) +#define RCT_EXTERN extern "C" __attribute__((visibility("default"))) +#else +#define RCT_EXTERN extern __attribute__((visibility("default"))) +#endif + +/** + * The RCT_DEBUG macro can be used to exclude error checking and logging code + * from release builds to improve performance and reduce binary size. + */ +#ifndef RCT_DEBUG +#if DEBUG +#define RCT_DEBUG 1 +#else +#define RCT_DEBUG 0 +#endif +#endif + +/** + * The RCT_DEV macro can be used to enable or disable development tools + * such as the debug executors, dev menu, red box, etc. + */ +#ifndef RCT_DEV +#if DEBUG +#define RCT_DEV 1 +#else +#define RCT_DEV 0 +#endif +#endif + +/** + * By default, only raise an NSAssertion in debug mode + * (custom assert functions will still be called). + */ +#ifndef RCT_NSASSERT +#if RCT_DEBUG +#define RCT_NSASSERT 1 +#else +#define RCT_NSASSERT 0 +#endif +#endif diff --git a/examples/node_modules/react-native/React/Base/RCTDevMenu.h b/examples/node_modules/react-native/React/Base/RCTDevMenu.h index a49e076e..8057e570 100644 --- a/examples/node_modules/react-native/React/Base/RCTDevMenu.h +++ b/examples/node_modules/react-native/React/Base/RCTDevMenu.h @@ -9,11 +9,50 @@ #import -@class RCTBridge; +#import "RCTBridge.h" +#import "RCTBridgeModule.h" +#import "RCTInvalidating.h" -@interface RCTDevMenu : NSObject +/** + * Developer menu, useful for exposing extra functionality when debugging. + */ +@interface RCTDevMenu : NSObject + +/** + * Is the menu enabled. The menu is enabled by default in debug mode, but + * you may wish to disable it so that you can provide your own shake handler. + */ +@property (nonatomic, assign) BOOL shakeToShow; + +/** + * Enables performance profiling. + */ +@property (nonatomic, assign) BOOL profilingEnabled; + +/** + * Enables automatic polling for JS code changes. Only applicable when + * running the app from a server. + */ +@property (nonatomic, assign) BOOL liveReloadEnabled; -- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; +/** + * The time between checks for code changes. Defaults to 1 second. + */ +@property (nonatomic, assign) NSTimeInterval liveReloadPeriod; + +/** + * Manually show the menu. This will. + */ - (void)show; @end + +/** + * This category makes the developer menu instance available via the + * RCTBridge, which is useful for any class that needs to access the menu. + */ +@interface RCTBridge (RCTDevMenu) + +@property (nonatomic, readonly) RCTDevMenu *devMenu; + +@end diff --git a/examples/node_modules/react-native/React/Base/RCTDevMenu.m b/examples/node_modules/react-native/React/Base/RCTDevMenu.m index 7621b195..4af9d4e6 100644 --- a/examples/node_modules/react-native/React/Base/RCTDevMenu.m +++ b/examples/node_modules/react-native/React/Base/RCTDevMenu.m @@ -9,101 +9,220 @@ #import "RCTDevMenu.h" -#import "RCTRedBox.h" +#import "RCTBridge.h" +#import "RCTLog.h" +#import "RCTProfile.h" #import "RCTRootView.h" #import "RCTSourceCode.h" -#import "RCTWebViewExecutor.h" +#import "RCTUtils.h" -@interface RCTBridge (RCTDevMenu) - -@property (nonatomic, copy, readonly) NSArray *profile; +@interface RCTBridge (Profiling) - (void)startProfiling; - (void)stopProfiling; @end +static NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification"; + +@implementation UIWindow (RCTDevMenu) + +- (void)RCT_motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event +{ + if (event.subtype == UIEventSubtypeMotionShake) { + [[NSNotificationCenter defaultCenter] postNotificationName:RCTShowDevMenuNotification object:nil]; + } +} + +@end + @interface RCTDevMenu () @end @implementation RCTDevMenu { - BOOL _liveReload; - __weak RCTBridge *_bridge; + NSTimer *_updateTimer; + UIActionSheet *_actionSheet; +} + +@synthesize bridge = _bridge; + +RCT_EXPORT_MODULE() + ++ (void)initialize +{ + // We're swizzling here because it's poor form to override methods in a category, + // however UIWindow doesn't actually implement motionEnded:withEvent:, so there's + // no need to call the original implementation. + RCTSwapInstanceMethods([UIWindow class], @selector(motionEnded:withEvent:), @selector(RCT_motionEnded:withEvent:)); } -- (instancetype)initWithBridge:(RCTBridge *)bridge +- (instancetype)init { - if (self = [super init]) { - _bridge = bridge; + if ((self = [super init])) { + + _shakeToShow = YES; + _liveReloadPeriod = 1.0; // 1 second + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(showOnShake) + name:RCTShowDevMenuNotification + object:nil]; } return self; } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)showOnShake +{ + if (_shakeToShow) { + [self show]; + } +} + - (void)show { - NSString *debugTitleChrome = _bridge.executorClass != Nil && _bridge.executorClass == NSClassFromString(@"RCTWebSocketExecutor") ? @"Disable Chrome Debugging" : @"Enable Chrome Debugging"; - NSString *debugTitleSafari = _bridge.executorClass == [RCTWebViewExecutor class] ? @"Disable Safari Debugging" : @"Enable Safari Debugging"; - NSString *liveReloadTitle = _liveReload ? @"Disable Live Reload" : @"Enable Live Reload"; - NSString *profilingTitle = _bridge.profile ? @"Stop Profiling" : @"Start Profiling"; - UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"React Native: Development" - delegate:self - cancelButtonTitle:@"Cancel" - destructiveButtonTitle:nil - otherButtonTitles:@"Reload", debugTitleChrome, debugTitleSafari, liveReloadTitle, profilingTitle, nil]; + if (_actionSheet) { + return; + } + + NSString *debugTitleChrome = _bridge.executorClass && _bridge.executorClass == NSClassFromString(@"RCTWebSocketExecutor") ? @"Disable Chrome Debugging" : @"Enable Chrome Debugging"; + NSString *debugTitleSafari = _bridge.executorClass && _bridge.executorClass == NSClassFromString(@"RCTWebViewExecutor") ? @"Disable Safari Debugging" : @"Enable Safari Debugging"; + NSString *liveReloadTitle = _liveReloadEnabled ? @"Disable Live Reload" : @"Enable Live Reload"; + NSString *profilingTitle = RCTProfileIsProfiling() ? @"Stop Profiling" : @"Start Profiling"; + + UIActionSheet *actionSheet = + [[UIActionSheet alloc] initWithTitle:@"React Native: Development" + delegate:self + cancelButtonTitle:@"Cancel" + destructiveButtonTitle:nil + otherButtonTitles:@"Reload", debugTitleChrome, debugTitleSafari, liveReloadTitle, profilingTitle, nil]; + actionSheet.actionSheetStyle = UIBarStyleBlack; - [actionSheet showInView:[[[[UIApplication sharedApplication] keyWindow] rootViewController] view]]; + [actionSheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; } - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { - if (buttonIndex == 0) { - [_bridge reload]; - } else if (buttonIndex == 1) { - Class cls = NSClassFromString(@"RCTWebSocketExecutor"); - _bridge.executorClass = (_bridge.executorClass != cls) ? cls : nil; - [_bridge reload]; - } else if (buttonIndex == 2) { - Class cls = [RCTWebViewExecutor class]; - _bridge.executorClass = (_bridge.executorClass != cls) ? cls : Nil; - [_bridge reload]; - } else if (buttonIndex == 3) { - _liveReload = !_liveReload; - [self _pollAndReload]; - } else if (buttonIndex == 4) { - if (_bridge.profile) { - [_bridge stopProfiling]; - } else { - [_bridge startProfiling]; + _actionSheet = nil; + + switch (buttonIndex) { + case 0: { + [_bridge reload]; + break; + } + case 1: { + Class cls = NSClassFromString(@"RCTWebSocketExecutor"); + _bridge.executorClass = (_bridge.executorClass != cls) ? cls : nil; + [_bridge reload]; + break; + } + case 2: { + Class cls = NSClassFromString(@"RCTWebViewExecutor"); + _bridge.executorClass = (_bridge.executorClass != cls) ? cls : Nil; + [_bridge reload]; + break; + } + case 3: { + self.liveReloadEnabled = !_liveReloadEnabled; + break; } + case 4: { + self.profilingEnabled = !_profilingEnabled; + break; + } + default: + break; } } -- (void)_pollAndReload +- (void)setProfilingEnabled:(BOOL)enabled { - if (_liveReload) { - RCTSourceCode *sourceCodeModule = _bridge.modules[RCTBridgeModuleNameForClass([RCTSourceCode class])]; - NSURL *url = sourceCodeModule.scriptURL; - NSURL *longPollURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:url]; - [self performSelectorInBackground:@selector(_checkForUpdates:) withObject:longPollURL]; + if (_profilingEnabled == enabled) { + return; + } + + _profilingEnabled = enabled; + if (RCTProfileIsProfiling()) { + [_bridge stopProfiling]; + } else { + [_bridge startProfiling]; } } -- (void)_checkForUpdates:(NSURL *)URL +- (void)setLiveReloadEnabled:(BOOL)enabled { - NSMutableURLRequest *longPollRequest = [NSMutableURLRequest requestWithURL:URL]; - longPollRequest.timeoutInterval = 30; - NSHTTPURLResponse *response; - [NSURLConnection sendSynchronousRequest:longPollRequest returningResponse:&response error:nil]; - - dispatch_async(dispatch_get_main_queue(), ^{ - if (_liveReload && response.statusCode == 205) { - [[RCTRedBox sharedInstance] dismiss]; - [_bridge reload]; - } - [self _pollAndReload]; - }); + if (_liveReloadEnabled == enabled) { + return; + } + + _liveReloadEnabled = enabled; + if (_liveReloadEnabled) { + + _updateTimer = [NSTimer scheduledTimerWithTimeInterval:_liveReloadPeriod + target:self + selector:@selector(pollForUpdates) + userInfo:nil + repeats:YES]; + } else { + + [_updateTimer invalidate]; + _updateTimer = nil; + } +} + +- (void)setLiveReloadPeriod:(NSTimeInterval)liveReloadPeriod +{ + _liveReloadPeriod = liveReloadPeriod; + if (_liveReloadEnabled) { + self.liveReloadEnabled = NO; + self.liveReloadEnabled = YES; + } +} + +- (void)pollForUpdates +{ + RCTSourceCode *sourceCodeModule = _bridge.modules[RCTBridgeModuleNameForClass([RCTSourceCode class])]; + if (!sourceCodeModule) { + RCTLogError(@"RCTSourceCode module not found"); + self.liveReloadEnabled = NO; + } + + NSURL *longPollURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:sourceCodeModule.scriptURL]; + [NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:longPollURL] + queue:[[NSOperationQueue alloc] init] + completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { + + NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response; + if (_liveReloadEnabled && HTTPResponse.statusCode == 205) { + [_bridge reload]; + } + }]; +} + +- (BOOL)isValid +{ + return !_liveReloadEnabled || _updateTimer != nil; +} + +- (void)invalidate +{ + [_actionSheet dismissWithClickedButtonIndex:_actionSheet.cancelButtonIndex animated:YES]; + [_updateTimer invalidate]; + _updateTimer = nil; +} + +@end + +@implementation RCTBridge (RCTDevMenu) + +- (RCTDevMenu *)devMenu +{ + return self.modules[RCTBridgeModuleNameForClass([RCTDevMenu class])]; } @end diff --git a/examples/node_modules/react-native/React/Base/RCTJavaScriptExecutor.h b/examples/node_modules/react-native/React/Base/RCTJavaScriptExecutor.h index 57dff78e..eb7fd7d3 100644 --- a/examples/node_modules/react-native/React/Base/RCTJavaScriptExecutor.h +++ b/examples/node_modules/react-native/React/Base/RCTJavaScriptExecutor.h @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import + #import #import "RCTInvalidating.h" @@ -27,6 +29,7 @@ typedef void (^RCTJavaScriptCallback)(id json, NSError *error); - (void)executeJSCall:(NSString *)name method:(NSString *)method arguments:(NSArray *)arguments + context:(NSNumber *)executorID callback:(RCTJavaScriptCallback)onComplete; /** @@ -39,4 +42,27 @@ typedef void (^RCTJavaScriptCallback)(id json, NSError *error); - (void)injectJSONText:(NSString *)script asGlobalObjectNamed:(NSString *)objectName callback:(RCTJavaScriptCompleteBlock)onComplete; + +/** + * Enqueue a block to run in the executors JS thread. Fallback to `dispatch_async` + * on the main queue if the executor doesn't own a thread. + */ +- (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block; + @end + +static const char *RCTJavaScriptExecutorID = "RCTJavaScriptExecutorID"; +__used static id RCTCreateExecutor(Class executorClass) +{ + static NSUInteger executorID = 0; + id executor = [[executorClass alloc] init]; + if (executor) { + objc_setAssociatedObject(executor, RCTJavaScriptExecutorID, @(++executorID), OBJC_ASSOCIATION_RETAIN); + } + return executor; +} + +__used static NSNumber *RCTGetExecutorID(id executor) +{ + return executor ? objc_getAssociatedObject(executor, RCTJavaScriptExecutorID) : @0; +} diff --git a/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.h b/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.h index bdc551b4..8d52529e 100755 --- a/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.h +++ b/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.h @@ -1,4 +1,11 @@ -// Copyright 2004-present Facebook. All Rights Reserved. +/** + * 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 diff --git a/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.m b/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.m index baf2ca34..dd8fab46 100755 --- a/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.m +++ b/examples/node_modules/react-native/React/Base/RCTJavaScriptLoader.m @@ -1,4 +1,11 @@ -// Copyright 2004-present Facebook. All Rights Reserved. +/** + * 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 "RCTJavaScriptLoader.h" @@ -78,8 +85,9 @@ - (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(void (^)(NSError *))onCom // Handle general request errors if (error) { if ([[error domain] isEqualToString:NSURLErrorDomain]) { + NSString *desc = [@"Could not connect to development server. Ensure node server is running and available on the same network - run 'npm start' from react-native root\n\nURL: " stringByAppendingString:[scriptURL absoluteString]]; NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: @"Could not connect to development server. Ensure node server is running - run 'npm start' from ReactKit root", + NSLocalizedDescriptionKey: desc, NSLocalizedFailureReasonErrorKey: [error localizedDescription], NSUnderlyingErrorKey: error, }; @@ -133,9 +141,9 @@ - (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(void (^)(NSError *))onCom sourceCodeModule.scriptURL = scriptURL; sourceCodeModule.scriptText = rawText; - [_bridge enqueueApplicationScript:rawText url:scriptURL onComplete:^(NSError *_error) { + [_bridge enqueueApplicationScript:rawText url:scriptURL onComplete:^(NSError *scriptError) { dispatch_async(dispatch_get_main_queue(), ^{ - onComplete(_error); + onComplete(scriptError); }); }]; }]; diff --git a/examples/node_modules/react-native/React/Base/RCTLog.h b/examples/node_modules/react-native/React/Base/RCTLog.h index 7ffd8600..75cbe722 100644 --- a/examples/node_modules/react-native/React/Base/RCTLog.h +++ b/examples/node_modules/react-native/React/Base/RCTLog.h @@ -10,10 +10,7 @@ #import #import "RCTAssert.h" - -#ifdef __cplusplus -extern "C" { -#endif +#import "RCTDefines.h" /** * Thresholds for logs to raise an assertion, or display redbox, respectively. @@ -45,11 +42,16 @@ typedef void (^RCTLogFunction)( NSString *message ); +/** + * Get a given thread's name (or the current queue, if in debug mode) + */ +RCT_EXTERN NSString *RCTThreadName(NSThread *); + /** * A method to generate a string from a collection of log data. To omit any * particular data from the log, just pass nil or zero for the argument. */ -NSString *RCTFormatLog( +RCT_EXTERN NSString *RCTFormatLog( NSDate *timestamp, NSThread *thread, RCTLogLevel level, @@ -68,35 +70,35 @@ extern RCTLogFunction RCTDefaultLogFunction; * below which logs will be ignored. Default is RCTLogLevelInfo for debug and * RCTLogLevelError for production. */ -void RCTSetLogThreshold(RCTLogLevel threshold); -RCTLogLevel RCTGetLogThreshold(void); +RCT_EXTERN void RCTSetLogThreshold(RCTLogLevel threshold); +RCT_EXTERN RCTLogLevel RCTGetLogThreshold(void); /** * These methods get and set the current logging function called by the RCTLogXX * macros. You can use these to replace the standard behavior with custom log * functionality. */ -void RCTSetLogFunction(RCTLogFunction logFunction); -RCTLogFunction RCTGetLogFunction(void); +RCT_EXTERN void RCTSetLogFunction(RCTLogFunction logFunction); +RCT_EXTERN RCTLogFunction RCTGetLogFunction(void); /** * This appends additional code to the existing log function, without replacing * the existing functionality. Useful if you just want to forward logs to an * extra service without changing the default behavior. */ -void RCTAddLogFunction(RCTLogFunction logFunction); +RCT_EXTERN void RCTAddLogFunction(RCTLogFunction logFunction); /** * This method adds a conditional prefix to any messages logged within the scope * of the passed block. This is useful for adding additional context to log * messages. The block will be performed synchronously on the current thread. */ -void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix); +RCT_EXTERN void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix); /** * Private logging functions - ignore these. */ -void _RCTLogFormat(RCTLogLevel, const char *, int, NSString *, ...) NS_FORMAT_FUNCTION(4,5); +RCT_EXTERN void _RCTLogFormat(RCTLogLevel, const char *, int, NSString *, ...) NS_FORMAT_FUNCTION(4,5); #define _RCTLog(lvl, ...) do { \ if (lvl >= RCTLOG_FATAL_LEVEL) { RCTAssert(NO, __VA_ARGS__); } \ _RCTLogFormat(lvl, __FILE__, __LINE__, __VA_ARGS__); \ @@ -111,7 +113,3 @@ void _RCTLogFormat(RCTLogLevel, const char *, int, NSString *, ...) NS_FORMAT_FU #define RCTLogWarn(...) _RCTLog(RCTLogLevelWarning, __VA_ARGS__) #define RCTLogError(...) _RCTLog(RCTLogLevelError, __VA_ARGS__) #define RCTLogMustFix(...) _RCTLog(RCTLogLevelMustFix, __VA_ARGS__) - -#ifdef __cplusplus -} -#endif diff --git a/examples/node_modules/react-native/React/Base/RCTLog.m b/examples/node_modules/react-native/React/Base/RCTLog.m index 1770a20a..fb70fe6d 100644 --- a/examples/node_modules/react-native/React/Base/RCTLog.m +++ b/examples/node_modules/react-native/React/Base/RCTLog.m @@ -11,6 +11,7 @@ #import "RCTAssert.h" #import "RCTBridge.h" +#import "RCTDefines.h" #import "RCTRedBox.h" @interface RCTBridge (Logging) @@ -31,12 +32,12 @@ + (void)logMessage:(NSString *)message level:(NSString *)level; static RCTLogFunction RCTCurrentLogFunction; static RCTLogLevel RCTCurrentLogThreshold; -void RCTLogSetup(void) __attribute__((constructor)); -void RCTLogSetup() +__attribute__((constructor)) +static void RCTLogSetup() { RCTCurrentLogFunction = RCTDefaultLogFunction; -#if DEBUG +#if RCT_DEBUG RCTCurrentLogThreshold = RCTLogLevelInfo - 1; #else RCTCurrentLogThreshold = RCTLogLevelError; @@ -98,6 +99,22 @@ void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix) [prefixStack removeLastObject]; } +NSString *RCTThreadName(NSThread *thread) +{ + NSString *threadName = [thread isMainThread] ? @"main" : thread.name; + if (threadName.length == 0) { +#if DEBUG // This is DEBUG not RCT_DEBUG because it *really* must not ship in RC +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + threadName = @(dispatch_queue_get_label(dispatch_get_current_queue())); +#pragma clang diagnostic pop +#else + threadName = [NSString stringWithFormat:@"%p", thread]; +#endif + } + return threadName; +} + NSString *RCTFormatLog( NSDate *timestamp, NSThread *thread, @@ -121,18 +138,7 @@ void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix) [log appendFormat:@"[%s]", RCTLogLevels[level - 1]]; } if (thread) { - NSString *threadName = [thread isMainThread] ? @"main" : thread.name; - if (threadName.length == 0) { -#if DEBUG -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - threadName = @(dispatch_queue_get_label(dispatch_get_current_queue())); -#pragma clang diagnostic pop -#else - threadName = [NSString stringWithFormat:@"%p", thread]; -#endif - } - [log appendFormat:@"[tid:%@]", threadName]; + [log appendFormat:@"[tid:%@]", RCTThreadName(thread)]; } if (fileName) { fileName = [fileName lastPathComponent]; @@ -156,12 +162,7 @@ void _RCTLogFormat( NSString *format, ...) { -#if DEBUG - BOOL log = YES; -#else - BOOL log = (RCTCurrentLogFunction != nil); -#endif - + BOOL log = RCT_DEBUG || (RCTCurrentLogFunction != nil); if (log && level >= RCTCurrentLogThreshold) { // Get message @@ -183,15 +184,15 @@ void _RCTLogFormat( level, fileName ? @(fileName) : nil, (lineNumber >= 0) ? @(lineNumber) : nil, message ); -#if DEBUG +#if RCT_DEBUG // Red box is only available in debug mode - // Log to red box - if (level >= RCTLOG_REDBOX_LEVEL) { - [[RCTRedBox sharedInstance] showErrorMessage:message]; - } + // Log to red box + if (level >= RCTLOG_REDBOX_LEVEL) { + [[RCTRedBox sharedInstance] showErrorMessage:message]; + } - // Log to JS executor - [RCTBridge logMessage:message level:level ? @(RCTLogLevels[level - 1]) : @"info"]; + // Log to JS executor + [RCTBridge logMessage:message level:level ? @(RCTLogLevels[level - 1]) : @"info"]; #endif diff --git a/examples/node_modules/react-native/React/Base/RCTProfile.h b/examples/node_modules/react-native/React/Base/RCTProfile.h new file mode 100644 index 00000000..0c254c80 --- /dev/null +++ b/examples/node_modules/react-native/React/Base/RCTProfile.h @@ -0,0 +1,105 @@ +/** + * 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 + +#import "RCTDefines.h" + +/** + * RCTProfile + * + * This file provides a set of functions and macros for performance profiling + * + * NOTE: This API is a work in a work in progress, please consider carefully + * before before using it. + */ + +#if RCT_DEV + +/** + * Returns YES if the profiling information is currently being collected + */ +RCT_EXTERN BOOL RCTProfileIsProfiling(void); + +/** + * Start collecting profiling information + */ +RCT_EXTERN void RCTProfileInit(void); + +/** + * Stop profiling and return a JSON string of the collected data - The data + * returned is compliant with google's trace event format - the format used + * as input to trace-viewer + */ +RCT_EXTERN NSString *RCTProfileEnd(void); + +/** + * Collects the initial event information for the event and returns a reference ID + */ +RCT_EXTERN NSNumber *_RCTProfileBeginEvent(void); + +/** + * The ID returned by BeginEvent should then be passed into EndEvent, with the + * rest of the event information. Just at this point the event will actually be + * registered + */ +RCT_EXTERN void _RCTProfileEndEvent(NSNumber *, NSString *, NSString *, id); + +/** + * This pair of macros implicitly handle the event ID when beginning and ending + * an event, for both simplicity and performance reasons, this method is preferred + * + * NOTE: The EndEvent call has to be either, in the same scope of BeginEvent, + * or in a sub-scope, otherwise the ID stored by BeginEvent won't be accessible + * for EndEvent, in this case you may want to use the actual C functions. + */ +#define RCTProfileBeginEvent() \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wshadow\"") \ +NSNumber *__rct_profile_id = _RCTProfileBeginEvent(); \ +_Pragma("clang diagnostic pop") + +#define RCTProfileEndEvent(name, category, args...) \ +_RCTProfileEndEvent(__rct_profile_id, name, category, args) + +/** + * An event that doesn't have a duration (i.e. Notification, VSync, etc) + */ +RCT_EXTERN void RCTProfileImmediateEvent(NSString *, NSTimeInterval , NSString *); + +/** + * Helper to profile the duration of the execution of a block. This method uses + * self and _cmd to name this event for simplicity sake. + * + * NOTE: The block can't expect any argument + */ +#define RCTProfileBlock(block, category, arguments) \ +^{ \ + RCTProfileBeginEvent(); \ + block(); \ + RCTProfileEndEvent([NSString stringWithFormat:@"[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd)], category, arguments); \ +} + +#else + +#define RCTProfileIsProfiling(...) NO +#define RCTProfileInit(...) +#define RCTProfileEnd(...) @"" + +#define _RCTProfileBeginEvent(...) @0 +#define RCTProfileBeginEvent(...) + +#define _RCTProfileEndEvent(...) +#define RCTProfileEndEvent(...) + +#define RCTProfileImmediateEvent(...) + +#define RCTProfileBlock(block, ...) block + +#endif diff --git a/examples/node_modules/react-native/React/Base/RCTProfile.m b/examples/node_modules/react-native/React/Base/RCTProfile.m new file mode 100644 index 00000000..19c6900c --- /dev/null +++ b/examples/node_modules/react-native/React/Base/RCTProfile.m @@ -0,0 +1,174 @@ +/** + * 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 "RCTProfile.h" + +#import + +#import + +#import "RCTDefines.h" +#import "RCTLog.h" +#import "RCTUtils.h" + +#if RCT_DEV + +#pragma mark - Prototypes + +NSNumber *RCTProfileTimestamp(NSTimeInterval); +NSString *RCTProfileMemory(vm_size_t); +NSDictionary *RCTProfileGetMemoryUsage(void); + +#pragma mark - Constants + +NSString const *RCTProfileTraceEvents = @"traceEvents"; +NSString const *RCTProfileSamples = @"samples"; + +#pragma mark - Variables + +NSDictionary *RCTProfileInfo; +NSUInteger RCTProfileEventID = 0; +NSMutableDictionary *RCTProfileOngoingEvents; +NSTimeInterval RCTProfileStartTime; +NSLock *_RCTProfileLock; + +#pragma mark - Macros + +#define RCTProfileAddEvent(type, props...) \ +[RCTProfileInfo[type] addObject:@{ \ + @"pid": @([[NSProcessInfo processInfo] processIdentifier]), \ + @"tid": RCTThreadName([NSThread currentThread]), \ + props \ +}]; + +#define CHECK(...) \ +if (!RCTProfileIsProfiling()) { \ + return __VA_ARGS__; \ +} + +#define RCTProfileLock(...) \ +[_RCTProfileLock lock]; \ +__VA_ARGS__ \ +[_RCTProfileLock unlock] + +#pragma mark - Private Helpers + +NSNumber *RCTProfileTimestamp(NSTimeInterval timestamp) +{ + return @((timestamp - RCTProfileStartTime) * 1e6); +} + +NSString *RCTProfileMemory(vm_size_t memory) +{ + double mem = ((double)memory) / 1024 / 1024; + return [NSString stringWithFormat:@"%.2lfmb", mem]; +} + +NSDictionary *RCTProfileGetMemoryUsage(void) +{ + struct task_basic_info info; + mach_msg_type_number_t size = sizeof(info); + kern_return_t kerr = task_info(mach_task_self(), + TASK_BASIC_INFO, + (task_info_t)&info, + &size); + if( kerr == KERN_SUCCESS ) { + return @{ + @"suspend_count": @(info.suspend_count), + @"virtual_size": RCTProfileMemory(info.virtual_size), + @"resident_size": RCTProfileMemory(info.resident_size), + }; + } else { + return @{}; + } +} + +#pragma mark - Public Functions + +BOOL RCTProfileIsProfiling(void) +{ + RCTProfileLock( + BOOL profiling = RCTProfileInfo != nil; + ); + return profiling; +} + +void RCTProfileInit(void) +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _RCTProfileLock = [[NSLock alloc] init]; + }); + RCTProfileLock( + RCTProfileStartTime = CACurrentMediaTime(); + RCTProfileOngoingEvents = [[NSMutableDictionary alloc] init]; + RCTProfileInfo = @{ + RCTProfileTraceEvents: [[NSMutableArray alloc] init], + RCTProfileSamples: [[NSMutableArray alloc] init], + }; + ); +} + +NSString *RCTProfileEnd(void) +{ + RCTProfileLock( + NSString *log = RCTJSONStringify(RCTProfileInfo, NULL); + RCTProfileEventID = 0; + RCTProfileInfo = nil; + RCTProfileOngoingEvents = nil; + ); + return log; +} + +NSNumber *_RCTProfileBeginEvent(void) +{ + CHECK(@0); + RCTProfileLock( + NSNumber *eventID = @(++RCTProfileEventID); + RCTProfileOngoingEvents[eventID] = RCTProfileTimestamp(CACurrentMediaTime()); + ); + return eventID; +} + +void _RCTProfileEndEvent(NSNumber *eventID, NSString *name, NSString *categories, id args) +{ + CHECK(); + RCTProfileLock( + NSNumber *startTimestamp = RCTProfileOngoingEvents[eventID]; + if (startTimestamp) { + NSNumber *endTimestamp = RCTProfileTimestamp(CACurrentMediaTime()); + + RCTProfileAddEvent(RCTProfileTraceEvents, + @"name": name, + @"cat": categories, + @"ph": @"X", + @"ts": startTimestamp, + @"dur": @(endTimestamp.doubleValue - startTimestamp.doubleValue), + @"args": args ?: @[], + ); + [RCTProfileOngoingEvents removeObjectForKey:eventID]; + } + ); +} + +void RCTProfileImmediateEvent(NSString *name, NSTimeInterval timestamp, NSString *scope) +{ + CHECK(); + RCTProfileLock( + RCTProfileAddEvent(RCTProfileTraceEvents, + @"name": name, + @"ts": RCTProfileTimestamp(timestamp), + @"scope": scope, + @"ph": @"i", + @"args": RCTProfileGetMemoryUsage(), + ); + ); +} + +#endif diff --git a/examples/node_modules/react-native/React/Base/RCTRedBox.h b/examples/node_modules/react-native/React/Base/RCTRedBox.h index 9a3a9b49..058759da 100644 --- a/examples/node_modules/react-native/React/Base/RCTRedBox.h +++ b/examples/node_modules/react-native/React/Base/RCTRedBox.h @@ -7,6 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import "RCTDefines.h" + +#if RCT_DEBUG // Red box is only available in debug mode + #import @interface RCTRedBox : NSObject @@ -23,3 +27,5 @@ - (void)dismiss; @end + +#endif diff --git a/examples/node_modules/react-native/React/Base/RCTRedBox.m b/examples/node_modules/react-native/React/Base/RCTRedBox.m index 3bed3150..62684025 100644 --- a/examples/node_modules/react-native/React/Base/RCTRedBox.m +++ b/examples/node_modules/react-native/React/Base/RCTRedBox.m @@ -7,6 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import "RCTDefines.h" + +#if RCT_DEBUG // Red box is only available in debug mode + #import "RCTRedBox.h" #import "RCTBridge.h" @@ -282,23 +286,12 @@ - (void)updateErrorMessage:(NSString *)message withStack:(NSArray *)stack - (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack showIfHidden:(BOOL)shouldShow { - -#if DEBUG - - dispatch_block_t block = ^{ + dispatch_async(dispatch_get_main_queue(), ^{ if (!_window) { _window = [[RCTRedBoxWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; } [_window showErrorMessage:message withStack:stack showIfHidden:shouldShow]; - }; - if ([NSThread isMainThread]) { - block(); - } else { - dispatch_async(dispatch_get_main_queue(), block); - } - -#endif - + }); } - (NSString *)currentErrorMessage @@ -316,3 +309,5 @@ - (void)dismiss } @end + +#endif diff --git a/examples/node_modules/react-native/React/Base/RCTRootView.h b/examples/node_modules/react-native/React/Base/RCTRootView.h index 1227eba9..ee5a35d7 100644 --- a/examples/node_modules/react-native/React/Base/RCTRootView.h +++ b/examples/node_modules/react-native/React/Base/RCTRootView.h @@ -57,12 +57,6 @@ */ @property (nonatomic, strong) Class executorClass; -/** - * If YES will watch for shake gestures and show development menu - * with options like "Reload", "Enable Debugging", etc. - */ -@property (nonatomic, assign) BOOL enableDevMenu; - /** * The backing view controller of the root view. */ diff --git a/examples/node_modules/react-native/React/Base/RCTRootView.m b/examples/node_modules/react-native/React/Base/RCTRootView.m index c9a97dfd..45624efd 100644 --- a/examples/node_modules/react-native/React/Base/RCTRootView.m +++ b/examples/node_modules/react-native/React/Base/RCTRootView.m @@ -13,7 +13,6 @@ #import "RCTBridge.h" #import "RCTContextExecutor.h" -#import "RCTDevMenu.h" #import "RCTEventDispatcher.h" #import "RCTKeyCommands.h" #import "RCTLog.h" @@ -42,7 +41,6 @@ - (NSNumber *)allocateRootTag; @implementation RCTRootView { - RCTDevMenu *_devMenu; RCTBridge *_bridge; RCTTouchHandler *_touchHandler; NSString *_moduleName; @@ -60,12 +58,6 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge self.backgroundColor = [UIColor whiteColor]; -#ifdef DEBUG - - _enableDevMenu = YES; - -#endif - _bridge = bridge; _moduleName = moduleName; @@ -120,18 +112,6 @@ - (BOOL)canBecomeFirstResponder return YES; } -- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event -{ - if (motion == UIEventSubtypeMotionShake && self.enableDevMenu) { - if (!_devMenu) { - _devMenu = [[RCTDevMenu alloc] initWithBridge:_bridge]; - } - [_devMenu show]; - } else { - [super motionEnded:motion withEvent:event]; - } -} - RCT_IMPORT_METHOD(AppRegistry, runApplication) RCT_IMPORT_METHOD(ReactIOS, unmountComponentAtNodeAndRemoveContainer) @@ -169,7 +149,7 @@ - (void)layoutSubviews [super layoutSubviews]; if (_contentView) { _contentView.frame = self.bounds; - [_bridge.uiManager setFrame:self.frame forRootView:_contentView]; + [_bridge.uiManager setFrame:self.bounds forRootView:_contentView]; } } diff --git a/examples/node_modules/react-native/React/Base/RCTUtils.h b/examples/node_modules/react-native/React/Base/RCTUtils.h index d20ba8a5..812a6512 100644 --- a/examples/node_modules/react-native/React/Base/RCTUtils.h +++ b/examples/node_modules/react-native/React/Base/RCTUtils.h @@ -13,43 +13,36 @@ #import #import "RCTAssert.h" - -#ifdef __cplusplus -extern "C" { -#endif +#import "RCTDefines.h" // Utility functions for JSON object <-> string serialization/deserialization -NSString *RCTJSONStringify(id jsonObject, NSError **error); -id RCTJSONParse(NSString *jsonString, NSError **error); +RCT_EXTERN NSString *RCTJSONStringify(id jsonObject, NSError **error); +RCT_EXTERN id RCTJSONParse(NSString *jsonString, NSError **error); // Get MD5 hash of a string (TODO: currently unused. Remove?) -NSString *RCTMD5Hash(NSString *string); +RCT_EXTERN NSString *RCTMD5Hash(NSString *string); // Get screen metrics in a thread-safe way -CGFloat RCTScreenScale(void); -CGSize RCTScreenSize(void); +RCT_EXTERN CGFloat RCTScreenScale(void); +RCT_EXTERN CGSize RCTScreenSize(void); // Round float coordinates to nearest whole screen pixel (not point) -CGFloat RCTRoundPixelValue(CGFloat value); -CGFloat RCTCeilPixelValue(CGFloat value); -CGFloat RCTFloorPixelValue(CGFloat value); +RCT_EXTERN CGFloat RCTRoundPixelValue(CGFloat value); +RCT_EXTERN CGFloat RCTCeilPixelValue(CGFloat value); +RCT_EXTERN CGFloat RCTFloorPixelValue(CGFloat value); // Get current time, for precise performance metrics -NSTimeInterval RCTTGetAbsoluteTime(void); +RCT_EXTERN NSTimeInterval RCTTGetAbsoluteTime(void); // Method swizzling -void RCTSwapClassMethods(Class cls, SEL original, SEL replacement); -void RCTSwapInstanceMethods(Class cls, SEL original, SEL replacement); +RCT_EXTERN void RCTSwapClassMethods(Class cls, SEL original, SEL replacement); +RCT_EXTERN void RCTSwapInstanceMethods(Class cls, SEL original, SEL replacement); // Module subclass support -BOOL RCTClassOverridesClassMethod(Class cls, SEL selector); -BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector); +RCT_EXTERN BOOL RCTClassOverridesClassMethod(Class cls, SEL selector); +RCT_EXTERN BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector); // Creates a standardized error object // TODO(#6472857): create NSErrors and automatically convert them over the bridge. -NSDictionary *RCTMakeError(NSString *message, id toStringify, NSDictionary *extraData); -NSDictionary *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary *extraData); - -#ifdef __cplusplus -} -#endif +RCT_EXTERN NSDictionary *RCTMakeError(NSString *message, id toStringify, NSDictionary *extraData); +RCT_EXTERN NSDictionary *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary *extraData); diff --git a/examples/node_modules/react-native/React/Executors/RCTContextExecutor.h b/examples/node_modules/react-native/React/Executors/RCTContextExecutor.h index 6e62d87b..159965a2 100644 --- a/examples/node_modules/react-native/React/Executors/RCTContextExecutor.h +++ b/examples/node_modules/react-native/React/Executors/RCTContextExecutor.h @@ -9,7 +9,7 @@ #import -#import "../Base/RCTJavaScriptExecutor.h" +#import "RCTJavaScriptExecutor.h" // TODO (#5906496): Might RCTJSCoreExecutor be a better name for this? diff --git a/examples/node_modules/react-native/React/Executors/RCTContextExecutor.m b/examples/node_modules/react-native/React/Executors/RCTContextExecutor.m index 8475e2af..86444dd2 100644 --- a/examples/node_modules/react-native/React/Executors/RCTContextExecutor.m +++ b/examples/node_modules/react-native/React/Executors/RCTContextExecutor.m @@ -14,7 +14,9 @@ #import #import "RCTAssert.h" +#import "RCTDefines.h" #import "RCTLog.h" +#import "RCTProfile.h" #import "RCTUtils.h" @interface RCTJavaScriptContext : NSObject @@ -46,9 +48,11 @@ - (BOOL)isValid - (void)invalidate { - JSGlobalContextRelease(_ctx); - _ctx = NULL; - _self = nil; + if (self.isValid) { + JSGlobalContextRelease(_ctx); + _ctx = NULL; + _self = nil; + } } @end @@ -85,7 +89,14 @@ static JSValueRef RCTNativeLoggingHook(JSContextRef context, JSObjectRef object, range:(NSRange){0, message.length} withTemplate:@"[$4$5] \t$2"]; - _RCTLogFormat(RCTLogLevelInfo, NULL, -1, @"%@", message); + // TODO: it would be good if log level was sent as a param, instead of this hack + RCTLogLevel level = RCTLogLevelInfo; + if ([message rangeOfString:@"error" options:NSCaseInsensitiveSearch].length) { + level = RCTLogLevelError; + } else if ([message rangeOfString:@"warning" options:NSCaseInsensitiveSearch].length) { + level = RCTLogLevelWarning; + } + _RCTLogFormat(level, NULL, -1, @"%@", message); } return JSValueMakeUndefined(context); @@ -126,8 +137,6 @@ static JSValueRef RCTNoop(JSContextRef context, JSObjectRef object, JSObjectRef + (void)runRunLoopThread { - // TODO (#5906496): Investigate exactly what this does and why - @autoreleasepool { // copy thread name to pthread name pthread_setname_np([[[NSThread currentThread] name] UTF8String]); @@ -210,10 +219,7 @@ - (BOOL)isValid - (void)invalidate { - if (self.isValid) { - [_context performSelector:@selector(invalidate) onThread:_javaScriptThread withObject:nil waitUntilDone:NO]; - _context = nil; - } + [_context performSelector:@selector(invalidate) onThread:_javaScriptThread withObject:nil waitUntilDone:NO]; } - (void)dealloc @@ -224,13 +230,14 @@ - (void)dealloc - (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:^{ + [self executeBlockOnJavaScriptQueue:RCTProfileBlock((^{ RCTContextExecutor *strongSelf = weakSelf; - if (!strongSelf || !strongSelf.isValid) { + if (!strongSelf || !strongSelf.isValid || ![RCTGetExecutorID(strongSelf) isEqualToNumber:executorID]) { return; } NSError *error; @@ -269,35 +276,36 @@ - (void)executeJSCall:(NSString *)name } onComplete(objcValue, nil); - }]; + }), @"js_call", (@{@"module":name, @"method": method, @"args": arguments}))]; } - (void)executeApplicationScript:(NSString *)script - sourceURL:(NSURL *)url + sourceURL:(NSURL *)sourceURL onComplete:(RCTJavaScriptCompleteBlock)onComplete { - RCTAssert(url != nil, @"url should not be nil"); - RCTAssert(onComplete != nil, @"onComplete block should not be nil"); + RCTAssert(sourceURL != nil, @"url should not be nil"); + __weak RCTContextExecutor *weakSelf = self; - [self executeBlockOnJavaScriptQueue:^{ + [self executeBlockOnJavaScriptQueue:RCTProfileBlock((^{ RCTContextExecutor *strongSelf = weakSelf; if (!strongSelf || !strongSelf.isValid) { return; } JSValueRef jsError = NULL; JSStringRef execJSString = JSStringCreateWithCFString((__bridge CFStringRef)script); - JSStringRef sourceURL = JSStringCreateWithCFString((__bridge CFStringRef)url.absoluteString); - JSValueRef result = JSEvaluateScript(strongSelf->_context.ctx, execJSString, NULL, sourceURL, 0, &jsError); - JSStringRelease(sourceURL); + JSStringRef jsURL = JSStringCreateWithCFString((__bridge CFStringRef)sourceURL.absoluteString); + JSValueRef result = JSEvaluateScript(strongSelf->_context.ctx, execJSString, NULL, jsURL, 0, &jsError); + JSStringRelease(jsURL); JSStringRelease(execJSString); - NSError *error; - if (!result) { - error = RCTNSErrorFromJSError(strongSelf->_context.ctx, jsError); + if (onComplete) { + NSError *error; + if (!result) { + error = RCTNSErrorFromJSError(strongSelf->_context.ctx, jsError); + } + onComplete(error); } - - onComplete(error); - }]; + }), @"js_call", (@{ @"url": sourceURL }))]; } - (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block @@ -314,13 +322,12 @@ - (void)injectJSONText:(NSString *)script asGlobalObjectNamed:(NSString *)objectName callback:(RCTJavaScriptCompleteBlock)onComplete { - RCTAssert(onComplete != nil, @"onComplete block should not be nil"); -#if DEBUG - RCTAssert(RCTJSONParse(script, NULL) != nil, @"%@ wasn't valid JSON!", script); -#endif + if (RCT_DEBUG) { + RCTAssert(RCTJSONParse(script, NULL) != nil, @"%@ wasn't valid JSON!", script); + } __weak RCTContextExecutor *weakSelf = self; - [self executeBlockOnJavaScriptQueue:^{ + [self executeBlockOnJavaScriptQueue:RCTProfileBlock((^{ RCTContextExecutor *strongSelf = weakSelf; if (!strongSelf || !strongSelf.isValid) { return; @@ -333,19 +340,21 @@ - (void)injectJSONText:(NSString *)script NSString *errorDesc = [NSString stringWithFormat:@"Can't make JSON value from script '%@'", script]; RCTLogError(@"%@", errorDesc); - NSError *error = [NSError errorWithDomain:@"JS" code:2 userInfo:@{NSLocalizedDescriptionKey: errorDesc}]; - onComplete(error); + if (onComplete) { + NSError *error = [NSError errorWithDomain:@"JS" code:2 userInfo:@{NSLocalizedDescriptionKey: errorDesc}]; + onComplete(error); + } return; } JSObjectRef globalObject = JSContextGetGlobalObject(strongSelf->_context.ctx); - JSStringRef JSName = JSStringCreateWithCFString((__bridge CFStringRef)objectName); JSObjectSetProperty(strongSelf->_context.ctx, globalObject, JSName, valueToInject, kJSPropertyAttributeNone, NULL); JSStringRelease(JSName); - onComplete(nil); - }]; - + if (onComplete) { + onComplete(nil); + } + }), @"js_call,json_call", (@{@"objectName": objectName}))]; } @end diff --git a/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.h b/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.h index 77d8a831..db8710c7 100644 --- a/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.h +++ b/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.h @@ -7,6 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import "RCTDefines.h" + +#if RCT_DEV // Debug executors are only supported in dev mode + #import #import "RCTJavaScriptExecutor.h" @@ -40,3 +44,5 @@ - (UIWebView *)invalidateAndReclaimWebView; @end + +#endif diff --git a/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.m b/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.m index 55de44ab..09628850 100644 --- a/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.m +++ b/examples/node_modules/react-native/React/Executors/RCTWebViewExecutor.m @@ -7,6 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import "RCTDefines.h" + +#if RCT_DEV // Debug executors are only supported in dev mode + #import "RCTWebViewExecutor.h" #import @@ -76,10 +80,15 @@ - (UIWebView *)invalidateAndReclaimWebView - (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]) { + return; + } + NSError *error; NSString *argsString = RCTJSONStringify(arguments, &error); if (!argsString) { @@ -183,9 +192,14 @@ - (void)injectJSONText:(NSString *)script asGlobalObjectNamed:(NSString *)objectName callback:(RCTJavaScriptCompleteBlock)onComplete { - RCTAssert(!_objectsToInject[objectName], - @"already injected object named %@", _objectsToInject[objectName]); + if (RCT_DEBUG) { + RCTAssert(!_objectsToInject[objectName], + @"already injected object named %@", _objectsToInject[objectName]); + } _objectsToInject[objectName] = script; onComplete(nil); } + @end + +#endif diff --git a/examples/node_modules/react-native/React/Layout/Layout.c b/examples/node_modules/react-native/React/Layout/Layout.c index 21dec570..2b168e44 100644 --- a/examples/node_modules/react-native/React/Layout/Layout.c +++ b/examples/node_modules/react-native/React/Layout/Layout.c @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<24fa633b4dd81b7fb40c2b2b0b7c97d0>> * * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * !! This file is a check-in from github! !! @@ -642,19 +642,6 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth) { } } - float containerMainAxis = node->layout.dimensions[dim[mainAxis]]; - // If the user didn't specify a width or height, and it has not been set - // by the container, then we set it via the children. - if (isUndefined(node->layout.dimensions[dim[mainAxis]])) { - containerMainAxis = fmaxf( - // We're missing the last padding at this point to get the final - // dimension - mainDim + getPaddingAndBorder(node, trailing[mainAxis]), - // We can never assign a width smaller than the padding and borders - getPaddingAndBorderAxis(node, mainAxis) - ); - } - float containerCrossAxis = node->layout.dimensions[dim[crossAxis]]; if (isUndefined(node->layout.dimensions[dim[crossAxis]])) { containerCrossAxis = fmaxf( diff --git a/examples/node_modules/react-native/React/Modules/RCTAlertManager.m b/examples/node_modules/react-native/React/Modules/RCTAlertManager.m index ae11ce52..2690de1d 100644 --- a/examples/node_modules/react-native/React/Modules/RCTAlertManager.m +++ b/examples/node_modules/react-native/React/Modules/RCTAlertManager.m @@ -35,6 +35,11 @@ - (instancetype)init return self; } +- (dispatch_queue_t)methodQueue +{ + return dispatch_get_main_queue(); +} + /** * @param {NSDictionary} args Dictionary of the form * @@ -64,37 +69,34 @@ - (instancetype)init return; } - dispatch_async(dispatch_get_main_queue(), ^{ - - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title - message:message - delegate:self - cancelButtonTitle:nil - otherButtonTitles:nil]; - - NSMutableArray *buttonKeys = [[NSMutableArray alloc] initWithCapacity:buttons.count]; - - NSInteger index = 0; - for (NSDictionary *button in buttons) { - if (button.count != 1) { - RCTLogError(@"Button definitions should have exactly one key."); - } - NSString *buttonKey = [button.allKeys firstObject]; - NSString *buttonTitle = [button[buttonKey] description]; - [alertView addButtonWithTitle:buttonTitle]; - if ([buttonKey isEqualToString: @"cancel"]) { - alertView.cancelButtonIndex = index; - } - [buttonKeys addObject:buttonKey]; - index ++; + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title + message:message + delegate:self + cancelButtonTitle:nil + otherButtonTitles:nil]; + + NSMutableArray *buttonKeys = [[NSMutableArray alloc] initWithCapacity:buttons.count]; + + NSInteger index = 0; + for (NSDictionary *button in buttons) { + if (button.count != 1) { + RCTLogError(@"Button definitions should have exactly one key."); + } + NSString *buttonKey = [button.allKeys firstObject]; + NSString *buttonTitle = [button[buttonKey] description]; + [alertView addButtonWithTitle:buttonTitle]; + if ([buttonKey isEqualToString: @"cancel"]) { + alertView.cancelButtonIndex = index; } + [buttonKeys addObject:buttonKey]; + index ++; + } - [_alerts addObject:alertView]; - [_alertCallbacks addObject:callback ?: ^(id unused) {}]; - [_alertButtonKeys addObject:buttonKeys]; + [_alerts addObject:alertView]; + [_alertCallbacks addObject:callback ?: ^(id unused) {}]; + [_alertButtonKeys addObject:buttonKeys]; - [alertView show]; - }); + [alertView show]; } #pragma mark - UIAlertViewDelegate diff --git a/examples/node_modules/react-native/React/Modules/RCTAsyncLocalStorage.m b/examples/node_modules/react-native/React/Modules/RCTAsyncLocalStorage.m index 8e6d414c..2c01161d 100644 --- a/examples/node_modules/react-native/React/Modules/RCTAsyncLocalStorage.m +++ b/examples/node_modules/react-native/React/Modules/RCTAsyncLocalStorage.m @@ -61,20 +61,6 @@ static id RCTReadFile(NSString *filePath, NSString *key, NSDictionary **errorOut return nil; } -static dispatch_queue_t RCTFileQueue(void) -{ - static dispatch_queue_t fileQueue = NULL; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - // All JS is single threaded, so a serial queue is our only option. - fileQueue = dispatch_queue_create("com.facebook.rkFile", DISPATCH_QUEUE_SERIAL); - dispatch_set_target_queue(fileQueue, - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)); - }); - - return fileQueue; -} - #pragma mark - RCTAsyncLocalStorage @implementation RCTAsyncLocalStorage @@ -90,6 +76,11 @@ @implementation RCTAsyncLocalStorage RCT_EXPORT_MODULE() +- (dispatch_queue_t)methodQueue +{ + return dispatch_queue_create("com.facebook.React.AsyncLocalStorageQueue", DISPATCH_QUEUE_SERIAL); +} + - (NSString *)_filePathForKey:(NSString *)key { NSString *safeFileName = RCTMD5Hash(key); @@ -196,99 +187,89 @@ - (id)_writeEntry:(NSArray *)entry return; } - dispatch_async(RCTFileQueue(), ^{ - id errorOut = [self _ensureSetup]; - if (errorOut) { - callback(@[@[errorOut], [NSNull null]]); - return; - } - NSMutableArray *errors; - NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:keys.count]; - for (NSString *key in keys) { - id keyError = [self _appendItemForKey:key toArray:result]; - RCTAppendError(keyError, &errors); - } - [self _writeManifest:&errors]; - callback(@[errors ?: [NSNull null], result]); - }); + id errorOut = [self _ensureSetup]; + if (errorOut) { + callback(@[@[errorOut], [NSNull null]]); + return; + } + NSMutableArray *errors; + NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:keys.count]; + for (NSString *key in keys) { + id keyError = [self _appendItemForKey:key toArray:result]; + RCTAppendError(keyError, &errors); + } + [self _writeManifest:&errors]; + callback(@[errors ?: [NSNull null], result]); } RCT_EXPORT_METHOD(multiSet:(NSArray *)kvPairs callback:(RCTResponseSenderBlock)callback) { - dispatch_async(RCTFileQueue(), ^{ - id errorOut = [self _ensureSetup]; - if (errorOut) { - callback(@[@[errorOut]]); - return; - } - NSMutableArray *errors; - for (NSArray *entry in kvPairs) { - id keyError = [self _writeEntry:entry]; - RCTAppendError(keyError, &errors); - } - [self _writeManifest:&errors]; - if (callback) { - callback(@[errors ?: [NSNull null]]); - } - }); + id errorOut = [self _ensureSetup]; + if (errorOut) { + callback(@[@[errorOut]]); + return; + } + NSMutableArray *errors; + for (NSArray *entry in kvPairs) { + id keyError = [self _writeEntry:entry]; + RCTAppendError(keyError, &errors); + } + [self _writeManifest:&errors]; + if (callback) { + callback(@[errors ?: [NSNull null]]); + } } RCT_EXPORT_METHOD(multiRemove:(NSArray *)keys callback:(RCTResponseSenderBlock)callback) { - dispatch_async(RCTFileQueue(), ^{ - id errorOut = [self _ensureSetup]; - if (errorOut) { - callback(@[@[errorOut]]); - return; - } - NSMutableArray *errors; - for (NSString *key in keys) { - id keyError = RCTErrorForKey(key); - if (!keyError) { - NSString *filePath = [self _filePathForKey:key]; - [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; - [_manifest removeObjectForKey:key]; - } - RCTAppendError(keyError, &errors); - } - [self _writeManifest:&errors]; - if (callback) { - callback(@[errors ?: [NSNull null]]); + id errorOut = [self _ensureSetup]; + if (errorOut) { + callback(@[@[errorOut]]); + return; + } + NSMutableArray *errors; + for (NSString *key in keys) { + id keyError = RCTErrorForKey(key); + if (!keyError) { + NSString *filePath = [self _filePathForKey:key]; + [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; + [_manifest removeObjectForKey:key]; } - }); + RCTAppendError(keyError, &errors); + } + [self _writeManifest:&errors]; + if (callback) { + callback(@[errors ?: [NSNull null]]); + } } RCT_EXPORT_METHOD(clear:(RCTResponseSenderBlock)callback) { - dispatch_async(RCTFileQueue(), ^{ - id errorOut = [self _ensureSetup]; - if (!errorOut) { - NSError *error; - for (NSString *key in _manifest) { - NSString *filePath = [self _filePathForKey:key]; - [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]; - } - [_manifest removeAllObjects]; - errorOut = [self _writeManifest:nil]; - } - if (callback) { - callback(@[errorOut ?: [NSNull null]]); + id errorOut = [self _ensureSetup]; + if (!errorOut) { + NSError *error; + for (NSString *key in _manifest) { + NSString *filePath = [self _filePathForKey:key]; + [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]; } - }); + [_manifest removeAllObjects]; + errorOut = [self _writeManifest:nil]; + } + if (callback) { + callback(@[errorOut ?: [NSNull null]]); + } } RCT_EXPORT_METHOD(getAllKeys:(RCTResponseSenderBlock)callback) { - dispatch_async(RCTFileQueue(), ^{ - id errorOut = [self _ensureSetup]; - if (errorOut) { - callback(@[errorOut, [NSNull null]]); - } else { - callback(@[[NSNull null], [_manifest allKeys]]); - } - }); + id errorOut = [self _ensureSetup]; + if (errorOut) { + callback(@[errorOut, [NSNull null]]); + } else { + callback(@[[NSNull null], [_manifest allKeys]]); + } } @end diff --git a/examples/node_modules/react-native/React/Modules/RCTExceptionsManager.m b/examples/node_modules/react-native/React/Modules/RCTExceptionsManager.m index 5be80133..87813828 100644 --- a/examples/node_modules/react-native/React/Modules/RCTExceptionsManager.m +++ b/examples/node_modules/react-native/React/Modules/RCTExceptionsManager.m @@ -9,6 +9,7 @@ #import "RCTExceptionsManager.h" +#import "RCTDefines.h" #import "RCTLog.h" #import "RCTRedBox.h" #import "RCTRootView.h" @@ -19,10 +20,6 @@ @implementation RCTExceptionsManager NSUInteger _reloadRetries; } -#ifndef DEBUG -static NSUInteger RCTReloadRetries = 0; -#endif - RCT_EXPORT_MODULE() - (instancetype)initWithDelegate:(id)delegate @@ -47,29 +44,32 @@ - (instancetype)init return; } -#ifdef DEBUG - [[RCTRedBox sharedInstance] showErrorMessage:message withStack:stack]; +#if RCT_DEBUG // Red box is only available in debug mode + + [[RCTRedBox sharedInstance] showErrorMessage:message withStack:stack]; + #else - if (RCTReloadRetries < _maxReloadAttempts) { - RCTReloadRetries++; - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification object:nil]; - }); + + static NSUInteger reloadRetries = 0; + const NSUInteger maxMessageLength = 75; + + if (reloadRetries < _maxReloadAttempts) { + + reloadRetries++; + [[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification + object:nil]; + } else { - NSError *error; - const NSUInteger MAX_SANITIZED_LENGTH = 75; + // Filter out numbers so the same base errors are mapped to the same categories independent of incorrect values. NSString *pattern = @"[+-]?\\d+[,.]?\\d*"; - NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error]; - RCTAssert(error == nil, @"Bad regex pattern: %@", pattern); - NSString *sanitizedMessage = [regex stringByReplacingMatchesInString:message - options:0 - range:NSMakeRange(0, message.length) - withTemplate:@""]; - if (sanitizedMessage.length > MAX_SANITIZED_LENGTH) { - sanitizedMessage = [[sanitizedMessage substringToIndex:MAX_SANITIZED_LENGTH] stringByAppendingString:@"..."]; + NSString *sanitizedMessage = [message stringByReplacingOccurrencesOfString:pattern withString:@"" options:NSRegularExpressionSearch range:(NSRange){0, message.length}]; + + if (sanitizedMessage.length > maxMessageLength) { + sanitizedMessage = [[sanitizedMessage substringToIndex:maxMessageLength] stringByAppendingString:@"..."]; } - NSMutableString *prettyStack = [@"\n" mutableCopy]; + + NSMutableString *prettyStack = [NSMutableString stringWithString:@"\n"]; for (NSDictionary *frame in stack) { [prettyStack appendFormat:@"%@@%@:%@\n", frame[@"methodName"], frame[@"lineNumber"], frame[@"column"]]; } @@ -77,13 +77,21 @@ - (instancetype)init NSString *name = [@"Unhandled JS Exception: " stringByAppendingString:sanitizedMessage]; [NSException raise:name format:@"Message: %@, stack: %@", message, prettyStack]; } + #endif + } RCT_EXPORT_METHOD(updateExceptionMessage:(NSString *)message stack:(NSArray *)stack) { - [[RCTRedBox sharedInstance] updateErrorMessage:message withStack:stack]; + +#if RCT_DEBUG // Red box is only available in debug mode + + [[RCTRedBox sharedInstance] updateErrorMessage:message withStack:stack]; + +#endif + } @end diff --git a/examples/node_modules/react-native/React/Modules/RCTSourceCode.m b/examples/node_modules/react-native/React/Modules/RCTSourceCode.m index 76e9190b..1b6eb842 100644 --- a/examples/node_modules/react-native/React/Modules/RCTSourceCode.m +++ b/examples/node_modules/react-native/React/Modules/RCTSourceCode.m @@ -10,12 +10,15 @@ #import "RCTSourceCode.h" #import "RCTAssert.h" +#import "RCTBridge.h" #import "RCTUtils.h" @implementation RCTSourceCode RCT_EXPORT_MODULE() +@synthesize bridge = _bridge; + RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback failureCallback:(RCTResponseSenderBlock)failureCallback) { @@ -24,7 +27,12 @@ @implementation RCTSourceCode } else { failureCallback(@[RCTMakeError(@"Source code is not available", nil, nil)]); } +} +- (NSDictionary *)constantsToExport +{ + NSString *URL = [self.bridge.bundleURL absoluteString] ?: @""; + return @{@"scriptURL": URL}; } @end diff --git a/examples/node_modules/react-native/React/Modules/RCTStatusBarManager.m b/examples/node_modules/react-native/React/Modules/RCTStatusBarManager.m index ad8ee1df..04bb3903 100644 --- a/examples/node_modules/react-native/React/Modules/RCTStatusBarManager.m +++ b/examples/node_modules/react-native/React/Modules/RCTStatusBarManager.m @@ -26,34 +26,33 @@ static BOOL RCTViewControllerBasedStatusBarAppearance() RCT_EXPORT_MODULE() +- (dispatch_queue_t)methodQueue +{ + return dispatch_get_main_queue(); +} + RCT_EXPORT_METHOD(setStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated) { - dispatch_async(dispatch_get_main_queue(), ^{ - - if (RCTViewControllerBasedStatusBarAppearance()) { - RCTLogError(@"RCTStatusBarManager module requires that the \ - UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); - } else { - [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle - animated:animated]; - } - }); + if (RCTViewControllerBasedStatusBarAppearance()) { + RCTLogError(@"RCTStatusBarManager module requires that the \ + UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); + } else { + [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle + animated:animated]; + } } RCT_EXPORT_METHOD(setHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation) { - dispatch_async(dispatch_get_main_queue(), ^{ - - if (RCTViewControllerBasedStatusBarAppearance()) { - RCTLogError(@"RCTStatusBarManager module requires that the \ - UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); - } else { - [[UIApplication sharedApplication] setStatusBarHidden:hidden - withAnimation:animation]; - } - }); + if (RCTViewControllerBasedStatusBarAppearance()) { + RCTLogError(@"RCTStatusBarManager module requires that the \ + UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); + } else { + [[UIApplication sharedApplication] setStatusBarHidden:hidden + withAnimation:animation]; + } } - (NSDictionary *)constantsToExport diff --git a/examples/node_modules/react-native/React/Modules/RCTTiming.m b/examples/node_modules/react-native/React/Modules/RCTTiming.m index aaab5fae..1d99c1a2 100644 --- a/examples/node_modules/react-native/React/Modules/RCTTiming.m +++ b/examples/node_modules/react-native/React/Modules/RCTTiming.m @@ -108,6 +108,11 @@ - (void)dealloc [[NSNotificationCenter defaultCenter] removeObserver:self]; } +- (dispatch_queue_t)methodQueue +{ + return dispatch_get_main_queue(); +} + - (BOOL)isValid { return _bridge != nil; @@ -137,8 +142,6 @@ - (void)startTimers - (void)didUpdateFrame:(RCTFrameUpdate *)update { - RCTAssertMainThread(); - NSMutableArray *timersToCall = [[NSMutableArray alloc] init]; for (RCTTimer *timer in _timers.allObjects) { if ([timer updateFoundNeedsJSUpdate]) { @@ -187,21 +190,17 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update interval:jsDuration targetTime:targetTime repeats:repeats]; - dispatch_async(dispatch_get_main_queue(), ^{ - _timers[callbackID] = timer; - [self startTimers]; - }); + _timers[callbackID] = timer; + [self startTimers]; } RCT_EXPORT_METHOD(deleteTimer:(NSNumber *)timerID) { if (timerID) { - dispatch_async(dispatch_get_main_queue(), ^{ - _timers[timerID] = nil; - if (_timers.count == 0) { - [self stopTimers]; - } - }); + _timers[timerID] = nil; + if (_timers.count == 0) { + [self stopTimers]; + } } else { RCTLogWarn(@"Called deleteTimer: with a nil timerID"); } diff --git a/examples/node_modules/react-native/React/Modules/RCTUIManager.h b/examples/node_modules/react-native/React/Modules/RCTUIManager.h index 4f42cd0b..6fa0e324 100644 --- a/examples/node_modules/react-native/React/Modules/RCTUIManager.h +++ b/examples/node_modules/react-native/React/Modules/RCTUIManager.h @@ -9,10 +9,10 @@ #import -#import "../Base/RCTBridge.h" -#import "../Base/RCTBridgeModule.h" -#import "../Base/RCTInvalidating.h" -#import "../Views/RCTViewManager.h" +#import "RCTBridge.h" +#import "RCTBridgeModule.h" +#import "RCTInvalidating.h" +#import "RCTViewManager.h" @protocol RCTScrollableProtocol; diff --git a/examples/node_modules/react-native/React/Modules/RCTUIManager.m b/examples/node_modules/react-native/React/Modules/RCTUIManager.m index b6a350dc..451a343d 100644 --- a/examples/node_modules/react-native/React/Modules/RCTUIManager.m +++ b/examples/node_modules/react-native/React/Modules/RCTUIManager.m @@ -18,7 +18,9 @@ #import "RCTAssert.h" #import "RCTBridge.h" #import "RCTConvert.h" +#import "RCTDefines.h" #import "RCTLog.h" +#import "RCTProfile.h" #import "RCTRootView.h" #import "RCTScrollableProtocol.h" #import "RCTShadowView.h" @@ -178,7 +180,7 @@ @interface RCTUIManager () @implementation RCTUIManager { - __weak dispatch_queue_t _shadowQueue; + dispatch_queue_t _shadowQueue; // Root views are only mutated on the shadow queue NSMutableSet *_rootViewTags; @@ -220,46 +222,34 @@ @implementation RCTUIManager return name; } +// TODO: only send name once instead of a dictionary of name and type keyed by name static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewName) { - NSMutableDictionary *nativeProps = [[NSMutableDictionary alloc] init]; - static const char *prefix = "getPropConfig"; - static const NSUInteger prefixLength = sizeof("getPropConfig") - 1; - unsigned int methodCount = 0; - Method *methods = class_copyMethodList(objc_getMetaClass(class_getName(managerClass)), &methodCount); - for (unsigned int i = 0; i < methodCount; i++) { + unsigned int count = 0; + Method *methods = class_copyMethodList(object_getClass(managerClass), &count); + NSMutableDictionary *props = [[NSMutableDictionary alloc] initWithCapacity:count]; + for (unsigned int i = 0; i < count; i++) { Method method = methods[i]; - SEL getInfo = method_getName(method); - const char *selName = sel_getName(getInfo); - if (strlen(selName) > prefixLength && strncmp(selName, prefix, prefixLength) == 0) { - NSDictionary *info = ((NSDictionary *(*)(id, SEL))method_getImplementation(method))(managerClass, getInfo); - nativeProps[info[@"name"]] = info; + NSString *methodName = NSStringFromSelector(method_getName(method)); + if ([methodName hasPrefix:@"getPropConfig"]) { + NSRange nameRange = [methodName rangeOfString:@"_"]; + if (nameRange.length) { + NSString *name = [methodName substringFromIndex:nameRange.location + 1]; + NSString *type = [managerClass valueForKey:methodName]; + props[name] = type; + } } } - return @{ - @"uiViewClassName": viewName, - @"nativeProps": nativeProps - }; -} - -/** - * This private constructor should only be called when creating - * isolated UIImanager instances for testing. Normal initialization - * is via -init:, which is called automatically by the bridge. - */ -- (instancetype)initWithShadowQueue:(dispatch_queue_t)shadowQueue -{ - if ((self = [self init])) { - _shadowQueue = shadowQueue; - _viewManagers = [[NSMutableDictionary alloc] init]; - } - return self; + free(methods); + return props; } - (instancetype)init { if ((self = [super init])) { + _shadowQueue = dispatch_queue_create("com.facebook.React.ShadowQueue", DISPATCH_QUEUE_SERIAL); + _pendingUIBlocksLock = [[NSLock alloc] init]; _defaultShadowViews = [[NSMutableDictionary alloc] init]; @@ -310,7 +300,6 @@ - (void)setBridge:(RCTBridge *)bridge RCTAssert(_bridge == nil, @"Should not re-use same UIIManager instance"); _bridge = bridge; - _shadowQueue = _bridge.shadowQueue; _shadowViewRegistry = [[RCTSparseArray alloc] init]; // Get view managers from bridge @@ -328,6 +317,11 @@ - (void)setBridge:(RCTBridge *)bridge _viewConfigs = [viewConfigs copy]; } +- (dispatch_queue_t)methodQueue +{ + return _shadowQueue; +} + - (void)registerRootView:(UIView *)rootView; { RCTAssertMainThread(); @@ -366,7 +360,7 @@ - (void)setFrame:(CGRect)frame forRootView:(UIView *)rootView NSNumber *reactTag = rootView.reactTag; RCTAssert(RCTIsReactRootView(reactTag), @"Specified view %@ is not a root view", reactTag); - dispatch_async(_bridge.shadowQueue, ^{ + dispatch_async(_shadowQueue, ^{ RCTShadowView *rootShadowView = _shadowViewRegistry[reactTag]; RCTAssert(rootShadowView != nil, @"Could not locate root view with tag #%@", reactTag); rootShadowView.frame = frame; @@ -396,15 +390,15 @@ - (void)_purgeChildren:(NSArray *)children fromRegistry:(RCTSparseArray *)regist - (void)addUIBlock:(RCTViewManagerUIBlock)block { - RCTAssert(![NSThread isMainThread], @"This method should only be called on the shadow thread"); + if (!self.isValid) { + return; + } __weak RCTUIManager *weakViewManager = self; - __weak RCTSparseArray *weakViewRegistry = _viewRegistry; dispatch_block_t outerBlock = ^{ RCTUIManager *strongViewManager = weakViewManager; - RCTSparseArray *strongViewRegistry = weakViewRegistry; - if (strongViewManager && strongViewRegistry) { - block(strongViewManager, strongViewRegistry); + if (strongViewManager && strongViewManager.isValid) { + block(strongViewManager, strongViewManager->_viewRegistry); } }; @@ -415,7 +409,7 @@ - (void)addUIBlock:(RCTViewManagerUIBlock)block - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTShadowView *)rootShadowView { - RCTAssert(![NSThread isMainThread], @"This should never be executed on main thread."); + RCTAssert(![NSThread isMainThread], @"Should be called on shadow thread"); NSMutableSet *viewsWithNewFrames = [NSMutableSet setWithCapacity:1]; @@ -677,6 +671,8 @@ - (void)_manageChildren:(NSNumber *)containerReactTag [self _purgeChildren:permanentlyRemovedChildren fromRegistry:registry]; + // TODO (#5906496): optimize all these loops - constantly calling array.count is not efficient + // Figure out what to insert - merge temporary inserts and adds NSMutableDictionary *destinationsToChildrenToAdd = [NSMutableDictionary dictionary]; for (NSInteger index = 0, length = temporarilyRemovedChildren.count; index < length; index++) { @@ -708,20 +704,16 @@ static BOOL RCTCallPropertySetter(NSString *key, SEL setter, id value, id view, ((void (*)(id, SEL, id, id, id))objc_msgSend)(manager, setter, value, view, defaultView); }; -#if DEBUG - - NSString *viewName = RCTViewNameForModuleName(RCTBridgeModuleNameForClass([manager class])); - NSString *logPrefix = [NSString stringWithFormat: - @"Error setting property '%@' of %@ with tag #%@: ", - key, viewName, [view reactTag]]; - - RCTPerformBlockWithLogPrefix(block, logPrefix); - -#else + if (RCT_DEBUG) { + NSString *viewName = RCTViewNameForModuleName(RCTBridgeModuleNameForClass([manager class])); + NSString *logPrefix = [NSString stringWithFormat: + @"Error setting property '%@' of %@ with tag #%@: ", + key, viewName, [view reactTag]]; - block(); - -#endif + RCTPerformBlockWithLogPrefix(block, logPrefix); + } else { + block(); + } return YES; } @@ -884,8 +876,6 @@ - (void)batchDidComplete - (void)flushUIBlocks { - RCTAssert(![NSThread isMainThread], @"Should be called on shadow thread"); - // First copy the previous blocks into a temporary variable, then reset the // pending blocks to a new array. This guards against mutation while // processing the pending blocks in another thread. @@ -896,9 +886,13 @@ - (void)flushUIBlocks // Execute the previously queued UI blocks dispatch_async(dispatch_get_main_queue(), ^{ + RCTProfileBeginEvent(); for (dispatch_block_t block in previousPendingUIBlocks) { block(); } + RCTProfileEndEvent(@"UIManager flushUIBlocks", @"objc_call", @{ + @"count": @(previousPendingUIBlocks.count), + }); }); } @@ -1007,11 +1001,12 @@ static void RCTMeasureLayout(RCTShadowView *view, * Only layouts for views that are within the rect passed in are returned. Invokes the error callback if the * passed in parent view does not exist. Invokes the supplied callback with the array of computed layouts. */ -RCT_EXPORT_METHOD(measureViewsInRect:(NSDictionary *)rect +RCT_EXPORT_METHOD(measureViewsInRect:(id)rectJSON parentView:(NSNumber *)reactTag errorCallback:(RCTResponseSenderBlock)errorCallback callback:(RCTResponseSenderBlock)callback) { + CGRect rect = [RCTConvert CGRect:rectJSON]; RCTShadowView *shadowView = _shadowViewRegistry[reactTag]; if (!shadowView) { RCTLogError(@"Attempting to measure view that does not exist (tag #%@)", reactTag); @@ -1019,7 +1014,7 @@ static void RCTMeasureLayout(RCTShadowView *view, } NSArray *childShadowViews = [shadowView reactSubviews]; NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:[childShadowViews count]]; - CGRect layoutRect = [RCTConvert CGRect:rect]; + [childShadowViews enumerateObjectsUsingBlock:^(RCTShadowView *childShadowView, NSUInteger idx, BOOL *stop) { CGRect childLayout = [childShadowView measureLayoutRelativeToAncestor:shadowView]; @@ -1034,10 +1029,11 @@ static void RCTMeasureLayout(RCTShadowView *view, CGFloat width = childLayout.size.width; CGFloat height = childLayout.size.height; - if (leftOffset <= layoutRect.origin.x + layoutRect.size.width && - leftOffset + width >= layoutRect.origin.x && - topOffset <= layoutRect.origin.y + layoutRect.size.height && - topOffset + height >= layoutRect.origin.y) { + if (leftOffset <= rect.origin.x + rect.size.width && + leftOffset + width >= rect.origin.x && + topOffset <= rect.origin.y + rect.size.height && + topOffset + height >= rect.origin.y) { + // This view is within the layout rect NSDictionary *result = @{@"index": @(idx), @"left": @(leftOffset), @@ -1106,8 +1102,9 @@ static void RCTMeasureLayout(RCTShadowView *view, } RCT_EXPORT_METHOD(zoomToRect:(NSNumber *)reactTag - withRect:(CGRect)rect) + withRect:(id)rectJSON) { + CGRect rect = [RCTConvert CGRect:rectJSON]; [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ UIView *view = viewRegistry[reactTag]; if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) { @@ -1389,17 +1386,22 @@ - (NSDictionary *)constantsToExport } mutableCopy]; [_viewManagers enumerateKeysAndObjectsUsingBlock:^(NSString *name, RCTViewManager *manager, BOOL *stop) { + NSMutableDictionary *constantsNamespace = [NSMutableDictionary dictionaryWithDictionary:allJSConstants[name]]; + + // Add custom constants // TODO: should these be inherited? NSDictionary *constants = RCTClassOverridesInstanceMethod([manager class], @selector(constantsToExport)) ? [manager constantsToExport] : nil; if (constants.count) { - NSMutableDictionary *constantsNamespace = [NSMutableDictionary dictionaryWithDictionary:allJSConstants[name]]; RCTAssert(constantsNamespace[@"Constants"] == nil , @"Cannot redefine Constants in namespace: %@", name); // add an additional 'Constants' namespace for each class constantsNamespace[@"Constants"] = constants; - allJSConstants[name] = [constantsNamespace copy]; } + + // Add native props + constantsNamespace[@"nativeProps"] = _viewConfigs[name]; + + allJSConstants[name] = [constantsNamespace copy]; }]; - allJSConstants[@"viewConfigs"] = _viewConfigs; return allJSConstants; } @@ -1408,8 +1410,7 @@ - (NSDictionary *)constantsToExport errorCallback:(RCTResponseSenderBlock)errorCallback) { if (_nextLayoutAnimation) { - RCTLogWarn(@"Warning: Overriding previous layout animation with new one before the first began:\n%@ -> %@.", - _nextLayoutAnimation, config); + RCTLogWarn(@"Warning: Overriding previous layout animation with new one before the first began:\n%@ -> %@.", _nextLayoutAnimation, config); } if (config[@"delete"] != nil) { RCTLogError(@"LayoutAnimation only supports create and update right now. Config: %@", config); diff --git a/examples/node_modules/react-native/React/React.xcodeproj/project.pbxproj b/examples/node_modules/react-native/React/React.xcodeproj/project.pbxproj index 294bf414..3364cce7 100644 --- a/examples/node_modules/react-native/React/React.xcodeproj/project.pbxproj +++ b/examples/node_modules/react-native/React/React.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 137327E91AA5CF210034F82E /* RCTTabBarItemManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E41AA5CF210034F82E /* RCTTabBarItemManager.m */; }; 137327EA1AA5CF210034F82E /* RCTTabBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E61AA5CF210034F82E /* RCTTabBarManager.m */; }; 13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */; }; + 13AF20451AE707F9005F5298 /* RCTSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 13AF20441AE707F9005F5298 /* RCTSlider.m */; }; 13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FE81A69327A00A75B9A /* RCTAlertManager.m */; }; 13B07FF01A69327A00A75B9A /* RCTExceptionsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FEA1A69327A00A75B9A /* RCTExceptionsManager.m */; }; 13B07FF21A69327A00A75B9A /* RCTTiming.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FEE1A69327A00A75B9A /* RCTTiming.m */; }; @@ -47,6 +48,7 @@ 14F3620D1AABD06A001CE568 /* RCTSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F362081AABD06A001CE568 /* RCTSwitch.m */; }; 14F3620E1AABD06A001CE568 /* RCTSwitchManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F3620A1AABD06A001CE568 /* RCTSwitchManager.m */; }; 14F484561AABFCE100FDF6B9 /* RCTSliderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F484551AABFCE100FDF6B9 /* RCTSliderManager.m */; }; + 14F4D38B1AE1B7E40049C042 /* RCTProfile.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F4D38A1AE1B7E40049C042 /* RCTProfile.m */; }; 58114A161AAE854800E7D092 /* RCTPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A131AAE854800E7D092 /* RCTPicker.m */; }; 58114A171AAE854800E7D092 /* RCTPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A151AAE854800E7D092 /* RCTPickerManager.m */; }; 58114A501AAE93D500E7D092 /* RCTAsyncLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */; }; @@ -107,6 +109,9 @@ 137327E61AA5CF210034F82E /* RCTTabBarManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTabBarManager.m; sourceTree = ""; }; 13A1F71C1A75392D00D3D453 /* RCTKeyCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTKeyCommands.h; sourceTree = ""; }; 13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTKeyCommands.m; sourceTree = ""; }; + 13AF1F851AE6E777005F5298 /* RCTDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDefines.h; sourceTree = ""; }; + 13AF20431AE707F8005F5298 /* RCTSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSlider.h; sourceTree = ""; }; + 13AF20441AE707F9005F5298 /* RCTSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSlider.m; sourceTree = ""; }; 13B07FC71A68125100A75B9A /* Layout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Layout.c; sourceTree = ""; }; 13B07FC81A68125100A75B9A /* Layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Layout.h; sourceTree = ""; }; 13B07FE71A69327A00A75B9A /* RCTAlertManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAlertManager.h; sourceTree = ""; }; @@ -165,6 +170,8 @@ 14F3620A1AABD06A001CE568 /* RCTSwitchManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSwitchManager.m; sourceTree = ""; }; 14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSliderManager.h; sourceTree = ""; }; 14F484551AABFCE100FDF6B9 /* RCTSliderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSliderManager.m; sourceTree = ""; }; + 14F4D3891AE1B7E40049C042 /* RCTProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTProfile.h; sourceTree = ""; }; + 14F4D38A1AE1B7E40049C042 /* RCTProfile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTProfile.m; sourceTree = ""; }; 58114A121AAE854800E7D092 /* RCTPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPicker.h; sourceTree = ""; }; 58114A131AAE854800E7D092 /* RCTPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPicker.m; sourceTree = ""; }; 58114A141AAE854800E7D092 /* RCTPickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPickerManager.h; sourceTree = ""; }; @@ -290,6 +297,8 @@ 13C325271AA63B6A0048765F /* RCTScrollableProtocol.h */, 13E0674B1A70F44B002CDEE1 /* RCTShadowView.h */, 13E0674C1A70F44B002CDEE1 /* RCTShadowView.m */, + 13AF20431AE707F8005F5298 /* RCTSlider.h */, + 13AF20441AE707F9005F5298 /* RCTSlider.m */, 14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */, 14F484551AABFCE100FDF6B9 /* RCTSliderManager.m */, 14F362071AABD06A001CE568 /* RCTSwitch.h */, @@ -372,6 +381,7 @@ 830BA4541A8E3BDA00D53203 /* RCTCache.m */, 83CBBACA1A6023D300E9B192 /* RCTConvert.h */, 83CBBACB1A6023D300E9B192 /* RCTConvert.m */, + 13AF1F851AE6E777005F5298 /* RCTDefines.h */, 83CBBA651A601EF300E9B192 /* RCTEventDispatcher.h */, 83CBBA661A601EF300E9B192 /* RCTEventDispatcher.m */, 83CBBA4C1A601E3B00E9B192 /* RCTInvalidating.h */, @@ -393,6 +403,8 @@ 83CBBA4F1A601E3B00E9B192 /* RCTUtils.h */, 83CBBA501A601E3B00E9B192 /* RCTUtils.m */, 1436DD071ADE7AA000A5ED7D /* RCTFrameUpdate.h */, + 14F4D3891AE1B7E40049C042 /* RCTProfile.h */, + 14F4D38A1AE1B7E40049C042 /* RCTProfile.m */, ); path = Base; sourceTree = ""; @@ -481,8 +493,10 @@ 13B07FF01A69327A00A75B9A /* RCTExceptionsManager.m in Sources */, 83CBBA5A1A601E9000E9B192 /* RCTRedBox.m in Sources */, 83CBBA511A601E3B00E9B192 /* RCTAssert.m in Sources */, + 13AF20451AE707F9005F5298 /* RCTSlider.m in Sources */, 58114A501AAE93D500E7D092 /* RCTAsyncLocalStorage.m in Sources */, 832348161A77A5AA00B55238 /* Layout.c in Sources */, + 14F4D38B1AE1B7E40049C042 /* RCTProfile.m in Sources */, 14F3620D1AABD06A001CE568 /* RCTSwitch.m in Sources */, 14F3620E1AABD06A001CE568 /* RCTSwitchManager.m in Sources */, 13B080201A69489C00A75B9A /* RCTUIActivityIndicatorViewManager.m in Sources */, @@ -611,6 +625,7 @@ 83CBBA401A601D0F00E9B192 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -622,6 +637,7 @@ ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; SKIP_INSTALL = YES; }; name = Debug; @@ -629,6 +645,7 @@ 83CBBA411A601D0F00E9B192 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_STATIC_ANALYZER_MODE = deep; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -636,6 +653,7 @@ ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = NO; SKIP_INSTALL = YES; }; name = Release; diff --git a/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/React.xcscheme b/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/React.xcscheme index da672896..051ba5e5 100644 --- a/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/React.xcscheme +++ b/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/React.xcscheme @@ -1,6 +1,6 @@ React.xcscheme orderHint - 72 + 2 SuppressBuildableAutocreation diff --git a/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist index 56da12ca..8c5de983 100644 --- a/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/examples/node_modules/react-native/React/React.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist @@ -2,14 +2,6 @@ - SchemeUserState - - React.xcscheme - - orderHint - 2 - - SuppressBuildableAutocreation 83CBBA2D1A601D0E00E9B192 diff --git a/examples/node_modules/react-native/React/Views/RCTMapManager.m b/examples/node_modules/react-native/React/Views/RCTMapManager.m index 8de35141..f9a6b917 100644 --- a/examples/node_modules/react-native/React/Views/RCTMapManager.m +++ b/examples/node_modules/react-native/React/Views/RCTMapManager.m @@ -67,15 +67,13 @@ - (void)mapView:(RCTMap *)mapView regionWillChangeAnimated:(BOOL)animated { [self _regionChanged:mapView]; - if (animated) { - mapView.regionChangeObserveTimer = [NSTimer timerWithTimeInterval:RCTMapRegionChangeObserveInterval - target:self - selector:@selector(_onTick:) - userInfo:@{ RCTMapViewKey: mapView } - repeats:YES]; - - [[NSRunLoop mainRunLoop] addTimer:mapView.regionChangeObserveTimer forMode:NSRunLoopCommonModes]; - } + mapView.regionChangeObserveTimer = [NSTimer timerWithTimeInterval:RCTMapRegionChangeObserveInterval + target:self + selector:@selector(_onTick:) + userInfo:@{ RCTMapViewKey: mapView } + repeats:YES]; + + [[NSRunLoop mainRunLoop] addTimer:mapView.regionChangeObserveTimer forMode:NSRunLoopCommonModes]; } - (void)mapView:(RCTMap *)mapView regionDidChangeAnimated:(BOOL)animated diff --git a/examples/node_modules/react-native/React/Views/RCTScrollView.m b/examples/node_modules/react-native/React/Views/RCTScrollView.m index 0376d2a9..1b317006 100644 --- a/examples/node_modules/react-native/React/Views/RCTScrollView.m +++ b/examples/node_modules/react-native/React/Views/RCTScrollView.m @@ -175,7 +175,7 @@ - (void)dockClosestSectionHeader scrollBounds.origin.y += self.contentInset.top; NSInteger i = 0; - for (UIView *subview in contentView.subviews) { + for (UIView *subview in contentView.reactSubviews) { CGRect rowFrame = [RCTCustomScrollView _calculateUntransformedFrame:subview]; if (CGRectIntersectsRect(scrollBounds, rowFrame)) { firstIndexInView = i; @@ -198,8 +198,8 @@ - (void)dockClosestSectionHeader NSInteger nextDockedIndex = (stickyHeaderii < _stickyHeaderIndices.count - 1) ? [_stickyHeaderIndices[stickyHeaderii + 1] integerValue] : -1; - UIView *currentHeader = contentView.subviews[currentlyDockedIndex]; - UIView *previousHeader = previouslyDockedIndex >= 0 ? contentView.subviews[previouslyDockedIndex] : nil; + UIView *currentHeader = contentView.reactSubviews[currentlyDockedIndex]; + UIView *previousHeader = previouslyDockedIndex >= 0 ? contentView.reactSubviews[previouslyDockedIndex] : nil; CGRect curFrame = [RCTCustomScrollView _calculateUntransformedFrame:currentHeader]; if (previousHeader) { @@ -210,7 +210,7 @@ - (void)dockClosestSectionHeader previousHeader.transform = CGAffineTransformMakeTranslation(0, yOffset); } - UIView *nextHeader = nextDockedIndex >= 0 ? contentView.subviews[nextDockedIndex] : nil; + UIView *nextHeader = nextDockedIndex >= 0 ? contentView.reactSubviews[nextDockedIndex] : nil; CGRect nextFrame = [RCTCustomScrollView _calculateUntransformedFrame:nextHeader]; if (curFrame.origin.y < scrollBounds.origin.y) { diff --git a/examples/node_modules/react-native/React/Views/RCTShadowView.h b/examples/node_modules/react-native/React/Views/RCTShadowView.h index 6efb0c1d..8d68855f 100644 --- a/examples/node_modules/react-native/React/Views/RCTShadowView.h +++ b/examples/node_modules/react-native/React/Views/RCTShadowView.h @@ -9,8 +9,7 @@ #import -#import "../Layout/Layout.h" - +#import "Layout.h" #import "RCTViewNodeProtocol.h" @class RCTSparseArray; diff --git a/examples/node_modules/react-native/React/Views/RCTSlider.h b/examples/node_modules/react-native/React/Views/RCTSlider.h new file mode 100644 index 00000000..916419a2 --- /dev/null +++ b/examples/node_modules/react-native/React/Views/RCTSlider.h @@ -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 + +@interface RCTSlider : UISlider + +@end diff --git a/examples/node_modules/react-native/React/Views/RCTSlider.m b/examples/node_modules/react-native/React/Views/RCTSlider.m new file mode 100644 index 00000000..04e8d841 --- /dev/null +++ b/examples/node_modules/react-native/React/Views/RCTSlider.m @@ -0,0 +1,35 @@ +/** + * 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 "RCTSlider.h" + +@implementation RCTSlider +{ + float _unclippedValue; +} + +- (void)setValue:(float)value +{ + _unclippedValue = value; + super.value = value; +} + +- (void)setMinimumValue:(float)minimumValue +{ + super.minimumValue = minimumValue; + super.value = _unclippedValue; +} + +- (void)setMaximumValue:(float)maximumValue +{ + super.maximumValue = maximumValue; + super.value = _unclippedValue; +} + +@end diff --git a/examples/node_modules/react-native/React/Views/RCTSliderManager.m b/examples/node_modules/react-native/React/Views/RCTSliderManager.m index 58b763b9..f57e1f36 100644 --- a/examples/node_modules/react-native/React/Views/RCTSliderManager.m +++ b/examples/node_modules/react-native/React/Views/RCTSliderManager.m @@ -11,6 +11,7 @@ #import "RCTBridge.h" #import "RCTEventDispatcher.h" +#import "RCTSlider.h" #import "UIView+React.h" @implementation RCTSliderManager @@ -19,36 +20,37 @@ @implementation RCTSliderManager - (UIView *)view { - UISlider *slider = [[UISlider alloc] init]; + RCTSlider *slider = [[RCTSlider alloc] init]; [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged]; [slider addTarget:self action:@selector(sliderTouchEnd:) forControlEvents:UIControlEventTouchUpInside]; return slider; } -- (void)sliderValueChanged:(UISlider *)sender +static void RCTSendSliderEvent(RCTSliderManager *self, UISlider *sender, BOOL continuous) { NSDictionary *event = @{ @"target": sender.reactTag, @"value": @(sender.value), - @"continuous": @YES, + @"continuous": @(continuous), }; [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event]; } -- (void)sliderTouchEnd:(UISlider *)sender +- (void)sliderValueChanged:(UISlider *)sender { - NSDictionary *event = @{ - @"target": sender.reactTag, - @"value": @(sender.value), - @"continuous": @NO, - }; + RCTSendSliderEvent(self, sender, YES); +} - [self.bridge.eventDispatcher sendInputEventWithName:@"topChange" body:event]; +- (void)sliderTouchEnd:(UISlider *)sender +{ + RCTSendSliderEvent(self, sender, NO); } RCT_EXPORT_VIEW_PROPERTY(value, float); RCT_EXPORT_VIEW_PROPERTY(minimumValue, float); RCT_EXPORT_VIEW_PROPERTY(maximumValue, float); +RCT_EXPORT_VIEW_PROPERTY(minimumTrackTintColor, UIColor); +RCT_EXPORT_VIEW_PROPERTY(maximumTrackTintColor, UIColor); @end diff --git a/examples/node_modules/react-native/React/Views/RCTSwitchManager.m b/examples/node_modules/react-native/React/Views/RCTSwitchManager.m index eb0d626e..c60d83e8 100644 --- a/examples/node_modules/react-native/React/Views/RCTSwitchManager.m +++ b/examples/node_modules/react-native/React/Views/RCTSwitchManager.m @@ -42,7 +42,14 @@ - (void)onChange:(RCTSwitch *)sender RCT_EXPORT_VIEW_PROPERTY(onTintColor, UIColor); RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor); RCT_EXPORT_VIEW_PROPERTY(thumbTintColor, UIColor); -RCT_EXPORT_VIEW_PROPERTY(on, BOOL); -RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL); +RCT_REMAP_VIEW_PROPERTY(value, on, BOOL); +RCT_CUSTOM_VIEW_PROPERTY(disabled, BOOL, RCTSwitch) +{ + if (json) { + view.enabled = !([RCTConvert BOOL:json]); + } else { + view.enabled = defaultView.enabled; + } +} @end diff --git a/examples/node_modules/react-native/React/Views/RCTTabBarItemManager.m b/examples/node_modules/react-native/React/Views/RCTTabBarItemManager.m index 8bbe782b..cdfa8669 100644 --- a/examples/node_modules/react-native/React/Views/RCTTabBarItemManager.m +++ b/examples/node_modules/react-native/React/Views/RCTTabBarItemManager.m @@ -24,7 +24,7 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(selected, BOOL); RCT_EXPORT_VIEW_PROPERTY(icon, NSString); RCT_REMAP_VIEW_PROPERTY(selectedIcon, barItem.selectedImage, UIImage); -RCT_REMAP_VIEW_PROPERTY(badgeValue, barItem.badgeValue, NSString); +RCT_REMAP_VIEW_PROPERTY(badge, barItem.badgeValue, NSString); RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem) { view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title; diff --git a/examples/node_modules/react-native/React/Views/RCTViewManager.h b/examples/node_modules/react-native/React/Views/RCTViewManager.h index 74c7bbd8..77dc6669 100644 --- a/examples/node_modules/react-native/React/Views/RCTViewManager.h +++ b/examples/node_modules/react-native/React/Views/RCTViewManager.h @@ -9,9 +9,9 @@ #import -#import "../Base/RCTBridgeModule.h" -#import "../Base/RCTConvert.h" -#import "../Base/RCTLog.h" +#import "RCTBridgeModule.h" +#import "RCTConvert.h" +#import "RCTLog.h" @class RCTBridge; @class RCTEventDispatcher; @@ -109,8 +109,7 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v * within the view or shadowView. */ #define RCT_REMAP_VIEW_PROPERTY(name, keyPath, type) \ -RCT_EXPORT_VIEW_PROP_CONFIG(name, type) \ -- (void)set_##name:(id)json forView:(id)view withDefaultView:(id)defaultView { \ +RCT_CUSTOM_VIEW_PROPERTY(name, type, UIView) { \ if ((json && !RCTSetProperty(view, @#keyPath, @selector(type:), json)) || \ (!json && !RCTCopyProperty(view, defaultView, @#keyPath))) { \ RCTLogError(@"%@ does not have setter for `%s` property", [view class], #name); \ @@ -118,8 +117,7 @@ RCT_EXPORT_VIEW_PROP_CONFIG(name, type) \ } #define RCT_REMAP_SHADOW_PROPERTY(name, keyPath, type) \ -RCT_EXPORT_SHADOW_PROP_CONFIG(name, type) \ -- (void)set_##name:(id)json forShadowView:(id)view withDefaultView:(id)defaultView { \ +RCT_CUSTOM_SHADOW_PROPERTY(name, type, RCTShadowView) { \ if ((json && !RCTSetProperty(view, @#keyPath, @selector(type:), json)) || \ (!json && !RCTCopyProperty(view, defaultView, @#keyPath))) { \ RCTLogError(@"%@ does not have setter for `%s` property", [view class], #name); \ @@ -132,11 +130,11 @@ RCT_EXPORT_SHADOW_PROP_CONFIG(name, type) \ * refer to "json", "view" and "defaultView" to implement the required logic. */ #define RCT_CUSTOM_VIEW_PROPERTY(name, type, viewClass) \ -RCT_EXPORT_VIEW_PROP_CONFIG(name, type) \ ++ (NSString *)getPropConfigView_##name { return @#type; } \ - (void)set_##name:(id)json forView:(viewClass *)view withDefaultView:(viewClass *)defaultView #define RCT_CUSTOM_SHADOW_PROPERTY(name, type, viewClass) \ -RCT_EXPORT_SHADOW_PROP_CONFIG(name, type) \ ++ (NSString *)getPropConfigShadow_##name { return @#type; } \ - (void)set_##name:(id)json forShadowView:(viewClass *)view withDefaultView:(viewClass *)defaultView /** @@ -164,17 +162,4 @@ RCT_EXPORT_SHADOW_PROP_CONFIG(name, type) \ [self set_##newName:json forView:view withDefaultView:defaultView]; \ } -/** - * PROP_CONFIG macros should only be paired with property setters. - */ -#define RCT_EXPORT_VIEW_PROP_CONFIG(name, type) \ -+ (NSDictionary *)getPropConfigView_##name { \ - return @{@"name": @#name, @"type": @#type}; \ -} - -#define RCT_EXPORT_SHADOW_PROP_CONFIG(name, type) \ -+ (NSDictionary *)getPropConfigShadow_##name { \ - return @{@"name": @#name, @"type": @#type}; \ -} - @end diff --git a/examples/node_modules/react-native/React/Views/RCTViewManager.m b/examples/node_modules/react-native/React/Views/RCTViewManager.m index 3c848537..8388b83c 100644 --- a/examples/node_modules/react-native/React/Views/RCTViewManager.m +++ b/examples/node_modules/react-native/React/Views/RCTViewManager.m @@ -14,6 +14,7 @@ #import "RCTEventDispatcher.h" #import "RCTLog.h" #import "RCTShadowView.h" +#import "RCTUIManager.h" #import "RCTUtils.h" #import "RCTView.h" @@ -23,6 +24,11 @@ @implementation RCTViewManager RCT_EXPORT_MODULE() +- (dispatch_queue_t)methodQueue +{ + return [_bridge.uiManager methodQueue]; +} + - (UIView *)view { return [[RCTView alloc] init]; diff --git a/examples/node_modules/react-native/React/Views/RCTWebView.m b/examples/node_modules/react-native/React/Views/RCTWebView.m index bb9bb2ac..56cda0c8 100644 --- a/examples/node_modules/react-native/React/Views/RCTWebView.m +++ b/examples/node_modules/react-native/React/Views/RCTWebView.m @@ -31,6 +31,7 @@ @implementation RCTWebView - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher { if ((self = [super initWithFrame:CGRectZero])) { + super.backgroundColor = [UIColor clearColor]; _automaticallyAdjustContentInsets = YES; _contentInset = UIEdgeInsetsZero; _eventDispatcher = eventDispatcher; @@ -95,6 +96,18 @@ - (void)setContentInset:(UIEdgeInsets)contentInset updateOffset:NO]; } +- (void)setBackgroundColor:(UIColor *)backgroundColor +{ + CGFloat alpha = CGColorGetAlpha(backgroundColor.CGColor); + self.opaque = _webView.opaque = (alpha == 1.0); + _webView.backgroundColor = backgroundColor; +} + +- (UIColor *)backgroundColor +{ + return _webView.backgroundColor; +} + - (NSMutableDictionary *)baseEvent { NSURL *url = _webView.request.URL; diff --git a/examples/node_modules/react-native/React/Views/RCTWebViewManager.m b/examples/node_modules/react-native/React/Views/RCTWebViewManager.m index e25a7da6..01528587 100644 --- a/examples/node_modules/react-native/React/Views/RCTWebViewManager.m +++ b/examples/node_modules/react-native/React/Views/RCTWebViewManager.m @@ -25,6 +25,8 @@ - (UIView *)view RCT_REMAP_VIEW_PROPERTY(url, URL, NSURL); RCT_REMAP_VIEW_PROPERTY(html, HTML, NSString); +RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL); +RCT_REMAP_VIEW_PROPERTY(scrollEnabled, _webView.scrollView.scrollEnabled, BOOL); RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets); RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL); RCT_EXPORT_VIEW_PROPERTY(shouldInjectAJAXHandler, BOOL); diff --git a/examples/node_modules/react-native/React/Views/RCTWrapperViewController.m b/examples/node_modules/react-native/React/Views/RCTWrapperViewController.m index f9f35163..53c2f16a 100644 --- a/examples/node_modules/react-native/React/Views/RCTWrapperViewController.m +++ b/examples/node_modules/react-native/React/Views/RCTWrapperViewController.m @@ -80,10 +80,7 @@ - (void)viewWillAppear:(BOOL)animated bar.barTintColor = _navItem.barTintColor; } if (_navItem.tintColor) { - BOOL canSetTintColor = _navItem.barTintColor == nil; - if (canSetTintColor) { - bar.tintColor = _navItem.tintColor; - } + bar.tintColor = _navItem.tintColor; } if (_navItem.titleTextColor) { [bar setTitleTextAttributes:@{NSForegroundColorAttributeName : _navItem.titleTextColor}]; diff --git a/examples/node_modules/react-native/local-cli/bundle.js b/examples/node_modules/react-native/local-cli/bundle.js new file mode 100644 index 00000000..f7748010 --- /dev/null +++ b/examples/node_modules/react-native/local-cli/bundle.js @@ -0,0 +1,65 @@ +var http = require('http'); +var fs = require('fs'); +var path = require('path'); +var chalk = require('chalk'); +var blacklist = require('../packager/blacklist.js'); +var ReactPackager = require('../packager/react-packager'); + +var OUT_PATH = 'iOS/main.jsbundle'; + +function getBundle(flags) { + + var options = { + projectRoots: [path.resolve(__dirname, '../../..')], + transformModulePath: require.resolve('../packager/transformer.js'), + assetRoots: [path.resolve(__dirname, '../../..')], + cacheVersion: '2', + blacklistRE: blacklist('ios') + }; + + var url = '/index.ios.bundle?dev=' + flags.dev; + + console.log('Building package...'); + ReactPackager.buildPackageFromUrl(options, url) + .done(function(bundle) { + console.log('Build complete'); + fs.writeFile(OUT_PATH, bundle.getSource({ + inlineSourceMap: false, + minify: flags.minify + }), function(err) { + if (err) { + console.log(chalk.red('Error saving bundle to disk')); + throw err; + } else { + console.log('Successfully saved bundle to ' + OUT_PATH); + } + }); + }); +} + +function showHelp() { + console.log([ + 'Usage: react-native bundle [options]', + '', + 'Options:', + ' --dev\t\tsets DEV flag to true', + ' --minify\tminify js bundle' + ].join('\n')); + process.exit(1); +} + +module.exports = { + init: function(args) { + var flags = { + help: args.indexOf('--help') !== -1, + dev: args.indexOf('--dev') !== -1, + minify: args.indexOf('--minify') !== -1 + } + + if (flags.help) { + showHelp(); + } else { + getBundle(flags); + } + } +} diff --git a/examples/node_modules/react-native/local-cli/cli.js b/examples/node_modules/react-native/local-cli/cli.js index 48dc9e5d..99d05c7c 100644 --- a/examples/node_modules/react-native/local-cli/cli.js +++ b/examples/node_modules/react-native/local-cli/cli.js @@ -7,6 +7,7 @@ var spawn = require('child_process').spawn; var path = require('path'); var install = require('./install.js'); +var bundle = require('./bundle.js'); function printUsage() { console.log([ @@ -14,7 +15,8 @@ function printUsage() { '', 'Commands:', ' start: starts the webserver', - ' install: installs npm react components' + ' install: installs npm react components', + ' bundle: builds the javascript bundle for offline use' ].join('\n')); process.exit(1); } @@ -36,6 +38,9 @@ function run() { case 'install': install.init(); break; + case 'bundle': + bundle.init(args); + break; default: console.error('Command `%s` unrecognized', args[0]); printUsage(); diff --git a/examples/node_modules/react-native/node_modules/absolute-path/package.json b/examples/node_modules/react-native/node_modules/absolute-path/package.json index d8132559..78a88d3c 100644 --- a/examples/node_modules/react-native/node_modules/absolute-path/package.json +++ b/examples/node_modules/react-native/node_modules/absolute-path/package.json @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/filearts/node-absolute-path" + "url": "git+https://github.com/filearts/node-absolute-path.git" }, "keywords": [ "path", @@ -43,5 +43,6 @@ ], "directories": {}, "_shasum": "a78762fbdadfb5297be99b15d35a785b2f095bf7", - "_resolved": "https://registry.npmjs.org/absolute-path/-/absolute-path-0.0.0.tgz" + "_resolved": "https://registry.npmjs.org/absolute-path/-/absolute-path-0.0.0.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/bluebird/changelog.md b/examples/node_modules/react-native/node_modules/bluebird/changelog.md index 1f506bb1..806435f8 100644 --- a/examples/node_modules/react-native/node_modules/bluebird/changelog.md +++ b/examples/node_modules/react-native/node_modules/bluebird/changelog.md @@ -1,3 +1,9 @@ +## 2.9.25 (2015-04-28) + +Bugfixes: + + - Fix crash in node 0.8 + ## 2.9.24 (2015-04-02) Bugfixes: diff --git a/examples/node_modules/react-native/node_modules/bluebird/js/browser/bluebird.js b/examples/node_modules/react-native/node_modules/bluebird/js/browser/bluebird.js index c42fe299..9e358b3a 100644 --- a/examples/node_modules/react-native/node_modules/bluebird/js/browser/bluebird.js +++ b/examples/node_modules/react-native/node_modules/bluebird/js/browser/bluebird.js @@ -23,7 +23,7 @@ * */ /** - * bluebird build version 2.9.24 + * bluebird build version 2.9.25 * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, cancel, using, filter, any, each, timers */ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o0},r.prototype.throwLater=function(t,e){1===arguments.length&&(e=t,t=function(){throw e});var r=this._getDomain();if(void 0!==r&&(t=r.bind(t)),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(n){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")}},r.prototype._getDomain=function(){},l.isNode){var h=t("events"),p=function(){var t=process.domain;return null===t?void 0:t};if(h.usingDomains)r.prototype._getDomain=p;else{var f=Object.getOwnPropertyDescriptor(h,"usingDomains");if(f.configurable){var _=!1;Object.defineProperty(h,"usingDomains",{configurable:!1,enumerable:!0,get:function(){return _},set:function(t){!_&&t&&(_=!0,r.prototype._getDomain=p,l.toFastProperties(process),process.emit("domainsActivated"))}})}else process.on("domainsActivated",function(){r.prototype._getDomain=p})}}l.hasDevTools?(r.prototype.invokeLater=function(t,e,r){this._trampolineEnabled?n.call(this,t,e,r):setTimeout(function(){t.call(e,r)},100)},r.prototype.invoke=function(t,e,r){this._trampolineEnabled?i.call(this,t,e,r):setTimeout(function(){t.call(e,r)},0)},r.prototype.settlePromises=function(t){this._trampolineEnabled?o.call(this,t):setTimeout(function(){t._settlePromises()},0)}):(r.prototype.invokeLater=n,r.prototype.invoke=i,r.prototype.settlePromises=o),r.prototype.invokeFirst=function(t,e,r){var n=this._getDomain();void 0!==n&&(t=n.bind(t)),this._normalQueue.unshift(t,e,r),this._queueTick()},r.prototype._drainQueue=function(t){for(;t.length()>0;){var e=t.shift();if("function"==typeof e){var r=t.shift(),n=t.shift();e.call(r,n)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=new r,e.exports.firstLineError=s},{"./queue.js":28,"./schedule.js":31,"./util.js":38,events:39}],3:[function(t,e){"use strict";e.exports=function(t,e,r){var n=function(t,e){this._reject(e)},i=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(n,n,null,this,t)},o=function(t,e){this._setBoundTo(t),this._isPending()&&this._resolveCallback(e.target)},s=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(n){var a=r(n),u=new t(e);u._propagateFrom(this,1);var c=this._target();if(a instanceof t){var l={promiseRejectionQueued:!1,promise:u,target:c,bindingPromise:a};c._then(e,i,u._progress,u,l),a._then(o,s,u._progress,u,l)}else u._setBoundTo(n),u._resolveCallback(c);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=131072|this._bitField,this._boundTo=t):this._bitField=-131073&this._bitField},t.prototype._isBound=function(){return 131072===(131072&this._bitField)},t.bind=function(n,i){var o=r(n),s=new t(e);return o instanceof t?o._then(function(t){s._setBoundTo(t),s._resolveCallback(i)},s._reject,s._progress,s,null):(s._setBoundTo(n),s._resolveCallback(i)),s}}},{}],4:[function(t,e){"use strict";function r(){try{Promise===i&&(Promise=n)}catch(t){}return i}var n;"undefined"!=typeof Promise&&(n=Promise);var i=t("./promise.js")();i.noConflict=r,e.exports=i},{"./promise.js":23}],5:[function(t,e){"use strict";var r=Object.create;if(r){var n=r(null),i=r(null);n[" size"]=i[" size"]=0}e.exports=function(e){function r(t,r){var n;if(null!=t&&(n=t[r]),"function"!=typeof n){var i="Object "+a.classString(t)+" has no method '"+a.toString(r)+"'";throw new e.TypeError(i)}return n}function n(t){var e=this.pop(),n=r(t,e);return n.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}{var s,a=t("./util.js"),u=a.canEvaluate;a.isIdentifier}e.prototype.call=function(t){for(var e=arguments.length,r=new Array(e-1),i=1;e>i;++i)r[i-1]=arguments[i];return r.push(t),this._then(n,void 0,void 0,r,void 0)},e.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=o;else if(u){var n=s(t);e=null!==n?n:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util.js":38}],6:[function(t,e){"use strict";e.exports=function(e){var r=t("./errors.js"),n=t("./async.js"),i=r.CancellationError;e.prototype._cancel=function(t){if(!this.isCancellable())return this;for(var e,r=this;void 0!==(e=r._cancellationParent)&&e.isCancellable();)r=e;this._unsetCancellable(),r._target()._rejectCallback(t,!1,!0)},e.prototype.cancel=function(t){return this.isCancellable()?(void 0===t&&(t=new i),n.invokeLater(this._cancel,this,t),this):this},e.prototype.cancellable=function(){return this._cancellable()?this:(n.enableTrampoline(),this._setCancellable(),this._cancellationParent=void 0,this)},e.prototype.uncancellable=function(){var t=this.then();return t._unsetCancellable(),t},e.prototype.fork=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);return n._setCancellable(),n._cancellationParent=void 0,n}}},{"./async.js":2,"./errors.js":13}],7:[function(t,e){"use strict";e.exports=function(){function e(t){this._parent=t;var r=this._length=1+(void 0===t?0:t._length);j(this,e),r>32&&this.uncycle()}function r(t,e){for(var r=0;r=0;--a)if(n[a]===o){s=a;break}for(var a=s;a>=0;--a){var u=n[a];if(e[i]!==u)break;e.pop(),i--}e=n}}function o(t){for(var e=[],r=0;r0&&(e=e.slice(r)),e}function a(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t.toString();var r=/\[object [a-zA-Z0-9$_]+\]/;if(r.test(e))try{var n=JSON.stringify(t);e=n}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+u(e)+">, no stack trace)"}function u(t){var e=41;return t.lengtht)){for(var e=[],r={},n=0,i=this;void 0!==i;++n)e.push(i),i=i._parent;t=this._length=n;for(var n=t-1;n>=0;--n){var o=e[n].stack;void 0===r[o]&&(r[o]=n)}for(var n=0;t>n;++n){var s=e[n].stack,a=r[s];if(void 0!==a&&a!==n){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var u=n>0?e[n-1]:this;t-1>a?(u._parent=e[a+1],u._parent.uncycle(),u._length=u._parent._length+1):(u._parent=void 0,u._length=1);for(var c=u._length+1,l=n-2;l>=0;--l)e[l]._length=c,c++;return}}}},e.prototype.parent=function(){return this._parent},e.prototype.hasParent=function(){return void 0!==this._parent},e.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var s=e.parseStackAndMessage(t),a=s.message,u=[s.stack],c=this;void 0!==c;)u.push(o(c.stack.split("\n"))),c=c._parent;i(u),n(u),p.notEnumerableProp(t,"stack",r(a,u)),p.notEnumerableProp(t,"__stackCleaned__",!0)}},e.parseStackAndMessage=function(t){var e=t.stack,r=t.toString();return e="string"==typeof e&&e.length>0?s(t):[" (No stack trace)"],{message:r,stack:o(e)}},e.formatAndLogError=function(t,e){if("undefined"!=typeof console){var r;if("object"==typeof t||"function"==typeof t){var n=t.stack;r=e+d(n,t)}else r=e+String(t);"function"==typeof l?l(r):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}},e.unhandledRejection=function(t){e.formatAndLogError(t,"^--- With additional stack trace: ")},e.isSupported=function(){return"function"==typeof j},e.fireRejectionEvent=function(t,r,n,i){var o=!1;try{"function"==typeof r&&(o=!0,"rejectionHandled"===t?r(i):r(n,i))}catch(s){h.throwLater(s)}var a=!1;try{a=b(t,n,i)}catch(s){a=!0,h.throwLater(s)}var u=!1;if(m)try{u=m(t.toLowerCase(),{reason:n,promise:i})}catch(s){u=!0,h.throwLater(s)}a||o||u||"unhandledRejection"!==t||e.formatAndLogError(n,"Unhandled rejection ")};var y=function(){return!1},g=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;e.setBounds=function(t,r){if(e.isSupported()){for(var n,i,o=t.stack.split("\n"),s=r.stack.split("\n"),a=-1,u=-1,l=0;la||0>u||!n||!i||n!==i||a>=u||(y=function(t){if(f.test(t))return!0;var e=c(t);return e&&e.fileName===n&&a<=e.line&&e.line<=u?!0:!1})}};var m,j=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():a(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit=Error.stackTraceLimit+6,_=t,d=e;var r=Error.captureStackTrace;return y=function(t){return f.test(t)},function(t,e){Error.stackTraceLimit=Error.stackTraceLimit+6,r(t,e),Error.stackTraceLimit=Error.stackTraceLimit-6}}var n=new Error;if("string"==typeof n.stack&&n.stack.split("\n")[0].indexOf("stackDetection@")>=0)return _=/@/,d=e,v=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in n||!i?(d=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?a(e):e.toString()},null):(_=t,d=e,function(t){Error.stackTraceLimit=Error.stackTraceLimit+6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit=Error.stackTraceLimit-6})}([]),b=function(){if(p.isNode)return function(t,e,r){return"rejectionHandled"===t?process.emit(t,r):process.emit(t,e,r)};var t=!1,e=!0;try{var r=new self.CustomEvent("test");t=r instanceof CustomEvent}catch(n){}if(!t)try{var i=document.createEvent("CustomEvent");i.initCustomEvent("testingtheevent",!1,!0,{}),self.dispatchEvent(i)}catch(n){e=!1}e&&(m=function(e,r){var n;return t?n=new self.CustomEvent(e,{detail:r,bubbles:!1,cancelable:!0}):self.dispatchEvent&&(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!1,!0,r)),n?!self.dispatchEvent(n):!1});var o={};return o.unhandledRejection="onunhandledRejection".toLowerCase(),o.rejectionHandled="onrejectionHandled".toLowerCase(),function(t,e,r){var n=o[t],i=self[n];return i?("rejectionHandled"===t?i.call(self,r):i.call(self,e,r),!0):!1}}();return"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(l=function(t){console.warn(t)},p.isNode&&process.stderr.isTTY?l=function(t){process.stderr.write(""+t+"\n")}:p.isNode||"string"!=typeof(new Error).stack||(l=function(t){console.warn("%c"+t,"color: red")})),e}},{"./async.js":2,"./util.js":38}],8:[function(t,e){"use strict";e.exports=function(e){function r(t,e,r){this._instances=t,this._callback=e,this._promise=r}function n(t,e){var r={},n=s(t).call(r,e);if(n===a)return n;var i=u(r);return i.length?(a.e=new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"),a):n}var i=t("./util.js"),o=t("./errors.js"),s=i.tryCatch,a=i.errorObj,u=t("./es5.js").keys,c=o.TypeError;return r.prototype.doFilter=function(t){for(var r=this._callback,i=this._promise,o=i._boundTo,u=0,c=this._instances.length;c>u;++u){var l=this._instances[u],h=l===Error||null!=l&&l.prototype instanceof Error;if(h&&t instanceof l){var p=s(r).call(o,t);return p===a?(e.e=p.e,e):p}if("function"==typeof l&&!h){var f=n(l,t);if(f===a){t=a.e;break}if(f){var p=s(r).call(o,t);return p===a?(e.e=p.e,e):p}}}return e.e=t,e},r}},{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(t,e){"use strict";e.exports=function(t,e,r){function n(){this._trace=new e(o())}function i(){return r()?new n:void 0}function o(){var t=s.length-1;return t>=0?s[t]:void 0}var s=[];return n.prototype._pushContext=function(){r()&&void 0!==this._trace&&s.push(this._trace)},n.prototype._popContext=function(){r()&&void 0!==this._trace&&s.pop()},t.prototype._peekContext=o,t.prototype._pushContext=n.prototype._pushContext,t.prototype._popContext=n.prototype._popContext,i}},{}],10:[function(t,e){"use strict";e.exports=function(e,r){var n,i,o=t("./async.js"),s=t("./errors.js").Warning,a=t("./util.js"),u=a.canAttachTrace,c=!1||a.isNode&&(!!process.env.BLUEBIRD_DEBUG||"development"===process.env.NODE_ENV);return c&&o.disableTrampolineIfNecessary(),e.prototype._ensurePossibleRejectionHandled=function(){this._setRejectionIsUnhandled(),o.invokeLater(this._notifyUnhandledRejection,this,void 0)},e.prototype._notifyUnhandledRejectionIsHandled=function(){r.fireRejectionEvent("rejectionHandled",n,void 0,this)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._getCarriedStackTrace()||this._settledValue;this._setUnhandledRejectionIsNotified(),r.fireRejectionEvent("unhandledRejection",i,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=524288|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-524289&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(524288&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=2097152|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-2097153&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(2097152&this._bitField)>0},e.prototype._setCarriedStackTrace=function(t){this._bitField=1048576|this._bitField,this._fulfillmentHandler0=t},e.prototype._isCarryingStackTrace=function(){return(1048576&this._bitField)>0},e.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},e.prototype._captureStackTrace=function(){return c&&(this._trace=new r(this._peekContext())),this},e.prototype._attachExtraTrace=function(t,e){if(c&&u(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var i=r.parseStackAndMessage(t);a.notEnumerableProp(t,"stack",i.message+"\n"+i.stack.join("\n")),a.notEnumerableProp(t,"__stackCleaned__",!0)}}},e.prototype._warn=function(t){var e=new s(t),n=this._peekContext();if(n)n.attachExtraTrace(e);else{var i=r.parseStackAndMessage(e);e.stack=i.message+"\n"+i.stack.join("\n")}r.formatAndLogError(e,"")},e.onPossiblyUnhandledRejection=function(t){i="function"==typeof t?t:void 0},e.onUnhandledRejectionHandled=function(t){n="function"==typeof t?t:void 0},e.longStackTraces=function(){if(o.haveItemsQueued()&&c===!1)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/DT1qyG\n");c=r.isSupported(),c&&o.disableTrampolineIfNecessary()},e.hasLongStackTraces=function(){return c&&r.isSupported()},r.isSupported()||(e.longStackTraces=function(){},c=!1),function(){return c}}},{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(t,e){"use strict";var r=t("./util.js"),n=r.isPrimitive,i=r.wrapsPrimitiveReceiver;e.exports=function(t){var e=function(){return this},r=function(){throw this},o=function(t,e){return 1===e?function(){throw t}:2===e?function(){return t}:void 0};t.prototype["return"]=t.prototype.thenReturn=function(t){return i&&n(t)?this._then(o(t,2),void 0,void 0,void 0,void 0):this._then(e,void 0,void 0,t,void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return i&&n(t)?this._then(o(t,1),void 0,void 0,void 0,void 0):this._then(r,void 0,void 0,t,void 0)}}},{"./util.js":38}],12:[function(t,e){"use strict";e.exports=function(t,e){var r=t.reduce;t.prototype.each=function(t){return r(this,t,null,e)},t.each=function(t,n){return r(t,n,null,e)}}},{}],13:[function(t,e){"use strict";function r(t,e){function r(n){return this instanceof r?(l(this,"message","string"==typeof n?n:e),l(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return c(r,Error),r}function n(t){return this instanceof n?(l(this,"name","OperationalError"),l(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(l(this,"message",t.message),l(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new n(t)}var i,o,s=t("./es5.js"),a=s.freeze,u=t("./util.js"),c=u.inherits,l=u.notEnumerableProp,h=r("Warning","warning"),p=r("CancellationError","cancellation error"),f=r("TimeoutError","timeout error"),_=r("AggregateError","aggregate error");try{i=TypeError,o=RangeError}catch(d){i=r("TypeError","type error"),o=r("RangeError","range error")}for(var v="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),y=0;y0&&"function"==typeof arguments[e]){t=arguments[e];var n}for(var i=arguments.length,o=new Array(i),s=0;i>s;++s)o[s]=arguments[s];t&&o.pop();var n=new r(o).promise();return void 0!==t?n.spread(t):n}}},{"./util.js":38}],19:[function(t,e){"use strict";e.exports=function(e,r,n,i,o){function s(t,e,r,n){this.constructor$(t),this._promise._captureStackTrace(),this._callback=e,this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:_,c.invoke(a,this,void 0)}function a(){this._init$(void 0,-2)}function u(t,e,r,n){var i="object"==typeof r&&null!==r?r.concurrency:0;return i="number"==typeof i&&isFinite(i)&&i>=1?i:0,new s(t,e,i,n)}var c=t("./async.js"),l=t("./util.js"),h=l.tryCatch,p=l.errorObj,f={},_=[];l.inherits(s,r),s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,a=this._limit;if(n[r]===f){if(n[r]=t,a>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return}else{if(a>=1&&this._inFlight>=a)return n[r]=t,void this._queue.push(r);null!==s&&(s[r]=t);var u=this._callback,c=this._promise._boundTo;this._promise._pushContext();var l=h(u).call(c,t,r,o);if(this._promise._popContext(),l===p)return this._reject(l.e);var _=i(l,this._promise);if(_ instanceof e){if(_=_._target(),_._isPending())return a>=1&&this._inFlight++,n[r]=f,_._proxyPromiseArray(this,r);if(!_._isFulfilled())return this._reject(_._reason());l=_._value()}n[r]=l}var d=++this._totalResolved;d>=o&&(null!==s?this._filter(n,s):this._resolve(n))},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlighto;++o)t[o]&&(n[i++]=e[o]);n.length=i,this._resolve(n)},s.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return"function"!=typeof t?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(this,t,e,null).promise()},e.map=function(t,e,r,i){return"function"!=typeof e?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(t,e,r,i).promise()}}},{"./async.js":2,"./util.js":38}],20:[function(t,e){"use strict";e.exports=function(e,r,n,i){var o=t("./util.js"),s=o.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("fn must be a function\n\n See http://goo.gl/916lJJ\n");return function(){var n=new e(r);n._captureStackTrace(),n._pushContext();var i=s(t).apply(this,arguments);return n._popContext(),n._resolveFromSyncValue(i),n}},e.attempt=e["try"]=function(t,n,a){if("function"!=typeof t)return i("fn must be a function\n\n See http://goo.gl/916lJJ\n");var u=new e(r);u._captureStackTrace(),u._pushContext();var c=o.isArray(n)?s(t).apply(a,n):s(t).call(a,n);return u._popContext(),u._resolveFromSyncValue(c),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1,!0):this._resolveCallback(t,!0)}}},{"./util.js":38}],21:[function(t,e){"use strict";e.exports=function(e){function r(t,e){var r=this;if(!o.isArray(t))return n.call(r,t,e);var i=a(e).apply(r._boundTo,[null].concat(t));i===u&&s.throwLater(i.e)}function n(t,e){var r=this,n=r._boundTo,i=void 0===t?a(e).call(n,null):a(e).call(n,null,t);i===u&&s.throwLater(i.e)}function i(t,e){var r=this;if(!t){var n=r._target(),i=n._getCarriedStackTrace();i.cause=t,t=i}var o=a(e).call(r._boundTo,t);o===u&&s.throwLater(o.e)}var o=t("./util.js"),s=t("./async.js"),a=o.tryCatch,u=o.errorObj;e.prototype.asCallback=e.prototype.nodeify=function(t,e){if("function"==typeof t){var o=n;void 0!==e&&Object(e).spread&&(o=r),this._then(o,i,void 0,this,t)}return this}}},{"./async.js":2,"./util.js":38}],22:[function(t,e){"use strict";e.exports=function(e,r){var n=t("./util.js"),i=t("./async.js"),o=n.tryCatch,s=n.errorObj;e.prototype.progressed=function(t){return this._then(void 0,void 0,t,void 0,void 0)},e.prototype._progress=function(t){this._isFollowingOrFulfilledOrRejected()||this._target()._progressUnchecked(t)},e.prototype._progressHandlerAt=function(t){return 0===t?this._progressHandler0:this[(t<<2)+t-5+2]},e.prototype._doProgressWith=function(t){var r=t.value,i=t.handler,a=t.promise,u=t.receiver,c=o(i).call(u,r);if(c===s){if(null!=c.e&&"StopProgressPropagation"!==c.e.name){var l=n.canAttachTrace(c.e)?c.e:new Error(n.toString(c.e));a._attachExtraTrace(l),a._progress(c.e)}}else c instanceof e?c._then(a._progress,null,null,a,void 0):a._progress(c)},e.prototype._progressUnchecked=function(t){for(var n=this._length(),o=this._progress,s=0;n>s;s++){var a=this._progressHandlerAt(s),u=this._promiseAt(s);if(u instanceof e)"function"==typeof a?i.invoke(this._doProgressWith,this,{handler:a,promise:u,receiver:this._receiverAt(s),value:t}):i.invoke(o,u,t);else{var c=this._receiverAt(s);"function"==typeof a?a.call(c,t,u):c instanceof r&&!c._isResolved()&&c._promiseProgressed(t,u)}}}}},{"./async.js":2,"./util.js":38}],23:[function(t,e){"use strict";e.exports=function(){function e(t){if("function"!=typeof t)throw new c("the promise constructor requires a resolver function\n\n See http://goo.gl/EC22Yn\n");if(this.constructor!==e)throw new c("the promise constructor cannot be invoked directly\n\n See http://goo.gl/KsIlge\n");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._progressHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,t!==l&&this._resolveFromResolver(t)}function r(t){var r=new e(l);r._fulfillmentHandler0=t,r._rejectionHandler0=t,r._progressHandler0=t,r._promise0=t,r._receiver0=t,r._settledValue=t}var n=function(){return new c("circular promise resolution chain\n\n See http://goo.gl/LhFpo0\n")},i=function(){return new e.PromiseInspection(this._target())},o=function(t){return e.reject(new c(t))},s=t("./util.js"),a=t("./async.js"),u=t("./errors.js"),c=e.TypeError=u.TypeError;e.RangeError=u.RangeError,e.CancellationError=u.CancellationError,e.TimeoutError=u.TimeoutError,e.OperationalError=u.OperationalError,e.RejectionError=u.OperationalError,e.AggregateError=u.AggregateError;var l=function(){},h={},p={e:null},f=t("./thenables.js")(e,l),_=t("./promise_array.js")(e,l,f,o),d=t("./captured_trace.js")(),v=t("./debuggability.js")(e,d),y=t("./context.js")(e,d,v),g=t("./catch_filter.js")(p),m=t("./promise_resolver.js"),j=m._nodebackForPromise,b=s.errorObj,w=s.tryCatch;return e.prototype.toString=function(){return"[object Promise]"},e.prototype.caught=e.prototype["catch"]=function(t){var r=arguments.length;if(r>1){var n,i=new Array(r-1),o=0;for(n=0;r-1>n;++n){var s=arguments[n];if("function"!=typeof s)return e.reject(new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"));i[o++]=s}i.length=o,t=arguments[n];var a=new g(i,t,this);return this._then(void 0,a.doFilter,void 0,a,void 0)}return this._then(void 0,t,void 0,void 0,void 0)},e.prototype.reflect=function(){return this._then(i,i,void 0,this,void 0)},e.prototype.then=function(t,e,r){if(v()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+s.classString(t); -arguments.length>1&&(n+=", "+s.classString(e)),this._warn(n)}return this._then(t,e,r,void 0,void 0)},e.prototype.done=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);n._setIsFinal()},e.prototype.spread=function(t,e){return this.all()._then(t,e,void 0,h,void 0)},e.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},e.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},e.prototype.all=function(){return new _(this).promise()},e.prototype.error=function(t){return this.caught(s.originatesFromRejection,t)},e.is=function(t){return t instanceof e},e.fromNode=function(t){var r=new e(l),n=w(t)(j(r));return n===b&&r._rejectCallback(n.e,!0,!0),r},e.all=function(t){return new _(t).promise()},e.defer=e.pending=function(){var t=new e(l);return new m(t)},e.cast=function(t){var r=f(t);if(!(r instanceof e)){var n=r;r=new e(l),r._fulfillUnchecked(n)}return r},e.resolve=e.fulfilled=e.cast,e.reject=e.rejected=function(t){var r=new e(l);return r._captureStackTrace(),r._rejectCallback(t,!0),r},e.setScheduler=function(t){if("function"!=typeof t)throw new c("fn must be a function\n\n See http://goo.gl/916lJJ\n");var e=a._schedule;return a._schedule=t,e},e.prototype._then=function(t,r,n,i,o){var s=void 0!==o,u=s?o:new e(l);s||(u._propagateFrom(this,5),u._captureStackTrace());var c=this._target();c!==this&&(void 0===i&&(i=this._boundTo),s||u._setIsMigrated());var h=c._addCallbacks(t,r,n,u,i);return c._isResolved()&&!c._isSettlePromisesQueued()&&a.invoke(c._settlePromiseAtPostResolution,c,h),u},e.prototype._settlePromiseAtPostResolution=function(t){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),this._settlePromiseAt(t)},e.prototype._length=function(){return 131071&this._bitField},e.prototype._isFollowingOrFulfilledOrRejected=function(){return(939524096&this._bitField)>0},e.prototype._isFollowing=function(){return 536870912===(536870912&this._bitField)},e.prototype._setLength=function(t){this._bitField=-131072&this._bitField|131071&t},e.prototype._setFulfilled=function(){this._bitField=268435456|this._bitField},e.prototype._setRejected=function(){this._bitField=134217728|this._bitField},e.prototype._setFollowing=function(){this._bitField=536870912|this._bitField},e.prototype._setIsFinal=function(){this._bitField=33554432|this._bitField},e.prototype._isFinal=function(){return(33554432&this._bitField)>0},e.prototype._cancellable=function(){return(67108864&this._bitField)>0},e.prototype._setCancellable=function(){this._bitField=67108864|this._bitField},e.prototype._unsetCancellable=function(){this._bitField=-67108865&this._bitField},e.prototype._setIsMigrated=function(){this._bitField=4194304|this._bitField},e.prototype._unsetIsMigrated=function(){this._bitField=-4194305&this._bitField},e.prototype._isMigrated=function(){return(4194304&this._bitField)>0},e.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[5*t-5+4];return void 0===e&&this._isBound()?this._boundTo:e},e.prototype._promiseAt=function(t){return 0===t?this._promise0:this[5*t-5+3]},e.prototype._fulfillmentHandlerAt=function(t){return 0===t?this._fulfillmentHandler0:this[5*t-5+0]},e.prototype._rejectionHandlerAt=function(t){return 0===t?this._rejectionHandler0:this[5*t-5+1]},e.prototype._migrateCallbacks=function(t,r){var n=t._fulfillmentHandlerAt(r),i=t._rejectionHandlerAt(r),o=t._progressHandlerAt(r),s=t._promiseAt(r),a=t._receiverAt(r);s instanceof e&&s._setIsMigrated(),this._addCallbacks(n,i,o,s,a)},e.prototype._addCallbacks=function(t,e,r,n,i){var o=this._length();if(o>=131066&&(o=0,this._setLength(0)),0===o)this._promise0=n,void 0!==i&&(this._receiver0=i),"function"!=typeof t||this._isCarryingStackTrace()||(this._fulfillmentHandler0=t),"function"==typeof e&&(this._rejectionHandler0=e),"function"==typeof r&&(this._progressHandler0=r);else{var s=5*o-5;this[s+3]=n,this[s+4]=i,"function"==typeof t&&(this[s+0]=t),"function"==typeof e&&(this[s+1]=e),"function"==typeof r&&(this[s+2]=r)}return this._setLength(o+1),o},e.prototype._setProxyHandlers=function(t,e){var r=this._length();if(r>=131066&&(r=0,this._setLength(0)),0===r)this._promise0=e,this._receiver0=t;else{var n=5*r-5;this[n+3]=e,this[n+4]=t}this._setLength(r+1)},e.prototype._proxyPromiseArray=function(t,e){this._setProxyHandlers(t,e)},e.prototype._resolveCallback=function(t,r){if(!this._isFollowingOrFulfilledOrRejected()){if(t===this)return this._rejectCallback(n(),!1,!0);var i=f(t,this);if(!(i instanceof e))return this._fulfill(t);var o=1|(r?4:0);this._propagateFrom(i,o);var s=i._target();if(s._isPending()){for(var a=this._length(),u=0;a>u;++u)s._migrateCallbacks(this,u);this._setFollowing(),this._setLength(0),this._setFollowee(s)}else s._isFulfilled()?this._fulfillUnchecked(s._value()):this._rejectUnchecked(s._reason(),s._getCarriedStackTrace())}},e.prototype._rejectCallback=function(t,e,r){r||s.markAsOriginatingFromRejection(t);var n=s.ensureErrorObject(t),i=n===t;this._attachExtraTrace(n,e?i:!1),this._reject(t,i?void 0:n)},e.prototype._resolveFromResolver=function(t){var e=this;this._captureStackTrace(),this._pushContext();var r=!0,n=w(t)(function(t){null!==e&&(e._resolveCallback(t),e=null)},function(t){null!==e&&(e._rejectCallback(t,r),e=null)});r=!1,this._popContext(),void 0!==n&&n===b&&null!==e&&(e._rejectCallback(n.e,!0,!0),e=null)},e.prototype._settlePromiseFromHandler=function(t,e,r,i){if(!i._isRejected()){i._pushContext();var o;if(o=e!==h||this._isRejected()?w(t).call(e,r):w(t).apply(this._boundTo,r),i._popContext(),o===b||o===i||o===p){var s=o===i?n():o.e;i._rejectCallback(s,!1,!0)}else i._resolveCallback(o)}},e.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},e.prototype._followee=function(){return this._rejectionHandler0},e.prototype._setFollowee=function(t){this._rejectionHandler0=t},e.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},e.prototype._propagateFrom=function(t,e){(1&e)>0&&t._cancellable()&&(this._setCancellable(),this._cancellationParent=t),(4&e)>0&&t._isBound()&&this._setBoundTo(t._boundTo)},e.prototype._fulfill=function(t){this._isFollowingOrFulfilledOrRejected()||this._fulfillUnchecked(t)},e.prototype._reject=function(t,e){this._isFollowingOrFulfilledOrRejected()||this._rejectUnchecked(t,e)},e.prototype._settlePromiseAt=function(t){var r=this._promiseAt(t),n=r instanceof e;if(n&&r._isMigrated())return r._unsetIsMigrated(),a.invoke(this._settlePromiseAt,this,t);var i=this._isFulfilled()?this._fulfillmentHandlerAt(t):this._rejectionHandlerAt(t),o=this._isCarryingStackTrace()?this._getCarriedStackTrace():void 0,s=this._settledValue,u=this._receiverAt(t);this._clearCallbackDataAtIndex(t),"function"==typeof i?n?this._settlePromiseFromHandler(i,u,s,r):i.call(u,s,r):u instanceof _?u._isResolved()||(this._isFulfilled()?u._promiseFulfilled(s,r):u._promiseRejected(s,r)):n&&(this._isFulfilled()?r._fulfill(s):r._reject(s,o)),t>=4&&4===(31&t)&&a.invokeLater(this._setLength,this,0)},e.prototype._clearCallbackDataAtIndex=function(t){if(0===t)this._isCarryingStackTrace()||(this._fulfillmentHandler0=void 0),this._rejectionHandler0=this._progressHandler0=this._receiver0=this._promise0=void 0;else{var e=5*t-5;this[e+3]=this[e+4]=this[e+0]=this[e+1]=this[e+2]=void 0}},e.prototype._isSettlePromisesQueued=function(){return-1073741824===(-1073741824&this._bitField)},e.prototype._setSettlePromisesQueued=function(){this._bitField=-1073741824|this._bitField},e.prototype._unsetSettlePromisesQueued=function(){this._bitField=1073741823&this._bitField},e.prototype._queueSettlePromises=function(){a.settlePromises(this),this._setSettlePromisesQueued()},e.prototype._fulfillUnchecked=function(t){if(t===this){var e=n();return this._attachExtraTrace(e),this._rejectUnchecked(e,void 0)}this._setFulfilled(),this._settledValue=t,this._cleanValues(),this._length()>0&&this._queueSettlePromises()},e.prototype._rejectUncheckedCheckError=function(t){var e=s.ensureErrorObject(t);this._rejectUnchecked(t,e===t?void 0:e)},e.prototype._rejectUnchecked=function(t,e){if(t===this){var r=n();return this._attachExtraTrace(r),this._rejectUnchecked(r)}return this._setRejected(),this._settledValue=t,this._cleanValues(),this._isFinal()?void a.throwLater(function(t){throw"stack"in t&&a.invokeFirst(d.unhandledRejection,void 0,t),t},void 0===e?t:e):(void 0!==e&&e!==t&&this._setCarriedStackTrace(e),void(this._length()>0?this._queueSettlePromises():this._ensurePossibleRejectionHandled()))},e.prototype._settlePromises=function(){this._unsetSettlePromisesQueued();for(var t=this._length(),e=0;t>e;e++)this._settlePromiseAt(e)},e._makeSelfResolutionError=n,t("./progress.js")(e,_),t("./method.js")(e,l,f,o),t("./bind.js")(e,l,f),t("./finally.js")(e,p,f),t("./direct_resolve.js")(e),t("./synchronous_inspection.js")(e),t("./join.js")(e,_,f,l),e.Promise=e,t("./map.js")(e,_,o,f,l),t("./cancel.js")(e),t("./using.js")(e,o,f,y),t("./generators.js")(e,o,l,f),t("./nodeify.js")(e),t("./call_get.js")(e),t("./props.js")(e,_,f,o),t("./race.js")(e,l,f,o),t("./reduce.js")(e,_,o,f,l),t("./settle.js")(e,_),t("./some.js")(e,_,o),t("./promisify.js")(e,l),t("./any.js")(e),t("./each.js")(e,l),t("./timers.js")(e,l),t("./filter.js")(e,l),s.toFastProperties(e),s.toFastProperties(e.prototype),r({a:1}),r({b:2}),r({c:3}),r(1),r(function(){}),r(void 0),r(!1),r(new e(l)),d.setBounds(a.firstLineError,s.lastLineError),e}},{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var n,i=this._promise=new e(r);t instanceof e&&(n=t,i._propagateFrom(n,5)),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var a=t("./util.js"),u=a.isArray;return s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function c(t,r){var s=n(this._values,this._promise);if(s instanceof e){if(s=s._target(),this._values=s,!s._isFulfilled())return s._isPending()?void s._then(c,this._reject,void 0,this,r):void this._reject(s._reason());if(s=s._value(),!u(s)){var a=new e.TypeError("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");return void this.__hardReject__(a)}}else if(!u(s))return void this._promise._reject(i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n")._reason());if(0===s.length)return void(-5===r?this._resolveEmptyArray():this._resolve(o(r)));var l=this.getActualLength(s.length);this._length=l,this._values=this.shouldCopyValues()?new Array(l):this._values;for(var h=this._promise,p=0;l>p;++p){var f=this._isResolved(),_=n(s[p],h);_ instanceof e?(_=_._target(),f?_._unsetRejectionIsUnhandled():_._isPending()?_._proxyPromiseArray(this,p):_._isFulfilled()?this._promiseFulfilled(_._value(),p):this._promiseRejected(_._reason(),p)):f||this._promiseFulfilled(_,p)}},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype.__hardReject__=s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1,!0)},s.prototype._promiseProgressed=function(t,e){this._promise._progress({index:e,value:t})},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},s.prototype._promiseRejected=function(t){this._totalResolved++,this._reject(t)},s.prototype.shouldCopyValues=function(){return!0},s.prototype.getActualLength=function(t){return t},s}},{"./util.js":38}],25:[function(t,e){"use strict";function r(t){return t instanceof Error&&p.getPrototypeOf(t)===Error.prototype}function n(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=p.keys(t),i=0;i2){for(var o=arguments.length,s=new Array(o-1),u=1;o>u;++u)s[u-1]=arguments[u];t._fulfill(s)}else t._fulfill(r);t=null}}}var o,s=t("./util.js"),a=s.maybeWrapAsError,u=t("./errors.js"),c=u.TimeoutError,l=u.OperationalError,h=s.haveGetters,p=t("./es5.js"),f=/^(?:name|message|stack|cause)$/;if(o=h?function(t){this.promise=t}:function(t){this.promise=t,this.asCallback=i(t),this.callback=this.asCallback},h){var _={get:function(){return i(this.promise)}};p.defineProperty(o.prototype,"asCallback",_),p.defineProperty(o.prototype,"callback",_)}o._nodebackForPromise=i,o.prototype.toString=function(){return"[object PromiseResolver]"},o.prototype.resolve=o.prototype.fulfill=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._resolveCallback(t)},o.prototype.reject=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._rejectCallback(t)},o.prototype.progress=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._progress(t)},o.prototype.cancel=function(t){this.promise.cancel(t)},o.prototype.timeout=function(){this.reject(new c("timeout"))},o.prototype.isResolved=function(){return this.promise.isResolved()},o.prototype.toJSON=function(){return this.promise.toJSON()},e.exports=o},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(t,e){"use strict";e.exports=function(e,r){function n(t){return!b.test(t)}function i(t){try{return t.__isPromisified__===!0}catch(e){return!1}}function o(t,e,r){var n=f.getDataPropertyOrDefault(t,e+r,j);return n?i(n):!1}function s(t,e,r){for(var n=0;ns;s+=2){var c=o[s],l=o[s+1],h=c+e;t[h]=n===E?E(c,p,c,l,e):n(l,function(){return E(c,p,c,l,e)})}return f.toFastProperties(t),t}function l(t,e){return E(t,e,void 0,t)}var h,p={},f=t("./util.js"),_=t("./promise_resolver.js")._nodebackForPromise,d=f.withAppended,v=f.maybeWrapAsError,y=f.canEvaluate,g=t("./errors").TypeError,m="Async",j={__isPromisified__:!0},b=/^(?:length|name|arguments|caller|callee|prototype|__isPromisified__)$/,w=function(t,e){return f.isIdentifier(t)&&"_"!==t.charAt(0)&&!f.isClass(e)},k=function(t){return t.replace(/([$])/,"\\$")},E=y?h:u;e.promisify=function(t,e){if("function"!=typeof t)throw new g("fn must be a function\n\n See http://goo.gl/916lJJ\n");if(i(t))return t;var r=l(t,arguments.length<2?p:e);return f.copyDescriptors(t,r,n),r},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new g("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/9ITlV0\n");e=Object(e);var r=e.suffix;"string"!=typeof r&&(r=m);var n=e.filter;"function"!=typeof n&&(n=w);var i=e.promisifier;if("function"!=typeof i&&(i=E),!f.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/8FZo5V\n");for(var o=f.inheritedDataKeys(t),s=0;si;++i){var o=e[i];n[i]=t[o],n[i+r]=o}this.constructor$(n)}function s(t){var r,s=n(t);return u(s)?(r=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&r._propagateFrom(s,4),r):i("cannot await properties of a non-object\n\n See http://goo.gl/OsFKC8\n")}var a=t("./util.js"),u=a.isObject,c=t("./es5.js");a.inherits(o,r),o.prototype._init=function(){this._init$(void 0,-3)},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){for(var n={},i=this.length(),o=0,s=this.length();s>o;++o)n[this._values[o+i]]=this._values[o];this._resolve(n)}},o.prototype._promiseProgressed=function(t,e){this._promise._progress({key:this._values[e+this.length()],value:t})},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5.js":14,"./util.js":38}],28:[function(t,e){"use strict";function r(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function n(t){this._capacity=t,this._length=0,this._front=0}n.prototype._willBeOverCapacity=function(t){return this._capacityp;++p){var _=t[p];(void 0!==_||p in t)&&e.cast(_)._then(l,h,void 0,c,null)}return c}var s=t("./util.js").isArray,a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util.js":38}],30:[function(t,e){"use strict";e.exports=function(e,r,n,i,o){function s(t,r,n,s){this.constructor$(t),this._promise._captureStackTrace(),this._preservedValues=s===o?[]:null,this._zerothIsAccum=void 0===n,this._gotAccum=!1,this._reducingIndex=this._zerothIsAccum?1:0,this._valuesPhase=void 0;var u=i(n,this._promise),l=!1,h=u instanceof e;h&&(u=u._target(),u._isPending()?u._proxyPromiseArray(this,-1):u._isFulfilled()?(n=u._value(),this._gotAccum=!0):(this._reject(u._reason()),l=!0)),h||this._zerothIsAccum||(this._gotAccum=!0),this._callback=r,this._accum=n,l||c.invoke(a,this,void 0)}function a(){this._init$(void 0,-5)}function u(t,e,r,i){if("function"!=typeof e)return n("fn must be a function\n\n See http://goo.gl/916lJJ\n");var o=new s(t,e,r,i);return o.promise()}var c=t("./async.js"),l=t("./util.js"),h=l.tryCatch,p=l.errorObj;l.inherits(s,r),s.prototype._init=function(){},s.prototype._resolveEmptyArray=function(){(this._gotAccum||this._zerothIsAccum)&&this._resolve(null!==this._preservedValues?[]:this._accum)},s.prototype._promiseFulfilled=function(t,r){var n=this._values;n[r]=t;var o,s=this.length(),a=this._preservedValues,u=null!==a,c=this._gotAccum,l=this._valuesPhase;if(!l)for(l=this._valuesPhase=new Array(s),o=0;s>o;++o)l[o]=0;if(o=l[r],0===r&&this._zerothIsAccum?(this._accum=t,this._gotAccum=c=!0,l[r]=0===o?1:2):-1===r?(this._accum=t,this._gotAccum=c=!0):0===o?l[r]=1:(l[r]=2,this._accum=t),c){for(var f,_=this._callback,d=this._promise._boundTo,v=this._reducingIndex;s>v;++v)if(o=l[v],2!==o){if(1!==o)return;if(t=n[v],this._promise._pushContext(),u?(a.push(t),f=h(_).call(d,t,v,s)):f=h(_).call(d,this._accum,t,v,s),this._promise._popContext(),f===p)return this._reject(f.e);var y=i(f,this._promise);if(y instanceof e){if(y=y._target(),y._isPending())return l[v]=4,y._proxyPromiseArray(this,v);if(!y._isFulfilled())return this._reject(y._reason());f=y._value()}this._reducingIndex=v+1,this._accum=f}else this._reducingIndex=v+1;this._resolve(u?a:this._accum)}},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,r,n){return u(t,e,r,n)}}},{"./async.js":2,"./util.js":38}],31:[function(t,e){"use strict";var r,n=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")};if(t("./util.js").isNode){var i=process.versions.node.split(".").map(Number);r=0===i[0]&&i[1]>10||i[0]>0?global.setImmediate:process.nextTick,r||(r="undefined"!=typeof setImmediate?setImmediate:"undefined"!=typeof setTimeout?setTimeout:n)}else"undefined"!=typeof MutationObserver?(r=function(t){var e=document.createElement("div"),r=new MutationObserver(t);return r.observe(e,{attributes:!0}),function(){e.classList.toggle("foo")}},r.isStatic=!0):r="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:n;e.exports=r},{"./util.js":38}],32:[function(t,e){"use strict";e.exports=function(e,r){function n(t){this.constructor$(t)}var i=e.PromiseInspection,o=t("./util.js");o.inherits(n,r),n.prototype._promiseResolved=function(t,e){this._values[t]=e;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},n.prototype._promiseFulfilled=function(t,e){var r=new i;r._bitField=268435456,r._settledValue=t,this._promiseResolved(e,r)},n.prototype._promiseRejected=function(t,e){var r=new i;r._bitField=134217728,r._settledValue=t,this._promiseResolved(e,r)},e.settle=function(t){return new n(t).promise()},e.prototype.settle=function(){return new n(this).promise()}}},{"./util.js":38}],33:[function(t,e){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer\n\n See http://goo.gl/1wAmHx\n");var r=new i(t),o=r.promise();return r.setHowMany(e),r.init(),o}var s=t("./util.js"),a=t("./errors.js").RangeError,u=t("./errors.js").AggregateError,c=s.isArray;s.inherits(i,r),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=c(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),this._resolve(1===this.howMany()&&this._unwrap?this._values[0]:this._values))},i.prototype._promiseRejected=function(t){if(this._addRejected(t),this.howMany()>this._canPossiblyFulfill()){for(var e=new u,r=this.length();r0},e.prototype.isRejected=t.prototype._isRejected=function(){return(134217728&this._bitField)>0},e.prototype.isPending=t.prototype._isPending=function(){return 0===(402653184&this._bitField)},e.prototype.isResolved=t.prototype._isResolved=function(){return(402653184&this._bitField)>0},t.prototype.isPending=function(){return this._target()._isPending()},t.prototype.isRejected=function(){return this._target()._isRejected()},t.prototype.isFulfilled=function(){return this._target()._isFulfilled()},t.prototype.isResolved=function(){return this._target()._isResolved()},t.prototype._value=function(){return this._settledValue},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue},t.prototype.value=function(){var t=this._target();if(!t.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return t._settledValue},t.prototype.reason=function(){var t=this._target();if(!t.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return t._unsetRejectionIsUnhandled(),t._settledValue},t.PromiseInspection=e}},{}],35:[function(t,e){"use strict";e.exports=function(e,r){function n(t,n){if(c(t)){if(t instanceof e)return t;if(o(t)){var l=new e(r);return t._then(l._fulfillUnchecked,l._rejectUncheckedCheckError,l._progressUnchecked,l,null),l}var h=a.tryCatch(i)(t);if(h===u){n&&n._pushContext();var l=e.reject(h.e);return n&&n._popContext(),l}if("function"==typeof h)return s(t,h,n)}return t}function i(t){return t.then}function o(t){return l.call(t,"_promise0")}function s(t,n,i){function o(r){l&&(t===r?l._rejectCallback(e._makeSelfResolutionError(),!1,!0):l._resolveCallback(r),l=null)}function s(t){l&&(l._rejectCallback(t,p,!0),l=null)}function c(t){l&&"function"==typeof l._progress&&l._progress(t)}var l=new e(r),h=l;i&&i._pushContext(),l._captureStackTrace(),i&&i._popContext();var p=!0,f=a.tryCatch(n).call(t,o,s,c);return p=!1,l&&f===u&&(l._rejectCallback(f.e,!0,!0),l=null),h}var a=t("./util.js"),u=a.errorObj,c=a.isObject,l={}.hasOwnProperty;return n}},{"./util.js":38}],36:[function(t,e){"use strict";e.exports=function(e,r){function n(t){var e=this;return e instanceof Number&&(e=+e),clearTimeout(e),t}function i(t){var e=this;throw e instanceof Number&&(e=+e),clearTimeout(e),t}var o=t("./util.js"),s=e.TimeoutError,a=function(t,e){if(t.isPending()){"string"!=typeof e&&(e="operation timed out");var r=new s(e);o.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._cancel(r)}},u=function(t){return c(+this).thenReturn(t)},c=e.delay=function(t,n){if(void 0===n){n=t,t=void 0;var i=new e(r);return setTimeout(function(){i._fulfill()},n),i}return n=+n,e.resolve(t)._then(u,null,null,n,void 0)};e.prototype.delay=function(t){return c(this,t)},e.prototype.timeout=function(t,e){t=+t;var r=this.then().cancellable();r._cancellationParent=this;var o=setTimeout(function(){a(r,e)},t);return r._then(n,i,void 0,o,void 0)}}},{"./util.js":38}],37:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t){for(var r=t.length,n=0;r>n;++n){var i=t[n];if(i.isRejected())return e.reject(i.error());t[n]=i._settledValue}return t}function s(t){setTimeout(function(){throw t},0)}function a(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,r){function i(){if(o>=u)return c.resolve();var l=a(t[o++]);if(l instanceof e&&l._isDisposable()){try{l=n(l._getDisposer().tryDispose(r),t.promise)}catch(h){return s(h)}if(l instanceof e)return l._then(i,s,null,null,null)}i()}var o=0,u=t.length,c=e.defer();return i(),c.promise}function c(t){var e=new v;return e._settledValue=t,e._bitField=268435456,u(this,e).thenReturn(t)}function l(t){var e=new v;return e._settledValue=t,e._bitField=134217728,u(this,e).thenThrow(t)}function h(t,e,r){this._data=t,this._promise=e,this._context=r}function p(t,e,r){this.constructor$(t,e,r)}function f(t){return h.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}var _=t("./errors.js").TypeError,d=t("./util.js").inherits,v=e.PromiseInspection;h.prototype.data=function(){return this._data},h.prototype.promise=function(){return this._promise},h.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},h.prototype.tryDispose=function(t){var e=this.resource(),r=this._context;void 0!==r&&r._pushContext();var n=null!==e?this.doDispose(e,t):null;return void 0!==r&&r._popContext(),this._promise._unsetDisposable(),this._data=null,n},h.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},d(p,h),p.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},e.using=function(){var t=arguments.length;if(2>t)return r("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return r("fn must be a function\n\n See http://goo.gl/916lJJ\n");t--;for(var s=new Array(t),a=0;t>a;++a){var u=arguments[a];if(h.isDisposer(u)){var p=u;u=u.promise(),u._setDisposable(p)}else{var _=n(u);_ instanceof e&&(u=_._then(f,null,null,{resources:s,index:a},void 0))}s[a]=u}var d=e.settle(s).then(o).then(function(t){d._pushContext();var e;try{e=i.apply(void 0,t)}finally{d._popContext()}return e})._then(c,l,void 0,s,void 0);return s.promise=d,d},e.prototype._setDisposable=function(t){this._bitField=262144|this._bitField,this._disposer=t},e.prototype._isDisposable=function(){return(262144&this._bitField)>0 -},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-262145&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new p(t,this,i());throw new _}}},{"./errors.js":13,"./util.js":38}],38:[function(t,e,r){"use strict";function n(){try{return T.apply(this,arguments)}catch(t){return F.e=t,F}}function i(t){return T=t,n}function o(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function s(t){return!o(t)}function a(t){return o(t)?new Error(v(t)):t}function u(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function c(t,e,r){if(!w.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function l(t,e,r){if(o(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return w.defineProperty(t,e,n),t}function h(t){throw t}function p(t){try{if("function"==typeof t){var e=w.names(t.prototype);return w.isES5?e.length>1:e.length>0&&!(1===e.length&&"constructor"===e[0])}return!1}catch(r){return!1}}function f(t){function e(){}e.prototype=t;for(var r=8;r--;)new e;return t}function _(t){return R.test(t)}function d(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){try{l(t,"isOperational",!0)}catch(e){}}function g(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function m(t){return t instanceof Error&&w.propertyIsWritable(t,"stack")}function j(t){return{}.toString.call(t)}function b(t,e,r){for(var n=w.names(t),i=0;it||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(c=r.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},{}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,r;return function n(t,e,r){function i(s,a){if(!e[s]){if(!t[s]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=e[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return i(r?r:e)},l,l.exports,n,t,e,r)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s0},r.prototype.throwLater=function(t,e){1===arguments.length&&(e=t,t=function(){throw e});var r=this._getDomain();if(void 0!==r&&(t=r.bind(t)),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(n){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")}},r.prototype._getDomain=function(){};l.hasDevTools?(r.prototype.invokeLater=function(t,e,r){this._trampolineEnabled?n.call(this,t,e,r):setTimeout(function(){t.call(e,r)},100)},r.prototype.invoke=function(t,e,r){this._trampolineEnabled?i.call(this,t,e,r):setTimeout(function(){t.call(e,r)},0)},r.prototype.settlePromises=function(t){this._trampolineEnabled?o.call(this,t):setTimeout(function(){t._settlePromises()},0)}):(r.prototype.invokeLater=n,r.prototype.invoke=i,r.prototype.settlePromises=o),r.prototype.invokeFirst=function(t,e,r){var n=this._getDomain();void 0!==n&&(t=n.bind(t)),this._normalQueue.unshift(t,e,r),this._queueTick()},r.prototype._drainQueue=function(t){for(;t.length()>0;){var e=t.shift();if("function"==typeof e){var r=t.shift(),n=t.shift();e.call(r,n)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=new r,e.exports.firstLineError=s},{"./queue.js":28,"./schedule.js":31,"./util.js":38,events:39}],3:[function(t,e){"use strict";e.exports=function(t,e,r){var n=function(t,e){this._reject(e)},i=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(n,n,null,this,t)},o=function(t,e){this._setBoundTo(t),this._isPending()&&this._resolveCallback(e.target)},s=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(n){var a=r(n),u=new t(e);u._propagateFrom(this,1);var c=this._target();if(a instanceof t){var l={promiseRejectionQueued:!1,promise:u,target:c,bindingPromise:a};c._then(e,i,u._progress,u,l),a._then(o,s,u._progress,u,l)}else u._setBoundTo(n),u._resolveCallback(c);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=131072|this._bitField,this._boundTo=t):this._bitField=-131073&this._bitField},t.prototype._isBound=function(){return 131072===(131072&this._bitField)},t.bind=function(n,i){var o=r(n),s=new t(e);return o instanceof t?o._then(function(t){s._setBoundTo(t),s._resolveCallback(i)},s._reject,s._progress,s,null):(s._setBoundTo(n),s._resolveCallback(i)),s}}},{}],4:[function(t,e){"use strict";function r(){try{Promise===i&&(Promise=n)}catch(t){}return i}var n;"undefined"!=typeof Promise&&(n=Promise);var i=t("./promise.js")();i.noConflict=r,e.exports=i},{"./promise.js":23}],5:[function(t,e){"use strict";var r=Object.create;if(r){var n=r(null),i=r(null);n[" size"]=i[" size"]=0}e.exports=function(e){function r(t,r){var n;if(null!=t&&(n=t[r]),"function"!=typeof n){var i="Object "+a.classString(t)+" has no method '"+a.toString(r)+"'";throw new e.TypeError(i)}return n}function n(t){var e=this.pop(),n=r(t,e);return n.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}{var s,a=t("./util.js"),u=a.canEvaluate;a.isIdentifier}e.prototype.call=function(t){for(var e=arguments.length,r=new Array(e-1),i=1;e>i;++i)r[i-1]=arguments[i];return r.push(t),this._then(n,void 0,void 0,r,void 0)},e.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=o;else if(u){var n=s(t);e=null!==n?n:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util.js":38}],6:[function(t,e){"use strict";e.exports=function(e){var r=t("./errors.js"),n=t("./async.js"),i=r.CancellationError;e.prototype._cancel=function(t){if(!this.isCancellable())return this;for(var e,r=this;void 0!==(e=r._cancellationParent)&&e.isCancellable();)r=e;this._unsetCancellable(),r._target()._rejectCallback(t,!1,!0)},e.prototype.cancel=function(t){return this.isCancellable()?(void 0===t&&(t=new i),n.invokeLater(this._cancel,this,t),this):this},e.prototype.cancellable=function(){return this._cancellable()?this:(n.enableTrampoline(),this._setCancellable(),this._cancellationParent=void 0,this)},e.prototype.uncancellable=function(){var t=this.then();return t._unsetCancellable(),t},e.prototype.fork=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);return n._setCancellable(),n._cancellationParent=void 0,n}}},{"./async.js":2,"./errors.js":13}],7:[function(t,e){"use strict";e.exports=function(){function e(t){this._parent=t;var r=this._length=1+(void 0===t?0:t._length);j(this,e),r>32&&this.uncycle()}function r(t,e){for(var r=0;r=0;--a)if(n[a]===o){s=a;break}for(var a=s;a>=0;--a){var u=n[a];if(e[i]!==u)break;e.pop(),i--}e=n}}function o(t){for(var e=[],r=0;r0&&(e=e.slice(r)),e}function a(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t.toString();var r=/\[object [a-zA-Z0-9$_]+\]/;if(r.test(e))try{var n=JSON.stringify(t);e=n}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+u(e)+">, no stack trace)"}function u(t){var e=41;return t.lengtht)){for(var e=[],r={},n=0,i=this;void 0!==i;++n)e.push(i),i=i._parent;t=this._length=n;for(var n=t-1;n>=0;--n){var o=e[n].stack;void 0===r[o]&&(r[o]=n)}for(var n=0;t>n;++n){var s=e[n].stack,a=r[s];if(void 0!==a&&a!==n){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var u=n>0?e[n-1]:this;t-1>a?(u._parent=e[a+1],u._parent.uncycle(),u._length=u._parent._length+1):(u._parent=void 0,u._length=1);for(var c=u._length+1,l=n-2;l>=0;--l)e[l]._length=c,c++;return}}}},e.prototype.parent=function(){return this._parent},e.prototype.hasParent=function(){return void 0!==this._parent},e.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var s=e.parseStackAndMessage(t),a=s.message,u=[s.stack],c=this;void 0!==c;)u.push(o(c.stack.split("\n"))),c=c._parent;i(u),n(u),p.notEnumerableProp(t,"stack",r(a,u)),p.notEnumerableProp(t,"__stackCleaned__",!0)}},e.parseStackAndMessage=function(t){var e=t.stack,r=t.toString();return e="string"==typeof e&&e.length>0?s(t):[" (No stack trace)"],{message:r,stack:o(e)}},e.formatAndLogError=function(t,e){if("undefined"!=typeof console){var r;if("object"==typeof t||"function"==typeof t){var n=t.stack;r=e+d(n,t)}else r=e+String(t);"function"==typeof l?l(r):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}},e.unhandledRejection=function(t){e.formatAndLogError(t,"^--- With additional stack trace: ")},e.isSupported=function(){return"function"==typeof j},e.fireRejectionEvent=function(t,r,n,i){var o=!1;try{"function"==typeof r&&(o=!0,"rejectionHandled"===t?r(i):r(n,i))}catch(s){h.throwLater(s)}var a=!1;try{a=b(t,n,i)}catch(s){a=!0,h.throwLater(s)}var u=!1;if(m)try{u=m(t.toLowerCase(),{reason:n,promise:i})}catch(s){u=!0,h.throwLater(s)}a||o||u||"unhandledRejection"!==t||e.formatAndLogError(n,"Unhandled rejection ")};var y=function(){return!1},g=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;e.setBounds=function(t,r){if(e.isSupported()){for(var n,i,o=t.stack.split("\n"),s=r.stack.split("\n"),a=-1,u=-1,l=0;la||0>u||!n||!i||n!==i||a>=u||(y=function(t){if(f.test(t))return!0;var e=c(t);return e&&e.fileName===n&&a<=e.line&&e.line<=u?!0:!1})}};var m,j=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():a(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit=Error.stackTraceLimit+6,_=t,d=e;var r=Error.captureStackTrace;return y=function(t){return f.test(t)},function(t,e){Error.stackTraceLimit=Error.stackTraceLimit+6,r(t,e),Error.stackTraceLimit=Error.stackTraceLimit-6}}var n=new Error;if("string"==typeof n.stack&&n.stack.split("\n")[0].indexOf("stackDetection@")>=0)return _=/@/,d=e,v=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in n||!i?(d=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?a(e):e.toString()},null):(_=t,d=e,function(t){Error.stackTraceLimit=Error.stackTraceLimit+6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit=Error.stackTraceLimit-6})}([]),b=function(){if(p.isNode)return function(t,e,r){return"rejectionHandled"===t?process.emit(t,r):process.emit(t,e,r)};var t=!1,e=!0;try{var r=new self.CustomEvent("test");t=r instanceof CustomEvent}catch(n){}if(!t)try{var i=document.createEvent("CustomEvent");i.initCustomEvent("testingtheevent",!1,!0,{}),self.dispatchEvent(i)}catch(n){e=!1}e&&(m=function(e,r){var n;return t?n=new self.CustomEvent(e,{detail:r,bubbles:!1,cancelable:!0}):self.dispatchEvent&&(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!1,!0,r)),n?!self.dispatchEvent(n):!1});var o={};return o.unhandledRejection="onunhandledRejection".toLowerCase(),o.rejectionHandled="onrejectionHandled".toLowerCase(),function(t,e,r){var n=o[t],i=self[n];return i?("rejectionHandled"===t?i.call(self,r):i.call(self,e,r),!0):!1}}();return"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(l=function(t){console.warn(t)},p.isNode&&process.stderr.isTTY?l=function(t){process.stderr.write(""+t+"\n")}:p.isNode||"string"!=typeof(new Error).stack||(l=function(t){console.warn("%c"+t,"color: red")})),e}},{"./async.js":2,"./util.js":38}],8:[function(t,e){"use strict";e.exports=function(e){function r(t,e,r){this._instances=t,this._callback=e,this._promise=r}function n(t,e){var r={},n=s(t).call(r,e);if(n===a)return n;var i=u(r);return i.length?(a.e=new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"),a):n}var i=t("./util.js"),o=t("./errors.js"),s=i.tryCatch,a=i.errorObj,u=t("./es5.js").keys,c=o.TypeError;return r.prototype.doFilter=function(t){for(var r=this._callback,i=this._promise,o=i._boundTo,u=0,c=this._instances.length;c>u;++u){var l=this._instances[u],h=l===Error||null!=l&&l.prototype instanceof Error;if(h&&t instanceof l){var p=s(r).call(o,t);return p===a?(e.e=p.e,e):p}if("function"==typeof l&&!h){var f=n(l,t);if(f===a){t=a.e;break}if(f){var p=s(r).call(o,t);return p===a?(e.e=p.e,e):p}}}return e.e=t,e},r}},{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(t,e){"use strict";e.exports=function(t,e,r){function n(){this._trace=new e(o())}function i(){return r()?new n:void 0}function o(){var t=s.length-1;return t>=0?s[t]:void 0}var s=[];return n.prototype._pushContext=function(){r()&&void 0!==this._trace&&s.push(this._trace)},n.prototype._popContext=function(){r()&&void 0!==this._trace&&s.pop()},t.prototype._peekContext=o,t.prototype._pushContext=n.prototype._pushContext,t.prototype._popContext=n.prototype._popContext,i}},{}],10:[function(t,e){"use strict";e.exports=function(e,r){var n,i,o=t("./async.js"),s=t("./errors.js").Warning,a=t("./util.js"),u=a.canAttachTrace,c=!1||a.isNode&&(!!process.env.BLUEBIRD_DEBUG||"development"===process.env.NODE_ENV);return c&&o.disableTrampolineIfNecessary(),e.prototype._ensurePossibleRejectionHandled=function(){this._setRejectionIsUnhandled(),o.invokeLater(this._notifyUnhandledRejection,this,void 0)},e.prototype._notifyUnhandledRejectionIsHandled=function(){r.fireRejectionEvent("rejectionHandled",n,void 0,this)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._getCarriedStackTrace()||this._settledValue;this._setUnhandledRejectionIsNotified(),r.fireRejectionEvent("unhandledRejection",i,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=524288|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-524289&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(524288&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=2097152|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-2097153&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(2097152&this._bitField)>0},e.prototype._setCarriedStackTrace=function(t){this._bitField=1048576|this._bitField,this._fulfillmentHandler0=t},e.prototype._isCarryingStackTrace=function(){return(1048576&this._bitField)>0},e.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},e.prototype._captureStackTrace=function(){return c&&(this._trace=new r(this._peekContext())),this},e.prototype._attachExtraTrace=function(t,e){if(c&&u(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var i=r.parseStackAndMessage(t);a.notEnumerableProp(t,"stack",i.message+"\n"+i.stack.join("\n")),a.notEnumerableProp(t,"__stackCleaned__",!0)}}},e.prototype._warn=function(t){var e=new s(t),n=this._peekContext();if(n)n.attachExtraTrace(e);else{var i=r.parseStackAndMessage(e);e.stack=i.message+"\n"+i.stack.join("\n")}r.formatAndLogError(e,"")},e.onPossiblyUnhandledRejection=function(t){i="function"==typeof t?t:void 0},e.onUnhandledRejectionHandled=function(t){n="function"==typeof t?t:void 0},e.longStackTraces=function(){if(o.haveItemsQueued()&&c===!1)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/DT1qyG\n");c=r.isSupported(),c&&o.disableTrampolineIfNecessary()},e.hasLongStackTraces=function(){return c&&r.isSupported()},r.isSupported()||(e.longStackTraces=function(){},c=!1),function(){return c}}},{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(t,e){"use strict";var r=t("./util.js"),n=r.isPrimitive,i=r.wrapsPrimitiveReceiver;e.exports=function(t){var e=function(){return this},r=function(){throw this},o=function(t,e){return 1===e?function(){throw t}:2===e?function(){return t}:void 0};t.prototype["return"]=t.prototype.thenReturn=function(t){return i&&n(t)?this._then(o(t,2),void 0,void 0,void 0,void 0):this._then(e,void 0,void 0,t,void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return i&&n(t)?this._then(o(t,1),void 0,void 0,void 0,void 0):this._then(r,void 0,void 0,t,void 0)}}},{"./util.js":38}],12:[function(t,e){"use strict";e.exports=function(t,e){var r=t.reduce;t.prototype.each=function(t){return r(this,t,null,e)},t.each=function(t,n){return r(t,n,null,e)}}},{}],13:[function(t,e){"use strict";function r(t,e){function r(n){return this instanceof r?(l(this,"message","string"==typeof n?n:e),l(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return c(r,Error),r}function n(t){return this instanceof n?(l(this,"name","OperationalError"),l(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(l(this,"message",t.message),l(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new n(t)}var i,o,s=t("./es5.js"),a=s.freeze,u=t("./util.js"),c=u.inherits,l=u.notEnumerableProp,h=r("Warning","warning"),p=r("CancellationError","cancellation error"),f=r("TimeoutError","timeout error"),_=r("AggregateError","aggregate error");try{i=TypeError,o=RangeError}catch(d){i=r("TypeError","type error"),o=r("RangeError","range error")}for(var v="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),y=0;y0&&"function"==typeof arguments[e]){t=arguments[e];var n}for(var i=arguments.length,o=new Array(i),s=0;i>s;++s)o[s]=arguments[s];t&&o.pop();var n=new r(o).promise();return void 0!==t?n.spread(t):n}}},{"./util.js":38}],19:[function(t,e){"use strict";e.exports=function(e,r,n,i,o){function s(t,e,r,n){this.constructor$(t),this._promise._captureStackTrace(),this._callback=e,this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:_,c.invoke(a,this,void 0)}function a(){this._init$(void 0,-2)}function u(t,e,r,n){var i="object"==typeof r&&null!==r?r.concurrency:0;return i="number"==typeof i&&isFinite(i)&&i>=1?i:0,new s(t,e,i,n)}var c=t("./async.js"),l=t("./util.js"),h=l.tryCatch,p=l.errorObj,f={},_=[];l.inherits(s,r),s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,a=this._limit;if(n[r]===f){if(n[r]=t,a>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return}else{if(a>=1&&this._inFlight>=a)return n[r]=t,void this._queue.push(r);null!==s&&(s[r]=t);var u=this._callback,c=this._promise._boundTo;this._promise._pushContext();var l=h(u).call(c,t,r,o);if(this._promise._popContext(),l===p)return this._reject(l.e);var _=i(l,this._promise);if(_ instanceof e){if(_=_._target(),_._isPending())return a>=1&&this._inFlight++,n[r]=f,_._proxyPromiseArray(this,r);if(!_._isFulfilled())return this._reject(_._reason());l=_._value()}n[r]=l}var d=++this._totalResolved;d>=o&&(null!==s?this._filter(n,s):this._resolve(n))},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlighto;++o)t[o]&&(n[i++]=e[o]);n.length=i,this._resolve(n)},s.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return"function"!=typeof t?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(this,t,e,null).promise()},e.map=function(t,e,r,i){return"function"!=typeof e?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(t,e,r,i).promise()}}},{"./async.js":2,"./util.js":38}],20:[function(t,e){"use strict";e.exports=function(e,r,n,i){var o=t("./util.js"),s=o.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("fn must be a function\n\n See http://goo.gl/916lJJ\n");return function(){var n=new e(r);n._captureStackTrace(),n._pushContext();var i=s(t).apply(this,arguments);return n._popContext(),n._resolveFromSyncValue(i),n}},e.attempt=e["try"]=function(t,n,a){if("function"!=typeof t)return i("fn must be a function\n\n See http://goo.gl/916lJJ\n");var u=new e(r);u._captureStackTrace(),u._pushContext();var c=o.isArray(n)?s(t).apply(a,n):s(t).call(a,n);return u._popContext(),u._resolveFromSyncValue(c),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1,!0):this._resolveCallback(t,!0)}}},{"./util.js":38}],21:[function(t,e){"use strict";e.exports=function(e){function r(t,e){var r=this;if(!o.isArray(t))return n.call(r,t,e);var i=a(e).apply(r._boundTo,[null].concat(t));i===u&&s.throwLater(i.e)}function n(t,e){var r=this,n=r._boundTo,i=void 0===t?a(e).call(n,null):a(e).call(n,null,t);i===u&&s.throwLater(i.e)}function i(t,e){var r=this;if(!t){var n=r._target(),i=n._getCarriedStackTrace();i.cause=t,t=i}var o=a(e).call(r._boundTo,t);o===u&&s.throwLater(o.e)}var o=t("./util.js"),s=t("./async.js"),a=o.tryCatch,u=o.errorObj;e.prototype.asCallback=e.prototype.nodeify=function(t,e){if("function"==typeof t){var o=n;void 0!==e&&Object(e).spread&&(o=r),this._then(o,i,void 0,this,t)}return this}}},{"./async.js":2,"./util.js":38}],22:[function(t,e){"use strict";e.exports=function(e,r){var n=t("./util.js"),i=t("./async.js"),o=n.tryCatch,s=n.errorObj;e.prototype.progressed=function(t){return this._then(void 0,void 0,t,void 0,void 0)},e.prototype._progress=function(t){this._isFollowingOrFulfilledOrRejected()||this._target()._progressUnchecked(t)},e.prototype._progressHandlerAt=function(t){return 0===t?this._progressHandler0:this[(t<<2)+t-5+2]},e.prototype._doProgressWith=function(t){var r=t.value,i=t.handler,a=t.promise,u=t.receiver,c=o(i).call(u,r);if(c===s){if(null!=c.e&&"StopProgressPropagation"!==c.e.name){var l=n.canAttachTrace(c.e)?c.e:new Error(n.toString(c.e));a._attachExtraTrace(l),a._progress(c.e)}}else c instanceof e?c._then(a._progress,null,null,a,void 0):a._progress(c)},e.prototype._progressUnchecked=function(t){for(var n=this._length(),o=this._progress,s=0;n>s;s++){var a=this._progressHandlerAt(s),u=this._promiseAt(s);if(u instanceof e)"function"==typeof a?i.invoke(this._doProgressWith,this,{handler:a,promise:u,receiver:this._receiverAt(s),value:t}):i.invoke(o,u,t);else{var c=this._receiverAt(s);"function"==typeof a?a.call(c,t,u):c instanceof r&&!c._isResolved()&&c._promiseProgressed(t,u)}}}}},{"./async.js":2,"./util.js":38}],23:[function(t,e){"use strict";e.exports=function(){function e(t){if("function"!=typeof t)throw new c("the promise constructor requires a resolver function\n\n See http://goo.gl/EC22Yn\n");if(this.constructor!==e)throw new c("the promise constructor cannot be invoked directly\n\n See http://goo.gl/KsIlge\n");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._progressHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,t!==l&&this._resolveFromResolver(t)}function r(t){var r=new e(l);r._fulfillmentHandler0=t,r._rejectionHandler0=t,r._progressHandler0=t,r._promise0=t,r._receiver0=t,r._settledValue=t}var n=function(){return new c("circular promise resolution chain\n\n See http://goo.gl/LhFpo0\n")},i=function(){return new e.PromiseInspection(this._target())},o=function(t){return e.reject(new c(t))},s=t("./util.js"),a=t("./async.js"),u=t("./errors.js"),c=e.TypeError=u.TypeError;e.RangeError=u.RangeError,e.CancellationError=u.CancellationError,e.TimeoutError=u.TimeoutError,e.OperationalError=u.OperationalError,e.RejectionError=u.OperationalError,e.AggregateError=u.AggregateError;var l=function(){},h={},p={e:null},f=t("./thenables.js")(e,l),_=t("./promise_array.js")(e,l,f,o),d=t("./captured_trace.js")(),v=t("./debuggability.js")(e,d),y=t("./context.js")(e,d,v),g=t("./catch_filter.js")(p),m=t("./promise_resolver.js"),j=m._nodebackForPromise,b=s.errorObj,w=s.tryCatch;return e.prototype.toString=function(){return"[object Promise]"},e.prototype.caught=e.prototype["catch"]=function(t){var r=arguments.length;if(r>1){var n,i=new Array(r-1),o=0;for(n=0;r-1>n;++n){var s=arguments[n];if("function"!=typeof s)return e.reject(new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"));i[o++]=s}i.length=o,t=arguments[n];var a=new g(i,t,this);return this._then(void 0,a.doFilter,void 0,a,void 0)}return this._then(void 0,t,void 0,void 0,void 0)},e.prototype.reflect=function(){return this._then(i,i,void 0,this,void 0)},e.prototype.then=function(t,e,r){if(v()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+s.classString(t);arguments.length>1&&(n+=", "+s.classString(e)),this._warn(n)}return this._then(t,e,r,void 0,void 0)},e.prototype.done=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);n._setIsFinal()},e.prototype.spread=function(t,e){return this.all()._then(t,e,void 0,h,void 0)},e.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},e.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0}; +return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},e.prototype.all=function(){return new _(this).promise()},e.prototype.error=function(t){return this.caught(s.originatesFromRejection,t)},e.is=function(t){return t instanceof e},e.fromNode=function(t){var r=new e(l),n=w(t)(j(r));return n===b&&r._rejectCallback(n.e,!0,!0),r},e.all=function(t){return new _(t).promise()},e.defer=e.pending=function(){var t=new e(l);return new m(t)},e.cast=function(t){var r=f(t);if(!(r instanceof e)){var n=r;r=new e(l),r._fulfillUnchecked(n)}return r},e.resolve=e.fulfilled=e.cast,e.reject=e.rejected=function(t){var r=new e(l);return r._captureStackTrace(),r._rejectCallback(t,!0),r},e.setScheduler=function(t){if("function"!=typeof t)throw new c("fn must be a function\n\n See http://goo.gl/916lJJ\n");var e=a._schedule;return a._schedule=t,e},e.prototype._then=function(t,r,n,i,o){var s=void 0!==o,u=s?o:new e(l);s||(u._propagateFrom(this,5),u._captureStackTrace());var c=this._target();c!==this&&(void 0===i&&(i=this._boundTo),s||u._setIsMigrated());var h=c._addCallbacks(t,r,n,u,i);return c._isResolved()&&!c._isSettlePromisesQueued()&&a.invoke(c._settlePromiseAtPostResolution,c,h),u},e.prototype._settlePromiseAtPostResolution=function(t){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),this._settlePromiseAt(t)},e.prototype._length=function(){return 131071&this._bitField},e.prototype._isFollowingOrFulfilledOrRejected=function(){return(939524096&this._bitField)>0},e.prototype._isFollowing=function(){return 536870912===(536870912&this._bitField)},e.prototype._setLength=function(t){this._bitField=-131072&this._bitField|131071&t},e.prototype._setFulfilled=function(){this._bitField=268435456|this._bitField},e.prototype._setRejected=function(){this._bitField=134217728|this._bitField},e.prototype._setFollowing=function(){this._bitField=536870912|this._bitField},e.prototype._setIsFinal=function(){this._bitField=33554432|this._bitField},e.prototype._isFinal=function(){return(33554432&this._bitField)>0},e.prototype._cancellable=function(){return(67108864&this._bitField)>0},e.prototype._setCancellable=function(){this._bitField=67108864|this._bitField},e.prototype._unsetCancellable=function(){this._bitField=-67108865&this._bitField},e.prototype._setIsMigrated=function(){this._bitField=4194304|this._bitField},e.prototype._unsetIsMigrated=function(){this._bitField=-4194305&this._bitField},e.prototype._isMigrated=function(){return(4194304&this._bitField)>0},e.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[5*t-5+4];return void 0===e&&this._isBound()?this._boundTo:e},e.prototype._promiseAt=function(t){return 0===t?this._promise0:this[5*t-5+3]},e.prototype._fulfillmentHandlerAt=function(t){return 0===t?this._fulfillmentHandler0:this[5*t-5+0]},e.prototype._rejectionHandlerAt=function(t){return 0===t?this._rejectionHandler0:this[5*t-5+1]},e.prototype._migrateCallbacks=function(t,r){var n=t._fulfillmentHandlerAt(r),i=t._rejectionHandlerAt(r),o=t._progressHandlerAt(r),s=t._promiseAt(r),a=t._receiverAt(r);s instanceof e&&s._setIsMigrated(),this._addCallbacks(n,i,o,s,a)},e.prototype._addCallbacks=function(t,e,r,n,i){var o=this._length();if(o>=131066&&(o=0,this._setLength(0)),0===o)this._promise0=n,void 0!==i&&(this._receiver0=i),"function"!=typeof t||this._isCarryingStackTrace()||(this._fulfillmentHandler0=t),"function"==typeof e&&(this._rejectionHandler0=e),"function"==typeof r&&(this._progressHandler0=r);else{var s=5*o-5;this[s+3]=n,this[s+4]=i,"function"==typeof t&&(this[s+0]=t),"function"==typeof e&&(this[s+1]=e),"function"==typeof r&&(this[s+2]=r)}return this._setLength(o+1),o},e.prototype._setProxyHandlers=function(t,e){var r=this._length();if(r>=131066&&(r=0,this._setLength(0)),0===r)this._promise0=e,this._receiver0=t;else{var n=5*r-5;this[n+3]=e,this[n+4]=t}this._setLength(r+1)},e.prototype._proxyPromiseArray=function(t,e){this._setProxyHandlers(t,e)},e.prototype._resolveCallback=function(t,r){if(!this._isFollowingOrFulfilledOrRejected()){if(t===this)return this._rejectCallback(n(),!1,!0);var i=f(t,this);if(!(i instanceof e))return this._fulfill(t);var o=1|(r?4:0);this._propagateFrom(i,o);var s=i._target();if(s._isPending()){for(var a=this._length(),u=0;a>u;++u)s._migrateCallbacks(this,u);this._setFollowing(),this._setLength(0),this._setFollowee(s)}else s._isFulfilled()?this._fulfillUnchecked(s._value()):this._rejectUnchecked(s._reason(),s._getCarriedStackTrace())}},e.prototype._rejectCallback=function(t,e,r){r||s.markAsOriginatingFromRejection(t);var n=s.ensureErrorObject(t),i=n===t;this._attachExtraTrace(n,e?i:!1),this._reject(t,i?void 0:n)},e.prototype._resolveFromResolver=function(t){var e=this;this._captureStackTrace(),this._pushContext();var r=!0,n=w(t)(function(t){null!==e&&(e._resolveCallback(t),e=null)},function(t){null!==e&&(e._rejectCallback(t,r),e=null)});r=!1,this._popContext(),void 0!==n&&n===b&&null!==e&&(e._rejectCallback(n.e,!0,!0),e=null)},e.prototype._settlePromiseFromHandler=function(t,e,r,i){if(!i._isRejected()){i._pushContext();var o;if(o=e!==h||this._isRejected()?w(t).call(e,r):w(t).apply(this._boundTo,r),i._popContext(),o===b||o===i||o===p){var s=o===i?n():o.e;i._rejectCallback(s,!1,!0)}else i._resolveCallback(o)}},e.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},e.prototype._followee=function(){return this._rejectionHandler0},e.prototype._setFollowee=function(t){this._rejectionHandler0=t},e.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},e.prototype._propagateFrom=function(t,e){(1&e)>0&&t._cancellable()&&(this._setCancellable(),this._cancellationParent=t),(4&e)>0&&t._isBound()&&this._setBoundTo(t._boundTo)},e.prototype._fulfill=function(t){this._isFollowingOrFulfilledOrRejected()||this._fulfillUnchecked(t)},e.prototype._reject=function(t,e){this._isFollowingOrFulfilledOrRejected()||this._rejectUnchecked(t,e)},e.prototype._settlePromiseAt=function(t){var r=this._promiseAt(t),n=r instanceof e;if(n&&r._isMigrated())return r._unsetIsMigrated(),a.invoke(this._settlePromiseAt,this,t);var i=this._isFulfilled()?this._fulfillmentHandlerAt(t):this._rejectionHandlerAt(t),o=this._isCarryingStackTrace()?this._getCarriedStackTrace():void 0,s=this._settledValue,u=this._receiverAt(t);this._clearCallbackDataAtIndex(t),"function"==typeof i?n?this._settlePromiseFromHandler(i,u,s,r):i.call(u,s,r):u instanceof _?u._isResolved()||(this._isFulfilled()?u._promiseFulfilled(s,r):u._promiseRejected(s,r)):n&&(this._isFulfilled()?r._fulfill(s):r._reject(s,o)),t>=4&&4===(31&t)&&a.invokeLater(this._setLength,this,0)},e.prototype._clearCallbackDataAtIndex=function(t){if(0===t)this._isCarryingStackTrace()||(this._fulfillmentHandler0=void 0),this._rejectionHandler0=this._progressHandler0=this._receiver0=this._promise0=void 0;else{var e=5*t-5;this[e+3]=this[e+4]=this[e+0]=this[e+1]=this[e+2]=void 0}},e.prototype._isSettlePromisesQueued=function(){return-1073741824===(-1073741824&this._bitField)},e.prototype._setSettlePromisesQueued=function(){this._bitField=-1073741824|this._bitField},e.prototype._unsetSettlePromisesQueued=function(){this._bitField=1073741823&this._bitField},e.prototype._queueSettlePromises=function(){a.settlePromises(this),this._setSettlePromisesQueued()},e.prototype._fulfillUnchecked=function(t){if(t===this){var e=n();return this._attachExtraTrace(e),this._rejectUnchecked(e,void 0)}this._setFulfilled(),this._settledValue=t,this._cleanValues(),this._length()>0&&this._queueSettlePromises()},e.prototype._rejectUncheckedCheckError=function(t){var e=s.ensureErrorObject(t);this._rejectUnchecked(t,e===t?void 0:e)},e.prototype._rejectUnchecked=function(t,e){if(t===this){var r=n();return this._attachExtraTrace(r),this._rejectUnchecked(r)}return this._setRejected(),this._settledValue=t,this._cleanValues(),this._isFinal()?void a.throwLater(function(t){throw"stack"in t&&a.invokeFirst(d.unhandledRejection,void 0,t),t},void 0===e?t:e):(void 0!==e&&e!==t&&this._setCarriedStackTrace(e),void(this._length()>0?this._queueSettlePromises():this._ensurePossibleRejectionHandled()))},e.prototype._settlePromises=function(){this._unsetSettlePromisesQueued();for(var t=this._length(),e=0;t>e;e++)this._settlePromiseAt(e)},e._makeSelfResolutionError=n,t("./progress.js")(e,_),t("./method.js")(e,l,f,o),t("./bind.js")(e,l,f),t("./finally.js")(e,p,f),t("./direct_resolve.js")(e),t("./synchronous_inspection.js")(e),t("./join.js")(e,_,f,l),e.Promise=e,t("./map.js")(e,_,o,f,l),t("./cancel.js")(e),t("./using.js")(e,o,f,y),t("./generators.js")(e,o,l,f),t("./nodeify.js")(e),t("./call_get.js")(e),t("./props.js")(e,_,f,o),t("./race.js")(e,l,f,o),t("./reduce.js")(e,_,o,f,l),t("./settle.js")(e,_),t("./some.js")(e,_,o),t("./promisify.js")(e,l),t("./any.js")(e),t("./each.js")(e,l),t("./timers.js")(e,l),t("./filter.js")(e,l),s.toFastProperties(e),s.toFastProperties(e.prototype),r({a:1}),r({b:2}),r({c:3}),r(1),r(function(){}),r(void 0),r(!1),r(new e(l)),d.setBounds(a.firstLineError,s.lastLineError),e}},{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var n,i=this._promise=new e(r);t instanceof e&&(n=t,i._propagateFrom(n,5)),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var a=t("./util.js"),u=a.isArray;return s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function c(t,r){var s=n(this._values,this._promise);if(s instanceof e){if(s=s._target(),this._values=s,!s._isFulfilled())return s._isPending()?void s._then(c,this._reject,void 0,this,r):void this._reject(s._reason());if(s=s._value(),!u(s)){var a=new e.TypeError("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");return void this.__hardReject__(a)}}else if(!u(s))return void this._promise._reject(i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n")._reason());if(0===s.length)return void(-5===r?this._resolveEmptyArray():this._resolve(o(r)));var l=this.getActualLength(s.length);this._length=l,this._values=this.shouldCopyValues()?new Array(l):this._values;for(var h=this._promise,p=0;l>p;++p){var f=this._isResolved(),_=n(s[p],h);_ instanceof e?(_=_._target(),f?_._unsetRejectionIsUnhandled():_._isPending()?_._proxyPromiseArray(this,p):_._isFulfilled()?this._promiseFulfilled(_._value(),p):this._promiseRejected(_._reason(),p)):f||this._promiseFulfilled(_,p)}},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype.__hardReject__=s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1,!0)},s.prototype._promiseProgressed=function(t,e){this._promise._progress({index:e,value:t})},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},s.prototype._promiseRejected=function(t){this._totalResolved++,this._reject(t)},s.prototype.shouldCopyValues=function(){return!0},s.prototype.getActualLength=function(t){return t},s}},{"./util.js":38}],25:[function(t,e){"use strict";function r(t){return t instanceof Error&&p.getPrototypeOf(t)===Error.prototype}function n(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=p.keys(t),i=0;i2){for(var o=arguments.length,s=new Array(o-1),u=1;o>u;++u)s[u-1]=arguments[u];t._fulfill(s)}else t._fulfill(r);t=null}}}var o,s=t("./util.js"),a=s.maybeWrapAsError,u=t("./errors.js"),c=u.TimeoutError,l=u.OperationalError,h=s.haveGetters,p=t("./es5.js"),f=/^(?:name|message|stack|cause)$/;if(o=h?function(t){this.promise=t}:function(t){this.promise=t,this.asCallback=i(t),this.callback=this.asCallback},h){var _={get:function(){return i(this.promise)}};p.defineProperty(o.prototype,"asCallback",_),p.defineProperty(o.prototype,"callback",_)}o._nodebackForPromise=i,o.prototype.toString=function(){return"[object PromiseResolver]"},o.prototype.resolve=o.prototype.fulfill=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._resolveCallback(t)},o.prototype.reject=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._rejectCallback(t)},o.prototype.progress=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._progress(t)},o.prototype.cancel=function(t){this.promise.cancel(t)},o.prototype.timeout=function(){this.reject(new c("timeout"))},o.prototype.isResolved=function(){return this.promise.isResolved()},o.prototype.toJSON=function(){return this.promise.toJSON()},e.exports=o},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(t,e){"use strict";e.exports=function(e,r){function n(t){return!b.test(t)}function i(t){try{return t.__isPromisified__===!0}catch(e){return!1}}function o(t,e,r){var n=f.getDataPropertyOrDefault(t,e+r,j);return n?i(n):!1}function s(t,e,r){for(var n=0;ns;s+=2){var c=o[s],l=o[s+1],h=c+e;t[h]=n===E?E(c,p,c,l,e):n(l,function(){return E(c,p,c,l,e)})}return f.toFastProperties(t),t}function l(t,e){return E(t,e,void 0,t)}var h,p={},f=t("./util.js"),_=t("./promise_resolver.js")._nodebackForPromise,d=f.withAppended,v=f.maybeWrapAsError,y=f.canEvaluate,g=t("./errors").TypeError,m="Async",j={__isPromisified__:!0},b=/^(?:length|name|arguments|caller|callee|prototype|__isPromisified__)$/,w=function(t,e){return f.isIdentifier(t)&&"_"!==t.charAt(0)&&!f.isClass(e)},k=function(t){return t.replace(/([$])/,"\\$")},E=y?h:u;e.promisify=function(t,e){if("function"!=typeof t)throw new g("fn must be a function\n\n See http://goo.gl/916lJJ\n");if(i(t))return t;var r=l(t,arguments.length<2?p:e);return f.copyDescriptors(t,r,n),r},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new g("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/9ITlV0\n");e=Object(e);var r=e.suffix;"string"!=typeof r&&(r=m);var n=e.filter;"function"!=typeof n&&(n=w);var i=e.promisifier;if("function"!=typeof i&&(i=E),!f.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/8FZo5V\n");for(var o=f.inheritedDataKeys(t),s=0;si;++i){var o=e[i];n[i]=t[o],n[i+r]=o}this.constructor$(n)}function s(t){var r,s=n(t);return u(s)?(r=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&r._propagateFrom(s,4),r):i("cannot await properties of a non-object\n\n See http://goo.gl/OsFKC8\n")}var a=t("./util.js"),u=a.isObject,c=t("./es5.js");a.inherits(o,r),o.prototype._init=function(){this._init$(void 0,-3)},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){for(var n={},i=this.length(),o=0,s=this.length();s>o;++o)n[this._values[o+i]]=this._values[o];this._resolve(n)}},o.prototype._promiseProgressed=function(t,e){this._promise._progress({key:this._values[e+this.length()],value:t})},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5.js":14,"./util.js":38}],28:[function(t,e){"use strict";function r(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function n(t){this._capacity=t,this._length=0,this._front=0}n.prototype._willBeOverCapacity=function(t){return this._capacityp;++p){var _=t[p];(void 0!==_||p in t)&&e.cast(_)._then(l,h,void 0,c,null)}return c}var s=t("./util.js").isArray,a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util.js":38}],30:[function(t,e){"use strict";e.exports=function(e,r,n,i,o){function s(t,r,n,s){this.constructor$(t),this._promise._captureStackTrace(),this._preservedValues=s===o?[]:null,this._zerothIsAccum=void 0===n,this._gotAccum=!1,this._reducingIndex=this._zerothIsAccum?1:0,this._valuesPhase=void 0;var u=i(n,this._promise),l=!1,h=u instanceof e;h&&(u=u._target(),u._isPending()?u._proxyPromiseArray(this,-1):u._isFulfilled()?(n=u._value(),this._gotAccum=!0):(this._reject(u._reason()),l=!0)),h||this._zerothIsAccum||(this._gotAccum=!0),this._callback=r,this._accum=n,l||c.invoke(a,this,void 0)}function a(){this._init$(void 0,-5)}function u(t,e,r,i){if("function"!=typeof e)return n("fn must be a function\n\n See http://goo.gl/916lJJ\n");var o=new s(t,e,r,i);return o.promise()}var c=t("./async.js"),l=t("./util.js"),h=l.tryCatch,p=l.errorObj;l.inherits(s,r),s.prototype._init=function(){},s.prototype._resolveEmptyArray=function(){(this._gotAccum||this._zerothIsAccum)&&this._resolve(null!==this._preservedValues?[]:this._accum)},s.prototype._promiseFulfilled=function(t,r){var n=this._values;n[r]=t;var o,s=this.length(),a=this._preservedValues,u=null!==a,c=this._gotAccum,l=this._valuesPhase;if(!l)for(l=this._valuesPhase=new Array(s),o=0;s>o;++o)l[o]=0;if(o=l[r],0===r&&this._zerothIsAccum?(this._accum=t,this._gotAccum=c=!0,l[r]=0===o?1:2):-1===r?(this._accum=t,this._gotAccum=c=!0):0===o?l[r]=1:(l[r]=2,this._accum=t),c){for(var f,_=this._callback,d=this._promise._boundTo,v=this._reducingIndex;s>v;++v)if(o=l[v],2!==o){if(1!==o)return;if(t=n[v],this._promise._pushContext(),u?(a.push(t),f=h(_).call(d,t,v,s)):f=h(_).call(d,this._accum,t,v,s),this._promise._popContext(),f===p)return this._reject(f.e);var y=i(f,this._promise);if(y instanceof e){if(y=y._target(),y._isPending())return l[v]=4,y._proxyPromiseArray(this,v);if(!y._isFulfilled())return this._reject(y._reason());f=y._value()}this._reducingIndex=v+1,this._accum=f}else this._reducingIndex=v+1;this._resolve(u?a:this._accum)}},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,r,n){return u(t,e,r,n)}}},{"./async.js":2,"./util.js":38}],31:[function(t,e){"use strict";var r,n=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")};if(t("./util.js").isNode){var i=process.versions.node.split(".").map(Number);r=0===i[0]&&i[1]>10||i[0]>0?global.setImmediate:process.nextTick,r||(r="undefined"!=typeof setImmediate?setImmediate:"undefined"!=typeof setTimeout?setTimeout:n)}else"undefined"!=typeof MutationObserver?(r=function(t){var e=document.createElement("div"),r=new MutationObserver(t);return r.observe(e,{attributes:!0}),function(){e.classList.toggle("foo")}},r.isStatic=!0):r="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:n;e.exports=r},{"./util.js":38}],32:[function(t,e){"use strict";e.exports=function(e,r){function n(t){this.constructor$(t)}var i=e.PromiseInspection,o=t("./util.js");o.inherits(n,r),n.prototype._promiseResolved=function(t,e){this._values[t]=e;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},n.prototype._promiseFulfilled=function(t,e){var r=new i;r._bitField=268435456,r._settledValue=t,this._promiseResolved(e,r)},n.prototype._promiseRejected=function(t,e){var r=new i;r._bitField=134217728,r._settledValue=t,this._promiseResolved(e,r)},e.settle=function(t){return new n(t).promise()},e.prototype.settle=function(){return new n(this).promise()}}},{"./util.js":38}],33:[function(t,e){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer\n\n See http://goo.gl/1wAmHx\n");var r=new i(t),o=r.promise();return r.setHowMany(e),r.init(),o}var s=t("./util.js"),a=t("./errors.js").RangeError,u=t("./errors.js").AggregateError,c=s.isArray;s.inherits(i,r),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=c(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),this._resolve(1===this.howMany()&&this._unwrap?this._values[0]:this._values))},i.prototype._promiseRejected=function(t){if(this._addRejected(t),this.howMany()>this._canPossiblyFulfill()){for(var e=new u,r=this.length();r0},e.prototype.isRejected=t.prototype._isRejected=function(){return(134217728&this._bitField)>0},e.prototype.isPending=t.prototype._isPending=function(){return 0===(402653184&this._bitField)},e.prototype.isResolved=t.prototype._isResolved=function(){return(402653184&this._bitField)>0},t.prototype.isPending=function(){return this._target()._isPending()},t.prototype.isRejected=function(){return this._target()._isRejected()},t.prototype.isFulfilled=function(){return this._target()._isFulfilled()},t.prototype.isResolved=function(){return this._target()._isResolved()},t.prototype._value=function(){return this._settledValue},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue},t.prototype.value=function(){var t=this._target();if(!t.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return t._settledValue},t.prototype.reason=function(){var t=this._target();if(!t.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return t._unsetRejectionIsUnhandled(),t._settledValue},t.PromiseInspection=e}},{}],35:[function(t,e){"use strict";e.exports=function(e,r){function n(t,n){if(c(t)){if(t instanceof e)return t;if(o(t)){var l=new e(r);return t._then(l._fulfillUnchecked,l._rejectUncheckedCheckError,l._progressUnchecked,l,null),l}var h=a.tryCatch(i)(t);if(h===u){n&&n._pushContext();var l=e.reject(h.e);return n&&n._popContext(),l}if("function"==typeof h)return s(t,h,n)}return t}function i(t){return t.then}function o(t){return l.call(t,"_promise0")}function s(t,n,i){function o(r){l&&(t===r?l._rejectCallback(e._makeSelfResolutionError(),!1,!0):l._resolveCallback(r),l=null)}function s(t){l&&(l._rejectCallback(t,p,!0),l=null)}function c(t){l&&"function"==typeof l._progress&&l._progress(t)}var l=new e(r),h=l;i&&i._pushContext(),l._captureStackTrace(),i&&i._popContext();var p=!0,f=a.tryCatch(n).call(t,o,s,c);return p=!1,l&&f===u&&(l._rejectCallback(f.e,!0,!0),l=null),h}var a=t("./util.js"),u=a.errorObj,c=a.isObject,l={}.hasOwnProperty;return n}},{"./util.js":38}],36:[function(t,e){"use strict";e.exports=function(e,r){function n(t){var e=this;return e instanceof Number&&(e=+e),clearTimeout(e),t}function i(t){var e=this;throw e instanceof Number&&(e=+e),clearTimeout(e),t}var o=t("./util.js"),s=e.TimeoutError,a=function(t,e){if(t.isPending()){"string"!=typeof e&&(e="operation timed out");var r=new s(e);o.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._cancel(r)}},u=function(t){return c(+this).thenReturn(t)},c=e.delay=function(t,n){if(void 0===n){n=t,t=void 0;var i=new e(r);return setTimeout(function(){i._fulfill()},n),i}return n=+n,e.resolve(t)._then(u,null,null,n,void 0)};e.prototype.delay=function(t){return c(this,t)},e.prototype.timeout=function(t,e){t=+t;var r=this.then().cancellable();r._cancellationParent=this;var o=setTimeout(function(){a(r,e)},t);return r._then(n,i,void 0,o,void 0)}}},{"./util.js":38}],37:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t){for(var r=t.length,n=0;r>n;++n){var i=t[n];if(i.isRejected())return e.reject(i.error());t[n]=i._settledValue}return t}function s(t){setTimeout(function(){throw t},0)}function a(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,r){function i(){if(o>=u)return c.resolve();var l=a(t[o++]);if(l instanceof e&&l._isDisposable()){try{l=n(l._getDisposer().tryDispose(r),t.promise)}catch(h){return s(h)}if(l instanceof e)return l._then(i,s,null,null,null)}i()}var o=0,u=t.length,c=e.defer();return i(),c.promise}function c(t){var e=new v;return e._settledValue=t,e._bitField=268435456,u(this,e).thenReturn(t)}function l(t){var e=new v;return e._settledValue=t,e._bitField=134217728,u(this,e).thenThrow(t)}function h(t,e,r){this._data=t,this._promise=e,this._context=r}function p(t,e,r){this.constructor$(t,e,r)}function f(t){return h.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}var _=t("./errors.js").TypeError,d=t("./util.js").inherits,v=e.PromiseInspection;h.prototype.data=function(){return this._data},h.prototype.promise=function(){return this._promise},h.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},h.prototype.tryDispose=function(t){var e=this.resource(),r=this._context;void 0!==r&&r._pushContext();var n=null!==e?this.doDispose(e,t):null;return void 0!==r&&r._popContext(),this._promise._unsetDisposable(),this._data=null,n},h.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},d(p,h),p.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},e.using=function(){var t=arguments.length;if(2>t)return r("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return r("fn must be a function\n\n See http://goo.gl/916lJJ\n");t--;for(var s=new Array(t),a=0;t>a;++a){var u=arguments[a];if(h.isDisposer(u)){var p=u;u=u.promise(),u._setDisposable(p)}else{var _=n(u);_ instanceof e&&(u=_._then(f,null,null,{resources:s,index:a},void 0))}s[a]=u}var d=e.settle(s).then(o).then(function(t){d._pushContext();var e;try{e=i.apply(void 0,t)}finally{d._popContext()}return e})._then(c,l,void 0,s,void 0);return s.promise=d,d},e.prototype._setDisposable=function(t){this._bitField=262144|this._bitField,this._disposer=t},e.prototype._isDisposable=function(){return(262144&this._bitField)>0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-262145&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new p(t,this,i());throw new _}}},{"./errors.js":13,"./util.js":38}],38:[function(t,e,r){"use strict";function n(){try{return T.apply(this,arguments)}catch(t){return F.e=t,F}}function i(t){return T=t,n}function o(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t +}function s(t){return!o(t)}function a(t){return o(t)?new Error(v(t)):t}function u(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function c(t,e,r){if(!w.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function l(t,e,r){if(o(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return w.defineProperty(t,e,n),t}function h(t){throw t}function p(t){try{if("function"==typeof t){var e=w.names(t.prototype);return w.isES5?e.length>1:e.length>0&&!(1===e.length&&"constructor"===e[0])}return!1}catch(r){return!1}}function f(t){function e(){}e.prototype=t;for(var r=8;r--;)new e;return t}function _(t){return R.test(t)}function d(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){try{l(t,"isOperational",!0)}catch(e){}}function g(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function m(t){return t instanceof Error&&w.propertyIsWritable(t,"stack")}function j(t){return{}.toString.call(t)}function b(t,e,r){for(var n=w.names(t),i=0;it||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(c=r.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},{}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); \ No newline at end of file diff --git a/examples/node_modules/react-native/node_modules/bluebird/js/main/async.js b/examples/node_modules/react-native/node_modules/bluebird/js/main/async.js index 39f23404..3b5f828c 100644 --- a/examples/node_modules/react-native/node_modules/bluebird/js/main/async.js +++ b/examples/node_modules/react-native/node_modules/bluebird/js/main/async.js @@ -59,6 +59,7 @@ Async.prototype.throwLater = function(fn, arg) { Async.prototype._getDomain = function() {}; +if (!false) { if (util.isNode) { var EventsModule = require("events"); @@ -74,31 +75,32 @@ if (util.isNode) { var descriptor = Object.getOwnPropertyDescriptor(EventsModule, "usingDomains"); - if (!descriptor.configurable) { - process.on("domainsActivated", function() { - Async.prototype._getDomain = domainGetter; - }); - } else { - var usingDomains = false; - Object.defineProperty(EventsModule, "usingDomains", { - configurable: false, - enumerable: true, - get: function() { - return usingDomains; - }, - set: function(value) { - if (usingDomains || !value) return; - usingDomains = true; + if (descriptor) { + if (!descriptor.configurable) { + process.on("domainsActivated", function() { Async.prototype._getDomain = domainGetter; - util.toFastProperties(process); - process.emit("domainsActivated"); - } - }); + }); + } else { + var usingDomains = false; + Object.defineProperty(EventsModule, "usingDomains", { + configurable: false, + enumerable: true, + get: function() { + return usingDomains; + }, + set: function(value) { + if (usingDomains || !value) return; + usingDomains = true; + Async.prototype._getDomain = domainGetter; + util.toFastProperties(process); + process.emit("domainsActivated"); + } + }); + } } - - } } +} function AsyncInvokeLater(fn, receiver, arg) { var domain = this._getDomain(); diff --git a/examples/node_modules/react-native/node_modules/bluebird/package.json b/examples/node_modules/react-native/node_modules/bluebird/package.json index 8d236e27..0f61acfd 100644 --- a/examples/node_modules/react-native/node_modules/bluebird/package.json +++ b/examples/node_modules/react-native/node_modules/bluebird/package.json @@ -1,7 +1,7 @@ { "name": "bluebird", "description": "Full featured Promises/A+ implementation with exceptionally good performance", - "version": "2.9.24", + "version": "2.9.25", "keywords": [ "promise", "performance", @@ -71,9 +71,9 @@ "LICENSE", "zalgo.js" ], - "gitHead": "3f58d8ea478329a2400ab7fa0bd841289b02fc07", - "_id": "bluebird@2.9.24", - "_shasum": "14a2e75f0548323dc35aa440d92007ca154e967c", + "gitHead": "13d7fbfc429422ea2dc9086371b4fd188b42038a", + "_id": "bluebird@2.9.25", + "_shasum": "6e36bd04064d9534c07160b9f7f26c5a738fe16a", "_from": "bluebird@>=2.9.21 <3.0.0", "_npmVersion": "2.7.1", "_nodeVersion": "1.6.2", @@ -88,10 +88,9 @@ } ], "dist": { - "shasum": "14a2e75f0548323dc35aa440d92007ca154e967c", - "tarball": "http://registry.npmjs.org/bluebird/-/bluebird-2.9.24.tgz" + "shasum": "6e36bd04064d9534c07160b9f7f26c5a738fe16a", + "tarball": "http://registry.npmjs.org/bluebird/-/bluebird-2.9.25.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.9.24.tgz", - "readme": "ERROR: No README data found!" + "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.9.25.tgz" } diff --git a/examples/node_modules/react-native/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/package.json b/examples/node_modules/react-native/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/package.json index 8f87f4d2..da92c5d1 100644 --- a/examples/node_modules/react-native/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/package.json +++ b/examples/node_modules/react-native/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/package.json @@ -73,5 +73,5 @@ "_id": "ansi-regex@1.1.1", "_shasum": "41c847194646375e6a1a5d10c3ca054ef9fc980d", "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz", - "_from": "ansi-regex@>=1.1.0 <2.0.0" + "_from": "ansi-regex@>=1.0.0 <2.0.0" } diff --git a/examples/node_modules/react-native/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/package.json b/examples/node_modules/react-native/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/package.json index 8f87f4d2..da92c5d1 100644 --- a/examples/node_modules/react-native/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/package.json +++ b/examples/node_modules/react-native/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex/package.json @@ -73,5 +73,5 @@ "_id": "ansi-regex@1.1.1", "_shasum": "41c847194646375e6a1a5d10c3ca054ef9fc980d", "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz", - "_from": "ansi-regex@>=1.1.0 <2.0.0" + "_from": "ansi-regex@>=1.0.0 <2.0.0" } diff --git a/examples/node_modules/react-native/node_modules/connect/node_modules/buffer-crc32/package.json b/examples/node_modules/react-native/node_modules/connect/node_modules/buffer-crc32/package.json index b421ae93..870a04eb 100644 --- a/examples/node_modules/react-native/node_modules/connect/node_modules/buffer-crc32/package.json +++ b/examples/node_modules/react-native/node_modules/connect/node_modules/buffer-crc32/package.json @@ -19,7 +19,7 @@ }, "main": "index.js", "scripts": { - "test": "./node_modules/.bin/tap tests/*.test.js" + "test": "tap tests/*.test.js" }, "dependencies": {}, "devDependencies": { @@ -48,5 +48,9 @@ "directories": {}, "_shasum": "be3e5382fc02b6d6324956ac1af98aa98b08534c", "_resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz", - "_from": "buffer-crc32@0.2.1" + "_from": "buffer-crc32@0.2.1", + "bugs": { + "url": "https://github.com/brianloveswords/buffer-crc32/issues" + }, + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/connect/node_modules/bytes/package.json b/examples/node_modules/react-native/node_modules/connect/node_modules/bytes/package.json index 443ec48b..0bf74deb 100644 --- a/examples/node_modules/react-native/node_modules/connect/node_modules/bytes/package.json +++ b/examples/node_modules/react-native/node_modules/connect/node_modules/bytes/package.json @@ -32,5 +32,6 @@ "directories": {}, "_shasum": "aad33ec14e3dc2ca74e8e7d451f9ba053ad4f7a0", "_resolved": "https://registry.npmjs.org/bytes/-/bytes-0.2.0.tgz", - "_from": "bytes@0.2.0" + "_from": "bytes@0.2.0", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/connect/node_modules/cookie-signature/package.json b/examples/node_modules/react-native/node_modules/connect/node_modules/cookie-signature/package.json index 9ed13586..a24232bd 100644 --- a/examples/node_modules/react-native/node_modules/connect/node_modules/cookie-signature/package.json +++ b/examples/node_modules/react-native/node_modules/connect/node_modules/cookie-signature/package.json @@ -36,5 +36,6 @@ ], "directories": {}, "_shasum": "44e072148af01e6e8e24afbf12690d68ae698ecb", - "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.1.tgz" + "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.1.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/connect/node_modules/formidable/package.json b/examples/node_modules/react-native/node_modules/connect/node_modules/formidable/package.json index e387f521..1ec5cac8 100644 --- a/examples/node_modules/react-native/node_modules/connect/node_modules/formidable/package.json +++ b/examples/node_modules/react-native/node_modules/connect/node_modules/formidable/package.json @@ -61,5 +61,6 @@ } ], "_shasum": "2b3f4c411cbb5fdd695c44843e2a23514a43231a", - "_resolved": "https://registry.npmjs.org/formidable/-/formidable-1.0.14.tgz" + "_resolved": "https://registry.npmjs.org/formidable/-/formidable-1.0.14.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/connect/node_modules/methods/package.json b/examples/node_modules/react-native/node_modules/connect/node_modules/methods/package.json index 0174ac1a..b748af60 100644 --- a/examples/node_modules/react-native/node_modules/connect/node_modules/methods/package.json +++ b/examples/node_modules/react-native/node_modules/connect/node_modules/methods/package.json @@ -28,5 +28,6 @@ "directories": {}, "_shasum": "277c90f8bef39709645a8371c51c3b6c648e068c", "_resolved": "https://registry.npmjs.org/methods/-/methods-0.0.1.tgz", - "_from": "methods@0.0.1" + "_from": "methods@0.0.1", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/connect/node_modules/pause/package.json b/examples/node_modules/react-native/node_modules/connect/node_modules/pause/package.json index 0095fe1e..9ede822d 100644 --- a/examples/node_modules/react-native/node_modules/connect/node_modules/pause/package.json +++ b/examples/node_modules/react-native/node_modules/connect/node_modules/pause/package.json @@ -27,5 +27,6 @@ "directories": {}, "_shasum": "1d408b3fdb76923b9543d96fb4c9dfd535d9cb5d", "_resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", - "_from": "pause@0.0.1" + "_from": "pause@0.0.1", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/connect/node_modules/send/node_modules/mime/package.json b/examples/node_modules/react-native/node_modules/connect/node_modules/send/node_modules/mime/package.json index fe8821ec..328900db 100644 --- a/examples/node_modules/react-native/node_modules/connect/node_modules/send/node_modules/mime/package.json +++ b/examples/node_modules/react-native/node_modules/connect/node_modules/send/node_modules/mime/package.json @@ -25,14 +25,33 @@ "type": "git" }, "version": "1.2.11", - "readme": "# mime\n\nComprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.\n\n## Install\n\nInstall with [npm](http://github.com/isaacs/npm):\n\n npm install mime\n\n## API - Queries\n\n### mime.lookup(path)\nGet the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.\n\n var mime = require('mime');\n\n mime.lookup('/path/to/file.txt'); // => 'text/plain'\n mime.lookup('file.txt'); // => 'text/plain'\n mime.lookup('.TXT'); // => 'text/plain'\n mime.lookup('htm'); // => 'text/html'\n\n### mime.default_type\nSets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)\n\n### mime.extension(type)\nGet the default extension for `type`\n\n mime.extension('text/html'); // => 'html'\n mime.extension('application/octet-stream'); // => 'bin'\n\n### mime.charsets.lookup()\n\nMap mime-type to charset\n\n mime.charsets.lookup('text/plain'); // => 'UTF-8'\n\n(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)\n\n## API - Defining Custom Types\n\nThe following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).\n\n### mime.define()\n\nAdd custom mime/extension mappings\n\n mime.define({\n 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],\n 'application/x-my-type': ['x-mt', 'x-mtt'],\n // etc ...\n });\n\n mime.lookup('x-sft'); // => 'text/x-some-format'\n\nThe first entry in the extensions array is returned by `mime.extension()`. E.g.\n\n mime.extension('text/x-some-format'); // => 'x-sf'\n\n### mime.load(filepath)\n\nLoad mappings from an Apache \".types\" format file\n\n mime.load('./my_project.types');\n\nThe .types file format is simple - See the `types` dir for examples.\n", - "readmeFilename": "README.md", "bugs": { "url": "https://github.com/broofa/node-mime/issues" }, - "homepage": "https://github.com/broofa/node-mime#readme", "_id": "mime@1.2.11", + "dist": { + "shasum": "58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10", + "tarball": "http://registry.npmjs.org/mime/-/mime-1.2.11.tgz" + }, + "_from": "mime@>=1.2.9 <1.3.0", + "_npmVersion": "1.3.6", + "_npmUser": { + "name": "broofa", + "email": "robert@broofa.com" + }, + "maintainers": [ + { + "name": "broofa", + "email": "robert@broofa.com" + }, + { + "name": "bentomas", + "email": "benjamin@benjaminthomas.org" + } + ], + "directories": {}, "_shasum": "58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10", "_resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz", - "_from": "mime@>=1.2.9 <1.3.0" + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/broofa/node-mime#readme" } diff --git a/examples/node_modules/react-native/node_modules/image-size/package.json b/examples/node_modules/react-native/node_modules/image-size/package.json index af1fae81..34dcedfe 100644 --- a/examples/node_modules/react-native/node_modules/image-size/package.json +++ b/examples/node_modules/react-native/node_modules/image-size/package.json @@ -14,7 +14,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:netroy/image-size.git" + "url": "git+ssh://git@github.com/netroy/image-size.git" }, "keywords": [ "image", @@ -70,5 +70,6 @@ "tarball": "http://registry.npmjs.org/image-size/-/image-size-0.3.5.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/image-size/-/image-size-0.3.5.tgz" + "_resolved": "https://registry.npmjs.org/image-size/-/image-size-0.3.5.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/jstransform/node_modules/base62/package.json b/examples/node_modules/react-native/node_modules/jstransform/node_modules/base62/package.json index 2f6c41f8..541a38c4 100644 --- a/examples/node_modules/react-native/node_modules/jstransform/node_modules/base62/package.json +++ b/examples/node_modules/react-native/node_modules/jstransform/node_modules/base62/package.json @@ -43,5 +43,10 @@ "directories": {}, "_shasum": "7b4174c2f94449753b11c2651c083da841a7b084", "_resolved": "https://registry.npmjs.org/base62/-/base62-0.1.1.tgz", - "_from": "base62@0.1.1" + "_from": "base62@0.1.1", + "bugs": { + "url": "https://github.com/andrew/base62.js/issues" + }, + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/andrew/base62.js#readme" } diff --git a/examples/node_modules/react-native/node_modules/module-deps/node_modules/JSONStream/node_modules/jsonparse/package.json b/examples/node_modules/react-native/node_modules/module-deps/node_modules/JSONStream/node_modules/jsonparse/package.json index 3cf3cd5a..45edae5e 100644 --- a/examples/node_modules/react-native/node_modules/module-deps/node_modules/JSONStream/node_modules/jsonparse/package.json +++ b/examples/node_modules/react-native/node_modules/module-deps/node_modules/JSONStream/node_modules/jsonparse/package.json @@ -12,7 +12,7 @@ }, "repository": { "type": "git", - "url": "http://github.com/creationix/jsonparse.git" + "url": "git+ssh://git@github.com/creationix/jsonparse.git" }, "devDependencies": { "tape": "~0.1.1", @@ -21,7 +21,9 @@ "scripts": { "test": "tap test/*.js" }, - "bugs": "http://github.com/creationix/jsonparse/issues", + "bugs": { + "url": "http://github.com/creationix/jsonparse/issues" + }, "engines": [ "node >= 0.2.0" ], @@ -50,5 +52,7 @@ ], "directories": {}, "_shasum": "330542ad3f0a654665b778f3eb2d9a9fa507ac64", - "_resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz" + "_resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz", + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/creationix/jsonparse#readme" } diff --git a/examples/node_modules/react-native/node_modules/module-deps/node_modules/duplexer2/package.json b/examples/node_modules/react-native/node_modules/module-deps/node_modules/duplexer2/package.json index fa06a378..0ac32172 100644 --- a/examples/node_modules/react-native/node_modules/module-deps/node_modules/duplexer2/package.json +++ b/examples/node_modules/react-native/node_modules/module-deps/node_modules/duplexer2/package.json @@ -52,5 +52,6 @@ ], "directories": {}, "_shasum": "c614dcf67e2fb14995a91711e5a617e8a60a31db", - "_resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz" + "_resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/module-deps/node_modules/shallow-copy/package.json b/examples/node_modules/react-native/node_modules/module-deps/node_modules/shallow-copy/package.json index 3c299088..5c3534e4 100644 --- a/examples/node_modules/react-native/node_modules/module-deps/node_modules/shallow-copy/package.json +++ b/examples/node_modules/react-native/node_modules/module-deps/node_modules/shallow-copy/package.json @@ -63,5 +63,6 @@ ], "directories": {}, "_shasum": "415f42702d73d810330292cc5ee86eae1a11a170", - "_resolved": "https://registry.npmjs.org/shallow-copy/-/shallow-copy-0.0.1.tgz" + "_resolved": "https://registry.npmjs.org/shallow-copy/-/shallow-copy-0.0.1.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/module-deps/node_modules/subarg/package.json b/examples/node_modules/react-native/node_modules/module-deps/node_modules/subarg/package.json index 1099cd72..9ae0ccfc 100644 --- a/examples/node_modules/react-native/node_modules/module-deps/node_modules/subarg/package.json +++ b/examples/node_modules/react-native/node_modules/module-deps/node_modules/subarg/package.json @@ -71,5 +71,6 @@ ], "directories": {}, "_shasum": "3d56b07dacfbc45bbb63f7672b43b63e46368e3a", - "_resolved": "https://registry.npmjs.org/subarg/-/subarg-0.0.1.tgz" + "_resolved": "https://registry.npmjs.org/subarg/-/subarg-0.0.1.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/promise/build.js b/examples/node_modules/react-native/node_modules/promise/build.js index 0f453237..1e028e9a 100644 --- a/examples/node_modules/react-native/node_modules/promise/build.js +++ b/examples/node_modules/react-native/node_modules/promise/build.js @@ -63,7 +63,7 @@ fs.mkdirSync(__dirname + '/setimmediate/'); fs.readdirSync(__dirname + '/src').forEach(function (filename) { var src = fs.readFileSync(__dirname + '/src/' + filename, 'utf8'); var out = fixup(src); - out = out.replace(/var asap \= require\(\'([a-z\/]+)\'\)/g, ''); + out = out.replace(/var asap \= require\(\'([a-z\/]+)\'\);/g, ''); out = out.replace(/asap/g, "setImmediate"); fs.writeFileSync(__dirname + '/setimmediate/' + filename, out); }); diff --git a/examples/node_modules/react-native/node_modules/promise/domains/core.js b/examples/node_modules/react-native/node_modules/promise/domains/core.js index c0141f59..958b871c 100644 --- a/examples/node_modules/react-native/node_modules/promise/domains/core.js +++ b/examples/node_modules/react-native/node_modules/promise/domains/core.js @@ -1,8 +1,8 @@ 'use strict'; -var asap = require('asap') +var asap = require('asap'); -function noop() {}; +function noop() {} // States: // @@ -50,100 +50,113 @@ function tryCallTwo(fn, a, b) { } module.exports = Promise; + function Promise(fn) { - if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new') - if (typeof fn !== 'function') throw new TypeError('not a function') - this._71 = 0; - this._18 = null; - this._61 = []; + if (typeof this !== 'object') { + throw new TypeError('Promises must be constructed via new'); + } + if (typeof fn !== 'function') { + throw new TypeError('not a function'); + } + this._32 = 0; + this._8 = null; + this._89 = []; if (fn === noop) return; doResolve(fn, this); } -Promise.prototype._10 = function (onFulfilled, onRejected) { - var self = this; - return new this.constructor(function (resolve, reject) { - var res = new Promise(noop); - res.then(resolve, reject); - self._24(new Handler(onFulfilled, onRejected, res)); - }); -}; +Promise._83 = noop; + Promise.prototype.then = function(onFulfilled, onRejected) { - if (this.constructor !== Promise) return this._10(onFulfilled, onRejected); + if (this.constructor !== Promise) { + return safeThen(this, onFulfilled, onRejected); + } var res = new Promise(noop); - this._24(new Handler(onFulfilled, onRejected, res)); + handle(this, new Handler(onFulfilled, onRejected, res)); return res; }; -Promise.prototype._24 = function(deferred) { - if (this._71 === 3) { - this._18._24(deferred); - return; + +function safeThen(self, onFulfilled, onRejected) { + return new self.constructor(function (resolve, reject) { + var res = new Promise(noop); + res.then(resolve, reject); + handle(self, new Handler(onFulfilled, onRejected, res)); + }); +}; +function handle(self, deferred) { + while (self._32 === 3) { + self = self._8; } - if (this._71 === 0) { - this._61.push(deferred); + if (self._32 === 0) { + self._89.push(deferred); return; } - var state = this._71; - var value = this._18; asap(function() { - var cb = state === 1 ? deferred.onFulfilled : deferred.onRejected + var cb = self._32 === 1 ? deferred.onFulfilled : deferred.onRejected; if (cb === null) { - (state === 1 ? deferred.promise._82(value) : deferred.promise._67(value)) - return + if (self._32 === 1) { + resolve(deferred.promise, self._8); + } else { + reject(deferred.promise, self._8); + } + return; } - var ret = tryCallOne(cb, value); + var ret = tryCallOne(cb, self._8); if (ret === IS_ERROR) { - deferred.promise._67(LAST_ERROR) + reject(deferred.promise, LAST_ERROR); } else { - deferred.promise._82(ret) + resolve(deferred.promise, ret); } }); -}; -Promise.prototype._82 = function(newValue) { - //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === this) { - return this._67(new TypeError('A promise cannot be resolved with itself.')) +} +function resolve(self, newValue) { + // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure + if (newValue === self) { + return reject( + self, + new TypeError('A promise cannot be resolved with itself.') + ); } - if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { + if ( + newValue && + (typeof newValue === 'object' || typeof newValue === 'function') + ) { var then = getThen(newValue); if (then === IS_ERROR) { - return this._67(LAST_ERROR); + return reject(self, LAST_ERROR); } if ( - then === this.then && - newValue instanceof Promise && - newValue._24 === this._24 + then === self.then && + newValue instanceof Promise ) { - this._71 = 3; - this._18 = newValue; - for (var i = 0; i < this._61.length; i++) { - newValue._24(this._61[i]); - } + self._32 = 3; + self._8 = newValue; + finale(self); return; } else if (typeof then === 'function') { - doResolve(then.bind(newValue), this) - return + doResolve(then.bind(newValue), self); + return; } } - this._71 = 1 - this._18 = newValue - this._94() + self._32 = 1; + self._8 = newValue; + finale(self); } -Promise.prototype._67 = function (newValue) { - this._71 = 2 - this._18 = newValue - this._94() +function reject(self, newValue) { + self._32 = 2; + self._8 = newValue; + finale(self); } -Promise.prototype._94 = function () { - for (var i = 0; i < this._61.length; i++) - this._24(this._61[i]) - this._61 = null +function finale(self) { + for (var i = 0; i < self._89.length; i++) { + handle(self, self._89[i]); + } + self._89 = null; } - function Handler(onFulfilled, onRejected, promise){ - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null - this.onRejected = typeof onRejected === 'function' ? onRejected : null + this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; + this.onRejected = typeof onRejected === 'function' ? onRejected : null; this.promise = promise; } @@ -156,16 +169,16 @@ function Handler(onFulfilled, onRejected, promise){ function doResolve(fn, promise) { var done = false; var res = tryCallTwo(fn, function (value) { - if (done) return - done = true - promise._82(value) + if (done) return; + done = true; + resolve(promise, value); }, function (reason) { - if (done) return - done = true - promise._67(reason) + if (done) return; + done = true; + reject(promise, reason); }) if (!done && res === IS_ERROR) { - done = true - promise._67(LAST_ERROR) + done = true; + reject(promise, LAST_ERROR); } -} \ No newline at end of file +} diff --git a/examples/node_modules/react-native/node_modules/promise/domains/done.js b/examples/node_modules/react-native/node_modules/promise/domains/done.js index 4b248ed3..f879317d 100644 --- a/examples/node_modules/react-native/node_modules/promise/domains/done.js +++ b/examples/node_modules/react-native/node_modules/promise/domains/done.js @@ -1,13 +1,13 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype.done = function (onFulfilled, onRejected) { - var self = arguments.length ? this.then.apply(this, arguments) : this + var self = arguments.length ? this.then.apply(this, arguments) : this; self.then(null, function (err) { setTimeout(function () { - throw err - }, 0) - }) -} \ No newline at end of file + throw err; + }, 0); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/domains/es6-extensions.js b/examples/node_modules/react-native/node_modules/promise/domains/es6-extensions.js index beb72152..c8aeec49 100644 --- a/examples/node_modules/react-native/node_modules/promise/domains/es6-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/domains/es6-extensions.js @@ -2,103 +2,107 @@ //This file contains the ES6 extensions to the core Promises/A+ API -var Promise = require('./core.js') -var asap = require('asap') +var Promise = require('./core.js'); +var asap = require('asap'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ -function ValuePromise(value) { - this.then = function (onFulfilled) { - if (typeof onFulfilled !== 'function') return this - return new Promise(function (resolve, reject) { - asap(function () { - try { - resolve(onFulfilled(value)) - } catch (ex) { - reject(ex); - } - }) - }) - } +var TRUE = valuePromise(true); +var FALSE = valuePromise(false); +var NULL = valuePromise(null); +var UNDEFINED = valuePromise(undefined); +var ZERO = valuePromise(0); +var EMPTYSTRING = valuePromise(''); + +function valuePromise(value) { + var p = new Promise(Promise._83); + p._32 = 1; + p._8 = value; + return p; } -ValuePromise.prototype = Promise.prototype - -var TRUE = new ValuePromise(true) -var FALSE = new ValuePromise(false) -var NULL = new ValuePromise(null) -var UNDEFINED = new ValuePromise(undefined) -var ZERO = new ValuePromise(0) -var EMPTYSTRING = new ValuePromise('') - Promise.resolve = function (value) { - if (value instanceof Promise) return value + if (value instanceof Promise) return value; - if (value === null) return NULL - if (value === undefined) return UNDEFINED - if (value === true) return TRUE - if (value === false) return FALSE - if (value === 0) return ZERO - if (value === '') return EMPTYSTRING + if (value === null) return NULL; + if (value === undefined) return UNDEFINED; + if (value === true) return TRUE; + if (value === false) return FALSE; + if (value === 0) return ZERO; + if (value === '') return EMPTYSTRING; if (typeof value === 'object' || typeof value === 'function') { try { - var then = value.then + var then = value.then; if (typeof then === 'function') { - return new Promise(then.bind(value)) + return new Promise(then.bind(value)); } } catch (ex) { return new Promise(function (resolve, reject) { - reject(ex) - }) + reject(ex); + }); } } - - return new ValuePromise(value) -} + return valuePromise(value); +}; Promise.all = function (arr) { - var args = Array.prototype.slice.call(arr) + var args = Array.prototype.slice.call(arr); return new Promise(function (resolve, reject) { - if (args.length === 0) return resolve([]) - var remaining = args.length + if (args.length === 0) return resolve([]); + var remaining = args.length; function res(i, val) { if (val && (typeof val === 'object' || typeof val === 'function')) { - var then = val.then - if (typeof then === 'function') { - then.call(val, function (val) { res(i, val) }, reject) - return + if (val instanceof Promise && val.then === Promise.prototype.then) { + while (val._32 === 3) { + val = val._8; + } + if (val._32 === 1) return res(i, val._8); + if (val._32 === 2) reject(val._8); + val.then(function (val) { + res(i, val); + }, reject); + return; + } else { + var then = val.then; + if (typeof then === 'function') { + var p = new Promise(then.bind(val)); + p.then(function (val) { + res(i, val); + }, reject); + return; + } } } - args[i] = val + args[i] = val; if (--remaining === 0) { resolve(args); } } for (var i = 0; i < args.length; i++) { - res(i, args[i]) + res(i, args[i]); } - }) -} + }); +}; Promise.reject = function (value) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { reject(value); }); -} +}; Promise.race = function (values) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { values.forEach(function(value){ Promise.resolve(value).then(resolve, reject); - }) + }); }); -} +}; /* Prototype Methods */ Promise.prototype['catch'] = function (onRejected) { return this.then(null, onRejected); -} +}; diff --git a/examples/node_modules/react-native/node_modules/promise/domains/finally.js b/examples/node_modules/react-native/node_modules/promise/domains/finally.js index a007c412..f5ee0b98 100644 --- a/examples/node_modules/react-native/node_modules/promise/domains/finally.js +++ b/examples/node_modules/react-native/node_modules/promise/domains/finally.js @@ -1,16 +1,16 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype['finally'] = function (f) { return this.then(function (value) { return Promise.resolve(f()).then(function () { - return value - }) + return value; + }); }, function (err) { return Promise.resolve(f()).then(function () { - throw err - }) - }) -} + throw err; + }); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/domains/index.js b/examples/node_modules/react-native/node_modules/promise/domains/index.js index 1af7bad9..bc6281fe 100644 --- a/examples/node_modules/react-native/node_modules/promise/domains/index.js +++ b/examples/node_modules/react-native/node_modules/promise/domains/index.js @@ -1,7 +1,7 @@ 'use strict'; -module.exports = require('./core.js') -require('./done.js') -require('./finally.js') -require('./es6-extensions.js') -require('./node-extensions.js') +module.exports = require('./core.js'); +require('./done.js'); +require('./finally.js'); +require('./es6-extensions.js'); +require('./node-extensions.js'); diff --git a/examples/node_modules/react-native/node_modules/promise/domains/node-extensions.js b/examples/node_modules/react-native/node_modules/promise/domains/node-extensions.js index 5e60f9e5..6065b90b 100644 --- a/examples/node_modules/react-native/node_modules/promise/domains/node-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/domains/node-extensions.js @@ -1,47 +1,57 @@ 'use strict'; -//This file contains then/promise specific extensions that are only useful for node.js interop +// This file contains then/promise specific extensions that are only useful +// for node.js interop -var Promise = require('./core.js') -var asap = require('asap') +var Promise = require('./core.js'); +var asap = require('asap'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ Promise.denodeify = function (fn, argumentCount) { - argumentCount = argumentCount || Infinity + argumentCount = argumentCount || Infinity; return function () { - var self = this - var args = Array.prototype.slice.call(arguments) + var self = this; + var args = Array.prototype.slice.call(arguments); return new Promise(function (resolve, reject) { while (args.length && args.length > argumentCount) { - args.pop() + args.pop(); } args.push(function (err, res) { - if (err) reject(err) - else resolve(res) + if (err) reject(err); + else resolve(res); }) - var res = fn.apply(self, args) - if (res && (typeof res === 'object' || typeof res === 'function') && typeof res.then === 'function') { - resolve(res) + var res = fn.apply(self, args); + if (res && + ( + typeof res === 'object' || + typeof res === 'function' + ) && + typeof res.then === 'function' + ) { + resolve(res); } }) } } Promise.nodeify = function (fn) { return function () { - var args = Array.prototype.slice.call(arguments) - var callback = typeof args[args.length - 1] === 'function' ? args.pop() : null - var ctx = this + var args = Array.prototype.slice.call(arguments); + var callback = + typeof args[args.length - 1] === 'function' ? args.pop() : null; + var ctx = this; try { - return fn.apply(this, arguments).nodeify(callback, ctx) + return fn.apply(this, arguments).nodeify(callback, ctx); } catch (ex) { if (callback === null || typeof callback == 'undefined') { - return new Promise(function (resolve, reject) { reject(ex) }) + return new Promise(function (resolve, reject) { + reject(ex); + }); } else { asap(function () { - callback.call(ctx, ex) + callback.call(ctx, ex); }) } } @@ -49,15 +59,15 @@ Promise.nodeify = function (fn) { } Promise.prototype.nodeify = function (callback, ctx) { - if (typeof callback != 'function') return this + if (typeof callback != 'function') return this; this.then(function (value) { asap(function () { - callback.call(ctx, null, value) - }) + callback.call(ctx, null, value); + }); }, function (err) { asap(function () { - callback.call(ctx, err) - }) - }) + callback.call(ctx, err); + }); + }); } diff --git a/examples/node_modules/react-native/node_modules/promise/lib/core.js b/examples/node_modules/react-native/node_modules/promise/lib/core.js index 02c9d883..b3e2284a 100644 --- a/examples/node_modules/react-native/node_modules/promise/lib/core.js +++ b/examples/node_modules/react-native/node_modules/promise/lib/core.js @@ -1,8 +1,8 @@ 'use strict'; -var asap = require('asap/raw') +var asap = require('asap/raw'); -function noop() {}; +function noop() {} // States: // @@ -50,100 +50,113 @@ function tryCallTwo(fn, a, b) { } module.exports = Promise; + function Promise(fn) { - if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new') - if (typeof fn !== 'function') throw new TypeError('not a function') - this._71 = 0; - this._18 = null; - this._61 = []; + if (typeof this !== 'object') { + throw new TypeError('Promises must be constructed via new'); + } + if (typeof fn !== 'function') { + throw new TypeError('not a function'); + } + this._32 = 0; + this._8 = null; + this._89 = []; if (fn === noop) return; doResolve(fn, this); } -Promise.prototype._10 = function (onFulfilled, onRejected) { - var self = this; - return new this.constructor(function (resolve, reject) { - var res = new Promise(noop); - res.then(resolve, reject); - self._24(new Handler(onFulfilled, onRejected, res)); - }); -}; +Promise._83 = noop; + Promise.prototype.then = function(onFulfilled, onRejected) { - if (this.constructor !== Promise) return this._10(onFulfilled, onRejected); + if (this.constructor !== Promise) { + return safeThen(this, onFulfilled, onRejected); + } var res = new Promise(noop); - this._24(new Handler(onFulfilled, onRejected, res)); + handle(this, new Handler(onFulfilled, onRejected, res)); return res; }; -Promise.prototype._24 = function(deferred) { - if (this._71 === 3) { - this._18._24(deferred); - return; + +function safeThen(self, onFulfilled, onRejected) { + return new self.constructor(function (resolve, reject) { + var res = new Promise(noop); + res.then(resolve, reject); + handle(self, new Handler(onFulfilled, onRejected, res)); + }); +}; +function handle(self, deferred) { + while (self._32 === 3) { + self = self._8; } - if (this._71 === 0) { - this._61.push(deferred); + if (self._32 === 0) { + self._89.push(deferred); return; } - var state = this._71; - var value = this._18; asap(function() { - var cb = state === 1 ? deferred.onFulfilled : deferred.onRejected + var cb = self._32 === 1 ? deferred.onFulfilled : deferred.onRejected; if (cb === null) { - (state === 1 ? deferred.promise._82(value) : deferred.promise._67(value)) - return + if (self._32 === 1) { + resolve(deferred.promise, self._8); + } else { + reject(deferred.promise, self._8); + } + return; } - var ret = tryCallOne(cb, value); + var ret = tryCallOne(cb, self._8); if (ret === IS_ERROR) { - deferred.promise._67(LAST_ERROR) + reject(deferred.promise, LAST_ERROR); } else { - deferred.promise._82(ret) + resolve(deferred.promise, ret); } }); -}; -Promise.prototype._82 = function(newValue) { - //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === this) { - return this._67(new TypeError('A promise cannot be resolved with itself.')) +} +function resolve(self, newValue) { + // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure + if (newValue === self) { + return reject( + self, + new TypeError('A promise cannot be resolved with itself.') + ); } - if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { + if ( + newValue && + (typeof newValue === 'object' || typeof newValue === 'function') + ) { var then = getThen(newValue); if (then === IS_ERROR) { - return this._67(LAST_ERROR); + return reject(self, LAST_ERROR); } if ( - then === this.then && - newValue instanceof Promise && - newValue._24 === this._24 + then === self.then && + newValue instanceof Promise ) { - this._71 = 3; - this._18 = newValue; - for (var i = 0; i < this._61.length; i++) { - newValue._24(this._61[i]); - } + self._32 = 3; + self._8 = newValue; + finale(self); return; } else if (typeof then === 'function') { - doResolve(then.bind(newValue), this) - return + doResolve(then.bind(newValue), self); + return; } } - this._71 = 1 - this._18 = newValue - this._94() + self._32 = 1; + self._8 = newValue; + finale(self); } -Promise.prototype._67 = function (newValue) { - this._71 = 2 - this._18 = newValue - this._94() +function reject(self, newValue) { + self._32 = 2; + self._8 = newValue; + finale(self); } -Promise.prototype._94 = function () { - for (var i = 0; i < this._61.length; i++) - this._24(this._61[i]) - this._61 = null +function finale(self) { + for (var i = 0; i < self._89.length; i++) { + handle(self, self._89[i]); + } + self._89 = null; } - function Handler(onFulfilled, onRejected, promise){ - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null - this.onRejected = typeof onRejected === 'function' ? onRejected : null + this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; + this.onRejected = typeof onRejected === 'function' ? onRejected : null; this.promise = promise; } @@ -156,16 +169,16 @@ function Handler(onFulfilled, onRejected, promise){ function doResolve(fn, promise) { var done = false; var res = tryCallTwo(fn, function (value) { - if (done) return - done = true - promise._82(value) + if (done) return; + done = true; + resolve(promise, value); }, function (reason) { - if (done) return - done = true - promise._67(reason) + if (done) return; + done = true; + reject(promise, reason); }) if (!done && res === IS_ERROR) { - done = true - promise._67(LAST_ERROR) + done = true; + reject(promise, LAST_ERROR); } -} \ No newline at end of file +} diff --git a/examples/node_modules/react-native/node_modules/promise/lib/done.js b/examples/node_modules/react-native/node_modules/promise/lib/done.js index 4b248ed3..f879317d 100644 --- a/examples/node_modules/react-native/node_modules/promise/lib/done.js +++ b/examples/node_modules/react-native/node_modules/promise/lib/done.js @@ -1,13 +1,13 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype.done = function (onFulfilled, onRejected) { - var self = arguments.length ? this.then.apply(this, arguments) : this + var self = arguments.length ? this.then.apply(this, arguments) : this; self.then(null, function (err) { setTimeout(function () { - throw err - }, 0) - }) -} \ No newline at end of file + throw err; + }, 0); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/lib/es6-extensions.js b/examples/node_modules/react-native/node_modules/promise/lib/es6-extensions.js index 8d7159b7..e1c41753 100644 --- a/examples/node_modules/react-native/node_modules/promise/lib/es6-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/lib/es6-extensions.js @@ -2,103 +2,107 @@ //This file contains the ES6 extensions to the core Promises/A+ API -var Promise = require('./core.js') -var asap = require('asap/raw') +var Promise = require('./core.js'); +var asap = require('asap/raw'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ -function ValuePromise(value) { - this.then = function (onFulfilled) { - if (typeof onFulfilled !== 'function') return this - return new Promise(function (resolve, reject) { - asap(function () { - try { - resolve(onFulfilled(value)) - } catch (ex) { - reject(ex); - } - }) - }) - } +var TRUE = valuePromise(true); +var FALSE = valuePromise(false); +var NULL = valuePromise(null); +var UNDEFINED = valuePromise(undefined); +var ZERO = valuePromise(0); +var EMPTYSTRING = valuePromise(''); + +function valuePromise(value) { + var p = new Promise(Promise._83); + p._32 = 1; + p._8 = value; + return p; } -ValuePromise.prototype = Promise.prototype - -var TRUE = new ValuePromise(true) -var FALSE = new ValuePromise(false) -var NULL = new ValuePromise(null) -var UNDEFINED = new ValuePromise(undefined) -var ZERO = new ValuePromise(0) -var EMPTYSTRING = new ValuePromise('') - Promise.resolve = function (value) { - if (value instanceof Promise) return value + if (value instanceof Promise) return value; - if (value === null) return NULL - if (value === undefined) return UNDEFINED - if (value === true) return TRUE - if (value === false) return FALSE - if (value === 0) return ZERO - if (value === '') return EMPTYSTRING + if (value === null) return NULL; + if (value === undefined) return UNDEFINED; + if (value === true) return TRUE; + if (value === false) return FALSE; + if (value === 0) return ZERO; + if (value === '') return EMPTYSTRING; if (typeof value === 'object' || typeof value === 'function') { try { - var then = value.then + var then = value.then; if (typeof then === 'function') { - return new Promise(then.bind(value)) + return new Promise(then.bind(value)); } } catch (ex) { return new Promise(function (resolve, reject) { - reject(ex) - }) + reject(ex); + }); } } - - return new ValuePromise(value) -} + return valuePromise(value); +}; Promise.all = function (arr) { - var args = Array.prototype.slice.call(arr) + var args = Array.prototype.slice.call(arr); return new Promise(function (resolve, reject) { - if (args.length === 0) return resolve([]) - var remaining = args.length + if (args.length === 0) return resolve([]); + var remaining = args.length; function res(i, val) { if (val && (typeof val === 'object' || typeof val === 'function')) { - var then = val.then - if (typeof then === 'function') { - then.call(val, function (val) { res(i, val) }, reject) - return + if (val instanceof Promise && val.then === Promise.prototype.then) { + while (val._32 === 3) { + val = val._8; + } + if (val._32 === 1) return res(i, val._8); + if (val._32 === 2) reject(val._8); + val.then(function (val) { + res(i, val); + }, reject); + return; + } else { + var then = val.then; + if (typeof then === 'function') { + var p = new Promise(then.bind(val)); + p.then(function (val) { + res(i, val); + }, reject); + return; + } } } - args[i] = val + args[i] = val; if (--remaining === 0) { resolve(args); } } for (var i = 0; i < args.length; i++) { - res(i, args[i]) + res(i, args[i]); } - }) -} + }); +}; Promise.reject = function (value) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { reject(value); }); -} +}; Promise.race = function (values) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { values.forEach(function(value){ Promise.resolve(value).then(resolve, reject); - }) + }); }); -} +}; /* Prototype Methods */ Promise.prototype['catch'] = function (onRejected) { return this.then(null, onRejected); -} +}; diff --git a/examples/node_modules/react-native/node_modules/promise/lib/finally.js b/examples/node_modules/react-native/node_modules/promise/lib/finally.js index a007c412..f5ee0b98 100644 --- a/examples/node_modules/react-native/node_modules/promise/lib/finally.js +++ b/examples/node_modules/react-native/node_modules/promise/lib/finally.js @@ -1,16 +1,16 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype['finally'] = function (f) { return this.then(function (value) { return Promise.resolve(f()).then(function () { - return value - }) + return value; + }); }, function (err) { return Promise.resolve(f()).then(function () { - throw err - }) - }) -} + throw err; + }); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/lib/index.js b/examples/node_modules/react-native/node_modules/promise/lib/index.js index 1af7bad9..bc6281fe 100644 --- a/examples/node_modules/react-native/node_modules/promise/lib/index.js +++ b/examples/node_modules/react-native/node_modules/promise/lib/index.js @@ -1,7 +1,7 @@ 'use strict'; -module.exports = require('./core.js') -require('./done.js') -require('./finally.js') -require('./es6-extensions.js') -require('./node-extensions.js') +module.exports = require('./core.js'); +require('./done.js'); +require('./finally.js'); +require('./es6-extensions.js'); +require('./node-extensions.js'); diff --git a/examples/node_modules/react-native/node_modules/promise/lib/node-extensions.js b/examples/node_modules/react-native/node_modules/promise/lib/node-extensions.js index 5e60f9e5..6065b90b 100644 --- a/examples/node_modules/react-native/node_modules/promise/lib/node-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/lib/node-extensions.js @@ -1,47 +1,57 @@ 'use strict'; -//This file contains then/promise specific extensions that are only useful for node.js interop +// This file contains then/promise specific extensions that are only useful +// for node.js interop -var Promise = require('./core.js') -var asap = require('asap') +var Promise = require('./core.js'); +var asap = require('asap'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ Promise.denodeify = function (fn, argumentCount) { - argumentCount = argumentCount || Infinity + argumentCount = argumentCount || Infinity; return function () { - var self = this - var args = Array.prototype.slice.call(arguments) + var self = this; + var args = Array.prototype.slice.call(arguments); return new Promise(function (resolve, reject) { while (args.length && args.length > argumentCount) { - args.pop() + args.pop(); } args.push(function (err, res) { - if (err) reject(err) - else resolve(res) + if (err) reject(err); + else resolve(res); }) - var res = fn.apply(self, args) - if (res && (typeof res === 'object' || typeof res === 'function') && typeof res.then === 'function') { - resolve(res) + var res = fn.apply(self, args); + if (res && + ( + typeof res === 'object' || + typeof res === 'function' + ) && + typeof res.then === 'function' + ) { + resolve(res); } }) } } Promise.nodeify = function (fn) { return function () { - var args = Array.prototype.slice.call(arguments) - var callback = typeof args[args.length - 1] === 'function' ? args.pop() : null - var ctx = this + var args = Array.prototype.slice.call(arguments); + var callback = + typeof args[args.length - 1] === 'function' ? args.pop() : null; + var ctx = this; try { - return fn.apply(this, arguments).nodeify(callback, ctx) + return fn.apply(this, arguments).nodeify(callback, ctx); } catch (ex) { if (callback === null || typeof callback == 'undefined') { - return new Promise(function (resolve, reject) { reject(ex) }) + return new Promise(function (resolve, reject) { + reject(ex); + }); } else { asap(function () { - callback.call(ctx, ex) + callback.call(ctx, ex); }) } } @@ -49,15 +59,15 @@ Promise.nodeify = function (fn) { } Promise.prototype.nodeify = function (callback, ctx) { - if (typeof callback != 'function') return this + if (typeof callback != 'function') return this; this.then(function (value) { asap(function () { - callback.call(ctx, null, value) - }) + callback.call(ctx, null, value); + }); }, function (err) { asap(function () { - callback.call(ctx, err) - }) - }) + callback.call(ctx, err); + }); + }); } diff --git a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/CHANGES.md b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/CHANGES.md new file mode 100644 index 00000000..e9ffa462 --- /dev/null +++ b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/CHANGES.md @@ -0,0 +1,64 @@ + +## 2.0.3 + +Version 2.0.3 fixes a bug when adjusting the capacity of the task queue. + +## 2.0.1-2.02 + +Version 2.0.1 fixes a bug in the way redirects were expressed that affected the +function of Browserify, but which Mr would tolerate. + +## 2.0.0 + +Version 2 of ASAP is a full rewrite with a few salient changes. +First, the ASAP source is CommonJS only and designed with [Browserify][] and +[Browserify-compatible][Mr] module loaders in mind. + +[Browserify]: https://github.com/substack/node-browserify +[Mr]: https://github.com/montagejs/mr + +The new version has been refactored in two dimensions. +Support for Node.js and browsers have been separated, using Browserify +redirects and ASAP has been divided into two modules. +The "raw" layer depends on the tasks to catch thrown exceptions and unravel +Node.js domains. + +The full implementation of ASAP is loadable as `require("asap")` in both Node.js +and browsers. + +The raw layer that lacks exception handling overhead is loadable as +`require("asap/raw")`. +The interface is the same for both layers. + +Tasks are no longer required to be functions, but can rather be any object that +implements `task.call()`. +With this feature you can recycle task objects to avoid garbage collector churn +and avoid closures in general. + +The implementation has been rigorously documented so that our successors can +understand the scope of the problem that this module solves and all of its +nuances, ensuring that the next generation of implementations know what details +are essential. + +- [asap.js](https://github.com/kriskowal/asap/blob/master/asap.js) +- [raw.js](https://github.com/kriskowal/asap/blob/master/raw.js) +- [browser-asap.js](https://github.com/kriskowal/asap/blob/master/browser-asap.js) +- [browser-raw.js](https://github.com/kriskowal/asap/blob/master/browser-raw.js) + +The new version has also been rigorously tested across a broad spectrum of +browsers, in both the window and worker context. +The following charts capture the browser test results for the most recent +release. +The first chart shows test results for ASAP running in the main window context. +The second chart shows test results for ASAP running in a web worker context. +Test results are inconclusive (grey) on browsers that do not support web +workers. +These data are captured automatically by [Continuous +Integration][]. + +![Browser Compatibility](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-results-matrix.svg) + +![Compatibility in Web Workers](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-worker-results-matrix.svg) + +[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md + diff --git a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/LICENSE.md b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/LICENSE.md new file mode 100644 index 00000000..ba18c613 --- /dev/null +++ b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/LICENSE.md @@ -0,0 +1,21 @@ + +Copyright 2009–2014 Contributors. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +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 NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS 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. + diff --git a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/browser-raw.js b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/browser-raw.js index 72bd4a0d..1cfd7729 100644 --- a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/browser-raw.js +++ b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/browser-raw.js @@ -58,7 +58,7 @@ function flush() { if (index > capacity) { // Manually shift all values starting at the index back to the // beginning of the queue. - for (var scan = 0; scan < index; scan++) { + for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { queue[scan] = queue[scan + index]; } queue.length -= index; @@ -218,4 +218,3 @@ rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; // to capture the MutationObserver implementation in a closure, were integrated // back into ASAP proper. // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js - diff --git a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/package.json b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/package.json index 152a7e63..3a62c675 100644 --- a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/package.json +++ b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/package.json @@ -1,6 +1,6 @@ { "name": "asap", - "version": "2.0.2", + "version": "2.0.3", "description": "High-priority task queue for Node.js and browsers", "keywords": [ "event", @@ -51,15 +51,16 @@ "wd": "^0.2.21", "weak-map": "^1.0.5" }, - "gitHead": "c09db7355b91e9bd76b1d6fa9c44cf7fc58e418d", + "gitHead": "ccbf94d4e4a0c3afc2df13331044020a46a74ab6", "bugs": { "url": "https://github.com/kriskowal/asap/issues" }, - "homepage": "https://github.com/kriskowal/asap", - "_id": "asap@2.0.2", - "_shasum": "4a028b746c1a0720151c2650c166c17ca032a2ef", + "homepage": "https://github.com/kriskowal/asap#readme", + "_id": "asap@2.0.3", + "_shasum": "1fc1d1564ee11620dfca6d67029850913f9f4679", "_from": "asap@>=2.0.1 <2.1.0", - "_npmVersion": "1.4.28", + "_npmVersion": "2.8.3", + "_nodeVersion": "1.8.1", "_npmUser": { "name": "kriskowal", "email": "kris.kowal@cixar.com" @@ -75,10 +76,9 @@ } ], "dist": { - "shasum": "4a028b746c1a0720151c2650c166c17ca032a2ef", - "tarball": "http://registry.npmjs.org/asap/-/asap-2.0.2.tgz" + "shasum": "1fc1d1564ee11620dfca6d67029850913f9f4679", + "tarball": "http://registry.npmjs.org/asap/-/asap-2.0.3.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/asap/-/asap-2.0.2.tgz", - "readme": "ERROR: No README data found!" + "_resolved": "https://registry.npmjs.org/asap/-/asap-2.0.3.tgz" } diff --git a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js index eba9e5e5..ae3b8923 100644 --- a/examples/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js +++ b/examples/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js @@ -30,7 +30,7 @@ var flushing = false; // preserved between calls to `flush` so that it can be resumed if // a task throws an exception. var index = 0; -// If a task schedules additional tasks recursively, the task queue can grown +// If a task schedules additional tasks recursively, the task queue can grow // unbounded. To prevent memory excaustion, the task queue will periodically // truncate already-completed tasks. var capacity = 1024; @@ -56,7 +56,7 @@ function flush() { if (index > capacity) { // Manually shift all values starting at the index back to the // beginning of the queue. - for (var scan = 0; scan < index; scan++) { + for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { queue[scan] = queue[scan + index]; } queue.length -= index; @@ -99,4 +99,3 @@ function requestFlush() { domain.active = process.domain = parentDomain; } } - diff --git a/examples/node_modules/react-native/node_modules/promise/package.json b/examples/node_modules/react-native/node_modules/promise/package.json index b011ad95..4b0c2803 100644 --- a/examples/node_modules/react-native/node_modules/promise/package.json +++ b/examples/node_modules/react-native/node_modules/promise/package.json @@ -1,6 +1,6 @@ { "name": "promise", - "version": "7.0.0", + "version": "7.0.1", "description": "Bare bones Promises/A+ implementation", "main": "index.js", "scripts": { @@ -12,7 +12,8 @@ "test": "mocha --bail --timeout 200 --slow 99999 -R dot && npm run test-memory-leak", "test-resolve": "mocha test/resolver-tests.js --timeout 200 --slow 999999", "test-extensions": "mocha test/extensions-tests.js --timeout 200 --slow 999999", - "test-memory-leak": "node --expose-gc test/memory-leak.js" + "test-memory-leak": "node --expose-gc test/memory-leak.js", + "coverage": "istanbul cover node_modules/mocha/bin/_mocha -- --bail --timeout 200 --slow 99999 -R dot" }, "repository": { "type": "git", @@ -25,6 +26,7 @@ "devDependencies": { "acorn": "^1.0.1", "better-assert": "*", + "istanbul": "^0.3.13", "mocha": "*", "promises-aplus-tests": "*", "rimraf": "^2.3.2" @@ -32,13 +34,13 @@ "dependencies": { "asap": "~2.0.1" }, - "gitHead": "0f7bcb9a010d299561b519c30406ad719bc349a1", + "gitHead": "d64deeec9cd1df50288dd9bdb3c9e919de3210cd", "bugs": { "url": "https://github.com/then/promise/issues" }, "homepage": "https://github.com/then/promise", - "_id": "promise@7.0.0", - "_shasum": "98ae4b5798755216c4aea2c1f62380517ab8767b", + "_id": "promise@7.0.1", + "_shasum": "383b49136cb2c259e265520978281283d40fafde", "_from": "promise@>=7.0.0 <8.0.0", "_npmVersion": "2.7.1", "_nodeVersion": "1.6.2", @@ -57,14 +59,10 @@ } ], "dist": { - "shasum": "98ae4b5798755216c4aea2c1f62380517ab8767b", - "size": 15536, - "noattachment": false, - "tarball": "http://registry.npm.taobao.org/promise/download/promise-7.0.0.tgz" + "shasum": "383b49136cb2c259e265520978281283d40fafde", + "tarball": "http://registry.npmjs.org/promise/-/promise-7.0.1.tgz" }, "directories": {}, - "publish_time": 1428446316171, - "_cnpm_publish_time": 1428446316171, - "_resolved": "http://registry.npm.taobao.org/promise/download/promise-7.0.0.tgz", + "_resolved": "https://registry.npmjs.org/promise/-/promise-7.0.1.tgz", "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/promise/setimmediate/core.js b/examples/node_modules/react-native/node_modules/promise/setimmediate/core.js index 6d304362..8014acd8 100644 --- a/examples/node_modules/react-native/node_modules/promise/setimmediate/core.js +++ b/examples/node_modules/react-native/node_modules/promise/setimmediate/core.js @@ -2,7 +2,7 @@ -function noop() {}; +function noop() {} // States: // @@ -50,100 +50,113 @@ function tryCallTwo(fn, a, b) { } module.exports = Promise; + function Promise(fn) { - if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new') - if (typeof fn !== 'function') throw new TypeError('not a function') - this._71 = 0; - this._18 = null; - this._61 = []; + if (typeof this !== 'object') { + throw new TypeError('Promises must be constructed via new'); + } + if (typeof fn !== 'function') { + throw new TypeError('not a function'); + } + this._32 = 0; + this._8 = null; + this._89 = []; if (fn === noop) return; doResolve(fn, this); } -Promise.prototype._10 = function (onFulfilled, onRejected) { - var self = this; - return new this.constructor(function (resolve, reject) { - var res = new Promise(noop); - res.then(resolve, reject); - self._24(new Handler(onFulfilled, onRejected, res)); - }); -}; +Promise._83 = noop; + Promise.prototype.then = function(onFulfilled, onRejected) { - if (this.constructor !== Promise) return this._10(onFulfilled, onRejected); + if (this.constructor !== Promise) { + return safeThen(this, onFulfilled, onRejected); + } var res = new Promise(noop); - this._24(new Handler(onFulfilled, onRejected, res)); + handle(this, new Handler(onFulfilled, onRejected, res)); return res; }; -Promise.prototype._24 = function(deferred) { - if (this._71 === 3) { - this._18._24(deferred); - return; + +function safeThen(self, onFulfilled, onRejected) { + return new self.constructor(function (resolve, reject) { + var res = new Promise(noop); + res.then(resolve, reject); + handle(self, new Handler(onFulfilled, onRejected, res)); + }); +}; +function handle(self, deferred) { + while (self._32 === 3) { + self = self._8; } - if (this._71 === 0) { - this._61.push(deferred); + if (self._32 === 0) { + self._89.push(deferred); return; } - var state = this._71; - var value = this._18; setImmediate(function() { - var cb = state === 1 ? deferred.onFulfilled : deferred.onRejected + var cb = self._32 === 1 ? deferred.onFulfilled : deferred.onRejected; if (cb === null) { - (state === 1 ? deferred.promise._82(value) : deferred.promise._67(value)) - return + if (self._32 === 1) { + resolve(deferred.promise, self._8); + } else { + reject(deferred.promise, self._8); + } + return; } - var ret = tryCallOne(cb, value); + var ret = tryCallOne(cb, self._8); if (ret === IS_ERROR) { - deferred.promise._67(LAST_ERROR) + reject(deferred.promise, LAST_ERROR); } else { - deferred.promise._82(ret) + resolve(deferred.promise, ret); } }); -}; -Promise.prototype._82 = function(newValue) { - //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === this) { - return this._67(new TypeError('A promise cannot be resolved with itself.')) +} +function resolve(self, newValue) { + // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure + if (newValue === self) { + return reject( + self, + new TypeError('A promise cannot be resolved with itself.') + ); } - if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { + if ( + newValue && + (typeof newValue === 'object' || typeof newValue === 'function') + ) { var then = getThen(newValue); if (then === IS_ERROR) { - return this._67(LAST_ERROR); + return reject(self, LAST_ERROR); } if ( - then === this.then && - newValue instanceof Promise && - newValue._24 === this._24 + then === self.then && + newValue instanceof Promise ) { - this._71 = 3; - this._18 = newValue; - for (var i = 0; i < this._61.length; i++) { - newValue._24(this._61[i]); - } + self._32 = 3; + self._8 = newValue; + finale(self); return; } else if (typeof then === 'function') { - doResolve(then.bind(newValue), this) - return + doResolve(then.bind(newValue), self); + return; } } - this._71 = 1 - this._18 = newValue - this._94() + self._32 = 1; + self._8 = newValue; + finale(self); } -Promise.prototype._67 = function (newValue) { - this._71 = 2 - this._18 = newValue - this._94() +function reject(self, newValue) { + self._32 = 2; + self._8 = newValue; + finale(self); } -Promise.prototype._94 = function () { - for (var i = 0; i < this._61.length; i++) - this._24(this._61[i]) - this._61 = null +function finale(self) { + for (var i = 0; i < self._89.length; i++) { + handle(self, self._89[i]); + } + self._89 = null; } - function Handler(onFulfilled, onRejected, promise){ - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null - this.onRejected = typeof onRejected === 'function' ? onRejected : null + this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; + this.onRejected = typeof onRejected === 'function' ? onRejected : null; this.promise = promise; } @@ -156,16 +169,16 @@ function Handler(onFulfilled, onRejected, promise){ function doResolve(fn, promise) { var done = false; var res = tryCallTwo(fn, function (value) { - if (done) return - done = true - promise._82(value) + if (done) return; + done = true; + resolve(promise, value); }, function (reason) { - if (done) return - done = true - promise._67(reason) + if (done) return; + done = true; + reject(promise, reason); }) if (!done && res === IS_ERROR) { - done = true - promise._67(LAST_ERROR) + done = true; + reject(promise, LAST_ERROR); } -} \ No newline at end of file +} diff --git a/examples/node_modules/react-native/node_modules/promise/setimmediate/done.js b/examples/node_modules/react-native/node_modules/promise/setimmediate/done.js index 4b248ed3..f879317d 100644 --- a/examples/node_modules/react-native/node_modules/promise/setimmediate/done.js +++ b/examples/node_modules/react-native/node_modules/promise/setimmediate/done.js @@ -1,13 +1,13 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype.done = function (onFulfilled, onRejected) { - var self = arguments.length ? this.then.apply(this, arguments) : this + var self = arguments.length ? this.then.apply(this, arguments) : this; self.then(null, function (err) { setTimeout(function () { - throw err - }, 0) - }) -} \ No newline at end of file + throw err; + }, 0); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/setimmediate/es6-extensions.js b/examples/node_modules/react-native/node_modules/promise/setimmediate/es6-extensions.js index ccf975e8..6779acf9 100644 --- a/examples/node_modules/react-native/node_modules/promise/setimmediate/es6-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/setimmediate/es6-extensions.js @@ -2,103 +2,107 @@ //This file contains the ES6 extensions to the core Promises/A+ API -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ -function ValuePromise(value) { - this.then = function (onFulfilled) { - if (typeof onFulfilled !== 'function') return this - return new Promise(function (resolve, reject) { - setImmediate(function () { - try { - resolve(onFulfilled(value)) - } catch (ex) { - reject(ex); - } - }) - }) - } +var TRUE = valuePromise(true); +var FALSE = valuePromise(false); +var NULL = valuePromise(null); +var UNDEFINED = valuePromise(undefined); +var ZERO = valuePromise(0); +var EMPTYSTRING = valuePromise(''); + +function valuePromise(value) { + var p = new Promise(Promise._83); + p._32 = 1; + p._8 = value; + return p; } -ValuePromise.prototype = Promise.prototype - -var TRUE = new ValuePromise(true) -var FALSE = new ValuePromise(false) -var NULL = new ValuePromise(null) -var UNDEFINED = new ValuePromise(undefined) -var ZERO = new ValuePromise(0) -var EMPTYSTRING = new ValuePromise('') - Promise.resolve = function (value) { - if (value instanceof Promise) return value + if (value instanceof Promise) return value; - if (value === null) return NULL - if (value === undefined) return UNDEFINED - if (value === true) return TRUE - if (value === false) return FALSE - if (value === 0) return ZERO - if (value === '') return EMPTYSTRING + if (value === null) return NULL; + if (value === undefined) return UNDEFINED; + if (value === true) return TRUE; + if (value === false) return FALSE; + if (value === 0) return ZERO; + if (value === '') return EMPTYSTRING; if (typeof value === 'object' || typeof value === 'function') { try { - var then = value.then + var then = value.then; if (typeof then === 'function') { - return new Promise(then.bind(value)) + return new Promise(then.bind(value)); } } catch (ex) { return new Promise(function (resolve, reject) { - reject(ex) - }) + reject(ex); + }); } } - - return new ValuePromise(value) -} + return valuePromise(value); +}; Promise.all = function (arr) { - var args = Array.prototype.slice.call(arr) + var args = Array.prototype.slice.call(arr); return new Promise(function (resolve, reject) { - if (args.length === 0) return resolve([]) - var remaining = args.length + if (args.length === 0) return resolve([]); + var remaining = args.length; function res(i, val) { if (val && (typeof val === 'object' || typeof val === 'function')) { - var then = val.then - if (typeof then === 'function') { - then.call(val, function (val) { res(i, val) }, reject) - return + if (val instanceof Promise && val.then === Promise.prototype.then) { + while (val._32 === 3) { + val = val._8; + } + if (val._32 === 1) return res(i, val._8); + if (val._32 === 2) reject(val._8); + val.then(function (val) { + res(i, val); + }, reject); + return; + } else { + var then = val.then; + if (typeof then === 'function') { + var p = new Promise(then.bind(val)); + p.then(function (val) { + res(i, val); + }, reject); + return; + } } } - args[i] = val + args[i] = val; if (--remaining === 0) { resolve(args); } } for (var i = 0; i < args.length; i++) { - res(i, args[i]) + res(i, args[i]); } - }) -} + }); +}; Promise.reject = function (value) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { reject(value); }); -} +}; Promise.race = function (values) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { values.forEach(function(value){ Promise.resolve(value).then(resolve, reject); - }) + }); }); -} +}; /* Prototype Methods */ Promise.prototype['catch'] = function (onRejected) { return this.then(null, onRejected); -} +}; diff --git a/examples/node_modules/react-native/node_modules/promise/setimmediate/finally.js b/examples/node_modules/react-native/node_modules/promise/setimmediate/finally.js index a007c412..f5ee0b98 100644 --- a/examples/node_modules/react-native/node_modules/promise/setimmediate/finally.js +++ b/examples/node_modules/react-native/node_modules/promise/setimmediate/finally.js @@ -1,16 +1,16 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype['finally'] = function (f) { return this.then(function (value) { return Promise.resolve(f()).then(function () { - return value - }) + return value; + }); }, function (err) { return Promise.resolve(f()).then(function () { - throw err - }) - }) -} + throw err; + }); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/setimmediate/index.js b/examples/node_modules/react-native/node_modules/promise/setimmediate/index.js index 1af7bad9..bc6281fe 100644 --- a/examples/node_modules/react-native/node_modules/promise/setimmediate/index.js +++ b/examples/node_modules/react-native/node_modules/promise/setimmediate/index.js @@ -1,7 +1,7 @@ 'use strict'; -module.exports = require('./core.js') -require('./done.js') -require('./finally.js') -require('./es6-extensions.js') -require('./node-extensions.js') +module.exports = require('./core.js'); +require('./done.js'); +require('./finally.js'); +require('./es6-extensions.js'); +require('./node-extensions.js'); diff --git a/examples/node_modules/react-native/node_modules/promise/setimmediate/node-extensions.js b/examples/node_modules/react-native/node_modules/promise/setimmediate/node-extensions.js index 19c613fb..54cf0c95 100644 --- a/examples/node_modules/react-native/node_modules/promise/setimmediate/node-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/setimmediate/node-extensions.js @@ -1,47 +1,57 @@ 'use strict'; -//This file contains then/promise specific extensions that are only useful for node.js interop +// This file contains then/promise specific extensions that are only useful +// for node.js interop -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ Promise.denodeify = function (fn, argumentCount) { - argumentCount = argumentCount || Infinity + argumentCount = argumentCount || Infinity; return function () { - var self = this - var args = Array.prototype.slice.call(arguments) + var self = this; + var args = Array.prototype.slice.call(arguments); return new Promise(function (resolve, reject) { while (args.length && args.length > argumentCount) { - args.pop() + args.pop(); } args.push(function (err, res) { - if (err) reject(err) - else resolve(res) + if (err) reject(err); + else resolve(res); }) - var res = fn.apply(self, args) - if (res && (typeof res === 'object' || typeof res === 'function') && typeof res.then === 'function') { - resolve(res) + var res = fn.apply(self, args); + if (res && + ( + typeof res === 'object' || + typeof res === 'function' + ) && + typeof res.then === 'function' + ) { + resolve(res); } }) } } Promise.nodeify = function (fn) { return function () { - var args = Array.prototype.slice.call(arguments) - var callback = typeof args[args.length - 1] === 'function' ? args.pop() : null - var ctx = this + var args = Array.prototype.slice.call(arguments); + var callback = + typeof args[args.length - 1] === 'function' ? args.pop() : null; + var ctx = this; try { - return fn.apply(this, arguments).nodeify(callback, ctx) + return fn.apply(this, arguments).nodeify(callback, ctx); } catch (ex) { if (callback === null || typeof callback == 'undefined') { - return new Promise(function (resolve, reject) { reject(ex) }) + return new Promise(function (resolve, reject) { + reject(ex); + }); } else { setImmediate(function () { - callback.call(ctx, ex) + callback.call(ctx, ex); }) } } @@ -49,15 +59,15 @@ Promise.nodeify = function (fn) { } Promise.prototype.nodeify = function (callback, ctx) { - if (typeof callback != 'function') return this + if (typeof callback != 'function') return this; this.then(function (value) { setImmediate(function () { - callback.call(ctx, null, value) - }) + callback.call(ctx, null, value); + }); }, function (err) { setImmediate(function () { - callback.call(ctx, err) - }) - }) + callback.call(ctx, err); + }); + }); } diff --git a/examples/node_modules/react-native/node_modules/promise/src/core.js b/examples/node_modules/react-native/node_modules/promise/src/core.js index 50e2f64a..30cabbbb 100644 --- a/examples/node_modules/react-native/node_modules/promise/src/core.js +++ b/examples/node_modules/react-native/node_modules/promise/src/core.js @@ -1,8 +1,8 @@ 'use strict'; -var asap = require('asap/raw') +var asap = require('asap/raw'); -function noop() {}; +function noop() {} // States: // @@ -50,100 +50,113 @@ function tryCallTwo(fn, a, b) { } module.exports = Promise; + function Promise(fn) { - if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new') - if (typeof fn !== 'function') throw new TypeError('not a function') + if (typeof this !== 'object') { + throw new TypeError('Promises must be constructed via new'); + } + if (typeof fn !== 'function') { + throw new TypeError('not a function'); + } this._state = 0; this._value = null; this._deferreds = []; if (fn === noop) return; doResolve(fn, this); } -Promise.prototype._safeThen = function (onFulfilled, onRejected) { - var self = this; - return new this.constructor(function (resolve, reject) { - var res = new Promise(noop); - res.then(resolve, reject); - self._handle(new Handler(onFulfilled, onRejected, res)); - }); -}; +Promise._noop = noop; + Promise.prototype.then = function(onFulfilled, onRejected) { - if (this.constructor !== Promise) return this._safeThen(onFulfilled, onRejected); + if (this.constructor !== Promise) { + return safeThen(this, onFulfilled, onRejected); + } var res = new Promise(noop); - this._handle(new Handler(onFulfilled, onRejected, res)); + handle(this, new Handler(onFulfilled, onRejected, res)); return res; }; -Promise.prototype._handle = function(deferred) { - if (this._state === 3) { - this._value._handle(deferred); - return; + +function safeThen(self, onFulfilled, onRejected) { + return new self.constructor(function (resolve, reject) { + var res = new Promise(noop); + res.then(resolve, reject); + handle(self, new Handler(onFulfilled, onRejected, res)); + }); +}; +function handle(self, deferred) { + while (self._state === 3) { + self = self._value; } - if (this._state === 0) { - this._deferreds.push(deferred); + if (self._state === 0) { + self._deferreds.push(deferred); return; } - var state = this._state; - var value = this._value; asap(function() { - var cb = state === 1 ? deferred.onFulfilled : deferred.onRejected + var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; if (cb === null) { - (state === 1 ? deferred.promise._resolve(value) : deferred.promise._reject(value)) - return + if (self._state === 1) { + resolve(deferred.promise, self._value); + } else { + reject(deferred.promise, self._value); + } + return; } - var ret = tryCallOne(cb, value); + var ret = tryCallOne(cb, self._value); if (ret === IS_ERROR) { - deferred.promise._reject(LAST_ERROR) + reject(deferred.promise, LAST_ERROR); } else { - deferred.promise._resolve(ret) + resolve(deferred.promise, ret); } }); -}; -Promise.prototype._resolve = function(newValue) { - //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === this) { - return this._reject(new TypeError('A promise cannot be resolved with itself.')) +} +function resolve(self, newValue) { + // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure + if (newValue === self) { + return reject( + self, + new TypeError('A promise cannot be resolved with itself.') + ); } - if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { + if ( + newValue && + (typeof newValue === 'object' || typeof newValue === 'function') + ) { var then = getThen(newValue); if (then === IS_ERROR) { - return this._reject(LAST_ERROR); + return reject(self, LAST_ERROR); } if ( - then === this.then && - newValue instanceof Promise && - newValue._handle === this._handle + then === self.then && + newValue instanceof Promise ) { - this._state = 3; - this._value = newValue; - for (var i = 0; i < this._deferreds.length; i++) { - newValue._handle(this._deferreds[i]); - } + self._state = 3; + self._value = newValue; + finale(self); return; } else if (typeof then === 'function') { - doResolve(then.bind(newValue), this) - return + doResolve(then.bind(newValue), self); + return; } } - this._state = 1 - this._value = newValue - this._finale() + self._state = 1; + self._value = newValue; + finale(self); } -Promise.prototype._reject = function (newValue) { - this._state = 2 - this._value = newValue - this._finale() +function reject(self, newValue) { + self._state = 2; + self._value = newValue; + finale(self); } -Promise.prototype._finale = function () { - for (var i = 0; i < this._deferreds.length; i++) - this._handle(this._deferreds[i]) - this._deferreds = null +function finale(self) { + for (var i = 0; i < self._deferreds.length; i++) { + handle(self, self._deferreds[i]); + } + self._deferreds = null; } - function Handler(onFulfilled, onRejected, promise){ - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null - this.onRejected = typeof onRejected === 'function' ? onRejected : null + this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; + this.onRejected = typeof onRejected === 'function' ? onRejected : null; this.promise = promise; } @@ -156,16 +169,16 @@ function Handler(onFulfilled, onRejected, promise){ function doResolve(fn, promise) { var done = false; var res = tryCallTwo(fn, function (value) { - if (done) return - done = true - promise._resolve(value) + if (done) return; + done = true; + resolve(promise, value); }, function (reason) { - if (done) return - done = true - promise._reject(reason) + if (done) return; + done = true; + reject(promise, reason); }) if (!done && res === IS_ERROR) { - done = true - promise._reject(LAST_ERROR) + done = true; + reject(promise, LAST_ERROR); } -} \ No newline at end of file +} diff --git a/examples/node_modules/react-native/node_modules/promise/src/done.js b/examples/node_modules/react-native/node_modules/promise/src/done.js index 4b248ed3..f879317d 100644 --- a/examples/node_modules/react-native/node_modules/promise/src/done.js +++ b/examples/node_modules/react-native/node_modules/promise/src/done.js @@ -1,13 +1,13 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype.done = function (onFulfilled, onRejected) { - var self = arguments.length ? this.then.apply(this, arguments) : this + var self = arguments.length ? this.then.apply(this, arguments) : this; self.then(null, function (err) { setTimeout(function () { - throw err - }, 0) - }) -} \ No newline at end of file + throw err; + }, 0); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/src/es6-extensions.js b/examples/node_modules/react-native/node_modules/promise/src/es6-extensions.js index 8d7159b7..6384cc2f 100644 --- a/examples/node_modules/react-native/node_modules/promise/src/es6-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/src/es6-extensions.js @@ -2,103 +2,107 @@ //This file contains the ES6 extensions to the core Promises/A+ API -var Promise = require('./core.js') -var asap = require('asap/raw') +var Promise = require('./core.js'); +var asap = require('asap/raw'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ -function ValuePromise(value) { - this.then = function (onFulfilled) { - if (typeof onFulfilled !== 'function') return this - return new Promise(function (resolve, reject) { - asap(function () { - try { - resolve(onFulfilled(value)) - } catch (ex) { - reject(ex); - } - }) - }) - } +var TRUE = valuePromise(true); +var FALSE = valuePromise(false); +var NULL = valuePromise(null); +var UNDEFINED = valuePromise(undefined); +var ZERO = valuePromise(0); +var EMPTYSTRING = valuePromise(''); + +function valuePromise(value) { + var p = new Promise(Promise._noop); + p._state = 1; + p._value = value; + return p; } -ValuePromise.prototype = Promise.prototype - -var TRUE = new ValuePromise(true) -var FALSE = new ValuePromise(false) -var NULL = new ValuePromise(null) -var UNDEFINED = new ValuePromise(undefined) -var ZERO = new ValuePromise(0) -var EMPTYSTRING = new ValuePromise('') - Promise.resolve = function (value) { - if (value instanceof Promise) return value + if (value instanceof Promise) return value; - if (value === null) return NULL - if (value === undefined) return UNDEFINED - if (value === true) return TRUE - if (value === false) return FALSE - if (value === 0) return ZERO - if (value === '') return EMPTYSTRING + if (value === null) return NULL; + if (value === undefined) return UNDEFINED; + if (value === true) return TRUE; + if (value === false) return FALSE; + if (value === 0) return ZERO; + if (value === '') return EMPTYSTRING; if (typeof value === 'object' || typeof value === 'function') { try { - var then = value.then + var then = value.then; if (typeof then === 'function') { - return new Promise(then.bind(value)) + return new Promise(then.bind(value)); } } catch (ex) { return new Promise(function (resolve, reject) { - reject(ex) - }) + reject(ex); + }); } } - - return new ValuePromise(value) -} + return valuePromise(value); +}; Promise.all = function (arr) { - var args = Array.prototype.slice.call(arr) + var args = Array.prototype.slice.call(arr); return new Promise(function (resolve, reject) { - if (args.length === 0) return resolve([]) - var remaining = args.length + if (args.length === 0) return resolve([]); + var remaining = args.length; function res(i, val) { if (val && (typeof val === 'object' || typeof val === 'function')) { - var then = val.then - if (typeof then === 'function') { - then.call(val, function (val) { res(i, val) }, reject) - return + if (val instanceof Promise && val.then === Promise.prototype.then) { + while (val._state === 3) { + val = val._value; + } + if (val._state === 1) return res(i, val._value); + if (val._state === 2) reject(val._value); + val.then(function (val) { + res(i, val); + }, reject); + return; + } else { + var then = val.then; + if (typeof then === 'function') { + var p = new Promise(then.bind(val)); + p.then(function (val) { + res(i, val); + }, reject); + return; + } } } - args[i] = val + args[i] = val; if (--remaining === 0) { resolve(args); } } for (var i = 0; i < args.length; i++) { - res(i, args[i]) + res(i, args[i]); } - }) -} + }); +}; Promise.reject = function (value) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { reject(value); }); -} +}; Promise.race = function (values) { - return new Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { values.forEach(function(value){ Promise.resolve(value).then(resolve, reject); - }) + }); }); -} +}; /* Prototype Methods */ Promise.prototype['catch'] = function (onRejected) { return this.then(null, onRejected); -} +}; diff --git a/examples/node_modules/react-native/node_modules/promise/src/finally.js b/examples/node_modules/react-native/node_modules/promise/src/finally.js index a007c412..f5ee0b98 100644 --- a/examples/node_modules/react-native/node_modules/promise/src/finally.js +++ b/examples/node_modules/react-native/node_modules/promise/src/finally.js @@ -1,16 +1,16 @@ 'use strict'; -var Promise = require('./core.js') +var Promise = require('./core.js'); -module.exports = Promise +module.exports = Promise; Promise.prototype['finally'] = function (f) { return this.then(function (value) { return Promise.resolve(f()).then(function () { - return value - }) + return value; + }); }, function (err) { return Promise.resolve(f()).then(function () { - throw err - }) - }) -} + throw err; + }); + }); +}; diff --git a/examples/node_modules/react-native/node_modules/promise/src/index.js b/examples/node_modules/react-native/node_modules/promise/src/index.js index 1af7bad9..bc6281fe 100644 --- a/examples/node_modules/react-native/node_modules/promise/src/index.js +++ b/examples/node_modules/react-native/node_modules/promise/src/index.js @@ -1,7 +1,7 @@ 'use strict'; -module.exports = require('./core.js') -require('./done.js') -require('./finally.js') -require('./es6-extensions.js') -require('./node-extensions.js') +module.exports = require('./core.js'); +require('./done.js'); +require('./finally.js'); +require('./es6-extensions.js'); +require('./node-extensions.js'); diff --git a/examples/node_modules/react-native/node_modules/promise/src/node-extensions.js b/examples/node_modules/react-native/node_modules/promise/src/node-extensions.js index 5e60f9e5..6065b90b 100644 --- a/examples/node_modules/react-native/node_modules/promise/src/node-extensions.js +++ b/examples/node_modules/react-native/node_modules/promise/src/node-extensions.js @@ -1,47 +1,57 @@ 'use strict'; -//This file contains then/promise specific extensions that are only useful for node.js interop +// This file contains then/promise specific extensions that are only useful +// for node.js interop -var Promise = require('./core.js') -var asap = require('asap') +var Promise = require('./core.js'); +var asap = require('asap'); -module.exports = Promise +module.exports = Promise; /* Static Functions */ Promise.denodeify = function (fn, argumentCount) { - argumentCount = argumentCount || Infinity + argumentCount = argumentCount || Infinity; return function () { - var self = this - var args = Array.prototype.slice.call(arguments) + var self = this; + var args = Array.prototype.slice.call(arguments); return new Promise(function (resolve, reject) { while (args.length && args.length > argumentCount) { - args.pop() + args.pop(); } args.push(function (err, res) { - if (err) reject(err) - else resolve(res) + if (err) reject(err); + else resolve(res); }) - var res = fn.apply(self, args) - if (res && (typeof res === 'object' || typeof res === 'function') && typeof res.then === 'function') { - resolve(res) + var res = fn.apply(self, args); + if (res && + ( + typeof res === 'object' || + typeof res === 'function' + ) && + typeof res.then === 'function' + ) { + resolve(res); } }) } } Promise.nodeify = function (fn) { return function () { - var args = Array.prototype.slice.call(arguments) - var callback = typeof args[args.length - 1] === 'function' ? args.pop() : null - var ctx = this + var args = Array.prototype.slice.call(arguments); + var callback = + typeof args[args.length - 1] === 'function' ? args.pop() : null; + var ctx = this; try { - return fn.apply(this, arguments).nodeify(callback, ctx) + return fn.apply(this, arguments).nodeify(callback, ctx); } catch (ex) { if (callback === null || typeof callback == 'undefined') { - return new Promise(function (resolve, reject) { reject(ex) }) + return new Promise(function (resolve, reject) { + reject(ex); + }); } else { asap(function () { - callback.call(ctx, ex) + callback.call(ctx, ex); }) } } @@ -49,15 +59,15 @@ Promise.nodeify = function (fn) { } Promise.prototype.nodeify = function (callback, ctx) { - if (typeof callback != 'function') return this + if (typeof callback != 'function') return this; this.then(function (value) { asap(function () { - callback.call(ctx, null, value) - }) + callback.call(ctx, null, value); + }); }, function (err) { asap(function () { - callback.call(ctx, err) - }) - }) + callback.call(ctx, err); + }); + }); } diff --git a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/bar.js b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/bar.js new file mode 100644 index 00000000..bccb2583 --- /dev/null +++ b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/bar.js @@ -0,0 +1 @@ +console.log("bar");module.exports = "bar"; require("./foo.js") diff --git a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/foo.js b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/foo.js new file mode 100644 index 00000000..c8a77e36 --- /dev/null +++ b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/foo.js @@ -0,0 +1 @@ +console.log(require(".")) diff --git a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js index 575b4476..d66e7a23 100644 --- a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +++ b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js @@ -238,7 +238,6 @@ function isStale(self, hit) { function use (self, hit) { shiftLU(self, hit) hit.lu = self._mru ++ - if (self._maxAge) hit.now = Date.now() self._lruList[hit.lu] = hit } diff --git a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/package.json b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/package.json index a20bae5d..54465786 100644 --- a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/package.json +++ b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/package.json @@ -1,7 +1,7 @@ { "name": "lru-cache", "description": "A cache object that deletes the least-recently-used items.", - "version": "2.6.1", + "version": "2.6.2", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me" @@ -27,23 +27,23 @@ "type": "MIT", "url": "http://github.com/isaacs/node-lru-cache/raw/master/LICENSE" }, - "gitHead": "ff3dfd40e437fa619f09610f45d1ac523bbf27c9", + "gitHead": "278d05fcc714636eeedb3959bca80c20c19a61df", "bugs": { "url": "https://github.com/isaacs/node-lru-cache/issues" }, "homepage": "https://github.com/isaacs/node-lru-cache#readme", - "_id": "lru-cache@2.6.1", - "_shasum": "9933eff15453fae1d27096365143c724e85c6cbd", + "_id": "lru-cache@2.6.2", + "_shasum": "77741638c6dc972e503dbe41dcb6bfdfba499a38", "_from": "lru-cache@>=2.0.0 <3.0.0", - "_npmVersion": "2.8.1", + "_npmVersion": "2.8.4", "_nodeVersion": "1.4.2", "_npmUser": { "name": "isaacs", "email": "isaacs@npmjs.com" }, "dist": { - "shasum": "9933eff15453fae1d27096365143c724e85c6cbd", - "tarball": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.6.1.tgz" + "shasum": "77741638c6dc972e503dbe41dcb6bfdfba499a38", + "tarball": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.6.2.tgz" }, "maintainers": [ { @@ -52,6 +52,6 @@ } ], "directories": {}, - "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.6.1.tgz", + "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.6.2.tgz", "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/test/timeout.js b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/test/timeout.js deleted file mode 100644 index 5dce62a9..00000000 --- a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/test/timeout.js +++ /dev/null @@ -1,21 +0,0 @@ -var test = require("tap").test -var LRU = require("../") - -var cache = LRU( { - max: 1, - maxAge: 500 -} ); - -test('set the key', function (t) { - cache.set( "1234", 1 ); - t.end() -}) - -for (var i = 0; i < 10; i ++) { - test('get after ' + i + '00ms', function (t) { - setTimeout(function () { - t.equal(cache.get('1234'), 1) - t.end() - }, 100) - }) -} diff --git a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/mkdirp/package.json b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/mkdirp/package.json index 81f97f6b..f3adb5bb 100644 --- a/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/mkdirp/package.json +++ b/examples/node_modules/react-native/node_modules/react-tools/node_modules/commoner/node_modules/mkdirp/package.json @@ -30,14 +30,29 @@ "mkdirp": "bin/cmd.js" }, "license": "MIT", - "readme": "# mkdirp\n\nLike `mkdir -p`, but in node.js!\n\n[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)\n\n# example\n\n## pow.js\n\n```js\nvar mkdirp = require('mkdirp');\n \nmkdirp('/tmp/foo/bar/baz', function (err) {\n if (err) console.error(err)\n else console.log('pow!')\n});\n```\n\nOutput\n\n```\npow!\n```\n\nAnd now /tmp/foo/bar/baz exists, huzzah!\n\n# methods\n\n```js\nvar mkdirp = require('mkdirp');\n```\n\n## mkdirp(dir, opts, cb)\n\nCreate a new directory and any necessary subdirectories at `dir` with octal\npermission string `opts.mode`. If `opts` is a non-object, it will be treated as\nthe `opts.mode`.\n\nIf `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\n`cb(err, made)` fires with the error or the first directory `made`\nthat had to be created, if any.\n\nYou can optionally pass in an alternate `fs` implementation by passing in\n`opts.fs`. Your implementation should have `opts.fs.mkdir(path, mode, cb)` and\n`opts.fs.stat(path, cb)`.\n\n## mkdirp.sync(dir, opts)\n\nSynchronously create a new directory and any necessary subdirectories at `dir`\nwith octal permission string `opts.mode`. If `opts` is a non-object, it will be\ntreated as the `opts.mode`.\n\nIf `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\nReturns the first directory that had to be created, if any.\n\nYou can optionally pass in an alternate `fs` implementation by passing in\n`opts.fs`. Your implementation should have `opts.fs.mkdirSync(path, mode)` and\n`opts.fs.statSync(path)`.\n\n# usage\n\nThis package also ships with a `mkdirp` command.\n\n```\nusage: mkdirp [DIR1,DIR2..] {OPTIONS}\n\n Create each supplied directory including any necessary parent directories that\n don't yet exist.\n \n If the directory already exists, do nothing.\n\nOPTIONS are:\n\n -m, --mode If a directory needs to be created, set the mode as an octal\n permission string.\n\n```\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install mkdirp\n```\n\nto get the library, or\n\n```\nnpm install -g mkdirp\n```\n\nto get the command.\n\n# license\n\nMIT\n", - "readmeFilename": "readme.markdown", "bugs": { "url": "https://github.com/substack/node-mkdirp/issues" }, - "homepage": "https://github.com/substack/node-mkdirp#readme", + "homepage": "https://github.com/substack/node-mkdirp", "_id": "mkdirp@0.5.0", + "dist": { + "shasum": "1d73076a6df986cd9344e15e71fcc05a4c9abf12", + "tarball": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz" + }, + "_from": "mkdirp@>=0.5.0 <0.6.0", + "_npmVersion": "1.4.3", + "_npmUser": { + "name": "substack", + "email": "mail@substack.net" + }, + "maintainers": [ + { + "name": "substack", + "email": "mail@substack.net" + } + ], + "directories": {}, "_shasum": "1d73076a6df986cd9344e15e71fcc05a4c9abf12", "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", - "_from": "mkdirp@>=0.5.0 <0.6.0" + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/react-tools/package.json b/examples/node_modules/react-native/node_modules/react-tools/package.json index fef7f9be..a2994f6d 100644 --- a/examples/node_modules/react-native/node_modules/react-tools/package.json +++ b/examples/node_modules/react-native/node_modules/react-tools/package.json @@ -26,7 +26,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/facebook/react" + "url": "git+https://github.com/facebook/react.git" }, "dependencies": { "commoner": "^0.10.0", @@ -128,5 +128,6 @@ "shasum": "7e8ea87c771d9f2114473950fa2fa8d2e3b8200d", "tarball": "http://registry.npmjs.org/react-tools/-/react-tools-0.13.1.tgz" }, - "directories": {} + "directories": {}, + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/node_modules/json-stream/package.json b/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/node_modules/json-stream/package.json index 8b925d35..baa24010 100644 --- a/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/node_modules/json-stream/package.json +++ b/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/node_modules/json-stream/package.json @@ -12,7 +12,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/mmalecki/json-stream.git" + "url": "git+https://github.com/mmalecki/json-stream.git" }, "license": "MIT", "gitHead": "43a1990a025a9e55d1d752549b45e9ad48e593ff", @@ -44,5 +44,6 @@ "tarball": "http://registry.npmjs.org/json-stream/-/json-stream-0.2.2.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/json-stream/-/json-stream-0.2.2.tgz" + "_resolved": "https://registry.npmjs.org/json-stream/-/json-stream-0.2.2.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/package.json b/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/package.json index bc0aa774..fdde114e 100644 --- a/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/package.json +++ b/examples/node_modules/react-native/node_modules/sane/node_modules/fb-watchman/package.json @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:facebook/watchman.git" + "url": "git+ssh://git@github.com/facebook/watchman.git" }, "dependencies": { "json-stream": "0.2.2", @@ -59,5 +59,6 @@ ], "directories": {}, "_shasum": "0a6775818dc611e306083382591c89c16f712d24", - "_resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-0.0.0.tgz" + "_resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-0.0.0.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/bar.js b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/bar.js new file mode 100644 index 00000000..bccb2583 --- /dev/null +++ b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/bar.js @@ -0,0 +1 @@ +console.log("bar");module.exports = "bar"; require("./foo.js") diff --git a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/foo.js b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/foo.js new file mode 100644 index 00000000..c8a77e36 --- /dev/null +++ b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/foo.js @@ -0,0 +1 @@ +console.log(require(".")) diff --git a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js index 575b4476..d66e7a23 100644 --- a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +++ b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js @@ -238,7 +238,6 @@ function isStale(self, hit) { function use (self, hit) { shiftLU(self, hit) hit.lu = self._mru ++ - if (self._maxAge) hit.now = Date.now() self._lruList[hit.lu] = hit } diff --git a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json index a20bae5d..54465786 100644 --- a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json +++ b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json @@ -1,7 +1,7 @@ { "name": "lru-cache", "description": "A cache object that deletes the least-recently-used items.", - "version": "2.6.1", + "version": "2.6.2", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me" @@ -27,23 +27,23 @@ "type": "MIT", "url": "http://github.com/isaacs/node-lru-cache/raw/master/LICENSE" }, - "gitHead": "ff3dfd40e437fa619f09610f45d1ac523bbf27c9", + "gitHead": "278d05fcc714636eeedb3959bca80c20c19a61df", "bugs": { "url": "https://github.com/isaacs/node-lru-cache/issues" }, "homepage": "https://github.com/isaacs/node-lru-cache#readme", - "_id": "lru-cache@2.6.1", - "_shasum": "9933eff15453fae1d27096365143c724e85c6cbd", + "_id": "lru-cache@2.6.2", + "_shasum": "77741638c6dc972e503dbe41dcb6bfdfba499a38", "_from": "lru-cache@>=2.0.0 <3.0.0", - "_npmVersion": "2.8.1", + "_npmVersion": "2.8.4", "_nodeVersion": "1.4.2", "_npmUser": { "name": "isaacs", "email": "isaacs@npmjs.com" }, "dist": { - "shasum": "9933eff15453fae1d27096365143c724e85c6cbd", - "tarball": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.6.1.tgz" + "shasum": "77741638c6dc972e503dbe41dcb6bfdfba499a38", + "tarball": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.6.2.tgz" }, "maintainers": [ { @@ -52,6 +52,6 @@ } ], "directories": {}, - "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.6.1.tgz", + "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.6.2.tgz", "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/timeout.js b/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/timeout.js deleted file mode 100644 index 5dce62a9..00000000 --- a/examples/node_modules/react-native/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/timeout.js +++ /dev/null @@ -1,21 +0,0 @@ -var test = require("tap").test -var LRU = require("../") - -var cache = LRU( { - max: 1, - maxAge: 500 -} ); - -test('set the key', function (t) { - cache.set( "1234", 1 ); - t.end() -}) - -for (var i = 0; i < 10; i ++) { - test('get after ' + i + '00ms', function (t) { - setTimeout(function () { - t.equal(cache.get('1234'), 1) - t.end() - }, 100) - }) -} diff --git a/examples/node_modules/react-native/node_modules/sane/package.json b/examples/node_modules/react-native/node_modules/sane/package.json index dda1773c..97791d0c 100644 --- a/examples/node_modules/react-native/node_modules/sane/package.json +++ b/examples/node_modules/react-native/node_modules/sane/package.json @@ -5,7 +5,7 @@ "main": "index.js", "repository": { "type": "git", - "url": "https://github.com/amasad/sane" + "url": "git+https://github.com/amasad/sane.git" }, "scripts": { "prepublish": "jshint --config=.jshintrc src/ index.js && mocha --bail", @@ -62,5 +62,6 @@ "tarball": "http://registry.npmjs.org/sane/-/sane-1.0.3.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/sane/-/sane-1.0.3.tgz" + "_resolved": "https://registry.npmjs.org/sane/-/sane-1.0.3.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/stacktrace-parser/README.md b/examples/node_modules/react-native/node_modules/stacktrace-parser/README.md index b6eb7832..ce808ea1 100644 --- a/examples/node_modules/react-native/node_modules/stacktrace-parser/README.md +++ b/examples/node_modules/react-native/node_modules/stacktrace-parser/README.md @@ -14,12 +14,6 @@ try { Every line contains four properties: `lineNumber`, `methodName`, `file` and `column` (if applicable). -## TODOs - -- travis (v0.1) -- check node v0.8 compatibility (v0.1) -- allow to run in browser (v0.2) - ## Contribution If you want to contrib, then do you thing, write tests, run `grunt test` ensure that everything is green , commit and make the pull request. Or just write an issue, or let's talk. diff --git a/examples/node_modules/react-native/node_modules/stacktrace-parser/lib/stacktrace-parser.js b/examples/node_modules/react-native/node_modules/stacktrace-parser/lib/stacktrace-parser.js index 66986380..1453f95c 100644 --- a/examples/node_modules/react-native/node_modules/stacktrace-parser/lib/stacktrace-parser.js +++ b/examples/node_modules/react-native/node_modules/stacktrace-parser/lib/stacktrace-parser.js @@ -9,7 +9,7 @@ var StackTraceParser = { */ parse: function(stackString) { var chrome = /^\s*at (?:(?:(?:Anonymous function)?|((?:\[object object\])?\S+(?: \[as \S+\])?)) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i, - gecko = /^(?:\s*(\S*)(?:\((.*?)\))?@)?((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i, + gecko = /^(?:\s*(\S*)(?:\((.*?)\))?@)?((?:\w).*?):(\d+)(?::(\d+))?\s*$/i, node = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i, lines = stackString.split('\n'), stack = [], diff --git a/examples/node_modules/react-native/node_modules/stacktrace-parser/package.json b/examples/node_modules/react-native/node_modules/stacktrace-parser/package.json index 85958135..933a0cb2 100644 --- a/examples/node_modules/react-native/node_modules/stacktrace-parser/package.json +++ b/examples/node_modules/react-native/node_modules/stacktrace-parser/package.json @@ -23,24 +23,11 @@ "scripts": { "test": "grunt test" }, + "gitHead": "493c5e5638a79b4d5886171867a06275cc703b00", + "readme": "# StackTrace-Parser\n\nThis parser parses a stack trace from any browser or Node.js and returns an array of hashes representing a line.\n\n## Usage\n\n``` JavaScript\ntry {\n throw new Error('My error');\n} catch(ex) {\n var lines = StackTraceParser.parse(ex.stack);\n}\n```\n\nEvery line contains four properties: `lineNumber`, `methodName`, `file` and `column` (if applicable).\n\n## Contribution\n\nIf you want to contrib, then do you thing, write tests, run `grunt test` ensure that everything is green , commit and make the pull request. Or just write an issue, or let's talk.\n\n## LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Georg Tavonius\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "readmeFilename": "README.md", "_id": "stacktrace-parser@0.1.1", - "dist": { - "shasum": "a61bcdd90d5ac52e361e1fbe061658d3a314accb", - "tarball": "http://registry.npmjs.org/stacktrace-parser/-/stacktrace-parser-0.1.1.tgz" - }, - "_from": "stacktrace-parser@0.1.1", - "_npmVersion": "1.3.24", - "_npmUser": { - "name": "calamari", - "email": "g.tavonius@gmail.com" - }, - "maintainers": [ - { - "name": "calamari", - "email": "g.tavonius@gmail.com" - } - ], - "directories": {}, - "_shasum": "a61bcdd90d5ac52e361e1fbe061658d3a314accb", - "_resolved": "https://registry.npmjs.org/stacktrace-parser/-/stacktrace-parser-0.1.1.tgz" + "_shasum": "9ee82ab3d70c3bf9e0dbc9250e45b99117080800", + "_from": "git://github.com/frantic/stacktrace-parser.git#493c5e5638", + "_resolved": "git://github.com/frantic/stacktrace-parser.git#493c5e5638a79b4d5886171867a06275cc703b00" } diff --git a/examples/node_modules/react-native/node_modules/stacktrace-parser/test/stacktrace_parser_test.js b/examples/node_modules/react-native/node_modules/stacktrace-parser/test/stacktrace_parser_test.js index 8a43680c..8696870b 100644 --- a/examples/node_modules/react-native/node_modules/stacktrace-parser/test/stacktrace_parser_test.js +++ b/examples/node_modules/react-native/node_modules/stacktrace-parser/test/stacktrace_parser_test.js @@ -157,6 +157,30 @@ describe('StackTraceParser', function() { column: 580 } ] } ], + 'JavaScriptCore': [ + { + from: "timeoutWithName@stack_traces/test:83:55\nwrapped@bandage.js:51:30", + to: [ { file: 'stack_traces/test', + methodName: 'timeoutWithName', + lineNumber: 83, + column: 55 }, + { file: 'bandage.js', + methodName: 'wrapped', + lineNumber: 51, + column: 30 } ] + }, + { + from: "timeoutWithName@stack_traces/test:83:55\nwrapped@42start-with-number.js:51:30", + to: [ { file: 'stack_traces/test', + methodName: 'timeoutWithName', + lineNumber: 83, + column: 55 }, + { file: '42start-with-number.js', + methodName: 'wrapped', + lineNumber: 51, + column: 30 } ] + } + ], 'Internet Explorer': [ { from: "Error: with timeout and named func\n at timeoutWithName (http://bandage.jaz-lounge.com/stack_traces/test:83:9)\n at wrapped (http://bandage.jaz-lounge.com/bandage.js:51:13)", diff --git a/examples/node_modules/react-native/node_modules/worker-farm/package.json b/examples/node_modules/react-native/node_modules/worker-farm/package.json index 7a52747e..c04b94fa 100644 --- a/examples/node_modules/react-native/node_modules/worker-farm/package.json +++ b/examples/node_modules/react-native/node_modules/worker-farm/package.json @@ -15,7 +15,7 @@ "main": "./lib/index.js", "repository": { "type": "git", - "url": "https://github.com/rvagg/node-worker-farm.git" + "url": "git+https://github.com/rvagg/node-worker-farm.git" }, "dependencies": { "errno": ">=0.1.1 <0.2.0-0", @@ -52,5 +52,6 @@ "tarball": "http://registry.npmjs.org/worker-farm/-/worker-farm-1.1.0.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.1.0.tgz" + "_resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.1.0.tgz", + "readme": "ERROR: No README data found!" } diff --git a/examples/node_modules/react-native/node_modules/ws/package.json b/examples/node_modules/react-native/node_modules/ws/package.json index a8d9f16b..a8b2d1a5 100644 --- a/examples/node_modules/react-native/node_modules/ws/package.json +++ b/examples/node_modules/react-native/node_modules/ws/package.json @@ -56,9 +56,7 @@ "_id": "ws@0.4.31", "dist": { "shasum": "5a4849e7a9ccd1ed5a81aeb4847c9fedf3122927", - "size": 55424, - "noattachment": false, - "tarball": "http://registry.npm.taobao.org/ws/download/ws-0.4.31.tgz" + "tarball": "http://registry.npmjs.org/ws/-/ws-0.4.31.tgz" }, "_from": "ws@0.4.31", "_npmVersion": "1.3.5", @@ -67,24 +65,16 @@ "email": "info@3rd-Eden.com" }, "maintainers": [ - { - "name": "3rdeden", - "email": "npm@3rd-Eden.com" - }, { "name": "einaros", "email": "einaros@gmail.com" }, { - "name": "v1", + "name": "V1", "email": "info@3rd-Eden.com" } ], "directories": {}, - "publish_time": 1379919310020, - "_cnpm_publish_time": 1379919310020, "_shasum": "5a4849e7a9ccd1ed5a81aeb4847c9fedf3122927", - "_resolved": "http://registry.npm.taobao.org/ws/download/ws-0.4.31.tgz", - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/einaros/ws#readme" + "_resolved": "https://registry.npmjs.org/ws/-/ws-0.4.31.tgz" } diff --git a/examples/node_modules/react-native/package.json b/examples/node_modules/react-native/package.json index dc5f0e53..c95a5e72 100644 --- a/examples/node_modules/react-native/package.json +++ b/examples/node_modules/react-native/package.json @@ -1,10 +1,10 @@ { "name": "react-native", - "version": "0.4.0", + "version": "0.4.1", "description": "A framework for building native apps using React", "repository": { "type": "git", - "url": "git+ssh://git@github.com/facebook/react-native.git" + "url": "git@github.com:facebook/react-native.git" }, "jest": { "scriptPreprocessor": "jestSupport/scriptPreprocess.js", @@ -58,7 +58,7 @@ "rebound": "^0.0.12", "sane": "1.0.3", "source-map": "0.1.31", - "stacktrace-parser": "0.1.1", + "stacktrace-parser": "git://github.com/frantic/stacktrace-parser.git#493c5e5638", "uglify-js": "~2.4.16", "underscore": "1.7.0", "worker-farm": "1.1.0", @@ -69,14 +69,14 @@ "jest-cli": "0.2.1", "eslint": "0.9.2" }, - "gitHead": "d937071517b47b3d2e54510a1f695885a27c5e52", + "gitHead": "abea586c6522245167a01a48df169317744e4dbb", "bugs": { "url": "https://github.com/facebook/react-native/issues" }, "homepage": "https://github.com/facebook/react-native", - "_id": "react-native@0.4.0", - "_shasum": "ad6232997a6d6de8b8e34df69e03b0384a194bf9", - "_from": "react-native@*", + "_id": "react-native@0.4.1", + "_shasum": "0fae6392a6a6147fa44ceae62e87f009a8ada54f", + "_from": "react-native@0.4.1", "_npmVersion": "2.1.18", "_nodeVersion": "0.10.35", "_npmUser": { @@ -85,31 +85,26 @@ }, "maintainers": [ { - "name": "amasad", - "email": "amjad.masad@gmail.com" + "name": "spicyj", + "email": "ben@benalpert.com" }, { "name": "frantic", "email": "alex.frantic@gmail.com" }, - { - "name": "spicyj", - "email": "ben@benalpert.com" - }, { "name": "vjeux", "email": "vjeuxx@gmail.com" + }, + { + "name": "amasad", + "email": "amjad.masad@gmail.com" } ], "dist": { - "shasum": "ad6232997a6d6de8b8e34df69e03b0384a194bf9", - "size": 468149, - "noattachment": false, - "tarball": "http://registry.npm.taobao.org/react-native/download/react-native-0.4.0.tgz" + "shasum": "0fae6392a6a6147fa44ceae62e87f009a8ada54f", + "tarball": "http://registry.npmjs.org/react-native/-/react-native-0.4.1.tgz" }, "directories": {}, - "publish_time": 1429286389453, - "_cnpm_publish_time": 1429286389453, - "_resolved": "http://registry.npm.taobao.org/react-native/download/react-native-0.4.0.tgz", - "readme": "ERROR: No README data found!" + "_resolved": "https://registry.npmjs.org/react-native/-/react-native-0.4.1.tgz" } diff --git a/examples/node_modules/react-native/packager/debugger.html b/examples/node_modules/react-native/packager/debugger.html index d0d4aba5..d72e40ea 100644 --- a/examples/node_modules/react-native/packager/debugger.html +++ b/examples/node_modules/react-native/packager/debugger.html @@ -41,13 +41,13 @@ window.localStorage.setItem('sessionID', message.id); window.location.reload(); }, - 'executeApplicationScript:sourceURL:onComplete:': function(message, sendReply) { + 'executeApplicationScript': function(message, sendReply) { for (var key in message.inject) { window[key] = JSON.parse(message.inject[key]); } loadScript(message.url, sendReply.bind(null, null)); }, - 'executeJSCall:method:arguments:callback:': function(message, sendReply) { + 'executeJSCall': function(message, sendReply) { var returnValue = [[], [], [], [], []]; try { if (window && window.require) { diff --git a/examples/node_modules/react-native/packager/getFlowTypeCheckMiddleware.js b/examples/node_modules/react-native/packager/getFlowTypeCheckMiddleware.js index 312da45e..c7f3e2b1 100644 --- a/examples/node_modules/react-native/packager/getFlowTypeCheckMiddleware.js +++ b/examples/node_modules/react-native/packager/getFlowTypeCheckMiddleware.js @@ -10,12 +10,15 @@ var chalk = require('chalk'); var exec = require('child_process').exec; +var Activity = require('./react-packager/src/Activity'); var hasWarned = {}; +var DISABLE_FLOW_CHECK = true; // temporarily disable while we figure out versioning issues. function getFlowTypeCheckMiddleware(options) { return function(req, res, next) { - if (options.skipflow) { + var isBundle = req.url.indexOf('.bundle') !== -1; + if (DISABLE_FLOW_CHECK || options.skipflow || !isBundle) { return next(); } if (options.flowroot || options.projectRoots.length === 1) { @@ -44,20 +47,10 @@ function getFlowTypeCheckMiddleware(options) { function doFlowTypecheck(res, flowroot, next) { var flowCmd = 'cd "' + flowroot + '" && flow --json --timeout 20'; - var start = Date.now(); - // Log start message if flow is slow to let user know something is happening. - var flowSlow = setTimeout( - function() { - console.log(chalk.gray('flow: Running static typechecks.')); - }, - 500 - ); + var eventId = Activity.startEvent('flow static typechecks'); exec(flowCmd, function(flowError, stdout, stderr) { - clearTimeout(flowSlow); + Activity.endEvent(eventId); if (!flowError) { - console.log(chalk.gray( - 'flow: Typechecks passed (' + (Date.now() - start) + 'ms).') - ); return next(); } else { try { diff --git a/examples/node_modules/react-native/packager/launchEditor.js b/examples/node_modules/react-native/packager/launchEditor.js index cf89ed4f..b572b5cb 100644 --- a/examples/node_modules/react-native/packager/launchEditor.js +++ b/examples/node_modules/react-native/packager/launchEditor.js @@ -8,23 +8,21 @@ */ 'use strict'; +var chalk = require('chalk'); var fs = require('fs'); -var spawn = require('child_process').spawn; - -var firstLaunch = true; - -function guessEditor() { - if (firstLaunch) { - console.log('When you see Red Box with stack trace, you can click any ' + - 'stack frame to jump to the source file. The packager will launch your ' + - 'editor of choice. It will first look at REACT_EDITOR environment ' + - 'variable, then at EDITOR. To set it up, you can add something like ' + - 'REACT_EDITOR=atom to your .bashrc.'); - firstLaunch = false; - } - - var editor = process.env.REACT_EDITOR || process.env.EDITOR || 'subl'; - return editor; +var exec = require('child_process').exec; + +function printInstructions(title) { + console.log([ + '', + chalk.bgBlue.white.bold(' ' + title + ' '), + ' When you see Red Box with stack trace, you can click any ', + ' stack frame to jump to the source file. The packager will launch your ', + ' editor of choice. It will first look at REACT_EDITOR environment ', + ' variable, then at EDITOR. To set it up, you can add something like ', + ' REACT_EDITOR=atom to your .bashrc.', + '' + ].join('\n')); } function launchEditor(fileName, lineNumber) { @@ -37,9 +35,18 @@ function launchEditor(fileName, lineNumber) { argument += ':' + lineNumber; } - var editor = guessEditor(); - console.log('Opening ' + fileName + ' with ' + editor); - spawn(editor, [argument], { stdio: ['pipe', 'pipe', process.stderr] }); + var editor = process.env.REACT_EDITOR || process.env.EDITOR; + if (editor) { + console.log('Opening ' + chalk.underline(fileName) + ' with ' + chalk.bold(editor)); + exec(editor + ' ' + argument, function(error) { + if (error) { + console.log(chalk.red(error.message)); + printInstructions('How to fix'); + } + }); + } else { + printInstructions('PRO TIP'); + } } module.exports = launchEditor; diff --git a/examples/node_modules/react-native/packager/packager.js b/examples/node_modules/react-native/packager/packager.js index 23da3a78..212e17f7 100644 --- a/examples/node_modules/react-native/packager/packager.js +++ b/examples/node_modules/react-native/packager/packager.js @@ -200,6 +200,7 @@ function getAppMiddleware(options) { cacheVersion: '2', transformModulePath: require.resolve('./transformer.js'), assetRoots: options.assetRoots, + assetExts: ['png', 'jpeg', 'jpg'] }); } diff --git a/examples/node_modules/react-native/packager/packager.sh b/examples/node_modules/react-native/packager/packager.sh index 93a017c3..f763b9ba 100755 --- a/examples/node_modules/react-native/packager/packager.sh +++ b/examples/node_modules/react-native/packager/packager.sh @@ -7,6 +7,12 @@ # 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. +if [ $REACT_PACKAGER_LOG ]; +then + echo "Logs will be redirected to $REACT_PACKAGER_LOG" + exec &> $REACT_PACKAGER_LOG +fi + ulimit -n 4096 THIS_DIR=$(dirname "$0") diff --git a/examples/node_modules/react-native/packager/react-packager/src/Activity/__mocks__/chalk.js b/examples/node_modules/react-native/packager/react-packager/src/Activity/__mocks__/chalk.js new file mode 100644 index 00000000..2981f979 --- /dev/null +++ b/examples/node_modules/react-native/packager/react-packager/src/Activity/__mocks__/chalk.js @@ -0,0 +1,13 @@ +/** + * 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. + */ +'use strict'; + +module.exports = { + dim: function(s) { return s; }, +}; diff --git a/examples/node_modules/react-native/packager/react-packager/src/Activity/index.js b/examples/node_modules/react-native/packager/react-packager/src/Activity/index.js index 05285d0f..8e593f9f 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/Activity/index.js +++ b/examples/node_modules/react-native/packager/react-packager/src/Activity/index.js @@ -8,6 +8,8 @@ */ 'use strict'; +var chalk = require('chalk'); + var COLLECTION_PERIOD = 1000; var _endedEvents = Object.create(null); @@ -132,22 +134,22 @@ function _writeAction(action) { switch (action.action) { case 'startEvent': - console.log( + console.log(chalk.dim( '[' + fmtTime + '] ' + ' ' + action.eventName + data - ); + )); break; case 'endEvent': var startAction = _eventStarts[action.eventId]; var startData = startAction.data ? ': ' + JSON.stringify(startAction.data) : ''; - console.log( + console.log(chalk.dim( '[' + fmtTime + '] ' + ' ' + startAction.eventName + - '(' + (action.tstamp - startAction.tstamp) + 'ms)' + + ' (' + (action.tstamp - startAction.tstamp) + 'ms)' + startData - ); + )); delete _eventStarts[action.eventId]; break; diff --git a/examples/node_modules/react-native/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js b/examples/node_modules/react-native/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js index eede72c0..ba804b5f 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js +++ b/examples/node_modules/react-native/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js @@ -1,72 +1,82 @@ 'use strict'; jest - .autoMockOff() - .mock('../../lib/declareOpts') - .mock('fs'); + .dontMock('path') + .dontMock('../../lib/getAssetDataFromName') + .dontMock('../'); -var fs = require('fs'); -var AssetServer = require('../'); var Promise = require('bluebird'); describe('AssetServer', function() { - pit('should work for the simple case', function() { - var server = new AssetServer({ - projectRoots: ['/root'], - assetExts: ['png'], - }); + var AssetServer; + var crypto; + var fs; + + beforeEach(function() { + AssetServer = require('../'); + crypto = require('crypto'); + fs = require('fs'); + }); + + describe('assetServer.get', function() { + pit('should work for the simple case', function() { + var server = new AssetServer({ + projectRoots: ['/root'], + assetExts: ['png'], + }); - fs.__setMockFilesystem({ - 'root': { - imgs: { - 'b.png': 'b image', - 'b@2x.png': 'b2 image', + fs.__setMockFilesystem({ + 'root': { + imgs: { + 'b.png': 'b image', + 'b@2x.png': 'b2 image', + } } - } - }); + }); - return Promise.all([ - server.get('imgs/b.png'), - server.get('imgs/b@1x.png'), - ]).then(function(resp) { - resp.forEach(function(data) { - expect(data).toBe('b image'); + return Promise.all([ + server.get('imgs/b.png'), + server.get('imgs/b@1x.png'), + ]).then(function(resp) { + resp.forEach(function(data) { + expect(data).toBe('b image'); + }); }); }); - }); - pit.only('should pick the bigger one', function() { - var server = new AssetServer({ - projectRoots: ['/root'], - assetExts: ['png'], - }); + pit('should pick the bigger one', function() { + var server = new AssetServer({ + projectRoots: ['/root'], + assetExts: ['png'], + }); - fs.__setMockFilesystem({ - 'root': { - imgs: { - 'b@1x.png': 'b1 image', - 'b@2x.png': 'b2 image', - 'b@4x.png': 'b4 image', - 'b@4.5x.png': 'b4.5 image', + fs.__setMockFilesystem({ + 'root': { + imgs: { + 'b@1x.png': 'b1 image', + 'b@2x.png': 'b2 image', + 'b@4x.png': 'b4 image', + 'b@4.5x.png': 'b4.5 image', + } } - } - }); + }); - return server.get('imgs/b@3x.png').then(function(data) { - expect(data).toBe('b4 image'); + return server.get('imgs/b@3x.png').then(function(data) { + expect(data).toBe('b4 image'); + }); }); - }); - pit('should support multiple project roots', function() { - var server = new AssetServer({ - projectRoots: ['/root'], - assetExts: ['png'], - }); + pit('should support multiple project roots', function() { + var server = new AssetServer({ + projectRoots: ['/root', '/root2'], + assetExts: ['png'], + }); - fs.__setMockFilesystem({ - 'root': { - imgs: { - 'b.png': 'b image', + fs.__setMockFilesystem({ + 'root': { + imgs: { + 'b.png': 'b image', + }, }, 'root2': { 'newImages': { @@ -75,11 +85,53 @@ describe('AssetServer', function() { }, }, }, - } + }); + + return server.get('newImages/imgs/b.png').then(function(data) { + expect(data).toBe('b1 image'); + }); }); + }); + + describe('assetSerer.getAssetData', function() { + pit('should get assetData', function() { + var hash = { + update: jest.genMockFn(), + digest: jest.genMockFn(), + }; - return server.get('newImages/imgs/b.png').then(function(data) { - expect(data).toBe('b1 image'); + hash.digest.mockImpl(function() { + return 'wow such hash'; + }); + crypto.createHash.mockImpl(function() { + return hash; + }); + + var server = new AssetServer({ + projectRoots: ['/root'], + assetExts: ['png'], + }); + + fs.__setMockFilesystem({ + 'root': { + imgs: { + 'b@1x.png': 'b1 image', + 'b@2x.png': 'b2 image', + 'b@4x.png': 'b4 image', + 'b@4.5x.png': 'b4.5 image', + } + } + }); + + return server.getAssetData('imgs/b.png').then(function(data) { + expect(hash.update.mock.calls.length).toBe(4); + expect(data).toEqual({ + type: 'png', + name: 'b', + scales: [1, 2, 4, 4.5], + hash: 'wow such hash', + }); + }); }); }); }); diff --git a/examples/node_modules/react-native/packager/react-packager/src/AssetServer/index.js b/examples/node_modules/react-native/packager/react-packager/src/AssetServer/index.js index bdabafff..6f07dd01 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/AssetServer/index.js +++ b/examples/node_modules/react-native/packager/react-packager/src/AssetServer/index.js @@ -9,10 +9,11 @@ 'use strict'; var declareOpts = require('../lib/declareOpts'); -var extractAssetResolution = require('../lib/extractAssetResolution'); +var getAssetDataFromName = require('../lib/getAssetDataFromName'); var path = require('path'); var Promise = require('bluebird'); var fs = require('fs'); +var crypto = require('crypto'); var lstat = Promise.promisify(fs.lstat); var readDir = Promise.promisify(fs.readdir); @@ -44,11 +45,11 @@ function AssetServer(options) { * * 1. We first parse the directory of the asset * 2. We check to find a matching directory in one of the project roots - * 3. We then build a map of all assets and their resolutions in this directory + * 3. We then build a map of all assets and their scales in this directory * 4. Then pick the closest resolution (rounding up) to the requested one */ -AssetServer.prototype.get = function(assetPath) { +AssetServer.prototype._getAssetRecord = function(assetPath) { var filename = path.basename(assetPath); return findRoot( @@ -60,13 +61,7 @@ AssetServer.prototype.get = function(assetPath) { readDir(dir), ]; }).spread(function(dir, files) { - // Easy case. File exactly what the client requested. - var index = files.indexOf(filename); - if (index > -1) { - return readFile(path.join(dir, filename)); - } - - var assetData = extractAssetResolution(filename); + var assetData = getAssetDataFromName(filename); var map = buildAssetMap(dir, files); var record = map[assetData.assetName]; @@ -74,8 +69,15 @@ AssetServer.prototype.get = function(assetPath) { throw new Error('Asset not found'); } - for (var i = 0; i < record.resolutions.length; i++) { - if (record.resolutions[i] >= assetData.resolution) { + return record; + }); +}; + +AssetServer.prototype.get = function(assetPath) { + var assetData = getAssetDataFromName(assetPath); + return this._getAssetRecord(assetPath).then(function(record) { + for (var i = 0; i < record.scales.length; i++) { + if (record.scales[i] >= assetData.resolution) { return readFile(record.files[i]); } } @@ -84,6 +86,33 @@ AssetServer.prototype.get = function(assetPath) { }); }; +AssetServer.prototype.getAssetData = function(assetPath) { + var nameData = getAssetDataFromName(assetPath); + var data = { + name: nameData.name, + type: 'png', + }; + + return this._getAssetRecord(assetPath).then(function(record) { + data.scales = record.scales; + + return Promise.all( + record.files.map(function(file) { + return lstat(file); + }) + ); + }).then(function(stats) { + var hash = crypto.createHash('md5'); + + stats.forEach(function(stat) { + hash.update(stat.mtime.getTime().toString()); + }); + + data.hash = hash.digest('hex'); + return data; + }); +}; + function findRoot(roots, dir) { return Promise.some( roots.map(function(root) { @@ -105,26 +134,26 @@ function findRoot(roots, dir) { } function buildAssetMap(dir, files) { - var assets = files.map(extractAssetResolution); + var assets = files.map(getAssetDataFromName); var map = Object.create(null); assets.forEach(function(asset, i) { var file = files[i]; var record = map[asset.assetName]; if (!record) { record = map[asset.assetName] = { - resolutions: [], + scales: [], files: [], }; } var insertIndex; - var length = record.resolutions.length; + var length = record.scales.length; for (insertIndex = 0; insertIndex < length; insertIndex++) { - if (asset.resolution < record.resolutions[insertIndex]) { + if (asset.resolution < record.scales[insertIndex]) { break; } } - record.resolutions.splice(insertIndex, 0, asset.resolution); + record.scales.splice(insertIndex, 0, asset.resolution); record.files.splice(insertIndex, 0, path.join(dir, file)); }); diff --git a/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/ModuleDescriptor.js b/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/ModuleDescriptor.js index 3cdfa1c6..90db1c4a 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/ModuleDescriptor.js +++ b/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/ModuleDescriptor.js @@ -45,6 +45,8 @@ function ModuleDescriptor(fields) { this.altId = fields.altId; + this.isJSON = fields.isJSON; + this._fields = fields; } diff --git a/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/__tests__/DependencyGraph-test.js b/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/__tests__/DependencyGraph-test.js index 98ae7eb7..9cb08122 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/__tests__/DependencyGraph-test.js +++ b/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/__tests__/DependencyGraph-test.js @@ -14,7 +14,7 @@ jest .dontMock('absolute-path') .dontMock('../docblock') .dontMock('../../replacePatterns') - .dontMock('../../../../lib/extractAssetResolution') + .dontMock('../../../../lib/getAssetDataFromName') .setMock('../../../ModuleDescriptor', function(data) {return data;}); describe('DependencyGraph', function() { @@ -101,6 +101,46 @@ describe('DependencyGraph', function() { }); }); + pit('should get json dependencies', function() { + var root = '/root'; + fs.__setMockFilesystem({ + 'root': { + 'package.json': JSON.stringify({ + name: 'package' + }), + 'index.js': [ + '/**', + ' * @providesModule index', + ' */', + 'require("./a.json")' + ].join('\n'), + 'a.json': JSON.stringify({}), + } + }); + + var dgraph = new DependencyGraph({ + roots: [root], + fileWatcher: fileWatcher + }); + return dgraph.load().then(function() { + expect(dgraph.getOrderedDependencies('/root/index.js')) + .toEqual([ + { + id: 'index', + altId: 'package/index', + path: '/root/index.js', + dependencies: ['./a.json'] + }, + { + id: 'package/a.json', + isJSON: true, + path: '/root/a.json', + dependencies: [] + }, + ]); + }); + }); + pit('should get dependencies with deprecated assets', function() { var root = '/root'; fs.__setMockFilesystem({ @@ -129,7 +169,8 @@ describe('DependencyGraph', function() { { id: 'image!a', path: '/root/imgs/a.png', dependencies: [], - isAsset_DEPRECATED: true + isAsset_DEPRECATED: true, + resolution: 1, }, ]); }); @@ -288,7 +329,8 @@ describe('DependencyGraph', function() { id: 'image!a', path: '/root/imgs/a.png', dependencies: [], - isAsset_DEPRECATED: true + isAsset_DEPRECATED: true, + resolution: 1, }, ]); }); @@ -1350,6 +1392,7 @@ describe('DependencyGraph', function() { path: '/root/foo.png', dependencies: [], isAsset_DEPRECATED: true, + resolution: 1, }, ]); }); diff --git a/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js b/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js index 9257d788..08a4b513 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js +++ b/examples/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js @@ -18,7 +18,7 @@ var isAbsolutePath = require('absolute-path'); var debug = require('debug')('DependecyGraph'); var util = require('util'); var declareOpts = require('../../../lib/declareOpts'); -var extractAssetResolution = require('../../../lib/extractAssetResolution'); +var getAssetDataFromName = require('../../../lib/getAssetDataFromName'); var readFile = Promise.promisify(fs.readFile); var readDir = Promise.promisify(fs.readdir); @@ -66,7 +66,7 @@ function DependecyGraph(options) { this._debugUpdateEvents = []; this._moduleExtPattern = new RegExp( - '\.(' + ['js'].concat(this._assetExts).join('|') + ')$' + '\.(' + ['js', 'json'].concat(this._assetExts).join('|') + ')$' ); // Kick off the search process to precompute the dependency graph. @@ -259,7 +259,7 @@ DependecyGraph.prototype.resolveDependency = function( } // JS modules can be required without extensios. - if (!this._isFileAsset(modulePath)) { + if (!this._isFileAsset(modulePath) && !modulePath.match(/\.json$/)) { modulePath = withExtJs(modulePath); } @@ -422,7 +422,7 @@ DependecyGraph.prototype._processModule = function(modulePath) { var module; if (this._assetExts.indexOf(extname(modulePath)) > -1) { - var assetData = extractAssetResolution(this._lookupName(modulePath)); + var assetData = getAssetDataFromName(this._lookupName(modulePath)); moduleData.id = assetData.assetName; moduleData.resolution = assetData.resolution; moduleData.isAsset = true; @@ -432,13 +432,23 @@ DependecyGraph.prototype._processModule = function(modulePath) { return Promise.resolve(module); } + if (extname(modulePath) === 'json') { + moduleData.id = this._lookupName(modulePath); + moduleData.isJSON = true; + moduleData.dependencies = []; + module = new ModuleDescriptor(moduleData); + this._updateGraphWithModule(module); + return Promise.resolve(module); + } + var self = this; return readFile(modulePath, 'utf8') .then(function(content) { var moduleDocBlock = docblock.parseAsObject(content); if (moduleDocBlock.providesModule || moduleDocBlock.provides) { - moduleData.id = - moduleDocBlock.providesModule || moduleDocBlock.provides; + moduleData.id = /^(\S*)/.exec( + moduleDocBlock.providesModule || moduleDocBlock.provides + )[1]; // Incase someone wants to require this module via // packageName/path/to/module @@ -641,6 +651,7 @@ DependecyGraph.prototype._processAsset_DEPRECATED = function(file) { path: path.resolve(file), isAsset_DEPRECATED: true, dependencies: [], + resolution: getAssetDataFromName(file).resolution, }); } }; diff --git a/examples/node_modules/react-native/packager/react-packager/src/FileWatcher/index.js b/examples/node_modules/react-native/packager/react-packager/src/FileWatcher/index.js index 9af96c14..38ad19bf 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/FileWatcher/index.js +++ b/examples/node_modules/react-native/packager/react-packager/src/FileWatcher/index.js @@ -26,7 +26,7 @@ var detectingWatcherClass = new Promise(function(resolve) { module.exports = FileWatcher; -var MAX_WAIT_TIME = 3000; +var MAX_WAIT_TIME = 10000; // Singleton var fileWatcher = null; @@ -73,7 +73,7 @@ function createWatcher(rootConfig) { var rejectTimeout = setTimeout(function() { reject(new Error([ 'Watcher took too long to load', - 'Try running `watchman` from your terminal', + 'Try running `watchman version` from your terminal', 'https://facebook.github.io/watchman/docs/troubleshooting.html', ].join('\n'))); }, MAX_WAIT_TIME); diff --git a/examples/node_modules/react-native/packager/react-packager/src/Packager/Package.js b/examples/node_modules/react-native/packager/react-packager/src/Packager/Package.js index 0f55c8ed..67e31e47 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/Packager/Package.js +++ b/examples/node_modules/react-native/packager/react-packager/src/Packager/Package.js @@ -17,6 +17,7 @@ module.exports = Package; function Package(sourceMapUrl) { this._finalized = false; this._modules = []; + this._assets = []; this._sourceMapUrl = sourceMapUrl; } @@ -36,6 +37,10 @@ Package.prototype.addModule = function( }); }; +Package.prototype.addAsset = function(asset) { + this._assets.push(asset); +}; + Package.prototype.finalize = function(options) { options = options || {}; if (options.runMainModule) { @@ -49,6 +54,8 @@ Package.prototype.finalize = function(options) { Object.freeze(this._modules); Object.seal(this._modules); + Object.freeze(this._assets); + Object.seal(this._assets); this._finalized = true; }; @@ -146,6 +153,10 @@ Package.prototype.getSourceMap = function(options) { return map; }; +Package.prototype.getAssets = function() { + return this._assets; +}; + Package.prototype._getMappings = function() { var modules = this._modules; diff --git a/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Package-test.js b/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Package-test.js index 5a7438d2..db596a7b 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Package-test.js +++ b/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Package-test.js @@ -76,6 +76,18 @@ describe('Package', function() { expect(s).toEqual(genSourceMap(p._modules)); }); }); + + describe('getAssets()', function() { + it('should save and return asset objects', function() { + var p = new Package('test_url'); + var asset1 = {}; + var asset2 = {}; + p.addAsset(asset1); + p.addAsset(asset2); + p.finalize(); + expect(p.getAssets()).toEqual([asset1, asset2]); + }); + }); }); function genSourceMap(modules) { diff --git a/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Packager-test.js b/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Packager-test.js index 0c9d4a84..8e1420a3 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Packager-test.js +++ b/examples/node_modules/react-native/packager/react-packager/src/Packager/__tests__/Packager-test.js @@ -43,7 +43,20 @@ describe('Packager', function() { }; }); - var packager = new Packager({projectRoots: ['/root']}); + + require('fs').readFile.mockImpl(function(file, callback) { + callback(null, '{"json":true}'); + }); + + var assetServer = { + getAssetData: jest.genMockFn(), + }; + + var packager = new Packager({ + projectRoots: ['/root'], + assetServer: assetServer, + }); + var modules = [ {id: 'foo', path: '/root/foo.js', dependencies: []}, {id: 'bar', path: '/root/bar.js', dependencies: []}, @@ -52,6 +65,7 @@ describe('Packager', function() { path: '/root/img/img.png', isAsset_DEPRECATED: true, dependencies: [], + resolution: 2, }, { id: 'new_image.png', @@ -59,7 +73,13 @@ describe('Packager', function() { isAsset: true, resolution: 2, dependencies: [] - } + }, + { + id: 'package/file.json', + path: '/root/file.json', + isJSON: true, + dependencies: [], + }, ]; getDependencies.mockImpl(function() { @@ -86,6 +106,15 @@ describe('Packager', function() { cb(null, { width: 50, height: 100 }); }); + assetServer.getAssetData.mockImpl(function() { + return { + scales: [1,2,3], + hash: 'i am a hash', + name: 'img', + type: 'png', + }; + }); + return packager.package('/root/foo.js', true, 'source_map_url') .then(function(p) { expect(p.addModule.mock.calls[0]).toEqual([ @@ -98,22 +127,37 @@ describe('Packager', function() { 'source /root/bar.js', '/root/bar.js' ]); + + var imgModule_DEPRECATED = { + __packager_asset: true, + isStatic: true, + path: '/root/img/img.png', + uri: 'img', + width: 25, + height: 50, + deprecated: true, + }; + expect(p.addModule.mock.calls[2]).toEqual([ 'lol module.exports = ' + - JSON.stringify({ uri: 'img', isStatic: true}) + + JSON.stringify(imgModule_DEPRECATED) + '; lol', 'module.exports = ' + - JSON.stringify({ uri: 'img', isStatic: true}) + + JSON.stringify(imgModule_DEPRECATED) + ';', '/root/img/img.png' ]); var imgModule = { - isStatic: true, - path: '/root/img/new_image.png', - uri: 'assets/img/new_image.png', + __packager_asset: true, + fileSystemLocation: '/root/img', + httpServerLocation: '/assets/img', width: 25, height: 50, + scales: [1, 2, 3], + hash: 'i am a hash', + name: 'img', + type: 'png', }; expect(p.addModule.mock.calls[3]).toEqual([ @@ -126,9 +170,23 @@ describe('Packager', function() { '/root/img/new_image.png' ]); + expect(p.addModule.mock.calls[4]).toEqual([ + 'lol module.exports = {"json":true}; lol', + 'module.exports = {"json":true};', + '/root/file.json' + ]); + expect(p.finalize.mock.calls[0]).toEqual([ {runMainModule: true} ]); + + expect(p.addAsset.mock.calls[0]).toEqual([ + imgModule_DEPRECATED + ]); + + expect(p.addAsset.mock.calls[1]).toEqual([ + imgModule + ]); }); }); diff --git a/examples/node_modules/react-native/packager/react-packager/src/Packager/index.js b/examples/node_modules/react-native/packager/react-packager/src/Packager/index.js index 74e2ff4c..8563e272 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/Packager/index.js +++ b/examples/node_modules/react-native/packager/react-packager/src/Packager/index.js @@ -20,6 +20,9 @@ var Activity = require('../Activity'); var declareOpts = require('../lib/declareOpts'); var imageSize = require('image-size'); +var sizeOf = Promise.promisify(imageSize); +var readFile = Promise.promisify(fs.readFile); + var validateOpts = declareOpts({ projectRoots: { type: 'array', @@ -64,6 +67,10 @@ var validateOpts = declareOpts({ type: 'object', required: true, }, + assetServer: { + type: 'object', + required: true, + } }); function Packager(options) { @@ -91,6 +98,7 @@ function Packager(options) { }); this._projectRoots = opts.projectRoots; + this._assetServer = opts.assetServer; } Packager.prototype.kill = function() { @@ -98,9 +106,9 @@ Packager.prototype.kill = function() { }; Packager.prototype.package = function(main, runModule, sourceMapUrl, isDev) { - var transformModule = this._transformModule.bind(this); var ppackage = new Package(sourceMapUrl); + var transformModule = this._transformModule.bind(this, ppackage); var findEventId = Activity.startEvent('find dependencies'); var transformEventId; @@ -138,16 +146,15 @@ Packager.prototype.getDependencies = function(main, isDev) { return this._resolver.getDependencies(main, { dev: isDev }); }; -Packager.prototype._transformModule = function(module) { +Packager.prototype._transformModule = function(ppackage, module) { var transform; if (module.isAsset_DEPRECATED) { - transform = Promise.resolve(generateAssetModule_DEPRECATED(module)); + transform = this.generateAssetModule_DEPRECATED(ppackage, module); } else if (module.isAsset) { - transform = generateAssetModule( - module, - getPathRelativeToRoot(this._projectRoots, module.path) - ); + transform = this.generateAssetModule(ppackage, module); + } else if (module.isJSON) { + transform = generateJSONModule(module); } else { transform = this._transformer.loadFileAndTransform( path.resolve(module.path) @@ -164,43 +171,69 @@ Packager.prototype._transformModule = function(module) { }); }; - -function verifyRootExists(root) { - // Verify that the root exists. - assert(fs.statSync(root).isDirectory(), 'Root has to be a valid directory'); -} - Packager.prototype.getGraphDebugInfo = function() { return this._resolver.getDebugInfo(); }; -function generateAssetModule_DEPRECATED(module) { - var code = 'module.exports = ' + JSON.stringify({ - uri: module.id.replace(/^[^!]+!/, ''), - isStatic: true, - }) + ';'; - - return { - code: code, - sourceCode: code, - sourcePath: module.path, - }; -} - -var sizeOf = Promise.promisify(imageSize); - -function generateAssetModule(module, relPath) { +Packager.prototype.generateAssetModule_DEPRECATED = function(ppackage, module) { return sizeOf(module.path).then(function(dimensions) { var img = { + __packager_asset: true, isStatic: true, - path: module.path, //TODO(amasad): this should be path inside tar file. - uri: path.join('assets', relPath), + path: module.path, + uri: module.id.replace(/^[^!]+!/, ''), + width: dimensions.width / module.resolution, + height: dimensions.height / module.resolution, + deprecated: true, + }; + + ppackage.addAsset(img); + + var code = 'module.exports = ' + JSON.stringify(img) + ';'; + + return { + code: code, + sourceCode: code, + sourcePath: module.path, + }; + }); +}; + +Packager.prototype.generateAssetModule = function(ppackage, module) { + var relPath = getPathRelativeToRoot(this._projectRoots, module.path); + + return Promise.all([ + sizeOf(module.path), + this._assetServer.getAssetData(relPath), + ]).spread(function(dimensions, assetData) { + var img = { + __packager_asset: true, + fileSystemLocation: path.dirname(module.path), + httpServerLocation: path.join('/assets', path.dirname(relPath)), width: dimensions.width / module.resolution, height: dimensions.height / module.resolution, + scales: assetData.scales, + hash: assetData.hash, + name: assetData.name, + type: assetData.type, }; + ppackage.addAsset(img); + var code = 'module.exports = ' + JSON.stringify(img) + ';'; + return { + code: code, + sourceCode: code, + sourcePath: module.path, + }; + }); +}; + +function generateJSONModule(module) { + return readFile(module.path).then(function(data) { + var code = 'module.exports = ' + data.toString('utf8') + ';'; + return { code: code, sourceCode: code, @@ -222,4 +255,9 @@ function getPathRelativeToRoot(roots, absPath) { ); } +function verifyRootExists(root) { + // Verify that the root exists. + assert(fs.statSync(root).isDirectory(), 'Root has to be a valid directory'); +} + module.exports = Packager; diff --git a/examples/node_modules/react-native/packager/react-packager/src/Server/index.js b/examples/node_modules/react-native/packager/react-packager/src/Server/index.js index 3c7be043..79022b21 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/Server/index.js +++ b/examples/node_modules/react-native/packager/react-packager/src/Server/index.js @@ -71,13 +71,17 @@ function Server(options) { this._packages = Object.create(null); this._changeWatchers = []; + var assetGlobs = opts.assetExts.map(function(ext) { + return '**/*.' + ext; + }); + var watchRootConfigs = opts.projectRoots.map(function(dir) { return { dir: dir, globs: [ '**/*.js', - '**/package.json', - ] + '**/*.json', + ].concat(assetGlobs), }; }); @@ -86,9 +90,7 @@ function Server(options) { opts.assetRoots.map(function(dir) { return { dir: dir, - globs: opts.assetExts.map(function(ext) { - return '**/*.' + ext; - }), + globs: assetGlobs, }; }) ); @@ -98,15 +100,16 @@ function Server(options) { ? FileWatcher.createDummyWatcher() : new FileWatcher(watchRootConfigs); - var packagerOpts = Object.create(opts); - packagerOpts.fileWatcher = this._fileWatcher; - this._packager = new Packager(packagerOpts); - this._assetServer = new AssetServer({ projectRoots: opts.projectRoots, assetExts: opts.assetExts, }); + var packagerOpts = Object.create(opts); + packagerOpts.fileWatcher = this._fileWatcher; + packagerOpts.assetServer = this._assetServer; + this._packager = new Packager(packagerOpts); + var onFileChange = this._onFileChange.bind(this); this._fileWatcher.on('all', onFileChange); diff --git a/examples/node_modules/react-native/packager/react-packager/src/__mocks__/fs.js b/examples/node_modules/react-native/packager/react-packager/src/__mocks__/fs.js index 0ea13d15..d0e08a2f 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/__mocks__/fs.js +++ b/examples/node_modules/react-native/packager/react-packager/src/__mocks__/fs.js @@ -67,6 +67,12 @@ fs.lstat.mockImpl(function(filepath, callback) { return callback(e); } + var mtime = { + getTime: function() { + return Math.ceil(Math.random() * 10000000); + } + }; + if (node && typeof node === 'object' && node.SYMLINK == null) { callback(null, { isDirectory: function() { @@ -74,7 +80,8 @@ fs.lstat.mockImpl(function(filepath, callback) { }, isSymbolicLink: function() { return false; - } + }, + mtime: mtime, }); } else { callback(null, { @@ -86,7 +93,8 @@ fs.lstat.mockImpl(function(filepath, callback) { return true; } return false; - } + }, + mtime: mtime, }); } }); diff --git a/examples/node_modules/react-native/packager/react-packager/src/lib/__tests__/extractAssetResolution-test.js b/examples/node_modules/react-native/packager/react-packager/src/lib/__tests__/extractAssetResolution-test.js index ad5ac3fb..d0309ca6 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/lib/__tests__/extractAssetResolution-test.js +++ b/examples/node_modules/react-native/packager/react-packager/src/lib/__tests__/extractAssetResolution-test.js @@ -1,42 +1,52 @@ 'use strict'; jest.autoMockOff(); -var extractAssetResolution = require('../extractAssetResolution'); +var getAssetDataFromName = require('../getAssetDataFromName'); -describe('extractAssetResolution', function() { +describe('getAssetDataFromName', function() { it('should extract resolution simple case', function() { - var data = extractAssetResolution('test@2x.png'); + var data = getAssetDataFromName('test@2x.png'); expect(data).toEqual({ assetName: 'test.png', resolution: 2, + type: 'png', + name: 'test', }); }); it('should default resolution to 1', function() { - var data = extractAssetResolution('test.png'); + var data = getAssetDataFromName('test.png'); expect(data).toEqual({ assetName: 'test.png', resolution: 1, + type: 'png', + name: 'test', }); }); it('should support float', function() { - var data = extractAssetResolution('test@1.1x.png'); + var data = getAssetDataFromName('test@1.1x.png'); expect(data).toEqual({ assetName: 'test.png', resolution: 1.1, + type: 'png', + name: 'test', }); - data = extractAssetResolution('test@.1x.png'); + data = getAssetDataFromName('test@.1x.png'); expect(data).toEqual({ assetName: 'test.png', resolution: 0.1, + type: 'png', + name: 'test', }); - data = extractAssetResolution('test@0.2x.png'); + data = getAssetDataFromName('test@0.2x.png'); expect(data).toEqual({ assetName: 'test.png', resolution: 0.2, + type: 'png', + name: 'test', }); }); }); diff --git a/examples/node_modules/react-native/packager/react-packager/src/lib/extractAssetResolution.js b/examples/node_modules/react-native/packager/react-packager/src/lib/getAssetDataFromName.js similarity index 63% rename from examples/node_modules/react-native/packager/react-packager/src/lib/extractAssetResolution.js rename to examples/node_modules/react-native/packager/react-packager/src/lib/getAssetDataFromName.js index 8fb91afc..c4848fd1 100644 --- a/examples/node_modules/react-native/packager/react-packager/src/lib/extractAssetResolution.js +++ b/examples/node_modules/react-native/packager/react-packager/src/lib/getAssetDataFromName.js @@ -2,7 +2,7 @@ var path = require('path'); -function extractAssetResolution(filename) { +function getAssetDataFromName(filename) { var ext = path.extname(filename); var re = new RegExp('@([\\d\\.]+)x\\' + ext + '$'); @@ -19,10 +19,13 @@ function extractAssetResolution(filename) { } } + var assetName = match ? filename.replace(re, ext) : filename; return { resolution: resolution, - assetName: match ? filename.replace(re, ext) : filename, + assetName: assetName, + type: ext.slice(1), + name: path.basename(assetName, ext) }; } -module.exports = extractAssetResolution; +module.exports = getAssetDataFromName; diff --git a/examples/package.json b/examples/package.json index d4095ce0..924fa380 100644 --- a/examples/package.json +++ b/examples/package.json @@ -6,6 +6,6 @@ "start": "node_modules/react-native/packager/packager.sh" }, "dependencies": { - "react-native": "^0.4.0" + "react-native": "^0.4.1" } } diff --git a/src/index.js b/src/index.js index 26b1069a..b676f2b2 100644 --- a/src/index.js +++ b/src/index.js @@ -130,6 +130,7 @@ export default React.createClass({ autoplayTimeout : React.PropTypes.number, autoplayDirection : React.PropTypes.bool, index : React.PropTypes.number, + renderPagination : React.PropTypes.function, }, mixins: [TimerMixin], @@ -265,6 +266,10 @@ export default React.createClass({ * @return {object} react-dom */ renderPagination() { + + // By default, dots only show when `total` > 2 + if(this.state.total <= 1) return null + let dots = [] for(let i = 0; i < this.state.total; i++) { dots.push(i === this.state.index @@ -385,7 +390,9 @@ export default React.createClass({ {...props}> {pages} - {props.showsPagination && total > 1 && this.renderPagination()} + {props.showsPagination && (props.renderPagination + ? this.props.renderPagination(state.index, state.total) + : this.renderPagination())} {this.renderTitle()} {this.props.showsButtons && this.renderButtons()}