From 059f27c7434e3265f4f929452f2decfc25c8a088 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 24 Aug 2021 16:11:04 +0800 Subject: [PATCH] Revert "debugging add module support" This reverts commit 85da528de5e258a765b842ca5e55c4cf81fd2936. --- .../main/java/pub/doric/devkit/DoricDev.java | 10 ---------- .../doric/devkit/remote/RemoteJSExecutor.java | 6 ++++-- .../main/java/pub/doric/DoricSingleton.java | 4 ---- doric-iOS/Devkit/Classes/DoricDev.m | 7 ------- doric-js/bundle/doric-vm.js | 12 ------------ doric-js/index.debug.ts | 18 ------------------ doric-js/lib/index.debug.js | 12 ------------ 7 files changed, 4 insertions(+), 65 deletions(-) diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java index 4e37bcd7..54b8eb37 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.WeakHashMap; @@ -132,15 +131,6 @@ public class DoricDev { .toJSONObject()); } else { final DoricContext context = contexts.get(contexts.size() - 1); - Map bundles = DoricSingleton.getInstance().getJSBundles(); - for (String key : bundles.keySet()) { - wsClient.sendToDebugger( - "LOAD_MODULE", - new JSONBuilder() - .put("name", key) - .put("content", bundles.get(key)) - .toJSONObject()); - } wsClient.sendToDebugger( "DEBUG_RES", new JSONBuilder() diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/remote/RemoteJSExecutor.java b/doric-android/devkit/src/main/java/pub/doric/devkit/remote/RemoteJSExecutor.java index 145a6c7e..71626c31 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/remote/RemoteJSExecutor.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/remote/RemoteJSExecutor.java @@ -19,17 +19,19 @@ import pub.doric.devkit.WSClient; public class RemoteJSExecutor implements WSClient.Interceptor { private final Map globalFunctions = new HashMap<>(); private final WSClient wsClient; + private final Thread currentThread; private final AtomicInteger callIdCounter = new AtomicInteger(); - private final Map mThreads = new HashMap<>(); - private final Map mResults = new HashMap<>(); + private Map mThreads = new HashMap<>(); + private Map mResults = new HashMap<>(); public volatile boolean invokingMethod = false; public RemoteJSExecutor(WSClient wsClient) { this.wsClient = wsClient; this.wsClient.addInterceptor(this); + currentThread = Thread.currentThread(); } public String loadJS(String script, String source) { diff --git a/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java b/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java index 2706aeaf..0f9ee5fd 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricSingleton.java @@ -91,8 +91,4 @@ public class DoricSingleton { public DoricContextManager getContextManager() { return doricContextManager; } - - public Map getJSBundles() { - return bundles; - } } diff --git a/doric-iOS/Devkit/Classes/DoricDev.m b/doric-iOS/Devkit/Classes/DoricDev.m index e71aa969..bee8f77d 100644 --- a/doric-iOS/Devkit/Classes/DoricDev.m +++ b/doric-iOS/Devkit/Classes/DoricDev.m @@ -226,13 +226,6 @@ - (void)startDebugging:(NSString *)source { @"msg": @"Cannot find suitable alive context for debugging" }]; } else { - [DoricSingleton.instance.bundles enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [self.wsClient sendToDebugger:@"LOAD_MODULE" - payload:@{ - @"name": key, - @"content": obj, - }]; - }]; DoricContext *context = contexts.lastObject; [self.wsClient sendToDebugger:@"DEBUG_RES" payload:@{ @"contextId": context.contextId diff --git a/doric-js/bundle/doric-vm.js b/doric-js/bundle/doric-vm.js index 7e491e18..f4cb0e3d 100644 --- a/doric-js/bundle/doric-vm.js +++ b/doric-js/bundle/doric-vm.js @@ -4644,18 +4644,6 @@ function initNativeEnvironment(source) { const msg = JSON.parse(data); const payload = msg.payload; switch (msg.cmd) { - case "": - const { name, content } = payload; - Reflect.apply(jsRegisterModule, undefined, [ - name, - Reflect.apply((function (__module) { - eval(`(function (module, exports, require) { - ${content} - })(__module, __module.exports, doric.__require__)`); - return __module.exports; - }), undefined, [{ exports: {} }]) - ]); - break; case "DEBUG_RES": const contextId = msg.payload.contextId; resolve(contextId); diff --git a/doric-js/index.debug.ts b/doric-js/index.debug.ts index 1949fd2d..eae17329 100644 --- a/doric-js/index.debug.ts +++ b/doric-js/index.debug.ts @@ -53,24 +53,6 @@ async function initNativeEnvironment(source: string) { const msg = JSON.parse(data as string) as MSG const payload = msg.payload switch (msg.cmd) { - case "": - const { name, content } = payload as { - name: string, - content: string - } - Reflect.apply( - doric.jsRegisterModule, - undefined, - [ - name, - Reflect.apply((function (__module: { exports: object }) { - eval(`(function (module, exports, require) { - ${content} - })(__module, __module.exports, doric.__require__)`) - return __module.exports - }), undefined, [{ exports: {} }]) - ]); - break; case "DEBUG_RES": const contextId = msg.payload.contextId as string; resolve(contextId); diff --git a/doric-js/lib/index.debug.js b/doric-js/lib/index.debug.js index d2984654..635d1440 100644 --- a/doric-js/lib/index.debug.js +++ b/doric-js/lib/index.debug.js @@ -54,18 +54,6 @@ function initNativeEnvironment(source) { const msg = JSON.parse(data); const payload = msg.payload; switch (msg.cmd) { - case "": - const { name, content } = payload; - Reflect.apply(doric.jsRegisterModule, undefined, [ - name, - Reflect.apply((function (__module) { - eval(`(function (module, exports, require) { - ${content} - })(__module, __module.exports, doric.__require__)`); - return __module.exports; - }), undefined, [{ exports: {} }]) - ]); - break; case "DEBUG_RES": const contextId = msg.payload.contextId; resolve(contextId);