rebase
This commit is contained in:
parent
83cdba1b08
commit
72ed849e35
|
@ -1,5 +1,10 @@
|
|||
# Xcode
|
||||
#
|
||||
!**/*.xcodeproj
|
||||
!**/*.pbxproj
|
||||
!**/*.xcworkspacedata
|
||||
!**/*.xcsettings
|
||||
!**/*.xcscheme
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:Movies.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:TicTacToe.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:UIExplorer.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -4,6 +4,7 @@
|
|||
#import "RCTInvalidating.h"
|
||||
#import "RCTJavaScriptExecutor.h"
|
||||
|
||||
@class RCTBridge;
|
||||
@class RCTEventDispatcher;
|
||||
@class RCTRootView;
|
||||
|
||||
|
@ -26,6 +27,12 @@ static inline NSDictionary *RCTAPIErrorObject(NSString *msg)
|
|||
return @{@"apiError": msg ?: @""};
|
||||
}
|
||||
|
||||
/**
|
||||
* This block can be used to instantiate modules that require additional
|
||||
* init parameters, or additional configuration prior to being used.
|
||||
*/
|
||||
typedef NSArray *(^RCTBridgeModuleProviderBlock)(RCTBridge *bridge);
|
||||
|
||||
/**
|
||||
* Async batched bridge used to communicate with the JavaScript application.
|
||||
*/
|
||||
|
@ -34,11 +41,13 @@ static inline NSDictionary *RCTAPIErrorObject(NSString *msg)
|
|||
/**
|
||||
* The designated initializer. This creates a new bridge on top of the specified
|
||||
* executor. The bridge should then be used for all subsequent communication
|
||||
* with the JavaScript code running in the executor. You can optionally pass in
|
||||
* a list of module instances to be used instead of the auto-instantiated versions.
|
||||
* with the JavaScript code running in the executor. Modules will be automatically
|
||||
* instantiated using the default contructor, but you can optionally pass in a
|
||||
* module provider block to manually instantiate modules that require additional
|
||||
* init parameters or configuration.
|
||||
*/
|
||||
- (instancetype)initWithJavaScriptExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor
|
||||
moduleInstances:(NSArray *)moduleInstances NS_DESIGNATED_INITIALIZER;
|
||||
moduleProvider:(RCTBridgeModuleProviderBlock)block NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* This method is used to call functions in the JavaScript application context.
|
||||
|
@ -60,6 +69,11 @@ static inline NSDictionary *RCTAPIErrorObject(NSString *msg)
|
|||
*/
|
||||
@property (nonatomic, readonly) RCTEventDispatcher *eventDispatcher;
|
||||
|
||||
/**
|
||||
* A dictionary of all registered RCTBridgeModule instances, keyed by moduleName.
|
||||
*/
|
||||
@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
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#import <objc/runtime.h>
|
||||
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTInvalidating.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTSparseArray.h"
|
||||
|
@ -101,6 +100,40 @@ static id<RCTBridgeModule> RCTCreateModuleInstance(Class cls, RCTBridge *bridge)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function scans all classes available at runtime and returns an array
|
||||
* of all JSMethods registered.
|
||||
*/
|
||||
static NSArray *RCTJSMethods(void)
|
||||
{
|
||||
static NSArray *JSMethods;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSMutableSet *uniqueMethods = [NSMutableSet set];
|
||||
|
||||
unsigned int classCount;
|
||||
Class *classes = objc_copyClassList(&classCount);
|
||||
for (unsigned int i = 0; i < classCount; i++) {
|
||||
|
||||
Class cls = classes[i];
|
||||
|
||||
if (!class_getSuperclass(cls)) {
|
||||
// Class has no superclass - it's probably something weird
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RCTClassOverridesClassMethod(cls, @selector(JSMethods))) {
|
||||
[uniqueMethods addObjectsFromArray:[cls JSMethods]];
|
||||
}
|
||||
}
|
||||
free(classes);
|
||||
|
||||
JSMethods = [uniqueMethods allObjects];
|
||||
});
|
||||
|
||||
return JSMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function scans all classes available at runtime and returns an array
|
||||
* of all classes that implement the RTCBridgeModule protocol.
|
||||
|
@ -264,7 +297,7 @@ static NSDictionary *RCTRemoteModulesConfig(NSDictionary *modulesByName)
|
|||
|
||||
NSArray *methods = RCTExportedMethodsByModuleID()[moduleID];
|
||||
NSMutableDictionary *methodsByName = [NSMutableDictionary dictionaryWithCapacity:methods.count];
|
||||
[methods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger methodID, BOOL *stop) {
|
||||
[methods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger methodID, BOOL *_stop) {
|
||||
methodsByName[method.JSMethodName] = @{
|
||||
@"methodID": @(methodID),
|
||||
@"type": @"remote",
|
||||
|
@ -335,38 +368,16 @@ static NSDictionary *RCTLocalModulesConfig()
|
|||
static NSMutableDictionary *localModules;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
|
||||
RCTLocalModuleIDs = [[NSMutableDictionary alloc] init];
|
||||
RCTLocalMethodIDs = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSMutableArray *JSMethods = [[NSMutableArray alloc] init];
|
||||
|
||||
// Add globally used methods
|
||||
[JSMethods addObjectsFromArray:@[
|
||||
@"AppRegistry.runApplication",
|
||||
@"RCTDeviceEventEmitter.emit",
|
||||
@"RCTEventEmitter.receiveEvent",
|
||||
@"RCTEventEmitter.receiveTouches",
|
||||
]];
|
||||
|
||||
// NOTE: these methods are currently unused in the OSS project
|
||||
// @"Dimensions.set",
|
||||
// @"RCTNativeAppEventEmitter.emit",
|
||||
// @"ReactIOS.unmountComponentAtNodeAndRemoveContainer",
|
||||
|
||||
// Register individual methods from modules
|
||||
for (Class cls in RCTBridgeModuleClassesByModuleID()) {
|
||||
if (RCTClassOverridesClassMethod(cls, @selector(JSMethods))) {
|
||||
[JSMethods addObjectsFromArray:[cls JSMethods]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
localModules = [[NSMutableDictionary alloc] init];
|
||||
for (NSString *moduleDotMethod in JSMethods) {
|
||||
|
||||
for (NSString *moduleDotMethod in RCTJSMethods()) {
|
||||
|
||||
NSArray *parts = [moduleDotMethod componentsSeparatedByString:@"."];
|
||||
RCTCAssert(parts.count == 2, @"'%@' is not a valid JS method definition - expected 'Module.method' format.", moduleDotMethod);
|
||||
|
||||
|
||||
// Add module if it doesn't already exist
|
||||
NSString *moduleName = parts[0];
|
||||
NSDictionary *module = localModules[moduleName];
|
||||
|
@ -377,7 +388,7 @@ static NSDictionary *RCTLocalModulesConfig()
|
|||
};
|
||||
localModules[moduleName] = module;
|
||||
}
|
||||
|
||||
|
||||
// Add method if it doesn't already exist
|
||||
NSString *methodName = parts[1];
|
||||
NSMutableDictionary *methods = module[@"methods"];
|
||||
|
@ -387,27 +398,27 @@ static NSDictionary *RCTLocalModulesConfig()
|
|||
@"type": @"local"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Add module and method lookup
|
||||
RCTLocalModuleIDs[moduleDotMethod] = module[@"moduleID"];
|
||||
RCTLocalMethodIDs[moduleDotMethod] = methods[methodName][@"methodID"];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return localModules;
|
||||
}
|
||||
|
||||
@implementation RCTBridge
|
||||
{
|
||||
RCTSparseArray *_modulesByID;
|
||||
NSMutableDictionary *_modulesByName;
|
||||
NSDictionary *_modulesByName;
|
||||
id<RCTJavaScriptExecutor> _javaScriptExecutor;
|
||||
}
|
||||
|
||||
static id<RCTJavaScriptExecutor> _latestJSExecutor;
|
||||
|
||||
- (instancetype)initWithJavaScriptExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor
|
||||
moduleInstances:(NSArray *)moduleInstances
|
||||
moduleProvider:(RCTBridgeModuleProviderBlock)block
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_javaScriptExecutor = javaScriptExecutor;
|
||||
|
@ -417,31 +428,39 @@ static id<RCTJavaScriptExecutor> _latestJSExecutor;
|
|||
|
||||
// Register passed-in module instances
|
||||
NSMutableDictionary *preregisteredModules = [[NSMutableDictionary alloc] init];
|
||||
for (id<RCTBridgeModule> module in moduleInstances) {
|
||||
preregisteredModules[RCTModuleNameForClass([module class])] = module;
|
||||
if (block) {
|
||||
for (id<RCTBridgeModule> module in block(self)) {
|
||||
preregisteredModules[RCTModuleNameForClass([module class])] = module;
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiate modules
|
||||
_modulesByID = [[RCTSparseArray alloc] init];
|
||||
_modulesByName = [[NSMutableDictionary alloc] initWithDictionary:preregisteredModules];
|
||||
NSMutableDictionary *modulesByName = [preregisteredModules mutableCopy];
|
||||
[RCTBridgeModuleClassesByModuleID() enumerateObjectsUsingBlock:^(Class moduleClass, NSUInteger moduleID, BOOL *stop) {
|
||||
NSString *moduleName = RCTModuleNamesByID[moduleID];
|
||||
// Check if module instance has already been registered for this name
|
||||
if (_modulesByName[moduleName] != nil) {
|
||||
if ((_modulesByID[moduleID] = modulesByName[moduleName])) {
|
||||
// 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(RCTCreateModuleInstance(moduleClass, self) == nil,
|
||||
@"Attempted to register RCTBridgeModule class %@ for the name '%@', \
|
||||
but name was already registered by class %@", moduleClass,
|
||||
moduleName, [_modulesByName[moduleName] class]);
|
||||
moduleName, [modulesByName[moduleName] class]);
|
||||
}
|
||||
} else {
|
||||
// Module name hasn't been used before, so go ahead and instantiate
|
||||
_modulesByID[moduleID] = _modulesByName[moduleName] = RCTCreateModuleInstance(moduleClass, self);
|
||||
id<RCTBridgeModule> module = RCTCreateModuleInstance(moduleClass, self);
|
||||
if (module) {
|
||||
_modulesByID[moduleID] = modulesByName[moduleName] = module;
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
// Store modules
|
||||
_modulesByName = [modulesByName copy];
|
||||
|
||||
// Inject module data into JS context
|
||||
NSString *configJSON = RCTJSONStringify(@{
|
||||
@"remoteModuleConfig": RCTRemoteModulesConfig(_modulesByName),
|
||||
|
@ -460,6 +479,14 @@ static id<RCTJavaScriptExecutor> _latestJSExecutor;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (NSDictionary *)modules
|
||||
{
|
||||
RCTAssert(_modulesByName != nil, @"Bridge modules have not yet been initialized. \
|
||||
You may be trying to access a module too early in the startup procedure.");
|
||||
|
||||
return _modulesByName;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RCTAssert(!self.valid, @"must call -invalidate before -dealloc");
|
||||
|
@ -516,7 +543,7 @@ static id<RCTJavaScriptExecutor> _latestJSExecutor;
|
|||
|
||||
[self _invokeAndProcessModule:@"BatchedBridge"
|
||||
method:@"callFunctionReturnFlushedQueue"
|
||||
arguments:@[moduleID, methodID, args]];
|
||||
arguments:@[moduleID, methodID, args ?: @[]]];
|
||||
}
|
||||
|
||||
- (void)enqueueApplicationScript:(NSString *)script url:(NSURL *)url onComplete:(RCTJavaScriptCompleteBlock)onComplete
|
||||
|
@ -699,8 +726,8 @@ static id<RCTJavaScriptExecutor> _latestJSExecutor;
|
|||
switch (argumentType[0]) {
|
||||
case ':':
|
||||
if ([param isKindOfClass:[NSString class]]) {
|
||||
SEL selector = NSSelectorFromString(param);
|
||||
[invocation setArgument:&selector atIndex:argIdx];
|
||||
SEL sel = NSSelectorFromString(param);
|
||||
[invocation setArgument:&sel atIndex:argIdx];
|
||||
shouldSet = NO;
|
||||
}
|
||||
break;
|
||||
|
@ -813,7 +840,7 @@ static id<RCTJavaScriptExecutor> _latestJSExecutor;
|
|||
+ (void)log:(NSArray *)objects level:(NSString *)level
|
||||
{
|
||||
if (!_latestJSExecutor || ![_latestJSExecutor isValid]) {
|
||||
RCTLogError(@"%@", RCTLogFormatString(@"ERROR: No valid JS executor to log %@.", objects));
|
||||
RCTLogError(@"ERROR: No valid JS executor to log %@.", objects);
|
||||
return;
|
||||
}
|
||||
NSMutableArray *args = [NSMutableArray arrayWithObject:level];
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "RCTJSMethodRegistrar.h"
|
||||
|
||||
@class RCTBridge;
|
||||
|
||||
/**
|
||||
|
@ -11,9 +13,9 @@
|
|||
typedef void (^RCTResponseSenderBlock)(NSArray *response);
|
||||
|
||||
/**
|
||||
* Provides minimal interface needed to register a bridge module
|
||||
* Provides the interface needed to register a bridge module.
|
||||
*/
|
||||
@protocol RCTBridgeModule <NSObject>
|
||||
@protocol RCTBridgeModule <RCTJSMethodRegistrar>
|
||||
@optional
|
||||
|
||||
/**
|
||||
|
@ -47,15 +49,12 @@ typedef void (^RCTResponseSenderBlock)(NSArray *response);
|
|||
+ (NSDictionary *)constantsToExport;
|
||||
|
||||
/**
|
||||
* An array of JavaScript methods that the module will call via the
|
||||
* -[RCTBridge enqueueJSCall:args:] method. Each method should be specified
|
||||
* as a string of the form "JSModuleName.jsMethodName". Attempting to call a
|
||||
* method that has not been registered will result in an error. If a method
|
||||
* has already been regsistered by another module, it is not necessary to
|
||||
* register it again, but it is good pratice. Registering the same method
|
||||
* more than once is silently ignored and will not result in an error.
|
||||
* Some "constants" are not really constant, and need to be re-generated
|
||||
* each time the bridge module is created. Support for this feature is
|
||||
* deprecated and may be going away or changing, but for now you can use
|
||||
* the -constantsToExport instance method to register these "pseudo-constants".
|
||||
*/
|
||||
+ (NSArray *)JSMethods;
|
||||
- (NSDictionary *)constantsToExport;
|
||||
|
||||
/**
|
||||
* Notifies the module that a batch of JS method invocations has just completed.
|
||||
|
|
|
@ -30,10 +30,16 @@ typedef NS_ENUM(NSInteger, RCTScrollEventType) {
|
|||
- (instancetype)initWithBridge:(RCTBridge *)bridge;
|
||||
|
||||
/**
|
||||
* Send a device or application event that does not relate to a specific
|
||||
* view, e.g. rotation, location, keyboard show/hide, background/awake, etc.
|
||||
* Send an application-specific event that does not relate to a specific
|
||||
* view, e.g. a navigation or data update notification.
|
||||
*/
|
||||
- (void)sendDeviceEventWithName:(NSString *)name body:(NSDictionary *)body;
|
||||
- (void)sendAppEventWithName:(NSString *)name body:(id)body;
|
||||
|
||||
/**
|
||||
* Send a device or iOS event that does not relate to a specific view,
|
||||
* e.g.rotation, location, keyboard show/hide, background/awake, etc.
|
||||
*/
|
||||
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body;
|
||||
|
||||
/**
|
||||
* Send a user input event. The body dictionary must contain a "target"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
@implementation RCTEventDispatcher
|
||||
{
|
||||
RCTBridge *_bridge;
|
||||
RCTBridge __weak *_bridge;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
|
@ -18,20 +18,34 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)sendDeviceEventWithName:(NSString *)name body:(NSDictionary *)body
|
||||
+ (NSArray *)JSMethods
|
||||
{
|
||||
return @[
|
||||
@"RCTNativeAppEventEmitter.emit",
|
||||
@"RCTDeviceEventEmitter.emit",
|
||||
@"RCTEventEmitter.receiveEvent",
|
||||
];
|
||||
}
|
||||
|
||||
- (void)sendAppEventWithName:(NSString *)name body:(id)body
|
||||
{
|
||||
[_bridge enqueueJSCall:@"RCTNativeAppEventEmitter.emit"
|
||||
args:body ? @[name, body] : @[name]];
|
||||
}
|
||||
|
||||
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
|
||||
{
|
||||
[_bridge enqueueJSCall:@"RCTDeviceEventEmitter.emit"
|
||||
args:body ? @[name, body] : @[name]];
|
||||
}
|
||||
|
||||
|
||||
- (void)sendInputEventWithName:(NSString *)name body:(NSDictionary *)body
|
||||
{
|
||||
RCTAssert([body[@"target"] isKindOfClass:[NSNumber class]],
|
||||
@"Event body dictionary must include a 'target' property containing a react tag");
|
||||
@"Event body dictionary must include a 'target' property containing a react tag");
|
||||
|
||||
[_bridge enqueueJSCall:@"RCTEventEmitter.receiveEvent"
|
||||
args:@[body[@"target"], name, body]];
|
||||
args:body ? @[body[@"target"], name, body] : @[body[@"target"], name]];
|
||||
}
|
||||
|
||||
- (void)sendTextEventWithType:(RCTTextEventType)type
|
||||
|
@ -46,9 +60,11 @@
|
|||
@"topEndEditing",
|
||||
};
|
||||
|
||||
[self sendInputEventWithName:events[type] body:@{
|
||||
[self sendInputEventWithName:events[type] body:text ? @{
|
||||
@"text": text,
|
||||
@"target": reactTag
|
||||
} : @{
|
||||
@"target": reactTag
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class RCTBridge;
|
||||
|
||||
/**
|
||||
* Provides an interface to register JS methods to be called via the bridge.
|
||||
*/
|
||||
@protocol RCTJSMethodRegistrar <NSObject>
|
||||
@optional
|
||||
|
||||
/**
|
||||
* An array of JavaScript methods that the class will call via the
|
||||
* -[RCTBridge enqueueJSCall:args:] method. Each method should be specified
|
||||
* as a string of the form "JSModuleName.jsMethodName". Attempting to call a
|
||||
* method that has not been registered will result in an error. If a method
|
||||
* has already been registered by another class, it is not necessary to
|
||||
* register it again, but it is good practice. Registering the same method
|
||||
* more than once is silently ignored and will not result in an error.
|
||||
*/
|
||||
+ (NSArray *)JSMethods;
|
||||
|
||||
@end
|
|
@ -81,9 +81,20 @@ static Class _globalExecutorClass;
|
|||
object:nil];
|
||||
}
|
||||
|
||||
+ (NSArray *)JSMethods
|
||||
{
|
||||
return @[
|
||||
@"AppRegistry.runApplication",
|
||||
@"ReactIOS.unmountComponentAtNodeAndRemoveContainer"
|
||||
];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[_bridge enqueueJSCall:@"ReactIOS.unmountComponentAtNodeAndRemoveContainer"
|
||||
args:@[self.reactTag]];
|
||||
}
|
||||
|
||||
- (void)bundleFinishedLoading:(NSError *)error
|
||||
|
@ -125,7 +136,7 @@ static Class _globalExecutorClass;
|
|||
|
||||
// Choose local executor if specified, followed by global, followed by default
|
||||
_executor = [[_executorClass ?: _globalExecutorClass ?: [RCTContextExecutor class] alloc] init];
|
||||
_bridge = [[RCTBridge alloc] initWithJavaScriptExecutor:_executor moduleInstances:nil];
|
||||
_bridge = [[RCTBridge alloc] initWithJavaScriptExecutor:_executor moduleProvider:nil];
|
||||
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:_bridge];
|
||||
[self addGestureRecognizer:_touchHandler];
|
||||
|
||||
|
|
|
@ -108,4 +108,9 @@
|
|||
return [[[self class] allocWithZone:zone] initWithSparseArray:self];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [[super description] stringByAppendingString:[_storage description]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -137,6 +137,11 @@ typedef NS_ENUM(NSInteger, RCTTouchEventType) {
|
|||
reactTouch[@"timestamp"] = @(nativeTouch.timestamp * 1000); // in ms, for JS
|
||||
}
|
||||
|
||||
+ (NSArray *)JSMethods
|
||||
{
|
||||
return @[@"RCTEventEmitter.receiveTouches"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs information about touch events to send across the serialized
|
||||
* boundary. This data should be compliant with W3C `Touch` objects. This data
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#import "RCTTiming.h"
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTSparseArray.h"
|
||||
|
@ -11,7 +12,7 @@
|
|||
|
||||
@property (nonatomic, strong, readonly) NSDate *target;
|
||||
@property (nonatomic, assign, readonly) BOOL repeats;
|
||||
@property (nonatomic, strong, readonly) NSNumber *callbackID;
|
||||
@property (nonatomic, copy, readonly) NSNumber *callbackID;
|
||||
@property (nonatomic, assign, readonly) NSTimeInterval interval;
|
||||
|
||||
@end
|
||||
|
@ -172,12 +173,12 @@
|
|||
if (jsSchedulingOverhead < 0) {
|
||||
RCTLogWarn(@"jsSchedulingOverhead (%ims) should be positive", (int)(jsSchedulingOverhead * 1000));
|
||||
}
|
||||
|
||||
|
||||
NSTimeInterval targetTime = interval - jsSchedulingOverhead;
|
||||
if (interval < 0.018) { // Make sure short intervals run each frame
|
||||
interval = 0;
|
||||
}
|
||||
|
||||
|
||||
RCTTimer *timer = [[RCTTimer alloc] initWithCallbackID:callbackID
|
||||
interval:interval
|
||||
targetTime:targetTime
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
13E067531A70F44B002CDEE1 /* UIView+ReactKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+ReactKit.h"; sourceTree = "<group>"; };
|
||||
13E067541A70F44B002CDEE1 /* UIView+ReactKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+ReactKit.m"; sourceTree = "<group>"; };
|
||||
13ED13891A80C9D40050A8F9 /* RCTPointerEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPointerEvents.h; sourceTree = "<group>"; };
|
||||
13EFFCCF1A98E6FE002607DC /* RCTJSMethodRegistrar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJSMethodRegistrar.h; sourceTree = "<group>"; };
|
||||
830213F31A654E0800B993E6 /* RCTBridgeModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTBridgeModule.h; sourceTree = "<group>"; };
|
||||
830A229C1A66C68A008503DA /* RCTRootView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootView.h; sourceTree = "<group>"; };
|
||||
830A229D1A66C68A008503DA /* RCTRootView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootView.m; sourceTree = "<group>"; };
|
||||
|
@ -320,6 +321,7 @@
|
|||
137029521A69923600575408 /* RCTImageDownloader.m */,
|
||||
83CBBA4C1A601E3B00E9B192 /* RCTInvalidating.h */,
|
||||
83CBBA631A601ECA00E9B192 /* RCTJavaScriptExecutor.h */,
|
||||
13EFFCCF1A98E6FE002607DC /* RCTJSMethodRegistrar.h */,
|
||||
13A1F71C1A75392D00D3D453 /* RCTKeyCommands.h */,
|
||||
13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */,
|
||||
83CBBA4D1A601E3B00E9B192 /* RCTLog.h */,
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:ReactKit.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -12,7 +12,9 @@
|
|||
"/node_modules/",
|
||||
"/packager/"
|
||||
],
|
||||
"testFileExtensions": ["js"]
|
||||
"testFileExtensions": [
|
||||
"js"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
|
@ -45,7 +47,8 @@
|
|||
"underscore": "1.7.0",
|
||||
"wordwrap": "0.0.2",
|
||||
"worker-farm": "1.1.0",
|
||||
"yargs": "1.3.2"
|
||||
"yargs": "1.3.2",
|
||||
"joi": "~5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest-cli": "0.2.1",
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
"description": "",
|
||||
"main": "index.js",
|
||||
"jest": {
|
||||
"unmockedModulePathPatterns": ["source-map"],
|
||||
"testPathIgnorePatterns": ["JSAppServer/node_modules"]
|
||||
"unmockedModulePathPatterns": [
|
||||
"source-map"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"JSAppServer/node_modules"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,18 +16,26 @@ var staticTypeSyntax =
|
|||
var visitorList = reactVisitors;
|
||||
|
||||
|
||||
function transform(transformSets, srcTxt, options) {
|
||||
options = options || {};
|
||||
function transform(transformSets, srcTxt) {
|
||||
var options = {
|
||||
es3: true,
|
||||
sourceType: 'nonStrictModule'
|
||||
};
|
||||
|
||||
// These tranforms mostly just erase type annotations and static typing
|
||||
// related statements, but they were conflicting with other tranforms.
|
||||
// Running them first solves that problem
|
||||
var staticTypeSyntaxResult = jstransform(
|
||||
staticTypeSyntax,
|
||||
srcTxt
|
||||
srcTxt,
|
||||
options
|
||||
);
|
||||
|
||||
return jstransform(visitorList, staticTypeSyntaxResult.code);
|
||||
return jstransform(
|
||||
visitorList,
|
||||
staticTypeSyntaxResult.code,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = function(data, callback) {
|
||||
|
@ -35,8 +43,7 @@ module.exports = function(data, callback) {
|
|||
try {
|
||||
result = transform(
|
||||
data.transformSets,
|
||||
data.sourceCode,
|
||||
data.options
|
||||
data.sourceCode
|
||||
);
|
||||
} catch (e) {
|
||||
return callback(null, {
|
||||
|
|
Loading…
Reference in New Issue