stim 1.18.0 → 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 (140) hide show
  1. package/README.md +1 -1
  2. package/dist/{activity-BxnkDZDi.mjs → activity-BSw0x84R.mjs} +3 -3
  3. package/dist/{agent-device-usage-output-CZ66YA4T.mjs → agent-device-usage-output-Bjxu_VmX.mjs} +5 -5
  4. package/dist/{android-BvwuMUJ9.mjs → android-BXc6BmEi.mjs} +507 -347
  5. package/dist/{android-DC3ZLuw0.mjs → android-BdQC6zs1.mjs} +6 -6
  6. package/dist/{android-BKA16DTf.mjs → android-BvV1gGdN.mjs} +3 -3
  7. package/dist/{android-CBwCNicO.mjs → android-DE5g_5gv.mjs} +2 -2
  8. package/dist/{android-cas-BBFyr9CA.mjs → android-cas-C87geAg-.mjs} +3 -3
  9. package/dist/android-cas-compiler.mjs +1 -1
  10. package/dist/{api-D0VtFhqk.mjs → api-DIf_s86s.mjs} +5 -7
  11. package/dist/api-run.mjs +8 -8
  12. package/dist/api.d.mts +8 -2
  13. package/dist/api.mjs +1 -1
  14. package/dist/{app-install-D-PUENug.mjs → app-install-CFI4ptUL.mjs} +33 -13
  15. package/dist/{web-DTU0uiWj.mjs → browser-web-CDhqQxhv.mjs} +134 -172
  16. package/dist/{budget-DIhL2BKx.mjs → budget-Dz-kyXLv.mjs} +15 -202
  17. package/dist/{build-facts-DcLv2HSd.d.mts → build-facts-B87vo-Im.d.mts} +32 -1
  18. package/dist/{cache-manifest-BI7ozfmH.mjs → cache-manifest-DiwKSyv9.mjs} +1 -1
  19. package/dist/cache-manifest.mjs +1 -1
  20. package/dist/{chrome-DJnmnS5q.mjs → chrome-BTUOo8p2.mjs} +1 -1
  21. package/dist/{cli-DNJMwADx.mjs → cli-C9Zvgbdc.mjs} +20 -20
  22. package/dist/cli.mjs +1 -1
  23. package/dist/{client-DzhapoMB.mjs → client-CuUo8Nvg.mjs} +248 -23
  24. package/dist/collector-run.d.mts +6 -0
  25. package/dist/collector-run.mjs +6 -6
  26. package/dist/{command-output-CBtzyIgF.mjs → command-output-Bt8ygHE7.mjs} +1 -1
  27. package/dist/{config-CgYMahz7.mjs → config-DC5jEtd1.mjs} +6 -2
  28. package/dist/{created-devices-DKbeWsiK.mjs → created-devices-D0s26Hx5.mjs} +2 -2
  29. package/dist/{dependency-state-xKoOypBm.mjs → dependency-state-DKaS1OM9.mjs} +2 -2
  30. package/dist/{detached-entry-BLfcgc4O.mjs → detached-entry-pB_IPfV4.mjs} +1 -1
  31. package/dist/{dev-client-CLnIH02x.mjs → dev-client-CDY_zAmD.mjs} +2 -2
  32. package/dist/{device-D7oCHGWi.mjs → device-BHw0WlHl.mjs} +8 -8
  33. package/dist/{device-capacity-EUOOYr8T.mjs → device-capacity-BoN1jQkO.mjs} +23 -12
  34. package/dist/device-host-worker.mjs +14 -14
  35. package/dist/{gradle-C6GKnunQ.mjs → device-ios-B2ruohE-.mjs} +659 -105
  36. package/dist/{device-lease-Co-EwifR.mjs → device-lease-Cu7PtQpZ.mjs} +5 -5
  37. package/dist/{device-lease-run-w1xhCqIW.mjs → device-lease-run-D38SnZtt.mjs} +4 -4
  38. package/dist/{device-pool-F5WvRPtD.mjs → device-pool-CP4rAsHx.mjs} +3 -3
  39. package/dist/{device-remote-tHbd1fKy.mjs → device-remote-B5GiUifk.mjs} +15 -16
  40. package/dist/{doctor-B9ckYUoU.mjs → doctor-PRJH94v6.mjs} +53 -29
  41. package/dist/doctor-watchman-wZhyTdp4.mjs +259 -0
  42. package/dist/{error-diagnostics-BRXOqDzG.mjs → error-diagnostics--v5HGOU0.mjs} +10 -10
  43. package/dist/{exec-DWhCZDGm.mjs → exec-i8GDPwq9.mjs} +32 -8
  44. package/dist/{gc-Dh6mXOKC.mjs → gc-CyHMcKcn.mjs} +19 -19
  45. package/dist/{guide-tm6igAaa.mjs → guide-dRaQJJk9.mjs} +409 -472
  46. package/dist/{hosted-android-Bv285t_t.mjs → hosted-android-Bs7fytj7.mjs} +3 -3
  47. package/dist/{hosted-client-C-rMtppF.mjs → hosted-client-C5G4h_OJ.mjs} +1 -1
  48. package/dist/{hosted-ios-D5mNmtj4.mjs → hosted-ios-Bik035eL.mjs} +1 -1
  49. package/dist/{hosted-logs-DN8Iz4mJ.mjs → hosted-logs-CI9Az9a4.mjs} +7 -7
  50. package/dist/{hosted-macos-B-wEjlwG.mjs → hosted-macos-DABm3ScO.mjs} +4 -4
  51. package/dist/{hosted-native-DeeOG8xZ.mjs → hosted-native-DbV2aUVw.mjs} +12 -8
  52. package/dist/{idle-shutdown-jjtxAn5C.mjs → idle-shutdown-DYiMBn34.mjs} +7 -7
  53. package/dist/{ios-B3SbOWdw.mjs → ios-BWbHFZVz.mjs} +5 -5
  54. package/dist/{ios-Bvbf0SGY.mjs → ios-DCrkgXEM.mjs} +1 -1
  55. package/dist/{ios-DNpdygiv.mjs → ios-DYUr9LGc.mjs} +7 -6
  56. package/dist/ios-ITYno9rO.mjs +2241 -0
  57. package/dist/{ios-device-vOaByMhw.mjs → ios-device-CJ_ZOGky.mjs} +3 -3
  58. package/dist/{ios-device-Bn7jWDB1.mjs → ios-device-CrW8aMb5.mjs} +1 -1
  59. package/dist/{ios-state-B2pES6Vs.mjs → ios-state-By0XuLTQ.mjs} +1 -1
  60. package/dist/{launch-verify-hskNcWkZ.mjs → launch-verify-DCveSE6d.mjs} +4 -4
  61. package/dist/{logs-1Ylc1Ri6.mjs → logs-Bao1HOMy.mjs} +10 -10
  62. package/dist/{macos-DF6C7wUU.mjs → macos-ciyBdTY5.mjs} +108 -130
  63. package/dist/macos-nIOATJmR.mjs +2 -0
  64. package/dist/macos-run.mjs +1 -1
  65. package/dist/maintenance-run.mjs +7 -7
  66. package/dist/manifest-CX0d1IkZ.mjs +148 -0
  67. package/dist/{metro-Dh8T4Ytd.mjs → metro-DI2AjPF_.mjs} +194 -41
  68. package/dist/{metro-gateway-CEUw9RMH.mjs → metro-gateway-BxpJLIwh.mjs} +2 -2
  69. package/dist/{plan-placement-CtxkCO54.mjs → miss-reason-CjQCOKqq.mjs} +180 -296
  70. package/dist/{named-ports-BFIz1Shz.mjs → named-ports-B4iWH4E-.mjs} +12 -5
  71. package/dist/{native-runtime-D_603JiC.mjs → native-runtime-BGxsbfny.mjs} +6 -6
  72. package/dist/offload-worker.d.mts +1 -29
  73. package/dist/offload-worker.mjs +9 -8
  74. package/dist/{ownership-D6Se7gg_.mjs → ownership-EB0ySdGK.mjs} +2 -2
  75. package/dist/{placement-log-BcPhRwR4.mjs → placement-log-Dxe34rJm.mjs} +7 -3
  76. package/dist/plan-placement-BVY59qa8.mjs +290 -0
  77. package/dist/{ports-BLTtfBq-.mjs → ports-ByPc0_97.mjs} +3 -3
  78. package/dist/{prebuild-juCyreaR.mjs → prebuild-BKJ3wJI1.mjs} +4 -4
  79. package/dist/{preview-D5V07Nrl.mjs → preview-BbSottmO.mjs} +16 -17
  80. package/dist/project-B5eQ1USs.mjs +612 -0
  81. package/dist/{pull-request-u4vp7zmK.mjs → pull-request-IHNdMnG8.mjs} +1 -1
  82. package/dist/pull-requests.mjs +1 -1
  83. package/dist/react-native-ios-BMh2i25I.mjs +2 -0
  84. package/dist/react-native-ios-CSpIxexZ.mjs +2083 -0
  85. package/dist/{recordings-BAWltsVt.mjs → recordings-Bv8McZN4.mjs} +1 -1
  86. package/dist/{reload-DvyWzVjJ.mjs → reload-rAPdqeRR.mjs} +13 -14
  87. package/dist/{remote-cache-BGg7aGIZ.mjs → remote-cache-N3hAEaAL.mjs} +4 -4
  88. package/dist/{run-vhtDgpHO.mjs → run-lAkle1-c.mjs} +2 -2
  89. package/dist/{server-bare-B9E7S1aR.mjs → server-bare-CkIjnegq.mjs} +3 -3
  90. package/dist/server-expo-DGsdUGX2.mjs +2 -0
  91. package/dist/{server-expo-DoBHhuzK.mjs → server-expo-n3tUi3Em.mjs} +3 -3
  92. package/dist/{settings-Byp2AQ_E.mjs → settings-2am7TSxp.mjs} +5 -6
  93. package/dist/{settings-CQyMElEP.mjs → settings-CxgngUZk.mjs} +767 -15
  94. package/dist/settings.schema.json +72 -6
  95. package/dist/{simslim-EHBQ2R4G.mjs → simslim-D9LkJxIO.mjs} +5 -5
  96. package/dist/{slot-launch-C1nqh4mu.mjs → slot-launch-HV_KtPIw.mjs} +6 -6
  97. package/dist/{stage-g_WqWeaE.mjs → stage-BgaZJVZY.mjs} +1 -1
  98. package/dist/{start-NTc1Ifqs.mjs → start-D8NbxNBb.mjs} +1 -1
  99. package/dist/{start-D-IeOyoK.mjs → start-DtxthMfI.mjs} +29 -22
  100. package/dist/{state-BG-aAk4k.mjs → state-D2KtnALG.mjs} +2 -2
  101. package/dist/{state-xnqpx3AD.mjs → state-Tp4uImDS.mjs} +4 -2
  102. package/dist/{stats-DY6ekz8F.mjs → stats-8EJ5ivFT.mjs} +6 -6
  103. package/dist/{status-DCjZeE-K.mjs → status-BOyp0CUl.mjs} +25 -27
  104. package/dist/{stim-desktop-Behws_fi.mjs → stim-desktop-C65jk_q2.mjs} +1 -1
  105. package/dist/{stim-installations-aR_WsNOA.mjs → stim-installations-DbmUjsLv.mjs} +1 -1
  106. package/dist/stop-D0UIpZuh.mjs +72 -0
  107. package/dist/{stop-DIJtD2GL.mjs → stop-DRipAg-e.mjs} +2 -2
  108. package/dist/{stop-BTjs3xbc.mjs → stop-zDlknFoz.mjs} +78 -31
  109. package/dist/supervisor-run.mjs +14 -14
  110. package/dist/{support-BaayeYCf.mjs → support-CNqYkV0y.mjs} +7 -7
  111. package/dist/{support-Bwvbrq5-.mjs → support-DsNaFg6D.mjs} +5 -5
  112. package/dist/swiftpm-macos-aJzPAj1t.mjs +119 -0
  113. package/dist/{toolchain-Bnyd_K3A.mjs → toolchain-C3xSoyUl.mjs} +27 -270
  114. package/dist/{trigger-CJMhwXe8.mjs → trigger-CAhmG-4s.mjs} +3 -3
  115. package/dist/trigger-CoalsMTV.mjs +2 -0
  116. package/dist/{warm-progress-CjB-MP6H.mjs → warm-progress-pFLB2e6P.mjs} +133 -36
  117. package/dist/{status-Dcr0Qexd.mjs → watchman-BL1IdOtq.mjs} +75 -7
  118. package/dist/web-DFpFeZu5.mjs +2 -0
  119. package/dist/web-DbbrPUn0.mjs +127 -0
  120. package/dist/web-run.mjs +7 -7
  121. package/dist/{workspace-state-C59dqG-Z.mjs → workspace-state-CR9X86xJ.mjs} +1 -1
  122. package/dist/{workspaces-xXItD8Dj.mjs → workspaces-Djb2gfi9.mjs} +102 -18
  123. package/dist/{worktree-BSYlofkq.mjs → worktree-BL4M1rhB.mjs} +45 -42
  124. package/dist/{worktree-BJfnU6r5.mjs → worktree-DV-A0LNL.mjs} +1 -1
  125. package/package.json +5 -5
  126. package/shim/bundle-response.cjs +2 -1
  127. package/shim/bundle-response.d.cts +1 -1
  128. package/shim/expo-metro-config.cjs +1 -1
  129. package/dist/device-ios-6MewKKnc.mjs +0 -412
  130. package/dist/guide-status-Bhf9SJXc.mjs +0 -125
  131. package/dist/ios-CPdkoKaa.mjs +0 -3953
  132. package/dist/macos-Ck7OBMNY.mjs +0 -2
  133. package/dist/native-run-B06FkmZx.mjs +0 -158
  134. package/dist/project-C3ChRLZy.mjs +0 -212
  135. package/dist/projects-DD7dBTCj.mjs +0 -92
  136. package/dist/server-expo-Db9HBUoa.mjs +0 -2
  137. package/dist/stop-BGhKMOuH.mjs +0 -48
  138. package/dist/trigger-DWAq9hkw.mjs +0 -2
  139. package/dist/web-B6_bFDn7.mjs +0 -2
  140. package/dist/worktree-CsKYexJM.mjs +0 -753
@@ -1,6 +1,6 @@
1
- import { t as getExecutor } from "./exec-DWhCZDGm.mjs";
2
- import { i as INSTALL_ERROR } from "./app-install-D-PUENug.mjs";
3
- import { n as TOOL_ERROR_PREFIX } from "./ios-device-Bn7jWDB1.mjs";
1
+ import { t as getExecutor } from "./exec-i8GDPwq9.mjs";
2
+ import { i as INSTALL_ERROR } from "./app-install-CFI4ptUL.mjs";
3
+ import { n as TOOL_ERROR_PREFIX } from "./ios-device-CrW8aMb5.mjs";
4
4
  import { mkdtempSync, readFileSync, rmSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { tmpdir } from "node:os";
@@ -1,4 +1,4 @@
1
- import { t as getExecutor } from "./exec-DWhCZDGm.mjs";
1
+ import { t as getExecutor } from "./exec-i8GDPwq9.mjs";
2
2
  //#region src/collector/ios-device.ts
3
3
  const CONSOLE_ENV = { OS_ACTIVITY_DT_MODE: "enable" };
4
4
  const DEV_MENU_LAUNCH_ARGS = [
@@ -1,4 +1,4 @@
1
- import { a as updateWorkspaceState, r as readWorkspaceState$1 } from "./workspace-state-C59dqG-Z.mjs";
1
+ import { a as updateWorkspaceState, r as readWorkspaceState$1 } from "./workspace-state-CR9X86xJ.mjs";
2
2
  import { HOSTED_METRO_REQUESTS_KEY, hostedMetroRequests, hostedNativeRecords, isJsonObject, parseHostedNativePlacement, unreadableHostedNative } from "@stim-cli/core/state";
3
3
  //#region src/device-host/ios-state.ts
4
4
  function readHostedNative(root, platform, slot) {
@@ -1,8 +1,8 @@
1
- import { t as getExecutor } from "./exec-DWhCZDGm.mjs";
2
- import { s as isAppLaunchError } from "./command-output-CBtzyIgF.mjs";
1
+ import { t as getExecutor } from "./exec-i8GDPwq9.mjs";
2
+ import { s as isAppLaunchError } from "./command-output-Bt8ygHE7.mjs";
3
3
  import { o as readNdjsonGenerations } from "./ndjson-LGZAMsqa.mjs";
4
- import { f as deviceShellArg, n as ANDROID_DISABLE_AUTO_LAUNCH_EXTRA, s as androidAppProcess } from "./app-install-D-PUENug.mjs";
5
- import { t as DEV_MENU_LAUNCH_ARGS } from "./ios-device-Bn7jWDB1.mjs";
4
+ import { f as deviceShellArg, n as ANDROID_DISABLE_AUTO_LAUNCH_EXTRA, s as androidAppProcess } from "./app-install-CFI4ptUL.mjs";
5
+ import { t as DEV_MENU_LAUNCH_ARGS } from "./ios-device-CrW8aMb5.mjs";
6
6
  import { join } from "node:path";
7
7
  //#region src/engine/app-readiness.ts
8
8
  const APP_READINESS_TIMEOUT_MS = 3e4;
@@ -1,15 +1,15 @@
1
1
  import { t as process_identity_exports } from "./process-identity-Biv3arCO.mjs";
2
- import { f as refuseNoProject, l as phaseLine, v as launchErrorPreview } from "./command-output-CBtzyIgF.mjs";
3
- import { H as projectDeviceSlots, V as parseDeviceSlotOption, _ as loadConfig$1, g as isPathPrefix } from "./config-CgYMahz7.mjs";
4
- import { o as findCommandWorkspace } from "./project-C3ChRLZy.mjs";
5
- import { r as readWorkspaceState$1, x as workspaceLogsDir$1 } from "./workspace-state-C59dqG-Z.mjs";
6
- import { n as agentDeviceLiveness, u as readAgentDeviceRecords } from "./activity-BxnkDZDi.mjs";
2
+ import { f as refuseNoProject, l as phaseLine, v as launchErrorPreview } from "./command-output-Bt8ygHE7.mjs";
3
+ import { H as projectDeviceSlots, V as parseDeviceSlotOption, _ as loadConfig$1, g as isPathPrefix } from "./config-DC5jEtd1.mjs";
4
+ import { r as readWorkspaceState$1, x as workspaceLogsDir$1 } from "./workspace-state-CR9X86xJ.mjs";
5
+ import { n as findCommandWorkspace } from "./project-B5eQ1USs.mjs";
6
+ import { n as agentDeviceLiveness, u as readAgentDeviceRecords } from "./activity-BSw0x84R.mjs";
7
7
  import { n as SOURCES, t as LEVELS } from "./ndjson-LGZAMsqa.mjs";
8
- import { o as connectHost } from "./hosted-client-C-rMtppF.mjs";
9
- import { n as pullHostedNativeLogs, t as pullHostedMacosLogs } from "./hosted-logs-DN8Iz4mJ.mjs";
10
- import { n as readHostedIos, t as readHostedAndroid } from "./ios-state-B2pES6Vs.mjs";
11
- import { i as captureWorkspaceCrashes, t as errorDiagnostics } from "./error-diagnostics-BRXOqDzG.mjs";
12
- import "./hosted-macos-B-wEjlwG.mjs";
8
+ import { o as connectHost } from "./hosted-client-C5G4h_OJ.mjs";
9
+ import { n as pullHostedNativeLogs, t as pullHostedMacosLogs } from "./hosted-logs-CI9Az9a4.mjs";
10
+ import { n as readHostedIos, t as readHostedAndroid } from "./ios-state-By0XuLTQ.mjs";
11
+ import { i as captureWorkspaceCrashes, t as errorDiagnostics } from "./error-diagnostics--v5HGOU0.mjs";
12
+ import "./hosted-macos-DABm3ScO.mjs";
13
13
  import { t as watchStdoutReader } from "./stdout-reader-C8yjre1x.mjs";
14
14
  import { realpathSync } from "node:fs";
15
15
  import { dirname, join, relative, resolve, sep } from "node:path";
@@ -1,30 +1,26 @@
1
1
  import { t as process_identity_exports } from "./process-identity-Biv3arCO.mjs";
2
- import { t as getExecutor } from "./exec-DWhCZDGm.mjs";
2
+ import { t as getExecutor } from "./exec-i8GDPwq9.mjs";
3
3
  import { t as spawnEntry } from "./spawn-entry-Dcb7sDUz.mjs";
4
- import { l as phaseLine } from "./command-output-CBtzyIgF.mjs";
5
- import { E as upsertProject, u as getConcurrencyLimits } from "./config-CgYMahz7.mjs";
6
- import { s as gitCommonDir, y as repoRoot } from "./worktree-CsKYexJM.mjs";
7
- import { s as findProjectRoot$1, u as ownedDeviceLabel } from "./project-C3ChRLZy.mjs";
8
- import { c as writeWorkspaceState, g as workspaceAgentDeviceDir, i as recordWorkspaceUse, u as ensureWorkspaceStorage, v as workspaceDir, x as workspaceLogsDir$1 } from "./workspace-state-C59dqG-Z.mjs";
9
- import { F as recordFinishedBuild, I as startBuildProgress, L as tapBuildLog, O as NO_BUILD_PROGRESS, P as recordBuildPhase } from "./budget-DIhL2BKx.mjs";
10
- import { N as releaseBuildSlot, j as acquireBuildSlot } from "./workspaces-xXItD8Dj.mjs";
4
+ import { l as phaseLine } from "./command-output-Bt8ygHE7.mjs";
5
+ import { E as upsertProject, u as getConcurrencyLimits } from "./config-DC5jEtd1.mjs";
6
+ import { c as writeWorkspaceState, g as workspaceAgentDeviceDir, i as recordWorkspaceUse, u as ensureWorkspaceStorage, v as workspaceDir, x as workspaceLogsDir$1 } from "./workspace-state-CR9X86xJ.mjs";
7
+ import { d as projectRegistry, o as ownedDeviceLabel, r as findProjectRoot } from "./project-B5eQ1USs.mjs";
8
+ import { B as settingShapeErrors, I as resolveSettings, i as SETTING_SHAPE_REMEDY, mt as repoRoot, nt as gitCommonDir } from "./settings-CxgngUZk.mjs";
9
+ import { F as recordFinishedBuild, I as startBuildProgress, L as tapBuildLog, O as NO_BUILD_PROGRESS, P as recordBuildPhase } from "./budget-Dz-kyXLv.mjs";
10
+ import { M as acquireBuildSlot, P as releaseBuildSlot } from "./workspaces-Djb2gfi9.mjs";
11
11
  import { a as spawnDeclared } from "./spawn-claims-Kqiifsk2.mjs";
12
- import { E as sanitizeDeviceLabel } from "./ios-B3SbOWdw.mjs";
13
- import { F as resolveSettings, i as SETTING_SHAPE_REMEDY, z as settingShapeErrors } from "./settings-CQyMElEP.mjs";
14
- import { a as withWorkspaceProcessLock } from "./named-ports-BFIz1Shz.mjs";
15
- import { a as requiredMacosRecord, n as macosLogFile, r as macosProcess, t as macosDir } from "./state-xnqpx3AD.mjs";
12
+ import { E as sanitizeDeviceLabel } from "./ios-BWbHFZVz.mjs";
13
+ import { a as withWorkspaceProcessLock } from "./named-ports-B4iWH4E-.mjs";
14
+ import { i as macosProcess, n as macosDir, o as requiredMacosRecord, r as macosLogFile } from "./state-Tp4uImDS.mjs";
16
15
  import { r as createNdjsonWriter } from "./ndjson-LGZAMsqa.mjs";
17
- import { _ as resolveBuildPlacement, a as offloadBuild, c as placementLoad, d as setRemoteLogSink, f as OffloadRefusal, h as parseBuildMachineOption, i as closeOffload, l as remotePhaseText, m as namedBuildMachine, n as buildPlacementCandidates, r as chooseBuildMachine, s as offloadPlacement } from "./client-DzhapoMB.mjs";
18
- import { i as macosToolchain } from "./toolchain-Bnyd_K3A.mjs";
19
- import { o as connectHost } from "./hosted-client-C-rMtppF.mjs";
20
- import { t as buildPlacementRecord } from "./placement-log-BcPhRwR4.mjs";
21
- import { f as withNativeBuildRun } from "./native-run-B06FkmZx.mjs";
22
- import { t as placeHostedMacos } from "./hosted-macos-B-wEjlwG.mjs";
23
- import { t as logLines } from "./run-vhtDgpHO.mjs";
24
- import { i as validateInfoPlist, n as setBundleName, r as stageBundle, t as resolveBundleExtras } from "./stage-g_WqWeaE.mjs";
25
- import { n as stopMacosAppHeld } from "./stop-BGhKMOuH.mjs";
16
+ import { A as resolveBuildPlacement, C as setRemoteLogSink, D as parseBuildMachineOption, E as namedBuildMachine, O as requireLocalBuild, S as withNativeBuildRun, a as offloadBuild, c as placementLoad, i as closeOffload, l as remotePhaseText, n as buildPlacementCandidates, r as chooseBuildMachine, s as offloadPlacement, w as OffloadRefusal } from "./client-CuUo8Nvg.mjs";
17
+ import { o as connectHost } from "./hosted-client-C5G4h_OJ.mjs";
18
+ import { t as buildPlacementRecord } from "./placement-log-Dxe34rJm.mjs";
19
+ import { t as placeHostedMacos } from "./hosted-macos-DABm3ScO.mjs";
20
+ import { i as validateInfoPlist, t as resolveBundleExtras } from "./stage-BgaZJVZY.mjs";
21
+ import { r as stopMacosAppHeld, t as stopBundleInstances } from "./stop-D0UIpZuh.mjs";
26
22
  import { closeSync, existsSync, mkdirSync, mkdtempSync, openSync, realpathSync, renameSync, rmSync } from "node:fs";
27
- import { join, relative, resolve } from "node:path";
23
+ import { join } from "node:path";
28
24
  import { machineCapacity, readMacosRecord, validHostedAppArguments } from "@stim-cli/core/state";
29
25
  import { LOG_ROTATE_BYTES } from "@stim-cli/core";
30
26
  import { createHash, randomUUID } from "node:crypto";
@@ -48,46 +44,12 @@ function workspaceAppName(root, product) {
48
44
  }
49
45
  //#endregion
50
46
  //#region src/macos/build.ts
51
- async function tool(root, args, writer, note, capture = false) {
52
- const child = spawnDeclared(() => getExecutor().spawn("swift", args, {
53
- cwd: root,
54
- detached: true,
55
- stdio: [
56
- "ignore",
57
- "pipe",
58
- "pipe"
59
- ]
60
- }));
61
- let stdout = "";
62
- child.stdout?.on("data", (chunk) => {
63
- if (capture) stdout += chunk.toString("utf8");
64
- });
65
- const write = (msg) => {
66
- writer.write({
67
- src: "build",
68
- platform: "macos",
69
- level: "debug",
70
- msg
71
- });
72
- note(msg);
73
- };
74
- if (child.stdout) logLines(child.stdout, write);
75
- if (child.stderr) logLines(child.stderr, write);
76
- await new Promise((done, reject) => {
77
- child.once("error", reject);
78
- child.once("close", (code) => code === 0 ? done() : reject(/* @__PURE__ */ new Error(`swift ${args[0]} failed (${code}). See stim logs --source build.`)));
79
- });
80
- return stdout.trim();
81
- }
82
- async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, displayName, scratch, writer, note, record, buildMachine, resources, assetCatalog, progress = NO_BUILD_PROGRESS }) {
47
+ async function buildMacosBundle({ root, recipe, bundle, bundleId, displayName, scratch, writer, note, record, buildMachine, progress = NO_BUILD_PROGRESS }) {
83
48
  if (record) record.buildMachine = buildMachine;
84
49
  setRemoteLogSink((entry) => writer.write({
85
50
  ...entry,
86
51
  platform: "macos"
87
52
  }));
88
- validateInfoPlist(root, product, infoPlist);
89
- const repository = realpathSync(repoRoot(root) ?? root);
90
- const extras = resolveBundleExtras(root, repository, resources, assetCatalog);
91
53
  const write = (msg) => {
92
54
  writer.write({
93
55
  src: "build",
@@ -113,6 +75,7 @@ async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, di
113
75
  }
114
76
  }));
115
77
  if (namedBuildMachine(buildMachine)) throw new OffloadRefusal(buildMachine, reason);
78
+ requireLocalBuild(buildMachine);
116
79
  offloadFallback = reason;
117
80
  if (record) record.offloadFallback = reason;
118
81
  writer.write({
@@ -141,10 +104,11 @@ async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, di
141
104
  let choice = null;
142
105
  try {
143
106
  try {
144
- const { mode, machines } = buildPlacementCandidates(buildMachine);
107
+ const { mode, machines, localEnabled } = buildPlacementCandidates(buildMachine);
145
108
  const here = machineCapacity();
146
109
  const placement = offloadPlacement({
147
110
  mode,
111
+ localEnabled,
148
112
  machines: machines.length,
149
113
  here,
150
114
  unsupported: null,
@@ -153,10 +117,7 @@ async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, di
153
117
  if (placement.offload) {
154
118
  const chosen = await chooseBuildMachine({
155
119
  projectRoot: root,
156
- target: {
157
- platform: "macos",
158
- local: macosToolchain()
159
- },
120
+ target: recipe.offload.target(),
160
121
  mode,
161
122
  here,
162
123
  machines,
@@ -179,14 +140,7 @@ async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, di
179
140
  write(`placement: ${choice.machine} (${placement.reason}${placementLoad(choice)})`);
180
141
  const outcome = await offloadBuild({
181
142
  choice,
182
- request: {
183
- platform: "macos",
184
- product,
185
- infoPlist: relative(root, resolve(root, infoPlist)),
186
- bundleId,
187
- resources: Object.fromEntries(Object.entries(extras.resources).map(([destination, source]) => [destination, relative(repository, source)])),
188
- assetCatalog: extras.assetCatalog ? relative(repository, extras.assetCatalog) : null
189
- },
143
+ request: recipe.offload.request(bundleId),
190
144
  stagingDir: join(staging, "offload"),
191
145
  onPhase: (phase, line) => note(remotePhaseText(phase, line, choice.machine)),
192
146
  onEnter: (phase) => {
@@ -211,30 +165,7 @@ async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, di
211
165
  progress.place(null);
212
166
  if (!outcome.ok) throw new Error(`${outcome.machine}: ${outcome.reason}`);
213
167
  progress.step("install");
214
- const executable = join(outcome.artifactPath, "Contents", "MacOS", product);
215
- const plist = JSON.parse(getExecutor().runFile("plutil", [
216
- "-convert",
217
- "json",
218
- "-o",
219
- "-",
220
- join(outcome.artifactPath, "Contents", "Info.plist")
221
- ]));
222
- if (plist.CFBundleIdentifier !== bundleId || plist.CFBundleExecutable !== product || !existsSync(executable)) throw new Error("The fetched macOS bundle does not match the requested identity and executable.");
223
- for (const destination of [...Object.keys(extras.resources), ...extras.assetCatalog ? ["Assets.car"] : []]) if (!existsSync(join(outcome.artifactPath, "Contents", "Resources", destination))) throw new Error(`The fetched macOS bundle lacks declared resource ${destination}.`);
224
- if (displayName !== void 0) {
225
- setBundleName(join(outcome.artifactPath, "Contents", "Info.plist"), displayName);
226
- getExecutor().runFile("codesign", [
227
- "--force",
228
- "--sign",
229
- "-",
230
- outcome.artifactPath
231
- ]);
232
- }
233
- getExecutor().runFile("codesign", [
234
- "--verify",
235
- "--strict",
236
- outcome.artifactPath
237
- ]);
168
+ recipe.validateFetched(outcome.artifactPath, bundleId, displayName);
238
169
  promote(outcome.artifactPath);
239
170
  if (record) {
240
171
  record.offloadedTo = outcome.machine;
@@ -264,36 +195,24 @@ async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, di
264
195
  let slot;
265
196
  try {
266
197
  slot = await acquireBuildSlot({
198
+ automatic: buildMachine === "auto",
267
199
  max: getConcurrencyLimits().maxBuilds,
268
200
  root,
269
201
  logFile: writer.file,
270
202
  out: note,
271
203
  waitingFor: (info) => progress.waitingFor(info, "build-slot")
272
204
  });
205
+ requireLocalBuild(buildMachine);
273
206
  if (record) record.builtOn = "here";
274
207
  progress.step("compile");
275
- await tool(root, [
276
- "build",
277
- "-c",
278
- "debug",
279
- "--product",
280
- product,
281
- "--scratch-path",
282
- scratch,
283
- "--jobs",
284
- "2"
285
- ], writer, note);
286
- const bin = await tool(root, [
287
- "build",
288
- "-c",
289
- "debug",
290
- "--scratch-path",
208
+ const bin = await recipe.compile({
291
209
  scratch,
292
- "--show-bin-path"
293
- ], writer, () => {}, true);
210
+ writer,
211
+ note
212
+ });
294
213
  progress.step("install");
295
- const staged = join(staging, `${product}.app`);
296
- stageBundle(root, product, infoPlist, bin, staged, bundleId, extras, displayName);
214
+ const staged = join(staging, `${recipe.product}.app`);
215
+ recipe.stage(bin, staged, bundleId, displayName);
297
216
  promote(staged);
298
217
  return {
299
218
  bundleId,
@@ -314,6 +233,41 @@ async function buildMacosBundle({ root, product, infoPlist, bundle, bundleId, di
314
233
  }
315
234
  }
316
235
  //#endregion
236
+ //#region src/macos/plan.ts
237
+ function planMacos(root, buildMachineFlag) {
238
+ if (process.platform !== "darwin") throw new Error("stim macos requires a Mac with Swift installed.");
239
+ root = realpathSync(root);
240
+ if (!existsSync(join(root, "Package.swift"))) throw new Error("Run stim macos from the directory containing Package.swift.");
241
+ const repository = repoRoot(root);
242
+ const settings = resolveSettings({
243
+ projectPath: root,
244
+ gitCommonDir: gitCommonDir(root),
245
+ repoRoot: repository
246
+ });
247
+ const [shape] = settingShapeErrors(settings);
248
+ if (shape) throw new Error(`${shape} ${SETTING_SHAPE_REMEDY}`);
249
+ const selected = resolveBuildPlacement(buildMachineFlag);
250
+ if (selected.failure) throw Object.assign(new Error(selected.failure.message), selected.failure);
251
+ const macos = settings.macos;
252
+ if (!macos?.product || !macos.infoPlist) throw Object.assign(/* @__PURE__ */ new Error("Set macos.product and macos.infoPlist explicitly in .stim.json. See stim guide macos."), { code: "STIM_BAD_ARG" });
253
+ validateInfoPlist(root, macos.product, macos.infoPlist);
254
+ resolveBundleExtras(root, repository ?? root, macos.resources, macos.assetCatalog);
255
+ return {
256
+ platform: "macos",
257
+ product: macos.product,
258
+ buildMachine: selected.selected,
259
+ fingerprint: null,
260
+ cacheKey: null,
261
+ cacheHit: false,
262
+ provider: null,
263
+ cacheSkipped: false,
264
+ prebuild: null,
265
+ outcome: null,
266
+ expectedMs: null,
267
+ basis: 0
268
+ };
269
+ }
270
+ //#endregion
317
271
  //#region src/commands/macos.ts
318
272
  /**
319
273
  * Builds the Debug app and launches it here, or with `remote` on that approved remote Mac. A named host never falls
@@ -325,7 +279,11 @@ async function runMacos(root, note = console.error, remote, buildMachineFlag) {
325
279
  if (backend === "auto") throw Object.assign(/* @__PURE__ */ new Error("stim macos --remote auto is not available yet: automatic placement has not shipped. Name a hosting Mac from remote.machines."), { code: "STIM_BAD_ARG" });
326
280
  if (process.platform !== "darwin") throw new Error("stim macos requires a Mac with Swift installed.");
327
281
  root = realpathSync(root);
328
- if (!existsSync(join(root, "Package.swift"))) throw new Error("Run stim macos from the directory containing Package.swift.");
282
+ const operation = projectRegistry.selectMacos(root);
283
+ if ("problem" in operation) throw Object.assign(new Error(operation.problem.message), {
284
+ code: "STIM_NO_PROJECT",
285
+ remedy: operation.problem.remedy
286
+ });
329
287
  const settings = resolveSettings({
330
288
  projectPath: root,
331
289
  gitCommonDir: gitCommonDir(root),
@@ -336,8 +294,7 @@ async function runMacos(root, note = console.error, remote, buildMachineFlag) {
336
294
  const selected = resolveBuildPlacement(buildMachineFlag);
337
295
  if (selected.failure) throw Object.assign(new Error(selected.failure.message), selected.failure);
338
296
  const buildMachine = selected.selected;
339
- const macos = settings.macos;
340
- if (!macos?.product || !macos.infoPlist) throw Object.assign(/* @__PURE__ */ new Error("Set macos.product and macos.infoPlist explicitly in .stim.json. See stim guide macos."), { code: "STIM_BAD_ARG" });
297
+ const macos = (await operation.load()).prepare(settings);
341
298
  ensureWorkspaceStorage(root);
342
299
  return withNativeBuildRun(root, {
343
300
  command: "macos",
@@ -353,7 +310,7 @@ async function runMacos(root, note = console.error, remote, buildMachineFlag) {
353
310
  return withWorkspaceProcessLock(workspaceDir(root), "macos-launch", async () => {
354
311
  const previous = requiredMacosRecord(root);
355
312
  if (previous?.host && previous.host.machine !== remote) throw new Error(`This workspace's macOS app runs on ${previous.host.machine}. Run stim stop first, then stim macos${remote ? ` --remote ${remote}` : ""}.`);
356
- if (remote && !validHostedAppArguments(macos.arguments ?? [])) throw new Error("macos.arguments is too large for a hosted app: at most 32 arguments of 1024 characters (8192 in total), without NUL or line breaks.");
313
+ if (remote && !validHostedAppArguments(macos.arguments)) throw new Error("macos.arguments is too large for a hosted app: at most 32 arguments of 1024 characters (8192 in total), without NUL or line breaks.");
357
314
  if (remote) (await connectHost(remote)).connection.close();
358
315
  if (!previous?.host) await stopMacosAppHeld(root);
359
316
  upsertProject(root, {});
@@ -365,7 +322,7 @@ async function runMacos(root, note = console.error, remote, buildMachineFlag) {
365
322
  bundleId: "",
366
323
  executable: join(bundle, "Contents", "MacOS", macos.product),
367
324
  launchId: randomUUID(),
368
- arguments: macos.arguments ?? [],
325
+ arguments: macos.arguments,
369
326
  supervisor: macosProcess(process.pid),
370
327
  build: {
371
328
  state: "running",
@@ -377,7 +334,7 @@ async function runMacos(root, note = console.error, remote, buildMachineFlag) {
377
334
  hostLaunched: previous.hostLaunched ?? false
378
335
  } : {}
379
336
  };
380
- const handoff = await buildBundle(root, macos.infoPlist, record, remote !== void 0, note, macos, progress);
337
+ const handoff = await buildBundle(root, macos, record, remote !== void 0, note, progress);
381
338
  progress.step("launch");
382
339
  const launched = () => {
383
340
  try {
@@ -403,7 +360,7 @@ async function runMacos(root, note = console.error, remote, buildMachineFlag) {
403
360
  bundle: record.bundle,
404
361
  bundleId: record.bundleId,
405
362
  handoff,
406
- arguments: macos.arguments ?? [],
363
+ arguments: macos.arguments,
407
364
  recorded: previous?.host,
408
365
  reserved: (reserved) => {
409
366
  placement = reserved;
@@ -443,19 +400,18 @@ async function runMacos(root, note = console.error, remote, buildMachineFlag) {
443
400
  }).finally(() => progress.clear());
444
401
  }, { write: note });
445
402
  }
446
- async function buildBundle(root, infoPlist, record, hosted, note, extras, progress = NO_BUILD_PROGRESS) {
403
+ async function buildBundle(root, recipe, record, hosted, note, progress = NO_BUILD_PROGRESS) {
447
404
  const started = Date.parse(record.build.startedAt);
448
405
  const scratch = join(macosDir(root), "build");
449
406
  writeWorkspaceState(root, { macos: record });
450
407
  const writer = tapBuildLog(createNdjsonWriter(macosLogFile(root), { maxBytes: LOG_ROTATE_BYTES }), progress);
451
408
  try {
452
- const { bundleId: base } = validateInfoPlist(root, record.product, infoPlist);
409
+ const base = recipe.bundleId;
453
410
  const bundleId = hosted ? base : `${base}.stim.${createHash("sha256").update(root).digest("hex").slice(0, 12)}`;
454
411
  const displayName = workspaceAppName(root, record.product);
455
412
  const built = await buildMacosBundle({
456
413
  root,
457
- product: record.product,
458
- infoPlist,
414
+ recipe,
459
415
  bundle: record.bundle,
460
416
  bundleId,
461
417
  displayName,
@@ -464,9 +420,7 @@ async function buildBundle(root, infoPlist, record, hosted, note, extras, progre
464
420
  note,
465
421
  progress,
466
422
  record: record.build,
467
- buildMachine: record.build.buildMachine,
468
- resources: extras.resources,
469
- assetCatalog: extras.assetCatalog
423
+ buildMachine: record.build.buildMachine
470
424
  });
471
425
  record.bundleId = built.bundleId;
472
426
  record.displayName = displayName;
@@ -528,6 +482,7 @@ function recordMacosBuild(root, build, compileSteps) {
528
482
  });
529
483
  }
530
484
  async function launchHere(root, record) {
485
+ await stopBundleInstances(root);
531
486
  const fd = openSync(join(workspaceLogsDir$1(root), "macos-supervisor.log"), "a");
532
487
  let child;
533
488
  try {
@@ -580,8 +535,31 @@ function launchPayload(root, record) {
580
535
  };
581
536
  }
582
537
  function macosCommand(program) {
583
- program.command("macos").description("Build and launch an owned Swift Package macOS Debug app.").option("--remote-build <value>", "Build on auto, local, or one named machine; a name refuses without fallback", parseBuildMachineOption).option("--json", "print one launch payload; build output goes to stderr").option("--remote <machine>", "run it on this approved remote Mac from remote.machines").action(async (options) => {
584
- const root = findProjectRoot$1(process.cwd());
538
+ program.command("macos").description("Build and launch an owned Swift Package macOS Debug app.").option("--remote-build <value>", "Build on auto, local, or one named machine; a name refuses without fallback", parseBuildMachineOption).option("--json", "print one launch or plan payload; build output goes to stderr").option("--plan", "validate the next SwiftPM Debug build without building or launching").option("--remote <machine>", "run it on this approved remote Mac from remote.machines").action(async (options) => {
539
+ const root = findProjectRoot(process.cwd());
540
+ if (options.plan) {
541
+ try {
542
+ if (!root) throw new Error("Run stim macos from the Swift Package directory.");
543
+ if (options.remote !== void 0) throw Object.assign(/* @__PURE__ */ new Error("--remote selects a launch host and does not apply to --plan."), { code: "STIM_BAD_ARG" });
544
+ const plan = planMacos(root, options.remoteBuild);
545
+ if (options.json) console.log(JSON.stringify(plan));
546
+ else {
547
+ console.log(phaseLine("plan", `macos ${plan.product}: SwiftPM Debug build, then stage and launch`));
548
+ console.log(phaseLine("build", `selection: ${plan.buildMachine}; worker availability is not checked`));
549
+ console.log(phaseLine("expect", "unknown: SwiftPM determines incremental work when the build runs"));
550
+ }
551
+ } catch (error) {
552
+ const failure = {
553
+ code: error.code ?? "STIM_BAD_ARG",
554
+ message: error instanceof Error ? error.message : String(error),
555
+ remedy: error.remedy ?? "Check the macOS project settings in stim guide macos."
556
+ };
557
+ console.error(failure.message);
558
+ if (options.json) console.log(JSON.stringify(failure));
559
+ process.exitCode = 1;
560
+ }
561
+ return;
562
+ }
585
563
  if (!root) throw new Error("Run stim macos from the Swift Package directory.");
586
564
  const record = await runMacos(root, console.error, options.remote, options.remoteBuild).catch((error) => {
587
565
  const remedy = error.remedy;
@@ -0,0 +1,2 @@
1
+ import { n as runMacos, t as macosCommand } from "./macos-ciyBdTY5.mjs";
2
+ export { macosCommand as default, runMacos };
@@ -1,2 +1,2 @@
1
- import { n as runMacosSupervisor, t as logLines } from "./run-vhtDgpHO.mjs";
1
+ import { n as runMacosSupervisor, t as logLines } from "./run-lAkle1-c.mjs";
2
2
  export { logLines, runMacosSupervisor };
@@ -1,13 +1,13 @@
1
- import { M as isOnMountedVolume, N as listMountedVolumes, _ as loadConfig$1, j as formatBytes } from "./config-CgYMahz7.mjs";
2
- import { a as unregister, n as readManifest } from "./cache-manifest-BI7ozfmH.mjs";
3
- import { Qt as pruneCache, Zt as discoverCaches, l as resolveBudget, pt as planCacheEmptying, r as cacheLabel, st as emptyCaches } from "./budget-DIhL2BKx.mjs";
4
- import { F as takeGcResults, I as canonicalPath, a as collectWorkspaceOutputs, i as collectOrphanedWorkspaces, o as deleteOrphanedWorkspaces, r as clearWorkspaceOutputs } from "./workspaces-xXItD8Dj.mjs";
5
- import { D as projectMaintenancePinned } from "./settings-CQyMElEP.mjs";
1
+ import { M as isOnMountedVolume, N as listMountedVolumes, _ as loadConfig$1, j as formatBytes } from "./config-DC5jEtd1.mjs";
2
+ import { D as projectMaintenancePinned } from "./settings-CxgngUZk.mjs";
3
+ import { a as unregister, n as readManifest } from "./cache-manifest-DiwKSyv9.mjs";
4
+ import { Nt as discoverCaches, Pt as pruneCache, l as resolveBudget, pt as planCacheEmptying, r as cacheLabel, st as emptyCaches } from "./budget-Dz-kyXLv.mjs";
5
+ import { I as takeGcResults, L as canonicalPath, a as collectWorkspaceOutputs, i as collectOrphanedWorkspaces, o as deleteOrphanedWorkspaces, r as clearWorkspaceOutputs } from "./workspaces-Djb2gfi9.mjs";
6
6
  import { r as createNdjsonWriter } from "./ndjson-LGZAMsqa.mjs";
7
- import { t as relaunchWithLogFile } from "./detached-entry-BLfcgc4O.mjs";
7
+ import { t as relaunchWithLogFile } from "./detached-entry-pB_IPfV4.mjs";
8
8
  import { t as resolveMaintenanceSettings } from "./settings-Djl-mpjX.mjs";
9
9
  import { r as due, t as capChildLog } from "./attempt-DW-mQqM7.mjs";
10
- import { a as recentUse, d as measureDisk, f as measurePressure, i as cacheEntryProtection, m as sizeScanDeferred, p as measureSizes, r as triggeringRoot, s as removeWorktrees, t as plannedMaintenance, u as cacheBlocked } from "./preview-D5V07Nrl.mjs";
10
+ import { a as recentUse, d as measureDisk, f as measurePressure, i as cacheEntryProtection, m as sizeScanDeferred, p as measureSizes, r as triggeringRoot, s as removeWorktrees, t as plannedMaintenance, u as cacheBlocked } from "./preview-BbSottmO.mjs";
11
11
  import { appendFileSync, existsSync, mkdirSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
12
12
  import { basename, join, resolve, sep } from "node:path";
13
13
  import { MAINTENANCE_LOG_NAME, maintenanceChildLogFile, maintenanceDir, maintenanceNdjsonFile, maintenanceRunClaims, maintenanceStateFile, readMaintenanceState, sharedCompilationCache, workspaceLogsDir } from "@stim-cli/core/state";
@@ -0,0 +1,148 @@
1
+ import { t as getExecutor } from "./exec-i8GDPwq9.mjs";
2
+ import { l as phaseLine } from "./command-output-Bt8ygHE7.mjs";
3
+ import { _ as loadConfig } from "./config-DC5jEtd1.mjs";
4
+ import { f as sharedCcache, x as workspaceLogsDir } from "./workspace-state-CR9X86xJ.mjs";
5
+ import { r as register } from "./cache-manifest-DiwKSyv9.mjs";
6
+ import { o as machineNumber } from "./budget-Dz-kyXLv.mjs";
7
+ import { readFileSync, realpathSync } from "node:fs";
8
+ import { isAbsolute, join } from "node:path";
9
+ import chalk from "chalk";
10
+ import { createHash } from "node:crypto";
11
+ const CCACHE_SLOPPINESS = "pch_defines,time_macros";
12
+ const STATS_LOG_FILE = "ccache-stats.log";
13
+ const CCACHE_UNAVAILABLE = {
14
+ status: "unavailable",
15
+ hits: null,
16
+ misses: null,
17
+ hitRatePercent: null
18
+ };
19
+ const CCACHE_NOT_RUN = {
20
+ status: "not-run",
21
+ hits: null,
22
+ misses: null,
23
+ hitRatePercent: null
24
+ };
25
+ function ccacheStatsLog(root) {
26
+ return join(workspaceLogsDir(root), STATS_LOG_FILE);
27
+ }
28
+ function ccacheMaxSize(config = loadConfig(), env = process.env) {
29
+ const { value, error } = machineNumber("caches.ccacheMaxGb", config, env);
30
+ return error || value === void 0 ? "5G" : `${value}G`;
31
+ }
32
+ function ccacheEnvironment({ binary, dir, workspaceRoot, statsLog, maxSize = "5G" }) {
33
+ return {
34
+ CMAKE_C_COMPILER_LAUNCHER: binary,
35
+ CMAKE_CXX_COMPILER_LAUNCHER: binary,
36
+ CCACHE_DIR: dir,
37
+ CCACHE_BASEDIR: workspaceRoot,
38
+ CCACHE_NOHASHDIR: "true",
39
+ CCACHE_SLOPPINESS,
40
+ CCACHE_MAXSIZE: maxSize,
41
+ CCACHE_STATSLOG: statsLog
42
+ };
43
+ }
44
+ function parseCcacheBinary(output) {
45
+ const first = String(output ?? "").split("\n")[0]?.trim();
46
+ if (!first || !isAbsolute(first)) return null;
47
+ return first;
48
+ }
49
+ const CMAKE_LAUNCHER = /CMAKE_(C|CXX)_COMPILER_LAUNCHER\b/;
50
+ function projectCmakeLauncher(source) {
51
+ if (typeof source !== "string") return null;
52
+ const match = CMAKE_LAUNCHER.exec(source);
53
+ return match ? `CMAKE_${match[1]}_COMPILER_LAUNCHER` : null;
54
+ }
55
+ const HIT_COUNTERS = /* @__PURE__ */ new Set(["direct_cache_hit", "preprocessed_cache_hit"]);
56
+ function parseCcacheStatsLog(text) {
57
+ if (typeof text !== "string") return null;
58
+ let hits = 0;
59
+ let misses = 0;
60
+ for (const raw of text.split("\n")) {
61
+ const line = raw.trim();
62
+ if (HIT_COUNTERS.has(line)) hits += 1;
63
+ else if (line === "cache_miss") misses += 1;
64
+ }
65
+ const total = hits + misses;
66
+ if (total === 0) return null;
67
+ return {
68
+ status: "reported",
69
+ hits,
70
+ misses,
71
+ hitRatePercent: Math.round(hits / total * 1e3) / 10
72
+ };
73
+ }
74
+ function readCcacheActivity(statsLog) {
75
+ let text;
76
+ try {
77
+ text = readFileSync(statsLog, "utf-8");
78
+ } catch {
79
+ return CCACHE_UNAVAILABLE;
80
+ }
81
+ return parseCcacheStatsLog(text) ?? CCACHE_UNAVAILABLE;
82
+ }
83
+ function ccacheActivityLine(activity) {
84
+ if (activity.status === "reported") return `${activity.hits} hits / ${activity.misses} misses (${activity.hitRatePercent}%)`;
85
+ if (activity.status === "not-run") return "not run; artifact cache supplied the app";
86
+ return "unavailable; no C++ compile went through ccache";
87
+ }
88
+ function lookupCcache() {
89
+ try {
90
+ return parseCcacheBinary(getExecutor().findExecutable("ccache"));
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+ function readOrNull(file) {
96
+ try {
97
+ return readFileSync(file, "utf-8");
98
+ } catch {
99
+ return null;
100
+ }
101
+ }
102
+ function canonical(root) {
103
+ try {
104
+ return realpathSync(root);
105
+ } catch {
106
+ return root;
107
+ }
108
+ }
109
+ function resolveCcache({ root, dir = sharedCcache(), lookup = lookupCcache, onNote = (line) => console.error(line) }) {
110
+ const binary = lookup();
111
+ if (!binary) {
112
+ onNote(chalk.dim(phaseLine("cache", "ccache off (not installed; brew install ccache)")));
113
+ return null;
114
+ }
115
+ const declared = projectCmakeLauncher(readOrNull(join(root, "android", "app", "build.gradle")));
116
+ if (declared) {
117
+ onNote(chalk.dim(phaseLine("cache", `ccache off (android/app/build.gradle sets ${declared} itself)`)));
118
+ return null;
119
+ }
120
+ const statsLog = ccacheStatsLog(root);
121
+ register({
122
+ dir,
123
+ name: "ccache",
124
+ prune: "atomic",
125
+ note: "ccache keeps itself under CCACHE_MAXSIZE, so it is emptied whole or not at all"
126
+ });
127
+ onNote(chalk.dim(phaseLine("cache", `ccache on (${dir})`)));
128
+ return {
129
+ dir,
130
+ statsLog,
131
+ env: ccacheEnvironment({
132
+ binary,
133
+ dir,
134
+ workspaceRoot: canonical(root),
135
+ statsLog,
136
+ maxSize: ccacheMaxSize()
137
+ })
138
+ };
139
+ }
140
+ //#endregion
141
+ //#region src/offload/manifest.ts
142
+ function manifestDigest(entries) {
143
+ const hash = createHash("sha256");
144
+ for (const entry of entries.toSorted((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0)) hash.update(`${entry.path}\0${entry.kind}\0${entry.sha256}\n`);
145
+ return hash.digest("hex");
146
+ }
147
+ //#endregion
148
+ export { projectCmakeLauncher as a, ccacheActivityLine as i, CCACHE_NOT_RUN as n, readCcacheActivity as o, CCACHE_UNAVAILABLE as r, resolveCcache as s, manifestDigest as t };