You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by kf...@apache.org on 2017/06/14 07:51:33 UTC

[1/2] incubator-weex git commit: + [ios] update dom to call native

Repository: incubator-weex
Updated Branches:
  refs/heads/0.14-dev c16beb861 -> d26c46f19


+ [ios] update dom to call native


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/8da1964d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/8da1964d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/8da1964d

Branch: refs/heads/0.14-dev
Commit: 8da1964d660bcb9b95df145c04454800e51d4c7e
Parents: 660efaa
Author: 齐山 <su...@163.com>
Authored: Fri Jun 9 15:10:09 2017 +0800
Committer: 齐山 <su...@163.com>
Committed: Fri Jun 9 15:10:09 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Bridge/WXBridgeContext.m    | 154 +++++++++++++++++++
 ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m | 111 +++++++++++++
 .../WeexSDK/Sources/Protocol/WXBridgeProtocol.h |  38 +++++
 3 files changed, 303 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8da1964d/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index 2990250..8b54377 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -131,6 +131,160 @@ _Pragma("clang diagnostic pop") \
         return 0;
     }];
     
+    [_jsBridge registerCallCreateBody:^NSInteger(NSString *instanceId, NSDictionary *bodyData) {
+        
+        // Temporary here , in order to improve performance, will be refactored next version.
+        WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
+        
+        if (!instance) {
+            WXLogInfo(@"instance not found, maybe already destroyed");
+            return -1;
+        }
+        
+        WXPerformBlockOnComponentThread(^{
+            WXComponentManager *manager = instance.componentManager;
+            if (!manager.isValid) {
+                return;
+            }
+            [manager startComponentTasks];
+            [manager createRoot:bodyData];
+        });
+        
+        return 0;
+    }];
+    
+    [_jsBridge registerCallRemoveElement:^NSInteger(NSString *instanceId, NSString *ref) {
+        
+        // Temporary here , in order to improve performance, will be refactored next version.
+        WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
+        
+        if (!instance) {
+            WXLogInfo(@"instance not found, maybe already destroyed");
+            return -1;
+        }
+        
+        WXPerformBlockOnComponentThread(^{
+            WXComponentManager *manager = instance.componentManager;
+            if (!manager.isValid) {
+                return;
+            }
+            [manager startComponentTasks];
+            [manager removeComponent:ref];
+        });
+        
+        return 0;
+    }];
+    
+    [_jsBridge registerCallMoveElement:^NSInteger(NSString *instanceId,NSString *ref,NSString *parentRef,NSInteger index) {
+        
+        // Temporary here , in order to improve performance, will be refactored next version.
+        WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
+        
+        if (!instance) {
+            WXLogInfo(@"instance not found, maybe already destroyed");
+            return -1;
+        }
+        
+        WXPerformBlockOnComponentThread(^{
+            WXComponentManager *manager = instance.componentManager;
+            if (!manager.isValid) {
+                return;
+            }
+            [manager startComponentTasks];
+            [manager moveComponent:ref toSuper:parentRef atIndex:index];
+        });
+        
+        return 0;
+    }];
+    
+    [_jsBridge registerCallUpdateAttrs:^NSInteger(NSString *instanceId,NSString *ref,NSDictionary *attrsData) {
+        
+        // Temporary here , in order to improve performance, will be refactored next version.
+        WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
+        
+        if (!instance) {
+            WXLogInfo(@"instance not found, maybe already destroyed");
+            return -1;
+        }
+        
+        WXPerformBlockOnComponentThread(^{
+            WXComponentManager *manager = instance.componentManager;
+            if (!manager.isValid) {
+                return;
+            }
+            [manager startComponentTasks];
+            [manager updateAttributes:attrsData forComponent:ref];
+        });
+        
+        return 0;
+    }];
+    
+    [_jsBridge registerCallUpdateStyle:^NSInteger(NSString *instanceId,NSString *ref,NSDictionary *stylesData) {
+        
+        // Temporary here , in order to improve performance, will be refactored next version.
+        WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
+        
+        if (!instance) {
+            WXLogInfo(@"instance not found, maybe already destroyed");
+            return -1;
+        }
+        
+        WXPerformBlockOnComponentThread(^{
+            WXComponentManager *manager = instance.componentManager;
+            if (!manager.isValid) {
+                return;
+            }
+            [manager startComponentTasks];
+            [manager updateStyles:stylesData forComponent:ref];
+        });
+        
+        return 0;
+    }];
+    
+    [_jsBridge registerCallAddEvent:^NSInteger(NSString *instanceId,NSString *ref,NSString *event) {
+        
+        // Temporary here , in order to improve performance, will be refactored next version.
+        WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
+        
+        if (!instance) {
+            WXLogInfo(@"instance not found, maybe already destroyed");
+            return -1;
+        }
+        
+        WXPerformBlockOnComponentThread(^{
+            WXComponentManager *manager = instance.componentManager;
+            if (!manager.isValid) {
+                return;
+            }
+            [manager startComponentTasks];
+            [manager addEvent:event toComponent:ref];
+        });
+        
+        return 0;
+    }];
+    
+    [_jsBridge registerCallRemoveEvent:^NSInteger(NSString *instanceId,NSString *ref,NSString *event) {
+        
+        // Temporary here , in order to improve performance, will be refactored next version.
+        WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
+        
+        if (!instance) {
+            WXLogInfo(@"instance not found, maybe already destroyed");
+            return -1;
+        }
+        
+        WXPerformBlockOnComponentThread(^{
+            WXComponentManager *manager = instance.componentManager;
+            if (!manager.isValid) {
+                return;
+            }
+            [manager startComponentTasks];
+            [manager removeEvent:event fromComponent:ref];
+        });
+        
+        return 0;
+    }];
+    
     [_jsBridge registerCallNativeModule:^NSInvocation*(NSString *instanceId, NSString *moduleName, NSString *methodName, NSArray *arguments, NSDictionary *options) {
         
         WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8da1964d/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
index 1cd52ee..ca32b9b 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
@@ -216,6 +216,117 @@
     _jsContext[@"callAddElement"] = callAddElementBlock;
 }
 
+- (void)registerCallCreateBody:(WXJSCallCreateBody)callCreateBody
+{
+    id WXJSCallCreateBodyBlock = ^(JSValue *instanceId, JSValue *body,JSValue *ifCallback) {
+        
+        NSString *instanceIdString = [instanceId toString];
+        NSDictionary *bodyData = [body toDictionary];
+        
+        WXLogDebug(@"callCreateBody...%@, %@,", instanceIdString, bodyData);
+        
+        return [JSValue valueWithInt32:(int32_t)callCreateBody(instanceIdString, bodyData) inContext:[JSContext currentContext]];
+    };
+    
+    _jsContext[@"callCreateBody"] = WXJSCallCreateBodyBlock;
+}
+
+- (void)registerCallRemoveElement:(WXJSCallRemoveElement)callRemoveElement
+{
+    id WXJSCallCreateBodyBlock = ^(JSValue *instanceId, JSValue *ref,JSValue *ifCallback) {
+        
+        NSString *instanceIdString = [instanceId toString];
+        NSString *refString = [ref toString];
+        
+        WXLogDebug(@"callRemoveElement...%@, %@,", instanceIdString, refString);
+        
+        return [JSValue valueWithInt32:(int32_t)callRemoveElement(instanceIdString, refString) inContext:[JSContext currentContext]];
+    };
+    
+    _jsContext[@"callRemoveElement"] = WXJSCallCreateBodyBlock;
+}
+
+- (void)registerCallMoveElement:(WXJSCallMoveElement)callMoveElement
+{
+    id WXJSCallMoveElementBlock = ^(JSValue *instanceId, JSValue *ref,JSValue *parentRef,JSValue *index, JSValue *ifCallback) {
+        
+        NSString *instanceIdString = [instanceId toString];
+        NSString *refString = [ref toString];
+        NSString *parentRefString = [parentRef toString];
+        NSInteger moveIndex = [[index toNumber] integerValue];
+        
+        WXLogDebug(@"callAddElement...%@, %@,", instanceIdString, refString);
+        
+        return [JSValue valueWithInt32:(int32_t)callMoveElement(instanceIdString, refString,parentRefString,moveIndex) inContext:[JSContext currentContext]];
+    };
+    
+    _jsContext[@"callMoveElement"] = WXJSCallMoveElementBlock;
+}
+
+- (void)registerCallUpdateAttrs:(WXJSCallUpdateAttrs)callUpdateAttrs
+{
+    id WXJSCallUpdateAttrsBlock = ^(JSValue *instanceId, JSValue *ref,JSValue *attrs, JSValue *ifCallback) {
+        
+        NSString *instanceIdString = [instanceId toString];
+        NSString *refString = [ref toString];
+        NSDictionary *attrsData = [attrs toDictionary];
+        
+        WXLogDebug(@"callUpdateAttrs...%@, %@, %@", instanceIdString, refString,attrsData);
+        
+        return [JSValue valueWithInt32:(int32_t)callUpdateAttrs(instanceIdString, refString,attrsData) inContext:[JSContext currentContext]];
+    };
+    
+    _jsContext[@"callUpdateAttrs"] = WXJSCallUpdateAttrsBlock;
+}
+
+- (void)registerCallUpdateStyle:(WXJSCallUpdateStyle)callUpdateStyle
+{
+    id WXJSCallUpdateStyleBlock = ^(JSValue *instanceId, JSValue *ref,JSValue *styles, JSValue *ifCallback) {
+        
+        NSString *instanceIdString = [instanceId toString];
+        NSString *refString = [ref toString];
+        NSDictionary *stylessData = [styles toDictionary];
+        
+        WXLogDebug(@"callUpdateStyle...%@, %@, %@", instanceIdString, refString,stylessData);
+        
+        return [JSValue valueWithInt32:(int32_t)callUpdateStyle(instanceIdString, refString,stylessData) inContext:[JSContext currentContext]];
+    };
+    
+    _jsContext[@"callUpdateStyle"] = WXJSCallUpdateStyleBlock;
+}
+
+- (void)registerCallAddEvent:(WXJSCallAddEvent)callAddEvent
+{
+    id WXJSCallAddEventBlock = ^(JSValue *instanceId, JSValue *ref,JSValue *event, JSValue *ifCallback) {
+        
+        NSString *instanceIdString = [instanceId toString];
+        NSString *refString = [ref toString];
+        NSString *eventString = [event toString];
+        
+        WXLogDebug(@"callAddEvent...%@, %@, %@", instanceIdString, refString,eventString);
+        
+        return [JSValue valueWithInt32:(int32_t)callAddEvent(instanceIdString, refString,eventString) inContext:[JSContext currentContext]];
+    };
+    
+    _jsContext[@"callAddEvent"] = WXJSCallAddEventBlock;
+}
+
+- (void)registerCallRemoveEvent:(WXJSCallRemoveEvent)callRemoveEvent
+{
+    id WXJSCallRemoveEventBlock = ^(JSValue *instanceId, JSValue *ref,JSValue *event, JSValue *ifCallback) {
+        
+        NSString *instanceIdString = [instanceId toString];
+        NSString *refString = [ref toString];
+        NSString *eventString = [event toString];
+        
+        WXLogDebug(@"callRemoveEvent...%@, %@, %@", instanceIdString, refString,eventString);
+        
+        return [JSValue valueWithInt32:(int32_t)callRemoveEvent(instanceIdString, refString,eventString) inContext:[JSContext currentContext]];
+    };
+    
+    _jsContext[@"callRemoveEvent"] = WXJSCallRemoveEventBlock;
+}
+
 - (void)registerCallNativeModule:(WXJSCallNativeModule)callNativeModuleBlock
 {
     _jsContext[@"callNativeModule"] = ^JSValue *(JSValue *instanceId, JSValue *moduleName, JSValue *methodName, JSValue *args, JSValue *options) {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8da1964d/ios/sdk/WeexSDK/Sources/Protocol/WXBridgeProtocol.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXBridgeProtocol.h b/ios/sdk/WeexSDK/Sources/Protocol/WXBridgeProtocol.h
index cfce2a3..7cf115f 100644
--- a/ios/sdk/WeexSDK/Sources/Protocol/WXBridgeProtocol.h
+++ b/ios/sdk/WeexSDK/Sources/Protocol/WXBridgeProtocol.h
@@ -21,6 +21,13 @@
 
 typedef NSInteger(^WXJSCallNative)(NSString *instance, NSArray *tasks, NSString *callback);
 typedef NSInteger(^WXJSCallAddElement)(NSString *instanceId,  NSString *parentRef, NSDictionary *elementData, NSInteger index);
+typedef NSInteger(^WXJSCallCreateBody)(NSString *instanceId, NSDictionary *bodyData);
+typedef NSInteger(^WXJSCallRemoveElement)(NSString *instanceId,NSString *ref);
+typedef NSInteger(^WXJSCallMoveElement)(NSString *instanceId,NSString *ref,NSString *parentRef,NSInteger index);
+typedef NSInteger(^WXJSCallUpdateAttrs)(NSString *instanceId,NSString *ref,NSDictionary *attrsData);
+typedef NSInteger(^WXJSCallUpdateStyle)(NSString *instanceId,NSString *ref,NSDictionary *stylesData);
+typedef NSInteger(^WXJSCallAddEvent)(NSString *instanceId,NSString *ref,NSString *event);
+typedef NSInteger(^WXJSCallRemoveEvent)(NSString *instanceId,NSString *ref,NSString *event);
 typedef NSInvocation *(^WXJSCallNativeModule)(NSString *instanceId, NSString *moduleName, NSString *methodName, NSArray *args, NSDictionary *options);
 typedef void (^WXJSCallNativeComponent)(NSString *instanceId, NSString *componentRef, NSString *methodName, NSArray *args, NSDictionary *options);
 
@@ -72,6 +79,37 @@ typedef void (^WXJSCallNativeComponent)(NSString *instanceId, NSString *componen
 - (void)registerCallAddElement:(WXJSCallAddElement)callAddElement;
 
 /**
+ * Register callback when createBody tasks occur
+ */
+- (void)registerCallCreateBody:(WXJSCallCreateBody)callCreateBody;
+
+/**
+ * Register callback when removeElement tasks occur
+ */
+- (void)registerCallRemoveElement:(WXJSCallRemoveElement)callRemoveElement;
+
+/**
+ * Register callback when removeElement tasks occur
+ */
+- (void)registerCallMoveElement:(WXJSCallMoveElement)callMoveElement;
+
+/**
+ * Register callback when updateAttrs tasks occur
+ */
+- (void)registerCallUpdateAttrs:(WXJSCallUpdateAttrs)callUpdateAttrs;
+/**
+ * Register callback when updateStyle tasks occur
+ */
+- (void)registerCallUpdateStyle:(WXJSCallUpdateStyle)callUpdateStyle;
+/**
+ * Register callback when addEvent tasks occur
+ */
+- (void)registerCallAddEvent:(WXJSCallAddEvent)callAddEvent;
+/**
+ * Register callback when removeEvent tasks occur
+ */
+- (void)registerCallRemoveEvent:(WXJSCallRemoveEvent)callRemoveEvent;
+/**
  * Register callback for global js function `callNativeModule`
  */
 - (void)registerCallNativeModule:(WXJSCallNativeModule)callNativeModuleBlock;


[2/2] incubator-weex git commit: Merge branch '0.14-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into ios-dom-0.14-dev

Posted by kf...@apache.org.
Merge branch '0.14-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into ios-dom-0.14-dev


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/d26c46f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d26c46f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d26c46f1

Branch: refs/heads/0.14-dev
Commit: d26c46f198870db400216cae4d41c3c6559f8269
Parents: 8da1964 c16beb8
Author: 齐山 <su...@163.com>
Authored: Wed Jun 14 15:50:18 2017 +0800
Committer: 齐山 <su...@163.com>
Committed: Wed Jun 14 15:50:18 2017 +0800

----------------------------------------------------------------------
 .travis.yml                                     |  86 ++++++++++++++----
 android/run-ci.sh                               |   7 --
 android/sdk/build.gradle                        |  11 +--
 .../taobao/weex/ui/module/WXTimerModule.java    |  87 ++++++++++---------
 .../weex/ui/module/WXTimerModuleTest.java       |  44 +++++++---
 ios/playground/WeexDemo/WXDemoViewController.m  |   6 --
 .../Sources/Component/WXCycleSliderComponent.m  |   7 +-
 package.json                                    |   2 +-
 test/ci-funcs.sh                                |  18 ----
 test/pages/css/border.vue                       |  15 ++--
 test/run.sh                                     |   4 +-
 test/screenshot/border-ios.png                  | Bin 128206 -> 126375 bytes
 test/scripts/util.js                            |   5 +-
 test/serve.sh                                   |   3 +-
 14 files changed, 175 insertions(+), 120 deletions(-)
----------------------------------------------------------------------