stim 1.3.0 → 1.4.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 (65) hide show
  1. package/README.md +17 -3
  2. package/dist/{android-CqcW1hrP.mjs → android-BTR1KTMP.mjs} +206 -120
  3. package/dist/{android-BqVIJoG7.mjs → android-BkM4qTaN.mjs} +76 -77
  4. package/dist/{android-cas-BR5YJBYv.mjs → android-cas-BjLRZyks.mjs} +15 -12
  5. package/dist/{app-install-DIp9riNx.mjs → app-install--PAocWvq.mjs} +2 -2
  6. package/dist/{build-slots-C3-R4XQr.mjs → build-slots-D6sDzOe-.mjs} +7 -8
  7. package/dist/{cache-manifest-CXR-Y8pH.mjs → cache-manifest-D02TpYjA.mjs} +1 -1
  8. package/dist/cache-manifest.mjs +1 -1
  9. package/dist/cli.mjs +14 -13
  10. package/dist/collector-run.mjs +4 -4
  11. package/dist/{command-output-8wHMEde0.mjs → command-output-BuIb_ZOI.mjs} +1 -4
  12. package/dist/{config-CcefMY2Q.mjs → config-6vdGngKa.mjs} +51 -51
  13. package/dist/dependency-state-BMirHEPD.mjs +76 -0
  14. package/dist/{deps-Spz8ozgo.mjs → deps-Ck4wuTwa.mjs} +1 -1
  15. package/dist/{dev-client-BjisHDB5.mjs → dev-client-Cd0v7iZk.mjs} +12 -12
  16. package/dist/{device-BkiW-gkk.mjs → device-CKXLnRRb.mjs} +7 -7
  17. package/dist/device-CMDFzx7C.mjs +1136 -0
  18. package/dist/{device-lease-BJYybF-2.mjs → device-lease-DDJr85OK.mjs} +3 -3
  19. package/dist/{device-pool-CPbLGfrB.mjs → device-pool-DJvbIBGW.mjs} +4 -4
  20. package/dist/{device-remote-AkYCKS8U.mjs → device-remote-CMfHhoc8.mjs} +7 -6
  21. package/dist/{doctor-Bmv86UUW.mjs → doctor-B_mfURdt.mjs} +536 -114
  22. package/dist/{error-diagnostics-DHC31rXA.mjs → error-diagnostics-_VmkqRZo.mjs} +8 -7
  23. package/dist/{gc-GGu-8ULN.mjs → gc-0AyxmECv.mjs} +61 -27
  24. package/dist/{guide-92CPA21s.mjs → guide-CGxdmQ0K.mjs} +236 -67
  25. package/dist/{ios-BSXFeO5H.mjs → ios-CtmGLx3X.mjs} +2667 -2607
  26. package/dist/{ios-device-CWOM_S44.mjs → ios-device-DJOi9FR5.mjs} +1 -1
  27. package/dist/{logs-DPNF4C9s.mjs → logs-BF3qPA7w.mjs} +32 -7
  28. package/dist/{logs-query-R-Cqc6Qv.mjs → logs-query-Cdp5aaCH.mjs} +1 -1
  29. package/dist/metro-DFLmaVz8.mjs +99 -0
  30. package/dist/named-ports-BO7Zpjp0.mjs +137 -0
  31. package/dist/{ownership-8O073GIC.mjs → ownership-BvSpZVBk.mjs} +5 -5
  32. package/dist/{ownership-BpCKiRlQ.mjs → ownership-C08Yzrp7.mjs} +6 -6
  33. package/dist/ports-BiKqP92J.mjs +39 -0
  34. package/dist/ports-ClqG8GPt.mjs +90 -0
  35. package/dist/{project-fKmuIaMI.mjs → project-CBFCwnN5.mjs} +2 -2
  36. package/dist/{reclaim-iW9Cad7k.mjs → reclaim-DpDVo-AP.mjs} +20 -13
  37. package/dist/{reload-DazHDSFA.mjs → reload-ByTqg6ZI.mjs} +8 -8
  38. package/dist/rolldown-runtime-BsOwBuO_.mjs +30 -0
  39. package/dist/{server-bare-DEzPZLvf.mjs → server-bare-Buk-k8tI.mjs} +3 -6
  40. package/dist/{server-expo-DizT4OMk.mjs → server-expo-D4P7iTvf.mjs} +3 -3
  41. package/dist/server-expo-Dho5Raiw.mjs +2 -0
  42. package/dist/{settings-DEJf6_kJ.mjs → settings-DwfltIXQ.mjs} +2 -2
  43. package/dist/{slot-launch-cci0xvmC.mjs → slot-launch-DeKen9e5.mjs} +4 -4
  44. package/dist/{start-mObjQH2W.mjs → start-BpKUHcU_.mjs} +16 -14
  45. package/dist/state-CDbvmZdt.mjs +131 -0
  46. package/dist/{stats-BR-kwj0B.mjs → stats-C59QLKm2.mjs} +1 -1
  47. package/dist/{stats-CaaQr4yN.mjs → stats-k5qMjyxo.mjs} +4 -4
  48. package/dist/{status-BxQNqu9t.mjs → status-Y2ij3dm6.mjs} +13 -12
  49. package/dist/{stop-DimGXEKY.mjs → stop-_P2OQwmZ.mjs} +15 -14
  50. package/dist/{stop-CrHGcjrV.mjs → stop-vKmmxhea.mjs} +2 -2
  51. package/dist/supervisor-run.d.mts +3 -27
  52. package/dist/supervisor-run.mjs +7 -6
  53. package/dist/{teardown-ClFp1Aax.mjs → teardown-KsPpvldq.mjs} +248 -110
  54. package/dist/{workspace-process-lock-3NcQnZ0X.mjs → workspace-process-lock-UEIrvZMJ.mjs} +4 -4
  55. package/dist/workspace-state-Do1e2mOH.mjs +146 -0
  56. package/dist/{worktree-DxTgN1CJ.mjs → worktree-BvcAIMdJ.mjs} +132 -123
  57. package/dist/{worktree-Eq6TLH8N.mjs → worktree-DWNx4tUg.mjs} +32 -2
  58. package/dist/xcode-D9tVItl-.mjs +860 -0
  59. package/package.json +7 -7
  60. package/dist/doctor-fAMXC4vl.mjs +0 -530
  61. package/dist/metro-CORqXyTL.mjs +0 -184
  62. package/dist/ownership-claim-Bf2CAfw3.mjs +0 -570
  63. package/dist/server-expo-44em5Pmg.mjs +0 -2
  64. package/dist/state-B3XA2wp2.mjs +0 -268
  65. package/dist/xcode-D7sAp-Zy.mjs +0 -1858
@@ -1,268 +0,0 @@
1
- import { D as sameProcessRecord, I as deviceSlotKey, R as parseDeviceSlotKey, k as withDirLock, u as getConfigDir } from "./config-CcefMY2Q.mjs";
2
- import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
3
- import { dirname } from "node:path";
4
- import { join as join$1, resolve as resolve$1 } from "path";
5
- import { buildCacheRoot as sharedBuildCache, workspaceId, workspaceName as workspaceName$1, workspaceStateDir as workspaceDir } from "@stim-cli/core";
6
- //#region src/paths.ts
7
- const WORKSPACE_METADATA_FILE_NAME = "workspace.json";
8
- function workspaceMetadataFile(projectRoot) {
9
- return join$1(workspaceDir(projectRoot), WORKSPACE_METADATA_FILE_NAME);
10
- }
11
- function ensureWorkspaceStorage(projectRoot) {
12
- const canonicalRoot = resolve$1(projectRoot);
13
- const dir = workspaceDir(canonicalRoot);
14
- const file = workspaceMetadataFile(canonicalRoot);
15
- mkdirSync(dir, { recursive: true });
16
- return withDirLock(join$1(dir, "metadata.lock"), () => {
17
- if (!existsSync(file)) {
18
- const metadata = {
19
- projectRoot: canonicalRoot,
20
- workspace: workspaceName$1(canonicalRoot),
21
- version: 1
22
- };
23
- const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
24
- writeFileSync(tmp, `${JSON.stringify(metadata, null, 2)}\n`);
25
- try {
26
- renameSync(tmp, file);
27
- } catch (error) {
28
- rmSync(tmp, { force: true });
29
- throw error;
30
- }
31
- return dir;
32
- }
33
- try {
34
- if (JSON.parse(readFileSync(file, "utf-8")).projectRoot === canonicalRoot) return dir;
35
- } catch {}
36
- const error = /* @__PURE__ */ new Error(`Stim workspace collision at ${dir}: its workspace.json does not belong to ${canonicalRoot}.`);
37
- error.code = "STIM_WORKSPACE_COLLISION";
38
- throw error;
39
- });
40
- }
41
- function workspaceLogsDir(projectRoot) {
42
- return join$1(workspaceDir(projectRoot), "logs");
43
- }
44
- function workspaceDerivedData(projectRoot) {
45
- return join$1(workspaceDir(projectRoot), "derived-data");
46
- }
47
- function supervisorPidFile(projectRoot) {
48
- return join$1(workspaceDir(projectRoot), "supervisor.pid");
49
- }
50
- function workspaceStateFile(projectRoot) {
51
- return join$1(workspaceDir(projectRoot), "state.json");
52
- }
53
- function workspaceStateLock(projectRoot) {
54
- return join$1(workspaceDir(projectRoot), "state.lock");
55
- }
56
- function supervisorLogFile(projectRoot) {
57
- return join$1(workspaceLogsDir(projectRoot), "supervisor.log");
58
- }
59
- function emulatorLogFile(projectRoot) {
60
- return join$1(workspaceLogsDir(projectRoot), "emulator.log");
61
- }
62
- function sharedCompilationCache() {
63
- return join$1(getConfigDir(), "compilation-cache");
64
- }
65
- function sharedCcache() {
66
- return join$1(getConfigDir(), "ccache");
67
- }
68
- //#endregion
69
- //#region src/supervisor/state.ts
70
- const MODE_BARE = "bare-inproc";
71
- const MODE_EXPO = "expo-child";
72
- function readMetroTunnel(root) {
73
- const record = readWorkspaceState(root)?.metroTunnel;
74
- if (!record || typeof record !== "object") return null;
75
- const kind = record.kind;
76
- const url = record.url;
77
- if (typeof url !== "string" || url.length === 0) return null;
78
- if (kind === "expo") return {
79
- kind: "expo",
80
- url
81
- };
82
- if (kind === "managed") {
83
- const provider = record.provider;
84
- const pid = record.pid;
85
- const port = record.port;
86
- const startedAt = record.startedAt;
87
- const processToken = record.processToken;
88
- const logFile = record.logFile;
89
- if (provider !== "ngrok" && provider !== "cloudflared" || typeof pid !== "number" || typeof port !== "number") return null;
90
- return {
91
- kind: "managed",
92
- provider,
93
- pid,
94
- url,
95
- port,
96
- startedAt: typeof startedAt === "string" ? startedAt : "",
97
- processToken: typeof processToken === "string" && processToken.length > 0 ? processToken : null,
98
- ...typeof logFile === "string" && logFile.length > 0 ? { logFile } : {}
99
- };
100
- }
101
- return null;
102
- }
103
- function readWorkspaceState(root) {
104
- try {
105
- const parsed = JSON.parse(readFileSync(workspaceStateFile(root), "utf-8"));
106
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
107
- return parsed;
108
- } catch {
109
- return null;
110
- }
111
- }
112
- function parseWorkspaceLaunchRecord(value) {
113
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
114
- const record = value;
115
- if (typeof record.appId !== "string" || record.appId.length === 0) return null;
116
- if (typeof record.deviceId !== "string" || record.deviceId.length === 0) return null;
117
- if (record.metroPort !== null && typeof record.metroPort !== "number") return null;
118
- if (typeof record.release !== "boolean") return null;
119
- if (typeof record.launchedAt !== "string") return null;
120
- return record;
121
- }
122
- function readWorkspaceLaunches(root) {
123
- const launches = readWorkspaceState(root)?.launches;
124
- if (!launches || typeof launches !== "object" || Array.isArray(launches)) return {};
125
- const records = {};
126
- for (const [key, value] of Object.entries(launches)) {
127
- const record = parseWorkspaceLaunchRecord(value);
128
- if (parseDeviceSlotKey(key) && record) records[key] = record;
129
- }
130
- return records;
131
- }
132
- function writeWorkspaceLaunch(root, platform, record, slot = "default") {
133
- withWorkspaceStateLock(root, () => {
134
- const state = readWorkspaceState(root) ?? {};
135
- const launches = state.launches && typeof state.launches === "object" ? state.launches : {};
136
- replaceWorkspaceState(root, {
137
- ...state,
138
- launches: {
139
- ...launches,
140
- [deviceSlotKey(platform, slot)]: record
141
- }
142
- });
143
- });
144
- }
145
- function readRemoteSession(root) {
146
- const record = readWorkspaceState(root)?.remoteDevice;
147
- if (!record || typeof record !== "object") return null;
148
- const id = record.sessionId;
149
- if (typeof id !== "string" || id.length === 0) return null;
150
- const platform = record.platform;
151
- const startedAt = record.startedAt;
152
- return {
153
- platform: platform === "ios" || platform === "android" ? platform : null,
154
- sessionId: id,
155
- startedAt: typeof startedAt === "string" ? startedAt : null
156
- };
157
- }
158
- function readRemoteSessionId(root) {
159
- return readRemoteSession(root)?.sessionId ?? null;
160
- }
161
- function clearRemoteSession(root, expectedSessionId) {
162
- clearWorkspaceStateKey(root, "remoteDevice", (value) => {
163
- if (typeof value !== "object" || value === null) return false;
164
- return value.sessionId === expectedSessionId;
165
- });
166
- }
167
- function withWorkspaceStateLock(root, fn) {
168
- const file = workspaceStateFile(root);
169
- return withDirLock(workspaceStateLock(root), fn, { ensureParent: () => {
170
- ensureWorkspaceStorage(root);
171
- mkdirSync(dirname(file), { recursive: true });
172
- } });
173
- }
174
- function writeWorkspaceState(root, patch) {
175
- return withWorkspaceStateLock(root, () => replaceWorkspaceState(root, {
176
- ...readWorkspaceState(root),
177
- ...patch
178
- }));
179
- }
180
- function replaceWorkspaceState(root, state) {
181
- const file = workspaceStateFile(root);
182
- mkdirSync(dirname(file), { recursive: true });
183
- const tmp = `${file}.tmp-${process.pid}`;
184
- writeFileSync(tmp, `${JSON.stringify(state, null, 2)}\n`);
185
- renameSync(tmp, file);
186
- return state;
187
- }
188
- function clearWorkspaceSupervisor(root, expected) {
189
- return withWorkspaceStateLock(root, () => {
190
- const current = readWorkspaceState(root)?.supervisor;
191
- if (current && expected !== void 0 && !sameProcessRecord(current, expected)) return false;
192
- clearWorkspaceStateKey(root, "supervisor", () => true);
193
- clearExpoMetroTunnel(root);
194
- if (expected === void 0 || readPidFile(root) === expected?.pid) rmSync(supervisorPidFile(root), { force: true });
195
- return true;
196
- });
197
- }
198
- function clearExpoMetroTunnel(root) {
199
- clearWorkspaceStateKey(root, "metroTunnel", (value) => {
200
- return typeof value === "object" && value !== null && value.kind === "expo";
201
- });
202
- }
203
- function clearManagedMetroTunnel(root, expected) {
204
- if (!existsSync(workspaceStateFile(root))) return true;
205
- return clearWorkspaceStateKey(root, "metroTunnel", (value) => {
206
- if (typeof value !== "object" || value === null) return false;
207
- const record = value;
208
- return record.kind === "managed" && record.provider === expected.provider && record.pid === expected.pid && record.url === expected.url && record.port === expected.port && record.startedAt === expected.startedAt && (record.processToken ?? null) === (expected.processToken ?? null) && (record.logFile ?? null) === (expected.logFile ?? null);
209
- });
210
- }
211
- function clearWorkspaceStateKeys(root, keys) {
212
- if (!existsSync(workspaceStateFile(root))) return;
213
- withWorkspaceStateLock(root, () => {
214
- const state = readWorkspaceState(root);
215
- const file = workspaceStateFile(root);
216
- if (!state) {
217
- try {
218
- rmSync(file, { force: true });
219
- } catch {}
220
- return;
221
- }
222
- let changed = false;
223
- for (const key of keys) {
224
- if (!(key in state)) continue;
225
- delete state[key];
226
- changed = true;
227
- }
228
- if (!changed) return;
229
- if (Object.keys(state).length === 0) {
230
- rmSync(file, { force: true });
231
- return;
232
- }
233
- replaceWorkspaceState(root, state);
234
- });
235
- }
236
- function clearWorkspaceStateKey(root, key, shouldClear) {
237
- return withWorkspaceStateLock(root, () => {
238
- const state = readWorkspaceState(root);
239
- if (!state || !(key in state)) return true;
240
- if (!shouldClear(state[key])) return false;
241
- delete state[key];
242
- const file = workspaceStateFile(root);
243
- if (Object.keys(state).length === 0) {
244
- try {
245
- rmSync(file, { force: true });
246
- } catch {}
247
- return true;
248
- }
249
- replaceWorkspaceState(root, state);
250
- return true;
251
- });
252
- }
253
- function writePidFile(root, pid) {
254
- const file = supervisorPidFile(root);
255
- mkdirSync(dirname(file), { recursive: true });
256
- writeFileSync(file, `${pid}\n`);
257
- return file;
258
- }
259
- function readPidFile(root) {
260
- try {
261
- const pid = parseInt(readFileSync(supervisorPidFile(root), "utf-8").trim(), 10);
262
- return Number.isFinite(pid) ? pid : null;
263
- } catch {
264
- return null;
265
- }
266
- }
267
- //#endregion
268
- export { supervisorLogFile as C, workspaceLogsDir as D, workspaceId as E, workspaceName$1 as O, sharedCompilationCache as S, workspaceDir as T, writeWorkspaceState as _, clearRemoteSession as a, sharedBuildCache as b, readMetroTunnel as c, readRemoteSessionId as d, readWorkspaceLaunches as f, writeWorkspaceLaunch as g, writePidFile as h, clearManagedMetroTunnel as i, workspaceStateFile as k, readPidFile as l, withWorkspaceStateLock as m, MODE_EXPO as n, clearWorkspaceStateKeys as o, readWorkspaceState as p, clearExpoMetroTunnel as r, clearWorkspaceSupervisor as s, MODE_BARE as t, readRemoteSession as u, emulatorLogFile as v, workspaceDerivedData as w, sharedCcache as x, ensureWorkspaceStorage as y };