stim 1.1.0 → 1.3.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 (64) hide show
  1. package/README.md +37 -0
  2. package/dist/{android-CC5bUer7.mjs → android-BW8i_YxU.mjs} +1 -1
  3. package/dist/android-BqVIJoG7.mjs +1368 -0
  4. package/dist/{android-DnZlT3aU.mjs → android-CqcW1hrP.mjs} +205 -58
  5. package/dist/{android-cas-DGlTStWu.mjs → android-cas-BR5YJBYv.mjs} +6 -6
  6. package/dist/android-cas-compiler.mjs +1 -1
  7. package/dist/{app-install-oZIQRbdD.mjs → app-install-DIp9riNx.mjs} +29 -21
  8. package/dist/{build-slots-CgacA9zQ.mjs → build-slots-C3-R4XQr.mjs} +3 -3
  9. package/dist/{cache-manifest-oeH18ERr.mjs → cache-manifest-CXR-Y8pH.mjs} +1 -1
  10. package/dist/cache-manifest.mjs +1 -1
  11. package/dist/cli.mjs +13 -13
  12. package/dist/collector-run.d.mts +4 -1
  13. package/dist/collector-run.mjs +36 -11
  14. package/dist/{config-D7uu8Gbq.mjs → config-CcefMY2Q.mjs} +94 -13
  15. package/dist/{deps-64wVnpZc.mjs → deps-Spz8ozgo.mjs} +2 -2
  16. package/dist/{dev-client-Bvky1hya.mjs → dev-client-BjisHDB5.mjs} +250 -10
  17. package/dist/{device-DJKv5Qej.mjs → device-BkiW-gkk.mjs} +19 -11
  18. package/dist/{device-lease-D-G3SgVe.mjs → device-lease-BJYybF-2.mjs} +107 -83
  19. package/dist/{device-pool-BlHXnYYs.mjs → device-pool-CPbLGfrB.mjs} +19 -13
  20. package/dist/{device-remote-CCgkG82J.mjs → device-remote-AkYCKS8U.mjs} +8 -8
  21. package/dist/{doctor-DlVxTtMq.mjs → doctor-Bmv86UUW.mjs} +18 -26
  22. package/dist/{doctor-BRF9aAJ3.mjs → doctor-fAMXC4vl.mjs} +10 -10
  23. package/dist/{error-diagnostics-B5IJwv3-.mjs → error-diagnostics-DHC31rXA.mjs} +65 -55
  24. package/dist/{exec-bsN9MJXb.mjs → exec-CyylIdq9.mjs} +4 -2
  25. package/dist/{gc-DhXdgSdt.mjs → gc-GGu-8ULN.mjs} +90 -67
  26. package/dist/{guide-DrhrDBo5.mjs → guide-92CPA21s.mjs} +414 -47
  27. package/dist/{ios-CK1Vrk6Q.mjs → ios-BSXFeO5H.mjs} +200 -59
  28. package/dist/{ios-BZxKPuqP.mjs → ios-Deh5js5V.mjs} +147 -40
  29. package/dist/{ios-device-CdSm0GDw.mjs → ios-device-CWOM_S44.mjs} +2 -2
  30. package/dist/{ios-device-CYbuRNXR.mjs → ios-device-D3pzTKQE.mjs} +1 -1
  31. package/dist/{logs-Dxoy16Qv.mjs → logs-DPNF4C9s.mjs} +9 -6
  32. package/dist/{logs-query-oqn47Ffx.mjs → logs-query-R-Cqc6Qv.mjs} +22 -5
  33. package/dist/{metro-B01H3EuD.mjs → metro-CORqXyTL.mjs} +3 -3
  34. package/dist/{ndjson-DcAtEx_K.mjs → ndjson-BZwI1NBv.mjs} +5 -2
  35. package/dist/{ownership-D8HmSv2E.mjs → ownership-8O073GIC.mjs} +3 -3
  36. package/dist/{ownership-B9QIdQOw.mjs → ownership-BpCKiRlQ.mjs} +4 -4
  37. package/dist/{ownership-claim-CeJLEpjD.mjs → ownership-claim-Bf2CAfw3.mjs} +4 -3
  38. package/dist/{project-COj6nzzh.mjs → project-fKmuIaMI.mjs} +2 -2
  39. package/dist/{reclaim-BPvN2HlP.mjs → reclaim-iW9Cad7k.mjs} +80 -73
  40. package/dist/{reload-DYZEBbZy.mjs → reload-DazHDSFA.mjs} +32 -24
  41. package/dist/{server-bare-BYHqEeyw.mjs → server-bare-DEzPZLvf.mjs} +7 -2
  42. package/dist/server-expo-44em5Pmg.mjs +2 -0
  43. package/dist/{server-expo-BEMr_m6p.mjs → server-expo-DizT4OMk.mjs} +5 -5
  44. package/dist/{settings-BSwrY4FZ.mjs → settings-DEJf6_kJ.mjs} +26 -5
  45. package/dist/slot-launch-cci0xvmC.mjs +19 -0
  46. package/dist/{start-ByCylYtB.mjs → start-mObjQH2W.mjs} +12 -12
  47. package/dist/{state-IYEY-zi8.mjs → state-B3XA2wp2.mjs} +9 -9
  48. package/dist/{stats-wqxPm7Tv.mjs → stats-BR-kwj0B.mjs} +1 -1
  49. package/dist/{stats-DZ4Q5J-7.mjs → stats-CaaQr4yN.mjs} +3 -3
  50. package/dist/{status-Dia0XTqG.mjs → status-BxQNqu9t.mjs} +86 -25
  51. package/dist/{stop-D6o5zAdm.mjs → stop-CrHGcjrV.mjs} +2 -2
  52. package/dist/{stop-BApyaF21.mjs → stop-DimGXEKY.mjs} +93 -42
  53. package/dist/supervisor-run.d.mts +1 -2
  54. package/dist/supervisor-run.mjs +5 -5
  55. package/dist/{remote-cache-DOi5-zLj.mjs → teardown-ClFp1Aax.mjs} +889 -830
  56. package/dist/{workspace-process-lock-CxOO9-pf.mjs → workspace-process-lock-3NcQnZ0X.mjs} +1 -1
  57. package/dist/{worktree-DxEmUI_n.mjs → worktree-DxTgN1CJ.mjs} +16 -16
  58. package/dist/{worktree-Dx3ZC5lS.mjs → worktree-Eq6TLH8N.mjs} +7 -3
  59. package/dist/{xcode-CDB6fytw.mjs → xcode-D7sAp-Zy.mjs} +256 -103
  60. package/package.json +5 -5
  61. package/shim/bundle-response.cjs +5 -0
  62. package/dist/android-xmyGBNy5.mjs +0 -665
  63. package/dist/build-lock-vE45ZzJZ.mjs +0 -645
  64. package/dist/server-expo-rb0k-0w7.mjs +0 -2
@@ -1,20 +1,19 @@
1
- import { t as getExecutor } from "./exec-bsN9MJXb.mjs";
2
- import { A as directorySize, M as isOnMountedVolume, N as listMountedVolumes, P as volumeRootFor, g as loadConfig, i as clearDevice, j as formatBytes, u as getConfigDir, v as removeProject } from "./config-D7uu8Gbq.mjs";
3
- import { i as registeredCaches } from "./cache-manifest-oeH18ERr.mjs";
4
- import { T as workspaceDir, k as workspaceStateFile } from "./state-IYEY-zi8.mjs";
5
- import { g as repoRoot, s as gitCommonDir } from "./worktree-Dx3ZC5lS.mjs";
6
- import { a as findProjectRoot, i as detectIsExpo } from "./project-COj6nzzh.mjs";
7
- import { S as readParked, _ as teardownParkedIosSim, b as dropParked, d as resolveEasCliBin, g as teardownParkedAvd, h as teardownOwnedIosSim, m as teardownOwnedAvd, v as POOL_SETTING_REMEDY, x as parkedMaxSetting } from "./remote-cache-DOi5-zLj.mjs";
8
- import { M as settingShapeErrors, a as SETTING_SHAPE_REMEDY, k as resolveSettings } from "./settings-BSwrY4FZ.mjs";
1
+ import { t as getExecutor } from "./exec-CyylIdq9.mjs";
2
+ import { A as directorySize, M as isOnMountedVolume, N as listMountedVolumes, P as volumeRootFor, g as loadConfig, i as clearDevice, j as formatBytes, u as getConfigDir, v as removeProject, z as projectDeviceSlots } from "./config-CcefMY2Q.mjs";
3
+ import { i as registeredCaches } from "./cache-manifest-CXR-Y8pH.mjs";
4
+ import { T as workspaceDir, k as workspaceStateFile } from "./state-B3XA2wp2.mjs";
5
+ import { g as repoRoot, s as gitCommonDir } from "./worktree-Eq6TLH8N.mjs";
6
+ import { a as findProjectRoot, i as detectIsExpo } from "./project-fKmuIaMI.mjs";
9
7
  import { m as shortUdid, o as formatLongDuration, u as plural } from "./command-output-8wHMEde0.mjs";
10
- import { h as parseRuntimeVersion, l as listAllIosSims, u as listIosDeviceTypes } from "./ios-BZxKPuqP.mjs";
11
- import { r as listBuildLocks } from "./build-lock-vE45ZzJZ.mjs";
12
- import { d as readClaimSet, o as clearFreeClaimSet } from "./ownership-claim-CeJLEpjD.mjs";
13
- import { i as listLeaseFiles, r as leaseIsExpired, u as removeExpiredLease } from "./device-lease-D-G3SgVe.mjs";
14
- import { n as listBuildSlots } from "./build-slots-CgacA9zQ.mjs";
15
- import { S as ownedAvdDirectory, v as listAvds } from "./android-xmyGBNy5.mjs";
16
- import { C as verifyStoppedSession, S as stopSessionArgs, _ as inspectSessionForTeardown, d as withEasProjectLock, f as easMachineStateRoot, g as getSessionArgs, h as findOrphanedOwnedSessions, m as removeEasSessionClaim, p as readEasSessionLedger, u as withRemoteSessionLock, v as isDefinitiveMissingSessionError, x as parseSessionListPage, y as listOwnedSessionsArgs } from "./device-remote-CCgkG82J.mjs";
17
- import { n as reclaimProject, t as describeDereferenced } from "./reclaim-BPvN2HlP.mjs";
8
+ import { d as readClaimSet, o as clearFreeClaimSet } from "./ownership-claim-Bf2CAfw3.mjs";
9
+ import { B as listBuildLocks, S as listOrphanedAvdDirectories, T as ownedAvdDirectory, b as listAvds } from "./android-BqVIJoG7.mjs";
10
+ import { A as resolveSettings, N as settingShapeErrors, a as SETTING_SHAPE_REMEDY } from "./settings-DEJf6_kJ.mjs";
11
+ import { a as POOL_SETTING_REMEDY, c as parkedMaxSetting, i as teardownParkedIosSim, l as readParked, n as teardownOwnedIosSim, r as teardownParkedAvd, s as dropParked, t as teardownOwnedAvd, x as resolveEasCliBin } from "./teardown-ClFp1Aax.mjs";
12
+ import { d as listIosDeviceTypes, g as parseRuntimeVersion, u as listAllIosSims } from "./ios-Deh5js5V.mjs";
13
+ import { i as listLeaseFiles, r as leaseIsExpired, u as removeExpiredLease } from "./device-lease-BJYybF-2.mjs";
14
+ import { n as listBuildSlots } from "./build-slots-C3-R4XQr.mjs";
15
+ import { C as verifyStoppedSession, S as stopSessionArgs, _ as inspectSessionForTeardown, d as withEasProjectLock, f as easMachineStateRoot, g as getSessionArgs, h as findOrphanedOwnedSessions, m as removeEasSessionClaim, p as readEasSessionLedger, u as withRemoteSessionLock, v as isDefinitiveMissingSessionError, x as parseSessionListPage, y as listOwnedSessionsArgs } from "./device-remote-AkYCKS8U.mjs";
16
+ import { n as reclaimProject, t as describeDereferenced } from "./reclaim-iW9Cad7k.mjs";
18
17
  import { InvalidArgumentError } from "commander";
19
18
  import { existsSync, readFileSync, readdirSync, realpathSync, rmSync, statSync } from "fs";
20
19
  import { homedir, tmpdir } from "os";
@@ -413,16 +412,18 @@ function findOrphanedDevices({ sims = [], avds = [], config, isMounted, deadProj
413
412
  for (const [path, proj] of Object.entries(config?.projects || {})) {
414
413
  if (dead.has(path)) continue;
415
414
  const mounted = isMounted ? isMounted(path) : true;
416
- const ios = proj?.platforms?.ios;
417
- if (ios?.deviceUdid) referenced.set(ios.deviceUdid, {
418
- path,
419
- mounted
420
- });
421
- const android = proj?.platforms?.android;
422
- if (android?.avdName) referenced.set(android.avdName, {
423
- path,
424
- mounted
425
- });
415
+ for (const { platforms } of projectDeviceSlots(proj)) {
416
+ const ios = platforms.ios;
417
+ if (ios?.deviceUdid) referenced.set(ios.deviceUdid, {
418
+ path,
419
+ mounted
420
+ });
421
+ const android = platforms.android;
422
+ if (android?.avdName) referenced.set(android.avdName, {
423
+ path,
424
+ mounted
425
+ });
426
+ }
426
427
  }
427
428
  for (const sim of readParked("ios", { config })) referenced.set(sim.udid, {
428
429
  path: "the simulator pool",
@@ -481,22 +482,26 @@ function findStaleProjectDevices({ config, sims = [], avds = [], olderThanDays,
481
482
  const touched = lastTouched(path);
482
483
  if (!Number.isFinite(touched) || touched >= cutoff) continue;
483
484
  const idleDays = Math.floor((now - touched) / DAY_MS);
484
- const ios = proj?.platforms?.ios;
485
- if (ios?.owned && ios.deviceUdid && liveSims.has(ios.deviceUdid)) stale.push({
486
- kind: "ios",
487
- id: ios.deviceUdid,
488
- name: liveSims.get(ios.deviceUdid),
489
- project: path,
490
- idleDays
491
- });
492
- const android = proj?.platforms?.android;
493
- if (android?.owned && android.avdName && liveAvds.has(android.avdName)) stale.push({
494
- kind: "android",
495
- id: android.avdName,
496
- name: android.avdName,
497
- project: path,
498
- idleDays
499
- });
485
+ for (const { slot, platforms } of projectDeviceSlots(proj)) {
486
+ const ios = platforms.ios;
487
+ if (ios?.owned && ios.deviceUdid && liveSims.has(ios.deviceUdid)) stale.push({
488
+ kind: "ios",
489
+ id: ios.deviceUdid,
490
+ name: liveSims.get(ios.deviceUdid),
491
+ project: path,
492
+ ...slot === "default" ? {} : { slot },
493
+ idleDays
494
+ });
495
+ const android = platforms.android;
496
+ if (android?.owned && android.avdName && liveAvds.has(android.avdName)) stale.push({
497
+ kind: "android",
498
+ id: android.avdName,
499
+ name: android.avdName,
500
+ project: path,
501
+ idleDays,
502
+ ...slot === "default" ? {} : { slot }
503
+ });
504
+ }
500
505
  }
501
506
  return stale;
502
507
  }
@@ -507,20 +512,24 @@ function findStaleDeviceRecords({ config, sims = [], avds = [], deadProjects = [
507
512
  const stale = [];
508
513
  for (const [path, proj] of Object.entries(config?.projects || {})) {
509
514
  if (dead.has(path)) continue;
510
- const ios = proj?.platforms?.ios;
511
- if (simsChecked && ios?.deviceUdid && !liveSims.has(ios.deviceUdid)) stale.push({
512
- kind: "ios",
513
- id: ios.deviceUdid,
514
- project: path,
515
- owned: Boolean(ios.owned)
516
- });
517
- const android = proj?.platforms?.android;
518
- if (avdsChecked && android?.avdName && !liveAvds.has(android.avdName)) stale.push({
519
- kind: "android",
520
- id: android.avdName,
521
- project: path,
522
- owned: Boolean(android.owned)
523
- });
515
+ for (const { slot, platforms } of projectDeviceSlots(proj)) {
516
+ const ios = platforms.ios;
517
+ if (simsChecked && ios?.deviceUdid && !liveSims.has(ios.deviceUdid)) stale.push({
518
+ kind: "ios",
519
+ id: ios.deviceUdid,
520
+ project: path,
521
+ ...slot === "default" ? {} : { slot },
522
+ owned: Boolean(ios.owned)
523
+ });
524
+ const android = platforms.android;
525
+ if (avdsChecked && android?.avdName && !liveAvds.has(android.avdName)) stale.push({
526
+ kind: "android",
527
+ id: android.avdName,
528
+ project: path,
529
+ ...slot === "default" ? {} : { slot },
530
+ owned: Boolean(android.owned)
531
+ });
532
+ }
524
533
  }
525
534
  return stale;
526
535
  }
@@ -532,7 +541,7 @@ function describeUnverifiableDevices(simNames = [], avdNames = [], { reason = "n
532
541
  function withAndroidAvdSizes(devices, { avdDirectory = ownedAvdDirectory, size = directorySize } = {}) {
533
542
  return devices.map((device) => {
534
543
  if (device.kind !== "android") return device;
535
- const dir = avdDirectory(device.id);
544
+ const dir = device.orphanedDirectory?.directory ?? avdDirectory(device.id);
536
545
  if (!dir) return device;
537
546
  try {
538
547
  const bytes = size(dir, { timeoutMs: AVD_SIZE_TIMEOUT_MS });
@@ -648,8 +657,8 @@ function deleteParkedSims(parkedSims, deps = {}) {
648
657
  if (emptied) console.log(chalk.dim(` emptied ${plural(emptied, "parked simulator")} from the pool`));
649
658
  return failures;
650
659
  }
651
- function deviceSweepIsScoped(unsafeAllowScopedDeviceSweep) {
652
- return Boolean(process.env.STIM_HOME) && !unsafeAllowScopedDeviceSweep;
660
+ function deviceSweepIsScoped() {
661
+ return Boolean(process.env.STIM_HOME);
653
662
  }
654
663
  function collectDeviceLeases(now) {
655
664
  const expired = [];
@@ -685,7 +694,11 @@ function deleteProjectDevices(orphanedDevices, staleDevices, staleDeviceRecords)
685
694
  const r = d.kind === "ios" ? teardownOwnedIosSim(d.id, {
686
695
  del: true,
687
696
  label: d.name
688
- }) : teardownOwnedAvd(d.name, { del: true });
697
+ }) : teardownOwnedAvd(d.name, {
698
+ del: true,
699
+ ..."project" in d ? { owner: { projectPath: d.project } } : {},
700
+ ..."orphanedDirectory" in d ? { orphanedDirectory: d.orphanedDirectory } : {}
701
+ });
689
702
  const what = d.kind === "ios" ? `ios sim ${d.name} (${d.id})` : `android avd ${d.name}`;
690
703
  if (r.status === "torn-down") console.log(chalk.green(`Deleted ${what}`));
691
704
  else if (r.status === "missing") console.log(chalk.dim(`${what} is already gone; nothing to delete.`));
@@ -700,12 +713,12 @@ function deleteProjectDevices(orphanedDevices, staleDevices, staleDeviceRecords)
700
713
  for (const d of staleDevices) {
701
714
  const status = reap(d);
702
715
  if (status === "torn-down" || status === "missing") {
703
- clearDevice(d.project, d.kind);
716
+ clearDevice(d.project, d.kind, d.slot);
704
717
  console.log(chalk.dim(` cleared the ${d.kind} record for ${d.project}`));
705
718
  }
706
719
  }
707
720
  for (const r of staleDeviceRecords) {
708
- clearDevice(r.project, r.kind);
721
+ clearDevice(r.project, r.kind, r.slot);
709
722
  console.log(chalk.green(`Cleared the ${r.kind} record for ${r.project} (${r.id} is not on this machine)`));
710
723
  }
711
724
  return deleteFailures;
@@ -1294,7 +1307,7 @@ function projectLastTouched(path) {
1294
1307
  return NaN;
1295
1308
  }
1296
1309
  }
1297
- async function collectGcReport({ olderThan = null, cache = null, now = Date.now(), lastTouched = projectLastTouched, unsafeAllowScopedDeviceSweep = false } = {}, deps = {}) {
1310
+ async function collectGcReport({ olderThan = null, cache = null, now = Date.now(), lastTouched = projectLastTouched } = {}, deps = {}) {
1298
1311
  const scope = typeof cache === "string" && cache.trim() ? cache : null;
1299
1312
  const all = scope !== null && olderThan === null;
1300
1313
  const caches = planCacheEmptying(sizeCaches(selectCaches(discoverCaches({ declared: declaredCachePaths() }), scope)), all);
@@ -1374,7 +1387,7 @@ async function collectGcReport({ olderThan = null, cache = null, now = Date.now(
1374
1387
  let orphanedDevices = [];
1375
1388
  let staleDevices = [];
1376
1389
  let staleDeviceRecords = [];
1377
- const unsweepableReason = cfg === null ? "no Stim config found" : deviceSweepIsScoped(unsafeAllowScopedDeviceSweep) ? "STIM_HOME scopes this config, but simulators and AVDs are machine-global" : null;
1390
+ const unsweepableReason = cfg === null ? "no Stim config found" : deviceSweepIsScoped() ? "STIM_HOME scopes this config, but simulators and AVDs are machine-global" : null;
1378
1391
  if (unsweepableReason) {
1379
1392
  let simNames = [];
1380
1393
  let avdNames = [];
@@ -1402,6 +1415,14 @@ async function collectGcReport({ olderThan = null, cache = null, now = Date.now(
1402
1415
  avdsChecked = false;
1403
1416
  deviceSweepNotices.push(`android device sweep skipped: emulator tooling did not answer within ${DEVICE_LIST_TIMEOUT_MS / 1e3}s`);
1404
1417
  }
1418
+ let orphanedAvdDirectories = [];
1419
+ if (avdsChecked) try {
1420
+ orphanedAvdDirectories = listOrphanedAvdDirectories();
1421
+ } catch (error) {
1422
+ avdsChecked = false;
1423
+ deviceSweepNotices.push(`android data sweep skipped: ${error.message}`);
1424
+ }
1425
+ avds = [.../* @__PURE__ */ new Set([...avds, ...orphanedAvdDirectories.map((entry) => entry.name)])];
1405
1426
  const isMounted = (path) => isOnMountedVolume(path, mountedVolumes);
1406
1427
  orphanedDevices = withAndroidAvdSizes(findOrphanedDevices({
1407
1428
  sims,
@@ -1409,7 +1430,10 @@ async function collectGcReport({ olderThan = null, cache = null, now = Date.now(
1409
1430
  config: cfg,
1410
1431
  isMounted,
1411
1432
  deadProjects
1412
- }).orphaned, {
1433
+ }).orphaned.flatMap((device) => {
1434
+ const directories = device.kind === "android" ? orphanedAvdDirectories.filter((entry) => entry.name === device.name) : [];
1435
+ return directories.length ? directories.map((orphanedDirectory) => Object.assign({}, device, { orphanedDirectory })) : [device];
1436
+ }), {
1413
1437
  avdDirectory: deps.avdDirectory ?? ownedAvdDirectory,
1414
1438
  size: deps.directorySize ?? directorySize
1415
1439
  });
@@ -1546,8 +1570,7 @@ async function runGcCore(opts, deps) {
1546
1570
  const cache = typeof opts.cache === "string" && opts.cache.trim() ? opts.cache : null;
1547
1571
  const report = await collectGcReport({
1548
1572
  olderThan,
1549
- cache,
1550
- unsafeAllowScopedDeviceSweep: opts.unsafeAllowScopedDeviceSweep
1573
+ cache
1551
1574
  }, deps);
1552
1575
  if (cache && report.caches.length === 0) {
1553
1576
  const names = [...new Set(discoverCaches({ declared: declaredCachePaths() }).map((c) => c.name))];