stim 1.14.0 → 1.15.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 (130) hide show
  1. package/README.md +2 -0
  2. package/dist/{activity-CYVDcrt3.mjs → activity-B2-kb7k0.mjs} +281 -41
  3. package/dist/{android-XpvCrV7q.mjs → android-CYmq0jNi.mjs} +2 -2
  4. package/dist/{android-LbPFRWVL.mjs → android-Cu_L4RpL.mjs} +502 -407
  5. package/dist/{android-d6rGq1pA.mjs → android-Db2eEMaf.mjs} +152 -65
  6. package/dist/android-cas-PnKfAdB2.mjs +167 -0
  7. package/dist/android-cas-compiler.mjs +2 -2
  8. package/dist/{app-install-BpgSgkJj.mjs → app-install-CAAplXAt.mjs} +95 -161
  9. package/dist/{budget-CGDkhvv_.mjs → budget-CMiqghig.mjs} +1038 -73
  10. package/dist/{build-plan-Dcr-3ie0.mjs → build-plan-aeGMFX7e.mjs} +193 -653
  11. package/dist/build-progress-C2Jv1AtA.mjs +872 -0
  12. package/dist/build-slots-Df1ApSuH.mjs +127 -0
  13. package/dist/{cache-manifest-C68QQ0ua.mjs → cache-manifest-DnUHBJaU.mjs} +2 -2
  14. package/dist/cache-manifest.mjs +1 -1
  15. package/dist/{chrome-BPCiC3ZX.mjs → chrome-BrcVWQyD.mjs} +1 -1
  16. package/dist/cli-0cX5s4NM.mjs +45 -0
  17. package/dist/cli.mjs +6 -42
  18. package/dist/client-C2IS36Qf.mjs +1333 -0
  19. package/dist/collector-run.mjs +8 -7
  20. package/dist/{command-output-DVcpw6eE.mjs → command-output-CliHHn7a.mjs} +1 -1
  21. package/dist/{config-lvc7d3C2.mjs → config-D0DbpZtM.mjs} +28 -29
  22. package/dist/{created-devices-CllH_8eb.mjs → created-devices-BwVb3liH.mjs} +2 -2
  23. package/dist/{dependency-state-DsT7aKeo.mjs → dependency-state-BmsjKZ2H.mjs} +2 -2
  24. package/dist/{deps-D9IcKqXS.mjs → deps-BFlKbOIp.mjs} +3 -3
  25. package/dist/{detached-entry-DJHoca49.mjs → detached-entry-CiTEgMR1.mjs} +1 -1
  26. package/dist/dev-client-CjzLoNs0.mjs +80 -0
  27. package/dist/{device-CjuuAJjQ.mjs → device-BZ1IyS5A.mjs} +7 -7
  28. package/dist/device-capacity-DMuKC7nx.mjs +136 -0
  29. package/dist/device-host-worker.d.mts +1 -0
  30. package/dist/device-host-worker.mjs +769 -0
  31. package/dist/device-ios-DMQBUPus.mjs +381 -0
  32. package/dist/{device-lease-5c3WrVRm.mjs → device-lease-W5Pi1q38.mjs} +43 -36
  33. package/dist/{device-pool-BiyDyPP-.mjs → device-pool-B2r38YjS.mjs} +4 -4
  34. package/dist/{device-remote-D87zEzaq.mjs → device-remote-9ulPsdhY.mjs} +68 -162
  35. package/dist/{doctor-x9pnU9fq.mjs → doctor-BcE5xsBn.mjs} +191 -99
  36. package/dist/{error-diagnostics-C5HzcwCW.mjs → error-diagnostics-Cb0P1WLS.mjs} +12 -11
  37. package/dist/{exec-DK8KaVHK.mjs → exec-CaErVv7t.mjs} +5 -1
  38. package/dist/{gc-ko6mUAYD.mjs → gc-BuL1Genr.mjs} +429 -101
  39. package/dist/{android-cas-iZK3DOCr.mjs → gradle-CmdOBq1d.mjs} +8 -294
  40. package/dist/{guide-6R0VNFqI.mjs → guide-cCSGRFd3.mjs} +1959 -222
  41. package/dist/{guide-status-BZrFPIA_.mjs → guide-status-CIoWK6mG.mjs} +3 -3
  42. package/dist/hosted-macos-DwowNU7W.mjs +447 -0
  43. package/dist/idle-shutdown-B5LPaNyY.mjs +122 -0
  44. package/dist/in-use-CndPMilN.mjs +110 -0
  45. package/dist/{ios-BwDPrnYQ.mjs → ios-3CtCRhwr.mjs} +201 -10
  46. package/dist/{ios-P1f5nm2n.mjs → ios-Chob8ny7.mjs} +512 -263
  47. package/dist/{ios-device-DGglU3E_.mjs → ios-device-DERmMmk-.mjs} +12 -7
  48. package/dist/{ios-device-BiOsSVzd.mjs → ios-device-Ee7sDXfp.mjs} +1 -1
  49. package/dist/{launch-verify-Deg4tB3Z.mjs → launch-verify-CLlofxRt.mjs} +4 -4
  50. package/dist/{logs-Civ4gbBH.mjs → logs-h9h6MUvE.mjs} +95 -13
  51. package/dist/machine-usage-D_YYMzfR.mjs +283 -0
  52. package/dist/machines-CYtOCqcj.mjs +259 -0
  53. package/dist/macos-BwtbUtTN.mjs +468 -0
  54. package/dist/macos-run.d.mts +5 -0
  55. package/dist/macos-run.mjs +2 -0
  56. package/dist/{merge-state-ytFQCeh4.mjs → merge-state-BnxLNQiM.mjs} +22 -12
  57. package/dist/{metro-CcEo8Fl8.mjs → metro-Di8EN2Tb.mjs} +20 -120
  58. package/dist/{named-ports-Blg8IxOh.mjs → named-ports-Dj_XBNaL.mjs} +6 -59
  59. package/dist/native-run-DFDoIRbY.mjs +147 -0
  60. package/dist/{native-runtime-DjBHRg5m.mjs → native-runtime-i6OkVg-w.mjs} +9 -5
  61. package/dist/offload-worker.d.mts +121 -0
  62. package/dist/offload-worker.mjs +601 -0
  63. package/dist/{ownership-DyYDF5ww.mjs → ownership-BkYxUtuj.mjs} +3 -2
  64. package/dist/{page-BHUzTDFt.mjs → page-QF_Ke10s.mjs} +7 -2
  65. package/dist/{ports-BguS83ex.mjs → ports-DddwttKM.mjs} +3 -3
  66. package/dist/prebuild-BvxDlD6C.mjs +213 -0
  67. package/dist/process-identity-BmRm1qV0.mjs +12 -0
  68. package/dist/{project-CWlvEaeN.mjs → project-CV3tDFHl.mjs} +9 -18
  69. package/dist/pull-request-pxnDCQzn.mjs +322 -0
  70. package/dist/pull-requests.d.mts +120 -0
  71. package/dist/pull-requests.mjs +2 -0
  72. package/dist/recordings-GEXp4iBT.mjs +37 -0
  73. package/dist/{reload-BiniwsSZ.mjs → reload-ChPiwvot.mjs} +70 -22
  74. package/dist/{remote-cache-CcR6o6lI.mjs → remote-cache-CO2elm_b.mjs} +4 -4
  75. package/dist/run-B-xqRrsg.mjs +119 -0
  76. package/dist/{server-bare-DGfgyJ5J.mjs → server-bare-X7PUgizL.mjs} +33 -15
  77. package/dist/{server-expo-BVuwQ65v.mjs → server-expo-DhtX6bom.mjs} +6 -10
  78. package/dist/server-expo-KJeD109I.mjs +2 -0
  79. package/dist/{settings-D61iNOsB.mjs → settings-CduVcoxj.mjs} +77 -26
  80. package/dist/{settings-B-fsC-Om.mjs → settings-DbL6uhH8.mjs} +16 -10
  81. package/dist/settings.schema.json +357 -2
  82. package/dist/{simslim-DrDN4WuV.mjs → simslim-Ciluxlq4.mjs} +8 -132
  83. package/dist/{slot-launch-D5t8EiMf.mjs → slot-launch-BY0BrOLh.mjs} +6 -6
  84. package/dist/{spawn-claims-Drw_o-Fb.mjs → spawn-claims-D0XfSe8u.mjs} +1 -1
  85. package/dist/spawn-entry-DncpJvWL.mjs +16 -0
  86. package/dist/stage-CzaiwFsI.mjs +143 -0
  87. package/dist/start-CPO4wRg7.mjs +2 -0
  88. package/dist/{start-s4RXp1wy.mjs → start-CUD9nasA.mjs} +108 -61
  89. package/dist/state-B4PQFXMW.d.mts +12 -0
  90. package/dist/state-BxCgeTQu.mjs +41 -0
  91. package/dist/{state-DHqvsbqC.mjs → state-CaeaHbDA.mjs} +7 -4
  92. package/dist/{state-Dk9RVXI7.mjs → state-DFm77wRn.mjs} +67 -5
  93. package/dist/stats-DBLLFmKd.mjs +66 -0
  94. package/dist/{status-BsPAnfOI.mjs → status-DYXxNOT0.mjs} +423 -268
  95. package/dist/{status-BgAuxESg.mjs → status-l84Gbvp2.mjs} +116 -20
  96. package/dist/stdout-reader-C8yjre1x.mjs +23 -0
  97. package/dist/stim-desktop-Cnz8CPnl.mjs +63 -0
  98. package/dist/stim-footprint.swift +32 -0
  99. package/dist/{stim-installations-CINXy_su.mjs → stim-installations-QMEI32v1.mjs} +1 -1
  100. package/dist/{stop-BzreOWJp.mjs → stop-Bad61z_2.mjs} +38 -12
  101. package/dist/stop-Bvf1MflS.mjs +48 -0
  102. package/dist/{stop-BWIF_6BK.mjs → stop-CceYh1yG.mjs} +2 -2
  103. package/dist/stop-cause-CZ_Mr-v9.mjs +665 -0
  104. package/dist/supervisor-run.d.mts +43 -11
  105. package/dist/supervisor-run.mjs +227 -19
  106. package/dist/support-CDQbDkL5.mjs +315 -0
  107. package/dist/support-WLOzVKUv.mjs +176 -0
  108. package/dist/teardown-BYuQafiA.mjs +718 -0
  109. package/dist/{xcode-Cp5KvK9x.mjs → toolchain-DmeYjXD9.mjs} +363 -13
  110. package/dist/warm-progress-DVHLN4uC.mjs +463 -0
  111. package/dist/{idle-DXtx3RbX.mjs → watchman-Bx0wceoF.mjs} +55 -8
  112. package/dist/{web-BsQs1WlO.mjs → web-k6w8-HnE.mjs} +37 -20
  113. package/dist/web-run.mjs +309 -12
  114. package/dist/workspace-process-lock-BL7Q0HCO.mjs +57 -0
  115. package/dist/workspace-state-CL2V2Ons.mjs +371 -0
  116. package/dist/worktree-BT_uULFx.mjs +2 -0
  117. package/dist/{worktree-BVrHsYZG.mjs → worktree-C0c5Udwa.mjs} +55 -54
  118. package/dist/{worktree-UrQWXSeb.mjs → worktree-qXKzADSC.mjs} +154 -252
  119. package/package.json +10 -5
  120. package/shim/bundle-response.cjs +28 -12
  121. package/dist/build-progress-DxKpwnaS.mjs +0 -247
  122. package/dist/in-use-DlqBDKqY.mjs +0 -249
  123. package/dist/server-expo-DIHDhvGg.mjs +0 -2
  124. package/dist/start-Cetfvy8l.mjs +0 -2
  125. package/dist/stats-CFpFGlJV.mjs +0 -62
  126. package/dist/stats-CX1Z8Tca.mjs +0 -368
  127. package/dist/stim-desktop-CXt8-Z3J.mjs +0 -40
  128. package/dist/stop-cause-hjGBOZTG.mjs +0 -1231
  129. package/dist/worktree-CHWWvm5v.mjs +0 -2
  130. 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";
3
+ import { C as workspaceLogsDir, g as sharedCompilationCache, h as sharedCcache, y as workspaceDerivedData } from "./workspace-state-CL2V2Ons.mjs";
4
+ import { f as resolvePackageJson } from "./project-CV3tDFHl.mjs";
5
+ import { a as spawnDeclared } from "./spawn-claims-D0XfSe8u.mjs";
6
6
  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";
7
+ import { a as formatElapsed, l as phaseLine } from "./command-output-CliHHn7a.mjs";
8
+ import { o as androidHome } from "./android-Db2eEMaf.mjs";
9
+ import { Y as resolveOptimizations } from "./settings-CduVcoxj.mjs";
10
+ import { t as cleanLine } from "./server-expo-DhtX6bom.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(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(), 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) {
@@ -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 };