@swmansion/argent 0.34.1-next.40 → 0.34.1-next.42
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/bin/argent-android-devtools-0.4.0.apk +0 -0
- package/bin/darwin/argent-macos-helper +0 -0
- package/bin/darwin/ax-service +0 -0
- package/bin/darwin/tvos-ax-service +0 -0
- package/bin/darwin/tvos-hid-daemon +0 -0
- package/bin/network-inspector/network-inspector.jar +0 -0
- package/bin/tcp/ax-service +0 -0
- package/dist/cli-cmds.mjs +3 -2
- package/dist/installer.mjs +1 -1
- package/dist/tool-args.generated.d.ts +2 -2
- package/dist/tool-server.cjs +725 -275
- package/dylibs/libArgentAudio.dylib +0 -0
- package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/libKeyboardPatch.dylib +0 -0
- package/dylibs/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
- package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
- package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
- package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
- package/package.json +1 -1
package/dist/tool-server.cjs
CHANGED
|
@@ -82375,7 +82375,7 @@ var require_websocket = __commonJS({
|
|
|
82375
82375
|
var http6 = require("http");
|
|
82376
82376
|
var net10 = require("net");
|
|
82377
82377
|
var tls = require("tls");
|
|
82378
|
-
var { randomBytes:
|
|
82378
|
+
var { randomBytes: randomBytes3, createHash: createHash9 } = require("crypto");
|
|
82379
82379
|
var { Duplex, Readable: Readable2 } = require("stream");
|
|
82380
82380
|
var { URL: URL2 } = require("url");
|
|
82381
82381
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -82926,7 +82926,7 @@ var require_websocket = __commonJS({
|
|
|
82926
82926
|
}
|
|
82927
82927
|
}
|
|
82928
82928
|
const defaultPort = isSecure2 ? 443 : 80;
|
|
82929
|
-
const key2 =
|
|
82929
|
+
const key2 = randomBytes3(16).toString("base64");
|
|
82930
82930
|
const request3 = isSecure2 ? https.request : http6.request;
|
|
82931
82931
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
82932
82932
|
let perMessageDeflate;
|
|
@@ -101443,7 +101443,7 @@ function isCi(env = process.env) {
|
|
|
101443
101443
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
101444
101444
|
function readCliVersion() {
|
|
101445
101445
|
if (true) {
|
|
101446
|
-
return "0.34.1-next.
|
|
101446
|
+
return "0.34.1-next.42";
|
|
101447
101447
|
}
|
|
101448
101448
|
return "0.0.0";
|
|
101449
101449
|
}
|
|
@@ -102289,7 +102289,7 @@ var import_promises13 = require("node:fs/promises");
|
|
|
102289
102289
|
var import_node_os11 = require("node:os");
|
|
102290
102290
|
var import_node_path15 = require("node:path");
|
|
102291
102291
|
init_src();
|
|
102292
|
-
var
|
|
102292
|
+
var import_node_crypto12 = require("node:crypto");
|
|
102293
102293
|
|
|
102294
102294
|
// ../archive/src/index.ts
|
|
102295
102295
|
var import_node_child_process2 = require("node:child_process");
|
|
@@ -124518,6 +124518,275 @@ function pickIosHost(device) {
|
|
|
124518
124518
|
return device.platform === "ios-remote" ? remoteIosHost : localIosHost;
|
|
124519
124519
|
}
|
|
124520
124520
|
|
|
124521
|
+
// ../tool-server/src/blueprints/ios-network-records.ts
|
|
124522
|
+
var import_node_crypto7 = require("node:crypto");
|
|
124523
|
+
var import_node_http2 = require("node:http");
|
|
124524
|
+
|
|
124525
|
+
// ../tool-server/src/utils/debugger/device-alias.ts
|
|
124526
|
+
var logicalIdToConnectId = /* @__PURE__ */ new Map();
|
|
124527
|
+
function rememberDeviceAlias(logicalDeviceId, connectDeviceId) {
|
|
124528
|
+
if (!logicalDeviceId || logicalDeviceId === connectDeviceId) return;
|
|
124529
|
+
logicalIdToConnectId.set(logicalDeviceId, connectDeviceId);
|
|
124530
|
+
}
|
|
124531
|
+
function canonicalDeviceId(deviceId) {
|
|
124532
|
+
if (!deviceId) return deviceId;
|
|
124533
|
+
return logicalIdToConnectId.get(deviceId) ?? deviceId;
|
|
124534
|
+
}
|
|
124535
|
+
function deviceIdsOf(deviceId) {
|
|
124536
|
+
const connectId = canonicalDeviceId(deviceId) ?? deviceId;
|
|
124537
|
+
const logicalIds = [...logicalIdToConnectId].filter(([, aliased]) => aliased === connectId).map(([logicalId]) => logicalId);
|
|
124538
|
+
return [.../* @__PURE__ */ new Set([deviceId, connectId, ...logicalIds])];
|
|
124539
|
+
}
|
|
124540
|
+
function forgetDeviceAlias(logicalDeviceId) {
|
|
124541
|
+
if (logicalDeviceId) logicalIdToConnectId.delete(logicalDeviceId);
|
|
124542
|
+
}
|
|
124543
|
+
var logicalKeyedConnectIds = /* @__PURE__ */ new Set();
|
|
124544
|
+
function rememberLogicalKeyedDevice(logicalDeviceId, connectDeviceId) {
|
|
124545
|
+
if (logicalDeviceId && logicalDeviceId === connectDeviceId) {
|
|
124546
|
+
logicalKeyedConnectIds.add(connectDeviceId.toLowerCase());
|
|
124547
|
+
}
|
|
124548
|
+
}
|
|
124549
|
+
function isLogicalKeyedDevice(deviceId) {
|
|
124550
|
+
return deviceId !== void 0 && logicalKeyedConnectIds.has(deviceId.toLowerCase());
|
|
124551
|
+
}
|
|
124552
|
+
function forgetLogicalKeyedDevice(connectDeviceId) {
|
|
124553
|
+
logicalKeyedConnectIds.delete(connectDeviceId.toLowerCase());
|
|
124554
|
+
}
|
|
124555
|
+
|
|
124556
|
+
// ../tool-server/src/utils/native-network-record.ts
|
|
124557
|
+
init_external_devices();
|
|
124558
|
+
function deviceKeyOf(deviceId) {
|
|
124559
|
+
return externalNativeId(canonicalDeviceId(deviceId) ?? deviceId);
|
|
124560
|
+
}
|
|
124561
|
+
var MAX_RECORDS = 2e3;
|
|
124562
|
+
var RECORD_CHARS_BUDGET = 32 * 1024 * 1024;
|
|
124563
|
+
var MAX_VALUE_CHARS = 64 * 1024;
|
|
124564
|
+
var MAX_HEADERS = 256;
|
|
124565
|
+
var MAX_HEADER_MAP_CHARS = 256 * 1024;
|
|
124566
|
+
var MAX_LAYER_ID_CHARS = 200;
|
|
124567
|
+
var NOT_RECONNECTED = "the agent did not reconnect after its connection dropped, so this request's final events never arrived";
|
|
124568
|
+
var PROCESS_ENDED = "the app process ended before the request finished";
|
|
124569
|
+
function isOpen(record2) {
|
|
124570
|
+
return record2.state === "pending" || record2.state === "headers";
|
|
124571
|
+
}
|
|
124572
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
124573
|
+
var ANDROID_EMULATOR_HOST = "10.0.2.2";
|
|
124574
|
+
var DEFAULT_PORTS = {
|
|
124575
|
+
"http:": 80,
|
|
124576
|
+
"ws:": 80,
|
|
124577
|
+
"https:": 443,
|
|
124578
|
+
"wss:": 443
|
|
124579
|
+
};
|
|
124580
|
+
function isMetroTraffic(url2, metroPort2, { androidEmulatorHost = false } = {}) {
|
|
124581
|
+
let parsed2;
|
|
124582
|
+
try {
|
|
124583
|
+
parsed2 = new URL(url2);
|
|
124584
|
+
} catch {
|
|
124585
|
+
return false;
|
|
124586
|
+
}
|
|
124587
|
+
const port = parsed2.port === "" ? DEFAULT_PORTS[parsed2.protocol] : Number(parsed2.port);
|
|
124588
|
+
const host = parsed2.hostname;
|
|
124589
|
+
const isHost = LOOPBACK_HOSTS.has(host) || androidEmulatorHost && host === ANDROID_EMULATOR_HOST;
|
|
124590
|
+
return isHost && port === metroPort2;
|
|
124591
|
+
}
|
|
124592
|
+
function capString(value, max = MAX_VALUE_CHARS) {
|
|
124593
|
+
return value.length > max ? `${value.slice(0, max)}\u2026[${value.length - max} more chars]` : value;
|
|
124594
|
+
}
|
|
124595
|
+
function headerMap(value) {
|
|
124596
|
+
const headers = {};
|
|
124597
|
+
let kept = 0;
|
|
124598
|
+
let chars = 0;
|
|
124599
|
+
let left = 0;
|
|
124600
|
+
for (const [name, v] of Object.entries(asObject(value))) {
|
|
124601
|
+
if (typeof v !== "string" && typeof v !== "number" && typeof v !== "boolean") continue;
|
|
124602
|
+
const key2 = capString(name, 1024);
|
|
124603
|
+
const text = capString(String(v));
|
|
124604
|
+
if (kept >= MAX_HEADERS || chars + key2.length + text.length > MAX_HEADER_MAP_CHARS) {
|
|
124605
|
+
left++;
|
|
124606
|
+
continue;
|
|
124607
|
+
}
|
|
124608
|
+
headers[key2] = text;
|
|
124609
|
+
kept++;
|
|
124610
|
+
chars += key2.length + text.length;
|
|
124611
|
+
}
|
|
124612
|
+
if (left > 0) headers["(not kept)"] = `${left} more headers`;
|
|
124613
|
+
return headers;
|
|
124614
|
+
}
|
|
124615
|
+
function mapChars(map2) {
|
|
124616
|
+
let chars = 0;
|
|
124617
|
+
for (const [name, value] of Object.entries(map2 ?? {})) chars += name.length + value.length;
|
|
124618
|
+
return chars;
|
|
124619
|
+
}
|
|
124620
|
+
function recordSize(record2) {
|
|
124621
|
+
let chars = record2.request.url.length + record2.request.method.length + mapChars(record2.request.headers) + mapChars(record2.request.wireHeaders) + (record2.errorText?.length ?? 0) + 256;
|
|
124622
|
+
if (record2.response) {
|
|
124623
|
+
chars += record2.response.url.length + record2.response.statusText.length + record2.response.mimeType.length + mapChars(record2.response.headers);
|
|
124624
|
+
}
|
|
124625
|
+
for (const hop of record2.redirects ?? []) {
|
|
124626
|
+
chars += hop.url.length + hop.statusText.length + mapChars(hop.headers) + mapChars(hop.requestHeaders);
|
|
124627
|
+
}
|
|
124628
|
+
return chars;
|
|
124629
|
+
}
|
|
124630
|
+
function asObject(value) {
|
|
124631
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
124632
|
+
}
|
|
124633
|
+
function asString2(value) {
|
|
124634
|
+
return typeof value === "string" ? value : "";
|
|
124635
|
+
}
|
|
124636
|
+
|
|
124637
|
+
// ../tool-server/src/blueprints/ios-network-records.ts
|
|
124638
|
+
var RUN_TAG = (0, import_node_crypto7.randomBytes)(2).toString("hex");
|
|
124639
|
+
var nextRecordNumber = 1;
|
|
124640
|
+
function createIosNetworkRecords(state3) {
|
|
124641
|
+
const records = [];
|
|
124642
|
+
let recordChars = 0;
|
|
124643
|
+
const recordSizes = /* @__PURE__ */ new WeakMap();
|
|
124644
|
+
const byId = /* @__PURE__ */ new Map();
|
|
124645
|
+
const byLayerId = /* @__PURE__ */ new Map();
|
|
124646
|
+
const cleared = /* @__PURE__ */ new WeakSet();
|
|
124647
|
+
const startArrivals = /* @__PURE__ */ new WeakMap();
|
|
124648
|
+
const keyOf = (connection, layerId) => `${connection}:${layerId}`;
|
|
124649
|
+
function startRecord(connection, layerId, p) {
|
|
124650
|
+
const req = asObject(p.request);
|
|
124651
|
+
const startedAt = typeof p.wallTime === "number" ? p.wallTime * 1e3 : typeof p.timestamp === "number" ? p.timestamp * 1e3 : Date.now();
|
|
124652
|
+
const postData = req.postData;
|
|
124653
|
+
const record2 = {
|
|
124654
|
+
id: `ios-${RUN_TAG}-${nextRecordNumber++}`,
|
|
124655
|
+
layer: "ios-native",
|
|
124656
|
+
layerId,
|
|
124657
|
+
connection,
|
|
124658
|
+
state: "pending",
|
|
124659
|
+
request: {
|
|
124660
|
+
url: capString(asString2(req.url)),
|
|
124661
|
+
method: capString(asString2(req.method), 100) || "GET",
|
|
124662
|
+
headers: headerMap(req.headers),
|
|
124663
|
+
...req.hasPostData === true || typeof postData === "string" && postData.length > 0 ? { hasPostData: true } : {}
|
|
124664
|
+
},
|
|
124665
|
+
timing: { startedAt: Math.round(startedAt) }
|
|
124666
|
+
};
|
|
124667
|
+
byLayerId.set(keyOf(connection, layerId), record2);
|
|
124668
|
+
startArrivals.set(record2, performance.now());
|
|
124669
|
+
records.push(record2);
|
|
124670
|
+
byId.set(record2.id, record2);
|
|
124671
|
+
resize(record2);
|
|
124672
|
+
}
|
|
124673
|
+
function setDuration(record2, p) {
|
|
124674
|
+
const measured = p.nativeDevtoolsDurationMs;
|
|
124675
|
+
if (typeof measured === "number" && Number.isFinite(measured) && measured >= 0) {
|
|
124676
|
+
record2.timing.durationMs = Math.round(measured);
|
|
124677
|
+
return;
|
|
124678
|
+
}
|
|
124679
|
+
const arrived = startArrivals.get(record2);
|
|
124680
|
+
if (arrived !== void 0) record2.timing.durationMs = Math.round(performance.now() - arrived);
|
|
124681
|
+
}
|
|
124682
|
+
function resize(record2) {
|
|
124683
|
+
if (!byId.has(record2.id)) return;
|
|
124684
|
+
const size = recordSize(record2);
|
|
124685
|
+
recordChars += size - (recordSizes.get(record2) ?? 0);
|
|
124686
|
+
recordSizes.set(record2, size);
|
|
124687
|
+
while (records.length > MAX_RECORDS || records.length > 1 && recordChars > RECORD_CHARS_BUDGET) {
|
|
124688
|
+
evict(records.shift());
|
|
124689
|
+
}
|
|
124690
|
+
}
|
|
124691
|
+
function evict(record2) {
|
|
124692
|
+
const key2 = keyOf(record2.connection, record2.layerId);
|
|
124693
|
+
if (byLayerId.get(key2) === record2) byLayerId.delete(key2);
|
|
124694
|
+
byId.delete(record2.id);
|
|
124695
|
+
recordChars -= recordSizes.get(record2) ?? 0;
|
|
124696
|
+
recordSizes.delete(record2);
|
|
124697
|
+
}
|
|
124698
|
+
return {
|
|
124699
|
+
state: state3,
|
|
124700
|
+
fold(connection, method, params) {
|
|
124701
|
+
if (typeof params !== "object" || params === null) return;
|
|
124702
|
+
const p = params;
|
|
124703
|
+
const layerId = typeof p.requestId === "string" ? p.requestId : null;
|
|
124704
|
+
if (!layerId || layerId.length > MAX_LAYER_ID_CHARS) return;
|
|
124705
|
+
if (method === "Network.requestWillBeSent") {
|
|
124706
|
+
if (p.redirectResponse !== void 0 && p.redirectResponse !== null) return;
|
|
124707
|
+
startRecord(connection, layerId, p);
|
|
124708
|
+
return;
|
|
124709
|
+
}
|
|
124710
|
+
const record2 = byLayerId.get(keyOf(connection, layerId));
|
|
124711
|
+
if (!record2) return;
|
|
124712
|
+
switch (method) {
|
|
124713
|
+
case "Network.responseReceived": {
|
|
124714
|
+
const r = asObject(p.response);
|
|
124715
|
+
const status = typeof r.status === "number" ? r.status : 0;
|
|
124716
|
+
record2.state = "headers";
|
|
124717
|
+
record2.response = {
|
|
124718
|
+
// The URL of the final response, after any redirects.
|
|
124719
|
+
url: capString(asString2(r.url)) || record2.request.url,
|
|
124720
|
+
status,
|
|
124721
|
+
statusText: import_node_http2.STATUS_CODES[status] ?? "",
|
|
124722
|
+
headers: headerMap(r.headers),
|
|
124723
|
+
mimeType: capString(asString2(r.mimeType))
|
|
124724
|
+
};
|
|
124725
|
+
if (typeof p.type === "string") record2.resourceType = capString(p.type, 100);
|
|
124726
|
+
break;
|
|
124727
|
+
}
|
|
124728
|
+
case "Network.loadingFinished":
|
|
124729
|
+
cleared.delete(record2);
|
|
124730
|
+
record2.state = "complete";
|
|
124731
|
+
if (typeof p.encodedDataLength === "number")
|
|
124732
|
+
record2.encodedDataLength = p.encodedDataLength;
|
|
124733
|
+
setDuration(record2, p);
|
|
124734
|
+
break;
|
|
124735
|
+
case "Network.loadingFailed":
|
|
124736
|
+
cleared.delete(record2);
|
|
124737
|
+
record2.state = "failed";
|
|
124738
|
+
record2.errorText = capString(asString2(p.errorText)) || "Unknown error";
|
|
124739
|
+
setDuration(record2, p);
|
|
124740
|
+
break;
|
|
124741
|
+
default:
|
|
124742
|
+
return;
|
|
124743
|
+
}
|
|
124744
|
+
resize(record2);
|
|
124745
|
+
},
|
|
124746
|
+
hasOpenRecords: (connection) => records.some((record2) => record2.connection === connection && isOpen(record2)),
|
|
124747
|
+
connectionClosed(connection, check3) {
|
|
124748
|
+
const ended = check3.superseded || check3.running === false || check3.runningPid !== void 0 && check3.connectionPid !== void 0 && check3.runningPid !== check3.connectionPid;
|
|
124749
|
+
const open5 = records.filter((r) => r.connection === connection && isOpen(r));
|
|
124750
|
+
for (const record2 of open5) {
|
|
124751
|
+
record2.state = "failed";
|
|
124752
|
+
record2.errorText = ended ? PROCESS_ENDED : NOT_RECONNECTED;
|
|
124753
|
+
cleared.delete(record2);
|
|
124754
|
+
}
|
|
124755
|
+
for (const record2 of open5) resize(record2);
|
|
124756
|
+
},
|
|
124757
|
+
records: (port) => records.filter((r) => !cleared.has(r) && !isMetroTraffic(r.request.url, port)),
|
|
124758
|
+
record: (id) => byId.get(id),
|
|
124759
|
+
clear() {
|
|
124760
|
+
for (const record2 of records) cleared.add(record2);
|
|
124761
|
+
}
|
|
124762
|
+
};
|
|
124763
|
+
}
|
|
124764
|
+
var liveCaptures = /* @__PURE__ */ new Set();
|
|
124765
|
+
function registerIosNetworkCaptures(captures) {
|
|
124766
|
+
liveCaptures.add(captures);
|
|
124767
|
+
return () => {
|
|
124768
|
+
liveCaptures.delete(captures);
|
|
124769
|
+
};
|
|
124770
|
+
}
|
|
124771
|
+
function capturing(captures, bundleId) {
|
|
124772
|
+
return captures.bundleIds.has(bundleId) && captures.stores.has(bundleId);
|
|
124773
|
+
}
|
|
124774
|
+
function liveIosNetworkCaptures(deviceId) {
|
|
124775
|
+
const key2 = deviceKeyOf(deviceId);
|
|
124776
|
+
const bundleIds = /* @__PURE__ */ new Set();
|
|
124777
|
+
for (const captures of liveCaptures) {
|
|
124778
|
+
if (deviceKeyOf(captures.udid) !== key2) continue;
|
|
124779
|
+
for (const bundleId of captures.bundleIds) {
|
|
124780
|
+
if (capturing(captures, bundleId)) bundleIds.add(bundleId);
|
|
124781
|
+
}
|
|
124782
|
+
}
|
|
124783
|
+
return [...bundleIds].sort();
|
|
124784
|
+
}
|
|
124785
|
+
function liveIosNetworkCaptureDevices(bundleId) {
|
|
124786
|
+
const udids = [...liveCaptures].filter((captures) => capturing(captures, bundleId)).map((captures) => captures.udid);
|
|
124787
|
+
return [...new Set(udids)].sort();
|
|
124788
|
+
}
|
|
124789
|
+
|
|
124521
124790
|
// ../tool-server/src/blueprints/native-devtools.ts
|
|
124522
124791
|
var NATIVE_DEVTOOLS_NAMESPACE = "NativeDevtools";
|
|
124523
124792
|
function isInjectableBundleId(bundleId) {
|
|
@@ -124630,7 +124899,12 @@ function nativeDevtoolsRef(device, { transport = "unix" } = {}) {
|
|
|
124630
124899
|
options: { device, transport }
|
|
124631
124900
|
};
|
|
124632
124901
|
}
|
|
124633
|
-
var
|
|
124902
|
+
var NETWORK_ENABLE_TIMEOUT_MS = 5e3;
|
|
124903
|
+
var LAUNCH_ARM_WAIT_MS = 5e3;
|
|
124904
|
+
var LENT_HANDSHAKE_PROMPT_MS = 1e3;
|
|
124905
|
+
var WAITING_FOR_ENABLE = "waiting for the agent to acknowledge Network.enable";
|
|
124906
|
+
var WAITING_FOR_CAPTURE_STATE = "waiting for the agent to say whether capture is on";
|
|
124907
|
+
var PROVIDER_CAPTURE_OFF = "the device provider has capture off for the app; argent does not turn it on, because that resets the provider's network settings: turn capture on in the provider";
|
|
124634
124908
|
function getNativeDevtoolsSocketPath(udid) {
|
|
124635
124909
|
return `/tmp/argent-nd-${udid.slice(0, 8)}.sock`;
|
|
124636
124910
|
}
|
|
@@ -124721,6 +124995,8 @@ var nativeDevtoolsBlueprint = {
|
|
|
124721
124995
|
const socketPath = getNativeDevtoolsSocketPath(udid);
|
|
124722
124996
|
const endpoint = transport === "tcp" ? { transport: "tcp" } : { transport: "unix", socketPath };
|
|
124723
124997
|
const connections2 = /* @__PURE__ */ new Map();
|
|
124998
|
+
let nextConnectionIndex = 1;
|
|
124999
|
+
const networkStores = /* @__PURE__ */ new Map();
|
|
124724
125000
|
const pendingRpc = /* @__PURE__ */ new Map();
|
|
124725
125001
|
let nextRpcId = 1;
|
|
124726
125002
|
let envSetup = false;
|
|
@@ -124728,10 +125004,16 @@ var nativeDevtoolsBlueprint = {
|
|
|
124728
125004
|
let inFlight4 = null;
|
|
124729
125005
|
let envRetired = false;
|
|
124730
125006
|
const activatedBundleIds = /* @__PURE__ */ new Set();
|
|
125007
|
+
const captureGaps = /* @__PURE__ */ new Set();
|
|
124731
125008
|
const networkConditions = /* @__PURE__ */ new Map();
|
|
124732
125009
|
const providerCapture = /* @__PURE__ */ new Map();
|
|
124733
125010
|
const unconfirmedThrottles = /* @__PURE__ */ new Set();
|
|
124734
125011
|
const events = new TypedEventEmitter();
|
|
125012
|
+
const connectionWaiters = /* @__PURE__ */ new Set();
|
|
125013
|
+
let connectionCloses = 0;
|
|
125014
|
+
const wakeConnectionWaiters = () => {
|
|
125015
|
+
for (const wake of [...connectionWaiters]) wake();
|
|
125016
|
+
};
|
|
124735
125017
|
const noteInitFailure = (err) => {
|
|
124736
125018
|
if (err instanceof XcodeFirstLaunchPendingError) return;
|
|
124737
125019
|
const lastError = err instanceof Error ? err.message : String(err);
|
|
@@ -124768,9 +125050,6 @@ var nativeDevtoolsBlueprint = {
|
|
|
124768
125050
|
const writeMessage = (socket, type, payload) => {
|
|
124769
125051
|
socket.write(JSON.stringify({ type, payload }) + "\n");
|
|
124770
125052
|
};
|
|
124771
|
-
const writeActivation = (socket) => {
|
|
124772
|
-
writeMessage(socket, "Control", { command: "activateNetworkInspection" });
|
|
124773
|
-
};
|
|
124774
125053
|
const isAppRunning = async (bundleId) => {
|
|
124775
125054
|
const runningBundleIds = await host.listRunningBundleIds(udid);
|
|
124776
125055
|
return runningBundleIds.has(bundleId);
|
|
@@ -124806,11 +125085,116 @@ var nativeDevtoolsBlueprint = {
|
|
|
124806
125085
|
}, timeoutMs);
|
|
124807
125086
|
});
|
|
124808
125087
|
}
|
|
125088
|
+
const waitForConnection = (test, timeoutMs) => {
|
|
125089
|
+
if (test()) return Promise.resolve(true);
|
|
125090
|
+
return new Promise((resolve21) => {
|
|
125091
|
+
const finish = () => {
|
|
125092
|
+
clearTimeout(timer);
|
|
125093
|
+
connectionWaiters.delete(check3);
|
|
125094
|
+
resolve21(!disposed && test());
|
|
125095
|
+
};
|
|
125096
|
+
const check3 = () => {
|
|
125097
|
+
if (disposed || test()) finish();
|
|
125098
|
+
};
|
|
125099
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
125100
|
+
timer.unref();
|
|
125101
|
+
connectionWaiters.add(check3);
|
|
125102
|
+
});
|
|
125103
|
+
};
|
|
125104
|
+
const enableOn = (conn) => {
|
|
125105
|
+
if (conn.armed && !lentSocketPath) return Promise.resolve(true);
|
|
125106
|
+
if (conn.enabling) return conn.enabling;
|
|
125107
|
+
delete conn.enableFailure;
|
|
125108
|
+
const enabling = conn.cdp.request(
|
|
125109
|
+
lentSocketPath ? "NativeDevtoolsIos.getConditions" : "Network.enable",
|
|
125110
|
+
{},
|
|
125111
|
+
{
|
|
125112
|
+
timeoutMs: NETWORK_ENABLE_TIMEOUT_MS,
|
|
125113
|
+
onResult: (result) => {
|
|
125114
|
+
conn.armed = !lentSocketPath || result?.enabled === true;
|
|
125115
|
+
if (!conn.armed) conn.enableFailure = PROVIDER_CAPTURE_OFF;
|
|
125116
|
+
wakeConnectionWaiters();
|
|
125117
|
+
}
|
|
125118
|
+
}
|
|
125119
|
+
).then(
|
|
125120
|
+
() => conn.armed,
|
|
125121
|
+
(err) => {
|
|
125122
|
+
if (conn.socket.destroyed || disposed) return false;
|
|
125123
|
+
const timedOut3 = getFailureSignal(err)?.error_kind === "timeout";
|
|
125124
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
125125
|
+
conn.enableFailure = lentSocketPath ? timedOut3 ? `the agent did not say within ${NETWORK_ENABLE_TIMEOUT_MS / 1e3} s whether capture is on; the next call asks again` : `the agent did not say whether capture is on (${detail}); the next call asks again` : timedOut3 ? `the agent did not acknowledge Network.enable within ${NETWORK_ENABLE_TIMEOUT_MS / 1e3} s; the next call asks again` : `the agent did not enable capture (${detail}); the next call asks again`;
|
|
125126
|
+
process.stderr.write(`[native-devtools ${udid.slice(0, 8)}] ${conn.enableFailure}
|
|
125127
|
+
`);
|
|
125128
|
+
wakeConnectionWaiters();
|
|
125129
|
+
return false;
|
|
125130
|
+
}
|
|
125131
|
+
).finally(() => {
|
|
125132
|
+
if (conn.enabling === enabling) conn.enabling = void 0;
|
|
125133
|
+
});
|
|
125134
|
+
conn.enabling = enabling;
|
|
125135
|
+
return enabling;
|
|
125136
|
+
};
|
|
125137
|
+
const captureState = (bundleId) => {
|
|
125138
|
+
const conn = connections2.get(bundleId);
|
|
125139
|
+
if (!conn) {
|
|
125140
|
+
return {
|
|
125141
|
+
armed: false,
|
|
125142
|
+
note: activatedBundleIds.has(bundleId) ? "the app is not connected; its next process is armed when it connects" : "the app is not connected"
|
|
125143
|
+
};
|
|
125144
|
+
}
|
|
125145
|
+
return {
|
|
125146
|
+
armed: conn.armed,
|
|
125147
|
+
...conn.pid !== void 0 ? { pid: conn.pid } : {},
|
|
125148
|
+
...conn.armed ? {} : conn.enabling ? { note: lentSocketPath ? WAITING_FOR_CAPTURE_STATE : WAITING_FOR_ENABLE } : conn.enableFailure ? { note: conn.enableFailure } : {}
|
|
125149
|
+
};
|
|
125150
|
+
};
|
|
125151
|
+
const readConnectionPid = async (bundleId, conn) => {
|
|
125152
|
+
if (lentSocketPath) return;
|
|
125153
|
+
const inspection = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125154
|
+
const pid = inspection?.process?.pid;
|
|
125155
|
+
if (pid === void 0 || disposed || connections2.get(bundleId) !== conn) return;
|
|
125156
|
+
conn.pid = pid;
|
|
125157
|
+
wakeConnectionWaiters();
|
|
125158
|
+
};
|
|
125159
|
+
const settleClosedConnection = async (bundleId, conn) => {
|
|
125160
|
+
const store = networkStores.get(bundleId);
|
|
125161
|
+
if (lentSocketPath || disposed || !store?.hasOpenRecords(conn.index)) return;
|
|
125162
|
+
const inspection = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125163
|
+
if (disposed) return;
|
|
125164
|
+
const live = connections2.get(bundleId);
|
|
125165
|
+
store.connectionClosed(conn.index, {
|
|
125166
|
+
superseded: live !== void 0 && live !== conn,
|
|
125167
|
+
...inspection ? { running: inspection.running } : {},
|
|
125168
|
+
...inspection?.process ? { runningPid: inspection.process.pid } : {},
|
|
125169
|
+
...conn.pid !== void 0 ? { connectionPid: conn.pid } : {}
|
|
125170
|
+
});
|
|
125171
|
+
};
|
|
125172
|
+
const closeConnection = (bundleId, conn) => {
|
|
125173
|
+
conn.cdp.close();
|
|
125174
|
+
conn.armed = false;
|
|
125175
|
+
if (connections2.get(bundleId) === conn) connections2.delete(bundleId);
|
|
125176
|
+
connectionCloses += 1;
|
|
125177
|
+
wakeConnectionWaiters();
|
|
125178
|
+
void settleClosedConnection(bundleId, conn);
|
|
125179
|
+
};
|
|
124809
125180
|
function sendViewInspectorRpc(targetBundleId, method, params = {}) {
|
|
124810
125181
|
const timeoutMs = method === "ViewHierarchy.getFullHierarchy" ? 15e3 : 5e3;
|
|
124811
125182
|
return sendRpc(targetBundleId, "ViewInspector", method, params, timeoutMs);
|
|
124812
125183
|
}
|
|
124813
|
-
const sendCdpRpc = (targetBundleId, method, params = {}) =>
|
|
125184
|
+
const sendCdpRpc = (targetBundleId, method, params = {}) => {
|
|
125185
|
+
const conn = connections2.get(targetBundleId);
|
|
125186
|
+
if (!conn) {
|
|
125187
|
+
return Promise.reject(
|
|
125188
|
+
new FailureError("Native devtools not connected for bundleId: " + targetBundleId, {
|
|
125189
|
+
error_code: FAILURE_CODES.NATIVE_DEVTOOLS_NOT_CONNECTED,
|
|
125190
|
+
failure_stage: "native_devtools_rpc_connection",
|
|
125191
|
+
failure_area: "tool_server",
|
|
125192
|
+
error_kind: "not_found"
|
|
125193
|
+
})
|
|
125194
|
+
);
|
|
125195
|
+
}
|
|
125196
|
+
return conn.cdp.request(method, params, { timeoutMs: 5e3 });
|
|
125197
|
+
};
|
|
124814
125198
|
const readCaptureEnabled = async (bundleId) => {
|
|
124815
125199
|
const state3 = await sendCdpRpc(bundleId, "NativeDevtoolsIos.getConditions").catch(() => null);
|
|
124816
125200
|
return state3?.enabled !== false;
|
|
@@ -124819,7 +125203,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124819
125203
|
if (!lentSocketPath || providerCapture.has(bundleId)) return;
|
|
124820
125204
|
providerCapture.set(bundleId, await readCaptureEnabled(bundleId));
|
|
124821
125205
|
};
|
|
124822
|
-
const keepsCapture = (bundleId) =>
|
|
125206
|
+
const keepsCapture = (bundleId) => lentSocketPath ? providerCapture.get(bundleId) === true : activatedBundleIds.has(bundleId);
|
|
124823
125207
|
const applyThrottle = async (bundleId, throttle) => {
|
|
124824
125208
|
await noteProviderCapture(bundleId);
|
|
124825
125209
|
await sendCdpRpc(bundleId, "NativeDevtoolsIos.configure", {
|
|
@@ -124833,7 +125217,16 @@ var nativeDevtoolsBlueprint = {
|
|
|
124833
125217
|
providerCapture.delete(bundleId);
|
|
124834
125218
|
};
|
|
124835
125219
|
const reapplyThrottle = (bundleId, throttle) => {
|
|
124836
|
-
|
|
125220
|
+
const reapplying = async () => {
|
|
125221
|
+
await noteProviderCapture(bundleId);
|
|
125222
|
+
await Promise.all([
|
|
125223
|
+
sendCdpRpc(bundleId, "NativeDevtoolsIos.configure", {
|
|
125224
|
+
bypassPorts: [throttle.metroPort]
|
|
125225
|
+
}),
|
|
125226
|
+
sendCdpRpc(bundleId, "Network.emulateNetworkConditions", { ...throttle.conditions })
|
|
125227
|
+
]);
|
|
125228
|
+
};
|
|
125229
|
+
reapplying().catch((err) => {
|
|
124837
125230
|
const reason2 = err instanceof Error ? err.message : String(err);
|
|
124838
125231
|
process.stderr.write(
|
|
124839
125232
|
`[native-devtools] could not re-apply network conditions to ${bundleId}: ${reason2}
|
|
@@ -124841,11 +125234,16 @@ var nativeDevtoolsBlueprint = {
|
|
|
124841
125234
|
);
|
|
124842
125235
|
});
|
|
124843
125236
|
};
|
|
124844
|
-
const
|
|
124845
|
-
if (activatedBundleIds.has(bundleId)) writeActivation(socket);
|
|
125237
|
+
const reapplyStoredThrottle = (bundleId) => {
|
|
124846
125238
|
const throttle = networkConditions.get(bundleId);
|
|
124847
125239
|
if (throttle) reapplyThrottle(bundleId, throttle);
|
|
124848
125240
|
};
|
|
125241
|
+
const armOn = (bundleId, conn) => {
|
|
125242
|
+
const sendsEnable = !lentSocketPath && !conn.armed && !conn.enabling;
|
|
125243
|
+
const arming = enableOn(conn);
|
|
125244
|
+
if (sendsEnable) reapplyStoredThrottle(bundleId);
|
|
125245
|
+
return arming;
|
|
125246
|
+
};
|
|
124849
125247
|
const storeThrottle = (bundleId, throttle) => {
|
|
124850
125248
|
if (throttle) networkConditions.set(bundleId, throttle);
|
|
124851
125249
|
else networkConditions.delete(bundleId);
|
|
@@ -124882,6 +125280,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124882
125280
|
}
|
|
124883
125281
|
const serveAgentConnection = (socket) => {
|
|
124884
125282
|
let bundleId = null;
|
|
125283
|
+
let conn = null;
|
|
124885
125284
|
attachNdjsonReader(socket, {
|
|
124886
125285
|
onDropped: reportDroppedFrameToStderr(`native-devtools ${udid.slice(0, 8)}`),
|
|
124887
125286
|
onMessage: (parsed2) => {
|
|
@@ -124891,37 +125290,48 @@ var nativeDevtoolsBlueprint = {
|
|
|
124891
125290
|
bundleId = msg.payload.bundleId;
|
|
124892
125291
|
const existing = connections2.get(bundleId);
|
|
124893
125292
|
if (existing) {
|
|
125293
|
+
closeConnection(bundleId, existing);
|
|
124894
125294
|
existing.socket.destroy();
|
|
124895
125295
|
}
|
|
124896
|
-
|
|
124897
|
-
|
|
125296
|
+
conn = {
|
|
125297
|
+
socket,
|
|
125298
|
+
index: nextConnectionIndex++,
|
|
125299
|
+
cdp: createNdjsonCdpRequester(socket, { label: `native-devtools ${bundleId}` }),
|
|
125300
|
+
armed: false
|
|
125301
|
+
};
|
|
125302
|
+
connections2.set(bundleId, conn);
|
|
125303
|
+
if (!networkStores.has(bundleId)) {
|
|
125304
|
+
const app = bundleId;
|
|
125305
|
+
networkStores.set(
|
|
125306
|
+
app,
|
|
125307
|
+
createIosNetworkRecords(() => captureState(app))
|
|
125308
|
+
);
|
|
125309
|
+
}
|
|
125310
|
+
if (lentSocketPath && performance.now() - lentConnectedAt < LENT_HANDSHAKE_PROMPT_MS) {
|
|
125311
|
+
captureGaps.add(bundleId);
|
|
125312
|
+
}
|
|
125313
|
+
if (activatedBundleIds.has(bundleId)) {
|
|
125314
|
+
if (!lentSocketPath) captureGaps.delete(bundleId);
|
|
125315
|
+
void armOn(bundleId, conn);
|
|
125316
|
+
} else {
|
|
125317
|
+
reapplyStoredThrottle(bundleId);
|
|
125318
|
+
}
|
|
125319
|
+
void readConnectionPid(bundleId, conn);
|
|
124898
125320
|
return;
|
|
124899
125321
|
}
|
|
124900
|
-
if (msg.type === "CDP") {
|
|
125322
|
+
if (msg.type === "CDP" && conn) {
|
|
124901
125323
|
const p = msg.payload;
|
|
124902
|
-
if (
|
|
124903
|
-
if (p.method && p.id === void 0) {
|
|
124904
|
-
|
|
124905
|
-
if (conn) {
|
|
124906
|
-
if (conn.networkLog.length >= NATIVE_NETWORK_LOG_LIMIT) {
|
|
124907
|
-
conn.networkLog.shift();
|
|
124908
|
-
}
|
|
124909
|
-
conn.networkLog.push({
|
|
124910
|
-
method: p.method,
|
|
124911
|
-
params: p.params,
|
|
124912
|
-
timestamp: Date.now()
|
|
124913
|
-
});
|
|
124914
|
-
}
|
|
125324
|
+
if (conn.cdp.handleResponse(p)) return;
|
|
125325
|
+
if (p && typeof p.method === "string" && p.id === void 0) {
|
|
125326
|
+
networkStores.get(bundleId)?.fold(conn.index, p.method, p.params);
|
|
124915
125327
|
}
|
|
124916
125328
|
}
|
|
124917
125329
|
if (msg.type === "ViewInspector") settleRpc(msg.payload);
|
|
124918
125330
|
}
|
|
124919
125331
|
});
|
|
124920
125332
|
socket.on("close", () => {
|
|
124921
|
-
if (bundleId !== null) {
|
|
124922
|
-
|
|
124923
|
-
connections2.delete(bundleId);
|
|
124924
|
-
}
|
|
125333
|
+
if (bundleId !== null && conn !== null && connections2.get(bundleId) === conn) {
|
|
125334
|
+
closeConnection(bundleId, conn);
|
|
124925
125335
|
}
|
|
124926
125336
|
});
|
|
124927
125337
|
socket.on("error", () => {
|
|
@@ -124929,6 +125339,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124929
125339
|
};
|
|
124930
125340
|
const server = lentSocketPath ? null : net.createServer(serveAgentConnection);
|
|
124931
125341
|
let lentSocket = null;
|
|
125342
|
+
let lentConnectedAt = 0;
|
|
124932
125343
|
let disposed = false;
|
|
124933
125344
|
if (lentSocketPath) {
|
|
124934
125345
|
lentSocket = await new Promise((resolve21, reject) => {
|
|
@@ -124953,6 +125364,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124953
125364
|
resolve21(socket);
|
|
124954
125365
|
});
|
|
124955
125366
|
});
|
|
125367
|
+
lentConnectedAt = performance.now();
|
|
124956
125368
|
serveAgentConnection(lentSocket);
|
|
124957
125369
|
lentSocket.once("close", () => {
|
|
124958
125370
|
if (disposed) return;
|
|
@@ -125044,10 +125456,12 @@ var nativeDevtoolsBlueprint = {
|
|
|
125044
125456
|
return "unregistered";
|
|
125045
125457
|
},
|
|
125046
125458
|
activateNetworkInspection(bundleId) {
|
|
125047
|
-
const
|
|
125459
|
+
const startedNow = !activatedBundleIds.has(bundleId);
|
|
125048
125460
|
activatedBundleIds.add(bundleId);
|
|
125049
125461
|
const conn = connections2.get(bundleId);
|
|
125050
|
-
if (conn
|
|
125462
|
+
if (!conn) return Promise.resolve(false);
|
|
125463
|
+
if (startedNow && !lentSocketPath) captureGaps.add(bundleId);
|
|
125464
|
+
return armOn(bundleId, conn);
|
|
125051
125465
|
},
|
|
125052
125466
|
async setNetworkConditions(bundleId, throttle) {
|
|
125053
125467
|
const previous = networkConditions.get(bundleId) ?? null;
|
|
@@ -125066,10 +125480,70 @@ var nativeDevtoolsBlueprint = {
|
|
|
125066
125480
|
throw err;
|
|
125067
125481
|
}
|
|
125068
125482
|
},
|
|
125069
|
-
|
|
125070
|
-
|
|
125071
|
-
|
|
125072
|
-
if (
|
|
125483
|
+
takeCaptureGap: (bundleId) => captureGaps.delete(bundleId),
|
|
125484
|
+
networkRecords: (bundleId) => networkStores.get(bundleId),
|
|
125485
|
+
async networkCaptureAfterLaunch(bundleId) {
|
|
125486
|
+
if (!activatedBundleIds.has(bundleId) || lentSocketPath) return void 0;
|
|
125487
|
+
let closes = connectionCloses;
|
|
125488
|
+
const inspection = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125489
|
+
if (disposed) return void 0;
|
|
125490
|
+
const gone = `native network capture is on for ${bundleId}, but no process of it is running after the launch; its next process is armed when it connects`;
|
|
125491
|
+
if (inspection?.running === false) return gone;
|
|
125492
|
+
const pid = inspection?.process?.pid;
|
|
125493
|
+
const ofLaunch = () => {
|
|
125494
|
+
const conn = connections2.get(bundleId);
|
|
125495
|
+
return conn && (pid === void 0 || conn.pid === pid) ? conn : void 0;
|
|
125496
|
+
};
|
|
125497
|
+
const running = inspection?.process;
|
|
125498
|
+
if (running && !ofLaunch()) {
|
|
125499
|
+
if (!processCarriesInjection(running.env, endpoint)) {
|
|
125500
|
+
return `native network capture is on for ${bundleId}, but its running process (pid ${running.pid}) was launched without argent's injection for this simulator, so capture cannot be armed in it; call restart-app to start a process that is armed`;
|
|
125501
|
+
}
|
|
125502
|
+
if (running.ageMs > Date.now() - listeningSince + NATIVE_DEVTOOLS_AGE_SLOP_MS) {
|
|
125503
|
+
return `native network capture is on for ${bundleId}, but its running process (pid ${running.pid}) started before this tool-server's native-devtools listener, so it never connects and capture cannot be armed in it; call restart-app to start a process that is armed`;
|
|
125504
|
+
}
|
|
125505
|
+
}
|
|
125506
|
+
const asked = ofLaunch();
|
|
125507
|
+
if (asked && !asked.armed && !asked.enabling) void enableOn(asked);
|
|
125508
|
+
let exited = false;
|
|
125509
|
+
const watchExit = () => {
|
|
125510
|
+
if (closes === connectionCloses) return;
|
|
125511
|
+
closes = connectionCloses;
|
|
125512
|
+
if (connections2.has(bundleId)) return;
|
|
125513
|
+
void host.inspectRunningApp(udid, bundleId).catch(() => null).then((now) => {
|
|
125514
|
+
if (now?.running !== false) return;
|
|
125515
|
+
exited = true;
|
|
125516
|
+
wakeConnectionWaiters();
|
|
125517
|
+
});
|
|
125518
|
+
};
|
|
125519
|
+
connectionWaiters.add(watchExit);
|
|
125520
|
+
watchExit();
|
|
125521
|
+
try {
|
|
125522
|
+
await waitForConnection(() => {
|
|
125523
|
+
const conn = ofLaunch();
|
|
125524
|
+
return exited || conn !== void 0 && (conn.armed || conn.enableFailure !== void 0);
|
|
125525
|
+
}, LAUNCH_ARM_WAIT_MS);
|
|
125526
|
+
} finally {
|
|
125527
|
+
connectionWaiters.delete(watchExit);
|
|
125528
|
+
}
|
|
125529
|
+
if (disposed) return void 0;
|
|
125530
|
+
if (exited) return gone;
|
|
125531
|
+
let launched = ofLaunch();
|
|
125532
|
+
if (!launched) {
|
|
125533
|
+
const now = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125534
|
+
if (disposed) return void 0;
|
|
125535
|
+
if (now?.running === false) return gone;
|
|
125536
|
+
launched = ofLaunch();
|
|
125537
|
+
}
|
|
125538
|
+
const shownPid = pid ?? launched?.pid;
|
|
125539
|
+
const pidText = shownPid !== void 0 ? ` (pid ${shownPid})` : "";
|
|
125540
|
+
if (launched?.armed) {
|
|
125541
|
+
return `native network capture is armed for ${bundleId}${pidText}; stop-all-simulator-servers for this device, then restart-app, ends it`;
|
|
125542
|
+
}
|
|
125543
|
+
if (launched?.enableFailure !== void 0) {
|
|
125544
|
+
return `native network capture is on for ${bundleId}, but its process${pidText} is not armed: ${launched.enableFailure}`;
|
|
125545
|
+
}
|
|
125546
|
+
return launched ? `native network capture is on for ${bundleId}, and its new process${pidText} has not acknowledged Network.enable yet; native-network-logs shows when it is armed` : `native network capture is on for ${bundleId}, and its new process has not connected yet; native-network-logs shows when it is armed`;
|
|
125073
125547
|
},
|
|
125074
125548
|
async getAppState(bundleId) {
|
|
125075
125549
|
const result = await sendViewInspectorRpc(bundleId, "Application.getState");
|
|
@@ -125114,16 +125588,27 @@ var nativeDevtoolsBlueprint = {
|
|
|
125114
125588
|
return sendViewInspectorRpc(bundleId, method, params);
|
|
125115
125589
|
}
|
|
125116
125590
|
};
|
|
125591
|
+
const unregisterCaptures = registerIosNetworkCaptures({
|
|
125592
|
+
udid,
|
|
125593
|
+
// A lent agent's capture is its provider's, so argent has none on there.
|
|
125594
|
+
bundleIds: lentSocketPath ? /* @__PURE__ */ new Set() : activatedBundleIds,
|
|
125595
|
+
stores: networkStores
|
|
125596
|
+
});
|
|
125117
125597
|
return {
|
|
125118
125598
|
api,
|
|
125119
125599
|
dispose: async () => {
|
|
125120
125600
|
disposed = true;
|
|
125601
|
+
unregisterCaptures();
|
|
125121
125602
|
if (lentSocketPath) await releaseLentThrottles();
|
|
125122
|
-
for (const { socket } of connections2.values()) {
|
|
125603
|
+
for (const { socket, cdp } of connections2.values()) {
|
|
125604
|
+
cdp.close();
|
|
125123
125605
|
socket.destroy();
|
|
125124
125606
|
}
|
|
125125
125607
|
connections2.clear();
|
|
125126
125608
|
activatedBundleIds.clear();
|
|
125609
|
+
captureGaps.clear();
|
|
125610
|
+
networkStores.clear();
|
|
125611
|
+
wakeConnectionWaiters();
|
|
125127
125612
|
networkConditions.clear();
|
|
125128
125613
|
unconfirmedThrottles.clear();
|
|
125129
125614
|
providerCapture.clear();
|
|
@@ -126030,7 +126515,7 @@ var import_node_util15 = require("node:util");
|
|
|
126030
126515
|
var fs25 = __toESM(require("node:fs/promises"));
|
|
126031
126516
|
var os7 = __toESM(require("node:os"));
|
|
126032
126517
|
var path21 = __toESM(require("node:path"));
|
|
126033
|
-
var
|
|
126518
|
+
var import_node_crypto8 = require("node:crypto");
|
|
126034
126519
|
init_src2();
|
|
126035
126520
|
|
|
126036
126521
|
// ../tool-server/src/utils/ios-device/usbmux-protocol.ts
|
|
@@ -126335,7 +126820,7 @@ async function runDevicectl(args, action, opts = {}) {
|
|
|
126335
126820
|
let jsonPath = null;
|
|
126336
126821
|
const argv = ["devicectl", ...args];
|
|
126337
126822
|
if (opts.json) {
|
|
126338
|
-
jsonPath = path21.join(os7.tmpdir(), `argent-devicectl-${process.pid}-${(0,
|
|
126823
|
+
jsonPath = path21.join(os7.tmpdir(), `argent-devicectl-${process.pid}-${(0, import_node_crypto8.randomUUID)()}.json`);
|
|
126339
126824
|
argv.push("--json-output", jsonPath);
|
|
126340
126825
|
}
|
|
126341
126826
|
try {
|
|
@@ -126607,7 +127092,7 @@ init_harmony_flag();
|
|
|
126607
127092
|
|
|
126608
127093
|
// ../tool-server/src/utils/macos-apps.ts
|
|
126609
127094
|
var import_node_child_process21 = require("node:child_process");
|
|
126610
|
-
var
|
|
127095
|
+
var import_node_crypto9 = require("node:crypto");
|
|
126611
127096
|
var fs26 = __toESM(require("node:fs"));
|
|
126612
127097
|
var os8 = __toESM(require("node:os"));
|
|
126613
127098
|
var path22 = __toESM(require("node:path"));
|
|
@@ -126693,7 +127178,7 @@ function stageMacosLibraries(bootstrapPath, libraryPath, teamId) {
|
|
|
126693
127178
|
}
|
|
126694
127179
|
var SOURCES_NAME = "sources";
|
|
126695
127180
|
function libraryHash(bootstrap, library) {
|
|
126696
|
-
return (0,
|
|
127181
|
+
return (0, import_node_crypto9.createHash)("sha256").update(`${bootstrap.length}:`).update(bootstrap).update(`${library.length}:`).update(library).digest("hex").slice(0, 16);
|
|
126697
127182
|
}
|
|
126698
127183
|
function recordLibrarySource(dir, source) {
|
|
126699
127184
|
const file2 = path22.join(dir, SOURCES_NAME);
|
|
@@ -126814,7 +127299,7 @@ function macosListenSocket(bundleId, sandboxed) {
|
|
|
126814
127299
|
}
|
|
126815
127300
|
const named = path22.join(macosArgentDir(), `${bundleId}.sock`);
|
|
126816
127301
|
if (fitsSocketPath(named)) return { env: named, path: named };
|
|
126817
|
-
const hash2 = (0,
|
|
127302
|
+
const hash2 = (0, import_node_crypto9.createHash)("sha256").update(bundleId).digest("hex").slice(0, 16);
|
|
126818
127303
|
const hashed = path22.join(macosArgentDir(), `${hash2}.sock`);
|
|
126819
127304
|
return fitsSocketPath(hashed) ? { env: hashed, path: hashed } : null;
|
|
126820
127305
|
}
|
|
@@ -128816,7 +129301,7 @@ function createTabsManager(deps) {
|
|
|
128816
129301
|
}
|
|
128817
129302
|
|
|
128818
129303
|
// ../tool-server/src/chromium-server/network.ts
|
|
128819
|
-
var
|
|
129304
|
+
var MAX_RECORDS2 = 1e3;
|
|
128820
129305
|
var shapesTraffic = (c) => c.offline || c.latency > 0 || c.downloadThroughput >= 0 || c.uploadThroughput >= 0;
|
|
128821
129306
|
function createNetworkManager(deps) {
|
|
128822
129307
|
const { cdp } = deps;
|
|
@@ -128829,7 +129314,7 @@ function createNetworkManager(deps) {
|
|
|
128829
129314
|
rec = { requestId, method: "", url: "", startedDateTime: "", startTs: 0 };
|
|
128830
129315
|
byId.set(requestId, rec);
|
|
128831
129316
|
order.push(requestId);
|
|
128832
|
-
if (order.length >
|
|
129317
|
+
if (order.length > MAX_RECORDS2) {
|
|
128833
129318
|
const evicted = order.shift();
|
|
128834
129319
|
if (evicted) byId.delete(evicted);
|
|
128835
129320
|
}
|
|
@@ -134023,37 +134508,6 @@ init_capability();
|
|
|
134023
134508
|
init_device_info();
|
|
134024
134509
|
init_external_devices();
|
|
134025
134510
|
|
|
134026
|
-
// ../tool-server/src/utils/debugger/device-alias.ts
|
|
134027
|
-
var logicalIdToConnectId = /* @__PURE__ */ new Map();
|
|
134028
|
-
function rememberDeviceAlias(logicalDeviceId, connectDeviceId) {
|
|
134029
|
-
if (!logicalDeviceId || logicalDeviceId === connectDeviceId) return;
|
|
134030
|
-
logicalIdToConnectId.set(logicalDeviceId, connectDeviceId);
|
|
134031
|
-
}
|
|
134032
|
-
function canonicalDeviceId(deviceId) {
|
|
134033
|
-
if (!deviceId) return deviceId;
|
|
134034
|
-
return logicalIdToConnectId.get(deviceId) ?? deviceId;
|
|
134035
|
-
}
|
|
134036
|
-
function deviceIdsOf(deviceId) {
|
|
134037
|
-
const connectId = canonicalDeviceId(deviceId) ?? deviceId;
|
|
134038
|
-
const logicalIds = [...logicalIdToConnectId].filter(([, aliased]) => aliased === connectId).map(([logicalId]) => logicalId);
|
|
134039
|
-
return [.../* @__PURE__ */ new Set([deviceId, connectId, ...logicalIds])];
|
|
134040
|
-
}
|
|
134041
|
-
function forgetDeviceAlias(logicalDeviceId) {
|
|
134042
|
-
if (logicalDeviceId) logicalIdToConnectId.delete(logicalDeviceId);
|
|
134043
|
-
}
|
|
134044
|
-
var logicalKeyedConnectIds = /* @__PURE__ */ new Set();
|
|
134045
|
-
function rememberLogicalKeyedDevice(logicalDeviceId, connectDeviceId) {
|
|
134046
|
-
if (logicalDeviceId && logicalDeviceId === connectDeviceId) {
|
|
134047
|
-
logicalKeyedConnectIds.add(connectDeviceId.toLowerCase());
|
|
134048
|
-
}
|
|
134049
|
-
}
|
|
134050
|
-
function isLogicalKeyedDevice(deviceId) {
|
|
134051
|
-
return deviceId !== void 0 && logicalKeyedConnectIds.has(deviceId.toLowerCase());
|
|
134052
|
-
}
|
|
134053
|
-
function forgetLogicalKeyedDevice(connectDeviceId) {
|
|
134054
|
-
logicalKeyedConnectIds.delete(connectDeviceId.toLowerCase());
|
|
134055
|
-
}
|
|
134056
|
-
|
|
134057
134511
|
// ../tool-server/src/utils/invalid-params.ts
|
|
134058
134512
|
function deriveInvalidParams(error63, declared) {
|
|
134059
134513
|
const out = [];
|
|
@@ -135411,7 +135865,7 @@ function reserveLaunchMeasurement(udid) {
|
|
|
135411
135865
|
// ../tool-server/src/utils/ios-device/runner-artifact.ts
|
|
135412
135866
|
var import_node_child_process26 = require("node:child_process");
|
|
135413
135867
|
var import_node_util18 = require("node:util");
|
|
135414
|
-
var
|
|
135868
|
+
var import_node_crypto10 = require("node:crypto");
|
|
135415
135869
|
var fs35 = __toESM(require("node:fs"));
|
|
135416
135870
|
var fsp = __toESM(require("node:fs/promises"));
|
|
135417
135871
|
var os13 = __toESM(require("node:os"));
|
|
@@ -135583,7 +136037,7 @@ var FINGERPRINT_NOISE = /* @__PURE__ */ new Set([
|
|
|
135583
136037
|
]);
|
|
135584
136038
|
async function fingerprintRunnerSources(projectPath) {
|
|
135585
136039
|
const root = path30.dirname(projectPath);
|
|
135586
|
-
const hash2 = (0,
|
|
136040
|
+
const hash2 = (0, import_node_crypto10.createHash)("sha256");
|
|
135587
136041
|
const walk = async (dir) => {
|
|
135588
136042
|
const entries = (await fsp.readdir(dir, { withFileTypes: true })).sort(
|
|
135589
136043
|
(a, b) => a.name.localeCompare(b.name)
|
|
@@ -135692,7 +136146,7 @@ function runnerBuildLocationArgs(derivedDataPath) {
|
|
|
135692
136146
|
];
|
|
135693
136147
|
}
|
|
135694
136148
|
function computeRunnerCacheKey(sourcesHash, xcodeVersion2, staticArgs) {
|
|
135695
|
-
return (0,
|
|
136149
|
+
return (0, import_node_crypto10.createHash)("sha256").update([sourcesHash, xcodeVersion2, ...staticArgs].join("\n")).digest("hex").slice(0, 16);
|
|
135696
136150
|
}
|
|
135697
136151
|
function isProfileMissingDeviceFailure(logText) {
|
|
135698
136152
|
return logText.includes("0xe8008012") || /doesn't include the currently selected device/i.test(logText) || /provisioning profile cannot be installed on this device/i.test(logText) || /team has no devices/i.test(logText);
|
|
@@ -136002,7 +136456,7 @@ async function killStaleRunnersForDevice(udid, listProcesses = listProcessTable)
|
|
|
136002
136456
|
var fs38 = __toESM(require("node:fs/promises"));
|
|
136003
136457
|
|
|
136004
136458
|
// ../tool-server/src/utils/ios-device/runner-http.ts
|
|
136005
|
-
var
|
|
136459
|
+
var import_node_http3 = __toESM(require("node:http"));
|
|
136006
136460
|
|
|
136007
136461
|
// ../tool-server/src/utils/ios-device/usbmux.ts
|
|
136008
136462
|
var import_node_events3 = require("node:events");
|
|
@@ -136217,7 +136671,7 @@ var RUNNER_HTTP_MAX_RESPONSE_BYTES = 64 * 1024 * 1024;
|
|
|
136217
136671
|
async function postRunnerCommand(options) {
|
|
136218
136672
|
requireTimeRemaining(options.deadline.remainingMs(), "send runner command");
|
|
136219
136673
|
const socket = await options.socketFactory();
|
|
136220
|
-
const agent = new
|
|
136674
|
+
const agent = new import_node_http3.default.Agent({ keepAlive: false });
|
|
136221
136675
|
agent.createConnection = ((_options, callback) => {
|
|
136222
136676
|
callback?.(null, socket);
|
|
136223
136677
|
return socket;
|
|
@@ -136237,7 +136691,7 @@ async function requestOverAgent(agent, socket, payload, timeoutMs) {
|
|
|
136237
136691
|
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
136238
136692
|
try {
|
|
136239
136693
|
return await new Promise((resolve21, reject) => {
|
|
136240
|
-
const request3 =
|
|
136694
|
+
const request3 = import_node_http3.default.request(
|
|
136241
136695
|
{
|
|
136242
136696
|
method: "POST",
|
|
136243
136697
|
// Host header only because the connection is the injected socket.
|
|
@@ -136382,7 +136836,7 @@ async function readRunnerCrashSummary(resultBundlePath) {
|
|
|
136382
136836
|
}
|
|
136383
136837
|
|
|
136384
136838
|
// ../tool-server/src/utils/ios-device/runner-client.ts
|
|
136385
|
-
var
|
|
136839
|
+
var import_node_crypto11 = require("node:crypto");
|
|
136386
136840
|
init_src2();
|
|
136387
136841
|
var RUNNER_COMMAND_TIMEOUT_MS = 45e3;
|
|
136388
136842
|
var RUNNER_STATUS_RECOVERY_TIMEOUT_MS = 3e3;
|
|
@@ -136595,7 +137049,7 @@ function withCommandId(command) {
|
|
|
136595
137049
|
if (command.command === "status" || typeof command.commandId === "string") {
|
|
136596
137050
|
return command;
|
|
136597
137051
|
}
|
|
136598
|
-
return { ...command, commandId: `argent-${(0,
|
|
137052
|
+
return { ...command, commandId: `argent-${(0, import_node_crypto11.randomUUID)()}` };
|
|
136599
137053
|
}
|
|
136600
137054
|
function unwrapEnvelope(response, udid) {
|
|
136601
137055
|
const envelope = asEnvelope(response);
|
|
@@ -139633,7 +140087,7 @@ async function describeChromium(api, limits = DEFAULT_WALK_LIMITS) {
|
|
|
139633
140087
|
init_src2();
|
|
139634
140088
|
|
|
139635
140089
|
// ../tool-server/src/utils/vega-inspect.ts
|
|
139636
|
-
var
|
|
140090
|
+
var import_node_http4 = require("node:http");
|
|
139637
140091
|
init_adb();
|
|
139638
140092
|
|
|
139639
140093
|
// ../tool-server/src/utils/vega-automation.ts
|
|
@@ -139811,7 +140265,7 @@ async function fetchVegaPageSource(timeoutMs = 15e3) {
|
|
|
139811
140265
|
}
|
|
139812
140266
|
function postJson(host, port, path72, body, timeoutMs) {
|
|
139813
140267
|
return new Promise((resolve21, reject) => {
|
|
139814
|
-
const req = (0,
|
|
140268
|
+
const req = (0, import_node_http4.request)(
|
|
139815
140269
|
{
|
|
139816
140270
|
host,
|
|
139817
140271
|
port,
|
|
@@ -144829,6 +145283,7 @@ async function startSuspensionWatch(helperPath, pid) {
|
|
|
144829
145283
|
}
|
|
144830
145284
|
|
|
144831
145285
|
// ../tool-server/src/blueprints/macos-app.ts
|
|
145286
|
+
var NATIVE_NETWORK_LOG_LIMIT = 1e3;
|
|
144832
145287
|
var MACOS_APP_NAMESPACE = "MacosApp";
|
|
144833
145288
|
function macosAppRef(device) {
|
|
144834
145289
|
return { urn: `${MACOS_APP_NAMESPACE}:${device.id}`, options: { device } };
|
|
@@ -145229,7 +145684,7 @@ function createMacosAppApi(bundleId) {
|
|
|
145229
145684
|
const reconnect = async () => {
|
|
145230
145685
|
const app = await runningTrackedApp(bundleId);
|
|
145231
145686
|
if (!app) throw notRunningError(bundleId);
|
|
145232
|
-
const
|
|
145687
|
+
const notConnected3 = (detail, cause) => macosFailure(
|
|
145233
145688
|
`${bundleId} is running (pid ${app.pid}) but argent cannot reach its library: ${detail} If it is paused in a debugger, continue it and try again. Otherwise run restart-app to start it again with the library.`,
|
|
145234
145689
|
FAILURE_CODES.MACOS_APP_NOT_CONNECTED,
|
|
145235
145690
|
"macos_app_reconnect",
|
|
@@ -145254,7 +145709,7 @@ function createMacosAppApi(bundleId) {
|
|
|
145254
145709
|
await ch.waitForHandshake(RECONNECT_TIMEOUT_MS);
|
|
145255
145710
|
} catch (err) {
|
|
145256
145711
|
ch.close();
|
|
145257
|
-
throw
|
|
145712
|
+
throw notConnected3(errorMessage2(err), err);
|
|
145258
145713
|
}
|
|
145259
145714
|
if (disposed && !launching) {
|
|
145260
145715
|
ch.close();
|
|
@@ -148341,7 +148796,7 @@ function createHttpApp(registry2, options) {
|
|
|
148341
148796
|
});
|
|
148342
148797
|
return;
|
|
148343
148798
|
}
|
|
148344
|
-
const id = (0,
|
|
148799
|
+
const id = (0, import_node_crypto12.randomUUID)();
|
|
148345
148800
|
const tarPath = (0, import_node_path15.join)((0, import_node_os11.tmpdir)(), `argent-upload-${id}.tar.gz`);
|
|
148346
148801
|
const ws = (0, import_node_fs12.createWriteStream)(tarPath);
|
|
148347
148802
|
let received = 0;
|
|
@@ -148358,7 +148813,7 @@ function createHttpApp(registry2, options) {
|
|
|
148358
148813
|
});
|
|
148359
148814
|
if (!res.headersSent) res.status(status).json({ error: message });
|
|
148360
148815
|
};
|
|
148361
|
-
const digest = (0,
|
|
148816
|
+
const digest = (0, import_node_crypto12.createHash)("sha256");
|
|
148362
148817
|
req.on("data", (chunk) => {
|
|
148363
148818
|
if (released) return;
|
|
148364
148819
|
received += chunk.length;
|
|
@@ -148634,7 +149089,7 @@ function createHttpApp(registry2, options) {
|
|
|
148634
149089
|
});
|
|
148635
149090
|
const keepAlive = def.longRunning && options?.idleTimeoutMs && options.idleTimeoutMs > 0 ? setInterval(() => idleTimer.touch(), Math.max(1e3, IDLE_CHECK_INTERVAL_MS / 2)) : null;
|
|
148636
149091
|
if (keepAlive) keepAlive.unref?.();
|
|
148637
|
-
const toolInvocationId = (0,
|
|
149092
|
+
const toolInvocationId = (0, import_node_crypto12.randomUUID)();
|
|
148638
149093
|
let releaseInvocationMeta;
|
|
148639
149094
|
let recordChildInvocation;
|
|
148640
149095
|
const recordInvocation = options?.recordInvocation;
|
|
@@ -148972,13 +149427,12 @@ init_src2();
|
|
|
148972
149427
|
init_src();
|
|
148973
149428
|
|
|
148974
149429
|
// ../tool-server/src/blueprints/android-network-inspector.ts
|
|
148975
|
-
var
|
|
149430
|
+
var import_node_crypto13 = require("node:crypto");
|
|
148976
149431
|
var fs41 = __toESM(require("node:fs"));
|
|
148977
149432
|
var net8 = __toESM(require("node:net"));
|
|
148978
149433
|
var path35 = __toESM(require("node:path"));
|
|
148979
149434
|
init_src2();
|
|
148980
149435
|
init_adb();
|
|
148981
|
-
init_external_devices();
|
|
148982
149436
|
|
|
148983
149437
|
// ../tool-server/src/blueprints/android-network-inspector-device.ts
|
|
148984
149438
|
init_adb();
|
|
@@ -149144,9 +149598,6 @@ function isAgentReason(message) {
|
|
|
149144
149598
|
|
|
149145
149599
|
// ../tool-server/src/blueprints/android-network-inspector.ts
|
|
149146
149600
|
var ANDROID_NETWORK_INSPECTOR_NAMESPACE = "AndroidNetworkInspector";
|
|
149147
|
-
function deviceKeyOf(deviceId) {
|
|
149148
|
-
return externalNativeId(canonicalDeviceId(deviceId) ?? deviceId);
|
|
149149
|
-
}
|
|
149150
149601
|
function androidNetworkInspectorRef(device, packageName, metroPort2) {
|
|
149151
149602
|
return {
|
|
149152
149603
|
urn: `${ANDROID_NETWORK_INSPECTOR_NAMESPACE}:${deviceKeyOf(device.id)}:${packageName}`,
|
|
@@ -149156,13 +149607,7 @@ function androidNetworkInspectorRef(device, packageName, metroPort2) {
|
|
|
149156
149607
|
var MIN_SDK = 26;
|
|
149157
149608
|
var PACKAGE_NAME2 = /^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)*$/;
|
|
149158
149609
|
var PROTOCOL_VERSION = 2;
|
|
149159
|
-
var MAX_RECORDS2 = 2e3;
|
|
149160
|
-
var RECORD_CHARS_BUDGET = 32 * 1024 * 1024;
|
|
149161
|
-
var MAX_VALUE_CHARS = 64 * 1024;
|
|
149162
|
-
var MAX_HEADERS = 256;
|
|
149163
|
-
var MAX_HEADER_MAP_CHARS = 256 * 1024;
|
|
149164
149610
|
var MAX_REDIRECTS = 32;
|
|
149165
|
-
var MAX_LAYER_ID_CHARS = 200;
|
|
149166
149611
|
var MAX_CACHED_BODIES = 64;
|
|
149167
149612
|
var MAX_FRAME_CHARS = 8 * 1024 * 1024;
|
|
149168
149613
|
var HANDSHAKE_FRAME_CHARS = 4 * 1024;
|
|
@@ -149184,14 +149629,12 @@ var SESSION_REMOVE_TIMEOUT_MS = 5e3;
|
|
|
149184
149629
|
var AGENT_BINARIES_MISSING_REASON = "agent binaries not present in this build";
|
|
149185
149630
|
var AGENT_GONE_REASON = "the agent that recorded the request is no longer in the app, as after an emulator snapshot load";
|
|
149186
149631
|
var LOST_WHILE_DISCONNECTED = "the agent lost this request's final events while it was disconnected";
|
|
149187
|
-
var NOT_RECONNECTED = "the agent did not reconnect after its connection dropped, so this request's final events never arrived";
|
|
149188
|
-
var PROCESS_ENDED = "the app process ended before the request finished";
|
|
149189
149632
|
var JS_LAYER_FALLBACK = "Use view-network-logs: the JS layer still records the app's JavaScript requests while Metro serves the app.";
|
|
149190
149633
|
var LOGGED_DETAIL_EVENTS = /* @__PURE__ */ new Set(["interceptor_installed", "interceptor_failed"]);
|
|
149191
|
-
var
|
|
149634
|
+
var RUN_TAG2 = (0, import_node_crypto13.randomBytes)(2).toString("hex");
|
|
149192
149635
|
var ANDROID_NATIVE_REQUEST_ID = /^android-[0-9a-f]{4}-\d+$/;
|
|
149193
149636
|
var liveInspectors = /* @__PURE__ */ new Map();
|
|
149194
|
-
var
|
|
149637
|
+
var nextRecordNumber2 = 1;
|
|
149195
149638
|
function allHandles() {
|
|
149196
149639
|
return [...liveInspectors.values()].flatMap((set2) => [...set2]);
|
|
149197
149640
|
}
|
|
@@ -149287,7 +149730,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
149287
149730
|
process.stderr.write(`[${tag3}] ${line}
|
|
149288
149731
|
`);
|
|
149289
149732
|
};
|
|
149290
|
-
const secret = (0,
|
|
149733
|
+
const secret = (0, import_node_crypto13.randomBytes)(32).toString("hex");
|
|
149291
149734
|
let metroPort2 = initialMetroPort;
|
|
149292
149735
|
let disposed = false;
|
|
149293
149736
|
let live = false;
|
|
@@ -149508,7 +149951,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
149508
149951
|
}
|
|
149509
149952
|
async function bindDevicePort() {
|
|
149510
149953
|
for (let attempt = 0; attempt < DEVICE_PORT_ATTEMPTS; attempt++) {
|
|
149511
|
-
const port = DEVICE_PORT_MIN + (0,
|
|
149954
|
+
const port = DEVICE_PORT_MIN + (0, import_node_crypto13.randomInt)(DEVICE_PORT_SPAN);
|
|
149512
149955
|
try {
|
|
149513
149956
|
await adbReverse(serial, port, hostPort, { timeoutMs: 1e4, noRebind: true });
|
|
149514
149957
|
} catch (err) {
|
|
@@ -149759,7 +150202,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
149759
150202
|
return;
|
|
149760
150203
|
}
|
|
149761
150204
|
agentNonce = payload.nonce;
|
|
149762
|
-
serverNonce = (0,
|
|
150205
|
+
serverNonce = (0, import_node_crypto13.randomBytes)(16).toString("hex");
|
|
149763
150206
|
writeNdjsonFrame(socket, {
|
|
149764
150207
|
type: "Control",
|
|
149765
150208
|
payload: {
|
|
@@ -150121,7 +150564,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150121
150564
|
const req = asObject(p.request);
|
|
150122
150565
|
const startedAt = typeof p.wallTime === "number" ? p.wallTime * 1e3 : typeof p.timestamp === "number" ? p.timestamp * 1e3 : Date.now();
|
|
150123
150566
|
const record2 = {
|
|
150124
|
-
id: `android-${
|
|
150567
|
+
id: `android-${RUN_TAG2}-${nextRecordNumber2++}`,
|
|
150125
150568
|
layer: "android-native",
|
|
150126
150569
|
layerId,
|
|
150127
150570
|
connection: conn.index,
|
|
@@ -150156,7 +150599,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150156
150599
|
const size = recordSize(record2);
|
|
150157
150600
|
recordChars += size - (recordSizes.get(record2) ?? 0);
|
|
150158
150601
|
recordSizes.set(record2, size);
|
|
150159
|
-
while (records.length >
|
|
150602
|
+
while (records.length > MAX_RECORDS || records.length > 1 && recordChars > RECORD_CHARS_BUDGET) {
|
|
150160
150603
|
evict(records.shift());
|
|
150161
150604
|
}
|
|
150162
150605
|
}
|
|
@@ -150391,7 +150834,9 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150391
150834
|
...!conn && note ? { note: shownNote() } : {}
|
|
150392
150835
|
};
|
|
150393
150836
|
},
|
|
150394
|
-
records: (port) => records.filter(
|
|
150837
|
+
records: (port) => records.filter(
|
|
150838
|
+
(r) => !cleared.has(r) && !isMetroTraffic(r.request.url, port, { androidEmulatorHost: true })
|
|
150839
|
+
),
|
|
150395
150840
|
record: (id) => byId.get(id)?.record,
|
|
150396
150841
|
responseBody: (id) => fetchBody(id, "response"),
|
|
150397
150842
|
requestPostData: (id) => fetchBody(id, "post"),
|
|
@@ -150442,14 +150887,14 @@ function readHandshake(payload) {
|
|
|
150442
150887
|
}
|
|
150443
150888
|
function proofMatches(proof, expected) {
|
|
150444
150889
|
if (!isHex2(proof, 64)) return false;
|
|
150445
|
-
return (0,
|
|
150890
|
+
return (0, import_node_crypto13.timingSafeEqual)(Buffer.from(proof, "hex"), Buffer.from(expected, "hex"));
|
|
150446
150891
|
}
|
|
150447
150892
|
function handshakeProof(secret, parts2) {
|
|
150448
|
-
return (0,
|
|
150893
|
+
return (0, import_node_crypto13.createHmac)("sha256", Buffer.from(secret, "ascii")).update(parts2.join("\n"), "utf8").digest("hex");
|
|
150449
150894
|
}
|
|
150450
150895
|
function sessionKeys(agentNonce, serverNonce, secret) {
|
|
150451
|
-
const prk = (0,
|
|
150452
|
-
const expand = (info) => (0,
|
|
150896
|
+
const prk = (0, import_node_crypto13.createHmac)("sha256", Buffer.from(agentNonce + serverNonce, "ascii")).update(Buffer.from(secret, "ascii")).digest();
|
|
150897
|
+
const expand = (info) => (0, import_node_crypto13.createHmac)("sha256", prk).update(Buffer.concat([Buffer.from(info, "ascii"), Buffer.of(1)])).digest();
|
|
150453
150898
|
return {
|
|
150454
150899
|
agent: expand("argent-nwi agent to server"),
|
|
150455
150900
|
server: expand("argent-nwi server to agent")
|
|
@@ -150461,7 +150906,7 @@ function frameIv(counter) {
|
|
|
150461
150906
|
return iv;
|
|
150462
150907
|
}
|
|
150463
150908
|
function sealFrame(key2, counter, frame2) {
|
|
150464
|
-
const cipher = (0,
|
|
150909
|
+
const cipher = (0, import_node_crypto13.createCipheriv)("aes-256-gcm", key2, frameIv(counter), {
|
|
150465
150910
|
authTagLength: GCM_TAG_BYTES
|
|
150466
150911
|
});
|
|
150467
150912
|
return Buffer.concat([
|
|
@@ -150479,7 +150924,7 @@ function openFrame(key2, counter, sealed) {
|
|
|
150479
150924
|
}
|
|
150480
150925
|
let plaintext;
|
|
150481
150926
|
try {
|
|
150482
|
-
const decipher = (0,
|
|
150927
|
+
const decipher = (0, import_node_crypto13.createDecipheriv)("aes-256-gcm", key2, frameIv(counter), {
|
|
150483
150928
|
authTagLength: GCM_TAG_BYTES
|
|
150484
150929
|
});
|
|
150485
150930
|
decipher.setAuthTag(bytes.subarray(bytes.length - GCM_TAG_BYTES));
|
|
@@ -150511,9 +150956,6 @@ function isHex2(value, length) {
|
|
|
150511
150956
|
function isCount(value) {
|
|
150512
150957
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
150513
150958
|
}
|
|
150514
|
-
function isOpen(record2) {
|
|
150515
|
-
return record2.state === "pending" || record2.state === "headers";
|
|
150516
|
-
}
|
|
150517
150959
|
function parseCapture(value) {
|
|
150518
150960
|
const o = asObject(value);
|
|
150519
150961
|
if (o.state !== "active" && o.state !== "waiting" && o.state !== "unavailable") return void 0;
|
|
@@ -150534,16 +150976,6 @@ function agentFiles() {
|
|
|
150534
150976
|
function isAgentAbi(abi) {
|
|
150535
150977
|
return AGENT_ABIS.includes(abi);
|
|
150536
150978
|
}
|
|
150537
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "10.0.2.2", "[::1]"]);
|
|
150538
|
-
function isMetroTraffic(url2, metroPort2) {
|
|
150539
|
-
let parsed2;
|
|
150540
|
-
try {
|
|
150541
|
-
parsed2 = new URL(url2);
|
|
150542
|
-
} catch {
|
|
150543
|
-
return false;
|
|
150544
|
-
}
|
|
150545
|
-
return LOOPBACK_HOSTS.has(parsed2.hostname) && Number(parsed2.port) === metroPort2;
|
|
150546
|
-
}
|
|
150547
150979
|
function toBody(result, kind) {
|
|
150548
150980
|
const r = asObject(result);
|
|
150549
150981
|
const text = kind === "response" ? r.body : r.postData;
|
|
@@ -150562,50 +150994,6 @@ function toBody(result, kind) {
|
|
|
150562
150994
|
function unavailable(reason2) {
|
|
150563
150995
|
return { available: false, body: "", base64Encoded: false, truncated: false, reason: reason2 };
|
|
150564
150996
|
}
|
|
150565
|
-
function capString(value, max = MAX_VALUE_CHARS) {
|
|
150566
|
-
return value.length > max ? `${value.slice(0, max)}\u2026[${value.length - max} more chars]` : value;
|
|
150567
|
-
}
|
|
150568
|
-
function headerMap(value) {
|
|
150569
|
-
const headers = {};
|
|
150570
|
-
let kept = 0;
|
|
150571
|
-
let chars = 0;
|
|
150572
|
-
let left = 0;
|
|
150573
|
-
for (const [name, v] of Object.entries(asObject(value))) {
|
|
150574
|
-
if (typeof v !== "string" && typeof v !== "number" && typeof v !== "boolean") continue;
|
|
150575
|
-
const key2 = capString(name, 1024);
|
|
150576
|
-
const text = capString(String(v));
|
|
150577
|
-
if (kept >= MAX_HEADERS || chars + key2.length + text.length > MAX_HEADER_MAP_CHARS) {
|
|
150578
|
-
left++;
|
|
150579
|
-
continue;
|
|
150580
|
-
}
|
|
150581
|
-
headers[key2] = text;
|
|
150582
|
-
kept++;
|
|
150583
|
-
chars += key2.length + text.length;
|
|
150584
|
-
}
|
|
150585
|
-
if (left > 0) headers["(not kept)"] = `${left} more headers`;
|
|
150586
|
-
return headers;
|
|
150587
|
-
}
|
|
150588
|
-
function mapChars(map2) {
|
|
150589
|
-
let chars = 0;
|
|
150590
|
-
for (const [name, value] of Object.entries(map2 ?? {})) chars += name.length + value.length;
|
|
150591
|
-
return chars;
|
|
150592
|
-
}
|
|
150593
|
-
function recordSize(record2) {
|
|
150594
|
-
let chars = record2.request.url.length + record2.request.method.length + mapChars(record2.request.headers) + mapChars(record2.request.wireHeaders) + (record2.errorText?.length ?? 0) + 256;
|
|
150595
|
-
if (record2.response) {
|
|
150596
|
-
chars += record2.response.url.length + record2.response.statusText.length + record2.response.mimeType.length + mapChars(record2.response.headers);
|
|
150597
|
-
}
|
|
150598
|
-
for (const hop of record2.redirects ?? []) {
|
|
150599
|
-
chars += hop.url.length + hop.statusText.length + mapChars(hop.headers) + mapChars(hop.requestHeaders);
|
|
150600
|
-
}
|
|
150601
|
-
return chars;
|
|
150602
|
-
}
|
|
150603
|
-
function asObject(value) {
|
|
150604
|
-
return typeof value === "object" && value !== null ? value : {};
|
|
150605
|
-
}
|
|
150606
|
-
function asString2(value) {
|
|
150607
|
-
return typeof value === "string" ? value : "";
|
|
150608
|
-
}
|
|
150609
150997
|
function isOwnFailure(err) {
|
|
150610
150998
|
const code = getFailureSignal(err)?.error_code;
|
|
150611
150999
|
return code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_UNKNOWN_PACKAGE || code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_RUN_AS_FAILED || code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_DEVICE_IN_USE || code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_NO_DEVICE_PORT;
|
|
@@ -150766,6 +151154,7 @@ Fails if the simulator server is not running for the given UDID.`,
|
|
|
150766
151154
|
init_zod();
|
|
150767
151155
|
init_src2();
|
|
150768
151156
|
init_device_info();
|
|
151157
|
+
init_external_devices();
|
|
150769
151158
|
|
|
150770
151159
|
// ../tool-server/src/tools/native-devtools/macos-view-hierarchy.ts
|
|
150771
151160
|
init_zod();
|
|
@@ -150931,9 +151320,11 @@ var zodSchema4 = external_exports.object({
|
|
|
150931
151320
|
"App bundle ID on iOS or package name on Android<flag:macos-apps> (on a Mac app, the bundle id in the device id)</flag:macos-apps>"
|
|
150932
151321
|
),
|
|
150933
151322
|
port: metroPortField.describe(
|
|
150934
|
-
"
|
|
151323
|
+
"The app's Metro port, whose requests are left out of the listing. Omit it to use this device's port, 8081 by default.<flag:macos-apps> A Mac app ignores it.</flag:macos-apps>"
|
|
151324
|
+
),
|
|
151325
|
+
limit: external_exports.number().int().nonnegative().optional().default(50).describe(
|
|
151326
|
+
"Maximum number of requests to return: the most recent ones, oldest first. 0 returns only the header and the total.<flag:macos-apps> On a Mac app it counts events, not requests: one request gives several events. 0 returns no events.</flag:macos-apps>"
|
|
150935
151327
|
),
|
|
150936
|
-
limit: external_exports.number().optional().default(50).describe("Maximum number of entries to return: the most recent ones, oldest first"),
|
|
150937
151328
|
clear: external_exports.boolean().optional().default(false).describe(
|
|
150938
151329
|
"Clear the log after reading. On Android, the IDs of cleared requests still work in view-network-request-details"
|
|
150939
151330
|
),
|
|
@@ -150957,15 +151348,17 @@ function createNativeNetworkLogsTool(registry2) {
|
|
|
150957
151348
|
},
|
|
150958
151349
|
description: `Retrieve network requests captured at the native level: NSURLProtocol on iOS, OkHttp on Android.
|
|
150959
151350
|
Use when inspecting native-level HTTP traffic that view-network-logs cannot see: requests that never pass through JS XMLHttpRequest or fetch.
|
|
150960
|
-
On iOS it sees URLSession requests (default and ephemeral session configurations, and URLSession.shared) from native modules and Swift/Objective-C code. It does not see background URLSession transfers, WKWebView, Network.framework, or HTTP stacks that bypass URLSession (e.g. Flutter), so an empty result does not mean the app sent nothing.
|
|
150961
|
-
|
|
150962
|
-
|
|
150963
|
-
|
|
150964
|
-
On a
|
|
150965
|
-
On
|
|
151351
|
+
On iOS it sees URLSession requests (default and ephemeral session configurations, and URLSession.shared) from native modules and Swift/Objective-C code. It does not see background URLSession transfers, WKWebView, Network.framework, or HTTP stacks that bypass URLSession (e.g. Flutter), so an empty result does not mean the app sent nothing.
|
|
151352
|
+
Returns { status, header, armed, count, total, requests }: one line per request, oldest first, with its id (ios-3f9a-12, android-3f9a-12), method, URL, state (pending, headers, complete or failed), status, mimeType, durationMs and errorText. The header says whether capture is armed, how many requests there are and the app's pid once read, and why capture is not armed when it is not. Requests to Metro on \`port\` are left out. The history is kept across relaunches of the app.
|
|
151353
|
+
The first call for an app starts capture, so earlier requests are not captured: repeat the action whose requests you need, then call again.
|
|
151354
|
+
On iOS: the first call waits until the app acknowledges capture. When capture started while the app was already running, the header of the first answer says that the app's launch was not recorded; to capture the launch, restart-app and call again, unless the header says the launch cannot be recorded on that device. Capture stays on for later processes of the app.
|
|
151355
|
+
<flag:macos-apps>On a Mac app: { status, count, events } of NSURLSession requests, react-native-macos fetch included; capture stays on across restart-app, a new log per process.
|
|
151356
|
+
</flag:macos-apps>On iOS: If status is restart_required: follow the message (usually restart-app), then retry. If status is service_stale: the app is already injected, so restarting it cannot help. Restart the tool-server (\`argent server stop && argent server start --detach\`) and retry. If the same status comes back after that restart, stop restarting: follow the message, which names the terminal fallback. If status is connect_pending: the app is injected and still connecting. Do not restart it, wait a few seconds and retry. If status is init_failed: follow the message (re-boot the simulator) rather than retrying.
|
|
151357
|
+
On a device whose devtools agent argent attached to rather than armed itself, only the agent's owner turns capture off; the list starts at argent's connection, not at the first call; a relaunch ends capture and clears the list; a not-connected app fails with \`NATIVE_DEVTOOLS_NOT_CONNECTED\` instead of a status, and no restart on argent's side fixes it. An Apple system app is rejected outright (terminal: never retry it).
|
|
151358
|
+
On Android: needs a debuggable build. The first call usually returns armed: false. Call it again every few seconds until armed is true, then repeat the action whose requests you need.
|
|
150966
151359
|
Capture also misses a request already in flight at the attach and requests from clients other than OkHttp (e.g. HttpURLConnection, Cronet); an app whose OkHttp is fully minified reports capture unavailable.
|
|
150967
|
-
|
|
150968
|
-
Capture can slow the app. It stays on, and launch-app and restart-app attach it to each new process, until a call with stop: true turns it off for this app (stop-all-simulator-servers for the device also does); restart-app then starts the app without the agent. stop: true returns { status, stopped, message }, where stopped is false when capture was not on for the app. On iOS stop: true fails: capture
|
|
151360
|
+
Android results also carry capture and captureDetail. When capture is active, captureDetail and the header can say that only some requests are captured: then an empty or short list does not mean the app sent nothing. Pass an Android request's ID (android-3f9a-12) to view-network-request-details for its headers, redirects and bodies.
|
|
151361
|
+
Capture can slow the app. It stays on, and launch-app and restart-app attach it to each new process, until a call with stop: true turns it off for this app (stop-all-simulator-servers for the device also does); restart-app then starts the app without the agent. stop: true returns { status, stopped, message }, where stopped is false when capture was not on for the app. On iOS stop: true fails: capture ends only with stop-all-simulator-servers for this device or a local simulator shutdown, and in the running process only when the app restarts.
|
|
150969
151362
|
When status is not_attachable, use view-network-logs and do not retry.`,
|
|
150970
151363
|
zodSchema: zodSchema4,
|
|
150971
151364
|
services: (params) => {
|
|
@@ -150993,37 +151386,48 @@ When status is not_attachable, use view-network-logs and do not retry.`,
|
|
|
150993
151386
|
params.bundleId
|
|
150994
151387
|
);
|
|
150995
151388
|
await app.activateNetworkInspection();
|
|
150996
|
-
const
|
|
151389
|
+
const events = params.limit === 0 ? [] : app.networkLog().slice(-params.limit);
|
|
150997
151390
|
if (params.clear) app.clearNetworkLog();
|
|
150998
|
-
return { status: "ok", count:
|
|
151391
|
+
return { status: "ok", count: events.length, events };
|
|
150999
151392
|
}
|
|
151000
151393
|
await ensureDeps(device.platform === "ios-remote" ? ["sim-remote"] : ["xcrun"]);
|
|
151001
151394
|
const api = services.nativeDevtools;
|
|
151002
151395
|
const blocked = await precheckNativeDevtools(api, params.udid, params.bundleId);
|
|
151396
|
+
const arming = api.activateNetworkInspection(params.bundleId);
|
|
151003
151397
|
if (blocked) return blocked;
|
|
151004
|
-
if (!api.isConnected(params.bundleId))
|
|
151005
|
-
|
|
151006
|
-
|
|
151007
|
-
|
|
151008
|
-
|
|
151009
|
-
|
|
151010
|
-
|
|
151011
|
-
|
|
151012
|
-
|
|
151013
|
-
|
|
151014
|
-
|
|
151015
|
-
|
|
151016
|
-
|
|
151017
|
-
|
|
151018
|
-
|
|
151019
|
-
|
|
151020
|
-
|
|
151398
|
+
if (!api.isConnected(params.bundleId)) throw notConnected(api, params.bundleId);
|
|
151399
|
+
await arming;
|
|
151400
|
+
const store = api.networkRecords(params.bundleId);
|
|
151401
|
+
if (!store) throw notConnected(api, params.bundleId);
|
|
151402
|
+
const all = store.records(metroPort({ device_id: params.udid, port: params.port }));
|
|
151403
|
+
const state3 = store.state();
|
|
151404
|
+
const detail = [];
|
|
151405
|
+
if (state3.pid !== void 0) detail.push(`pid ${state3.pid}`);
|
|
151406
|
+
if (state3.note) detail.push(state3.note);
|
|
151407
|
+
if (api.takeCaptureGap(params.bundleId)) detail.push(captureGapNote(api.armsEnv));
|
|
151408
|
+
const listing = listNative("ios-native", all, params.limit, state3.armed, detail);
|
|
151409
|
+
if (params.clear) store.clear();
|
|
151410
|
+
return listing;
|
|
151411
|
+
}
|
|
151412
|
+
};
|
|
151413
|
+
}
|
|
151414
|
+
function notConnected(api, bundleId) {
|
|
151415
|
+
const remedy = api.armsEnv ? `Network capture is on for it and arms once it connects, so call again in a few seconds. Requests made before then are not recorded.` : `Native devtools here are an external provider's agent, which serves only the app that provider chose to lend. ${bundleId} is either not that app or its connection has not landed yet, so no native network log is being captured for it. argent did not launch this process and cannot re-point it, so restarting anything is the provider's call rather than argent's. Retry if the app has just started; otherwise, for a React Native app, read its JavaScript requests with view-network-logs.`;
|
|
151416
|
+
return new FailureError(`Native devtools not connected for bundleId: ${bundleId}. ${remedy}`, {
|
|
151417
|
+
error_code: FAILURE_CODES.NATIVE_DEVTOOLS_NOT_CONNECTED,
|
|
151418
|
+
error_kind: "not_found",
|
|
151419
|
+
failure_area: "tool_server",
|
|
151420
|
+
failure_stage: "native_network_logs_connection"
|
|
151421
|
+
});
|
|
151422
|
+
}
|
|
151423
|
+
function captureGapNote(armsEnv) {
|
|
151424
|
+
return armsEnv ? "capture started while the app was already running, so the requests before that, its launch among them, were not recorded; to capture the launch, restart-app and call again" : "argent connected to the app's agent while the app was running, so the requests before that, its launch among them, were not recorded; on this device a relaunch ends capture, so the launch cannot be recorded here: do not restart the app for it";
|
|
151021
151425
|
}
|
|
151022
151426
|
async function stopAndroidNative(registry2, params) {
|
|
151023
151427
|
const device = resolveDevice(params.udid);
|
|
151024
151428
|
if (device.platform !== "android") {
|
|
151025
151429
|
throw new FailureError(
|
|
151026
|
-
device.platform === "macos" ? "stop applies to Android only. On a Mac app, network capture stays on until stop-all-simulator-servers stops this device's services or the tool-server stops." : "stop applies to Android only. On iOS, network capture stays on for the app until stop-all-simulator-servers stops this device's services and the app restarts.",
|
|
151430
|
+
device.platform === "macos" ? "stop applies to Android only. On a Mac app, network capture stays on until stop-all-simulator-servers stops this device's services or the tool-server stops." : externalClaimForAnyId(device.id) ? "stop applies to Android only. On this simulator the device provider controls network capture: argent does not turn it on or off, so turn it off in the provider." : "stop applies to Android only. On iOS, network capture stays on for the app until stop-all-simulator-servers stops this device's services and the app restarts.",
|
|
151027
151431
|
{
|
|
151028
151432
|
error_code: FAILURE_CODES.NATIVE_NETWORK_LOGS_STOP_UNSUPPORTED,
|
|
151029
151433
|
failure_stage: "native_network_logs_stop",
|
|
@@ -151060,21 +151464,31 @@ async function listAndroidNative(api, params) {
|
|
|
151060
151464
|
const attached = await api.ensureAttached(port);
|
|
151061
151465
|
if (attached?.status === "not_attachable") return attached;
|
|
151062
151466
|
const all = api.records(port);
|
|
151063
|
-
const shown = all.slice(-params.limit);
|
|
151064
|
-
const requests = shown.map(toRequestLine);
|
|
151065
|
-
if (params.clear) api.clear();
|
|
151066
151467
|
const state3 = api.state();
|
|
151067
|
-
const
|
|
151468
|
+
const listing = listNative(
|
|
151469
|
+
"android-native",
|
|
151470
|
+
all,
|
|
151471
|
+
params.limit,
|
|
151472
|
+
state3.armed,
|
|
151473
|
+
headerDetail(state3, attached?.note)
|
|
151474
|
+
);
|
|
151475
|
+
if (params.clear) api.clear();
|
|
151476
|
+
return {
|
|
151477
|
+
...listing,
|
|
151478
|
+
...state3.capture ? { capture: state3.capture.state } : {},
|
|
151479
|
+
...state3.capture?.detail ? { captureDetail: state3.capture.detail } : {}
|
|
151480
|
+
};
|
|
151481
|
+
}
|
|
151482
|
+
function listNative(layer, all, limit, armed, detail) {
|
|
151483
|
+
const shown = limit === 0 ? [] : all.slice(-limit);
|
|
151068
151484
|
const noun = all.length === 1 ? "request" : "requests";
|
|
151069
151485
|
return {
|
|
151070
151486
|
status: "ok",
|
|
151071
|
-
header:
|
|
151072
|
-
armed
|
|
151073
|
-
|
|
151074
|
-
...state3.capture?.detail ? { captureDetail: state3.capture.detail } : {},
|
|
151075
|
-
count: requests.length,
|
|
151487
|
+
header: `${layer}: ${armed ? "armed" : "not armed"}, ${all.length} ${noun}` + (detail.length > 0 ? ` (${detail.join("; ")})` : ""),
|
|
151488
|
+
armed,
|
|
151489
|
+
count: shown.length,
|
|
151076
151490
|
total: all.length,
|
|
151077
|
-
requests
|
|
151491
|
+
requests: shown.map(toRequestLine)
|
|
151078
151492
|
};
|
|
151079
151493
|
}
|
|
151080
151494
|
function headerDetail(state3, callNote) {
|
|
@@ -151478,7 +151892,7 @@ init_device_info();
|
|
|
151478
151892
|
init_external_devices();
|
|
151479
151893
|
|
|
151480
151894
|
// ../tool-server/src/utils/debugger/target-selection.ts
|
|
151481
|
-
var
|
|
151895
|
+
var import_node_crypto14 = require("node:crypto");
|
|
151482
151896
|
init_src2();
|
|
151483
151897
|
init_device_info();
|
|
151484
151898
|
init_external_devices();
|
|
@@ -151501,7 +151915,7 @@ function macosAppBundleIdOf(target) {
|
|
|
151501
151915
|
const vendorIds = trackedMacosAppKind(bundleId) === "catalyst" ? catalystVendorId ? [catalystVendorId] : [] : [""];
|
|
151502
151916
|
for (const vendorId of vendorIds) {
|
|
151503
151917
|
for (const mode of ["fusebox", "legacy"]) {
|
|
151504
|
-
const id = (0,
|
|
151918
|
+
const id = (0, import_node_crypto14.createHash)("sha256").update(`apple-${vendorId}-${bundleId}-${mode}`).digest("hex").slice(0, 40);
|
|
151505
151919
|
if (id === logicalId) return bundleId;
|
|
151506
151920
|
}
|
|
151507
151921
|
}
|
|
@@ -156256,13 +156670,11 @@ var execFileAsync25 = (0, import_node_util25.promisify)(import_node_child_proces
|
|
|
156256
156670
|
function makeIosImpl(registry2) {
|
|
156257
156671
|
return {
|
|
156258
156672
|
requires: ["xcrun"],
|
|
156259
|
-
handler: async (_services, params, device) => {
|
|
156673
|
+
handler: async (_services, params, device, options) => {
|
|
156674
|
+
let nativeDevtools;
|
|
156260
156675
|
if (!externalClaimForAnyId(device.id)) {
|
|
156261
156676
|
const ndRef = nativeDevtoolsRef(device);
|
|
156262
|
-
|
|
156263
|
-
ndRef.urn,
|
|
156264
|
-
ndRef.options
|
|
156265
|
-
);
|
|
156677
|
+
nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
|
|
156266
156678
|
const blocked = await precheckNativeDevtools(nativeDevtools, params.udid);
|
|
156267
156679
|
if (blocked) return blocked;
|
|
156268
156680
|
}
|
|
@@ -156315,7 +156727,18 @@ function makeIosImpl(registry2) {
|
|
|
156315
156727
|
{ cause: err instanceof Error ? err : new Error(String(err)) }
|
|
156316
156728
|
);
|
|
156317
156729
|
}
|
|
156318
|
-
|
|
156730
|
+
const capture = nativeDevtools ? await settleWithin(
|
|
156731
|
+
nativeDevtools.networkCaptureAfterLaunch(params.bundleId),
|
|
156732
|
+
void 0,
|
|
156733
|
+
options?.signal
|
|
156734
|
+
) : void 0;
|
|
156735
|
+
if (capture?.type === "error") throw capture.cause;
|
|
156736
|
+
const networkCapture = capture?.type === "value" ? capture.value : void 0;
|
|
156737
|
+
return {
|
|
156738
|
+
launched: true,
|
|
156739
|
+
bundleId: params.bundleId,
|
|
156740
|
+
...networkCapture ? { networkCapture } : {}
|
|
156741
|
+
};
|
|
156319
156742
|
}
|
|
156320
156743
|
};
|
|
156321
156744
|
}
|
|
@@ -156748,7 +157171,7 @@ function createLaunchAppTool(registry2) {
|
|
|
156748
157171
|
longRunning: true,
|
|
156749
157172
|
description: `Open an installed app, or confirm the running renderer (Chromium).<flag:macos-apps> On a Mac app it starts the app in the background when it does not run, and leaves a running app as it is.</flag:macos-apps>
|
|
156750
157173
|
Use when starting any app; prefer this over tapping home-screen / launcher icons. Also prepares the native-devtools injection before the app starts (iOS and Apple TV).
|
|
156751
|
-
Returns { launched, bundleId, <flag:macos-apps>kind?, appPath?, args?, </flag:macos-apps>note?, networkCapture? }. Fails if the app is not installed on the target device (iOS / Android<flag:harmonyos> / HarmonyOS</flag:harmonyos>). On a physical iPhone this registers the app every other tool acts on; com.apple.springboard and com.apple.Spotlight register without launching. note warns when runner signing is not ready. networkCapture (Android) says whether native network capture followed the launch.<flag:macos-apps>
|
|
157174
|
+
Returns { launched, bundleId, <flag:macos-apps>kind?, appPath?, args?, </flag:macos-apps>note?, networkCapture? }. Fails if the app is not installed on the target device (iOS / Android<flag:harmonyos> / HarmonyOS</flag:harmonyos>). On a physical iPhone this registers the app every other tool acts on; com.apple.springboard and com.apple.Spotlight register without launching. note warns when runner signing is not ready. networkCapture (Android, and local iOS simulators where capture stays on for later processes) says whether native network capture followed the launch.<flag:macos-apps>
|
|
156752
157175
|
For Mac apps, kind is 'catalyst' or 'app'. Check appPath and args to confirm the build and arguments in use. The note can report an already running app or a missing window.</flag:macos-apps>
|
|
156753
157176
|
For Chromium, the app is already running behind a CDP port; this call simply refreshes the cached viewport and acknowledges the bundleId tag. To change the visible route, use \`open-url\`.
|
|
156754
157177
|
|
|
@@ -156800,14 +157223,12 @@ var execFileAsync26 = (0, import_node_util26.promisify)(import_node_child_proces
|
|
|
156800
157223
|
function makeIosImpl2(registry2) {
|
|
156801
157224
|
return {
|
|
156802
157225
|
requires: ["xcrun"],
|
|
156803
|
-
handler: async (_services, params, device) => {
|
|
157226
|
+
handler: async (_services, params, device, options) => {
|
|
156804
157227
|
const { udid, bundleId } = params;
|
|
157228
|
+
let nativeDevtools;
|
|
156805
157229
|
if (!externalClaimForAnyId(device.id)) {
|
|
156806
157230
|
const ndRef = nativeDevtoolsRef(device);
|
|
156807
|
-
|
|
156808
|
-
ndRef.urn,
|
|
156809
|
-
ndRef.options
|
|
156810
|
-
);
|
|
157231
|
+
nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
|
|
156811
157232
|
const blocked = await precheckNativeDevtools(nativeDevtools, udid);
|
|
156812
157233
|
if (blocked) return blocked;
|
|
156813
157234
|
}
|
|
@@ -156852,7 +157273,14 @@ function makeIosImpl2(registry2) {
|
|
|
156852
157273
|
{ cause: err instanceof Error ? err : new Error(String(err)) }
|
|
156853
157274
|
);
|
|
156854
157275
|
}
|
|
156855
|
-
|
|
157276
|
+
const capture = nativeDevtools ? await settleWithin(
|
|
157277
|
+
nativeDevtools.networkCaptureAfterLaunch(bundleId),
|
|
157278
|
+
void 0,
|
|
157279
|
+
options?.signal
|
|
157280
|
+
) : void 0;
|
|
157281
|
+
if (capture?.type === "error") throw capture.cause;
|
|
157282
|
+
const networkCapture = capture?.type === "value" ? capture.value : void 0;
|
|
157283
|
+
return { restarted: true, bundleId, ...networkCapture ? { networkCapture } : {} };
|
|
156856
157284
|
}
|
|
156857
157285
|
};
|
|
156858
157286
|
}
|
|
@@ -157043,7 +157471,7 @@ function createRestartAppTool(registry2) {
|
|
|
157043
157471
|
longRunning: true,
|
|
157044
157472
|
description: `Terminate then relaunch an app on iOS, Android, <flag:harmonyos>HarmonyOS, </flag:harmonyos><flag:macos-apps>macOS, </flag:macos-apps>or Vega.
|
|
157045
157473
|
Use when you need a clean in-memory state without a full reinstall. The relaunch also refreshes the native-devtools injection (iOS and Apple TV).<flag:macos-apps> On a Mac app it quits the app and starts the same .app again in the background.</flag:macos-apps>
|
|
157046
|
-
Returns { restarted, bundleId, <flag:macos-apps>kind?, appPath?, args?, note?, </flag:macos-apps>networkCapture? }. networkCapture (Android) says whether native network capture followed the launch. Fails if the app is not installed, on a local iOS simulator if terminating it does not finish within 15s, or on a remote simulator if terminating it fails for a reason other than the app not running.<flag:macos-apps>
|
|
157474
|
+
Returns { restarted, bundleId, <flag:macos-apps>kind?, appPath?, args?, note?, </flag:macos-apps>networkCapture? }. networkCapture (Android, and local iOS simulators where capture stays on for later processes) says whether native network capture followed the launch. Fails if the app is not installed, on a local iOS simulator if terminating it does not finish within 15s, or on a remote simulator if terminating it fails for a reason other than the app not running.<flag:macos-apps>
|
|
157047
157475
|
For Mac apps, kind is 'catalyst' or 'app'. Check appPath and args to confirm the restarted build and arguments. Check note for warnings such as a force-quit or no window.</flag:macos-apps>`,
|
|
157048
157476
|
zodSchema: zodSchema12,
|
|
157049
157477
|
alwaysLoad: true,
|
|
@@ -161621,7 +162049,7 @@ function missingBundleId() {
|
|
|
161621
162049
|
error_kind: "validation"
|
|
161622
162050
|
});
|
|
161623
162051
|
}
|
|
161624
|
-
function
|
|
162052
|
+
function notConnected2(bundleId) {
|
|
161625
162053
|
return new FailureError(`Native devtools not connected for bundleId: ${bundleId}.`, {
|
|
161626
162054
|
error_code: FAILURE_CODES.NATIVE_DEVTOOLS_NOT_CONNECTED,
|
|
161627
162055
|
failure_stage: "network_conditions_connection",
|
|
@@ -161657,7 +162085,7 @@ var iosImpl5 = {
|
|
|
161657
162085
|
if (conditions || !await isNotRunning(api, bundleId)) {
|
|
161658
162086
|
const blocked = await precheckNativeDevtools(api, params.udid, bundleId);
|
|
161659
162087
|
if (blocked) return blocked;
|
|
161660
|
-
if (!api.isConnected(bundleId)) throw
|
|
162088
|
+
if (!api.isConnected(bundleId)) throw notConnected2(bundleId);
|
|
161661
162089
|
}
|
|
161662
162090
|
const throttle = conditions && {
|
|
161663
162091
|
conditions: toCdpNetworkConditions(conditions),
|
|
@@ -162393,7 +162821,7 @@ init_device_info();
|
|
|
162393
162821
|
init_capability();
|
|
162394
162822
|
|
|
162395
162823
|
// ../tool-server/src/utils/sub-invoke.ts
|
|
162396
|
-
var
|
|
162824
|
+
var import_node_crypto15 = require("node:crypto");
|
|
162397
162825
|
init_src2();
|
|
162398
162826
|
async function invokeSubTool(registry2, ctx, toolId, args, extra) {
|
|
162399
162827
|
const signal = ctx?.signal;
|
|
@@ -162409,7 +162837,7 @@ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
|
|
|
162409
162837
|
if (!recordChildInvocation) {
|
|
162410
162838
|
return signal || Object.keys(forwarded).length > 0 ? registry2.invokeTool(toolId, args, { ...signal ? { signal } : {}, ...forwarded }) : registry2.invokeTool(toolId, args);
|
|
162411
162839
|
}
|
|
162412
|
-
const toolInvocationId = (0,
|
|
162840
|
+
const toolInvocationId = (0, import_node_crypto15.randomUUID)();
|
|
162413
162841
|
const release2 = recordChildInvocation(toolInvocationId, args);
|
|
162414
162842
|
try {
|
|
162415
162843
|
return await registry2.invokeTool(toolId, args, {
|
|
@@ -164319,7 +164747,7 @@ When the debugger cannot be reached, it returns { status: "not_connected", reaso
|
|
|
164319
164747
|
}
|
|
164320
164748
|
|
|
164321
164749
|
// ../tool-server/src/tools/network/network-logs.ts
|
|
164322
|
-
var
|
|
164750
|
+
var import_node_http5 = require("node:http");
|
|
164323
164751
|
init_zod();
|
|
164324
164752
|
var import_bytes3 = __toESM(require_bytes());
|
|
164325
164753
|
init_device_info();
|
|
@@ -164331,7 +164759,7 @@ function formatBytes2(bytes) {
|
|
|
164331
164759
|
return (0, import_bytes3.default)(bytes, { decimalPlaces: 1, unitSeparator: " " }) ?? `${bytes} B`;
|
|
164332
164760
|
}
|
|
164333
164761
|
function reasonPhrase(status) {
|
|
164334
|
-
return
|
|
164762
|
+
return import_node_http5.STATUS_CODES[status] ?? "";
|
|
164335
164763
|
}
|
|
164336
164764
|
function comparableUrl(url2) {
|
|
164337
164765
|
let text = url2;
|
|
@@ -166470,7 +166898,7 @@ init_zod();
|
|
|
166470
166898
|
init_src2();
|
|
166471
166899
|
|
|
166472
166900
|
// ../tool-server/src/utils/debugger/runtime-device.ts
|
|
166473
|
-
var
|
|
166901
|
+
var import_node_crypto16 = require("node:crypto");
|
|
166474
166902
|
var import_node_child_process46 = require("node:child_process");
|
|
166475
166903
|
var import_node_util35 = require("node:util");
|
|
166476
166904
|
init_adb();
|
|
@@ -166483,7 +166911,7 @@ async function findRuntimeDevices(cdp, {
|
|
|
166483
166911
|
awaitSerials = [],
|
|
166484
166912
|
waitSerials = []
|
|
166485
166913
|
} = {}) {
|
|
166486
|
-
const marker = `argent-device-probe:${(0,
|
|
166914
|
+
const marker = `argent-device-probe:${(0, import_node_crypto16.randomUUID)()}`;
|
|
166487
166915
|
const logged = await cdp.evaluate(
|
|
166488
166916
|
`(function () {
|
|
166489
166917
|
if (typeof nativeLoggingHook !== "function") return false;
|
|
@@ -166646,21 +167074,35 @@ function bootstrapFailureMessage(bootstrap) {
|
|
|
166646
167074
|
|
|
166647
167075
|
// ../tool-server/src/utils/profiler-shared/network-capture-warning.ts
|
|
166648
167076
|
var CAPTURE_COST = "It can slow the app, so the timings in this profile can differ from a run without it.";
|
|
167077
|
+
function agentSentence(platform, one, where = "") {
|
|
167078
|
+
return platform === "android" ? `Argent attaches its in-app agent to the processes of ${one ? "that app" : "these apps"}${where}.` : `Argent's in-app agent captures the requests of ${one ? "that app's" : "these apps'"} processes${where}.`;
|
|
167079
|
+
}
|
|
166649
167080
|
function nativeNetworkCaptureWarning(deviceId, runtimeApp, runtimeDevices = { found: [], unresolved: [] }) {
|
|
166650
167081
|
try {
|
|
166651
167082
|
if (runtimeDevices.found.length > 0) {
|
|
166652
167083
|
return foundDeviceWarning(runtimeDevices, runtimeApp);
|
|
166653
167084
|
}
|
|
166654
|
-
|
|
167085
|
+
let platform = "android";
|
|
167086
|
+
let packages = liveAndroidNetworkCaptures(deviceId);
|
|
167087
|
+
if (packages.length === 0) {
|
|
167088
|
+
platform = "ios";
|
|
167089
|
+
packages = liveIosNetworkCaptures(deviceId);
|
|
167090
|
+
}
|
|
166655
167091
|
if (packages.length === 0) return logicalDeviceWarning(deviceId, runtimeApp);
|
|
166656
167092
|
const apps = packages.join(", ");
|
|
166657
167093
|
const one = packages.length === 1;
|
|
166658
|
-
|
|
167094
|
+
const remedy = platform === "android" ? `call native-network-logs with stop: true for ${one ? "that app" : "each of these apps"}` : "call stop-all-simulator-servers for this device";
|
|
167095
|
+
return `Native network capture is on for ${apps} on this device: ${agentSentence(platform, one)} ${CAPTURE_COST} To profile without it, stop this profile, ${remedy}, then restart-app and profile again.`;
|
|
166659
167096
|
} catch {
|
|
166660
167097
|
return void 0;
|
|
166661
167098
|
}
|
|
166662
167099
|
}
|
|
166663
167100
|
function foundDeviceWarning({ found, unresolved }, runtimeApp) {
|
|
167101
|
+
const iosApps = found.length === 1 ? liveIosNetworkCaptures(found[0]) : [];
|
|
167102
|
+
if (iosApps.length > 0) {
|
|
167103
|
+
const [udid] = found;
|
|
167104
|
+
return `Native network capture is on for ${iosApps.join(", ")} on ${udid}, the device this profile runs on: ${agentSentence("ios", iosApps.length === 1)} ${CAPTURE_COST} To profile without it, stop this profile, call stop-all-simulator-servers for ${udid}, then restart-app on ${udid} and profile again.`;
|
|
167105
|
+
}
|
|
166664
167106
|
const captures = found.map((device) => ({ device, packages: liveAndroidNetworkCaptures(device) })).filter(({ packages }) => packages.length > 0);
|
|
166665
167107
|
const appId = runtimeApp?.platform === "android" ? runtimeApp.appId : void 0;
|
|
166666
167108
|
const maybe = appId ? unresolved.filter((serial) => liveAndroidNetworkCaptures(serial).includes(appId)) : [];
|
|
@@ -166690,13 +167132,15 @@ function foundDeviceWarning({ found, unresolved }, runtimeApp) {
|
|
|
166690
167132
|
}
|
|
166691
167133
|
function logicalDeviceWarning(deviceId, runtimeApp) {
|
|
166692
167134
|
const appId = runtimeApp?.appId;
|
|
166693
|
-
|
|
166694
|
-
|
|
166695
|
-
|
|
166696
|
-
const
|
|
166697
|
-
if (
|
|
166698
|
-
const one =
|
|
166699
|
-
|
|
167135
|
+
const platform = runtimeApp?.platform;
|
|
167136
|
+
if (!isLogicalKeyedDevice(deviceId) || !appId) return void 0;
|
|
167137
|
+
if (platform !== "android" && platform !== "ios") return void 0;
|
|
167138
|
+
const devices2 = platform === "android" ? liveAndroidNetworkCaptureDevices(appId) : liveIosNetworkCaptureDevices(appId);
|
|
167139
|
+
if (devices2.length === 0) return void 0;
|
|
167140
|
+
const one = devices2.length === 1;
|
|
167141
|
+
const those = one ? "that device" : "each of those devices";
|
|
167142
|
+
const remedy = platform === "android" ? `call native-network-logs with stop: true for ${appId} on ${those}` : `call stop-all-simulator-servers for ${those}`;
|
|
167143
|
+
return `Native network capture is on for ${appId} on ${devices2.join(", ")}, ${one ? "which" : "one of which"} may be the device this profile runs on: its device_id is a Metro logicalDeviceId, which does not say which device it is. ${agentSentence(platform, true, " there")} ${CAPTURE_COST} To profile without it, stop this profile, ${remedy}, then restart-app and profile again.`;
|
|
166700
167144
|
}
|
|
166701
167145
|
|
|
166702
167146
|
// ../tool-server/src/tools/profiler/react/react-profiler-start.ts
|
|
@@ -166785,7 +167229,7 @@ function createReactProfilerStartTool(registry2) {
|
|
|
166785
167229
|
description: `Record Hermes CPU samples and React commits during an interaction.<flag:macos-apps> For a Mac app, use a Debug build that loads JavaScript from Metro: react-native-macos 0.76+, or React Native built for Mac Catalyst. The profiler connects without debugger-connect.</flag:macos-apps>
|
|
166786
167230
|
On an iOS simulator, Android device<flag:macos-apps>, or Mac app</flag:macos-apps>, call native-profiler-start in parallel on the same target for a combined report, unless the user declines native profiling.
|
|
166787
167231
|
After starting, ask the user to perform the interaction to profile, then call react-profiler-stop.
|
|
166788
|
-
Returns { started_at, startedAtEpochMs, hermes_version, detected_architecture }. On Android, a warning names the apps with native network capture on (started by native-network-logs): their timings in the profile can differ. If a session is already running, returns { already_running: true, mine, owner, \u2026 } instead, without clobbering its data, unless it is another tool-server's stale run, has no owner record, or is a lost run of this tool-server: start replaces those. mine: true means this tool-server started the run: if it is yours, call react-profiler-stop. With stale: true it may be another agent's: follow the note. Otherwise, BEFORE OVERTAKING with { force: true }, ask the user for approval first, as how_to_reclaim explains. A start that replaces a run reports it in took_over.
|
|
167232
|
+
Returns { started_at, startedAtEpochMs, hermes_version, detected_architecture }. On iOS and Android, a warning names the apps with native network capture on (started by native-network-logs): their timings in the profile can differ. If a session is already running, returns { already_running: true, mine, owner, \u2026 } instead, without clobbering its data, unless it is another tool-server's stale run, has no owner record, or is a lost run of this tool-server: start replaces those. mine: true means this tool-server started the run: if it is yours, call react-profiler-stop. With stale: true it may be another agent's: follow the note. Otherwise, BEFORE OVERTAKING with { force: true }, ask the user for approval first, as how_to_reclaim explains. A start that replaces a run reports it in took_over.
|
|
166789
167233
|
Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot be established.`,
|
|
166790
167234
|
zodSchema: zodSchema45,
|
|
166791
167235
|
interaction: {
|
|
@@ -175134,7 +175578,7 @@ var nativeProfilerStartTool = {
|
|
|
175134
175578
|
longRunning: true,
|
|
175135
175579
|
description: `Start native profiling. Instruments records CPU, hangs, and leaks on iOS<flag:macos-apps> and Mac apps</flag:macos-apps>. Perfetto records CPU, jank, and memory growth on Android.
|
|
175136
175580
|
Start the target app first for an attach recording. Wait for this call to return before reproducing the scenario, then call native-profiler-stop while the app is still running.
|
|
175137
|
-
On Android, a warning names apps whose timings may be affected by native network capture.<flag:macos-apps> On a Mac app, a warning says when the app runs with malloc stack logging. Launch the app through Argent and use a development-signed build. If signing blocks profiling in a background session such as SSH, try the "Time Profiler" template for CPU and hangs without leak checks.
|
|
175581
|
+
On iOS and Android, a warning names apps whose timings may be affected by native network capture.<flag:macos-apps> On a Mac app, a warning says when the app runs with malloc stack logging. Launch the app through Argent and use a development-signed build. If signing blocks profiling in a background session such as SSH, try the "Time Profiler" template for CPU and hangs without leak checks.
|
|
175138
175582
|
With malloc stack logging off, Argent blocks the bundled template if it detects a WebKit heap or the check fails. Use "Time Profiler" to keep the app's state, or set malloc_stack_logging to true to restart the app and record leaks with the bundled template. With logging off, other templates that use the Allocations instrument, including "Leaks" and "Allocations", can freeze an affected app.</flag:macos-apps>`,
|
|
175139
175583
|
zodSchema: zodSchema53,
|
|
175140
175584
|
interaction: {
|
|
@@ -175159,6 +175603,7 @@ With malloc stack logging off, Argent blocks the bundled template if it detects
|
|
|
175159
175603
|
if (api.platform === "ios") {
|
|
175160
175604
|
await ensureDeps(["xcrun"]);
|
|
175161
175605
|
started = await startNativeProfilerIos(api, params);
|
|
175606
|
+
warning = nativeNetworkCaptureWarning(params.device_id);
|
|
175162
175607
|
} else if (api.platform === "macos") {
|
|
175163
175608
|
await ensureDeps(["xcrun"]);
|
|
175164
175609
|
({ warning, ...started } = await startNativeProfilerMacos(
|
|
@@ -175313,7 +175758,7 @@ var import_node_child_process48 = require("node:child_process");
|
|
|
175313
175758
|
var import_node_util38 = require("node:util");
|
|
175314
175759
|
var fsp5 = __toESM(require("node:fs/promises"));
|
|
175315
175760
|
var path49 = __toESM(require("node:path"));
|
|
175316
|
-
var
|
|
175761
|
+
var import_node_crypto17 = require("node:crypto");
|
|
175317
175762
|
init_src2();
|
|
175318
175763
|
|
|
175319
175764
|
// ../tool-server/src/utils/ios-launch-time/workflow.ts
|
|
@@ -175896,7 +176341,7 @@ async function measurePreparedLaunch(context2, ctx) {
|
|
|
175896
176341
|
const runnerSigning = context2.simulator ? null : await resolveRunnerSigningConfig(context2.deviceId);
|
|
175897
176342
|
const runnerBundleId = runnerSigning?.appBundleId ?? "com.argent.runner.tsimulator";
|
|
175898
176343
|
const testBundleId = runnerSigning?.testBundleId ?? `${runnerBundleId}.uitests`;
|
|
175899
|
-
const runnerBuildKey = (0,
|
|
176344
|
+
const runnerBuildKey = (0, import_node_crypto17.createHash)("sha256").update(
|
|
175900
176345
|
[
|
|
175901
176346
|
// Builds for two simulators, or two iPhones, are the same build.
|
|
175902
176347
|
context2.simulator ? "iOS Simulator" : "iOS",
|
|
@@ -176035,7 +176480,7 @@ async function measurePreparedLaunch(context2, ctx) {
|
|
|
176035
176480
|
|
|
176036
176481
|
// ../tool-server/src/tools/profiler/native-profiler/launch-analysis/profile.ts
|
|
176037
176482
|
var import_node_child_process49 = require("node:child_process");
|
|
176038
|
-
var
|
|
176483
|
+
var import_node_crypto18 = require("node:crypto");
|
|
176039
176484
|
var import_node_util39 = require("node:util");
|
|
176040
176485
|
var fsp6 = __toESM(require("node:fs/promises"));
|
|
176041
176486
|
var path50 = __toESM(require("node:path"));
|
|
@@ -176283,7 +176728,7 @@ var TABLE_XPATH = (schema) => `/trace-toc/run[@number="1"]/data/table[@schema="$
|
|
|
176283
176728
|
async function writeProfilerSession(xml) {
|
|
176284
176729
|
const debugDir = await getDebugDir();
|
|
176285
176730
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace("T", "-").slice(0, 15);
|
|
176286
|
-
const sessionId = `${timestamp}-launch-${(0,
|
|
176731
|
+
const sessionId = `${timestamp}-launch-${(0, import_node_crypto18.randomUUID)()}`;
|
|
176287
176732
|
const cpuXmlPath = path50.join(debugDir, `native-profiler-${sessionId}_raw_cpu.xml`);
|
|
176288
176733
|
await fsp6.writeFile(cpuXmlPath, xml, { flag: "wx" });
|
|
176289
176734
|
return { sessionId, cpuXmlPath };
|
|
@@ -176623,7 +177068,7 @@ init_zod();
|
|
|
176623
177068
|
var import_node_child_process50 = require("node:child_process");
|
|
176624
177069
|
var fs62 = __toESM(require("node:fs"));
|
|
176625
177070
|
var path51 = __toESM(require("node:path"));
|
|
176626
|
-
var
|
|
177071
|
+
var import_node_crypto19 = require("node:crypto");
|
|
176627
177072
|
var import_node_util40 = require("node:util");
|
|
176628
177073
|
init_src2();
|
|
176629
177074
|
init_capability();
|
|
@@ -176839,7 +177284,7 @@ async function setAudioInput(session, source) {
|
|
|
176839
177284
|
} else {
|
|
176840
177285
|
removeFiles(dir, `in-${process.pid}-`);
|
|
176841
177286
|
feeder = new InputFeeder(
|
|
176842
|
-
path51.join(dir, `in-${process.pid}-${(0,
|
|
177287
|
+
path51.join(dir, `in-${process.pid}-${(0, import_node_crypto19.randomUUID)().slice(0, 8)}.ring`),
|
|
176843
177288
|
feederSource
|
|
176844
177289
|
);
|
|
176845
177290
|
feeder.start();
|
|
@@ -189166,7 +189611,7 @@ init_device_info();
|
|
|
189166
189611
|
init_capability();
|
|
189167
189612
|
|
|
189168
189613
|
// ../tool-server/src/tools/flows/flow-visual.ts
|
|
189169
|
-
var
|
|
189614
|
+
var import_node_crypto20 = require("node:crypto");
|
|
189170
189615
|
var fs79 = __toESM(require("node:fs/promises"));
|
|
189171
189616
|
var os25 = __toESM(require("node:os"));
|
|
189172
189617
|
var path65 = __toESM(require("node:path"));
|
|
@@ -191290,7 +191735,7 @@ async function runSnapshot(env, opts) {
|
|
|
191290
191735
|
});
|
|
191291
191736
|
let captureWarned = shot.warning !== void 0 ? { warning: shot.warning } : {};
|
|
191292
191737
|
const { w, h } = await pngDimensions(shot.image.hostPath);
|
|
191293
|
-
const cropSuffix = opts.cropOn === void 0 ? "" : `-crop-${(0,
|
|
191738
|
+
const cropSuffix = opts.cropOn === void 0 ? "" : `-crop-${(0, import_node_crypto20.createHash)("sha256").update(cropIdentity(opts.cropOn)).digest("hex").slice(0, 8)}`;
|
|
191294
191739
|
const keyFor = (width, height) => `${opts.name}__${authoringPlatform(env.device.platform)}-${width}x${height}${cropSuffix}`;
|
|
191295
191740
|
const baselineFor = (file2) => opts.clientFlowPath === void 0 ? path65.join(baselineDir(opts.flowsDir, opts.flowName), file2) : clientBaselinePath(opts.clientFlowPath, opts.flowName, file2);
|
|
191296
191741
|
const snapshotKey = keyFor(w, h);
|
|
@@ -191637,7 +192082,7 @@ var FOREGROUND_CHANGING_TOOLS = /* @__PURE__ */ new Set([
|
|
|
191637
192082
|
"open-url",
|
|
191638
192083
|
"button"
|
|
191639
192084
|
]);
|
|
191640
|
-
async function waitForNativeDevtools(registry2, device, bundleId, signal) {
|
|
192085
|
+
async function waitForNativeDevtools(registry2, device, bundleId, signal, relaunchedAt) {
|
|
191641
192086
|
let api;
|
|
191642
192087
|
try {
|
|
191643
192088
|
const ref = nativeDevtoolsRef(device);
|
|
@@ -191656,23 +192101,27 @@ async function waitForNativeDevtools(registry2, device, bundleId, signal) {
|
|
|
191656
192101
|
if (!isInjectableBundleId(bundleId)) return null;
|
|
191657
192102
|
const state3 = await api.appConnectionState(bundleId).catch(() => "indeterminate");
|
|
191658
192103
|
if (state3 === "connected") return null;
|
|
191659
|
-
return flowLaunchGateReason(
|
|
192104
|
+
return flowLaunchGateReason(
|
|
192105
|
+
bundleId,
|
|
192106
|
+
state3,
|
|
192107
|
+
relaunchedAt === void 0 ? void 0 : Date.now() - relaunchedAt
|
|
192108
|
+
);
|
|
191660
192109
|
}
|
|
191661
|
-
function flowLaunchGateReason(bundleId, state3) {
|
|
192110
|
+
function flowLaunchGateReason(bundleId, state3, spentMs = LAUNCH_TO_VERDICT_MS) {
|
|
191662
192111
|
const measured = buildAppStateMessage(bundleId, state3);
|
|
191663
192112
|
switch (state3) {
|
|
191664
192113
|
case "not_running":
|
|
191665
|
-
return `${bundleId} was relaunched by this step and is no longer running ${
|
|
192114
|
+
return `${bundleId} was relaunched by this step and is no longer running ${spentMs} ms later, so it exited after launch rather than failing to connect. Re-running the e2e test repeats the same launch: start it by hand (launch-app, then describe or screenshot) to see the crash or early exit first.`;
|
|
191666
192115
|
case "stale_process":
|
|
191667
192116
|
return `${measured} This step already relaunched it, so the process it measured predates whatever the relaunch would have given it \u2014 re-run the e2e test to launch again. If it lands here twice, the simulator's launchd environment is not holding argent's instrumentation: re-boot the device (boot-device with force) before re-running.`;
|
|
191668
192117
|
case "unregistered":
|
|
191669
|
-
return `${measured} A cold start slower than the ${
|
|
192118
|
+
return `${measured} A cold start slower than the ${spentMs} ms this step waited reads the same way \u2014 if that is likely, re-run the e2e test to relaunch and wait again before restarting anything.`;
|
|
191670
192119
|
case "connecting":
|
|
191671
|
-
return `${measured} This step launched it ${
|
|
192120
|
+
return `${measured} This step launched it ${spentMs} ms before that reading, so the process being measured started after the step's own launch \u2014 something relaunched it in between. Re-run the e2e test once the app is settled.`;
|
|
191672
192121
|
case "indeterminate":
|
|
191673
192122
|
return `${measured} This step already performed that one restart, so re-run the e2e test at most once more before restarting the tool-server rather than the app.`;
|
|
191674
192123
|
case "provider_attached":
|
|
191675
|
-
return `${measured} This step already waited ${
|
|
192124
|
+
return `${measured} This step already waited ${spentMs} ms after launching it, so the provider is lending a different app rather than one still connecting. Re-run the e2e test only once it is lending this one; otherwise drive the app by coordinate.`;
|
|
191676
192125
|
}
|
|
191677
192126
|
}
|
|
191678
192127
|
async function waitForVegaAutomation(device, signal) {
|
|
@@ -191700,7 +192149,7 @@ async function androidDevtoolsReady(registry2, device) {
|
|
|
191700
192149
|
return { ready: false, reason: err instanceof Error ? err.message : String(err) };
|
|
191701
192150
|
}
|
|
191702
192151
|
}
|
|
191703
|
-
async function treeSourceGate(registry2, device, bundleId, signal) {
|
|
192152
|
+
async function treeSourceGate(registry2, device, bundleId, signal, relaunchedAt) {
|
|
191704
192153
|
if (isIosPhysicalDevice(device) && !signal?.aborted) {
|
|
191705
192154
|
try {
|
|
191706
192155
|
const ref = iosDeviceRunnerRef(device);
|
|
@@ -191711,7 +192160,7 @@ async function treeSourceGate(registry2, device, bundleId, signal) {
|
|
|
191711
192160
|
}
|
|
191712
192161
|
}
|
|
191713
192162
|
if ((device.platform === "ios" || device.platform === "ios-remote") && !signal?.aborted) {
|
|
191714
|
-
const reason2 = await waitForNativeDevtools(registry2, device, bundleId, signal);
|
|
192163
|
+
const reason2 = await waitForNativeDevtools(registry2, device, bundleId, signal, relaunchedAt);
|
|
191715
192164
|
if (reason2 !== null && !signal?.aborted) {
|
|
191716
192165
|
return `could not connect to native devtools. ${reason2}`;
|
|
191717
192166
|
}
|
|
@@ -191761,6 +192210,7 @@ async function runLaunch(state3, app) {
|
|
|
191761
192210
|
const key2 = authoringPlatform(device.platform);
|
|
191762
192211
|
const launchArgs = key2 === "ios" ? appLaunchArgs(app, "ios") : key2 === "macos" ? appLaunchArgs(app, "macos") ?? [] : void 0;
|
|
191763
192212
|
let restart;
|
|
192213
|
+
const relaunchedAt = Date.now();
|
|
191764
192214
|
try {
|
|
191765
192215
|
restart = await invokeOnDevice(env, "restart-app", {
|
|
191766
192216
|
bundleId,
|
|
@@ -191775,7 +192225,7 @@ async function runLaunch(state3, app) {
|
|
|
191775
192225
|
}
|
|
191776
192226
|
refreshMacosDeviceKind(state3);
|
|
191777
192227
|
if (!await sleepOrAbort(POST_LAUNCH_SETTLE_MS, signal)) return ABORTED_OUTCOME;
|
|
191778
|
-
const gate = await treeSourceGate(registry2, device, bundleId, signal);
|
|
192228
|
+
const gate = await treeSourceGate(registry2, device, bundleId, signal, relaunchedAt);
|
|
191779
192229
|
if (signal?.aborted) return ABORTED_OUTCOME;
|
|
191780
192230
|
if (gate) return { ok: false, reason: gate };
|
|
191781
192231
|
state3.treeTarget = { bundleId, pinned: true, probeAnswered: false };
|
|
@@ -193848,7 +194298,7 @@ var dismissUpdateTool = {
|
|
|
193848
194298
|
};
|
|
193849
194299
|
|
|
193850
194300
|
// ../tool-server/src/tools/screenshot-diff/index.ts
|
|
193851
|
-
var
|
|
194301
|
+
var import_node_crypto21 = __toESM(require("node:crypto"));
|
|
193852
194302
|
var import_promises23 = __toESM(require("fs/promises"));
|
|
193853
194303
|
var import_node_os18 = __toESM(require("node:os"));
|
|
193854
194304
|
var import_path9 = __toESM(require("path"));
|
|
@@ -194004,7 +194454,7 @@ async function resolveOutputDir(params, options) {
|
|
|
194004
194454
|
const dir = import_path9.default.join(
|
|
194005
194455
|
import_node_os18.default.tmpdir(),
|
|
194006
194456
|
"argent-screenshot-diff",
|
|
194007
|
-
|
|
194457
|
+
import_node_crypto21.default.randomBytes(6).toString("hex")
|
|
194008
194458
|
);
|
|
194009
194459
|
await import_promises23.default.mkdir(dir, { recursive: true });
|
|
194010
194460
|
return dir;
|
|
@@ -194109,7 +194559,7 @@ async function captureIosDeviceLiveInput(params) {
|
|
|
194109
194559
|
return writeLivePng(params.outputDir, params.name, png);
|
|
194110
194560
|
}
|
|
194111
194561
|
async function writeLivePng(outputDir, name, png) {
|
|
194112
|
-
const suffix =
|
|
194562
|
+
const suffix = import_node_crypto21.default.randomBytes(4).toString("hex");
|
|
194113
194563
|
const destination = import_path9.default.join(outputDir, `${name}-${suffix}.live.png`);
|
|
194114
194564
|
await import_promises23.default.mkdir(outputDir, { recursive: true });
|
|
194115
194565
|
await import_promises23.default.writeFile(destination, png);
|
|
@@ -194127,7 +194577,7 @@ async function captureHarmonyLiveInput(params) {
|
|
|
194127
194577
|
}
|
|
194128
194578
|
await ensureDep("hdc");
|
|
194129
194579
|
const captured = await captureHarmonyScreenshotPng({ connectKey: params.connectKey, scale: 1 });
|
|
194130
|
-
const suffix =
|
|
194580
|
+
const suffix = import_node_crypto21.default.randomBytes(4).toString("hex");
|
|
194131
194581
|
const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
|
|
194132
194582
|
try {
|
|
194133
194583
|
await import_promises23.default.mkdir(params.outputDir, { recursive: true });
|
|
@@ -194150,7 +194600,7 @@ async function captureLiveInput(params) {
|
|
|
194150
194600
|
captureScreenshot2,
|
|
194151
194601
|
params.peekFor?.(params.device)
|
|
194152
194602
|
);
|
|
194153
|
-
const suffix =
|
|
194603
|
+
const suffix = import_node_crypto21.default.randomBytes(4).toString("hex");
|
|
194154
194604
|
const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
|
|
194155
194605
|
await import_promises23.default.mkdir(params.outputDir, { recursive: true });
|
|
194156
194606
|
await import_promises23.default.copyFile(capture.path, destination);
|