stim 1.21.0 → 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 (184) hide show
  1. package/README.md +60 -7
  2. package/dist/{acquire-artifact-CD4lbiWE.mjs → acquire-artifact-Co2k4f7O.mjs} +21 -3
  3. package/dist/{act-DHAw2A2S.mjs → act-DsuqEkiM.mjs} +298 -164
  4. package/dist/{activity-BzVfHSrY.mjs → activity-CMLmzp7o.mjs} +33 -12
  5. package/dist/{agent-device-usage-output-zh1vhbLp.mjs → agent-device-usage-output-DUFaTMdd.mjs} +7 -7
  6. package/dist/{android-BLgbNqox.mjs → android-ByRMUoiJ.mjs} +66 -52
  7. package/dist/{android-DUYkNF4u.mjs → android-C7sVmyI9.mjs} +160 -59
  8. package/dist/{android-CV_GCELZ.mjs → android-DGkNqa_c.mjs} +5 -5
  9. package/dist/{android-BEJ8Jpl7.mjs → android-DR5lZ2Az.mjs} +2 -2
  10. package/dist/android-cas-compiler.mjs +1 -1
  11. package/dist/{android-cas-Ct5b1xCK.mjs → android-cas-ngferVq2.mjs} +3 -3
  12. package/dist/{client-B7QVOlCr.d.mts → android-project-DVWyCbWU.d.mts} +145 -7
  13. package/dist/api.d.mts +132 -118
  14. package/dist/api.mjs +239 -42
  15. package/dist/{artifact-B8T3S5gi.mjs → artifact-8EY8SAPw.mjs} +40 -35
  16. package/dist/{artifact-DAuZ-FNU.mjs → artifact-DJPy518Y.mjs} +69 -40
  17. package/dist/artifact-platform-CXcmX_j3.mjs +27 -0
  18. package/dist/{browser-web-QQzVjz3O.mjs → browser-web-Bcv99PBM.mjs} +187 -59
  19. package/dist/{budget-Bs6SxxzO.mjs → budget-Cvwn54qV.mjs} +830 -699
  20. package/dist/{build-CoPzQRNw.mjs → build-CabC3G23.mjs} +34 -27
  21. package/dist/{build-cache-DmyR9Zzc.mjs → build-cache-Dv7RN200.mjs} +4 -4
  22. package/dist/{build-plan-CaFskB7_.mjs → build-plan-DUC8Ka9y.mjs} +74 -14
  23. package/dist/{cache-manifest-DkkqguoK.mjs → cache-manifest-DSeQjt-Q.mjs} +1 -1
  24. package/dist/cache-manifest.mjs +1 -1
  25. package/dist/{ccache-BJRZ9pG3.mjs → ccache-Btwc36-I.mjs} +6 -6
  26. package/dist/{cdp-CWmIUMbw.mjs → cdp-3fwICjzi.mjs} +1 -1
  27. package/dist/{chrome-B6tfCta1.mjs → chrome-Bbw689-6.mjs} +1 -1
  28. package/dist/{cli-0DYf8QhQ.mjs → cli-CHZa9Lvk.mjs} +20 -20
  29. package/dist/cli.mjs +1 -1
  30. package/dist/{client-UXD70ZbM.mjs → client-OyRoEuSr.mjs} +218 -47
  31. package/dist/collector-run.d.mts +1 -1
  32. package/dist/collector-run.mjs +6 -6
  33. package/dist/{command-output-B1UrjZHL.mjs → command-output-gwpm28fu.mjs} +1 -1
  34. package/dist/{config-CYcBF478.mjs → config-DlrsduwG.mjs} +17 -11
  35. package/dist/{created-devices-CqeBlrEn.mjs → created-devices-x9rN6bhs.mjs} +13 -3
  36. package/dist/{dependency-state-BbKQW83h.mjs → dependency-state-1I9KZT1Y.mjs} +2 -2
  37. package/dist/{detached-entry-DFRyG1_o.mjs → detached-entry-BwNEtIrP.mjs} +1 -1
  38. package/dist/{dev-client-UOeESKm6.mjs → dev-client-BSDR5h3F.mjs} +2 -2
  39. package/dist/{device-ExJq8Ei7.mjs → device-B-L3Fbxy.mjs} +71 -14
  40. package/dist/{device-DCxH7_By.mjs → device-DklWZLqb.mjs} +16 -16
  41. package/dist/{device-capacity-CMlqEcvw.mjs → device-capacity-DK5_EwRS.mjs} +9 -10
  42. package/dist/device-host-worker.mjs +25 -32
  43. package/dist/{device-ios-DRUeKaFV.mjs → device-ios-DoB6KFCO.mjs} +39 -16
  44. package/dist/{device-lease-run-C8raGFoP.mjs → device-lease-run-xJPQ_QQG.mjs} +5 -5
  45. package/dist/{device-pool-DMRpVX9a.mjs → device-pool-BMkdsefq.mjs} +3 -3
  46. package/dist/{doctor-DTvaDOda.mjs → doctor-Bo7BXLux.mjs} +24 -37
  47. package/dist/{doctor-Dhqebm0q.mjs → doctor-D5_EzwfA.mjs} +19 -16
  48. package/dist/doctor-fingerprint-DZLoYFVb.mjs +16 -0
  49. package/dist/doctor-fingerprint.mjs +1 -1
  50. package/dist/{doctor-BLHCYxzi.mjs → doctor-thjWAV0z.mjs} +1 -1
  51. package/dist/{doctor-watchman-Cv1F10Kj.mjs → doctor-watchman-N2wDotwQ.mjs} +5 -5
  52. package/dist/{eas-build-BomfRnFT.mjs → eas-build-CwknaQYj.mjs} +4 -4
  53. package/dist/{eas-fallback-DJwZpy0c.mjs → eas-fallback-CSgAulr5.mjs} +27 -18
  54. package/dist/{eas-session-ledger-op6A54yi.mjs → eas-session-ledger-DlY_serQ.mjs} +8 -7
  55. package/dist/{error-diagnostics-Bf0rZvG9.mjs → error-diagnostics-DBWO2rxE.mjs} +10 -10
  56. package/dist/{exec-_UbtCQcG.mjs → exec-DEoAhcze.mjs} +155 -47
  57. package/dist/{exec-H20xSg2T.d.mts → exec-DnYc4HGH.d.mts} +17 -4
  58. package/dist/{gc-_-dCXdyL.mjs → gc-CXxN-4SE.mjs} +587 -313
  59. package/dist/gc-DnNDQyaP.mjs +3 -0
  60. package/dist/{guide-Yqwt2bd6.mjs → guide-Br0LEfKy.mjs} +239 -43
  61. package/dist/{hosted-android-Bw-honsd.mjs → hosted-android-B-9f-jkd.mjs} +6 -6
  62. package/dist/{hosted-client-DB_gBPfY.mjs → hosted-client-DZAPrcro.mjs} +4 -4
  63. package/dist/{hosted-ios-CUvOf4Vr.mjs → hosted-ios-CsCS21hn.mjs} +1 -1
  64. package/dist/{hosted-logs-DL_P5AdN.mjs → hosted-logs-FIRx9X2f.mjs} +5 -5
  65. package/dist/{hosted-macos-QI141yKk.mjs → hosted-macos-_awYSpfv.mjs} +21 -12
  66. package/dist/{hosted-native-Ksyjgzq-.mjs → hosted-native-BdzE668-.mjs} +27 -14
  67. package/dist/{idle-BVeRGroT.d.mts → idle-C4cZ757K.d.mts} +3 -3
  68. package/dist/{idle-shutdown-DaKmZi0z.mjs → idle-shutdown-DDg3SdvY.mjs} +7 -7
  69. package/dist/ios-CDvlmUs7.d.mts +24 -0
  70. package/dist/{ios-CQ68hG9s.mjs → ios-Ds1clbIt.mjs} +8 -8
  71. package/dist/{ios-device-CwFMehUS.mjs → ios-device--h_-8ENa.mjs} +3 -3
  72. package/dist/{ios-device-CXGP1bsD.mjs → ios-device-BXZ0c7Kb.mjs} +1 -1
  73. package/dist/{ios-CpByZy12.mjs → ios-hcBpnEGk.mjs} +81 -34
  74. package/dist/{ios-ubFsBzwq.mjs → ios-pm4nL6By.mjs} +59 -50
  75. package/dist/{ios-project-WuwwBdvW.mjs → ios-project-CZhKODF3.mjs} +5 -5
  76. package/dist/{ios-signing-DTTIChGs.mjs → ios-signing-BtAffm0A.mjs} +2 -2
  77. package/dist/{ios-state-DvFX-K_l.mjs → ios-state-Dtw5K2aI.mjs} +1 -1
  78. package/dist/{ios-qNJt4dFm.mjs → ios-xtlRHaeB.mjs} +1 -1
  79. package/dist/{js-swap-Cc1dttps.mjs → js-swap-Bwhh4S7V.mjs} +7 -29
  80. package/dist/{launch-Zq2mOSDy.mjs → launch-BjxemNpK.mjs} +40 -39
  81. package/dist/{launch-CD1yVc7U.mjs → launch-CCzXlc8r.mjs} +16 -16
  82. package/dist/{logs-BS00Anxf.mjs → logs-BfwwadsZ.mjs} +151 -24
  83. package/dist/{logs-CMm05HxN.mjs → logs-jTS_lHSo.mjs} +10 -17
  84. package/dist/{macos-B65--pPd.mjs → macos-DVlSSyUg.mjs} +1 -1
  85. package/dist/{macos-C-0qJ6zq.mjs → macos-NfV2D7dO.mjs} +143 -46
  86. package/dist/macos-run.mjs +1 -1
  87. package/dist/maintenance-run.mjs +8 -8
  88. package/dist/{metro-DEXpIhHC.mjs → metro-DiXtA3Ty.mjs} +59 -37
  89. package/dist/{metro-gateway-BMJNlj3E.mjs → metro-gateway-CKZqKqx7.mjs} +120 -22
  90. package/dist/{named-ports-BWTzt6mu.mjs → named-ports-DkEzOfzO.mjs} +40 -33
  91. package/dist/{native-android-JACyjTZs.mjs → native-android-CqgnOgsT.mjs} +43 -242
  92. package/dist/native-gradle-artifact-inputs-DHFnmrVf.mjs +270 -0
  93. package/dist/{native-gradle-inputs-Bep9JcSF.mjs → native-gradle-inputs-Dnh84Zbd.mjs} +3 -129
  94. package/dist/{native-run-DY_RLx3C.mjs → native-run-NwUuxbkg.mjs} +4 -5
  95. package/dist/{native-runtime-Dg1Q7tfF.mjs → native-runtime-B7KIafpM.mjs} +8 -7
  96. package/dist/native-source-Y0yLhFyQ.mjs +133 -0
  97. package/dist/{native-xcode-inputs-CB2iQeWq.mjs → native-xcode-inputs-D_VOfFL7.mjs} +2 -3
  98. package/dist/{native-xcode-ios-CXX39F7o.mjs → native-xcode-ios-BYDOHWLN.mjs} +27 -32
  99. package/dist/offload-worker.d.mts +65 -2
  100. package/dist/offload-worker.mjs +305 -73
  101. package/dist/operation-exec-BW0em61G.mjs +171 -0
  102. package/dist/{ownership-DEmM5vhh.mjs → ownership-C5fo5Edb.mjs} +3 -3
  103. package/dist/{page-CPaHeYqj.mjs → page-DBL2PiUU.mjs} +8 -4
  104. package/dist/{placement-log-BqGbTa61.mjs → placement-log-BnGgJRRZ.mjs} +1 -1
  105. package/dist/{plan-placement-Bwj-IjY1.mjs → plan-placement-DIsMtN-d.mjs} +12 -8
  106. package/dist/{ports-D-MmCTdv.mjs → ports-Cy1RkmuQ.mjs} +3 -3
  107. package/dist/{prebuild-uD_ipCxF.mjs → prebuild-D4JoEAEs.mjs} +49 -14
  108. package/dist/{project-BZNjmW_8.mjs → project-wM_XFTvE.mjs} +16 -16
  109. package/dist/{pull-request-Lfetn8Kr.mjs → pull-request-W1IuLXDt.mjs} +102 -20
  110. package/dist/{pull-request-zjCSAryH.d.mts → pull-request-eODyIqZF.d.mts} +6 -2
  111. package/dist/pull-requests.d.mts +2 -2
  112. package/dist/pull-requests.mjs +2 -2
  113. package/dist/{react-native-android-DuzH0cn3.mjs → react-native-android-6OZ7MSM7.mjs} +71 -48
  114. package/dist/{react-native-build-rhk4smwQ.mjs → react-native-build-Dvd8hC21.mjs} +8 -8
  115. package/dist/{react-native-doctor-CQpuIMso.mjs → react-native-doctor-DsoSF1Y9.mjs} +7 -7
  116. package/dist/{react-native-ios-Bhq1rJeV.mjs → react-native-ios-4u1Rn-GR.mjs} +40 -26
  117. package/dist/{recordings-DYteQSu4.mjs → recordings-CQmfzAh7.mjs} +1 -1
  118. package/dist/registration-BcRgF6Ox.mjs +51 -0
  119. package/dist/{reload-CmTRFJaX.mjs → reload-BzkYabB-.mjs} +16 -15
  120. package/dist/{reload-DzjSl5P_.mjs → reload-D7AVlb8N.mjs} +1 -1
  121. package/dist/{remote-ByYkXdGD.mjs → remote-DjGDmlTZ.mjs} +18 -15
  122. package/dist/{result-DNiS-tTP.mjs → result-D2Ykz_iD.mjs} +24 -23
  123. package/dist/{run-D23HmJMs.mjs → run-DidHghD1.mjs} +3 -2
  124. package/dist/{selection-CSl9i5qU.mjs → selection-DSMbWEX2.mjs} +6 -5
  125. package/dist/{server-bare-CxTrvDg8.mjs → server-bare-CafzuyFB.mjs} +2 -2
  126. package/dist/{server-command-CtzloH3v.mjs → server-command-C6QjeupS.mjs} +5 -5
  127. package/dist/{server-expo-DT_F_uVI.mjs → server-expo-CrjB29pq.mjs} +7 -5
  128. package/dist/server-expo-D58c9L0M.mjs +2 -0
  129. package/dist/{settings-CsJDEXgK.mjs → settings-C7O8A6ZI.mjs} +223 -243
  130. package/dist/{settings-T1gtc3bf.mjs → settings-DpR-1Wnn.mjs} +1 -1
  131. package/dist/{settings-write-HyVZ8eQ8.mjs → settings-write-CzD60rOD.mjs} +7 -6
  132. package/dist/settings.schema.json +13 -0
  133. package/dist/{simslim-Cgk17SXV.mjs → simslim-BNckWpXi.mjs} +2 -2
  134. package/dist/{slot-launch-DF8VfT64.mjs → slot-launch-CbfmNgM6.mjs} +6 -6
  135. package/dist/{stage-BIS0ydsV.mjs → stage-Bps5oius.mjs} +21 -4
  136. package/dist/{start-RChynRDp.mjs → start-Br-oxqMD.mjs} +1 -1
  137. package/dist/{start-7lpH7hmN.mjs → start-EojN4WFz.mjs} +622 -393
  138. package/dist/{state-C4ZtUisW.mjs → state--smjFSTL.mjs} +22 -7
  139. package/dist/{state-XMziexv2.mjs → state-08I3hw3_.mjs} +2 -2
  140. package/dist/{stats-53T7OTb9.mjs → stats-D3GerlFW.mjs} +5 -5
  141. package/dist/{stats-report-BFfMpWWF.mjs → stats-report-BzaPrRm6.mjs} +1 -1
  142. package/dist/{status-DqEUSSxs.mjs → status-BRROykC8.mjs} +2 -2
  143. package/dist/{status-CSi6tlRq.mjs → status-EvrK72L2.mjs} +1 -1
  144. package/dist/{status-BL7jVyAB.mjs → status-WBDajew2.mjs} +43 -29
  145. package/dist/{status-watch-GDCfqpTE.mjs → status-watch-Bg_u-pwR.mjs} +48 -16
  146. package/dist/status-worker.mjs +1 -1
  147. package/dist/{stim-desktop-C12we7lz.mjs → stim-desktop-D5OGpYZM.mjs} +2 -2
  148. package/dist/{stop-Bk_1qiV6.mjs → stop-DTZ9uTw3.mjs} +2 -2
  149. package/dist/{stop-D7h6jAXQ.mjs → stop-Dky10AEJ.mjs} +31 -22
  150. package/dist/{stop-CPzlM1L-.mjs → stop-Mv6W9FAk.mjs} +15 -16
  151. package/dist/supervisor-run.d.mts +3 -3
  152. package/dist/supervisor-run.mjs +28 -36
  153. package/dist/{support-Dlu37g6H.mjs → support-CNioewsd.mjs} +10 -10
  154. package/dist/{support-67vraa1Q.mjs → support-yUiOjnVY.mjs} +8 -8
  155. package/dist/swiftpm-artifact-inputs-DFcGsXDP.mjs +153 -0
  156. package/dist/swiftpm-macos-BIak-Rxv.mjs +532 -0
  157. package/dist/toolchain-BY8X8HXx.mjs +2 -0
  158. package/dist/{toolchain-Hp9sCpK4.mjs → toolchain-DpJMHq0n.mjs} +9 -6
  159. package/dist/{trigger-BAahxUPq.mjs → trigger-Cbyc41d_.mjs} +3 -3
  160. package/dist/trigger-yb_nFzPF.mjs +2 -0
  161. package/dist/{warm-progress-BHX5r0Ei.mjs → warm-progress-CA3TgT3-.mjs} +29 -16
  162. package/dist/web-CZ07gd77.mjs +2 -0
  163. package/dist/{web-CJmIj6AI.mjs → web-DKx6yoFA.mjs} +11 -10
  164. package/dist/web-run.mjs +11 -9
  165. package/dist/windows-report.mjs +1 -1
  166. package/dist/{workspace-state-Cjuigeeu.mjs → workspace-state-U08dEzhG.mjs} +3 -3
  167. package/dist/{workspaces-BccMFmGQ.mjs → workspaces-CpANmBlq.mjs} +594 -266
  168. package/dist/{worktree-DQ6Zi2Mv.mjs → worktree-CHecZ4Oq.mjs} +850 -551
  169. package/dist/worktree-ZqZVjD9K.mjs +2 -0
  170. package/dist/{xcode-Zlx3qjEs.mjs → xcode-BXn9-xYx.mjs} +5 -5
  171. package/package.json +7 -7
  172. package/shim/android-audio/Main.java +24 -0
  173. package/shim/android-audio/README.md +17 -0
  174. package/shim/android-audio.jar +0 -0
  175. package/dist/gc-C-WwL0yi.mjs +0 -3
  176. package/dist/git-C3iTsJaZ.mjs +0 -73
  177. package/dist/server-expo-C-90EhcG.mjs +0 -2
  178. package/dist/settings-DkdmlelE.d.mts +0 -15
  179. package/dist/swiftpm-macos-p8WZbxKU.mjs +0 -130
  180. package/dist/toolchain-DhKwp9iI.mjs +0 -2
  181. package/dist/trigger-Bf3uDcpv.mjs +0 -2
  182. package/dist/web-DknQETPs.mjs +0 -2
  183. package/dist/workspace-process-lock-1_1OoVW5.mjs +0 -57
  184. package/dist/worktree-CK2MpJW5.mjs +0 -2
@@ -0,0 +1,171 @@
1
+ import { m as operationState, r as WorkspaceProcessCleanupError, t as getExecutor } from "./exec-DEoAhcze.mjs";
2
+ import { sep } from "node:path";
3
+ //#region src/cancellation.ts
4
+ function cancelledError(what, cause) {
5
+ return Object.assign(new Error(`The ${what} was cancelled.`, cause === void 0 ? void 0 : { cause }), { code: "STIM_CANCELLED" });
6
+ }
7
+ function throwIfCancelled(signal, what) {
8
+ if (signal?.aborted) throw cancelledError(what);
9
+ }
10
+ function cancellableSleep(ms, { signal, what = "wait", ref = true } = {}) {
11
+ return new Promise((resolve, reject) => {
12
+ if (signal?.aborted) return reject(cancelledError(what));
13
+ const onAbort = () => {
14
+ clearTimeout(timer);
15
+ reject(cancelledError(what));
16
+ };
17
+ const timer = setTimeout(() => {
18
+ signal?.removeEventListener("abort", onAbort);
19
+ resolve();
20
+ }, ms);
21
+ if (!ref) timer.unref();
22
+ signal?.addEventListener("abort", onAbort, { once: true });
23
+ });
24
+ }
25
+ //#endregion
26
+ //#region src/workspace/git.ts
27
+ const GIT_TIMEOUT_MS = 1e4;
28
+ const GIT_CONCURRENCY = 6;
29
+ function gitCall(cwd, args, { write, signal: _signal, timeoutMs = GIT_TIMEOUT_MS, ...opts }) {
30
+ return {
31
+ args: [
32
+ ...write ? [] : ["--no-optional-locks"],
33
+ "-C",
34
+ cwd,
35
+ ...args
36
+ ],
37
+ opts: {
38
+ cwd,
39
+ ...opts,
40
+ timeoutMs
41
+ }
42
+ };
43
+ }
44
+ /** Runs git in `cwd`, bounded by `timeoutMs` (10 s by default); throws like `runFile`. */
45
+ function git(cwd, args, opts = {}) {
46
+ const call = gitCall(cwd, args, opts);
47
+ return getExecutor().runFile("git", call.args, call.opts);
48
+ }
49
+ /** `git`, returning null instead of throwing. */
50
+ function gitQuiet(cwd, args, opts = {}) {
51
+ const call = gitCall(cwd, args, opts);
52
+ return getExecutor().runFileQuiet("git", call.args, call.opts);
53
+ }
54
+ const queue = [];
55
+ let running = 0;
56
+ /** `git` without blocking the event loop, at most six at a time; the budget starts when the call leaves the queue. */
57
+ async function gitAsync(cwd, args, opts = {}) {
58
+ const signal = opts.signal ?? getExecutor().reportSignal?.();
59
+ signal?.throwIfAborted();
60
+ if (running < GIT_CONCURRENCY) running++;
61
+ else await new Promise((resolve, reject) => {
62
+ const proceed = () => {
63
+ signal?.removeEventListener("abort", cancel);
64
+ resolve();
65
+ };
66
+ const cancel = () => {
67
+ const index = queue.indexOf(proceed);
68
+ if (index !== -1) queue.splice(index, 1);
69
+ reject(signal?.reason);
70
+ };
71
+ queue.push(proceed);
72
+ signal?.addEventListener("abort", cancel, { once: true });
73
+ if (signal?.aborted) cancel();
74
+ });
75
+ let cleanupFailed = false;
76
+ try {
77
+ signal?.throwIfAborted();
78
+ const call = gitCall(cwd, args, opts);
79
+ return await getExecutor().runFileAsync("git", call.args, {
80
+ ...call.opts,
81
+ signal
82
+ });
83
+ } catch (error) {
84
+ cleanupFailed = error instanceof WorkspaceProcessCleanupError || error instanceof Error && "reportCleanup" in error;
85
+ throw error;
86
+ } finally {
87
+ const next = queue.shift();
88
+ if (next) next();
89
+ else running--;
90
+ if (!cleanupFailed) signal?.throwIfAborted();
91
+ }
92
+ }
93
+ /** `gitAsync`, returning null for ordinary failures; cancellation and unresolved cleanup reject. */
94
+ async function gitQuietAsync(cwd, args, opts = {}) {
95
+ try {
96
+ return await gitAsync(cwd, args, opts);
97
+ } catch (error) {
98
+ if (error instanceof WorkspaceProcessCleanupError || error instanceof Error && "reportCleanup" in error) throw error;
99
+ (opts.signal ?? getExecutor().reportSignal?.())?.throwIfAborted();
100
+ return null;
101
+ }
102
+ }
103
+ //#endregion
104
+ //#region src/workspace/git-read.ts
105
+ function childEnvironment(env) {
106
+ return {
107
+ env: Object.fromEntries(Object.entries(env).flatMap(([name, value]) => value === void 0 ? [] : [[name, value]])),
108
+ omitEnv: Object.keys(process.env).filter((name) => env[name] === void 0)
109
+ };
110
+ }
111
+ function killOnAbort(signal) {
112
+ return (child) => {
113
+ if (!signal || getExecutor().reportSignal?.()) return;
114
+ if (signal.aborted) return void child.kill("SIGKILL");
115
+ const kill = () => child.kill("SIGKILL");
116
+ signal.addEventListener("abort", kill, { once: true });
117
+ child.once("close", () => signal.removeEventListener("abort", kill));
118
+ };
119
+ }
120
+ /** `git rev-parse <args>` in `cwd` as a native path, or null; Git runs with exactly `env` and dies when `signal` aborts. */
121
+ function gitPath(cwd, args, env, signal) {
122
+ return gitAsync(cwd, ["rev-parse", ...args], {
123
+ ...childEnvironment(env),
124
+ signal
125
+ }).then((out) => {
126
+ const path = out.trim();
127
+ if (!path) return null;
128
+ return sep === "/" ? path : path.replaceAll("/", sep);
129
+ }, () => null);
130
+ }
131
+ //#endregion
132
+ //#region src/engine/operation-exec.ts
133
+ async function runOperationFile(context, executor, file, args, options) {
134
+ const signal = context ? operationState(context).runSignal ?? context.signal : options.signal;
135
+ throwIfCancelled(signal, file);
136
+ const environment = context ? childEnvironment(context.env) : {
137
+ env: {},
138
+ omitEnv: []
139
+ };
140
+ const output = await executor.runFileAsync(file, args, {
141
+ ...environment,
142
+ ...options,
143
+ ...context ? { env: {
144
+ ...environment.env,
145
+ ...options.env
146
+ } } : {},
147
+ omitEnv: [...environment.omitEnv.filter((name) => options.env?.[name] === void 0), ...options.omitEnv ?? []],
148
+ declareFor: context,
149
+ signal
150
+ });
151
+ throwIfCancelled(signal, file);
152
+ return output;
153
+ }
154
+ /** Contextual probes return null for ordinary failures and propagate cancellation or unresolved cleanup; other calls retain the executor's quiet behavior. */
155
+ async function runOperationFileQuiet(context, executor, file, args, options) {
156
+ const signal = context ? operationState(context).runSignal ?? context.signal : options.signal;
157
+ signal?.throwIfAborted();
158
+ try {
159
+ const output = context ? await runOperationFile(context, executor, file, args, options) : await executor.runFileQuietAsync(file, args, options);
160
+ options.signal?.throwIfAborted();
161
+ signal?.throwIfAborted();
162
+ return output;
163
+ } catch (error) {
164
+ if (error instanceof WorkspaceProcessCleanupError || error instanceof Error && "reportCleanup" in error) throw error;
165
+ options.signal?.throwIfAborted();
166
+ signal?.throwIfAborted();
167
+ return null;
168
+ }
169
+ }
170
+ //#endregion
171
+ export { killOnAbort as a, gitQuiet as c, cancelledError as d, throwIfCancelled as f, gitPath as i, gitQuietAsync as l, runOperationFileQuiet as n, git as o, childEnvironment as r, gitAsync as s, runOperationFile as t, cancellableSleep as u };
@@ -1,6 +1,6 @@
1
- import { p as process_identity_exports } from "./exec-_UbtCQcG.mjs";
2
- import { c as withWorkspaceStateLock, d as writeWorkspaceState, r as readWorkspaceState } from "./workspace-state-Cjuigeeu.mjs";
3
- import { l as pidExists } from "./metro-DEXpIhHC.mjs";
1
+ import { g as process_identity_exports } from "./exec-DEoAhcze.mjs";
2
+ import { c as withWorkspaceStateLock, d as writeWorkspaceState, r as readWorkspaceState } from "./workspace-state-U08dEzhG.mjs";
3
+ import { c as pidExists } from "./metro-DiXtA3Ty.mjs";
4
4
  import { realpathSync } from "node:fs";
5
5
  //#region src/collector/state.ts
6
6
  function collectorRoot(root) {
@@ -1,6 +1,6 @@
1
- import { p as process_identity_exports } from "./exec-_UbtCQcG.mjs";
2
- import { en as throwIfCancelled } from "./settings-CsJDEXgK.mjs";
3
- import { t as connectOwnedBrowser } from "./cdp-CWmIUMbw.mjs";
1
+ import { g as process_identity_exports } from "./exec-DEoAhcze.mjs";
2
+ import { f as throwIfCancelled } from "./operation-exec-BW0em61G.mjs";
3
+ import { t as connectOwnedBrowser } from "./cdp-3fwICjzi.mjs";
4
4
  //#region src/web/page.ts
5
5
  /** The record of a verified live browser: its supervisor and Chrome are the processes the record names. */
6
6
  function liveWebRecord(record) {
@@ -15,6 +15,7 @@ const NAVIGATE_ACK_MS = 1e3;
15
15
  */
16
16
  async function sendToOwnedPage(record, method, params = {}, signal) {
17
17
  const cdp = await connectOwnedBrowser(record.cdpPort, record.chromeProcess.pid, signal);
18
+ let navigateTimer;
18
19
  try {
19
20
  const { targetInfo } = await cdp.send("Target.getTargetInfo", { targetId: record.targetId });
20
21
  throwIfCancelled(signal, "browser operation");
@@ -26,10 +27,13 @@ async function sendToOwnedPage(record, method, params = {}, signal) {
26
27
  const reply = cdp.send(method, params, sessionId);
27
28
  if (method === "Page.navigate") {
28
29
  reply.catch(() => {});
29
- await Promise.race([reply, new Promise((resolve) => setTimeout(resolve, NAVIGATE_ACK_MS))]);
30
+ await Promise.race([reply, new Promise((resolve) => {
31
+ navigateTimer = setTimeout(resolve, NAVIGATE_ACK_MS);
32
+ })]);
30
33
  } else await reply;
31
34
  return targetInfo.url;
32
35
  } finally {
36
+ clearTimeout(navigateTimer);
33
37
  cdp.close();
34
38
  }
35
39
  }
@@ -1,4 +1,4 @@
1
- import { n as buildPlacementSettings } from "./selection-CSl9i5qU.mjs";
1
+ import { n as buildPlacementSettings } from "./selection-DSMbWEX2.mjs";
2
2
  //#region src/placement-log.ts
3
3
  /** `machine` is `local` when the run stays on this machine. */
4
4
  function placementRecord(input) {
@@ -1,6 +1,6 @@
1
- import { d as hostingMachines } from "./selection-CSl9i5qU.mjs";
2
- import { r as readHostedNative } from "./ios-state-DvFX-K_l.mjs";
3
- import { i as probeHost, n as automaticDevicePlacement } from "./eas-fallback-DJwZpy0c.mjs";
1
+ import { d as hostingMachines } from "./selection-DSMbWEX2.mjs";
2
+ import { r as readHostedNative } from "./ios-state-Dtw5K2aI.mjs";
3
+ import { i as probeHost, n as automaticDevicePlacement } from "./eas-fallback-CSgAulr5.mjs";
4
4
  import { automaticMachineEnabled } from "@stim-cli/core/state";
5
5
  //#region src/device-host/plan-placement.ts
6
6
  /**
@@ -9,10 +9,10 @@ import { automaticMachineEnabled } from "@stim-cli/core/state";
9
9
  * give; `auto` repeats the placement decision a run makes now and, when that stays on this machine, notes any Mac
10
10
  * whose device would key differently. The result predicts the cache key only; a run reads its own device.
11
11
  */
12
- async function planHostedDevice({ root, slot, platform, machine, selectors, sameKey, eas, deps = {} }) {
13
- const { automatic = automaticDevicePlacement, probe = probeHost, machines = hostingMachines } = deps;
12
+ async function planHostedDevice({ root, slot, platform, machine, selectors, sameKey, eas, deps = {}, operation }) {
13
+ const { automatic = automaticDevicePlacement, probe = probeHost, machines = () => hostingMachines(void 0, operation?.signal) } = deps;
14
14
  const named = async (name) => {
15
- const result = await probe(name, platform, selectors);
15
+ const result = await probe(name, platform, selectors, void 0, operation?.signal);
16
16
  if ("failure" in result.probe) return {
17
17
  kind: "unknown",
18
18
  reason: `${name} did not give a ${platform} device (${result.probe.failure})`
@@ -38,6 +38,7 @@ async function planHostedDevice({ root, slot, platform, machine, selectors, same
38
38
  platform,
39
39
  selectors,
40
40
  noWait: false,
41
+ signal: operation?.signal,
41
42
  ...eas ? { eas } : {}
42
43
  }, {
43
44
  read: () => ({}),
@@ -52,8 +53,10 @@ async function planHostedDevice({ root, slot, platform, machine, selectors, same
52
53
  choice: placed.target.choice,
53
54
  placement: `on ${placed.target.host.machine}, as auto would now`
54
55
  };
55
- const names = (machines() ?? []).filter((name) => automaticMachineEnabled("device", name));
56
- const differs = (await Promise.all(names.map((name) => probe(name, platform, selectors)))).flatMap(({ probe: each }) => "offer" in each && each.offer.choice && sameKey(each.offer.choice) === false ? [each.machine] : []);
56
+ const names = (await machines() ?? []).filter((name) => automaticMachineEnabled("device", name));
57
+ operation?.signal.throwIfAborted();
58
+ const offers = await Promise.all(names.map((name) => probe(name, platform, selectors, void 0, operation?.signal)));
59
+ const differs = (await Promise.all(offers.map(async ({ probe: each }) => "offer" in each && each.offer.choice && await sameKey(each.offer.choice) === false ? [each.machine] : []))).flat();
57
60
  if (differs.length) return {
58
61
  kind: "local",
59
62
  placement: `this machine; auto may use ${differs.join(", ")}, which builds for another architecture, so its key differs`
@@ -63,6 +66,7 @@ async function planHostedDevice({ root, slot, platform, machine, selectors, same
63
66
  placement: names.length ? `this machine; auto may use ${names.join(", ")}` : "this machine"
64
67
  };
65
68
  } catch (error) {
69
+ operation?.signal.throwIfAborted();
66
70
  return {
67
71
  kind: "unknown",
68
72
  reason: error.message
@@ -1,6 +1,6 @@
1
- import { p as getProject } from "./config-CYcBF478.mjs";
2
- import { n as findCommandWorkspace } from "./project-BZNjmW_8.mjs";
3
- import { n as getNamedPort, t as clearNamedPorts } from "./named-ports-BWTzt6mu.mjs";
1
+ import { p as getProject } from "./config-DlrsduwG.mjs";
2
+ import { n as findCommandWorkspace } from "./project-wM_XFTvE.mjs";
3
+ import { n as getNamedPort, t as clearNamedPorts } from "./named-ports-DkEzOfzO.mjs";
4
4
  //#region src/commands/ports.ts
5
5
  async function inProject(action) {
6
6
  try {
@@ -1,13 +1,13 @@
1
- import { s as spawnDeclared, t as getExecutor } from "./exec-_UbtCQcG.mjs";
1
+ import { d as spawnDeclared, t as getExecutor } from "./exec-DEoAhcze.mjs";
2
2
  import { i as sharedBuildCache } from "./paths-DQtTgsBf.mjs";
3
3
  import { n as stripAnsi, r as waitForChild, t as createLineReader } from "./process-output-Fpl8PYi8.mjs";
4
- import { o as updateWorkspaceState, r as readWorkspaceState$1 } from "./workspace-state-Cjuigeeu.mjs";
5
- import { bt as gitCommonDirOnDisk } from "./settings-CsJDEXgK.mjs";
6
- import { t as git } from "./git-C3iTsJaZ.mjs";
7
- import { v as detectIsExpo } from "./project-BZNjmW_8.mjs";
8
- import { Zn as remoteCliInvocation } from "./budget-Bs6SxxzO.mjs";
9
- import { a as diffFingerprintSources, v as storedSources } from "./build-cache-DmyR9Zzc.mjs";
10
- import { i as expoBinRefusal, r as expoBinPath } from "./server-expo-DT_F_uVI.mjs";
4
+ import { o as git, s as gitAsync } from "./operation-exec-BW0em61G.mjs";
5
+ import { o as updateWorkspaceState, r as readWorkspaceState$1 } from "./workspace-state-U08dEzhG.mjs";
6
+ import { yt as gitCommonDirOnDisk } from "./settings-C7O8A6ZI.mjs";
7
+ import { v as detectIsExpo } from "./project-wM_XFTvE.mjs";
8
+ import { Zn as remoteCliInvocation } from "./budget-Cvwn54qV.mjs";
9
+ import { a as diffFingerprintSources, v as storedSources } from "./build-cache-Dv7RN200.mjs";
10
+ import { i as expoBinRefusal, r as expoBinPath } from "./server-expo-CrjB29pq.mjs";
11
11
  import { existsSync, realpathSync } from "node:fs";
12
12
  import { dirname, join, relative } from "node:path";
13
13
  import { ambientContext } from "@stim-cli/core";
@@ -270,6 +270,10 @@ function prebuildRecord(state) {
270
270
  const record = state?.prebuild;
271
271
  return record && typeof record === "object" ? record : {};
272
272
  }
273
+ function unreadableGitTracksNativeDir(error) {
274
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
275
+ return !/not a git repository \(or any (of the parent directories|parent up to mount point)/.test(error instanceof Error ? error.message : String(error));
276
+ }
273
277
  function gitTracksNativeDir(root, platform) {
274
278
  try {
275
279
  return git(root, [
@@ -281,22 +285,53 @@ function gitTracksNativeDir(root, platform) {
281
285
  LANGUAGE: "C"
282
286
  } }).trim() !== "";
283
287
  } catch (error) {
284
- if (error?.code === "ENOENT") return false;
285
- return !/not a git repository \(or any (of the parent directories|parent up to mount point)/.test(String(error?.message));
288
+ return unreadableGitTracksNativeDir(error);
286
289
  }
287
290
  }
288
- function planPrebuild(root, platform, { isExpo, fingerprint, sources }) {
291
+ function prebuildInputs(root, platform, { isExpo, fingerprint, sources }) {
289
292
  const nativeDirExists = existsSync(nativeDir(root, platform));
290
293
  const fingerprinted = nativeDirInFingerprint(sources, platform);
291
294
  const generatedFrom = prebuildRecord(readWorkspaceState$1(root))[platform];
292
- return prebuildAction({
295
+ return {
293
296
  isExpo,
294
297
  nativeDirExists,
295
298
  nativeDirFingerprinted: fingerprinted,
296
- nativeDirTracked: nativeDirExists && !fingerprinted && gitTracksNativeDir(root, platform),
297
299
  generatedFrom: typeof generatedFrom === "string" ? generatedFrom : null,
298
300
  fingerprint
301
+ };
302
+ }
303
+ function planPrebuild(root, platform, options) {
304
+ const inputs = prebuildInputs(root, platform, options);
305
+ return prebuildAction({
306
+ ...inputs,
307
+ nativeDirTracked: inputs.nativeDirExists && !inputs.nativeDirFingerprinted && gitTracksNativeDir(root, platform)
308
+ });
309
+ }
310
+ async function planPrebuildAsync(root, platform, options, signal) {
311
+ signal?.throwIfAborted();
312
+ const untracked = prebuildAction({
313
+ ...prebuildInputs(root, platform, options),
314
+ nativeDirTracked: false
299
315
  });
316
+ if (untracked !== "regenerate") return untracked;
317
+ let tracked;
318
+ try {
319
+ tracked = (await gitAsync(root, [
320
+ "ls-files",
321
+ "--",
322
+ nativeDirName(platform)
323
+ ], {
324
+ env: {
325
+ LC_ALL: "C",
326
+ LANGUAGE: "C"
327
+ },
328
+ signal
329
+ })).trim() !== "";
330
+ } catch (error) {
331
+ signal?.throwIfAborted();
332
+ tracked = unreadableGitTracksNativeDir(error);
333
+ }
334
+ return tracked ? "refuse" : "regenerate";
300
335
  }
301
336
  function recordPrebuild(root, platform, fingerprint) {
302
337
  updateWorkspaceState(root, (state) => ({
@@ -446,4 +481,4 @@ async function runPrebuild(root, platform, logWriter, { spawnFn = null, now = Da
446
481
  };
447
482
  }
448
483
  //#endregion
449
- export { explainBuildMiss as a, skippedMissReason as c, staleNativeDirRefusal as i, recordPrebuild as n, fingerprintErrorMissReason as o, runPrebuild as r, predictBuildMiss as s, planPrebuild as t };
484
+ export { staleNativeDirRefusal as a, predictBuildMiss as c, runPrebuild as i, skippedMissReason as l, planPrebuildAsync as n, explainBuildMiss as o, recordPrebuild as r, fingerprintErrorMissReason as s, planPrebuild as t };
@@ -1,8 +1,8 @@
1
- import { p as process_identity_exports } from "./exec-_UbtCQcG.mjs";
1
+ import { g as process_identity_exports } from "./exec-DEoAhcze.mjs";
2
2
  import { c as supervisorPidFile, g as workspaceStateFile$1 } from "./paths-DQtTgsBf.mjs";
3
- import { H as deviceSlotKey, W as parseDeviceSlotKey, _ as loadConfig$1, g as isPathPrefix, l as findEnclosingWorktreeRoot, p as getProject } from "./config-CYcBF478.mjs";
4
- import { c as withWorkspaceStateLock, o as updateWorkspaceState, r as readWorkspaceState$1, t as clearWorkspaceStateKey } from "./workspace-state-Cjuigeeu.mjs";
5
- import { Ft as repoRoot, K as resolveIosProjectDir, W as resolveAndroidLayout, at as webSettings, tt as settingValueAt } from "./settings-CsJDEXgK.mjs";
3
+ import { U as parseDeviceSlotKey, V as deviceSlotKey, _ as loadConfig$1, g as isPathPrefix, l as findEnclosingWorktreeRoot, p as getProject } from "./config-DlrsduwG.mjs";
4
+ import { c as withWorkspaceStateLock, o as updateWorkspaceState, r as readWorkspaceState$1, t as clearWorkspaceStateKey } from "./workspace-state-U08dEzhG.mjs";
5
+ import { K as resolveIosProjectDir, Mt as repoRoot, W as resolveAndroidLayout, at as webSettings, tt as settingValueAt } from "./settings-C7O8A6ZI.mjs";
6
6
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
7
7
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
8
8
  import { projectRootDirectories } from "@stim-cli/core/state";
@@ -308,8 +308,8 @@ const nativeAndroidIntegration = {
308
308
  application: true,
309
309
  platforms: () => ["android"],
310
310
  validate: (operation) => operation === "android" ? null : void 0,
311
- android: async () => (await import("./native-android-JACyjTZs.mjs")).nativeAndroidProject(root),
312
- doctor: async () => (await import("./native-android-JACyjTZs.mjs")).nativeAndroidDoctor(root)
311
+ android: async () => (await import("./native-android-CqgnOgsT.mjs")).nativeAndroidProject(root),
312
+ doctor: async () => (await import("./native-android-CqgnOgsT.mjs")).nativeAndroidDoctor(root)
313
313
  };
314
314
  }
315
315
  };
@@ -737,8 +737,8 @@ const nativeXcodeProjectIntegration = {
737
737
  application: problem === null,
738
738
  platforms: () => problem ? [] : ["ios"],
739
739
  validate: (operation) => operation === "ios" ? problem : void 0,
740
- ios: async () => (await import("./native-xcode-ios-CXX39F7o.mjs")).nativeXcodeIosProject(root),
741
- doctor: async () => (await import("./native-xcode-ios-CXX39F7o.mjs")).nativeXcodeDoctor(root)
740
+ ios: async () => (await import("./native-xcode-ios-BYDOHWLN.mjs")).nativeXcodeIosProject(root),
741
+ doctor: async () => (await import("./native-xcode-ios-BYDOHWLN.mjs")).nativeXcodeDoctor(root)
742
742
  };
743
743
  }
744
744
  };
@@ -943,7 +943,7 @@ function createProjectRegistry(integrations) {
943
943
  //#region src/integrations/projects.ts
944
944
  const expo = {
945
945
  mode: MODE_EXPO,
946
- loadDevServer: async () => (await import("./server-expo-C-90EhcG.mjs")).startExpoServer,
946
+ loadDevServer: async () => (await import("./server-expo-D58c9L0M.mjs")).startExpoServer,
947
947
  platforms(root) {
948
948
  const appJson = readAppJson(root);
949
949
  const config = appJson?.expo ?? appJson;
@@ -963,7 +963,7 @@ const expo = {
963
963
  };
964
964
  const reactNative = {
965
965
  mode: MODE_BARE,
966
- loadDevServer: async () => (await import("./server-bare-CxTrvDg8.mjs")).startBareServer,
966
+ loadDevServer: async () => (await import("./server-bare-CafzuyFB.mjs")).startBareServer,
967
967
  platforms(root, { context, settings }) {
968
968
  if (!declaresAppDependency(readPackageJson(root))) return [];
969
969
  const platforms = [];
@@ -993,9 +993,9 @@ const projectRegistry = createProjectRegistry([
993
993
  ownedRoots: problem === null ? [join(root, "ios"), join(root, "android")] : [],
994
994
  platforms: (resolved) => nativeProjectIntegration(root).platforms(root, resolved),
995
995
  validate: (operation) => operation === "ios" || operation === "android" || operation === "dev-server" ? problem : void 0,
996
- ios: async (settings) => (await import("./react-native-ios-Bhq1rJeV.mjs")).reactNativeIosProject(root, settings),
997
- android: async (resolved) => (await import("./react-native-android-DuzH0cn3.mjs")).reactNativeAndroidProject(root, resolved),
998
- doctor: async () => (await import("./react-native-doctor-CQpuIMso.mjs")).reactNativeProjectDoctor(root)
996
+ ios: async (settings) => (await import("./react-native-ios-4u1Rn-GR.mjs")).reactNativeIosProject(root, settings),
997
+ android: async (resolved) => (await import("./react-native-android-6OZ7MSM7.mjs")).reactNativeAndroidProject(root, resolved),
998
+ doctor: async () => (await import("./react-native-doctor-DsoSF1Y9.mjs")).reactNativeProjectDoctor(root)
999
999
  };
1000
1000
  }
1001
1001
  },
@@ -1009,9 +1009,9 @@ const projectRegistry = createProjectRegistry([
1009
1009
  application: true,
1010
1010
  platforms: ({ settings }) => settingValueAt(settings, "macos.product") && settingValueAt(settings, "macos.infoPlist") ? ["macos"] : [],
1011
1011
  validate: (operation) => operation === "macos" ? null : void 0,
1012
- macos: async () => (await import("./swiftpm-macos-p8WZbxKU.mjs")).swiftpmMacosProject(root),
1012
+ macos: async () => (await import("./swiftpm-macos-BIak-Rxv.mjs")).swiftpmMacosProject(root),
1013
1013
  doctor: async () => {
1014
- const { macosToolchain, macosToolchainAsync } = await import("./toolchain-DhKwp9iI.mjs");
1014
+ const { macosToolchain, macosToolchainAsync } = await import("./toolchain-BY8X8HXx.mjs");
1015
1015
  return {
1016
1016
  inspect: () => [],
1017
1017
  offloadTargets: ({ options: { host = process.platform, platform, operation } }) => host === "darwin" && platform === void 0 ? async () => [{
@@ -1031,7 +1031,7 @@ const projectRegistry = createProjectRegistry([
1031
1031
  application: false,
1032
1032
  platforms: ({ settings }) => webSettings(settings).url !== null ? ["web"] : [],
1033
1033
  validate: (operation) => operation === "web" ? null : void 0,
1034
- web: async () => (await import("./browser-web-QQzVjz3O.mjs")).browserWebProject(root)
1034
+ web: async () => (await import("./browser-web-Bcv99PBM.mjs")).browserWebProject(root)
1035
1035
  };
1036
1036
  }
1037
1037
  },
@@ -1,5 +1,5 @@
1
- import { t as getExecutor } from "./exec-_UbtCQcG.mjs";
2
- import { n as gitAsync, r as gitQuiet } from "./git-C3iTsJaZ.mjs";
1
+ import { r as WorkspaceProcessCleanupError, t as getExecutor } from "./exec-DEoAhcze.mjs";
2
+ import { c as gitQuiet, l as gitQuietAsync, r as childEnvironment, s as gitAsync, t as runOperationFile } from "./operation-exec-BW0em61G.mjs";
3
3
  //#region src/workspace/pull-request.ts
4
4
  const GH_TIMEOUT_MS = 2e4;
5
5
  const GH_ENV = {
@@ -81,16 +81,8 @@ function headRepoOf(pull) {
81
81
  const name = pull.headRepository?.name;
82
82
  return owner && name ? `${owner.toLowerCase()}/${name.toLowerCase()}` : null;
83
83
  }
84
- /**
85
- * Picks the pull request that describes `head` among those `gh pr list --head <branch>` returned. One whose head is
86
- * `head` wins, then one whose head contains `head`, then one whose head `head` contains. An open one wins a tier,
87
- * then the newest. A pull request unrelated to `head` is from an earlier use of the branch name and is ignored. A
88
- * cross-repository pull request is kept only when its head repository is one of `ownRepos` (this checkout's own git
89
- * remotes, lowercased "owner/name"); otherwise it only shares the branch name with a stranger's fork and is ignored.
90
- * `isAncestor(a, b)` answers whether commit `a` is an ancestor of commit `b`, and false when git cannot tell.
91
- */
92
- function selectPullRequest(pulls, head, isAncestor, ownRepos = /* @__PURE__ */ new Set()) {
93
- const known = pulls.flatMap((pull) => {
84
+ function knownPullRequests(pulls, ownRepos) {
85
+ return pulls.flatMap((pull) => {
94
86
  if (!pull || typeof pull !== "object") return [];
95
87
  const state = stateOf(pull.state);
96
88
  if (!state || !pull.headRefOid) return [];
@@ -103,6 +95,17 @@ function selectPullRequest(pulls, head, isAncestor, ownRepos = /* @__PURE__ */ n
103
95
  state
104
96
  }];
105
97
  });
98
+ }
99
+ /**
100
+ * Picks the pull request that describes `head` among those `gh pr list --head <branch>` returned. One whose head is
101
+ * `head` wins, then one whose head contains `head`, then one whose head `head` contains. An open one wins a tier,
102
+ * then the newest. A pull request unrelated to `head` is from an earlier use of the branch name and is ignored. A
103
+ * cross-repository pull request is kept only when its head repository is one of `ownRepos` (this checkout's own git
104
+ * remotes, lowercased "owner/name"); otherwise it only shares the branch name with a stranger's fork and is ignored.
105
+ * `isAncestor(a, b)` answers whether commit `a` is an ancestor of commit `b`, and false when git cannot tell.
106
+ */
107
+ function selectPullRequest(pulls, head, isAncestor, ownRepos = /* @__PURE__ */ new Set()) {
108
+ const known = knownPullRequests(pulls, ownRepos);
106
109
  const tiers = [
107
110
  known.filter(({ pull }) => pull.headRefOid === head),
108
111
  known.filter(({ pull }) => pull.headRefOid !== head && isAncestor(head, pull.headRefOid)),
@@ -159,7 +162,9 @@ function parseRemoteRepo(url) {
159
162
  return owner && name ? `${owner.toLowerCase()}/${name.toLowerCase()}` : null;
160
163
  }
161
164
  function localRemoteRepos(cwd) {
162
- const out = gitQuiet(cwd, ["remote", "-v"]);
165
+ return remoteRepos(gitQuiet(cwd, ["remote", "-v"]));
166
+ }
167
+ function remoteRepos(out) {
163
168
  const repos = /* @__PURE__ */ new Set();
164
169
  for (const line of out ? out.split("\n") : []) {
165
170
  const url = /^\S+\s+(\S+)\s+\((?:fetch|push)\)$/.exec(line)?.[1];
@@ -168,6 +173,33 @@ function localRemoteRepos(cwd) {
168
173
  }
169
174
  return repos;
170
175
  }
176
+ function gitExecution(operation) {
177
+ return {
178
+ ...operation ? childEnvironment(operation.env) : {},
179
+ signal: operation?.signal,
180
+ declareFor: operation,
181
+ cwd: operation?.cwd,
182
+ killSignal: "SIGKILL"
183
+ };
184
+ }
185
+ async function selectPullRequestAsync(cwd, pulls, head, ownRepos, operation) {
186
+ const options = gitExecution(operation);
187
+ const ancestors = /* @__PURE__ */ new Map();
188
+ for (const { pull } of knownPullRequests(pulls, ownRepos)) {
189
+ if (pull.headRefOid === head) continue;
190
+ for (const [a, b] of [[head, pull.headRefOid], [pull.headRefOid, head]]) {
191
+ const key = `${a}:${b}`;
192
+ if (!ancestors.has(key)) ancestors.set(key, await gitQuietAsync(cwd, [
193
+ "merge-base",
194
+ "--is-ancestor",
195
+ a,
196
+ b
197
+ ], options) !== null);
198
+ }
199
+ }
200
+ operation?.signal.throwIfAborted();
201
+ return selectPullRequest(pulls, head, (a, b) => ancestors.get(`${a}:${b}`) ?? false, ownRepos);
202
+ }
171
203
  /**
172
204
  * Asks GitHub, through `gh`, which pull requests have `branch` as their head, run from `cwd` so `gh` picks the
173
205
  * repository from its remotes. Each call is one fixed `gh pr list` invocation. Once `gh` is missing, signed out or
@@ -211,6 +243,50 @@ function pullRequestLookup() {
211
243
  return { pullRequest: Array.isArray(pulls) ? selectPullRequest(pulls, head, ancestry(cwd), localRemoteRepos(cwd)) : null };
212
244
  };
213
245
  }
246
+ /** The same branch and commit lookup as `pullRequestLookup`, with nonblocking Git and GitHub probes. */
247
+ function pullRequestLookupAsync(operation) {
248
+ let unavailable;
249
+ return async (cwd, branch, head) => {
250
+ const exec = getExecutor();
251
+ operation?.signal.throwIfAborted();
252
+ if (unavailable === void 0) unavailable = exec.findExecutable("gh") ? null : "gh is not installed";
253
+ if (unavailable) return { unavailable };
254
+ let out;
255
+ try {
256
+ out = await runOperationFile(operation, exec, "gh", [
257
+ "pr",
258
+ "list",
259
+ "--head",
260
+ branch,
261
+ "--state",
262
+ "all",
263
+ "--limit",
264
+ "20",
265
+ "--json",
266
+ GH_FIELDS
267
+ ], {
268
+ cwd,
269
+ timeoutMs: GH_TIMEOUT_MS,
270
+ env: GH_ENV
271
+ });
272
+ } catch (error) {
273
+ if (error instanceof WorkspaceProcessCleanupError || error instanceof Error && "reportCleanup" in error) throw error;
274
+ operation?.signal.throwIfAborted();
275
+ const failure = ghFailure(error, "gh pr list");
276
+ if (failure.sticky) unavailable = failure.unavailable;
277
+ return { unavailable: failure.unavailable };
278
+ }
279
+ let pulls;
280
+ try {
281
+ pulls = JSON.parse(out);
282
+ } catch {
283
+ return { unavailable: "gh pr list printed no JSON" };
284
+ }
285
+ if (!Array.isArray(pulls)) return { pullRequest: null };
286
+ const ownRepos = remoteRepos(await gitQuietAsync(cwd, ["remote", "-v"], gitExecution(operation)));
287
+ return { pullRequest: await selectPullRequestAsync(cwd, pulls, head, ownRepos, operation) };
288
+ };
289
+ }
214
290
  function branchesQuery(count, detail) {
215
291
  const variables = Array.from({ length: count }, (_, i) => `, $b${i}: String!`).join("");
216
292
  const nodes = `${GH_SCALAR_FIELDS.replaceAll(",", " ")} ${GH_GRAPHQL_REPO_SELECTION}` + (detail ? ` ${GH_DETAIL_FIELDS}` : "");
@@ -223,9 +299,10 @@ function branchesQuery(count, detail) {
223
299
  * out or times out, every later call through the same function answers `unavailable` without running it again.
224
300
  * With `detail`, it also asks for each pull request's title, review decision and head commit check counts.
225
301
  */
226
- function pullRequestLookups({ detail = false } = {}) {
302
+ function pullRequestLookups({ detail = false, operation } = {}) {
227
303
  let unavailable;
228
304
  return async (repo, queries) => {
305
+ operation?.signal.throwIfAborted();
229
306
  const exec = getExecutor();
230
307
  if (unavailable === void 0) unavailable = exec.findExecutable("gh") ? null : "gh is not installed";
231
308
  const all = (lookup) => queries.map(() => lookup);
@@ -243,12 +320,14 @@ function pullRequestLookups({ detail = false } = {}) {
243
320
  args.push("-f", `query=${branchesQuery(queries.length, detail)}`);
244
321
  let out;
245
322
  try {
246
- out = await exec.runFileAsync("gh", args, {
323
+ out = await runOperationFile(operation, exec, "gh", args, {
247
324
  cwd: repo,
248
325
  timeoutMs: GH_TIMEOUT_MS,
249
326
  env: GH_ENV
250
327
  });
251
328
  } catch (error) {
329
+ if (error instanceof WorkspaceProcessCleanupError || error instanceof Error && "reportCleanup" in error) throw error;
330
+ operation?.signal.throwIfAborted();
252
331
  const failure = ghFailure(error, "gh api graphql");
253
332
  if (failure.sticky) unavailable = failure.unavailable;
254
333
  return all({ unavailable: failure.unavailable });
@@ -260,11 +339,14 @@ function pullRequestLookups({ detail = false } = {}) {
260
339
  return all({ unavailable: "gh api graphql printed no JSON" });
261
340
  }
262
341
  if (!found) return all({ unavailable: "gh api graphql printed no repository" });
263
- const ownRepos = localRemoteRepos(repo);
264
- return queries.map(({ cwd, head }, i) => {
342
+ const ownRepos = remoteRepos(await gitQuietAsync(repo, ["remote", "-v"], gitExecution(operation)));
343
+ const results = [];
344
+ for (const [i, { cwd, head }] of queries.entries()) {
345
+ operation?.signal.throwIfAborted();
265
346
  const pulls = found[`b${i}`]?.nodes;
266
- return { pullRequest: Array.isArray(pulls) ? selectPullRequest(pulls, head, ancestry(cwd), ownRepos) : null };
267
- });
347
+ results.push({ pullRequest: Array.isArray(pulls) ? await selectPullRequestAsync(cwd, pulls, head, ownRepos, operation) : null });
348
+ }
349
+ return results;
268
350
  };
269
351
  }
270
352
  /** The merged or closed pull request whose commits include HEAD, which makes the worktree removable. */
@@ -306,4 +388,4 @@ function worktreePullRequests() {
306
388
  };
307
389
  }
308
390
  //#endregion
309
- export { pullRequestLookup as a, worktreePullRequests as c, parseRemoteRepo as i, describePullRequest as n, pullRequestLookups as o, endedPullRequest as r, selectPullRequest as s, checkCounts as t };
391
+ export { pullRequestLookup as a, selectPullRequest as c, parseRemoteRepo as i, worktreePullRequests as l, describePullRequest as n, pullRequestLookupAsync as o, endedPullRequest as r, pullRequestLookups as s, checkCounts as t };