2015-03-23 20:28:42 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-03-13 00:49:54 +00:00
|
|
|
|
|
|
|
#import "RCTSourceCode.h"
|
|
|
|
|
|
|
|
#import "RCTAssert.h"
|
2015-04-20 21:04:53 +00:00
|
|
|
#import "RCTBridge.h"
|
2015-03-13 00:49:54 +00:00
|
|
|
#import "RCTUtils.h"
|
|
|
|
|
|
|
|
@implementation RCTSourceCode
|
|
|
|
|
2015-04-08 12:42:43 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
2015-04-20 21:04:53 +00:00
|
|
|
@synthesize bridge = _bridge;
|
|
|
|
|
2015-04-08 15:52:48 +00:00
|
|
|
RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
|
2015-07-14 10:51:22 +00:00
|
|
|
failureCallback:(RCTResponseErrorBlock)failureCallback)
|
2015-03-13 00:49:54 +00:00
|
|
|
{
|
|
|
|
if (self.scriptText && self.scriptURL) {
|
2015-08-24 10:14:33 +00:00
|
|
|
successCallback(@[@{@"text": self.scriptText, @"url": self.scriptURL.absoluteString}]);
|
2015-03-13 00:49:54 +00:00
|
|
|
} else {
|
2015-07-14 10:51:22 +00:00
|
|
|
failureCallback(RCTErrorWithMessage(@"Source code is not available"));
|
2015-03-13 00:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-20 21:04:53 +00:00
|
|
|
- (NSDictionary *)constantsToExport
|
|
|
|
{
|
2015-08-24 10:14:33 +00:00
|
|
|
NSString *URL = self.bridge.bundleURL.absoluteString ?: @"";
|
2015-04-20 21:04:53 +00:00
|
|
|
return @{@"scriptURL": URL};
|
|
|
|
}
|
|
|
|
|
2015-03-13 00:49:54 +00:00
|
|
|
@end
|