nativescript 9.0.0-alpha.2 → 9.0.0-alpha.3

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 (326) hide show
  1. package/lib/android-tools-info.js +12 -0
  2. package/lib/base-package-manager.js +7 -0
  3. package/lib/bootstrap.js +5 -1
  4. package/lib/bun-package-manager.js +14 -1
  5. package/lib/color.js +3 -0
  6. package/lib/commands/add-platform.js +1 -0
  7. package/lib/commands/apple-login.js +1 -0
  8. package/lib/commands/appstore-list.js +1 -0
  9. package/lib/commands/appstore-upload.js +3 -0
  10. package/lib/commands/build.js +3 -2
  11. package/lib/commands/clean.js +22 -1
  12. package/lib/commands/command-base.js +1 -0
  13. package/lib/commands/config.js +4 -0
  14. package/lib/commands/create-project.js +6 -0
  15. package/lib/commands/debug.js +6 -1
  16. package/lib/commands/deploy.js +3 -2
  17. package/lib/commands/embedding/embed.js +7 -0
  18. package/lib/commands/extensibility/install-extension.js +1 -0
  19. package/lib/commands/extensibility/list-extensions.js +1 -0
  20. package/lib/commands/extensibility/uninstall-extension.js +1 -0
  21. package/lib/commands/fonts.js +1 -0
  22. package/lib/commands/generate-assets.js +1 -0
  23. package/lib/commands/generate-help.js +1 -0
  24. package/lib/commands/generate.js +48 -1
  25. package/lib/commands/info.js +1 -0
  26. package/lib/commands/install.js +1 -0
  27. package/lib/commands/list-platforms.js +1 -0
  28. package/lib/commands/migrate.js +1 -0
  29. package/lib/commands/native-add.js +5 -0
  30. package/lib/commands/platform-clean.js +1 -0
  31. package/lib/commands/plugin/add-plugin.js +1 -0
  32. package/lib/commands/plugin/build-plugin.js +1 -0
  33. package/lib/commands/plugin/create-plugin.js +5 -0
  34. package/lib/commands/plugin/list-plugins.js +1 -0
  35. package/lib/commands/plugin/remove-plugin.js +2 -0
  36. package/lib/commands/plugin/update-plugin.js +1 -0
  37. package/lib/commands/post-install.js +6 -0
  38. package/lib/commands/prepare.js +4 -3
  39. package/lib/commands/preview.js +2 -0
  40. package/lib/commands/remove-platform.js +1 -0
  41. package/lib/commands/resources/resources-update.js +2 -0
  42. package/lib/commands/run.js +1 -0
  43. package/lib/commands/setup.js +1 -0
  44. package/lib/commands/start.js +1 -0
  45. package/lib/commands/test-init.js +4 -0
  46. package/lib/commands/test.js +9 -2
  47. package/lib/commands/typings.js +2 -1
  48. package/lib/commands/update-platform.js +5 -0
  49. package/lib/commands/update.js +2 -0
  50. package/lib/commands/widget.js +20 -1
  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 +11 -8
  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 +26 -0
  103. package/lib/common/mobile/android/device-android-debug-bridge.js +1 -0
  104. package/lib/common/mobile/android/genymotion/genymotion-service.js +6 -1
  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 +90 -4
  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 +144 -119
  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 +1 -0
  228. package/lib/services/android-device-debug-service.js +6 -0
  229. package/lib/services/android-plugin-build-service.js +31 -2
  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/apple-portal/srp/srp-wrapper.js +4 -1
  236. package/lib/services/assets-generation/assets-generation-service.js +10 -5
  237. package/lib/services/build-artifacts-service.js +2 -1
  238. package/lib/services/build-data-service.js +1 -0
  239. package/lib/services/build-info-file-service.js +1 -0
  240. package/lib/services/bundler/bundler-compiler-service.js +45 -1
  241. package/lib/services/bundler/bundler.js +1 -0
  242. package/lib/services/cleanup-service.js +13 -9
  243. package/lib/services/cocoapods-platform-manager.js +9 -0
  244. package/lib/services/cocoapods-service.js +21 -1
  245. package/lib/services/debug-data-service.js +1 -0
  246. package/lib/services/debug-service-base.js +7 -0
  247. package/lib/services/device/device-install-app-service.js +2 -1
  248. package/lib/services/doctor-service.js +21 -6
  249. package/lib/services/extensibility-service.js +8 -0
  250. package/lib/services/files-hash-service.js +1 -0
  251. package/lib/services/hmr-status-service.js +2 -0
  252. package/lib/services/info-service.js +1 -0
  253. package/lib/services/initialize-service.js +5 -1
  254. package/lib/services/ios/export-options-plist-service.js +4 -0
  255. package/lib/services/ios/ios-signing-service.js +4 -0
  256. package/lib/services/ios/spm-service.js +11 -0
  257. package/lib/services/ios/xcodebuild-args-service.js +9 -0
  258. package/lib/services/ios/xcodebuild-command-service.js +1 -0
  259. package/lib/services/ios/xcodebuild-service.js +2 -1
  260. package/lib/services/ios-debugger-port-service.js +1 -0
  261. package/lib/services/ios-device-debug-service.js +1 -0
  262. package/lib/services/ios-entitlements-service.js +1 -0
  263. package/lib/services/ios-extensions-service.js +1 -0
  264. package/lib/services/ios-log-filter.js +20 -0
  265. package/lib/services/ios-native-target-service.js +6 -4
  266. package/lib/services/ios-project-service.js +91 -1
  267. package/lib/services/ios-provision-service.js +3 -0
  268. package/lib/services/ios-watch-app-service.js +1 -0
  269. package/lib/services/ip-service.js +2 -0
  270. package/lib/services/itmstransporter-service.js +1 -0
  271. package/lib/services/karma-execution.js +2 -0
  272. package/lib/services/livesync/android-device-livesync-service-base.js +1 -0
  273. package/lib/services/livesync/android-device-livesync-service.js +2 -0
  274. package/lib/services/livesync/android-device-livesync-sockets-service.js +3 -0
  275. package/lib/services/livesync/android-livesync-service.js +1 -0
  276. package/lib/services/livesync/android-livesync-tool.js +4 -0
  277. package/lib/services/livesync/device-livesync-service-base.js +2 -0
  278. package/lib/services/livesync/ios-device-livesync-service.js +7 -0
  279. package/lib/services/livesync/ios-livesync-service.js +2 -0
  280. package/lib/services/livesync/livesync-socket.js +1 -0
  281. package/lib/services/livesync/platform-livesync-service-base.js +5 -0
  282. package/lib/services/livesync-process-data-service.js +1 -0
  283. package/lib/services/log-parser-service.js +1 -0
  284. package/lib/services/log-source-map-service.js +15 -0
  285. package/lib/services/marking-mode-service.js +8 -5
  286. package/lib/services/metadata-filtering-service.js +1 -0
  287. package/lib/services/npm-config-service.js +4 -0
  288. package/lib/services/pacote-service.js +7 -0
  289. package/lib/services/performance-service.js +3 -1
  290. package/lib/services/platform/add-platform-service.js +49 -2
  291. package/lib/services/platform/platform-validation-service.js +1 -0
  292. package/lib/services/platform/prepare-native-platform-service.js +5 -2
  293. package/lib/services/platform-environment-requirements.js +8 -3
  294. package/lib/services/platform-project-service-base.js +1 -0
  295. package/lib/services/platforms-data-service.js +1 -0
  296. package/lib/services/plugins-service.js +20 -2
  297. package/lib/services/prepare-data-service.js +1 -0
  298. package/lib/services/project-backup-service.js +4 -0
  299. package/lib/services/project-changes-service.js +14 -3
  300. package/lib/services/project-cleanup-service.js +2 -0
  301. package/lib/services/project-config-service.js +21 -2
  302. package/lib/services/project-data-service.js +36 -7
  303. package/lib/services/project-name-service.js +1 -0
  304. package/lib/services/project-service.js +10 -0
  305. package/lib/services/project-templates-service.js +3 -2
  306. package/lib/services/qr-code-terminal-service.js +1 -0
  307. package/lib/services/require-service.js +1 -0
  308. package/lib/services/start-service.js +1 -0
  309. package/lib/services/temp-service.js +1 -0
  310. package/lib/services/terminal-spinner-service.js +2 -0
  311. package/lib/services/test-execution-service.js +9 -2
  312. package/lib/services/test-initialization-service.js +4 -0
  313. package/lib/services/timeline-profiler-service.js +1 -0
  314. package/lib/services/user-settings-service.js +1 -0
  315. package/lib/services/versions-service.js +6 -4
  316. package/lib/services/watch-ignore-list-service.js +1 -0
  317. package/lib/services/xcconfig-service.js +2 -0
  318. package/lib/services/xcproj-service.js +1 -0
  319. package/lib/shared-event-bus.js +6 -0
  320. package/lib/sys-info.js +2 -1
  321. package/lib/tools/config-manipulation/config-transformer.js +12 -0
  322. package/lib/tools/node-modules/node-modules-builder.js +1 -0
  323. package/lib/tools/node-modules/node-modules-dependencies-builder.js +6 -0
  324. package/lib/yarn-package-manager.js +1 -0
  325. package/lib/yarn2-package-manager.js +3 -0
  326. package/package.json +6 -4
@@ -18,7 +18,40 @@ const constants_1 = require("../common/constants");
18
18
  const helpers_1 = require("../common/helpers");
19
19
  const decorators_1 = require(".././common/decorators");
20
20
  const yok_1 = require("../common/yok");
21
- function topologicalSortNativeDependencies(dependencies, start = [], depth = 0, total = 0) {
21
+ //
22
+ // we sort the native dependencies topologically to make sure they are processed in the right order
23
+ // native dependenciess need to be sorted so the deepst dependencies are built before it's parents
24
+ //
25
+ // for example, given this dep structure (assuming these are all native dependencies that need to be built)
26
+ // (note: we list all dependencies at the root level, so the leaf nodes are essentially references to the root nodes)
27
+ //
28
+ // |- dep1
29
+ // |- dep2
30
+ // |- |- dep3
31
+ // |- |- dep4
32
+ // |- |- |- dep5
33
+ // |- dep3
34
+ // |- dep4
35
+ // |- |- dep5
36
+ // |- dep5
37
+ //
38
+ // It is sorted:
39
+ //
40
+ // |- dep1
41
+ // |- dep3
42
+ // |- dep5
43
+ // |- dep4 # depends on dep5, so dep5 must be built first, ie above ^
44
+ // |- |- dep5
45
+ // |- dep2 # depends on dep3, dep4 (and dep5 through dep4) so all of them must be built first before dep2 is built
46
+ // |- |- dep3
47
+ // |- |- dep4
48
+ // |- |- |- dep5
49
+ //
50
+ // for more details see: https://wikiless.org/wiki/Topological_sorting?lang=en
51
+ //
52
+ function topologicalSortNativeDependencies(dependencies, start = [], depth = 0, total = 0 // do not pass in, we calculate it in the initial run!
53
+ ) {
54
+ // we set the total on the initial call - and never increment it, as it's used for esacaping the recursion
22
55
  if (total === 0) {
23
56
  total = dependencies.length;
24
57
  }
@@ -32,6 +65,8 @@ function topologicalSortNativeDependencies(dependencies, start = [], depth = 0,
32
65
  return sortedDeps;
33
66
  }, start);
34
67
  const remainingDeps = dependencies.filter((nativeDep) => !sortedDeps.includes(nativeDep));
68
+ // recurse if we still have remaining deps
69
+ // the second condition here prevents infinite recursion
35
70
  if (remainingDeps.length && sortedDeps.length < total) {
36
71
  return topologicalSortNativeDependencies(remainingDeps, sortedDeps, depth + 1, total);
37
72
  }
@@ -85,7 +120,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
85
120
  constants.APK_DIR,
86
121
  ];
87
122
  const packageName = this.getProjectNameFromId(projectData);
88
- const runtimePackage = this.$projectDataService.getRuntimePackage(projectData.projectDir, "android");
123
+ const runtimePackage = this.$projectDataService.getRuntimePackage(projectData.projectDir, "android" /* constants.PlatformTypes.android */);
89
124
  this._platformData = {
90
125
  frameworkPackageName: runtimePackage.name,
91
126
  normalizedPlatformName: "Android",
@@ -126,7 +161,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
126
161
  configurationFileName: constants.MANIFEST_FILE_NAME,
127
162
  configurationFilePath: path.join(...configurationsDirectoryArr),
128
163
  relativeToFrameworkConfigurationFilePath: path.join(constants.SRC_DIR, constants.MAIN_DIR, constants.MANIFEST_FILE_NAME),
129
- fastLivesyncFileExtensions: [".jpg", ".gif", ".png", ".bmp", ".webp"],
164
+ fastLivesyncFileExtensions: [".jpg", ".gif", ".png", ".bmp", ".webp"], // http://developer.android.com/guide/appendix/media-formats.html
130
165
  };
131
166
  }
132
167
  return this._platformData;
@@ -176,6 +211,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
176
211
  const targetSdkVersion = androidToolsInfo && androidToolsInfo.targetSdkVersion;
177
212
  this.$logger.trace(`Using Android SDK '${targetSdkVersion}'.`);
178
213
  this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "*", "-R");
214
+ // TODO: Check if we actually need this and if it should be targetSdk or compileSdk
179
215
  this.cleanResValues(targetSdkVersion, projectData);
180
216
  }
181
217
  getResDestinationDir(projectData) {
@@ -207,6 +243,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
207
243
  _.map(directoriesToClean, (dir) => this.$fs.deleteDirectory(dir));
208
244
  }
209
245
  async interpolateData(projectData) {
246
+ // Interpolate the apilevel and package
210
247
  this.interpolateConfigurationFile(projectData);
211
248
  const appResourcesDirectoryPath = projectData.getAppResourcesDirectoryPath();
212
249
  let stringsFilePath;
@@ -222,8 +259,10 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
222
259
  const gradleSettingsFilePath = path.join(this.getPlatformData(projectData).projectRoot, "settings.gradle");
223
260
  shell.sed("-i", /__PROJECT_NAME__/, this.getProjectNameFromId(projectData), gradleSettingsFilePath);
224
261
  try {
262
+ // will replace applicationId in app/App_Resources/Android/app.gradle if it has not been edited by the user
225
263
  const appGradleContent = this.$fs.readText(projectData.appGradlePath);
226
264
  if (appGradleContent.indexOf(constants.PACKAGE_PLACEHOLDER_NAME) !== -1) {
265
+ //TODO: For compatibility with old templates. Once all templates are updated should delete.
227
266
  shell.sed("-i", new RegExp(constants.PACKAGE_PLACEHOLDER_NAME), projectData.projectIdentifiers.android, projectData.appGradlePath);
228
267
  }
229
268
  }
@@ -274,6 +313,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
274
313
  return [".jar", ".dat"];
275
314
  }
276
315
  async prepareProject() {
316
+ // Intentionally left empty.
277
317
  }
278
318
  ensureConfigurationFileInAppResources(projectData) {
279
319
  const appResourcesDirectoryPath = projectData.appResourcesDirectoryPath;
@@ -290,6 +330,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
290
330
  this.$logger.warn("No manifest found in " + originalAndroidManifestFilePath);
291
331
  return;
292
332
  }
333
+ // Overwrite the AndroidManifest from runtime.
293
334
  if (!appResourcesDirStructureHasMigrated) {
294
335
  this.$fs.copyFile(originalAndroidManifestFilePath, this.getPlatformData(projectData).configurationFilePath);
295
336
  }
@@ -306,6 +347,8 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
306
347
  }
307
348
  else {
308
349
  this.$fs.copyFile(path.join(projectAppResourcesPath, platformData.normalizedPlatformName, "*"), platformsAppResourcesPath);
350
+ // https://github.com/NativeScript/android-runtime/issues/899
351
+ // App_Resources/Android/libs is reserved to user's aars and jars, but they should not be copied as resources
309
352
  this.$fs.deleteDirectory(path.join(platformsAppResourcesPath, "libs"));
310
353
  }
311
354
  const androidToolsInfo = this.$androidToolsInfo.getToolsInfo({
@@ -315,6 +358,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
315
358
  this.cleanResValues(compileSdkVersion, projectData);
316
359
  }
317
360
  async preparePluginNativeCode(pluginData, projectData) {
361
+ // build Android plugins which contain AndroidManifest.xml and/or resources
318
362
  const pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath(pluginData, AndroidProjectService.ANDROID_PLATFORM_NAME);
319
363
  if (this.$fs.exists(pluginPlatformsFolderPath)) {
320
364
  const options = {
@@ -336,6 +380,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
336
380
  return;
337
381
  }
338
382
  async removePluginNativeCode(pluginData, projectData) {
383
+ // not implemented
339
384
  }
340
385
  async beforePrepareAllPlugins(projectData, dependencies) {
341
386
  if (dependencies) {
@@ -349,6 +394,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
349
394
  filterUniqueDependencies(dependencies) {
350
395
  const depsDictionary = dependencies.reduce((dict, dep) => {
351
396
  const collision = dict[dep.name];
397
+ // in case there are multiple dependencies to the same module, the one declared in the package.json takes precedence
352
398
  if (!collision || collision.depth > dep.depth) {
353
399
  dict[dep.name] = dep;
354
400
  }
@@ -367,6 +413,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
367
413
  name,
368
414
  directory: path.relative(platformDir, directory),
369
415
  dependencies: dependencies.filter((dep) => {
416
+ // filter out transient dependencies that don't have native dependencies
370
417
  return (nativeDependencyData.findIndex((nativeDep) => nativeDep.name === dep) !== -1);
371
418
  }),
372
419
  };
@@ -374,6 +421,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
374
421
  nativeDependencies = topologicalSortNativeDependencies(nativeDependencies);
375
422
  const jsonContent = JSON.stringify(nativeDependencies, null, 4);
376
423
  this.$fs.writeFile(dependenciesJsonPath, jsonContent);
424
+ // we sort all the dependencies to respect the topological sorting of the native dependencies
377
425
  return dependencies.sort(function (a, b) {
378
426
  return (nativeDependencies.findIndex((n) => n.name === a.name) -
379
427
  nativeDependencies.findIndex((n) => n.name === b.name));
@@ -405,6 +453,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
405
453
  await adb.executeShellCommand(["rm", "-rf", deviceRootPath]);
406
454
  }
407
455
  async checkForChanges() {
456
+ // Nothing android specific to check yet.
408
457
  }
409
458
  getDeploymentTarget(projectData) {
410
459
  return;
@@ -414,9 +463,12 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
414
463
  shell.cp(cpArg, paths, projectRoot);
415
464
  }
416
465
  validatePackageName(packageName) {
466
+ //Make the package conform to Java package types
467
+ //Enforce underscore limitation
417
468
  if (!/^[a-zA-Z]+(\.[a-zA-Z0-9][a-zA-Z0-9_]*)+$/.test(packageName)) {
418
469
  this.$errors.fail(`Package name must look like: com.company.Name. Got: ${packageName}`);
419
470
  }
471
+ //Class is a reserved word
420
472
  if (/\b[Cc]lass\b/.test(packageName)) {
421
473
  this.$errors.fail("class is a reserved word");
422
474
  }
@@ -425,6 +477,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
425
477
  if (projectName === "") {
426
478
  this.$errors.fail("Project name cannot be empty");
427
479
  }
480
+ //Classes in Java don't begin with numbers
428
481
  if (/^[0-9]/.test(projectName)) {
429
482
  this.$errors.fail("Project name must not begin with a number");
430
483
  }
@@ -445,6 +498,19 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
445
498
  ];
446
499
  return path.join(this.getPlatformData(projectData).projectRoot, ...resourcePath);
447
500
  }
501
+ /**
502
+ * The purpose of this method is to delete the previously prepared user resources.
503
+ * The content of the `<platforms>/android/.../res` directory is based on user's resources and gradle project template from android-runtime.
504
+ * During preparation of the `<path to user's App_Resources>/Android` we want to clean all the users files from previous preparation,
505
+ * but keep the ones that were introduced during `platform add` of the android-runtime.
506
+ * Currently the Gradle project template contains resources only in values and values-v21 directories.
507
+ * So the current logic of the method is cleaning al resources from `<platforms>/android/.../res` that are not in `values.*` directories
508
+ * and that exist in the `<path to user's App_Resources>/Android/.../res` directory
509
+ * This means that if user has a resource file in values-v29 for example, builds the project and then deletes this resource,
510
+ * it will be kept in platforms directory. Reference issue: `https://github.com/NativeScript/nativescript-cli/issues/5083`
511
+ * Same is valid for files in `drawable-<resolution>` directories - in case in user's resources there's drawable-hdpi directory,
512
+ * which is deleted after the first build of app, it will remain in platforms directory.
513
+ */
448
514
  cleanUpPreparedResources(projectData) {
449
515
  let resourcesDirPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName);
450
516
  if (this.$androidResourcesMigrationService.hasMigrated(projectData.appResourcesDirectoryPath)) {
@@ -469,7 +535,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
469
535
  const hasUseKotlinPropertyInAppData = `hasUseKotlinPropertyInApp${analyticsDelimiter}${buildStatistics.kotlinUsage.hasUseKotlinPropertyInApp}`;
470
536
  const hasKotlinRuntimeClassesData = `hasKotlinRuntimeClasses${analyticsDelimiter}${buildStatistics.kotlinUsage.hasKotlinRuntimeClasses}`;
471
537
  await this.$analyticsService.trackEventActionInGoogleAnalytics({
472
- action: "Using Kotlin",
538
+ action: "Using Kotlin" /* constants.TrackActionNames.UsingKotlin */,
473
539
  additionalData: `${hasUseKotlinPropertyInAppData}${analyticsDelimiter}${hasKotlinRuntimeClassesData}`,
474
540
  });
475
541
  }
@@ -502,3 +568,4 @@ __decorate([
502
568
  (0, helpers_1.hook)("buildAndroid")
503
569
  ], AndroidProjectService.prototype, "buildProject", null);
504
570
  yok_1.injector.register("androidProjectService", AndroidProjectService);
571
+ //# sourceMappingURL=android-project-service.js.map
@@ -46,6 +46,7 @@ class AndroidResourcesMigrationService {
46
46
  const appResourcesMainSourceSetResourcesDestination = path.join(appMainSourceSet, constants.RESOURCES_DIR);
47
47
  this.$fs.ensureDirectoryExists(appResourcesDestination);
48
48
  this.$fs.ensureDirectoryExists(appMainSourceSet);
49
+ // create /java, /res and /assets in the App_Resources/Android/src/main directory
49
50
  this.$fs.ensureDirectoryExists(appResourcesMainSourceSetResourcesDestination);
50
51
  this.$fs.ensureDirectoryExists(path.join(appMainSourceSet, "java"));
51
52
  this.$fs.ensureDirectoryExists(path.join(appMainSourceSet, constants.ASSETS_DIR));
@@ -59,20 +60,25 @@ class AndroidResourcesMigrationService {
59
60
  const resourceFiles = getFiles(appResourcesFiles);
60
61
  resourceDirectories.forEach((dir) => {
61
62
  if (path.basename(dir) !== "libs") {
63
+ // don't copy /App_Resources/Android/libs into the src/main/res/libs directory
62
64
  this.$fs.copyFile(dir, appResourcesMainSourceSetResourcesDestination);
63
65
  }
64
66
  else {
67
+ // copy App_Resources/Android/libs to App_ResourcesNew/Android/libs
65
68
  this.$fs.copyFile(dir, path.join(appResourcesDestination));
66
69
  }
67
70
  });
68
71
  resourceFiles.forEach((file) => {
69
72
  const fileName = path.basename(file);
70
73
  if (fileName !== constants.MANIFEST_FILE_NAME) {
74
+ // don't copy AndroidManifest into /App_Resources/Android as it needs to be inside src/main/
71
75
  this.$fs.copyFile(file, path.join(appResourcesDestination, fileName));
72
76
  }
73
77
  });
74
78
  this.$fs.copyFile(path.join(originalAppResources, constants.MANIFEST_FILE_NAME), path.join(appMainSourceSet, constants.MANIFEST_FILE_NAME));
79
+ // rename the legacy app_resources to ANDROID_DIR_OLD
75
80
  this.$fs.rename(originalAppResources, appResourcesBackup);
81
+ // move the new, updated app_resources to App_Resources/Android, as the de facto resources
76
82
  this.$fs.rename(appResourcesDestination, originalAppResources);
77
83
  }
78
84
  recover(originalAppResources, appResourcesDestination, appResourcesBackup) {
@@ -89,3 +95,4 @@ AndroidResourcesMigrationService.ANDROID_DIR = "Android";
89
95
  AndroidResourcesMigrationService.ANDROID_DIR_TEMP = "Android-Updated";
90
96
  AndroidResourcesMigrationService.ANDROID_DIR_OLD = "Android-Pre-v4";
91
97
  yok_1.injector.register("androidResourcesMigrationService", AndroidResourcesMigrationService);
98
+ //# sourceMappingURL=android-resources-migration-service.js.map
@@ -63,3 +63,4 @@ class ApplePortalApplicationService {
63
63
  }
64
64
  exports.ApplePortalApplicationService = ApplePortalApplicationService;
65
65
  yok_1.injector.register("applePortalApplicationService", ApplePortalApplicationService);
66
+ //# sourceMappingURL=apple-portal-application-service.js.map
@@ -51,3 +51,4 @@ class ApplePortalCookieService {
51
51
  }
52
52
  exports.ApplePortalCookieService = ApplePortalCookieService;
53
53
  yok_1.injector.register("applePortalCookieService", ApplePortalCookieService);
54
+ //# sourceMappingURL=apple-portal-cookie-service.js.map
@@ -201,10 +201,10 @@ For more details how to set up your environment, please execute "ns publish ios
201
201
  const data = JSON.parse(authResponse.body);
202
202
  const isSMS = data.trustedPhoneNumbers &&
203
203
  data.trustedPhoneNumbers.length === 1 &&
204
- data.noTrustedDevices;
204
+ data.noTrustedDevices; // 1 device and no trusted devices means sms was automatically sent.
205
205
  const multiSMS = data.trustedPhoneNumbers &&
206
206
  data.trustedPhoneNumbers.length !== 1 &&
207
- data.noTrustedDevices;
207
+ data.noTrustedDevices; // Not handling more than 1 sms device and no trusted devices.
208
208
  let token;
209
209
  if (data.trustedPhoneNumbers &&
210
210
  data.trustedPhoneNumbers.length &&
@@ -218,6 +218,7 @@ For more details how to set up your environment, please execute "ns publish ios
218
218
  };
219
219
  let url = `https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode`;
220
220
  if (isSMS) {
221
+ // No trusted devices means it must be sms.
221
222
  body.mode = "sms";
222
223
  body.phoneNumber = {
223
224
  id: data.trustedPhoneNumbers[0].id,
@@ -280,8 +281,9 @@ function checkBits(bits, digest) {
280
281
  return result;
281
282
  }
282
283
  function checkBit(position, buffer) {
283
- const bitOffset = position & 7;
284
- const byteIndex = position >> 3;
284
+ const bitOffset = position & 7; // in byte
285
+ const byteIndex = position >> 3; // in buffer
285
286
  const bit = (buffer[byteIndex] >> bitOffset) & 1;
286
287
  return bit === 0;
287
288
  }
289
+ //# sourceMappingURL=apple-portal-session-service.js.map
@@ -28,7 +28,9 @@ class GSASRPAuthenticator {
28
28
  async getInit() {
29
29
  if (this.srpClient)
30
30
  throw new Error("Already initialized");
31
- this.srpClient = await srp.newClient(stringToU8Array(this.username), new Uint8Array());
31
+ this.srpClient = await srp.newClient(stringToU8Array(this.username),
32
+ // provide fake passsword because we need to get data from server
33
+ new Uint8Array());
32
34
  let a = Buffer.from(js_srp_1.util.bytesFromBigint(this.srpClient.A)).toString("base64");
33
35
  return {
34
36
  a,
@@ -59,3 +61,4 @@ class GSASRPAuthenticator {
59
61
  }
60
62
  }
61
63
  exports.GSASRPAuthenticator = GSASRPAuthenticator;
64
+ //# sourceMappingURL=srp-wrapper.js.map
@@ -82,7 +82,7 @@ class AssetsGenerationService {
82
82
  }
83
83
  continue;
84
84
  }
85
- const operation = assetItem.resizeOperation || "resize";
85
+ const operation = assetItem.resizeOperation || "resize" /* Operations.Resize */;
86
86
  let tempScale = null;
87
87
  if (assetItem.scale) {
88
88
  if (_.isNumber(assetItem.scale)) {
@@ -107,27 +107,31 @@ class AssetsGenerationService {
107
107
  }
108
108
  let image;
109
109
  switch (operation) {
110
- case "overlayWith":
110
+ case "overlayWith" /* Operations.OverlayWith */:
111
111
  const overlayImageScale = assetItem.overlayImageScale ||
112
112
  constants_1.AssetConstants.defaultOverlayImageScale;
113
113
  const imageResize = Math.round(Math.min(width, height) * overlayImageScale);
114
114
  image = await this.resize(generationData.imagePath, imageResize, imageResize);
115
115
  image = this.generateImage(background, width, height, image);
116
116
  break;
117
- case "blank":
117
+ case "blank" /* Operations.Blank */:
118
118
  image = this.generateImage(background, width, height);
119
119
  break;
120
- case "resize":
120
+ case "resize" /* Operations.Resize */:
121
121
  image = await this.resize(generationData.imagePath, width, height);
122
122
  break;
123
- case "outerScale":
123
+ case "outerScale" /* Operations.OuterScale */:
124
+ // Resize image without applying scale
124
125
  image = await this.resize(generationData.imagePath, assetItem.width, assetItem.height);
126
+ // The scale will apply to the underlying layer of the generated image
125
127
  image = this.generateImage("#00000000", width, height, image);
126
128
  break;
127
129
  default:
128
130
  throw new Error(`Invalid image generation operation: ${operation}`);
129
131
  }
132
+ // This code disables the alpha chanel, as some images for the Apple App Store must not have transparency.
130
133
  if (assetItem.rgba === false) {
134
+ // Add an underlying white layer
131
135
  image = this.generateImage("#FFFFFF", image.width, image.height, image);
132
136
  }
133
137
  if (this.isAssetFilePath(outputPath)) {
@@ -181,3 +185,4 @@ __decorate([
181
185
  (0, decorators_1.exported)("assetsGenerationService")
182
186
  ], AssetsGenerationService.prototype, "generateSplashScreens", null);
183
187
  yok_1.injector.register("assetsGenerationService", AssetsGenerationService);
188
+ //# sourceMappingURL=assets-generation-service.js.map
@@ -64,7 +64,7 @@ class BuildArtifactsService {
64
64
  if (packages.length > 1) {
65
65
  this.$logger.warn(`More than one ${packageExtName} found in ${buildOutputPath} directory. Using the last one produced from build.`);
66
66
  }
67
- packages = _.sortBy(packages, (pkg) => pkg.time).reverse();
67
+ packages = _.sortBy(packages, (pkg) => pkg.time).reverse(); // We need to reverse because sortBy always sorts in ascending order
68
68
  return packages[0];
69
69
  }
70
70
  getApplicationPackagesCore(candidates, validPackageNames) {
@@ -85,3 +85,4 @@ class BuildArtifactsService {
85
85
  }
86
86
  exports.BuildArtifactsService = BuildArtifactsService;
87
87
  yok_1.injector.register("buildArtifactsService", BuildArtifactsService);
88
+ //# sourceMappingURL=build-artifacts-service.js.map
@@ -18,3 +18,4 @@ class BuildDataService {
18
18
  }
19
19
  exports.BuildDataService = BuildDataService;
20
20
  yok_1.injector.register("buildDataService", BuildDataService);
21
+ //# sourceMappingURL=build-data-service.js.map
@@ -62,3 +62,4 @@ class BuildInfoFileService {
62
62
  }
63
63
  exports.BuildInfoFileService = BuildInfoFileService;
64
64
  yok_1.injector.register("buildInfoFileService", BuildInfoFileService);
65
+ //# sourceMappingURL=build-info-file-service.js.map
@@ -16,7 +16,8 @@ const constants_1 = require("../../constants");
16
16
  const yok_1 = require("../../common/yok");
17
17
  const package_path_helper_1 = require("../../helpers/package-path-helper");
18
18
  class BundlerCompilerService extends events_1.EventEmitter {
19
- constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager, $projectConfigService) {
19
+ constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager, // private $sharedEventBus: ISharedEventBus
20
+ $projectConfigService) {
20
21
  super();
21
22
  this.$options = $options;
22
23
  this.$errors = $errors;
@@ -51,14 +52,23 @@ class BundlerCompilerService extends events_1.EventEmitter {
51
52
  });
52
53
  childProcess.on("message", (message) => {
53
54
  this.$logger.trace(`Message from ${projectData.bundler}`, message);
55
+ // if we are on webpack5 - we handle HMR in a slightly different way
54
56
  if (typeof message === "object" &&
55
57
  "version" in message &&
56
58
  "type" in message) {
59
+ // first compilation can be ignored because it will be synced regardless
60
+ // handling it here would trigger 2 syncs
57
61
  if (isFirstBundlerWatchCompilation) {
58
62
  isFirstBundlerWatchCompilation = false;
59
63
  resolve(childProcess);
60
64
  return;
61
65
  }
66
+ // if ((message as IWebpackMessage).type === "hmr-status") {
67
+ // // we pass message through our event-bus to be handled wherever needed
68
+ // // in this case webpack-hmr-status-service listens for this event
69
+ // this.$sharedEventBus.emit("webpack:hmr-status", message);
70
+ // return;
71
+ // }
62
72
  return this.handleHMRMessage(message, platformData, projectData, prepareData);
63
73
  }
64
74
  if (message ===
@@ -74,6 +84,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
74
84
  prepareData.hmr ? message.hash : "";
75
85
  return;
76
86
  }
87
+ // Persist the previousHash value before calling `this.getUpdatedEmittedFiles` as it will modify the expectedHashes object with the current hash
77
88
  const previousHash = this.expectedHashes[platformData.platformNameLowerCase];
78
89
  let result;
79
90
  if (prepareData.hmr) {
@@ -98,6 +109,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
98
109
  platform: platformData.platformNameLowerCase,
99
110
  };
100
111
  this.$logger.trace(`Generated data from ${projectData.bundler} message:`, data);
112
+ // the hash of the compilation is the same as the previous one and there are only hot updates produced
101
113
  if (data.hasOnlyHotUpdateFiles && previousHash === message.hash) {
102
114
  return;
103
115
  }
@@ -115,6 +127,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
115
127
  const exitCode = typeof arg === "number" ? arg : arg && arg.code;
116
128
  this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} process exited with code ${exitCode} when we expected it to be long living with watch.`);
117
129
  if (this.getBundler() === "vite" && exitCode === 0) {
130
+ // note experimental: investigate watch mode
118
131
  const bundlePath = path.join(projectData.projectDir, "dist/bundle.js");
119
132
  console.log("bundlePath:", bundlePath);
120
133
  const data = {
@@ -183,6 +196,9 @@ class BundlerCompilerService extends events_1.EventEmitter {
183
196
  }
184
197
  }
185
198
  async shouldUsePreserveSymlinksOption() {
199
+ // pnpm does not require symlink (https://github.com/nodejs/node-eps/issues/46#issuecomment-277373566)
200
+ // and it also does not work in some cases.
201
+ // Check https://github.com/NativeScript/nativescript-cli/issues/5259 for more information
186
202
  const currentPackageManager = await this.$packageManager.getPackageManagerName();
187
203
  const res = currentPackageManager !== constants_1.PackageManagers.pnpm;
188
204
  return res;
@@ -201,6 +217,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
201
217
  const envData = this.buildEnvData(platformData.platformNameLowerCase, projectData, prepareData);
202
218
  const isVite = this.getBundler() === "vite";
203
219
  const cliArgs = await this.buildEnvCommandLineParams(envData, platformData, projectData, prepareData);
220
+ // Note: With Vite, we need `--` to prevent vite cli from erroring on unknown options.
204
221
  const envParams = isVite
205
222
  ? [`--mode=${platformData.platformNameLowerCase}`, "--", ...cliArgs]
206
223
  : cliArgs;
@@ -261,16 +278,28 @@ class BundlerCompilerService extends events_1.EventEmitter {
261
278
  });
262
279
  envData.verbose = envData.verbose || this.$logger.isVerbose();
263
280
  envData.production = envData.production || prepareData.release;
281
+ // add the config file name to the env data so the webpack process can read the
282
+ // correct config file when resolving the CLI lib and the config service
283
+ // we are explicitly setting it to false to force using the defaults
264
284
  envData.config =
265
285
  (_b = (_a = process.env.NATIVESCRIPT_CONFIG_NAME) !== null && _a !== void 0 ? _a : this.$options.config) !== null && _b !== void 0 ? _b : "false";
286
+ // explicitly set the env variable
266
287
  process.env.NATIVESCRIPT_CONFIG_NAME = envData.config;
288
+ // The snapshot generation is wrongly located in the Webpack plugin.
289
+ // It should be moved in the Native Prepare of the CLI or a Gradle task in the Runtime.
290
+ // As a workaround, we skip the mksnapshot, xxd and android-ndk calls based on skipNativePrepare.
291
+ // In this way the plugin will prepare only the snapshot JS entry without any native prepare and
292
+ // we will able to execute cloud builds with snapshot without having any local snapshot or Docker setup.
293
+ // TODO: Remove this flag when we remove the native part from the plugin.
267
294
  envData.skipSnapshotTools =
268
295
  prepareData.nativePrepare && prepareData.nativePrepare.skipNativePrepare;
296
+ // only set sourceMap if not explicitly set through a flag
269
297
  if (typeof ((_c = prepareData === null || prepareData === void 0 ? void 0 : prepareData.env) === null || _c === void 0 ? void 0 : _c.sourceMap) === "undefined") {
270
298
  if (!prepareData.release) {
271
299
  envData.sourceMap = true;
272
300
  }
273
301
  }
302
+ // convert string to boolean
274
303
  if (envData.sourceMap === "true" || envData.sourceMap === "false") {
275
304
  envData.sourceMap = envData.sourceMap === "true";
276
305
  }
@@ -291,6 +320,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
291
320
  }
292
321
  else if (this.$hostInfo.isWindows) {
293
322
  if (projectData.bundler === "webpack") {
323
+ //TODO: check this use case for webpack5 WEBPACK_PLUGIN_NAME
294
324
  const minWebpackPluginWithWinSnapshotsVersion = "1.3.0";
295
325
  const installedWebpackPluginVersion = await this.$packageInstallationManager.getInstalledDependencyVersion(constants_1.WEBPACK_PLUGIN_NAME, projectData.projectDir);
296
326
  const hasWebpackPluginWithWinSnapshotsSupport = !!installedWebpackPluginVersion
@@ -324,6 +354,15 @@ class BundlerCompilerService extends events_1.EventEmitter {
324
354
  }
325
355
  getUpdatedEmittedFiles(allEmittedFiles, chunkFiles, nextHash, platform) {
326
356
  const currentHash = this.getCurrentHotUpdateHash(allEmittedFiles);
357
+ // This logic is needed as there are already cases when webpack doesn't emit any files physically.
358
+ // We've set noEmitOnErrors in webpack.config.js based on noEmitOnError from tsconfig.json,
359
+ // so webpack doesn't emit any files when noEmitOnErrors: true is set in webpack.config.js and
360
+ // there is a compilation error in the source code. On the other side, hmr generates new hot-update files
361
+ // on every change and the hash of the next hmr update is written inside hot-update.json file.
362
+ // Although webpack doesn't emit any files, hmr hash is still generated. The hash is generated per compilation no matter
363
+ // if files will be emitted or not. This way, the first successful compilation after fixing the compilation error generates
364
+ // a hash that is not the same as the one expected in the latest emitted hot-update.json file.
365
+ // As a result, the hmr chain is broken and the changes are not applied.
327
366
  const isHashValid = nextHash
328
367
  ? this.expectedHashes[platform] === currentHash
329
368
  : true;
@@ -342,6 +381,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
342
381
  let hotHash;
343
382
  const hotUpdateScripts = emittedFiles.filter((x) => x.endsWith(".hot-update.js"));
344
383
  if (hotUpdateScripts && hotUpdateScripts.length) {
384
+ // the hash is the same for each hot update in the current compilation
345
385
  const hotUpdateName = hotUpdateScripts[0];
346
386
  const matcher = /^(.+)\.(.+)\.hot-update/gm;
347
387
  const matches = matcher.exec(hotUpdateName);
@@ -359,6 +399,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
359
399
  }
360
400
  }
361
401
  handleHMRMessage(message, platformData, projectData, prepareData) {
402
+ // handle new bundler hmr packets
362
403
  this.$logger.trace(`Received message from ${projectData.bundler} process:`, message);
363
404
  if (message.type !== "compilation") {
364
405
  return;
@@ -366,6 +407,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
366
407
  this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} build done!`);
367
408
  const files = message.data.emittedAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
368
409
  const staleFiles = message.data.staleAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
410
+ // extract last hash from emitted filenames
369
411
  const lastHash = (() => {
370
412
  const absoluteFileNameWithLastHash = files.find((fileName) => fileName.endsWith("hot-update.js"));
371
413
  if (!absoluteFileNameWithLastHash) {
@@ -378,6 +420,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
378
420
  }
379
421
  })();
380
422
  if (!files.length) {
423
+ // ignore compilations if no new files are emitted
381
424
  return;
382
425
  }
383
426
  this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, {
@@ -449,3 +492,4 @@ function capitalizeFirstLetter(val) {
449
492
  return String(val).charAt(0).toUpperCase() + String(val).slice(1);
450
493
  }
451
494
  yok_1.injector.register("bundlerCompilerService", BundlerCompilerService);
495
+ //# sourceMappingURL=bundler-compiler-service.js.map
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=bundler.js.map