stim 1.17.2 → 1.19.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 +50 -1
- package/dist/{activity-IRvJY_ru.mjs → activity-BSw0x84R.mjs} +4 -4
- package/dist/{agent-device-usage-output-BK41vnzN.mjs → agent-device-usage-output-Bjxu_VmX.mjs} +8 -8
- package/dist/{android-B9yaNKwa.mjs → android-BXc6BmEi.mjs} +658 -404
- package/dist/{android-B_YNZy61.mjs → android-BdQC6zs1.mjs} +9 -9
- package/dist/android-BvV1gGdN.mjs +4 -0
- package/dist/{android-DE4v59Mb.mjs → android-DE5g_5gv.mjs} +2 -2
- package/dist/{android-cas-ZFpjJBL_.mjs → android-cas-C87geAg-.mjs} +5 -5
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/api-DIf_s86s.mjs +150 -0
- package/dist/api-run.d.mts +1 -0
- package/dist/api-run.mjs +145 -0
- package/dist/api.d.mts +218 -0
- package/dist/api.mjs +2 -0
- package/dist/{app-install-VPkI5WEg.mjs → app-install-CFI4ptUL.mjs} +33 -13
- package/dist/{attempt-Bk2ouQVL.mjs → attempt-DW-mQqM7.mjs} +14 -4
- package/dist/{web-Dl0KSRHf.mjs → browser-web-CDhqQxhv.mjs} +138 -176
- package/dist/{budget-DfcgFdQB.mjs → budget-Dz-kyXLv.mjs} +1391 -58
- package/dist/build-facts-B87vo-Im.d.mts +142 -0
- package/dist/{cache-manifest-DnUHBJaU.mjs → cache-manifest-DiwKSyv9.mjs} +3 -3
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{chrome-BrcVWQyD.mjs → chrome-BTUOo8p2.mjs} +1 -1
- package/dist/cli-C9Zvgbdc.mjs +68 -0
- package/dist/cli.mjs +1 -1
- package/dist/{client-SvBdgObD.mjs → client-CuUo8Nvg.mjs} +381 -49
- package/dist/collector-run.d.mts +6 -0
- package/dist/collector-run.mjs +9 -9
- package/dist/{command-output-CDAIFD-8.mjs → command-output-Bt8ygHE7.mjs} +2 -2
- package/dist/{config-D0DbpZtM.mjs → config-DC5jEtd1.mjs} +9 -5
- package/dist/{created-devices-CpvzBL25.mjs → created-devices-D0s26Hx5.mjs} +2 -2
- package/dist/{dependency-state-CLcBHH2M.mjs → dependency-state-DKaS1OM9.mjs} +2 -2
- package/dist/{detached-entry-CiTEgMR1.mjs → detached-entry-pB_IPfV4.mjs} +1 -1
- package/dist/{dev-client-B-XC4uRH.mjs → dev-client-CDY_zAmD.mjs} +2 -2
- package/dist/{device-C8IOoJPv.mjs → device-BHw0WlHl.mjs} +8 -8
- package/dist/{device-capacity-ZC4XSZ4R.mjs → device-capacity-BoN1jQkO.mjs} +25 -14
- package/dist/device-host-worker.mjs +19 -19
- package/dist/{gradle-dJpre3Yn.mjs → device-ios-B2ruohE-.mjs} +661 -107
- package/dist/{device-lease-DpoS36_u.mjs → device-lease-Cu7PtQpZ.mjs} +9 -9
- package/dist/{device-lease-run-B8YltIH_.mjs → device-lease-run-D38SnZtt.mjs} +4 -4
- package/dist/{device-pool-3o7s5lo4.mjs → device-pool-CP4rAsHx.mjs} +3 -3
- package/dist/{device-remote-hFSkpfQu.mjs → device-remote-B5GiUifk.mjs} +15 -16
- package/dist/{doctor-CFv1fCrF.mjs → doctor-PRJH94v6.mjs} +61 -34
- package/dist/doctor-watchman-wZhyTdp4.mjs +259 -0
- package/dist/{error-diagnostics-C-NMnhrk.mjs → error-diagnostics--v5HGOU0.mjs} +11 -11
- package/dist/{exec-CaErVv7t.mjs → exec-i8GDPwq9.mjs} +93 -6
- package/dist/{gc-DEmkg3Xh.mjs → gc-CyHMcKcn.mjs} +25 -471
- package/dist/{guide-CSmhMTf8.mjs → guide-dRaQJJk9.mjs} +681 -507
- package/dist/{hosted-android-E1Heoqnv.mjs → hosted-android-Bs7fytj7.mjs} +3 -3
- package/dist/{hosted-client-Bp4knSwu.mjs → hosted-client-C5G4h_OJ.mjs} +2 -2
- package/dist/{hosted-ios-BnbeYOUD.mjs → hosted-ios-Bik035eL.mjs} +1 -1
- package/dist/{hosted-logs-OcgIBvCT.mjs → hosted-logs-CI9Az9a4.mjs} +9 -9
- package/dist/{hosted-macos-DcxKjtfH.mjs → hosted-macos-DABm3ScO.mjs} +5 -5
- package/dist/{hosted-native-1Ebbig4w.mjs → hosted-native-DbV2aUVw.mjs} +13 -9
- package/dist/{idle-shutdown-IGyNV8Cr.mjs → idle-shutdown-DYiMBn34.mjs} +7 -8
- package/dist/{ios-DSfnPfse.mjs → ios-BWbHFZVz.mjs} +19 -7
- package/dist/{ios-Cr1h5gnO.mjs → ios-DCrkgXEM.mjs} +1 -1
- package/dist/ios-DYUr9LGc.mjs +8 -0
- package/dist/ios-ITYno9rO.mjs +2241 -0
- package/dist/{ios-device-pAN4t54-.mjs → ios-device-CJ_ZOGky.mjs} +3 -3
- package/dist/{ios-device-Ee7sDXfp.mjs → ios-device-CrW8aMb5.mjs} +1 -1
- package/dist/{ios-state-8L3lgum6.mjs → ios-state-By0XuLTQ.mjs} +1 -1
- package/dist/{launch-verify-lTnWZikR.mjs → launch-verify-DCveSE6d.mjs} +5 -5
- package/dist/{logs-BAaS7gS2.mjs → logs-Bao1HOMy.mjs} +13 -13
- package/dist/{macos-BIRQS90f.mjs → macos-ciyBdTY5.mjs} +194 -132
- package/dist/macos-nIOATJmR.mjs +2 -0
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +349 -47
- package/dist/manifest-CX0d1IkZ.mjs +148 -0
- package/dist/{metro-g8NqiJp-.mjs → metro-DI2AjPF_.mjs} +196 -43
- package/dist/{metro-gateway-C-ijGI2F.mjs → metro-gateway-BxpJLIwh.mjs} +4 -4
- package/dist/{metro-store-CDDZHtPl.mjs → metro-store-BAHFcJm6.mjs} +16 -2
- package/dist/{build-plan-BDsSi09V.mjs → miss-reason-CjQCOKqq.mjs} +207 -249
- package/dist/{named-ports-C8m8EQs2.mjs → named-ports-B4iWH4E-.mjs} +70 -8
- package/dist/{native-runtime-BEK171xQ.mjs → native-runtime-BGxsbfny.mjs} +6 -6
- package/dist/{ndjson-PclOIwVY.mjs → ndjson-LGZAMsqa.mjs} +8 -4
- package/dist/offload-worker.d.mts +3 -45
- package/dist/offload-worker.mjs +11 -11
- package/dist/{ownership-DyRQru0q.mjs → ownership-EB0ySdGK.mjs} +3 -3
- package/dist/{page-QF_Ke10s.mjs → page-Bv9s2KwY.mjs} +1 -1
- package/dist/placement-log-Dxe34rJm.mjs +88 -0
- package/dist/plan-placement-BVY59qa8.mjs +290 -0
- package/dist/{ports-4nYqxPWC.mjs → ports-ByPc0_97.mjs} +3 -3
- package/dist/{prebuild-D7RUMkwN.mjs → prebuild-BKJ3wJI1.mjs} +5 -5
- package/dist/preview-BbSottmO.mjs +986 -0
- package/dist/{rolldown-runtime-BsOwBuO_.mjs → process-identity-Biv3arCO.mjs} +11 -1
- package/dist/project-B5eQ1USs.mjs +612 -0
- package/dist/{pull-request-pxnDCQzn.mjs → pull-request-IHNdMnG8.mjs} +1 -1
- package/dist/pull-requests.mjs +1 -1
- package/dist/react-native-ios-BMh2i25I.mjs +2 -0
- package/dist/react-native-ios-CSpIxexZ.mjs +2083 -0
- package/dist/{recordings-BNgsD1Tr.mjs → recordings-Bv8McZN4.mjs} +1 -1
- package/dist/{reload-DcRxj3qG.mjs → reload-rAPdqeRR.mjs} +14 -15
- package/dist/{remote-cache-Ci4DQYYj.mjs → remote-cache-N3hAEaAL.mjs} +5 -5
- package/dist/{run-CkE9y0nc.mjs → run-lAkle1-c.mjs} +5 -5
- package/dist/{server-bare-BkrSxSsZ.mjs → server-bare-CkIjnegq.mjs} +5 -6
- package/dist/server-expo-DGsdUGX2.mjs +2 -0
- package/dist/{server-expo-CHTyXD0G.mjs → server-expo-n3tUi3Em.mjs} +5 -6
- package/dist/{settings-SR9OmW9h.mjs → settings-2am7TSxp.mjs} +5 -5
- package/dist/{settings-Cfd-0r2d.mjs → settings-CxgngUZk.mjs} +116 -103
- package/dist/{settings-BBpMcDbD.mjs → settings-Djl-mpjX.mjs} +1 -1
- package/dist/settings.schema.json +198 -9
- package/dist/{simslim-BWNrc3M3.mjs → simslim-D9LkJxIO.mjs} +7 -7
- package/dist/{slot-launch-DmjBmpQV.mjs → slot-launch-HV_KtPIw.mjs} +6 -6
- package/dist/{spawn-claims-D0XfSe8u.mjs → spawn-claims-Kqiifsk2.mjs} +1 -1
- package/dist/{spawn-entry-jw19m8Nl.mjs → spawn-entry-Dcb7sDUz.mjs} +1 -0
- package/dist/{stage-CzaiwFsI.mjs → stage-BgaZJVZY.mjs} +14 -3
- package/dist/{start-AlfCPRVU.mjs → start-D8NbxNBb.mjs} +1 -1
- package/dist/{start-DUz3mYdb.mjs → start-DtxthMfI.mjs} +34 -27
- package/dist/{state-PeQiJuIu.mjs → state-D2KtnALG.mjs} +4 -4
- package/dist/{state-DyaNTgfR.mjs → state-Tp4uImDS.mjs} +5 -3
- package/dist/{state-B4PQFXMW.d.mts → state-lKh8shBp.d.mts} +2 -3
- package/dist/{stats-Bq4fJOdB.mjs → stats-8EJ5ivFT.mjs} +6 -6
- package/dist/{status-DlKvVJBE.mjs → status-BEeL6IKz.mjs} +6 -4
- package/dist/{status-BA2pehwf.mjs → status-BOyp0CUl.mjs} +31 -34
- package/dist/{stim-desktop-Cnz8CPnl.mjs → stim-desktop-C65jk_q2.mjs} +1 -1
- package/dist/{stim-installations-QMEI32v1.mjs → stim-installations-DbmUjsLv.mjs} +1 -1
- package/dist/stop-D0UIpZuh.mjs +72 -0
- package/dist/{stop-zF1y04f2.mjs → stop-DRipAg-e.mjs} +2 -2
- package/dist/{stop-DQIasgKp.mjs → stop-zDlknFoz.mjs} +79 -33
- package/dist/supervisor-run.d.mts +24 -22
- package/dist/supervisor-run.mjs +21 -22
- package/dist/{support-CsJNVfOc.mjs → support-CNqYkV0y.mjs} +7 -7
- package/dist/{support-WvD__tSV.mjs → support-DsNaFg6D.mjs} +5 -5
- package/dist/swiftpm-macos-aJzPAj1t.mjs +119 -0
- package/dist/{toolchain-DNyR3NPq.mjs → toolchain-C3xSoyUl.mjs} +475 -269
- package/dist/{trigger-Bemu8ytw.mjs → trigger-CAhmG-4s.mjs} +6 -6
- package/dist/trigger-CoalsMTV.mjs +2 -0
- package/dist/{warm-progress-DF4JRvYI.mjs → warm-progress-pFLB2e6P.mjs} +135 -38
- package/dist/{status-CzS4bPO9.mjs → watchman-BL1IdOtq.mjs} +75 -7
- package/dist/web-DFpFeZu5.mjs +2 -0
- package/dist/web-DbbrPUn0.mjs +127 -0
- package/dist/web-run.mjs +10 -10
- package/dist/{workspace-state-DqcCbpE7.mjs → workspace-state-CR9X86xJ.mjs} +3 -3
- package/dist/{ownership-BMLqyBgJ.mjs → workspaces-Djb2gfi9.mjs} +661 -23
- package/dist/{worktree-Be_7NLKy.mjs → worktree-BL4M1rhB.mjs} +252 -50
- package/dist/{worktree-j3IcFAI5.mjs → worktree-DV-A0LNL.mjs} +1 -1
- package/package.json +10 -5
- package/shim/bundle-response.cjs +2 -1
- package/shim/bundle-response.d.cts +1 -1
- package/shim/expo-metro-config.cjs +1 -1
- package/dist/build-progress-D0WkjCPd.mjs +0 -1036
- package/dist/build-slots-41v_d2x9.mjs +0 -142
- package/dist/cli-CYXb29oE.mjs +0 -51
- package/dist/deps-iKw0eD4P.mjs +0 -438
- package/dist/device-ios-C2Um-XUR.mjs +0 -412
- package/dist/errors-B6W7FkxQ.mjs +0 -15
- package/dist/guide-status-Du-ZQ3FD.mjs +0 -125
- package/dist/idle-BXG__1BA.mjs +0 -176
- package/dist/in-use-CvGOUn-x.mjs +0 -130
- package/dist/ios-BJ4XUSe1.mjs +0 -3867
- package/dist/native-run-D1Q56rAD.mjs +0 -158
- package/dist/preview-B-g9d7kV.mjs +0 -318
- package/dist/process-identity-BmRm1qV0.mjs +0 -12
- package/dist/project-D47Rh0ly.mjs +0 -276
- package/dist/server-expo-CeakhI8P.mjs +0 -2
- package/dist/state-BKa8wNN5.mjs +0 -148
- package/dist/stop-BIiM49EY.mjs +0 -48
- package/dist/stop-cause-rhmGfwvt.mjs +0 -97
- package/dist/trigger-CXts6qt1.mjs +0 -2
- package/dist/watchman-APYjXSQa.mjs +0 -48
- package/dist/workspace-process-lock-2mNzOlaB.mjs +0 -58
- package/dist/workspaces-Bcib97-6.mjs +0 -306
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { a as formatElapsed } from "./command-output-CDAIFD-8.mjs";
|
|
2
|
-
import { a as updateWorkspaceState, r as readWorkspaceState, t as clearWorkspaceStateKey, v as workspaceDir } from "./workspace-state-DqcCbpE7.mjs";
|
|
3
|
-
import { i as signalDeclaredSpawns, r as refuseDeclaredSpawns, t as allowDeclaredSpawns } from "./spawn-claims-D0XfSe8u.mjs";
|
|
4
|
-
import { t as withWorkspaceProcessLock } from "./workspace-process-lock-2mNzOlaB.mjs";
|
|
5
|
-
//#region src/engine/native-run.ts
|
|
6
|
-
const NATIVE_RUN_LOCK = "native-run";
|
|
7
|
-
const NATIVE_RUN_WAIT_MS = 18e5;
|
|
8
|
-
const WAIT_HEARTBEAT_MS = 3e4;
|
|
9
|
-
const CANCEL_REQUEST_KEY = "nativeRunCancel";
|
|
10
|
-
function nativeRunHolder(holder) {
|
|
11
|
-
const { command, platform, slot } = holder.details;
|
|
12
|
-
return {
|
|
13
|
-
command: typeof command === "string" ? command : null,
|
|
14
|
-
platform: typeof platform === "string" ? platform : null,
|
|
15
|
-
slot: typeof slot === "string" ? slot : "default"
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function describeNativeRunHolder(holder, now) {
|
|
19
|
-
const { command, slot } = nativeRunHolder(holder);
|
|
20
|
-
const started = Date.parse(holder.startedAt);
|
|
21
|
-
const facts = [`pid ${holder.owner.pid}`];
|
|
22
|
-
if (Number.isFinite(started)) facts.push(`running for ${formatElapsed(now - started)}`);
|
|
23
|
-
if (command === null) return `another Stim run (${facts.join(", ")})`;
|
|
24
|
-
return `\`stim ${command}${slot === "default" ? "" : ` --slot ${slot}`}\` (${facts.join(", ")})`;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Report a wait on the native-run lock: one line as soon as a holder is seen, a line for each new
|
|
28
|
-
* holder, and a heartbeat every WAIT_HEARTBEAT_MS while the same holder keeps it.
|
|
29
|
-
*/
|
|
30
|
-
function nativeRunWaitNotice({ write, now = Date.now, describe = describeNativeRunHolder }) {
|
|
31
|
-
let claimId = null;
|
|
32
|
-
let lastAt = 0;
|
|
33
|
-
return (holder, firstLine) => {
|
|
34
|
-
const at = now();
|
|
35
|
-
if (holder.claimId !== claimId) {
|
|
36
|
-
claimId = holder.claimId;
|
|
37
|
-
lastAt = at;
|
|
38
|
-
write(firstLine ?? `waiting for ${describe(holder, at)} in this workspace to finish`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (at - lastAt < WAIT_HEARTBEAT_MS) return;
|
|
42
|
-
lastAt = at;
|
|
43
|
-
write(`still waiting for ${describe(holder, at)}`);
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* What `stop` does about the run holding the native-run lock. A build is interrupted only when the stop
|
|
48
|
-
* leaves it nothing to deploy to: the whole workspace stops, the build targets the stopped slot, or the
|
|
49
|
-
* stopped slot is the workspace's only device. A build for another slot that stays is left running and
|
|
50
|
-
* the stop proceeds without the lock. Only an owner whose identity is proven live is signalled.
|
|
51
|
-
*/
|
|
52
|
-
function decideStopAction({ stopSlot, holder, ownerIdentity, deviceSlots }) {
|
|
53
|
-
if (holder.command === "macos") {
|
|
54
|
-
if (stopSlot !== void 0) return { action: "proceed" };
|
|
55
|
-
return ownerIdentity === "same" ? { action: "interrupt" } : { action: "refuse" };
|
|
56
|
-
}
|
|
57
|
-
if (holder.command !== "ios" && holder.command !== "android") return { action: "wait" };
|
|
58
|
-
if (!(stopSlot === void 0 || holder.slot === stopSlot || deviceSlots.includes(stopSlot) && deviceSlots.every((slot) => slot === stopSlot))) return { action: "proceed" };
|
|
59
|
-
return ownerIdentity === "same" ? { action: "interrupt" } : { action: "refuse" };
|
|
60
|
-
}
|
|
61
|
-
function requestNativeRunCancel(root, claimId, pid = process.pid) {
|
|
62
|
-
updateWorkspaceState(root, (state) => ({
|
|
63
|
-
...state,
|
|
64
|
-
[CANCEL_REQUEST_KEY]: {
|
|
65
|
-
claimId,
|
|
66
|
-
pid,
|
|
67
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
function cancelRequestFor(root, claimId) {
|
|
72
|
-
const request = readWorkspaceState(root)?.[CANCEL_REQUEST_KEY];
|
|
73
|
-
if (request?.claimId !== claimId || typeof request.pid !== "number") return null;
|
|
74
|
-
return { pid: request.pid };
|
|
75
|
-
}
|
|
76
|
-
function clearNativeRunCancel(root, claimId) {
|
|
77
|
-
try {
|
|
78
|
-
clearWorkspaceStateKey(root, CANCEL_REQUEST_KEY, (value) => value?.claimId === claimId);
|
|
79
|
-
} catch {}
|
|
80
|
-
}
|
|
81
|
-
let cancelled = null;
|
|
82
|
-
let cancellationSignal;
|
|
83
|
-
/** The active native run aborts this signal when it is cancelled. */
|
|
84
|
-
function runCancellationSignal() {
|
|
85
|
-
return cancellationSignal;
|
|
86
|
-
}
|
|
87
|
-
/** Why this process's native run was cancelled, or null while it was not. */
|
|
88
|
-
function runCancellation() {
|
|
89
|
-
return cancelled;
|
|
90
|
-
}
|
|
91
|
-
function cancelledFailure(platform, { code, message }) {
|
|
92
|
-
if (cancelled === null) return null;
|
|
93
|
-
return {
|
|
94
|
-
code: "STIM_CANCELLED",
|
|
95
|
-
message: `The ${platform} run was ${cancelled} before it finished.`,
|
|
96
|
-
remedy: `Run \`stim ${platform}\` again when you want the app on a device.`,
|
|
97
|
-
lines: [`it stopped at ${code ?? "an unfinished step"}${message ? `: ${message}` : ""}`]
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function cancelOnInterrupt({ root, claim, write, exit, controller }) {
|
|
101
|
-
let signals = 0;
|
|
102
|
-
const onInterrupt = () => {
|
|
103
|
-
signals += 1;
|
|
104
|
-
if (signals > 1) {
|
|
105
|
-
exit(130);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
const request = cancelRequestFor(root, claim.claimId);
|
|
109
|
-
cancelled = request ? `cancelled by \`stim stop\` (pid ${request.pid})` : "cancelled by an interrupt";
|
|
110
|
-
controller.abort();
|
|
111
|
-
refuseDeclaredSpawns(`the run was ${cancelled}`);
|
|
112
|
-
const signalled = signalDeclaredSpawns("SIGINT");
|
|
113
|
-
write(signalled > 0 ? `${cancelled}; stopping the running build tool` : request ? `${cancelled}; stopping before the next build tool or install` : cancelled);
|
|
114
|
-
if (signalled === 0 && !request) exit(130);
|
|
115
|
-
};
|
|
116
|
-
process.on("SIGINT", onInterrupt);
|
|
117
|
-
return () => {
|
|
118
|
-
process.off("SIGINT", onInterrupt);
|
|
119
|
-
allowDeclaredSpawns();
|
|
120
|
-
clearNativeRunCancel(root, claim.claimId);
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Run an `ios`, `android` or `macos` invocation under the workspace's native-run lock: the claim records the
|
|
125
|
-
* command, platform and slot, and a wait for another holder is reported on `write`. The first SIGINT
|
|
126
|
-
* forwards the interrupt to the running declared build tool; a run `stim stop` cancelled between build
|
|
127
|
-
* tools starts no further one; a terminal interrupt with no build tool running, or a second SIGINT, exits
|
|
128
|
-
* with 130 at once.
|
|
129
|
-
*/
|
|
130
|
-
function withNativeBuildRun(root, details, fn, { write, exit = (code) => process.exit(code) }) {
|
|
131
|
-
const notice = nativeRunWaitNotice({ write });
|
|
132
|
-
return withWorkspaceProcessLock(workspaceDir(root), NATIVE_RUN_LOCK, async (claim) => {
|
|
133
|
-
cancelled = null;
|
|
134
|
-
const controller = new AbortController();
|
|
135
|
-
cancellationSignal = controller.signal;
|
|
136
|
-
const dispose = cancelOnInterrupt({
|
|
137
|
-
root,
|
|
138
|
-
claim,
|
|
139
|
-
write,
|
|
140
|
-
exit,
|
|
141
|
-
controller
|
|
142
|
-
});
|
|
143
|
-
try {
|
|
144
|
-
return await fn(claim);
|
|
145
|
-
} finally {
|
|
146
|
-
dispose();
|
|
147
|
-
cancellationSignal = void 0;
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
external: true,
|
|
151
|
-
waitMs: NATIVE_RUN_WAIT_MS,
|
|
152
|
-
declareSpawns: true,
|
|
153
|
-
details: { ...details },
|
|
154
|
-
onHeld: (holder) => notice(holder)
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
export { decideStopAction as a, nativeRunWaitNotice as c, runCancellationSignal as d, withNativeBuildRun as f, clearNativeRunCancel as i, requestNativeRunCancel as l, NATIVE_RUN_WAIT_MS as n, describeNativeRunHolder as o, cancelledFailure as r, nativeRunHolder as s, NATIVE_RUN_LOCK as t, runCancellation as u };
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { P as measuredDirectorySize } from "./config-D0DbpZtM.mjs";
|
|
2
|
-
import { s as findProjectRoot$1 } from "./project-D47Rh0ly.mjs";
|
|
3
|
-
import { M as planCacheEmptying, Q as discoverCaches, c as resolveBudget, r as enforceBudget, s as readVolumeSpace } from "./budget-DfcgFdQB.mjs";
|
|
4
|
-
import { o as canonicalPath } from "./in-use-CvGOUn-x.mjs";
|
|
5
|
-
import { h as listBuildLocks } from "./device-lease-DpoS36_u.mjs";
|
|
6
|
-
import { n as listBuildSlots } from "./build-slots-41v_d2x9.mjs";
|
|
7
|
-
import { j as readHostMemoryPressure } from "./ios-DSfnPfse.mjs";
|
|
8
|
-
import { a as collectWorkspaceOutputs } from "./workspaces-Bcib97-6.mjs";
|
|
9
|
-
import { t as resolveMaintenanceSettings } from "./settings-BBpMcDbD.mjs";
|
|
10
|
-
import { existsSync } from "node:fs";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { buildCacheRoot, configDir, metroCacheRoot } from "@stim-cli/core";
|
|
13
|
-
import { buildWorkerRoot, loadConfig, readMaintenanceState, sharedCcache, sharedCompilationCache } from "@stim-cli/core/state";
|
|
14
|
-
import { cpus, freemem, loadavg, totalmem } from "node:os";
|
|
15
|
-
//#region src/maintenance/measure.ts
|
|
16
|
-
function measurePressure(settings, previous, now) {
|
|
17
|
-
const config = loadConfig();
|
|
18
|
-
const level = readHostMemoryPressure();
|
|
19
|
-
const availableBytes = process.platform === "darwin" ? null : freemem();
|
|
20
|
-
const warningSince = level === "warning" ? previous?.warningSince ?? now : null;
|
|
21
|
-
const pressured = settings.memoryPressureLevel !== "off" && (level === "critical" || settings.memoryPressureLevel === "warning" && warningSince !== null && now - warningSince >= settings.memoryWarningMinutes * 6e4 || availableBytes !== null && availableBytes < (settings.minAvailableMemoryGb === void 0 ? totalmem() * .1 : settings.minAvailableMemoryGb * 1024 ** 3));
|
|
22
|
-
return {
|
|
23
|
-
disk: readVolumeSpace([
|
|
24
|
-
configDir(),
|
|
25
|
-
...Object.keys(config?.projects ?? {}),
|
|
26
|
-
buildWorkerRoot(config)
|
|
27
|
-
]),
|
|
28
|
-
memory: {
|
|
29
|
-
level,
|
|
30
|
-
availableBytes,
|
|
31
|
-
pressured
|
|
32
|
-
},
|
|
33
|
-
warningSince
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function sizeScanDeferred(settings) {
|
|
37
|
-
return loadavg()[0] / Math.max(1, cpus().length) > settings.maxLoadPerCore;
|
|
38
|
-
}
|
|
39
|
-
function cacheBlocked(entry, discovered = discoverCaches()) {
|
|
40
|
-
return planCacheEmptying([{
|
|
41
|
-
...entry,
|
|
42
|
-
note: "",
|
|
43
|
-
prune: "entries",
|
|
44
|
-
...discovered.some((cache) => canonicalPath(cache.dir) === canonicalPath(entry.dir) && cache.source === "registered") ? { source: "registered" } : {}
|
|
45
|
-
}], false)[0]?.machineGlobal ?? (entry.category === "compilation-cache" && [...listBuildLocks(), ...listBuildSlots()].some((item) => item.alive || item.unresolved) ? "a build lock or slot is live or unresolved" : void 0);
|
|
46
|
-
}
|
|
47
|
-
function measureSizes(now, failure) {
|
|
48
|
-
const sizes = [];
|
|
49
|
-
const outputs = collectWorkspaceOutputs({
|
|
50
|
-
olderThan: null,
|
|
51
|
-
now,
|
|
52
|
-
sizeTimeoutMs: 12e4
|
|
53
|
-
});
|
|
54
|
-
for (const entry of outputs.workspaces) {
|
|
55
|
-
if (entry.bytes === null) {
|
|
56
|
-
failure(entry.dir, entry.projectRoot ?? void 0);
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
sizes.push({
|
|
60
|
-
name: "workspace build outputs",
|
|
61
|
-
category: "workspace-outputs",
|
|
62
|
-
dir: entry.dir,
|
|
63
|
-
bytes: entry.bytes,
|
|
64
|
-
measuredAt: now,
|
|
65
|
-
...entry.projectRoot ? { workspace: canonicalPath(entry.projectRoot) } : {},
|
|
66
|
-
idleDays: entry.idleDays,
|
|
67
|
-
...!entry.willClear ? { blocked: entry.keptReason ?? "workspace ownership is unresolved" } : {}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const known = [
|
|
71
|
-
{
|
|
72
|
-
name: "shared build cache",
|
|
73
|
-
dir: buildCacheRoot(),
|
|
74
|
-
category: "build-cache"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "Metro transform caches",
|
|
78
|
-
dir: metroCacheRoot(),
|
|
79
|
-
category: "metro-cache"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "ccache",
|
|
83
|
-
dir: sharedCcache(),
|
|
84
|
-
category: "ccache"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "Swift compilation cache",
|
|
88
|
-
dir: sharedCompilationCache(),
|
|
89
|
-
category: "compilation-cache"
|
|
90
|
-
}
|
|
91
|
-
];
|
|
92
|
-
const discovered = discoverCaches();
|
|
93
|
-
for (const cache of discovered) {
|
|
94
|
-
if (cache.source !== "registered" && !canonicalPath(cache.dir).startsWith(`${canonicalPath(configDir())}/`)) continue;
|
|
95
|
-
if (cache.prune === "report-only") continue;
|
|
96
|
-
const dir = canonicalPath(cache.dir);
|
|
97
|
-
if (known.some((item) => dir === canonicalPath(item.dir) || dir.startsWith(`${canonicalPath(item.dir)}/`))) continue;
|
|
98
|
-
const category = cache.name.startsWith("Metro transform cache") ? "metro-cache" : /^(Expo build cache|native build cache|Build cache)$/.test(cache.name) ? "build-cache" : "other";
|
|
99
|
-
known.push({
|
|
100
|
-
name: cache.name,
|
|
101
|
-
dir: cache.dir,
|
|
102
|
-
category
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
for (const entry of known) {
|
|
106
|
-
if (!existsSync(entry.dir)) continue;
|
|
107
|
-
const bytes = measuredDirectorySize(entry.dir, { timeoutMs: 12e4 });
|
|
108
|
-
if (bytes === null) {
|
|
109
|
-
failure(entry.dir);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
const blocked = cacheBlocked(entry, discovered);
|
|
113
|
-
sizes.push({
|
|
114
|
-
...entry,
|
|
115
|
-
bytes,
|
|
116
|
-
measuredAt: now,
|
|
117
|
-
...blocked ? { blocked } : {}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
return sizes;
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/maintenance/plan.ts
|
|
124
|
-
function plan({ pressure, sizes, settings, budget, diskSteps = [], protectedRoot, scoped = false, projects = [] }) {
|
|
125
|
-
const actions = [];
|
|
126
|
-
const blocked = [];
|
|
127
|
-
const skips = [];
|
|
128
|
-
const add = (action) => {
|
|
129
|
-
if (!actions.some((entry) => entry.kind === action.kind && entry.target === action.target)) actions.push(action);
|
|
130
|
-
};
|
|
131
|
-
const floor = Math.max(budget.minFreeDiskMb, budget.hardFloorDiskMb);
|
|
132
|
-
const low = pressure?.disk.filter((disk) => disk.freeMb < floor) ?? [];
|
|
133
|
-
const reason = low.map((disk) => `free disk ${(disk.freeMb / 1024).toFixed(1)}G on ${disk.volume} under the ${(floor / 1024).toFixed(1)}G floor`).join("; ");
|
|
134
|
-
const kinds = {
|
|
135
|
-
"idle-devices": "would-shutdown-device",
|
|
136
|
-
"idle-dev-servers": "would-stop-workspace",
|
|
137
|
-
"workspace-outputs": "would-clear-outputs",
|
|
138
|
-
"stale-cache-entries": "would-trim-cache"
|
|
139
|
-
};
|
|
140
|
-
if (low.length) {
|
|
141
|
-
for (const step of diskSteps) {
|
|
142
|
-
if (scoped && step.step === "idle-devices") continue;
|
|
143
|
-
for (const target of step.targets) {
|
|
144
|
-
const workspace = projects.find((root) => root === target || target.endsWith(` in ${root}`)) ?? (step.step === "idle-dev-servers" || step.step === "workspace-outputs" ? target : void 0);
|
|
145
|
-
if (workspace === protectedRoot || target === protectedRoot) continue;
|
|
146
|
-
const size = workspace && step.step !== "idle-devices" ? sizes.find((entry) => entry.workspace === workspace && entry.category === "workspace-outputs") : void 0;
|
|
147
|
-
add({
|
|
148
|
-
kind: kinds[step.step],
|
|
149
|
-
target,
|
|
150
|
-
bytes: step.step === "workspace-outputs" ? size?.bytes ?? 0 : 0,
|
|
151
|
-
reason: `${size?.idleDays == null ? "" : `idle ${size.idleDays} days, `}${reason}`,
|
|
152
|
-
...workspace ? { workspace } : {}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if (step.failures) blocked.push(`Could not plan ${step.step}: ${step.failures} failures`);
|
|
156
|
-
}
|
|
157
|
-
if (actions.length === 0) blocked.push(`${reason}; no reclaimable disk targets`);
|
|
158
|
-
}
|
|
159
|
-
const caps = [
|
|
160
|
-
[
|
|
161
|
-
"workspace-outputs",
|
|
162
|
-
settings.workspaceOutputsMaxGb,
|
|
163
|
-
"would-clear-outputs"
|
|
164
|
-
],
|
|
165
|
-
[
|
|
166
|
-
"build-cache",
|
|
167
|
-
settings.buildCacheMaxGb,
|
|
168
|
-
"would-trim-cache"
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
"metro-cache",
|
|
172
|
-
settings.metroCacheMaxGb,
|
|
173
|
-
"would-trim-cache"
|
|
174
|
-
],
|
|
175
|
-
[
|
|
176
|
-
"compilation-cache",
|
|
177
|
-
settings.swiftCompilationCacheMaxGb,
|
|
178
|
-
"would-empty-cache"
|
|
179
|
-
]
|
|
180
|
-
];
|
|
181
|
-
for (const [category, capGb, kind] of caps) {
|
|
182
|
-
const entries = sizes.filter((size) => size.category === category);
|
|
183
|
-
const total = entries.reduce((sum, size) => sum + size.bytes, 0);
|
|
184
|
-
const cap = capGb * 1024 ** 3;
|
|
185
|
-
if (cap === 0 || total <= cap) continue;
|
|
186
|
-
let remaining = total;
|
|
187
|
-
const targetBytes = cap * settings.capTargetPercent / 100;
|
|
188
|
-
const why = `${category} ${(total / 1024 ** 3).toFixed(1)}G over the ${capGb}G cap; target ${(targetBytes / 1024 ** 3).toFixed(1)}G`;
|
|
189
|
-
for (const size of entries.toSorted((a, b) => (b.idleDays ?? 0) - (a.idleDays ?? 0))) {
|
|
190
|
-
if (remaining <= targetBytes) break;
|
|
191
|
-
const kept = size.workspace === protectedRoot ? "the triggering workspace is protected" : size.blocked;
|
|
192
|
-
if (kept) {
|
|
193
|
-
skips.push({
|
|
194
|
-
target: size.dir,
|
|
195
|
-
reason: kept,
|
|
196
|
-
...size.workspace ? { workspace: size.workspace } : {}
|
|
197
|
-
});
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
const bytes = kind === "would-trim-cache" ? Math.min(size.bytes, remaining - targetBytes) : size.bytes;
|
|
201
|
-
add({
|
|
202
|
-
kind,
|
|
203
|
-
target: size.workspace ?? size.dir,
|
|
204
|
-
bytes,
|
|
205
|
-
reason: `${!size.workspace || size.idleDays == null ? "" : `idle ${size.idleDays} days, `}${why}`,
|
|
206
|
-
...size.workspace ? { workspace: size.workspace } : {}
|
|
207
|
-
});
|
|
208
|
-
remaining -= bytes;
|
|
209
|
-
}
|
|
210
|
-
if (remaining > targetBytes) blocked.push(`${why}; eligible targets cannot reach the target`);
|
|
211
|
-
}
|
|
212
|
-
if (pressure?.memory.pressured) skips.push({
|
|
213
|
-
target: "memory",
|
|
214
|
-
reason: "memory pressure observed; stopping helpers and idle workspaces is not active in report-only mode"
|
|
215
|
-
});
|
|
216
|
-
return {
|
|
217
|
-
actions,
|
|
218
|
-
blocked,
|
|
219
|
-
skips
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/maintenance/preview.ts
|
|
224
|
-
function triggeringRoot() {
|
|
225
|
-
return canonicalPath(findProjectRoot$1(process.cwd()) ?? join(configDir(), "maintenance", "no-project"));
|
|
226
|
-
}
|
|
227
|
-
async function plannedMaintenance(pressure, sizes, settings, { devices = true } = {}) {
|
|
228
|
-
const resolved = resolveBudget();
|
|
229
|
-
if (resolved.error) throw new Error(resolved.error);
|
|
230
|
-
const budget = {
|
|
231
|
-
...resolved.budget,
|
|
232
|
-
maxCommittedMemoryMb: 0,
|
|
233
|
-
maxLiveWorkspaces: 0
|
|
234
|
-
};
|
|
235
|
-
const root = triggeringRoot();
|
|
236
|
-
const floor = Math.max(budget.minFreeDiskMb, budget.hardFloorDiskMb);
|
|
237
|
-
const low = pressure?.disk.some((disk) => disk.freeMb < floor);
|
|
238
|
-
const outcome = low ? await enforceBudget({
|
|
239
|
-
root,
|
|
240
|
-
note: () => {},
|
|
241
|
-
dryRun: true,
|
|
242
|
-
budget
|
|
243
|
-
}, { volumes: () => pressure.disk }) : null;
|
|
244
|
-
if (outcome && outcome.status !== "ok") throw new Error(outcome.refusal.message);
|
|
245
|
-
const outputs = collectWorkspaceOutputs({
|
|
246
|
-
olderThan: null,
|
|
247
|
-
now: Date.now(),
|
|
248
|
-
measure: false
|
|
249
|
-
});
|
|
250
|
-
const result = plan({
|
|
251
|
-
pressure,
|
|
252
|
-
sizes: sizes.map((size) => {
|
|
253
|
-
if (size.category === "compilation-cache") return {
|
|
254
|
-
...size,
|
|
255
|
-
blocked: cacheBlocked(size)
|
|
256
|
-
};
|
|
257
|
-
if (!size.workspace) return size;
|
|
258
|
-
const current = outputs.workspaces.find((entry) => entry.projectRoot && canonicalPath(entry.projectRoot) === size.workspace);
|
|
259
|
-
return Object.assign({}, size, { blocked: current?.willClear ? void 0 : current?.keptReason ?? "workspace outputs cannot be resolved" });
|
|
260
|
-
}),
|
|
261
|
-
settings,
|
|
262
|
-
budget,
|
|
263
|
-
diskSteps: outcome?.status === "ok" ? outcome.reclaimed.filter((step) => devices || step.step !== "idle-devices") : [],
|
|
264
|
-
protectedRoot: root,
|
|
265
|
-
scoped: Boolean(process.env.STIM_HOME),
|
|
266
|
-
projects: Object.keys(loadConfig()?.projects ?? {}).map(canonicalPath)
|
|
267
|
-
});
|
|
268
|
-
if (low) result.skips.push(...outputs.workspaces.filter((entry) => !entry.willClear && entry.keptReason).map((entry) => ({
|
|
269
|
-
target: entry.dir,
|
|
270
|
-
reason: entry.keptReason,
|
|
271
|
-
workspace: entry.projectRoot ?? void 0
|
|
272
|
-
})));
|
|
273
|
-
return result;
|
|
274
|
-
}
|
|
275
|
-
async function previewMaintenance({ devices = true } = {}) {
|
|
276
|
-
let settings;
|
|
277
|
-
try {
|
|
278
|
-
settings = resolveMaintenanceSettings();
|
|
279
|
-
const state = readMaintenanceState();
|
|
280
|
-
if (settings.invalid && settings.mode === "off") return {
|
|
281
|
-
mode: "off",
|
|
282
|
-
pressure: null,
|
|
283
|
-
actions: [],
|
|
284
|
-
blocked: [],
|
|
285
|
-
skips: [],
|
|
286
|
-
invalid: settings.invalid,
|
|
287
|
-
note: settings.invalid
|
|
288
|
-
};
|
|
289
|
-
if (settings.mode === "off") return {
|
|
290
|
-
mode: "off",
|
|
291
|
-
pressure: null,
|
|
292
|
-
actions: [],
|
|
293
|
-
blocked: [],
|
|
294
|
-
skips: [],
|
|
295
|
-
note: "maintenance.mode is off"
|
|
296
|
-
};
|
|
297
|
-
const pressure = measurePressure(settings, state?.pressure ?? null, Date.now());
|
|
298
|
-
return {
|
|
299
|
-
...await plannedMaintenance(pressure, state?.sizes ?? [], settings, { devices }),
|
|
300
|
-
mode: settings.mode,
|
|
301
|
-
...settings.invalid ? { invalid: settings.invalid } : {},
|
|
302
|
-
pressure,
|
|
303
|
-
note: settings.invalid ?? (state === null ? "no pass has run yet; sizes have not been measured" : null)
|
|
304
|
-
};
|
|
305
|
-
} catch (error) {
|
|
306
|
-
return {
|
|
307
|
-
mode: settings?.mode ?? "off",
|
|
308
|
-
...settings?.invalid ? { invalid: settings.invalid } : {},
|
|
309
|
-
pressure: null,
|
|
310
|
-
actions: [],
|
|
311
|
-
blocked: [String(error)],
|
|
312
|
-
skips: [],
|
|
313
|
-
note: "maintenance preview failed"
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
//#endregion
|
|
318
|
-
export { sizeScanDeferred as a, measureSizes as i, previewMaintenance as n, measurePressure as r, plannedMaintenance as t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { n as __exportAll, r as __reExport } from "./rolldown-runtime-BsOwBuO_.mjs";
|
|
2
|
-
//#region src/ownership-claim.ts
|
|
3
|
-
var ownership_claim_exports = /* @__PURE__ */ __exportAll({});
|
|
4
|
-
import * as import__stim_cli_core_ownership_claim from "@stim-cli/core/ownership-claim";
|
|
5
|
-
__reExport(ownership_claim_exports, import__stim_cli_core_ownership_claim);
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/process-identity.ts
|
|
8
|
-
var process_identity_exports = /* @__PURE__ */ __exportAll({});
|
|
9
|
-
import * as import__stim_cli_core_process_identity from "@stim-cli/core/process-identity";
|
|
10
|
-
__reExport(process_identity_exports, import__stim_cli_core_process_identity);
|
|
11
|
-
//#endregion
|
|
12
|
-
export { ownership_claim_exports as n, process_identity_exports as t };
|