UNPKG

mobile-cli-lib

Version:
81 lines (80 loc) 4.34 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var decorators_1 = require("../../../decorators"); var constants_1 = require("../../../constants"); var NS_COMPANION_APP_IDENTIFIER = "com.telerik.NativeScript"; var APPBUILDER_ANDROID_COMPANION_APP_IDENTIFIER = "com.telerik.AppBuilder"; var APPBUILDER_IOS_COMPANION_APP_IDENTIFIER = "com.telerik.Icenium"; var APPBUILDER_WP8_COMPANION_APP_IDENTIFIER = "{9155af5b-e7ed-486d-bc6b-35087fb59ecc}"; var CompanionAppsService = (function () { function CompanionAppsService($mobileHelper, $devicePlatformsConstants) { this.$mobileHelper = $mobileHelper; this.$devicePlatformsConstants = $devicePlatformsConstants; } CompanionAppsService.prototype.getCompanionAppIdentifier = function (framework, platform) { var lowerCasedFramework = (framework || "").toLowerCase(); var lowerCasedPlatform = (platform || "").toLowerCase(); if (lowerCasedFramework === constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase()) { if (this.$mobileHelper.isAndroidPlatform(lowerCasedPlatform)) { return APPBUILDER_ANDROID_COMPANION_APP_IDENTIFIER; } else if (this.$mobileHelper.isiOSPlatform(lowerCasedPlatform)) { return APPBUILDER_IOS_COMPANION_APP_IDENTIFIER; } else if (this.$mobileHelper.isWP8Platform(lowerCasedPlatform)) { return APPBUILDER_WP8_COMPANION_APP_IDENTIFIER; } } else if (lowerCasedFramework === constants_1.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript.toLowerCase()) { if (!this.$mobileHelper.isWP8Platform(lowerCasedPlatform)) { return NS_COMPANION_APP_IDENTIFIER; } } return null; }; CompanionAppsService.prototype.getAllCompanionAppIdentifiers = function () { var _this = this; var platforms = [ this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS, this.$devicePlatformsConstants.WP8 ]; var frameworks = [ constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase(), constants_1.TARGET_FRAMEWORK_IDENTIFIERS.NativeScript.toLowerCase() ]; var companionAppIdentifiers = {}; _.each(frameworks, function (framework) { var lowerCasedFramework = framework.toLowerCase(); companionAppIdentifiers[lowerCasedFramework] = companionAppIdentifiers[lowerCasedFramework] || {}; _.each(platforms, function (platform) { var lowerCasedPlatform = platform.toLowerCase(); companionAppIdentifiers[lowerCasedFramework][lowerCasedPlatform] = _this.getCompanionAppIdentifier(lowerCasedFramework, lowerCasedPlatform); }); }); return companionAppIdentifiers; }; __decorate([ decorators_1.exported("companionAppsService"), __metadata('design:type', Function), __metadata('design:paramtypes', [String, String]), __metadata('design:returntype', String) ], CompanionAppsService.prototype, "getCompanionAppIdentifier", null); __decorate([ decorators_1.exported("companionAppsService"), __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', Object) ], CompanionAppsService.prototype, "getAllCompanionAppIdentifiers", null); return CompanionAppsService; }()); exports.CompanionAppsService = CompanionAppsService; $injector.register("companionAppsService", CompanionAppsService);