nativescript 8.8.0 → 8.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/config/test-deps-versions-generated.json +1 -1
  2. package/lib/android-tools-info.js +12 -0
  3. package/lib/base-package-manager.js +11 -1
  4. package/lib/bootstrap.js +5 -1
  5. package/lib/bun-package-manager.js +17 -1
  6. package/lib/color.js +3 -0
  7. package/lib/commands/add-platform.js +1 -0
  8. package/lib/commands/apple-login.js +1 -0
  9. package/lib/commands/appstore-list.js +1 -0
  10. package/lib/commands/appstore-upload.js +4 -0
  11. package/lib/commands/build.js +3 -2
  12. package/lib/commands/clean.js +22 -1
  13. package/lib/commands/command-base.js +1 -0
  14. package/lib/commands/config.js +3 -0
  15. package/lib/commands/create-project.js +6 -0
  16. package/lib/commands/debug.js +6 -1
  17. package/lib/commands/deploy.js +3 -2
  18. package/lib/commands/embedding/embed.js +7 -0
  19. package/lib/commands/extensibility/install-extension.js +1 -0
  20. package/lib/commands/extensibility/list-extensions.js +1 -0
  21. package/lib/commands/extensibility/uninstall-extension.js +1 -0
  22. package/lib/commands/fonts.js +1 -0
  23. package/lib/commands/generate-assets.js +1 -0
  24. package/lib/commands/generate-help.js +1 -0
  25. package/lib/commands/generate.js +12 -2
  26. package/lib/commands/info.js +1 -0
  27. package/lib/commands/install.js +1 -0
  28. package/lib/commands/list-platforms.js +1 -0
  29. package/lib/commands/migrate.js +1 -0
  30. package/lib/commands/native-add.js +5 -0
  31. package/lib/commands/platform-clean.js +1 -0
  32. package/lib/commands/plugin/add-plugin.js +1 -0
  33. package/lib/commands/plugin/build-plugin.js +1 -0
  34. package/lib/commands/plugin/create-plugin.js +5 -0
  35. package/lib/commands/plugin/list-plugins.js +1 -0
  36. package/lib/commands/plugin/remove-plugin.js +2 -0
  37. package/lib/commands/plugin/update-plugin.js +1 -0
  38. package/lib/commands/post-install.js +6 -0
  39. package/lib/commands/prepare.js +4 -3
  40. package/lib/commands/preview.js +2 -0
  41. package/lib/commands/remove-platform.js +1 -0
  42. package/lib/commands/resources/resources-update.js +2 -0
  43. package/lib/commands/run.js +1 -0
  44. package/lib/commands/setup.js +1 -0
  45. package/lib/commands/start.js +1 -0
  46. package/lib/commands/test-init.js +4 -0
  47. package/lib/commands/test.js +9 -2
  48. package/lib/commands/typings.js +2 -1
  49. package/lib/commands/update-platform.js +5 -0
  50. package/lib/commands/update.js +2 -0
  51. package/lib/common/bootstrap.js +1 -0
  52. package/lib/common/child-process.js +3 -0
  53. package/lib/common/codeGeneration/code-entity.js +1 -0
  54. package/lib/common/codeGeneration/code-printer.js +1 -0
  55. package/lib/common/command-params.js +1 -0
  56. package/lib/common/commands/analytics.js +3 -0
  57. package/lib/common/commands/autocompletion.js +3 -0
  58. package/lib/common/commands/device/device-log-stream.js +1 -0
  59. package/lib/common/commands/device/get-file.js +2 -0
  60. package/lib/common/commands/device/list-applications.js +1 -0
  61. package/lib/common/commands/device/list-devices.js +3 -0
  62. package/lib/common/commands/device/list-files.js +2 -0
  63. package/lib/common/commands/device/put-file.js +2 -0
  64. package/lib/common/commands/device/run-application.js +1 -0
  65. package/lib/common/commands/device/stop-application.js +1 -0
  66. package/lib/common/commands/device/uninstall-application.js +1 -0
  67. package/lib/common/commands/doctor.js +3 -2
  68. package/lib/common/commands/generate-messages.js +1 -0
  69. package/lib/common/commands/help.js +1 -0
  70. package/lib/common/commands/package-manager-get.js +1 -0
  71. package/lib/common/commands/package-manager-set.js +1 -0
  72. package/lib/common/commands/post-install.js +1 -0
  73. package/lib/common/commands/preuninstall.js +11 -2
  74. package/lib/common/commands/proxy/proxy-base.js +4 -0
  75. package/lib/common/commands/proxy/proxy-clear.js +1 -0
  76. package/lib/common/commands/proxy/proxy-get.js +1 -0
  77. package/lib/common/commands/proxy/proxy-set.js +1 -0
  78. package/lib/common/common-lib.js +1 -0
  79. package/lib/common/constants.js +11 -0
  80. package/lib/common/decorators.js +48 -0
  81. package/lib/common/dispatchers.js +10 -1
  82. package/lib/common/errors.js +13 -3
  83. package/lib/common/file-system.js +13 -2
  84. package/lib/common/header.js +3 -0
  85. package/lib/common/helpers.js +89 -3
  86. package/lib/common/host-info.js +4 -0
  87. package/lib/common/http-client.js +20 -0
  88. package/lib/common/logger/appenders/cli-appender.js +4 -0
  89. package/lib/common/logger/appenders/emit-appender.js +4 -0
  90. package/lib/common/logger/layouts/cli-layout.js +1 -0
  91. package/lib/common/logger/logger.js +5 -0
  92. package/lib/common/messages/messages.js +6 -0
  93. package/lib/common/mobile/android/android-application-manager.js +20 -1
  94. package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -0
  95. package/lib/common/mobile/android/android-debug-bridge.js +6 -0
  96. package/lib/common/mobile/android/android-device-file-system.js +4 -0
  97. package/lib/common/mobile/android/android-device-hash-service.js +3 -0
  98. package/lib/common/mobile/android/android-device.js +8 -0
  99. package/lib/common/mobile/android/android-emulator-services.js +2 -1
  100. package/lib/common/mobile/android/android-ini-file-parser.js +9 -0
  101. package/lib/common/mobile/android/android-log-filter.js +4 -0
  102. package/lib/common/mobile/android/android-virtual-device-service.js +30 -1
  103. package/lib/common/mobile/android/device-android-debug-bridge.js +1 -0
  104. package/lib/common/mobile/android/genymotion/genymotion-service.js +5 -0
  105. package/lib/common/mobile/android/genymotion/virtualbox-service.js +11 -0
  106. package/lib/common/mobile/android/logcat-helper.js +13 -0
  107. package/lib/common/mobile/application-manager-base.js +6 -0
  108. package/lib/common/mobile/device-emitter.js +4 -0
  109. package/lib/common/mobile/device-log-emitter.js +1 -0
  110. package/lib/common/mobile/device-log-provider-base.js +1 -0
  111. package/lib/common/mobile/device-log-provider.js +23 -0
  112. package/lib/common/mobile/device-platforms-constants.js +1 -0
  113. package/lib/common/mobile/emulator-helper.js +4 -0
  114. package/lib/common/mobile/ios/device/ios-application-manager.js +3 -0
  115. package/lib/common/mobile/ios/device/ios-device-file-system.js +1 -0
  116. package/lib/common/mobile/ios/device/ios-device-operations.js +4 -0
  117. package/lib/common/mobile/ios/device/ios-device.js +4 -0
  118. package/lib/common/mobile/ios/ios-device-base.js +1 -0
  119. package/lib/common/mobile/ios/ios-device-product-name-mapper.js +2 -0
  120. package/lib/common/mobile/ios/ios-log-filter.js +1 -0
  121. package/lib/common/mobile/ios/simulator/ios-emulator-services.js +4 -0
  122. package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -0
  123. package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +6 -0
  124. package/lib/common/mobile/ios/simulator/ios-simulator-device.js +5 -0
  125. package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +1 -0
  126. package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +1 -0
  127. package/lib/common/mobile/local-to-device-path-data-factory.js +1 -0
  128. package/lib/common/mobile/log-filter.js +2 -0
  129. package/lib/common/mobile/logging-levels.js +1 -0
  130. package/lib/common/mobile/mobile-core/android-device-discovery.js +2 -0
  131. package/lib/common/mobile/mobile-core/android-emulator-discovery.js +3 -0
  132. package/lib/common/mobile/mobile-core/android-process-service.js +32 -0
  133. package/lib/common/mobile/mobile-core/device-discovery.js +1 -0
  134. package/lib/common/mobile/mobile-core/devices-service.js +69 -0
  135. package/lib/common/mobile/mobile-core/ios-device-discovery.js +2 -0
  136. package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +3 -0
  137. package/lib/common/mobile/mobile-helper.js +1 -0
  138. package/lib/common/mobile/wp8/wp8-emulator-services.js +1 -0
  139. package/lib/common/opener.js +1 -0
  140. package/lib/common/os-info.js +1 -0
  141. package/lib/common/plist-parser.js +1 -0
  142. package/lib/common/project-helper.js +1 -0
  143. package/lib/common/prompter.js +9 -1
  144. package/lib/common/queue.js +1 -0
  145. package/lib/common/resource-loader.js +1 -0
  146. package/lib/common/services/auto-completion-service.js +13 -1
  147. package/lib/common/services/cancellation.js +2 -1
  148. package/lib/common/services/commands-service.js +17 -6
  149. package/lib/common/services/help-service.js +11 -3
  150. package/lib/common/services/hooks-service.js +13 -0
  151. package/lib/common/services/ios-notification-service.js +1 -0
  152. package/lib/common/services/json-file-settings-service.js +6 -0
  153. package/lib/common/services/lock-service.js +6 -0
  154. package/lib/common/services/message-contract-generator.js +1 -0
  155. package/lib/common/services/messages-service.js +1 -0
  156. package/lib/common/services/micro-templating-service.js +6 -0
  157. package/lib/common/services/net-service.js +3 -0
  158. package/lib/common/services/project-files-manager.js +5 -0
  159. package/lib/common/services/project-files-provider-base.js +1 -0
  160. package/lib/common/services/proxy-service.js +1 -0
  161. package/lib/common/services/qr.js +1 -0
  162. package/lib/common/services/settings-service.js +1 -0
  163. package/lib/common/services/xcode-select-service.js +1 -0
  164. package/lib/common/utils.js +1 -0
  165. package/lib/common/validators/project-name-validator.js +1 -0
  166. package/lib/common/validators/validation-result.js +1 -0
  167. package/lib/common/verify-node-version.js +8 -1
  168. package/lib/common/yok.js +32 -11
  169. package/lib/config.js +22 -1
  170. package/lib/constants-provider.js +1 -0
  171. package/lib/constants.js +53 -0
  172. package/lib/controllers/build-controller.js +4 -3
  173. package/lib/controllers/debug-controller.js +8 -3
  174. package/lib/controllers/deploy-controller.js +1 -0
  175. package/lib/controllers/migrate-controller.js +91 -3
  176. package/lib/controllers/platform-controller.js +9 -1
  177. package/lib/controllers/prepare-controller.js +17 -4
  178. package/lib/controllers/run-controller.js +17 -1
  179. package/lib/controllers/update-controller-base.js +1 -0
  180. package/lib/controllers/update-controller.js +11 -0
  181. package/lib/data/build-data.js +1 -0
  182. package/lib/data/controller-data-base.js +1 -0
  183. package/lib/data/debug-data.js +1 -0
  184. package/lib/data/platform-data.js +1 -0
  185. package/lib/data/prepare-data.js +1 -0
  186. package/lib/data/run-data.js +1 -0
  187. package/lib/detached-processes/cleanup-js-subprocess.js +8 -2
  188. package/lib/detached-processes/cleanup-process.js +18 -14
  189. package/lib/detached-processes/file-log-service.js +2 -1
  190. package/lib/device-path-provider.js +1 -0
  191. package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +7 -0
  192. package/lib/device-sockets/ios/notification.js +3 -0
  193. package/lib/device-sockets/ios/socket-request-executor.js +3 -0
  194. package/lib/helpers/android-bundle-validator-helper.js +2 -1
  195. package/lib/helpers/deploy-command-helper.js +1 -0
  196. package/lib/helpers/key-command-helper.js +4 -2
  197. package/lib/helpers/livesync-command-helper.js +4 -1
  198. package/lib/helpers/network-connectivity-validator.js +1 -0
  199. package/lib/helpers/options-track-helper.js +3 -2
  200. package/lib/helpers/package-path-helper.js +1 -0
  201. package/lib/helpers/platform-command-helper.js +7 -2
  202. package/lib/helpers/version-validator-helper.js +1 -0
  203. package/lib/key-commands/bootstrap.js +3 -2
  204. package/lib/key-commands/index.js +5 -4
  205. package/lib/nativescript-cli-lib-bootstrap.js +4 -0
  206. package/lib/nativescript-cli-lib.js +1 -0
  207. package/lib/nativescript-cli.js +10 -1
  208. package/lib/node/pbxproj-dom-xcode.js +1 -0
  209. package/lib/node/xcode.js +1 -0
  210. package/lib/node-package-manager.js +11 -1
  211. package/lib/options.js +143 -118
  212. package/lib/package-installation-manager.js +8 -1
  213. package/lib/package-manager.js +2 -0
  214. package/lib/platform-command-param.js +1 -0
  215. package/lib/pnpm-package-manager.js +4 -1
  216. package/lib/project-data.js +12 -0
  217. package/lib/providers/project-files-provider.js +1 -0
  218. package/lib/resolvers/livesync-service-resolver.js +1 -0
  219. package/lib/services/analytics/analytics-broker-process.js +10 -6
  220. package/lib/services/analytics/analytics-broker.js +2 -1
  221. package/lib/services/analytics/analytics-service.js +29 -25
  222. package/lib/services/analytics/google-analytics-provider.js +13 -12
  223. package/lib/services/analytics-settings-service.js +5 -0
  224. package/lib/services/android/android-bundle-tool-service.js +1 -0
  225. package/lib/services/android/gradle-build-args-service.js +3 -0
  226. package/lib/services/android/gradle-build-service.js +1 -0
  227. package/lib/services/android/gradle-command-service.js +6 -1
  228. package/lib/services/android-device-debug-service.js +6 -0
  229. package/lib/services/android-plugin-build-service.js +33 -1
  230. package/lib/services/android-project-service.js +71 -4
  231. package/lib/services/android-resources-migration-service.js +7 -0
  232. package/lib/services/apple-portal/apple-portal-application-service.js +1 -0
  233. package/lib/services/apple-portal/apple-portal-cookie-service.js +1 -0
  234. package/lib/services/apple-portal/apple-portal-session-service.js +6 -4
  235. package/lib/services/assets-generation/assets-generation-service.js +16 -5
  236. package/lib/services/build-artifacts-service.js +2 -1
  237. package/lib/services/build-data-service.js +1 -0
  238. package/lib/services/build-info-file-service.js +1 -0
  239. package/lib/services/cleanup-service.js +13 -9
  240. package/lib/services/cocoapods-platform-manager.js +9 -0
  241. package/lib/services/cocoapods-service.js +21 -1
  242. package/lib/services/debug-data-service.js +1 -0
  243. package/lib/services/debug-service-base.js +7 -0
  244. package/lib/services/device/device-install-app-service.js +2 -1
  245. package/lib/services/doctor-service.js +21 -6
  246. package/lib/services/extensibility-service.js +8 -0
  247. package/lib/services/files-hash-service.js +1 -0
  248. package/lib/services/hmr-status-service.js +2 -0
  249. package/lib/services/info-service.js +1 -0
  250. package/lib/services/initialize-service.js +5 -1
  251. package/lib/services/ios/export-options-plist-service.js +4 -0
  252. package/lib/services/ios/ios-signing-service.js +4 -0
  253. package/lib/services/ios/spm-service.js +9 -0
  254. package/lib/services/ios/xcodebuild-args-service.js +9 -0
  255. package/lib/services/ios/xcodebuild-command-service.js +1 -0
  256. package/lib/services/ios/xcodebuild-service.js +1 -0
  257. package/lib/services/ios-debugger-port-service.js +1 -0
  258. package/lib/services/ios-device-debug-service.js +1 -0
  259. package/lib/services/ios-entitlements-service.js +1 -0
  260. package/lib/services/ios-extensions-service.js +1 -0
  261. package/lib/services/ios-log-filter.js +20 -0
  262. package/lib/services/ios-native-target-service.js +6 -4
  263. package/lib/services/ios-project-service.js +94 -2
  264. package/lib/services/ios-provision-service.js +3 -0
  265. package/lib/services/ios-watch-app-service.js +1 -0
  266. package/lib/services/ip-service.js +2 -0
  267. package/lib/services/itmstransporter-service.js +1 -0
  268. package/lib/services/karma-execution.js +2 -0
  269. package/lib/services/livesync/android-device-livesync-service-base.js +1 -0
  270. package/lib/services/livesync/android-device-livesync-service.js +2 -0
  271. package/lib/services/livesync/android-device-livesync-sockets-service.js +3 -0
  272. package/lib/services/livesync/android-livesync-service.js +1 -0
  273. package/lib/services/livesync/android-livesync-tool.js +4 -0
  274. package/lib/services/livesync/device-livesync-service-base.js +2 -0
  275. package/lib/services/livesync/ios-device-livesync-service.js +7 -0
  276. package/lib/services/livesync/ios-livesync-service.js +2 -0
  277. package/lib/services/livesync/livesync-socket.js +1 -0
  278. package/lib/services/livesync/platform-livesync-service-base.js +5 -0
  279. package/lib/services/livesync-process-data-service.js +1 -0
  280. package/lib/services/log-parser-service.js +1 -0
  281. package/lib/services/log-source-map-service.js +15 -0
  282. package/lib/services/marking-mode-service.js +8 -5
  283. package/lib/services/metadata-filtering-service.js +1 -0
  284. package/lib/services/npm-config-service.js +4 -0
  285. package/lib/services/pacote-service.js +7 -0
  286. package/lib/services/performance-service.js +3 -1
  287. package/lib/services/platform/add-platform-service.js +49 -2
  288. package/lib/services/platform/platform-validation-service.js +1 -0
  289. package/lib/services/platform/prepare-native-platform-service.js +5 -2
  290. package/lib/services/platform-environment-requirements.js +8 -3
  291. package/lib/services/platform-project-service-base.js +1 -0
  292. package/lib/services/platforms-data-service.js +1 -0
  293. package/lib/services/plugins-service.js +20 -2
  294. package/lib/services/prepare-data-service.js +1 -0
  295. package/lib/services/project-backup-service.js +4 -0
  296. package/lib/services/project-changes-service.js +14 -3
  297. package/lib/services/project-cleanup-service.js +2 -0
  298. package/lib/services/project-config-service.js +22 -2
  299. package/lib/services/project-data-service.js +36 -7
  300. package/lib/services/project-name-service.js +1 -0
  301. package/lib/services/project-service.js +10 -0
  302. package/lib/services/project-templates-service.js +3 -2
  303. package/lib/services/qr-code-terminal-service.js +1 -0
  304. package/lib/services/require-service.js +1 -0
  305. package/lib/services/start-service.js +1 -0
  306. package/lib/services/temp-service.js +1 -0
  307. package/lib/services/terminal-spinner-service.js +2 -0
  308. package/lib/services/test-execution-service.js +9 -2
  309. package/lib/services/test-initialization-service.js +4 -0
  310. package/lib/services/timeline-profiler-service.js +1 -0
  311. package/lib/services/user-settings-service.js +1 -0
  312. package/lib/services/versions-service.js +6 -4
  313. package/lib/services/watch-ignore-list-service.js +1 -0
  314. package/lib/services/webpack/webpack-compiler-service.js +42 -1
  315. package/lib/services/xcconfig-service.js +2 -0
  316. package/lib/services/xcproj-service.js +1 -0
  317. package/lib/shared-event-bus.js +6 -0
  318. package/lib/sys-info.js +2 -1
  319. package/lib/tools/config-manipulation/config-transformer.js +12 -0
  320. package/lib/tools/node-modules/node-modules-builder.js +1 -0
  321. package/lib/tools/node-modules/node-modules-dependencies-builder.js +6 -0
  322. package/lib/yarn-package-manager.js +1 -0
  323. package/lib/yarn2-package-manager.js +3 -0
  324. package/node_modules/@npmcli/move-file/node_modules/mkdirp/CHANGELOG.md +15 -0
  325. package/node_modules/rimraf/CHANGELOG.md +65 -0
  326. package/node_modules/stringify-package/CHANGELOG.md +16 -0
  327. package/package.json +2 -2
@@ -36,6 +36,7 @@ class DeviceLogProvider extends device_log_provider_base_1.DeviceLogProviderBase
36
36
  this.colorPoolIndex = 0;
37
37
  }
38
38
  logData(lineText, platform, deviceIdentifier) {
39
+ // console.log(lineText)
39
40
  const loggingOptions = this.getDeviceLogOptionsForDevice(deviceIdentifier);
40
41
  let data = this.$logFilter.filterData(platform, lineText, loggingOptions);
41
42
  data = this.$logSourceMapService.replaceWithOriginalFileLocations(platform, data, loggingOptions);
@@ -53,6 +54,7 @@ class DeviceLogProvider extends device_log_provider_base_1.DeviceLogProviderBase
53
54
  return this.deviceColorMap.get(deviceIdentifier);
54
55
  }
55
56
  const color = this.colorPool[this.colorPoolIndex];
57
+ // wrap around if we have no more colors in the pool
56
58
  this.colorPoolIndex =
57
59
  this.colorPoolIndex === this.colorPool.length - 1
58
60
  ? 0
@@ -62,10 +64,13 @@ class DeviceLogProvider extends device_log_provider_base_1.DeviceLogProviderBase
62
64
  }
63
65
  logDataCore(data, deviceIdentifier) {
64
66
  var _a, _b, _c;
67
+ // todo: use config to set logger - --env.classicLogs is temporary!
65
68
  if ("classicLogs" in ((_a = this.$options.env) !== null && _a !== void 0 ? _a : {})) {
69
+ // legacy logging
66
70
  this.$logger.info(data, { [constants_2.LoggerConfigData.skipNewLine]: true });
67
71
  return;
68
72
  }
73
+ // todo: extract into an injectable printer/logger service
69
74
  let shouldPrepend = false;
70
75
  let splitIndexes = [];
71
76
  const lines = data
@@ -120,7 +125,25 @@ class DeviceLogProvider extends device_log_provider_base_1.DeviceLogProviderBase
120
125
  printLine(prefix, ...parts) {
121
126
  const fullLine = parts.join(" ");
122
127
  console.log(prefix, fullLine);
128
+ /**
129
+ * Note: Disabled
130
+ *
131
+ * This splits the output into lines that fit within the current
132
+ * terminal width, however this makes copying json objects that
133
+ * span across multiple lines difficult, as it introduces
134
+ * whitespace & line breaks
135
+ */
136
+ // const maxWidth = process.stdout.columns - 2;
137
+ // if (!maxWidth || maxWidth < 10 || fullLine.length < maxWidth) {
138
+ // console.log(prefix, fullLine);
139
+ // } else {
140
+ // for (let i = 0; i < fullLine.length; i += maxWidth) {
141
+ // const part = fullLine.substring(i, i + maxWidth);
142
+ // console.log(prefix, part);
143
+ // }
144
+ // }
123
145
  }
124
146
  }
125
147
  exports.DeviceLogProvider = DeviceLogProvider;
126
148
  yok_1.injector.register("deviceLogProvider", DeviceLogProvider);
149
+ //# sourceMappingURL=device-log-provider.js.map
@@ -20,3 +20,4 @@ class DevicePlatformsConstants {
20
20
  }
21
21
  exports.DevicePlatformsConstants = DevicePlatformsConstants;
22
22
  yok_1.injector.register("devicePlatformsConstants", DevicePlatformsConstants);
23
+ //# sourceMappingURL=device-platforms-constants.js.map
@@ -6,7 +6,9 @@ const _ = require("lodash");
6
6
  const yok_1 = require("../yok");
7
7
  class EmulatorHelper {
8
8
  constructor() {
9
+ // https://developer.android.com/guide/topics/manifest/uses-sdk-element
9
10
  this.mapAndroidApiLevelToVersion = {
11
+ "android-35": "15.0.0",
10
12
  "android-34": "14.0.0",
11
13
  "android-33": "13.0.0",
12
14
  "android-32": "12.0.0",
@@ -78,7 +80,9 @@ class EmulatorHelper {
78
80
  emulator.identifier = emulatorId;
79
81
  emulator.status = constants_1.RUNNING_EMULATOR_STATUS;
80
82
  emulator.type = constants_1.DeviceTypes.Device;
83
+ //emulator.isTablet; // TODO: consider to do this here!!!
81
84
  }
82
85
  }
83
86
  exports.EmulatorHelper = EmulatorHelper;
84
87
  yok_1.injector.register("emulatorHelper", EmulatorHelper);
88
+ //# sourceMappingURL=emulator-helper.js.map
@@ -144,9 +144,11 @@ class IOSApplicationManager extends application_manager_base_1.ApplicationManage
144
144
  });
145
145
  }
146
146
  getDebuggableApps() {
147
+ // Implement when we can find debuggable applications for iOS.
147
148
  return Promise.resolve([]);
148
149
  }
149
150
  getDebuggableAppViews(appIdentifiers) {
151
+ // Implement when we can find debuggable applications for iOS.
150
152
  return Promise.resolve(null);
151
153
  }
152
154
  }
@@ -157,3 +159,4 @@ __decorate([
157
159
  (0, decorators_1.cache)()
158
160
  ], IOSApplicationManager.prototype, "startDeviceLog", null);
159
161
  exports.IOSApplicationManager = IOSApplicationManager;
162
+ //# sourceMappingURL=ios-application-manager.js.map
@@ -131,3 +131,4 @@ class IOSDeviceFileSystem {
131
131
  }
132
132
  IOSDeviceFileSystem.AFC_DELETE_FILE_NOT_FOUND_ERROR = 8;
133
133
  exports.IOSDeviceFileSystem = IOSDeviceFileSystem;
134
+ //# sourceMappingURL=ios-device-file-system.js.map
@@ -58,6 +58,7 @@ class IOSDeviceOperations extends events_1.EventEmitter {
58
58
  if (options && options.shouldReturnImmediateResult) {
59
59
  return;
60
60
  }
61
+ // We need this because we need to make sure that we have devices.
61
62
  yield new Promise((resolve, reject) => {
62
63
  let iterationsCount = 0;
63
64
  const maxIterationsCount = 3;
@@ -154,6 +155,8 @@ class IOSDeviceOperations extends events_1.EventEmitter {
154
155
  });
155
156
  }
156
157
  dispose(signal) {
158
+ // We need to check if we should dispose the device lib.
159
+ // For example we do not want to dispose it when we start printing the device logs.
157
160
  if (this.shouldDispose && this.deviceLib) {
158
161
  this.deviceLib.removeAllListeners();
159
162
  this.deviceLib.dispose(signal);
@@ -232,3 +235,4 @@ __decorate([
232
235
  ], IOSDeviceOperations.prototype, "attacheDeviceLogDataHandler", null);
233
236
  exports.IOSDeviceOperations = IOSDeviceOperations;
234
237
  yok_1.injector.register("iosDeviceOperations", IOSDeviceOperations);
238
+ //# sourceMappingURL=ios-device-operations.js.map
@@ -122,6 +122,7 @@ class IOSDevice extends ios_device_base_1.IOSDeviceBase {
122
122
  const majorVersionAsString = productType.match(/.*?(\d+)\,(\d+)/)[1];
123
123
  const majorVersion = parseInt(majorVersionAsString);
124
124
  let isArm64Architecture = false;
125
+ //https://en.wikipedia.org/wiki/List_of_iOS_devices
125
126
  if (_.startsWith(productType, "iphone")) {
126
127
  isArm64Architecture = majorVersion >= 6;
127
128
  }
@@ -132,6 +133,7 @@ class IOSDevice extends ios_device_base_1.IOSDeviceBase {
132
133
  isArm64Architecture = majorVersion >= 7;
133
134
  }
134
135
  else if (_.startsWith(productType, "realitydevice")) {
136
+ // visionos
135
137
  isArm64Architecture = true;
136
138
  }
137
139
  activeArchitecture = isArm64Architecture ? "arm64" : "armv7";
@@ -141,6 +143,7 @@ class IOSDevice extends ios_device_base_1.IOSDeviceBase {
141
143
  getPlatform(productType) {
142
144
  productType = productType.toLowerCase().trim();
143
145
  if (_.startsWith(productType, "realitydevice")) {
146
+ // visionos
144
147
  return this.$devicePlatformsConstants.visionOS;
145
148
  }
146
149
  return this.$devicePlatformsConstants.iOS;
@@ -151,3 +154,4 @@ __decorate([
151
154
  ], IOSDevice.prototype, "openDeviceLogStream", null);
152
155
  exports.IOSDevice = IOSDevice;
153
156
  yok_1.injector.register("iOSDevice", IOSDevice);
157
+ //# sourceMappingURL=ios-device.js.map
@@ -106,3 +106,4 @@ __decorate([
106
106
  (0, decorators_1.performanceLog)()
107
107
  ], IOSDeviceBase.prototype, "getDebugSocket", null);
108
108
  exports.IOSDeviceBase = IOSDeviceBase;
109
+ //# sourceMappingURL=ios-device-base.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const yok_1 = require("../../yok");
4
4
  class IosDeviceProductNameMapper {
5
5
  constructor() {
6
+ // http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/ios-device-types
6
7
  this.map = {
7
8
  "iPhone1,1": "iPhone",
8
9
  "iPhone1,2": "iPhone 3G",
@@ -63,3 +64,4 @@ class IosDeviceProductNameMapper {
63
64
  }
64
65
  }
65
66
  yok_1.injector.register("iOSDeviceProductNameMapper", IosDeviceProductNameMapper);
67
+ //# sourceMappingURL=ios-device-product-name-mapper.js.map
@@ -22,3 +22,4 @@ class IOSLogFilter {
22
22
  }
23
23
  exports.IOSLogFilter = IOSLogFilter;
24
24
  yok_1.injector.register("iOSLogFilter", IOSLogFilter);
25
+ //# sourceMappingURL=ios-log-filter.js.map
@@ -28,6 +28,7 @@ class IosEmulatorServices {
28
28
  try {
29
29
  if (options.platform === this.$devicePlatformsConstants.visionOS &&
30
30
  !options.emulatorIdOrName) {
31
+ // find first available visionOS simulator (for now).
31
32
  const { devices } = yield this.tryGetiOSSimDevices();
32
33
  options.emulatorIdOrName = (_a = devices.find((device) => device.platform === this.$devicePlatformsConstants.visionOS)) === null || _a === void 0 ? void 0 : _a.id;
33
34
  }
@@ -73,6 +74,8 @@ class IosEmulatorServices {
73
74
  connectToPort(data) {
74
75
  return __awaiter(this, void 0, void 0, function* () {
75
76
  try {
77
+ // node v17+ resolves localhost to ::1 (ipv6) instead of 127.0.0.1 (ipv4)
78
+ // so we explicitly pass ipv4
76
79
  const socket = net.connect(data.port, "127.0.0.1");
77
80
  return socket;
78
81
  }
@@ -137,3 +140,4 @@ class IosEmulatorServices {
137
140
  }
138
141
  }
139
142
  yok_1.injector.register("iOSEmulatorServices", IosEmulatorServices);
143
+ //# sourceMappingURL=ios-emulator-services.js.map
@@ -21,3 +21,4 @@ IOSSimResolver.iOSSimName = "ios-sim-portable";
21
21
  IOSSimResolver.iOSStandaloneExecutableName = "ios-sim-standalone.js";
22
22
  exports.IOSSimResolver = IOSSimResolver;
23
23
  yok_1.injector.register("iOSSimResolver", IOSSimResolver);
24
+ //# sourceMappingURL=ios-sim-resolver.js.map
@@ -95,9 +95,14 @@ class IOSSimulatorApplicationManager extends application_manager_base_1.Applicat
95
95
  }
96
96
  getDebuggableAppViews(appIdentifiers) {
97
97
  return __awaiter(this, void 0, void 0, function* () {
98
+ // Implement when we can find debuggable applications for iOS.
98
99
  return Promise.resolve(null);
99
100
  });
100
101
  }
102
+ // iOS will kill the app if we freeze it in the NativeScript Runtime and wait for debug-brk.
103
+ // In order to avoid that, we are attaching lldb and passing it "process continue".
104
+ // In this way, iOS will not kill the app because it has a native debugger attached
105
+ // and the users will be able to attach a debug session using the debug-brk flag.
101
106
  attachNativeDebugger(appId, pid) {
102
107
  this._lldbProcesses[appId] = this.$childProcess.spawn("lldb", ["-p", pid]);
103
108
  if (log4js.levels.TRACE.isGreaterThanOrEqualTo(this.$logger.getLevel())) {
@@ -145,3 +150,4 @@ __decorate([
145
150
  (0, decorators_1.cache)()
146
151
  ], IOSSimulatorApplicationManager.prototype, "startDeviceLog", null);
147
152
  exports.IOSSimulatorApplicationManager = IOSSimulatorApplicationManager;
153
+ //# sourceMappingURL=ios-simulator-application-manager.js.map
@@ -80,11 +80,15 @@ class IOSSimulator extends ios_device_base_1.IOSDeviceBase {
80
80
  let socket;
81
81
  const attachRequestMessage = this.$iOSNotification.getAttachRequest(appId, this.deviceInfo.identifier);
82
82
  yield this.$iOSEmulatorServices.postDarwinNotification(attachRequestMessage, this.deviceInfo.identifier);
83
+ // Retry posting the notification every five seconds, in case the AttachRequest
84
+ // event handler wasn't registered when the first one was sent
83
85
  const postNotificationRetryInterval = setInterval(() => {
84
86
  this.$iOSEmulatorServices
85
87
  .postDarwinNotification(attachRequestMessage, this.deviceInfo.identifier)
86
88
  .catch((e) => this.$logger.error(e));
87
89
  }, 5e3);
90
+ // the internal retry-mechanism of getDebuggerPort will ensure the above
91
+ // interval has a chance to execute multiple times
88
92
  const port = yield _super.getDebuggerPort.call(this, appId).finally(() => {
89
93
  clearInterval(postNotificationRetryInterval);
90
94
  });
@@ -104,3 +108,4 @@ __decorate([
104
108
  (0, decorators_1.cache)()
105
109
  ], IOSSimulator.prototype, "openDeviceLogStream", null);
106
110
  exports.IOSSimulator = IOSSimulator;
111
+ //# sourceMappingURL=ios-simulator-device.js.map
@@ -79,3 +79,4 @@ class IOSSimulatorFileSystem {
79
79
  }
80
80
  }
81
81
  exports.IOSSimulatorFileSystem = IOSSimulatorFileSystem;
82
+ //# sourceMappingURL=ios-simulator-file-system.js.map
@@ -67,3 +67,4 @@ class IOSSimulatorLogProvider extends events_1.EventEmitter {
67
67
  }
68
68
  exports.IOSSimulatorLogProvider = IOSSimulatorLogProvider;
69
69
  yok_1.injector.register("iOSSimulatorLogProvider", IOSSimulatorLogProvider);
70
+ //# sourceMappingURL=ios-simulator-log-provider.js.map
@@ -35,3 +35,4 @@ class LocalToDevicePathDataFactory {
35
35
  }
36
36
  exports.LocalToDevicePathDataFactory = LocalToDevicePathDataFactory;
37
37
  yok_1.injector.register("localToDevicePathDataFactory", LocalToDevicePathDataFactory);
38
+ //# sourceMappingURL=local-to-device-path-data-factory.js.map
@@ -24,6 +24,7 @@ class LogFilter {
24
24
  if (deviceLogFilter) {
25
25
  return deviceLogFilter.filterData(data, loggingOptions);
26
26
  }
27
+ // In case the platform is not valid, just return the data without filtering.
27
28
  return data;
28
29
  }
29
30
  getDeviceLogFilterInstance(platform) {
@@ -49,3 +50,4 @@ class LogFilter {
49
50
  }
50
51
  exports.LogFilter = LogFilter;
51
52
  yok_1.injector.register("logFilter", LogFilter);
53
+ //# sourceMappingURL=log-filter.js.map
@@ -10,3 +10,4 @@ class LoggingLevels {
10
10
  }
11
11
  exports.LoggingLevels = LoggingLevels;
12
12
  yok_1.injector.register("loggingLevels", LoggingLevels);
13
+ //# sourceMappingURL=logging-levels.js.map
@@ -54,6 +54,7 @@ class AndroidDeviceDiscovery extends device_discovery_1.DeviceDiscovery {
54
54
  checkCurrentData(result) {
55
55
  return __awaiter(this, void 0, void 0, function* () {
56
56
  const currentDevices = result.map((element) => {
57
+ // http://developer.android.com/tools/help/adb.html#devicestatus
57
58
  const data = element.split("\t");
58
59
  const identifier = data[0];
59
60
  const status = data[1];
@@ -89,3 +90,4 @@ class AndroidDeviceDiscovery extends device_discovery_1.DeviceDiscovery {
89
90
  }
90
91
  exports.AndroidDeviceDiscovery = AndroidDeviceDiscovery;
91
92
  yok_1.injector.register("androidDeviceDiscovery", AndroidDeviceDiscovery);
93
+ //# sourceMappingURL=android-device-discovery.js.map
@@ -31,9 +31,11 @@ class AndroidEmulatorDiscovery extends events_1.EventEmitter {
31
31
  const availableEmulatorsOutput = yield this.$androidEmulatorServices.getEmulatorImages();
32
32
  const currentEmulators = availableEmulatorsOutput.devices;
33
33
  const cachedEmulators = _.values(this._emulators);
34
+ // Remove old emulators
34
35
  const lostEmulators = _(cachedEmulators)
35
36
  .reject((e) => _.some(currentEmulators, (emulator) => emulator && e && emulator.imageIdentifier === e.imageIdentifier))
36
37
  .value();
38
+ // Add new emulators
37
39
  const foundEmulators = _(currentEmulators)
38
40
  .reject((e) => _.some(cachedEmulators, (emulator) => emulator && e && emulator.imageIdentifier === e.imageIdentifier))
39
41
  .value();
@@ -63,3 +65,4 @@ class AndroidEmulatorDiscovery extends events_1.EventEmitter {
63
65
  }
64
66
  exports.AndroidEmulatorDiscovery = AndroidEmulatorDiscovery;
65
67
  yok_1.injector.register("androidEmulatorDiscovery", AndroidEmulatorDiscovery);
68
+ //# sourceMappingURL=android-emulator-discovery.js.map
@@ -87,6 +87,19 @@ class AndroidProcessService {
87
87
  return __awaiter(this, void 0, void 0, function* () {
88
88
  const adb = this.getAdb(deviceIdentifier);
89
89
  const androidWebViewPortInformation = (yield this.getAbstractPortsInformation(adb)).split(os_1.EOL);
90
+ // TODO: Add tests and make sure only unique names are returned. Input before groupBy is:
91
+ // [ { deviceIdentifier: 'SH26BW100473',
92
+ // appIdentifier: 'com.telerik.EmptyNS',
93
+ // framework: 'NativeScript' },
94
+ // { deviceIdentifier: 'SH26BW100473',
95
+ // appIdentifier: 'com.telerik.EmptyNS',
96
+ // framework: 'Cordova' },
97
+ // { deviceIdentifier: 'SH26BW100473',
98
+ // appIdentifier: 'chrome',
99
+ // framework: 'Cordova' },
100
+ // { deviceIdentifier: 'SH26BW100473',
101
+ // appIdentifier: 'chrome',
102
+ // framework: 'Cordova' } ]
90
103
  const portInformation = yield Promise.all(_.map(androidWebViewPortInformation, (line) => __awaiter(this, void 0, void 0, function* () {
91
104
  return (yield this.getApplicationInfoFromWebViewPortInformation(adb, deviceIdentifier, line)) ||
92
105
  (yield this.getNativeScriptApplicationInformation(adb, deviceIdentifier, line));
@@ -135,6 +148,7 @@ class AndroidProcessService {
135
148
  }
136
149
  getApplicationInfoFromWebViewPortInformation(adb, deviceIdentifier, information) {
137
150
  return __awaiter(this, void 0, void 0, function* () {
151
+ // Need to search by processId to check for old Android webviews (@webview_devtools_remote_<processId>).
138
152
  const processIdRegExp = /@webview_devtools_remote_(.+)/g;
139
153
  const processIdMatches = processIdRegExp.exec(information);
140
154
  let cordovaAppIdentifier;
@@ -143,6 +157,7 @@ class AndroidProcessService {
143
157
  cordovaAppIdentifier = yield this.getApplicationIdentifierFromPid(adb, processId);
144
158
  }
145
159
  else {
160
+ // Search for appIdentifier (@<appIdentifier>_devtools_remote).
146
161
  const chromeAppIdentifierRegExp = /@(.+)_devtools_remote\s?/g;
147
162
  const chromeAppIdentifierMatches = chromeAppIdentifierRegExp.exec(information);
148
163
  if (chromeAppIdentifierMatches && chromeAppIdentifierMatches.length > 0) {
@@ -161,6 +176,7 @@ class AndroidProcessService {
161
176
  }
162
177
  getNativeScriptApplicationInformation(adb, deviceIdentifier, information) {
163
178
  return __awaiter(this, void 0, void 0, function* () {
179
+ // Search for appIdentifier (@<appIdentifier-debug>).
164
180
  const nativeScriptAppIdentifierRegExp = /@(.+)-(debug|inspectorServer)/g;
165
181
  const nativeScriptAppIdentifierMatches = nativeScriptAppIdentifierRegExp.exec(information);
166
182
  if (nativeScriptAppIdentifierMatches &&
@@ -177,6 +193,10 @@ class AndroidProcessService {
177
193
  }
178
194
  getAbstractPortForApplication(adb, processId, appIdentifier, abstractPortsInformation, framework) {
179
195
  return __awaiter(this, void 0, void 0, function* () {
196
+ // The result will look like this (without the columns names):
197
+ // Num RefCount Protocol Flags Type St Inode Path
198
+ // 0000000000000000: 00000002 00000000 00010000 0001 01 189004 @webview_devtools_remote_25512
199
+ // The Path column is the abstract port.
180
200
  framework = framework || "";
181
201
  switch (framework.toLowerCase()) {
182
202
  case constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase():
@@ -207,6 +227,9 @@ class AndroidProcessService {
207
227
  }
208
228
  getProcessIds(adb, appIdentifiers) {
209
229
  return __awaiter(this, void 0, void 0, function* () {
230
+ // Process information will look like this (without the columns names):
231
+ // USER PID PPID VSIZE RSS WCHAN PC NAME
232
+ // u0_a63 25512 1334 1519560 96040 ffffffff f76a8f75 S com.telerik.appbuildertabstest
210
233
  const result = {};
211
234
  const processIdInformation = yield adb.executeShellCommand(["ps"]);
212
235
  _.each(appIdentifiers, (appIdentifier) => {
@@ -219,6 +242,11 @@ class AndroidProcessService {
219
242
  getAlreadyMappedPort(adb, deviceIdentifier, abstractPort, adbForwardList) {
220
243
  return __awaiter(this, void 0, void 0, function* () {
221
244
  const allForwardedPorts = adbForwardList || (yield adb.executeCommand(["forward", "--list"])) || "";
245
+ // Sample output:
246
+ // 5e2e580b tcp:62503 localabstract:webview_devtools_remote_7985
247
+ // 5e2e580b tcp:62524 localabstract:webview_devtools_remote_7986
248
+ // 5e2e580b tcp:63160 localabstract:webview_devtools_remote_7987
249
+ // 5e2e580b tcp:57577 localabstract:com.telerik.nrel-debug
222
250
  const regex = new RegExp(`${deviceIdentifier}\\s+?tcp:(\\d+?)\\s+?.*?${abstractPort}$`);
223
251
  return this.getFirstMatchingGroupFromMultilineResult(allForwardedPorts, regex);
224
252
  });
@@ -234,6 +262,9 @@ class AndroidProcessService {
234
262
  getApplicationIdentifierFromPid(adb, pid, psData) {
235
263
  return __awaiter(this, void 0, void 0, function* () {
236
264
  psData = psData || (yield adb.executeShellCommand(["ps"]));
265
+ // Process information will look like this (without the columns names):
266
+ // USER PID PPID VSIZE RSS WCHAN PC NAME
267
+ // u0_a63 25512 1334 1519560 96040 ffffffff f76a8f75 S com.telerik.appbuildertabstest
237
268
  return this.getFirstMatchingGroupFromMultilineResult(psData, new RegExp(`\\s+${pid}(?:\\s+\\d+){3}\\s+.*\\s+(.*?)$`));
238
269
  });
239
270
  }
@@ -257,3 +288,4 @@ __decorate([
257
288
  ], AndroidProcessService.prototype, "getAppProcessId", null);
258
289
  exports.AndroidProcessService = AndroidProcessService;
259
290
  yok_1.injector.register("androidProcessService", AndroidProcessService);
291
+ //# sourceMappingURL=android-process-service.js.map
@@ -62,3 +62,4 @@ class DeviceDiscovery extends events_1.EventEmitter {
62
62
  }
63
63
  exports.DeviceDiscovery = DeviceDiscovery;
64
64
  yok_1.injector.register("deviceDiscovery", DeviceDiscovery);
65
+ //# sourceMappingURL=device-discovery.js.map
@@ -72,6 +72,7 @@ class DevicesService extends events_1.EventEmitter {
72
72
  const device = yield this.getDevice(options.deviceId);
73
73
  return device;
74
74
  }
75
+ // Now let's take data for each device:
75
76
  const availableDevicesAndEmulators = this.getDeviceInstances().filter((d) => d.deviceInfo.status === constants_2.CONNECTED_STATUS &&
76
77
  (!this.platform ||
77
78
  d.deviceInfo.platform.toLowerCase() === this.platform.toLowerCase()));
@@ -94,6 +95,8 @@ class DevicesService extends events_1.EventEmitter {
94
95
  const devices = sortedInstances.filter((d) => !d.isEmulator);
95
96
  let selectedInstance;
96
97
  if (options.onlyEmulators || options.onlyDevices) {
98
+ // When --emulator or --forDevice is passed, the instances are already filtered
99
+ // So we are sure we have exactly the type we need and we can safely return the last one (highest OS version).
97
100
  selectedInstance = _.last(sortedInstances);
98
101
  }
99
102
  else {
@@ -156,6 +159,7 @@ class DevicesService extends events_1.EventEmitter {
156
159
  ...additionalErrors,
157
160
  ];
158
161
  }
162
+ // emulator is already running
159
163
  if (emulator.status === constants.RUNNING_EMULATOR_STATUS) {
160
164
  return null;
161
165
  }
@@ -188,9 +192,11 @@ class DevicesService extends events_1.EventEmitter {
188
192
  return !!(this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform) &&
189
193
  device.isEmulator);
190
194
  }
195
+ /* tslint:disable:no-unused-variable */
191
196
  setLogLevel(logLevel, deviceIdentifier) {
192
197
  this.$deviceLogProvider.setLogLevel(logLevel, deviceIdentifier);
193
198
  }
199
+ /* tslint:enable:no-unused-variable */
194
200
  isAppInstalledOnDevices(deviceIdentifiers, appId, projectName, projectDir) {
195
201
  this.$logger.trace(`Called isInstalledOnDevices for identifiers ${deviceIdentifiers}. AppIdentifier is ${appId}.`);
196
202
  return _.map(deviceIdentifiers, (deviceIdentifier) => this.isApplicationInstalledOnDevice(deviceIdentifier, {
@@ -264,6 +270,9 @@ class DevicesService extends events_1.EventEmitter {
264
270
  delete this._availableEmulators[emulator.imageIdentifier];
265
271
  this.emit(constants.EmulatorDiscoveryNames.EMULATOR_IMAGE_LOST, emulator);
266
272
  }
273
+ /**
274
+ * Starts looking for devices. Any found devices are pushed to "_devices" variable.
275
+ */
267
276
  detectCurrentlyAttachedDevices(deviceInitOpts) {
268
277
  return __awaiter(this, void 0, void 0, function* () {
269
278
  const options = this.getDeviceLookingOptions(deviceInitOpts);
@@ -336,6 +345,11 @@ class DevicesService extends events_1.EventEmitter {
336
345
  clearInterval(this.emulatorDetectionInterval);
337
346
  }
338
347
  }
348
+ /**
349
+ * Returns device that matches an identifier.
350
+ * The identifier is expected to be the same as the running device declares it (emulator-5554 for android or GUID for ios).
351
+ * @param identifier running emulator or device identifier
352
+ */
339
353
  getDeviceByIdentifier(identifier) {
340
354
  const searchedDevice = _.find(this.getDeviceInstances(), (device) => {
341
355
  if (this.$mobileHelper.isApplePlatform(device.deviceInfo.platform) &&
@@ -351,6 +365,9 @@ class DevicesService extends events_1.EventEmitter {
351
365
  }
352
366
  return searchedDevice;
353
367
  }
368
+ /**
369
+ * Starts looking for running devices. All found devices are pushed to _devices variable.
370
+ */
354
371
  startLookingForDevices(deviceInitOpts) {
355
372
  return __awaiter(this, void 0, void 0, function* () {
356
373
  this.$logger.trace("startLookingForDevices; platform is %s", this._platform);
@@ -362,10 +379,20 @@ class DevicesService extends events_1.EventEmitter {
362
379
  yield this.startDeviceDetectionInterval(deviceInitOpts);
363
380
  });
364
381
  }
382
+ /**
383
+ * Returns device depending on the passed index.
384
+ * The index refers to assigned number to listed devices by tns device command.
385
+ * @param index assigned device number
386
+ */
365
387
  getDeviceByIndex(index) {
366
388
  this.validateIndex(index - 1);
367
389
  return this.getDeviceInstances()[index - 1];
368
390
  }
391
+ /**
392
+ * Returns running device for specified --device <DeviceId>.
393
+ * Method expects running devices.
394
+ * @param deviceOption parameter passed by the user to --device flag. Can be name, identifier or imageIdentifier.
395
+ */
369
396
  getDevice(deviceOption) {
370
397
  return __awaiter(this, void 0, void 0, function* () {
371
398
  let device = null;
@@ -387,6 +414,11 @@ class DevicesService extends events_1.EventEmitter {
387
414
  return device;
388
415
  });
389
416
  }
417
+ /**
418
+ * Method runs action for a --device (value), specified by the user.
419
+ * @param action action to be executed if canExecute returns true
420
+ * @param canExecute predicate to decide whether the command can be ran
421
+ */
390
422
  executeOnDevice(action, canExecute) {
391
423
  return __awaiter(this, void 0, void 0, function* () {
392
424
  if (!canExecute || canExecute(this._device)) {
@@ -397,6 +429,11 @@ class DevicesService extends events_1.EventEmitter {
397
429
  }
398
430
  });
399
431
  }
432
+ /**
433
+ * Executes passed action for each found device.
434
+ * @param action action to be executed if canExecute returns true
435
+ * @param canExecute predicate to decide whether the command can be ran
436
+ */
400
437
  executeOnAllConnectedDevices(action, canExecute) {
401
438
  return __awaiter(this, void 0, void 0, function* () {
402
439
  const devices = this.filterDevicesByPlatform();
@@ -450,6 +487,12 @@ class DevicesService extends events_1.EventEmitter {
450
487
  });
451
488
  }));
452
489
  }
490
+ /**
491
+ * Runs the passed action if the predicate "canExecute" returns true
492
+ * @param action action to be executed if canExecute returns true.
493
+ * @param canExecute predicate to decide whether the command can be ran
494
+ * @param options all possible options that can be passed to the command.
495
+ */
453
496
  execute(action, canExecute, options) {
454
497
  return __awaiter(this, void 0, void 0, function* () {
455
498
  assert.ok(this._isInitialized, "Devices services not initialized!");
@@ -459,6 +502,7 @@ class DevicesService extends events_1.EventEmitter {
459
502
  this.$mobileHelper.isiOSPlatform(this._platform) &&
460
503
  this.$options.emulator &&
461
504
  !this.isOnlyiOSSimultorRunning()) {
505
+ // Executes the command only on iOS simulator
462
506
  const originalCanExecute = canExecute;
463
507
  canExecute = (dev) => this.isiOSSimulator(dev) &&
464
508
  (!originalCanExecute || !!originalCanExecute(dev));
@@ -483,6 +527,11 @@ class DevicesService extends events_1.EventEmitter {
483
527
  }
484
528
  });
485
529
  }
530
+ /**
531
+ * Starts emulator or simulator if necessary depending on --device or --emulator flags.
532
+ * If no options are passed runs default emulator/simulator if no devices are connected.
533
+ * @param deviceInitOpts mainly contains information about --emulator and --deviceId flags.
534
+ */
486
535
  startEmulatorIfNecessary(deviceInitOpts) {
487
536
  return __awaiter(this, void 0, void 0, function* () {
488
537
  if (deviceInitOpts && deviceInitOpts.deviceId && deviceInitOpts.emulator) {
@@ -492,6 +541,7 @@ class DevicesService extends events_1.EventEmitter {
492
541
  if (deviceInitOpts &&
493
542
  deviceInitOpts.platform &&
494
543
  !deviceInitOpts.skipEmulatorStart) {
544
+ // are there any running devices
495
545
  this._platform = deviceInitOpts.platform;
496
546
  try {
497
547
  yield this.startLookingForDevices(deviceInitOpts);
@@ -519,9 +569,11 @@ class DevicesService extends events_1.EventEmitter {
519
569
  _startEmulatorIfNecessary(data) {
520
570
  return __awaiter(this, void 0, void 0, function* () {
521
571
  const deviceInstances = this.getDeviceInstances();
572
+ //if no --device is passed and no devices are found, the default emulator is started
522
573
  if (!data.deviceId && _.isEmpty(deviceInstances)) {
523
574
  return this.startEmulatorCore(data);
524
575
  }
576
+ //check if --device(value) is running, if it's not or it's not the same as is specified, start with name from --device(value)
525
577
  if (data.deviceId) {
526
578
  if (!helpers.isNumberWithoutExponent(data.deviceId)) {
527
579
  const activeDeviceInstance = _.find(deviceInstances, (device) => device.deviceInfo.identifier === data.deviceId);
@@ -530,6 +582,7 @@ class DevicesService extends events_1.EventEmitter {
530
582
  }
531
583
  }
532
584
  }
585
+ // make sure if the target platform is visionOS we don't try to run it on an already running iOS simulator...
533
586
  if (data.platform === this.$devicePlatformsConstants.visionOS &&
534
587
  deviceInstances.length) {
535
588
  const runningDeviceInstance = deviceInstances.find((device) => device.deviceInfo.platform === this.$devicePlatformsConstants.visionOS);
@@ -537,6 +590,7 @@ class DevicesService extends events_1.EventEmitter {
537
590
  return this.startEmulatorCore(data);
538
591
  }
539
592
  }
593
+ // if only emulator flag is passed and no other emulators are running, start default emulator
540
594
  if (data.emulator && deviceInstances.length) {
541
595
  const runningDeviceInstance = _.some(deviceInstances, (value) => value.isEmulator);
542
596
  if (!runningDeviceInstance) {
@@ -545,6 +599,12 @@ class DevicesService extends events_1.EventEmitter {
545
599
  }
546
600
  });
547
601
  }
602
+ /**
603
+ * Takes care of gathering information about all running devices.
604
+ * Sets "_isInitialized" to true after infomation is present.
605
+ * Method expects running devices.
606
+ * @param data mainly contains information about --emulator and --deviceId flags.
607
+ */
548
608
  initialize(data) {
549
609
  return __awaiter(this, void 0, void 0, function* () {
550
610
  if (!this._deviceInitializePromise) {
@@ -554,6 +614,7 @@ class DevicesService extends events_1.EventEmitter {
554
614
  yield this._deviceInitializePromise;
555
615
  }
556
616
  catch (err) {
617
+ // In case the initalization fails, we want to allow calling `initlialize` again with other arguments for example, so remove the cached promise value.
557
618
  this.$logger.trace(`Error while initializing devicesService: ${err}`);
558
619
  this._deviceInitializePromise = null;
559
620
  throw err;
@@ -579,6 +640,7 @@ class DevicesService extends events_1.EventEmitter {
579
640
  deviceInitOpts = deviceInitOpts || {};
580
641
  this._data = deviceInitOpts;
581
642
  if (!deviceInitOpts.skipEmulatorStart) {
643
+ // TODO: Remove from here as it calls startLookingForDevices, so we double the calls to specific device detection services
582
644
  yield this.startEmulatorIfNecessary(deviceInitOpts);
583
645
  }
584
646
  const platform = deviceInitOpts.platform;
@@ -609,6 +671,7 @@ class DevicesService extends events_1.EventEmitter {
609
671
  yield this.startLookingForDevices(deviceLookingOptions);
610
672
  }
611
673
  else {
674
+ // platform and deviceId are not specified
612
675
  if (deviceInitOpts.skipInferPlatform) {
613
676
  if (deviceInitOpts.skipDeviceDetectionInterval) {
614
677
  yield this.detectCurrentlyAttachedDevices(deviceLookingOptions);
@@ -723,6 +786,11 @@ class DevicesService extends events_1.EventEmitter {
723
786
  }
724
787
  return null;
725
788
  }
789
+ /**
790
+ * Starts emulator for platform and makes sure started devices/emulators/simulators are in _devices array before finishing.
791
+ * @param platform (optional) platform to start emulator/simulator for
792
+ * @param emulatorIdOrName (optional) emulator/simulator image identifier or name
793
+ */
726
794
  startEmulatorCore(deviceInitOpts = {}) {
727
795
  return __awaiter(this, void 0, void 0, function* () {
728
796
  const { deviceId } = deviceInitOpts;
@@ -852,3 +920,4 @@ __decorate([
852
920
  ], DevicesService.prototype, "getDebuggableViews", null);
853
921
  exports.DevicesService = DevicesService;
854
922
  yok_1.injector.register("devicesService", DevicesService);
923
+ //# sourceMappingURL=devices-service.js.map