Revert "debugging add module support"

This reverts commit 85da528de5e258a765b842ca5e55c4cf81fd2936.
This commit is contained in:
pengfei.zhou 2021-08-24 16:11:04 +08:00 committed by osborn
parent 7516cef93e
commit 059f27c743
7 changed files with 4 additions and 65 deletions

View File

@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@ -132,15 +131,6 @@ public class DoricDev {
.toJSONObject()); .toJSONObject());
} else { } else {
final DoricContext context = contexts.get(contexts.size() - 1); final DoricContext context = contexts.get(contexts.size() - 1);
Map<String, String> 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( wsClient.sendToDebugger(
"DEBUG_RES", "DEBUG_RES",
new JSONBuilder() new JSONBuilder()

View File

@ -19,17 +19,19 @@ import pub.doric.devkit.WSClient;
public class RemoteJSExecutor implements WSClient.Interceptor { public class RemoteJSExecutor implements WSClient.Interceptor {
private final Map<String, JavaFunction> globalFunctions = new HashMap<>(); private final Map<String, JavaFunction> globalFunctions = new HashMap<>();
private final WSClient wsClient; private final WSClient wsClient;
private final Thread currentThread;
private final AtomicInteger callIdCounter = new AtomicInteger(); private final AtomicInteger callIdCounter = new AtomicInteger();
private final Map<Integer, Thread> mThreads = new HashMap<>(); private Map<Integer, Thread> mThreads = new HashMap<>();
private final Map<Integer, JSDecoder> mResults = new HashMap<>(); private Map<Integer, JSDecoder> mResults = new HashMap<>();
public volatile boolean invokingMethod = false; public volatile boolean invokingMethod = false;
public RemoteJSExecutor(WSClient wsClient) { public RemoteJSExecutor(WSClient wsClient) {
this.wsClient = wsClient; this.wsClient = wsClient;
this.wsClient.addInterceptor(this); this.wsClient.addInterceptor(this);
currentThread = Thread.currentThread();
} }
public String loadJS(String script, String source) { public String loadJS(String script, String source) {

View File

@ -91,8 +91,4 @@ public class DoricSingleton {
public DoricContextManager getContextManager() { public DoricContextManager getContextManager() {
return doricContextManager; return doricContextManager;
} }
public Map<String, String> getJSBundles() {
return bundles;
}
} }

View File

@ -226,13 +226,6 @@ - (void)startDebugging:(NSString *)source {
@"msg": @"Cannot find suitable alive context for debugging" @"msg": @"Cannot find suitable alive context for debugging"
}]; }];
} else { } 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; DoricContext *context = contexts.lastObject;
[self.wsClient sendToDebugger:@"DEBUG_RES" payload:@{ [self.wsClient sendToDebugger:@"DEBUG_RES" payload:@{
@"contextId": context.contextId @"contextId": context.contextId

View File

@ -4644,18 +4644,6 @@ function initNativeEnvironment(source) {
const msg = JSON.parse(data); const msg = JSON.parse(data);
const payload = msg.payload; const payload = msg.payload;
switch (msg.cmd) { 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": case "DEBUG_RES":
const contextId = msg.payload.contextId; const contextId = msg.payload.contextId;
resolve(contextId); resolve(contextId);

View File

@ -53,24 +53,6 @@ async function initNativeEnvironment(source: string) {
const msg = JSON.parse(data as string) as MSG const msg = JSON.parse(data as string) as MSG
const payload = msg.payload const payload = msg.payload
switch (msg.cmd) { 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": case "DEBUG_RES":
const contextId = msg.payload.contextId as string; const contextId = msg.payload.contextId as string;
resolve(contextId); resolve(contextId);

View File

@ -54,18 +54,6 @@ function initNativeEnvironment(source) {
const msg = JSON.parse(data); const msg = JSON.parse(data);
const payload = msg.payload; const payload = msg.payload;
switch (msg.cmd) { 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": case "DEBUG_RES":
const contextId = msg.payload.contextId; const contextId = msg.payload.contextId;
resolve(contextId); resolve(contextId);