stim 1.29.0 → 1.30.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/dist/{acquire-artifact-C2DKfenN.mjs → acquire-artifact-CrZ4rEbI.mjs} +1 -1
- package/dist/{act-CrTcskiE.mjs → act-BaKjDWGw.mjs} +12 -12
- package/dist/{activity-BR5oHSO5.mjs → activity-BTaUf0tc.mjs} +2 -2
- package/dist/{agent-device-usage-output-W0x4SoC7.mjs → agent-device-usage-output-DYBpO17K.mjs} +3 -3
- package/dist/{android-BPmCmyAy.mjs → android-BCYLwmH6.mjs} +5 -5
- package/dist/{android-CLU_MMnb.mjs → android-BEQUDpOg.mjs} +1 -1
- package/dist/{android-l616dRP1.mjs → android-BWqdDK6R.mjs} +36 -34
- package/dist/{android-BHKgeOuq.mjs → android-DdKG6lyD.mjs} +39 -30
- package/dist/api.mjs +21 -21
- package/dist/{apk-signed-tail-B-wKoF_8.mjs → apk-signed-tail-B8kw4a8K.mjs} +1 -1
- package/dist/{artifact-Dm9ScLrh.mjs → artifact-DTHXcmQ3.mjs} +11 -11
- package/dist/{artifact-DHuFYfhD.mjs → artifact-M6W2l-xh.mjs} +11 -11
- package/dist/{auto-placement-C8sJsyMN.mjs → auto-placement-CZaWDmcY.mjs} +8 -8
- package/dist/{browser-web-_tQTbQUs.mjs → browser-web-JQ7lFej3.mjs} +5 -5
- package/dist/{build-DtCU9Kim.mjs → build-C2ZWoCmg.mjs} +18 -18
- package/dist/{build-cache-BGwTsIEa.mjs → build-cache-DlC3owap.mjs} +1 -1
- package/dist/{build-plan-CWyjMPKo.mjs → build-plan-J3iRR3gI.mjs} +5 -5
- package/dist/{ccache-DsDkdP72.mjs → ccache-B8gY50-h.mjs} +11 -11
- package/dist/{cli-3fjOg-Oc.mjs → cli-xRPXJPtA.mjs} +17 -17
- package/dist/cli.mjs +1 -1
- package/dist/{client-BTUH8TF1.mjs → client-DrHykA24.mjs} +3 -3
- package/dist/collector-run.mjs +1 -1
- package/dist/{command-output-DjCsmzLZ.mjs → command-output-BBW8eWPL.mjs} +1 -1
- package/dist/{dependencies-CHNqX6Pr.mjs → dependencies-vUh9mp5z.mjs} +31 -30
- package/dist/{dev-client-CROrxj1x.mjs → dev-client-CASgAOu7.mjs} +2 -2
- package/dist/device-ChnO7bR9.mjs +761 -0
- package/dist/device-CsIdRXfm.mjs +175 -0
- package/dist/{device-Bmm5qjM-.mjs → device-android-CcdQqQWg.mjs} +26 -193
- package/dist/{device-capacity-B2ChA-bz.mjs → device-capacity-C5C_jOQd.mjs} +9 -9
- package/dist/device-host-worker.mjs +40 -31
- package/dist/{device-ios-CYzivd31.mjs → device-ios-DbmtPIiw.mjs} +24 -14
- package/dist/{device-lease-run-qRq_2W2V.mjs → device-lease-run-Do6zYA7y.mjs} +3 -3
- package/dist/{device-pool-CrmiE4_x.mjs → device-pool-CpoYiCGO.mjs} +2 -2
- package/dist/{device-provision-CK2XiEp1.mjs → device-provision-B5Ms94qY.mjs} +6 -6
- package/dist/{doctor-Dr3C1iXV.mjs → doctor-CJSB5q-s.mjs} +14 -14
- package/dist/{doctor-Cp4-HN1f.mjs → doctor-CLE4AZEI.mjs} +12 -12
- package/dist/{doctor-BO_kaFWX.mjs → doctor-CpfbYh3Q.mjs} +1 -1
- package/dist/doctor-fingerprint.mjs +1 -1
- package/dist/{doctor-watchman-CJr2aXXv.mjs → doctor-watchman-D1IyMle9.mjs} +2 -2
- package/dist/{eas-build-D-9HmGZS.mjs → eas-build-DIDOHw2P.mjs} +2 -2
- package/dist/{eas-fallback-Cemt2GVL.mjs → eas-fallback-DVS9oBSc.mjs} +2 -2
- package/dist/{eas-session-ledger-B0KLZx5m.mjs → eas-session-ledger-CW3l-inB.mjs} +1 -1
- package/dist/{error-diagnostics-CV_1RoEH.mjs → error-diagnostics-XJ9eWdtq.mjs} +5 -5
- package/dist/{gc-DjXwQXHK.mjs → gc-BVIcxCxE.mjs} +2 -2
- package/dist/{gc-CKHqL4aS.mjs → gc-Co7PE36D.mjs} +13 -13
- package/dist/{guide-CeRlWVsS.mjs → guide-DkepBgHT.mjs} +110 -13
- package/dist/{hosted-android-DI_vvv7U.mjs → hosted-android-Du7NxufJ.mjs} +2 -2
- package/dist/{hosted-client-CgoxdU9j.mjs → hosted-client-Cect92SZ.mjs} +2 -2
- package/dist/{hosted-logs-C-4INmkn.mjs → hosted-logs-Opcjv1Lr.mjs} +3 -3
- package/dist/{hosted-logs-sync-Bf5s02fi.mjs → hosted-logs-sync-wsI7N1Hv.mjs} +6 -10
- package/dist/{hosted-macos-Doh85YUM.mjs → hosted-macos-BP9Kucat.mjs} +4 -4
- package/dist/{hosted-native-DvZENAL-.mjs → hosted-native-DmdLSmvu.mjs} +6 -5
- package/dist/{idle-shutdown-BM37gMfU.mjs → idle-shutdown-BcMN_cLm.mjs} +4 -4
- package/dist/{ios-CNDH6fNF.mjs → ios-BFkBHuRT.mjs} +8 -8
- package/dist/{ios-UM_dManb.mjs → ios-CG0IsLtt.mjs} +24 -24
- package/dist/{ios-CoMCWfub.mjs → ios-CXnoVO_z.mjs} +2 -2
- package/dist/{ios-device-L1-pota_.mjs → ios-device-ClSfuu-_.mjs} +1 -1
- package/dist/{ios-project-DJYptOCh.mjs → ios-project-BM9TbTE7.mjs} +5 -5
- package/dist/{js-swap-BthE4kZC.mjs → js-swap-9Rx-5Nqz.mjs} +3 -3
- package/dist/{launch-D798aSm8.mjs → launch-DvJV1Mx4.mjs} +14 -14
- package/dist/{lightened-vSxkstg6.mjs → lightened-23pqe7LS.mjs} +2 -2
- package/dist/{logs-BND8MiBq.mjs → logs-DJgZlf2K.mjs} +5 -5
- package/dist/{logs-CilPftm3.mjs → logs-Pkeh3wZk.mjs} +5 -4
- package/dist/{macos-CxUi9xcE.mjs → macos-DPvPQadc.mjs} +15 -15
- package/dist/{macos-BOQrKYeJ.mjs → macos-Du07NsOB.mjs} +1 -1
- package/dist/maintenance-run.mjs +4 -4
- package/dist/{native-android-BkhrCjdX.mjs → native-android-CBOM1_gB.mjs} +12 -12
- package/dist/{native-gradle-artifact-inputs-Cw4P6Gyr.mjs → native-gradle-artifact-inputs-D_iAfPuS.mjs} +3 -3
- package/dist/{native-runtime-DyH2gkXK.mjs → native-runtime-D4cTwU0Z.mjs} +3 -3
- package/dist/{native-xcode-inputs-DV8jr3kJ.mjs → native-xcode-inputs-BF-ogSnG.mjs} +1 -1
- package/dist/{native-xcode-ios-DdpPG2iT.mjs → native-xcode-ios-DwJBfMP6.mjs} +12 -12
- package/dist/offload-worker.mjs +15 -15
- package/dist/{phone-reverses-DZRad8HT.mjs → phone-reverses-CvhhkGMH.mjs} +2 -2
- package/dist/{placement-log-CoN6xrjY.mjs → placement-log-CRR_TE1r.mjs} +1 -1
- package/dist/{plan-placement-7sHuqR-r.mjs → plan-placement-CdLc-pTb.mjs} +4 -4
- package/dist/{ports-VQSAPZhl.mjs → ports-g4N_cfyg.mjs} +1 -1
- package/dist/{prebuild-Bqp0LFGN.mjs → prebuild-DBJMhwSS.mjs} +6 -6
- package/dist/{project-D1n0K4yg.mjs → project-DPQjnpcI.mjs} +11 -11
- package/dist/{react-native-android-FQ-yX3Mv.mjs → react-native-android-idMWOwkX.mjs} +21 -21
- package/dist/{react-native-build-D58bIqV9.mjs → react-native-build-BSoh4HkH.mjs} +5 -5
- package/dist/{react-native-doctor-AkUH2aca.mjs → react-native-doctor-CYibY8-4.mjs} +8 -7
- package/dist/{react-native-ios-Dmsv8j7T.mjs → react-native-ios-13KIIOOy.mjs} +15 -14
- package/dist/{reload-CDKEzzaf.mjs → reload-B9DZOjcV.mjs} +1 -1
- package/dist/{reload-BV0nD-k9.mjs → reload-BUQI3dSu.mjs} +8 -8
- package/dist/{remote-C8xyslUa.mjs → remote-C-RGHhAP.mjs} +6 -6
- package/dist/{result-9fqcJ90W.mjs → result-W4HCum4A.mjs} +11 -11
- package/dist/{selection-D1ZDzHFX.mjs → selection-PCMT97XD.mjs} +1 -1
- package/dist/{server-command-RlS-Kl4a.mjs → server-command-oqi3TDy7.mjs} +2 -2
- package/dist/server-expo-BUFAq2In.mjs +2 -0
- package/dist/{server-expo-bB1VV2k-.mjs → server-expo-C1K07shx.mjs} +1 -1
- package/dist/{settings-BcVCcAT5.mjs → settings-CKlMOmhj.mjs} +2 -2
- package/dist/{settings-payload-_aatELz2.mjs → settings-payload-CE-NZ6Lq.mjs} +1 -1
- package/dist/{settings-write-CkTVGQ4O.mjs → settings-write-D7Xwa_-M.mjs} +2 -2
- package/dist/{slot-launch-Dbgfh8gc.mjs → slot-launch-CeIK1iUI.mjs} +4 -4
- package/dist/{stage-BuHuRj1y.mjs → stage-Blqe6bWb.mjs} +1 -1
- package/dist/{start-Dlv4XXTP.mjs → start-B7J5a9nS.mjs} +5 -5
- package/dist/{start-Cr-c3Xhq.mjs → start-CvP2pJjc.mjs} +1 -1
- package/dist/{stats-D5c-uIBp.mjs → stats-Uo7l8OAk.mjs} +3 -3
- package/dist/{status-DbQv--Yb.mjs → status-CqJI1TgG.mjs} +1 -1
- package/dist/{status-D6PBK6_-.mjs → status-_rWXFSO7.mjs} +15 -15
- package/dist/{status-watch-okrpea4i.mjs → status-watch-CnSyXUmj.mjs} +3 -3
- package/dist/status-worker.mjs +1 -1
- package/dist/{stop-CHtAiv79.mjs → stop-Bogo9oO2.mjs} +2 -2
- package/dist/{stop-uRQ-zYcl.mjs → stop-CMVfaA-6.mjs} +2 -2
- package/dist/{stop-p9uSKuGE.mjs → stop-CnF9ixYe.mjs} +10 -10
- package/dist/supervisor-run.mjs +9 -9
- package/dist/{support-PFyTkrnr.mjs → support-BGqpYMV8.mjs} +15 -11
- package/dist/{support-BMpQIug0.mjs → support-DUevTPur.mjs} +7 -7
- package/dist/{swiftpm-artifact-inputs-Cddq6jN2.mjs → swiftpm-artifact-inputs-BcJk6-3u.mjs} +1 -1
- package/dist/{swiftpm-macos-BSj9iZlI.mjs → swiftpm-macos-DBrmoocG.mjs} +4 -4
- package/dist/toolchain-Cw9VVHOY.mjs +2 -0
- package/dist/{toolchain-CLGnEUgT.mjs → toolchain-DLdoyxIt.mjs} +18 -10
- package/dist/{warm-progress--KkkBBaq.mjs → warm-progress-DQ2wQZKp.mjs} +1 -1
- package/dist/web-CI_qCRPw.mjs +2 -0
- package/dist/{web-xlVssjQf.mjs → web-g9U7L1sR.mjs} +3 -3
- package/dist/web-run.mjs +2 -2
- package/dist/{workspaces-CvSYD_78.mjs → workspaces-7_RWoi6c.mjs} +4 -4
- package/dist/{worktree-DTOIohFe.mjs → worktree-DEet9H3p.mjs} +1 -1
- package/dist/{worktree-CaQBf6kh.mjs → worktree-qKJ3x07S.mjs} +13 -13
- package/package.json +7 -7
- package/dist/device-BvpasThQ.mjs +0 -297
- package/dist/server-expo-BVV9qy31.mjs +0 -2
- package/dist/toolchain-B-mzR9Rh.mjs +0 -2
- package/dist/web-BxSo493O.mjs +0 -2
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { H as deviceSlotPlatforms } from "./config-AbUjIBOQ.mjs";
|
|
2
|
+
import { s as ownedDeviceLabel } from "./project-DPQjnpcI.mjs";
|
|
3
|
+
import { b as configureNewOwnedAvd } from "./android-DdKG6lyD.mjs";
|
|
4
|
+
import { c as pidExists } from "./metro-BMQHczcf.mjs";
|
|
5
|
+
import { pt as teardownOwnedAvd } from "./workspaces-7_RWoi6c.mjs";
|
|
6
|
+
import { h as tailLines } from "./activity-BTaUf0tc.mjs";
|
|
7
|
+
import "./ios-CXnoVO_z.mjs";
|
|
8
|
+
import { t as clearDeviceIdleShutdown } from "./idle-shutdown-BcMN_cLm.mjs";
|
|
9
|
+
import { i as ensureOwnedIosDevice, r as ensureIosBooted } from "./device-ios-DbmtPIiw.mjs";
|
|
10
|
+
import { t as reconcileSimSlim } from "./simslim-CbpHERcv.mjs";
|
|
11
|
+
import { n as ensureAndroidBooted, r as ensureOwnedAndroidDevice, t as ANDROID_BOOT_TIMEOUT_MS } from "./device-android-CcdQqQWg.mjs";
|
|
12
|
+
import { existsSync } from "node:fs";
|
|
13
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
14
|
+
import { rotatedLogPath } from "@stim-cli/core";
|
|
15
|
+
import { acceptsShape, settingDefinition } from "@stim-cli/core/state";
|
|
16
|
+
import { request } from "node:http";
|
|
17
|
+
//#region src/engine/metro-warmup.ts
|
|
18
|
+
const WARMUP_TIMEOUT_MS = 6e4;
|
|
19
|
+
async function requestLocal(url, platform, prefetch) {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
const req = request(url, { headers: {
|
|
22
|
+
accept: "application/json",
|
|
23
|
+
"expo-platform": platform,
|
|
24
|
+
"x-stim-metro-warmup": "1"
|
|
25
|
+
} });
|
|
26
|
+
const timer = setTimeout(() => req.destroy(), WARMUP_TIMEOUT_MS);
|
|
27
|
+
timer.unref();
|
|
28
|
+
req.on("socket", (socket) => socket.unref());
|
|
29
|
+
req.on("error", () => resolve(null));
|
|
30
|
+
req.on("close", () => {
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
resolve(null);
|
|
33
|
+
});
|
|
34
|
+
req.on("response", (res) => {
|
|
35
|
+
let body = "";
|
|
36
|
+
res.setEncoding("utf8");
|
|
37
|
+
res.on("data", (chunk) => {
|
|
38
|
+
if (!prefetch) body += chunk;
|
|
39
|
+
});
|
|
40
|
+
res.on("error", () => resolve(null));
|
|
41
|
+
res.on("end", () => resolve(res.statusCode === 200 ? body : null));
|
|
42
|
+
});
|
|
43
|
+
req.end();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const ENTRY_EXTENSIONS = [
|
|
47
|
+
"",
|
|
48
|
+
".js",
|
|
49
|
+
".jsx",
|
|
50
|
+
".ts",
|
|
51
|
+
".tsx"
|
|
52
|
+
];
|
|
53
|
+
function entryExists(bundlePath, root) {
|
|
54
|
+
const entry = decodeURIComponent(bundlePath.replace(/\.bundle\/*$/, ""));
|
|
55
|
+
if (entry.startsWith("/.expo/")) return true;
|
|
56
|
+
for (let dir = resolve(root);; dir = dirname(dir)) {
|
|
57
|
+
const file = resolve(dir, `.${entry}`);
|
|
58
|
+
if (file.startsWith(dir + sep) && ENTRY_EXTENSIONS.some((ext) => existsSync(file + ext))) return true;
|
|
59
|
+
if (dirname(dir) === dir) return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function recordedBundleUrl(logsDir, root, platform) {
|
|
63
|
+
const setting = settingDefinition(`metro.warmupUrl.${platform}`);
|
|
64
|
+
if (!logsDir || !root || !setting) return null;
|
|
65
|
+
const log = join(logsDir, "metro.ndjson");
|
|
66
|
+
for (const file of [log, rotatedLogPath(log)]) for (const line of (tailLines(file) ?? []).toReversed()) try {
|
|
67
|
+
const record = JSON.parse(line);
|
|
68
|
+
if (record?.event === "bundle_response_started" && record.platform === platform && acceptsShape(setting, record.url) && entryExists(new URL(record.url, "http://localhost").pathname, root)) return record.url;
|
|
69
|
+
} catch {}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
async function warmMetro({ port, platform, isExpo, appId, bundleUrl, logsDir, root }) {
|
|
73
|
+
try {
|
|
74
|
+
const origin = `http://127.0.0.1:${port}`;
|
|
75
|
+
if (await requestLocal(new URL("/_stim/metro-warmup", origin), platform, false) !== "ready") return;
|
|
76
|
+
const url = new URL("/index.bundle", origin);
|
|
77
|
+
url.search = new URLSearchParams({
|
|
78
|
+
platform,
|
|
79
|
+
dev: "true",
|
|
80
|
+
lazy: "true",
|
|
81
|
+
minify: "false",
|
|
82
|
+
...platform === "ios" ? { inlineSourceMap: "false" } : {},
|
|
83
|
+
modulesOnly: "false",
|
|
84
|
+
runModule: "true",
|
|
85
|
+
excludeSource: "true",
|
|
86
|
+
sourcePaths: "url-server",
|
|
87
|
+
...appId ? { app: appId } : {}
|
|
88
|
+
}).toString();
|
|
89
|
+
bundleUrl ||= recordedBundleUrl(logsDir, root, platform);
|
|
90
|
+
if (!bundleUrl && isExpo) {
|
|
91
|
+
const body = await requestLocal(new URL(origin), platform, false);
|
|
92
|
+
if (body === null) return;
|
|
93
|
+
const manifest = JSON.parse(body);
|
|
94
|
+
bundleUrl = manifest.launchAsset?.url ?? manifest.bundleUrl;
|
|
95
|
+
if (typeof bundleUrl !== "string") return;
|
|
96
|
+
}
|
|
97
|
+
if (bundleUrl) {
|
|
98
|
+
const bundle = new URL(bundleUrl, origin);
|
|
99
|
+
url.pathname = bundle.pathname;
|
|
100
|
+
url.search = bundle.search;
|
|
101
|
+
}
|
|
102
|
+
await requestLocal(url, platform, true);
|
|
103
|
+
} catch {}
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/engine/device.ts
|
|
107
|
+
/**
|
|
108
|
+
* Whether `ensureOwnedDevice` created, adopted or started booting the device, rather than finding it booted.
|
|
109
|
+
* Undefined for a remote device, which those functions do not describe.
|
|
110
|
+
*/
|
|
111
|
+
function didSetUpDevice(device, remote) {
|
|
112
|
+
return remote ? void 0 : Boolean(device.setup || device.booting);
|
|
113
|
+
}
|
|
114
|
+
async function ensureOwnedDevice({ platform, project, projectPath, slot, settingsRoot = projectPath, label = ownedDeviceLabel(projectPath), settings, flags = {}, note = () => {}, out = () => {}, logFile = null, alive = pidExists, configureAvd = configureNewOwnedAvd, teardownAvd = teardownOwnedAvd, reconcileIosSimulator = reconcileSimSlim, simSnapshot }) {
|
|
115
|
+
await clearDeviceIdleShutdown(projectPath, platform, slot);
|
|
116
|
+
if (slot && slot !== "default") label = `${label}-${slot}`;
|
|
117
|
+
const record = deviceSlotPlatforms(project, slot)?.[platform] ?? null;
|
|
118
|
+
if (platform === "ios") return ensureOwnedIosDevice({
|
|
119
|
+
record,
|
|
120
|
+
projectPath,
|
|
121
|
+
slot,
|
|
122
|
+
settingsRoot,
|
|
123
|
+
label,
|
|
124
|
+
settings,
|
|
125
|
+
flags,
|
|
126
|
+
note,
|
|
127
|
+
out,
|
|
128
|
+
reconcileIosSimulator,
|
|
129
|
+
simSnapshot
|
|
130
|
+
});
|
|
131
|
+
return ensureOwnedAndroidDevice({
|
|
132
|
+
record,
|
|
133
|
+
projectPath,
|
|
134
|
+
slot,
|
|
135
|
+
settingsRoot,
|
|
136
|
+
label,
|
|
137
|
+
settings,
|
|
138
|
+
flags,
|
|
139
|
+
note,
|
|
140
|
+
out,
|
|
141
|
+
logFile,
|
|
142
|
+
alive,
|
|
143
|
+
configureAvd,
|
|
144
|
+
teardownAvd
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const BOOT_POLL_MS = 500;
|
|
148
|
+
async function ensureBooted({ platform, device, simulatorApp, timeoutMs, pollMs = BOOT_POLL_MS, out = () => {}, logFile = null, alive = pidExists, projectPath, slot, deviceSlotWait }) {
|
|
149
|
+
if (platform === "ios") return ensureIosBooted({
|
|
150
|
+
device,
|
|
151
|
+
projectPath,
|
|
152
|
+
slot,
|
|
153
|
+
deviceSlotWait,
|
|
154
|
+
simulatorApp,
|
|
155
|
+
timeoutMs: timeoutMs ?? 6e5,
|
|
156
|
+
pollMs,
|
|
157
|
+
out
|
|
158
|
+
});
|
|
159
|
+
if (platform === "android") return ensureAndroidBooted({
|
|
160
|
+
device,
|
|
161
|
+
deviceSlotWait,
|
|
162
|
+
projectPath,
|
|
163
|
+
slot,
|
|
164
|
+
timeoutMs: timeoutMs ?? ANDROID_BOOT_TIMEOUT_MS,
|
|
165
|
+
out,
|
|
166
|
+
logFile,
|
|
167
|
+
alive
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
failed: true,
|
|
171
|
+
reason: `Unknown platform "${platform}".`
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
export { warmMetro as i, ensureBooted as n, ensureOwnedDevice as r, didSetUpDevice as t };
|
|
@@ -1,117 +1,19 @@
|
|
|
1
1
|
import { D as ownership_claim_exports, t as getExecutor } from "./exec-aULwtNly.mjs";
|
|
2
|
-
import { D as withConfigLock
|
|
3
|
-
import { l as phaseLine } from "./command-output-
|
|
2
|
+
import { D as withConfigLock, G as projectDeviceSlots, H as deviceSlotPlatforms, O as withConfigLockAsync, _ as loadConfig, a as clearDevice, b as releaseAndroidConsolePort, i as clearAndroidBootPending, j as acquireAvdClaim, t as allConsolePortsAndSerials, w as setDevice } from "./config-AbUjIBOQ.mjs";
|
|
3
|
+
import { l as phaseLine } from "./command-output-BBW8eWPL.mjs";
|
|
4
4
|
import { l as androidDataPartitionSizeGbSetting, o as androidAvdConfigSetting } from "./settings-D776ygML.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { B as ownedAvdDeviceProfile, F as listAvdsAsync, H as ownedAvdMatchesConfiguration, I as listInstalledSystemImages, K as ownedAvdSystemImage, O as getAvdNameForSerialAsync, U as ownedAvdName, X as pickDefaultSystemImage, _ as avdPoolConfiguration, b as configureNewOwnedAvd, ct as waitForBoot, gt as isLegacyDeletionClaim, j as listAdbDevicesAsync, n as OWNED_AVD_CONFIG_DEFAULTS, nt as resolveOwnedAvdSerialAsync, p as assertOwnedAvdStoppedAsync, pt as adoptParked, t as DEFAULT_AVD_DEVICE_PROFILE, vt as parkedMaxSetting, x as createOwnedAvd, y as bootAndroidEmulator, yt as readParked, z as nextConsolePort } from "./android-BHKgeOuq.mjs";
|
|
5
|
+
import { B as ownedAvdDeviceProfile, H as ownedAvdMatchesConfiguration, I as listAvdsAsync, K as ownedAvdSystemImage, L as listInstalledSystemImages, M as listAdbDevicesAsync, U as ownedAvdName, X as pickDefaultSystemImage, _ as avdPoolConfiguration, ct as waitForBoot, gt as isLegacyDeletionClaim, k as getAvdNameForSerialAsync, n as OWNED_AVD_CONFIG_DEFAULTS, nt as resolveOwnedAvdSerialAsync, p as assertOwnedAvdStoppedAsync, pt as adoptParked, t as DEFAULT_AVD_DEVICE_PROFILE, vt as parkedMaxSetting, x as createOwnedAvd, y as bootAndroidEmulator, yt as readParked, z as nextConsolePort } from "./android-DdKG6lyD.mjs";
|
|
7
6
|
import { c as pidExists } from "./metro-BMQHczcf.mjs";
|
|
8
|
-
import { gt as teardownParkedAvd, pt as teardownOwnedAvd } from "./workspaces-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { g as withDeviceBootAdmission, n as DeviceAdmissionRefusal, o as countLiveOwnedDevicesFrom } from "./device-capacity-B2ChA-bz.mjs";
|
|
12
|
-
import { t as clearDeviceIdleShutdown } from "./idle-shutdown-BM37gMfU.mjs";
|
|
13
|
-
import { i as ensureOwnedIosDevice, r as ensureIosBooted } from "./device-ios-CYzivd31.mjs";
|
|
14
|
-
import { t as reconcileSimSlim } from "./simslim-CbpHERcv.mjs";
|
|
7
|
+
import { gt as teardownParkedAvd, pt as teardownOwnedAvd } from "./workspaces-7_RWoi6c.mjs";
|
|
8
|
+
import { B as reportMemoryCulprits, L as memoryCulpritsUnderAsync, R as readHostMemoryPressure, V as memoryCulpritAdvice, f as listAllIosSimsAsync } from "./ios-CXnoVO_z.mjs";
|
|
9
|
+
import { g as withDeviceBootAdmission, n as DeviceAdmissionRefusal, o as countLiveOwnedDevicesFrom } from "./device-capacity-C5C_jOQd.mjs";
|
|
15
10
|
import { claimRemoveCommand, clearClaimChild, markClaimChildPending, processGroupAlive, releaseClaim, setClaimChild } from "@stim-cli/core/ownership-claim";
|
|
16
11
|
import { randomUUID } from "node:crypto";
|
|
17
12
|
import { existsSync } from "node:fs";
|
|
18
13
|
import { isDeepStrictEqual } from "node:util";
|
|
19
|
-
import { dirname, join, resolve, sep } from "node:path";
|
|
20
|
-
import { rotatedLogPath } from "@stim-cli/core";
|
|
21
|
-
import { acceptsShape, settingDefinition } from "@stim-cli/core/state";
|
|
22
|
-
import { request } from "node:http";
|
|
23
14
|
import { fileURLToPath } from "node:url";
|
|
24
15
|
import { captureProcessIdentity } from "@stim-cli/core/process-identity";
|
|
25
16
|
import chalk from "chalk";
|
|
26
|
-
//#region src/engine/metro-warmup.ts
|
|
27
|
-
const WARMUP_TIMEOUT_MS = 6e4;
|
|
28
|
-
async function requestLocal(url, platform, prefetch) {
|
|
29
|
-
return new Promise((resolve) => {
|
|
30
|
-
const req = request(url, { headers: {
|
|
31
|
-
accept: "application/json",
|
|
32
|
-
"expo-platform": platform,
|
|
33
|
-
"x-stim-metro-warmup": "1"
|
|
34
|
-
} });
|
|
35
|
-
const timer = setTimeout(() => req.destroy(), WARMUP_TIMEOUT_MS);
|
|
36
|
-
timer.unref();
|
|
37
|
-
req.on("socket", (socket) => socket.unref());
|
|
38
|
-
req.on("error", () => resolve(null));
|
|
39
|
-
req.on("close", () => {
|
|
40
|
-
clearTimeout(timer);
|
|
41
|
-
resolve(null);
|
|
42
|
-
});
|
|
43
|
-
req.on("response", (res) => {
|
|
44
|
-
let body = "";
|
|
45
|
-
res.setEncoding("utf8");
|
|
46
|
-
res.on("data", (chunk) => {
|
|
47
|
-
if (!prefetch) body += chunk;
|
|
48
|
-
});
|
|
49
|
-
res.on("error", () => resolve(null));
|
|
50
|
-
res.on("end", () => resolve(res.statusCode === 200 ? body : null));
|
|
51
|
-
});
|
|
52
|
-
req.end();
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const ENTRY_EXTENSIONS = [
|
|
56
|
-
"",
|
|
57
|
-
".js",
|
|
58
|
-
".jsx",
|
|
59
|
-
".ts",
|
|
60
|
-
".tsx"
|
|
61
|
-
];
|
|
62
|
-
function entryExists(bundlePath, root) {
|
|
63
|
-
const entry = decodeURIComponent(bundlePath.replace(/\.bundle\/*$/, ""));
|
|
64
|
-
if (entry.startsWith("/.expo/")) return true;
|
|
65
|
-
for (let dir = resolve(root);; dir = dirname(dir)) {
|
|
66
|
-
const file = resolve(dir, `.${entry}`);
|
|
67
|
-
if (file.startsWith(dir + sep) && ENTRY_EXTENSIONS.some((ext) => existsSync(file + ext))) return true;
|
|
68
|
-
if (dirname(dir) === dir) return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function recordedBundleUrl(logsDir, root, platform) {
|
|
72
|
-
const setting = settingDefinition(`metro.warmupUrl.${platform}`);
|
|
73
|
-
if (!logsDir || !root || !setting) return null;
|
|
74
|
-
const log = join(logsDir, "metro.ndjson");
|
|
75
|
-
for (const file of [log, rotatedLogPath(log)]) for (const line of (tailLines(file) ?? []).toReversed()) try {
|
|
76
|
-
const record = JSON.parse(line);
|
|
77
|
-
if (record?.event === "bundle_response_started" && record.platform === platform && acceptsShape(setting, record.url) && entryExists(new URL(record.url, "http://localhost").pathname, root)) return record.url;
|
|
78
|
-
} catch {}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
async function warmMetro({ port, platform, isExpo, appId, bundleUrl, logsDir, root }) {
|
|
82
|
-
try {
|
|
83
|
-
const origin = `http://127.0.0.1:${port}`;
|
|
84
|
-
if (await requestLocal(new URL("/_stim/metro-warmup", origin), platform, false) !== "ready") return;
|
|
85
|
-
const url = new URL("/index.bundle", origin);
|
|
86
|
-
url.search = new URLSearchParams({
|
|
87
|
-
platform,
|
|
88
|
-
dev: "true",
|
|
89
|
-
lazy: "true",
|
|
90
|
-
minify: "false",
|
|
91
|
-
...platform === "ios" ? { inlineSourceMap: "false" } : {},
|
|
92
|
-
modulesOnly: "false",
|
|
93
|
-
runModule: "true",
|
|
94
|
-
excludeSource: "true",
|
|
95
|
-
sourcePaths: "url-server",
|
|
96
|
-
...appId ? { app: appId } : {}
|
|
97
|
-
}).toString();
|
|
98
|
-
bundleUrl ||= recordedBundleUrl(logsDir, root, platform);
|
|
99
|
-
if (!bundleUrl && isExpo) {
|
|
100
|
-
const body = await requestLocal(new URL(origin), platform, false);
|
|
101
|
-
if (body === null) return;
|
|
102
|
-
const manifest = JSON.parse(body);
|
|
103
|
-
bundleUrl = manifest.launchAsset?.url ?? manifest.bundleUrl;
|
|
104
|
-
if (typeof bundleUrl !== "string") return;
|
|
105
|
-
}
|
|
106
|
-
if (bundleUrl) {
|
|
107
|
-
const bundle = new URL(bundleUrl, origin);
|
|
108
|
-
url.pathname = bundle.pathname;
|
|
109
|
-
url.search = bundle.search;
|
|
110
|
-
}
|
|
111
|
-
await requestLocal(url, platform, true);
|
|
112
|
-
} catch {}
|
|
113
|
-
}
|
|
114
|
-
//#endregion
|
|
115
17
|
//#region src/engine/android-avd-setup.ts
|
|
116
18
|
var AvdBootError = class extends Error {
|
|
117
19
|
remedy;
|
|
@@ -122,12 +24,12 @@ var AvdBootError = class extends Error {
|
|
|
122
24
|
};
|
|
123
25
|
var AvdRecoveryError = class extends AvdBootError {};
|
|
124
26
|
function findOtherOwner(avdName, projectPath, selectedSlot = "default") {
|
|
125
|
-
for (const [path, project] of Object.entries(loadConfig
|
|
27
|
+
for (const [path, project] of Object.entries(loadConfig()?.projects ?? {})) if (projectDeviceSlots(project).some(({ slot, platforms }) => (path !== projectPath || slot !== selectedSlot) && platforms.android?.avdName?.toLowerCase() === avdName.toLowerCase())) return path;
|
|
126
28
|
return null;
|
|
127
29
|
}
|
|
128
30
|
async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, systemImage, deviceProfile, configuration, configure, teardown = teardownOwnedAvd }) {
|
|
129
|
-
const { claim, reservation, previous, avdName } = await withConfigLockAsync
|
|
130
|
-
const previous = deviceSlotPlatforms(loadConfig
|
|
31
|
+
const { claim, reservation, previous, avdName } = await withConfigLockAsync(() => {
|
|
32
|
+
const previous = deviceSlotPlatforms(loadConfig()?.projects?.[projectPath], slot)?.android;
|
|
131
33
|
if (previous?.avdName && previous.avdName !== previousAvdName) throw new Error(`Another Stim run assigned AVD ${previous.avdName} to this workspace. Retry to use it.`);
|
|
132
34
|
if (readParked("android").some((entry) => entry.name === ownedAvdName(label)) || findOtherOwner(ownedAvdName(label), projectPath, slot)) label = `${label}-${randomUUID().slice(0, 8)}`;
|
|
133
35
|
const avdName = ownedAvdName(label);
|
|
@@ -152,7 +54,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
|
|
|
152
54
|
throw error;
|
|
153
55
|
}
|
|
154
56
|
});
|
|
155
|
-
const currentRecord = () => deviceSlotPlatforms(loadConfig
|
|
57
|
+
const currentRecord = () => deviceSlotPlatforms(loadConfig()?.projects?.[projectPath], slot)?.android;
|
|
156
58
|
const assertReservation = () => {
|
|
157
59
|
if (readParked("android").some((entry) => entry.name === avdName)) throw new Error(`AVD ${avdName} was parked by another Stim run. Retry to adopt it safely.`);
|
|
158
60
|
const owner = findOtherOwner(avdName, projectPath, slot);
|
|
@@ -199,7 +101,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
|
|
|
199
101
|
if (!message.includes("already exists")) throw error;
|
|
200
102
|
try {
|
|
201
103
|
if (!(await listAvdsAsync()).includes(avdName)) throw new AvdRecoveryError(`AVD ${avdName} already exists on disk but is not listed by the emulator. ${message}`, "Run `npx stim gc` to inspect orphaned owned AVDs, then `npx stim gc --delete` to reclaim those safe to delete. Retry `stim android` after cleanup; keep any AVD that GC cannot verify.", error);
|
|
202
|
-
await withConfigLockAsync
|
|
104
|
+
await withConfigLockAsync(assertReservation);
|
|
203
105
|
const resolved = await resolveOwnedAvdSerialAsync(avdName);
|
|
204
106
|
if (resolved.missing || resolved.notOwned) throw new Error(`AVD ${avdName} could not be verified for recovery. Retry after checking its registration.`, { cause: error });
|
|
205
107
|
if (!resolved.serial) await assertOwnedAvdStoppedAsync(avdName);
|
|
@@ -214,7 +116,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
|
|
|
214
116
|
} : {}
|
|
215
117
|
};
|
|
216
118
|
} catch (recoveryError) {
|
|
217
|
-
await withConfigLockAsync
|
|
119
|
+
await withConfigLockAsync(() => {
|
|
218
120
|
if (!isDeepStrictEqual(currentRecord(), reservation)) return;
|
|
219
121
|
if (previous) setDevice(projectPath, "android", previous, slot);
|
|
220
122
|
else clearDevice(projectPath, "android", slot, avdName);
|
|
@@ -228,7 +130,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
|
|
|
228
130
|
} catch (error) {
|
|
229
131
|
configurationFailure = { error };
|
|
230
132
|
}
|
|
231
|
-
if (!configurationFailure) await withConfigLockAsync
|
|
133
|
+
if (!configurationFailure) await withConfigLockAsync(() => {
|
|
232
134
|
assertReservation();
|
|
233
135
|
setDevice(projectPath, "android", {
|
|
234
136
|
avdName,
|
|
@@ -258,7 +160,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
|
|
|
258
160
|
slot,
|
|
259
161
|
expectedRecord: reservation
|
|
260
162
|
},
|
|
261
|
-
onRemoved: () => withConfigLockAsync
|
|
163
|
+
onRemoved: () => withConfigLockAsync(() => clearDevice(projectPath, "android", slot, avdName))
|
|
262
164
|
});
|
|
263
165
|
const orphan = cleanup.status === "failed" || cleanup.status === "skipped" ? ` The owned AVD remains tracked for cleanup (${cleanup.reason || cleanup.status}); fix the cause, then retry or run \`stim gc --delete\`.` : "";
|
|
264
166
|
throw new Error(`Created owned AVD ${avdName}, but could not configure its AVD settings: ${String(error?.message || error)}${orphan}`, { cause: error });
|
|
@@ -286,7 +188,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
|
|
|
286
188
|
slot,
|
|
287
189
|
expectedRecord: record
|
|
288
190
|
},
|
|
289
|
-
onRemoved: () => withConfigLockAsync
|
|
191
|
+
onRemoved: () => withConfigLockAsync(() => clearDevice(projectPath, "android", slot, avdName))
|
|
290
192
|
});
|
|
291
193
|
if (cleanup.status === "failed" || cleanup.status === "skipped") throw new AvdRecoveryError(`Owned AVD ${record.avdName} has incomplete setup and could not be deleted (${cleanup.reason || cleanup.status}). Fix the cause, then retry; Stim kept the device record for cleanup.`, "Wait for any active AVD operation to finish. If the refusal names an unresolved claim, inspect its creator and native processes before removing only that claim. Retry `stim android` to reconcile the incomplete device.");
|
|
292
194
|
record = null;
|
|
@@ -304,7 +206,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
|
|
|
304
206
|
slot,
|
|
305
207
|
expectedRecord: record
|
|
306
208
|
},
|
|
307
|
-
onRemoved: () => withConfigLockAsync
|
|
209
|
+
onRemoved: () => withConfigLockAsync(() => clearDevice(projectPath, "android", slot, avdName))
|
|
308
210
|
});
|
|
309
211
|
if (cleanup.status === "failed" || cleanup.status === "skipped") throw new AvdRecoveryError(`Owned AVD ${avdName} never finished a boot, but could not be deleted to create one on ${requestedImage} (${cleanup.reason || cleanup.status}). Stim kept the device record.`, "Fix the cause, then retry, or pass `--slot <name>` to create the requested emulator beside it.");
|
|
310
212
|
out(phaseLine("device", `deleted ${avdName}, which never finished a boot, to create one on ${requestedImage}`));
|
|
@@ -329,7 +231,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
|
|
|
329
231
|
owned: true,
|
|
330
232
|
deviceName: record.deviceName ?? record.avdName
|
|
331
233
|
};
|
|
332
|
-
await withConfigLockAsync
|
|
234
|
+
await withConfigLockAsync(() => setDevice(projectPath, "android", updated, slot));
|
|
333
235
|
return {
|
|
334
236
|
...updated,
|
|
335
237
|
systemImage: ownedAvdSystemImage(record.avdName),
|
|
@@ -469,7 +371,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
|
|
|
469
371
|
deviceProfile: created.deviceProfile
|
|
470
372
|
};
|
|
471
373
|
}
|
|
472
|
-
function claimAndroidConsolePort({ projectPath, slot, avdName, deviceName, livePorts = [], metadata }, { lock = withConfigLock
|
|
374
|
+
function claimAndroidConsolePort({ projectPath, slot, avdName, deviceName, livePorts = [], metadata }, { lock = withConfigLock, recordedPorts = () => allConsolePortsAndSerials().androidConsolePorts, record = setDevice } = {}) {
|
|
473
375
|
return lock(() => {
|
|
474
376
|
const consolePort = nextConsolePort([...recordedPorts(), ...livePorts]);
|
|
475
377
|
const claim = {
|
|
@@ -495,7 +397,7 @@ async function bootOwnedAvdOnFreshPort({ avdName, deviceSlotWait, metadata, proj
|
|
|
495
397
|
key: avdName
|
|
496
398
|
}, async () => {
|
|
497
399
|
const livePorts = await liveAndroidConsolePorts();
|
|
498
|
-
const claim = await withConfigLockAsync
|
|
400
|
+
const claim = await withConfigLockAsync(() => claimAndroidConsolePort({
|
|
499
401
|
projectPath,
|
|
500
402
|
slot,
|
|
501
403
|
avdName,
|
|
@@ -518,7 +420,7 @@ async function bootOwnedAvdOnFreshPort({ avdName, deviceSlotWait, metadata, proj
|
|
|
518
420
|
if (result.failed) throw new AvdBootError(result.reason, result.remedy);
|
|
519
421
|
const running = await getAvdNameForSerialAsync(serial);
|
|
520
422
|
if (running && running !== avdName) throw new Error(`${serial} is running AVD ${running}, not this workspace's owned AVD ${avdName}; refusing to use it.`);
|
|
521
|
-
await withConfigLockAsync
|
|
423
|
+
await withConfigLockAsync(() => clearAndroidBootPending(projectPath, avdName, slot));
|
|
522
424
|
await muteBootedEmulator(serial, avdName, out);
|
|
523
425
|
const { bootPending: _booted, ...booted } = claim;
|
|
524
426
|
return {
|
|
@@ -527,7 +429,7 @@ async function bootOwnedAvdOnFreshPort({ avdName, deviceSlotWait, metadata, proj
|
|
|
527
429
|
setup: true
|
|
528
430
|
};
|
|
529
431
|
} catch (error) {
|
|
530
|
-
await withConfigLockAsync
|
|
432
|
+
await withConfigLockAsync(() => releaseAndroidConsolePort(projectPath, claim.consolePort, slot));
|
|
531
433
|
throw error;
|
|
532
434
|
}
|
|
533
435
|
}, {
|
|
@@ -670,7 +572,7 @@ async function ensureAndroidBooted({ device, deviceSlotWait, projectPath, slot,
|
|
|
670
572
|
};
|
|
671
573
|
const avdName = device.avdName;
|
|
672
574
|
const booted = async (result) => {
|
|
673
|
-
if (!result.failed) await withConfigLockAsync
|
|
575
|
+
if (!result.failed) await withConfigLockAsync(() => clearAndroidBootPending(projectPath, avdName, slot));
|
|
674
576
|
return result;
|
|
675
577
|
};
|
|
676
578
|
if (resolved.serial) return booted(await waitForAndroidBoot({
|
|
@@ -686,7 +588,7 @@ async function ensureAndroidBooted({ device, deviceSlotWait, projectPath, slot,
|
|
|
686
588
|
}));
|
|
687
589
|
const boot = async () => {
|
|
688
590
|
const livePorts = await liveAndroidConsolePorts();
|
|
689
|
-
const claim = await withConfigLockAsync
|
|
591
|
+
const claim = await withConfigLockAsync(() => claimAndroidConsolePort({
|
|
690
592
|
projectPath,
|
|
691
593
|
slot,
|
|
692
594
|
avdName,
|
|
@@ -701,7 +603,7 @@ async function ensureAndroidBooted({ device, deviceSlotWait, projectPath, slot,
|
|
|
701
603
|
try {
|
|
702
604
|
pid = await bootAndroidEmulator(avdName, claim.consolePort, { logFile });
|
|
703
605
|
} catch (e) {
|
|
704
|
-
await withConfigLockAsync
|
|
606
|
+
await withConfigLockAsync(() => releaseAndroidConsolePort(projectPath, claim.consolePort, slot));
|
|
705
607
|
return {
|
|
706
608
|
failed: true,
|
|
707
609
|
reason: `Could not start emulator for AVD ${avdName}: ${e?.message || e}`
|
|
@@ -714,7 +616,7 @@ async function ensureAndroidBooted({ device, deviceSlotWait, projectPath, slot,
|
|
|
714
616
|
alive,
|
|
715
617
|
out
|
|
716
618
|
});
|
|
717
|
-
if (result.failed) await withConfigLockAsync
|
|
619
|
+
if (result.failed) await withConfigLockAsync(() => releaseAndroidConsolePort(projectPath, claim.consolePort, slot));
|
|
718
620
|
else await muteBootedEmulator(serial, avdName, out);
|
|
719
621
|
return booted(result);
|
|
720
622
|
};
|
|
@@ -739,73 +641,4 @@ async function ensureAndroidBooted({ device, deviceSlotWait, projectPath, slot,
|
|
|
739
641
|
}
|
|
740
642
|
}
|
|
741
643
|
//#endregion
|
|
742
|
-
|
|
743
|
-
/**
|
|
744
|
-
* Whether `ensureOwnedDevice` created, adopted or started booting the device, rather than finding it booted.
|
|
745
|
-
* Undefined for a remote device, which those functions do not describe.
|
|
746
|
-
*/
|
|
747
|
-
function didSetUpDevice(device, remote) {
|
|
748
|
-
return remote ? void 0 : Boolean(device.setup || device.booting);
|
|
749
|
-
}
|
|
750
|
-
async function ensureOwnedDevice({ platform, project, projectPath, slot, settingsRoot = projectPath, label = ownedDeviceLabel(projectPath), settings, flags = {}, note = () => {}, out = () => {}, logFile = null, alive = pidExists, configureAvd = configureNewOwnedAvd, teardownAvd = teardownOwnedAvd, reconcileIosSimulator = reconcileSimSlim, simSnapshot }) {
|
|
751
|
-
await clearDeviceIdleShutdown(projectPath, platform, slot);
|
|
752
|
-
if (slot && slot !== "default") label = `${label}-${slot}`;
|
|
753
|
-
const record = deviceSlotPlatforms(project, slot)?.[platform] ?? null;
|
|
754
|
-
if (platform === "ios") return ensureOwnedIosDevice({
|
|
755
|
-
record,
|
|
756
|
-
projectPath,
|
|
757
|
-
slot,
|
|
758
|
-
settingsRoot,
|
|
759
|
-
label,
|
|
760
|
-
settings,
|
|
761
|
-
flags,
|
|
762
|
-
note,
|
|
763
|
-
out,
|
|
764
|
-
reconcileIosSimulator,
|
|
765
|
-
simSnapshot
|
|
766
|
-
});
|
|
767
|
-
return ensureOwnedAndroidDevice({
|
|
768
|
-
record,
|
|
769
|
-
projectPath,
|
|
770
|
-
slot,
|
|
771
|
-
settingsRoot,
|
|
772
|
-
label,
|
|
773
|
-
settings,
|
|
774
|
-
flags,
|
|
775
|
-
note,
|
|
776
|
-
out,
|
|
777
|
-
logFile,
|
|
778
|
-
alive,
|
|
779
|
-
configureAvd,
|
|
780
|
-
teardownAvd
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
const BOOT_POLL_MS = 500;
|
|
784
|
-
async function ensureBooted({ platform, device, simulatorApp, timeoutMs, pollMs = BOOT_POLL_MS, out = () => {}, logFile = null, alive = pidExists, projectPath, slot, deviceSlotWait }) {
|
|
785
|
-
if (platform === "ios") return ensureIosBooted({
|
|
786
|
-
device,
|
|
787
|
-
projectPath,
|
|
788
|
-
slot,
|
|
789
|
-
deviceSlotWait,
|
|
790
|
-
simulatorApp,
|
|
791
|
-
timeoutMs: timeoutMs ?? 6e5,
|
|
792
|
-
pollMs,
|
|
793
|
-
out
|
|
794
|
-
});
|
|
795
|
-
if (platform === "android") return ensureAndroidBooted({
|
|
796
|
-
device,
|
|
797
|
-
deviceSlotWait,
|
|
798
|
-
projectPath,
|
|
799
|
-
slot,
|
|
800
|
-
timeoutMs: timeoutMs ?? ANDROID_BOOT_TIMEOUT_MS,
|
|
801
|
-
out,
|
|
802
|
-
logFile,
|
|
803
|
-
alive
|
|
804
|
-
});
|
|
805
|
-
return {
|
|
806
|
-
failed: true,
|
|
807
|
-
reason: `Unknown platform "${platform}".`
|
|
808
|
-
};
|
|
809
|
-
}
|
|
810
|
-
//#endregion
|
|
811
|
-
export { AvdRecoveryError as a, AvdBootError as i, ensureBooted as n, warmMetro as o, ensureOwnedDevice as r, didSetUpDevice as t };
|
|
644
|
+
export { AvdBootError as a, muteBootedEmulator as i, ensureAndroidBooted as n, AvdRecoveryError as o, ensureOwnedAndroidDevice as r, ANDROID_BOOT_TIMEOUT_MS as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { D as ownership_claim_exports, d as workspaceProcessLockError, u as withWorkspaceProcessLock } from "./exec-aULwtNly.mjs";
|
|
2
2
|
import { G as projectDeviceSlots, H as deviceSlotPlatforms, O as withConfigLockAsync$1, _ as loadConfig$1, d as getConfigDir, u as getConcurrencyLimits } from "./config-AbUjIBOQ.mjs";
|
|
3
|
-
import { a as formatElapsed, l as phaseLine } from "./command-output-
|
|
3
|
+
import { a as formatElapsed, l as phaseLine } from "./command-output-BBW8eWPL.mjs";
|
|
4
4
|
import { g as deviceReclaimIdleMinutesSetting } from "./settings-D776ygML.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { ot as recordCapacityRefusal, st as recordCapacityWait, v as withIdleWorkspace } from "./workspaces-
|
|
5
|
+
import { M as listAdbDevicesAsync, j as listAdbDevices } from "./android-DdKG6lyD.mjs";
|
|
6
|
+
import { ot as recordCapacityRefusal, st as recordCapacityWait, v as withIdleWorkspace } from "./workspaces-7_RWoi6c.mjs";
|
|
7
7
|
import { t as canonicalPath } from "./paths-BsJMoPP2.mjs";
|
|
8
|
-
import { d as listAllIosSims, f as listAllIosSimsAsync, l as iosRuntimeMatches, y as parseRuntimeVersion } from "./ios-
|
|
9
|
-
import { i as writeIdleShutdownEvent, n as dueIdleDevices, r as shutDownIdleDevices } from "./idle-shutdown-
|
|
8
|
+
import { d as listAllIosSims, f as listAllIosSimsAsync, l as iosRuntimeMatches, y as parseRuntimeVersion } from "./ios-CXnoVO_z.mjs";
|
|
9
|
+
import { i as writeIdleShutdownEvent, n as dueIdleDevices, r as shutDownIdleDevices } from "./idle-shutdown-BcMN_cLm.mjs";
|
|
10
10
|
import { realpathSync } from "node:fs";
|
|
11
11
|
import { basename, join } from "node:path";
|
|
12
12
|
import { workspaceId } from "@stim-cli/core";
|
|
@@ -331,11 +331,11 @@ function deviceCapacityRefusal({ platform, project, slot = "default", max, sims
|
|
|
331
331
|
* The early `concurrency.maxDevices` check, before Metro starts or a device is created. It is advisory, so an
|
|
332
332
|
* unknown count passes: `withDeviceBootAdmission` makes the binding decision when the boot starts.
|
|
333
333
|
*/
|
|
334
|
-
function checkDeviceCapacity({ platform, project, slot = "default", max, ...sources } = {}) {
|
|
334
|
+
async function checkDeviceCapacity({ platform, project, slot = "default", max, ...sources } = {}) {
|
|
335
335
|
if (!max || max <= 0) return null;
|
|
336
336
|
let inventory;
|
|
337
337
|
try {
|
|
338
|
-
inventory =
|
|
338
|
+
inventory = await readInventoryAsync(sources);
|
|
339
339
|
} catch (error) {
|
|
340
340
|
if ((0, ownership_claim_exports.isClaimRefusal)(error)) return null;
|
|
341
341
|
throw error;
|
|
@@ -349,9 +349,9 @@ function checkDeviceCapacity({ platform, project, slot = "default", max, ...sour
|
|
|
349
349
|
...inventory
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
|
-
function peekDeviceSlots({ platform, project, slot = "default", max = getConcurrencyLimits().maxDevices, sources = {} }) {
|
|
352
|
+
async function peekDeviceSlots({ platform, project, slot = "default", max = getConcurrencyLimits().maxDevices, sources = {} }) {
|
|
353
353
|
try {
|
|
354
|
-
const inventory =
|
|
354
|
+
const inventory = await readInventoryAsync(sources);
|
|
355
355
|
if ("code" in inventory) return {
|
|
356
356
|
count: null,
|
|
357
357
|
max,
|