nativescript 8.9.0-dev.0 → 8.9.0-dev.2

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 (405) hide show
  1. package/config/test-deps-versions-generated.json +1 -1
  2. package/lib/.d.ts +1 -0
  3. package/lib/android-tools-info.js +32 -9
  4. package/lib/base-package-manager.js +71 -47
  5. package/lib/bootstrap.js +6 -1
  6. package/lib/bun-package-manager.js +104 -65
  7. package/lib/color.js +5 -2
  8. package/lib/commands/add-platform.js +31 -14
  9. package/lib/commands/apple-login.js +30 -18
  10. package/lib/commands/appstore-list.js +46 -34
  11. package/lib/commands/appstore-upload.js +68 -52
  12. package/lib/commands/build.js +90 -57
  13. package/lib/commands/clean.js +197 -161
  14. package/lib/commands/command-base.js +28 -14
  15. package/lib/commands/config.js +71 -48
  16. package/lib/commands/create-project.js +235 -210
  17. package/lib/commands/debug.js +93 -66
  18. package/lib/commands/deploy.js +47 -30
  19. package/lib/commands/embedding/embed.js +59 -33
  20. package/lib/commands/extensibility/install-extension.js +17 -5
  21. package/lib/commands/extensibility/list-extensions.js +25 -13
  22. package/lib/commands/extensibility/uninstall-extension.js +16 -4
  23. package/lib/commands/fonts.js +42 -30
  24. package/lib/commands/generate-assets.js +29 -13
  25. package/lib/commands/generate-help.js +14 -2
  26. package/lib/commands/generate.js +70 -12
  27. package/lib/commands/info.js +14 -2
  28. package/lib/commands/install.js +50 -34
  29. package/lib/commands/list-platforms.js +26 -14
  30. package/lib/commands/migrate.js +27 -15
  31. package/lib/commands/native-add.js +51 -23
  32. package/lib/commands/platform-clean.js +33 -19
  33. package/lib/commands/plugin/add-plugin.js +26 -12
  34. package/lib/commands/plugin/build-plugin.js +45 -31
  35. package/lib/commands/plugin/create-plugin.js +138 -110
  36. package/lib/commands/plugin/list-plugins.js +34 -22
  37. package/lib/commands/plugin/remove-plugin.js +35 -20
  38. package/lib/commands/plugin/update-plugin.js +34 -20
  39. package/lib/commands/post-install.js +39 -20
  40. package/lib/commands/prepare.js +39 -22
  41. package/lib/commands/preview.js +64 -49
  42. package/lib/commands/remove-platform.js +19 -7
  43. package/lib/commands/resources/resources-update.js +28 -13
  44. package/lib/commands/run.js +77 -55
  45. package/lib/commands/setup.js +1 -0
  46. package/lib/commands/start.js +20 -6
  47. package/lib/commands/test-init.js +138 -123
  48. package/lib/commands/test.js +97 -67
  49. package/lib/commands/typings.js +143 -126
  50. package/lib/commands/update-platform.js +40 -22
  51. package/lib/commands/update.js +45 -30
  52. package/lib/commands/widget.js +767 -0
  53. package/lib/common/bootstrap.js +1 -0
  54. package/lib/common/child-process.js +75 -53
  55. package/lib/common/codeGeneration/code-entity.js +2 -1
  56. package/lib/common/codeGeneration/code-printer.js +2 -1
  57. package/lib/common/command-params.js +19 -7
  58. package/lib/common/commands/analytics.js +43 -27
  59. package/lib/common/commands/autocompletion.js +59 -39
  60. package/lib/common/commands/device/device-log-stream.js +24 -12
  61. package/lib/common/commands/device/get-file.js +35 -22
  62. package/lib/common/commands/device/list-applications.js +24 -12
  63. package/lib/common/commands/device/list-devices.js +90 -72
  64. package/lib/common/commands/device/list-files.js +36 -23
  65. package/lib/common/commands/device/put-file.js +35 -22
  66. package/lib/common/commands/device/run-application.js +26 -12
  67. package/lib/common/commands/device/stop-application.js +23 -11
  68. package/lib/common/commands/device/uninstall-application.js +18 -6
  69. package/lib/common/commands/doctor.js +3 -2
  70. package/lib/common/commands/generate-messages.js +29 -17
  71. package/lib/common/commands/help.js +34 -20
  72. package/lib/common/commands/package-manager-get.js +18 -6
  73. package/lib/common/commands/package-manager-set.js +21 -9
  74. package/lib/common/commands/post-install.js +14 -2
  75. package/lib/common/commands/preuninstall.js +48 -24
  76. package/lib/common/commands/proxy/proxy-base.js +23 -8
  77. package/lib/common/commands/proxy/proxy-clear.js +16 -4
  78. package/lib/common/commands/proxy/proxy-get.js +15 -3
  79. package/lib/common/commands/proxy/proxy-set.js +101 -87
  80. package/lib/common/common-lib.js +1 -0
  81. package/lib/common/constants.js +22 -11
  82. package/lib/common/decorators.js +70 -10
  83. package/lib/common/dispatchers.js +106 -80
  84. package/lib/common/errors.js +116 -91
  85. package/lib/common/file-system.js +141 -108
  86. package/lib/common/header.js +5 -1
  87. package/lib/common/helpers.js +267 -152
  88. package/lib/common/host-info.js +54 -37
  89. package/lib/common/http-client.js +128 -93
  90. package/lib/common/logger/appenders/cli-appender.js +6 -1
  91. package/lib/common/logger/appenders/emit-appender.js +6 -1
  92. package/lib/common/logger/layouts/cli-layout.js +3 -1
  93. package/lib/common/logger/logger.js +9 -4
  94. package/lib/common/messages/messages.js +6 -0
  95. package/lib/common/mobile/android/android-application-manager.js +162 -122
  96. package/lib/common/mobile/android/android-debug-bridge-result-handler.js +2 -1
  97. package/lib/common/mobile/android/android-debug-bridge.js +118 -87
  98. package/lib/common/mobile/android/android-device-file-system.js +135 -98
  99. package/lib/common/mobile/android/android-device-hash-service.js +78 -50
  100. package/lib/common/mobile/android/android-device.js +93 -68
  101. package/lib/common/mobile/android/android-emulator-services.js +131 -105
  102. package/lib/common/mobile/android/android-ini-file-parser.js +9 -0
  103. package/lib/common/mobile/android/android-log-filter.js +5 -1
  104. package/lib/common/mobile/android/android-virtual-device-service.js +123 -76
  105. package/lib/common/mobile/android/device-android-debug-bridge.js +30 -13
  106. package/lib/common/mobile/android/genymotion/genymotion-service.js +123 -91
  107. package/lib/common/mobile/android/genymotion/virtualbox-service.js +92 -64
  108. package/lib/common/mobile/android/logcat-helper.js +140 -108
  109. package/lib/common/mobile/application-manager-base.js +113 -84
  110. package/lib/common/mobile/device-emitter.js +4 -0
  111. package/lib/common/mobile/device-log-emitter.js +1 -0
  112. package/lib/common/mobile/device-log-provider-base.js +19 -7
  113. package/lib/common/mobile/device-log-provider.js +23 -0
  114. package/lib/common/mobile/device-platforms-constants.js +1 -0
  115. package/lib/common/mobile/emulator-helper.js +3 -0
  116. package/lib/common/mobile/ios/device/ios-application-manager.js +111 -79
  117. package/lib/common/mobile/ios/device/ios-device-file-system.js +106 -78
  118. package/lib/common/mobile/ios/device/ios-device-operations.js +146 -105
  119. package/lib/common/mobile/ios/device/ios-device.js +40 -20
  120. package/lib/common/mobile/ios/ios-device-base.js +82 -58
  121. package/lib/common/mobile/ios/ios-device-product-name-mapper.js +2 -0
  122. package/lib/common/mobile/ios/ios-log-filter.js +1 -0
  123. package/lib/common/mobile/ios/simulator/ios-emulator-services.js +96 -63
  124. package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +2 -1
  125. package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +95 -60
  126. package/lib/common/mobile/ios/simulator/ios-simulator-device.js +48 -27
  127. package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +63 -37
  128. package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +36 -24
  129. package/lib/common/mobile/local-to-device-path-data-factory.js +1 -0
  130. package/lib/common/mobile/log-filter.js +2 -0
  131. package/lib/common/mobile/logging-levels.js +1 -0
  132. package/lib/common/mobile/mobile-core/android-device-discovery.js +64 -43
  133. package/lib/common/mobile/mobile-core/android-emulator-discovery.js +35 -21
  134. package/lib/common/mobile/mobile-core/android-process-service.js +214 -143
  135. package/lib/common/mobile/mobile-core/device-discovery.js +14 -2
  136. package/lib/common/mobile/mobile-core/devices-service.js +505 -386
  137. package/lib/common/mobile/mobile-core/ios-device-discovery.js +37 -24
  138. package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +65 -47
  139. package/lib/common/mobile/mobile-helper.js +27 -15
  140. package/lib/common/mobile/wp8/wp8-emulator-services.js +53 -25
  141. package/lib/common/opener.js +3 -2
  142. package/lib/common/os-info.js +1 -0
  143. package/lib/common/plist-parser.js +1 -0
  144. package/lib/common/project-helper.js +1 -0
  145. package/lib/common/prompter.js +114 -91
  146. package/lib/common/queue.js +21 -9
  147. package/lib/common/resource-loader.js +1 -0
  148. package/lib/common/services/auto-completion-service.js +65 -40
  149. package/lib/common/services/cancellation.js +29 -17
  150. package/lib/common/services/commands-service.js +180 -146
  151. package/lib/common/services/help-service.js +166 -133
  152. package/lib/common/services/hooks-service.js +121 -93
  153. package/lib/common/services/ios-notification-service.js +35 -21
  154. package/lib/common/services/json-file-settings-service.js +77 -52
  155. package/lib/common/services/lock-service.js +58 -35
  156. package/lib/common/services/message-contract-generator.js +47 -35
  157. package/lib/common/services/messages-service.js +1 -0
  158. package/lib/common/services/micro-templating-service.js +21 -4
  159. package/lib/common/services/net-service.js +110 -90
  160. package/lib/common/services/project-files-manager.js +28 -10
  161. package/lib/common/services/project-files-provider-base.js +1 -0
  162. package/lib/common/services/proxy-service.js +25 -13
  163. package/lib/common/services/qr.js +25 -13
  164. package/lib/common/services/settings-service.js +2 -1
  165. package/lib/common/services/xcode-select-service.js +36 -20
  166. package/lib/common/utils.js +3 -2
  167. package/lib/common/validators/project-name-validator.js +2 -1
  168. package/lib/common/validators/validation-result.js +2 -1
  169. package/lib/common/verify-node-version.js +11 -3
  170. package/lib/common/yok.js +69 -35
  171. package/lib/config.js +72 -36
  172. package/lib/constants-provider.js +1 -0
  173. package/lib/constants.js +78 -25
  174. package/lib/controllers/build-controller.js +100 -82
  175. package/lib/controllers/debug-controller.js +133 -107
  176. package/lib/controllers/deploy-controller.js +24 -15
  177. package/lib/controllers/migrate-controller.js +884 -723
  178. package/lib/controllers/platform-controller.js +94 -71
  179. package/lib/controllers/prepare-controller.js +274 -232
  180. package/lib/controllers/run-controller.js +427 -397
  181. package/lib/controllers/update-controller-base.js +30 -16
  182. package/lib/controllers/update-controller.js +130 -94
  183. package/lib/data/build-data.js +1 -0
  184. package/lib/data/controller-data-base.js +1 -0
  185. package/lib/data/debug-data.js +1 -0
  186. package/lib/data/platform-data.js +1 -0
  187. package/lib/data/prepare-data.js +2 -4
  188. package/lib/data/run-data.js +1 -0
  189. package/lib/definitions/ios.d.ts +4 -2
  190. package/lib/definitions/project.d.ts +26 -0
  191. package/lib/detached-processes/cleanup-js-subprocess.js +20 -5
  192. package/lib/detached-processes/cleanup-process.js +43 -30
  193. package/lib/detached-processes/file-log-service.js +2 -1
  194. package/lib/device-path-provider.js +35 -23
  195. package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +171 -149
  196. package/lib/device-sockets/ios/notification.js +4 -1
  197. package/lib/device-sockets/ios/socket-request-executor.js +42 -24
  198. package/lib/helpers/android-bundle-validator-helper.js +3 -2
  199. package/lib/helpers/deploy-command-helper.js +50 -44
  200. package/lib/helpers/key-command-helper.js +17 -6
  201. package/lib/helpers/livesync-command-helper.js +155 -137
  202. package/lib/helpers/network-connectivity-validator.js +18 -6
  203. package/lib/helpers/options-track-helper.js +19 -7
  204. package/lib/helpers/package-path-helper.js +1 -0
  205. package/lib/helpers/platform-command-helper.js +127 -101
  206. package/lib/helpers/version-validator-helper.js +1 -0
  207. package/lib/key-commands/bootstrap.js +3 -2
  208. package/lib/key-commands/index.js +205 -154
  209. package/lib/nativescript-cli-lib-bootstrap.js +4 -0
  210. package/lib/nativescript-cli-lib.js +1 -0
  211. package/lib/nativescript-cli.js +24 -6
  212. package/lib/node/pbxproj-dom-xcode.js +1 -0
  213. package/lib/node/xcode.js +1 -0
  214. package/lib/node-package-manager.js +114 -81
  215. package/lib/options.js +156 -122
  216. package/lib/package-installation-manager.js +172 -130
  217. package/lib/package-manager.js +88 -63
  218. package/lib/platform-command-param.js +16 -4
  219. package/lib/pnpm-package-manager.js +81 -59
  220. package/lib/project-data.js +13 -1
  221. package/lib/providers/project-files-provider.js +2 -1
  222. package/lib/resolvers/livesync-service-resolver.js +1 -0
  223. package/lib/services/analytics/analytics-broker-process.js +32 -19
  224. package/lib/services/analytics/analytics-broker.js +31 -17
  225. package/lib/services/analytics/analytics-service.js +210 -170
  226. package/lib/services/analytics/google-analytics-provider.js +59 -43
  227. package/lib/services/analytics-settings-service.js +37 -15
  228. package/lib/services/android/android-bundle-tool-service.js +61 -43
  229. package/lib/services/android/gradle-build-args-service.js +23 -9
  230. package/lib/services/android/gradle-build-service.js +36 -22
  231. package/lib/services/android/gradle-command-service.js +36 -22
  232. package/lib/services/android-device-debug-service.js +123 -90
  233. package/lib/services/android-plugin-build-service.js +260 -205
  234. package/lib/services/android-project-service.js +241 -129
  235. package/lib/services/android-resources-migration-service.js +71 -51
  236. package/lib/services/apple-portal/apple-portal-application-service.js +64 -46
  237. package/lib/services/apple-portal/apple-portal-cookie-service.js +1 -0
  238. package/lib/services/apple-portal/apple-portal-session-service.js +218 -197
  239. package/lib/services/apple-portal/srp/srp-wrapper.js +61 -43
  240. package/lib/services/assets-generation/assets-generation-service.js +128 -103
  241. package/lib/services/build-artifacts-service.js +22 -10
  242. package/lib/services/build-data-service.js +1 -0
  243. package/lib/services/build-info-file-service.js +36 -20
  244. package/lib/services/cleanup-service.js +81 -48
  245. package/lib/services/cocoapods-platform-manager.js +9 -0
  246. package/lib/services/cocoapods-service.js +153 -112
  247. package/lib/services/debug-data-service.js +1 -0
  248. package/lib/services/debug-service-base.js +7 -0
  249. package/lib/services/device/device-install-app-service.js +72 -54
  250. package/lib/services/doctor-service.js +135 -101
  251. package/lib/services/extensibility-service.js +108 -81
  252. package/lib/services/files-hash-service.js +44 -26
  253. package/lib/services/hmr-status-service.js +3 -1
  254. package/lib/services/info-service.js +1 -0
  255. package/lib/services/initialize-service.js +54 -37
  256. package/lib/services/ios/export-options-plist-service.js +55 -38
  257. package/lib/services/ios/ios-signing-service.js +191 -168
  258. package/lib/services/ios/spm-service.js +73 -43
  259. package/lib/services/ios/xcodebuild-args-service.js +103 -77
  260. package/lib/services/ios/xcodebuild-command-service.js +26 -14
  261. package/lib/services/ios/xcodebuild-service.js +72 -52
  262. package/lib/services/ios-debugger-port-service.js +38 -24
  263. package/lib/services/ios-device-debug-service.js +103 -75
  264. package/lib/services/ios-entitlements-service.js +43 -31
  265. package/lib/services/ios-extensions-service.js +30 -18
  266. package/lib/services/ios-log-filter.js +20 -0
  267. package/lib/services/ios-native-target-service.js +6 -4
  268. package/lib/services/ios-project-service.js +605 -437
  269. package/lib/services/ios-provision-service.js +132 -108
  270. package/lib/services/ios-watch-app-service.js +33 -21
  271. package/lib/services/ip-service.js +55 -38
  272. package/lib/services/itmstransporter-service.js +153 -129
  273. package/lib/services/karma-execution.js +2 -0
  274. package/lib/services/livesync/android-device-livesync-service-base.js +49 -31
  275. package/lib/services/livesync/android-device-livesync-service.js +151 -120
  276. package/lib/services/livesync/android-device-livesync-sockets-service.js +155 -121
  277. package/lib/services/livesync/android-livesync-service.js +36 -14
  278. package/lib/services/livesync/android-livesync-tool.js +117 -90
  279. package/lib/services/livesync/device-livesync-service-base.js +30 -15
  280. package/lib/services/livesync/ios-device-livesync-service.js +150 -114
  281. package/lib/services/livesync/ios-livesync-service.js +60 -42
  282. package/lib/services/livesync/livesync-socket.js +1 -0
  283. package/lib/services/livesync/platform-livesync-service-base.js +124 -94
  284. package/lib/services/livesync-process-data-service.js +1 -0
  285. package/lib/services/log-parser-service.js +2 -1
  286. package/lib/services/log-source-map-service.js +56 -30
  287. package/lib/services/marking-mode-service.js +33 -17
  288. package/lib/services/metadata-filtering-service.js +1 -0
  289. package/lib/services/npm-config-service.js +5 -1
  290. package/lib/services/pacote-service.js +73 -51
  291. package/lib/services/performance-service.js +4 -2
  292. package/lib/services/platform/add-platform-service.js +119 -51
  293. package/lib/services/platform/platform-validation-service.js +34 -22
  294. package/lib/services/platform/prepare-native-platform-service.js +65 -49
  295. package/lib/services/platform-environment-requirements.js +43 -27
  296. package/lib/services/platform-project-service-base.js +1 -0
  297. package/lib/services/platforms-data-service.js +1 -0
  298. package/lib/services/plugins-service.js +168 -125
  299. package/lib/services/prepare-data-service.js +1 -0
  300. package/lib/services/project-backup-service.js +5 -1
  301. package/lib/services/project-changes-service.js +152 -124
  302. package/lib/services/project-cleanup-service.js +79 -64
  303. package/lib/services/project-config-service.js +111 -73
  304. package/lib/services/project-data-service.js +154 -108
  305. package/lib/services/project-name-service.js +44 -28
  306. package/lib/services/project-service.js +113 -84
  307. package/lib/services/project-templates-service.js +68 -52
  308. package/lib/services/qr-code-terminal-service.js +1 -0
  309. package/lib/services/require-service.js +1 -0
  310. package/lib/services/start-service.js +60 -41
  311. package/lib/services/temp-service.js +22 -8
  312. package/lib/services/terminal-spinner-service.js +28 -15
  313. package/lib/services/test-execution-service.js +79 -59
  314. package/lib/services/test-initialization-service.js +6 -2
  315. package/lib/services/timeline-profiler-service.js +2 -1
  316. package/lib/services/user-settings-service.js +1 -0
  317. package/lib/services/versions-service.js +140 -119
  318. package/lib/services/watch-ignore-list-service.js +1 -0
  319. package/lib/services/webpack/webpack-compiler-service.js +279 -215
  320. package/lib/services/xcconfig-service.js +21 -8
  321. package/lib/services/xcproj-service.js +1 -0
  322. package/lib/shared-event-bus.js +6 -0
  323. package/lib/sys-info.js +63 -45
  324. package/lib/tools/config-manipulation/config-transformer.js +21 -0
  325. package/lib/tools/node-modules/node-modules-builder.js +28 -16
  326. package/lib/tools/node-modules/node-modules-dependencies-builder.js +6 -0
  327. package/lib/yarn-package-manager.js +79 -59
  328. package/lib/yarn2-package-manager.js +82 -60
  329. package/node_modules/@npmcli/move-file/LICENSE.md +22 -0
  330. package/node_modules/@npmcli/move-file/README.md +69 -0
  331. package/node_modules/@npmcli/move-file/lib/index.js +185 -0
  332. package/node_modules/@npmcli/move-file/node_modules/mkdirp/LICENSE +21 -0
  333. package/node_modules/@npmcli/move-file/node_modules/mkdirp/bin/cmd.js +68 -0
  334. package/node_modules/@npmcli/move-file/node_modules/mkdirp/index.js +31 -0
  335. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/find-made.js +29 -0
  336. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-manual.js +64 -0
  337. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-native.js +39 -0
  338. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/opts-arg.js +23 -0
  339. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/path-arg.js +29 -0
  340. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/use-native.js +10 -0
  341. package/node_modules/@npmcli/move-file/node_modules/mkdirp/package.json +44 -0
  342. package/node_modules/@npmcli/move-file/node_modules/mkdirp/readme.markdown +266 -0
  343. package/node_modules/@npmcli/move-file/package.json +47 -0
  344. package/node_modules/balanced-match/.github/FUNDING.yml +2 -0
  345. package/node_modules/balanced-match/LICENSE.md +21 -0
  346. package/node_modules/balanced-match/README.md +97 -0
  347. package/node_modules/balanced-match/index.js +62 -0
  348. package/node_modules/balanced-match/package.json +48 -0
  349. package/node_modules/concat-map/.travis.yml +4 -0
  350. package/node_modules/concat-map/LICENSE +18 -0
  351. package/node_modules/concat-map/README.markdown +62 -0
  352. package/node_modules/concat-map/example/map.js +6 -0
  353. package/node_modules/concat-map/index.js +13 -0
  354. package/node_modules/concat-map/package.json +43 -0
  355. package/node_modules/concat-map/test/map.js +39 -0
  356. package/node_modules/fs.realpath/LICENSE +43 -0
  357. package/node_modules/fs.realpath/README.md +33 -0
  358. package/node_modules/fs.realpath/index.js +66 -0
  359. package/node_modules/fs.realpath/old.js +303 -0
  360. package/node_modules/fs.realpath/package.json +26 -0
  361. package/node_modules/inflight/LICENSE +15 -0
  362. package/node_modules/inflight/README.md +37 -0
  363. package/node_modules/inflight/inflight.js +54 -0
  364. package/node_modules/inflight/package.json +29 -0
  365. package/node_modules/inherits/LICENSE +16 -0
  366. package/node_modules/inherits/README.md +42 -0
  367. package/node_modules/inherits/inherits.js +9 -0
  368. package/node_modules/inherits/inherits_browser.js +27 -0
  369. package/node_modules/inherits/package.json +29 -0
  370. package/node_modules/once/LICENSE +15 -0
  371. package/node_modules/once/README.md +79 -0
  372. package/node_modules/once/once.js +42 -0
  373. package/node_modules/once/package.json +33 -0
  374. package/node_modules/path-is-absolute/index.js +20 -0
  375. package/node_modules/path-is-absolute/license +21 -0
  376. package/node_modules/path-is-absolute/package.json +43 -0
  377. package/node_modules/path-is-absolute/readme.md +59 -0
  378. package/node_modules/rimraf/LICENSE +15 -0
  379. package/node_modules/rimraf/README.md +101 -0
  380. package/node_modules/rimraf/bin.js +68 -0
  381. package/node_modules/rimraf/node_modules/brace-expansion/LICENSE +21 -0
  382. package/node_modules/rimraf/node_modules/brace-expansion/README.md +129 -0
  383. package/node_modules/rimraf/node_modules/brace-expansion/index.js +201 -0
  384. package/node_modules/rimraf/node_modules/brace-expansion/package.json +47 -0
  385. package/node_modules/rimraf/node_modules/glob/LICENSE +21 -0
  386. package/node_modules/rimraf/node_modules/glob/README.md +378 -0
  387. package/node_modules/rimraf/node_modules/glob/common.js +238 -0
  388. package/node_modules/rimraf/node_modules/glob/glob.js +790 -0
  389. package/node_modules/rimraf/node_modules/glob/package.json +55 -0
  390. package/node_modules/rimraf/node_modules/glob/sync.js +486 -0
  391. package/node_modules/rimraf/node_modules/minimatch/LICENSE +15 -0
  392. package/node_modules/rimraf/node_modules/minimatch/README.md +230 -0
  393. package/node_modules/rimraf/node_modules/minimatch/minimatch.js +947 -0
  394. package/node_modules/rimraf/node_modules/minimatch/package.json +33 -0
  395. package/node_modules/rimraf/package.json +32 -0
  396. package/node_modules/rimraf/rimraf.js +360 -0
  397. package/node_modules/stringify-package/LICENSE +13 -0
  398. package/node_modules/stringify-package/README.md +55 -0
  399. package/node_modules/stringify-package/index.js +18 -0
  400. package/node_modules/stringify-package/package.json +38 -0
  401. package/node_modules/wrappy/LICENSE +15 -0
  402. package/node_modules/wrappy/README.md +36 -0
  403. package/node_modules/wrappy/package.json +29 -0
  404. package/node_modules/wrappy/wrappy.js +33 -0
  405. package/package.json +79 -64
@@ -0,0 +1,767 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.WidgetIOSCommand = exports.WidgetCommand = void 0;
13
+ const fs = require("fs");
14
+ const prompts = require("prompts");
15
+ const path = require("path");
16
+ const plist = require("plist");
17
+ const yok_1 = require("../common/yok");
18
+ const utils_1 = require("../common/utils");
19
+ const os_1 = require("os");
20
+ class WidgetCommand {
21
+ constructor($projectData, $projectConfigService, $logger, $errors) {
22
+ this.$projectData = $projectData;
23
+ this.$projectConfigService = $projectConfigService;
24
+ this.$logger = $logger;
25
+ this.$errors = $errors;
26
+ this.allowedParameters = [];
27
+ this.$projectData.initializeProjectData();
28
+ }
29
+ execute(args) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ this.failWithUsage();
32
+ return Promise.resolve();
33
+ });
34
+ }
35
+ failWithUsage() {
36
+ this.$errors.failWithHelp("Usage: ns widget ios");
37
+ }
38
+ canExecute(args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ this.failWithUsage();
41
+ return false;
42
+ });
43
+ }
44
+ getIosSourcePathBase() {
45
+ const resources = this.$projectData.getAppResourcesDirectoryPath();
46
+ return path.join(resources, "iOS", "src");
47
+ }
48
+ }
49
+ exports.WidgetCommand = WidgetCommand;
50
+ class WidgetIOSCommand extends WidgetCommand {
51
+ constructor($projectData, $projectConfigService, $logger, $errors) {
52
+ super($projectData, $projectConfigService, $logger, $errors);
53
+ }
54
+ canExecute(args) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return true;
57
+ });
58
+ }
59
+ execute(args) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ this.startPrompt(args);
62
+ });
63
+ }
64
+ startPrompt(args) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ let result = yield prompts.prompt({
67
+ type: "text",
68
+ name: "name",
69
+ message: `What name would you like for this widget? (Default is 'widget')`,
70
+ });
71
+ const name = (result.name || "widget").toLowerCase();
72
+ result = yield prompts.prompt({
73
+ type: "select",
74
+ name: "value",
75
+ message: `What type of widget would you like? (Request more options: https://github.com/NativeScript/nativescript-cli/issues)`,
76
+ choices: [
77
+ {
78
+ title: "Live Activity",
79
+ description: "This will create a Live Activity that will display on the iOS Lock Screen.",
80
+ value: 0,
81
+ },
82
+ {
83
+ title: "Live Activity with Home Screen Widget",
84
+ description: "This will create a Live Activity that will display on the iOS Lock Screen with an optional Widget.",
85
+ value: 1,
86
+ },
87
+ {
88
+ title: "Home Screen Widget",
89
+ description: "This will create just a Home Screen Widget.",
90
+ value: 2,
91
+ },
92
+ ],
93
+ initial: 1,
94
+ });
95
+ switch (result.value) {
96
+ case 0:
97
+ this.$logger.info("TODO");
98
+ break;
99
+ case 1:
100
+ yield this.generateSharedWidgetPackage(this.$projectData.projectDir, name);
101
+ this.generateWidget(this.$projectData.projectDir, name, result.value);
102
+ this.generateAppleUtility(this.$projectData.projectDir, name);
103
+ break;
104
+ case 2:
105
+ this.$logger.info("TODO");
106
+ break;
107
+ }
108
+ });
109
+ }
110
+ generateSharedWidgetPackage(projectDir, name) {
111
+ var _a;
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const sharedWidgetDir = "Shared_Resources/iOS/SharedWidget";
114
+ const sharedWidgetPath = path.join(projectDir, sharedWidgetDir);
115
+ const sharedWidgetSourceDir = "Sources/SharedWidget";
116
+ const sharedWidgetPackagePath = path.join(projectDir, `${sharedWidgetDir}/Package.swift`);
117
+ const sharedWidgetSourcePath = path.join(sharedWidgetPath, `${sharedWidgetSourceDir}/${(0, utils_1.capitalizeFirstLetter)(name)}Model.swift`);
118
+ const gitIgnorePath = path.join(projectDir, ".gitignore");
119
+ if (!fs.existsSync(sharedWidgetPackagePath)) {
120
+ fs.mkdirSync(sharedWidgetPath, { recursive: true });
121
+ fs.mkdirSync(path.join(sharedWidgetPath, sharedWidgetSourceDir), {
122
+ recursive: true,
123
+ });
124
+ let content = `// swift-tools-version:5.9
125
+ import PackageDescription
126
+
127
+ let package = Package(
128
+ name: "SharedWidget",
129
+ platforms: [
130
+ .iOS(.v13)
131
+ ],
132
+ products: [
133
+ .library(
134
+ name: "SharedWidget",
135
+ targets: ["SharedWidget"])
136
+ ],
137
+ dependencies: [
138
+ // Dependencies declare other packages that this package depends on.
139
+ ],
140
+ targets: [
141
+ .target(
142
+ name: "SharedWidget",
143
+ dependencies: []
144
+ )
145
+ ]
146
+ )${os_1.EOL}`;
147
+ fs.writeFileSync(sharedWidgetPackagePath, content);
148
+ content = `import ActivityKit
149
+ import WidgetKit
150
+
151
+ public struct ${(0, utils_1.capitalizeFirstLetter)(name)}Model: ActivityAttributes {
152
+ public typealias DeliveryStatus = ContentState
153
+
154
+ public struct ContentState: Codable, Hashable {
155
+ // Dynamic stateful properties about your activity go here!
156
+ public var driverName: String
157
+ public var estimatedDeliveryTime: ClosedRange<Date>
158
+
159
+ public init(driverName: String, estimatedDeliveryTime: ClosedRange<Date>) {
160
+ self.driverName = driverName
161
+ self.estimatedDeliveryTime = estimatedDeliveryTime
162
+ }
163
+ }
164
+
165
+ // Fixed non-changing properties about your activity go here!
166
+ public var numberOfPizzas: Int
167
+ public var totalAmount: String
168
+
169
+ public init(numberOfPizzas: Int, totalAmount: String) {
170
+ self.numberOfPizzas = numberOfPizzas
171
+ self.totalAmount = totalAmount
172
+ }
173
+ }${os_1.EOL}`;
174
+ fs.writeFileSync(sharedWidgetSourcePath, content);
175
+ // update spm package
176
+ const configData = this.$projectConfigService.readConfig(projectDir);
177
+ if (!configData.ios) {
178
+ configData.ios = {};
179
+ }
180
+ if (!configData.ios.SPMPackages) {
181
+ configData.ios.SPMPackages = [];
182
+ }
183
+ const spmPackages = configData.ios.SPMPackages;
184
+ const sharedWidgetPackage = spmPackages === null || spmPackages === void 0 ? void 0 : spmPackages.find((p) => p.name === "SharedWidget");
185
+ if (!sharedWidgetPackage) {
186
+ spmPackages.push({
187
+ name: "SharedWidget",
188
+ libs: ["SharedWidget"],
189
+ path: "./Shared_Resources/iOS/SharedWidget",
190
+ // @ts-ignore
191
+ targets: [name],
192
+ });
193
+ }
194
+ else {
195
+ // add target if needed
196
+ if (!((_a = sharedWidgetPackage.targets) === null || _a === void 0 ? void 0 : _a.includes(name))) {
197
+ sharedWidgetPackage.targets.push(name);
198
+ }
199
+ }
200
+ configData.ios.SPMPackages = spmPackages;
201
+ yield this.$projectConfigService.setValue("", // root
202
+ configData);
203
+ if (fs.existsSync(gitIgnorePath)) {
204
+ const gitIgnore = fs.readFileSync(gitIgnorePath, {
205
+ encoding: "utf-8",
206
+ });
207
+ const swiftBuildIgnore = `# Swift
208
+ .build
209
+ .swiftpm`;
210
+ if (gitIgnore.indexOf(swiftBuildIgnore) === -1) {
211
+ content = `${gitIgnore}${os_1.EOL}${swiftBuildIgnore}${os_1.EOL}`;
212
+ fs.writeFileSync(gitIgnorePath, content);
213
+ }
214
+ }
215
+ console.log(`\nCreated Shared Resources: ${sharedWidgetDir}.\n`);
216
+ }
217
+ });
218
+ }
219
+ generateWidget(projectDir, name, type) {
220
+ const appResourcePath = this.$projectData.appResourcesDirectoryPath;
221
+ const capitalName = (0, utils_1.capitalizeFirstLetter)(name);
222
+ const appInfoPlistPath = path.join(appResourcePath, "iOS", "Info.plist");
223
+ const extensionDir = path.join(appResourcePath, "iOS", "extensions");
224
+ const widgetPath = path.join(extensionDir, name);
225
+ const extensionProvisionPath = path.join(extensionDir, `provisioning.json`);
226
+ const extensionsInfoPath = path.join(widgetPath, `Info.plist`);
227
+ const extensionsPrivacyPath = path.join(widgetPath, `PrivacyInfo.xcprivacy`);
228
+ const extensionsConfigPath = path.join(widgetPath, `extension.json`);
229
+ const entitlementsPath = path.join(widgetPath, `${name}.entitlements`);
230
+ const widgetBundlePath = path.join(widgetPath, `${capitalName}Bundle.swift`);
231
+ const widgetHomeScreenPath = path.join(widgetPath, `${capitalName}HomeScreenWidget.swift`);
232
+ const widgetLiveActivityPath = path.join(widgetPath, `${capitalName}LiveActivity.swift`);
233
+ const appIntentPath = path.join(widgetPath, `AppIntent.swift`);
234
+ // const widgetLockScreenControlPath = path.join(
235
+ // widgetPath,
236
+ // `${capitalName}LockScreenControl.swift`
237
+ // );
238
+ const appEntitlementsPath = path.join(appResourcePath, "iOS", "app.entitlements");
239
+ if (!fs.existsSync(extensionsConfigPath)) {
240
+ fs.mkdirSync(widgetPath, { recursive: true });
241
+ let content = `<?xml version="1.0" encoding="UTF-8"?>
242
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
243
+ <plist version="1.0">
244
+ <dict>
245
+ <key>NSExtension</key>
246
+ <dict>
247
+ <key>NSExtensionPointIdentifier</key>
248
+ <string>com.apple.widgetkit-extension</string>
249
+ </dict>
250
+ </dict>
251
+ </plist>${os_1.EOL}`;
252
+ fs.writeFileSync(extensionsInfoPath, content);
253
+ content = `<?xml version="1.0" encoding="UTF-8"?>
254
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
255
+ <plist version="1.0">
256
+ <dict>
257
+ <key>NSPrivacyAccessedAPITypes</key>
258
+ <array>
259
+ <dict>
260
+ <key>NSPrivacyAccessedAPIType</key>
261
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
262
+ <key>NSPrivacyAccessedAPITypeReasons</key>
263
+ <array>
264
+ <string>CA92.1</string>
265
+ </array>
266
+ </dict>
267
+ </array>
268
+ <key>NSPrivacyCollectedDataTypes</key>
269
+ <array/>
270
+ <key>NSPrivacyTracking</key>
271
+ <false/>
272
+ </dict>
273
+ </plist>${os_1.EOL}`;
274
+ fs.writeFileSync(extensionsPrivacyPath, content);
275
+ // TODO: can add control (lock screen custom control icon handler) in future
276
+ // ${[1, 2].includes(type) ? capitalName + "LockScreenControl()" : ""}
277
+ content = `import WidgetKit
278
+ import SwiftUI
279
+
280
+ @main
281
+ struct ${capitalName}Bundle: WidgetBundle {
282
+ var body: some Widget {
283
+ ${[1, 2].includes(type) ? capitalName + "HomeScreenWidget()" : ""}
284
+ ${[0, 1].includes(type) ? capitalName + "LiveActivity()" : ""}
285
+ }
286
+ }${os_1.EOL}`;
287
+ fs.writeFileSync(widgetBundlePath, content);
288
+ content = `import WidgetKit
289
+ import AppIntents
290
+
291
+ struct ConfigurationAppIntent: WidgetConfigurationIntent {
292
+ static var title: LocalizedStringResource { "Pizza Delivery" }
293
+ static var description: IntentDescription { "Get up to date delivery details" }
294
+
295
+ // An example configurable parameter.
296
+ @Parameter(title: "Favorite Pizza", default: "🍕")
297
+ var favoritePizza: String
298
+
299
+ @Parameter(title: "Random", default: "Hello")
300
+ var random: String
301
+ }${os_1.EOL}`;
302
+ fs.writeFileSync(appIntentPath, content);
303
+ if ([0, 1].includes(type)) {
304
+ content = `import ActivityKit
305
+ import SwiftUI
306
+ import WidgetKit
307
+ import Foundation
308
+ import SharedWidget
309
+
310
+ struct ${capitalName}LiveActivity: Widget {
311
+ var body: some WidgetConfiguration {
312
+ ActivityConfiguration(for: ${capitalName}Model.self) { context in
313
+ // Lock screen/banner UI goes here
314
+ ContentView(driver: context.state.driverName)
315
+ .activityBackgroundTint(Color.black)
316
+ .activitySystemActionForegroundColor(Color.white)
317
+
318
+ } dynamicIsland: { context in
319
+ DynamicIsland {
320
+ // Expanded UI goes here. Compose the expanded UI through
321
+ // various regions, like leading/trailing/center/bottom
322
+ DynamicIslandExpandedRegion(.leading) {
323
+ if let timeLeft = timeLeft(range1: Date(), range2: context.state.estimatedDeliveryTime) {
324
+ Image(systemName: "car")
325
+ .resizable()
326
+ .scaledToFit()
327
+ .frame(width: 50, height: 50) // Adjust size
328
+ .foregroundColor(timeLeft <= 1000 ? Color.green : Color.orange)
329
+ }
330
+ }
331
+ DynamicIslandExpandedRegion(.trailing) {
332
+ if let timeLeft = timeLeft(range1: Date(), range2: context.state.estimatedDeliveryTime) {
333
+ ProgressView(value: timeLeft, total: 3600)
334
+ .progressViewStyle(.circular)
335
+ .tint(timeLeft <= 1000 ? Color.green : Color.orange)
336
+ }
337
+ }
338
+ DynamicIslandExpandedRegion(.bottom) {
339
+ if let timeLeft = timeLeft(range1: Date(), range2: context.state.estimatedDeliveryTime) {
340
+ Text("\\(context.state.driverName) \\(timeLeft <= 0 ? "has arrived!" : String(format: "is %.1f min away", timeLeft / 60))")
341
+ }
342
+ }
343
+ } compactLeading: {
344
+ if let timeLeft = timeLeft(range1: Date(), range2: context.state.estimatedDeliveryTime) {
345
+ Image(systemName: "car")
346
+ .resizable()
347
+ .scaledToFit()
348
+ .frame(width: 20, height: 20)
349
+ .foregroundColor(timeLeft <= 0 ? .green : .orange)
350
+ }
351
+ } compactTrailing: {
352
+ if let timeLeft = timeLeft(range1: Date(), range2: context.state.estimatedDeliveryTime) {
353
+ Image(systemName: "timer.circle.fill")
354
+ .resizable()
355
+ .scaledToFit()
356
+ .frame(width: 20, height: 20)
357
+ .foregroundColor(timeLeft <= 0 ? .green : .orange)
358
+ }
359
+ } minimal: {
360
+ Text(context.state.driverName).font(.system(size: 12))
361
+ }
362
+ .widgetURL(URL(string: "http://www.apple.com"))
363
+ .keylineTint(Color.red)
364
+ }
365
+ }
366
+
367
+ func timeLeft(range1: Date, range2: ClosedRange<Date>) -> TimeInterval? {
368
+ let end = min(range1, range2.upperBound)
369
+
370
+ if end > range1 {
371
+ let remaining = end.timeIntervalSince(range1)
372
+ print("Time left: \\(remaining)")
373
+ return remaining
374
+ } else {
375
+ return 0
376
+ }
377
+ }
378
+ }
379
+
380
+ struct ContentView: View {
381
+ @State var driver = ""
382
+
383
+ var body: some View {
384
+ HStack {
385
+ Spacer()
386
+ Image(uiImage: UIImage(named: "pizza-live") ?? UIImage())
387
+ Spacer()
388
+ Text("\\(driver) is on \\(driver == "Sally" ? "her" : "his") way!")
389
+ Spacer()
390
+ }.frame(maxWidth: .infinity, maxHeight: .infinity)
391
+ }
392
+ }${os_1.EOL}`;
393
+ fs.writeFileSync(widgetLiveActivityPath, content);
394
+ }
395
+ if ([1, 2].includes(type)) {
396
+ content = `import SwiftUI
397
+ import WidgetKit
398
+
399
+ struct Provider: AppIntentTimelineProvider {
400
+ func placeholder(in context: Context) -> SimpleEntry {
401
+ SimpleEntry(date: Date(), random: "Starting", configuration: ConfigurationAppIntent())
402
+ }
403
+
404
+ func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry
405
+ {
406
+ SimpleEntry(date: Date(), random: configuration.random, configuration: configuration)
407
+ }
408
+
409
+ func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<
410
+ SimpleEntry
411
+ > {
412
+ var entries: [SimpleEntry] = []
413
+
414
+ // Generate a timeline consisting of five entries a second apart, starting from the current time.
415
+ let currentDate = Date()
416
+ for secondOffset in 0..<5 {
417
+ let entryDate = Calendar.current.date(
418
+ byAdding: .second, value: secondOffset, to: currentDate)!
419
+ var config = configuration
420
+ switch (secondOffset) {
421
+ case 1:
422
+ config = .pepperoni
423
+ case 2:
424
+ config = .supreme
425
+ case 3:
426
+ config = .cowboy
427
+ case 4:
428
+ config = .pineswine
429
+ default:
430
+ break;
431
+ }
432
+ let entry = SimpleEntry(date: entryDate, random: config.random, configuration: config)
433
+ entries.append(entry)
434
+ }
435
+
436
+ return Timeline(entries: entries, policy: .atEnd)
437
+ }
438
+ }
439
+
440
+ struct SimpleEntry: TimelineEntry {
441
+ let date: Date
442
+ let random: String
443
+ let configuration: ConfigurationAppIntent
444
+ }
445
+
446
+ struct WidgetView: View {
447
+ var entry: Provider.Entry
448
+
449
+ var body: some View {
450
+ ZStack {
451
+ Image(uiImage: UIImage(named: "pizza") ?? UIImage()).frame(
452
+ maxWidth: .infinity, maxHeight: .infinity)
453
+ VStack {
454
+ Text("Time:")
455
+ .foregroundStyle(.white)
456
+ Text(entry.date, style: .time)
457
+ .foregroundStyle(.white)
458
+ Text("Random City:")
459
+ .foregroundStyle(.white)
460
+ Text(entry.configuration.random)
461
+ .foregroundStyle(.white)
462
+ Text("Favorite Pizza:")
463
+ .foregroundStyle(.white)
464
+ Text(entry.configuration.favoritePizza)
465
+ .foregroundStyle(.white)
466
+ }
467
+ }.frame(maxWidth: .infinity, maxHeight: .infinity)
468
+ }
469
+ }
470
+
471
+ @available(iOSApplicationExtension 17.0, *)
472
+ struct ${capitalName}HomeScreenWidget: Widget {
473
+ let kind: String = "widget"
474
+
475
+ var body: some WidgetConfiguration {
476
+ AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) {
477
+ entry in
478
+ WidgetView(entry: entry)
479
+ .containerBackground(.fill.tertiary, for: .widget)
480
+ }
481
+ }
482
+ }
483
+
484
+ extension ConfigurationAppIntent {
485
+ fileprivate static var pepperoni: ConfigurationAppIntent {
486
+ let intent = ConfigurationAppIntent()
487
+ intent.favoritePizza = "Pepperoni"
488
+ intent.random = "Georgia"
489
+ return intent
490
+ }
491
+ fileprivate static var supreme: ConfigurationAppIntent {
492
+ let intent = ConfigurationAppIntent()
493
+ intent.favoritePizza = "Supreme"
494
+ intent.random = "Kansas City"
495
+ return intent
496
+ }
497
+
498
+ fileprivate static var cowboy: ConfigurationAppIntent {
499
+ let intent = ConfigurationAppIntent()
500
+ intent.favoritePizza = "Cowboy"
501
+ intent.random = "Nashville"
502
+ return intent
503
+ }
504
+
505
+ fileprivate static var pineswine: ConfigurationAppIntent {
506
+ let intent = ConfigurationAppIntent()
507
+ intent.favoritePizza = "Pine & Swine"
508
+ intent.random = "Portland"
509
+ return intent
510
+ }
511
+ }
512
+
513
+ #Preview(as: .systemSmall) {
514
+ ${capitalName}HomeScreenWidget()
515
+ } timeline: {
516
+ SimpleEntry(date: .now, random: "Atlanta", configuration: .pepperoni)
517
+ SimpleEntry(date: .now, random: "Austin", configuration: .supreme)
518
+ }${os_1.EOL}`;
519
+ fs.writeFileSync(widgetHomeScreenPath, content);
520
+ }
521
+ const bundleId = this.$projectConfigService.getValue(`id`, "");
522
+ content = `{
523
+ "${bundleId}.${name}": "{set-your-provision-profile-id}"
524
+ }`;
525
+ fs.writeFileSync(extensionProvisionPath, content);
526
+ content = `<?xml version="1.0" encoding="UTF-8"?>
527
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
528
+ <plist version="1.0">
529
+ <dict>
530
+ <key>com.apple.security.application-groups</key>
531
+ <array>
532
+ <string>group.${bundleId}</string>
533
+ </array>
534
+ </dict>
535
+ </plist>${os_1.EOL}`;
536
+ fs.writeFileSync(entitlementsPath, content);
537
+ if (fs.existsSync(appInfoPlistPath)) {
538
+ const appSupportLiveActivity = "NSSupportsLiveActivities";
539
+ const appInfoPlist = plist.parse(fs.readFileSync(appInfoPlistPath, {
540
+ encoding: "utf-8",
541
+ }));
542
+ if (!appInfoPlist[appSupportLiveActivity]) {
543
+ // @ts-ignore
544
+ appInfoPlist[appSupportLiveActivity] = true;
545
+ const appPlist = plist.build(appInfoPlist);
546
+ fs.writeFileSync(appInfoPlistPath, appPlist);
547
+ }
548
+ }
549
+ const appGroupKey = "com.apple.security.application-groups";
550
+ if (fs.existsSync(appEntitlementsPath)) {
551
+ const appEntitlementsPlist = plist.parse(fs.readFileSync(appEntitlementsPath, {
552
+ encoding: "utf-8",
553
+ }));
554
+ if (!appEntitlementsPlist[appGroupKey]) {
555
+ // @ts-ignore
556
+ appEntitlementsPlist[appGroupKey] = [`group.${bundleId}`];
557
+ const appEntitlements = plist.build(appEntitlementsPlist);
558
+ console.log("appentitlement:", appEntitlements);
559
+ fs.writeFileSync(appEntitlementsPath, appEntitlements);
560
+ }
561
+ }
562
+ else {
563
+ content = `<?xml version="1.0" encoding="UTF-8"?>
564
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
565
+ <plist version="1.0">
566
+ <dict>
567
+ <key>com.apple.security.application-groups</key>
568
+ <array>
569
+ <string>group.${bundleId}</string>
570
+ </array>
571
+ </dict>
572
+ </plist>${os_1.EOL}`;
573
+ fs.writeFileSync(appEntitlementsPath, content);
574
+ }
575
+ content = `{
576
+ "frameworks": [
577
+ "SwiftUI.framework",
578
+ "WidgetKit.framework"
579
+ ],
580
+ "targetBuildConfigurationProperties": {
581
+ "ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME": "AccentColor",
582
+ "ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME": "WidgetBackground",
583
+ "CLANG_ANALYZER_NONNULL": "YES",
584
+ "CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION": "YES_AGGRESSIVE",
585
+ "CLANG_CXX_LANGUAGE_STANDARD": "\\"gnu++20\\"",
586
+ "CLANG_ENABLE_OBJC_WEAK": "YES",
587
+ "CLANG_WARN_DOCUMENTATION_COMMENTS": "YES",
588
+ "CLANG_WARN_UNGUARDED_AVAILABILITY": "YES_AGGRESSIVE",
589
+ "CURRENT_PROJECT_VERSION": 1,
590
+ "GCC_C_LANGUAGE_STANDARD": "gnu11",
591
+ "GCC_WARN_UNINITIALIZED_AUTOS": "YES_AGGRESSIVE",
592
+ "GENERATE_INFOPLIST_FILE": "YES",
593
+ "INFOPLIST_KEY_CFBundleDisplayName": "widget",
594
+ "INFOPLIST_KEY_NSHumanReadableCopyright": "\\"Copyright © All rights reserved.\\"",
595
+ "IPHONEOS_DEPLOYMENT_TARGET": 18.0,
596
+ "MARKETING_VERSION": "1.0",
597
+ "MTL_FAST_MATH": "YES",
598
+ "PRODUCT_NAME": "widget",
599
+ "SWIFT_EMIT_LOC_STRINGS": "YES",
600
+ "SWIFT_VERSION": "5.0",
601
+ "TARGETED_DEVICE_FAMILY": "\\"1,2\\"",
602
+ "MTL_ENABLE_DEBUG_INFO": "NO",
603
+ "SWIFT_OPTIMIZATION_LEVEL": "\\"-O\\"",
604
+ "COPY_PHASE_STRIP": "NO",
605
+ "SWIFT_COMPILATION_MODE": "wholemodule",
606
+ "CODE_SIGN_ENTITLEMENTS": "../../App_Resources/iOS/extensions/${name}/${name}.entitlements"
607
+ },
608
+ "targetNamedBuildConfigurationProperties": {
609
+ "debug": {
610
+ "DEBUG_INFORMATION_FORMAT": "dwarf",
611
+ "GCC_PREPROCESSOR_DEFINITIONS": "(\\"DEBUG=1\\",\\"$(inherited)\\",)",
612
+ "MTL_ENABLE_DEBUG_INFO": "INCLUDE_SOURCE",
613
+ "SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
614
+ "SWIFT_OPTIMIZATION_LEVEL": "\\"-Onone\\""
615
+ },
616
+ "release": {
617
+ "CODE_SIGN_STYLE": "Manual",
618
+ "MTL_ENABLE_DEBUG_INFO": "NO",
619
+ "SWIFT_OPTIMIZATION_LEVEL": "\\"-O\\"",
620
+ "COPY_PHASE_STRIP": "NO",
621
+ "SWIFT_COMPILATION_MODE": "wholemodule"
622
+ }
623
+ }
624
+ }${os_1.EOL}`;
625
+ fs.writeFileSync(extensionsConfigPath, content);
626
+ console.log(`🚀 Your widget is now ready to develop: App_Resources/iOS/extensions/${name}.\n`);
627
+ console.log(`Followup steps:\n
628
+ - Update App_Resources/iOS/extensions/provisioning.json with your profile id.
629
+ - Customize App_Resources/iOS/extensions/${name}/${(0, utils_1.capitalizeFirstLetter)(name)}LiveActivity.swift for your display.
630
+ - Customize Shared_Resources/iOS/SharedWidget/Sources/SharedWidget/${(0, utils_1.capitalizeFirstLetter)(name)}Model.swift for your data.
631
+ `);
632
+ }
633
+ // if (fs.existsSync(filePath)) {
634
+ // this.$errors.failWithHelp(`Error: File '${filePath}' already exists.`);
635
+ // return;
636
+ // }
637
+ }
638
+ generateAppleUtility(projectDir, name) {
639
+ const appResourcePath = this.$projectData.appResourcesDirectoryPath;
640
+ const appResourceSrcPath = path.join(appResourcePath, "iOS", "src");
641
+ const appleUtilityPath = path.join(appResourceSrcPath, `AppleWidgetUtils.swift`);
642
+ const referenceTypesPath = path.join(projectDir, "references.d.ts");
643
+ if (!fs.existsSync(appleUtilityPath)) {
644
+ fs.mkdirSync(appResourceSrcPath, { recursive: true });
645
+ }
646
+ if (!fs.existsSync(appleUtilityPath)) {
647
+ }
648
+ let content = `import Foundation
649
+ import UIKit
650
+ import ActivityKit
651
+ import WidgetKit
652
+ import SharedWidget
653
+
654
+ @objcMembers
655
+ public class AppleWidgetUtils: NSObject {
656
+
657
+ // Live Activity Handling
658
+ public static func startActivity(_ data: NSDictionary) {
659
+ if ActivityAuthorizationInfo().areActivitiesEnabled {
660
+ let numberOfPizzas = data.object(forKey: "numberOfPizzas") as! Int
661
+ let totalAmount = data.object(forKey: "totalAmount") as! String
662
+ let attrs = ${(0, utils_1.capitalizeFirstLetter)(name)}Model(numberOfPizzas: numberOfPizzas, totalAmount: totalAmount)
663
+
664
+ let driverName = data.object(forKey: "driverName") as! String
665
+ let deliveryTime = data.object(forKey: "deliveryTime") as! CGFloat
666
+ let initialStatus = ${(0, utils_1.capitalizeFirstLetter)(name)}Model.DeliveryStatus(
667
+ driverName: driverName, estimatedDeliveryTime: Date()...Date().addingTimeInterval(deliveryTime * 60))
668
+ let content = ActivityContent(state: initialStatus, staleDate: nil)
669
+
670
+ do {
671
+ let activity = try Activity<${(0, utils_1.capitalizeFirstLetter)(name)}Model>.request(
672
+ attributes: attrs,
673
+ content: content,
674
+ pushType: nil)
675
+ print("Requested a Live Activity \\(activity.id)")
676
+ } catch (let error) {
677
+ print("Error requesting Live Activity \\(error.localizedDescription)")
678
+ }
679
+ }
680
+ }
681
+ public static func updateActivity(_ data: NSDictionary) {
682
+ if ActivityAuthorizationInfo().areActivitiesEnabled {
683
+ Task {
684
+ let driverName = data.object(forKey: "driverName") as! String
685
+ let deliveryTime = data.object(forKey: "deliveryTime") as! CGFloat
686
+ let status = ${(0, utils_1.capitalizeFirstLetter)(name)}Model.DeliveryStatus(
687
+ driverName: driverName, estimatedDeliveryTime: Date()...Date().addingTimeInterval(deliveryTime * 60))
688
+ let content = ActivityContent(state: status, staleDate: nil)
689
+
690
+ for activity in Activity<${(0, utils_1.capitalizeFirstLetter)(name)}Model>.activities {
691
+ await activity.update(content)
692
+ }
693
+ }
694
+ }
695
+ }
696
+ public static func cancelActivity(_ data: NSDictionary) {
697
+ if ActivityAuthorizationInfo().areActivitiesEnabled {
698
+ Task {
699
+ let driverName = data.object(forKey: "driverName") as! String
700
+ let status = ${(0, utils_1.capitalizeFirstLetter)(name)}Model.DeliveryStatus(
701
+ driverName: driverName, estimatedDeliveryTime: Date()...Date())
702
+ let content = ActivityContent(state: status, staleDate: nil)
703
+
704
+ for activity in Activity<${(0, utils_1.capitalizeFirstLetter)(name)}Model>.activities {
705
+ await activity.end(content, dismissalPolicy: .immediate)
706
+ }
707
+ }
708
+ }
709
+ }
710
+ public static func showAllActivities() {
711
+ if ActivityAuthorizationInfo().areActivitiesEnabled {
712
+ Task {
713
+ for activity in Activity<${(0, utils_1.capitalizeFirstLetter)(name)}Model>.activities {
714
+ print("Activity Details: \\(activity.id) -> \\(activity.attributes)")
715
+ }
716
+ }
717
+ }
718
+ }
719
+
720
+ // Home Screen Widget Handling
721
+ public static func updateWidget() {
722
+ if #available(iOS 14.0, *) {
723
+ Task.detached(priority: .userInitiated) {
724
+ WidgetCenter.shared.reloadAllTimelines()
725
+ }
726
+ }
727
+ }
728
+ }${os_1.EOL}`;
729
+ fs.writeFileSync(appleUtilityPath, content);
730
+ content = `/**
731
+ * Customize for your own Apple Widget Data
732
+ */
733
+ declare interface AppleWidgetModelData {
734
+ numberOfPizzas: number;
735
+ totalAmount: string;
736
+ driverName: string;
737
+ deliveryTime: number;
738
+ }
739
+ declare class AppleWidgetUtils extends NSObject {
740
+ static startActivity(data: AppleWidgetModelData): void;
741
+ static updateActivity(
742
+ data: Pick<AppleWidgetModelData, "driverName" | "deliveryTime">
743
+ ): void;
744
+ static cancelActivity(data: Pick<AppleWidgetModelData, "driverName">): void;
745
+ static showAllActivities(): void;
746
+ static updateWidget(): void;
747
+ }${os_1.EOL}`;
748
+ if (!fs.existsSync(referenceTypesPath)) {
749
+ const references = `/// <reference path="./node_modules/@nativescript/types-android/index.d.ts" />
750
+ /// <reference path="./node_modules/@nativescript/types-ios/complete.d.ts" />${os_1.EOL}${content}`;
751
+ fs.writeFileSync(referenceTypesPath, references);
752
+ }
753
+ else {
754
+ const references = fs.readFileSync(referenceTypesPath, {
755
+ encoding: "utf-8",
756
+ });
757
+ if ((references === null || references === void 0 ? void 0 : references.indexOf("AppleWidgetUtils")) === -1) {
758
+ content = `${references.toString()}${os_1.EOL}${content}`;
759
+ fs.writeFileSync(referenceTypesPath, content);
760
+ }
761
+ }
762
+ }
763
+ }
764
+ exports.WidgetIOSCommand = WidgetIOSCommand;
765
+ yok_1.injector.registerCommand(["widget"], WidgetCommand);
766
+ yok_1.injector.registerCommand(["widget|ios"], WidgetIOSCommand);
767
+ //# sourceMappingURL=widget.js.map