Skip to content

Commit 33371a4

Browse files
rosen-vladimirovDimitar Kerezov
authored andcommitted
WIP next
1 parent a0f037e commit 33371a4

File tree

4 files changed

+142
-146
lines changed

4 files changed

+142
-146
lines changed

lib/declarations.d.ts

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -257,149 +257,6 @@ interface IOpener {
257257
open(target: string, appname: string): void;
258258
}
259259

260-
interface IFSWatcher extends NodeJS.EventEmitter {
261-
// from fs.FSWatcher
262-
close(): void;
263-
264-
/**
265-
* events.EventEmitter
266-
* 1. change
267-
* 2. error
268-
*/
269-
addListener(event: string, listener: Function): this;
270-
addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
271-
addListener(event: "error", listener: (code: number, signal: string) => void): this;
272-
273-
on(event: string, listener: Function): this;
274-
on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
275-
on(event: "error", listener: (code: number, signal: string) => void): this;
276-
277-
once(event: string, listener: Function): this;
278-
once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
279-
once(event: "error", listener: (code: number, signal: string) => void): this;
280-
281-
prependListener(event: string, listener: Function): this;
282-
prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
283-
prependListener(event: "error", listener: (code: number, signal: string) => void): this;
284-
285-
prependOnceListener(event: string, listener: Function): this;
286-
prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
287-
prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this;
288-
289-
// From chokidar FSWatcher
290-
291-
/**
292-
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
293-
* string.
294-
*/
295-
add(paths: string | string[]): void;
296-
297-
/**
298-
* Stop watching files, directories, or glob patterns. Takes an array of strings or just one
299-
* string.
300-
*/
301-
unwatch(paths: string | string[]): void;
302-
303-
/**
304-
* Returns an object representing all the paths on the file system being watched by this
305-
* `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
306-
* the `cwd` option was used), and the values are arrays of the names of the items contained in
307-
* each directory.
308-
*/
309-
getWatched(): IDictionary<string[]>;
310-
311-
/**
312-
* Removes all listeners from watched files.
313-
*/
314-
close(): void;
315-
}
316-
317-
interface ILiveSyncProcessInfo {
318-
timer: NodeJS.Timer;
319-
watcher: IFSWatcher;
320-
actionsChain: Promise<any>;
321-
isStopped: boolean;
322-
}
323-
324-
interface ILiveSyncDeviceInfo {
325-
identifier: string;
326-
buildAction: () => Promise<string>;
327-
outputPath?: string;
328-
}
329-
330-
interface ILiveSyncInfo {
331-
projectDir: string;
332-
shouldStartWatcher: boolean;
333-
syncAllFiles?: boolean;
334-
}
335-
336-
interface ILiveSyncBuildInfo {
337-
platform: string;
338-
isEmulator: boolean;
339-
pathToBuildItem: string;
340-
}
341-
342-
// interface ILiveSyncDebugInfo {
343-
// outputFilePath?: string;
344-
// debugData: IDebugData;
345-
// debugOptions: IDebugOptions;
346-
// }
347-
348-
interface ILiveSyncService {
349-
liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo): Promise<void>;
350-
stopLiveSync(projectDir: string): Promise<void>;
351-
}
352-
353-
interface ILiveSyncWatchInfo {
354-
projectData: IProjectData;
355-
filesToRemove: string[];
356-
filesToSync: string[];
357-
isRebuilt: boolean;
358-
syncAllFiles: boolean;
359-
}
360-
361-
interface ILiveSyncResultInfo {
362-
modifiedFilesData: Mobile.ILocalToDevicePathData[];
363-
isFullSync: boolean;
364-
deviceAppData: Mobile.IDeviceAppData;
365-
}
366-
367-
interface IFullSyncInfo {
368-
projectData: IProjectData;
369-
device: Mobile.IDevice;
370-
syncAllFiles: boolean;
371-
}
372-
373-
interface IPlatformLiveSyncService {
374-
fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo>;
375-
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo>;
376-
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
377-
}
378-
379-
interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase {
380-
/**
381-
* Refreshes the application's content on a device
382-
* @param {Mobile.IDeviceAppData} deviceAppData Information about the application and the device.
383-
* @param {Mobile.ILocalToDevicePathData[]} localToDevicePaths Object containing a mapping of file paths from the system to the device.
384-
* @param {boolean} forceExecuteFullSync If this is passed a full LiveSync is performed instead of an incremental one.
385-
* @param {IProjectData} projectData Project data.
386-
* @return {Promise<void>}
387-
*/
388-
refreshApplication(deviceAppData: Mobile.IDeviceAppData,
389-
localToDevicePaths: Mobile.ILocalToDevicePathData[],
390-
forceExecuteFullSync: boolean,
391-
projectData: IProjectData): Promise<void>;
392-
393-
/**
394-
* Removes specified files from a connected device
395-
* @param {string} appIdentifier Application identifier.
396-
* @param {Mobile.ILocalToDevicePathData[]} localToDevicePaths Object containing a mapping of file paths from the system to the device.
397-
* @param {string} projectId Project identifier - for example org.nativescript.livesync.
398-
* @return {Promise<void>}
399-
*/
400-
removeFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectId: string): Promise<void>;
401-
}
402-
403260
interface IBundle {
404261
bundle: boolean;
405262
}

lib/definitions/livesync.d.ts

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
interface IFSWatcher extends NodeJS.EventEmitter {
2+
// from fs.FSWatcher
3+
close(): void;
4+
5+
/**
6+
* events.EventEmitter
7+
* 1. change
8+
* 2. error
9+
*/
10+
addListener(event: string, listener: Function): this;
11+
addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
12+
addListener(event: "error", listener: (code: number, signal: string) => void): this;
13+
14+
on(event: string, listener: Function): this;
15+
on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
16+
on(event: "error", listener: (code: number, signal: string) => void): this;
17+
18+
once(event: string, listener: Function): this;
19+
once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
20+
once(event: "error", listener: (code: number, signal: string) => void): this;
21+
22+
prependListener(event: string, listener: Function): this;
23+
prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
24+
prependListener(event: "error", listener: (code: number, signal: string) => void): this;
25+
26+
prependOnceListener(event: string, listener: Function): this;
27+
prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
28+
prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this;
29+
30+
// From chokidar FSWatcher
31+
32+
/**
33+
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
34+
* string.
35+
*/
36+
add(paths: string | string[]): void;
37+
38+
/**
39+
* Stop watching files, directories, or glob patterns. Takes an array of strings or just one
40+
* string.
41+
*/
42+
unwatch(paths: string | string[]): void;
43+
44+
/**
45+
* Returns an object representing all the paths on the file system being watched by this
46+
* `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
47+
* the `cwd` option was used), and the values are arrays of the names of the items contained in
48+
* each directory.
49+
*/
50+
getWatched(): IDictionary<string[]>;
51+
52+
/**
53+
* Removes all listeners from watched files.
54+
*/
55+
close(): void;
56+
}
57+
58+
interface ILiveSyncProcessInfo {
59+
timer: NodeJS.Timer;
60+
watcher: IFSWatcher;
61+
actionsChain: Promise<any>;
62+
isStopped: boolean;
63+
}
64+
65+
interface ILiveSyncDeviceInfo {
66+
identifier: string;
67+
buildAction: () => Promise<string>;
68+
outputPath?: string;
69+
}
70+
71+
interface ILiveSyncInfo {
72+
projectDir: string;
73+
shouldStartWatcher: boolean;
74+
syncAllFiles?: boolean;
75+
useLiveEdit?: boolean;
76+
}
77+
78+
interface ILiveSyncBuildInfo {
79+
platform: string;
80+
isEmulator: boolean;
81+
pathToBuildItem: string;
82+
}
83+
84+
interface ILiveSyncService {
85+
liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo): Promise<void>;
86+
stopLiveSync(projectDir: string): Promise<void>;
87+
}
88+
89+
interface ILiveSyncWatchInfo {
90+
projectData: IProjectData;
91+
filesToRemove: string[];
92+
filesToSync: string[];
93+
isRebuilt: boolean;
94+
syncAllFiles: boolean;
95+
}
96+
97+
interface ILiveSyncResultInfo {
98+
modifiedFilesData: Mobile.ILocalToDevicePathData[];
99+
isFullSync: boolean;
100+
deviceAppData: Mobile.IDeviceAppData;
101+
}
102+
103+
interface IFullSyncInfo {
104+
projectData: IProjectData;
105+
device: Mobile.IDevice;
106+
syncAllFiles: boolean;
107+
}
108+
109+
interface IPlatformLiveSyncService {
110+
fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo>;
111+
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo>;
112+
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
113+
}
114+
115+
interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase {
116+
/**
117+
* Refreshes the application's content on a device
118+
* @param {Mobile.IDeviceAppData} deviceAppData Information about the application and the device.
119+
* @param {Mobile.ILocalToDevicePathData[]} localToDevicePaths Object containing a mapping of file paths from the system to the device.
120+
* @param {boolean} forceExecuteFullSync If this is passed a full LiveSync is performed instead of an incremental one.
121+
* @param {IProjectData} projectData Project data.
122+
* @return {Promise<void>}
123+
*/
124+
refreshApplication(deviceAppData: Mobile.IDeviceAppData,
125+
localToDevicePaths: Mobile.ILocalToDevicePathData[],
126+
forceExecuteFullSync: boolean,
127+
projectData: IProjectData): Promise<void>;
128+
129+
/**
130+
* Removes specified files from a connected device
131+
* @param {string} appIdentifier Application identifier.
132+
* @param {Mobile.ILocalToDevicePathData[]} localToDevicePaths Object containing a mapping of file paths from the system to the device.
133+
* @param {string} projectId Project identifier - for example org.nativescript.livesync.
134+
* @return {Promise<void>}
135+
*/
136+
removeFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectId: string): Promise<void>;
137+
}

lib/services/livesync/ios-device-livesync-service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ export class IOSLiveSyncService implements INativeScriptDeviceLiveSyncService {
5555
await Promise.all(_.map(localToDevicePaths, localToDevicePathData => this.device.fileSystem.deleteFile(localToDevicePathData.getDevicePath(), appIdentifier)));
5656
}
5757

58-
public async refreshApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], forceExecuteFullSync: boolean, projectData: IProjectData): Promise<void> {
58+
public async refreshApplication(
59+
deviceAppData: Mobile.IDeviceAppData,
60+
localToDevicePaths: Mobile.ILocalToDevicePathData[],
61+
forceExecuteFullSync: boolean,
62+
projectData: IProjectData): Promise<void> {
5963
if (forceExecuteFullSync) {
6064
await this.restartApplication(deviceAppData, projectData.projectName);
6165
return;

lib/services/livesync/livesync-service.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
272272
this.liveSyncProcessesInfo[liveSyncData.projectDir].timer = timeoutTimer;
273273
this.liveSyncProcessesInfo[liveSyncData.projectDir].isStopped = false;
274274

275-
this.liveSyncProcessesInfo[liveSyncData.projectDir].isStopped = false;
276-
277275
this.$processService.attachToProcessExitSignals(this, () => {
278276
_.keys(this.liveSyncProcessesInfo).forEach(projectDir => {
279277
// Do not await here, we are in process exit's handler.

0 commit comments

Comments
 (0)