stim 1.12.0 → 1.13.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 (71) hide show
  1. package/README.md +3 -1
  2. package/dist/{activity-CCZJs__P.mjs → activity-DfVKZTEB.mjs} +42 -25
  3. package/dist/{android-BQiKJYK0.mjs → android-BHfAu2mf.mjs} +1 -1
  4. package/dist/{android-B7X-8H7h.mjs → android-CD8pr8Q2.mjs} +62 -47
  5. package/dist/{android-cas-DzLPXiEn.mjs → android-cas-B9Kv9aIy.mjs} +9 -7
  6. package/dist/{android-75Sk2rIR.mjs → android-qx_31wJo.mjs} +395 -116
  7. package/dist/{app-install-CsZi0SAT.mjs → app-install-CDFY2nUL.mjs} +1 -1
  8. package/dist/{budget-DbzW5VTD.mjs → budget-E5o91NR1.mjs} +154 -37
  9. package/dist/{build-plan-CqntbR7b.mjs → build-plan-BTa93o_r.mjs} +21 -88
  10. package/dist/{build-progress-h60GPV27.mjs → build-progress-l7d-X-ZP.mjs} +75 -7
  11. package/dist/cdp-Dq_ypAlJ.mjs +115 -0
  12. package/dist/chrome-B5hWgQJS.mjs +61 -0
  13. package/dist/cli.mjs +16 -15
  14. package/dist/collector-run.mjs +14 -8
  15. package/dist/{command-output-BWCj5Vh-.mjs → command-output-BIL7rlX7.mjs} +1 -1
  16. package/dist/created-devices-Cd558h31.mjs +37 -0
  17. package/dist/{deps-CO-_7UOm.mjs → deps-2Wo81np9.mjs} +1 -1
  18. package/dist/{device-9r9xRYDa.mjs → device-Cf7vl-so.mjs} +6 -6
  19. package/dist/{device-lease-B9LAXIUH.mjs → device-lease-CL9dZf73.mjs} +52 -3
  20. package/dist/{device-pool-BoezJd-c.mjs → device-pool-MuoiyRcu.mjs} +3 -3
  21. package/dist/{device-remote-C0_o-tJH.mjs → device-remote-DT9ngZiD.mjs} +10 -10
  22. package/dist/{doctor-LfDlbR-N.mjs → doctor-D2iysNNH.mjs} +47 -18
  23. package/dist/{error-diagnostics-CCxjn31V.mjs → error-diagnostics-BoiOhck8.mjs} +6 -6
  24. package/dist/{gc-C4nQFcTX.mjs → gc-eA-PRBX8.mjs} +853 -126
  25. package/dist/{guide-BPBlh9ML.mjs → guide-BfZ0OmiP.mjs} +736 -110
  26. package/dist/{guide-status-i9ogHt4v.mjs → guide-status-BaMYu55M.mjs} +1 -1
  27. package/dist/{idle-S3tFZ53_.mjs → idle-DxLi5OkN.mjs} +42 -9
  28. package/dist/{in-use-D9XYEgFD.mjs → in-use-wYEaKQM9.mjs} +9 -5
  29. package/dist/{ios-CDzWL1mj.mjs → ios-CcfCeZ19.mjs} +98 -54
  30. package/dist/{ios-CZWOHTTc.mjs → ios-CmEzZiOj.mjs} +10 -5
  31. package/dist/{ios-device-D9cLxVr5.mjs → ios-device-BW-t_Lkv.mjs} +1 -1
  32. package/dist/{launch-verify-B2oR_kFN.mjs → launch-verify-CuJaBpEa.mjs} +33 -20
  33. package/dist/{logs-SzuYudOj.mjs → logs-DcSRbC2t.mjs} +11 -10
  34. package/dist/{metro-Dzo30hvJ.mjs → metro-BPeY1YMh.mjs} +4 -4
  35. package/dist/{named-ports-Dn1o61D9.mjs → named-ports-n7tnJsI8.mjs} +78 -6
  36. package/dist/native-runtime-CiiFHt0e.mjs +74 -0
  37. package/dist/{ownership-Dqnrjrio.mjs → ownership-Bz2kETAS.mjs} +1 -1
  38. package/dist/{ownership-B8d4kXBx.mjs → ownership-PUP4Dwai.mjs} +134 -209
  39. package/dist/page-BTu7I60K.mjs +29 -0
  40. package/dist/{ports-Dp_QTwTC.mjs → ports-C5UutqpJ.mjs} +4 -4
  41. package/dist/{project-B8rbutVC.mjs → project-DGeclhvO.mjs} +53 -17
  42. package/dist/{reload-nocmx8KB.mjs → reload-C-cV5yy_.mjs} +79 -20
  43. package/dist/{remote-cache-BRsRZru5.mjs → remote-cache--aehr4Pr.mjs} +3 -3
  44. package/dist/{server-bare-Gn3ssSdK.mjs → server-bare-Bq8BpSIo.mjs} +1 -1
  45. package/dist/server-expo-BeYwP_Xy.mjs +2 -0
  46. package/dist/{server-expo-CeT1nIIk.mjs → server-expo-DUCg52-K.mjs} +2 -2
  47. package/dist/{settings-bE-Gu3Ti.mjs → settings-ssVBToDR.mjs} +10 -10
  48. package/dist/{settings-BlyDn2Oz.mjs → settings-xB0Frkg6.mjs} +11 -2
  49. package/dist/settings.schema.json +53 -1
  50. package/dist/{simslim-COtEEP7x.mjs → simslim-Bbg9UWrt.mjs} +12 -6
  51. package/dist/{slot-launch-DIACGEfH.mjs → slot-launch-BIWEW-wI.mjs} +3 -3
  52. package/dist/{start-BboE1HIS.mjs → start-BZhItkiL.mjs} +11 -10
  53. package/dist/{start-BFstVBlx.mjs → start-Rw2GD3nV.mjs} +1 -1
  54. package/dist/{state-DcDgzfu3.mjs → state-DwAU2_-D.mjs} +1 -1
  55. package/dist/state-l1pYwOre.mjs +148 -0
  56. package/dist/{stats-DiCtmluY.mjs → stats-CaSwmsSZ.mjs} +2 -2
  57. package/dist/{status-DI9Tjo7T.mjs → status-TJlL0HWo.mjs} +624 -103
  58. package/dist/{status-BUASYyy_.mjs → status-sszP4XKU.mjs} +59 -2
  59. package/dist/{stim-desktop-D0xhpZt8.mjs → stim-desktop-CXt8-Z3J.mjs} +13 -2
  60. package/dist/{stop-Bn6v-GvS.mjs → stop-BZ2qMiBP.mjs} +37 -12
  61. package/dist/{stop-BI7QY76M.mjs → stop-DskDKNTU.mjs} +2 -2
  62. package/dist/supervisor-run.mjs +10 -10
  63. package/dist/web-run.d.mts +22 -0
  64. package/dist/web-run.mjs +481 -0
  65. package/dist/web-sWXd5iek.mjs +394 -0
  66. package/dist/{worktree-B5sTRskL.mjs → worktree-3cBa-bQt.mjs} +1 -1
  67. package/dist/{worktree-ChDL5fO1.mjs → worktree-D4Do_XiQ.mjs} +226 -19
  68. package/dist/{xcode-BzplpQzc.mjs → xcode-LM6A8cNZ.mjs} +5 -5
  69. package/package.json +5 -5
  70. package/dist/server-expo-eWi9Coof.mjs +0 -2
  71. package/dist/workspace-process-lock-BvvJTfo_.mjs +0 -57
@@ -0,0 +1,148 @@
1
+ import { A as ownership_claim_exports, O as process_identity_exports } from "./config-0jCcMM0E.mjs";
2
+ import { M as workspaceLogsDir, _ as updateWorkspaceState, a as pidExists, b as writeWorkspaceState, h as readWorkspaceState$1, k as workspaceDir, p as clearWorkspaceStateKey } from "./metro-BPeY1YMh.mjs";
3
+ import { readlinkSync, rmSync } from "node:fs";
4
+ import { WEB_VIEWPORTS } from "@stim-cli/core/state";
5
+ import { join } from "node:path";
6
+ import { hostname } from "node:os";
7
+ //#region src/web/profile.ts
8
+ const SINGLETON_FILES = [
9
+ "SingletonLock",
10
+ "SingletonSocket",
11
+ "SingletonCookie"
12
+ ];
13
+ /**
14
+ * The process Chrome's `SingletonLock` names, when it is a live process on this host. Chrome writes the lock as a
15
+ * symlink to `<hostname>-<pid>` and refuses a second instance on the profile while that process lives.
16
+ */
17
+ function liveProfileHolder(profile, { alive = pidExists } = {}) {
18
+ let target;
19
+ try {
20
+ target = readlinkSync(join(profile, "SingletonLock"));
21
+ } catch {
22
+ return null;
23
+ }
24
+ const match = /^(.*)-(\d+)$/.exec(target);
25
+ if (!match || match[1] !== hostname()) return null;
26
+ const pid = Number(match[2]);
27
+ return alive(pid) ? pid : null;
28
+ }
29
+ /** Removes the lock files a Chrome that did not exit cleanly leaves; call only once that Chrome is gone. */
30
+ function removeSingletonFiles(profile) {
31
+ for (const name of SINGLETON_FILES) rmSync(join(profile, name), { force: true });
32
+ }
33
+ /**
34
+ * Whether the owned Chrome still runs. `lingering` means the recorded process exited but its process group, whose
35
+ * id is that pid, still has helper processes: a live group id cannot be reused. A pid now held by a different
36
+ * process is `gone`, never something to signal.
37
+ */
38
+ function chromeProcessState(record) {
39
+ const identity = (0, process_identity_exports.inspectProcessIdentity)(record);
40
+ if (identity === "same") return "running";
41
+ if (identity === "unknown") return "unknown";
42
+ if (identity === "different") return "gone";
43
+ return (0, ownership_claim_exports.processGroupAlive)(record.pid) ? "lingering" : "gone";
44
+ }
45
+ //#endregion
46
+ //#region src/web/state.ts
47
+ const WEB_STATE_KEY = "web";
48
+ const CDP_PORT_LABEL = "web-cdp";
49
+ function webDir(root) {
50
+ return join(workspaceDir(root), "web");
51
+ }
52
+ function webProfileDir(root) {
53
+ return join(webDir(root), "profile");
54
+ }
55
+ function webClaimRoot(root) {
56
+ return join(webDir(root), "supervisor.lock");
57
+ }
58
+ function webLogFile(root) {
59
+ return join(workspaceLogsDir(root), "web.ndjson");
60
+ }
61
+ function webSupervisorLogFile(root) {
62
+ return join(workspaceLogsDir(root), "web-supervisor.log");
63
+ }
64
+ function browserLogFile(root) {
65
+ return join(workspaceLogsDir(root), "browser.log");
66
+ }
67
+ function processRecord(value) {
68
+ const record = value;
69
+ return typeof record?.pid === "number" && typeof record.processToken === "string" ? {
70
+ pid: record.pid,
71
+ processToken: record.processToken
72
+ } : void 0;
73
+ }
74
+ function parseWebRecord(value) {
75
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
76
+ const record = value;
77
+ const owner = processRecord(record);
78
+ if (!owner || typeof record.cdpPort !== "number" || typeof record.profile !== "string") return null;
79
+ if (typeof record.url !== "string" || typeof record.chrome !== "string") return null;
80
+ const chromeProcess = processRecord(record.chromeProcess);
81
+ return {
82
+ pid: owner.pid,
83
+ processToken: owner.processToken,
84
+ chrome: record.chrome,
85
+ ...chromeProcess ? { chromeProcess } : {},
86
+ cdpPort: record.cdpPort,
87
+ profile: record.profile,
88
+ url: record.url,
89
+ headless: record.headless !== false,
90
+ viewport: WEB_VIEWPORTS.includes(record.viewport) ? record.viewport : "desktop",
91
+ ignoreCertificateErrors: record.ignoreCertificateErrors === true,
92
+ startedAt: typeof record.startedAt === "string" ? record.startedAt : "",
93
+ ...typeof record.targetId === "string" ? { targetId: record.targetId } : {},
94
+ ...typeof record.version === "string" ? { version: record.version } : {},
95
+ ...typeof record.launchId === "string" ? { launchId: record.launchId } : {}
96
+ };
97
+ }
98
+ function readWebRecord(root) {
99
+ return parseWebRecord(readWorkspaceState$1(root)?.[WEB_STATE_KEY]);
100
+ }
101
+ function writeWebRecord(root, record) {
102
+ writeWorkspaceState(root, { [WEB_STATE_KEY]: record });
103
+ }
104
+ /** Merges `patch` into the record only while `owner` still holds it; false when another supervisor does. */
105
+ function updateWebRecord(root, owner, patch) {
106
+ let updated = false;
107
+ updateWorkspaceState(root, (state) => {
108
+ const current = parseWebRecord(state[WEB_STATE_KEY]);
109
+ if (!current || !(0, process_identity_exports.sameProcessRecord)(current, owner)) return state;
110
+ updated = true;
111
+ return {
112
+ ...state,
113
+ [WEB_STATE_KEY]: {
114
+ ...current,
115
+ ...patch
116
+ }
117
+ };
118
+ });
119
+ return updated;
120
+ }
121
+ function clearWebRecord(root, owner) {
122
+ return clearWorkspaceStateKey(root, WEB_STATE_KEY, (value) => {
123
+ const current = parseWebRecord(value);
124
+ return !current || (0, process_identity_exports.sameProcessRecord)(current, owner);
125
+ });
126
+ }
127
+ function cdpEndpoint(port) {
128
+ return `http://127.0.0.1:${port}`;
129
+ }
130
+ function webFacts(record) {
131
+ if (!record) return null;
132
+ const supervisor = (0, process_identity_exports.inspectProcessIdentity)(record);
133
+ const chrome = record.chromeProcess ? chromeProcessState(record.chromeProcess) : "gone";
134
+ if (supervisor === "unknown" || chrome === "unknown") return {
135
+ record,
136
+ status: "unverified"
137
+ };
138
+ if (chrome === "gone") return {
139
+ record,
140
+ status: "stopped"
141
+ };
142
+ return {
143
+ record,
144
+ status: supervisor === "same" && chrome === "running" ? "running" : "orphaned"
145
+ };
146
+ }
147
+ //#endregion
148
+ export { readWebRecord as a, webDir as c, webProfileDir as d, webSupervisorLogFile as f, removeSingletonFiles as g, liveProfileHolder as h, clearWebRecord as i, webFacts as l, chromeProcessState as m, browserLogFile as n, updateWebRecord as o, writeWebRecord as p, cdpEndpoint as r, webClaimRoot as s, CDP_PORT_LABEL as t, webLogFile as u };
@@ -1,6 +1,6 @@
1
1
  import { s as gitCommonDir, y as repoRoot } from "./worktree-DeBQSVtR.mjs";
2
- import { i as findProjectRoot } from "./project-B8rbutVC.mjs";
3
- import { o as formatLongDuration } from "./command-output-BWCj5Vh-.mjs";
2
+ import { a as findProjectRoot } from "./project-DGeclhvO.mjs";
3
+ import { o as formatLongDuration } from "./command-output-BIL7rlX7.mjs";
4
4
  import { a as statsProjectKey, r as readStats } from "./stats-D8rUTPHd.mjs";
5
5
  import chalk from "chalk";
6
6
  //#region src/commands/stats.ts