stim 1.17.2 → 1.19.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 (162) hide show
  1. package/README.md +50 -1
  2. package/dist/{activity-IRvJY_ru.mjs → activity-BSw0x84R.mjs} +4 -4
  3. package/dist/{agent-device-usage-output-BK41vnzN.mjs → agent-device-usage-output-Bjxu_VmX.mjs} +8 -8
  4. package/dist/{android-B9yaNKwa.mjs → android-BXc6BmEi.mjs} +658 -404
  5. package/dist/{android-B_YNZy61.mjs → android-BdQC6zs1.mjs} +9 -9
  6. package/dist/android-BvV1gGdN.mjs +4 -0
  7. package/dist/{android-DE4v59Mb.mjs → android-DE5g_5gv.mjs} +2 -2
  8. package/dist/{android-cas-ZFpjJBL_.mjs → android-cas-C87geAg-.mjs} +5 -5
  9. package/dist/android-cas-compiler.mjs +2 -2
  10. package/dist/api-DIf_s86s.mjs +150 -0
  11. package/dist/api-run.d.mts +1 -0
  12. package/dist/api-run.mjs +145 -0
  13. package/dist/api.d.mts +218 -0
  14. package/dist/api.mjs +2 -0
  15. package/dist/{app-install-VPkI5WEg.mjs → app-install-CFI4ptUL.mjs} +33 -13
  16. package/dist/{attempt-Bk2ouQVL.mjs → attempt-DW-mQqM7.mjs} +14 -4
  17. package/dist/{web-Dl0KSRHf.mjs → browser-web-CDhqQxhv.mjs} +138 -176
  18. package/dist/{budget-DfcgFdQB.mjs → budget-Dz-kyXLv.mjs} +1391 -58
  19. package/dist/build-facts-B87vo-Im.d.mts +142 -0
  20. package/dist/{cache-manifest-DnUHBJaU.mjs → cache-manifest-DiwKSyv9.mjs} +3 -3
  21. package/dist/cache-manifest.mjs +1 -1
  22. package/dist/{chrome-BrcVWQyD.mjs → chrome-BTUOo8p2.mjs} +1 -1
  23. package/dist/cli-C9Zvgbdc.mjs +68 -0
  24. package/dist/cli.mjs +1 -1
  25. package/dist/{client-SvBdgObD.mjs → client-CuUo8Nvg.mjs} +381 -49
  26. package/dist/collector-run.d.mts +6 -0
  27. package/dist/collector-run.mjs +9 -9
  28. package/dist/{command-output-CDAIFD-8.mjs → command-output-Bt8ygHE7.mjs} +2 -2
  29. package/dist/{config-D0DbpZtM.mjs → config-DC5jEtd1.mjs} +9 -5
  30. package/dist/{created-devices-CpvzBL25.mjs → created-devices-D0s26Hx5.mjs} +2 -2
  31. package/dist/{dependency-state-CLcBHH2M.mjs → dependency-state-DKaS1OM9.mjs} +2 -2
  32. package/dist/{detached-entry-CiTEgMR1.mjs → detached-entry-pB_IPfV4.mjs} +1 -1
  33. package/dist/{dev-client-B-XC4uRH.mjs → dev-client-CDY_zAmD.mjs} +2 -2
  34. package/dist/{device-C8IOoJPv.mjs → device-BHw0WlHl.mjs} +8 -8
  35. package/dist/{device-capacity-ZC4XSZ4R.mjs → device-capacity-BoN1jQkO.mjs} +25 -14
  36. package/dist/device-host-worker.mjs +19 -19
  37. package/dist/{gradle-dJpre3Yn.mjs → device-ios-B2ruohE-.mjs} +661 -107
  38. package/dist/{device-lease-DpoS36_u.mjs → device-lease-Cu7PtQpZ.mjs} +9 -9
  39. package/dist/{device-lease-run-B8YltIH_.mjs → device-lease-run-D38SnZtt.mjs} +4 -4
  40. package/dist/{device-pool-3o7s5lo4.mjs → device-pool-CP4rAsHx.mjs} +3 -3
  41. package/dist/{device-remote-hFSkpfQu.mjs → device-remote-B5GiUifk.mjs} +15 -16
  42. package/dist/{doctor-CFv1fCrF.mjs → doctor-PRJH94v6.mjs} +61 -34
  43. package/dist/doctor-watchman-wZhyTdp4.mjs +259 -0
  44. package/dist/{error-diagnostics-C-NMnhrk.mjs → error-diagnostics--v5HGOU0.mjs} +11 -11
  45. package/dist/{exec-CaErVv7t.mjs → exec-i8GDPwq9.mjs} +93 -6
  46. package/dist/{gc-DEmkg3Xh.mjs → gc-CyHMcKcn.mjs} +25 -471
  47. package/dist/{guide-CSmhMTf8.mjs → guide-dRaQJJk9.mjs} +681 -507
  48. package/dist/{hosted-android-E1Heoqnv.mjs → hosted-android-Bs7fytj7.mjs} +3 -3
  49. package/dist/{hosted-client-Bp4knSwu.mjs → hosted-client-C5G4h_OJ.mjs} +2 -2
  50. package/dist/{hosted-ios-BnbeYOUD.mjs → hosted-ios-Bik035eL.mjs} +1 -1
  51. package/dist/{hosted-logs-OcgIBvCT.mjs → hosted-logs-CI9Az9a4.mjs} +9 -9
  52. package/dist/{hosted-macos-DcxKjtfH.mjs → hosted-macos-DABm3ScO.mjs} +5 -5
  53. package/dist/{hosted-native-1Ebbig4w.mjs → hosted-native-DbV2aUVw.mjs} +13 -9
  54. package/dist/{idle-shutdown-IGyNV8Cr.mjs → idle-shutdown-DYiMBn34.mjs} +7 -8
  55. package/dist/{ios-DSfnPfse.mjs → ios-BWbHFZVz.mjs} +19 -7
  56. package/dist/{ios-Cr1h5gnO.mjs → ios-DCrkgXEM.mjs} +1 -1
  57. package/dist/ios-DYUr9LGc.mjs +8 -0
  58. package/dist/ios-ITYno9rO.mjs +2241 -0
  59. package/dist/{ios-device-pAN4t54-.mjs → ios-device-CJ_ZOGky.mjs} +3 -3
  60. package/dist/{ios-device-Ee7sDXfp.mjs → ios-device-CrW8aMb5.mjs} +1 -1
  61. package/dist/{ios-state-8L3lgum6.mjs → ios-state-By0XuLTQ.mjs} +1 -1
  62. package/dist/{launch-verify-lTnWZikR.mjs → launch-verify-DCveSE6d.mjs} +5 -5
  63. package/dist/{logs-BAaS7gS2.mjs → logs-Bao1HOMy.mjs} +13 -13
  64. package/dist/{macos-BIRQS90f.mjs → macos-ciyBdTY5.mjs} +194 -132
  65. package/dist/macos-nIOATJmR.mjs +2 -0
  66. package/dist/macos-run.mjs +1 -1
  67. package/dist/maintenance-run.mjs +349 -47
  68. package/dist/manifest-CX0d1IkZ.mjs +148 -0
  69. package/dist/{metro-g8NqiJp-.mjs → metro-DI2AjPF_.mjs} +196 -43
  70. package/dist/{metro-gateway-C-ijGI2F.mjs → metro-gateway-BxpJLIwh.mjs} +4 -4
  71. package/dist/{metro-store-CDDZHtPl.mjs → metro-store-BAHFcJm6.mjs} +16 -2
  72. package/dist/{build-plan-BDsSi09V.mjs → miss-reason-CjQCOKqq.mjs} +207 -249
  73. package/dist/{named-ports-C8m8EQs2.mjs → named-ports-B4iWH4E-.mjs} +70 -8
  74. package/dist/{native-runtime-BEK171xQ.mjs → native-runtime-BGxsbfny.mjs} +6 -6
  75. package/dist/{ndjson-PclOIwVY.mjs → ndjson-LGZAMsqa.mjs} +8 -4
  76. package/dist/offload-worker.d.mts +3 -45
  77. package/dist/offload-worker.mjs +11 -11
  78. package/dist/{ownership-DyRQru0q.mjs → ownership-EB0ySdGK.mjs} +3 -3
  79. package/dist/{page-QF_Ke10s.mjs → page-Bv9s2KwY.mjs} +1 -1
  80. package/dist/placement-log-Dxe34rJm.mjs +88 -0
  81. package/dist/plan-placement-BVY59qa8.mjs +290 -0
  82. package/dist/{ports-4nYqxPWC.mjs → ports-ByPc0_97.mjs} +3 -3
  83. package/dist/{prebuild-D7RUMkwN.mjs → prebuild-BKJ3wJI1.mjs} +5 -5
  84. package/dist/preview-BbSottmO.mjs +986 -0
  85. package/dist/{rolldown-runtime-BsOwBuO_.mjs → process-identity-Biv3arCO.mjs} +11 -1
  86. package/dist/project-B5eQ1USs.mjs +612 -0
  87. package/dist/{pull-request-pxnDCQzn.mjs → pull-request-IHNdMnG8.mjs} +1 -1
  88. package/dist/pull-requests.mjs +1 -1
  89. package/dist/react-native-ios-BMh2i25I.mjs +2 -0
  90. package/dist/react-native-ios-CSpIxexZ.mjs +2083 -0
  91. package/dist/{recordings-BNgsD1Tr.mjs → recordings-Bv8McZN4.mjs} +1 -1
  92. package/dist/{reload-DcRxj3qG.mjs → reload-rAPdqeRR.mjs} +14 -15
  93. package/dist/{remote-cache-Ci4DQYYj.mjs → remote-cache-N3hAEaAL.mjs} +5 -5
  94. package/dist/{run-CkE9y0nc.mjs → run-lAkle1-c.mjs} +5 -5
  95. package/dist/{server-bare-BkrSxSsZ.mjs → server-bare-CkIjnegq.mjs} +5 -6
  96. package/dist/server-expo-DGsdUGX2.mjs +2 -0
  97. package/dist/{server-expo-CHTyXD0G.mjs → server-expo-n3tUi3Em.mjs} +5 -6
  98. package/dist/{settings-SR9OmW9h.mjs → settings-2am7TSxp.mjs} +5 -5
  99. package/dist/{settings-Cfd-0r2d.mjs → settings-CxgngUZk.mjs} +116 -103
  100. package/dist/{settings-BBpMcDbD.mjs → settings-Djl-mpjX.mjs} +1 -1
  101. package/dist/settings.schema.json +198 -9
  102. package/dist/{simslim-BWNrc3M3.mjs → simslim-D9LkJxIO.mjs} +7 -7
  103. package/dist/{slot-launch-DmjBmpQV.mjs → slot-launch-HV_KtPIw.mjs} +6 -6
  104. package/dist/{spawn-claims-D0XfSe8u.mjs → spawn-claims-Kqiifsk2.mjs} +1 -1
  105. package/dist/{spawn-entry-jw19m8Nl.mjs → spawn-entry-Dcb7sDUz.mjs} +1 -0
  106. package/dist/{stage-CzaiwFsI.mjs → stage-BgaZJVZY.mjs} +14 -3
  107. package/dist/{start-AlfCPRVU.mjs → start-D8NbxNBb.mjs} +1 -1
  108. package/dist/{start-DUz3mYdb.mjs → start-DtxthMfI.mjs} +34 -27
  109. package/dist/{state-PeQiJuIu.mjs → state-D2KtnALG.mjs} +4 -4
  110. package/dist/{state-DyaNTgfR.mjs → state-Tp4uImDS.mjs} +5 -3
  111. package/dist/{state-B4PQFXMW.d.mts → state-lKh8shBp.d.mts} +2 -3
  112. package/dist/{stats-Bq4fJOdB.mjs → stats-8EJ5ivFT.mjs} +6 -6
  113. package/dist/{status-DlKvVJBE.mjs → status-BEeL6IKz.mjs} +6 -4
  114. package/dist/{status-BA2pehwf.mjs → status-BOyp0CUl.mjs} +31 -34
  115. package/dist/{stim-desktop-Cnz8CPnl.mjs → stim-desktop-C65jk_q2.mjs} +1 -1
  116. package/dist/{stim-installations-QMEI32v1.mjs → stim-installations-DbmUjsLv.mjs} +1 -1
  117. package/dist/stop-D0UIpZuh.mjs +72 -0
  118. package/dist/{stop-zF1y04f2.mjs → stop-DRipAg-e.mjs} +2 -2
  119. package/dist/{stop-DQIasgKp.mjs → stop-zDlknFoz.mjs} +79 -33
  120. package/dist/supervisor-run.d.mts +24 -22
  121. package/dist/supervisor-run.mjs +21 -22
  122. package/dist/{support-CsJNVfOc.mjs → support-CNqYkV0y.mjs} +7 -7
  123. package/dist/{support-WvD__tSV.mjs → support-DsNaFg6D.mjs} +5 -5
  124. package/dist/swiftpm-macos-aJzPAj1t.mjs +119 -0
  125. package/dist/{toolchain-DNyR3NPq.mjs → toolchain-C3xSoyUl.mjs} +475 -269
  126. package/dist/{trigger-Bemu8ytw.mjs → trigger-CAhmG-4s.mjs} +6 -6
  127. package/dist/trigger-CoalsMTV.mjs +2 -0
  128. package/dist/{warm-progress-DF4JRvYI.mjs → warm-progress-pFLB2e6P.mjs} +135 -38
  129. package/dist/{status-CzS4bPO9.mjs → watchman-BL1IdOtq.mjs} +75 -7
  130. package/dist/web-DFpFeZu5.mjs +2 -0
  131. package/dist/web-DbbrPUn0.mjs +127 -0
  132. package/dist/web-run.mjs +10 -10
  133. package/dist/{workspace-state-DqcCbpE7.mjs → workspace-state-CR9X86xJ.mjs} +3 -3
  134. package/dist/{ownership-BMLqyBgJ.mjs → workspaces-Djb2gfi9.mjs} +661 -23
  135. package/dist/{worktree-Be_7NLKy.mjs → worktree-BL4M1rhB.mjs} +252 -50
  136. package/dist/{worktree-j3IcFAI5.mjs → worktree-DV-A0LNL.mjs} +1 -1
  137. package/package.json +10 -5
  138. package/shim/bundle-response.cjs +2 -1
  139. package/shim/bundle-response.d.cts +1 -1
  140. package/shim/expo-metro-config.cjs +1 -1
  141. package/dist/build-progress-D0WkjCPd.mjs +0 -1036
  142. package/dist/build-slots-41v_d2x9.mjs +0 -142
  143. package/dist/cli-CYXb29oE.mjs +0 -51
  144. package/dist/deps-iKw0eD4P.mjs +0 -438
  145. package/dist/device-ios-C2Um-XUR.mjs +0 -412
  146. package/dist/errors-B6W7FkxQ.mjs +0 -15
  147. package/dist/guide-status-Du-ZQ3FD.mjs +0 -125
  148. package/dist/idle-BXG__1BA.mjs +0 -176
  149. package/dist/in-use-CvGOUn-x.mjs +0 -130
  150. package/dist/ios-BJ4XUSe1.mjs +0 -3867
  151. package/dist/native-run-D1Q56rAD.mjs +0 -158
  152. package/dist/preview-B-g9d7kV.mjs +0 -318
  153. package/dist/process-identity-BmRm1qV0.mjs +0 -12
  154. package/dist/project-D47Rh0ly.mjs +0 -276
  155. package/dist/server-expo-CeakhI8P.mjs +0 -2
  156. package/dist/state-BKa8wNN5.mjs +0 -148
  157. package/dist/stop-BIiM49EY.mjs +0 -48
  158. package/dist/stop-cause-rhmGfwvt.mjs +0 -97
  159. package/dist/trigger-CXts6qt1.mjs +0 -2
  160. package/dist/watchman-APYjXSQa.mjs +0 -48
  161. package/dist/workspace-process-lock-2mNzOlaB.mjs +0 -58
  162. package/dist/workspaces-Bcib97-6.mjs +0 -306
@@ -1,412 +0,0 @@
1
- import { t as getExecutor } from "./exec-CaErVv7t.mjs";
2
- 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-D0DbpZtM.mjs";
3
- import { n as ownership_claim_exports } from "./process-identity-BmRm1qV0.mjs";
4
- import { l as phaseLine } from "./command-output-CDAIFD-8.mjs";
5
- import { v as iosSimSlimProfileSetting } from "./settings-Cfd-0r2d.mjs";
6
- import { y as workspaceId } from "./workspace-state-DqcCbpE7.mjs";
7
- import { ct as dropParked, ft as parkedMaxSetting, ht as selectParked, pt as readParked, st as adoptParked } from "./android-B_YNZy61.mjs";
8
- import { A as hostMemoryPressureAdvice, C as resolveIosCreation, O as configuredIosSimulatorViewer, S as resetIosPrivacy, _ as parseRuntimeVersion, b as renameIosSim, f as listIosDeviceTypes, h as ownedSimName, i as createOwnedIosSim, j as readHostMemoryPressure, l as iosSimulatorFailureAdvice, n as bootIosSim, p as listIosRuntimes, u as listAllIosSims, w as resolveOwnedIosSim, x as resetIosKeychain } from "./ios-DSfnPfse.mjs";
9
- import { v as teardownParkedIosSim } from "./ownership-BMLqyBgJ.mjs";
10
- import { t as withWorkspaceProcessLock } from "./workspace-process-lock-2mNzOlaB.mjs";
11
- import { a as deviceTypeMismatch, c as runtimeMismatch, n as DeviceAdmissionRefusal, p as withDeviceBootAdmission } from "./device-capacity-ZC4XSZ4R.mjs";
12
- import chalk from "chalk";
13
- //#region src/engine/device-ios.ts
14
- function startIosBoot(udid, configure, label, out, simulatorApp, root, deviceSlotWait) {
15
- const done = withDeviceBootAdmission({
16
- platform: "ios",
17
- key: udid
18
- }, async () => {
19
- out(chalk.dim(phaseLine("device", `booting ${label} (${udid})`)));
20
- await bootIosSim(udid, {
21
- label,
22
- out,
23
- simulatorApp
24
- });
25
- await configure();
26
- }, {
27
- ...deviceSlotWait,
28
- root,
29
- out
30
- });
31
- done.catch(() => {});
32
- return {
33
- udid,
34
- done
35
- };
36
- }
37
- var IosDeviceMismatchError = class extends Error {
38
- 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.";
39
- };
40
- async function ensureOwnedIosDevice({ record, projectPath, slot, settingsRoot, label, settings, flags, note, out, reconcileIosSimulator }) {
41
- const memoryAdvice = hostMemoryPressureAdvice(readHostMemoryPressure());
42
- if (memoryAdvice) out(chalk.yellow(phaseLine("memory", memoryAdvice)));
43
- const simslimProfile = iosSimSlimProfileSetting(settings, settingsRoot);
44
- if (record?.deviceUdid) {
45
- if (record.owned) {
46
- const listed = listAllIosSims({ includeUnavailable: true });
47
- const resolved = resolveOwnedIosSim(record.deviceUdid, listed);
48
- 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.`));
49
- else if (resolved.missing) {} else {
50
- const sim = resolved.sim;
51
- const wantedType = flags.deviceType || settings?.ios?.deviceType;
52
- const deviceTypes = listIosDeviceTypes();
53
- const mismatch = deviceTypeMismatch(sim.deviceTypeIdentifier, wantedType, deviceTypes);
54
- if (mismatch) throw new IosDeviceMismatchError(`${mismatch}. Stim will not silently boot a different model.`);
55
- const versionMismatch = flags.runtimeFlag ? runtimeMismatch(sim.runtime, flags.runtimeFlag, listIosRuntimes()) : null;
56
- if (versionMismatch) throw new IosDeviceMismatchError(`${versionMismatch}. Stim will not silently boot a different iOS version.`);
57
- const model = {
58
- model: deviceTypes.find((d) => d.identifier === sim.deviceTypeIdentifier)?.name ?? null,
59
- runtime: parseRuntimeVersion(sim.runtime)
60
- };
61
- const name = ownedIosName(sim, label, model, projectPath, listed) === sim.name ? sim.name : await withIosDeviceNameLock(() => renameToOwnedName(sim, label, model, projectPath));
62
- const updated = {
63
- deviceUdid: sim.udid,
64
- owned: true,
65
- deviceName: name,
66
- ...record.simslimManaged ? { simslimManaged: true } : {},
67
- ...record.adopted ? { adopted: true } : {},
68
- ...record.adoptionPending ? { adoptionPending: true } : {},
69
- ...record.parkedCacheKey ? { parkedCacheKey: record.parkedCacheKey } : {},
70
- ...record.schemeApprovals ? { schemeApprovals: record.schemeApprovals } : {}
71
- };
72
- const configure = async () => {
73
- if (record.adoptionPending) resetAdoptedSim(sim.udid, out);
74
- return configureOwnedIosSim({
75
- record: updated,
76
- projectPath,
77
- slot,
78
- profile: simslimProfile,
79
- out,
80
- reconcileIosSimulator
81
- });
82
- };
83
- const facts = {
84
- deviceType: model.model,
85
- runtime: model.runtime
86
- };
87
- if (sim.state !== "Booted") return {
88
- ...updated,
89
- booting: startIosBoot(sim.udid, configure, name, out, flags.simulatorApp, projectPath, flags.deviceSlotWait),
90
- ...facts
91
- };
92
- return {
93
- ...await configure(),
94
- ...facts,
95
- booted: sim.udid
96
- };
97
- }
98
- } else {
99
- const sim = listAllIosSims().find((s) => s.udid === record.deviceUdid);
100
- if (sim) {
101
- if (sim.state !== "Booted") {
102
- 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.`));
103
- note(chalk.dim("Boot it yourself, or run `stim gc --delete` to clear the assignment so Stim can create an owned sim."));
104
- }
105
- return record;
106
- }
107
- }
108
- withConfigLock(() => {
109
- const current = deviceSlotPlatforms(loadConfig()?.projects?.[projectPath], slot)?.ios;
110
- if (!current) return;
111
- if (current.deviceUdid !== record.deviceUdid || current.owned !== record.owned) throw new Error("The simulator assignment changed during recovery. Run `stim ios` again.");
112
- clearDevice(projectPath, "ios", slot);
113
- });
114
- }
115
- const choice = resolveIosCreation({
116
- deviceType: flags.deviceType || settings.ios?.deviceType,
117
- runtime: flags.runtime || settings.ios?.runtime
118
- });
119
- const adopted = parkedMaxSetting("ios").max > 0 ? await withIosDeviceNameLock(() => takeParkedIosSim({
120
- projectPath,
121
- slot,
122
- label,
123
- choice,
124
- out
125
- })) : null;
126
- if (adopted) {
127
- const booting = startIosBoot(adopted.deviceUdid, async () => {
128
- resetAdoptedSim(adopted.deviceUdid, out);
129
- await configureOwnedIosSim({
130
- record: adopted,
131
- projectPath,
132
- slot,
133
- profile: simslimProfile,
134
- out,
135
- reconcileIosSimulator
136
- });
137
- }, adopted.deviceName, out, flags.simulatorApp, projectPath, flags.deviceSlotWait);
138
- return {
139
- ...adopted,
140
- booting,
141
- deviceType: choice.deviceType,
142
- runtime: choice.runtime
143
- };
144
- }
145
- const created = await withIosDeviceNameLock(() => {
146
- const suffix = ownedIosNameSuffix(label, {
147
- model: choice.deviceType,
148
- runtime: choice.runtime
149
- }, projectPath);
150
- const result = createOwnedIosSim(label, { suffix }, choice);
151
- setDevice(projectPath, "ios", {
152
- deviceUdid: result.udid,
153
- owned: true,
154
- deviceName: result.name
155
- }, slot);
156
- return result;
157
- });
158
- const newRecord = {
159
- deviceUdid: created.udid,
160
- owned: true,
161
- deviceName: created.name
162
- };
163
- const booting = startIosBoot(created.udid, () => configureOwnedIosSim({
164
- record: newRecord,
165
- projectPath,
166
- slot,
167
- profile: simslimProfile,
168
- out,
169
- reconcileIosSimulator
170
- }), created.name, out, flags.simulatorApp, projectPath, flags.deviceSlotWait);
171
- return {
172
- ...newRecord,
173
- created: true,
174
- booting,
175
- deviceType: created.deviceType,
176
- runtime: created.runtime
177
- };
178
- }
179
- function withIosDeviceNameLock(fn) {
180
- return withWorkspaceProcessLock(getConfigDir(), "ios-device-names", async () => fn(), { external: true });
181
- }
182
- function ownedIosNameSuffix(label, model, projectPath, udid, listed = listAllIosSims({ includeUnavailable: true })) {
183
- const names = new Set(listed.filter((sim) => sim.udid !== udid).map((sim) => sim.name));
184
- for (const project of Object.values(loadConfig()?.projects ?? {})) for (const { platforms } of projectDeviceSlots(project)) {
185
- const record = platforms.ios;
186
- if (record?.deviceUdid !== udid && record?.deviceName) names.add(record.deviceName);
187
- }
188
- for (const parked of readParked("ios")) if (parked.udid !== udid) names.add(parked.name);
189
- let suffix = "";
190
- for (let attempt = 0; names.has(ownedSimName(label, model, suffix)); attempt++) suffix = ` ${workspaceId(projectPath)}${attempt ? `-${attempt}` : ""}`;
191
- return suffix;
192
- }
193
- function ownedIosName(sim, label, model, projectPath, listed) {
194
- return ownedSimName(label, model, ownedIosNameSuffix(label, model, projectPath, sim.udid, listed));
195
- }
196
- function renameToOwnedName(sim, label, model, projectPath) {
197
- const wanted = ownedIosName(sim, label, model, projectPath);
198
- if (sim.name === wanted) return wanted;
199
- try {
200
- renameIosSim(sim.udid, wanted);
201
- return wanted;
202
- } catch {
203
- return sim.name;
204
- }
205
- }
206
- function resetAdoptedSim(udid, out) {
207
- out(chalk.dim(phaseLine("device", `resetting privacy grants and the keychain on ${udid}`)));
208
- resetIosPrivacy(udid);
209
- resetIosKeychain(udid);
210
- }
211
- function takeParkedIosSim({ projectPath, slot, label, choice, out }) {
212
- const candidates = selectParked(readParked("ios"), {
213
- deviceTypeIdentifier: choice.deviceTypeId,
214
- runtimeIdentifier: choice.runtimeId
215
- });
216
- if (candidates.length === 0) return null;
217
- const listed = new Map(listAllIosSims({ includeUnavailable: true }).map((sim) => [sim.udid, sim]));
218
- for (const parked of candidates) {
219
- const sim = listed.get(parked.udid);
220
- if (!sim || !sim.available) {
221
- const result = sim ? teardownParkedIosSim(parked.udid, { label: parked.name }) : null;
222
- if (sim ? result?.status === "torn-down" : dropParked("ios", parked.udid)) out(chalk.dim(phaseLine("device", `deleted parked ${parked.name} (${parked.udid}): ${sim ? "unavailable" : "gone"}`)));
223
- else if (result?.status === "failed") out(chalk.yellow(phaseLine("device", `could not delete unavailable parked ${parked.name} (${parked.udid}): ${result.reason}`)));
224
- continue;
225
- }
226
- if (!sim.name.startsWith("stim-")) {
227
- out(chalk.yellow(phaseLine("device", `kept parked record for ${parked.udid}: simulator is now named ${JSON.stringify(sim.name)} and is not Stim-owned`)));
228
- continue;
229
- }
230
- const model = {
231
- model: choice.deviceType,
232
- runtime: choice.runtime
233
- };
234
- const name = ownedSimName(label, model, ownedIosNameSuffix(label, model, projectPath, parked.udid));
235
- const device = {
236
- deviceUdid: parked.udid,
237
- owned: true,
238
- deviceName: name,
239
- adopted: true,
240
- adoptionPending: true,
241
- ...parked.simslimManaged ? { simslimManaged: true } : {},
242
- ...parked.cacheKey ? { parkedCacheKey: parked.cacheKey } : {}
243
- };
244
- const adopted = adoptParked({
245
- platform: "ios",
246
- projectPath,
247
- slot,
248
- udid: parked.udid,
249
- device
250
- });
251
- if (!adopted) continue;
252
- try {
253
- renameIosSim(parked.udid, name);
254
- } catch {}
255
- return adopted.schemeApprovals && adopted.schemeApprovals.length > 0 ? {
256
- ...device,
257
- schemeApprovals: adopted.schemeApprovals
258
- } : device;
259
- }
260
- return null;
261
- }
262
- function clearIosAdoptionPending(projectPath, slot = "default") {
263
- withConfigLock(() => {
264
- const cfg = loadConfig();
265
- const ios = deviceSlotPlatforms(cfg?.projects?.[projectPath], slot)?.ios;
266
- if (!cfg || !ios?.adoptionPending) return;
267
- delete ios.adopted;
268
- delete ios.adoptionPending;
269
- delete ios.parkedCacheKey;
270
- saveConfig(cfg);
271
- });
272
- }
273
- async function configureOwnedIosSim({ record, projectPath, slot, profile, out, reconcileIosSimulator }) {
274
- if (profile) out(chalk.dim(phaseLine("device", `applying the SimSlim profile to ${record.deviceUdid}`)));
275
- else if (record.simslimManaged) out(chalk.dim(phaseLine("device", `restoring stock simulator services on ${record.deviceUdid}`)));
276
- const previouslyManaged = Boolean(record.simslimManaged);
277
- if (profile && !record.simslimManaged) {
278
- const pending = {
279
- ...record,
280
- simslimManaged: true
281
- };
282
- setDevice(projectPath, "ios", pending, slot);
283
- record = pending;
284
- }
285
- const result = await reconcileIosSimulator({
286
- udid: record.deviceUdid,
287
- profile,
288
- previouslyManaged,
289
- out
290
- });
291
- const updated = { ...record };
292
- if (result.managed) updated.simslimManaged = true;
293
- else delete updated.simslimManaged;
294
- setDevice(projectPath, "ios", updated, slot);
295
- return updated;
296
- }
297
- async function ensureIosBooted({ device, projectPath, deviceSlotWait, simulatorApp, timeoutMs, pollMs, out }) {
298
- const udid = device?.deviceUdid;
299
- if (!udid) return {
300
- failed: true,
301
- reason: "No iOS simulator is recorded for this project."
302
- };
303
- const ready = () => {
304
- try {
305
- getExecutor().runFile("xcrun", [
306
- "simctl",
307
- "spawn",
308
- udid,
309
- "launchctl",
310
- "list"
311
- ], { timeoutMs: 3e4 });
312
- return {
313
- ok: true,
314
- udid
315
- };
316
- } catch (error) {
317
- return {
318
- failed: true,
319
- reason: `Simulator ${udid} failed its process-spawn readiness check: ${error?.message || error}. ${iosSimulatorFailureAdvice()}`
320
- };
321
- }
322
- };
323
- const booting = device?.booting;
324
- if (booting?.udid === udid) {
325
- try {
326
- await booting.done;
327
- } catch (e) {
328
- return bootFailure(udid, e);
329
- }
330
- return ready();
331
- }
332
- const readiness = device?.booted === udid ? ready() : null;
333
- if (readiness?.ok) {
334
- if (simulatorApp !== void 0) configuredIosSimulatorViewer(simulatorApp).open(udid);
335
- return readiness;
336
- }
337
- let resolved;
338
- try {
339
- resolved = resolveOwnedIosSim(udid);
340
- } catch (e) {
341
- return {
342
- failed: true,
343
- reason: `Could not list simulators: ${e?.message || e}`
344
- };
345
- }
346
- if (resolved.missing) return {
347
- failed: true,
348
- reason: `Simulator ${udid} no longer exists. Run \`stim ios\` again to create a fresh owned sim.`
349
- };
350
- if (resolved.notOwned) return {
351
- failed: true,
352
- reason: `Simulator ${udid} is now named "${resolved.notOwned}" and is not Stim-owned; refusing to boot it.`
353
- };
354
- const sim = resolved.sim;
355
- if (sim.state === "Booted") {
356
- const result = readiness ?? ready();
357
- if (result.ok && simulatorApp !== void 0) configuredIosSimulatorViewer(simulatorApp).open(udid);
358
- return result;
359
- }
360
- const bootDeadline = Date.now() + timeoutMs;
361
- try {
362
- await withDeviceBootAdmission({
363
- platform: "ios",
364
- key: udid
365
- }, () => {
366
- out(chalk.dim(phaseLine("device", `booting ${sim.name} (${udid})`)));
367
- return bootIosSim(udid, {
368
- timeoutMs,
369
- label: sim.name,
370
- out,
371
- simulatorApp
372
- });
373
- }, {
374
- ...deviceSlotWait,
375
- root: projectPath,
376
- out
377
- });
378
- } catch (e) {
379
- return bootFailure(udid, e);
380
- }
381
- const deadline = Math.max(bootDeadline, Date.now() + 2 * pollMs);
382
- while (Date.now() < deadline) {
383
- await sleep(pollMs);
384
- let state = null;
385
- try {
386
- state = listAllIosSims({ timeoutMs: 3e4 }).find((s) => s.udid === udid)?.state ?? null;
387
- } catch {}
388
- if (state === "Booted") return ready();
389
- }
390
- return {
391
- failed: true,
392
- reason: `Simulator ${udid} did not reach the Booted state within ${Math.round(timeoutMs / 1e3)}s.`
393
- };
394
- }
395
- function bootFailure(udid, error) {
396
- const refusal = error instanceof DeviceAdmissionRefusal ? error : (0, ownership_claim_exports.claimFailure)(error, "stim ios");
397
- if (refusal) return {
398
- failed: true,
399
- code: refusal.code,
400
- reason: refusal.message,
401
- remedy: refusal.remedy
402
- };
403
- return {
404
- failed: true,
405
- reason: `Could not boot simulator ${udid}: ${error?.message || error}`
406
- };
407
- }
408
- function sleep(ms) {
409
- return new Promise((r) => setTimeout(r, ms));
410
- }
411
- //#endregion
412
- export { ensureOwnedIosDevice as i, clearIosAdoptionPending as n, ensureIosBooted as r, IosDeviceMismatchError as t };
@@ -1,15 +0,0 @@
1
- //#region src/supervisor/errors.ts
2
- function supervisorError(code, message, remedy) {
3
- const err = new Error(message);
4
- err.code = code;
5
- if (remedy) err.remedy = remedy;
6
- return err;
7
- }
8
- function describeError(err) {
9
- if (!err) return "unknown error";
10
- const e = err;
11
- const message = e.message || String(err);
12
- return `${e.code ? `${e.code}: ` : ""}${message}${e.remedy ? ` Remedy: ${e.remedy}` : ""}`;
13
- }
14
- //#endregion
15
- export { supervisorError as n, describeError as t };
@@ -1,125 +0,0 @@
1
- import { E as upsertProject, d as getConfigDir, p as getProject } from "./config-D0DbpZtM.mjs";
2
- import { n as appProjectProblem } from "./project-D47Rh0ly.mjs";
3
- import { t as compareStimVersions } from "./stim-installations-QMEI32v1.mjs";
4
- import { mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
5
- import { join } from "node:path";
6
- //#region src/guide-status.ts
7
- const DAY_MS = 864e5;
8
- const DOCTOR_STALE_MS = 7 * DAY_MS;
9
- const UPDATE_CHECK_INTERVAL_MS = DAY_MS;
10
- const UPDATE_CHECK_TIMEOUT_MS = 2e3;
11
- const LATEST_URL = "https://registry.npmjs.org/stim/latest";
12
- const PLATFORMS = ["ios", "android"];
13
- function recordDoctorRun(projectRoot, platform, version, now = /* @__PURE__ */ new Date()) {
14
- const run = {
15
- at: now.toISOString(),
16
- version
17
- };
18
- try {
19
- if (appProjectProblem(projectRoot)) return;
20
- upsertProject(projectRoot, (existing) => {
21
- const doctorRuns = { ...existing.doctorRuns };
22
- for (const target of platform ? [platform] : PLATFORMS) doctorRuns[target] = run;
23
- return { doctorRuns };
24
- });
25
- } catch {}
26
- }
27
- function doctorDueReason(record, running, now) {
28
- const at = record ? Date.parse(record.at) : NaN;
29
- if (!record || Number.isNaN(at)) return "never run";
30
- if (record.version !== running) return `last run with stim ${record.version}`;
31
- const age = now.getTime() - at;
32
- if (age > DOCTOR_STALE_MS) return `last run ${Math.floor(age / DAY_MS)} days ago`;
33
- return null;
34
- }
35
- function updateCacheFile() {
36
- return join(getConfigDir(), "update-check.json");
37
- }
38
- function readUpdateCache() {
39
- try {
40
- const parsed = JSON.parse(readFileSync(updateCacheFile(), "utf-8"));
41
- if (typeof parsed?.checkedAt !== "string") return null;
42
- return {
43
- checkedAt: parsed.checkedAt,
44
- latest: typeof parsed.latest === "string" ? parsed.latest : null
45
- };
46
- } catch {
47
- return null;
48
- }
49
- }
50
- function writeUpdateCache(cache) {
51
- const target = updateCacheFile();
52
- const tmp = `${target}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
53
- try {
54
- mkdirSync(getConfigDir(), { recursive: true });
55
- writeFileSync(tmp, `${JSON.stringify(cache)}\n`);
56
- renameSync(tmp, target);
57
- } catch {
58
- try {
59
- unlinkSync(tmp);
60
- } catch {}
61
- }
62
- }
63
- async function fetchLatest(fetchImpl) {
64
- const res = await fetchImpl(LATEST_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) });
65
- if (!res.ok) return null;
66
- const body = await res.json();
67
- return typeof body.version === "string" ? body.version : null;
68
- }
69
- async function checkForUpdate(running, { now = /* @__PURE__ */ new Date(), fetch: fetchImpl = fetch } = {}) {
70
- if (process.env.STIM_NO_UPDATE_CHECK) return null;
71
- const cached = readUpdateCache();
72
- const checkedAt = cached ? Date.parse(cached.checkedAt) : NaN;
73
- let latest = cached?.latest ?? null;
74
- if (Number.isNaN(checkedAt) || now.getTime() - checkedAt > UPDATE_CHECK_INTERVAL_MS) {
75
- try {
76
- latest = await fetchLatest(fetchImpl);
77
- } catch {
78
- latest = null;
79
- }
80
- writeUpdateCache({
81
- checkedAt: now.toISOString(),
82
- latest
83
- });
84
- }
85
- if (!latest) return null;
86
- const comparison = compareStimVersions(latest, running);
87
- return comparison !== null && comparison > 0 ? latest : null;
88
- }
89
- function renderGuideStatus({ running, doctor, latest }) {
90
- const lines = [];
91
- if (doctor.length) {
92
- const named = doctor.map((due) => `${due.platform} (${due.reason})`).join(" and ");
93
- const command = doctor.length === 1 ? `stim doctor --platform ${doctor[0]?.platform}` : "stim doctor";
94
- lines.push(` Doctor is due for ${named}.`, ` Run before native work: ${command}`);
95
- }
96
- if (latest) lines.push(` stim ${latest} is available (running ${running}): npm install -g stim@latest`);
97
- if (!lines.length) return null;
98
- return ["STATUS", ...lines].join("\n");
99
- }
100
- async function guideStatus({ projectRoot, running, now = /* @__PURE__ */ new Date(), fetch: fetchImpl = fetch }) {
101
- const doctor = [];
102
- if (projectRoot && !appProjectProblem(projectRoot)) {
103
- let runs = null;
104
- try {
105
- runs = getProject(projectRoot)?.doctorRuns ?? {};
106
- } catch {}
107
- if (runs) for (const platform of PLATFORMS) {
108
- const reason = doctorDueReason(runs[platform], running, now);
109
- if (reason) doctor.push({
110
- platform,
111
- reason
112
- });
113
- }
114
- }
115
- return renderGuideStatus({
116
- running,
117
- doctor,
118
- latest: await checkForUpdate(running, {
119
- now,
120
- fetch: fetchImpl
121
- })
122
- });
123
- }
124
- //#endregion
125
- export { recordDoctorRun as n, guideStatus as t };