stim 1.15.0 → 1.17.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 (123) hide show
  1. package/dist/{activity-B2-kb7k0.mjs → activity-IRvJY_ru.mjs} +49 -16
  2. package/dist/agent-device-usage-output-BK41vnzN.mjs +411 -0
  3. package/dist/{android-Cu_L4RpL.mjs → android--GorydsK.mjs} +692 -321
  4. package/dist/{android-Db2eEMaf.mjs → android-B_YNZy61.mjs} +25 -60
  5. package/dist/{android-CYmq0jNi.mjs → android-DE4v59Mb.mjs} +12 -3
  6. package/dist/{android-cas-PnKfAdB2.mjs → android-cas-ZFpjJBL_.mjs} +6 -5
  7. package/dist/{app-install-CAAplXAt.mjs → app-install-VPkI5WEg.mjs} +52 -8
  8. package/dist/attempt-Bk2ouQVL.mjs +39 -0
  9. package/dist/{budget-CMiqghig.mjs → budget-DM984mnd.mjs} +372 -366
  10. package/dist/{build-plan-aeGMFX7e.mjs → build-plan-CmQCoyT-.mjs} +346 -88
  11. package/dist/{build-slots-Df1ApSuH.mjs → build-slots-41v_d2x9.mjs} +36 -21
  12. package/dist/{cli-0cX5s4NM.mjs → cli-Daxug5-K.mjs} +23 -17
  13. package/dist/cli.mjs +1 -1
  14. package/dist/collector-run.mjs +5 -192
  15. package/dist/{command-output-CliHHn7a.mjs → command-output-CDAIFD-8.mjs} +3 -3
  16. package/dist/{created-devices-BwVb3liH.mjs → created-devices-CpvzBL25.mjs} +1 -1
  17. package/dist/{dependency-state-BmsjKZ2H.mjs → dependency-state-CLcBHH2M.mjs} +1 -1
  18. package/dist/{deps-BFlKbOIp.mjs → deps-DNWaQs4V.mjs} +2 -2
  19. package/dist/{dev-client-CjzLoNs0.mjs → dev-client-B-XC4uRH.mjs} +3 -40
  20. package/dist/{device-BZ1IyS5A.mjs → device-C8IOoJPv.mjs} +7 -6
  21. package/dist/device-capacity-D0GWHnTM.mjs +580 -0
  22. package/dist/device-host-worker.mjs +587 -110
  23. package/dist/{device-ios-DMQBUPus.mjs → device-ios-Bc7vbGwl.mjs} +75 -44
  24. package/dist/{device-lease-W5Pi1q38.mjs → device-lease-DpoS36_u.mjs} +2 -2
  25. package/dist/{device-pool-B2r38YjS.mjs → device-lease-run-B8YltIH_.mjs} +5 -125
  26. package/dist/device-pool-3o7s5lo4.mjs +125 -0
  27. package/dist/{device-remote-9ulPsdhY.mjs → device-remote-hFSkpfQu.mjs} +13 -13
  28. package/dist/{doctor-BcE5xsBn.mjs → doctor-Cnk9d7Hm.mjs} +86 -59
  29. package/dist/{error-diagnostics-Cb0P1WLS.mjs → error-diagnostics-C-NMnhrk.mjs} +11 -15
  30. package/dist/{gc-BuL1Genr.mjs → gc-DxCL2A46.mjs} +478 -33
  31. package/dist/{gradle-CmdOBq1d.mjs → gradle-D7-L2Th3.mjs} +4 -4
  32. package/dist/{guide-cCSGRFd3.mjs → guide-DjrTQGik.mjs} +2198 -566
  33. package/dist/{guide-status-CIoWK6mG.mjs → guide-status-Du-ZQ3FD.mjs} +1 -1
  34. package/dist/hosted-android-DwLS4Mse.mjs +32 -0
  35. package/dist/hosted-client-wk1W_CNW.mjs +196 -0
  36. package/dist/hosted-ios-aMo7Cljf.mjs +15 -0
  37. package/dist/hosted-logs-DqYmWtXc.mjs +187 -0
  38. package/dist/hosted-macos-dlHXEeF5.mjs +135 -0
  39. package/dist/hosted-native-C9xJ9rpA.mjs +255 -0
  40. package/dist/{build-progress-C2Jv1AtA.mjs → idle-B2m-Ovod.mjs} +300 -9
  41. package/dist/{idle-shutdown-B5LPaNyY.mjs → idle-shutdown-_3oOV1V_.mjs} +25 -17
  42. package/dist/{in-use-CndPMilN.mjs → in-use-CvGOUn-x.mjs} +30 -10
  43. package/dist/ios-Cr1h5gnO.mjs +189 -0
  44. package/dist/{ios-Chob8ny7.mjs → ios-DE6duQoz.mjs} +819 -460
  45. package/dist/{ios-3CtCRhwr.mjs → ios-DSfnPfse.mjs} +4 -4
  46. package/dist/{ios-device-DERmMmk-.mjs → ios-device-pAN4t54-.mjs} +1 -1
  47. package/dist/ios-state-8L3lgum6.mjs +89 -0
  48. package/dist/{launch-verify-CLlofxRt.mjs → launch-verify-lTnWZikR.mjs} +3 -3
  49. package/dist/logs-DUoKlDoS.mjs +384 -0
  50. package/dist/{client-C2IS36Qf.mjs → machines-C2XiNwh9.mjs} +330 -37
  51. package/dist/{macos-BwtbUtTN.mjs → macos-32po3kUq.mjs} +23 -18
  52. package/dist/macos-run.mjs +1 -1
  53. package/dist/maintenance-run.d.mts +4 -0
  54. package/dist/maintenance-run.mjs +254 -0
  55. package/dist/{metro-Di8EN2Tb.mjs → metro-g8NqiJp-.mjs} +1 -1
  56. package/dist/metro-gateway-DmslUM30.mjs +103 -0
  57. package/dist/{named-ports-Dj_XBNaL.mjs → named-ports-C8m8EQs2.mjs} +2 -2
  58. package/dist/{native-run-DFDoIRbY.mjs → native-run-D1Q56rAD.mjs} +17 -6
  59. package/dist/{native-runtime-i6OkVg-w.mjs → native-runtime-DhJI3IVQ.mjs} +6 -6
  60. package/dist/{ndjson-CDY9IkVC.mjs → ndjson-PclOIwVY.mjs} +2 -2
  61. package/dist/offload-worker.d.mts +1 -0
  62. package/dist/offload-worker.mjs +13 -8
  63. package/dist/{teardown-BYuQafiA.mjs → ownership-BMLqyBgJ.mjs} +639 -53
  64. package/dist/{ownership-BkYxUtuj.mjs → ownership-DyRQru0q.mjs} +2 -2
  65. package/dist/{ports-DddwttKM.mjs → ports-4nYqxPWC.mjs} +2 -2
  66. package/dist/{prebuild-BvxDlD6C.mjs → prebuild-D7RUMkwN.mjs} +4 -4
  67. package/dist/preview-CxPRIEht.mjs +318 -0
  68. package/dist/{project-CV3tDFHl.mjs → project-D47Rh0ly.mjs} +72 -3
  69. package/dist/{recordings-GEXp4iBT.mjs → recordings-BNgsD1Tr.mjs} +1 -1
  70. package/dist/{reload-ChPiwvot.mjs → reload-qZei6iWn.mjs} +77 -13
  71. package/dist/{remote-cache-CO2elm_b.mjs → remote-cache-Ci4DQYYj.mjs} +4 -4
  72. package/dist/{run-B-xqRrsg.mjs → run-CkE9y0nc.mjs} +2 -2
  73. package/dist/{server-bare-X7PUgizL.mjs → server-bare-BkrSxSsZ.mjs} +1 -1
  74. package/dist/{server-expo-DhtX6bom.mjs → server-expo-CHTyXD0G.mjs} +4 -4
  75. package/dist/server-expo-CeakhI8P.mjs +2 -0
  76. package/dist/settings-BBpMcDbD.mjs +25 -0
  77. package/dist/settings-Cfd-0r2d.mjs +1440 -0
  78. package/dist/{settings-DbL6uhH8.mjs → settings-SR9OmW9h.mjs} +10 -4
  79. package/dist/settings.schema.json +472 -50
  80. package/dist/{simslim-Ciluxlq4.mjs → simslim-BWNrc3M3.mjs} +3 -3
  81. package/dist/{slot-launch-BY0BrOLh.mjs → slot-launch-DmjBmpQV.mjs} +10 -7
  82. package/dist/{spawn-entry-DncpJvWL.mjs → spawn-entry-jw19m8Nl.mjs} +1 -0
  83. package/dist/{start-CPO4wRg7.mjs → start-BopZcr4n.mjs} +1 -1
  84. package/dist/{start-CUD9nasA.mjs → start-uee1wWjY.mjs} +21 -17
  85. package/dist/{state-CaeaHbDA.mjs → state-BKa8wNN5.mjs} +1 -1
  86. package/dist/{state-BxCgeTQu.mjs → state-DyaNTgfR.mjs} +2 -2
  87. package/dist/{state-DFm77wRn.mjs → state-PeQiJuIu.mjs} +5 -5
  88. package/dist/{stats-DBLLFmKd.mjs → stats-Bq4fJOdB.mjs} +19 -5
  89. package/dist/{status-l84Gbvp2.mjs → status-CzS4bPO9.mjs} +5 -3
  90. package/dist/status-DlKvVJBE.mjs +49 -0
  91. package/dist/{status-DYXxNOT0.mjs → status-dXX2JX1C.mjs} +244 -50
  92. package/dist/{stop-CceYh1yG.mjs → stop-BCwvvs7F.mjs} +2 -2
  93. package/dist/{stop-Bad61z_2.mjs → stop-BjizrQwv.mjs} +83 -21
  94. package/dist/{stop-Bvf1MflS.mjs → stop-Cr1d8DSE.mjs} +4 -4
  95. package/dist/stop-cause-rhmGfwvt.mjs +97 -0
  96. package/dist/supervisor-run.d.mts +7 -4
  97. package/dist/supervisor-run.mjs +156 -27
  98. package/dist/{support-WLOzVKUv.mjs → support-BJPgYCu-.mjs} +61 -11
  99. package/dist/{support-CDQbDkL5.mjs → support-F9-sr0Oi.mjs} +6 -5
  100. package/dist/{toolchain-DmeYjXD9.mjs → toolchain-CNIBTIOv.mjs} +11 -11
  101. package/dist/trigger-Bemu8ytw.mjs +65 -0
  102. package/dist/trigger-CXts6qt1.mjs +2 -0
  103. package/dist/{warm-progress-DVHLN4uC.mjs → warm-progress-DF4JRvYI.mjs} +274 -5
  104. package/dist/watchman-APYjXSQa.mjs +48 -0
  105. package/dist/{web-k6w8-HnE.mjs → web-exQtGkoc.mjs} +14 -16
  106. package/dist/web-run.mjs +5 -5
  107. package/dist/{workspace-process-lock-BL7Q0HCO.mjs → workspace-process-lock-2mNzOlaB.mjs} +3 -2
  108. package/dist/{workspace-state-CL2V2Ons.mjs → workspace-state-DqcCbpE7.mjs} +34 -34
  109. package/dist/workspaces-Bcib97-6.mjs +306 -0
  110. package/dist/{worktree-BT_uULFx.mjs → worktree-Dc98cE6_.mjs} +1 -1
  111. package/dist/{worktree-qXKzADSC.mjs → worktree-ZpZR3S1k.mjs} +601 -33
  112. package/package.json +5 -5
  113. package/dist/device-capacity-DMuKC7nx.mjs +0 -136
  114. package/dist/hosted-macos-DwowNU7W.mjs +0 -447
  115. package/dist/logs-h9h6MUvE.mjs +0 -568
  116. package/dist/machine-usage-D_YYMzfR.mjs +0 -283
  117. package/dist/machines-CYtOCqcj.mjs +0 -259
  118. package/dist/merge-state-BnxLNQiM.mjs +0 -272
  119. package/dist/server-expo-KJeD109I.mjs +0 -2
  120. package/dist/settings-CduVcoxj.mjs +0 -680
  121. package/dist/stop-cause-CZ_Mr-v9.mjs +0 -665
  122. package/dist/watchman-Bx0wceoF.mjs +0 -238
  123. package/dist/worktree-C0c5Udwa.mjs +0 -753
@@ -1,72 +1,20 @@
1
1
  import { t as getExecutor } from "./exec-CaErVv7t.mjs";
2
2
  import { C as saveConfig, D as withConfigLock$1, H as projectDeviceSlots, I as assignSlotDevice, U as removeSlotDevice, _ as loadConfig$1, c as ensureConfig, d as getConfigDir, f as getConfigPath$1, z as deviceSlotPlatforms } from "./config-D0DbpZtM.mjs";
3
3
  import { n as ownership_claim_exports, t as process_identity_exports } from "./process-identity-BmRm1qV0.mjs";
4
+ import { s as androidDataPartitionSizeBytes } from "./settings-Cfd-0r2d.mjs";
5
+ import { o as pidExists, u as signalProcessTree } from "./metro-g8NqiJp-.mjs";
6
+ import { n as readCreatedDevices$1, r as recordCreatedDevice, t as forgetCreatedDevice } from "./created-devices-CpvzBL25.mjs";
4
7
  import { n as settingDefault, r as stimDesktopInstalled, t as STIM_DESKTOP_OPEN_OPTIONS } from "./stim-desktop-Cnz8CPnl.mjs";
5
- import { n as readCreatedDevices$1, r as recordCreatedDevice, t as forgetCreatedDevice } from "./created-devices-BwVb3liH.mjs";
6
- import { o as pidExists, u as signalProcessTree } from "./metro-Di8EN2Tb.mjs";
7
- import { c as androidDataPartitionSizeBytes } from "./settings-CduVcoxj.mjs";
8
8
  import { join } from "node:path";
9
9
  import { existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
10
10
  import { homedir, tmpdir } from "os";
11
11
  import { dirname as dirname$1, isAbsolute as isAbsolute$1, join as join$1, resolve as resolve$1 } from "path";
12
- import { ANDROID_EMULATOR_APPS, loadConfig, settingDefinition } from "@stim-cli/core/state";
12
+ import { ANDROID_EMULATOR_APPS, getParkedMax, loadConfig, settingDefinition } from "@stim-cli/core/state";
13
13
  import { isDeepStrictEqual } from "node:util";
14
- //#region src/devices/android-emulator-viewer.ts
15
- function configuredAndroidEmulatorApp(platform = process.platform) {
16
- const value = loadConfig$1()?.androidEmulatorApp ?? settingDefault(settingDefinition("androidEmulatorApp"), () => stimDesktopInstalled(platform)).value;
17
- if (ANDROID_EMULATOR_APPS.includes(value)) return value;
18
- const error = /* @__PURE__ */ new Error("Invalid androidEmulatorApp in machine config. Use \"emulator\" or \"stim-desktop\".");
19
- Object.assign(error, { code: "STIM_BAD_ARG" });
20
- throw error;
21
- }
22
- function openEmulatorInStimDesktop(serial) {
23
- getExecutor().runFileQuiet("open", [
24
- "-g",
25
- "-a",
26
- "Stim",
27
- `stim-desktop://open?serial=${serial}`
28
- ], STIM_DESKTOP_OPEN_OPTIONS);
29
- }
14
+ //#region src/devices/sim-pool.ts
30
15
  const POOL_SETTING_REMEDY = "Run `stim guide settings` for the device pool bounds and where it can be set.";
31
- const MAX_SETTING = {
32
- ios: {
33
- key: "iosParkedMax",
34
- env: "STIM_POOL_IOS_PARKED_MAX"
35
- },
36
- android: {
37
- key: "androidParkedMax",
38
- env: "STIM_POOL_ANDROID_PARKED_MAX"
39
- }
40
- };
41
- function parseMax(raw, strings) {
42
- const value = strings && typeof raw === "string" ? /^\d+$/.test(raw.trim()) ? Number(raw.trim()) : NaN : raw;
43
- if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) return null;
44
- return value;
45
- }
46
- function parkedMaxSetting(platform, { config, env = process.env } = {}) {
47
- const { key, env: envKey } = MAX_SETTING[platform];
48
- const fromEnv = env[envKey];
49
- const explicit = fromEnv !== void 0 && fromEnv !== "";
50
- const pool = (config === void 0 ? loadConfig$1() : config)?.pool;
51
- if (!explicit && pool !== void 0 && (pool === null || typeof pool !== "object" || Array.isArray(pool))) return {
52
- max: 0,
53
- error: "Invalid pool value. Expected an object with simulator and emulator bounds."
54
- };
55
- const fromConfig = pool !== null && typeof pool === "object" && !Array.isArray(pool) ? pool[key] : void 0;
56
- const raw = explicit ? fromEnv : fromConfig;
57
- if (raw === void 0) return {
58
- max: env.STIM_HOME ? 0 : 3,
59
- error: null
60
- };
61
- const parsed = parseMax(raw, explicit);
62
- if (parsed === null) return {
63
- max: 0,
64
- error: `Invalid ${explicit ? envKey : `pool.${key}`} value ${JSON.stringify(raw)}. Expected a whole number of parked ${platform === "ios" ? "simulators" : "emulators"}, 0 or more.`
65
- };
66
- return {
67
- max: explicit ? parsed : env.STIM_HOME ? 0 : parsed,
68
- error: null
69
- };
16
+ function parkedMaxSetting(platform, options = {}) {
17
+ return getParkedMax(platform, options);
70
18
  }
71
19
  function isParkedRecord(value, platform) {
72
20
  if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
@@ -282,6 +230,23 @@ function isStimOwnedAvd(name) {
282
230
  return name.startsWith("stim-") && isStimOwnedDevice("android", name);
283
231
  }
284
232
  //#endregion
233
+ //#region src/devices/android-emulator-viewer.ts
234
+ function configuredAndroidEmulatorApp(platform = process.platform) {
235
+ const value = loadConfig$1()?.androidEmulatorApp ?? settingDefault(settingDefinition("androidEmulatorApp"), () => stimDesktopInstalled(platform)).value;
236
+ if (ANDROID_EMULATOR_APPS.includes(value)) return value;
237
+ const error = /* @__PURE__ */ new Error("Invalid androidEmulatorApp in machine config. Use \"emulator\" or \"stim-desktop\".");
238
+ Object.assign(error, { code: "STIM_BAD_ARG" });
239
+ throw error;
240
+ }
241
+ function openEmulatorInStimDesktop(serial) {
242
+ getExecutor().runFileQuiet("open", [
243
+ "-g",
244
+ "-a",
245
+ "Stim",
246
+ `stim-desktop://open?serial=${serial}`
247
+ ], STIM_DESKTOP_OPEN_OPTIONS);
248
+ }
249
+ //#endregion
285
250
  //#region src/devices/android.ts
286
251
  const ANDROID_ABIS = /* @__PURE__ */ new Set([
287
252
  "armeabi-v7a",
@@ -1425,4 +1390,4 @@ function ownedAvdSerialResolver({ timeoutMs } = {}) {
1425
1390
  };
1426
1391
  }
1427
1392
  //#endregion
1428
- export { trimAndroidCaches as $, listAvds as A, ownedAvdSystemImage as B, emulatorFailureRemedy as C, hostSystemImageArch as D, getAvdNameForSerial as E, ownedAvdDeviceProfile as F, probeEmulatorSerial as G, parseAvdSystemImage as H, ownedAvdDirectory as I, resolveOwnedAvdSerial as J, profileNeedsFoldFeature as K, ownedAvdMatchesConfiguration as L, listOrphanedAvdDirectories as M, memoizeEmulatorProbe as N, listAdbDevices as O, nextConsolePort as P, systemImageSupportsFold as Q, ownedAvdName as R, emulatorDiskSpaceRemedy as S, findBuildTool as T, physicalDeviceModel as U, parseAvdDeviceProfile as V, pickDefaultSystemImage as W, shutdownAndroidEmulator as X, resolvePhysicalDevice as Y, sleepSync as Z, avdStorageRoots as _, androidDeviceAbi as a, POOL_SETTING_REMEDY as at, createOwnedAvd as b, androidPoolNoCandidatesRefusal as c, eraseParkedAfter as ct, androidToolPath as d, parkedMaxSetting as dt, waitForAndroidEmulatorShutdown as et, assertOwnedAvdStopped as f, readParked as ft, avdPoolConfiguration as g, avdPathExists as h, configuredAndroidEmulatorApp as ht, androidDataFreeBytes as i, isStimOwnedSim as it, listInstalledSystemImages as j, listAvdDeviceProfiles as k, androidSystemImageAbi as l, isLegacyDeletionClaim as lt, avdNameAbsent as m, selectParked as mt, OWNED_AVD_CONFIG_DEFAULTS as n, wipeAvdUserData as nt, androidHome as o, adoptParked as ot, avdIniPaths as p, removeParkedAfter as pt, resetAdoptedAvd as q, androidBuildToolName as r, isStimOwnedAvd as rt, androidPoolCandidates as s, dropParked as st, DEFAULT_AVD_DEVICE_PROFILE as t, waitForBoot as tt, androidToolCwd as u, parkSim as ut, bootAndroidEmulator as v, extractEmulatorFailure as w, deleteAvd as x, configureNewOwnedAvd as y, ownedAvdSerialResolver as z };
1393
+ export { trimAndroidCaches as $, listAvds as A, ownedAvdSystemImage as B, emulatorFailureRemedy as C, hostSystemImageArch as D, getAvdNameForSerial as E, ownedAvdDeviceProfile as F, probeEmulatorSerial as G, parseAvdSystemImage as H, ownedAvdDirectory as I, resolveOwnedAvdSerial as J, profileNeedsFoldFeature as K, ownedAvdMatchesConfiguration as L, listOrphanedAvdDirectories as M, memoizeEmulatorProbe as N, listAdbDevices as O, nextConsolePort as P, systemImageSupportsFold as Q, ownedAvdName as R, emulatorDiskSpaceRemedy as S, findBuildTool as T, physicalDeviceModel as U, parseAvdDeviceProfile as V, pickDefaultSystemImage as W, shutdownAndroidEmulator as X, resolvePhysicalDevice as Y, sleepSync as Z, avdStorageRoots as _, androidDeviceAbi as a, isStimOwnedSim as at, createOwnedAvd as b, androidPoolNoCandidatesRefusal as c, dropParked as ct, androidToolPath as d, parkSim as dt, waitForAndroidEmulatorShutdown as et, assertOwnedAvdStopped as f, parkedMaxSetting as ft, avdPoolConfiguration as g, avdPathExists as h, selectParked as ht, androidDataFreeBytes as i, isStimOwnedAvd as it, listInstalledSystemImages as j, listAvdDeviceProfiles as k, androidSystemImageAbi as l, eraseParkedAfter as lt, avdNameAbsent as m, removeParkedAfter as mt, OWNED_AVD_CONFIG_DEFAULTS as n, wipeAvdUserData as nt, androidHome as o, POOL_SETTING_REMEDY as ot, avdIniPaths as p, readParked as pt, resetAdoptedAvd as q, androidBuildToolName as r, configuredAndroidEmulatorApp as rt, androidPoolCandidates as s, adoptParked as st, DEFAULT_AVD_DEVICE_PROFILE as t, waitForBoot as tt, androidToolCwd as u, isLegacyDeletionClaim as ut, bootAndroidEmulator as v, extractEmulatorFailure as w, deleteAvd as x, configureNewOwnedAvd as y, ownedAvdSerialResolver as z };
@@ -1,5 +1,5 @@
1
1
  import { t as getExecutor } from "./exec-CaErVv7t.mjs";
2
- import { u as androidToolCwd } from "./android-Db2eEMaf.mjs";
2
+ import { u as androidToolCwd } from "./android-B_YNZy61.mjs";
3
3
  //#region src/collector/android.ts
4
4
  const LEVEL_BY_LETTER = {
5
5
  V: "debug",
@@ -45,7 +45,16 @@ function parseLogcatTimestamp({ month, day, hour, minute, second, millis }, now
45
45
  }
46
46
  function parseLogcatLine(line, { now = Date.now, clockOffsetMs = null } = {}) {
47
47
  if (typeof line !== "string") return null;
48
- const epoch = LOGCAT_EPOCH.exec(line.trimEnd());
48
+ const thread = /^\s*(\d+)\.(\d{3,6})\s+(\d+)\s+\d+\s+([A-Z])\s+(.*?):\s?(.*)$/.exec(line.trimEnd());
49
+ const epoch = thread ? [
50
+ thread[0],
51
+ thread[1],
52
+ thread[2],
53
+ thread[4],
54
+ thread[5],
55
+ thread[3],
56
+ thread[6]
57
+ ] : LOGCAT_EPOCH.exec(line.trimEnd());
49
58
  if (epoch) {
50
59
  const [, seconds, fraction, letter, tag, pid, msg] = epoch;
51
60
  if (!letter || !tag || !msg?.trim()) return null;
@@ -205,4 +214,4 @@ function watchAppPid({ serial, packageName, pid, intervalMs = null, exec = null,
205
214
  };
206
215
  }
207
216
  //#endregion
208
- export { watchAppPid as a, waitForAppPid as i, parseLogcatLine as n, startAndroidLogcat as r, androidClockOffset as t };
217
+ export { waitForAppPid as a, startAndroidLogcat as i, parseLogcatLine as n, watchAppPid as o, parsePidof as r, androidClockOffset as t };
@@ -1,11 +1,12 @@
1
1
  import { d as getConfigDir } from "./config-D0DbpZtM.mjs";
2
2
  import { r as register } from "./cache-manifest-DnUHBJaU.mjs";
3
- import { E as withDirLock, p as ensureWorkspaceStorage } from "./workspace-state-CL2V2Ons.mjs";
3
+ import { u as ensureWorkspaceStorage, w as withDirLock$1 } from "./workspace-state-DqcCbpE7.mjs";
4
4
  import { createHash, randomUUID } from "node:crypto";
5
- import { accessSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, symlinkSync, writeFileSync } from "node:fs";
5
+ import { accessSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
+ import { quotedPath } from "@stim-cli/core";
7
8
  import { isJsonObject, readJsonFile } from "@stim-cli/core/state";
8
- import { fileURLToPath } from "node:url";
9
+ import { fileURLToPath, pathToFileURL } from "node:url";
9
10
  //#region src/engine/android-cas.ts
10
11
  const CAS_TOOLCHAIN_FIELDS = [
11
12
  "clang",
@@ -121,11 +122,11 @@ function resolveAndroidCas(root, env = process.env) {
121
122
  const context = join(state, "context.json");
122
123
  mkdirSync(state, { recursive: true });
123
124
  mkdirSync(dir, { recursive: true });
124
- withDirLock(join(state, "setup.lock"), () => {
125
+ withDirLock$1(join(state, "setup.lock"), () => {
125
126
  for (const name of ["clang", "clang++"]) {
126
127
  const path = join(state, name);
127
128
  const temporary = `${path}.${randomUUID()}.tmp`;
128
- symlinkSync(scripts[3], temporary);
129
+ writeFileSync(temporary, `#!/bin/sh\nexec ${quotedPath(process.execPath)} --input-type=module --eval ${quotedPath(`import ${JSON.stringify(pathToFileURL(scripts[3]).href)}`)} "$0" "$@"\n`, { mode: 493 });
129
130
  renameSync(temporary, path);
130
131
  }
131
132
  const temporary = `${context}.${process.pid}.tmp`;
@@ -1,6 +1,49 @@
1
1
  import { t as getExecutor } from "./exec-CaErVv7t.mjs";
2
- import { D as uninstallIosApp, M as deviceHoldsApk, N as deviceHoldsBundle, l as iosSimulatorFailureAdvice, m as listUserApps } from "./ios-3CtCRhwr.mjs";
2
+ import { D as uninstallIosApp, M as deviceHoldsApk, N as deviceHoldsBundle, l as iosSimulatorFailureAdvice, m as listUserApps } from "./ios-DSfnPfse.mjs";
3
3
  import { t as DEV_MENU_LAUNCH_ARGS } from "./ios-device-Ee7sDXfp.mjs";
4
+ import { join } from "node:path";
5
+ //#region src/engine/app-schemes.ts
6
+ function schemesFromInfoPlist(plist) {
7
+ const types = plist?.CFBundleURLTypes;
8
+ if (!Array.isArray(types)) return [];
9
+ const out = [];
10
+ for (const type of types) {
11
+ const schemes = type?.CFBundleURLSchemes;
12
+ if (Array.isArray(schemes)) out.push(...schemes.filter((s) => typeof s === "string" && s.trim() !== ""));
13
+ }
14
+ return out;
15
+ }
16
+ function readBundleSchemes(appPath, { exec = null } = {}) {
17
+ if (typeof appPath !== "string" || appPath.trim() === "") return [];
18
+ const e = exec || getExecutor();
19
+ let out;
20
+ try {
21
+ out = e.runFile("plutil", [
22
+ "-convert",
23
+ "json",
24
+ "-o",
25
+ "-",
26
+ join(appPath, "Info.plist")
27
+ ]);
28
+ } catch {
29
+ return [];
30
+ }
31
+ try {
32
+ return schemesFromInfoPlist(JSON.parse(String(out)));
33
+ } catch {
34
+ return [];
35
+ }
36
+ }
37
+ const THIRD_PARTY_SCHEME = /^(?:fb\d+|com\.googleusercontent\.apps\.|msauth\.|msauthv2|twitterkit-|db-[a-z0-9]+$|spotify|snapchat|com\.facebook)/i;
38
+ function approvableSchemes(schemes) {
39
+ return (Array.isArray(schemes) ? schemes : []).filter((s) => typeof s === "string" && s.trim() !== "").map((s) => s.trim()).filter((s) => !/^(?:https?|mailto|tel|sms|itms(?:-apps)?)$/i.test(s) && !THIRD_PARTY_SCHEME.test(s));
40
+ }
41
+ function pickDevClientScheme(schemes) {
42
+ const all = approvableSchemes(schemes);
43
+ const expo = all.filter((s) => s.startsWith("exp+"));
44
+ return (expo.length ? expo : all).toSorted((a, b) => b.length - a.length)[0] ?? null;
45
+ }
46
+ //#endregion
4
47
  //#region src/engine/app-install.ts
5
48
  const INSTALL_ERROR = "STIM_INSTALL_FAILED";
6
49
  const LAUNCH_ERROR = "STIM_LAUNCH_FAILED";
@@ -68,7 +111,7 @@ function installIosApp({ udid, appPath, bundleId = null, devClientScheme = null,
68
111
  const artifactFinishedAt = now?.();
69
112
  const artifactDurationMs = artifactStartedAt !== void 0 && artifactFinishedAt !== void 0 ? artifactFinishedAt - artifactStartedAt : void 0;
70
113
  const devMenuKeys = bundleId && devClientScheme && !skipped ? IOS_DEV_MENU_OFF_KEYS : [];
71
- const missingApprovals = (bundleId && devClientScheme ? iosSchemeApprovalKeys(bundleId, devClientScheme) : []).filter((key) => !schemeApprovals.includes(`${key}=${bundleId}`));
114
+ const missingApprovals = (bundleId ? iosSchemeApprovalKeys(bundleId, [...approvableSchemes(readBundleSchemes(appPath, { exec: e })), ...devClientScheme ? [devClientScheme] : []]) : []).filter((key) => !schemeApprovals.includes(`${key}=${bundleId}`));
72
115
  const preparing = bundleId && (devMenuKeys.length > 0 || missingApprovals.length > 0);
73
116
  const preparationStartedAt = preparing ? artifactFinishedAt : void 0;
74
117
  if (bundleId && preparing) try {
@@ -149,8 +192,8 @@ function devClientDeepLink(scheme, projectOrigin, { devMenuParams = false } = {}
149
192
  function devClientUrl(scheme, metroPort, host = "localhost", options = {}) {
150
193
  return devClientDeepLink(scheme, `http://${host}:${metroPort}`, options);
151
194
  }
152
- function iosSchemeApprovalKeys(bundleId, devClientScheme) {
153
- return [.../* @__PURE__ */ new Set([bundleId, devClientScheme])].map((target) => `${IOS_SCHEME_APPROVAL_OPENER}-->${target}`);
195
+ function iosSchemeApprovalKeys(bundleId, schemes) {
196
+ return [.../* @__PURE__ */ new Set([bundleId, ...schemes])].map((target) => `${IOS_SCHEME_APPROVAL_OPENER}-->${target}`);
154
197
  }
155
198
  function restartedAppNote(restartedPid, lead = " ") {
156
199
  return restartedPid ? `${lead}restarted running app (was pid ${restartedPid})` : "";
@@ -613,13 +656,14 @@ function stopRunningAndroidApp(serial, packageName, exec) {
613
656
  }
614
657
  return { restartedPid: pid };
615
658
  }
616
- function launchAndroidApp({ serial, packageName, metroPort, devClientScheme = null, physical = false }, { exec = null } = {}) {
659
+ function launchAndroidApp({ serial, packageName, metroPort, devClientScheme = null, physical = false, bridgePort }, { exec = null } = {}) {
617
660
  const e = exec || getExecutor();
618
661
  const restart = stopRunningAndroidApp(serial, packageName, e);
619
662
  if (restart.failed) return restart;
620
663
  const reversed = reverseMetroPorts({
621
664
  serial,
622
- metroPort
665
+ metroPort: bridgePort ?? metroPort,
666
+ devicePorts: [metroPort]
623
667
  }, { exec: e });
624
668
  if (reversed.failed) return reversed;
625
669
  const prefs = writeDebugHttpHost({
@@ -632,7 +676,7 @@ function launchAndroidApp({ serial, packageName, metroPort, devClientScheme = nu
632
676
  if (!prefs.ok && Number(metroPort) !== 8081) {
633
677
  const fallback = reverseMetroPorts({
634
678
  serial,
635
- metroPort,
679
+ metroPort: bridgePort ?? metroPort,
636
680
  devicePorts: [DEFAULT_METRO_PORT]
637
681
  }, { exec: e });
638
682
  if (fallback.failed) return fallback;
@@ -805,4 +849,4 @@ function androidAppProcess(serial, packageName, { exec = null } = {}) {
805
849
  }
806
850
  }
807
851
  //#endregion
808
- export { restartedAppNote as S, installIosApp as _, IOS_DEV_MENU_OFF_DEFAULTS_PLIST as a, launchAndroidReleaseApp as b, androidDevClientUrl as c, devClientUrl as d, deviceShellArg as f, installConflictKind as g, installAndroidApp as h, INSTALL_ERROR as i, clearOtherUserApps as l, hasMetroReverse as m, ANDROID_DISABLE_AUTO_LAUNCH_EXTRA as n, LAUNCH_ERROR as o, ensureMetroReverse as p, DEFAULT_METRO_PORT as r, androidAppProcess as s, ADB_INSTALL_TIMEOUT_MS as t, devClientDeepLink as u, iosAppProcess as v, launchIosApp as x, launchAndroidApp as y };
852
+ export { reverseMetroPorts as C, schemesFromInfoPlist as D, readBundleSchemes as E, restartedAppNote as S, pickDevClientScheme as T, installIosApp as _, IOS_DEV_MENU_OFF_DEFAULTS_PLIST as a, launchAndroidReleaseApp as b, androidDevClientUrl as c, devClientUrl as d, deviceShellArg as f, installConflictKind as g, installAndroidApp as h, INSTALL_ERROR as i, clearOtherUserApps as l, hasMetroReverse as m, ANDROID_DISABLE_AUTO_LAUNCH_EXTRA as n, LAUNCH_ERROR as o, ensureMetroReverse as p, DEFAULT_METRO_PORT as r, androidAppProcess as s, ADB_INSTALL_TIMEOUT_MS as t, devClientDeepLink as u, iosAppProcess as v, writeDebugHttpHost as w, launchIosApp as x, launchAndroidApp as y };
@@ -0,0 +1,39 @@
1
+ import { mkdirSync, renameSync, statSync, truncateSync, unlinkSync, writeFileSync } from "node:fs";
2
+ import { maintenanceAttemptFile, maintenanceChildLogFile, maintenanceDir } from "@stim-cli/core/state";
3
+ //#region src/maintenance/due.ts
4
+ const DEFERRED_RETRY_MS = 3e5;
5
+ const ATTEMPT_BACKOFF_MS = 6e4;
6
+ function due(state, settings, now, attemptedAt) {
7
+ const elapsed = (stamp) => stamp === void 0 || stamp > now ? Infinity : now - stamp;
8
+ if (elapsed(attemptedAt) < ATTEMPT_BACKOFF_MS) return [];
9
+ return ["pressure", "size"].filter((check) => {
10
+ if (elapsed(state?.deferredAt?.[check]) < DEFERRED_RETRY_MS) return false;
11
+ const interval = check === "pressure" ? settings.pressureCheckMinutes : settings.sizeCheckMinutes;
12
+ return elapsed(state?.lastAt[check]) >= interval * 6e4;
13
+ });
14
+ }
15
+ //#endregion
16
+ //#region src/maintenance/attempt.ts
17
+ const CHILD_LOG_MAX_BYTES = 65536;
18
+ /** Records that a child is about to start, so a child that dies before it can write anything does not respawn on every command. */
19
+ function stampAttempt(now) {
20
+ mkdirSync(maintenanceDir(), { recursive: true });
21
+ const file = maintenanceAttemptFile();
22
+ const tmp = `${file}.${process.pid}.tmp`;
23
+ writeFileSync(tmp, `${JSON.stringify({ attemptedAt: now })}\n`);
24
+ try {
25
+ renameSync(tmp, file);
26
+ } finally {
27
+ try {
28
+ unlinkSync(tmp);
29
+ } catch {}
30
+ }
31
+ }
32
+ function capChildLog() {
33
+ try {
34
+ const file = maintenanceChildLogFile();
35
+ if (statSync(file).size > CHILD_LOG_MAX_BYTES) truncateSync(file);
36
+ } catch {}
37
+ }
38
+ //#endregion
39
+ export { stampAttempt as n, due as r, capChildLog as t };