Skip to content

Commit

Permalink
release 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
misakuo committed Jul 21, 2017
1 parent e02dc75 commit 9a28cd2
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 305 deletions.
3 changes: 2 additions & 1 deletion inspector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ buildscript {

allprojects {
repositories {
maven { url "http://mvnrepo.alibaba-inc.com/mvn/repository" }
mavenCentral()
jcenter()
}
Expand Down Expand Up @@ -81,7 +82,7 @@ android.libraryVariants.all { variant ->
into "build/metainf-${name}/META-INF"
}

task "fatjar${name}"(type: Jar, dependsOn: [ "jar${name}", "tidyCommonsCli${name}", "metainf${name}" ]) {
task "fatjar${name}"(type: Jar, dependsOn: ["jar${name}", "tidyCommonsCli${name}", "metainf${name}"]) {
classifier = 'fatjar'
from variant.javaCompile.destinationDir
from "build/commons-cli-tidy-${name}"
Expand Down
2 changes: 1 addition & 1 deletion inspector/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ POM_ARTIFACT_ID=inspector
POM_OPTIONAL_DEPS=com.android.support:appcompat-v7
POM_PACKAGING=aar

WEEX_SDK_VERSION = 0.11.0
WEEX_SDK_VERSION = 0.13.2.7
FAST_JSON_VERSION = 1.1.45+
PROTOCOL_VERSION = 1.1.2
64 changes: 10 additions & 54 deletions inspector/src/main/java/com/taobao/weex/devtools/WeexInspector.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;

import com.taobao.weex.devtools.common.LogUtil;
import com.taobao.weex.devtools.debug.IWebSocketClient;
import com.taobao.weex.devtools.inspector.console.RuntimeReplFactory;
import com.taobao.weex.devtools.inspector.database.DatabaseFilesProvider;
import com.taobao.weex.devtools.inspector.database.DefaultDatabaseFilesProvider;
Expand Down Expand Up @@ -42,13 +42,6 @@
import com.taobao.weex.devtools.inspector.protocol.module.Worker;
import com.taobao.weex.devtools.inspector.protocol.module.WxDebug;
import com.taobao.weex.devtools.inspector.runtime.RhinoDetectingRuntimeReplFactory;
//import com.taobao.weex.devtools.server.AddressNameHelper;
//import com.taobao.weex.devtools.server.LazySocketHandler;
//import com.taobao.weex.devtools.server.LocalSocketServer;
//import com.taobao.weex.devtools.server.ProtocolDetectingSocketHandler;
//import com.taobao.weex.devtools.server.ServerManager;
//import com.taobao.weex.devtools.server.SocketHandler;
//import com.taobao.weex.devtools.server.SocketHandlerFactory;

import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -69,6 +62,7 @@
* the {@code stetho-sample} for more information.
*/
public class WeexInspector {
private static IWebSocketClient customerWSClient;
private WeexInspector() {
}

Expand Down Expand Up @@ -121,15 +115,6 @@ public static void initialize(final Initializer initializer) {
// initializer.start();
}

// public static DumperPluginsProvider defaultDumperPluginsProvider(final Context context) {
// return new DumperPluginsProvider() {
// @Override
// public Iterable<DumperPlugin> get() {
// return new DefaultDumperPluginsBuilder(context).finish();
// }
// };
// }

public static InspectorModulesProvider defaultInspectorModulesProvider(final Context context) {
return new InspectorModulesProvider() {
@Override
Expand Down Expand Up @@ -179,43 +164,6 @@ public Iterable<T> finish() {
}
}

/**
* Convenience mechanism to extend the default set of dumper plugins provided by WeexInspector.
*
* @see #initializeWithDefaults(Context)
*/
// public static final class DefaultDumperPluginsBuilder {
// private final Context mContext;
// private final PluginBuilder<DumperPlugin> mDelegate = new PluginBuilder<>();
//
// public DefaultDumperPluginsBuilder(Context context) {
// mContext = context;
// }
//
// public DefaultDumperPluginsBuilder provide(DumperPlugin plugin) {
// mDelegate.provide(plugin.getName(), plugin);
// return this;
// }
//
// private DefaultDumperPluginsBuilder provideIfDesired(DumperPlugin plugin) {
// mDelegate.provideIfDesired(plugin.getName(), plugin);
// return this;
// }
//
// public DefaultDumperPluginsBuilder remove(String pluginName) {
// mDelegate.remove(pluginName);
// return this;
// }
//
// public Iterable<DumperPlugin> finish() {
// provideIfDesired(new HprofDumperPlugin(mContext));
// provideIfDesired(new SharedPreferencesDumperPlugin(mContext));
// provideIfDesired(new CrashDumperPlugin());
// provideIfDesired(new FilesDumperPlugin(mContext));
// return mDelegate.finish();
// }
// }

/**
* Configuration mechanism to customize the behaviour of the standard set of inspector
* modules satisfying the Chrome DevTools protocol. Note that while it is still technically
Expand Down Expand Up @@ -365,6 +313,14 @@ private DocumentProviderFactory resolveDocumentProvider() {
}
}

public static void overrideWebSocketClient(IWebSocketClient webSocketClient) {
WeexInspector.customerWSClient = webSocketClient;
}

public static IWebSocketClient getCustomerWSClient() {
return WeexInspector.customerWSClient;
}

/**
* Callers can choose to subclass this directly to provide the initialization configuration
* or they can construct a concrete instance using {@link #newInitializerBuilder(Context)}.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.taobao.weex.devtools.debug;

import com.taobao.weex.devtools.WeexInspector;

import java.io.IOException;

/**
* Created by moxun on 2017/6/12.
*/

public class CustomerWSClient extends SocketClient {

private IWebSocketClient webSocketClient;

public CustomerWSClient(DebugServerProxy proxy) {
super(proxy);
webSocketClient = WeexInspector.getCustomerWSClient();
}

@Override
protected void connect(String url) {
if (webSocketClient != null) {
webSocketClient.connect(url, new IWebSocketClient.WSListener() {
@Override
public void onOpen() {
if (mConnectCallback != null) {
mConnectCallback.onSuccess(null);
}
}

@Override
public void onMessage(String message) {
try {
mProxy.handleMessage(message);
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void onClose() {
if (mHandlerThread != null && mHandlerThread.isAlive()) {
mHandler.sendEmptyMessage(CLOSE_WEB_SOCKET);
}
}

@Override
public void onFailure(Throwable cause) {
if (mConnectCallback != null) {
mConnectCallback.onFailure(cause);
mConnectCallback = null;
}
}
});
}
}

@Override
protected void close() {
if (webSocketClient != null) {
webSocketClient.close();
}
}

@Override
protected void sendProtocolMessage(int requestID, String message) {
if (webSocketClient != null) {
webSocketClient.sendMessage(requestID, message);
}
}

@Override
public boolean isOpen() {
return webSocketClient != null && webSocketClient.isOpen();
}

public boolean isAvailed() {
return webSocketClient != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public int execJS(String instanceId, String namespace, String function, WXJSObje

@Override
public int execJSService(String javascript) {
if(!TextUtils.isEmpty(javascript)){
if (!TextUtils.isEmpty(javascript)) {
Map<String, Object> params = new HashMap<>();
params.put(WXDebugConstants.PARAM_JS_SOURCE, javascript);

Expand Down Expand Up @@ -177,6 +177,76 @@ public void callNativeComponent(String instanceId, String componentRef, String m
WXBridgeManager.getInstance().callNativeComponent(instanceId, componentRef, method, argArray, options);
}

public int callCreateBody(String s, String s1, String s2) {
if (mJsManager != null) {
return mJsManager.callCreateBody(s, s1, s2);
}
return 0;
}

public int callUpdateFinish(String s, byte[] bytes, String s1) {
if (mJsManager != null) {
return mJsManager.callUpdateFinish(s, s1);
}
return 0;
}

public int callCreateFinish(String s, byte[] bytes, String s1) {
if (mJsManager != null) {
return mJsManager.callCreateFinish(s, s1);
}
return 0;
}

public int callRefreshFinish(String s, byte[] bytes, String s1) {
if (mJsManager != null) {
return mJsManager.callRefreshFinish(s, s1);
}
return 0;
}

public int callUpdateAttrs(String s, String s1, byte[] bytes, String s2) {
if (mJsManager != null) {
return mJsManager.callUpdateAttrs(s, s1, new String(bytes), s2);
}
return 0;
}

public int callUpdateStyle(String s, String s1, byte[] bytes, String s2) {
if (mJsManager != null) {
return mJsManager.callUpdateStyle(s, s1, new String(bytes), s2);
}
return 0;
}

public int callRemoveElement(String s, String s1, String s2) {
if (mJsManager != null) {
return mJsManager.callRemoveElement(s, s1, s2);
}
return 0;
}

public int callMoveElement(String s, String s1, String s2, String s3, String s4) {
if (mJsManager != null) {
return mJsManager.callMoveElement(s, s1, s2, s3, s4);
}
return 0;
}

public int callAddEvent(String s, String s1, String s2, String s3) {
if (mJsManager != null) {
return mJsManager.callAddEvent(s, s1, s2, s3);
}
return 0;
}

public int callRemoveEvent(String s, String s1, String s2, String s3) {
if (mJsManager != null) {
return mJsManager.callRemoveEvent(s, s1, s2, s3);
}
return 0;
}

public void onConnected() {
Log.v(TAG, "connect to debug server success");
synchronized (mLock) {
Expand Down Expand Up @@ -206,4 +276,8 @@ private int sendMessage(String message) {
public void takeHeapSnapshot(String filename) {
LogUtil.log("warning", "Ignore invoke takeSnapshot: " + filename);
}

public int callCreateBody(String instanceId, byte[] tasks, String callback) {
return callCreateBody(instanceId, new String(tasks), callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

public class DebugServerProxy implements IWXDebugProxy {
private static final String TAG = "DebugServerProxy";
private static final String DEVTOOL_VERSION = "0.8.0.0";
private static final String DEVTOOL_VERSION = "0.12.0";
private SocketClient mWebSocketClient;
private ObjectMapper mObjectMapper = new ObjectMapper();
private MethodDispatcher mMethodDispatcher;
Expand Down Expand Up @@ -84,14 +84,19 @@ private String getDeviceId(Context context) {
return deviceId;
}

@Override
public void start() {
synchronized (DebugServerProxy.class) {
if (mContext == null) {
new IllegalArgumentException("Context is null").printStackTrace();
return;
}
WXEnvironment.sDebugServerConnectable = true;
WeexInspector.initializeWithDefaults(mContext);
mBridge = DebugBridge.getInstance();
mBridge.setSession(mWebSocketClient);
mBridge.setBridgeManager(mJsManager);
mWebSocketClient.connect(mRemoteUrl, new OkHttp3SocketClient.Callback() {
mWebSocketClient.connect(mRemoteUrl, new SocketClient.Callback() {

private String getShakeHandsMessage() {
Map<String, Object> func = new HashMap<>();
Expand Down Expand Up @@ -148,15 +153,16 @@ public void onFailure(Throwable cause) {
if (mBridge != null) {
mBridge.onDisConnected();
}
Log.d(TAG, "connect debugger server failure!! " + cause.toString());
Log.w(TAG, "connect debugger server failure!!");
cause.printStackTrace();
}
}

});
}
}

//@Override
@Override
public void stop(boolean reload) {
synchronized (DebugServerProxy.class) {
if (mWebSocketClient != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.taobao.weex.devtools.debug;

/**
* Created by moxun on 2017/6/12.
*/

public interface IWebSocketClient {
boolean isOpen();
void connect(String wsAddress, WSListener listener);
void close();
void sendMessage(int requestId, String message);

interface WSListener {
void onOpen();
void onMessage(String message);
void onClose();
void onFailure(Throwable cause);
}
}
Loading

0 comments on commit 9a28cd2

Please sign in to comment.