1
1
import * as constants from "../../constants" ;
2
2
import * as minimatch from "minimatch" ;
3
- import { cache } from "../../common/decorators" ;
4
- import { IOS_APP_CRASH_LOG_REG_EXP } from "../../common/constants" ;
5
3
import * as net from "net" ;
6
4
import { DeviceLiveSyncServiceBase } from "./device-livesync-service-base" ;
7
5
import { performanceLog } from "../../common/decorators" ;
@@ -10,10 +8,7 @@ import * as semver from "semver";
10
8
let currentPageReloadId = 0 ;
11
9
12
10
export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implements INativeScriptDeviceLiveSyncService {
13
- public static SUCCESS_LIVESYNC_LOG_REGEX = / S u c c e s s f u l l y r e f r e s h e d t h e a p p l i c a t i o n w i t h R e f r e s h R e q u e s t ./ ;
14
- public static FAIL_LIVESYNC_LOG_REGEX = / F a i l e d t o r e f r e s h t h e a p p l i c a t i o n w i t h R e f r e s h R e q u e s t ./ ;
15
11
private static MIN_RUNTIME_VERSION_WITH_REFRESH_NOTIFICATION = "6.1.0" ;
16
- private _isLiveSyncSuccessful : boolean = null ;
17
12
18
13
private socket : net . Socket ;
19
14
@@ -22,12 +17,10 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
22
17
private $iOSSocketRequestExecutor : IiOSSocketRequestExecutor ,
23
18
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
24
19
private $lockService : ILockService ,
25
- private $logParserService : ILogParserService ,
26
20
protected platformsDataService : IPlatformsDataService ,
27
21
private $platformCommandHelper : IPlatformCommandHelper ,
28
22
protected device : Mobile . IiOSDevice ) {
29
23
super ( platformsDataService , device ) ;
30
-
31
24
}
32
25
33
26
private canRefreshWithNotification ( projectData : IProjectData ) : boolean {
@@ -123,16 +116,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
123
116
private async refreshWithNotification ( projectData : IProjectData ) {
124
117
let didRefresh = false ;
125
118
await this . $lockService . executeActionWithLock ( async ( ) => {
126
- this . _isLiveSyncSuccessful = null ;
127
- this . attachToLiveSyncLogs ( ) ;
128
- // TODO: start the application only when needed when we know the app state
129
- await this . device . applicationManager . startApplication ( {
130
- appId : projectData . projectIdentifiers . ios ,
131
- projectName : projectData . projectName ,
132
- projectDir : projectData . projectDir
133
- } ) ;
134
- await this . $iOSSocketRequestExecutor . executeRefreshRequest ( this . device , projectData . projectIdentifiers . ios ) ;
135
- didRefresh = await this . isLiveSyncSuccessful ( ) ;
119
+ didRefresh = await this . $iOSSocketRequestExecutor . executeRefreshRequest ( this . device , projectData . projectIdentifiers . ios ) ;
136
120
} , `ios-device-livesync-${ this . device . deviceInfo . identifier } -${ projectData . projectIdentifiers . ios } .lock` ) ;
137
121
138
122
return didRefresh ;
@@ -147,55 +131,6 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
147
131
} ) ;
148
132
}
149
133
150
- @cache ( )
151
- private attachToLiveSyncLogs ( ) : void {
152
- this . $logParserService . addParseRule ( {
153
- regex : IOSDeviceLiveSyncService . SUCCESS_LIVESYNC_LOG_REGEX ,
154
- handler : this . onSuccessfulLiveSync . bind ( this ) ,
155
- name : "successfulLiveSync" ,
156
- platform : this . $devicePlatformsConstants . iOS . toLowerCase ( )
157
- } ) ;
158
- this . $logParserService . addParseRule ( {
159
- regex : IOSDeviceLiveSyncService . FAIL_LIVESYNC_LOG_REGEX ,
160
- handler : this . onFailedLiveSync . bind ( this ) ,
161
- name : "failedLiveSync" ,
162
- platform : this . $devicePlatformsConstants . iOS . toLowerCase ( )
163
- } ) ;
164
- this . $logParserService . addParseRule ( {
165
- regex : IOS_APP_CRASH_LOG_REG_EXP ,
166
- handler : this . onFailedLiveSync . bind ( this ) ,
167
- name : "liveSyncCrash" ,
168
- platform : this . $devicePlatformsConstants . iOS . toLowerCase ( )
169
- } ) ;
170
- }
171
-
172
- private onSuccessfulLiveSync ( ) : void {
173
- this . _isLiveSyncSuccessful = true ;
174
- }
175
-
176
- private onFailedLiveSync ( ) : void {
177
- this . _isLiveSyncSuccessful = false ;
178
- }
179
-
180
- private async isLiveSyncSuccessful ( ) : Promise < boolean > {
181
- return new Promise < boolean > ( ( resolve , reject ) => {
182
- const retryInterval = 500 ;
183
- let retryCount = 60 * 1000 / retryInterval ;
184
-
185
- const interval = setInterval ( ( ) => {
186
- if ( this . _isLiveSyncSuccessful !== null ) {
187
- clearInterval ( interval ) ;
188
- resolve ( this . _isLiveSyncSuccessful ) ;
189
- } else if ( retryCount === 0 ) {
190
- clearInterval ( interval ) ;
191
- resolve ( false ) ;
192
- } else {
193
- retryCount -- ;
194
- }
195
- } , retryInterval ) ;
196
- } ) ;
197
- }
198
-
199
134
private async reloadPage ( ) : Promise < void > {
200
135
const message = JSON . stringify ( {
201
136
method : "Page.reload" ,
0 commit comments