stim 1.20.2 → 1.22.0

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 (231) hide show
  1. package/README.md +141 -8
  2. package/dist/acquire-artifact-Co2k4f7O.mjs +171 -0
  3. package/dist/act-DsuqEkiM.mjs +2801 -0
  4. package/dist/activity-CMLmzp7o.mjs +1397 -0
  5. package/dist/{agent-device-usage-output-Dzgv6lgR.mjs → agent-device-usage-output-DUFaTMdd.mjs} +23 -67
  6. package/dist/{android-DCKZrNvV.mjs → android-ByRMUoiJ.mjs} +157 -93
  7. package/dist/{android-Mz_Inn3w.mjs → android-C7sVmyI9.mjs} +299 -116
  8. package/dist/{android-Dlzxshgp.mjs → android-DGkNqa_c.mjs} +5 -5
  9. package/dist/{android-HqP1_vB_.mjs → android-DR5lZ2Az.mjs} +2 -2
  10. package/dist/android-cas-compiler.mjs +2 -2
  11. package/dist/{android-cas-Bl-cLJBk.mjs → android-cas-ngferVq2.mjs} +7 -6
  12. package/dist/android-project-BCAAmMwz.mjs +12 -0
  13. package/dist/android-project-DVWyCbWU.d.mts +391 -0
  14. package/dist/api.d.mts +810 -64
  15. package/dist/api.mjs +782 -1
  16. package/dist/{artifact-HSwkIWEQ.mjs → artifact-8EY8SAPw.mjs} +240 -213
  17. package/dist/{artifact-D3czlUvT.mjs → artifact-DJPy518Y.mjs} +203 -164
  18. package/dist/artifact-platform-CXcmX_j3.mjs +27 -0
  19. package/dist/{browser-web-CA-F1GQo.mjs → browser-web-Bcv99PBM.mjs} +194 -64
  20. package/dist/budget-Cvwn54qV.mjs +9285 -0
  21. package/dist/{build-DYDbfkk5.mjs → build-CabC3G23.mjs} +153 -98
  22. package/dist/build-cache-Dv7RN200.mjs +602 -0
  23. package/dist/build-plan-DUC8Ka9y.mjs +248 -0
  24. package/dist/{cache-manifest-XH-fvDUj.mjs → cache-manifest-DSeQjt-Q.mjs} +2 -2
  25. package/dist/cache-manifest.mjs +1 -1
  26. package/dist/{ccache-zdKiYQ3E.mjs → ccache-Btwc36-I.mjs} +10 -9
  27. package/dist/{cdp-Dq_ypAlJ.mjs → cdp-3fwICjzi.mjs} +18 -5
  28. package/dist/{chrome-BnzZMqsR.mjs → chrome-Bbw689-6.mjs} +7 -4
  29. package/dist/{cli-CLP3diBm.mjs → cli-CHZa9Lvk.mjs} +20 -20
  30. package/dist/cli.mjs +1 -1
  31. package/dist/client-OyRoEuSr.mjs +1577 -0
  32. package/dist/collector-run.d.mts +4 -40
  33. package/dist/collector-run.mjs +9 -8
  34. package/dist/{command-output-BTy8hZ0F.mjs → command-output-gwpm28fu.mjs} +1 -1
  35. package/dist/config-DlrsduwG.mjs +955 -0
  36. package/dist/{created-devices-Dzd5C2LF.mjs → created-devices-x9rN6bhs.mjs} +14 -4
  37. package/dist/{dependency-state-DG0p31-y.mjs → dependency-state-1I9KZT1Y.mjs} +20 -5
  38. package/dist/{detached-entry-B9C_zeQC.mjs → detached-entry-BwNEtIrP.mjs} +1 -1
  39. package/dist/{dev-client-DAWVIGBu.mjs → dev-client-BSDR5h3F.mjs} +2 -2
  40. package/dist/{device-BECOiufl.mjs → device-B-L3Fbxy.mjs} +91 -34
  41. package/dist/device-DklWZLqb.mjs +1068 -0
  42. package/dist/{device-capacity-CBUAcRyQ.mjs → device-capacity-DK5_EwRS.mjs} +42 -13
  43. package/dist/device-host-worker.mjs +76 -79
  44. package/dist/{device-ios-COSi6oS1.mjs → device-ios-DoB6KFCO.mjs} +77 -51
  45. package/dist/{device-lease-run-Cw2M4z51.mjs → device-lease-run-xJPQ_QQG.mjs} +14 -26
  46. package/dist/{device-pool-Bf-pOhSw.mjs → device-pool-BMkdsefq.mjs} +5 -5
  47. package/dist/{doctor-kfMBnUw6.mjs → doctor-Bo7BXLux.mjs} +271 -320
  48. package/dist/{doctor-CB8oZKCk.mjs → doctor-D5_EzwfA.mjs} +186 -91
  49. package/dist/doctor-fingerprint-DZLoYFVb.mjs +16 -0
  50. package/dist/doctor-fingerprint.mjs +19 -0
  51. package/dist/doctor-thjWAV0z.mjs +2 -0
  52. package/dist/{doctor-watchman-BRyV2adA.mjs → doctor-watchman-N2wDotwQ.mjs} +40 -21
  53. package/dist/{eas-build-JyfqyHfC.mjs → eas-build-CwknaQYj.mjs} +53 -20
  54. package/dist/{build-plan-B7SZsc2N.mjs → eas-fallback-CSgAulr5.mjs} +41 -214
  55. package/dist/{watchman-CPQFZLXY.mjs → eas-session-ledger-DlY_serQ.mjs} +230 -11
  56. package/dist/{error-diagnostics-BR677IDM.mjs → error-diagnostics-DBWO2rxE.mjs} +172 -82
  57. package/dist/exec-DEoAhcze.mjs +858 -0
  58. package/dist/exec-DnYc4HGH.d.mts +78 -0
  59. package/dist/{gc-qWOMdnER.mjs → gc-CXxN-4SE.mjs} +1091 -1029
  60. package/dist/gc-DnNDQyaP.mjs +3 -0
  61. package/dist/{guide-G9cAbVAc.mjs → guide-Br0LEfKy.mjs} +1165 -297
  62. package/dist/{hosted-android-C3MHGld1.mjs → hosted-android-B-9f-jkd.mjs} +10 -8
  63. package/dist/{hosted-client-ZEKpS9vw.mjs → hosted-client-DZAPrcro.mjs} +34 -19
  64. package/dist/{hosted-ios-l-o3iM9J.mjs → hosted-ios-CsCS21hn.mjs} +1 -1
  65. package/dist/{hosted-logs-EzQM7-3Z.mjs → hosted-logs-FIRx9X2f.mjs} +77 -43
  66. package/dist/{hosted-macos-BACVAVqE.mjs → hosted-macos-_awYSpfv.mjs} +35 -22
  67. package/dist/{hosted-native-A4s1QPXe.mjs → hosted-native-BdzE668-.mjs} +49 -27
  68. package/dist/idle-C4cZ757K.d.mts +24 -0
  69. package/dist/{idle-shutdown-DtxhPTKe.mjs → idle-shutdown-DDg3SdvY.mjs} +11 -10
  70. package/dist/ios-CDvlmUs7.d.mts +24 -0
  71. package/dist/{ios-BwVCF7oA.mjs → ios-Ds1clbIt.mjs} +8 -8
  72. package/dist/{ios-device-D7pi2Sca.mjs → ios-device--h_-8ENa.mjs} +51 -26
  73. package/dist/{ios-device-B5veSDDQ.mjs → ios-device-BXZ0c7Kb.mjs} +1 -1
  74. package/dist/{ios-RkW4pnQf.mjs → ios-hcBpnEGk.mjs} +200 -93
  75. package/dist/{ios-Ce7bc7br.mjs → ios-pm4nL6By.mjs} +160 -108
  76. package/dist/{ios-project-K9hY_Jab.mjs → ios-project-CZhKODF3.mjs} +13 -13
  77. package/dist/ios-signing-BtAffm0A.mjs +489 -0
  78. package/dist/{ios-state-CBLe1xYw.mjs → ios-state-Dtw5K2aI.mjs} +1 -1
  79. package/dist/{ios-nOLJGVdy.mjs → ios-xtlRHaeB.mjs} +1 -1
  80. package/dist/{js-swap-Bb3nsS07.mjs → js-swap-Bwhh4S7V.mjs} +30 -25
  81. package/dist/{launch-C3qJ6Agb.mjs → launch-BjxemNpK.mjs} +85 -543
  82. package/dist/{launch-F4sOqAhB.mjs → launch-CCzXlc8r.mjs} +91 -90
  83. package/dist/logs-BfwwadsZ.mjs +479 -0
  84. package/dist/logs-jTS_lHSo.mjs +248 -0
  85. package/dist/{macos-D7uDvO-z.mjs → macos-DVlSSyUg.mjs} +1 -1
  86. package/dist/macos-NfV2D7dO.mjs +694 -0
  87. package/dist/macos-run.mjs +1 -1
  88. package/dist/maintenance-run.mjs +123 -248
  89. package/dist/{metro-DnCEjCxs.mjs → metro-DiXtA3Ty.mjs} +107 -30
  90. package/dist/metro-gateway-CKZqKqx7.mjs +209 -0
  91. package/dist/{named-ports-4WopRPg-.mjs → named-ports-DkEzOfzO.mjs} +42 -90
  92. package/dist/native-android-CqgnOgsT.mjs +645 -0
  93. package/dist/native-gradle-artifact-inputs-DHFnmrVf.mjs +270 -0
  94. package/dist/native-gradle-inputs-Dnh84Zbd.mjs +211 -0
  95. package/dist/native-inputs-TRTTTRxt.mjs +91 -0
  96. package/dist/native-run-NwUuxbkg.mjs +276 -0
  97. package/dist/{native-runtime-k8dTIrbK.mjs → native-runtime-B7KIafpM.mjs} +11 -9
  98. package/dist/native-source-Y0yLhFyQ.mjs +133 -0
  99. package/dist/{native-xcode-inputs-CykopJdM.mjs → native-xcode-inputs-D_VOfFL7.mjs} +26 -18
  100. package/dist/{native-xcode-ios-Bbf30Gm0.mjs → native-xcode-ios-BYDOHWLN.mjs} +104 -60
  101. package/dist/{ndjson-GOnbyvso.mjs → ndjson-CgE_o3Dl.mjs} +3 -3
  102. package/dist/offload-worker.d.mts +59 -41
  103. package/dist/offload-worker.mjs +478 -115
  104. package/dist/operation-exec-BW0em61G.mjs +171 -0
  105. package/dist/{ownership-DCtw_2IA.mjs → ownership-C5fo5Edb.mjs} +3 -3
  106. package/dist/{page-DRHy329N.mjs → page-DBL2PiUU.mjs} +12 -5
  107. package/dist/paths-BsJMoPP2.mjs +12 -0
  108. package/dist/paths-DQtTgsBf.mjs +42 -0
  109. package/dist/{placement-log-MOfPVgaM.mjs → placement-log-BnGgJRRZ.mjs} +5 -5
  110. package/dist/{plan-placement-V0TdzYXp.mjs → plan-placement-DIsMtN-d.mjs} +15 -11
  111. package/dist/{ports-DdSUicVo.mjs → ports-Cy1RkmuQ.mjs} +3 -3
  112. package/dist/prebuild-D4JoEAEs.mjs +484 -0
  113. package/dist/{project-_phNIJfs.mjs → project-wM_XFTvE.mjs} +65 -37
  114. package/dist/{pull-request-CQ8sPbZa.mjs → pull-request-W1IuLXDt.mjs} +102 -20
  115. package/dist/pull-request-eODyIqZF.d.mts +124 -0
  116. package/dist/pull-requests.d.mts +2 -120
  117. package/dist/pull-requests.mjs +2 -2
  118. package/dist/{react-native-android-CM1XRDwv.mjs → react-native-android-6OZ7MSM7.mjs} +121 -72
  119. package/dist/{gradle-DSrXb6lG.mjs → react-native-build-Dvd8hC21.mjs} +292 -15
  120. package/dist/react-native-doctor-DsoSF1Y9.mjs +234 -0
  121. package/dist/{react-native-ios-Dhq_eiYQ.mjs → react-native-ios-4u1Rn-GR.mjs} +71 -39
  122. package/dist/{recordings-D0d5aQt0.mjs → recordings-CQmfzAh7.mjs} +12 -9
  123. package/dist/registration-BcRgF6Ox.mjs +51 -0
  124. package/dist/{reload-C8JhxjSh.mjs → reload-BzkYabB-.mjs} +94 -47
  125. package/dist/reload-D7AVlb8N.mjs +2 -0
  126. package/dist/{remote-BiR6aYjy.mjs → remote-DjGDmlTZ.mjs} +26 -18
  127. package/dist/result-D2Ykz_iD.mjs +435 -0
  128. package/dist/{run-BtPgpKks.mjs → run-DidHghD1.mjs} +5 -5
  129. package/dist/selection-DSMbWEX2.mjs +620 -0
  130. package/dist/{server-bare-R2m_gsH8.mjs → server-bare-CafzuyFB.mjs} +3 -4
  131. package/dist/{server-command-CTtCkmcQ.mjs → server-command-C6QjeupS.mjs} +14 -7
  132. package/dist/{server-expo-DsguMGUF.mjs → server-expo-CrjB29pq.mjs} +54 -11
  133. package/dist/server-expo-D58c9L0M.mjs +2 -0
  134. package/dist/{settings-B717odTD.mjs → settings-C7O8A6ZI.mjs} +309 -119
  135. package/dist/settings-DpR-1Wnn.mjs +114 -0
  136. package/dist/settings-write-CzD60rOD.mjs +360 -0
  137. package/dist/settings.schema.json +176 -16
  138. package/dist/{simslim-CCr3rE-A.mjs → simslim-BNckWpXi.mjs} +14 -12
  139. package/dist/{slot-launch-DPt0m9Nd.mjs → slot-launch-CbfmNgM6.mjs} +15 -20
  140. package/dist/{spawn-entry-Dcb7sDUz.mjs → spawn-entry-jw19m8Nl.mjs} +0 -1
  141. package/dist/stage-Bps5oius.mjs +200 -0
  142. package/dist/{start-TXeMmmO2.mjs → start-Br-oxqMD.mjs} +1 -1
  143. package/dist/start-EojN4WFz.mjs +1364 -0
  144. package/dist/{state-D1Icyjlu.mjs → state--smjFSTL.mjs} +55 -13
  145. package/dist/{state-CG_OFoaA.mjs → state-08I3hw3_.mjs} +3 -2
  146. package/dist/{stats-BoY5sEPU.mjs → stats-D3GerlFW.mjs} +7 -13
  147. package/dist/stats-report-BzaPrRm6.mjs +16 -0
  148. package/dist/{status-BTA7kKiQ.mjs → status-BRROykC8.mjs} +7 -5
  149. package/dist/status-EvrK72L2.mjs +2 -0
  150. package/dist/{status-WgFbkRzj.mjs → status-WBDajew2.mjs} +554 -452
  151. package/dist/{status-watch-C23ILtf9.mjs → status-watch-Bg_u-pwR.mjs} +222 -25
  152. package/dist/status-worker.d.mts +1 -0
  153. package/dist/status-worker.mjs +19 -0
  154. package/dist/stim-desktop-D5OGpYZM.mjs +112 -0
  155. package/dist/{stop-DR6VoDIk.mjs → stop-DTZ9uTw3.mjs} +2 -2
  156. package/dist/{stop-DPEhunlw.mjs → stop-Dky10AEJ.mjs} +33 -23
  157. package/dist/{stop-BNmBMi1F.mjs → stop-Mv6W9FAk.mjs} +137 -98
  158. package/dist/supervisor-run.d.mts +8 -17
  159. package/dist/supervisor-run.mjs +56 -28
  160. package/dist/{support-CwjbFs9H.mjs → support-CNioewsd.mjs} +14 -14
  161. package/dist/{support-DMTqj3Hm.mjs → support-yUiOjnVY.mjs} +20 -13
  162. package/dist/swiftpm-artifact-inputs-DFcGsXDP.mjs +153 -0
  163. package/dist/swiftpm-macos-BIak-Rxv.mjs +532 -0
  164. package/dist/toolchain-BY8X8HXx.mjs +2 -0
  165. package/dist/toolchain-DpJMHq0n.mjs +876 -0
  166. package/dist/{trigger-CigAYjeL.mjs → trigger-Cbyc41d_.mjs} +21 -6
  167. package/dist/trigger-yb_nFzPF.mjs +2 -0
  168. package/dist/{warm-progress-BuY-Fvfn.mjs → warm-progress-CA3TgT3-.mjs} +263 -156
  169. package/dist/web-CZ07gd77.mjs +2 -0
  170. package/dist/{web-BDBMxDpx.mjs → web-DKx6yoFA.mjs} +20 -14
  171. package/dist/web-run.mjs +13 -12
  172. package/dist/windows-report.d.mts +1 -0
  173. package/dist/windows-report.mjs +18 -0
  174. package/dist/windows-report.ps1 +43 -0
  175. package/dist/{workspace-state-DJt_MMvf.mjs → workspace-state-U08dEzhG.mjs} +62 -58
  176. package/dist/{workspaces-C36s2jb9.mjs → workspaces-CpANmBlq.mjs} +1723 -1286
  177. package/dist/{worktree-CgvJYJ-Q.mjs → worktree-CHecZ4Oq.mjs} +1097 -547
  178. package/dist/worktree-ZqZVjD9K.mjs +2 -0
  179. package/dist/xcode-BXn9-xYx.mjs +896 -0
  180. package/package.json +7 -5
  181. package/shim/android-audio/Main.java +24 -0
  182. package/shim/android-audio/README.md +17 -0
  183. package/shim/android-audio.jar +0 -0
  184. package/shim/android-optimizations.gradle +7 -5
  185. package/dist/activity-BSV745Kz.mjs +0 -629
  186. package/dist/api-qvOzWyfO.mjs +0 -154
  187. package/dist/api-run.mjs +0 -294
  188. package/dist/app-install-BIKtMfPq.mjs +0 -896
  189. package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
  190. package/dist/budget-f7516Zk0.mjs +0 -4106
  191. package/dist/build-facts-DcLv2HSd.d.mts +0 -111
  192. package/dist/cancellation-C_22VQTH.mjs +0 -24
  193. package/dist/client-qQAaXSUs.mjs +0 -1771
  194. package/dist/config-BYDxlMY3.mjs +0 -562
  195. package/dist/device-DuiPJQSn.mjs +0 -290
  196. package/dist/device-lease-BX1sJQ2E.mjs +0 -1224
  197. package/dist/device-remote-xRT0Vmo9.mjs +0 -1272
  198. package/dist/eas-session-ledger-Cm0Gwq2F.mjs +0 -207
  199. package/dist/exec-DqKo9GKJ.mjs +0 -268
  200. package/dist/git-DDfFzkMm.mjs +0 -45
  201. package/dist/launch-verify-B6Q8hZP-.mjs +0 -428
  202. package/dist/logs-BGrEUaEs.mjs +0 -383
  203. package/dist/macos-Ch5VJmcS.mjs +0 -584
  204. package/dist/metro-gateway-CX9Xlkq2.mjs +0 -103
  205. package/dist/miss-reason-mKzZ4VvN.mjs +0 -238
  206. package/dist/native-android-D5qc3-_v.mjs +0 -226
  207. package/dist/native-gradle-inputs-BsLRrl7u.mjs +0 -349
  208. package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
  209. package/dist/plan-C4TjdPsR.mjs +0 -260
  210. package/dist/prebuild-DYbucPXy.mjs +0 -212
  211. package/dist/preview-78a9kR_-.mjs +0 -1011
  212. package/dist/react-native-build-CtCccJtb.mjs +0 -239
  213. package/dist/react-native-doctor-CfRnFfjs.mjs +0 -78
  214. package/dist/remote-cache-OyOyVIS3.mjs +0 -526
  215. package/dist/result-CaJg5Iat.mjs +0 -186
  216. package/dist/server-expo-Bigriskl.mjs +0 -2
  217. package/dist/settings-BORNaaCO.mjs +0 -402
  218. package/dist/settings-vk3mJGSm.d.mts +0 -13
  219. package/dist/spawn-claims-DVS5RkMS.mjs +0 -72
  220. package/dist/stage-KNTQopqv.mjs +0 -157
  221. package/dist/start-BWqzODpb.mjs +0 -1116
  222. package/dist/stim-desktop-BzBN2Em2.mjs +0 -63
  223. package/dist/swiftpm-macos-DRNVJWlb.mjs +0 -119
  224. package/dist/tailnet-Dh-qiYzG.mjs +0 -265
  225. package/dist/toolchain-BFkAcstd.mjs +0 -2
  226. package/dist/toolchain-DxSsNssu.mjs +0 -1657
  227. package/dist/trigger-9_USgmxz.mjs +0 -2
  228. package/dist/web-Dq-i3wzJ.mjs +0 -2
  229. package/dist/worktree-DpLdCHga.mjs +0 -2
  230. package/dist/{api-run.d.mts → doctor-fingerprint.d.mts} +0 -0
  231. package/dist/{errors-DzkMYh8Q.mjs → errors-ccaPc4ox.mjs} +2 -2
@@ -0,0 +1,532 @@
1
+ import { d as spawnDeclared, t as getExecutor, y as trackReportResource } from "./exec-DEoAhcze.mjs";
2
+ import { i as sharedBuildCache } from "./paths-DQtTgsBf.mjs";
3
+ import { G as resolveCacheProviderConfig, L as projectSettingsContextAsync, Nt as repoRootAsync, tt as settingValueAt } from "./settings-C7O8A6ZI.mjs";
4
+ import { r as register } from "./cache-manifest-DSeQjt-Q.mjs";
5
+ import { d as runCancellationSignal } from "./native-run-NwUuxbkg.mjs";
6
+ import "./build-cache-Dv7RN200.mjs";
7
+ import { l as artifactCachePolicy, p as resolveOptimizations } from "./errors-ccaPc4ox.mjs";
8
+ import { l as macosToolchainAsync } from "./toolchain-DpJMHq0n.mjs";
9
+ import { r as nativeFileDigest } from "./native-source-Y0yLhFyQ.mjs";
10
+ import { a as validateInfoPlist, i as stageBundle, n as resolveBundleExtras, r as setBundleName, t as reidentifyBundle } from "./stage-Bps5oius.mjs";
11
+ import { t as validateMacosArtifactPlatform } from "./artifact-platform-CXcmX_j3.mjs";
12
+ import { t as logLines } from "./run-DidHghD1.mjs";
13
+ import { n as swiftpmArtifactInputs, r as swiftpmArtifactSnapshot, t as readSwiftpmArtifactToolchain } from "./swiftpm-artifact-inputs-DFcGsXDP.mjs";
14
+ import { createHash } from "node:crypto";
15
+ import { createReadStream, createWriteStream, existsSync, realpathSync } from "node:fs";
16
+ import { tmpdir } from "node:os";
17
+ import { dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
18
+ import { parseHostedAppManifest } from "@stim-cli/core/state";
19
+ import { cp, lstat, mkdir, mkdtemp, open, readdir, readlink, realpath, rm, symlink, writeFile } from "node:fs/promises";
20
+ import { buildResolveTimeoutMs, buildUploadTimeoutMs, createFilesystemFileCache, loadCacheProvider } from "@stim-cli/cache";
21
+ import { pipeline } from "node:stream/promises";
22
+ import { Readable } from "node:stream";
23
+ //#region src/macos/artifact-file.ts
24
+ const MAGIC = Buffer.from("STIMMAC1\n");
25
+ const MAX_HEADER_BYTES = 16777216;
26
+ const canonical = (path) => path.normalize("NFC").toLowerCase();
27
+ async function bundleFiles(bundle, signal) {
28
+ const files = [];
29
+ const directories = [];
30
+ const walk = async (path) => {
31
+ signal.throwIfAborted();
32
+ const absolute = join(bundle, path);
33
+ const info = await lstat(absolute);
34
+ if (info.isDirectory()) {
35
+ if (path) directories.push(path);
36
+ for (const entry of await readdir(absolute)) await walk(path ? `${path}/${entry}` : entry);
37
+ } else if (info.isFile()) files.push({
38
+ path,
39
+ kind: info.mode & 73 ? "exec" : "file",
40
+ ...await nativeFileDigest(absolute, signal)
41
+ });
42
+ else if (info.isSymbolicLink()) {
43
+ const bytes = Buffer.from(await readlink(absolute));
44
+ files.push({
45
+ path,
46
+ kind: "link",
47
+ size: bytes.length,
48
+ sha256: createHash("sha256").update(bytes).digest("hex")
49
+ });
50
+ } else throw new Error("The cached macOS bundle contains an unsupported file.");
51
+ };
52
+ await walk("");
53
+ const parsed = parseHostedAppManifest(files);
54
+ if (!parsed || directories.length > 2e4) throw new Error("The cached macOS bundle has an invalid file inventory.");
55
+ return {
56
+ files: parsed,
57
+ directories: directories.toSorted()
58
+ };
59
+ }
60
+ async function packMacosArtifact(bundle, key, output, signal) {
61
+ const { files, directories } = await bundleFiles(bundle, signal);
62
+ const metadata = Buffer.from(JSON.stringify({
63
+ key,
64
+ files,
65
+ directories
66
+ }));
67
+ if (metadata.length > MAX_HEADER_BYTES) throw new Error("The cached macOS bundle receipt is too large.");
68
+ const header = Buffer.alloc(MAGIC.length + 4);
69
+ MAGIC.copy(header);
70
+ header.writeUInt32BE(metadata.length, MAGIC.length);
71
+ const payload = async function* () {
72
+ yield header;
73
+ yield metadata;
74
+ for (const file of files) {
75
+ signal.throwIfAborted();
76
+ const hash = createHash("sha256");
77
+ let size = 0;
78
+ const path = join(bundle, file.path);
79
+ const input = file.kind === "link" ? [Buffer.from(await readlink(path))] : createReadStream(path, { signal });
80
+ for await (const bytes of input) {
81
+ hash.update(bytes);
82
+ size += bytes.length;
83
+ yield bytes;
84
+ }
85
+ if (size !== file.size || hash.digest("hex") !== file.sha256) throw new Error("The macOS bundle changed while its cache entry was packed.");
86
+ }
87
+ };
88
+ await pipeline(Readable.from(payload()), createWriteStream(output, {
89
+ flags: "wx",
90
+ mode: 384
91
+ }), { signal });
92
+ }
93
+ async function readExactly(file, size, position, signal) {
94
+ const bytes = Buffer.alloc(size);
95
+ let offset = 0;
96
+ while (offset < size) {
97
+ signal.throwIfAborted();
98
+ const read = await file.read(bytes, offset, size - offset, position + offset);
99
+ if (!read.bytesRead) throw new Error("The cached macOS entry is truncated.");
100
+ offset += read.bytesRead;
101
+ }
102
+ return bytes;
103
+ }
104
+ async function unpackMacosArtifact(source, key, bundle, signal) {
105
+ signal.throwIfAborted();
106
+ const file = await open(source, "r");
107
+ try {
108
+ const header = await readExactly(file, MAGIC.length + 4, 0, signal);
109
+ const size = header.readUInt32BE(MAGIC.length);
110
+ if (!header.subarray(0, MAGIC.length).equals(MAGIC) || size === 0 || size > MAX_HEADER_BYTES) throw new Error("The cached macOS entry has an unsupported header.");
111
+ const metadata = JSON.parse((await readExactly(file, size, header.length, signal)).toString("utf8"));
112
+ const files = parseHostedAppManifest(metadata?.files);
113
+ if (metadata?.key !== key || !files) throw new Error("The cached macOS entry has an invalid identity or inventory.");
114
+ const directories = metadata.directories;
115
+ if (!Array.isArray(directories) || directories.length > 2e4 || !directories.every((path) => typeof path === "string" && path.length > 0 && path.length <= 1024 && !/[\\\0\r\n]/.test(path) && path.split("/").every((part) => part && part !== "." && part !== ".."))) throw new Error("The cached macOS entry has invalid directories.");
116
+ const filePaths = new Set(files.map((entry) => canonical(entry.path)));
117
+ for (const path of directories) {
118
+ let ancestor = canonical(path);
119
+ while (ancestor !== ".") {
120
+ if (filePaths.has(ancestor)) throw new Error("A cached macOS directory overlaps a file or link.");
121
+ ancestor = posix.dirname(ancestor);
122
+ }
123
+ }
124
+ let position = header.length + size;
125
+ if ((await file.stat()).size !== position + files.reduce((sum, entry) => sum + entry.size, 0)) throw new Error("The cached macOS entry has an invalid payload length.");
126
+ await mkdir(bundle, { mode: 448 });
127
+ for (const path of directories) {
128
+ signal.throwIfAborted();
129
+ await mkdir(join(bundle, path), {
130
+ recursive: true,
131
+ mode: 493
132
+ });
133
+ }
134
+ const links = [];
135
+ for (const entry of files) {
136
+ signal.throwIfAborted();
137
+ const path = join(bundle, entry.path);
138
+ await mkdir(dirname(path), {
139
+ recursive: true,
140
+ mode: 448
141
+ });
142
+ if (entry.kind === "link") {
143
+ const bytes = await readExactly(file, entry.size, position, signal);
144
+ if (createHash("sha256").update(bytes).digest("hex") !== entry.sha256) throw new Error("A cached macOS link differs from its digest.");
145
+ const target = bytes.toString("utf8");
146
+ const destination = posix.normalize(posix.join(posix.dirname(entry.path), target));
147
+ if (!target || !Buffer.from(target).equals(bytes) || /[\\\0\r\n]/.test(target) || posix.isAbsolute(target) || destination === "." || destination === ".." || destination.startsWith("../") || entry.path.startsWith(`${destination}/`)) throw new Error("A cached macOS link leaves its bundle or forms an ancestor cycle.");
148
+ links.push({
149
+ path,
150
+ target
151
+ });
152
+ } else {
153
+ const hash = createHash("sha256");
154
+ if (entry.size === 0) await writeFile(path, "", {
155
+ flag: "wx",
156
+ mode: entry.kind === "exec" ? 493 : 420,
157
+ signal
158
+ });
159
+ else {
160
+ const bytes = async function* () {
161
+ for await (const chunk of file.createReadStream({
162
+ start: position,
163
+ end: position + entry.size - 1,
164
+ autoClose: false
165
+ })) {
166
+ signal.throwIfAborted();
167
+ hash.update(chunk);
168
+ yield chunk;
169
+ }
170
+ };
171
+ await pipeline(Readable.from(bytes()), createWriteStream(path, {
172
+ flags: "wx",
173
+ mode: entry.kind === "exec" ? 493 : 420
174
+ }), { signal });
175
+ }
176
+ if (hash.digest("hex") !== entry.sha256) throw new Error("A cached macOS file differs from its digest.");
177
+ }
178
+ position += entry.size;
179
+ }
180
+ for (const link of links) await symlink(link.target, link.path);
181
+ const root = await realpath(bundle);
182
+ for (const link of links) {
183
+ signal.throwIfAborted();
184
+ const path = relative(root, await realpath(link.path));
185
+ if (isAbsolute(path) || path === ".." || path.startsWith(`..${sep}`)) throw new Error("A cached macOS link leaves its bundle.");
186
+ }
187
+ } finally {
188
+ await file.close();
189
+ }
190
+ }
191
+ //#endregion
192
+ //#region src/macos/artifact-cache.ts
193
+ async function providerCall(call, timeoutMs, context, directory, signal) {
194
+ signal.throwIfAborted();
195
+ const controller = new AbortController();
196
+ const failure = Object.assign(/* @__PURE__ */ new Error(`SwiftPM cache provider cleanup did not finish within 35 seconds. Retained ${directory}.`), {
197
+ code: "STIM_CLAIM_UNAVAILABLE",
198
+ reportCleanup: true,
199
+ remedy: "Confirm that the provider has stopped using the retained directory before removing it and retrying."
200
+ });
201
+ const pending = Promise.resolve().then(() => {
202
+ controller.signal.throwIfAborted();
203
+ return call(controller.signal);
204
+ }).then((value) => ({ value }), (error) => ({ error }));
205
+ let close;
206
+ const closed = new Promise((settleClosed) => {
207
+ close = settleClosed;
208
+ });
209
+ let cleanup;
210
+ const finish = () => cleanup ??= (async () => {
211
+ let timer;
212
+ if (!await Promise.race([pending.then(() => true), new Promise((settleDrain) => {
213
+ timer = setTimeout(() => settleDrain(false), 35e3);
214
+ })]).finally(() => clearTimeout(timer))) throw failure;
215
+ const result = await pending;
216
+ if ("error" in result && result.error instanceof Error && "reportCleanup" in result.error) throw result.error;
217
+ })().finally(() => close());
218
+ let notifyAbort;
219
+ const aborted = new Promise((settleAbort) => {
220
+ notifyAbort = () => settleAbort({ aborted: true });
221
+ });
222
+ const childAborted = () => notifyAbort();
223
+ controller.signal.addEventListener("abort", childAborted, { once: true });
224
+ const abort = () => controller.abort(signal.reason);
225
+ signal.addEventListener("abort", abort, { once: true });
226
+ trackReportResource(context, closed, finish, signal, failure);
227
+ const deadline = setTimeout(() => controller.abort(), timeoutMs);
228
+ if (signal.aborted) abort();
229
+ const outcome = await Promise.race([pending, aborted]);
230
+ clearTimeout(deadline);
231
+ signal.removeEventListener("abort", abort);
232
+ controller.signal.removeEventListener("abort", childAborted);
233
+ await finish();
234
+ signal.throwIfAborted();
235
+ if ("aborted" in outcome) throw new Error("SwiftPM cache provider timed out.");
236
+ if ("error" in outcome) throw outcome.error;
237
+ return outcome.value;
238
+ }
239
+ const fileKey = (key) => `swiftpm/v1/${key}`;
240
+ async function contained(path, directory) {
241
+ const rel = relative(await realpath(directory), await realpath(path));
242
+ if (!rel || isAbsolute(rel) || rel === ".." || rel.startsWith(`..${sep}`) || !(await lstat(path)).isFile()) throw new Error("The shared SwiftPM cache file is outside its download directory or is not a regular file.");
243
+ }
244
+ function swiftpmArtifactCache(context, root, settings, recipe, build) {
245
+ const declaration = settingValueAt(settings, "macos.artifactInputs");
246
+ if (!declaration) return void 0;
247
+ const policy = artifactCachePolicy(resolveOptimizations(settings, context.env), true, false);
248
+ if (!policy.read) return void 0;
249
+ const activeSignal = () => runCancellationSignal(context) ?? context.signal;
250
+ const localRoot = sharedBuildCache();
251
+ const local = createFilesystemFileCache(join(localRoot, "macos"));
252
+ const storeLocal = async (key, sourcePath, signal) => {
253
+ register({
254
+ dir: localRoot,
255
+ registeredBy: root,
256
+ name: "Build cache",
257
+ prune: "entries",
258
+ entriesDepth: 2,
259
+ note: "completed native artifacts keyed on build inputs"
260
+ });
261
+ await local.store({
262
+ key: fileKey(key),
263
+ sourcePath,
264
+ overwrite: true,
265
+ signal
266
+ });
267
+ };
268
+ let provider;
269
+ const shared = () => provider ??= (async () => {
270
+ const signal = activeSignal();
271
+ if (!policy.remote) return null;
272
+ const settingsContext = await projectSettingsContextAsync(root, void 0, {
273
+ env: context.env,
274
+ signal,
275
+ declareFor: context
276
+ });
277
+ const loaded = await loadCacheProvider({
278
+ projectRoot: root,
279
+ config: resolveCacheProviderConfig(settingsContext),
280
+ env: context.env
281
+ });
282
+ if (loaded.unavailable) throw new Error(loaded.unavailable);
283
+ return loaded.provider?.files ?? null;
284
+ })();
285
+ const unpack = async (path, key, directory) => {
286
+ const signal = activeSignal();
287
+ const bundle = join(directory, "Cached.app");
288
+ await unpackMacosArtifact(path, key, bundle, signal);
289
+ await recipe.validateFetched(bundle, recipe.bundleId);
290
+ await validateMacosArtifactPlatform(context, bundle, recipe.product, signal);
291
+ return bundle;
292
+ };
293
+ const identity = async () => {
294
+ const signal = activeSignal();
295
+ return swiftpmArtifactSnapshot(root, declaration, build, await readSwiftpmArtifactToolchain(context, signal, root), context.env, signal);
296
+ };
297
+ return {
298
+ peer: () => policy.remote ? {
299
+ inputs: swiftpmArtifactInputs(declaration),
300
+ write: policy.write
301
+ } : null,
302
+ identity,
303
+ async has(key) {
304
+ const signal = activeSignal();
305
+ if (!await local.stat({
306
+ key: fileKey(key),
307
+ signal
308
+ })) return false;
309
+ const directory = await mkdtemp(join(tmpdir(), "stim-macos-cache-plan-"));
310
+ let retainDirectory = false;
311
+ try {
312
+ const source = await local.resolve({
313
+ key: fileKey(key),
314
+ destinationDir: directory,
315
+ signal
316
+ });
317
+ if (!source) return false;
318
+ await unpack(source, key, directory);
319
+ return true;
320
+ } catch (error) {
321
+ if (error instanceof Error && "reportCleanup" in error) {
322
+ retainDirectory = true;
323
+ throw error;
324
+ }
325
+ signal.throwIfAborted();
326
+ return false;
327
+ } finally {
328
+ if (!retainDirectory) await rm(directory, {
329
+ recursive: true,
330
+ force: true
331
+ });
332
+ }
333
+ },
334
+ async restore(key, directory) {
335
+ const signal = activeSignal();
336
+ await mkdir(directory, { recursive: true });
337
+ const cached = await local.resolve({
338
+ key: fileKey(key),
339
+ destinationDir: directory,
340
+ signal
341
+ });
342
+ if (cached) try {
343
+ return {
344
+ bundle: await unpack(cached, key, directory),
345
+ tier: "local"
346
+ };
347
+ } catch (error) {
348
+ if (error instanceof Error && "reportCleanup" in error) throw error;
349
+ signal.throwIfAborted();
350
+ await rm(join(directory, "Cached.app"), {
351
+ recursive: true,
352
+ force: true
353
+ });
354
+ }
355
+ const files = await shared();
356
+ if (!files) return null;
357
+ const result = await providerCall((childSignal) => files.resolve({
358
+ key: fileKey(key),
359
+ destinationDir: directory,
360
+ signal: childSignal
361
+ }), buildResolveTimeoutMs(context.env), context, directory, signal);
362
+ signal.throwIfAborted();
363
+ if (!result) return null;
364
+ await contained(result, directory);
365
+ const bundle = await unpack(result, key, directory);
366
+ await storeLocal(key, result, signal);
367
+ return {
368
+ bundle,
369
+ tier: "provider"
370
+ };
371
+ },
372
+ async store(key, bundle, directory) {
373
+ const signal = activeSignal();
374
+ const canonical = join(directory, "Canonical.app");
375
+ await cp(bundle, canonical, {
376
+ recursive: true,
377
+ verbatimSymlinks: true,
378
+ filter: () => {
379
+ signal.throwIfAborted();
380
+ return true;
381
+ }
382
+ });
383
+ await cp(resolve(root, build.infoPlist), join(canonical, "Contents", "Info.plist"));
384
+ await reidentifyBundle(context, canonical, recipe.bundleId);
385
+ await recipe.validateFetched(canonical, recipe.bundleId);
386
+ const sourcePath = join(directory, "artifact.cache");
387
+ await packMacosArtifact(canonical, key, sourcePath, signal);
388
+ if ((await identity()).key !== key) throw new Error("SwiftPM inputs changed while the cache entry was packed.");
389
+ await storeLocal(key, sourcePath, signal);
390
+ const files = await shared();
391
+ if (!files) return;
392
+ await providerCall((childSignal) => files.store({
393
+ key: fileKey(key),
394
+ sourcePath,
395
+ overwrite: true,
396
+ signal: childSignal
397
+ }), buildUploadTimeoutMs(context.env), context, directory, signal);
398
+ signal.throwIfAborted();
399
+ }
400
+ };
401
+ }
402
+ //#endregion
403
+ //#region src/integrations/swiftpm-macos.ts
404
+ function swiftpmMacosProject(root) {
405
+ return { async prepare(context, settings) {
406
+ const macos = settings.macos;
407
+ if (!macos?.product || !macos.infoPlist) throw Object.assign(/* @__PURE__ */ new Error("Set macos.product and macos.infoPlist explicitly in .stim.json. See stim guide macos."), { code: "STIM_BAD_ARG" });
408
+ const { product, infoPlist } = macos;
409
+ const { bundleId } = await validateInfoPlist(context, root, product, infoPlist);
410
+ const repository = realpathSync(await repoRootAsync(root, {
411
+ env: context.env,
412
+ signal: context.signal
413
+ }) ?? root);
414
+ const extras = resolveBundleExtras(root, repository, macos.resources, macos.assetCatalog);
415
+ const recipe = {
416
+ product,
417
+ arguments: macos.arguments ?? [],
418
+ bundleId,
419
+ async compile({ scratch, writer, note }) {
420
+ await tool(context, root, [
421
+ "build",
422
+ "-c",
423
+ "debug",
424
+ "--product",
425
+ product,
426
+ "--scratch-path",
427
+ scratch,
428
+ "--jobs",
429
+ "2"
430
+ ], writer, note);
431
+ return tool(context, root, [
432
+ "build",
433
+ "-c",
434
+ "debug",
435
+ "--scratch-path",
436
+ scratch,
437
+ "--show-bin-path"
438
+ ], writer, () => {}, true);
439
+ },
440
+ stage: (bin, bundle, id, displayName) => stageBundle(context, root, product, infoPlist, bin, bundle, id, extras, displayName),
441
+ async validateFetched(bundle, id, displayName) {
442
+ const executable = join(bundle, "Contents", "MacOS", product);
443
+ const plist = JSON.parse(await getExecutor().runFileAsync("plutil", [
444
+ "-convert",
445
+ "json",
446
+ "-o",
447
+ "-",
448
+ join(bundle, "Contents", "Info.plist")
449
+ ], {
450
+ timeoutMs: 1e4,
451
+ declareFor: context
452
+ }));
453
+ if (plist.CFBundleIdentifier !== id || plist.CFBundleExecutable !== product || !existsSync(executable)) throw new Error("The fetched macOS bundle does not match the requested identity and executable.");
454
+ for (const destination of [...Object.keys(extras.resources), ...extras.assetCatalog ? ["Assets.car"] : []]) if (!existsSync(join(bundle, "Contents", "Resources", destination))) throw new Error(`The fetched macOS bundle lacks declared resource ${destination}.`);
455
+ if (displayName !== void 0) {
456
+ await setBundleName(context, join(bundle, "Contents", "Info.plist"), displayName);
457
+ await getExecutor().runFileAsync("codesign", [
458
+ "--force",
459
+ "--sign",
460
+ "-",
461
+ bundle
462
+ ], {
463
+ timeoutMs: "unbounded",
464
+ declareFor: context
465
+ });
466
+ }
467
+ await getExecutor().runFileAsync("codesign", [
468
+ "--verify",
469
+ "--strict",
470
+ bundle
471
+ ], {
472
+ timeoutMs: "unbounded",
473
+ declareFor: context
474
+ });
475
+ },
476
+ offload: {
477
+ target: async () => ({
478
+ platform: "macos",
479
+ local: await macosToolchainAsync()
480
+ }),
481
+ request: (id) => ({
482
+ platform: "macos",
483
+ product,
484
+ infoPlist: relative(root, resolve(root, infoPlist)),
485
+ bundleId: id,
486
+ resources: Object.fromEntries(Object.entries(extras.resources).map(([destination, source]) => [destination, relative(repository, source)])),
487
+ assetCatalog: extras.assetCatalog ? relative(repository, extras.assetCatalog) : null
488
+ })
489
+ }
490
+ };
491
+ recipe.cache = swiftpmArtifactCache(context, root, settings, recipe, {
492
+ product,
493
+ infoPlist,
494
+ resources: Object.fromEntries(Object.entries(extras.resources).map(([destination, source]) => [destination, relative(root, source)])),
495
+ assetCatalog: extras.assetCatalog ? relative(root, extras.assetCatalog) : null
496
+ });
497
+ return recipe;
498
+ } };
499
+ }
500
+ async function tool(context, root, args, writer, note, capture = false) {
501
+ const child = spawnDeclared(context, () => getExecutor().spawn("swift", args, {
502
+ cwd: root,
503
+ detached: true,
504
+ stdio: [
505
+ "ignore",
506
+ "pipe",
507
+ "pipe"
508
+ ]
509
+ }));
510
+ let stdout = "";
511
+ child.stdout?.on("data", (chunk) => {
512
+ if (capture) stdout += chunk.toString("utf8");
513
+ });
514
+ const write = (msg) => {
515
+ writer.write({
516
+ src: "build",
517
+ platform: "macos",
518
+ level: "debug",
519
+ msg
520
+ });
521
+ note(msg);
522
+ };
523
+ if (child.stdout) logLines(child.stdout, write);
524
+ if (child.stderr) logLines(child.stderr, write);
525
+ await new Promise((done, reject) => {
526
+ child.once("error", reject);
527
+ child.once("close", (code) => code === 0 ? done() : reject(/* @__PURE__ */ new Error(`swift ${args[0]} failed (${code}). See stim logs --source build.`)));
528
+ });
529
+ return stdout.trim();
530
+ }
531
+ //#endregion
532
+ export { swiftpmMacosProject };
@@ -0,0 +1,2 @@
1
+ import { c as macosToolchain, l as macosToolchainAsync } from "./toolchain-DpJMHq0n.mjs";
2
+ export { macosToolchain, macosToolchainAsync };