UNPKG

mobile-cli-lib

Version:
294 lines (293 loc) 14.5 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var path = require("path"); var util = require("util"); var appbuilder_device_app_data_base_1 = require("../mobile/appbuilder-device-app-data-base"); var appbuilder_companion_device_app_data_base_1 = require("../mobile/appbuilder-companion-device-app-data-base"); var constants_1 = require("../../constants"); var Future = require("fibers/future"); var AndroidAppIdentifier = (function (_super) { __extends(AndroidAppIdentifier, _super); function AndroidAppIdentifier(_appIdentifier, device, platform, $deployHelper, $devicePlatformsConstants, $errors) { _super.call(this, _appIdentifier, device, platform, $deployHelper, $devicePlatformsConstants); this.$errors = $errors; this._deviceProjectRootPath = null; } Object.defineProperty(AndroidAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { if (!this._deviceProjectRootPath) { var deviceTmpDirFormat = ""; var version = this.getLiveSyncVersion().wait(); if (version === 2) { deviceTmpDirFormat = constants_1.LiveSyncConstants.DEVICE_TMP_DIR_FORMAT_V2; } else if (version === 3) { deviceTmpDirFormat = constants_1.LiveSyncConstants.DEVICE_TMP_DIR_FORMAT_V3; } else { this.$errors.failWithoutHelp("Unsupported LiveSync version: " + version); } this._deviceProjectRootPath = this.getDeviceProjectRootPath(util.format(deviceTmpDirFormat, this.appIdentifier)); } return this._deviceProjectRootPath; }, enumerable: true, configurable: true }); AndroidAppIdentifier.prototype.encodeLiveSyncHostUri = function (hostUri) { return hostUri; }; AndroidAppIdentifier.prototype.isLiveSyncSupported = function () { var _this = this; return (function () { return _super.prototype.isLiveSyncSupported.call(_this).wait() && _this.getLiveSyncVersion().wait() !== 0; }).future()(); }; AndroidAppIdentifier.prototype.getLiveSyncVersion = function () { var _this = this; return (function () { if (!_this._liveSyncVersion) { _this._liveSyncVersion = _this.device.adb.sendBroadcastToDevice(constants_1.LiveSyncConstants.CHECK_LIVESYNC_INTENT_NAME, { "app-id": _this.appIdentifier }).wait(); } return _this._liveSyncVersion; }).future()(); }; return AndroidAppIdentifier; }(appbuilder_device_app_data_base_1.AppBuilderDeviceAppDataBase)); exports.AndroidAppIdentifier = AndroidAppIdentifier; var AndroidCompanionAppIdentifier = (function (_super) { __extends(AndroidCompanionAppIdentifier, _super); function AndroidCompanionAppIdentifier(device, platform, $deployHelper, $devicePlatformsConstants, $companionAppsService) { _super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova, platform), device, platform, $deployHelper, $devicePlatformsConstants); this.$companionAppsService = $companionAppsService; } Object.defineProperty(AndroidCompanionAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { return this.getDeviceProjectRootPath(util.format(constants_1.LiveSyncConstants.DEVICE_TMP_DIR_FORMAT_V3, this.appIdentifier)); }, enumerable: true, configurable: true }); Object.defineProperty(AndroidCompanionAppIdentifier.prototype, "liveSyncFormat", { get: function () { return "icenium://%s?token=%s&appId=%s&configuration=%s"; }, enumerable: true, configurable: true }); AndroidCompanionAppIdentifier.prototype.getCompanionAppName = function () { return "companion app"; }; return AndroidCompanionAppIdentifier; }(appbuilder_companion_device_app_data_base_1.AppBuilderCompanionDeviceAppDataBase)); exports.AndroidCompanionAppIdentifier = AndroidCompanionAppIdentifier; var AndroidNativeScriptCompanionAppIdentifier = (function (_super) { __extends(AndroidNativeScriptCompanionAppIdentifier, _super); function AndroidNativeScriptCompanionAppIdentifier(device, platform, $deployHelper, $devicePlatformsConstants, $companionAppsService) { _super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript, platform), device, platform, $deployHelper, $devicePlatformsConstants); this.$companionAppsService = $companionAppsService; } Object.defineProperty(AndroidNativeScriptCompanionAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { return util.format(constants_1.LiveSyncConstants.DEVICE_TMP_DIR_FORMAT_V3, this.appIdentifier); }, enumerable: true, configurable: true }); Object.defineProperty(AndroidNativeScriptCompanionAppIdentifier.prototype, "liveSyncFormat", { get: function () { return "nativescript://%s?token=%s&appId=%s&configuration=%s"; }, enumerable: true, configurable: true }); AndroidNativeScriptCompanionAppIdentifier.prototype.getCompanionAppName = function () { return "NativeScript companion app"; }; return AndroidNativeScriptCompanionAppIdentifier; }(appbuilder_companion_device_app_data_base_1.AppBuilderCompanionDeviceAppDataBase)); exports.AndroidNativeScriptCompanionAppIdentifier = AndroidNativeScriptCompanionAppIdentifier; var IOSAppIdentifier = (function (_super) { __extends(IOSAppIdentifier, _super); function IOSAppIdentifier(_appIdentifier, device, platform, $deployHelper, $devicePlatformsConstants, $iOSSimResolver) { _super.call(this, _appIdentifier, device, platform, $deployHelper, $devicePlatformsConstants); this.$iOSSimResolver = $iOSSimResolver; this._deviceProjectRootPath = null; } Object.defineProperty(IOSAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { if (!this._deviceProjectRootPath) { if (this.device.isEmulator) { var applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier); this._deviceProjectRootPath = path.join(applicationPath, "www"); } else { this._deviceProjectRootPath = constants_1.LiveSyncConstants.IOS_PROJECT_PATH; } } return this._deviceProjectRootPath; }, enumerable: true, configurable: true }); IOSAppIdentifier.prototype.getLiveSyncNotSupportedError = function () { return "You can't LiveSync on device with id " + this.device.deviceInfo.identifier + "! Deploy the app with LiveSync enabled and wait for the initial start up before LiveSyncing."; }; return IOSAppIdentifier; }(appbuilder_device_app_data_base_1.AppBuilderDeviceAppDataBase)); exports.IOSAppIdentifier = IOSAppIdentifier; var IOSNativeScriptAppIdentifier = (function (_super) { __extends(IOSNativeScriptAppIdentifier, _super); function IOSNativeScriptAppIdentifier(_appIdentifier, device, platform, $deployHelper, $devicePlatformsConstants, $iOSSimResolver) { _super.call(this, _appIdentifier, device, platform, $deployHelper, $devicePlatformsConstants); this.$iOSSimResolver = $iOSSimResolver; this._deviceProjectRootPath = null; } Object.defineProperty(IOSNativeScriptAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { if (!this._deviceProjectRootPath) { if (this.device.isEmulator) { var applicationPath = this.$iOSSimResolver.iOSSim.getApplicationPath(this.device.deviceInfo.identifier, this.appIdentifier); this._deviceProjectRootPath = applicationPath; } else { this._deviceProjectRootPath = constants_1.LiveSyncConstants.IOS_PROJECT_PATH; } } return this._deviceProjectRootPath; }, enumerable: true, configurable: true }); return IOSNativeScriptAppIdentifier; }(appbuilder_device_app_data_base_1.AppBuilderDeviceAppDataBase)); exports.IOSNativeScriptAppIdentifier = IOSNativeScriptAppIdentifier; var IOSCompanionAppIdentifier = (function (_super) { __extends(IOSCompanionAppIdentifier, _super); function IOSCompanionAppIdentifier(device, platform, $deployHelper, $devicePlatformsConstants, $companionAppsService) { _super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova, platform), device, platform, $deployHelper, $devicePlatformsConstants); this.$companionAppsService = $companionAppsService; } Object.defineProperty(IOSCompanionAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { return constants_1.LiveSyncConstants.IOS_PROJECT_PATH; }, enumerable: true, configurable: true }); Object.defineProperty(IOSCompanionAppIdentifier.prototype, "liveSyncFormat", { get: function () { return "icenium://%s?LiveSyncToken=%s&appId=%s&configuration=%s"; }, enumerable: true, configurable: true }); IOSCompanionAppIdentifier.prototype.getCompanionAppName = function () { return "companion app"; }; return IOSCompanionAppIdentifier; }(appbuilder_companion_device_app_data_base_1.AppBuilderCompanionDeviceAppDataBase)); exports.IOSCompanionAppIdentifier = IOSCompanionAppIdentifier; var IOSNativeScriptCompanionAppIdentifier = (function (_super) { __extends(IOSNativeScriptCompanionAppIdentifier, _super); function IOSNativeScriptCompanionAppIdentifier(device, platform, $deployHelper, $devicePlatformsConstants, $companionAppsService) { _super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript, platform), device, platform, $deployHelper, $devicePlatformsConstants); this.$companionAppsService = $companionAppsService; } Object.defineProperty(IOSNativeScriptCompanionAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { return constants_1.LiveSyncConstants.IOS_PROJECT_PATH; }, enumerable: true, configurable: true }); Object.defineProperty(IOSNativeScriptCompanionAppIdentifier.prototype, "liveSyncFormat", { get: function () { return "nativescript://%s?LiveSyncToken=%s&appId=%s&configuration=%s"; }, enumerable: true, configurable: true }); IOSNativeScriptCompanionAppIdentifier.prototype.getCompanionAppName = function () { return "NativeScript companion app"; }; return IOSNativeScriptCompanionAppIdentifier; }(appbuilder_companion_device_app_data_base_1.AppBuilderCompanionDeviceAppDataBase)); exports.IOSNativeScriptCompanionAppIdentifier = IOSNativeScriptCompanionAppIdentifier; var WP8CompanionAppIdentifier = (function (_super) { __extends(WP8CompanionAppIdentifier, _super); function WP8CompanionAppIdentifier(device, $deployHelper, $devicePlatformsConstants, platform, $companionAppsService) { _super.call(this, $companionAppsService.getCompanionAppIdentifier(constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova, platform), device, platform, $deployHelper, $devicePlatformsConstants); this.platform = platform; this.$companionAppsService = $companionAppsService; } Object.defineProperty(WP8CompanionAppIdentifier.prototype, "deviceProjectRootPath", { get: function () { return ""; }, enumerable: true, configurable: true }); Object.defineProperty(WP8CompanionAppIdentifier.prototype, "liveSyncFormat", { get: function () { return "%s/Mist/MobilePackage/redirect?token=%s&appId=%s&configuration=%s"; }, enumerable: true, configurable: true }); WP8CompanionAppIdentifier.prototype.encodeLiveSyncHostUri = function (hostUri) { return hostUri; }; WP8CompanionAppIdentifier.prototype.isLiveSyncSupported = function () { return Future.fromResult(true); }; WP8CompanionAppIdentifier.prototype.getLiveSyncNotSupportedError = function () { return ""; }; WP8CompanionAppIdentifier.prototype.getCompanionAppName = function () { return "companion app"; }; return WP8CompanionAppIdentifier; }(appbuilder_companion_device_app_data_base_1.AppBuilderCompanionDeviceAppDataBase)); exports.WP8CompanionAppIdentifier = WP8CompanionAppIdentifier; var DeviceAppDataProvider = (function () { function DeviceAppDataProvider($project) { this.$project = $project; } DeviceAppDataProvider.prototype.createFactoryRules = function () { var rules = { Cordova: { Android: { vanilla: AndroidAppIdentifier, companion: AndroidCompanionAppIdentifier }, iOS: { vanilla: IOSAppIdentifier, companion: IOSCompanionAppIdentifier }, WP8: { vanilla: "", companion: WP8CompanionAppIdentifier } }, NativeScript: { Android: { vanilla: AndroidAppIdentifier, companion: AndroidNativeScriptCompanionAppIdentifier }, iOS: { vanilla: IOSNativeScriptAppIdentifier, companion: IOSNativeScriptCompanionAppIdentifier } } }; return rules[this.$project.projectData.Framework]; }; return DeviceAppDataProvider; }()); exports.DeviceAppDataProvider = DeviceAppDataProvider; $injector.register("deviceAppDataProvider", DeviceAppDataProvider);