11import * as constants from "../../constants" ;
22import * as minimatch from "minimatch" ;
3- import { cache } from "../../common/decorators" ;
4- import { IOS_APP_CRASH_LOG_REG_EXP } from "../../common/constants" ;
53import * as net from "net" ;
64import { DeviceLiveSyncServiceBase } from "./device-livesync-service-base" ;
75import { performanceLog } from "../../common/decorators" ;
@@ -10,10 +8,7 @@ import * as semver from "semver";
108let currentPageReloadId = 0 ;
119
1210export 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 ./ ;
1511 private static MIN_RUNTIME_VERSION_WITH_REFRESH_NOTIFICATION = "6.1.0" ;
16- private _isLiveSyncSuccessful : boolean = null ;
1712
1813 private socket : net . Socket ;
1914
@@ -22,12 +17,10 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
2217 private $iOSSocketRequestExecutor : IiOSSocketRequestExecutor ,
2318 private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
2419 private $lockService : ILockService ,
25- private $logParserService : ILogParserService ,
2620 protected platformsDataService : IPlatformsDataService ,
2721 private $platformCommandHelper : IPlatformCommandHelper ,
2822 protected device : Mobile . IiOSDevice ) {
2923 super ( platformsDataService , device ) ;
30-
3124 }
3225
3326 private canRefreshWithNotification ( projectData : IProjectData ) : boolean {
@@ -123,16 +116,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
123116 private async refreshWithNotification ( projectData : IProjectData ) {
124117 let didRefresh = false ;
125118 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 ) ;
136120 } , `ios-device-livesync-${ this . device . deviceInfo . identifier } -${ projectData . projectIdentifiers . ios } .lock` ) ;
137121
138122 return didRefresh ;
@@ -147,55 +131,6 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
147131 } ) ;
148132 }
149133
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-
199134 private async reloadPage ( ) : Promise < void > {
200135 const message = JSON . stringify ( {
201136 method : "Page.reload" ,
0 commit comments