24
24
#import " PDDOMDomainController.h"
25
25
#import " PDInspectorDomainController.h"
26
26
#import " PDConsoleDomainController.h"
27
- #import " WXDebuggerDomainController .h"
27
+ #import " WXSourceDebuggerDomainController .h"
28
28
#import " WXTimelineDomainController.h"
29
29
#import " WXCSSDomainController.h"
30
+ #import " WXDebugDomainController.h"
30
31
#import " WXDevTool.h"
31
32
32
33
#import " WXAppConfiguration.h"
@@ -133,10 +134,7 @@ - (void)webSocketDidOpen:(SRWebSocket *)webSocket;
133
134
- (void )webSocket : (SRWebSocket *)webSocket didReceiveMessage : (NSString *)message ;
134
135
{
135
136
if ([WXDevTool isDebug ]) {
136
- __weak typeof (self) weakSelf = self;
137
- [self _executeBridgeThead: ^() {
138
- [weakSelf _evaluateNative: message];
139
- }];
137
+ [self _changeToDebugLogicMessage: message];
140
138
}
141
139
142
140
NSDictionary *obj = [NSJSONSerialization JSONObjectWithData: [message dataUsingEncoding: NSUTF8StringEncoding] options: 0 error: nil ];
@@ -154,6 +152,12 @@ - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(NSString *)message
154
152
if (result) {
155
153
NSMutableDictionary *newResult = [[NSMutableDictionary alloc ] initWithCapacity: result.count];
156
154
[result enumerateKeysAndObjectsUsingBlock: ^(id key, id val, BOOL *stop) {
155
+ if ([key isEqualToString: @" WXDebug_result" ]) {
156
+ [WXDevTool setDebug: YES ];
157
+ [WXSDKEngine restart ];
158
+ [[NSNotificationCenter defaultCenter ] postNotificationName: @" RefreshInstance" object: nil ];
159
+ return ;
160
+ }
157
161
[newResult setObject: [val PD_JSONObjectCopy ] forKey: key];
158
162
}];
159
163
[response setObject: newResult forKey: @" result" ];
@@ -443,11 +447,11 @@ - (void)clearConsole;
443
447
- (void )enableRemoteDebugger {
444
448
[self _addController: [PDRuntimeDomainController defaultInstance ]];
445
449
[self _addController: [PDPageDomainController defaultInstance ]];
446
- [self _addController: [WXDebuggerDomainController defaultInstance ]];
450
+ [self _addController: [WXSourceDebuggerDomainController defaultInstance ]];
447
451
}
448
452
449
453
- (void )remoteDebuggertest {
450
- [[WXDebuggerDomainController defaultInstance ] remoteDebuggerControllerTest ];
454
+ [[WXSourceDebuggerDomainController defaultInstance ] remoteDebuggerControllerTest ];
451
455
}
452
456
453
457
#pragma mark - Timeline
@@ -460,6 +464,11 @@ - (void)enableCSSStyle {
460
464
[self _addController: [WXCSSDomainController defaultInstance ]];
461
465
}
462
466
467
+ #pragma mark - DevToolDebug
468
+ - (void )enableDevToolDebug {
469
+ [self _addController: [WXDebugDomainController defaultInstance ]];
470
+ }
471
+
463
472
#pragma mark - WXBridgeProtocol
464
473
- (void )executeJSFramework : (NSString *)frameworkScript {
465
474
// WXLogInfo(@"======yangshengtao 0:jsThread:%@,currentThread:%@",_bridgeThread,[NSThread currentThread]);
@@ -513,6 +522,13 @@ - (void)resetEnvironment
513
522
514
523
515
524
#pragma mark - Private Methods
525
+ - (void )_changeToDebugLogicMessage : (NSString *)message {
526
+ __weak typeof (self) weakSelf = self;
527
+ [self _executeBridgeThead: ^() {
528
+ [weakSelf _evaluateNative: message];
529
+ }];
530
+ }
531
+
516
532
- (void )_initBridgeThread {
517
533
_bridgeThread = [NSThread currentThread ];
518
534
if (_debugAry.count > 0 && _registerData) {
@@ -559,7 +575,12 @@ - (void)_executeBridgeThead:(dispatch_block_t)block
559
575
-(void )_evaluateNative : (NSString *)data
560
576
{
561
577
NSDictionary *dict = [WXUtility objectFromJSON: data];
562
- NSString *method = [[dict objectForKey: @" method" ] substringFromIndex: 8 ];
578
+
579
+ NSString *fullMethodName = [dict objectForKey: @" method" ];
580
+ NSInteger dotPosition = [fullMethodName rangeOfString: @" ." ].location ;
581
+ NSString *method = [fullMethodName substringFromIndex: dotPosition + 1 ];
582
+
583
+ // NSString *method = [[dict objectForKey:@"method"] substringFromIndex:8];
563
584
NSDictionary *args = [dict objectForKey: @" params" ];
564
585
565
586
if ([method isEqualToString: @" callNative" ]) {
@@ -645,6 +666,12 @@ - (void)_registerDeviceWithParams:(id)params {
645
666
[_debugAry insertObject: encodedData atIndex: 0 ];
646
667
[self _executionDebugAry ];
647
668
}];
669
+ }else if (![WXDevTool isDebug ]) {
670
+ [self _executeBridgeThead: ^{
671
+ _registerData = encodedData;
672
+ [_msgAry insertObject: encodedData atIndex: 0 ];
673
+ [self _executionMsgAry ];
674
+ }];
648
675
}
649
676
}
650
677
0 commit comments