-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathlivesync.d.ts
271 lines (234 loc) · 9.35 KB
/
livesync.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
// This interface is a mashup of NodeJS' along with Chokidar's event watchers
interface IFSWatcher extends NodeJS.EventEmitter {
// from fs.FSWatcher
close(): void;
/**
* events.EventEmitter
* 1. change
* 2. error
*/
addListener(event: string, listener: Function): this;
addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
addListener(event: "error", listener: (code: number, signal: string) => void): this;
on(event: string, listener: Function): this;
on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
on(event: "error", listener: (code: number, signal: string) => void): this;
once(event: string, listener: Function): this;
once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
once(event: "error", listener: (code: number, signal: string) => void): this;
prependListener(event: string, listener: Function): this;
prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
prependListener(event: "error", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: string, listener: Function): this;
prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this;
// From chokidar FSWatcher
/**
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
* string.
*/
add(paths: string | string[]): void;
/**
* Stop watching files, directories, or glob patterns. Takes an array of strings or just one
* string.
*/
unwatch(paths: string | string[]): void;
/**
* Returns an object representing all the paths on the file system being watched by this
* `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
* the `cwd` option was used), and the values are arrays of the names of the items contained in
* each directory.
*/
getWatched(): IDictionary<string[]>;
/**
* Removes all listeners from watched files.
*/
close(): void;
}
interface ILiveSyncProcessInfo {
timer: NodeJS.Timer;
watcherInfo: {
watcher: IFSWatcher,
pattern: string | string[]
};
actionsChain: Promise<any>;
isStopped: boolean;
deviceDescriptors: ILiveSyncDeviceInfo[];
}
/**
* Describes information for LiveSync on a device.
*/
interface ILiveSyncDeviceInfo {
/**
* Device identifier.
*/
identifier: string;
/**
* Action that will rebuild the application. The action must return a Promise, which is resolved with at path to build artifact.
* @returns {Promise<string>} Path to build artifact (.ipa, .apk or .zip).
*/
buildAction: () => Promise<string>;
/**
* Path where the build result is located (directory containing .ipa, .apk or .zip).
* This is required for initial checks where LiveSync will skip the rebuild in case there's already a build result and no change requiring rebuild is made since then.
* In case it is not passed, the default output for local builds will be used.
*/
outputPath?: string;
/**
* Whether to skip preparing the native platform.
*/
skipNativePrepare?: boolean;
}
/**
* Describes a LiveSync operation.
*/
interface ILiveSyncInfo {
/**
* Directory of the project that will be synced.
*/
projectDir: string;
/**
* Defines if the watcher should be skipped. If not passed, fs.Watcher will be started.
*/
skipWatcher?: boolean;
/**
* Defines if all project files should be watched for changes. In case it is not passed, only `app` dir of the project will be watched for changes.
* In case it is set to true, the package.json of the project and node_modules directory will also be watched, so any change there will be transferred to device(s).
*/
watchAllFiles?: boolean;
/**
* Defines if the liveEdit functionality should be used, i.e. LiveSync of .js files without restart.
* NOTE: Currently this is available only for iOS.
*/
useLiveEdit?: boolean;
/**
* Forces a build before the initial livesync.
*/
clean?: boolean;
}
interface ILatestAppPackageInstalledSettings extends IDictionary<IDictionary<boolean>> { /* empty */ }
interface ILiveSyncBuildInfo {
platform: string;
isEmulator: boolean;
pathToBuildItem: string;
}
/**
* Desribes object that can be passed to ensureLatestAppPackageIsInstalledOnDevice method.
*/
interface IEnsureLatestAppPackageIsInstalledOnDeviceOptions {
device: Mobile.IDevice;
preparedPlatforms: string[];
rebuiltInformation: ILiveSyncBuildInfo[];
projectData: IProjectData;
deviceBuildInfoDescriptor: ILiveSyncDeviceInfo;
settings: ILatestAppPackageInstalledSettings;
liveSyncData?: ILiveSyncInfo;
modifiedFiles?: string[];
}
/**
* Describes the action that has been executed during ensureLatestAppPackageIsInstalledOnDevice execution.
*/
interface IAppInstalledOnDeviceResult {
/**
* Defines if the app has been installed on device from the ensureLatestAppPackageIsInstalledOnDevice method.
*/
appInstalled: boolean;
}
/**
* Describes LiveSync operations.
*/
interface ILiveSyncService {
/**
* Starts LiveSync operation by rebuilding the application if necessary and starting watcher.
* @param {ILiveSyncDeviceInfo[]} deviceDescriptors Describes each device for which we would like to sync the application - identifier, outputPath and action to rebuild the app.
* @param {ILiveSyncInfo} liveSyncData Describes the LiveSync operation - for which project directory is the operation and other settings.
* @returns {Promise<void>}
*/
liveSync(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo): Promise<void>;
/**
* Stops LiveSync operation for specified directory.
* @param {string} projectDir The directory for which to stop the operation.
* @param {string[]} @optional deviceIdentifiers Device ids for which to stop the application. In case nothing is passed, LiveSync operation will be stopped for all devices.
* @param { shouldAwaitAllActions: boolean } @optional stopOptions Specifies whether we should await all actions.
* @returns {Promise<void>}
*/
stopLiveSync(projectDir: string, deviceIdentifiers?: string[], stopOptions?: { shouldAwaitAllActions: boolean }): Promise<void>;
}
/**
* Describes LiveSync operations while debuggging.
*/
interface IDebugLiveSyncService extends ILiveSyncService {
/**
* Prints debug information.
* @param {string[]} information Array of information to be printed. Note that false-like values will be stripped from the array.
* @returns {void}
*/
printDebugInformation(information: string): void;
}
interface ILiveSyncWatchInfo {
projectData: IProjectData;
filesToRemove: string[];
filesToSync: string[];
isReinstalled: boolean;
syncAllFiles: boolean;
useLiveEdit?: boolean;
}
interface ILiveSyncResultInfo {
modifiedFilesData: Mobile.ILocalToDevicePathData[];
isFullSync: boolean;
deviceAppData: Mobile.IDeviceAppData;
useLiveEdit?: boolean;
}
interface IFullSyncInfo {
projectData: IProjectData;
device: Mobile.IDevice;
watch: boolean;
syncAllFiles: boolean;
useLiveEdit?: boolean;
}
interface IPlatformLiveSyncService {
fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo>;
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo>;
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
}
interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase {
/**
* Refreshes the application's content on a device
* @param {Mobile.IDeviceAppData} deviceAppData Information about the application and the device.
* @param {Mobile.ILocalToDevicePathData[]} localToDevicePaths Object containing a mapping of file paths from the system to the device.
* @param {boolean} forceExecuteFullSync If this is passed a full LiveSync is performed instead of an incremental one.
* @param {IProjectData} projectData Project data.
* @return {Promise<void>}
*/
refreshApplication(projectData: IProjectData,
liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
/**
* Removes specified files from a connected device
* @param {Mobile.IDeviceAppData} deviceAppData Data about device and app.
* @param {Mobile.ILocalToDevicePathData[]} localToDevicePaths Object containing a mapping of file paths from the system to the device.
* @return {Promise<void>}
*/
removeFiles(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void>;
}
interface IAndroidNativeScriptDeviceLiveSyncService {
/**
* Retrieves the android device's hash service.
* @param {string} appIdentifier Application identifier.
* @return {Promise<Mobile.IAndroidDeviceHashService>} The hash service
*/
getDeviceHashService(appIdentifier: string): Mobile.IAndroidDeviceHashService;
}
interface IDeviceProjectRootOptions {
appIdentifier: string;
getDirname?: boolean;
syncAllFiles?: boolean;
watch?: boolean;
}
interface IDevicePathProvider {
getDeviceProjectRootPath(device: Mobile.IDevice, options: IDeviceProjectRootOptions): Promise<string>;
getDeviceSyncZipPath(device: Mobile.IDevice): string;
}
interface ILiveSyncCommandHelper {
executeLiveSyncOperation(devices: Mobile.IDevice[], liveSyncService: ILiveSyncService, platform: string): Promise<void>;
getPlatformsForOperation(platform: string): string[];
}