stim 1.8.0 → 1.10.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.
- package/README.md +23 -155
- package/dist/{android-DWssqHQ8.mjs → android-787HhP5w.mjs} +168 -39
- package/dist/{android-BRgBYzU0.mjs → android-DBkeHwpm.mjs} +250 -200
- package/dist/{android-DeYdjjBP.mjs → android-DPov-fv2.mjs} +2 -2
- package/dist/{android-cas-SWIjzeuL.mjs → android-cas-CITmIeWY.mjs} +22 -14
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/app-install-CrJ6t_bv.mjs +819 -0
- package/dist/budget-BP4jZZL4.mjs +620 -0
- package/dist/build-progress-BXx-ZBe4.mjs +512 -0
- package/dist/{cache-manifest-CYJi8-Hx.mjs → cache-manifest-Pubfp8wV.mjs} +4 -4
- package/dist/cache-manifest.mjs +1 -1
- package/dist/cli.mjs +22 -19
- package/dist/collector-run.d.mts +7 -1
- package/dist/collector-run.mjs +10 -9
- package/dist/{command-output-B3ycpsYv.mjs → command-output-D5z2_bcF.mjs} +11 -2
- package/dist/{config-B7iyKWkL.mjs → config-BEq0Qw_a.mjs} +134 -121
- package/dist/{dependency-state-D0M7oKA7.mjs → dependency-state-r9UesA9a.mjs} +2 -2
- package/dist/{deps-oCXVNEqQ.mjs → deps-DP4eWqea.mjs} +8 -5
- package/dist/{detached-entry-Bpo6ZY_I.mjs → detached-entry-DJHoca49.mjs} +1 -1
- package/dist/{device-BUoZyMoR.mjs → dev-client-92U593KT.mjs} +1090 -660
- package/dist/{device-RdujjHLB.mjs → device-DhTZe7L4.mjs} +13 -20
- package/dist/{build-lock-CgtsB6TV.mjs → device-lease-CbEaIk7b.mjs} +481 -27
- package/dist/{device-pool-BxRwdufO.mjs → device-pool-Di8Q-9Ro.mjs} +7 -7
- package/dist/{device-remote-ByN8P6CB.mjs → device-remote-Dy1jGj3U.mjs} +645 -119
- package/dist/{doctor-BMt156qe.mjs → doctor-B-inAJmt.mjs} +137 -113
- package/dist/{error-diagnostics-D1Kaf-eT.mjs → error-diagnostics-xxWKNO3-.mjs} +22 -17
- package/dist/exec-DK8KaVHK.mjs +133 -0
- package/dist/{gc-v2YcoJvm.mjs → gc-ChPFZMRC.mjs} +836 -813
- package/dist/{guide-BTAlD1_y.mjs → guide-DwmaD_Wa.mjs} +953 -209
- package/dist/guide-status-CWvti2Lg.mjs +125 -0
- package/dist/idle-DpRLp5lj.mjs +157 -0
- package/dist/{build-slots-C-oAHRT1.mjs → in-use-CjUluqIX.mjs} +102 -8
- package/dist/{ios-BcCiI4TS.mjs → ios-B2Fpqvlb.mjs} +60 -71
- package/dist/{ios-BP04pY5f.mjs → ios-Dd-hYJBh.mjs} +241 -234
- package/dist/{ios-device-CFXA46ez.mjs → ios-device-BiOsSVzd.mjs} +3 -2
- package/dist/{ios-device-CauFJiYx.mjs → ios-device-CtRdEVjx.mjs} +149 -52
- package/dist/launch-verify-CQS_Kg-C.mjs +365 -0
- package/dist/{logs-CakdBTtm.mjs → logs-MARIy6m9.mjs} +20 -15
- package/dist/metro-BWLOJ_Wr.mjs +409 -0
- package/dist/{named-ports-DzMOlmaX.mjs → named-ports-DiTfSz6p.mjs} +4 -4
- package/dist/{ndjson-BZwI1NBv.mjs → ndjson-CDY9IkVC.mjs} +23 -43
- package/dist/{ndjson-DvHSsNU9.d.mts → ndjson-Du3j0AQ9.d.mts} +1 -0
- package/dist/{ownership-Cp52QAK1.mjs → ownership-D2xbLVoz.mjs} +2 -3
- package/dist/{teardown-BJqEzPo_.mjs → ownership-DZjdx8Gq.mjs} +664 -612
- package/dist/{ports-BIbJaKNW.mjs → ports-CLSSFOuz.mjs} +3 -3
- package/dist/{process-output-Dl5uKE03.mjs → process-output-Fpl8PYi8.mjs} +1 -1
- package/dist/{project-DDZWf_16.mjs → project-BXZzOABt.mjs} +8 -3
- package/dist/{reload-BdypPbjM.mjs → reload-DoETJ3rl.mjs} +11 -13
- package/dist/{server-bare-BQkyxa_b.mjs → server-bare-DVbb7kXH.mjs} +2 -2
- package/dist/{server-expo-BVAA1OqJ.mjs → server-expo-BvOCeakp.mjs} +8 -7
- package/dist/server-expo-DBVTdult.mjs +2 -0
- package/dist/{settings-BXXorVM2.mjs → settings-DOugPlPz.mjs} +59 -159
- package/dist/settings-EWYNwe72.mjs +378 -0
- package/dist/settings.schema.json +1064 -0
- package/dist/simslim-Ca3487H6.mjs +436 -0
- package/dist/{slot-launch-ZUUe0TQP.mjs → slot-launch-C5cg0fmk.mjs} +4 -4
- package/dist/spawn-claims-CUleC2cM.mjs +49 -0
- package/dist/{start-CmxtOKjU.mjs → start-F9gv5dcC.mjs} +159 -114
- package/dist/start-VoFsPSes.mjs +2 -0
- package/dist/{state-DZobzxLW.mjs → state-WGdIbi_d.mjs} +5 -3
- package/dist/{stats-BYcZ6n1h.mjs → stats-BAgJaLA4.mjs} +66 -5
- package/dist/{stats-CLg5RuDS.mjs → stats-DBYJ5bxL.mjs} +4 -4
- package/dist/status-DLCD-o3s.mjs +764 -0
- package/dist/status-Dr4fRkym.mjs +216 -0
- package/dist/{guide-status-Craq9z0t.mjs → stim-installations-CINXy_su.mjs} +3 -122
- package/dist/{stop-C8JW6kKp.mjs → stop-Dj4pfmyv.mjs} +111 -31
- package/dist/{stop-B1kOpYei.mjs → stop-ZvOeTmKb.mjs} +2 -2
- package/dist/supervisor-run.d.mts +11 -2
- package/dist/supervisor-run.mjs +228 -42
- package/dist/{workspace-process-lock-BYfZz_S-.mjs → workspace-process-lock-BXA96myD.mjs} +14 -9
- package/dist/workspaces-BTUyFfkv.mjs +1003 -0
- package/dist/worktree-4aZg2NnI.mjs +2 -0
- package/dist/{worktree-CFLA-6MX.mjs → worktree-BMS7GeqB.mjs} +523 -61
- package/dist/{worktree-FG_ZKKdb.mjs → worktree-BlizKDpZ.mjs} +200 -54
- package/dist/{xcode-B6YaWeg0.mjs → xcode-B2tBkf0m.mjs} +66 -57
- package/package.json +6 -6
- package/skill/SKILL.md +2 -0
- package/dist/app-install-BDbsSgCl.mjs +0 -1175
- package/dist/dev-client-BmT-ioFI.mjs +0 -797
- package/dist/device-lease-Ffz_M5t0.mjs +0 -359
- package/dist/exec-B29XNuhP.mjs +0 -77
- package/dist/logs-query-BGL-Pl12.mjs +0 -290
- package/dist/metro-C7bcJ0uo.mjs +0 -233
- package/dist/ownership-wolE-0Do.mjs +0 -470
- package/dist/public-http-probe-CyMDrQ3c.mjs +0 -61
- package/dist/reclaim-KJ-0uWEF.mjs +0 -361
- package/dist/server-expo-YDDG3eP7.mjs +0 -2
- package/dist/spawn-entry-nCE6m770.mjs +0 -14
- package/dist/status-DdkLki47.mjs +0 -426
- package/dist/workspace-state-BT5E3SA2.mjs +0 -146
- package/dist/{metro-store-CDDZHtPl.mjs → metro-store-DzeWkfqW.mjs} +1 -1
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import { B as validateDeviceSlot, D as withDirLock, F as deviceSlotKey, L as parseDeviceSlotKey, u as getConfigDir } from "./config-B7iyKWkL.mjs";
|
|
2
|
-
import { a as withWorkspaceStateLock, n as clearWorkspaceStateKeys, o as writeWorkspaceState, r as readWorkspaceState } from "./workspace-state-BT5E3SA2.mjs";
|
|
3
|
-
import { a as segment } from "./build-lock-CgtsB6TV.mjs";
|
|
4
|
-
import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { randomBytes } from "node:crypto";
|
|
6
|
-
import { join } from "node:path";
|
|
7
|
-
const DEFAULT_LEASE_MS = 3e5;
|
|
8
|
-
const LEASE_SUFFIX = ".json";
|
|
9
|
-
const LOCK_SUFFIX = ".lock";
|
|
10
|
-
const DURATION = /^[1-9][0-9]*(s|m)$/;
|
|
11
|
-
function deviceLocksDir() {
|
|
12
|
-
return join(getConfigDir(), "device-locks");
|
|
13
|
-
}
|
|
14
|
-
function leaseStem(platform, id) {
|
|
15
|
-
return `${segment(platform)}-${segment(id)}`;
|
|
16
|
-
}
|
|
17
|
-
function deviceLeasePath(platform, id) {
|
|
18
|
-
return join(deviceLocksDir(), `${leaseStem(platform, id)}${LEASE_SUFFIX}`);
|
|
19
|
-
}
|
|
20
|
-
function deviceLeaseLockPath(platform, id) {
|
|
21
|
-
return join(deviceLocksDir(), `${leaseStem(platform, id)}${LOCK_SUFFIX}`);
|
|
22
|
-
}
|
|
23
|
-
const fileLeaseIo = {
|
|
24
|
-
withHolderLock: withWorkspaceStateLock,
|
|
25
|
-
now: () => Date.now(),
|
|
26
|
-
readLease(path) {
|
|
27
|
-
try {
|
|
28
|
-
return readFileSync(path, "utf-8");
|
|
29
|
-
} catch {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
writeLease(path, body) {
|
|
34
|
-
mkdirSync(deviceLocksDir(), { recursive: true });
|
|
35
|
-
const tmp = `${path}.tmp-${process.pid}-${randomBytes(4).toString("hex")}`;
|
|
36
|
-
writeFileSync(tmp, body);
|
|
37
|
-
try {
|
|
38
|
-
renameSync(tmp, path);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
rmSync(tmp, { force: true });
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
removeLease(path) {
|
|
45
|
-
rmSync(path, { force: true });
|
|
46
|
-
},
|
|
47
|
-
listLeaseNames() {
|
|
48
|
-
try {
|
|
49
|
-
return readdirSync(deviceLocksDir());
|
|
50
|
-
} catch {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
withLeaseLock(lockPath, fn) {
|
|
55
|
-
return withDirLock(lockPath, fn, { ensureParent: () => mkdirSync(deviceLocksDir(), { recursive: true }) });
|
|
56
|
-
},
|
|
57
|
-
readHolder(root) {
|
|
58
|
-
return parseWorkspaceLeases(readWorkspaceState(root)?.deviceLeases);
|
|
59
|
-
},
|
|
60
|
-
writeHolder(root, leases) {
|
|
61
|
-
if (Object.keys(leases).length === 0) clearWorkspaceStateKeys(root, ["deviceLeases"]);
|
|
62
|
-
else writeWorkspaceState(root, { deviceLeases: leases });
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
function text(value) {
|
|
66
|
-
return typeof value === "string" && value.trim() !== "" ? value : null;
|
|
67
|
-
}
|
|
68
|
-
function isPlatform(value) {
|
|
69
|
-
return value === "ios" || value === "android";
|
|
70
|
-
}
|
|
71
|
-
function parseLease(raw) {
|
|
72
|
-
if (typeof raw !== "string") return null;
|
|
73
|
-
let parsed;
|
|
74
|
-
try {
|
|
75
|
-
parsed = JSON.parse(raw);
|
|
76
|
-
} catch {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
80
|
-
const entry = parsed;
|
|
81
|
-
if (entry.version !== 1 || !isPlatform(entry.platform)) return null;
|
|
82
|
-
const id = text(entry.id);
|
|
83
|
-
const holder = text(entry.holder);
|
|
84
|
-
const token = text(entry.token);
|
|
85
|
-
const expiresAt = text(entry.expiresAt);
|
|
86
|
-
if (!id || !holder || !token || !expiresAt || !Number.isFinite(Date.parse(expiresAt))) return null;
|
|
87
|
-
if (entry.slot !== void 0) {
|
|
88
|
-
if (typeof entry.slot !== "string") return null;
|
|
89
|
-
try {
|
|
90
|
-
validateDeviceSlot(entry.slot);
|
|
91
|
-
} catch {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
version: 1,
|
|
97
|
-
...typeof entry.slot === "string" ? { slot: entry.slot } : {},
|
|
98
|
-
platform: entry.platform,
|
|
99
|
-
id,
|
|
100
|
-
deviceName: text(entry.deviceName),
|
|
101
|
-
holder,
|
|
102
|
-
token,
|
|
103
|
-
grantedAt: text(entry.grantedAt),
|
|
104
|
-
expiresAt
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function parseWorkspaceLeases(value) {
|
|
108
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
109
|
-
const leases = {};
|
|
110
|
-
for (const [platform, entry] of Object.entries(value)) {
|
|
111
|
-
if (!parseDeviceSlotKey(platform) || !entry || typeof entry !== "object") continue;
|
|
112
|
-
const record = entry;
|
|
113
|
-
const id = text(record.id);
|
|
114
|
-
const token = text(record.token);
|
|
115
|
-
if (!id || !token) continue;
|
|
116
|
-
leases[platform] = {
|
|
117
|
-
id,
|
|
118
|
-
token,
|
|
119
|
-
kind: record.kind === "run" ? "run" : "declared"
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return leases;
|
|
123
|
-
}
|
|
124
|
-
function leaseIsExpired(lease, now) {
|
|
125
|
-
return Date.parse(lease.expiresAt) <= now;
|
|
126
|
-
}
|
|
127
|
-
function parseLeaseDuration(value) {
|
|
128
|
-
const raw = String(value ?? "").trim();
|
|
129
|
-
const match = DURATION.exec(raw);
|
|
130
|
-
if (!match) return { error: `--for must be a whole number of seconds or minutes, such as 90s or 5m (got "${raw}").` };
|
|
131
|
-
const ms = Number(raw.slice(0, -1)) * (match[1] === "s" ? 1e3 : 6e4);
|
|
132
|
-
if (ms < 1e4 || ms > 18e5) return { error: `--for must be between 10s and 30m (got "${raw}").` };
|
|
133
|
-
return { ms };
|
|
134
|
-
}
|
|
135
|
-
function listLeaseFiles(io = fileLeaseIo) {
|
|
136
|
-
const dir = deviceLocksDir();
|
|
137
|
-
const entries = [];
|
|
138
|
-
for (const name of io.listLeaseNames().toSorted()) {
|
|
139
|
-
if (!name.endsWith(LEASE_SUFFIX)) continue;
|
|
140
|
-
const path = join(dir, name);
|
|
141
|
-
const lease = parseLease(io.readLease(path));
|
|
142
|
-
const stem = name.slice(0, -5);
|
|
143
|
-
const cut = stem.indexOf("-");
|
|
144
|
-
entries.push({
|
|
145
|
-
path,
|
|
146
|
-
name,
|
|
147
|
-
platform: lease?.platform ?? (cut > 0 ? stem.slice(0, cut) : stem),
|
|
148
|
-
id: lease?.id ?? (cut > 0 ? stem.slice(cut + 1) : null),
|
|
149
|
-
lease
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
return entries;
|
|
153
|
-
}
|
|
154
|
-
function writeLease(lease, io) {
|
|
155
|
-
io.writeLease(deviceLeasePath(lease.platform, lease.id), `${JSON.stringify(lease, null, 2)}\n`);
|
|
156
|
-
return lease;
|
|
157
|
-
}
|
|
158
|
-
function takeLease({ root, platform, slot = "default", id, deviceName = null, kind, durationMs = DEFAULT_LEASE_MS }, io = fileLeaseIo) {
|
|
159
|
-
return withHolderLock(io, root, () => {
|
|
160
|
-
const key = deviceSlotKey(platform, slot);
|
|
161
|
-
const previous = io.readHolder(root)[key];
|
|
162
|
-
if (previous && previous.id !== id) releaseHeld(root, platform, previous, io, slot);
|
|
163
|
-
for (const entry of listLeaseFiles(io)) {
|
|
164
|
-
const other = entry.lease;
|
|
165
|
-
if (!other || other.platform !== platform || other.holder !== root || (other.slot ?? "default") !== slot || other.id === id) continue;
|
|
166
|
-
releaseByRoot(root, platform, other.id, io);
|
|
167
|
-
}
|
|
168
|
-
const declared = previous?.kind === "declared" && previous.id === id;
|
|
169
|
-
const path = deviceLeasePath(platform, id);
|
|
170
|
-
const result = io.withLeaseLock(deviceLeaseLockPath(platform, id), () => {
|
|
171
|
-
const now = io.now();
|
|
172
|
-
const raw = io.readLease(path);
|
|
173
|
-
const current = parseLease(raw);
|
|
174
|
-
if (raw !== null && !current) return {
|
|
175
|
-
status: "unreadable",
|
|
176
|
-
path
|
|
177
|
-
};
|
|
178
|
-
const asked = now + durationMs;
|
|
179
|
-
if (current && !leaseIsExpired(current, now)) {
|
|
180
|
-
if (current.holder !== root || (current.slot ?? "default") !== slot) return {
|
|
181
|
-
status: "held",
|
|
182
|
-
lease: current
|
|
183
|
-
};
|
|
184
|
-
const floor = declared && kind === "run" ? Math.max(asked, Date.parse(current.expiresAt)) : asked;
|
|
185
|
-
return {
|
|
186
|
-
status: "set",
|
|
187
|
-
lease: writeLease({
|
|
188
|
-
...current,
|
|
189
|
-
deviceName: deviceName ?? current.deviceName,
|
|
190
|
-
expiresAt: new Date(floor).toISOString()
|
|
191
|
-
}, io)
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
const expiresAt = new Date(asked).toISOString();
|
|
195
|
-
return {
|
|
196
|
-
status: "taken",
|
|
197
|
-
lease: writeLease({
|
|
198
|
-
version: 1,
|
|
199
|
-
...slot === "default" ? {} : { slot },
|
|
200
|
-
platform,
|
|
201
|
-
id,
|
|
202
|
-
deviceName,
|
|
203
|
-
holder: root,
|
|
204
|
-
token: randomBytes(12).toString("hex"),
|
|
205
|
-
grantedAt: new Date(now).toISOString(),
|
|
206
|
-
expiresAt
|
|
207
|
-
}, io)
|
|
208
|
-
};
|
|
209
|
-
});
|
|
210
|
-
if (result.status === "taken" || result.status === "set") {
|
|
211
|
-
const recorded = result.status === "set" && declared ? "declared" : kind;
|
|
212
|
-
io.writeHolder(root, {
|
|
213
|
-
...io.readHolder(root),
|
|
214
|
-
[key]: {
|
|
215
|
-
id,
|
|
216
|
-
token: result.lease.token,
|
|
217
|
-
kind: recorded
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
return result;
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
function raiseLease({ root, platform, slot = "default", minMs }, io = fileLeaseIo) {
|
|
225
|
-
const record = io.readHolder(root)[deviceSlotKey(platform, slot)];
|
|
226
|
-
if (!record) return { status: "none" };
|
|
227
|
-
const path = deviceLeasePath(platform, record.id);
|
|
228
|
-
return io.withLeaseLock(deviceLeaseLockPath(platform, record.id), () => {
|
|
229
|
-
const current = parseLease(io.readLease(path));
|
|
230
|
-
if (!current || current.token !== record.token) return {
|
|
231
|
-
status: "lost",
|
|
232
|
-
lease: current
|
|
233
|
-
};
|
|
234
|
-
const floor = io.now() + minMs;
|
|
235
|
-
if (Date.parse(current.expiresAt) >= floor) return {
|
|
236
|
-
status: "raised",
|
|
237
|
-
lease: current
|
|
238
|
-
};
|
|
239
|
-
return {
|
|
240
|
-
status: "raised",
|
|
241
|
-
lease: writeLease({
|
|
242
|
-
...current,
|
|
243
|
-
expiresAt: new Date(floor).toISOString()
|
|
244
|
-
}, io)
|
|
245
|
-
};
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
function summarize(lease) {
|
|
249
|
-
return {
|
|
250
|
-
platform: lease.platform,
|
|
251
|
-
id: lease.id,
|
|
252
|
-
deviceName: lease.deviceName,
|
|
253
|
-
expiresAt: lease.expiresAt
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
function releaseHeld(root, platform, record, io, slot = "default") {
|
|
257
|
-
const key = deviceSlotKey(platform, slot);
|
|
258
|
-
const path = deviceLeasePath(platform, record.id);
|
|
259
|
-
const released = io.withLeaseLock(deviceLeaseLockPath(platform, record.id), () => {
|
|
260
|
-
const current = parseLease(io.readLease(path));
|
|
261
|
-
if (!current || current.token !== record.token) return null;
|
|
262
|
-
io.removeLease(path);
|
|
263
|
-
return current;
|
|
264
|
-
});
|
|
265
|
-
const held = io.readHolder(root);
|
|
266
|
-
if (held[key]?.token === record.token) {
|
|
267
|
-
delete held[key];
|
|
268
|
-
io.writeHolder(root, held);
|
|
269
|
-
}
|
|
270
|
-
return released;
|
|
271
|
-
}
|
|
272
|
-
function releaseByRoot(root, platform, id, io) {
|
|
273
|
-
const path = deviceLeasePath(platform, id);
|
|
274
|
-
return io.withLeaseLock(deviceLeaseLockPath(platform, id), () => {
|
|
275
|
-
const current = parseLease(io.readLease(path));
|
|
276
|
-
if (!current || current.holder !== root) return null;
|
|
277
|
-
io.removeLease(path);
|
|
278
|
-
return current;
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
function releaseRunLease({ root, platform, slot = "default" }, io = fileLeaseIo) {
|
|
282
|
-
return withHolderLock(io, root, () => {
|
|
283
|
-
const record = io.readHolder(root)[deviceSlotKey(platform, slot)];
|
|
284
|
-
if (!record || record.kind !== "run") return null;
|
|
285
|
-
const released = releaseHeld(root, platform, record, io, slot);
|
|
286
|
-
return released ? summarize(released) : null;
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
function releaseWorkspaceLeases(root, { platform = null, slot = null } = {}, io = fileLeaseIo) {
|
|
290
|
-
return withHolderLock(io, root, () => {
|
|
291
|
-
const released = [];
|
|
292
|
-
for (const [name, record] of Object.entries(io.readHolder(root))) {
|
|
293
|
-
const parsed = parseDeviceSlotKey(name);
|
|
294
|
-
if (!parsed || platform && parsed.platform !== platform || slot !== null && parsed.slot !== slot) continue;
|
|
295
|
-
const lease = releaseHeld(root, parsed.platform, record, io, parsed.slot);
|
|
296
|
-
if (lease) released.push(summarize(lease));
|
|
297
|
-
}
|
|
298
|
-
for (const entry of listLeaseFiles(io)) {
|
|
299
|
-
const lease = entry.lease;
|
|
300
|
-
if (!lease || lease.holder !== root) continue;
|
|
301
|
-
if (platform && lease.platform !== platform) continue;
|
|
302
|
-
if (slot !== null && (lease.slot ?? "default") !== slot) continue;
|
|
303
|
-
const byRoot = releaseByRoot(root, lease.platform, lease.id, io);
|
|
304
|
-
if (byRoot) released.push(summarize(byRoot));
|
|
305
|
-
}
|
|
306
|
-
return released;
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
function removeExpiredLease(entry, io = fileLeaseIo) {
|
|
310
|
-
const lease = entry.lease;
|
|
311
|
-
if (!lease) return false;
|
|
312
|
-
return io.withLeaseLock(deviceLeaseLockPath(lease.platform, lease.id), () => {
|
|
313
|
-
const current = parseLease(io.readLease(entry.path));
|
|
314
|
-
if (!current || !leaseIsExpired(current, io.now())) return false;
|
|
315
|
-
io.removeLease(entry.path);
|
|
316
|
-
return true;
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
function selectPoolDevice({ candidates, leases, held = null, now }) {
|
|
320
|
-
const ordered = candidates.toSorted((a, b) => {
|
|
321
|
-
const left = a.id.toLowerCase();
|
|
322
|
-
const right = b.id.toLowerCase();
|
|
323
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
324
|
-
});
|
|
325
|
-
if (held) {
|
|
326
|
-
const mine = ordered.find((candidate) => candidate.id === held);
|
|
327
|
-
return mine ? {
|
|
328
|
-
status: "selected",
|
|
329
|
-
candidate: mine
|
|
330
|
-
} : {
|
|
331
|
-
status: "held-disconnected",
|
|
332
|
-
id: held
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
if (ordered.length === 0) return { status: "none" };
|
|
336
|
-
const byId = new Map(leases.map((lease) => [lease.id, lease]));
|
|
337
|
-
const holders = [];
|
|
338
|
-
for (const candidate of ordered) {
|
|
339
|
-
const lease = byId.get(candidate.id);
|
|
340
|
-
if (!lease || leaseIsExpired(lease, now)) return {
|
|
341
|
-
status: "selected",
|
|
342
|
-
candidate
|
|
343
|
-
};
|
|
344
|
-
holders.push({
|
|
345
|
-
id: lease.id,
|
|
346
|
-
holder: lease.holder,
|
|
347
|
-
expiresAt: lease.expiresAt
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
return {
|
|
351
|
-
status: "busy",
|
|
352
|
-
holders
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
function withHolderLock(io, root, fn) {
|
|
356
|
-
return io.withHolderLock ? io.withHolderLock(root, fn) : fn();
|
|
357
|
-
}
|
|
358
|
-
//#endregion
|
|
359
|
-
export { parseLease as a, releaseRunLease as c, selectPoolDevice as d, takeLease as f, listLeaseFiles as i, releaseWorkspaceLeases as l, fileLeaseIo as n, parseLeaseDuration as o, leaseIsExpired as r, raiseLease as s, deviceLeasePath as t, removeExpiredLease as u };
|
package/dist/exec-B29XNuhP.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
|
-
import spawn from "cross-spawn";
|
|
3
|
-
import which from "which";
|
|
4
|
-
//#region src/exec.ts
|
|
5
|
-
const MAX_BUFFER = 67108864;
|
|
6
|
-
let active = {
|
|
7
|
-
run(cmd, { timeoutMs, killSignal, cwd } = {}) {
|
|
8
|
-
const opts = {
|
|
9
|
-
encoding: "utf-8",
|
|
10
|
-
stdio: [
|
|
11
|
-
"pipe",
|
|
12
|
-
"pipe",
|
|
13
|
-
"pipe"
|
|
14
|
-
],
|
|
15
|
-
maxBuffer: MAX_BUFFER
|
|
16
|
-
};
|
|
17
|
-
if (timeoutMs) opts.timeout = timeoutMs;
|
|
18
|
-
if (killSignal) opts.killSignal = killSignal;
|
|
19
|
-
if (cwd) opts.cwd = cwd;
|
|
20
|
-
return String(execSync(cmd, opts)).trim();
|
|
21
|
-
},
|
|
22
|
-
runFile(file, args = [], { timeoutMs, killSignal, cwd, env, omitEnv } = {}) {
|
|
23
|
-
const opts = {
|
|
24
|
-
encoding: "utf-8",
|
|
25
|
-
stdio: [
|
|
26
|
-
"pipe",
|
|
27
|
-
"pipe",
|
|
28
|
-
"pipe"
|
|
29
|
-
],
|
|
30
|
-
maxBuffer: MAX_BUFFER
|
|
31
|
-
};
|
|
32
|
-
if (timeoutMs) opts.timeout = timeoutMs;
|
|
33
|
-
if (killSignal) opts.killSignal = killSignal;
|
|
34
|
-
if (cwd) opts.cwd = cwd;
|
|
35
|
-
if (env || omitEnv?.length) {
|
|
36
|
-
const childEnv = {
|
|
37
|
-
...process.env,
|
|
38
|
-
...env
|
|
39
|
-
};
|
|
40
|
-
for (const key of omitEnv ?? []) delete childEnv[key];
|
|
41
|
-
opts.env = childEnv;
|
|
42
|
-
}
|
|
43
|
-
const result = spawn.sync(file, args, opts);
|
|
44
|
-
if (result.error) throw Object.assign(result.error, result);
|
|
45
|
-
if (result.status !== 0) {
|
|
46
|
-
const stderr = String(result.stderr ?? "");
|
|
47
|
-
const message = `Command failed: ${[file, ...args].join(" ")}${stderr ? `\n${stderr}` : ""}`;
|
|
48
|
-
throw Object.assign(new Error(message), result);
|
|
49
|
-
}
|
|
50
|
-
return String(result.stdout).trim();
|
|
51
|
-
},
|
|
52
|
-
runQuiet(cmd, opts) {
|
|
53
|
-
try {
|
|
54
|
-
return this.run(cmd, opts);
|
|
55
|
-
} catch {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
runFileQuiet(file, args, opts) {
|
|
60
|
-
try {
|
|
61
|
-
return this.runFile(file, args, opts);
|
|
62
|
-
} catch {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
spawn(cmd, args = [], opts = {}) {
|
|
67
|
-
return spawn(cmd, args, opts);
|
|
68
|
-
},
|
|
69
|
-
findExecutable(name) {
|
|
70
|
-
return which.sync(name, { nothrow: true });
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
function getExecutor() {
|
|
74
|
-
return active;
|
|
75
|
-
}
|
|
76
|
-
//#endregion
|
|
77
|
-
export { getExecutor as t };
|