@swmansion/argent 0.34.1-next.3 → 0.34.1-next.4
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/tool-server.cjs +148 -24
- package/package.json +1 -1
package/dist/tool-server.cjs
CHANGED
|
@@ -123338,6 +123338,9 @@ function registerCaptureOnDemandSender(deviceId, endpoint, send) {
|
|
|
123338
123338
|
if (entry.onDemand) entry.send(false);
|
|
123339
123339
|
};
|
|
123340
123340
|
}
|
|
123341
|
+
function simulatorServerDeviceIds() {
|
|
123342
|
+
return [...servers.keys()];
|
|
123343
|
+
}
|
|
123341
123344
|
function captureOnDemandDropped(deviceId, endpoint) {
|
|
123342
123345
|
const server = servers.get(deviceId);
|
|
123343
123346
|
if (server?.endpoint === endpoint) server.onDemand = false;
|
|
@@ -128553,8 +128556,8 @@ function parseVegaDeviceList(stdout) {
|
|
|
128553
128556
|
}
|
|
128554
128557
|
return devices;
|
|
128555
128558
|
}
|
|
128556
|
-
function filterVvdShadowsFromAndroid(
|
|
128557
|
-
return
|
|
128559
|
+
function filterVvdShadowsFromAndroid(androidDevices2, vvdAdbSerials) {
|
|
128560
|
+
return androidDevices2.filter((d) => !vvdAdbSerials.has(d.serial));
|
|
128558
128561
|
}
|
|
128559
128562
|
async function readVegaInfo() {
|
|
128560
128563
|
try {
|
|
@@ -128729,12 +128732,12 @@ function sortIosRemote(a, b) {
|
|
|
128729
128732
|
const bBooted = b.state === "Booted" ? 0 : 1;
|
|
128730
128733
|
return aBooted - bBooted;
|
|
128731
128734
|
}
|
|
128732
|
-
async function resolveVvdShadowAdbSerials(
|
|
128735
|
+
async function resolveVvdShadowAdbSerials(androidDevices2, vega) {
|
|
128733
128736
|
if (!vega.some((d) => d.kind === "vvd" && d.state === "running")) return /* @__PURE__ */ new Set();
|
|
128734
128737
|
const vvdPorts = await listRunningVvdConsolePorts();
|
|
128735
128738
|
if (vvdPorts.size === 0) return /* @__PURE__ */ new Set();
|
|
128736
128739
|
const shadows = /* @__PURE__ */ new Set();
|
|
128737
|
-
for (const d of
|
|
128740
|
+
for (const d of androidDevices2) {
|
|
128738
128741
|
const port = consolePortFromAdbSerial(d.serial);
|
|
128739
128742
|
if (port !== null && vvdPorts.has(port)) shadows.add(d.serial);
|
|
128740
128743
|
}
|
|
@@ -145614,8 +145617,14 @@ function findAndroidNativeRecord(id) {
|
|
|
145614
145617
|
function liveAndroidNetworkCaptures(deviceId) {
|
|
145615
145618
|
return [...liveInspectors.get(deviceKeyOf(deviceId)) ?? []].filter((handle) => handle.isLive()).map((handle) => handle.packageName).sort();
|
|
145616
145619
|
}
|
|
145620
|
+
function liveAndroidNetworkCaptureSerials() {
|
|
145621
|
+
return liveCaptureSerials(() => true);
|
|
145622
|
+
}
|
|
145617
145623
|
function liveAndroidNetworkCaptureDevices(packageName) {
|
|
145618
|
-
|
|
145624
|
+
return liveCaptureSerials((handle) => handle.packageName === packageName);
|
|
145625
|
+
}
|
|
145626
|
+
function liveCaptureSerials(matches2) {
|
|
145627
|
+
const serials = allHandles().filter((handle) => matches2(handle) && handle.isLive()).map((handle) => handle.serial);
|
|
145619
145628
|
return [...new Set(serials)].sort();
|
|
145620
145629
|
}
|
|
145621
145630
|
async function attachAndroidNetworkInspectorToLaunch(deviceId, packageName) {
|
|
@@ -162424,7 +162433,12 @@ init_adb();
|
|
|
162424
162433
|
var execFileAsync35 = (0, import_node_util35.promisify)(import_node_child_process46.execFile);
|
|
162425
162434
|
var LOG_READ_TIMEOUT_MS = 5e3;
|
|
162426
162435
|
var RETRY_DELAY_MS = 300;
|
|
162427
|
-
|
|
162436
|
+
var OTHER_TRANSPORTS_GRACE_MS = 500;
|
|
162437
|
+
var NOT_FOUND = { found: [], unresolved: [] };
|
|
162438
|
+
async function findRuntimeDevices(cdp, {
|
|
162439
|
+
awaitSerials = [],
|
|
162440
|
+
waitSerials = []
|
|
162441
|
+
} = {}) {
|
|
162428
162442
|
const marker = `argent-device-probe:${(0, import_node_crypto15.randomUUID)()}`;
|
|
162429
162443
|
const logged = await cdp.evaluate(
|
|
162430
162444
|
`(function () {
|
|
@@ -162433,30 +162447,88 @@ async function findRuntimeDevice(cdp) {
|
|
|
162433
162447
|
return true;
|
|
162434
162448
|
})()`
|
|
162435
162449
|
).catch(() => false);
|
|
162436
|
-
if (logged !== true) return
|
|
162450
|
+
if (logged !== true) return NOT_FOUND;
|
|
162437
162451
|
const checks = [
|
|
162438
|
-
async () =>
|
|
162439
|
-
async () =>
|
|
162452
|
+
async () => androidDevices(await androidSerials(), marker, awaitSerials, waitSerials),
|
|
162453
|
+
async () => {
|
|
162454
|
+
const udids = await bootedSimulators();
|
|
162455
|
+
const udid = await firstFound(udids.map((udid2) => () => simulatorLogHolds(udid2, marker)));
|
|
162456
|
+
return udid === void 0 ? void 0 : { found: [udid], unresolved: [] };
|
|
162457
|
+
}
|
|
162440
162458
|
];
|
|
162441
162459
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
162442
162460
|
if (attempt > 0) await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
|
|
162443
162461
|
const found = await firstFound(checks);
|
|
162444
162462
|
if (found !== void 0) return found;
|
|
162445
162463
|
}
|
|
162446
|
-
return
|
|
162464
|
+
return NOT_FOUND;
|
|
162447
162465
|
}
|
|
162448
162466
|
function firstFound(checks) {
|
|
162449
162467
|
return new Promise((resolve19) => {
|
|
162450
162468
|
let left = checks.length;
|
|
162451
162469
|
if (left === 0) resolve19(void 0);
|
|
162452
162470
|
for (const check3 of checks) {
|
|
162453
|
-
void check3().then((
|
|
162454
|
-
if (
|
|
162471
|
+
void check3().then((value) => {
|
|
162472
|
+
if (value !== void 0) resolve19(value);
|
|
162455
162473
|
else if (--left === 0) resolve19(void 0);
|
|
162456
162474
|
});
|
|
162457
162475
|
}
|
|
162458
162476
|
});
|
|
162459
162477
|
}
|
|
162478
|
+
async function androidDevices(serials, marker, awaitSerials, waitSerials) {
|
|
162479
|
+
const listed = [...new Set(serials)];
|
|
162480
|
+
const awaited = listed.filter(
|
|
162481
|
+
(serial) => awaitSerials.includes(serial) || waitSerials.includes(serial)
|
|
162482
|
+
);
|
|
162483
|
+
const answers = /* @__PURE__ */ new Map();
|
|
162484
|
+
await new Promise((resolve19) => {
|
|
162485
|
+
let graceOver = false;
|
|
162486
|
+
let grace;
|
|
162487
|
+
const settle3 = () => {
|
|
162488
|
+
const held = heldSerials(answers);
|
|
162489
|
+
const waitingOn = listed.filter(
|
|
162490
|
+
(serial) => !answers.has(serial) && (!graceOver || awaited.includes(serial)) && !held.some((found2) => anotherDevice(serial, found2))
|
|
162491
|
+
);
|
|
162492
|
+
if (waitingOn.length === 0) {
|
|
162493
|
+
clearTimeout(grace);
|
|
162494
|
+
resolve19();
|
|
162495
|
+
}
|
|
162496
|
+
};
|
|
162497
|
+
settle3();
|
|
162498
|
+
for (const serial of listed) {
|
|
162499
|
+
void logcatHolds(serial, marker).then((read) => {
|
|
162500
|
+
answers.set(serial, read);
|
|
162501
|
+
if (read === "held") {
|
|
162502
|
+
grace ??= setTimeout(() => {
|
|
162503
|
+
graceOver = true;
|
|
162504
|
+
settle3();
|
|
162505
|
+
}, OTHER_TRANSPORTS_GRACE_MS);
|
|
162506
|
+
}
|
|
162507
|
+
settle3();
|
|
162508
|
+
});
|
|
162509
|
+
}
|
|
162510
|
+
});
|
|
162511
|
+
const found = heldSerials(answers);
|
|
162512
|
+
if (found.length === 0) return void 0;
|
|
162513
|
+
const unresolved = [...new Set(awaitSerials)].filter(
|
|
162514
|
+
(serial) => (!listed.includes(serial) || answers.get(serial) === "failed") && !found.some((device) => anotherDevice(serial, device))
|
|
162515
|
+
);
|
|
162516
|
+
return { found, unresolved };
|
|
162517
|
+
}
|
|
162518
|
+
function heldSerials(answers) {
|
|
162519
|
+
return [...answers].filter(([, read]) => read === "held").map(([serial]) => serial);
|
|
162520
|
+
}
|
|
162521
|
+
function anotherDevice(a, b) {
|
|
162522
|
+
if (a === b) return false;
|
|
162523
|
+
const portA = consolePortFromAdbSerial(a);
|
|
162524
|
+
const portB = consolePortFromAdbSerial(b);
|
|
162525
|
+
if (portA !== null && portB !== null) return portA !== portB;
|
|
162526
|
+
if (isUsbSerial(a) && isUsbSerial(b)) return true;
|
|
162527
|
+
return portA !== null && isUsbSerial(b) || portB !== null && isUsbSerial(a);
|
|
162528
|
+
}
|
|
162529
|
+
function isUsbSerial(serial) {
|
|
162530
|
+
return !serial.startsWith("emulator-") && !serial.includes(":") && !serial.includes("._");
|
|
162531
|
+
}
|
|
162460
162532
|
async function androidSerials() {
|
|
162461
162533
|
try {
|
|
162462
162534
|
const { stdout } = await runAdb(["devices"], { timeoutMs: ADB_DEVICES_TIMEOUT_MS });
|
|
@@ -162475,9 +162547,9 @@ async function logcatHolds(serial, marker) {
|
|
|
162475
162547
|
["-s", serial, "logcat", "-d", "-s", "ReactNativeJS", "-e", marker],
|
|
162476
162548
|
{ timeoutMs: LOG_READ_TIMEOUT_MS }
|
|
162477
162549
|
);
|
|
162478
|
-
return stdout.includes(marker) ?
|
|
162550
|
+
return stdout.includes(marker) ? "held" : "absent";
|
|
162479
162551
|
} catch {
|
|
162480
|
-
return
|
|
162552
|
+
return "failed";
|
|
162481
162553
|
}
|
|
162482
162554
|
}
|
|
162483
162555
|
async function simulatorLogHolds(udid, marker) {
|
|
@@ -162506,6 +162578,9 @@ async function simulatorLogHolds(udid, marker) {
|
|
|
162506
162578
|
}
|
|
162507
162579
|
}
|
|
162508
162580
|
|
|
162581
|
+
// ../tool-server/src/tools/profiler/react/react-profiler-start.ts
|
|
162582
|
+
init_external_devices();
|
|
162583
|
+
|
|
162509
162584
|
// ../tool-server/src/utils/react-profiler/devtools-bootstrap.ts
|
|
162510
162585
|
function bootstrapFailureMessage(bootstrap) {
|
|
162511
162586
|
switch (bootstrap.reason) {
|
|
@@ -162527,17 +162602,47 @@ function bootstrapFailureMessage(bootstrap) {
|
|
|
162527
162602
|
|
|
162528
162603
|
// ../tool-server/src/utils/profiler-shared/network-capture-warning.ts
|
|
162529
162604
|
var CAPTURE_COST = "It can slow the app, so the timings in this profile can differ from a run without it.";
|
|
162530
|
-
function nativeNetworkCaptureWarning(deviceId, runtimeApp) {
|
|
162531
|
-
let packages;
|
|
162605
|
+
function nativeNetworkCaptureWarning(deviceId, runtimeApp, runtimeDevices = { found: [], unresolved: [] }) {
|
|
162532
162606
|
try {
|
|
162533
|
-
|
|
162607
|
+
if (runtimeDevices.found.length > 0) {
|
|
162608
|
+
return foundDeviceWarning(runtimeDevices, runtimeApp);
|
|
162609
|
+
}
|
|
162610
|
+
const packages = liveAndroidNetworkCaptures(deviceId);
|
|
162534
162611
|
if (packages.length === 0) return logicalDeviceWarning(deviceId, runtimeApp);
|
|
162612
|
+
const apps = packages.join(", ");
|
|
162613
|
+
const one = packages.length === 1;
|
|
162614
|
+
return `Native network capture is on for ${apps} on this device: Argent attaches its in-app agent to the processes of ${one ? "that app" : "these apps"}. ${CAPTURE_COST} To profile without it, stop this profile, call native-network-logs with stop: true for ${one ? "that app" : "each of these apps"}, then restart-app and profile again.`;
|
|
162535
162615
|
} catch {
|
|
162536
162616
|
return void 0;
|
|
162537
162617
|
}
|
|
162538
|
-
|
|
162539
|
-
|
|
162540
|
-
|
|
162618
|
+
}
|
|
162619
|
+
function foundDeviceWarning({ found, unresolved }, runtimeApp) {
|
|
162620
|
+
const captures = found.map((device) => ({ device, packages: liveAndroidNetworkCaptures(device) })).filter(({ packages }) => packages.length > 0);
|
|
162621
|
+
const appId = runtimeApp?.platform === "android" ? runtimeApp.appId : void 0;
|
|
162622
|
+
const maybe = appId ? unresolved.filter((serial) => liveAndroidNetworkCaptures(serial).includes(appId)) : [];
|
|
162623
|
+
const first = captures[0];
|
|
162624
|
+
if (!first && (!appId || maybe.length === 0)) return void 0;
|
|
162625
|
+
const sentences = [];
|
|
162626
|
+
if (first) {
|
|
162627
|
+
const apps = [...new Set(captures.flatMap(({ packages }) => packages))].sort();
|
|
162628
|
+
const where = captures.length === 1 ? `${first.device}, the device this profile runs on` : `${captures.map(({ device }) => device).join(" and ")}, adb serials of the device this profile runs on`;
|
|
162629
|
+
sentences.push(
|
|
162630
|
+
`Native network capture is on for ${apps.join(", ")} on ${where}: Argent attaches its in-app agent to the processes of ${apps.length === 1 ? "that app" : "these apps"}.`
|
|
162631
|
+
);
|
|
162632
|
+
}
|
|
162633
|
+
if (appId && maybe.length > 0) {
|
|
162634
|
+
const one = maybe.length === 1;
|
|
162635
|
+
sentences.push(
|
|
162636
|
+
`Native network capture is ${first ? "also " : ""}on for ${appId} on ${maybe.join(", ")}, ${one ? "which" : "each of which"} may also be the device this profile runs on: ${one ? "its logcat" : "their logcats"} could not be read to tell. Argent attaches its in-app agent to the processes of that app there.`
|
|
162637
|
+
);
|
|
162638
|
+
}
|
|
162639
|
+
const stops = [
|
|
162640
|
+
...captures.flatMap(({ device, packages }) => packages.map((app) => ({ app, device }))),
|
|
162641
|
+
...appId ? maybe.map((device) => ({ app: appId, device })) : []
|
|
162642
|
+
];
|
|
162643
|
+
const stop = first && captures.length === 1 && maybe.length === 0 ? `with udid ${first.device} and stop: true for ${first.packages.length === 1 ? "that app" : "each of these apps"}` : `with stop: true for ${stops.map(({ app, device }) => `${app} with udid ${device}`).join(", ")}`;
|
|
162644
|
+
const restart = first?.device ?? found[0];
|
|
162645
|
+
return `${sentences.join(" ")} ${CAPTURE_COST} To profile without it, stop this profile, call native-network-logs ${stop}, then restart-app on ${restart} and profile again.`;
|
|
162541
162646
|
}
|
|
162542
162647
|
function logicalDeviceWarning(deviceId, runtimeApp) {
|
|
162543
162648
|
const appId = runtimeApp?.appId;
|
|
@@ -162594,6 +162699,25 @@ function failedTakeoverText({ session_id, reason: reason2 }) {
|
|
|
162594
162699
|
const run2 = session_id ? `session ${session_id}` : "a recording with no owner record";
|
|
162595
162700
|
return `Before it failed, this start stopped ${run2} (reason: ${reason2}), and nothing is recording now.`;
|
|
162596
162701
|
}
|
|
162702
|
+
function findProfiledDevices(cdp) {
|
|
162703
|
+
return findRuntimeDevices(cdp, {
|
|
162704
|
+
awaitSerials: idsOf(liveAndroidNetworkCaptureSerials),
|
|
162705
|
+
waitSerials: idsOf(simulatorServerDeviceIds).map(externalNativeId)
|
|
162706
|
+
});
|
|
162707
|
+
}
|
|
162708
|
+
function trackedIds(found) {
|
|
162709
|
+
const driven = idsOf(simulatorServerDeviceIds).filter(
|
|
162710
|
+
(id) => found.includes(externalNativeId(id))
|
|
162711
|
+
);
|
|
162712
|
+
return [.../* @__PURE__ */ new Set([...found, ...driven])];
|
|
162713
|
+
}
|
|
162714
|
+
function idsOf(lookup) {
|
|
162715
|
+
try {
|
|
162716
|
+
return lookup();
|
|
162717
|
+
} catch {
|
|
162718
|
+
return [];
|
|
162719
|
+
}
|
|
162720
|
+
}
|
|
162597
162721
|
function safeGetState(registry2, urn) {
|
|
162598
162722
|
try {
|
|
162599
162723
|
return registry2.getServiceState(urn);
|
|
@@ -162794,7 +162918,7 @@ Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot
|
|
|
162794
162918
|
}
|
|
162795
162919
|
await cdp.send("Profiler.stop").catch(ignore);
|
|
162796
162920
|
api.profilingActive = false;
|
|
162797
|
-
const
|
|
162921
|
+
const runtimeDevices = isLogicalKeyedDevice(api.deviceId) ? await findProfiledDevices(cdp) : { found: [], unresolved: [] };
|
|
162798
162922
|
const sessionId = crypto6.randomUUID();
|
|
162799
162923
|
const ownerPayload = {
|
|
162800
162924
|
sessionId,
|
|
@@ -162877,8 +163001,8 @@ Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot
|
|
|
162877
163001
|
api.sessionId = sessionId;
|
|
162878
163002
|
api.ownerToolServerPid = process.pid;
|
|
162879
163003
|
trackProfilingRun(api.deviceId, api);
|
|
162880
|
-
|
|
162881
|
-
const warning = nativeNetworkCaptureWarning(deviceId
|
|
163004
|
+
for (const device of trackedIds(runtimeDevices.found)) trackProfilingRun(device, api);
|
|
163005
|
+
const warning = nativeNetworkCaptureWarning(api.deviceId, api.runtimeApp, runtimeDevices);
|
|
162882
163006
|
return {
|
|
162883
163007
|
started_at: new Date(startedAtEpochMs).toISOString(),
|
|
162884
163008
|
startedAtEpochMs,
|
|
@@ -162886,7 +163010,7 @@ Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot
|
|
|
162886
163010
|
detected_architecture: api.detectedArchitecture,
|
|
162887
163011
|
...tookOver ? { took_over: tookOver } : {},
|
|
162888
163012
|
...warning ? { warning } : {},
|
|
162889
|
-
...isLogicalKeyedDevice(api.deviceId) &&
|
|
163013
|
+
...isLogicalKeyedDevice(api.deviceId) && runtimeDevices.found.length === 0 ? { [RESULT_NOTE_KEY]: UNKNOWN_DEVICE_NOTE } : {}
|
|
162890
163014
|
};
|
|
162891
163015
|
}
|
|
162892
163016
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.34.1-next.
|
|
3
|
+
"version": "0.34.1-next.4",
|
|
4
4
|
"mcpName": "io.github.software-mansion/argent",
|
|
5
5
|
"description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
|
|
6
6
|
"license": "Apache-2.0",
|