UNPKG

nativescript

Version:

Command-line interface for building NativeScript projects

95 lines 4.97 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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.IOSSimulator = void 0; const applicationManagerPath = require("./ios-simulator-application-manager"); const fileSystemPath = require("./ios-simulator-file-system"); const constants = require("../../../constants"); const _ = require("lodash"); const decorators_1 = require("../../../decorators"); const helpers = require("../../../../common/helpers"); const ios_device_base_1 = require("../ios-device-base"); const constants_1 = require("../../../../constants"); class IOSSimulator extends ios_device_base_1.IOSDeviceBase { constructor(simulator, $devicePlatformsConstants, $deviceLogProvider, $errors, $lockService, $injector, $iOSDebuggerPortService, $iOSSimResolver, $iOSEmulatorServices, $iOSNotification, $iOSSimulatorLogProvider, $logger) { var _a; super(); this.simulator = simulator; this.$devicePlatformsConstants = $devicePlatformsConstants; this.$deviceLogProvider = $deviceLogProvider; this.$errors = $errors; this.$lockService = $lockService; this.$injector = $injector; this.$iOSDebuggerPortService = $iOSDebuggerPortService; this.$iOSSimResolver = $iOSSimResolver; this.$iOSEmulatorServices = $iOSEmulatorServices; this.$iOSNotification = $iOSNotification; this.$iOSSimulatorLogProvider = $iOSSimulatorLogProvider; this.$logger = $logger; this.applicationManager = this.$injector.resolve(applicationManagerPath.IOSSimulatorApplicationManager, { iosSim: this.$iOSSimResolver.iOSSim, device: this }); this.fileSystem = this.$injector.resolve(fileSystemPath.IOSSimulatorFileSystem, { iosSim: this.$iOSSimResolver.iOSSim }); this.deviceInfo = { imageIdentifier: this.simulator.id, identifier: this.simulator.id, displayName: this.simulator.name, model: _.last(this.simulator.fullId.split(".")), version: this.simulator.runtimeVersion, vendor: "Apple", platform: (_a = this.simulator.platform) !== null && _a !== void 0 ? _a : this.$devicePlatformsConstants.iOS, status: constants.CONNECTED_STATUS, errorHelp: null, isTablet: this.simulator.fullId.toLowerCase().indexOf("ipad") !== -1, type: constants.DeviceTypes.Emulator, connectionTypes: [constants_1.DeviceConnectionType.Local], }; } get isEmulator() { return true; } get isOnlyWiFiConnected() { return false; } async openDeviceLogStream(options) { options = options || {}; options.predicate = options.hasOwnProperty("predicate") ? options.predicate : constants.IOS_LOG_PREDICATE; return this.$iOSSimulatorLogProvider.startLogProcess(this.simulator.id, options); } async getDebugSocketCore(appId) { let socket; const attachRequestMessage = this.$iOSNotification.getAttachRequest(appId, this.deviceInfo.identifier); await this.$iOSEmulatorServices.postDarwinNotification(attachRequestMessage, this.deviceInfo.identifier); // Retry posting the notification every five seconds, in case the AttachRequest // event handler wasn't registered when the first one was sent const postNotificationRetryInterval = setInterval(() => { this.$iOSEmulatorServices .postDarwinNotification(attachRequestMessage, this.deviceInfo.identifier) .catch((e) => this.$logger.error(e)); }, 5e3); // the internal retry-mechanism of getDebuggerPort will ensure the above // interval has a chance to execute multiple times const port = await super.getDebuggerPort(appId).finally(() => { clearInterval(postNotificationRetryInterval); }); try { socket = await helpers.connectEventuallyUntilTimeout(async () => { return this.$iOSEmulatorServices.connectToPort({ port }); }, constants.SOCKET_CONNECTION_TIMEOUT_MS); } catch (e) { this.$logger.warn(e); } return socket; } } exports.IOSSimulator = IOSSimulator; __decorate([ (0, decorators_1.cache)() ], IOSSimulator.prototype, "openDeviceLogStream", null); //# sourceMappingURL=ios-simulator-device.js.map