stim 1.19.0 → 1.20.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 (172) hide show
  1. package/README.md +20 -3
  2. package/dist/{activity-BSw0x84R.mjs → activity-BrGh9EAI.mjs} +3 -3
  3. package/dist/{agent-device-usage-output-Bjxu_VmX.mjs → agent-device-usage-output-DVyv_hWj.mjs} +7 -7
  4. package/dist/android-0vv-OruW.mjs +6 -0
  5. package/dist/android-Brx6EKvJ.mjs +1258 -0
  6. package/dist/{android-BdQC6zs1.mjs → android-BsYNR81W.mjs} +103 -45
  7. package/dist/{android-DE5g_5gv.mjs → android-CK3fpEyZ.mjs} +2 -2
  8. package/dist/{android-cas-C87geAg-.mjs → android-cas-DCAuXryb.mjs} +9 -5
  9. package/dist/android-cas-compiler.mjs +1 -1
  10. package/dist/api-run.mjs +159 -8
  11. package/dist/{api-DIf_s86s.mjs → api-zuX3ynYN.mjs} +5 -1
  12. package/dist/api.d.mts +98 -4
  13. package/dist/api.mjs +1 -1
  14. package/dist/{app-install-CFI4ptUL.mjs → app-install-0LgaQRT7.mjs} +9 -8
  15. package/dist/artifact-CnC0mfov.mjs +807 -0
  16. package/dist/artifact-DClXJNWx.mjs +772 -0
  17. package/dist/artifact-lifecycle-DzPpBYvK.mjs +30 -0
  18. package/dist/{browser-web-CDhqQxhv.mjs → browser-web-CzBmhmgs.mjs} +19 -19
  19. package/dist/{budget-Dz-kyXLv.mjs → budget-BONq9vXY.mjs} +3101 -3062
  20. package/dist/build-BixRI6sB.mjs +462 -0
  21. package/dist/{build-facts-B87vo-Im.d.mts → build-facts-DcLv2HSd.d.mts} +1 -32
  22. package/dist/build-plan-CP0tckNU.mjs +553 -0
  23. package/dist/{cache-manifest-DiwKSyv9.mjs → cache-manifest-qA3dT2x2.mjs} +1 -1
  24. package/dist/cache-manifest.mjs +1 -1
  25. package/dist/{manifest-CX0d1IkZ.mjs → ccache-CjHQ5F8g.mjs} +13 -19
  26. package/dist/{chrome-BTUOo8p2.mjs → chrome-Dp2lMLBe.mjs} +1 -1
  27. package/dist/{cli-C9Zvgbdc.mjs → cli-B2R8wH1F.mjs} +20 -20
  28. package/dist/cli.mjs +1 -1
  29. package/dist/{client-CuUo8Nvg.mjs → client-BLy1Pw2V.mjs} +89 -307
  30. package/dist/collector-run.d.mts +4 -0
  31. package/dist/collector-run.mjs +7 -7
  32. package/dist/{command-output-Bt8ygHE7.mjs → command-output-BjPN99ZB.mjs} +2 -2
  33. package/dist/{config-DC5jEtd1.mjs → config-D0LhTY3S.mjs} +8 -12
  34. package/dist/{created-devices-D0s26Hx5.mjs → created-devices-HU_DAb_Q.mjs} +7 -6
  35. package/dist/{dependency-state-DKaS1OM9.mjs → dependency-state-B2m8eqsS.mjs} +2 -2
  36. package/dist/{detached-entry-pB_IPfV4.mjs → detached-entry-BXq4fIl-.mjs} +1 -1
  37. package/dist/{dev-client-CDY_zAmD.mjs → dev-client-ClATaJoH.mjs} +2 -2
  38. package/dist/{device-BHw0WlHl.mjs → device-B7lsC0K1.mjs} +8 -8
  39. package/dist/device-DVCwAFlX.mjs +727 -0
  40. package/dist/{device-capacity-BoN1jQkO.mjs → device-capacity-Ca_ke1LE.mjs} +13 -14
  41. package/dist/device-host-worker.mjs +38 -18
  42. package/dist/device-ios-CRUqPxKw.mjs +413 -0
  43. package/dist/{device-lease-Cu7PtQpZ.mjs → device-lease-DHOBXGgS.mjs} +135 -22
  44. package/dist/{device-lease-run-D38SnZtt.mjs → device-lease-run-CvDeHTkG.mjs} +4 -4
  45. package/dist/{device-pool-CP4rAsHx.mjs → device-pool-L2-5GxMy.mjs} +3 -3
  46. package/dist/{device-remote-B5GiUifk.mjs → device-remote-Bmg42063.mjs} +17 -68
  47. package/dist/doctor-C2MSuMMg.mjs +515 -0
  48. package/dist/{doctor-PRJH94v6.mjs → doctor-DPAqhVCK.mjs} +333 -744
  49. package/dist/{doctor-watchman-wZhyTdp4.mjs → doctor-watchman-CB4NnVZm.mjs} +13 -12
  50. package/dist/{simslim-D9LkJxIO.mjs → eas-build-Dw_ec2Km.mjs} +6 -152
  51. package/dist/{stim-installations-DbmUjsLv.mjs → eas-session-ledger-DZlC-Fq3.mjs} +57 -4
  52. package/dist/{error-diagnostics--v5HGOU0.mjs → error-diagnostics-Du7I_GuY.mjs} +17 -12
  53. package/dist/errors-DzkMYh8Q.mjs +205 -0
  54. package/dist/{exec-i8GDPwq9.mjs → exec-B81Qodjn.mjs} +40 -10
  55. package/dist/{gc-CyHMcKcn.mjs → gc-PWp34zGb.mjs} +21 -20
  56. package/dist/{device-ios-B2ruohE-.mjs → gradle-C2OEKCCI.mjs} +21 -650
  57. package/dist/{guide-dRaQJJk9.mjs → guide-Dai9lphv.mjs} +504 -117
  58. package/dist/{hosted-android-Bs7fytj7.mjs → hosted-android-DQ-Agsd8.mjs} +5 -5
  59. package/dist/{hosted-client-C5G4h_OJ.mjs → hosted-client-Io01s5By.mjs} +9 -3
  60. package/dist/{hosted-ios-Bik035eL.mjs → hosted-ios-DIxFnYp-.mjs} +3 -3
  61. package/dist/{hosted-logs-CI9Az9a4.mjs → hosted-logs-DP-ABU_M.mjs} +8 -8
  62. package/dist/{hosted-macos-DABm3ScO.mjs → hosted-macos-Aziw9T_9.mjs} +7 -6
  63. package/dist/{hosted-native-DbV2aUVw.mjs → hosted-native-BdAQi21M.mjs} +17 -14
  64. package/dist/{idle-shutdown-DYiMBn34.mjs → idle-shutdown-DdMqoSUB.mjs} +7 -7
  65. package/dist/{ios-DYUr9LGc.mjs → ios-BZ9dg2Fr.mjs} +8 -7
  66. package/dist/{ios-BWbHFZVz.mjs → ios-CXLIUxXJ.mjs} +180 -24
  67. package/dist/ios-CZuv6gRv.mjs +1112 -0
  68. package/dist/{ios-DCrkgXEM.mjs → ios-VGvNdsv2.mjs} +1 -1
  69. package/dist/{ios-device-CrW8aMb5.mjs → ios-device-B1B14xND.mjs} +1 -1
  70. package/dist/{ios-device-CJ_ZOGky.mjs → ios-device-BreZOpM0.mjs} +3 -3
  71. package/dist/ios-project-B9drt_aY.mjs +197 -0
  72. package/dist/{ios-state-By0XuLTQ.mjs → ios-state-CjrL2qv-.mjs} +1 -1
  73. package/dist/js-swap-C8icNYIY.mjs +432 -0
  74. package/dist/launch-DxH0THLP.mjs +745 -0
  75. package/dist/{react-native-ios-CSpIxexZ.mjs → launch-YrbqaIFj.mjs} +59 -612
  76. package/dist/{launch-verify-DCveSE6d.mjs → launch-verify-BzRdbuO1.mjs} +26 -7
  77. package/dist/{logs-Bao1HOMy.mjs → logs-DHaRNfg7.mjs} +11 -11
  78. package/dist/macos-C0iljhsN.mjs +2 -0
  79. package/dist/{macos-ciyBdTY5.mjs → macos-V_3Ui7g4.mjs} +42 -50
  80. package/dist/macos-run.mjs +1 -1
  81. package/dist/maintenance-run.mjs +13 -10
  82. package/dist/{metro-DI2AjPF_.mjs → metro-D_j9sN-B.mjs} +18 -5
  83. package/dist/{metro-gateway-BxpJLIwh.mjs → metro-gateway-BBJldOdi.mjs} +2 -2
  84. package/dist/miss-reason-BPAzZS0r.mjs +238 -0
  85. package/dist/{named-ports-B4iWH4E-.mjs → named-ports-C2lvoPsb.mjs} +3 -3
  86. package/dist/native-android-lHzaew7r.mjs +226 -0
  87. package/dist/native-gradle-inputs-BQnIdAlL.mjs +356 -0
  88. package/dist/{native-runtime-BGxsbfny.mjs → native-runtime-BRmWL7ru.mjs} +9 -8
  89. package/dist/native-xcode-inputs-eutS19jU.mjs +307 -0
  90. package/dist/native-xcode-ios-DP3cHLwu.mjs +434 -0
  91. package/dist/{ndjson-LGZAMsqa.mjs → ndjson-GOnbyvso.mjs} +6 -6
  92. package/dist/offload-worker.d.mts +41 -7
  93. package/dist/offload-worker.mjs +409 -74
  94. package/dist/{ownership-EB0ySdGK.mjs → ownership-DXzMMSx6.mjs} +2 -2
  95. package/dist/{placement-log-Dxe34rJm.mjs → placement-log-reFbjqEr.mjs} +1 -1
  96. package/dist/plan-BDk2AeY_.mjs +260 -0
  97. package/dist/plan-placement-D_YYlE6N.mjs +73 -0
  98. package/dist/{ports-ByPc0_97.mjs → ports-jzvAJXXL.mjs} +3 -3
  99. package/dist/{prebuild-BKJ3wJI1.mjs → prebuild-Bw44QxVh.mjs} +4 -4
  100. package/dist/{preview-BbSottmO.mjs → preview-BaBJ72Al.mjs} +50 -32
  101. package/dist/project-B8_duAzW.mjs +1067 -0
  102. package/dist/project-plan-BPwbLwQu.mjs +10 -0
  103. package/dist/{pull-request-IHNdMnG8.mjs → pull-request-vOhLNmIb.mjs} +1 -1
  104. package/dist/pull-requests.mjs +1 -1
  105. package/dist/react-native-android-chm1DMlA.mjs +921 -0
  106. package/dist/react-native-build-oAw6gQeW.mjs +239 -0
  107. package/dist/react-native-doctor-DYXoh-6I.mjs +78 -0
  108. package/dist/react-native-ios-SCTK_CT5.mjs +595 -0
  109. package/dist/{recordings-Bv8McZN4.mjs → recordings-Bk-VivUV.mjs} +1 -1
  110. package/dist/{reload-rAPdqeRR.mjs → reload-D34GkY78.mjs} +17 -13
  111. package/dist/remote-BU9UyhCJ.mjs +192 -0
  112. package/dist/{remote-cache-N3hAEaAL.mjs → remote-cache-Bsts6f6Y.mjs} +5 -5
  113. package/dist/result-BDoRk1k3.mjs +186 -0
  114. package/dist/{run-lAkle1-c.mjs → run-qvff78hv.mjs} +3 -3
  115. package/dist/{server-bare-CkIjnegq.mjs → server-bare-dWjAarki.mjs} +5 -5
  116. package/dist/server-command-7XIKlWtO.mjs +69 -0
  117. package/dist/{server-expo-n3tUi3Em.mjs → server-expo-CsYu2aKL.mjs} +107 -82
  118. package/dist/server-expo-DV43vep4.mjs +2 -0
  119. package/dist/{settings-CxgngUZk.mjs → settings-Bbztm4oV.mjs} +179 -129
  120. package/dist/{settings-2am7TSxp.mjs → settings-CT3E71-i.mjs} +6 -6
  121. package/dist/{state-lKh8shBp.d.mts → settings-vk3mJGSm.d.mts} +4 -2
  122. package/dist/settings.schema.json +84 -0
  123. package/dist/simslim-ChMfe8rg.mjs +149 -0
  124. package/dist/{slot-launch-HV_KtPIw.mjs → slot-launch-B9hn96wd.mjs} +6 -6
  125. package/dist/{stage-BgaZJVZY.mjs → stage-BNKKdDNc.mjs} +6 -3
  126. package/dist/start-CbQCSnXQ.mjs +2 -0
  127. package/dist/{start-DtxthMfI.mjs → start-CdvcTaXr.mjs} +97 -68
  128. package/dist/{state-Tp4uImDS.mjs → state-Boo0IMJq.mjs} +1 -1
  129. package/dist/{state-D2KtnALG.mjs → state-DI84A-uu.mjs} +29 -10
  130. package/dist/{stats-8EJ5ivFT.mjs → stats-BIIDrjA8.mjs} +5 -5
  131. package/dist/{status-BEeL6IKz.mjs → status-BDGHwkCs.mjs} +3 -1
  132. package/dist/{status-BOyp0CUl.mjs → status-DARMkc9q.mjs} +81 -293
  133. package/dist/status-watch-DvmI3SmN.mjs +296 -0
  134. package/dist/{stim-desktop-C65jk_q2.mjs → stim-desktop-8GQX2OV8.mjs} +1 -1
  135. package/dist/{stop-DRipAg-e.mjs → stop-CCZS-C9m.mjs} +2 -2
  136. package/dist/{stop-D0UIpZuh.mjs → stop-WQPQHLuy.mjs} +5 -5
  137. package/dist/{stop-zDlknFoz.mjs → stop-iNemHsJC.mjs} +21 -20
  138. package/dist/supervisor-run.d.mts +7 -2
  139. package/dist/supervisor-run.mjs +32 -20
  140. package/dist/{support-DsNaFg6D.mjs → support-CnE_SIjt.mjs} +17 -7
  141. package/dist/{support-CNqYkV0y.mjs → support-DCco5fut.mjs} +61 -8
  142. package/dist/{swiftpm-macos-aJzPAj1t.mjs → swiftpm-macos-afeNUExW.mjs} +5 -5
  143. package/dist/tailnet-CoJUb2tB.mjs +265 -0
  144. package/dist/toolchain-BIupIro1.mjs +2 -0
  145. package/dist/{toolchain-C3xSoyUl.mjs → toolchain-DqyDXs30.mjs} +206 -53
  146. package/dist/{trigger-CAhmG-4s.mjs → trigger-C0MWBi8O.mjs} +2 -2
  147. package/dist/trigger-SHLOWJ4O.mjs +2 -0
  148. package/dist/{warm-progress-pFLB2e6P.mjs → warm-progress-C3ASD6z5.mjs} +6 -6
  149. package/dist/{watchman-BL1IdOtq.mjs → watchman-CQl51YZu.mjs} +6 -6
  150. package/dist/{web-DbbrPUn0.mjs → web-B3eldHFH.mjs} +9 -13
  151. package/dist/web-BLXpOe6b.mjs +2 -0
  152. package/dist/web-run.mjs +10 -10
  153. package/dist/{workspace-state-CR9X86xJ.mjs → workspace-state-CSIFuuDa.mjs} +33 -33
  154. package/dist/{workspaces-Djb2gfi9.mjs → workspaces-D2xSHBDY.mjs} +1260 -1258
  155. package/dist/{worktree-BL4M1rhB.mjs → worktree-BxDqaTev.mjs} +84 -48
  156. package/dist/worktree-q7_OZNY0.mjs +2 -0
  157. package/package.json +8 -6
  158. package/shim/native-android.gradle +101 -0
  159. package/dist/android-BXc6BmEi.mjs +0 -3732
  160. package/dist/android-BvV1gGdN.mjs +0 -4
  161. package/dist/ios-ITYno9rO.mjs +0 -2241
  162. package/dist/macos-nIOATJmR.mjs +0 -2
  163. package/dist/metro-store-BAHFcJm6.mjs +0 -106
  164. package/dist/miss-reason-CjQCOKqq.mjs +0 -1743
  165. package/dist/plan-placement-BVY59qa8.mjs +0 -290
  166. package/dist/project-B5eQ1USs.mjs +0 -612
  167. package/dist/react-native-ios-BMh2i25I.mjs +0 -2
  168. package/dist/server-expo-DGsdUGX2.mjs +0 -2
  169. package/dist/start-D8NbxNBb.mjs +0 -2
  170. package/dist/trigger-CoalsMTV.mjs +0 -2
  171. package/dist/web-DFpFeZu5.mjs +0 -2
  172. package/dist/worktree-DV-A0LNL.mjs +0 -2
@@ -1,46 +1,15 @@
1
- import { n as ownership_claim_exports } from "./process-identity-Biv3arCO.mjs";
2
- import { t as getExecutor } from "./exec-i8GDPwq9.mjs";
1
+ import { t as getExecutor } from "./exec-B81Qodjn.mjs";
3
2
  import { n as stripAnsi, r as waitForChild, t as createLineReader } from "./process-output-Fpl8PYi8.mjs";
4
- import { l as phaseLine } from "./command-output-Bt8ygHE7.mjs";
5
- import { C as saveConfig, D as withConfigLock, H as projectDeviceSlots, _ as loadConfig, a as clearDevice, d as getConfigDir, w as setDevice, z as deviceSlotPlatforms } from "./config-DC5jEtd1.mjs";
6
- import { p as sharedCompilationCache, y as workspaceId } from "./workspace-state-CR9X86xJ.mjs";
7
- import { v as resolvePackageJson } from "./project-B5eQ1USs.mjs";
8
- import { Ot as resolveOptimizations, v as iosSimSlimProfileSetting } from "./settings-CxgngUZk.mjs";
9
- import { r as register } from "./cache-manifest-DiwKSyv9.mjs";
10
- import { j as teardownParkedIosSim } from "./workspaces-Djb2gfi9.mjs";
3
+ import { l as phaseLine } from "./command-output-BjPN99ZB.mjs";
4
+ import { o as androidHome } from "./android-BsYNR81W.mjs";
11
5
  import { a as spawnDeclared } from "./spawn-claims-Kqiifsk2.mjs";
12
- import { ct as dropParked, ft as parkedMaxSetting, ht as selectParked, o as androidHome, pt as readParked, st as adoptParked } from "./android-BdQC6zs1.mjs";
13
- import { C as resetIosPrivacy, M as readHostMemoryPressure, S as resetIosKeychain, T as resolveOwnedIosSim, a as createOwnedIosSim, d as listAllIosSims, g as ownedSimName, j as hostMemoryPressureAdvice, k as configuredIosSimulatorViewer, m as listIosRuntimes, n as bootIosSim, p as listIosDeviceTypes, u as iosSimulatorFailureAdvice, v as parseRuntimeVersion, w as resolveIosCreation, x as renameIosSim } from "./ios-BWbHFZVz.mjs";
14
- import { a as withWorkspaceProcessLock } from "./named-ports-B4iWH4E-.mjs";
15
- import { a as deviceTypeMismatch, c as runtimeMismatch, n as DeviceAdmissionRefusal, p as withDeviceBootAdmission } from "./device-capacity-BoN1jQkO.mjs";
16
- import { o as readCcacheActivity, r as CCACHE_UNAVAILABLE } from "./manifest-CX0d1IkZ.mjs";
17
- import { D as swiftPrefixMappingSupported, E as startBuildHeartbeat, S as pickXcodeProject, _ as buildXcode, b as detectSwiftVersion, g as SWIFT_PREFIX_MAPPING_MIN_SWIFT, h as HEARTBEAT_INTERVAL_MS, x as detectXcodeMajor, y as compilationCacheSettings } from "./toolchain-C3xSoyUl.mjs";
6
+ import { a as readCcacheActivity, n as CCACHE_UNAVAILABLE } from "./ccache-CjHQ5F8g.mjs";
7
+ import { M as startBuildHeartbeat, y as HEARTBEAT_INTERVAL_MS } from "./toolchain-DqyDXs30.mjs";
18
8
  import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
19
9
  import { dirname, isAbsolute, join, relative, sep } from "node:path";
20
10
  import { fileURLToPath } from "node:url";
21
- import chalk from "chalk";
22
11
  import { createHash } from "node:crypto";
23
- /** The ABI name a build for every ABI has to fit; `stim android` narrows a build to the device's. */
24
- const LONGEST_ANDROID_ABI = "armeabi-v7a";
25
- function androidPathRoom(root, { abi = null, variant = null, platform = process.platform } = {}) {
26
- if (platform !== "win32") return null;
27
- const abiName = abi ?? LONGEST_ANDROID_ABI;
28
- const tail = 198 + (/release$/i.test(variant ?? "") ? 14 : 5) - 5 + abiName.length;
29
- const longest = root.length + tail;
30
- if (longest < 240) return null;
31
- return {
32
- root,
33
- abi: abiName,
34
- longest,
35
- maxRootLength: 239 - tail
36
- };
37
- }
38
- function androidPathRoomMessage({ root, abi, longest, maxRootLength }) {
39
- return `The project root ${root} is ${root.length} characters, so the longest known Android native object path (react_codegen_safeareacontext for ${abi}) reaches ${longest} characters, past the 239 the NDK's ninja can be given on Windows; the root can be at most ${maxRootLength} characters.`;
40
- }
41
- function androidPathRoomRemedy({ root }) {
42
- return `Map the project to a drive letter (\`subst X: "${root}"\`) and run Stim from X:\\, or move it under a shorter root.`;
43
- }
12
+ import chalk from "chalk";
44
13
  const MAX_MESSAGE_LENGTH = 300;
45
14
  const KOTLIN_URI = /^e:\s+file:\/\/(\/\S+?):(\d+):(\d+)\s+(.*)$/;
46
15
  const KOTLIN_PAREN = /^e:\s+(\S+?):\s*\((\d+),\s*(\d+)\):\s*(.*)$/;
@@ -342,7 +311,7 @@ function variantNameOf(segments) {
342
311
  return (Array.isArray(segments) ? segments : []).filter((s) => typeof s === "string" && s.trim()).map((s, i) => i === 0 ? s : `${s[0].toUpperCase()}${s.slice(1)}`).join("");
343
312
  }
344
313
  function apkInDir(dir) {
345
- const metadata = readOrNull$1(join(dir, "output-metadata.json"));
314
+ const metadata = readOrNull(join(dir, "output-metadata.json"));
346
315
  if (metadata) {
347
316
  const named = parseOutputMetadata(metadata);
348
317
  if (named) {
@@ -570,7 +539,7 @@ function gradleArgs(task, { buildCache = true, projectArgs = [] } = {}) {
570
539
  ...projectArgs
571
540
  ];
572
541
  }
573
- async function buildGradle({ root, logWriter, variant = null, project, task, projectArgs = [], preflightFailure = null }, { spawnFn = null, now = Date.now, env = process.env, buildCache = true, ccache = null, cas = null, pch = "auto", compilerCacheDisabled = false, heartbeatMs = HEARTBEAT_INTERVAL_MS, estimateMs = null, onHeartbeat = (line) => console.error(line), onNote = (line) => console.error(line) } = {}) {
542
+ async function buildGradle({ root, logWriter, variant = null, project, task, projectArgs = [], preflightFailure = null, locate }, { spawnFn = null, now = Date.now, env = process.env, buildCache = true, ccache = null, cas = null, pch = "auto", compilerCacheDisabled = false, heartbeatMs = HEARTBEAT_INTERVAL_MS, estimateMs = null, onHeartbeat = (line) => console.error(line), onNote = (line) => console.error(line) } = {}) {
574
543
  const sdk = androidHome(env);
575
544
  const sdkExists = existsSync(sdk);
576
545
  const refusal = androidSdkRefusal({
@@ -712,7 +681,16 @@ async function buildGradle({ root, logWriter, variant = null, project, task, pro
712
681
  ccache: ccacheActivity
713
682
  };
714
683
  }
715
- const located = locateApk(project, transcript, variant);
684
+ const located = locate ? await locate() : locateApk(project, transcript, variant);
685
+ if ("code" in located) return {
686
+ ok: false,
687
+ ...located,
688
+ diagnostics: [],
689
+ truncated: 0,
690
+ lastLines: tail.slice(),
691
+ durationMs,
692
+ ccache: ccacheActivity
693
+ };
716
694
  if (!located.apkPath && located.candidates?.length) return {
717
695
  ok: false,
718
696
  code: BUILD_ERROR,
@@ -739,6 +717,7 @@ async function buildGradle({ root, logWriter, variant = null, project, task, pro
739
717
  ok: true,
740
718
  apkPath: located.apkPath,
741
719
  apkNote: located.note ?? null,
720
+ ...located.androidPackage ? { androidPackage: located.androidPackage } : {},
742
721
  durationMs,
743
722
  lastLines: tail.slice(),
744
723
  ccache: ccacheActivity
@@ -776,7 +755,7 @@ function safeList(dir) {
776
755
  return [];
777
756
  }
778
757
  }
779
- function readOrNull$1(file) {
758
+ function readOrNull(file) {
780
759
  try {
781
760
  return readFileSync(file, "utf-8");
782
761
  } catch {
@@ -784,612 +763,4 @@ function readOrNull$1(file) {
784
763
  }
785
764
  }
786
765
  //#endregion
787
- //#region src/integrations/react-native-build.ts
788
- function androidDir(root) {
789
- return join(root, "android");
790
- }
791
- function gradlewPath(root) {
792
- return join(androidDir(root), process.platform === "win32" ? "gradlew.bat" : "gradlew");
793
- }
794
- function apkOutputsDir(root) {
795
- return join(androidDir(root), "app", "build", "outputs", "apk");
796
- }
797
- function discoverAndroidProject(root) {
798
- const dir = androidDir(root);
799
- if (!existsSync(dir)) return {
800
- failed: true,
801
- code: BUILD_ERROR,
802
- reason: `No android/ directory in ${root}.`,
803
- remedy: "Generate it (`npx expo prebuild -p android`, which `stim android` runs itself on an Expo project) or check out the native sources."
804
- };
805
- const gradlew = gradlewPath(root);
806
- if (!existsSync(gradlew)) return {
807
- failed: true,
808
- code: BUILD_ERROR,
809
- reason: `${gradlew} does not exist, so there is no gradle wrapper to build with.`,
810
- remedy: "Restore the wrapper (`gradle wrapper` in android/, or regenerate the project with `npx expo prebuild -p android --clean`)."
811
- };
812
- return {
813
- androidDir: dir,
814
- gradlew
815
- };
816
- }
817
- function readProductFlavors(root) {
818
- return parseProductFlavors(readOrNull(join(androidDir(root), "app", "build.gradle")));
819
- }
820
- function productFlavorRefusal({ flavors, variant }) {
821
- if (variant) return null;
822
- if (!flavors.known || flavors.dimensions.length === 0) return null;
823
- let combinations = [[]];
824
- for (const group of flavors.dimensions) combinations = combinations.flatMap((combination) => group.map((flavor) => combination.concat(flavor)));
825
- if (combinations.length < 2) return null;
826
- const count = flavors.dimensions.reduce((total, group) => total + group.length, 0);
827
- const variants = combinations.map((combination) => variantNameOf(combination.concat("debug")));
828
- return {
829
- code: "STIM_BAD_ARG",
830
- reason: `android/app/build.gradle declares ${count} product flavors, so \`./gradlew ${ASSEMBLE_TASK}\` builds an APK for each of them and nothing says which flavor to install.`,
831
- remedy: `Pass \`--variant ${variants[0]}\` or set the android.variant setting -- e.g. {"android": {"variant": "${variants[0]}"}} in .stim.json. The debug variants are: ${variants.join(", ")}.`
832
- };
833
- }
834
- function readOrNull(path) {
835
- try {
836
- return readFileSync(path, "utf-8");
837
- } catch {
838
- return null;
839
- }
840
- }
841
- async function buildAndroid({ root, logWriter, variant = null, abi = null }, options = {}) {
842
- const project = discoverAndroidProject(root);
843
- if (project.failed) return {
844
- ok: false,
845
- code: project.code,
846
- reason: project.reason,
847
- remedy: project.remedy,
848
- diagnostics: [],
849
- truncated: 0,
850
- lastLines: [],
851
- durationMs: 0
852
- };
853
- const room = androidPathRoom(root, {
854
- abi,
855
- variant,
856
- platform: options.platform ?? process.platform
857
- });
858
- return buildGradle({
859
- root,
860
- logWriter,
861
- variant,
862
- project: {
863
- directory: project.androidDir,
864
- gradlew: project.gradlew,
865
- module: ":app",
866
- outputsDir: apkOutputsDir(root)
867
- },
868
- task: assembleTaskFor(variant),
869
- projectArgs: abi ? [`-PreactNativeArchitectures=${abi}`] : [],
870
- preflightFailure: room ? {
871
- code: "STIM_PATH_TOO_LONG",
872
- reason: androidPathRoomMessage(room),
873
- remedy: androidPathRoomRemedy(room)
874
- } : null
875
- }, options);
876
- }
877
- const IOS_DIR = "ios";
878
- const PREBUILD_REMEDY = "Generate it with `npx expo prebuild -p ios` (stim ios does this automatically for an Expo project with no ios/ directory), or commit the native project.";
879
- function buildFailure(message, remedy) {
880
- return { error: {
881
- code: "STIM_BUILD_FAILED",
882
- message,
883
- remedy
884
- } };
885
- }
886
- function discoverXcodeProject(root) {
887
- const dir = join(root, IOS_DIR);
888
- let entries;
889
- try {
890
- entries = readdirSync(dir);
891
- } catch {
892
- return buildFailure(`No ${IOS_DIR}/ directory in ${root}.`, PREBUILD_REMEDY);
893
- }
894
- const picked = pickXcodeProject(entries);
895
- if (!picked) return buildFailure(`${dir} contains no .xcworkspace and no .xcodeproj.`, PREBUILD_REMEDY);
896
- return {
897
- ...picked,
898
- dir,
899
- path: join(dir, picked.file)
900
- };
901
- }
902
- function ccacheEnabled(podfileProperties) {
903
- if (!podfileProperties || typeof podfileProperties !== "object") return false;
904
- return podfileProperties["apple.ccacheEnabled"] === "true";
905
- }
906
- function readPodfileProperties(root) {
907
- try {
908
- const parsed = JSON.parse(readFileSync(join(root, IOS_DIR, "Podfile.properties.json"), "utf-8"));
909
- return parsed && typeof parsed === "object" ? parsed : null;
910
- } catch {
911
- return null;
912
- }
913
- }
914
- const SWIFT_CACHE_MIN_REACT_NATIVE = {
915
- major: 0,
916
- minor: 87
917
- };
918
- function reactNativeSupportsSwiftCache(version) {
919
- if (!version) return false;
920
- const min = SWIFT_CACHE_MIN_REACT_NATIVE;
921
- return version.major > min.major || version.major === min.major && version.minor >= min.minor;
922
- }
923
- function parseReactNativeVersion(packageJson) {
924
- if (!packageJson || typeof packageJson !== "object") return null;
925
- const raw = packageJson.version;
926
- const m = typeof raw === "string" ? /^(\d+)\.(\d+)\./.exec(raw) : null;
927
- if (!m || m[1] === void 0 || m[2] === void 0) return null;
928
- return {
929
- major: parseInt(m[1], 10),
930
- minor: parseInt(m[2], 10)
931
- };
932
- }
933
- function detectReactNativeVersion(root) {
934
- const file = resolvePackageJson(root, "react-native");
935
- if (!file) return null;
936
- try {
937
- return parseReactNativeVersion(JSON.parse(readFileSync(file, "utf-8")));
938
- } catch {
939
- return null;
940
- }
941
- }
942
- function reactNativeCompilationCacheSettings({ reactNativeVersion = null, ...options }) {
943
- return compilationCacheSettings({
944
- ...options,
945
- swiftCacheCompatible: reactNativeSupportsSwiftCache(reactNativeVersion)
946
- });
947
- }
948
- function resolveCompilationCacheSettings({ root, derivedDataPath, exec = null, casPath = sharedCompilationCache(), optimizations = resolveOptimizations({}, {}).ios, onNote = (line) => console.error(line) }) {
949
- const xcodeMajor = detectXcodeMajor(exec);
950
- const ccache = ccacheEnabled(readPodfileProperties(root));
951
- const probe = xcodeMajor !== null && xcodeMajor >= 26 && !ccache && optimizations.compilationCache && optimizations.swiftCompilationCache !== false;
952
- const swiftVersion = probe ? detectSwiftVersion(exec) : null;
953
- const reactNativeVersion = probe ? detectReactNativeVersion(root) : null;
954
- const settings = reactNativeCompilationCacheSettings({
955
- workspaceRoot: root,
956
- derivedDataPath,
957
- casPath,
958
- xcodeMajor,
959
- swiftVersion,
960
- reactNativeVersion,
961
- ccache,
962
- optimizations
963
- });
964
- if (settings.length > 0 && optimizations.compilationCache) {
965
- register({
966
- dir: casPath,
967
- name: "Xcode compilation cache",
968
- prune: "atomic",
969
- note: "shared Xcode compilation cache"
970
- });
971
- const swift = settings.includes("SWIFT_ENABLE_COMPILE_CACHE=YES") ? settings.includes("SWIFT_ENABLE_PREFIX_MAPPING=YES") ? "Swift on" : "Swift on, unmapped" : swiftVersion && !swiftPrefixMappingSupported(swiftVersion) ? `Swift off, ${swiftVersion.major}.${swiftVersion.minor} < ${SWIFT_PREFIX_MAPPING_MIN_SWIFT.major}.${SWIFT_PREFIX_MAPPING_MIN_SWIFT.minor}` : swiftVersion && reactNativeVersion && !reactNativeSupportsSwiftCache(reactNativeVersion) ? `Swift off, react-native ${reactNativeVersion.major}.${reactNativeVersion.minor} < ${SWIFT_CACHE_MIN_REACT_NATIVE.major}.${SWIFT_CACHE_MIN_REACT_NATIVE.minor}` : "Swift off";
972
- onNote(chalk.dim(phaseLine("cache", `compilation cache on (CAS at ${casPath}, ${swift})`)));
973
- }
974
- return settings;
975
- }
976
- async function buildIos(inputs) {
977
- const { root, logWriter, udid, destination, now = () => Date.now() } = inputs;
978
- if (!root || typeof root !== "string") throw new TypeError("buildIos requires {root}");
979
- if (!logWriter || typeof logWriter.write !== "function") throw new TypeError("buildIos requires {logWriter} with a write() method");
980
- if (!udid && !destination) throw new TypeError("buildIos requires {udid} (or an explicit {destination})");
981
- const startedAt = now();
982
- return buildXcode({
983
- ...inputs,
984
- startedAt,
985
- project: inputs.project ?? discoverXcodeProject(root),
986
- compilationCache: inputs.compilationCache === void 0 ? ({ derivedDataPath, exec }) => resolveCompilationCacheSettings({
987
- root,
988
- derivedDataPath,
989
- exec,
990
- optimizations: inputs.optimizations,
991
- onNote: inputs.onNote
992
- }) : inputs.compilationCache
993
- });
994
- }
995
- //#endregion
996
- //#region src/engine/device-ios.ts
997
- function startIosBoot(udid, configure, label, out, simulatorApp, root, deviceSlotWait) {
998
- const done = withDeviceBootAdmission({
999
- platform: "ios",
1000
- key: udid
1001
- }, async () => {
1002
- out(chalk.dim(phaseLine("device", `booting ${label} (${udid})`)));
1003
- await bootIosSim(udid, {
1004
- label,
1005
- out,
1006
- simulatorApp
1007
- });
1008
- await configure();
1009
- }, {
1010
- ...deviceSlotWait,
1011
- root,
1012
- out
1013
- });
1014
- done.catch(() => {});
1015
- return {
1016
- udid,
1017
- done
1018
- };
1019
- }
1020
- var IosDeviceMismatchError = class extends Error {
1021
- remedy = "Run `stim worktree remove` (or `stim gc --delete`) to reap the current sim, then `stim ios` again to create the requested one, or pass `--slot <name>` to create it beside the current one.";
1022
- };
1023
- async function ensureOwnedIosDevice({ record, projectPath, slot, settingsRoot, label, settings, flags, note, out, reconcileIosSimulator, simSnapshot }) {
1024
- const memoryAdvice = hostMemoryPressureAdvice(readHostMemoryPressure());
1025
- if (memoryAdvice) out(chalk.yellow(phaseLine("memory", memoryAdvice)));
1026
- const simslimProfile = iosSimSlimProfileSetting(settings, settingsRoot);
1027
- if (record?.deviceUdid) {
1028
- if (record.owned) {
1029
- const listed = simSnapshot ? simSnapshot.read() : listAllIosSims({ includeUnavailable: true });
1030
- const resolved = resolveOwnedIosSim(record.deviceUdid, listed);
1031
- if (resolved.notOwned) note(chalk.yellow(`Note: recorded sim is now named "${resolved.notOwned}", not Stim-owned -- creating a fresh owned sim instead of booting it.`));
1032
- else if (resolved.missing) {} else {
1033
- const sim = resolved.sim;
1034
- const wantedType = flags.deviceType || settings?.ios?.deviceType;
1035
- const deviceTypes = listIosDeviceTypes();
1036
- const mismatch = deviceTypeMismatch(sim.deviceTypeIdentifier, wantedType, deviceTypes);
1037
- if (mismatch) throw new IosDeviceMismatchError(`${mismatch}. Stim will not silently boot a different model.`);
1038
- const versionMismatch = flags.runtimeFlag ? runtimeMismatch(sim.runtime, flags.runtimeFlag, listIosRuntimes()) : null;
1039
- if (versionMismatch) throw new IosDeviceMismatchError(`${versionMismatch}. Stim will not silently boot a different iOS version.`);
1040
- const model = {
1041
- model: deviceTypes.find((d) => d.identifier === sim.deviceTypeIdentifier)?.name ?? null,
1042
- runtime: parseRuntimeVersion(sim.runtime)
1043
- };
1044
- const name = ownedIosName(sim, label, model, projectPath, listed) === sim.name ? sim.name : await withIosDeviceNameLock(() => renameToOwnedName(sim, label, model, projectPath));
1045
- const updated = {
1046
- deviceUdid: sim.udid,
1047
- owned: true,
1048
- deviceName: name,
1049
- ...record.simslimManaged ? { simslimManaged: true } : {},
1050
- ...record.adopted ? { adopted: true } : {},
1051
- ...record.adoptionPending ? { adoptionPending: true } : {},
1052
- ...record.parkedCacheKey ? { parkedCacheKey: record.parkedCacheKey } : {},
1053
- ...record.schemeApprovals ? { schemeApprovals: record.schemeApprovals } : {}
1054
- };
1055
- const configure = async () => {
1056
- if (record.adoptionPending) resetAdoptedSim(sim.udid, out);
1057
- return configureOwnedIosSim({
1058
- record: updated,
1059
- projectPath,
1060
- slot,
1061
- profile: simslimProfile,
1062
- out,
1063
- reconcileIosSimulator
1064
- });
1065
- };
1066
- const facts = {
1067
- deviceType: model.model,
1068
- runtime: model.runtime
1069
- };
1070
- if (sim.state !== "Booted") return {
1071
- ...updated,
1072
- booting: startIosBoot(sim.udid, configure, name, out, flags.simulatorApp, projectPath, flags.deviceSlotWait),
1073
- ...facts
1074
- };
1075
- return {
1076
- ...await configure(),
1077
- ...facts,
1078
- booted: sim.udid
1079
- };
1080
- }
1081
- } else {
1082
- const sim = listAllIosSims().find((s) => s.udid === record.deviceUdid);
1083
- if (sim) {
1084
- if (sim.state !== "Booted") {
1085
- note(chalk.yellow(`Note: assigned sim ${sim.name} (${sim.udid}) is shut down and is not owned by Stim, so it will not be booted automatically.`));
1086
- note(chalk.dim("Boot it yourself, or run `stim gc --delete` to clear the assignment so Stim can create an owned sim."));
1087
- }
1088
- return record;
1089
- }
1090
- }
1091
- withConfigLock(() => {
1092
- const current = deviceSlotPlatforms(loadConfig()?.projects?.[projectPath], slot)?.ios;
1093
- if (!current) return;
1094
- if (current.deviceUdid !== record.deviceUdid || current.owned !== record.owned) throw new Error("The simulator assignment changed during recovery. Run `stim ios` again.");
1095
- clearDevice(projectPath, "ios", slot);
1096
- });
1097
- }
1098
- const choice = resolveIosCreation({
1099
- deviceType: flags.deviceType || settings.ios?.deviceType,
1100
- runtime: flags.runtime || settings.ios?.runtime
1101
- });
1102
- const adopted = parkedMaxSetting("ios").max > 0 ? await withIosDeviceNameLock(() => takeParkedIosSim({
1103
- projectPath,
1104
- slot,
1105
- label,
1106
- choice,
1107
- out
1108
- })) : null;
1109
- if (adopted) {
1110
- const booting = startIosBoot(adopted.deviceUdid, async () => {
1111
- resetAdoptedSim(adopted.deviceUdid, out);
1112
- await configureOwnedIosSim({
1113
- record: adopted,
1114
- projectPath,
1115
- slot,
1116
- profile: simslimProfile,
1117
- out,
1118
- reconcileIosSimulator
1119
- });
1120
- }, adopted.deviceName, out, flags.simulatorApp, projectPath, flags.deviceSlotWait);
1121
- return {
1122
- ...adopted,
1123
- booting,
1124
- deviceType: choice.deviceType,
1125
- runtime: choice.runtime
1126
- };
1127
- }
1128
- const created = await withIosDeviceNameLock(() => {
1129
- const suffix = ownedIosNameSuffix(label, {
1130
- model: choice.deviceType,
1131
- runtime: choice.runtime
1132
- }, projectPath);
1133
- const result = createOwnedIosSim(label, { suffix }, choice);
1134
- setDevice(projectPath, "ios", {
1135
- deviceUdid: result.udid,
1136
- owned: true,
1137
- deviceName: result.name
1138
- }, slot);
1139
- return result;
1140
- });
1141
- const newRecord = {
1142
- deviceUdid: created.udid,
1143
- owned: true,
1144
- deviceName: created.name
1145
- };
1146
- const booting = startIosBoot(created.udid, () => configureOwnedIosSim({
1147
- record: newRecord,
1148
- projectPath,
1149
- slot,
1150
- profile: simslimProfile,
1151
- out,
1152
- reconcileIosSimulator
1153
- }), created.name, out, flags.simulatorApp, projectPath, flags.deviceSlotWait);
1154
- return {
1155
- ...newRecord,
1156
- created: true,
1157
- booting,
1158
- deviceType: created.deviceType,
1159
- runtime: created.runtime
1160
- };
1161
- }
1162
- function withIosDeviceNameLock(fn) {
1163
- return withWorkspaceProcessLock(getConfigDir(), "ios-device-names", async () => fn(), { external: true });
1164
- }
1165
- function ownedIosNameSuffix(label, model, projectPath, udid, listed = listAllIosSims({ includeUnavailable: true })) {
1166
- const names = new Set(listed.filter((sim) => sim.udid !== udid).map((sim) => sim.name));
1167
- for (const project of Object.values(loadConfig()?.projects ?? {})) for (const { platforms } of projectDeviceSlots(project)) {
1168
- const record = platforms.ios;
1169
- if (record?.deviceUdid !== udid && record?.deviceName) names.add(record.deviceName);
1170
- }
1171
- for (const parked of readParked("ios")) if (parked.udid !== udid) names.add(parked.name);
1172
- let suffix = "";
1173
- for (let attempt = 0; names.has(ownedSimName(label, model, suffix)); attempt++) suffix = ` ${workspaceId(projectPath)}${attempt ? `-${attempt}` : ""}`;
1174
- return suffix;
1175
- }
1176
- function ownedIosName(sim, label, model, projectPath, listed) {
1177
- return ownedSimName(label, model, ownedIosNameSuffix(label, model, projectPath, sim.udid, listed));
1178
- }
1179
- function renameToOwnedName(sim, label, model, projectPath) {
1180
- const wanted = ownedIosName(sim, label, model, projectPath);
1181
- if (sim.name === wanted) return wanted;
1182
- try {
1183
- renameIosSim(sim.udid, wanted);
1184
- return wanted;
1185
- } catch {
1186
- return sim.name;
1187
- }
1188
- }
1189
- function resetAdoptedSim(udid, out) {
1190
- out(chalk.dim(phaseLine("device", `resetting privacy grants and the keychain on ${udid}`)));
1191
- resetIosPrivacy(udid);
1192
- resetIosKeychain(udid);
1193
- }
1194
- function takeParkedIosSim({ projectPath, slot, label, choice, out }) {
1195
- const candidates = selectParked(readParked("ios"), {
1196
- deviceTypeIdentifier: choice.deviceTypeId,
1197
- runtimeIdentifier: choice.runtimeId
1198
- });
1199
- if (candidates.length === 0) return null;
1200
- const listed = new Map(listAllIosSims({ includeUnavailable: true }).map((sim) => [sim.udid, sim]));
1201
- for (const parked of candidates) {
1202
- const sim = listed.get(parked.udid);
1203
- if (!sim || !sim.available) {
1204
- const result = sim ? teardownParkedIosSim(parked.udid, { label: parked.name }) : null;
1205
- if (sim ? result?.status === "torn-down" : dropParked("ios", parked.udid)) out(chalk.dim(phaseLine("device", `deleted parked ${parked.name} (${parked.udid}): ${sim ? "unavailable" : "gone"}`)));
1206
- else if (result?.status === "failed") out(chalk.yellow(phaseLine("device", `could not delete unavailable parked ${parked.name} (${parked.udid}): ${result.reason}`)));
1207
- continue;
1208
- }
1209
- if (!sim.name.startsWith("stim-")) {
1210
- out(chalk.yellow(phaseLine("device", `kept parked record for ${parked.udid}: simulator is now named ${JSON.stringify(sim.name)} and is not Stim-owned`)));
1211
- continue;
1212
- }
1213
- const model = {
1214
- model: choice.deviceType,
1215
- runtime: choice.runtime
1216
- };
1217
- const name = ownedSimName(label, model, ownedIosNameSuffix(label, model, projectPath, parked.udid));
1218
- const device = {
1219
- deviceUdid: parked.udid,
1220
- owned: true,
1221
- deviceName: name,
1222
- adopted: true,
1223
- adoptionPending: true,
1224
- ...parked.simslimManaged ? { simslimManaged: true } : {},
1225
- ...parked.cacheKey ? { parkedCacheKey: parked.cacheKey } : {}
1226
- };
1227
- const adopted = adoptParked({
1228
- platform: "ios",
1229
- projectPath,
1230
- slot,
1231
- udid: parked.udid,
1232
- device
1233
- });
1234
- if (!adopted) continue;
1235
- try {
1236
- renameIosSim(parked.udid, name);
1237
- } catch {}
1238
- return adopted.schemeApprovals && adopted.schemeApprovals.length > 0 ? {
1239
- ...device,
1240
- schemeApprovals: adopted.schemeApprovals
1241
- } : device;
1242
- }
1243
- return null;
1244
- }
1245
- function clearIosAdoptionPending(projectPath, slot = "default") {
1246
- withConfigLock(() => {
1247
- const cfg = loadConfig();
1248
- const ios = deviceSlotPlatforms(cfg?.projects?.[projectPath], slot)?.ios;
1249
- if (!cfg || !ios?.adoptionPending) return;
1250
- delete ios.adopted;
1251
- delete ios.adoptionPending;
1252
- delete ios.parkedCacheKey;
1253
- saveConfig(cfg);
1254
- });
1255
- }
1256
- async function configureOwnedIosSim({ record, projectPath, slot, profile, out, reconcileIosSimulator }) {
1257
- if (profile) out(chalk.dim(phaseLine("device", `applying the SimSlim profile to ${record.deviceUdid}`)));
1258
- else if (record.simslimManaged) out(chalk.dim(phaseLine("device", `restoring stock simulator services on ${record.deviceUdid}`)));
1259
- const previouslyManaged = Boolean(record.simslimManaged);
1260
- if (profile && !record.simslimManaged) {
1261
- const pending = {
1262
- ...record,
1263
- simslimManaged: true
1264
- };
1265
- setDevice(projectPath, "ios", pending, slot);
1266
- record = pending;
1267
- }
1268
- const result = await reconcileIosSimulator({
1269
- udid: record.deviceUdid,
1270
- profile,
1271
- previouslyManaged,
1272
- out
1273
- });
1274
- const updated = { ...record };
1275
- if (result.managed) updated.simslimManaged = true;
1276
- else delete updated.simslimManaged;
1277
- setDevice(projectPath, "ios", updated, slot);
1278
- return updated;
1279
- }
1280
- async function ensureIosBooted({ device, projectPath, deviceSlotWait, simulatorApp, timeoutMs, pollMs, out }) {
1281
- const udid = device?.deviceUdid;
1282
- if (!udid) return {
1283
- failed: true,
1284
- reason: "No iOS simulator is recorded for this project."
1285
- };
1286
- const ready = () => {
1287
- try {
1288
- getExecutor().runFile("xcrun", [
1289
- "simctl",
1290
- "spawn",
1291
- udid,
1292
- "launchctl",
1293
- "list"
1294
- ], { timeoutMs: 3e4 });
1295
- return {
1296
- ok: true,
1297
- udid
1298
- };
1299
- } catch (error) {
1300
- return {
1301
- failed: true,
1302
- reason: `Simulator ${udid} failed its process-spawn readiness check: ${error?.message || error}. ${iosSimulatorFailureAdvice()}`
1303
- };
1304
- }
1305
- };
1306
- const booting = device?.booting;
1307
- if (booting?.udid === udid) {
1308
- try {
1309
- await booting.done;
1310
- } catch (e) {
1311
- return bootFailure(udid, e);
1312
- }
1313
- return ready();
1314
- }
1315
- const readiness = device?.booted === udid ? ready() : null;
1316
- if (readiness?.ok) {
1317
- if (simulatorApp !== void 0) configuredIosSimulatorViewer(simulatorApp).open(udid);
1318
- return readiness;
1319
- }
1320
- let resolved;
1321
- try {
1322
- resolved = resolveOwnedIosSim(udid);
1323
- } catch (e) {
1324
- return {
1325
- failed: true,
1326
- reason: `Could not list simulators: ${e?.message || e}`
1327
- };
1328
- }
1329
- if (resolved.missing) return {
1330
- failed: true,
1331
- reason: `Simulator ${udid} no longer exists. Run \`stim ios\` again to create a fresh owned sim.`
1332
- };
1333
- if (resolved.notOwned) return {
1334
- failed: true,
1335
- reason: `Simulator ${udid} is now named "${resolved.notOwned}" and is not Stim-owned; refusing to boot it.`
1336
- };
1337
- const sim = resolved.sim;
1338
- if (sim.state === "Booted") {
1339
- const result = readiness ?? ready();
1340
- if (result.ok && simulatorApp !== void 0) configuredIosSimulatorViewer(simulatorApp).open(udid);
1341
- return result;
1342
- }
1343
- const bootDeadline = Date.now() + timeoutMs;
1344
- try {
1345
- await withDeviceBootAdmission({
1346
- platform: "ios",
1347
- key: udid
1348
- }, () => {
1349
- out(chalk.dim(phaseLine("device", `booting ${sim.name} (${udid})`)));
1350
- return bootIosSim(udid, {
1351
- timeoutMs,
1352
- label: sim.name,
1353
- out,
1354
- simulatorApp
1355
- });
1356
- }, {
1357
- ...deviceSlotWait,
1358
- root: projectPath,
1359
- out
1360
- });
1361
- } catch (e) {
1362
- return bootFailure(udid, e);
1363
- }
1364
- const deadline = Math.max(bootDeadline, Date.now() + 2 * pollMs);
1365
- while (Date.now() < deadline) {
1366
- await sleep(pollMs);
1367
- let state = null;
1368
- try {
1369
- state = listAllIosSims({ timeoutMs: 3e4 }).find((s) => s.udid === udid)?.state ?? null;
1370
- } catch {}
1371
- if (state === "Booted") return ready();
1372
- }
1373
- return {
1374
- failed: true,
1375
- reason: `Simulator ${udid} did not reach the Booted state within ${Math.round(timeoutMs / 1e3)}s.`
1376
- };
1377
- }
1378
- function bootFailure(udid, error) {
1379
- const refusal = error instanceof DeviceAdmissionRefusal ? error : (0, ownership_claim_exports.claimFailure)(error, "stim ios");
1380
- if (refusal) return {
1381
- failed: true,
1382
- code: refusal.code,
1383
- reason: refusal.message,
1384
- remedy: refusal.remedy
1385
- };
1386
- return {
1387
- failed: true,
1388
- reason: `Could not boot simulator ${udid}: ${error?.message || error}`
1389
- };
1390
- }
1391
- function sleep(ms) {
1392
- return new Promise((r) => setTimeout(r, ms));
1393
- }
1394
- //#endregion
1395
- export { androidPathRoomMessage as _, apkOutputsDir as a, ccacheEnabled as c, productFlavorRefusal as d, readProductFlavors as f, androidPathRoom as g, formatDiagnostic as h, ensureOwnedIosDevice as i, discoverXcodeProject as l, assembleTaskFor as m, clearIosAdoptionPending as n, buildAndroid as o, androidSdkRefusal as p, ensureIosBooted as r, buildIos as s, IosDeviceMismatchError as t, gradlewPath as u, androidPathRoomRemedy as v };
766
+ export { buildGradle as a, formatDiagnostic as c, assembleTaskFor as i, BUILD_ERROR as n, parseProductFlavors as o, androidSdkRefusal as r, variantNameOf as s, ASSEMBLE_TASK as t };