stim 1.9.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/dist/{android-_y4Ohi5z.mjs → android-787HhP5w.mjs} +119 -29
- package/dist/{android-BPGizezh.mjs → android-DBkeHwpm.mjs} +168 -95
- package/dist/{android-DEgo4oCo.mjs → android-DPov-fv2.mjs} +2 -2
- package/dist/{android-cas-eiExNLf7.mjs → android-cas-CITmIeWY.mjs} +9 -8
- package/dist/android-cas-compiler.mjs +1 -1
- package/dist/{app-install-Uf3a83Tv.mjs → app-install-CrJ6t_bv.mjs} +2 -2
- package/dist/budget-BP4jZZL4.mjs +620 -0
- package/dist/build-progress-BXx-ZBe4.mjs +512 -0
- package/dist/{cache-manifest-Dg7OnMrp.mjs → cache-manifest-Pubfp8wV.mjs} +1 -1
- package/dist/cache-manifest.mjs +1 -1
- package/dist/cli.mjs +16 -16
- package/dist/collector-run.d.mts +5 -1
- package/dist/collector-run.mjs +7 -7
- package/dist/{command-output-gByVmIjy.mjs → command-output-D5z2_bcF.mjs} +1 -1
- package/dist/{config-Cp9lM3wX.mjs → config-BEq0Qw_a.mjs} +14 -131
- package/dist/{dependency-state-Bq5DcLGn.mjs → dependency-state-r9UesA9a.mjs} +2 -2
- package/dist/{deps-Cip5vUm1.mjs → deps-DP4eWqea.mjs} +3 -3
- package/dist/{detached-entry-KEu0_AXL.mjs → detached-entry-DJHoca49.mjs} +1 -1
- package/dist/{dev-client-HyqISM0h.mjs → dev-client-92U593KT.mjs} +137 -250
- package/dist/{device-D4U-xLty.mjs → device-DhTZe7L4.mjs} +7 -7
- package/dist/{build-lock-DPXPLgTc.mjs → device-lease-CbEaIk7b.mjs} +370 -12
- package/dist/{device-pool-CnTAz8X1.mjs → device-pool-Di8Q-9Ro.mjs} +4 -4
- package/dist/{device-remote-AQ5rQPqr.mjs → device-remote-Dy1jGj3U.mjs} +547 -468
- package/dist/{doctor-B_Ei3bZu.mjs → doctor-B-inAJmt.mjs} +58 -22
- package/dist/{error-diagnostics-Vfz83GCF.mjs → error-diagnostics-xxWKNO3-.mjs} +11 -12
- package/dist/{exec-jIAlgilk.mjs → exec-DK8KaVHK.mjs} +3 -2
- package/dist/{gc-Ckw8RQHi.mjs → gc-ChPFZMRC.mjs} +500 -1114
- package/dist/{guide-BiAbhs1J.mjs → guide-DwmaD_Wa.mjs} +882 -528
- package/dist/guide-status-CWvti2Lg.mjs +125 -0
- package/dist/idle-DpRLp5lj.mjs +157 -0
- package/dist/in-use-CjUluqIX.mjs +245 -0
- package/dist/{ios-BL2NFckr.mjs → ios-B2Fpqvlb.mjs} +25 -59
- package/dist/{ios-BzUJWk1K.mjs → ios-Dd-hYJBh.mjs} +130 -89
- package/dist/{ios-device-DPsSm0v_.mjs → ios-device-BiOsSVzd.mjs} +1 -1
- package/dist/{ios-device-D972i9wf.mjs → ios-device-CtRdEVjx.mjs} +3 -3
- package/dist/{launch-verify-Q_OtW1Rf.mjs → launch-verify-CQS_Kg-C.mjs} +5 -5
- package/dist/{logs-CI9NQSK7.mjs → logs-MARIy6m9.mjs} +9 -9
- package/dist/{metro-DrLHaMn2.mjs → metro-BWLOJ_Wr.mjs} +116 -10
- package/dist/{named-ports-CmLQSIRj.mjs → named-ports-DiTfSz6p.mjs} +4 -4
- package/dist/{ndjson-9uFNRwfe.mjs → ndjson-CDY9IkVC.mjs} +3 -56
- package/dist/{ndjson-DvHSsNU9.d.mts → ndjson-Du3j0AQ9.d.mts} +1 -0
- package/dist/{ownership-D15Op8vN.mjs → ownership-D2xbLVoz.mjs} +2 -3
- package/dist/ownership-DZjdx8Gq.mjs +1180 -0
- package/dist/{ports-BNKoWVWZ.mjs → ports-CLSSFOuz.mjs} +3 -3
- package/dist/{project-DS112DYB.mjs → project-BXZzOABt.mjs} +2 -2
- package/dist/{reload-ZNJUo1pl.mjs → reload-DoETJ3rl.mjs} +9 -10
- package/dist/{server-bare-DWkkcIxV.mjs → server-bare-DVbb7kXH.mjs} +1 -1
- package/dist/{server-expo-B_lctBR3.mjs → server-expo-BvOCeakp.mjs} +4 -4
- package/dist/server-expo-DBVTdult.mjs +2 -0
- package/dist/{settings-D030k0t4.mjs → settings-DOugPlPz.mjs} +16 -428
- package/dist/{settings-BKNh5rl4.mjs → settings-EWYNwe72.mjs} +16 -14
- package/dist/settings.schema.json +75 -0
- package/dist/{simslim-B_LsGLuJ.mjs → simslim-Ca3487H6.mjs} +182 -5
- package/dist/{slot-launch-DU9A-gYw.mjs → slot-launch-C5cg0fmk.mjs} +4 -4
- package/dist/{spawn-claims-Dn3C_N6w.mjs → spawn-claims-CUleC2cM.mjs} +1 -1
- package/dist/{start-DYkkKF0s.mjs → start-F9gv5dcC.mjs} +147 -98
- package/dist/start-VoFsPSes.mjs +2 -0
- package/dist/{state-NcJzMEBF.mjs → state-WGdIbi_d.mjs} +2 -2
- package/dist/{stats-DG9e66Rz.mjs → stats-BAgJaLA4.mjs} +1 -1
- package/dist/{stats-B63-JVAY.mjs → stats-DBYJ5bxL.mjs} +4 -4
- package/dist/{status-S6ehL4Ui.mjs → status-DLCD-o3s.mjs} +63 -231
- package/dist/status-Dr4fRkym.mjs +216 -0
- package/dist/{guide-status-BAMVU0ZA.mjs → stim-installations-CINXy_su.mjs} +3 -124
- package/dist/{stop-BO28HGqF.mjs → stop-Dj4pfmyv.mjs} +22 -18
- package/dist/{stop-T1R-cZRz.mjs → stop-ZvOeTmKb.mjs} +2 -2
- package/dist/supervisor-run.d.mts +11 -2
- package/dist/supervisor-run.mjs +185 -17
- package/dist/{workspace-process-lock-DWaiRD0e.mjs → workspace-process-lock-BXA96myD.mjs} +2 -2
- package/dist/workspaces-BTUyFfkv.mjs +1003 -0
- package/dist/{worktree-DKhSF0UX.mjs → worktree-4aZg2NnI.mjs} +1 -1
- package/dist/{worktree-LGB-UwgG.mjs → worktree-BMS7GeqB.mjs} +40 -122
- package/dist/{worktree-R_cUlE7s.mjs → worktree-BlizKDpZ.mjs} +143 -18
- package/dist/{xcode-BZqyxh3e.mjs → xcode-B2tBkf0m.mjs} +9 -158
- package/package.json +6 -5
- package/dist/build-progress-CVqkfPC6.mjs +0 -188
- package/dist/device-lease-Crs-HkJY.mjs +0 -366
- package/dist/logs-query-Cqma3WIu.mjs +0 -298
- package/dist/ownership-DCQPuWEc.mjs +0 -489
- package/dist/public-http-probe-CyMDrQ3c.mjs +0 -61
- package/dist/server-expo-CeILEu86.mjs +0 -2
- package/dist/sim-pool-KaIsp2Ft.mjs +0 -723
- package/dist/spawn-entry-nCE6m770.mjs +0 -14
- package/dist/workspace-state-DF2gCFhx.mjs +0 -169
|
@@ -1,9 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { u as getConfigDir } from "./config-BEq0Qw_a.mjs";
|
|
2
|
+
import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
|
|
3
|
+
import { P as withDirLock, c as signalProcessTree, i as pidExists } from "./metro-BWLOJ_Wr.mjs";
|
|
4
|
+
import { c as androidDataPartitionSizeBytes } from "./settings-DOugPlPz.mjs";
|
|
5
|
+
import { mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { existsSync as existsSync$1, lstatSync as lstatSync$1, mkdirSync as mkdirSync$1, openSync as openSync$1, readFileSync as readFileSync$1, readdirSync as readdirSync$1, realpathSync as realpathSync$1, renameSync as renameSync$1, rmSync as rmSync$1, statSync as statSync$1, writeFileSync as writeFileSync$1 } from "fs";
|
|
5
7
|
import { dirname, isAbsolute, join, resolve } from "path";
|
|
8
|
+
import { createdDevicesFile, createdDevicesLock, readCreatedDevices, readCreatedDevices as readCreatedDevices$1 } from "@stim-cli/core/state";
|
|
6
9
|
import { homedir, tmpdir } from "os";
|
|
10
|
+
//#region src/devices/created-devices.ts
|
|
11
|
+
function update(platform, change) {
|
|
12
|
+
const dir = getConfigDir();
|
|
13
|
+
withDirLock(createdDevicesLock(), () => {
|
|
14
|
+
const current = readCreatedDevices();
|
|
15
|
+
const entries = new Set(current[platform]);
|
|
16
|
+
if (!change(entries)) return;
|
|
17
|
+
const next = {
|
|
18
|
+
version: 1,
|
|
19
|
+
ios: [...current.ios],
|
|
20
|
+
android: [...current.android],
|
|
21
|
+
[platform]: [...entries]
|
|
22
|
+
};
|
|
23
|
+
const file = createdDevicesFile();
|
|
24
|
+
const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
25
|
+
writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`);
|
|
26
|
+
try {
|
|
27
|
+
renameSync(tmp, file);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
rmSync(tmp, { force: true });
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}, { ensureParent: () => mkdirSync(dir, { recursive: true }) });
|
|
33
|
+
}
|
|
34
|
+
function recordCreatedDevice(platform, id) {
|
|
35
|
+
update(platform, (entries) => entries.size !== entries.add(id).size);
|
|
36
|
+
}
|
|
37
|
+
function forgetCreatedDevice(platform, id) {
|
|
38
|
+
update(platform, (entries) => entries.delete(id));
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/devices/device-ownership.ts
|
|
42
|
+
const OWNED_SIM_NAME = /^stim-[A-Za-z0-9._-]+ \(.* \d+(?:\.\d+)*\)(?: [A-Za-z0-9-]+)?$/;
|
|
43
|
+
const OWNED_AVD_NAME = /^stim-[A-Za-z0-9._-]+$/;
|
|
44
|
+
const GIB = 1024 ** 3;
|
|
45
|
+
function isOwnedSimName(name) {
|
|
46
|
+
return OWNED_SIM_NAME.test(name);
|
|
47
|
+
}
|
|
48
|
+
function isOwnedAvdName(name) {
|
|
49
|
+
return OWNED_AVD_NAME.test(name);
|
|
50
|
+
}
|
|
51
|
+
function avdConfigWrittenByStim(configIni) {
|
|
52
|
+
for (const line of String(configIni ?? "").split(/\r?\n/)) {
|
|
53
|
+
const match = /^disk\.dataPartition\.size=(\d+)$/.exec(line.trim());
|
|
54
|
+
if (match) return Number(match[1]) > 0 && Number(match[1]) % GIB === 0;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function isStimOwnedSim(sim, created = readCreatedDevices$1()) {
|
|
59
|
+
const name = sim.name ?? "";
|
|
60
|
+
return name.startsWith("stim-") && (created.ios.has(sim.udid) || isOwnedSimName(name));
|
|
61
|
+
}
|
|
62
|
+
function isStimOwnedAvd(name, readConfig, created = readCreatedDevices$1()) {
|
|
63
|
+
return isOwnedAvdName(name) && (created.android.has(name) || avdConfigWrittenByStim(readConfig()));
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
7
66
|
//#region src/devices/android.ts
|
|
8
67
|
const ANDROID_ABIS = /* @__PURE__ */ new Set([
|
|
9
68
|
"armeabi-v7a",
|
|
@@ -38,7 +97,7 @@ function androidToolPath(tool, platform = process.platform) {
|
|
|
38
97
|
const bare = location.at(-1);
|
|
39
98
|
const name = platform === "win32" ? `${bare}${WINDOWS_SDK_TOOL_EXTENSIONS[tool]}` : bare;
|
|
40
99
|
const abs = join(androidHome(), ...location.slice(0, -1), name);
|
|
41
|
-
return existsSync(abs) ? abs : bare;
|
|
100
|
+
return existsSync$1(abs) ? abs : bare;
|
|
42
101
|
}
|
|
43
102
|
const WINDOWS_BUILD_TOOL_EXTENSIONS = { apksigner: ".bat" };
|
|
44
103
|
function androidBuildToolName(tool, platform = process.platform) {
|
|
@@ -60,7 +119,7 @@ function buildToolsMajor(version) {
|
|
|
60
119
|
const major = Number(String(version ?? "").split(/[.-]/)[0]);
|
|
61
120
|
return Number.isFinite(major) ? major : 0;
|
|
62
121
|
}
|
|
63
|
-
function findBuildTool(tools, { home = androidHome(), readDir = readdirSync, exists = existsSync, platform = process.platform } = {}) {
|
|
122
|
+
function findBuildTool(tools, { home = androidHome(), readDir = readdirSync$1, exists = existsSync$1, platform = process.platform } = {}) {
|
|
64
123
|
const root = join(home, "build-tools");
|
|
65
124
|
let versions = [];
|
|
66
125
|
try {
|
|
@@ -91,7 +150,7 @@ function androidTool(tool) {
|
|
|
91
150
|
function listInstalledSystemImages() {
|
|
92
151
|
const root = join(androidHome(), "system-images");
|
|
93
152
|
const images = [];
|
|
94
|
-
if (!existsSync(root)) return images;
|
|
153
|
+
if (!existsSync$1(root)) return images;
|
|
95
154
|
for (const apiDir of safeList(root)) {
|
|
96
155
|
const m = apiDir.match(/^android-(\d+)$/);
|
|
97
156
|
if (!m) continue;
|
|
@@ -107,7 +166,7 @@ function listInstalledSystemImages() {
|
|
|
107
166
|
}
|
|
108
167
|
function safeList(dir) {
|
|
109
168
|
try {
|
|
110
|
-
return readdirSync(dir);
|
|
169
|
+
return readdirSync$1(dir);
|
|
111
170
|
} catch {
|
|
112
171
|
return [];
|
|
113
172
|
}
|
|
@@ -132,6 +191,7 @@ async function createOwnedAvd(label, { systemImage, spawn = (...args) => getExec
|
|
|
132
191
|
throw new Error(`No ${arch} Android system image is installed. Install one, e.g.: sdkmanager "system-images;android-36;google_apis;${arch}"`);
|
|
133
192
|
}
|
|
134
193
|
const avdName = ownedAvdName(label);
|
|
194
|
+
recordCreatedDevice("android", avdName);
|
|
135
195
|
const tool = androidToolPath("avdmanager");
|
|
136
196
|
const args = [
|
|
137
197
|
"create",
|
|
@@ -183,7 +243,7 @@ function parseAvdSystemImage(configIni) {
|
|
|
183
243
|
}
|
|
184
244
|
return null;
|
|
185
245
|
}
|
|
186
|
-
function ownedAvdSystemImage(avdName, { avdDirectory = ownedAvdDirectory, readFile = (path) => readFileSync(path, "utf8") } = {}) {
|
|
246
|
+
function ownedAvdSystemImage(avdName, { avdDirectory = ownedAvdDirectory, readFile = (path) => readFileSync$1(path, "utf8") } = {}) {
|
|
187
247
|
const directory = avdDirectory(avdName);
|
|
188
248
|
if (!directory) return null;
|
|
189
249
|
try {
|
|
@@ -195,17 +255,32 @@ function ownedAvdSystemImage(avdName, { avdDirectory = ownedAvdDirectory, readFi
|
|
|
195
255
|
function sanitizeAvdLabel(label) {
|
|
196
256
|
return String(label).replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
197
257
|
}
|
|
258
|
+
function avdConfigIni(avdName, directory = ownedAvdDirectory(avdName)) {
|
|
259
|
+
if (!directory) return null;
|
|
260
|
+
try {
|
|
261
|
+
return readFileSync$1(join(directory, "config.ini"), "utf8");
|
|
262
|
+
} catch {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function registeredOrOrphanedAvdDirectory(avdName) {
|
|
267
|
+
return ownedAvdDirectory(avdName) ?? listOrphanedAvdDirectories(avdName)[0]?.directory ?? null;
|
|
268
|
+
}
|
|
269
|
+
function isStimOwnedAvdName(avdName, directory) {
|
|
270
|
+
return isStimOwnedAvd(avdName, () => avdConfigIni(avdName, directory === void 0 ? registeredOrOrphanedAvdDirectory(avdName) : directory));
|
|
271
|
+
}
|
|
198
272
|
function ownedAvdName(label) {
|
|
199
273
|
const clean = sanitizeAvdLabel(label);
|
|
200
274
|
return `stim-${clean.startsWith("stim-") ? clean.slice(5) : clean}`;
|
|
201
275
|
}
|
|
202
276
|
const AVDMANAGER_DELETE_TIMEOUT_MS = 12e4;
|
|
203
277
|
function deleteAvd(avdName) {
|
|
204
|
-
if (!avdName
|
|
278
|
+
if (!isStimOwnedAvdName(avdName)) throw new Error(`Refusing to delete AVD "${avdName}": not a Stim-owned AVD; Stim has no record of creating it.`);
|
|
205
279
|
getExecutor().run(`${androidTool("avdmanager")} delete avd -n "${avdName}"`, {
|
|
206
280
|
timeoutMs: AVDMANAGER_DELETE_TIMEOUT_MS,
|
|
207
281
|
killSignal: "SIGKILL"
|
|
208
282
|
});
|
|
283
|
+
forgetCreatedDevice("android", avdName);
|
|
209
284
|
}
|
|
210
285
|
function parseAvdList(text) {
|
|
211
286
|
return text.split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("INFO") && !l.startsWith("WARNING"));
|
|
@@ -420,7 +495,7 @@ function avdStorageRoots() {
|
|
|
420
495
|
}
|
|
421
496
|
function avdPathExists(path) {
|
|
422
497
|
try {
|
|
423
|
-
lstatSync(path);
|
|
498
|
+
lstatSync$1(path);
|
|
424
499
|
return true;
|
|
425
500
|
} catch (error) {
|
|
426
501
|
if (error.code === "ENOENT") return false;
|
|
@@ -431,17 +506,17 @@ function listOrphanedAvdDirectories(avdName) {
|
|
|
431
506
|
const roots = avdStorageRoots();
|
|
432
507
|
const stores = roots.filter(avdPathExists).map((root) => ({
|
|
433
508
|
root,
|
|
434
|
-
canonicalRoot: realpathSync(root),
|
|
435
|
-
names: readdirSync(root)
|
|
509
|
+
canonicalRoot: realpathSync$1(root),
|
|
510
|
+
names: readdirSync$1(root)
|
|
436
511
|
}));
|
|
437
512
|
const registered = /* @__PURE__ */ new Set();
|
|
438
513
|
for (const { root, canonicalRoot, names } of stores) for (const name of names.filter((entry) => entry.endsWith(".ini"))) {
|
|
439
514
|
const path = join(root, name);
|
|
440
|
-
const ini = readFileSync(path, "utf8");
|
|
515
|
+
const ini = readFileSync$1(path, "utf8");
|
|
441
516
|
const targets = /* @__PURE__ */ new Set([...avdIniPaths(root, ini), ...avdIniPaths(canonicalRoot, ini)]);
|
|
442
517
|
if (!targets.size) throw new Error(`Cannot verify AVD registration at ${path}; its data was kept.`);
|
|
443
518
|
for (const target of targets) try {
|
|
444
|
-
registered.add(realpathSync(target));
|
|
519
|
+
registered.add(realpathSync$1(target));
|
|
445
520
|
} catch (error) {
|
|
446
521
|
const code = error.code;
|
|
447
522
|
if (code !== "ENOENT" && code !== "ENOTDIR") throw error;
|
|
@@ -456,8 +531,8 @@ function listOrphanedAvdDirectories(avdName) {
|
|
|
456
531
|
if (roots.some((candidate) => avdPathExists(join(candidate, `${name}.ini`)))) continue;
|
|
457
532
|
const directory = join(canonicalRoot, entry);
|
|
458
533
|
if (registered.has(directory) || !avdPathExists(directory)) continue;
|
|
459
|
-
const stat = lstatSync(directory);
|
|
460
|
-
if (!stat.isDirectory() || stat.isSymbolicLink() || realpathSync(directory) !== directory) throw new Error(`Cannot verify AVD data at ${directory}; it was kept.`);
|
|
534
|
+
const stat = lstatSync$1(directory);
|
|
535
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || realpathSync$1(directory) !== directory) throw new Error(`Cannot verify AVD data at ${directory}; it was kept.`);
|
|
461
536
|
if (!orphaned.some((candidate) => candidate.directory === directory)) orphaned.push({
|
|
462
537
|
name,
|
|
463
538
|
directory,
|
|
@@ -468,7 +543,7 @@ function listOrphanedAvdDirectories(avdName) {
|
|
|
468
543
|
}
|
|
469
544
|
return orphaned;
|
|
470
545
|
}
|
|
471
|
-
function ownedAvdDirectory(avdName, { env = process.env, home = homedir(), readFile = (path) => readFileSync(path, "utf8"), realpath = realpathSync, isDirectory = (path) => statSync(path).isDirectory() } = {}) {
|
|
546
|
+
function ownedAvdDirectory(avdName, { env = process.env, home = homedir(), readFile = (path) => readFileSync$1(path, "utf8"), realpath = realpathSync$1, isDirectory = (path) => statSync$1(path).isDirectory() } = {}) {
|
|
472
547
|
if (!/^stim-[A-Za-z0-9._-]+$/.test(avdName)) return null;
|
|
473
548
|
const roots = [
|
|
474
549
|
env.ANDROID_AVD_HOME,
|
|
@@ -492,6 +567,21 @@ function ownedAvdDirectory(avdName, { env = process.env, home = homedir(), readF
|
|
|
492
567
|
}
|
|
493
568
|
return null;
|
|
494
569
|
}
|
|
570
|
+
const AVD_USER_DATA = [
|
|
571
|
+
"userdata-qemu.img",
|
|
572
|
+
"userdata-qemu.img.qcow2",
|
|
573
|
+
"encryptionkey.img",
|
|
574
|
+
"encryptionkey.img.qcow2",
|
|
575
|
+
"cache.img",
|
|
576
|
+
"cache.img.qcow2",
|
|
577
|
+
"snapshots"
|
|
578
|
+
];
|
|
579
|
+
function wipeAvdUserData(directory) {
|
|
580
|
+
for (const name of AVD_USER_DATA) rmSync$1(join(directory, name), {
|
|
581
|
+
recursive: true,
|
|
582
|
+
force: true
|
|
583
|
+
});
|
|
584
|
+
}
|
|
495
585
|
function withAvdConfigOverrides(contents, overrides) {
|
|
496
586
|
const newline = contents.includes("\r\n") ? "\r\n" : "\n";
|
|
497
587
|
const trailingNewline = /\r?\n$/.test(contents);
|
|
@@ -513,10 +603,10 @@ function withAvdConfigOverrides(contents, overrides) {
|
|
|
513
603
|
return updated.join(newline) + (trailingNewline ? newline : "");
|
|
514
604
|
}
|
|
515
605
|
let avdConfigWriteSequence = 0;
|
|
516
|
-
function configureNewOwnedAvd(avdName, { dataPartitionSizeGb, avdConfig = {} }, { avdDirectory = ownedAvdDirectory, readFile = (path) => readFileSync(path, "utf8"), writeFile = (path, contents) => writeFileSync(path, contents, {
|
|
606
|
+
function configureNewOwnedAvd(avdName, { dataPartitionSizeGb, avdConfig = {} }, { avdDirectory = ownedAvdDirectory, readFile = (path) => readFileSync$1(path, "utf8"), writeFile = (path, contents) => writeFileSync$1(path, contents, {
|
|
517
607
|
encoding: "utf8",
|
|
518
608
|
flag: "wx"
|
|
519
|
-
}), rename = renameSync, remove = (path) => rmSync(path, { force: true }) } = {}) {
|
|
609
|
+
}), rename = renameSync$1, remove = (path) => rmSync$1(path, { force: true }) } = {}) {
|
|
520
610
|
const sizeBytes = androidDataPartitionSizeBytes(dataPartitionSizeGb);
|
|
521
611
|
const directory = avdDirectory(avdName);
|
|
522
612
|
if (!directory) throw new Error(`Could not resolve the content directory for newly created AVD ${avdName}.`);
|
|
@@ -551,7 +641,7 @@ function avdPoolConfiguration(dataPartitionSizeGb, avdConfig) {
|
|
|
551
641
|
function ownedAvdMatchesConfiguration(avdName, configuration) {
|
|
552
642
|
const directory = ownedAvdDirectory(avdName);
|
|
553
643
|
if (!directory) return false;
|
|
554
|
-
const contents = readFileSync(join(directory, "config.ini"), "utf8");
|
|
644
|
+
const contents = readFileSync$1(join(directory, "config.ini"), "utf8");
|
|
555
645
|
const expected = JSON.parse(configuration);
|
|
556
646
|
return Array.isArray(expected) && expected.length > 0 && expected.every((entry) => Array.isArray(entry) && entry.length === 2 && entry.every((value) => typeof value === "string") && contents.split(/\r?\n/).some((line) => line.trim() === `${entry[0]}=${entry[1]}`));
|
|
557
647
|
}
|
|
@@ -634,7 +724,7 @@ const CRASH_REPORT_MODE_EMULATOR_VERSION = 37;
|
|
|
634
724
|
function emulatorCrashDatabases(env = process.env) {
|
|
635
725
|
const root = join(env.TMP || env.TEMP || tmpdir(), "AndroidEmulator");
|
|
636
726
|
try {
|
|
637
|
-
return readdirSync(root).filter((name) => /^emu-crash-.*\.db$/.test(name)).map((name) => join(root, name));
|
|
727
|
+
return readdirSync$1(root).filter((name) => /^emu-crash-.*\.db$/.test(name)).map((name) => join(root, name));
|
|
638
728
|
} catch {
|
|
639
729
|
return [];
|
|
640
730
|
}
|
|
@@ -648,7 +738,7 @@ function emulatorCrashDatabases(env = process.env) {
|
|
|
648
738
|
* removed instead, which has the same effect unless a crash handler is still writing into it.
|
|
649
739
|
* https://github.com/appandflow/stim/issues/918
|
|
650
740
|
*/
|
|
651
|
-
function suppressEmulatorCrashConsent({ platform = process.platform, version = emulatorMajorVersion, databases = emulatorCrashDatabases, remove = (path) => rmSync(path, {
|
|
741
|
+
function suppressEmulatorCrashConsent({ platform = process.platform, version = emulatorMajorVersion, databases = emulatorCrashDatabases, remove = (path) => rmSync$1(path, {
|
|
652
742
|
recursive: true,
|
|
653
743
|
force: true
|
|
654
744
|
}) } = {}) {
|
|
@@ -682,8 +772,8 @@ function bootAndroidEmulator(avdName, consolePort, { logFile, platform = process
|
|
|
682
772
|
function emulatorStdio(logFile) {
|
|
683
773
|
if (!logFile) return "ignore";
|
|
684
774
|
try {
|
|
685
|
-
mkdirSync(dirname(logFile), { recursive: true });
|
|
686
|
-
const fd = openSync(logFile, "w");
|
|
775
|
+
mkdirSync$1(dirname(logFile), { recursive: true });
|
|
776
|
+
const fd = openSync$1(logFile, "w");
|
|
687
777
|
return [
|
|
688
778
|
"ignore",
|
|
689
779
|
fd,
|
|
@@ -788,7 +878,7 @@ function avdProcessLockPaths(avdDirectory, platform) {
|
|
|
788
878
|
}
|
|
789
879
|
function readAvdProcessId(path) {
|
|
790
880
|
try {
|
|
791
|
-
const pid = Number(readFileSync(path, "utf8").split("\0")[0]);
|
|
881
|
+
const pid = Number(readFileSync$1(path, "utf8").split("\0")[0]);
|
|
792
882
|
if (!Number.isSafeInteger(pid) || pid <= 0) throw new Error(`Could not read the emulator PID from process lock ${path}.`);
|
|
793
883
|
return pid;
|
|
794
884
|
} catch (error) {
|
|
@@ -831,7 +921,7 @@ function emulatorCrashHandlerPids(qemuPid) {
|
|
|
831
921
|
], { timeoutMs: 1e4 });
|
|
832
922
|
return String(out ?? "").split(/\r?\n/).map((line) => Number(line.trim())).filter((pid) => Number.isSafeInteger(pid) && pid > 0);
|
|
833
923
|
}
|
|
834
|
-
function waitForAndroidEmulatorShutdown(avdName, shutdown, { timeoutMs = ANDROID_EMULATOR_SHUTDOWN_TIMEOUT_MS, pollMs = ANDROID_EMULATOR_SHUTDOWN_POLL_MS, platform = process.platform, resolveDirectory = ownedAvdDirectory, readProcessId = readAvdProcessId, processAlive = pidExists, directoryExists = (path) => statSync(path).isDirectory(), crashHandlerPids = emulatorCrashHandlerPids, killCrashHandler = (pid) => signalProcessTree(pid, "SIGKILL", { platform }), now = Date.now, sleep = sleepSync } = {}) {
|
|
924
|
+
function waitForAndroidEmulatorShutdown(avdName, shutdown, { timeoutMs = ANDROID_EMULATOR_SHUTDOWN_TIMEOUT_MS, pollMs = ANDROID_EMULATOR_SHUTDOWN_POLL_MS, platform = process.platform, resolveDirectory = ownedAvdDirectory, readProcessId = readAvdProcessId, processAlive = pidExists, directoryExists = (path) => statSync$1(path).isDirectory(), crashHandlerPids = emulatorCrashHandlerPids, killCrashHandler = (pid) => signalProcessTree(pid, "SIGKILL", { platform }), now = Date.now, sleep = sleepSync } = {}) {
|
|
835
925
|
const { directory, processId } = resolveAvdProcess(avdName, {
|
|
836
926
|
platform,
|
|
837
927
|
resolveDirectory,
|
|
@@ -899,7 +989,7 @@ function ownedAvdSerialResolver({ timeoutMs } = {}) {
|
|
|
899
989
|
};
|
|
900
990
|
return (avdName) => {
|
|
901
991
|
if (!avds().includes(avdName)) return { missing: true };
|
|
902
|
-
if (!avdName
|
|
992
|
+
if (!isStimOwnedAvdName(avdName)) return { notOwned: true };
|
|
903
993
|
const devices = adb();
|
|
904
994
|
const match = [...devices.emulators, ...devices.unhealthy.filter((entry) => entry.kind === "emulator" && entry.consolePort !== void 0)].find((e) => avdNameOf(e.serial) === avdName);
|
|
905
995
|
if (match) return { serial: match.serial };
|
|
@@ -907,4 +997,4 @@ function ownedAvdSerialResolver({ timeoutMs } = {}) {
|
|
|
907
997
|
};
|
|
908
998
|
}
|
|
909
999
|
//#endregion
|
|
910
|
-
export {
|
|
1000
|
+
export { ownedAvdDirectory as A, resolvePhysicalDevice as B, isStimOwnedAvdName as C, listOrphanedAvdDirectories as D, listInstalledSystemImages as E, physicalDeviceModel as F, wipeAvdUserData as G, sleepSync as H, pickDefaultSystemImage as I, recordCreatedDevice as J, isStimOwnedSim as K, probeEmulatorSerial as L, ownedAvdName as M, ownedAvdSerialResolver as N, memoizeEmulatorProbe as O, ownedAvdSystemImage as P, resetAdoptedAvd as R, hostSystemImageArch as S, listAvds as T, waitForAndroidEmulatorShutdown as U, shutdownAndroidEmulator as V, waitForBoot as W, emulatorDiskSpaceRemedy as _, androidPoolNoCandidatesRefusal as a, findBuildTool as b, androidToolPath as c, avdPoolConfiguration as d, avdStorageRoots as f, deleteAvd as g, createOwnedAvd as h, androidPoolCandidates as i, ownedAvdMatchesConfiguration as j, nextConsolePort as k, assertOwnedAvdStopped as l, configureNewOwnedAvd as m, androidDeviceAbi as n, androidSystemImageAbi as o, bootAndroidEmulator as p, forgetCreatedDevice as q, androidHome as r, androidToolCwd as s, androidBuildToolName as t, avdPathExists as u, emulatorFailureRemedy as v, listAdbDevices as w, getAvdNameForSerial as x, extractEmulatorFailure as y, resolveOwnedAvdSerial as z };
|