mobile-cli-lib
Advanced tools
Comparing version 0.17.3 to 0.18.0
@@ -86,2 +86,11 @@ "use strict"; | ||
}); | ||
device.applicationManager.on("debuggableViewFound", function (appIdentifier, debuggableWebViewInfo) { | ||
_this.emit("debuggableViewFound", device.deviceInfo.identifier, appIdentifier, debuggableWebViewInfo); | ||
}); | ||
device.applicationManager.on("debuggableViewLost", function (appIdentifier, debuggableWebViewInfo) { | ||
_this.emit("debuggableViewLost", device.deviceInfo.identifier, appIdentifier, debuggableWebViewInfo); | ||
}); | ||
device.applicationManager.on("debuggableViewChanged", function (appIdentifier, debuggableWebViewInfo) { | ||
_this.emit("debuggableViewChanged", device.deviceInfo.identifier, appIdentifier, debuggableWebViewInfo); | ||
}); | ||
}; | ||
@@ -88,0 +97,0 @@ DeviceEmitter.prototype.checkCompanionAppChanged = function (device, applicationName, eventName) { |
"use strict"; | ||
var os_1 = require("os"); | ||
var Future = require("fibers/future"); | ||
var HelpCommand = (function () { | ||
function HelpCommand($logger, $injector, $htmlHelpService, $options) { | ||
function HelpCommand($logger, $injector, $htmlHelpService, $staticConfig, $options) { | ||
this.$logger = $logger; | ||
this.$injector = $injector; | ||
this.$htmlHelpService = $htmlHelpService; | ||
this.$staticConfig = $staticConfig; | ||
this.$options = $options; | ||
@@ -25,2 +27,5 @@ this.enableHooks = false; | ||
var help = _this.$htmlHelpService.getCommandLineHelpForCommand(topic).wait(); | ||
if (_this.$staticConfig.FULL_CLIENT_NAME) { | ||
_this.$logger.info(_this.$staticConfig.FULL_CLIENT_NAME.green.bold + os_1.EOL); | ||
} | ||
_this.$logger.printMarkdown(help); | ||
@@ -27,0 +32,0 @@ } |
@@ -13,3 +13,3 @@ "use strict"; | ||
__extends(AndroidApplicationManager, _super); | ||
function AndroidApplicationManager(adb, identifier, $staticConfig, $options, $logcatHelper, $androidProcessService, $logger) { | ||
function AndroidApplicationManager(adb, identifier, $staticConfig, $options, $logcatHelper, $androidProcessService, $httpClient, $logger) { | ||
_super.call(this, $logger); | ||
@@ -22,2 +22,3 @@ this.adb = adb; | ||
this.$androidProcessService = $androidProcessService; | ||
this.$httpClient = $httpClient; | ||
} | ||
@@ -80,2 +81,22 @@ AndroidApplicationManager.prototype.getInstalledApplications = function () { | ||
}; | ||
AndroidApplicationManager.prototype.getDebuggableAppViews = function (appIdentifiers) { | ||
var _this = this; | ||
return (function () { | ||
var mappedAppIdentifierPorts = _this.$androidProcessService.getMappedAbstractToTcpPorts(_this.identifier, appIdentifiers).wait(), applicationViews = {}; | ||
_.each(mappedAppIdentifierPorts, function (port, appIdentifier) { | ||
applicationViews[appIdentifier] = []; | ||
var localAddress = "http://127.0.0.1:" + port + "/json"; | ||
try { | ||
if (port) { | ||
var apps = _this.$httpClient.httpRequest(localAddress).wait().body; | ||
applicationViews[appIdentifier] = JSON.parse(apps); | ||
} | ||
} | ||
catch (err) { | ||
_this.$logger.trace("Error while checking " + localAddress + ". Error is: " + err.message); | ||
} | ||
}); | ||
return applicationViews; | ||
}).future()(); | ||
}; | ||
AndroidApplicationManager.prototype.getStartPackageActivity = function (framework) { | ||
@@ -82,0 +103,0 @@ framework = framework || ""; |
@@ -8,2 +8,3 @@ "use strict"; | ||
var events_1 = require("events"); | ||
var constants_1 = require("../constants"); | ||
var ApplicationManagerBase = (function (_super) { | ||
@@ -14,2 +15,3 @@ __extends(ApplicationManagerBase, _super); | ||
this.$logger = $logger; | ||
this.lastAvailableDebuggableAppViews = {}; | ||
this.isChecking = false; | ||
@@ -82,4 +84,35 @@ } | ||
_this.lastAvailableDebuggableApps = currentlyAvailableDebuggableApps; | ||
_.each(newAvailableDebuggableApps, function (appInfo) { return _this.emit("debuggableAppFound", appInfo); }); | ||
_.each(notAvailableAppsForDebugging, function (appInfo) { return _this.emit("debuggableAppLost", appInfo); }); | ||
_.each(newAvailableDebuggableApps, function (appInfo) { | ||
_this.emit("debuggableAppFound", appInfo); | ||
}); | ||
_.each(notAvailableAppsForDebugging, function (appInfo) { | ||
_this.emit("debuggableAppLost", appInfo); | ||
if (_.has(_this.lastAvailableDebuggableAppViews, appInfo.appIdentifier)) { | ||
delete _this.lastAvailableDebuggableAppViews[appInfo.appIdentifier]; | ||
} | ||
}); | ||
var cordovaDebuggableAppIdentifiers = _(currentlyAvailableDebuggableApps) | ||
.filter(function (c) { return c.framework === constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova; }) | ||
.map(function (c) { return c.appIdentifier; }) | ||
.value(); | ||
var currentlyAvailableAppViews = _this.getDebuggableAppViews(cordovaDebuggableAppIdentifiers).wait(); | ||
_.each(currentlyAvailableAppViews, function (currentlyAvailableViews, appIdentifier) { | ||
var previouslyAvailableViews = _this.lastAvailableDebuggableAppViews[appIdentifier]; | ||
var newAvailableViews = _.differenceBy(currentlyAvailableViews, previouslyAvailableViews, "id"); | ||
var notAvailableViews = _.differenceBy(previouslyAvailableViews, currentlyAvailableViews, "id"); | ||
_.each(notAvailableViews, function (debugWebViewInfo) { | ||
_this.emit("debuggableViewLost", appIdentifier, debugWebViewInfo); | ||
}); | ||
_.each(newAvailableViews, function (debugWebViewInfo) { | ||
_this.emit("debuggableViewFound", appIdentifier, debugWebViewInfo); | ||
}); | ||
var keptViews = _.differenceBy(currentlyAvailableViews, newAvailableViews, "id"); | ||
_.each(keptViews, function (view) { | ||
var previousTimeViewInfo = _.find(previouslyAvailableViews, function (previousView) { return previousView.id === view.id; }); | ||
if (!_.isEqual(view, previousTimeViewInfo)) { | ||
_this.emit("debuggableViewChanged", appIdentifier, view); | ||
} | ||
}); | ||
_this.lastAvailableDebuggableAppViews[appIdentifier] = currentlyAvailableViews; | ||
}); | ||
}).future()(); | ||
@@ -86,0 +119,0 @@ }; |
@@ -158,2 +158,5 @@ "use strict"; | ||
}; | ||
IOSApplicationManager.prototype.getDebuggableAppViews = function (appIdentifiers) { | ||
return Future.fromResult(null); | ||
}; | ||
IOSApplicationManager.prototype.lookupApplications = function () { | ||
@@ -160,0 +163,0 @@ var _this = this; |
@@ -91,4 +91,7 @@ "use strict"; | ||
}; | ||
IOSSimulatorApplicationManager.prototype.getDebuggableAppViews = function (appIdentifiers) { | ||
return Future.fromResult(null); | ||
}; | ||
return IOSSimulatorApplicationManager; | ||
}(application_manager_base_1.ApplicationManagerBase)); | ||
exports.IOSSimulatorApplicationManager = IOSSimulatorApplicationManager; |
@@ -6,7 +6,6 @@ "use strict"; | ||
var AndroidProcessService = (function () { | ||
function AndroidProcessService($errors, $staticConfig, $injector, $httpClient, $net) { | ||
function AndroidProcessService($errors, $staticConfig, $injector, $net) { | ||
this.$errors = $errors; | ||
this.$staticConfig = $staticConfig; | ||
this.$injector = $injector; | ||
this.$httpClient = $httpClient; | ||
this.$net = $net; | ||
@@ -30,3 +29,3 @@ this._devicesAdbs = {}; | ||
var adb = _this.getAdb(deviceIdentifier); | ||
var processId = _this.getProcessId(adb, appIdentifier).wait(); | ||
var processId = _this.getProcessIds(adb, [appIdentifier]).wait()[appIdentifier]; | ||
var applicationNotStartedErrorMessage = "The application is not started on the device with identifier " + deviceIdentifier + "."; | ||
@@ -36,3 +35,4 @@ if (!processId) { | ||
} | ||
var abstractPort = _this.getAbstractPortForApplication(adb, processId, appIdentifier).wait(); | ||
var abstractPortsInformation = _this.getAbstractPortsInformation(adb).wait(); | ||
var abstractPort = _this.getAbstractPortForApplication(adb, processId, appIdentifier, abstractPortsInformation).wait(); | ||
if (!abstractPort) { | ||
@@ -49,2 +49,24 @@ _this.$errors.failWithoutHelp(applicationNotStartedErrorMessage); | ||
}; | ||
AndroidProcessService.prototype.getMappedAbstractToTcpPorts = function (deviceIdentifier, appIdentifiers) { | ||
var _this = this; | ||
return (function () { | ||
var adb = _this.getAdb(deviceIdentifier), abstractPortsInformation = _this.getAbstractPortsInformation(adb).wait(), processIds = _this.getProcessIds(adb, appIdentifiers).wait(), adbForwardList = adb.executeCommand(["forward", "--list"]).wait(), localPorts = {}; | ||
_.each(appIdentifiers, function (appIdentifier) { | ||
localPorts[appIdentifier] = null; | ||
var processId = processIds[appIdentifier]; | ||
if (!processId) { | ||
return; | ||
} | ||
var abstractPort = _this.getAbstractPortForApplication(adb, processId, appIdentifier, abstractPortsInformation).wait(); | ||
if (!abstractPort) { | ||
return; | ||
} | ||
var localPort = _this.getAlreadyMappedPort(adb, deviceIdentifier, abstractPort, adbForwardList).wait(); | ||
if (localPort) { | ||
localPorts[appIdentifier] = localPort; | ||
} | ||
}); | ||
return localPorts; | ||
}).future()(); | ||
}; | ||
AndroidProcessService.prototype.getDebuggableApps = function (deviceIdentifier) { | ||
@@ -56,5 +78,6 @@ var _this = this; | ||
return _(androidWebViewPortInformation) | ||
.map(function (line) { return _this.getApplicationInfoFromWebViewPortInformation(adb, deviceIdentifier, line).wait(); }) | ||
.filter(function (appIdentifier) { return !!appIdentifier; }) | ||
.uniqBy("appIdentifier") | ||
.map(function (line) { return _this.getApplicationInfoFromWebViewPortInformation(adb, deviceIdentifier, line).wait() | ||
|| _this.getNativeScriptApplicationInformation(adb, deviceIdentifier, line).wait(); }) | ||
.filter(function (deviceAppInfo) { return !!deviceAppInfo; }) | ||
.uniqBy(function (deviceAppInfo) { return deviceAppInfo.appIdentifier; }) | ||
.value(); | ||
@@ -64,18 +87,16 @@ }).future()(); | ||
AndroidProcessService.prototype.getApplicationInfoFromWebViewPortInformation = function (adb, deviceIdentifier, information) { | ||
var _this = this; | ||
return (function () { | ||
var processIdRegExp = /@webview_devtools_remote_(.+)/g; | ||
var processIdMatches = processIdRegExp.exec(information); | ||
var oldAndroidWebViewAppIdentifier; | ||
var processIdRegExp = /@webview_devtools_remote_(.+)/g, processIdMatches = processIdRegExp.exec(information), cordovaAppIdentifier; | ||
if (processIdMatches) { | ||
var processId = processIdMatches[1]; | ||
var processIdInformation = adb.executeShellCommand(["ps", "|grep", processId]).wait(); | ||
oldAndroidWebViewAppIdentifier = _.last(processIdInformation.trim().split(/[ \t]/)); | ||
cordovaAppIdentifier = _this.getApplicationIdentifierFromPid(adb, processId).wait(); | ||
} | ||
var chromeAppIdentifierRegExp = /@(.+)_devtools_remote\s?/g; | ||
var chromeAppIdentifierMatches = chromeAppIdentifierRegExp.exec(information); | ||
var chromeAppIdentifier; | ||
if (chromeAppIdentifierMatches && chromeAppIdentifierMatches.length > 0) { | ||
chromeAppIdentifier = chromeAppIdentifierMatches[1]; | ||
else { | ||
var chromeAppIdentifierRegExp = /@(.+)_devtools_remote\s?/g; | ||
var chromeAppIdentifierMatches = chromeAppIdentifierRegExp.exec(information); | ||
if (chromeAppIdentifierMatches && chromeAppIdentifierMatches.length > 0) { | ||
cordovaAppIdentifier = chromeAppIdentifierMatches[1]; | ||
} | ||
} | ||
var cordovaAppIdentifier = oldAndroidWebViewAppIdentifier || chromeAppIdentifier; | ||
if (cordovaAppIdentifier) { | ||
@@ -88,2 +109,7 @@ return { | ||
} | ||
return null; | ||
}).future()(); | ||
}; | ||
AndroidProcessService.prototype.getNativeScriptApplicationInformation = function (adb, deviceIdentifier, information) { | ||
return (function () { | ||
var nativeScriptAppIdentifierRegExp = /@(.+)-debug/g; | ||
@@ -102,6 +128,5 @@ var nativeScriptAppIdentifierMatches = nativeScriptAppIdentifierRegExp.exec(information); | ||
}; | ||
AndroidProcessService.prototype.getAbstractPortForApplication = function (adb, processId, appIdentifier) { | ||
AndroidProcessService.prototype.getAbstractPortForApplication = function (adb, processId, appIdentifier, abstractPortsInformation) { | ||
var _this = this; | ||
return (function () { | ||
var abstractPortsInformation = _this.getAbstractPortsInformation(adb).wait(); | ||
return _this.getPortInformation(abstractPortsInformation, processId) || | ||
@@ -120,16 +145,20 @@ _this.getPortInformation(abstractPortsInformation, appIdentifier + "_devtools_remote") || | ||
}; | ||
AndroidProcessService.prototype.getProcessId = function (adb, appIdentifier) { | ||
AndroidProcessService.prototype.getProcessIds = function (adb, appIdentifiers) { | ||
var _this = this; | ||
return (function () { | ||
var processIdRegExp = new RegExp("^\\w*\\s*(\\d+).*?" + appIdentifier + "$"); | ||
var result = {}; | ||
var processIdInformation = adb.executeShellCommand(["ps"]).wait(); | ||
return _this.parseMultilineResult(processIdInformation, processIdRegExp); | ||
_.each(appIdentifiers, function (appIdentifier) { | ||
var processIdRegExp = new RegExp("^\\w*\\s*(\\d+).*?" + appIdentifier + "$"); | ||
result[appIdentifier] = _this.getFirstMatchingGroupFromMultilineResult(processIdInformation, processIdRegExp); | ||
}); | ||
return result; | ||
}).future()(); | ||
}; | ||
AndroidProcessService.prototype.getAlreadyMappedPort = function (adb, deviceIdentifier, abstractPort) { | ||
AndroidProcessService.prototype.getAlreadyMappedPort = function (adb, deviceIdentifier, abstractPort, adbForwardList) { | ||
var _this = this; | ||
return (function () { | ||
var allForwardedPorts = adb.executeCommand(["forward", "--list"]).wait() || ""; | ||
var regex = new RegExp(deviceIdentifier + "\\s+?tcp:(\\d+?)\\s+?.*?" + abstractPort + ".*$"); | ||
return _this.parseMultilineResult(allForwardedPorts, regex); | ||
var allForwardedPorts = adbForwardList || adb.executeCommand(["forward", "--list"]).wait() || ""; | ||
var regex = new RegExp(deviceIdentifier + "\\s+?tcp:(\\d+?)\\s+?.*?" + abstractPort + "$"); | ||
return _this.getFirstMatchingGroupFromMultilineResult(allForwardedPorts, regex); | ||
}).future()(); | ||
@@ -143,4 +172,11 @@ }; | ||
}; | ||
AndroidProcessService.prototype.parseMultilineResult = function (input, regex) { | ||
var selectedNumber; | ||
AndroidProcessService.prototype.getApplicationIdentifierFromPid = function (adb, pid, psData) { | ||
var _this = this; | ||
return (function () { | ||
psData = psData || adb.executeShellCommand(["ps"]).wait(); | ||
return _this.getFirstMatchingGroupFromMultilineResult(psData, new RegExp("\\s+" + pid + "(?:\\s+\\d+){3}\\s+.*\\s+(.*?)$")); | ||
}).future()(); | ||
}; | ||
AndroidProcessService.prototype.getFirstMatchingGroupFromMultilineResult = function (input, regex) { | ||
var result; | ||
_((input || "").split('\n')) | ||
@@ -152,7 +188,7 @@ .map(function (line) { return line.trim(); }) | ||
if (matches && matches[1]) { | ||
selectedNumber = +matches[1]; | ||
result = matches[1]; | ||
return false; | ||
} | ||
}); | ||
return selectedNumber; | ||
return result; | ||
}; | ||
@@ -159,0 +195,0 @@ return AndroidProcessService; |
@@ -226,10 +226,2 @@ "use strict"; | ||
}; | ||
DevicesService.prototype.getAllConnectedDevices = function () { | ||
if (!this._platform) { | ||
return this.getDeviceInstances(); | ||
} | ||
else { | ||
return this.filterDevicesByPlatform(); | ||
} | ||
}; | ||
DevicesService.prototype.getDeviceByIndex = function (index) { | ||
@@ -267,3 +259,3 @@ this.validateIndex(index - 1); | ||
return (function () { | ||
var devices = _this.getAllConnectedDevices(); | ||
var devices = _this.filterDevicesByPlatform(); | ||
var sortedDevices = _.sortBy(devices, function (device) { return device.deviceInfo.platform; }); | ||
@@ -408,2 +400,9 @@ var futures = _.map(sortedDevices, function (device) { | ||
}; | ||
DevicesService.prototype.getDebuggableViews = function (deviceIdentifier, appIdentifier) { | ||
var _this = this; | ||
return (function () { | ||
var device = _this.getDeviceByIdentifier(deviceIdentifier), debuggableViewsPerApp = device.applicationManager.getDebuggableAppViews([appIdentifier]).wait(); | ||
return debuggableViewsPerApp && debuggableViewsPerApp[appIdentifier]; | ||
}).future()(); | ||
}; | ||
DevicesService.prototype.getDebuggableAppsCore = function (deviceIdentifier) { | ||
@@ -431,3 +430,11 @@ var _this = this; | ||
var _this = this; | ||
return _.filter(this.getDeviceInstances(), function (device) { return device.deviceInfo.platform === _this._platform; }); | ||
return _.filter(this.getDeviceInstances(), function (device) { | ||
if (_this.$options.emulator && !device.isEmulator) { | ||
return false; | ||
} | ||
if (_this._platform) { | ||
return device.deviceInfo.platform === _this._platform; | ||
} | ||
return true; | ||
}); | ||
}; | ||
@@ -558,2 +565,8 @@ DevicesService.prototype.validateIndex = function (index) { | ||
], DevicesService.prototype, "getDebuggableApps", null); | ||
__decorate([ | ||
decorators_1.exportedPromise("devicesService"), | ||
__metadata('design:type', Function), | ||
__metadata('design:paramtypes', [String, String]), | ||
__metadata('design:returntype', Object) | ||
], DevicesService.prototype, "getDebuggableViews", null); | ||
return DevicesService; | ||
@@ -560,0 +573,0 @@ }()); |
{ | ||
"name": "mobile-cli-lib", | ||
"preferGlobal": false, | ||
"version": "0.17.3", | ||
"version": "0.18.0", | ||
"author": "Telerik <support@telerik.com>", | ||
@@ -42,3 +42,3 @@ "description": "common lib used by different CLI", | ||
"inquirer": "0.8.2", | ||
"ios-sim-portable": "1.1.1", | ||
"ios-sim-portable": "~1.1.4", | ||
"lodash": "4.13.1", | ||
@@ -95,3 +95,3 @@ "log4js": "0.6.9", | ||
}, | ||
"buildVersion": "215" | ||
"buildVersion": "218" | ||
} |
214
README.md
@@ -10,5 +10,5 @@ mobile-cli-lib | ||
Latest version: 0.17.3 | ||
Latest version: 0.18.0 | ||
Release date: 2016, July 12 | ||
Release date: 2016, July 14 | ||
@@ -297,2 +297,10 @@ ### System Requirements | ||
* `applicationUninstalled` - Raised when application is removed from device. The callback has two arguments - `deviceIdentifier` and `applicationIdentifier`. <br/><br/> | ||
Sample usage: | ||
```JavaScript | ||
require("mobile-cli-lib").deviceEmitter.on("applicationUninstalled", function(identifier, applicationIdentifier) { | ||
console.log("Application " + applicationIdentifier + " has been uninstalled from device with id: " + identifier); | ||
}); | ||
``` | ||
* `debuggableAppFound` - Raised when application on a device becomes available for debugging. The callback has one argument - `applicationInfo`. <br/><br/> | ||
@@ -332,10 +340,68 @@ Sample usage: | ||
* `applicationUninstalled` - Raised when application is removed from device. The callback has two arguments - `deviceIdentifier` and `applicationIdentifier`. <br/><br/> | ||
* `debuggableViewFound` - Raised when a new debuggable WebView is found. The callback has three arguments - `deviceIdentifier`, `appIdentifier` and `webViewInfo`. | ||
Sample usage: | ||
```JavaScript | ||
require("mobile-cli-lib").deviceEmitter.on("applicationUninstalled", function(identifier, applicationIdentifier) { | ||
console.log("Application " + applicationIdentifier + " has been uninstalled from device with id: " + identifier); | ||
require("mobile-cli-lib") | ||
.deviceEmitter.on("debuggableViewFound", function(deviceIdentifier, appIdentifier, debuggableViewInfo) { | ||
console.log("On device " + deviceIdentifier + " the application " + appIdentifier + " now has new WebView: " + debuggableViewInfo); | ||
}); | ||
``` | ||
Sample result for `debuggableViewInfo` will be: | ||
```JSON | ||
{ | ||
"description": "", | ||
"devtoolsFrontendUrl": "http://chrome-devtools-frontend.appspot.com/serve_rev/@211d45a5b74b06d12bb016f3c4d54095faf2646f/inspector.html?ws=127.0.0.1:53213/devtools/page/4050", | ||
"id": "4050", | ||
"title": "New tab", | ||
"type": "page", | ||
"url": "chrome-native://newtab/", | ||
"webSocketDebuggerUrl": "ws://127.0.0.1:53213/devtools/page/4050" | ||
} | ||
``` | ||
* `debuggableViewLost` - Raised when a debuggable WebView is lost. The callback has three arguments - `deviceIdentifier`, `appIdentifier` and `webViewInfo`. | ||
Sample usage: | ||
```JavaScript | ||
require("mobile-cli-lib") | ||
.deviceEmitter.on("debuggableViewLost", function(deviceIdentifier, appIdentifier, debuggableViewInfo) { | ||
console.log("On device " + deviceIdentifier + " the application " + appIdentifier + " now cannot debug WebView: " + debuggableViewInfo); | ||
}); | ||
``` | ||
Sample result for `debuggableViewInfo` will be: | ||
```JSON | ||
{ | ||
"description": "", | ||
"devtoolsFrontendUrl": "http://chrome-devtools-frontend.appspot.com/serve_rev/@211d45a5b74b06d12bb016f3c4d54095faf2646f/inspector.html?ws=127.0.0.1:53213/devtools/page/4050", | ||
"id": "4050", | ||
"title": "New tab", | ||
"type": "page", | ||
"url": "chrome-native://newtab/", | ||
"webSocketDebuggerUrl": "ws://127.0.0.1:53213/devtools/page/4050" | ||
} | ||
``` | ||
* `debuggableViewChanged` - Raised when a property of debuggable WebView is changed, for example it's title. The callback has three arguments - `deviceIdentifier`, `appIdentifier` and `webViewInfo`. | ||
Sample usage: | ||
```JavaScript | ||
require("mobile-cli-lib") | ||
.deviceEmitter.on("debuggableViewChanged", function(deviceIdentifier, appIdentifier, debuggableViewInfo) { | ||
console.log("On device " + deviceIdentifier + " the application " + appIdentifier + " has changes in WebView: " + debuggableViewInfo); | ||
}); | ||
``` | ||
Sample result for `debuggableViewInfo` will be: | ||
```JSON | ||
{ | ||
"description": "", | ||
"devtoolsFrontendUrl": "http://chrome-devtools-frontend.appspot.com/serve_rev/@211d45a5b74b06d12bb016f3c4d54095faf2646f/inspector.html?ws=127.0.0.1:53213/devtools/page/4050", | ||
"id": "4050", | ||
"title": "New tab 2", | ||
"type": "page", | ||
"url": "chrome-native://newtab/", | ||
"webSocketDebuggerUrl": "ws://127.0.0.1:53213/devtools/page/4050" | ||
} | ||
``` | ||
* `companionAppInstalled` - Raised when application is removed from device. The callback has two arguments - `deviceIdentifier` and `framwork`. <br/><br/> | ||
@@ -554,2 +620,140 @@ Sample usage: | ||
* `getDebuggableApps(deviceIdentifiers: string[]): Promise<IDeviceApplicationInformation[]>[]` - This function checks the proc/net/unix file of each device from the deviceIdentifiers argument for web views connected to abstract ports and returns information about the applications. | ||
```JavaScript | ||
/** | ||
* Describes basic information about application on device. | ||
*/ | ||
interface IDeviceApplicationInformation { | ||
/** | ||
* The device identifier. | ||
*/ | ||
deviceIdentifier: string; | ||
/** | ||
* The application identifier. | ||
*/ | ||
appIdentifier: string; | ||
/** | ||
* The framework of the project (Cordova or NativeScript). | ||
*/ | ||
framework: string; | ||
} | ||
``` | ||
Sample usage: | ||
```JavaScript | ||
Promise.all(require("mobile-cli-lib").devicesService.getDebuggableApps(["4df18f307d8a8f1b", "JJY5KBTW75TCHQUK"])) | ||
.then(function(data) { | ||
data.forEach(function(apps) { | ||
console.log(apps); | ||
}); | ||
}, function(err) { | ||
console.log(err); | ||
}); | ||
``` | ||
Sample result will be: | ||
```JSON | ||
[[{ | ||
"deviceIdentifier": "4df18f307d8a8f1b", | ||
"appIdentifier": "com.telerik.Fitness", | ||
"framework": "NativeScript" | ||
}, { | ||
"deviceIdentifier": "4df18f307d8a8f1b", | ||
"appIdentifier": "com.telerik.livesynctest", | ||
"framework": "Cordova" | ||
}], [{ | ||
"deviceIdentifier": "JJY5KBTW75TCHQUK", | ||
"appIdentifier": "com.telerik.PhotoAlbum", | ||
"framework": "NativeScript" | ||
}]] | ||
``` | ||
* `getDebuggableViews(deviceIdentifier: string, appIdentifier: string): Promise<IDebugWebViewInfo[]>` - This function returns WebViews that can be debugged for specified application on specified device. | ||
> NOTE: This method works only for Cordova based applications. DO NOT pass appIdentifier of NativeScript application. | ||
```JavaScript | ||
/** | ||
* Describes information for WebView that can be debugged. | ||
*/ | ||
interface IDebugWebViewInfo { | ||
/** | ||
* Short description of the view. | ||
*/ | ||
description: string; | ||
/** | ||
* Url to the devtools. | ||
* @example http://chrome-devtools-frontend.appspot.com/serve_rev/@211d45a5b74b06d12bb016f3c4d54095faf2646f/inspector.html?ws=127.0.0.1:53213/devtools/page/4024 | ||
*/ | ||
devtoolsFrontendUrl: string; | ||
/** | ||
* Unique identifier of the web view. Could be number or GUID. | ||
* @example 4027 | ||
*/ | ||
id: string; | ||
/** | ||
* Title of the WebView. | ||
* @example https://bit.ly/12345V is not available | ||
*/ | ||
title: string; | ||
/** | ||
* Type of the WebView. | ||
* @example page | ||
*/ | ||
type: string; | ||
/** | ||
* URL loaded in the view. | ||
* @example https://bit.ly/12345V | ||
*/ | ||
url: string; | ||
/** | ||
* Debugger URL. | ||
* @example ws://127.0.0.1:53213/devtools/page/4027 | ||
*/ | ||
webSocketDebuggerUrl: string; | ||
} | ||
``` | ||
Sample usage: | ||
```JavaScript | ||
require("mobile-cli-lib") | ||
.devicesService | ||
.getDebuggableViews("4df18f307d8a8f1b", "com.telerik.cordovaApp") | ||
.then(function(data) { | ||
console.log(data); | ||
}, function(err) { | ||
console.log(err); | ||
}); | ||
``` | ||
Sample result will be: | ||
```JSON | ||
[{ | ||
"description": "", | ||
"devtoolsFrontendUrl": "http://chrome-devtools-frontend.appspot.com/serve_rev/@211d45a5b74b06d12bb016f3c4d54095faf2646f/inspector.html?ws=127.0.0.1:53213/devtools/page/4050", | ||
"id": "4050", | ||
"title": "New tab", | ||
"type": "page", | ||
"url": "chrome-native://newtab/", | ||
"webSocketDebuggerUrl": "ws://127.0.0.1:53213/devtools/page/4050" | ||
}, | ||
{ | ||
"description": "", | ||
"devtoolsFrontendUrl": "http://chrome-devtools-frontend.appspot.com/serve_rev/@211d45a5b74b06d12bb016f3c4d54095faf2646f/inspector.html?ws=127.0.0.1:53213/devtools/page/4032", | ||
"id": "4032", | ||
"title": "New tab", | ||
"type": "page", | ||
"url": "chrome-native://newtab/", | ||
"webSocketDebuggerUrl": "ws://127.0.0.1:53213/devtools/page/4032" | ||
} | ||
] | ||
``` | ||
### Module liveSyncService | ||
@@ -556,0 +760,0 @@ > Stability: 1 - Could be changed due to some new requirments. |
@@ -249,2 +249,44 @@ "use strict"; | ||
}); | ||
_.each(["debuggableViewFound", "debuggableViewLost", "debuggableViewChanged"], function (applicationEvent) { | ||
describe(applicationEvent, function () { | ||
var createDebuggableWebView = function (uniqueId) { | ||
return { | ||
description: "description_" + uniqueId, | ||
devtoolsFrontendUrl: "devtoolsFrontendUrl_" + uniqueId, | ||
id: "" + uniqueId, | ||
title: "title_" + uniqueId, | ||
type: "type_" + uniqueId, | ||
url: "url_" + uniqueId, | ||
webSocketDebuggerUrl: "webSocketDebuggerUrl_" + uniqueId, | ||
}; | ||
}; | ||
var appId = "appId"; | ||
var attachDebuggableEventVerificationHandler = function (expectedDeviceIdentifier, expectedAppIdentifier, expectedDebuggableViewInfo, done) { | ||
deviceEmitter.on(applicationEvent, function (deviceIdentifier, appIdentifier, debuggableViewInfo) { | ||
chai_1.assert.deepEqual(deviceIdentifier, expectedDeviceIdentifier); | ||
chai_1.assert.deepEqual(appIdentifier, expectedAppIdentifier); | ||
chai_1.assert.deepEqual(debuggableViewInfo, expectedDebuggableViewInfo); | ||
setTimeout(done, 0); | ||
}); | ||
}; | ||
it("is raised when working with android device", function (done) { | ||
var expectedDebuggableViewInfo = createDebuggableWebView("test1"); | ||
attachDebuggableEventVerificationHandler(androidDevice.deviceInfo.identifier, appId, expectedDebuggableViewInfo, done); | ||
androidDeviceDiscovery.emit("deviceFound", androidDevice); | ||
androidDevice.applicationManager.emit(applicationEvent, appId, expectedDebuggableViewInfo); | ||
}); | ||
it("is raised when working with iOS device", function (done) { | ||
var expectedDebuggableViewInfo = createDebuggableWebView("test1"); | ||
attachDebuggableEventVerificationHandler(iOSDevice.deviceInfo.identifier, appId, expectedDebuggableViewInfo, done); | ||
iOSDeviceDiscovery.emit("deviceFound", iOSDevice); | ||
iOSDevice.applicationManager.emit(applicationEvent, appId, expectedDebuggableViewInfo); | ||
}); | ||
it("is raised when working with iOS simulator", function (done) { | ||
var expectedDebuggableViewInfo = createDebuggableWebView("test1"); | ||
attachDebuggableEventVerificationHandler(iOSSimulator.deviceInfo.identifier, appId, expectedDebuggableViewInfo, done); | ||
iOSSimulatorDiscovery.emit("deviceFound", iOSSimulator); | ||
iOSSimulator.applicationManager.emit(applicationEvent, appId, expectedDebuggableViewInfo); | ||
}); | ||
}); | ||
}); | ||
_.each(["companionAppInstalled", "companionAppUninstalled"], function (applicationEvent) { | ||
@@ -251,0 +293,0 @@ describe(applicationEvent, function () { |
@@ -12,3 +12,3 @@ "use strict"; | ||
var Future = require("fibers/future"); | ||
var currentlyAvailableAppsForDebugging, currentlyInstalledApps; | ||
var currentlyAvailableAppsForDebugging, currentlyInstalledApps, currentlyAvailableAppWebViewsForDebugging; | ||
var ApplicationManager = (function (_super) { | ||
@@ -46,2 +46,5 @@ __extends(ApplicationManager, _super); | ||
}; | ||
ApplicationManager.prototype.getDebuggableAppViews = function (appIdentifiers) { | ||
return Future.fromResult(_.cloneDeep(currentlyAvailableAppWebViewsForDebugging)); | ||
}; | ||
return ApplicationManager; | ||
@@ -62,2 +65,20 @@ }(application_manager_base_1.ApplicationManagerBase)); | ||
} | ||
function createDebuggableWebView(uniqueId) { | ||
return { | ||
description: "description_" + uniqueId, | ||
devtoolsFrontendUrl: "devtoolsFrontendUrl_" + uniqueId, | ||
id: "" + uniqueId, | ||
title: "title_" + uniqueId, | ||
type: "type_" + uniqueId, | ||
url: "url_" + uniqueId, | ||
webSocketDebuggerUrl: "webSocketDebuggerUrl_" + uniqueId, | ||
}; | ||
} | ||
function createDebuggableWebViews(appInfos, numberOfViews) { | ||
var result = {}; | ||
_.each(appInfos, function (appInfo, index) { | ||
result[appInfo.appIdentifier] = _.times(numberOfViews, function (currentViewIndex) { return createDebuggableWebView(index + "_" + currentViewIndex); }); | ||
}); | ||
return result; | ||
} | ||
describe("ApplicationManagerBase", function () { | ||
@@ -68,2 +89,3 @@ var applicationManager, testInjector; | ||
currentlyAvailableAppsForDebugging = null; | ||
currentlyAvailableAppWebViewsForDebugging = null; | ||
applicationManager = testInjector.resolve("applicationManager"); | ||
@@ -170,2 +192,130 @@ }); | ||
}); | ||
it("emits debuggableViewFound when new views are available for debug", function (done) { | ||
currentlyAvailableAppsForDebugging = createAppsAvailableForDebugging(2); | ||
var numberOfViewsPerApp = 2; | ||
currentlyAvailableAppWebViewsForDebugging = createDebuggableWebViews(currentlyAvailableAppsForDebugging, numberOfViewsPerApp); | ||
var currentDebuggableViews = {}; | ||
applicationManager.on("debuggableViewFound", function (appIdentifier, d) { | ||
currentDebuggableViews[appIdentifier] = currentDebuggableViews[appIdentifier] || []; | ||
currentDebuggableViews[appIdentifier].push(d); | ||
var numberOfFoundViewsPerApp = _.uniq(_.values(currentDebuggableViews).map(function (arr) { return arr.length; })); | ||
if (_.keys(currentDebuggableViews).length === currentlyAvailableAppsForDebugging.length | ||
&& numberOfFoundViewsPerApp.length === 1 | ||
&& numberOfFoundViewsPerApp[0] === numberOfViewsPerApp) { | ||
_.each(currentDebuggableViews, function (webViews, appId) { | ||
_.each(webViews, function (webView) { | ||
var expectedWebView = _.find(currentlyAvailableAppWebViewsForDebugging[appId], function (c) { return c.id === webView.id; }); | ||
chai_1.assert.isTrue(_.isEqual(webView, expectedWebView)); | ||
}); | ||
}); | ||
setTimeout(done, 0); | ||
} | ||
}); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
}); | ||
it("emits debuggableViewLost when views for debug are removed", function (done) { | ||
currentlyAvailableAppsForDebugging = createAppsAvailableForDebugging(2); | ||
var numberOfViewsPerApp = 2; | ||
currentlyAvailableAppWebViewsForDebugging = createDebuggableWebViews(currentlyAvailableAppsForDebugging, numberOfViewsPerApp); | ||
var expectedResults = _.cloneDeep(currentlyAvailableAppWebViewsForDebugging); | ||
var currentDebuggableViews = {}; | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
applicationManager.on("debuggableViewLost", function (appIdentifier, d) { | ||
currentDebuggableViews[appIdentifier] = currentDebuggableViews[appIdentifier] || []; | ||
currentDebuggableViews[appIdentifier].push(d); | ||
var numberOfFoundViewsPerApp = _.uniq(_.values(currentDebuggableViews).map(function (arr) { return arr.length; })); | ||
if (_.keys(currentDebuggableViews).length === currentlyAvailableAppsForDebugging.length | ||
&& numberOfFoundViewsPerApp.length === 1 | ||
&& numberOfFoundViewsPerApp[0] === numberOfViewsPerApp) { | ||
_.each(currentDebuggableViews, function (webViews, appId) { | ||
_.each(webViews, function (webView) { | ||
var expectedWebView = _.find(expectedResults[appId], function (c) { return c.id === webView.id; }); | ||
chai_1.assert.isTrue(_.isEqual(webView, expectedWebView)); | ||
}); | ||
}); | ||
setTimeout(done, 0); | ||
} | ||
}); | ||
currentlyAvailableAppWebViewsForDebugging = _.mapValues(currentlyAvailableAppWebViewsForDebugging, function (a) { return []; }); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
}); | ||
it("emits debuggableViewFound when new views are available for debug", function (done) { | ||
currentlyAvailableAppsForDebugging = createAppsAvailableForDebugging(2); | ||
var numberOfViewsPerApp = 2; | ||
currentlyAvailableAppWebViewsForDebugging = createDebuggableWebViews(currentlyAvailableAppsForDebugging, numberOfViewsPerApp); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
var expectedViewToBeFound = createDebuggableWebView("uniqueId"), expectedAppIdentifier = currentlyAvailableAppsForDebugging[0].appIdentifier, isLastCheck = false; | ||
applicationManager.on("debuggableViewFound", function (appIdentifier, d) { | ||
chai_1.assert.deepEqual(appIdentifier, expectedAppIdentifier); | ||
chai_1.assert.isTrue(_.isEqual(d, expectedViewToBeFound)); | ||
if (isLastCheck) { | ||
setTimeout(done, 0); | ||
} | ||
}); | ||
currentlyAvailableAppWebViewsForDebugging[expectedAppIdentifier].push(_.cloneDeep(expectedViewToBeFound)); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
expectedViewToBeFound = createDebuggableWebView("uniqueId1"); | ||
currentlyAvailableAppWebViewsForDebugging[expectedAppIdentifier].push(_.cloneDeep(expectedViewToBeFound)); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
expectedViewToBeFound = createDebuggableWebView("uniqueId2"); | ||
expectedAppIdentifier = currentlyAvailableAppsForDebugging[1].appIdentifier; | ||
isLastCheck = true; | ||
currentlyAvailableAppWebViewsForDebugging[expectedAppIdentifier].push(_.cloneDeep(expectedViewToBeFound)); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
}); | ||
it("emits debuggableViewLost when views for debug are not available anymore", function (done) { | ||
currentlyAvailableAppsForDebugging = createAppsAvailableForDebugging(2); | ||
var numberOfViewsPerApp = 2; | ||
currentlyAvailableAppWebViewsForDebugging = createDebuggableWebViews(currentlyAvailableAppsForDebugging, numberOfViewsPerApp); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
var expectedAppIdentifier = currentlyAvailableAppsForDebugging[0].appIdentifier, expectedViewToBeLost = currentlyAvailableAppWebViewsForDebugging[expectedAppIdentifier].splice(0, 1)[0], isLastCheck = false; | ||
applicationManager.on("debuggableViewLost", function (appIdentifier, d) { | ||
chai_1.assert.deepEqual(appIdentifier, expectedAppIdentifier); | ||
chai_1.assert.isTrue(_.isEqual(d, expectedViewToBeLost)); | ||
if (isLastCheck) { | ||
setTimeout(done, 0); | ||
} | ||
}); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
expectedViewToBeLost = currentlyAvailableAppWebViewsForDebugging[expectedAppIdentifier].splice(0, 1)[0]; | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
expectedAppIdentifier = currentlyAvailableAppsForDebugging[1].appIdentifier; | ||
expectedViewToBeLost = currentlyAvailableAppWebViewsForDebugging[expectedAppIdentifier].splice(0, 1)[0]; | ||
isLastCheck = true; | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
}); | ||
it("emits debuggableViewChanged when view's property is modified (each one except id)", function (done) { | ||
currentlyAvailableAppsForDebugging = createAppsAvailableForDebugging(1); | ||
currentlyAvailableAppWebViewsForDebugging = createDebuggableWebViews(currentlyAvailableAppsForDebugging, 2); | ||
var viewToChange = currentlyAvailableAppWebViewsForDebugging[currentlyAvailableAppsForDebugging[0].appIdentifier][0]; | ||
var expectedView = _.cloneDeep(viewToChange); | ||
expectedView.title = "new title"; | ||
applicationManager.on("debuggableViewChanged", function (appIdentifier, d) { | ||
chai_1.assert.isTrue(_.isEqual(d, expectedView)); | ||
setTimeout(done, 0); | ||
}); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
viewToChange.title = "new title"; | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
}); | ||
it("does not emit debuggableViewChanged when id is modified", function (done) { | ||
currentlyAvailableAppsForDebugging = createAppsAvailableForDebugging(1); | ||
currentlyAvailableAppWebViewsForDebugging = createDebuggableWebViews(currentlyAvailableAppsForDebugging, 2); | ||
var viewToChange = currentlyAvailableAppWebViewsForDebugging[currentlyAvailableAppsForDebugging[0].appIdentifier][0]; | ||
var expectedView = _.cloneDeep(viewToChange); | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
applicationManager.on("debuggableViewChanged", function (appIdentifier, d) { | ||
setTimeout(function () { return done(new Error("When id is changed, debuggableViewChanged must not be emitted.")); }, 0); | ||
}); | ||
applicationManager.on("debuggableViewLost", function (appIdentifier, d) { | ||
chai_1.assert.isTrue(_.isEqual(d, expectedView)); | ||
}); | ||
applicationManager.on("debuggableViewFound", function (appIdentifier, d) { | ||
expectedView.id = "new id"; | ||
chai_1.assert.isTrue(_.isEqual(d, expectedView)); | ||
setTimeout(done, 0); | ||
}); | ||
viewToChange.id = "new id"; | ||
applicationManager.checkForApplicationUpdates().wait(); | ||
}); | ||
}); | ||
@@ -172,0 +322,0 @@ describe("installed and uninstalled apps", function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9800491
19784
966
+ Addedios-sim-portable@1.1.4(transitive)
- Removedios-sim-portable@1.1.1(transitive)
Updatedios-sim-portable@~1.1.4