stim 1.25.0 → 1.27.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 (182) hide show
  1. package/README.md +1 -1
  2. package/dist/{acquire-artifact-zA4S7RHE.mjs → acquire-artifact-BKN2Yuhg.mjs} +2 -2
  3. package/dist/{act-BbHS3oV8.mjs → act-ROviTF_t.mjs} +415 -118
  4. package/dist/{activity-BpjwrQXU.mjs → activity-Cd-ysFes.mjs} +6 -7
  5. package/dist/{agent-device-usage-output-Bnkerfod.mjs → agent-device-usage-output-C5nCKWp9.mjs} +5 -5
  6. package/dist/{android-CNZgRC-4.mjs → android--HBgpvpW.mjs} +5 -5
  7. package/dist/{android-BGwuK3Mc.mjs → android-Cd6w7_qw.mjs} +134 -57
  8. package/dist/{android-saBeB4lr.mjs → android-Deb9X3_Y.mjs} +37 -15
  9. package/dist/{android-Cjcj8MCw.mjs → android-DriNoAVy.mjs} +99 -47
  10. package/dist/{android-cas-BVqh2Zep.mjs → android-cas-D5e6ecUg.mjs} +4 -4
  11. package/dist/android-cas-compiler.mjs +1 -1
  12. package/dist/{android-project-CTYaETc0.d.mts → android-project-DUGMbq28.d.mts} +55 -1
  13. package/dist/api.d.mts +20 -7
  14. package/dist/api.mjs +42 -32
  15. package/dist/apk-signed-tail-BHQHx3Rm.mjs +142 -0
  16. package/dist/{artifact-Co8zixVx.mjs → artifact-0AGJYB9O.mjs} +28 -28
  17. package/dist/{artifact-DN8JNwqS.mjs → artifact-faemIZv5.mjs} +40 -30
  18. package/dist/{artifact-platform-CMRc0M_r.mjs → artifact-platform-BO2Uvk_A.mjs} +1 -1
  19. package/dist/{attempt-DW-mQqM7.mjs → attempt-ClyJlZPT.mjs} +4 -2
  20. package/dist/auto-placement-z-H5pJza.mjs +350 -0
  21. package/dist/{browser-web-CCgZsHmI.mjs → browser-web-slD8AvLp.mjs} +16 -17
  22. package/dist/{build-cache-CKCzxzxA.mjs → build-cache-gBJ-WKzA.mjs} +141 -37
  23. package/dist/{build-CAiw8Ezm.mjs → build-hS0QyFlQ.mjs} +38 -31
  24. package/dist/{build-plan-zCuHGlA8.mjs → build-plan-CBqYbzYM.mjs} +7 -6
  25. package/dist/{cache-manifest-BPXRONJz.mjs → cache-manifest-DEjqGGat.mjs} +1 -1
  26. package/dist/cache-manifest.mjs +1 -1
  27. package/dist/{budget-HyShrIpL.mjs → ccache-BWTze1Ls.mjs} +634 -1514
  28. package/dist/{cdp-BG3FJCCx.mjs → cdp-C3svvXiE.mjs} +1 -1
  29. package/dist/{chrome-BvV8ssI3.mjs → chrome-DyDWurWG.mjs} +1 -1
  30. package/dist/{cli-C4w607Pz.mjs → cli-ftXDLto1.mjs} +24 -23
  31. package/dist/cli.mjs +1 -1
  32. package/dist/{client-BQsmyp_-.mjs → client-xsdxrhWA.mjs} +77 -116
  33. package/dist/collector-run.d.mts +10 -9
  34. package/dist/collector-run.mjs +42 -27
  35. package/dist/{command-output-BBvS1H6v.mjs → command-output-Dj-WT4BP.mjs} +1 -1
  36. package/dist/{config-BZhXY15H.mjs → config-Cn94Jc0g.mjs} +343 -18
  37. package/dist/{launch-DscF1QfM.mjs → dependencies-BGokZ-Ng.mjs} +330 -279
  38. package/dist/{dependency-state-BwNCYG5Q.mjs → dependency-state-C3OtgG94.mjs} +14 -7
  39. package/dist/{detached-entry-KmieOKgN.mjs → detached-entry-BPlSaCwC.mjs} +1 -1
  40. package/dist/{dev-client-CHoXXZeg.mjs → dev-client-BMca82xo.mjs} +2 -2
  41. package/dist/{device-F5-4z9ef.mjs → device-BJm0irrq.mjs} +16 -16
  42. package/dist/{device-capacity-ZYaRALv5.mjs → device-capacity-6LP7QsaA.mjs} +103 -25
  43. package/dist/device-host-worker.mjs +19 -21
  44. package/dist/{device-ios-DkHBrmvH.mjs → device-ios-534c14fz.mjs} +288 -28
  45. package/dist/{device-lease-run-ogEeJ62K.mjs → device-lease-run-DwsGfjUN.mjs} +5 -5
  46. package/dist/{device-pool-BIg8MU8l.mjs → device-pool-BnQqvs6o.mjs} +3 -3
  47. package/dist/{device-B9FqTBYW.mjs → device-tM41-TUq.mjs} +25 -24
  48. package/dist/{doctor-A_Nr_fDe.mjs → doctor-Dbx1ZpD2.mjs} +1 -1
  49. package/dist/{doctor-k3P3PizH.mjs → doctor-DyqE9n1J.mjs} +28 -16
  50. package/dist/{doctor-Bm8TVpGn.mjs → doctor-F-3VUUyN.mjs} +128 -35
  51. package/dist/{doctor-fingerprint-zlujA1Gs.mjs → doctor-fingerprint-o7ZI9YLn.mjs} +9 -3
  52. package/dist/doctor-fingerprint.mjs +1 -1
  53. package/dist/{doctor-watchman-BovI1y3-.mjs → doctor-watchman-CxDbyrrt.mjs} +5 -5
  54. package/dist/{eas-build-CyDKNTBP.mjs → eas-build-CjNSWmjo.mjs} +4 -4
  55. package/dist/eas-fallback-9fqb46kW.mjs +87 -0
  56. package/dist/{eas-session-ledger-BMCA1gdO.mjs → eas-session-ledger-DrP4OuuM.mjs} +6 -6
  57. package/dist/{error-diagnostics-B1Mj_-7h.mjs → error-diagnostics-snej9k4j.mjs} +51 -25
  58. package/dist/{exec-VFRpu1iA.mjs → exec-aULwtNly.mjs} +57 -6
  59. package/dist/{gc-eaz403W6.mjs → gc-BRwAY3qT.mjs} +2 -2
  60. package/dist/{gc-B9jcnmIk.mjs → gc-CGZ1Yg88.mjs} +218 -72
  61. package/dist/{guide-DR0K0xW9.mjs → guide-_rfEh_zM.mjs} +839 -222
  62. package/dist/{hosted-android-Bvb2-ZxD.mjs → hosted-android-BMKzUNnY.mjs} +4 -4
  63. package/dist/{hosted-client-rsRqysJc.mjs → hosted-client-D7Pk_Oo1.mjs} +13 -9
  64. package/dist/{hosted-logs-CWKGYWNX.mjs → hosted-logs-B1gqQuva.mjs} +18 -12
  65. package/dist/hosted-logs-sync-Dg3qrZmV.mjs +195 -0
  66. package/dist/{hosted-macos-d0pv9Tth.mjs → hosted-macos-B9w4H8hc.mjs} +6 -6
  67. package/dist/{hosted-native-BxTizGU2.mjs → hosted-native-CdgaiuyP.mjs} +17 -17
  68. package/dist/{idle-shutdown-BIyfl0Zj.mjs → idle-shutdown-Cbvo5KEh.mjs} +21 -9
  69. package/dist/{ios-BRVM8b0P.mjs → ios-B5HlVMhQ.mjs} +138 -55
  70. package/dist/{ios-Dvt97HgQ.mjs → ios-Bk4mWbtS.mjs} +8 -8
  71. package/dist/{ios-ENC4sRPA.mjs → ios-CsRVik64.mjs} +7 -1
  72. package/dist/{ios-BQzvJlzw.mjs → ios-E26qSpkb.mjs} +94 -11
  73. package/dist/{ios-device-CKSvk0bu.mjs → ios-device-C_QkIf1Z.mjs} +3 -3
  74. package/dist/{ios-device-B6HK951C.mjs → ios-device-CiBA-er9.mjs} +1 -1
  75. package/dist/{ios-project-DCUDo06I.mjs → ios-project-D8Jcy_br.mjs} +22 -9
  76. package/dist/{ios-signing-4c_qXvQm.mjs → ios-signing-BJzvDPfU.mjs} +2 -2
  77. package/dist/{ios-state-CT9nV5SP.mjs → ios-state-BZ03NFgF.mjs} +1 -1
  78. package/dist/{js-swap-Z9HbC4cj.mjs → js-swap-Dg2a945i.mjs} +8 -7
  79. package/dist/{launch-D0lPvFFu.mjs → launch-CRyBeNsA.mjs} +53 -44
  80. package/dist/lightened-BCsdAGj_.mjs +171 -0
  81. package/dist/{logs-BsIRre8x.mjs → logs-CC_-ZzEE.mjs} +10 -174
  82. package/dist/{logs-Crs9y34Z.mjs → logs-aJQb-RDg.mjs} +112 -38
  83. package/dist/{macos-CcUlJPMu.mjs → macos-BGmTpnv9.mjs} +1 -1
  84. package/dist/{macos-D477nfzH.mjs → macos-DlCBhMw5.mjs} +73 -39
  85. package/dist/macos-run.mjs +1 -1
  86. package/dist/maintenance-run.mjs +30 -13
  87. package/dist/{metro-1pJgCX4U.mjs → metro-CvyD-xwe.mjs} +4 -4
  88. package/dist/{metro-gateway-Bp9gJQAN.mjs → metro-gateway-BnHdqMO_.mjs} +3 -4
  89. package/dist/{named-ports-BVbn8SvC.mjs → named-ports-BCyMWA6b.mjs} +3 -3
  90. package/dist/{native-android-BvMizJn1.mjs → native-android-DlpxCyOP.mjs} +17 -18
  91. package/dist/{native-gradle-artifact-inputs-BJscK4vN.mjs → native-gradle-artifact-inputs-C13qT7R_.mjs} +5 -5
  92. package/dist/{native-runtime-B9w_Qyz3.mjs → native-runtime-DqaIBO5w.mjs} +9 -9
  93. package/dist/{native-source-D-4Dh4JU.mjs → native-source-D1AzWiuP.mjs} +1 -1
  94. package/dist/{native-xcode-inputs-Cv4l-obn.mjs → native-xcode-inputs-B1W8SrxB.mjs} +3 -3
  95. package/dist/{native-xcode-ios-DGrg90hE.mjs → native-xcode-ios-QPP0Rm68.mjs} +17 -18
  96. package/dist/{ndjson-CgE_o3Dl.mjs → ndjson-Dy2W4vRa.mjs} +2 -2
  97. package/dist/offload-worker.d.mts +3 -1
  98. package/dist/offload-worker.mjs +34 -25
  99. package/dist/{operation-exec-CUZifp6Z.mjs → operation-exec-Dp4FuIGR.mjs} +1 -1
  100. package/dist/{ownership-jxxz-19m.mjs → ownership-Bx-0cku-.mjs} +3 -3
  101. package/dist/{page-CzEA_-5_.mjs → page-CQJlcj3x.mjs} +2 -2
  102. package/dist/{phone-reverses-CYb7RRAx.mjs → phone-reverses-C9yAaKEv.mjs} +18 -4
  103. package/dist/{placement-log-DjOXJRIH.mjs → placement-log-BXUbiZM6.mjs} +3 -3
  104. package/dist/{plan-placement-BqKgKHCi.mjs → plan-placement-UxnQjv5Z.mjs} +36 -10
  105. package/dist/{ports-DtS1Amb0.mjs → ports-uUrghqWN.mjs} +3 -3
  106. package/dist/prebuild-BDpToDgR.mjs +1246 -0
  107. package/dist/{project-BiC68mIp.mjs → project-DYj-HVx6.mjs} +17 -18
  108. package/dist/{pull-request-CbNlkFok.mjs → pull-request-BzLmzAIQ.mjs} +2 -2
  109. package/dist/pull-requests.mjs +1 -1
  110. package/dist/{react-native-android-DRYqoJc4.mjs → react-native-android-DDBccgJw.mjs} +56 -36
  111. package/dist/{react-native-build-CwZB-agu.mjs → react-native-build-DaK2IFyP.mjs} +9 -9
  112. package/dist/{react-native-doctor-BCrytK7h.mjs → react-native-doctor-B-Mw6DcR.mjs} +50 -9
  113. package/dist/{react-native-ios-Cr1buNFo.mjs → react-native-ios-DjYwUF9U.mjs} +45 -25
  114. package/dist/{recordings-BaoQ0t-J.mjs → recordings-C20iUZfp.mjs} +1 -1
  115. package/dist/{registration-CN6nlhcD.mjs → registration-BwCe64PH.mjs} +1 -1
  116. package/dist/{reload-Beftw2X3.mjs → reload-DJBeF_rC.mjs} +1 -1
  117. package/dist/{reload-FbSgMF8x.mjs → reload-fUdkH2_p.mjs} +16 -16
  118. package/dist/{remote-BuZj6AyU.mjs → remote-y6n99WMW.mjs} +22 -9
  119. package/dist/{result-CR2vk2cj.mjs → result-CTqBw2Te.mjs} +32 -21
  120. package/dist/{run-BtzE09Dl.mjs → run-DaCeNKRm.mjs} +3 -3
  121. package/dist/{selection-D5cxEl3t.mjs → selection-Bs8phwhN.mjs} +183 -62
  122. package/dist/{server-bare-CH9X0RLn.mjs → server-bare-BOh-iZEj.mjs} +2 -2
  123. package/dist/{server-command-CaBbDNU2.mjs → server-command-8CuA51Cv.mjs} +6 -6
  124. package/dist/{server-expo-Ck8EIidM.mjs → server-expo-ABQs2XFA.mjs} +4 -4
  125. package/dist/server-expo-Ba_Y21vB.mjs +2 -0
  126. package/dist/{settings-B5tCoq9N.mjs → settings-BDVI8Ivc.mjs} +331 -62
  127. package/dist/{settings-DzH9mGQZ.mjs → settings-CMHhQNwI.mjs} +24 -3
  128. package/dist/settings-payload-cm60Zhib.mjs +257 -0
  129. package/dist/settings-write-BdNRLlBn.mjs +185 -0
  130. package/dist/settings.schema.json +84 -39
  131. package/dist/{simslim-BjxszUAb.mjs → simslim-DCQwzoPy.mjs} +4 -3
  132. package/dist/{slot-launch-QeuJMlnJ.mjs → slot-launch-0l7RqSpr.mjs} +6 -6
  133. package/dist/{stage-D8xlRU2D.mjs → stage-F4cAfJGi.mjs} +2 -2
  134. package/dist/{start-C1JLjkNw.mjs → start-DcqnF9p8.mjs} +1 -1
  135. package/dist/{start-YMpNwLhh.mjs → start-DrPwER_2.mjs} +27 -23
  136. package/dist/{state-DMRNP7-4.mjs → state-BX1y5syV.mjs} +4 -5
  137. package/dist/{state-DPaM3u5K.mjs → state-CZxLyetD.mjs} +2 -3
  138. package/dist/{stats-CP7STzZw.mjs → stats-GxuCbles.mjs} +5 -5
  139. package/dist/{stats-report-n2U5plhk.mjs → stats-report-B86Cv7Uc.mjs} +1 -1
  140. package/dist/{status-Fect2w9R.mjs → status-7ULDEJ1e.mjs} +1 -1
  141. package/dist/{status-CRLiJ-O_.mjs → status-BfnK9pUd.mjs} +25 -26
  142. package/dist/{status-cNw6i0_t.mjs → status-Bj7ZYvvc.mjs} +1 -1
  143. package/dist/{status-watch-Bc2J4TZn.mjs → status-watch-BfabQn03.mjs} +5 -5
  144. package/dist/status-worker.mjs +1 -1
  145. package/dist/{stim-desktop-DS0mzR8U.mjs → stim-desktop-CbWo21kb.mjs} +2 -2
  146. package/dist/{stop-COP6PQqw.mjs → stop-CH79S3IZ.mjs} +5 -6
  147. package/dist/{stop-Db9Kh-UA.mjs → stop-D-EAr25B.mjs} +25 -22
  148. package/dist/{stop-Br7LKxBE.mjs → stop-x1Yu3He4.mjs} +2 -2
  149. package/dist/supervisor-run.d.mts +1 -0
  150. package/dist/supervisor-run.mjs +17 -18
  151. package/dist/{support-qKcbgmI5.mjs → support-Be0UeVZU.mjs} +10 -10
  152. package/dist/{support-Cxj9CmII.mjs → support-CNg_YsOk.mjs} +6 -6
  153. package/dist/{swiftpm-artifact-inputs-iY9fsmOc.mjs → swiftpm-artifact-inputs-uPqYvGBv.mjs} +4 -4
  154. package/dist/{swiftpm-macos-Bp_sn9P4.mjs → swiftpm-macos-Ch4YjY_A.mjs} +11 -12
  155. package/dist/toolchain-CbCG6C5Z.mjs +2413 -0
  156. package/dist/toolchain-JYAOquPg.mjs +2 -0
  157. package/dist/{trigger-CBMe2YLH.mjs → trigger-DMou-X7j.mjs} +3 -3
  158. package/dist/trigger-qp2ji5wE.mjs +2 -0
  159. package/dist/{warm-progress-BV3ZPmcY.mjs → warm-progress-C0RsbngN.mjs} +731 -728
  160. package/dist/{web-B4Yjyt1G.mjs → web-Cq_AQ4DK.mjs} +9 -10
  161. package/dist/web-Je6abcpz.mjs +2 -0
  162. package/dist/web-run.mjs +9 -9
  163. package/dist/windows-report.mjs +1 -1
  164. package/dist/{workspace-state-CPSp3mav.mjs → workspace-state-BjqdjnJR.mjs} +46 -8
  165. package/dist/{workspaces-C9w4aeXF.mjs → workspaces-DFbj07jp.mjs} +1801 -76
  166. package/dist/{worktree-CclFIe1Z.mjs → worktree-COAJ3-OD.mjs} +934 -511
  167. package/dist/{worktree-Ct9Gk3KL.mjs → worktree-JGUd_53L.mjs} +1 -1
  168. package/package.json +8 -8
  169. package/dist/ccache-h1FKhZeg.mjs +0 -143
  170. package/dist/created-devices-D2Aca-xu.mjs +0 -52
  171. package/dist/eas-fallback-gaZi-dJL.mjs +0 -381
  172. package/dist/hosted-ios-RtVcJH3u.mjs +0 -15
  173. package/dist/native-run-D5OJsGwA.mjs +0 -276
  174. package/dist/paths-DQtTgsBf.mjs +0 -42
  175. package/dist/prebuild-JUaqOLpc.mjs +0 -501
  176. package/dist/server-expo-C16Zf2k7.mjs +0 -2
  177. package/dist/settings-write-n0zwfohx.mjs +0 -360
  178. package/dist/toolchain-DB1aeqxO.mjs +0 -2
  179. package/dist/toolchain-VzLJzZ7O.mjs +0 -908
  180. package/dist/trigger-BLsHgAGR.mjs +0 -2
  181. package/dist/web-DS4UDWvf.mjs +0 -2
  182. package/dist/xcode-CiIIDnuD.mjs +0 -910
@@ -1,276 +0,0 @@
1
- import { D as ownership_claim_exports, b as operationState, g as signalDeclaredSpawns, h as refuseDeclaredSpawns, p as allowDeclaredSpawns, u as withWorkspaceProcessLock, y as isTermination } from "./exec-VFRpu1iA.mjs";
2
- import { d as workspaceDir } from "./paths-DQtTgsBf.mjs";
3
- import { a as formatElapsed, l as phaseLine } from "./command-output-BBvS1H6v.mjs";
4
- import { l as withWorkspaceStateLockAsync, o as updateWorkspaceState, r as readWorkspaceState, t as clearWorkspaceStateKey } from "./workspace-state-CPSp3mav.mjs";
5
- import { t as canonicalPath } from "./paths-BsJMoPP2.mjs";
6
- import { existsSync, mkdirSync } from "node:fs";
7
- import { basename, dirname, join } from "node:path";
8
- import { setTimeout } from "node:timers/promises";
9
- //#region src/cache/cache-claim.ts
10
- const LABEL = "cache";
11
- const POLL_MS = 500;
12
- const EMPTYING_WAIT_MS = 6e5;
13
- /**
14
- * The claim set guarding a cache Stim can only empty whole. It sits beside the cache's resolved directory, so emptying
15
- * the cache never removes it and every path that reaches the same cache names the same set; before the cache exists,
16
- * its resolved parent stands in for it.
17
- */
18
- function cacheClaimRoot(dir) {
19
- return `${existsSync(dir) ? canonicalPath(dir) : join(canonicalPath(dirname(dir)), basename(dir))}.claims`;
20
- }
21
- function describe(holder) {
22
- const { platform, projectRoot } = holder.details;
23
- const where = typeof projectRoot === "string" ? ` in ${projectRoot}` : "";
24
- return holder.mode === "shared" ? `the ${typeof platform === "string" ? platform : "iOS"} build (pid ${holder.owner.pid}${where}) may be using it` : `pid ${holder.owner.pid} is emptying it`;
25
- }
26
- /** Why the cache at `dir` may be in use, from its claim set, without taking or removing any claim. */
27
- function cacheUser(dir) {
28
- const root = cacheClaimRoot(dir);
29
- const survey = (0, ownership_claim_exports.readClaimSet)(root);
30
- const problem = survey.unresolved[0];
31
- if (problem) return `the cache claim ${problem.path} is unresolved, so a build may be using it`;
32
- const holder = survey.live[0];
33
- return holder ? describe(holder) : void 0;
34
- }
35
- /**
36
- * Takes the exclusive claim an emptier holds while it removes the cache's contents; a string is why it cannot.
37
- * It never waits for a build that holds the cache.
38
- */
39
- function claimForEmptying(dir) {
40
- try {
41
- const attempt = (0, ownership_claim_exports.tryAcquireClaim)({
42
- root: cacheClaimRoot(dir),
43
- mode: "exclusive",
44
- label: LABEL
45
- });
46
- if (attempt.acquired) return attempt.acquired;
47
- if (attempt.pending) (0, ownership_claim_exports.releaseClaim)(attempt.pending);
48
- const holder = attempt.held ?? attempt.waitingFor?.[0];
49
- return holder ? describe(holder) : `its claim at ${cacheClaimRoot(dir)} could not be taken`;
50
- } catch (error) {
51
- if ((0, ownership_claim_exports.isClaimRefusal)(error) || (0, ownership_claim_exports.isClaimUnavailable)(error)) return error.message;
52
- return `its claim at ${cacheClaimRoot(dir)} could not be taken: ${error instanceof Error ? error.message : String(error)}`;
53
- }
54
- }
55
- /**
56
- * Takes the shared claim a build holds on the compilation cache it compiles with, waiting while an emptier holds it.
57
- * A claim set Stim cannot resolve, or no process identity, is a failure: the build never runs unguarded.
58
- */
59
- async function shareCompilationCache({ dir, projectRoot, note, signal }) {
60
- const started = Date.now();
61
- let told = false;
62
- for (;;) {
63
- signal?.throwIfAborted();
64
- let attempt;
65
- let root = `${dir}.claims`;
66
- try {
67
- mkdirSync(dirname(dir), { recursive: true });
68
- root = cacheClaimRoot(dir);
69
- attempt = (0, ownership_claim_exports.tryAcquireClaim)({
70
- root,
71
- mode: "shared",
72
- label: LABEL,
73
- details: {
74
- platform: "ios",
75
- projectRoot
76
- }
77
- });
78
- } catch (error) {
79
- return { failure: (0, ownership_claim_exports.claimFailure)(error, null) ?? {
80
- code: ownership_claim_exports.CLAIM_UNAVAILABLE,
81
- message: `Stim could not take the compilation cache claim at ${root}: ${error instanceof Error ? error.message : String(error)}.`,
82
- remedy: `Restore write access to ${dirname(root)}, then retry the same Stim command.`
83
- } };
84
- }
85
- if (attempt.acquired) return { claim: attempt.acquired };
86
- const emptier = attempt.held ? `pid ${attempt.held.owner.pid}` : "another process";
87
- const waited = Date.now() - started;
88
- if (waited >= EMPTYING_WAIT_MS) return { failure: {
89
- code: "STIM_BUILD_FAILED",
90
- message: `${emptier} has been emptying the compilation cache at ${dir} for ${formatElapsed(waited)}.`,
91
- remedy: "Run the same command again once it has finished."
92
- } };
93
- if (!told) note(phaseLine("build", `waiting for ${emptier} to finish emptying the compilation cache at ${dir}`));
94
- told = true;
95
- await setTimeout(POLL_MS);
96
- }
97
- }
98
- //#endregion
99
- //#region src/engine/native-run.ts
100
- const NATIVE_RUN_LOCK = "native-run";
101
- const NATIVE_RUN_WAIT_MS = 18e5;
102
- const WAIT_HEARTBEAT_MS = 3e4;
103
- const CANCEL_REQUEST_KEY = "nativeRunCancel";
104
- const REQUEST_POLL_MS = 250;
105
- function nativeRunHolder(holder) {
106
- const { command, platform, slot, interrupt } = holder.details;
107
- return {
108
- command: typeof command === "string" ? command : null,
109
- platform: typeof platform === "string" ? platform : null,
110
- slot: typeof slot === "string" ? slot : "default",
111
- takesSignals: interrupt === "signal"
112
- };
113
- }
114
- function describeNativeRunHolder(holder, now) {
115
- const { command, slot } = nativeRunHolder(holder);
116
- const started = Date.parse(holder.startedAt);
117
- const facts = [`pid ${holder.owner.pid}`];
118
- if (Number.isFinite(started)) facts.push(`running for ${formatElapsed(now - started)}`);
119
- if (command === null) return `another Stim run (${facts.join(", ")})`;
120
- if (command === "build") return `an artifact build (${facts.join(", ")})`;
121
- return `\`stim ${command}${slot === "default" ? "" : ` --slot ${slot}`}\` (${facts.join(", ")})`;
122
- }
123
- /**
124
- * Report a wait on the native-run lock: one line as soon as a holder is seen, a line for each new
125
- * holder, and a heartbeat every WAIT_HEARTBEAT_MS while the same holder keeps it.
126
- */
127
- function nativeRunWaitNotice({ write, now = Date.now, describe = describeNativeRunHolder }) {
128
- let claimId = null;
129
- let lastAt = 0;
130
- return (holder, firstLine) => {
131
- const at = now();
132
- if (holder.claimId !== claimId) {
133
- claimId = holder.claimId;
134
- lastAt = at;
135
- write(firstLine ?? `waiting for ${describe(holder, at)} in this workspace to finish`);
136
- return;
137
- }
138
- if (at - lastAt < WAIT_HEARTBEAT_MS) return;
139
- lastAt = at;
140
- write(`still waiting for ${describe(holder, at)}`);
141
- };
142
- }
143
- /**
144
- * What `stop` does about the run holding the native-run lock. A build is interrupted only when the stop
145
- * leaves it nothing to deploy to: the whole workspace stops, the build targets the stopped slot, or the
146
- * stopped slot is the workspace's only device. A build for another slot that stays is left running and
147
- * the stop proceeds without the lock. Only an owner whose identity is proven live is signalled.
148
- */
149
- function decideStopAction({ stopSlot, holder, ownerIdentity, deviceSlots }) {
150
- if (holder.command === "macos" || holder.command === "build") {
151
- if (stopSlot !== void 0) return { action: "proceed" };
152
- return ownerIdentity === "same" ? { action: "interrupt" } : { action: "refuse" };
153
- }
154
- if (holder.command !== "ios" && holder.command !== "android") return { action: "wait" };
155
- if (!(stopSlot === void 0 || holder.slot === stopSlot || deviceSlots.includes(stopSlot) && deviceSlots.every((slot) => slot === stopSlot))) return { action: "proceed" };
156
- return ownerIdentity === "same" ? { action: "interrupt" } : { action: "refuse" };
157
- }
158
- const requestListeners = /* @__PURE__ */ new Map();
159
- /**
160
- * Ask the run holding `claimId` to cancel: the request is written to the workspace state, where the run's watch
161
- * finds it, and a run in this process is told at once.
162
- */
163
- function requestNativeRunCancel(root, claimId, pid = process.pid) {
164
- updateWorkspaceState(root, (state) => ({
165
- ...state,
166
- [CANCEL_REQUEST_KEY]: {
167
- claimId,
168
- pid,
169
- at: (/* @__PURE__ */ new Date()).toISOString()
170
- }
171
- }));
172
- requestListeners.get(claimId)?.();
173
- }
174
- function cancelRequestFor(root, claimId) {
175
- const request = readWorkspaceState(root)?.[CANCEL_REQUEST_KEY];
176
- if (request?.claimId !== claimId || typeof request.pid !== "number") return null;
177
- return { pid: request.pid };
178
- }
179
- function clearNativeRunCancel(root, claimId) {
180
- try {
181
- clearWorkspaceStateKey(root, CANCEL_REQUEST_KEY, (value) => value?.claimId === claimId);
182
- } catch {}
183
- }
184
- /** The active native run of `context`'s operation aborts this signal when it is cancelled. */
185
- function runCancellationSignal(context) {
186
- return operationState(context).runSignal;
187
- }
188
- /** Why `context`'s native run was cancelled, or null while it was not. */
189
- function runCancellation(context) {
190
- return operationState(context).cancelled;
191
- }
192
- function cancelledFailure(context, platform, { code, message }) {
193
- const cancelled = runCancellation(context);
194
- if (cancelled === null || code === "STIM_CLAIM_UNAVAILABLE") return null;
195
- return {
196
- code: "STIM_CANCELLED",
197
- message: `The ${platform} run was ${cancelled} before it finished.`,
198
- remedy: `Run \`stim ${platform}\` again when you want the app on a device.`,
199
- lines: [`it stopped at ${code ?? "an unfinished step"}${message ? `: ${message}` : ""}`]
200
- };
201
- }
202
- function cancelOnAbort({ context, root, claim, write, controller }) {
203
- const state = operationState(context);
204
- const cancel = () => {
205
- if (controller.signal.aborted) return;
206
- const request = cancelRequestFor(root, claim.claimId);
207
- const cancelled = request ? `cancelled by \`stim stop\` (pid ${request.pid})` : "cancelled by an interrupt";
208
- state.cancelled = cancelled;
209
- state.handled = true;
210
- controller.abort();
211
- refuseDeclaredSpawns(context, `the run was ${cancelled}`);
212
- const signalled = signalDeclaredSpawns(context, "SIGINT");
213
- if (signalled > 0 || request) state.draining = true;
214
- write(signalled > 0 ? `${cancelled}; stopping the running build tool` : request ? `${cancelled}; stopping before the next build tool or install` : cancelled);
215
- };
216
- const onAbort = () => {
217
- if (!isTermination(context.signal.reason)) cancel();
218
- };
219
- const onRequest = () => {
220
- if (controller.signal.aborted || !cancelRequestFor(root, claim.claimId)) return;
221
- cancel();
222
- state.abortOperation?.("stop");
223
- };
224
- context.signal.addEventListener("abort", onAbort);
225
- if (context.signal.aborted) onAbort();
226
- requestListeners.set(claim.claimId, onRequest);
227
- const watch = setInterval(onRequest, REQUEST_POLL_MS);
228
- watch.unref();
229
- return async () => {
230
- clearInterval(watch);
231
- requestListeners.delete(claim.claimId);
232
- context.signal.removeEventListener("abort", onAbort);
233
- allowDeclaredSpawns(context);
234
- await withWorkspaceStateLockAsync(root, () => clearNativeRunCancel(root, claim.claimId)).catch(() => {});
235
- };
236
- }
237
- /**
238
- * Run an `ios`, `android` or `macos` invocation under the workspace's native-run lock: the claim records the
239
- * command, platform and slot, and a wait for another holder is reported on `write`. An abort of `context.signal`
240
- * forwards an interrupt to the running declared build tool and refuses any later one; a run `stim stop` cancelled
241
- * stops before its next build tool or install. A `SIGTERM` abort reason is left to the caller.
242
- */
243
- function withNativeBuildRun(context, root, details, fn, { write }) {
244
- const notice = nativeRunWaitNotice({ write });
245
- const state = operationState(context);
246
- return withWorkspaceProcessLock(workspaceDir(root), NATIVE_RUN_LOCK, async (claim) => {
247
- state.cancelled = null;
248
- const controller = new AbortController();
249
- state.runSignal = controller.signal;
250
- const dispose = cancelOnAbort({
251
- context,
252
- root,
253
- claim,
254
- write,
255
- controller
256
- });
257
- try {
258
- return await fn(claim);
259
- } finally {
260
- await dispose();
261
- state.runSignal = void 0;
262
- }
263
- }, {
264
- external: true,
265
- signal: context.signal,
266
- waitMs: NATIVE_RUN_WAIT_MS,
267
- declareSpawnsFor: context,
268
- details: {
269
- ...details,
270
- interrupt: state.takesSignals ? "signal" : "request"
271
- },
272
- onHeld: (holder) => notice(holder)
273
- });
274
- }
275
- //#endregion
276
- export { decideStopAction as a, nativeRunWaitNotice as c, runCancellationSignal as d, withNativeBuildRun as f, shareCompilationCache as h, clearNativeRunCancel as i, requestNativeRunCancel as l, claimForEmptying as m, NATIVE_RUN_WAIT_MS as n, describeNativeRunHolder as o, cacheUser as p, cancelledFailure as r, nativeRunHolder as s, NATIVE_RUN_LOCK as t, runCancellation as u };
@@ -1,42 +0,0 @@
1
- import { existsSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
- import { buildCacheRoot as sharedBuildCache, ensurePrivateDir, withDirLock as withDirLock$1, withDirLockAsync as withDirLockAsync$1, workspaceId as workspaceId$1, workspaceName as workspaceName$1, workspaceStateDir as workspaceDir } from "@stim-cli/core";
3
- import { emulatorLogFile, readJsonObject, sharedCcache as sharedCcache$1, sharedCompilationCache as sharedCompilationCache$1, supervisorLogFile, supervisorPidFile, workspaceAgentDeviceDir, workspaceDerivedData, workspaceLogErrorIndex, workspaceLogsDir as workspaceLogsDir$1, workspaceMetadataFile, workspaceStateFile as workspaceStateFile$1, workspaceStateLock } from "@stim-cli/core/state";
4
- import { join, resolve } from "path";
5
- //#region src/workspace/paths.ts
6
- function ensureWorkspaceStorage(projectRoot) {
7
- const canonicalRoot = resolve(projectRoot);
8
- const dir = workspaceDir(canonicalRoot);
9
- const file = workspaceMetadataFile(canonicalRoot);
10
- ensurePrivateDir(dir);
11
- return withDirLock$1(join(dir, "metadata.lock"), () => {
12
- if (!existsSync(file)) {
13
- const metadata = {
14
- projectRoot: canonicalRoot,
15
- workspace: workspaceName$1(canonicalRoot),
16
- version: 1
17
- };
18
- const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
19
- writeFileSync(tmp, `${JSON.stringify(metadata, null, 2)}\n`);
20
- try {
21
- renameSync(tmp, file);
22
- } catch (error) {
23
- rmSync(tmp, { force: true });
24
- throw error;
25
- }
26
- return dir;
27
- }
28
- if (readJsonObject(file)?.projectRoot === canonicalRoot) return dir;
29
- const error = /* @__PURE__ */ new Error(`Stim workspace collision at ${dir}: its workspace.json does not belong to ${canonicalRoot}.`);
30
- error.code = "STIM_WORKSPACE_COLLISION";
31
- throw error;
32
- });
33
- }
34
- /** Initializes or validates workspace storage after asynchronously acquiring its metadata lock. */
35
- function ensureWorkspaceStorageAsync(projectRoot, signal) {
36
- signal?.throwIfAborted();
37
- const dir = workspaceDir(resolve(projectRoot));
38
- ensurePrivateDir(dir);
39
- return withDirLockAsync$1(join(dir, "metadata.lock"), () => ensureWorkspaceStorage(projectRoot), { signal });
40
- }
41
- //#endregion
42
- export { workspaceStateLock as _, sharedCcache$1 as a, supervisorPidFile as c, workspaceDir as d, workspaceId$1 as f, workspaceStateFile$1 as g, workspaceName$1 as h, sharedBuildCache as i, workspaceAgentDeviceDir as l, workspaceLogsDir$1 as m, ensureWorkspaceStorage as n, sharedCompilationCache$1 as o, workspaceLogErrorIndex as p, ensureWorkspaceStorageAsync as r, supervisorLogFile as s, emulatorLogFile as t, workspaceDerivedData as u, withDirLock$1 as v, withDirLockAsync$1 as y };