stim 1.14.0 → 1.16.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 (152) hide show
  1. package/README.md +2 -0
  2. package/dist/activity-BxwdD81S.mjs +609 -0
  3. package/dist/agent-device-usage-output-Dpih1Tfa.mjs +411 -0
  4. package/dist/{android-d6rGq1pA.mjs → android-B_NumVyQ.mjs} +169 -81
  5. package/dist/{android-LbPFRWVL.mjs → android-Ift4kVvt.mjs} +517 -413
  6. package/dist/android-cas-8U4DPqeR.mjs +167 -0
  7. package/dist/android-cas-compiler.mjs +2 -2
  8. package/dist/{android-XpvCrV7q.mjs → android-r2rBL8kV.mjs} +2 -2
  9. package/dist/{app-install-BpgSgkJj.mjs → app-install-CKWdbXIX.mjs} +128 -151
  10. package/dist/attempt-Bk2ouQVL.mjs +39 -0
  11. package/dist/budget-DjrURfQn.mjs +2700 -0
  12. package/dist/{build-plan-Dcr-3ie0.mjs → build-plan-DjeSb2Xl.mjs} +192 -653
  13. package/dist/build-slots-rUk77xqh.mjs +132 -0
  14. package/dist/{cache-manifest-C68QQ0ua.mjs → cache-manifest-DnUHBJaU.mjs} +2 -2
  15. package/dist/cache-manifest.mjs +1 -1
  16. package/dist/{chrome-BPCiC3ZX.mjs → chrome-BrcVWQyD.mjs} +1 -1
  17. package/dist/cli-BkYZ_6hy.mjs +51 -0
  18. package/dist/cli.mjs +6 -42
  19. package/dist/client-BTY686R6.mjs +1368 -0
  20. package/dist/collector-run.mjs +9 -195
  21. package/dist/{command-output-DVcpw6eE.mjs → command-output-DnJMdEY-.mjs} +1 -1
  22. package/dist/{config-lvc7d3C2.mjs → config-D0DbpZtM.mjs} +28 -29
  23. package/dist/{created-devices-CllH_8eb.mjs → created-devices-D5owjN4C.mjs} +2 -2
  24. package/dist/{dependency-state-DsT7aKeo.mjs → dependency-state-B6cMXZab.mjs} +2 -2
  25. package/dist/{deps-D9IcKqXS.mjs → deps-urbmfXig.mjs} +3 -3
  26. package/dist/{detached-entry-DJHoca49.mjs → detached-entry-CiTEgMR1.mjs} +1 -1
  27. package/dist/dev-client-CroAIjjj.mjs +43 -0
  28. package/dist/{device-CjuuAJjQ.mjs → device-DZQjF7H5.mjs} +8 -7
  29. package/dist/device-capacity-BHwxNBlu.mjs +136 -0
  30. package/dist/device-host-worker.d.mts +1 -0
  31. package/dist/device-host-worker.mjs +964 -0
  32. package/dist/device-ios-BadmeL2V.mjs +381 -0
  33. package/dist/{device-lease-5c3WrVRm.mjs → device-lease-D-hLqx1b.mjs} +43 -36
  34. package/dist/{device-pool-BiyDyPP-.mjs → device-lease-run-CqjShqWW.mjs} +6 -126
  35. package/dist/device-pool-CUaEWMMm.mjs +125 -0
  36. package/dist/{device-remote-D87zEzaq.mjs → device-remote-D5WVWqOq.mjs} +69 -163
  37. package/dist/{doctor-x9pnU9fq.mjs → doctor-Cimf-gGB.mjs} +241 -103
  38. package/dist/{error-diagnostics-C5HzcwCW.mjs → error-diagnostics-B9L4Ae0x.mjs} +15 -18
  39. package/dist/{exec-DK8KaVHK.mjs → exec-CaErVv7t.mjs} +5 -1
  40. package/dist/{gc-ko6mUAYD.mjs → gc-Bqy4bjEu.mjs} +599 -108
  41. package/dist/{android-cas-iZK3DOCr.mjs → gradle-BsO1MdsH.mjs} +8 -294
  42. package/dist/{guide-6R0VNFqI.mjs → guide-B_uyKTxW.mjs} +2511 -239
  43. package/dist/{guide-status-BZrFPIA_.mjs → guide-status-CjEZMAD4.mjs} +3 -3
  44. package/dist/hosted-client-a-WmqE2L.mjs +197 -0
  45. package/dist/hosted-ios-CIWelIqf.mjs +220 -0
  46. package/dist/hosted-logs-D5g041Q3.mjs +187 -0
  47. package/dist/hosted-macos-BSZyIb3y.mjs +135 -0
  48. package/dist/idle-DYVymG92.mjs +1099 -0
  49. package/dist/idle-shutdown-CTsDnAde.mjs +122 -0
  50. package/dist/in-use-DvBw0Kxo.mjs +130 -0
  51. package/dist/{ios-BwDPrnYQ.mjs → ios-BaInn3sW.mjs} +201 -10
  52. package/dist/ios-Cr1h5gnO.mjs +189 -0
  53. package/dist/{ios-P1f5nm2n.mjs → ios-aq3QoGI3.mjs} +1159 -633
  54. package/dist/{ios-device-BiOsSVzd.mjs → ios-device-Ee7sDXfp.mjs} +1 -1
  55. package/dist/{ios-device-DGglU3E_.mjs → ios-device-FfCN_C8p.mjs} +12 -7
  56. package/dist/ios-state-DS5UpYTH.mjs +48 -0
  57. package/dist/{launch-verify-Deg4tB3Z.mjs → launch-verify-2DBRizjo.mjs} +5 -5
  58. package/dist/logs-CHEVK8zD.mjs +371 -0
  59. package/dist/machines-BIBUdhpj.mjs +265 -0
  60. package/dist/macos-CSYEAFmF.mjs +473 -0
  61. package/dist/macos-run.d.mts +5 -0
  62. package/dist/macos-run.mjs +2 -0
  63. package/dist/maintenance-run.d.mts +4 -0
  64. package/dist/maintenance-run.mjs +254 -0
  65. package/dist/{metro-CcEo8Fl8.mjs → metro-BeK1ZPz1.mjs} +20 -120
  66. package/dist/metro-gateway-BJ-rxQAB.mjs +84 -0
  67. package/dist/{named-ports-Blg8IxOh.mjs → named-ports-Bk_YXEmE.mjs} +6 -59
  68. package/dist/native-run-NaBrRFtQ.mjs +147 -0
  69. package/dist/{native-runtime-DjBHRg5m.mjs → native-runtime-DBzRnEKS.mjs} +9 -5
  70. package/dist/{ndjson-CDY9IkVC.mjs → ndjson-PclOIwVY.mjs} +2 -2
  71. package/dist/offload-worker.d.mts +122 -0
  72. package/dist/offload-worker.mjs +606 -0
  73. package/dist/{ownership-DyYDF5ww.mjs → ownership-DiA16AsN.mjs} +3 -2
  74. package/dist/ownership-hCkPzGmr.mjs +571 -0
  75. package/dist/{page-BHUzTDFt.mjs → page-QF_Ke10s.mjs} +7 -2
  76. package/dist/{ports-BguS83ex.mjs → ports-R2k4Knz3.mjs} +3 -3
  77. package/dist/prebuild-D2fsca_Z.mjs +213 -0
  78. package/dist/preview-DhVbvPAZ.mjs +318 -0
  79. package/dist/process-identity-BmRm1qV0.mjs +12 -0
  80. package/dist/{project-CWlvEaeN.mjs → project-Du91Ilvc.mjs} +74 -19
  81. package/dist/pull-request-pxnDCQzn.mjs +322 -0
  82. package/dist/pull-requests.d.mts +120 -0
  83. package/dist/pull-requests.mjs +2 -0
  84. package/dist/recordings-BIXOzVnr.mjs +37 -0
  85. package/dist/{reload-BiniwsSZ.mjs → reload-rM9jV1fz.mjs} +109 -24
  86. package/dist/{remote-cache-CcR6o6lI.mjs → remote-cache-C8-V13XN.mjs} +5 -5
  87. package/dist/run-f4vI6EnK.mjs +119 -0
  88. package/dist/{server-bare-DGfgyJ5J.mjs → server-bare-CpPGmnmO.mjs} +33 -15
  89. package/dist/server-expo-CVqO2c35.mjs +2 -0
  90. package/dist/{server-expo-BVuwQ65v.mjs → server-expo-MC0rHlOC.mjs} +8 -12
  91. package/dist/settings-BBpMcDbD.mjs +25 -0
  92. package/dist/{settings-B-fsC-Om.mjs → settings-ZkDzkzvB.mjs} +22 -10
  93. package/dist/settings-oTSkkNrM.mjs +1439 -0
  94. package/dist/settings.schema.json +845 -97
  95. package/dist/{simslim-DrDN4WuV.mjs → simslim-B8-7AoTI.mjs} +8 -132
  96. package/dist/{slot-launch-D5t8EiMf.mjs → slot-launch-B8VrHxn1.mjs} +11 -8
  97. package/dist/{spawn-claims-Drw_o-Fb.mjs → spawn-claims-D0XfSe8u.mjs} +1 -1
  98. package/dist/spawn-entry-jw19m8Nl.mjs +17 -0
  99. package/dist/stage-CzaiwFsI.mjs +143 -0
  100. package/dist/start-CX8Ig-U2.mjs +2 -0
  101. package/dist/{start-s4RXp1wy.mjs → start-ClDfwXa4.mjs} +116 -65
  102. package/dist/state-3DwSQIBK.mjs +41 -0
  103. package/dist/state-B4PQFXMW.d.mts +12 -0
  104. package/dist/{state-Dk9RVXI7.mjs → state-C1jB7Q8q.mjs} +70 -8
  105. package/dist/{state-DHqvsbqC.mjs → state-DcW6vOd_.mjs} +7 -4
  106. package/dist/stats-CEZ_i5je.mjs +77 -0
  107. package/dist/{status-BgAuxESg.mjs → status-BuvBFeII.mjs} +118 -20
  108. package/dist/{status-BsPAnfOI.mjs → status-Cs7VLg9D.mjs} +542 -283
  109. package/dist/status-DlKvVJBE.mjs +49 -0
  110. package/dist/stdout-reader-C8yjre1x.mjs +23 -0
  111. package/dist/stim-desktop-Cnz8CPnl.mjs +63 -0
  112. package/dist/stim-footprint.swift +32 -0
  113. package/dist/{stim-installations-CINXy_su.mjs → stim-installations-QMEI32v1.mjs} +1 -1
  114. package/dist/stop-B0Yxtmiy.mjs +48 -0
  115. package/dist/{stop-BzreOWJp.mjs → stop-Bffozsac.mjs} +83 -16
  116. package/dist/{stop-BWIF_6BK.mjs → stop-Dt_dM16A.mjs} +2 -2
  117. package/dist/stop-cause-CidxIqup.mjs +97 -0
  118. package/dist/supervisor-run.d.mts +43 -11
  119. package/dist/supervisor-run.mjs +363 -24
  120. package/dist/support-CAP8qDUF.mjs +316 -0
  121. package/dist/support-D4aYJniO.mjs +201 -0
  122. package/dist/teardown-CL6vDs2Y.mjs +727 -0
  123. package/dist/{xcode-Cp5KvK9x.mjs → toolchain-DkUflduf.mjs} +364 -14
  124. package/dist/trigger-Bemu8ytw.mjs +65 -0
  125. package/dist/trigger-CXts6qt1.mjs +2 -0
  126. package/dist/warm-progress-CpGv3Wb6.mjs +732 -0
  127. package/dist/{web-BsQs1WlO.mjs → web-DWUaMp8P.mjs} +37 -21
  128. package/dist/web-run.mjs +310 -13
  129. package/dist/workspace-process-lock-BL7Q0HCO.mjs +57 -0
  130. package/dist/workspace-state-B8-aJ1_5.mjs +371 -0
  131. package/dist/workspaces-BV4pdHFz.mjs +306 -0
  132. package/dist/{worktree-UrQWXSeb.mjs → worktree-K-xj9Db0.mjs} +625 -256
  133. package/dist/worktree-jnG8Iph5.mjs +2 -0
  134. package/package.json +10 -5
  135. package/shim/bundle-response.cjs +28 -12
  136. package/dist/activity-CYVDcrt3.mjs +0 -356
  137. package/dist/budget-CGDkhvv_.mjs +0 -1745
  138. package/dist/build-progress-DxKpwnaS.mjs +0 -247
  139. package/dist/idle-DXtx3RbX.mjs +0 -191
  140. package/dist/in-use-DlqBDKqY.mjs +0 -249
  141. package/dist/logs-Civ4gbBH.mjs +0 -486
  142. package/dist/merge-state-ytFQCeh4.mjs +0 -262
  143. package/dist/server-expo-DIHDhvGg.mjs +0 -2
  144. package/dist/settings-D61iNOsB.mjs +0 -629
  145. package/dist/start-Cetfvy8l.mjs +0 -2
  146. package/dist/stats-CFpFGlJV.mjs +0 -62
  147. package/dist/stats-CX1Z8Tca.mjs +0 -368
  148. package/dist/stim-desktop-CXt8-Z3J.mjs +0 -40
  149. package/dist/stop-cause-hjGBOZTG.mjs +0 -1231
  150. package/dist/worktree-BVrHsYZG.mjs +0 -752
  151. package/dist/worktree-CHWWvm5v.mjs +0 -2
  152. package/dist/{metro-store-DzeWkfqW.mjs → metro-store-CDDZHtPl.mjs} +1 -1
@@ -1,16 +1,145 @@
1
- import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
2
- import { r as register } from "./cache-manifest-C68QQ0ua.mjs";
3
- import { O as workspaceDerivedData, T as sharedCompilationCache } from "./metro-CcEo8Fl8.mjs";
4
- import { f as resolvePackageJson } from "./project-CWlvEaeN.mjs";
5
- import { a as spawnDeclared } from "./spawn-claims-Drw_o-Fb.mjs";
1
+ import { t as getExecutor } from "./exec-CaErVv7t.mjs";
2
+ import { r as register } from "./cache-manifest-DnUHBJaU.mjs";
6
3
  import { t as createLineReader } from "./process-output-Fpl8PYi8.mjs";
7
- import { a as formatElapsed, l as phaseLine } from "./command-output-DVcpw6eE.mjs";
8
- import { G as resolveOptimizations } from "./settings-D61iNOsB.mjs";
9
- import { t as cleanLine } from "./server-expo-BVuwQ65v.mjs";
10
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
11
- import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ import { a as formatElapsed, l as phaseLine } from "./command-output-DnJMdEY-.mjs";
5
+ import { Z as resolveOptimizations } from "./settings-oTSkkNrM.mjs";
6
+ import { p as resolvePackageJson } from "./project-Du91Ilvc.mjs";
7
+ import { _ as workspaceDerivedData, f as sharedCcache$1, p as sharedCompilationCache$1, x as workspaceLogsDir$1 } from "./workspace-state-B8-aJ1_5.mjs";
8
+ import { a as spawnDeclared } from "./spawn-claims-D0XfSe8u.mjs";
9
+ import { o as androidHome } from "./android-B_NumVyQ.mjs";
10
+ import { t as cleanLine } from "./server-expo-MC0rHlOC.mjs";
11
+ import { createRequire } from "node:module";
12
12
  import { createHash } from "node:crypto";
13
+ import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
14
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
15
+ import { stimBuildDigest } from "@stim-cli/core/state";
16
+ import { fileURLToPath } from "node:url";
13
17
  import chalk from "chalk";
18
+ const CCACHE_SLOPPINESS = "pch_defines,time_macros";
19
+ const STATS_LOG_FILE = "ccache-stats.log";
20
+ const CCACHE_UNAVAILABLE = {
21
+ status: "unavailable",
22
+ hits: null,
23
+ misses: null,
24
+ hitRatePercent: null
25
+ };
26
+ const CCACHE_NOT_RUN = {
27
+ status: "not-run",
28
+ hits: null,
29
+ misses: null,
30
+ hitRatePercent: null
31
+ };
32
+ function ccacheStatsLog(root) {
33
+ return join(workspaceLogsDir$1(root), STATS_LOG_FILE);
34
+ }
35
+ function ccacheEnvironment({ binary, dir, workspaceRoot, statsLog }) {
36
+ return {
37
+ CMAKE_C_COMPILER_LAUNCHER: binary,
38
+ CMAKE_CXX_COMPILER_LAUNCHER: binary,
39
+ CCACHE_DIR: dir,
40
+ CCACHE_BASEDIR: workspaceRoot,
41
+ CCACHE_NOHASHDIR: "true",
42
+ CCACHE_SLOPPINESS,
43
+ CCACHE_MAXSIZE: "5G",
44
+ CCACHE_STATSLOG: statsLog
45
+ };
46
+ }
47
+ function parseCcacheBinary(output) {
48
+ const first = String(output ?? "").split("\n")[0]?.trim();
49
+ if (!first || !isAbsolute(first)) return null;
50
+ return first;
51
+ }
52
+ const CMAKE_LAUNCHER = /CMAKE_(C|CXX)_COMPILER_LAUNCHER\b/;
53
+ function projectCmakeLauncher(source) {
54
+ if (typeof source !== "string") return null;
55
+ const match = CMAKE_LAUNCHER.exec(source);
56
+ return match ? `CMAKE_${match[1]}_COMPILER_LAUNCHER` : null;
57
+ }
58
+ const HIT_COUNTERS = /* @__PURE__ */ new Set(["direct_cache_hit", "preprocessed_cache_hit"]);
59
+ function parseCcacheStatsLog(text) {
60
+ if (typeof text !== "string") return null;
61
+ let hits = 0;
62
+ let misses = 0;
63
+ for (const raw of text.split("\n")) {
64
+ const line = raw.trim();
65
+ if (HIT_COUNTERS.has(line)) hits += 1;
66
+ else if (line === "cache_miss") misses += 1;
67
+ }
68
+ const total = hits + misses;
69
+ if (total === 0) return null;
70
+ return {
71
+ status: "reported",
72
+ hits,
73
+ misses,
74
+ hitRatePercent: Math.round(hits / total * 1e3) / 10
75
+ };
76
+ }
77
+ function readCcacheActivity(statsLog) {
78
+ let text;
79
+ try {
80
+ text = readFileSync(statsLog, "utf-8");
81
+ } catch {
82
+ return CCACHE_UNAVAILABLE;
83
+ }
84
+ return parseCcacheStatsLog(text) ?? CCACHE_UNAVAILABLE;
85
+ }
86
+ function ccacheActivityLine(activity) {
87
+ if (activity.status === "reported") return `${activity.hits} hits / ${activity.misses} misses (${activity.hitRatePercent}%)`;
88
+ if (activity.status === "not-run") return "not run; artifact cache supplied the app";
89
+ return "unavailable; no C++ compile went through ccache";
90
+ }
91
+ function lookupCcache() {
92
+ try {
93
+ return parseCcacheBinary(getExecutor().findExecutable("ccache"));
94
+ } catch {
95
+ return null;
96
+ }
97
+ }
98
+ function readOrNull(file) {
99
+ try {
100
+ return readFileSync(file, "utf-8");
101
+ } catch {
102
+ return null;
103
+ }
104
+ }
105
+ function canonical(root) {
106
+ try {
107
+ return realpathSync(root);
108
+ } catch {
109
+ return root;
110
+ }
111
+ }
112
+ function resolveCcache({ root, dir = sharedCcache$1(), lookup = lookupCcache, onNote = (line) => console.error(line) }) {
113
+ const binary = lookup();
114
+ if (!binary) {
115
+ onNote(chalk.dim(phaseLine("cache", "ccache off (not installed; brew install ccache)")));
116
+ return null;
117
+ }
118
+ const declared = projectCmakeLauncher(readOrNull(join(root, "android", "app", "build.gradle")));
119
+ if (declared) {
120
+ onNote(chalk.dim(phaseLine("cache", `ccache off (android/app/build.gradle sets ${declared} itself)`)));
121
+ return null;
122
+ }
123
+ const statsLog = ccacheStatsLog(root);
124
+ register({
125
+ dir,
126
+ name: "ccache",
127
+ prune: "atomic",
128
+ note: "ccache keeps itself under CCACHE_MAXSIZE, so it is emptied whole or not at all"
129
+ });
130
+ onNote(chalk.dim(phaseLine("cache", `ccache on (${dir})`)));
131
+ return {
132
+ dir,
133
+ statsLog,
134
+ env: ccacheEnvironment({
135
+ binary,
136
+ dir,
137
+ workspaceRoot: canonical(root),
138
+ statsLog
139
+ })
140
+ };
141
+ }
142
+ //#endregion
14
143
  //#region src/engine/bundler.ts
15
144
  const COCOAPODS_SPEC = /^ {4}cocoapods \(/m;
16
145
  function bundlerPin(root) {
@@ -415,7 +544,7 @@ function parseXcodeMajor(output) {
415
544
  function detectXcodeMajor(exec = null) {
416
545
  return parseXcodeMajor((exec || getExecutor()).runQuiet("xcodebuild -version", { timeoutMs: 1e4 }));
417
546
  }
418
- function resolveCompilationCacheSettings({ root, derivedDataPath, exec = null, casPath = sharedCompilationCache(), optimizations = resolveOptimizations({}, {}).ios, onNote = (line) => console.error(line) }) {
547
+ function resolveCompilationCacheSettings({ root, derivedDataPath, exec = null, casPath = sharedCompilationCache$1(), optimizations = resolveOptimizations({}, {}).ios, onNote = (line) => console.error(line) }) {
419
548
  const xcodeMajor = detectXcodeMajor(exec);
420
549
  const ccache = ccacheEnabled(readPodfileProperties(root));
421
550
  const probe = xcodeMajor !== null && xcodeMajor >= 26 && !ccache && optimizations.compilationCache && optimizations.swiftCompilationCache !== false;
@@ -645,7 +774,7 @@ function compilationCacheActivityLine(activity) {
645
774
  if (activity.status === "not-run") return "not run; artifact cache supplied the app";
646
775
  return "unavailable; Xcode did not report reliable statistics";
647
776
  }
648
- async function buildIos({ root, udid = null, logWriter, project = null, scheme = null, configuration = "Debug", sdk = "iphonesimulator", destination = null, derivedDataPath = null, extraArgs = [], compilationCache = void 0, optimizations = resolveOptimizations({}, {}).ios, now = () => Date.now(), exec = null, heartbeatMs = HEARTBEAT_INTERVAL_MS, estimateMs = null, onHeartbeat = (line) => console.error(line), onNote = (line) => console.error(line) }) {
777
+ async function buildIos({ root, udid = null, logWriter, project = null, scheme = null, configuration = "Debug", sdk = "iphonesimulator", destination = null, arch = null, derivedDataPath = null, extraArgs = [], compilationCache = void 0, optimizations = resolveOptimizations({}, {}).ios, now = () => Date.now(), exec = null, heartbeatMs = HEARTBEAT_INTERVAL_MS, estimateMs = null, onHeartbeat = (line) => console.error(line), onNote = (line) => console.error(line) }) {
649
778
  if (!root || typeof root !== "string") throw new TypeError("buildIos requires {root}");
650
779
  if (!logWriter || typeof logWriter.write !== "function") throw new TypeError("buildIos requires {logWriter} with a write() method");
651
780
  if (!udid && !destination) throw new TypeError("buildIos requires {udid} (or an explicit {destination})");
@@ -695,13 +824,18 @@ async function buildIos({ root, udid = null, logWriter, project = null, scheme =
695
824
  });
696
825
  }
697
826
  const buildScheme = selected.scheme;
698
- const buildSettings = compilationCache === void 0 ? resolveCompilationCacheSettings({
827
+ const cacheSettings = compilationCache === void 0 ? resolveCompilationCacheSettings({
699
828
  root,
700
829
  derivedDataPath: dd,
701
830
  exec: executor,
702
831
  onNote,
703
832
  optimizations
704
833
  }) : compilationCache || [];
834
+ const buildSettings = arch ? [
835
+ ...cacheSettings,
836
+ `ARCHS=${arch}`,
837
+ "ONLY_ACTIVE_ARCH=YES"
838
+ ] : cacheSettings;
705
839
  const args = xcodebuildArgs({
706
840
  project: resolvedTarget,
707
841
  scheme: buildScheme,
@@ -941,4 +1075,220 @@ async function buildIos({ root, udid = null, logWriter, project = null, scheme =
941
1075
  };
942
1076
  }
943
1077
  //#endregion
944
- export { compilationCacheActivityLine as a, readBundleExecutable as c, startBuildHeartbeat as d, tailLines as f, podInstallCommand as h, ccacheEnabled as i, readBundleId as l, bundlerPin as m, HEARTBEAT_INTERVAL_MS as n, detectXcodeMajor as o, describeDiagnostic as p, buildIos as r, discoverXcodeProject as s, COMPILATION_CACHE_NOT_RUN as t, resolveScheme as u };
1078
+ //#region src/offload/manifest.ts
1079
+ function manifestDigest(entries) {
1080
+ const hash = createHash("sha256");
1081
+ 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`);
1082
+ return hash.digest("hex");
1083
+ }
1084
+ //#endregion
1085
+ //#region src/offload/toolchain.ts
1086
+ const distDir = dirname(fileURLToPath(import.meta.url));
1087
+ function quiet(file, args) {
1088
+ return getExecutor().runFileQuiet(file, args, { timeoutMs: 2e4 });
1089
+ }
1090
+ function iosToolchain() {
1091
+ const xcode = quiet("xcodebuild", ["-version"]);
1092
+ return {
1093
+ stimBuild: stimBuildDigest(distDir),
1094
+ arch: process.arch,
1095
+ xcode: xcode ? xcode.trim().replace(/\n/g, " / ") : null,
1096
+ simulatorSdk: quiet("xcrun", [
1097
+ "--sdk",
1098
+ "iphonesimulator",
1099
+ "--show-sdk-version"
1100
+ ])?.trim() ?? null,
1101
+ cocoapods: quiet("pod", ["--version"])?.trim().split("\n").pop()?.trim() ?? null
1102
+ };
1103
+ }
1104
+ function macosToolchain() {
1105
+ const xcode = quiet("xcodebuild", ["-version"]);
1106
+ return {
1107
+ stimBuild: stimBuildDigest(distDir),
1108
+ arch: process.arch,
1109
+ xcode: xcode ? xcode.trim().replace(/\n/g, " / ") : null,
1110
+ macosSdk: quiet("xcrun", [
1111
+ "--sdk",
1112
+ "macosx",
1113
+ "--show-sdk-version"
1114
+ ])?.trim() ?? null
1115
+ };
1116
+ }
1117
+ /** The major version in a JDK's `release` file, as `JAVA_VERSION="17.0.19"` gives it. */
1118
+ function jdkMajor(release) {
1119
+ return /^JAVA_VERSION="(\d+)/m.exec(release)?.[1] ?? null;
1120
+ }
1121
+ function releaseMajor(home) {
1122
+ try {
1123
+ return jdkMajor(readFileSync(join(home, "release"), "utf8"));
1124
+ } catch {
1125
+ return null;
1126
+ }
1127
+ }
1128
+ /**
1129
+ * The JDK Gradle's wrapper picks: `JAVA_HOME`, else the `java` on PATH, which is the macOS `/usr/bin/java`
1130
+ * stub (resolved through `java_home`) unless a real JDK comes first.
1131
+ */
1132
+ function localJdk(env = process.env) {
1133
+ if (env.JAVA_HOME) return releaseMajor(env.JAVA_HOME);
1134
+ const java = getExecutor().findExecutable("java");
1135
+ if (java) try {
1136
+ const fromPath = releaseMajor(dirname(dirname(realpathSync(java))));
1137
+ if (fromPath) return fromPath;
1138
+ } catch {}
1139
+ const home = quiet("/usr/libexec/java_home", [])?.trim();
1140
+ return home ? releaseMajor(home) : null;
1141
+ }
1142
+ function androidToolchain() {
1143
+ return {
1144
+ stimBuild: stimBuildDigest(distDir),
1145
+ arch: process.arch,
1146
+ jdk: localJdk()
1147
+ };
1148
+ }
1149
+ /** `ndkVersion`, `buildTools` and `compileSdk` from React Native's `gradle/libs.versions.toml`. */
1150
+ function parseAndroidRequirements(catalog) {
1151
+ const value = (key) => new RegExp(`^${key}\\s*=\\s*"([^"]+)"`, "m").exec(catalog)?.[1] ?? null;
1152
+ return {
1153
+ ndk: value("ndkVersion"),
1154
+ buildTools: value("buildTools"),
1155
+ compileSdk: value("compileSdk")
1156
+ };
1157
+ }
1158
+ function androidRequirements(projectRoot) {
1159
+ try {
1160
+ const pkg = createRequire(join(projectRoot, "package.json")).resolve("react-native/package.json");
1161
+ return parseAndroidRequirements(readFileSync(join(dirname(pkg), "gradle", "libs.versions.toml"), "utf8"));
1162
+ } catch {
1163
+ return {
1164
+ ndk: null,
1165
+ buildTools: null,
1166
+ compileSdk: null
1167
+ };
1168
+ }
1169
+ }
1170
+ /** Runtime identifiers that have at least one available iPhone simulator, from `simctl list devices -j`. */
1171
+ function iphoneRuntimes(listed) {
1172
+ const devices = listed?.devices;
1173
+ if (!devices || typeof devices !== "object") return [];
1174
+ return Object.entries(devices).filter(([, list]) => (Array.isArray(list) ? list : []).some((device) => device.isAvailable !== false && typeof device.name === "string" && device.name.startsWith("iPhone"))).map(([runtime]) => runtime).toSorted();
1175
+ }
1176
+ function listDir(path) {
1177
+ try {
1178
+ return readdirSync(path).filter((entry) => !entry.startsWith(".")).toSorted();
1179
+ } catch {
1180
+ return null;
1181
+ }
1182
+ }
1183
+ function sdkPackages() {
1184
+ const sdk = androidHome();
1185
+ const platforms = listDir(join(sdk, "platforms"));
1186
+ if (!platforms) return null;
1187
+ return {
1188
+ ndk: listDir(join(sdk, "ndk")) ?? [],
1189
+ buildTools: listDir(join(sdk, "build-tools")) ?? [],
1190
+ platforms
1191
+ };
1192
+ }
1193
+ function workerToolchain() {
1194
+ let listed = null;
1195
+ try {
1196
+ listed = JSON.parse(quiet("xcrun", [
1197
+ "simctl",
1198
+ "list",
1199
+ "devices",
1200
+ "available",
1201
+ "-j"
1202
+ ]) ?? "null");
1203
+ } catch {}
1204
+ return {
1205
+ ...iosToolchain(),
1206
+ macosSdk: quiet("xcrun", [
1207
+ "--sdk",
1208
+ "macosx",
1209
+ "--show-sdk-version"
1210
+ ])?.trim() ?? null,
1211
+ bundler: quiet("bundle", ["--version"])?.trim() || null,
1212
+ runtimes: iphoneRuntimes(listed),
1213
+ jdk: localJdk(),
1214
+ androidSdk: sdkPackages()
1215
+ };
1216
+ }
1217
+ /** The API level of an SDK `platforms/` directory: `android-37.0` and `android-37` are both 37. */
1218
+ const platformLevel = (dir) => dir.replace(/^android-/, "").split(".")[0];
1219
+ function androidMismatches(local, requires, worker) {
1220
+ const out = [];
1221
+ if (!local.jdk || worker.jdk !== local.jdk) out.push({
1222
+ code: "jdk",
1223
+ reason: `JDK ${worker.jdk ?? "none"} there, ${local.jdk ?? "none"} here`
1224
+ });
1225
+ const sdk = worker.androidSdk;
1226
+ if (!sdk) return [...out, {
1227
+ code: "android-sdk",
1228
+ reason: "no Android SDK there"
1229
+ }];
1230
+ if (requires.ndk && !sdk.ndk.includes(requires.ndk)) out.push({
1231
+ code: "ndk",
1232
+ reason: `no NDK ${requires.ndk} there`
1233
+ });
1234
+ if (requires.buildTools && !sdk.buildTools.includes(requires.buildTools)) out.push({
1235
+ code: "build-tools",
1236
+ reason: `no build-tools ${requires.buildTools} there`
1237
+ });
1238
+ if (requires.compileSdk && !sdk.platforms.some((dir) => platformLevel(dir) === requires.compileSdk)) out.push({
1239
+ code: "compile-sdk",
1240
+ reason: `no platform android-${requires.compileSdk} there`
1241
+ });
1242
+ return out;
1243
+ }
1244
+ /** Why a build machine cannot build like this Mac; empty when it can. */
1245
+ function toolchainMismatches(target, worker) {
1246
+ const { local } = target;
1247
+ const out = [];
1248
+ if (!local.stimBuild || worker.stimBuild !== local.stimBuild) out.push({
1249
+ code: "stim-build",
1250
+ reason: `Stim build ${worker.stimBuild ?? "unknown"} there, ${local.stimBuild ?? "unknown"} here`
1251
+ });
1252
+ if (worker.arch !== local.arch) out.push({
1253
+ code: "arch",
1254
+ reason: `CPU ${worker.arch} there, ${local.arch} here`
1255
+ });
1256
+ if (target.platform === "android") return [...out, ...androidMismatches(target.local, target.requires, worker)];
1257
+ if (target.platform === "macos") {
1258
+ const macos = target.local;
1259
+ if (!macos.xcode || worker.xcode !== macos.xcode) out.push({
1260
+ code: "xcode",
1261
+ reason: `Xcode ${worker.xcode} there, ${macos.xcode} here`
1262
+ });
1263
+ if (!macos.macosSdk || worker.macosSdk !== macos.macosSdk) out.push({
1264
+ code: "macos-sdk",
1265
+ reason: `macOS SDK ${worker.macosSdk} there, ${macos.macosSdk} here`
1266
+ });
1267
+ return out;
1268
+ }
1269
+ const ios = target.local;
1270
+ if (!ios.xcode || worker.xcode !== ios.xcode) out.push({
1271
+ code: "xcode",
1272
+ reason: `Xcode ${worker.xcode} there, ${ios.xcode} here`
1273
+ });
1274
+ if (!ios.simulatorSdk || worker.simulatorSdk !== ios.simulatorSdk) out.push({
1275
+ code: "simulator-sdk",
1276
+ reason: `simulator SDK ${worker.simulatorSdk} there, ${ios.simulatorSdk} here`
1277
+ });
1278
+ if (target.cocoapodsPinned) {
1279
+ if (!worker.bundler) out.push({
1280
+ code: "bundler",
1281
+ reason: "no Bundler there to run the CocoaPods this project's Gemfile.lock pins"
1282
+ });
1283
+ } else if (worker.cocoapods !== ios.cocoapods) out.push({
1284
+ code: "cocoapods",
1285
+ reason: `CocoaPods ${worker.cocoapods} there, ${ios.cocoapods} here`
1286
+ });
1287
+ if (target.runtime && !worker.runtimes.includes(target.runtime)) out.push({
1288
+ code: "runtime",
1289
+ reason: `no iPhone simulator on ${target.runtime} there`
1290
+ });
1291
+ return out;
1292
+ }
1293
+ //#endregion
1294
+ export { podInstallCommand as C, projectCmakeLauncher as D, ccacheActivityLine as E, readCcacheActivity as O, bundlerPin as S, CCACHE_UNAVAILABLE as T, readBundleId as _, toolchainMismatches as a, tailLines as b, COMPILATION_CACHE_NOT_RUN as c, buildIos as d, ccacheEnabled as f, readBundleExecutable as g, discoverXcodeProject as h, macosToolchain as i, resolveCcache as k, COMPILATION_CACHE_UNAVAILABLE as l, detectXcodeMajor as m, androidToolchain as n, workerToolchain as o, compilationCacheActivityLine as p, iosToolchain as r, manifestDigest as s, androidRequirements as t, HEARTBEAT_INTERVAL_MS as u, resolveScheme as v, CCACHE_NOT_RUN as w, describeDiagnostic as x, startBuildHeartbeat as y };
@@ -0,0 +1,65 @@
1
+ import { t as getExecutor } from "./exec-CaErVv7t.mjs";
2
+ import { n as windowsLauncherArgs } from "./detached-entry-CiTEgMR1.mjs";
3
+ import { t as resolveMaintenanceSettings } from "./settings-BBpMcDbD.mjs";
4
+ import { n as stampAttempt, r as due, t as capChildLog } from "./attempt-Bk2ouQVL.mjs";
5
+ import { t as spawnEntry } from "./spawn-entry-jw19m8Nl.mjs";
6
+ import { closeSync, openSync } from "node:fs";
7
+ import { maintenanceChildLogFile, maintenanceRunClaims, readMaintenanceAttempt, readMaintenanceState } from "@stim-cli/core/state";
8
+ import { readClaimSet } from "@stim-cli/core/ownership-claim";
9
+ //#region src/maintenance/trigger.ts
10
+ function triggerMaintenance(trigger, { argv = process.argv.slice(2), platform = process.platform } = {}) {
11
+ try {
12
+ const env = process.env;
13
+ if ([
14
+ "guide",
15
+ "settings",
16
+ "help"
17
+ ].includes(argv[0] ?? "") || argv[0] === "gc" && argv.includes("--delete") || argv.some((arg) => [
18
+ "--help",
19
+ "-h",
20
+ "--version",
21
+ "-V"
22
+ ].includes(arg))) return;
23
+ if (env.STIM_MAINTENANCE_CHILD === "1" || (env.STIM_HOME || env.CI) && env.STIM_MAINTENANCE === void 0) return;
24
+ const settings = resolveMaintenanceSettings();
25
+ if (settings.mode === "off" || due(readMaintenanceState(), settings, Date.now(), readMaintenanceAttempt()).length === 0) return;
26
+ const claims = readClaimSet(maintenanceRunClaims());
27
+ if (claims.live.length || claims.unresolved.length) return;
28
+ stampAttempt(Date.now());
29
+ capChildLog();
30
+ const logFile = maintenanceChildLogFile();
31
+ const fd = openSync(logFile, "a");
32
+ try {
33
+ const cwd = process.cwd();
34
+ const entry = spawnEntry("maintenance-run");
35
+ const args = [trigger];
36
+ const launcher = platform === "win32" ? windowsLauncherArgs({
37
+ entry,
38
+ args,
39
+ cwd,
40
+ logFile
41
+ }) : null;
42
+ const child = getExecutor().spawn(launcher?.file ?? process.execPath, launcher?.args ?? [entry, ...args], {
43
+ cwd,
44
+ detached: true,
45
+ stdio: [
46
+ "ignore",
47
+ fd,
48
+ fd
49
+ ],
50
+ env: {
51
+ ...env,
52
+ STIM_MAINTENANCE_CHILD: "1",
53
+ ...launcher?.env
54
+ },
55
+ ...launcher ? { windowsHide: true } : {}
56
+ });
57
+ child.on?.("error", () => {});
58
+ child.unref?.();
59
+ } finally {
60
+ closeSync(fd);
61
+ }
62
+ } catch {}
63
+ }
64
+ //#endregion
65
+ export { triggerMaintenance as t };
@@ -0,0 +1,2 @@
1
+ import { t as triggerMaintenance } from "./trigger-Bemu8ytw.mjs";
2
+ export { triggerMaintenance };