@swmansion/argent 0.34.1-next.41 → 0.34.1-next.43
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 +1 -1
- package/dist/installer.mjs +1 -1
- package/dist/tool-args.generated.d.ts +5 -5
- package/dist/tool-server.cjs +1096 -349
- 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.43";
|
|
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,533 @@ 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
|
+
init_src2();
|
|
124525
|
+
|
|
124526
|
+
// ../tool-server/src/utils/keyed-lock.ts
|
|
124527
|
+
async function withKeyedLock(locks, key2, fn) {
|
|
124528
|
+
const previous = locks.get(key2) ?? Promise.resolve();
|
|
124529
|
+
const run2 = previous.then(() => fn());
|
|
124530
|
+
const held = run2.catch(() => {
|
|
124531
|
+
});
|
|
124532
|
+
locks.set(key2, held);
|
|
124533
|
+
void held.then(() => {
|
|
124534
|
+
if (locks.get(key2) === held) locks.delete(key2);
|
|
124535
|
+
});
|
|
124536
|
+
return run2;
|
|
124537
|
+
}
|
|
124538
|
+
|
|
124539
|
+
// ../tool-server/src/utils/debugger/device-alias.ts
|
|
124540
|
+
var logicalIdToConnectId = /* @__PURE__ */ new Map();
|
|
124541
|
+
function rememberDeviceAlias(logicalDeviceId, connectDeviceId) {
|
|
124542
|
+
if (!logicalDeviceId || logicalDeviceId === connectDeviceId) return;
|
|
124543
|
+
logicalIdToConnectId.set(logicalDeviceId, connectDeviceId);
|
|
124544
|
+
}
|
|
124545
|
+
function canonicalDeviceId(deviceId) {
|
|
124546
|
+
if (!deviceId) return deviceId;
|
|
124547
|
+
return logicalIdToConnectId.get(deviceId) ?? deviceId;
|
|
124548
|
+
}
|
|
124549
|
+
function deviceIdsOf(deviceId) {
|
|
124550
|
+
const connectId = canonicalDeviceId(deviceId) ?? deviceId;
|
|
124551
|
+
const logicalIds = [...logicalIdToConnectId].filter(([, aliased]) => aliased === connectId).map(([logicalId]) => logicalId);
|
|
124552
|
+
return [.../* @__PURE__ */ new Set([deviceId, connectId, ...logicalIds])];
|
|
124553
|
+
}
|
|
124554
|
+
function forgetDeviceAlias(logicalDeviceId) {
|
|
124555
|
+
if (logicalDeviceId) logicalIdToConnectId.delete(logicalDeviceId);
|
|
124556
|
+
}
|
|
124557
|
+
var logicalKeyedConnectIds = /* @__PURE__ */ new Set();
|
|
124558
|
+
function rememberLogicalKeyedDevice(logicalDeviceId, connectDeviceId) {
|
|
124559
|
+
if (logicalDeviceId && logicalDeviceId === connectDeviceId) {
|
|
124560
|
+
logicalKeyedConnectIds.add(connectDeviceId.toLowerCase());
|
|
124561
|
+
}
|
|
124562
|
+
}
|
|
124563
|
+
function isLogicalKeyedDevice(deviceId) {
|
|
124564
|
+
return deviceId !== void 0 && logicalKeyedConnectIds.has(deviceId.toLowerCase());
|
|
124565
|
+
}
|
|
124566
|
+
function forgetLogicalKeyedDevice(connectDeviceId) {
|
|
124567
|
+
logicalKeyedConnectIds.delete(connectDeviceId.toLowerCase());
|
|
124568
|
+
}
|
|
124569
|
+
|
|
124570
|
+
// ../tool-server/src/utils/native-network-record.ts
|
|
124571
|
+
init_external_devices();
|
|
124572
|
+
function deviceKeyOf(deviceId) {
|
|
124573
|
+
return externalNativeId(canonicalDeviceId(deviceId) ?? deviceId);
|
|
124574
|
+
}
|
|
124575
|
+
var MAX_RECORDS = 2e3;
|
|
124576
|
+
var RECORD_CHARS_BUDGET = 32 * 1024 * 1024;
|
|
124577
|
+
var MAX_VALUE_CHARS = 64 * 1024;
|
|
124578
|
+
var MAX_HEADERS = 256;
|
|
124579
|
+
var MAX_HEADER_MAP_CHARS = 256 * 1024;
|
|
124580
|
+
var MAX_LAYER_ID_CHARS = 200;
|
|
124581
|
+
var MAX_CACHED_BODIES = 64;
|
|
124582
|
+
var NOT_RECONNECTED = "the agent did not reconnect after its connection dropped, so this request's final events never arrived";
|
|
124583
|
+
var PROCESS_ENDED = "the app process ended before the request finished";
|
|
124584
|
+
var PROCESS_GONE = "the app process that made the request is gone";
|
|
124585
|
+
function isOpen(record2) {
|
|
124586
|
+
return record2.state === "pending" || record2.state === "headers";
|
|
124587
|
+
}
|
|
124588
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
124589
|
+
var ANDROID_EMULATOR_HOST = "10.0.2.2";
|
|
124590
|
+
var DEFAULT_PORTS = {
|
|
124591
|
+
"http:": 80,
|
|
124592
|
+
"ws:": 80,
|
|
124593
|
+
"https:": 443,
|
|
124594
|
+
"wss:": 443
|
|
124595
|
+
};
|
|
124596
|
+
function isMetroTraffic(url2, metroPort2, { androidEmulatorHost = false } = {}) {
|
|
124597
|
+
let parsed2;
|
|
124598
|
+
try {
|
|
124599
|
+
parsed2 = new URL(url2);
|
|
124600
|
+
} catch {
|
|
124601
|
+
return false;
|
|
124602
|
+
}
|
|
124603
|
+
const port = parsed2.port === "" ? DEFAULT_PORTS[parsed2.protocol] : Number(parsed2.port);
|
|
124604
|
+
const host = parsed2.hostname;
|
|
124605
|
+
const isHost = LOOPBACK_HOSTS.has(host) || androidEmulatorHost && host === ANDROID_EMULATOR_HOST;
|
|
124606
|
+
return isHost && port === metroPort2;
|
|
124607
|
+
}
|
|
124608
|
+
function capString(value, max = MAX_VALUE_CHARS) {
|
|
124609
|
+
return value.length > max ? `${value.slice(0, max)}\u2026[${value.length - max} more chars]` : value;
|
|
124610
|
+
}
|
|
124611
|
+
function headerMap(value) {
|
|
124612
|
+
const headers = {};
|
|
124613
|
+
let kept = 0;
|
|
124614
|
+
let chars = 0;
|
|
124615
|
+
let left = 0;
|
|
124616
|
+
for (const [name, v] of Object.entries(asObject(value))) {
|
|
124617
|
+
if (typeof v !== "string" && typeof v !== "number" && typeof v !== "boolean") continue;
|
|
124618
|
+
const key2 = capString(name, 1024);
|
|
124619
|
+
const text = capString(String(v));
|
|
124620
|
+
if (kept >= MAX_HEADERS || chars + key2.length + text.length > MAX_HEADER_MAP_CHARS) {
|
|
124621
|
+
left++;
|
|
124622
|
+
continue;
|
|
124623
|
+
}
|
|
124624
|
+
headers[key2] = text;
|
|
124625
|
+
kept++;
|
|
124626
|
+
chars += key2.length + text.length;
|
|
124627
|
+
}
|
|
124628
|
+
if (left > 0) headers["(not kept)"] = `${left} more headers`;
|
|
124629
|
+
return headers;
|
|
124630
|
+
}
|
|
124631
|
+
function mapChars(map2) {
|
|
124632
|
+
let chars = 0;
|
|
124633
|
+
for (const [name, value] of Object.entries(map2 ?? {})) chars += name.length + value.length;
|
|
124634
|
+
return chars;
|
|
124635
|
+
}
|
|
124636
|
+
function recordSize(record2) {
|
|
124637
|
+
let chars = record2.request.url.length + record2.request.method.length + mapChars(record2.request.headers) + mapChars(record2.request.wireHeaders) + (record2.errorText?.length ?? 0) + 256;
|
|
124638
|
+
if (record2.response) {
|
|
124639
|
+
chars += record2.response.url.length + record2.response.statusText.length + record2.response.mimeType.length + mapChars(record2.response.headers);
|
|
124640
|
+
}
|
|
124641
|
+
for (const hop of record2.redirects ?? []) {
|
|
124642
|
+
chars += hop.url.length + hop.statusText.length + mapChars(hop.headers) + mapChars(hop.requestHeaders);
|
|
124643
|
+
}
|
|
124644
|
+
return chars;
|
|
124645
|
+
}
|
|
124646
|
+
function toBody(result, kind) {
|
|
124647
|
+
const r = asObject(result);
|
|
124648
|
+
const text = kind === "response" ? r.body : r.postData;
|
|
124649
|
+
if (r.bodyAvailable === false || typeof text !== "string") {
|
|
124650
|
+
return unavailable(
|
|
124651
|
+
kind === "response" ? "the agent holds no body for this response" : "the agent holds no body for this request"
|
|
124652
|
+
);
|
|
124653
|
+
}
|
|
124654
|
+
const incomplete = kind === "post" && r.incomplete === true;
|
|
124655
|
+
return {
|
|
124656
|
+
available: true,
|
|
124657
|
+
body: text,
|
|
124658
|
+
base64Encoded: r.base64Encoded === true,
|
|
124659
|
+
truncated: r.wasTruncated === true || incomplete,
|
|
124660
|
+
...incomplete ? { incomplete } : {}
|
|
124661
|
+
};
|
|
124662
|
+
}
|
|
124663
|
+
function unavailable(reason2) {
|
|
124664
|
+
return { available: false, body: "", base64Encoded: false, truncated: false, reason: reason2 };
|
|
124665
|
+
}
|
|
124666
|
+
function asObject(value) {
|
|
124667
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
124668
|
+
}
|
|
124669
|
+
function asString2(value) {
|
|
124670
|
+
return typeof value === "string" ? value : "";
|
|
124671
|
+
}
|
|
124672
|
+
|
|
124673
|
+
// ../tool-server/src/blueprints/ios-network-records.ts
|
|
124674
|
+
var RUN_TAG = (0, import_node_crypto7.randomBytes)(2).toString("hex");
|
|
124675
|
+
var IOS_NATIVE_REQUEST_ID = /^ios-[0-9a-f]{4}-\d+$/;
|
|
124676
|
+
var nextRecordNumber = 1;
|
|
124677
|
+
var POST_DATA_WAIT_MS = 5e3;
|
|
124678
|
+
var POST_DATA_TIMEOUT_MS = 2 ** 31 - 1;
|
|
124679
|
+
var RESPONSE_BODY_TIMEOUT_MS = 1e4;
|
|
124680
|
+
var KEPT_BODY_CHARS_BUDGET = 64 * 1024 * 1024;
|
|
124681
|
+
var STILL_SENDING = "the app may still be sending this request body; read it again after the request ends";
|
|
124682
|
+
var NO_ANSWER = `the app did not answer within ${POST_DATA_WAIT_MS / 1e3} s; read it again later`;
|
|
124683
|
+
var NO_EARLIER_ANSWER = `the app did not answer an earlier body read within ${RESPONSE_BODY_TIMEOUT_MS / 1e3} s; read it again later`;
|
|
124684
|
+
var CONNECTION_CLOSED = "the agent's connection closed before this body was read";
|
|
124685
|
+
var REQUEST_BODY_GONE = "the agent holds no body for this request";
|
|
124686
|
+
var BODY_NO_LONGER_HELD = "the agent no longer holds this body";
|
|
124687
|
+
var NO_RESPONSE_BODY = "the response has no body";
|
|
124688
|
+
function createIosNetworkRecords(state3, link) {
|
|
124689
|
+
const records = [];
|
|
124690
|
+
let recordChars = 0;
|
|
124691
|
+
const recordSizes = /* @__PURE__ */ new WeakMap();
|
|
124692
|
+
const byId = /* @__PURE__ */ new Map();
|
|
124693
|
+
const byLayerId = /* @__PURE__ */ new Map();
|
|
124694
|
+
const cleared = /* @__PURE__ */ new WeakSet();
|
|
124695
|
+
const startArrivals = /* @__PURE__ */ new WeakMap();
|
|
124696
|
+
const uploadEnds = /* @__PURE__ */ new WeakMap();
|
|
124697
|
+
const inlineBodies = /* @__PURE__ */ new WeakMap();
|
|
124698
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
124699
|
+
const bodyReads = /* @__PURE__ */ new Map();
|
|
124700
|
+
const stalls = /* @__PURE__ */ new Map();
|
|
124701
|
+
const endedConnections = /* @__PURE__ */ new Set();
|
|
124702
|
+
let newestConnection = -1;
|
|
124703
|
+
const sawConnection = (connection) => {
|
|
124704
|
+
if (connection > newestConnection) newestConnection = connection;
|
|
124705
|
+
};
|
|
124706
|
+
const keyOf = (connection, layerId) => `${connection}:${layerId}`;
|
|
124707
|
+
function startRecord(connection, layerId, p) {
|
|
124708
|
+
const req = asObject(p.request);
|
|
124709
|
+
const startedAt = typeof p.wallTime === "number" ? p.wallTime * 1e3 : typeof p.timestamp === "number" ? p.timestamp * 1e3 : Date.now();
|
|
124710
|
+
const postData = typeof req.postData === "string" ? req.postData : "";
|
|
124711
|
+
const record2 = {
|
|
124712
|
+
id: `ios-${RUN_TAG}-${nextRecordNumber++}`,
|
|
124713
|
+
layer: "ios-native",
|
|
124714
|
+
layerId,
|
|
124715
|
+
connection,
|
|
124716
|
+
state: "pending",
|
|
124717
|
+
request: {
|
|
124718
|
+
url: capString(asString2(req.url)),
|
|
124719
|
+
method: capString(asString2(req.method), 100) || "GET",
|
|
124720
|
+
headers: headerMap(req.headers),
|
|
124721
|
+
...req.hasPostData === true || postData.length > 0 ? { hasPostData: true } : {}
|
|
124722
|
+
},
|
|
124723
|
+
timing: { startedAt: Math.round(startedAt) }
|
|
124724
|
+
};
|
|
124725
|
+
if (postData.length > 0) {
|
|
124726
|
+
inlineBodies.set(record2, {
|
|
124727
|
+
text: ownCopy(postData.slice(0, MAX_VALUE_CHARS)),
|
|
124728
|
+
chars: postData.length
|
|
124729
|
+
});
|
|
124730
|
+
}
|
|
124731
|
+
byLayerId.set(keyOf(connection, layerId), record2);
|
|
124732
|
+
startArrivals.set(record2, performance.now());
|
|
124733
|
+
records.push(record2);
|
|
124734
|
+
byId.set(record2.id, record2);
|
|
124735
|
+
resize(record2);
|
|
124736
|
+
}
|
|
124737
|
+
function setDuration(record2, p) {
|
|
124738
|
+
const measured = p.nativeDevtoolsDurationMs;
|
|
124739
|
+
if (typeof measured === "number" && Number.isFinite(measured) && measured >= 0) {
|
|
124740
|
+
record2.timing.durationMs = Math.round(measured);
|
|
124741
|
+
return;
|
|
124742
|
+
}
|
|
124743
|
+
const arrived = startArrivals.get(record2);
|
|
124744
|
+
if (arrived !== void 0) record2.timing.durationMs = Math.round(performance.now() - arrived);
|
|
124745
|
+
}
|
|
124746
|
+
function resize(record2) {
|
|
124747
|
+
if (!byId.has(record2.id)) return;
|
|
124748
|
+
const size = recordSize(record2) + (inlineBodies.get(record2)?.text.length ?? 0);
|
|
124749
|
+
recordChars += size - (recordSizes.get(record2) ?? 0);
|
|
124750
|
+
recordSizes.set(record2, size);
|
|
124751
|
+
while (records.length > MAX_RECORDS || records.length > 1 && recordChars > RECORD_CHARS_BUDGET) {
|
|
124752
|
+
evict(records.shift());
|
|
124753
|
+
}
|
|
124754
|
+
}
|
|
124755
|
+
function evict(record2) {
|
|
124756
|
+
const key2 = keyOf(record2.connection, record2.layerId);
|
|
124757
|
+
if (byLayerId.get(key2) === record2) byLayerId.delete(key2);
|
|
124758
|
+
byId.delete(record2.id);
|
|
124759
|
+
recordChars -= recordSizes.get(record2) ?? 0;
|
|
124760
|
+
recordSizes.delete(record2);
|
|
124761
|
+
bodies.delete(`response:${record2.id}`);
|
|
124762
|
+
bodies.delete(`post:${record2.id}`);
|
|
124763
|
+
}
|
|
124764
|
+
function closedReason(connection) {
|
|
124765
|
+
const live = link.liveConnection();
|
|
124766
|
+
if (live !== void 0) sawConnection(live);
|
|
124767
|
+
return endedConnections.has(connection) || newestConnection > connection ? PROCESS_GONE : CONNECTION_CLOSED;
|
|
124768
|
+
}
|
|
124769
|
+
function readBody(id, kind) {
|
|
124770
|
+
const record2 = byId.get(id);
|
|
124771
|
+
if (!record2) return Promise.resolve(unavailable("no such request"));
|
|
124772
|
+
if (kind === "post") {
|
|
124773
|
+
if (!record2.request.hasPostData) {
|
|
124774
|
+
return Promise.resolve(unavailable("the request has no body"));
|
|
124775
|
+
}
|
|
124776
|
+
const inline = inlineBodies.get(record2);
|
|
124777
|
+
if (inline) {
|
|
124778
|
+
return Promise.resolve({
|
|
124779
|
+
available: true,
|
|
124780
|
+
body: inline.text,
|
|
124781
|
+
base64Encoded: false,
|
|
124782
|
+
truncated: inline.text.length < inline.chars,
|
|
124783
|
+
inlineChars: inline.chars
|
|
124784
|
+
});
|
|
124785
|
+
}
|
|
124786
|
+
} else if (record2.state !== "complete") {
|
|
124787
|
+
return Promise.resolve(
|
|
124788
|
+
unavailable(
|
|
124789
|
+
record2.state !== "failed" ? "the response has not finished yet" : record2.response ? "the response failed before its body finished" : "the request failed before a response arrived"
|
|
124790
|
+
)
|
|
124791
|
+
);
|
|
124792
|
+
} else if (record2.encodedDataLength === 0) {
|
|
124793
|
+
return Promise.resolve(unavailable(NO_RESPONSE_BODY));
|
|
124794
|
+
}
|
|
124795
|
+
const cacheKey2 = `${kind}:${id}`;
|
|
124796
|
+
const cached3 = bodies.get(cacheKey2);
|
|
124797
|
+
if (cached3 && !(kind === "post" && lostRead(cached3, record2))) {
|
|
124798
|
+
bodies.delete(cacheKey2);
|
|
124799
|
+
bodies.set(cacheKey2, cached3);
|
|
124800
|
+
return shownOf(cached3, kind, record2);
|
|
124801
|
+
}
|
|
124802
|
+
if (link.liveConnection() !== record2.connection) {
|
|
124803
|
+
return Promise.resolve(unavailable(closedReason(record2.connection)));
|
|
124804
|
+
}
|
|
124805
|
+
let adoptAnswer;
|
|
124806
|
+
const answer = new Promise((resolve21) => {
|
|
124807
|
+
adoptAnswer = resolve21;
|
|
124808
|
+
});
|
|
124809
|
+
let markSent;
|
|
124810
|
+
const sent = new Promise((resolve21) => {
|
|
124811
|
+
markSent = resolve21;
|
|
124812
|
+
});
|
|
124813
|
+
const read = { sent, answer, settled: false, chars: 0 };
|
|
124814
|
+
bodies.delete(cacheKey2);
|
|
124815
|
+
bodies.set(cacheKey2, read);
|
|
124816
|
+
if (cached3) adoptLateBody(cached3.answer, answer, adoptAnswer);
|
|
124817
|
+
void answer.then((body) => {
|
|
124818
|
+
read.settled = true;
|
|
124819
|
+
read.chars = body.body.length;
|
|
124820
|
+
if (bodies.get(cacheKey2) === read) {
|
|
124821
|
+
bodies.delete(cacheKey2);
|
|
124822
|
+
if (body.available) bodies.set(cacheKey2, read);
|
|
124823
|
+
}
|
|
124824
|
+
dropOldBodies();
|
|
124825
|
+
});
|
|
124826
|
+
const askedAt = performance.now();
|
|
124827
|
+
void withKeyedLock(bodyReads, String(record2.connection), () => {
|
|
124828
|
+
if (read.settled) {
|
|
124829
|
+
markSent();
|
|
124830
|
+
return answer;
|
|
124831
|
+
}
|
|
124832
|
+
if (kind === "response" && (stalls.get(record2.connection) ?? -Infinity) > askedAt) {
|
|
124833
|
+
adoptAnswer(unavailable(NO_EARLIER_ANSWER));
|
|
124834
|
+
markSent();
|
|
124835
|
+
return answer;
|
|
124836
|
+
}
|
|
124837
|
+
read.heldOpen = kind === "post" && record2.state === "pending";
|
|
124838
|
+
void sendBodyRead(record2, kind).then(adoptAnswer);
|
|
124839
|
+
markSent();
|
|
124840
|
+
return kind === "post" ? withinWait(answer, record2) : answer;
|
|
124841
|
+
});
|
|
124842
|
+
return shownOf(read, kind, record2);
|
|
124843
|
+
}
|
|
124844
|
+
function lostRead(read, record2) {
|
|
124845
|
+
const ended = uploadEnds.get(record2);
|
|
124846
|
+
return read.heldOpen === true && !read.settled && ended !== void 0 && performance.now() - ended >= POST_DATA_WAIT_MS;
|
|
124847
|
+
}
|
|
124848
|
+
function dropOldBodies() {
|
|
124849
|
+
let kept = 0;
|
|
124850
|
+
let chars = 0;
|
|
124851
|
+
for (const read of bodies.values()) {
|
|
124852
|
+
if (!read.settled) continue;
|
|
124853
|
+
kept++;
|
|
124854
|
+
chars += read.chars;
|
|
124855
|
+
}
|
|
124856
|
+
for (const [key2, read] of bodies) {
|
|
124857
|
+
if (kept <= MAX_CACHED_BODIES && (kept <= 1 || chars <= KEPT_BODY_CHARS_BUDGET)) return;
|
|
124858
|
+
if (read.settled) {
|
|
124859
|
+
bodies.delete(key2);
|
|
124860
|
+
kept--;
|
|
124861
|
+
chars -= read.chars;
|
|
124862
|
+
}
|
|
124863
|
+
}
|
|
124864
|
+
}
|
|
124865
|
+
function sendBodyRead(record2, kind) {
|
|
124866
|
+
const method = kind === "response" ? "Network.getResponseBody" : "Network.getRequestPostData";
|
|
124867
|
+
return new Promise((resolve21) => {
|
|
124868
|
+
resolve21(
|
|
124869
|
+
link.request(
|
|
124870
|
+
record2.connection,
|
|
124871
|
+
method,
|
|
124872
|
+
{ requestId: record2.layerId },
|
|
124873
|
+
kind === "response" ? RESPONSE_BODY_TIMEOUT_MS : POST_DATA_TIMEOUT_MS
|
|
124874
|
+
)
|
|
124875
|
+
);
|
|
124876
|
+
}).then(
|
|
124877
|
+
(result) => {
|
|
124878
|
+
stalls.delete(record2.connection);
|
|
124879
|
+
return toBody(result, kind);
|
|
124880
|
+
},
|
|
124881
|
+
(err) => {
|
|
124882
|
+
if (getFailureSignal(err)?.error_code === FAILURE_CODES.NDJSON_CDP_REQUEST_TIMEOUT) {
|
|
124883
|
+
stalls.set(record2.connection, performance.now());
|
|
124884
|
+
} else {
|
|
124885
|
+
stalls.delete(record2.connection);
|
|
124886
|
+
}
|
|
124887
|
+
return unavailable(failureReason(record2, kind, method, err));
|
|
124888
|
+
}
|
|
124889
|
+
);
|
|
124890
|
+
}
|
|
124891
|
+
function failureReason(record2, kind, method, err) {
|
|
124892
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
124893
|
+
switch (getFailureSignal(err)?.error_code) {
|
|
124894
|
+
case FAILURE_CODES.NDJSON_CDP_CONNECTION_CLOSED:
|
|
124895
|
+
return closedReason(record2.connection);
|
|
124896
|
+
case FAILURE_CODES.NDJSON_CDP_REQUEST_FAILED: {
|
|
124897
|
+
const marker = `${method} failed: `;
|
|
124898
|
+
const at = message.indexOf(marker);
|
|
124899
|
+
const detail = at === -1 ? message : message.slice(at + marker.length);
|
|
124900
|
+
if (/^no /i.test(detail)) {
|
|
124901
|
+
if (kind === "response") return BODY_NO_LONGER_HELD;
|
|
124902
|
+
if (/^no request stored\b/i.test(detail)) {
|
|
124903
|
+
return record2.state === "pending" ? STILL_SENDING : BODY_NO_LONGER_HELD;
|
|
124904
|
+
}
|
|
124905
|
+
return REQUEST_BODY_GONE;
|
|
124906
|
+
}
|
|
124907
|
+
return `the agent did not return the body: ${detail}`;
|
|
124908
|
+
}
|
|
124909
|
+
}
|
|
124910
|
+
return `the agent did not return the body: ${message}`;
|
|
124911
|
+
}
|
|
124912
|
+
return {
|
|
124913
|
+
state: state3,
|
|
124914
|
+
fold(connection, method, params) {
|
|
124915
|
+
sawConnection(connection);
|
|
124916
|
+
if (typeof params !== "object" || params === null) return;
|
|
124917
|
+
const p = params;
|
|
124918
|
+
const layerId = typeof p.requestId === "string" ? p.requestId : null;
|
|
124919
|
+
if (!layerId || layerId.length > MAX_LAYER_ID_CHARS) return;
|
|
124920
|
+
if (method === "Network.requestWillBeSent") {
|
|
124921
|
+
if (p.redirectResponse !== void 0 && p.redirectResponse !== null) return;
|
|
124922
|
+
startRecord(connection, layerId, p);
|
|
124923
|
+
return;
|
|
124924
|
+
}
|
|
124925
|
+
const record2 = byLayerId.get(keyOf(connection, layerId));
|
|
124926
|
+
if (!record2) return;
|
|
124927
|
+
const uploading = record2.state === "pending" && record2.request.hasPostData === true;
|
|
124928
|
+
switch (method) {
|
|
124929
|
+
case "Network.responseReceived": {
|
|
124930
|
+
const r = asObject(p.response);
|
|
124931
|
+
const status = typeof r.status === "number" ? r.status : 0;
|
|
124932
|
+
record2.state = "headers";
|
|
124933
|
+
record2.response = {
|
|
124934
|
+
// The URL of the final response, after any redirects.
|
|
124935
|
+
url: capString(asString2(r.url)) || record2.request.url,
|
|
124936
|
+
status,
|
|
124937
|
+
statusText: import_node_http2.STATUS_CODES[status] ?? "",
|
|
124938
|
+
headers: headerMap(r.headers),
|
|
124939
|
+
mimeType: capString(asString2(r.mimeType))
|
|
124940
|
+
};
|
|
124941
|
+
if (typeof p.type === "string") record2.resourceType = capString(p.type, 100);
|
|
124942
|
+
break;
|
|
124943
|
+
}
|
|
124944
|
+
case "Network.loadingFinished":
|
|
124945
|
+
cleared.delete(record2);
|
|
124946
|
+
record2.state = "complete";
|
|
124947
|
+
if (typeof p.encodedDataLength === "number")
|
|
124948
|
+
record2.encodedDataLength = p.encodedDataLength;
|
|
124949
|
+
setDuration(record2, p);
|
|
124950
|
+
break;
|
|
124951
|
+
case "Network.loadingFailed":
|
|
124952
|
+
cleared.delete(record2);
|
|
124953
|
+
record2.state = "failed";
|
|
124954
|
+
record2.errorText = capString(asString2(p.errorText)) || "Unknown error";
|
|
124955
|
+
setDuration(record2, p);
|
|
124956
|
+
break;
|
|
124957
|
+
default:
|
|
124958
|
+
return;
|
|
124959
|
+
}
|
|
124960
|
+
if (uploading) uploadEnds.set(record2, performance.now());
|
|
124961
|
+
resize(record2);
|
|
124962
|
+
},
|
|
124963
|
+
holdsRecordsOf: (connection) => records.some((record2) => record2.connection === connection),
|
|
124964
|
+
connectionClosed(connection, check3) {
|
|
124965
|
+
sawConnection(connection);
|
|
124966
|
+
const ended = check3.superseded || check3.running === false || check3.runningPid !== void 0 && check3.connectionPid !== void 0 && check3.runningPid !== check3.connectionPid;
|
|
124967
|
+
if (ended) endedConnections.add(connection);
|
|
124968
|
+
const open5 = records.filter((r) => r.connection === connection && isOpen(r));
|
|
124969
|
+
for (const record2 of open5) {
|
|
124970
|
+
record2.state = "failed";
|
|
124971
|
+
record2.errorText = ended ? PROCESS_ENDED : NOT_RECONNECTED;
|
|
124972
|
+
cleared.delete(record2);
|
|
124973
|
+
}
|
|
124974
|
+
for (const record2 of open5) resize(record2);
|
|
124975
|
+
},
|
|
124976
|
+
records: (port) => records.filter((r) => !cleared.has(r) && !isMetroTraffic(r.request.url, port)),
|
|
124977
|
+
record: (id) => byId.get(id),
|
|
124978
|
+
clear() {
|
|
124979
|
+
for (const record2 of records) cleared.add(record2);
|
|
124980
|
+
},
|
|
124981
|
+
responseBody: (id) => readBody(id, "response"),
|
|
124982
|
+
requestPostData: (id) => readBody(id, "post")
|
|
124983
|
+
};
|
|
124984
|
+
}
|
|
124985
|
+
function ownCopy(text) {
|
|
124986
|
+
return Buffer.from(text, "utf16le").toString("utf16le");
|
|
124987
|
+
}
|
|
124988
|
+
function adoptLateBody(lost, replacing, adopt) {
|
|
124989
|
+
let take2 = adopt;
|
|
124990
|
+
void replacing.then(() => {
|
|
124991
|
+
take2 = void 0;
|
|
124992
|
+
});
|
|
124993
|
+
void lost.then((body) => {
|
|
124994
|
+
if (body.available) take2?.(body);
|
|
124995
|
+
});
|
|
124996
|
+
}
|
|
124997
|
+
function shownOf(read, kind, record2) {
|
|
124998
|
+
return kind === "post" ? read.sent.then(() => withinWait(read.answer, record2)) : read.answer;
|
|
124999
|
+
}
|
|
125000
|
+
function withinWait(answer, record2) {
|
|
125001
|
+
return new Promise((resolve21) => {
|
|
125002
|
+
const timer = setTimeout(
|
|
125003
|
+
() => resolve21(unavailable(record2.state === "pending" ? STILL_SENDING : NO_ANSWER)),
|
|
125004
|
+
POST_DATA_WAIT_MS
|
|
125005
|
+
);
|
|
125006
|
+
timer.unref();
|
|
125007
|
+
void answer.then((body) => {
|
|
125008
|
+
clearTimeout(timer);
|
|
125009
|
+
resolve21(body);
|
|
125010
|
+
});
|
|
125011
|
+
});
|
|
125012
|
+
}
|
|
125013
|
+
var liveCaptures = /* @__PURE__ */ new Set();
|
|
125014
|
+
function registerIosNetworkCaptures(captures) {
|
|
125015
|
+
liveCaptures.add(captures);
|
|
125016
|
+
return () => {
|
|
125017
|
+
liveCaptures.delete(captures);
|
|
125018
|
+
};
|
|
125019
|
+
}
|
|
125020
|
+
function findIosNativeRecord(id) {
|
|
125021
|
+
for (const captures of liveCaptures) {
|
|
125022
|
+
for (const records of captures.stores.values()) {
|
|
125023
|
+
const record2 = records.record(id);
|
|
125024
|
+
if (record2) return { records, record: record2 };
|
|
125025
|
+
}
|
|
125026
|
+
}
|
|
125027
|
+
return void 0;
|
|
125028
|
+
}
|
|
125029
|
+
function capturing(captures, bundleId) {
|
|
125030
|
+
return captures.bundleIds.has(bundleId) && captures.stores.has(bundleId);
|
|
125031
|
+
}
|
|
125032
|
+
function liveIosNetworkCaptures(deviceId) {
|
|
125033
|
+
const key2 = deviceKeyOf(deviceId);
|
|
125034
|
+
const bundleIds = /* @__PURE__ */ new Set();
|
|
125035
|
+
for (const captures of liveCaptures) {
|
|
125036
|
+
if (deviceKeyOf(captures.udid) !== key2) continue;
|
|
125037
|
+
for (const bundleId of captures.bundleIds) {
|
|
125038
|
+
if (capturing(captures, bundleId)) bundleIds.add(bundleId);
|
|
125039
|
+
}
|
|
125040
|
+
}
|
|
125041
|
+
return [...bundleIds].sort();
|
|
125042
|
+
}
|
|
125043
|
+
function liveIosNetworkCaptureDevices(bundleId) {
|
|
125044
|
+
const udids = [...liveCaptures].filter((captures) => capturing(captures, bundleId)).map((captures) => captures.udid);
|
|
125045
|
+
return [...new Set(udids)].sort();
|
|
125046
|
+
}
|
|
125047
|
+
|
|
124521
125048
|
// ../tool-server/src/blueprints/native-devtools.ts
|
|
124522
125049
|
var NATIVE_DEVTOOLS_NAMESPACE = "NativeDevtools";
|
|
124523
125050
|
function isInjectableBundleId(bundleId) {
|
|
@@ -124630,7 +125157,23 @@ function nativeDevtoolsRef(device, { transport = "unix" } = {}) {
|
|
|
124630
125157
|
options: { device, transport }
|
|
124631
125158
|
};
|
|
124632
125159
|
}
|
|
124633
|
-
var
|
|
125160
|
+
var NETWORK_ENABLE_TIMEOUT_MS = 5e3;
|
|
125161
|
+
var LAUNCH_ARM_WAIT_MS = 5e3;
|
|
125162
|
+
var LENT_HANDSHAKE_PROMPT_MS = 1e3;
|
|
125163
|
+
var WAITING_FOR_ENABLE = "waiting for the agent to acknowledge Network.enable";
|
|
125164
|
+
var WAITING_FOR_CAPTURE_STATE = "waiting for the agent to say whether capture is on";
|
|
125165
|
+
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";
|
|
125166
|
+
function closedBeforeRequest(bundleId, method) {
|
|
125167
|
+
return new FailureError(
|
|
125168
|
+
`native-devtools ${bundleId}: the connection closed before ${method} was answered`,
|
|
125169
|
+
{
|
|
125170
|
+
error_code: FAILURE_CODES.NDJSON_CDP_CONNECTION_CLOSED,
|
|
125171
|
+
failure_stage: "ndjson_cdp_request",
|
|
125172
|
+
failure_area: "tool_server",
|
|
125173
|
+
error_kind: "network"
|
|
125174
|
+
}
|
|
125175
|
+
);
|
|
125176
|
+
}
|
|
124634
125177
|
function getNativeDevtoolsSocketPath(udid) {
|
|
124635
125178
|
return `/tmp/argent-nd-${udid.slice(0, 8)}.sock`;
|
|
124636
125179
|
}
|
|
@@ -124721,6 +125264,8 @@ var nativeDevtoolsBlueprint = {
|
|
|
124721
125264
|
const socketPath = getNativeDevtoolsSocketPath(udid);
|
|
124722
125265
|
const endpoint = transport === "tcp" ? { transport: "tcp" } : { transport: "unix", socketPath };
|
|
124723
125266
|
const connections2 = /* @__PURE__ */ new Map();
|
|
125267
|
+
let nextConnectionIndex = 1;
|
|
125268
|
+
const networkStores = /* @__PURE__ */ new Map();
|
|
124724
125269
|
const pendingRpc = /* @__PURE__ */ new Map();
|
|
124725
125270
|
let nextRpcId = 1;
|
|
124726
125271
|
let envSetup = false;
|
|
@@ -124728,10 +125273,16 @@ var nativeDevtoolsBlueprint = {
|
|
|
124728
125273
|
let inFlight4 = null;
|
|
124729
125274
|
let envRetired = false;
|
|
124730
125275
|
const activatedBundleIds = /* @__PURE__ */ new Set();
|
|
125276
|
+
const captureGaps = /* @__PURE__ */ new Set();
|
|
124731
125277
|
const networkConditions = /* @__PURE__ */ new Map();
|
|
124732
125278
|
const providerCapture = /* @__PURE__ */ new Map();
|
|
124733
125279
|
const unconfirmedThrottles = /* @__PURE__ */ new Set();
|
|
124734
125280
|
const events = new TypedEventEmitter();
|
|
125281
|
+
const connectionWaiters = /* @__PURE__ */ new Set();
|
|
125282
|
+
let connectionCloses = 0;
|
|
125283
|
+
const wakeConnectionWaiters = () => {
|
|
125284
|
+
for (const wake of [...connectionWaiters]) wake();
|
|
125285
|
+
};
|
|
124735
125286
|
const noteInitFailure = (err) => {
|
|
124736
125287
|
if (err instanceof XcodeFirstLaunchPendingError) return;
|
|
124737
125288
|
const lastError = err instanceof Error ? err.message : String(err);
|
|
@@ -124768,9 +125319,6 @@ var nativeDevtoolsBlueprint = {
|
|
|
124768
125319
|
const writeMessage = (socket, type, payload) => {
|
|
124769
125320
|
socket.write(JSON.stringify({ type, payload }) + "\n");
|
|
124770
125321
|
};
|
|
124771
|
-
const writeActivation = (socket) => {
|
|
124772
|
-
writeMessage(socket, "Control", { command: "activateNetworkInspection" });
|
|
124773
|
-
};
|
|
124774
125322
|
const isAppRunning = async (bundleId) => {
|
|
124775
125323
|
const runningBundleIds = await host.listRunningBundleIds(udid);
|
|
124776
125324
|
return runningBundleIds.has(bundleId);
|
|
@@ -124806,11 +125354,121 @@ var nativeDevtoolsBlueprint = {
|
|
|
124806
125354
|
}, timeoutMs);
|
|
124807
125355
|
});
|
|
124808
125356
|
}
|
|
125357
|
+
const waitForConnection = (test, timeoutMs) => {
|
|
125358
|
+
if (test()) return Promise.resolve(true);
|
|
125359
|
+
return new Promise((resolve21) => {
|
|
125360
|
+
const finish = () => {
|
|
125361
|
+
clearTimeout(timer);
|
|
125362
|
+
connectionWaiters.delete(check3);
|
|
125363
|
+
resolve21(!disposed && test());
|
|
125364
|
+
};
|
|
125365
|
+
const check3 = () => {
|
|
125366
|
+
if (disposed || test()) finish();
|
|
125367
|
+
};
|
|
125368
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
125369
|
+
timer.unref();
|
|
125370
|
+
connectionWaiters.add(check3);
|
|
125371
|
+
});
|
|
125372
|
+
};
|
|
125373
|
+
const enableOn = (conn) => {
|
|
125374
|
+
if (conn.armed && !lentSocketPath) return Promise.resolve(true);
|
|
125375
|
+
if (conn.enabling) return conn.enabling;
|
|
125376
|
+
delete conn.enableFailure;
|
|
125377
|
+
const enabling = conn.cdp.request(
|
|
125378
|
+
lentSocketPath ? "NativeDevtoolsIos.getConditions" : "Network.enable",
|
|
125379
|
+
{},
|
|
125380
|
+
{
|
|
125381
|
+
timeoutMs: NETWORK_ENABLE_TIMEOUT_MS,
|
|
125382
|
+
onResult: (result) => {
|
|
125383
|
+
conn.armed = !lentSocketPath || result?.enabled === true;
|
|
125384
|
+
if (!conn.armed) conn.enableFailure = PROVIDER_CAPTURE_OFF;
|
|
125385
|
+
wakeConnectionWaiters();
|
|
125386
|
+
}
|
|
125387
|
+
}
|
|
125388
|
+
).then(
|
|
125389
|
+
() => conn.armed,
|
|
125390
|
+
(err) => {
|
|
125391
|
+
if (conn.socket.destroyed || disposed) return false;
|
|
125392
|
+
const timedOut3 = getFailureSignal(err)?.error_kind === "timeout";
|
|
125393
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
125394
|
+
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`;
|
|
125395
|
+
process.stderr.write(`[native-devtools ${udid.slice(0, 8)}] ${conn.enableFailure}
|
|
125396
|
+
`);
|
|
125397
|
+
wakeConnectionWaiters();
|
|
125398
|
+
return false;
|
|
125399
|
+
}
|
|
125400
|
+
).finally(() => {
|
|
125401
|
+
if (conn.enabling === enabling) conn.enabling = void 0;
|
|
125402
|
+
});
|
|
125403
|
+
conn.enabling = enabling;
|
|
125404
|
+
return enabling;
|
|
125405
|
+
};
|
|
125406
|
+
const captureState = (bundleId) => {
|
|
125407
|
+
const conn = connections2.get(bundleId);
|
|
125408
|
+
if (!conn) {
|
|
125409
|
+
return {
|
|
125410
|
+
armed: false,
|
|
125411
|
+
note: activatedBundleIds.has(bundleId) ? "the app is not connected; its next process is armed when it connects" : "the app is not connected"
|
|
125412
|
+
};
|
|
125413
|
+
}
|
|
125414
|
+
return {
|
|
125415
|
+
armed: conn.armed,
|
|
125416
|
+
...conn.pid !== void 0 ? { pid: conn.pid } : {},
|
|
125417
|
+
...conn.armed ? {} : conn.enabling ? { note: lentSocketPath ? WAITING_FOR_CAPTURE_STATE : WAITING_FOR_ENABLE } : conn.enableFailure ? { note: conn.enableFailure } : {}
|
|
125418
|
+
};
|
|
125419
|
+
};
|
|
125420
|
+
const readConnectionPid = async (bundleId, conn) => {
|
|
125421
|
+
if (lentSocketPath) return;
|
|
125422
|
+
const inspection = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125423
|
+
const pid = inspection?.process?.pid;
|
|
125424
|
+
if (pid === void 0 || disposed || connections2.get(bundleId) !== conn) return;
|
|
125425
|
+
conn.pid = pid;
|
|
125426
|
+
wakeConnectionWaiters();
|
|
125427
|
+
};
|
|
125428
|
+
const settleClosedConnection = async (bundleId, conn) => {
|
|
125429
|
+
const store = networkStores.get(bundleId);
|
|
125430
|
+
if (lentSocketPath || disposed || !store) return;
|
|
125431
|
+
if (!store.holdsRecordsOf(conn.index)) {
|
|
125432
|
+
const live2 = connections2.get(bundleId);
|
|
125433
|
+
store.connectionClosed(conn.index, { superseded: live2 !== void 0 && live2 !== conn });
|
|
125434
|
+
return;
|
|
125435
|
+
}
|
|
125436
|
+
const inspection = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125437
|
+
if (disposed) return;
|
|
125438
|
+
const live = connections2.get(bundleId);
|
|
125439
|
+
store.connectionClosed(conn.index, {
|
|
125440
|
+
superseded: live !== void 0 && live !== conn,
|
|
125441
|
+
...inspection ? { running: inspection.running } : {},
|
|
125442
|
+
...inspection?.process ? { runningPid: inspection.process.pid } : {},
|
|
125443
|
+
...conn.pid !== void 0 ? { connectionPid: conn.pid } : {}
|
|
125444
|
+
});
|
|
125445
|
+
};
|
|
125446
|
+
const closeConnection = (bundleId, conn) => {
|
|
125447
|
+
conn.cdp.close();
|
|
125448
|
+
conn.armed = false;
|
|
125449
|
+
if (connections2.get(bundleId) === conn) connections2.delete(bundleId);
|
|
125450
|
+
connectionCloses += 1;
|
|
125451
|
+
wakeConnectionWaiters();
|
|
125452
|
+
void settleClosedConnection(bundleId, conn);
|
|
125453
|
+
};
|
|
124809
125454
|
function sendViewInspectorRpc(targetBundleId, method, params = {}) {
|
|
124810
125455
|
const timeoutMs = method === "ViewHierarchy.getFullHierarchy" ? 15e3 : 5e3;
|
|
124811
125456
|
return sendRpc(targetBundleId, "ViewInspector", method, params, timeoutMs);
|
|
124812
125457
|
}
|
|
124813
|
-
const sendCdpRpc = (targetBundleId, method, params = {}) =>
|
|
125458
|
+
const sendCdpRpc = (targetBundleId, method, params = {}) => {
|
|
125459
|
+
const conn = connections2.get(targetBundleId);
|
|
125460
|
+
if (!conn) {
|
|
125461
|
+
return Promise.reject(
|
|
125462
|
+
new FailureError("Native devtools not connected for bundleId: " + targetBundleId, {
|
|
125463
|
+
error_code: FAILURE_CODES.NATIVE_DEVTOOLS_NOT_CONNECTED,
|
|
125464
|
+
failure_stage: "native_devtools_rpc_connection",
|
|
125465
|
+
failure_area: "tool_server",
|
|
125466
|
+
error_kind: "not_found"
|
|
125467
|
+
})
|
|
125468
|
+
);
|
|
125469
|
+
}
|
|
125470
|
+
return conn.cdp.request(method, params, { timeoutMs: 5e3 });
|
|
125471
|
+
};
|
|
124814
125472
|
const readCaptureEnabled = async (bundleId) => {
|
|
124815
125473
|
const state3 = await sendCdpRpc(bundleId, "NativeDevtoolsIos.getConditions").catch(() => null);
|
|
124816
125474
|
return state3?.enabled !== false;
|
|
@@ -124819,7 +125477,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124819
125477
|
if (!lentSocketPath || providerCapture.has(bundleId)) return;
|
|
124820
125478
|
providerCapture.set(bundleId, await readCaptureEnabled(bundleId));
|
|
124821
125479
|
};
|
|
124822
|
-
const keepsCapture = (bundleId) =>
|
|
125480
|
+
const keepsCapture = (bundleId) => lentSocketPath ? providerCapture.get(bundleId) === true : activatedBundleIds.has(bundleId);
|
|
124823
125481
|
const applyThrottle = async (bundleId, throttle) => {
|
|
124824
125482
|
await noteProviderCapture(bundleId);
|
|
124825
125483
|
await sendCdpRpc(bundleId, "NativeDevtoolsIos.configure", {
|
|
@@ -124833,7 +125491,16 @@ var nativeDevtoolsBlueprint = {
|
|
|
124833
125491
|
providerCapture.delete(bundleId);
|
|
124834
125492
|
};
|
|
124835
125493
|
const reapplyThrottle = (bundleId, throttle) => {
|
|
124836
|
-
|
|
125494
|
+
const reapplying = async () => {
|
|
125495
|
+
await noteProviderCapture(bundleId);
|
|
125496
|
+
await Promise.all([
|
|
125497
|
+
sendCdpRpc(bundleId, "NativeDevtoolsIos.configure", {
|
|
125498
|
+
bypassPorts: [throttle.metroPort]
|
|
125499
|
+
}),
|
|
125500
|
+
sendCdpRpc(bundleId, "Network.emulateNetworkConditions", { ...throttle.conditions })
|
|
125501
|
+
]);
|
|
125502
|
+
};
|
|
125503
|
+
reapplying().catch((err) => {
|
|
124837
125504
|
const reason2 = err instanceof Error ? err.message : String(err);
|
|
124838
125505
|
process.stderr.write(
|
|
124839
125506
|
`[native-devtools] could not re-apply network conditions to ${bundleId}: ${reason2}
|
|
@@ -124841,11 +125508,16 @@ var nativeDevtoolsBlueprint = {
|
|
|
124841
125508
|
);
|
|
124842
125509
|
});
|
|
124843
125510
|
};
|
|
124844
|
-
const
|
|
124845
|
-
if (activatedBundleIds.has(bundleId)) writeActivation(socket);
|
|
125511
|
+
const reapplyStoredThrottle = (bundleId) => {
|
|
124846
125512
|
const throttle = networkConditions.get(bundleId);
|
|
124847
125513
|
if (throttle) reapplyThrottle(bundleId, throttle);
|
|
124848
125514
|
};
|
|
125515
|
+
const armOn = (bundleId, conn) => {
|
|
125516
|
+
const sendsEnable = !lentSocketPath && !conn.armed && !conn.enabling;
|
|
125517
|
+
const arming = enableOn(conn);
|
|
125518
|
+
if (sendsEnable) reapplyStoredThrottle(bundleId);
|
|
125519
|
+
return arming;
|
|
125520
|
+
};
|
|
124849
125521
|
const storeThrottle = (bundleId, throttle) => {
|
|
124850
125522
|
if (throttle) networkConditions.set(bundleId, throttle);
|
|
124851
125523
|
else networkConditions.delete(bundleId);
|
|
@@ -124882,6 +125554,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124882
125554
|
}
|
|
124883
125555
|
const serveAgentConnection = (socket) => {
|
|
124884
125556
|
let bundleId = null;
|
|
125557
|
+
let conn = null;
|
|
124885
125558
|
attachNdjsonReader(socket, {
|
|
124886
125559
|
onDropped: reportDroppedFrameToStderr(`native-devtools ${udid.slice(0, 8)}`),
|
|
124887
125560
|
onMessage: (parsed2) => {
|
|
@@ -124891,37 +125564,54 @@ var nativeDevtoolsBlueprint = {
|
|
|
124891
125564
|
bundleId = msg.payload.bundleId;
|
|
124892
125565
|
const existing = connections2.get(bundleId);
|
|
124893
125566
|
if (existing) {
|
|
125567
|
+
closeConnection(bundleId, existing);
|
|
124894
125568
|
existing.socket.destroy();
|
|
124895
125569
|
}
|
|
124896
|
-
|
|
124897
|
-
|
|
125570
|
+
conn = {
|
|
125571
|
+
socket,
|
|
125572
|
+
index: nextConnectionIndex++,
|
|
125573
|
+
cdp: createNdjsonCdpRequester(socket, { label: `native-devtools ${bundleId}` }),
|
|
125574
|
+
armed: false
|
|
125575
|
+
};
|
|
125576
|
+
connections2.set(bundleId, conn);
|
|
125577
|
+
if (!networkStores.has(bundleId)) {
|
|
125578
|
+
const app = bundleId;
|
|
125579
|
+
networkStores.set(
|
|
125580
|
+
app,
|
|
125581
|
+
createIosNetworkRecords(() => captureState(app), {
|
|
125582
|
+
liveConnection: () => connections2.get(app)?.index,
|
|
125583
|
+
request: (index, method, params, timeoutMs) => {
|
|
125584
|
+
const live = connections2.get(app);
|
|
125585
|
+
return live?.index === index ? live.cdp.request(method, params, { timeoutMs }) : Promise.reject(closedBeforeRequest(app, method));
|
|
125586
|
+
}
|
|
125587
|
+
})
|
|
125588
|
+
);
|
|
125589
|
+
}
|
|
125590
|
+
if (lentSocketPath && performance.now() - lentConnectedAt < LENT_HANDSHAKE_PROMPT_MS) {
|
|
125591
|
+
captureGaps.add(bundleId);
|
|
125592
|
+
}
|
|
125593
|
+
if (activatedBundleIds.has(bundleId)) {
|
|
125594
|
+
if (!lentSocketPath) captureGaps.delete(bundleId);
|
|
125595
|
+
void armOn(bundleId, conn);
|
|
125596
|
+
} else {
|
|
125597
|
+
reapplyStoredThrottle(bundleId);
|
|
125598
|
+
}
|
|
125599
|
+
void readConnectionPid(bundleId, conn);
|
|
124898
125600
|
return;
|
|
124899
125601
|
}
|
|
124900
|
-
if (msg.type === "CDP") {
|
|
125602
|
+
if (msg.type === "CDP" && conn) {
|
|
124901
125603
|
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
|
-
}
|
|
125604
|
+
if (conn.cdp.handleResponse(p)) return;
|
|
125605
|
+
if (p && typeof p.method === "string" && p.id === void 0) {
|
|
125606
|
+
networkStores.get(bundleId)?.fold(conn.index, p.method, p.params);
|
|
124915
125607
|
}
|
|
124916
125608
|
}
|
|
124917
125609
|
if (msg.type === "ViewInspector") settleRpc(msg.payload);
|
|
124918
125610
|
}
|
|
124919
125611
|
});
|
|
124920
125612
|
socket.on("close", () => {
|
|
124921
|
-
if (bundleId !== null) {
|
|
124922
|
-
|
|
124923
|
-
connections2.delete(bundleId);
|
|
124924
|
-
}
|
|
125613
|
+
if (bundleId !== null && conn !== null && connections2.get(bundleId) === conn) {
|
|
125614
|
+
closeConnection(bundleId, conn);
|
|
124925
125615
|
}
|
|
124926
125616
|
});
|
|
124927
125617
|
socket.on("error", () => {
|
|
@@ -124929,6 +125619,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124929
125619
|
};
|
|
124930
125620
|
const server = lentSocketPath ? null : net.createServer(serveAgentConnection);
|
|
124931
125621
|
let lentSocket = null;
|
|
125622
|
+
let lentConnectedAt = 0;
|
|
124932
125623
|
let disposed = false;
|
|
124933
125624
|
if (lentSocketPath) {
|
|
124934
125625
|
lentSocket = await new Promise((resolve21, reject) => {
|
|
@@ -124953,6 +125644,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
124953
125644
|
resolve21(socket);
|
|
124954
125645
|
});
|
|
124955
125646
|
});
|
|
125647
|
+
lentConnectedAt = performance.now();
|
|
124956
125648
|
serveAgentConnection(lentSocket);
|
|
124957
125649
|
lentSocket.once("close", () => {
|
|
124958
125650
|
if (disposed) return;
|
|
@@ -125044,10 +125736,12 @@ var nativeDevtoolsBlueprint = {
|
|
|
125044
125736
|
return "unregistered";
|
|
125045
125737
|
},
|
|
125046
125738
|
activateNetworkInspection(bundleId) {
|
|
125047
|
-
const
|
|
125739
|
+
const startedNow = !activatedBundleIds.has(bundleId);
|
|
125048
125740
|
activatedBundleIds.add(bundleId);
|
|
125049
125741
|
const conn = connections2.get(bundleId);
|
|
125050
|
-
if (conn
|
|
125742
|
+
if (!conn) return Promise.resolve(false);
|
|
125743
|
+
if (startedNow && !lentSocketPath) captureGaps.add(bundleId);
|
|
125744
|
+
return armOn(bundleId, conn);
|
|
125051
125745
|
},
|
|
125052
125746
|
async setNetworkConditions(bundleId, throttle) {
|
|
125053
125747
|
const previous = networkConditions.get(bundleId) ?? null;
|
|
@@ -125066,10 +125760,70 @@ var nativeDevtoolsBlueprint = {
|
|
|
125066
125760
|
throw err;
|
|
125067
125761
|
}
|
|
125068
125762
|
},
|
|
125069
|
-
|
|
125070
|
-
|
|
125071
|
-
|
|
125072
|
-
if (
|
|
125763
|
+
takeCaptureGap: (bundleId) => captureGaps.delete(bundleId),
|
|
125764
|
+
networkRecords: (bundleId) => networkStores.get(bundleId),
|
|
125765
|
+
async networkCaptureAfterLaunch(bundleId) {
|
|
125766
|
+
if (!activatedBundleIds.has(bundleId) || lentSocketPath) return void 0;
|
|
125767
|
+
let closes = connectionCloses;
|
|
125768
|
+
const inspection = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125769
|
+
if (disposed) return void 0;
|
|
125770
|
+
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`;
|
|
125771
|
+
if (inspection?.running === false) return gone;
|
|
125772
|
+
const pid = inspection?.process?.pid;
|
|
125773
|
+
const ofLaunch = () => {
|
|
125774
|
+
const conn = connections2.get(bundleId);
|
|
125775
|
+
return conn && (pid === void 0 || conn.pid === pid) ? conn : void 0;
|
|
125776
|
+
};
|
|
125777
|
+
const running = inspection?.process;
|
|
125778
|
+
if (running && !ofLaunch()) {
|
|
125779
|
+
if (!processCarriesInjection(running.env, endpoint)) {
|
|
125780
|
+
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`;
|
|
125781
|
+
}
|
|
125782
|
+
if (running.ageMs > Date.now() - listeningSince + NATIVE_DEVTOOLS_AGE_SLOP_MS) {
|
|
125783
|
+
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`;
|
|
125784
|
+
}
|
|
125785
|
+
}
|
|
125786
|
+
const asked = ofLaunch();
|
|
125787
|
+
if (asked && !asked.armed && !asked.enabling) void enableOn(asked);
|
|
125788
|
+
let exited = false;
|
|
125789
|
+
const watchExit = () => {
|
|
125790
|
+
if (closes === connectionCloses) return;
|
|
125791
|
+
closes = connectionCloses;
|
|
125792
|
+
if (connections2.has(bundleId)) return;
|
|
125793
|
+
void host.inspectRunningApp(udid, bundleId).catch(() => null).then((now) => {
|
|
125794
|
+
if (now?.running !== false) return;
|
|
125795
|
+
exited = true;
|
|
125796
|
+
wakeConnectionWaiters();
|
|
125797
|
+
});
|
|
125798
|
+
};
|
|
125799
|
+
connectionWaiters.add(watchExit);
|
|
125800
|
+
watchExit();
|
|
125801
|
+
try {
|
|
125802
|
+
await waitForConnection(() => {
|
|
125803
|
+
const conn = ofLaunch();
|
|
125804
|
+
return exited || conn !== void 0 && (conn.armed || conn.enableFailure !== void 0);
|
|
125805
|
+
}, LAUNCH_ARM_WAIT_MS);
|
|
125806
|
+
} finally {
|
|
125807
|
+
connectionWaiters.delete(watchExit);
|
|
125808
|
+
}
|
|
125809
|
+
if (disposed) return void 0;
|
|
125810
|
+
if (exited) return gone;
|
|
125811
|
+
let launched = ofLaunch();
|
|
125812
|
+
if (!launched) {
|
|
125813
|
+
const now = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125814
|
+
if (disposed) return void 0;
|
|
125815
|
+
if (now?.running === false) return gone;
|
|
125816
|
+
launched = ofLaunch();
|
|
125817
|
+
}
|
|
125818
|
+
const shownPid = pid ?? launched?.pid;
|
|
125819
|
+
const pidText = shownPid !== void 0 ? ` (pid ${shownPid})` : "";
|
|
125820
|
+
if (launched?.armed) {
|
|
125821
|
+
return `native network capture is armed for ${bundleId}${pidText}; stop-all-simulator-servers for this device, then restart-app, ends it`;
|
|
125822
|
+
}
|
|
125823
|
+
if (launched?.enableFailure !== void 0) {
|
|
125824
|
+
return `native network capture is on for ${bundleId}, but its process${pidText} is not armed: ${launched.enableFailure}`;
|
|
125825
|
+
}
|
|
125826
|
+
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
125827
|
},
|
|
125074
125828
|
async getAppState(bundleId) {
|
|
125075
125829
|
const result = await sendViewInspectorRpc(bundleId, "Application.getState");
|
|
@@ -125114,16 +125868,27 @@ var nativeDevtoolsBlueprint = {
|
|
|
125114
125868
|
return sendViewInspectorRpc(bundleId, method, params);
|
|
125115
125869
|
}
|
|
125116
125870
|
};
|
|
125871
|
+
const unregisterCaptures = registerIosNetworkCaptures({
|
|
125872
|
+
udid,
|
|
125873
|
+
// A lent agent's capture is its provider's, so argent has none on there.
|
|
125874
|
+
bundleIds: lentSocketPath ? /* @__PURE__ */ new Set() : activatedBundleIds,
|
|
125875
|
+
stores: networkStores
|
|
125876
|
+
});
|
|
125117
125877
|
return {
|
|
125118
125878
|
api,
|
|
125119
125879
|
dispose: async () => {
|
|
125120
125880
|
disposed = true;
|
|
125881
|
+
unregisterCaptures();
|
|
125121
125882
|
if (lentSocketPath) await releaseLentThrottles();
|
|
125122
|
-
for (const { socket } of connections2.values()) {
|
|
125883
|
+
for (const { socket, cdp } of connections2.values()) {
|
|
125884
|
+
cdp.close();
|
|
125123
125885
|
socket.destroy();
|
|
125124
125886
|
}
|
|
125125
125887
|
connections2.clear();
|
|
125126
125888
|
activatedBundleIds.clear();
|
|
125889
|
+
captureGaps.clear();
|
|
125890
|
+
networkStores.clear();
|
|
125891
|
+
wakeConnectionWaiters();
|
|
125127
125892
|
networkConditions.clear();
|
|
125128
125893
|
unconfirmedThrottles.clear();
|
|
125129
125894
|
providerCapture.clear();
|
|
@@ -126030,7 +126795,7 @@ var import_node_util15 = require("node:util");
|
|
|
126030
126795
|
var fs25 = __toESM(require("node:fs/promises"));
|
|
126031
126796
|
var os7 = __toESM(require("node:os"));
|
|
126032
126797
|
var path21 = __toESM(require("node:path"));
|
|
126033
|
-
var
|
|
126798
|
+
var import_node_crypto8 = require("node:crypto");
|
|
126034
126799
|
init_src2();
|
|
126035
126800
|
|
|
126036
126801
|
// ../tool-server/src/utils/ios-device/usbmux-protocol.ts
|
|
@@ -126335,7 +127100,7 @@ async function runDevicectl(args, action, opts = {}) {
|
|
|
126335
127100
|
let jsonPath = null;
|
|
126336
127101
|
const argv = ["devicectl", ...args];
|
|
126337
127102
|
if (opts.json) {
|
|
126338
|
-
jsonPath = path21.join(os7.tmpdir(), `argent-devicectl-${process.pid}-${(0,
|
|
127103
|
+
jsonPath = path21.join(os7.tmpdir(), `argent-devicectl-${process.pid}-${(0, import_node_crypto8.randomUUID)()}.json`);
|
|
126339
127104
|
argv.push("--json-output", jsonPath);
|
|
126340
127105
|
}
|
|
126341
127106
|
try {
|
|
@@ -126607,7 +127372,7 @@ init_harmony_flag();
|
|
|
126607
127372
|
|
|
126608
127373
|
// ../tool-server/src/utils/macos-apps.ts
|
|
126609
127374
|
var import_node_child_process21 = require("node:child_process");
|
|
126610
|
-
var
|
|
127375
|
+
var import_node_crypto9 = require("node:crypto");
|
|
126611
127376
|
var fs26 = __toESM(require("node:fs"));
|
|
126612
127377
|
var os8 = __toESM(require("node:os"));
|
|
126613
127378
|
var path22 = __toESM(require("node:path"));
|
|
@@ -126693,7 +127458,7 @@ function stageMacosLibraries(bootstrapPath, libraryPath, teamId) {
|
|
|
126693
127458
|
}
|
|
126694
127459
|
var SOURCES_NAME = "sources";
|
|
126695
127460
|
function libraryHash(bootstrap, library) {
|
|
126696
|
-
return (0,
|
|
127461
|
+
return (0, import_node_crypto9.createHash)("sha256").update(`${bootstrap.length}:`).update(bootstrap).update(`${library.length}:`).update(library).digest("hex").slice(0, 16);
|
|
126697
127462
|
}
|
|
126698
127463
|
function recordLibrarySource(dir, source) {
|
|
126699
127464
|
const file2 = path22.join(dir, SOURCES_NAME);
|
|
@@ -126814,7 +127579,7 @@ function macosListenSocket(bundleId, sandboxed) {
|
|
|
126814
127579
|
}
|
|
126815
127580
|
const named = path22.join(macosArgentDir(), `${bundleId}.sock`);
|
|
126816
127581
|
if (fitsSocketPath(named)) return { env: named, path: named };
|
|
126817
|
-
const hash2 = (0,
|
|
127582
|
+
const hash2 = (0, import_node_crypto9.createHash)("sha256").update(bundleId).digest("hex").slice(0, 16);
|
|
126818
127583
|
const hashed = path22.join(macosArgentDir(), `${hash2}.sock`);
|
|
126819
127584
|
return fitsSocketPath(hashed) ? { env: hashed, path: hashed } : null;
|
|
126820
127585
|
}
|
|
@@ -128816,7 +129581,7 @@ function createTabsManager(deps) {
|
|
|
128816
129581
|
}
|
|
128817
129582
|
|
|
128818
129583
|
// ../tool-server/src/chromium-server/network.ts
|
|
128819
|
-
var
|
|
129584
|
+
var MAX_RECORDS2 = 1e3;
|
|
128820
129585
|
var shapesTraffic = (c) => c.offline || c.latency > 0 || c.downloadThroughput >= 0 || c.uploadThroughput >= 0;
|
|
128821
129586
|
function createNetworkManager(deps) {
|
|
128822
129587
|
const { cdp } = deps;
|
|
@@ -128829,7 +129594,7 @@ function createNetworkManager(deps) {
|
|
|
128829
129594
|
rec = { requestId, method: "", url: "", startedDateTime: "", startTs: 0 };
|
|
128830
129595
|
byId.set(requestId, rec);
|
|
128831
129596
|
order.push(requestId);
|
|
128832
|
-
if (order.length >
|
|
129597
|
+
if (order.length > MAX_RECORDS2) {
|
|
128833
129598
|
const evicted = order.shift();
|
|
128834
129599
|
if (evicted) byId.delete(evicted);
|
|
128835
129600
|
}
|
|
@@ -134023,37 +134788,6 @@ init_capability();
|
|
|
134023
134788
|
init_device_info();
|
|
134024
134789
|
init_external_devices();
|
|
134025
134790
|
|
|
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
134791
|
// ../tool-server/src/utils/invalid-params.ts
|
|
134058
134792
|
function deriveInvalidParams(error63, declared) {
|
|
134059
134793
|
const out = [];
|
|
@@ -135411,26 +136145,13 @@ function reserveLaunchMeasurement(udid) {
|
|
|
135411
136145
|
// ../tool-server/src/utils/ios-device/runner-artifact.ts
|
|
135412
136146
|
var import_node_child_process26 = require("node:child_process");
|
|
135413
136147
|
var import_node_util18 = require("node:util");
|
|
135414
|
-
var
|
|
136148
|
+
var import_node_crypto10 = require("node:crypto");
|
|
135415
136149
|
var fs35 = __toESM(require("node:fs"));
|
|
135416
136150
|
var fsp = __toESM(require("node:fs/promises"));
|
|
135417
136151
|
var os13 = __toESM(require("node:os"));
|
|
135418
136152
|
var path30 = __toESM(require("node:path"));
|
|
135419
136153
|
init_src2();
|
|
135420
136154
|
|
|
135421
|
-
// ../tool-server/src/utils/keyed-lock.ts
|
|
135422
|
-
async function withKeyedLock(locks, key2, fn) {
|
|
135423
|
-
const previous = locks.get(key2) ?? Promise.resolve();
|
|
135424
|
-
const run2 = previous.then(() => fn());
|
|
135425
|
-
const held = run2.catch(() => {
|
|
135426
|
-
});
|
|
135427
|
-
locks.set(key2, held);
|
|
135428
|
-
void held.then(() => {
|
|
135429
|
-
if (locks.get(key2) === held) locks.delete(key2);
|
|
135430
|
-
});
|
|
135431
|
-
return run2;
|
|
135432
|
-
}
|
|
135433
|
-
|
|
135434
136155
|
// ../tool-server/src/utils/ios-device/runner-signing.ts
|
|
135435
136156
|
init_src2();
|
|
135436
136157
|
|
|
@@ -135583,7 +136304,7 @@ var FINGERPRINT_NOISE = /* @__PURE__ */ new Set([
|
|
|
135583
136304
|
]);
|
|
135584
136305
|
async function fingerprintRunnerSources(projectPath) {
|
|
135585
136306
|
const root = path30.dirname(projectPath);
|
|
135586
|
-
const hash2 = (0,
|
|
136307
|
+
const hash2 = (0, import_node_crypto10.createHash)("sha256");
|
|
135587
136308
|
const walk = async (dir) => {
|
|
135588
136309
|
const entries = (await fsp.readdir(dir, { withFileTypes: true })).sort(
|
|
135589
136310
|
(a, b) => a.name.localeCompare(b.name)
|
|
@@ -135692,7 +136413,7 @@ function runnerBuildLocationArgs(derivedDataPath) {
|
|
|
135692
136413
|
];
|
|
135693
136414
|
}
|
|
135694
136415
|
function computeRunnerCacheKey(sourcesHash, xcodeVersion2, staticArgs) {
|
|
135695
|
-
return (0,
|
|
136416
|
+
return (0, import_node_crypto10.createHash)("sha256").update([sourcesHash, xcodeVersion2, ...staticArgs].join("\n")).digest("hex").slice(0, 16);
|
|
135696
136417
|
}
|
|
135697
136418
|
function isProfileMissingDeviceFailure(logText) {
|
|
135698
136419
|
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 +136723,7 @@ async function killStaleRunnersForDevice(udid, listProcesses = listProcessTable)
|
|
|
136002
136723
|
var fs38 = __toESM(require("node:fs/promises"));
|
|
136003
136724
|
|
|
136004
136725
|
// ../tool-server/src/utils/ios-device/runner-http.ts
|
|
136005
|
-
var
|
|
136726
|
+
var import_node_http3 = __toESM(require("node:http"));
|
|
136006
136727
|
|
|
136007
136728
|
// ../tool-server/src/utils/ios-device/usbmux.ts
|
|
136008
136729
|
var import_node_events3 = require("node:events");
|
|
@@ -136217,7 +136938,7 @@ var RUNNER_HTTP_MAX_RESPONSE_BYTES = 64 * 1024 * 1024;
|
|
|
136217
136938
|
async function postRunnerCommand(options) {
|
|
136218
136939
|
requireTimeRemaining(options.deadline.remainingMs(), "send runner command");
|
|
136219
136940
|
const socket = await options.socketFactory();
|
|
136220
|
-
const agent = new
|
|
136941
|
+
const agent = new import_node_http3.default.Agent({ keepAlive: false });
|
|
136221
136942
|
agent.createConnection = ((_options, callback) => {
|
|
136222
136943
|
callback?.(null, socket);
|
|
136223
136944
|
return socket;
|
|
@@ -136237,7 +136958,7 @@ async function requestOverAgent(agent, socket, payload, timeoutMs) {
|
|
|
136237
136958
|
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
136238
136959
|
try {
|
|
136239
136960
|
return await new Promise((resolve21, reject) => {
|
|
136240
|
-
const request3 =
|
|
136961
|
+
const request3 = import_node_http3.default.request(
|
|
136241
136962
|
{
|
|
136242
136963
|
method: "POST",
|
|
136243
136964
|
// Host header only because the connection is the injected socket.
|
|
@@ -136382,7 +137103,7 @@ async function readRunnerCrashSummary(resultBundlePath) {
|
|
|
136382
137103
|
}
|
|
136383
137104
|
|
|
136384
137105
|
// ../tool-server/src/utils/ios-device/runner-client.ts
|
|
136385
|
-
var
|
|
137106
|
+
var import_node_crypto11 = require("node:crypto");
|
|
136386
137107
|
init_src2();
|
|
136387
137108
|
var RUNNER_COMMAND_TIMEOUT_MS = 45e3;
|
|
136388
137109
|
var RUNNER_STATUS_RECOVERY_TIMEOUT_MS = 3e3;
|
|
@@ -136595,7 +137316,7 @@ function withCommandId(command) {
|
|
|
136595
137316
|
if (command.command === "status" || typeof command.commandId === "string") {
|
|
136596
137317
|
return command;
|
|
136597
137318
|
}
|
|
136598
|
-
return { ...command, commandId: `argent-${(0,
|
|
137319
|
+
return { ...command, commandId: `argent-${(0, import_node_crypto11.randomUUID)()}` };
|
|
136599
137320
|
}
|
|
136600
137321
|
function unwrapEnvelope(response, udid) {
|
|
136601
137322
|
const envelope = asEnvelope(response);
|
|
@@ -139633,7 +140354,7 @@ async function describeChromium(api, limits = DEFAULT_WALK_LIMITS) {
|
|
|
139633
140354
|
init_src2();
|
|
139634
140355
|
|
|
139635
140356
|
// ../tool-server/src/utils/vega-inspect.ts
|
|
139636
|
-
var
|
|
140357
|
+
var import_node_http4 = require("node:http");
|
|
139637
140358
|
init_adb();
|
|
139638
140359
|
|
|
139639
140360
|
// ../tool-server/src/utils/vega-automation.ts
|
|
@@ -139811,7 +140532,7 @@ async function fetchVegaPageSource(timeoutMs = 15e3) {
|
|
|
139811
140532
|
}
|
|
139812
140533
|
function postJson(host, port, path72, body, timeoutMs) {
|
|
139813
140534
|
return new Promise((resolve21, reject) => {
|
|
139814
|
-
const req = (0,
|
|
140535
|
+
const req = (0, import_node_http4.request)(
|
|
139815
140536
|
{
|
|
139816
140537
|
host,
|
|
139817
140538
|
port,
|
|
@@ -144829,6 +145550,7 @@ async function startSuspensionWatch(helperPath, pid) {
|
|
|
144829
145550
|
}
|
|
144830
145551
|
|
|
144831
145552
|
// ../tool-server/src/blueprints/macos-app.ts
|
|
145553
|
+
var NATIVE_NETWORK_LOG_LIMIT = 1e3;
|
|
144832
145554
|
var MACOS_APP_NAMESPACE = "MacosApp";
|
|
144833
145555
|
function macosAppRef(device) {
|
|
144834
145556
|
return { urn: `${MACOS_APP_NAMESPACE}:${device.id}`, options: { device } };
|
|
@@ -145229,7 +145951,7 @@ function createMacosAppApi(bundleId) {
|
|
|
145229
145951
|
const reconnect = async () => {
|
|
145230
145952
|
const app = await runningTrackedApp(bundleId);
|
|
145231
145953
|
if (!app) throw notRunningError(bundleId);
|
|
145232
|
-
const
|
|
145954
|
+
const notConnected3 = (detail, cause) => macosFailure(
|
|
145233
145955
|
`${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
145956
|
FAILURE_CODES.MACOS_APP_NOT_CONNECTED,
|
|
145235
145957
|
"macos_app_reconnect",
|
|
@@ -145254,7 +145976,7 @@ function createMacosAppApi(bundleId) {
|
|
|
145254
145976
|
await ch.waitForHandshake(RECONNECT_TIMEOUT_MS);
|
|
145255
145977
|
} catch (err) {
|
|
145256
145978
|
ch.close();
|
|
145257
|
-
throw
|
|
145979
|
+
throw notConnected3(errorMessage2(err), err);
|
|
145258
145980
|
}
|
|
145259
145981
|
if (disposed && !launching) {
|
|
145260
145982
|
ch.close();
|
|
@@ -148341,7 +149063,7 @@ function createHttpApp(registry2, options) {
|
|
|
148341
149063
|
});
|
|
148342
149064
|
return;
|
|
148343
149065
|
}
|
|
148344
|
-
const id = (0,
|
|
149066
|
+
const id = (0, import_node_crypto12.randomUUID)();
|
|
148345
149067
|
const tarPath = (0, import_node_path15.join)((0, import_node_os11.tmpdir)(), `argent-upload-${id}.tar.gz`);
|
|
148346
149068
|
const ws = (0, import_node_fs12.createWriteStream)(tarPath);
|
|
148347
149069
|
let received = 0;
|
|
@@ -148358,7 +149080,7 @@ function createHttpApp(registry2, options) {
|
|
|
148358
149080
|
});
|
|
148359
149081
|
if (!res.headersSent) res.status(status).json({ error: message });
|
|
148360
149082
|
};
|
|
148361
|
-
const digest = (0,
|
|
149083
|
+
const digest = (0, import_node_crypto12.createHash)("sha256");
|
|
148362
149084
|
req.on("data", (chunk) => {
|
|
148363
149085
|
if (released) return;
|
|
148364
149086
|
received += chunk.length;
|
|
@@ -148634,7 +149356,7 @@ function createHttpApp(registry2, options) {
|
|
|
148634
149356
|
});
|
|
148635
149357
|
const keepAlive = def.longRunning && options?.idleTimeoutMs && options.idleTimeoutMs > 0 ? setInterval(() => idleTimer.touch(), Math.max(1e3, IDLE_CHECK_INTERVAL_MS / 2)) : null;
|
|
148636
149358
|
if (keepAlive) keepAlive.unref?.();
|
|
148637
|
-
const toolInvocationId = (0,
|
|
149359
|
+
const toolInvocationId = (0, import_node_crypto12.randomUUID)();
|
|
148638
149360
|
let releaseInvocationMeta;
|
|
148639
149361
|
let recordChildInvocation;
|
|
148640
149362
|
const recordInvocation = options?.recordInvocation;
|
|
@@ -148972,13 +149694,12 @@ init_src2();
|
|
|
148972
149694
|
init_src();
|
|
148973
149695
|
|
|
148974
149696
|
// ../tool-server/src/blueprints/android-network-inspector.ts
|
|
148975
|
-
var
|
|
149697
|
+
var import_node_crypto13 = require("node:crypto");
|
|
148976
149698
|
var fs41 = __toESM(require("node:fs"));
|
|
148977
149699
|
var net8 = __toESM(require("node:net"));
|
|
148978
149700
|
var path35 = __toESM(require("node:path"));
|
|
148979
149701
|
init_src2();
|
|
148980
149702
|
init_adb();
|
|
148981
|
-
init_external_devices();
|
|
148982
149703
|
|
|
148983
149704
|
// ../tool-server/src/blueprints/android-network-inspector-device.ts
|
|
148984
149705
|
init_adb();
|
|
@@ -149144,9 +149865,6 @@ function isAgentReason(message) {
|
|
|
149144
149865
|
|
|
149145
149866
|
// ../tool-server/src/blueprints/android-network-inspector.ts
|
|
149146
149867
|
var ANDROID_NETWORK_INSPECTOR_NAMESPACE = "AndroidNetworkInspector";
|
|
149147
|
-
function deviceKeyOf(deviceId) {
|
|
149148
|
-
return externalNativeId(canonicalDeviceId(deviceId) ?? deviceId);
|
|
149149
|
-
}
|
|
149150
149868
|
function androidNetworkInspectorRef(device, packageName, metroPort2) {
|
|
149151
149869
|
return {
|
|
149152
149870
|
urn: `${ANDROID_NETWORK_INSPECTOR_NAMESPACE}:${deviceKeyOf(device.id)}:${packageName}`,
|
|
@@ -149156,14 +149874,7 @@ function androidNetworkInspectorRef(device, packageName, metroPort2) {
|
|
|
149156
149874
|
var MIN_SDK = 26;
|
|
149157
149875
|
var PACKAGE_NAME2 = /^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)*$/;
|
|
149158
149876
|
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
149877
|
var MAX_REDIRECTS = 32;
|
|
149165
|
-
var MAX_LAYER_ID_CHARS = 200;
|
|
149166
|
-
var MAX_CACHED_BODIES = 64;
|
|
149167
149878
|
var MAX_FRAME_CHARS = 8 * 1024 * 1024;
|
|
149168
149879
|
var HANDSHAKE_FRAME_CHARS = 4 * 1024;
|
|
149169
149880
|
var MAX_PENDING_HANDSHAKES = 32;
|
|
@@ -149184,14 +149895,12 @@ var SESSION_REMOVE_TIMEOUT_MS = 5e3;
|
|
|
149184
149895
|
var AGENT_BINARIES_MISSING_REASON = "agent binaries not present in this build";
|
|
149185
149896
|
var AGENT_GONE_REASON = "the agent that recorded the request is no longer in the app, as after an emulator snapshot load";
|
|
149186
149897
|
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
149898
|
var JS_LAYER_FALLBACK = "Use view-network-logs: the JS layer still records the app's JavaScript requests while Metro serves the app.";
|
|
149190
149899
|
var LOGGED_DETAIL_EVENTS = /* @__PURE__ */ new Set(["interceptor_installed", "interceptor_failed"]);
|
|
149191
|
-
var
|
|
149900
|
+
var RUN_TAG2 = (0, import_node_crypto13.randomBytes)(2).toString("hex");
|
|
149192
149901
|
var ANDROID_NATIVE_REQUEST_ID = /^android-[0-9a-f]{4}-\d+$/;
|
|
149193
149902
|
var liveInspectors = /* @__PURE__ */ new Map();
|
|
149194
|
-
var
|
|
149903
|
+
var nextRecordNumber2 = 1;
|
|
149195
149904
|
function allHandles() {
|
|
149196
149905
|
return [...liveInspectors.values()].flatMap((set2) => [...set2]);
|
|
149197
149906
|
}
|
|
@@ -149287,7 +149996,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
149287
149996
|
process.stderr.write(`[${tag3}] ${line}
|
|
149288
149997
|
`);
|
|
149289
149998
|
};
|
|
149290
|
-
const secret = (0,
|
|
149999
|
+
const secret = (0, import_node_crypto13.randomBytes)(32).toString("hex");
|
|
149291
150000
|
let metroPort2 = initialMetroPort;
|
|
149292
150001
|
let disposed = false;
|
|
149293
150002
|
let live = false;
|
|
@@ -149508,7 +150217,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
149508
150217
|
}
|
|
149509
150218
|
async function bindDevicePort() {
|
|
149510
150219
|
for (let attempt = 0; attempt < DEVICE_PORT_ATTEMPTS; attempt++) {
|
|
149511
|
-
const port = DEVICE_PORT_MIN + (0,
|
|
150220
|
+
const port = DEVICE_PORT_MIN + (0, import_node_crypto13.randomInt)(DEVICE_PORT_SPAN);
|
|
149512
150221
|
try {
|
|
149513
150222
|
await adbReverse(serial, port, hostPort, { timeoutMs: 1e4, noRebind: true });
|
|
149514
150223
|
} catch (err) {
|
|
@@ -149759,7 +150468,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
149759
150468
|
return;
|
|
149760
150469
|
}
|
|
149761
150470
|
agentNonce = payload.nonce;
|
|
149762
|
-
serverNonce = (0,
|
|
150471
|
+
serverNonce = (0, import_node_crypto13.randomBytes)(16).toString("hex");
|
|
149763
150472
|
writeNdjsonFrame(socket, {
|
|
149764
150473
|
type: "Control",
|
|
149765
150474
|
payload: {
|
|
@@ -150121,7 +150830,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150121
150830
|
const req = asObject(p.request);
|
|
150122
150831
|
const startedAt = typeof p.wallTime === "number" ? p.wallTime * 1e3 : typeof p.timestamp === "number" ? p.timestamp * 1e3 : Date.now();
|
|
150123
150832
|
const record2 = {
|
|
150124
|
-
id: `android-${
|
|
150833
|
+
id: `android-${RUN_TAG2}-${nextRecordNumber2++}`,
|
|
150125
150834
|
layer: "android-native",
|
|
150126
150835
|
layerId,
|
|
150127
150836
|
connection: conn.index,
|
|
@@ -150156,7 +150865,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150156
150865
|
const size = recordSize(record2);
|
|
150157
150866
|
recordChars += size - (recordSizes.get(record2) ?? 0);
|
|
150158
150867
|
recordSizes.set(record2, size);
|
|
150159
|
-
while (records.length >
|
|
150868
|
+
while (records.length > MAX_RECORDS || records.length > 1 && recordChars > RECORD_CHARS_BUDGET) {
|
|
150160
150869
|
evict(records.shift());
|
|
150161
150870
|
}
|
|
150162
150871
|
}
|
|
@@ -150221,9 +150930,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150221
150930
|
const conn = liveConnectionFor(entry.conn);
|
|
150222
150931
|
if (!conn) {
|
|
150223
150932
|
return Promise.resolve(
|
|
150224
|
-
unavailable(
|
|
150225
|
-
agentGoneFor(entry.conn) ? AGENT_GONE_REASON : "the app process that made the request is gone"
|
|
150226
|
-
)
|
|
150933
|
+
unavailable(agentGoneFor(entry.conn) ? AGENT_GONE_REASON : PROCESS_GONE)
|
|
150227
150934
|
);
|
|
150228
150935
|
}
|
|
150229
150936
|
const sending = kind === "post" && record2.state === "pending";
|
|
@@ -150391,7 +151098,9 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150391
151098
|
...!conn && note ? { note: shownNote() } : {}
|
|
150392
151099
|
};
|
|
150393
151100
|
},
|
|
150394
|
-
records: (port) => records.filter(
|
|
151101
|
+
records: (port) => records.filter(
|
|
151102
|
+
(r) => !cleared.has(r) && !isMetroTraffic(r.request.url, port, { androidEmulatorHost: true })
|
|
151103
|
+
),
|
|
150395
151104
|
record: (id) => byId.get(id)?.record,
|
|
150396
151105
|
responseBody: (id) => fetchBody(id, "response"),
|
|
150397
151106
|
requestPostData: (id) => fetchBody(id, "post"),
|
|
@@ -150442,14 +151151,14 @@ function readHandshake(payload) {
|
|
|
150442
151151
|
}
|
|
150443
151152
|
function proofMatches(proof, expected) {
|
|
150444
151153
|
if (!isHex2(proof, 64)) return false;
|
|
150445
|
-
return (0,
|
|
151154
|
+
return (0, import_node_crypto13.timingSafeEqual)(Buffer.from(proof, "hex"), Buffer.from(expected, "hex"));
|
|
150446
151155
|
}
|
|
150447
151156
|
function handshakeProof(secret, parts2) {
|
|
150448
|
-
return (0,
|
|
151157
|
+
return (0, import_node_crypto13.createHmac)("sha256", Buffer.from(secret, "ascii")).update(parts2.join("\n"), "utf8").digest("hex");
|
|
150449
151158
|
}
|
|
150450
151159
|
function sessionKeys(agentNonce, serverNonce, secret) {
|
|
150451
|
-
const prk = (0,
|
|
150452
|
-
const expand = (info) => (0,
|
|
151160
|
+
const prk = (0, import_node_crypto13.createHmac)("sha256", Buffer.from(agentNonce + serverNonce, "ascii")).update(Buffer.from(secret, "ascii")).digest();
|
|
151161
|
+
const expand = (info) => (0, import_node_crypto13.createHmac)("sha256", prk).update(Buffer.concat([Buffer.from(info, "ascii"), Buffer.of(1)])).digest();
|
|
150453
151162
|
return {
|
|
150454
151163
|
agent: expand("argent-nwi agent to server"),
|
|
150455
151164
|
server: expand("argent-nwi server to agent")
|
|
@@ -150461,7 +151170,7 @@ function frameIv(counter) {
|
|
|
150461
151170
|
return iv;
|
|
150462
151171
|
}
|
|
150463
151172
|
function sealFrame(key2, counter, frame2) {
|
|
150464
|
-
const cipher = (0,
|
|
151173
|
+
const cipher = (0, import_node_crypto13.createCipheriv)("aes-256-gcm", key2, frameIv(counter), {
|
|
150465
151174
|
authTagLength: GCM_TAG_BYTES
|
|
150466
151175
|
});
|
|
150467
151176
|
return Buffer.concat([
|
|
@@ -150479,7 +151188,7 @@ function openFrame(key2, counter, sealed) {
|
|
|
150479
151188
|
}
|
|
150480
151189
|
let plaintext;
|
|
150481
151190
|
try {
|
|
150482
|
-
const decipher = (0,
|
|
151191
|
+
const decipher = (0, import_node_crypto13.createDecipheriv)("aes-256-gcm", key2, frameIv(counter), {
|
|
150483
151192
|
authTagLength: GCM_TAG_BYTES
|
|
150484
151193
|
});
|
|
150485
151194
|
decipher.setAuthTag(bytes.subarray(bytes.length - GCM_TAG_BYTES));
|
|
@@ -150511,9 +151220,6 @@ function isHex2(value, length) {
|
|
|
150511
151220
|
function isCount(value) {
|
|
150512
151221
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
150513
151222
|
}
|
|
150514
|
-
function isOpen(record2) {
|
|
150515
|
-
return record2.state === "pending" || record2.state === "headers";
|
|
150516
|
-
}
|
|
150517
151223
|
function parseCapture(value) {
|
|
150518
151224
|
const o = asObject(value);
|
|
150519
151225
|
if (o.state !== "active" && o.state !== "waiting" && o.state !== "unavailable") return void 0;
|
|
@@ -150534,78 +151240,6 @@ function agentFiles() {
|
|
|
150534
151240
|
function isAgentAbi(abi) {
|
|
150535
151241
|
return AGENT_ABIS.includes(abi);
|
|
150536
151242
|
}
|
|
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
|
-
function toBody(result, kind) {
|
|
150548
|
-
const r = asObject(result);
|
|
150549
|
-
const text = kind === "response" ? r.body : r.postData;
|
|
150550
|
-
if (r.bodyAvailable === false || typeof text !== "string") {
|
|
150551
|
-
return unavailable(
|
|
150552
|
-
kind === "response" ? "the agent holds no body for this response" : "the agent holds no body for this request"
|
|
150553
|
-
);
|
|
150554
|
-
}
|
|
150555
|
-
return {
|
|
150556
|
-
available: true,
|
|
150557
|
-
body: text,
|
|
150558
|
-
base64Encoded: r.base64Encoded === true,
|
|
150559
|
-
truncated: r.wasTruncated === true
|
|
150560
|
-
};
|
|
150561
|
-
}
|
|
150562
|
-
function unavailable(reason2) {
|
|
150563
|
-
return { available: false, body: "", base64Encoded: false, truncated: false, reason: reason2 };
|
|
150564
|
-
}
|
|
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
151243
|
function isOwnFailure(err) {
|
|
150610
151244
|
const code = getFailureSignal(err)?.error_code;
|
|
150611
151245
|
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 +151400,7 @@ Fails if the simulator server is not running for the given UDID.`,
|
|
|
150766
151400
|
init_zod();
|
|
150767
151401
|
init_src2();
|
|
150768
151402
|
init_device_info();
|
|
151403
|
+
init_external_devices();
|
|
150769
151404
|
|
|
150770
151405
|
// ../tool-server/src/tools/native-devtools/macos-view-hierarchy.ts
|
|
150771
151406
|
init_zod();
|
|
@@ -150931,11 +151566,13 @@ var zodSchema4 = external_exports.object({
|
|
|
150931
151566
|
"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
151567
|
),
|
|
150933
151568
|
port: metroPortField.describe(
|
|
150934
|
-
"
|
|
151569
|
+
"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>"
|
|
151570
|
+
),
|
|
151571
|
+
limit: external_exports.number().int().nonnegative().optional().default(50).describe(
|
|
151572
|
+
"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
151573
|
),
|
|
150936
|
-
limit: external_exports.number().optional().default(50).describe("Maximum number of entries to return: the most recent ones, oldest first"),
|
|
150937
151574
|
clear: external_exports.boolean().optional().default(false).describe(
|
|
150938
|
-
"Clear the log after reading. On Android, the IDs of cleared requests still work in view-network-request-details"
|
|
151575
|
+
"Clear the log after reading. On iOS and Android, the IDs of cleared requests still work in view-network-request-details"
|
|
150939
151576
|
),
|
|
150940
151577
|
stop: external_exports.boolean().optional().describe(
|
|
150941
151578
|
"Android only: turn native capture off for this app instead of listing. Other apps keep theirs."
|
|
@@ -150957,15 +151594,17 @@ function createNativeNetworkLogsTool(registry2) {
|
|
|
150957
151594
|
},
|
|
150958
151595
|
description: `Retrieve network requests captured at the native level: NSURLProtocol on iOS, OkHttp on Android.
|
|
150959
151596
|
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
|
|
151597
|
+
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.
|
|
151598
|
+
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. Pass a request's id to view-network-request-details for its headers and bodies, and on Android its redirects. The history is kept across relaunches of the app.
|
|
151599
|
+
The first call for an app starts capture, so earlier requests are not captured: repeat the action whose requests you need, then call again.
|
|
151600
|
+
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.
|
|
151601
|
+
<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.
|
|
151602
|
+
</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.
|
|
151603
|
+
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).
|
|
151604
|
+
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
151605
|
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
|
|
151606
|
+
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.
|
|
151607
|
+
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
151608
|
When status is not_attachable, use view-network-logs and do not retry.`,
|
|
150970
151609
|
zodSchema: zodSchema4,
|
|
150971
151610
|
services: (params) => {
|
|
@@ -150993,37 +151632,48 @@ When status is not_attachable, use view-network-logs and do not retry.`,
|
|
|
150993
151632
|
params.bundleId
|
|
150994
151633
|
);
|
|
150995
151634
|
await app.activateNetworkInspection();
|
|
150996
|
-
const
|
|
151635
|
+
const events = params.limit === 0 ? [] : app.networkLog().slice(-params.limit);
|
|
150997
151636
|
if (params.clear) app.clearNetworkLog();
|
|
150998
|
-
return { status: "ok", count:
|
|
151637
|
+
return { status: "ok", count: events.length, events };
|
|
150999
151638
|
}
|
|
151000
151639
|
await ensureDeps(device.platform === "ios-remote" ? ["sim-remote"] : ["xcrun"]);
|
|
151001
151640
|
const api = services.nativeDevtools;
|
|
151002
151641
|
const blocked = await precheckNativeDevtools(api, params.udid, params.bundleId);
|
|
151642
|
+
const arming = api.activateNetworkInspection(params.bundleId);
|
|
151003
151643
|
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
|
-
|
|
151644
|
+
if (!api.isConnected(params.bundleId)) throw notConnected(api, params.bundleId);
|
|
151645
|
+
await arming;
|
|
151646
|
+
const store = api.networkRecords(params.bundleId);
|
|
151647
|
+
if (!store) throw notConnected(api, params.bundleId);
|
|
151648
|
+
const all = store.records(metroPort({ device_id: params.udid, port: params.port }));
|
|
151649
|
+
const state3 = store.state();
|
|
151650
|
+
const detail = [];
|
|
151651
|
+
if (state3.pid !== void 0) detail.push(`pid ${state3.pid}`);
|
|
151652
|
+
if (state3.note) detail.push(state3.note);
|
|
151653
|
+
if (api.takeCaptureGap(params.bundleId)) detail.push(captureGapNote(api.armsEnv));
|
|
151654
|
+
const listing = listNative("ios-native", all, params.limit, state3.armed, detail);
|
|
151655
|
+
if (params.clear) store.clear();
|
|
151656
|
+
return listing;
|
|
151657
|
+
}
|
|
151658
|
+
};
|
|
151659
|
+
}
|
|
151660
|
+
function notConnected(api, bundleId) {
|
|
151661
|
+
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.`;
|
|
151662
|
+
return new FailureError(`Native devtools not connected for bundleId: ${bundleId}. ${remedy}`, {
|
|
151663
|
+
error_code: FAILURE_CODES.NATIVE_DEVTOOLS_NOT_CONNECTED,
|
|
151664
|
+
error_kind: "not_found",
|
|
151665
|
+
failure_area: "tool_server",
|
|
151666
|
+
failure_stage: "native_network_logs_connection"
|
|
151667
|
+
});
|
|
151668
|
+
}
|
|
151669
|
+
function captureGapNote(armsEnv) {
|
|
151670
|
+
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
151671
|
}
|
|
151022
151672
|
async function stopAndroidNative(registry2, params) {
|
|
151023
151673
|
const device = resolveDevice(params.udid);
|
|
151024
151674
|
if (device.platform !== "android") {
|
|
151025
151675
|
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.",
|
|
151676
|
+
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
151677
|
{
|
|
151028
151678
|
error_code: FAILURE_CODES.NATIVE_NETWORK_LOGS_STOP_UNSUPPORTED,
|
|
151029
151679
|
failure_stage: "native_network_logs_stop",
|
|
@@ -151060,21 +151710,31 @@ async function listAndroidNative(api, params) {
|
|
|
151060
151710
|
const attached = await api.ensureAttached(port);
|
|
151061
151711
|
if (attached?.status === "not_attachable") return attached;
|
|
151062
151712
|
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
151713
|
const state3 = api.state();
|
|
151067
|
-
const
|
|
151714
|
+
const listing = listNative(
|
|
151715
|
+
"android-native",
|
|
151716
|
+
all,
|
|
151717
|
+
params.limit,
|
|
151718
|
+
state3.armed,
|
|
151719
|
+
headerDetail(state3, attached?.note)
|
|
151720
|
+
);
|
|
151721
|
+
if (params.clear) api.clear();
|
|
151722
|
+
return {
|
|
151723
|
+
...listing,
|
|
151724
|
+
...state3.capture ? { capture: state3.capture.state } : {},
|
|
151725
|
+
...state3.capture?.detail ? { captureDetail: state3.capture.detail } : {}
|
|
151726
|
+
};
|
|
151727
|
+
}
|
|
151728
|
+
function listNative(layer, all, limit, armed, detail) {
|
|
151729
|
+
const shown = limit === 0 ? [] : all.slice(-limit);
|
|
151068
151730
|
const noun = all.length === 1 ? "request" : "requests";
|
|
151069
151731
|
return {
|
|
151070
151732
|
status: "ok",
|
|
151071
|
-
header:
|
|
151072
|
-
armed
|
|
151073
|
-
|
|
151074
|
-
...state3.capture?.detail ? { captureDetail: state3.capture.detail } : {},
|
|
151075
|
-
count: requests.length,
|
|
151733
|
+
header: `${layer}: ${armed ? "armed" : "not armed"}, ${all.length} ${noun}` + (detail.length > 0 ? ` (${detail.join("; ")})` : ""),
|
|
151734
|
+
armed,
|
|
151735
|
+
count: shown.length,
|
|
151076
151736
|
total: all.length,
|
|
151077
|
-
requests
|
|
151737
|
+
requests: shown.map(toRequestLine)
|
|
151078
151738
|
};
|
|
151079
151739
|
}
|
|
151080
151740
|
function headerDetail(state3, callNote) {
|
|
@@ -151478,7 +152138,7 @@ init_device_info();
|
|
|
151478
152138
|
init_external_devices();
|
|
151479
152139
|
|
|
151480
152140
|
// ../tool-server/src/utils/debugger/target-selection.ts
|
|
151481
|
-
var
|
|
152141
|
+
var import_node_crypto14 = require("node:crypto");
|
|
151482
152142
|
init_src2();
|
|
151483
152143
|
init_device_info();
|
|
151484
152144
|
init_external_devices();
|
|
@@ -151501,7 +152161,7 @@ function macosAppBundleIdOf(target) {
|
|
|
151501
152161
|
const vendorIds = trackedMacosAppKind(bundleId) === "catalyst" ? catalystVendorId ? [catalystVendorId] : [] : [""];
|
|
151502
152162
|
for (const vendorId of vendorIds) {
|
|
151503
152163
|
for (const mode of ["fusebox", "legacy"]) {
|
|
151504
|
-
const id = (0,
|
|
152164
|
+
const id = (0, import_node_crypto14.createHash)("sha256").update(`apple-${vendorId}-${bundleId}-${mode}`).digest("hex").slice(0, 40);
|
|
151505
152165
|
if (id === logicalId) return bundleId;
|
|
151506
152166
|
}
|
|
151507
152167
|
}
|
|
@@ -152151,6 +152811,7 @@ var jsRuntimeDebuggerBlueprint = {
|
|
|
152151
152811
|
init_src2();
|
|
152152
152812
|
|
|
152153
152813
|
// ../tool-server/src/utils/debugger/scripts/network-interceptor.ts
|
|
152814
|
+
var BINARY_BODY_TYPES = /^(image\/(?!svg)|audio\/|video\/|font\/|application\/(octet-stream|pdf|zip|gzip|wasm|x-protobuf)$)/;
|
|
152154
152815
|
var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
152155
152816
|
var g = globalThis;
|
|
152156
152817
|
if (g.__argent_network_v2) return JSON.stringify({ installed: false, reason: 'already installed' });
|
|
@@ -152229,7 +152890,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
152229
152890
|
}
|
|
152230
152891
|
|
|
152231
152892
|
// A body of one of these types is not text: its size is recorded and it is not read as text.
|
|
152232
|
-
var BINARY_TYPES =
|
|
152893
|
+
var BINARY_TYPES = ${BINARY_BODY_TYPES};
|
|
152233
152894
|
function isBinaryType(mime) {
|
|
152234
152895
|
return typeof mime === 'string' && BINARY_TYPES.test(mime.toLowerCase());
|
|
152235
152896
|
}
|
|
@@ -156256,13 +156917,11 @@ var execFileAsync25 = (0, import_node_util25.promisify)(import_node_child_proces
|
|
|
156256
156917
|
function makeIosImpl(registry2) {
|
|
156257
156918
|
return {
|
|
156258
156919
|
requires: ["xcrun"],
|
|
156259
|
-
handler: async (_services, params, device) => {
|
|
156920
|
+
handler: async (_services, params, device, options) => {
|
|
156921
|
+
let nativeDevtools;
|
|
156260
156922
|
if (!externalClaimForAnyId(device.id)) {
|
|
156261
156923
|
const ndRef = nativeDevtoolsRef(device);
|
|
156262
|
-
|
|
156263
|
-
ndRef.urn,
|
|
156264
|
-
ndRef.options
|
|
156265
|
-
);
|
|
156924
|
+
nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
|
|
156266
156925
|
const blocked = await precheckNativeDevtools(nativeDevtools, params.udid);
|
|
156267
156926
|
if (blocked) return blocked;
|
|
156268
156927
|
}
|
|
@@ -156315,7 +156974,18 @@ function makeIosImpl(registry2) {
|
|
|
156315
156974
|
{ cause: err instanceof Error ? err : new Error(String(err)) }
|
|
156316
156975
|
);
|
|
156317
156976
|
}
|
|
156318
|
-
|
|
156977
|
+
const capture = nativeDevtools ? await settleWithin(
|
|
156978
|
+
nativeDevtools.networkCaptureAfterLaunch(params.bundleId),
|
|
156979
|
+
void 0,
|
|
156980
|
+
options?.signal
|
|
156981
|
+
) : void 0;
|
|
156982
|
+
if (capture?.type === "error") throw capture.cause;
|
|
156983
|
+
const networkCapture = capture?.type === "value" ? capture.value : void 0;
|
|
156984
|
+
return {
|
|
156985
|
+
launched: true,
|
|
156986
|
+
bundleId: params.bundleId,
|
|
156987
|
+
...networkCapture ? { networkCapture } : {}
|
|
156988
|
+
};
|
|
156319
156989
|
}
|
|
156320
156990
|
};
|
|
156321
156991
|
}
|
|
@@ -156748,7 +157418,7 @@ function createLaunchAppTool(registry2) {
|
|
|
156748
157418
|
longRunning: true,
|
|
156749
157419
|
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
157420
|
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>
|
|
157421
|
+
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
157422
|
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
157423
|
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
157424
|
|
|
@@ -156800,14 +157470,12 @@ var execFileAsync26 = (0, import_node_util26.promisify)(import_node_child_proces
|
|
|
156800
157470
|
function makeIosImpl2(registry2) {
|
|
156801
157471
|
return {
|
|
156802
157472
|
requires: ["xcrun"],
|
|
156803
|
-
handler: async (_services, params, device) => {
|
|
157473
|
+
handler: async (_services, params, device, options) => {
|
|
156804
157474
|
const { udid, bundleId } = params;
|
|
157475
|
+
let nativeDevtools;
|
|
156805
157476
|
if (!externalClaimForAnyId(device.id)) {
|
|
156806
157477
|
const ndRef = nativeDevtoolsRef(device);
|
|
156807
|
-
|
|
156808
|
-
ndRef.urn,
|
|
156809
|
-
ndRef.options
|
|
156810
|
-
);
|
|
157478
|
+
nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
|
|
156811
157479
|
const blocked = await precheckNativeDevtools(nativeDevtools, udid);
|
|
156812
157480
|
if (blocked) return blocked;
|
|
156813
157481
|
}
|
|
@@ -156852,7 +157520,14 @@ function makeIosImpl2(registry2) {
|
|
|
156852
157520
|
{ cause: err instanceof Error ? err : new Error(String(err)) }
|
|
156853
157521
|
);
|
|
156854
157522
|
}
|
|
156855
|
-
|
|
157523
|
+
const capture = nativeDevtools ? await settleWithin(
|
|
157524
|
+
nativeDevtools.networkCaptureAfterLaunch(bundleId),
|
|
157525
|
+
void 0,
|
|
157526
|
+
options?.signal
|
|
157527
|
+
) : void 0;
|
|
157528
|
+
if (capture?.type === "error") throw capture.cause;
|
|
157529
|
+
const networkCapture = capture?.type === "value" ? capture.value : void 0;
|
|
157530
|
+
return { restarted: true, bundleId, ...networkCapture ? { networkCapture } : {} };
|
|
156856
157531
|
}
|
|
156857
157532
|
};
|
|
156858
157533
|
}
|
|
@@ -157043,7 +157718,7 @@ function createRestartAppTool(registry2) {
|
|
|
157043
157718
|
longRunning: true,
|
|
157044
157719
|
description: `Terminate then relaunch an app on iOS, Android, <flag:harmonyos>HarmonyOS, </flag:harmonyos><flag:macos-apps>macOS, </flag:macos-apps>or Vega.
|
|
157045
157720
|
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>
|
|
157721
|
+
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
157722
|
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
157723
|
zodSchema: zodSchema12,
|
|
157049
157724
|
alwaysLoad: true,
|
|
@@ -161621,7 +162296,7 @@ function missingBundleId() {
|
|
|
161621
162296
|
error_kind: "validation"
|
|
161622
162297
|
});
|
|
161623
162298
|
}
|
|
161624
|
-
function
|
|
162299
|
+
function notConnected2(bundleId) {
|
|
161625
162300
|
return new FailureError(`Native devtools not connected for bundleId: ${bundleId}.`, {
|
|
161626
162301
|
error_code: FAILURE_CODES.NATIVE_DEVTOOLS_NOT_CONNECTED,
|
|
161627
162302
|
failure_stage: "network_conditions_connection",
|
|
@@ -161657,7 +162332,7 @@ var iosImpl5 = {
|
|
|
161657
162332
|
if (conditions || !await isNotRunning(api, bundleId)) {
|
|
161658
162333
|
const blocked = await precheckNativeDevtools(api, params.udid, bundleId);
|
|
161659
162334
|
if (blocked) return blocked;
|
|
161660
|
-
if (!api.isConnected(bundleId)) throw
|
|
162335
|
+
if (!api.isConnected(bundleId)) throw notConnected2(bundleId);
|
|
161661
162336
|
}
|
|
161662
162337
|
const throttle = conditions && {
|
|
161663
162338
|
conditions: toCdpNetworkConditions(conditions),
|
|
@@ -162393,7 +163068,7 @@ init_device_info();
|
|
|
162393
163068
|
init_capability();
|
|
162394
163069
|
|
|
162395
163070
|
// ../tool-server/src/utils/sub-invoke.ts
|
|
162396
|
-
var
|
|
163071
|
+
var import_node_crypto15 = require("node:crypto");
|
|
162397
163072
|
init_src2();
|
|
162398
163073
|
async function invokeSubTool(registry2, ctx, toolId, args, extra) {
|
|
162399
163074
|
const signal = ctx?.signal;
|
|
@@ -162409,7 +163084,7 @@ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
|
|
|
162409
163084
|
if (!recordChildInvocation) {
|
|
162410
163085
|
return signal || Object.keys(forwarded).length > 0 ? registry2.invokeTool(toolId, args, { ...signal ? { signal } : {}, ...forwarded }) : registry2.invokeTool(toolId, args);
|
|
162411
163086
|
}
|
|
162412
|
-
const toolInvocationId = (0,
|
|
163087
|
+
const toolInvocationId = (0, import_node_crypto15.randomUUID)();
|
|
162413
163088
|
const release2 = recordChildInvocation(toolInvocationId, args);
|
|
162414
163089
|
try {
|
|
162415
163090
|
return await registry2.invokeTool(toolId, args, {
|
|
@@ -164319,7 +164994,7 @@ When the debugger cannot be reached, it returns { status: "not_connected", reaso
|
|
|
164319
164994
|
}
|
|
164320
164995
|
|
|
164321
164996
|
// ../tool-server/src/tools/network/network-logs.ts
|
|
164322
|
-
var
|
|
164997
|
+
var import_node_http5 = require("node:http");
|
|
164323
164998
|
init_zod();
|
|
164324
164999
|
var import_bytes3 = __toESM(require_bytes());
|
|
164325
165000
|
init_device_info();
|
|
@@ -164331,7 +165006,7 @@ function formatBytes2(bytes) {
|
|
|
164331
165006
|
return (0, import_bytes3.default)(bytes, { decimalPlaces: 1, unitSeparator: " " }) ?? `${bytes} B`;
|
|
164332
165007
|
}
|
|
164333
165008
|
function reasonPhrase(status) {
|
|
164334
|
-
return
|
|
165009
|
+
return import_node_http5.STATUS_CODES[status] ?? "";
|
|
164335
165010
|
}
|
|
164336
165011
|
function comparableUrl(url2) {
|
|
164337
165012
|
let text = url2;
|
|
@@ -164533,11 +165208,16 @@ function redactHeaders(headers) {
|
|
|
164533
165208
|
}
|
|
164534
165209
|
return result;
|
|
164535
165210
|
}
|
|
164536
|
-
var
|
|
165211
|
+
var NATIVE_ID_PREFIXES = { android: "android-", ios: "ios-" };
|
|
165212
|
+
function nativeIdPlatform2(requestId) {
|
|
165213
|
+
if (requestId.startsWith(NATIVE_ID_PREFIXES.android)) return "android";
|
|
165214
|
+
if (requestId.startsWith(NATIVE_ID_PREFIXES.ios)) return "ios";
|
|
165215
|
+
return void 0;
|
|
165216
|
+
}
|
|
164537
165217
|
var MAX_BODY_SIZE = 1e3;
|
|
164538
165218
|
var MAX_DECODED_BODY_BYTES = 16 * 1024 * 1024;
|
|
164539
165219
|
function cutMarker(fullSize, mimeType, shown = MAX_BODY_SIZE) {
|
|
164540
|
-
const mime = mimeType
|
|
165220
|
+
const mime = mimeType ? `, MIME: ${mimeType}` : "";
|
|
164541
165221
|
return `[TRUNCATED: first ${shown} chars shown, full size: ${fullSize}${mime}]`;
|
|
164542
165222
|
}
|
|
164543
165223
|
function truncateBody(body, mimeType) {
|
|
@@ -164560,16 +165240,18 @@ ${postData.slice(0, MAX_BODY_SIZE)}...`;
|
|
|
164560
165240
|
var zodSchema39 = external_exports.object({
|
|
164561
165241
|
port: metroPortField,
|
|
164562
165242
|
device_id: external_exports.string().describe(
|
|
164563
|
-
"Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An android- ID needs no debugger connection."
|
|
165243
|
+
"Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An ios- or android- ID needs no debugger connection."
|
|
165244
|
+
),
|
|
165245
|
+
requestId: external_exports.string().describe(
|
|
165246
|
+
"The requestId from view-network-logs, or an ios- or android- ID from native-network-logs."
|
|
164564
165247
|
),
|
|
164565
|
-
requestId: external_exports.string().describe("The requestId from view-network-logs, or an android- ID from native-network-logs."),
|
|
164566
165248
|
includeBody: external_exports.boolean().default(true).describe("Whether to include the response body (if captured).")
|
|
164567
165249
|
});
|
|
164568
165250
|
var networkRequestTool = {
|
|
164569
165251
|
id: "view-network-request-details",
|
|
164570
|
-
description: `Get full details of a specific network request by its requestId.
|
|
165252
|
+
description: `Get full details of a specific network request by its requestId: one from view-network-logs, or an ios- or android- ID from native-network-logs, which needs no debugger connection.
|
|
164571
165253
|
Returns request/response headers (sensitive headers redacted), status, timing, the request body, and optionally the response body.
|
|
164572
|
-
Request and response bodies over 1000 chars are cut to 1000 under a "[TRUNCATED: ...]" line that gives the full size; a binary response body is omitted. Use when you need headers, body, or timing for a specific request after listing logs.
|
|
165254
|
+
Request and response bodies over 1000 chars are cut to 1000 under a "[TRUNCATED: ...]" line that gives the full size; a binary response body is omitted, as is a binary request body of an ios- or android- ID. For an ios- or android- ID, a body that cannot be read shows "[unavailable: <reason>]"; when the reason says the app may still be sending the request body, call again once the request has ended. Use when you need headers, body, or timing for a specific request after listing logs.
|
|
164573
165255
|
Returns an error message string if the requestId is not found.`,
|
|
164574
165256
|
zodSchema: zodSchema39,
|
|
164575
165257
|
readOnly: true,
|
|
@@ -164580,19 +165262,24 @@ Returns an error message string if the requestId is not found.`,
|
|
|
164580
165262
|
},
|
|
164581
165263
|
capability: DEBUGGER_TOOL_CAPABILITY,
|
|
164582
165264
|
services: (params) => {
|
|
164583
|
-
if (
|
|
165265
|
+
if (isNativeRequestId(params.requestId)) return {};
|
|
164584
165266
|
const device = resolveDevice(params.device_id);
|
|
164585
165267
|
if (device.platform === "chromium") {
|
|
164586
165268
|
return { chromium: chromiumCdpRef(device) };
|
|
164587
165269
|
}
|
|
164588
|
-
if (params.requestId
|
|
165270
|
+
if (nativeIdPlatform2(params.requestId)) return {};
|
|
164589
165271
|
return {
|
|
164590
165272
|
inspector: `NetworkInspector:${metroPort(params)}:${canonicalDeviceId(params.device_id)}`
|
|
164591
165273
|
};
|
|
164592
165274
|
},
|
|
164593
165275
|
async execute(services, params) {
|
|
164594
165276
|
if (ANDROID_NATIVE_REQUEST_ID.test(params.requestId)) {
|
|
164595
|
-
|
|
165277
|
+
const found = findAndroidNativeRecord(params.requestId);
|
|
165278
|
+
return found ? nativeRequestDetails(found.record, found.inspector, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "android");
|
|
165279
|
+
}
|
|
165280
|
+
if (IOS_NATIVE_REQUEST_ID.test(params.requestId)) {
|
|
165281
|
+
const found = findIosNativeRecord(params.requestId);
|
|
165282
|
+
return found ? nativeRequestDetails(found.record, found.records, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "ios");
|
|
164596
165283
|
}
|
|
164597
165284
|
const device = resolveDevice(params.device_id);
|
|
164598
165285
|
if (device.platform === "chromium") {
|
|
@@ -164645,9 +165332,8 @@ Returns an error message string if the requestId is not found.`,
|
|
|
164645
165332
|
}
|
|
164646
165333
|
return details2;
|
|
164647
165334
|
}
|
|
164648
|
-
|
|
164649
|
-
|
|
164650
|
-
}
|
|
165335
|
+
const nativePlatform = nativeIdPlatform2(params.requestId);
|
|
165336
|
+
if (nativePlatform) return nativeNotFound(params.requestId, params.device_id, nativePlatform);
|
|
164651
165337
|
const api = services.inspector;
|
|
164652
165338
|
await api.cdp.evaluate(NETWORK_INTERCEPTOR_SCRIPT).catch(() => {
|
|
164653
165339
|
});
|
|
@@ -164702,14 +165388,15 @@ ${body.slice(0, MAX_BODY_SIZE)}...`;
|
|
|
164702
165388
|
return details;
|
|
164703
165389
|
}
|
|
164704
165390
|
};
|
|
164705
|
-
function
|
|
165391
|
+
function isNativeRequestId(requestId) {
|
|
165392
|
+
return ANDROID_NATIVE_REQUEST_ID.test(requestId) || IOS_NATIVE_REQUEST_ID.test(requestId);
|
|
165393
|
+
}
|
|
165394
|
+
function nativeNotFound(requestId, deviceId, layer) {
|
|
164706
165395
|
const { platform } = resolveDevice(deviceId);
|
|
164707
|
-
|
|
165396
|
+
const prefix = NATIVE_ID_PREFIXES[layer];
|
|
165397
|
+
return platform === "chromium" || platform === "vega" ? `Request ${requestId} not found. An ${prefix} ID comes from ${layer === "android" ? "an Android device" : "an iOS simulator"}. Use view-network-logs to list this device's requests.` : `Request ${requestId} not found. Use native-network-logs to list the requests the ${layer === "android" ? "Android" : "iOS"} native layer recorded.`;
|
|
164708
165398
|
}
|
|
164709
|
-
async function
|
|
164710
|
-
const found = findAndroidNativeRecord(requestId);
|
|
164711
|
-
if (!found) return androidNativeNotFound(requestId, deviceId);
|
|
164712
|
-
const { inspector, record: record2 } = found;
|
|
165399
|
+
async function nativeRequestDetails(record2, bodies, includeBody) {
|
|
164713
165400
|
const { wireHeaders } = record2.request;
|
|
164714
165401
|
const bodyHeaders = record2.redirects?.[0]?.requestHeaders ?? wireHeaders ?? {};
|
|
164715
165402
|
const requestHeader = (name) => headerValue(bodyHeaders, name) || headerValue(record2.request.headers, name);
|
|
@@ -164721,7 +165408,7 @@ async function androidNativeRequestDetails(requestId, includeBody, deviceId) {
|
|
|
164721
165408
|
const headersNote = requestHeadersNote(record2);
|
|
164722
165409
|
if (headersNote) request3.headersNote = headersNote;
|
|
164723
165410
|
if (record2.request.hasPostData) {
|
|
164724
|
-
request3.postData = await
|
|
165411
|
+
request3.postData = await readNativeBody(() => bodies.requestPostData(record2.id), {
|
|
164725
165412
|
contentType: requestHeader("content-type"),
|
|
164726
165413
|
contentEncoding: requestHeader("content-encoding"),
|
|
164727
165414
|
wholeSize: sizeInBytes(
|
|
@@ -164759,10 +165446,11 @@ async function androidNativeRequestDetails(requestId, includeBody, deviceId) {
|
|
|
164759
165446
|
};
|
|
164760
165447
|
if (record2.response.fromCache) resp.fromCache = true;
|
|
164761
165448
|
if (includeBody) {
|
|
164762
|
-
resp.body = await
|
|
165449
|
+
resp.body = await readNativeBody(() => bodies.responseBody(record2.id), {
|
|
164763
165450
|
mimeType: record2.response.mimeType,
|
|
164764
165451
|
contentType: headerValue(record2.response.headers, "content-type"),
|
|
164765
|
-
|
|
165452
|
+
// An iOS response body is read decoded, so its Content-Encoding is not applied again.
|
|
165453
|
+
contentEncoding: record2.layer === "ios-native" ? "" : headerValue(record2.response.headers, "content-encoding"),
|
|
164766
165454
|
wholeSize: sizeInBytes(record2.encodedDataLength ?? NaN, "as the app received them")
|
|
164767
165455
|
});
|
|
164768
165456
|
}
|
|
@@ -164779,7 +165467,7 @@ function requestHeadersNote(record2) {
|
|
|
164779
165467
|
}
|
|
164780
165468
|
return "These are the headers the app set. The headers sent on the wire (such as Cookie and User-Agent) were not reported for this request.";
|
|
164781
165469
|
}
|
|
164782
|
-
async function
|
|
165470
|
+
async function readNativeBody(read, framing) {
|
|
164783
165471
|
const mimeType = framing.mimeType ?? framing.contentType.split(";")[0].trim();
|
|
164784
165472
|
let body;
|
|
164785
165473
|
try {
|
|
@@ -164788,36 +165476,70 @@ async function readAndroidBody(read, framing) {
|
|
|
164788
165476
|
return `[unavailable: ${err instanceof Error ? err.message : String(err)}]`;
|
|
164789
165477
|
}
|
|
164790
165478
|
if (!body.available) return `[unavailable: ${body.reason ?? "no body"}]`;
|
|
164791
|
-
if (
|
|
164792
|
-
|
|
165479
|
+
if (body.incomplete) framing = { ...framing, wholeSize: void 0 };
|
|
165480
|
+
if (body.inlineChars !== void 0) {
|
|
165481
|
+
return inlineBody(body.body, body.inlineChars, body.truncated, mimeType, framing);
|
|
164793
165482
|
}
|
|
164794
|
-
const
|
|
165483
|
+
const asSent = () => {
|
|
165484
|
+
const text2 = inDeclaredCharset(body.body, framing.contentType, body.truncated);
|
|
165485
|
+
return body.truncated ? cutByAgent(text2, mimeType, Buffer.byteLength(body.body), framing, body.incomplete) : truncateBody(text2, mimeType);
|
|
165486
|
+
};
|
|
165487
|
+
if (!body.base64Encoded && contentCodings(framing.contentEncoding).length === 0) return asSent();
|
|
165488
|
+
const kept = Buffer.from(body.body, body.base64Encoded ? "base64" : "utf8");
|
|
164795
165489
|
const bytes = decodeContent2(kept, framing.contentEncoding, body.truncated);
|
|
164796
|
-
if (!bytes)
|
|
164797
|
-
|
|
164798
|
-
}
|
|
165490
|
+
if (!bytes) return decodesTooLarge(framing);
|
|
165491
|
+
if (!body.base64Encoded && bytes === kept) return asSent();
|
|
164799
165492
|
const text = decodeText(bytes, charsetOf(framing.contentType), body.truncated);
|
|
164800
165493
|
if (text === null) {
|
|
164801
|
-
return body.truncated ? `[body omitted: binary ${mimeType || "data"}, ${framing.wholeSize ?? "size unknown"}; ${agentKept(kept.length)}]` : `[body omitted: binary ${mimeType || "data"}, ${bytes.length} bytes]`;
|
|
164802
|
-
}
|
|
164803
|
-
return body.truncated ? cutByAgent(text, mimeType, kept.length, framing) : truncateBody(text, mimeType);
|
|
165494
|
+
return body.truncated ? `[body omitted: binary ${mimeType || "data"}, ${framing.wholeSize ?? "size unknown"}; ${agentKept(kept.length, body.incomplete)}]` : `[body omitted: binary ${mimeType || "data"}, ${bytes.length} bytes]`;
|
|
165495
|
+
}
|
|
165496
|
+
return body.truncated ? cutByAgent(text, mimeType, kept.length, framing, body.incomplete) : truncateBody(text, mimeType);
|
|
165497
|
+
}
|
|
165498
|
+
function inDeclaredCharset(text, contentType, truncated) {
|
|
165499
|
+
if (namesUtf8(contentType)) return text;
|
|
165500
|
+
return decodeText(Buffer.from(text, "utf8"), charsetOf(contentType), truncated) ?? text;
|
|
165501
|
+
}
|
|
165502
|
+
function namesUtf8(contentType) {
|
|
165503
|
+
const charset = charsetOf(contentType);
|
|
165504
|
+
return !charset || /^utf-?8$/i.test(charset);
|
|
165505
|
+
}
|
|
165506
|
+
function inlineBody(text, wholeChars, truncated, mimeType, framing) {
|
|
165507
|
+
if (BINARY_BODY_TYPES.test(mimeType.toLowerCase())) {
|
|
165508
|
+
return `[body omitted: binary ${mimeType}, ${framing.wholeSize ?? "size unknown"}]`;
|
|
165509
|
+
}
|
|
165510
|
+
const sent = contentCodings(framing.contentEncoding).length ? Buffer.from(text, "utf8") : null;
|
|
165511
|
+
const bytes = sent && decodeContent2(sent, framing.contentEncoding, truncated);
|
|
165512
|
+
if (sent && !bytes) return decodesTooLarge(framing);
|
|
165513
|
+
const encoded = bytes && bytes !== sent ? bytes : null;
|
|
165514
|
+
const decoded2 = encoded ? decodeText(encoded, charsetOf(framing.contentType), truncated) : inDeclaredCharset(text, framing.contentType, truncated);
|
|
165515
|
+
if (decoded2 === null) {
|
|
165516
|
+
const size = truncated ? framing.wholeSize ?? "size unknown" : `${encoded.length} bytes`;
|
|
165517
|
+
return `[body omitted: binary ${mimeType || "data"}, ${size}]`;
|
|
165518
|
+
}
|
|
165519
|
+
if (!truncated) return truncateBody(decoded2, mimeType);
|
|
165520
|
+
const fullSize = !encoded && namesUtf8(framing.contentType) ? `${wholeChars} chars` : `more than ${decoded2.length} chars`;
|
|
165521
|
+
const shown = Math.min(decoded2.length, MAX_BODY_SIZE);
|
|
165522
|
+
return `${cutMarker(fullSize, mimeType, shown)}
|
|
165523
|
+
${decoded2.slice(0, shown)}${decoded2.length > shown ? "..." : ""}`;
|
|
165524
|
+
}
|
|
165525
|
+
function decodesTooLarge(framing) {
|
|
165526
|
+
return `[unavailable: the ${framing.contentEncoding.trim()} body decodes to more than ${MAX_DECODED_BODY_BYTES / (1024 * 1024)} MiB]`;
|
|
164804
165527
|
}
|
|
164805
|
-
function cutByAgent(text, mimeType, keptBytes, framing) {
|
|
165528
|
+
function cutByAgent(text, mimeType, keptBytes, framing, incomplete) {
|
|
164806
165529
|
const shown = Math.min(text.length, MAX_BODY_SIZE);
|
|
164807
|
-
const fullSize = `${framing.wholeSize ?? "unknown"}; ${agentKept(keptBytes)}`;
|
|
165530
|
+
const fullSize = `${framing.wholeSize ?? "unknown"}; ${agentKept(keptBytes, incomplete)}`;
|
|
164808
165531
|
return `${cutMarker(fullSize, mimeType, shown)}
|
|
164809
165532
|
${text.slice(0, shown)}${text.length > shown ? "..." : ""}`;
|
|
164810
165533
|
}
|
|
164811
|
-
function agentKept(keptBytes) {
|
|
164812
|
-
return `the agent kept only the first ${keptBytes} bytes`;
|
|
165534
|
+
function agentKept(keptBytes, incomplete) {
|
|
165535
|
+
return incomplete ? `the upload ended after the first ${keptBytes} bytes, before the app's body stream reached its end` : `the agent kept only the first ${keptBytes} bytes`;
|
|
164813
165536
|
}
|
|
164814
165537
|
function sizeInBytes(bytes, how) {
|
|
164815
165538
|
return Number.isSafeInteger(bytes) && bytes > 0 ? `${bytes} bytes ${how}` : void 0;
|
|
164816
165539
|
}
|
|
164817
165540
|
function decodeContent2(bytes, contentEncoding, truncated = false) {
|
|
164818
|
-
const codings = contentEncoding.split(",").map((coding) => coding.trim().toLowerCase()).filter((coding) => coding !== "" && coding !== "identity");
|
|
164819
165541
|
let decoded2 = bytes;
|
|
164820
|
-
for (const coding of
|
|
165542
|
+
for (const coding of contentCodings(contentEncoding).reverse()) {
|
|
164821
165543
|
const next = decodeOne(decoded2, coding, truncated);
|
|
164822
165544
|
if (next === null) return null;
|
|
164823
165545
|
if (next === void 0) return bytes;
|
|
@@ -164825,6 +165547,9 @@ function decodeContent2(bytes, contentEncoding, truncated = false) {
|
|
|
164825
165547
|
}
|
|
164826
165548
|
return decoded2;
|
|
164827
165549
|
}
|
|
165550
|
+
function contentCodings(contentEncoding) {
|
|
165551
|
+
return contentEncoding.split(",").map((coding) => coding.trim().toLowerCase()).filter((coding) => coding !== "" && coding !== "identity");
|
|
165552
|
+
}
|
|
164828
165553
|
function decodeOne(bytes, coding, truncated) {
|
|
164829
165554
|
const maxOutputLength = MAX_DECODED_BODY_BYTES;
|
|
164830
165555
|
const flush = (mode) => truncated ? { finishFlush: mode } : {};
|
|
@@ -166470,7 +167195,7 @@ init_zod();
|
|
|
166470
167195
|
init_src2();
|
|
166471
167196
|
|
|
166472
167197
|
// ../tool-server/src/utils/debugger/runtime-device.ts
|
|
166473
|
-
var
|
|
167198
|
+
var import_node_crypto16 = require("node:crypto");
|
|
166474
167199
|
var import_node_child_process46 = require("node:child_process");
|
|
166475
167200
|
var import_node_util35 = require("node:util");
|
|
166476
167201
|
init_adb();
|
|
@@ -166483,7 +167208,7 @@ async function findRuntimeDevices(cdp, {
|
|
|
166483
167208
|
awaitSerials = [],
|
|
166484
167209
|
waitSerials = []
|
|
166485
167210
|
} = {}) {
|
|
166486
|
-
const marker = `argent-device-probe:${(0,
|
|
167211
|
+
const marker = `argent-device-probe:${(0, import_node_crypto16.randomUUID)()}`;
|
|
166487
167212
|
const logged = await cdp.evaluate(
|
|
166488
167213
|
`(function () {
|
|
166489
167214
|
if (typeof nativeLoggingHook !== "function") return false;
|
|
@@ -166646,21 +167371,35 @@ function bootstrapFailureMessage(bootstrap) {
|
|
|
166646
167371
|
|
|
166647
167372
|
// ../tool-server/src/utils/profiler-shared/network-capture-warning.ts
|
|
166648
167373
|
var CAPTURE_COST = "It can slow the app, so the timings in this profile can differ from a run without it.";
|
|
167374
|
+
function agentSentence(platform, one, where = "") {
|
|
167375
|
+
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}.`;
|
|
167376
|
+
}
|
|
166649
167377
|
function nativeNetworkCaptureWarning(deviceId, runtimeApp, runtimeDevices = { found: [], unresolved: [] }) {
|
|
166650
167378
|
try {
|
|
166651
167379
|
if (runtimeDevices.found.length > 0) {
|
|
166652
167380
|
return foundDeviceWarning(runtimeDevices, runtimeApp);
|
|
166653
167381
|
}
|
|
166654
|
-
|
|
167382
|
+
let platform = "android";
|
|
167383
|
+
let packages = liveAndroidNetworkCaptures(deviceId);
|
|
167384
|
+
if (packages.length === 0) {
|
|
167385
|
+
platform = "ios";
|
|
167386
|
+
packages = liveIosNetworkCaptures(deviceId);
|
|
167387
|
+
}
|
|
166655
167388
|
if (packages.length === 0) return logicalDeviceWarning(deviceId, runtimeApp);
|
|
166656
167389
|
const apps = packages.join(", ");
|
|
166657
167390
|
const one = packages.length === 1;
|
|
166658
|
-
|
|
167391
|
+
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";
|
|
167392
|
+
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
167393
|
} catch {
|
|
166660
167394
|
return void 0;
|
|
166661
167395
|
}
|
|
166662
167396
|
}
|
|
166663
167397
|
function foundDeviceWarning({ found, unresolved }, runtimeApp) {
|
|
167398
|
+
const iosApps = found.length === 1 ? liveIosNetworkCaptures(found[0]) : [];
|
|
167399
|
+
if (iosApps.length > 0) {
|
|
167400
|
+
const [udid] = found;
|
|
167401
|
+
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.`;
|
|
167402
|
+
}
|
|
166664
167403
|
const captures = found.map((device) => ({ device, packages: liveAndroidNetworkCaptures(device) })).filter(({ packages }) => packages.length > 0);
|
|
166665
167404
|
const appId = runtimeApp?.platform === "android" ? runtimeApp.appId : void 0;
|
|
166666
167405
|
const maybe = appId ? unresolved.filter((serial) => liveAndroidNetworkCaptures(serial).includes(appId)) : [];
|
|
@@ -166690,13 +167429,15 @@ function foundDeviceWarning({ found, unresolved }, runtimeApp) {
|
|
|
166690
167429
|
}
|
|
166691
167430
|
function logicalDeviceWarning(deviceId, runtimeApp) {
|
|
166692
167431
|
const appId = runtimeApp?.appId;
|
|
166693
|
-
|
|
166694
|
-
|
|
166695
|
-
|
|
166696
|
-
const
|
|
166697
|
-
if (
|
|
166698
|
-
const one =
|
|
166699
|
-
|
|
167432
|
+
const platform = runtimeApp?.platform;
|
|
167433
|
+
if (!isLogicalKeyedDevice(deviceId) || !appId) return void 0;
|
|
167434
|
+
if (platform !== "android" && platform !== "ios") return void 0;
|
|
167435
|
+
const devices2 = platform === "android" ? liveAndroidNetworkCaptureDevices(appId) : liveIosNetworkCaptureDevices(appId);
|
|
167436
|
+
if (devices2.length === 0) return void 0;
|
|
167437
|
+
const one = devices2.length === 1;
|
|
167438
|
+
const those = one ? "that device" : "each of those devices";
|
|
167439
|
+
const remedy = platform === "android" ? `call native-network-logs with stop: true for ${appId} on ${those}` : `call stop-all-simulator-servers for ${those}`;
|
|
167440
|
+
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
167441
|
}
|
|
166701
167442
|
|
|
166702
167443
|
// ../tool-server/src/tools/profiler/react/react-profiler-start.ts
|
|
@@ -166785,7 +167526,7 @@ function createReactProfilerStartTool(registry2) {
|
|
|
166785
167526
|
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
167527
|
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
167528
|
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.
|
|
167529
|
+
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
167530
|
Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot be established.`,
|
|
166790
167531
|
zodSchema: zodSchema45,
|
|
166791
167532
|
interaction: {
|
|
@@ -175134,7 +175875,7 @@ var nativeProfilerStartTool = {
|
|
|
175134
175875
|
longRunning: true,
|
|
175135
175876
|
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
175877
|
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.
|
|
175878
|
+
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
175879
|
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
175880
|
zodSchema: zodSchema53,
|
|
175140
175881
|
interaction: {
|
|
@@ -175159,6 +175900,7 @@ With malloc stack logging off, Argent blocks the bundled template if it detects
|
|
|
175159
175900
|
if (api.platform === "ios") {
|
|
175160
175901
|
await ensureDeps(["xcrun"]);
|
|
175161
175902
|
started = await startNativeProfilerIos(api, params);
|
|
175903
|
+
warning = nativeNetworkCaptureWarning(params.device_id);
|
|
175162
175904
|
} else if (api.platform === "macos") {
|
|
175163
175905
|
await ensureDeps(["xcrun"]);
|
|
175164
175906
|
({ warning, ...started } = await startNativeProfilerMacos(
|
|
@@ -175313,7 +176055,7 @@ var import_node_child_process48 = require("node:child_process");
|
|
|
175313
176055
|
var import_node_util38 = require("node:util");
|
|
175314
176056
|
var fsp5 = __toESM(require("node:fs/promises"));
|
|
175315
176057
|
var path49 = __toESM(require("node:path"));
|
|
175316
|
-
var
|
|
176058
|
+
var import_node_crypto17 = require("node:crypto");
|
|
175317
176059
|
init_src2();
|
|
175318
176060
|
|
|
175319
176061
|
// ../tool-server/src/utils/ios-launch-time/workflow.ts
|
|
@@ -175896,7 +176638,7 @@ async function measurePreparedLaunch(context2, ctx) {
|
|
|
175896
176638
|
const runnerSigning = context2.simulator ? null : await resolveRunnerSigningConfig(context2.deviceId);
|
|
175897
176639
|
const runnerBundleId = runnerSigning?.appBundleId ?? "com.argent.runner.tsimulator";
|
|
175898
176640
|
const testBundleId = runnerSigning?.testBundleId ?? `${runnerBundleId}.uitests`;
|
|
175899
|
-
const runnerBuildKey = (0,
|
|
176641
|
+
const runnerBuildKey = (0, import_node_crypto17.createHash)("sha256").update(
|
|
175900
176642
|
[
|
|
175901
176643
|
// Builds for two simulators, or two iPhones, are the same build.
|
|
175902
176644
|
context2.simulator ? "iOS Simulator" : "iOS",
|
|
@@ -176035,7 +176777,7 @@ async function measurePreparedLaunch(context2, ctx) {
|
|
|
176035
176777
|
|
|
176036
176778
|
// ../tool-server/src/tools/profiler/native-profiler/launch-analysis/profile.ts
|
|
176037
176779
|
var import_node_child_process49 = require("node:child_process");
|
|
176038
|
-
var
|
|
176780
|
+
var import_node_crypto18 = require("node:crypto");
|
|
176039
176781
|
var import_node_util39 = require("node:util");
|
|
176040
176782
|
var fsp6 = __toESM(require("node:fs/promises"));
|
|
176041
176783
|
var path50 = __toESM(require("node:path"));
|
|
@@ -176283,7 +177025,7 @@ var TABLE_XPATH = (schema) => `/trace-toc/run[@number="1"]/data/table[@schema="$
|
|
|
176283
177025
|
async function writeProfilerSession(xml) {
|
|
176284
177026
|
const debugDir = await getDebugDir();
|
|
176285
177027
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace("T", "-").slice(0, 15);
|
|
176286
|
-
const sessionId = `${timestamp}-launch-${(0,
|
|
177028
|
+
const sessionId = `${timestamp}-launch-${(0, import_node_crypto18.randomUUID)()}`;
|
|
176287
177029
|
const cpuXmlPath = path50.join(debugDir, `native-profiler-${sessionId}_raw_cpu.xml`);
|
|
176288
177030
|
await fsp6.writeFile(cpuXmlPath, xml, { flag: "wx" });
|
|
176289
177031
|
return { sessionId, cpuXmlPath };
|
|
@@ -176623,7 +177365,7 @@ init_zod();
|
|
|
176623
177365
|
var import_node_child_process50 = require("node:child_process");
|
|
176624
177366
|
var fs62 = __toESM(require("node:fs"));
|
|
176625
177367
|
var path51 = __toESM(require("node:path"));
|
|
176626
|
-
var
|
|
177368
|
+
var import_node_crypto19 = require("node:crypto");
|
|
176627
177369
|
var import_node_util40 = require("node:util");
|
|
176628
177370
|
init_src2();
|
|
176629
177371
|
init_capability();
|
|
@@ -176839,7 +177581,7 @@ async function setAudioInput(session, source) {
|
|
|
176839
177581
|
} else {
|
|
176840
177582
|
removeFiles(dir, `in-${process.pid}-`);
|
|
176841
177583
|
feeder = new InputFeeder(
|
|
176842
|
-
path51.join(dir, `in-${process.pid}-${(0,
|
|
177584
|
+
path51.join(dir, `in-${process.pid}-${(0, import_node_crypto19.randomUUID)().slice(0, 8)}.ring`),
|
|
176843
177585
|
feederSource
|
|
176844
177586
|
);
|
|
176845
177587
|
feeder.start();
|
|
@@ -189166,7 +189908,7 @@ init_device_info();
|
|
|
189166
189908
|
init_capability();
|
|
189167
189909
|
|
|
189168
189910
|
// ../tool-server/src/tools/flows/flow-visual.ts
|
|
189169
|
-
var
|
|
189911
|
+
var import_node_crypto20 = require("node:crypto");
|
|
189170
189912
|
var fs79 = __toESM(require("node:fs/promises"));
|
|
189171
189913
|
var os25 = __toESM(require("node:os"));
|
|
189172
189914
|
var path65 = __toESM(require("node:path"));
|
|
@@ -191290,7 +192032,7 @@ async function runSnapshot(env, opts) {
|
|
|
191290
192032
|
});
|
|
191291
192033
|
let captureWarned = shot.warning !== void 0 ? { warning: shot.warning } : {};
|
|
191292
192034
|
const { w, h } = await pngDimensions(shot.image.hostPath);
|
|
191293
|
-
const cropSuffix = opts.cropOn === void 0 ? "" : `-crop-${(0,
|
|
192035
|
+
const cropSuffix = opts.cropOn === void 0 ? "" : `-crop-${(0, import_node_crypto20.createHash)("sha256").update(cropIdentity(opts.cropOn)).digest("hex").slice(0, 8)}`;
|
|
191294
192036
|
const keyFor = (width, height) => `${opts.name}__${authoringPlatform(env.device.platform)}-${width}x${height}${cropSuffix}`;
|
|
191295
192037
|
const baselineFor = (file2) => opts.clientFlowPath === void 0 ? path65.join(baselineDir(opts.flowsDir, opts.flowName), file2) : clientBaselinePath(opts.clientFlowPath, opts.flowName, file2);
|
|
191296
192038
|
const snapshotKey = keyFor(w, h);
|
|
@@ -191637,7 +192379,7 @@ var FOREGROUND_CHANGING_TOOLS = /* @__PURE__ */ new Set([
|
|
|
191637
192379
|
"open-url",
|
|
191638
192380
|
"button"
|
|
191639
192381
|
]);
|
|
191640
|
-
async function waitForNativeDevtools(registry2, device, bundleId, signal) {
|
|
192382
|
+
async function waitForNativeDevtools(registry2, device, bundleId, signal, relaunchedAt) {
|
|
191641
192383
|
let api;
|
|
191642
192384
|
try {
|
|
191643
192385
|
const ref = nativeDevtoolsRef(device);
|
|
@@ -191656,23 +192398,27 @@ async function waitForNativeDevtools(registry2, device, bundleId, signal) {
|
|
|
191656
192398
|
if (!isInjectableBundleId(bundleId)) return null;
|
|
191657
192399
|
const state3 = await api.appConnectionState(bundleId).catch(() => "indeterminate");
|
|
191658
192400
|
if (state3 === "connected") return null;
|
|
191659
|
-
return flowLaunchGateReason(
|
|
192401
|
+
return flowLaunchGateReason(
|
|
192402
|
+
bundleId,
|
|
192403
|
+
state3,
|
|
192404
|
+
relaunchedAt === void 0 ? void 0 : Date.now() - relaunchedAt
|
|
192405
|
+
);
|
|
191660
192406
|
}
|
|
191661
|
-
function flowLaunchGateReason(bundleId, state3) {
|
|
192407
|
+
function flowLaunchGateReason(bundleId, state3, spentMs = LAUNCH_TO_VERDICT_MS) {
|
|
191662
192408
|
const measured = buildAppStateMessage(bundleId, state3);
|
|
191663
192409
|
switch (state3) {
|
|
191664
192410
|
case "not_running":
|
|
191665
|
-
return `${bundleId} was relaunched by this step and is no longer running ${
|
|
192411
|
+
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
192412
|
case "stale_process":
|
|
191667
192413
|
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
192414
|
case "unregistered":
|
|
191669
|
-
return `${measured} A cold start slower than the ${
|
|
192415
|
+
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
192416
|
case "connecting":
|
|
191671
|
-
return `${measured} This step launched it ${
|
|
192417
|
+
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
192418
|
case "indeterminate":
|
|
191673
192419
|
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
192420
|
case "provider_attached":
|
|
191675
|
-
return `${measured} This step already waited ${
|
|
192421
|
+
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
192422
|
}
|
|
191677
192423
|
}
|
|
191678
192424
|
async function waitForVegaAutomation(device, signal) {
|
|
@@ -191700,7 +192446,7 @@ async function androidDevtoolsReady(registry2, device) {
|
|
|
191700
192446
|
return { ready: false, reason: err instanceof Error ? err.message : String(err) };
|
|
191701
192447
|
}
|
|
191702
192448
|
}
|
|
191703
|
-
async function treeSourceGate(registry2, device, bundleId, signal) {
|
|
192449
|
+
async function treeSourceGate(registry2, device, bundleId, signal, relaunchedAt) {
|
|
191704
192450
|
if (isIosPhysicalDevice(device) && !signal?.aborted) {
|
|
191705
192451
|
try {
|
|
191706
192452
|
const ref = iosDeviceRunnerRef(device);
|
|
@@ -191711,7 +192457,7 @@ async function treeSourceGate(registry2, device, bundleId, signal) {
|
|
|
191711
192457
|
}
|
|
191712
192458
|
}
|
|
191713
192459
|
if ((device.platform === "ios" || device.platform === "ios-remote") && !signal?.aborted) {
|
|
191714
|
-
const reason2 = await waitForNativeDevtools(registry2, device, bundleId, signal);
|
|
192460
|
+
const reason2 = await waitForNativeDevtools(registry2, device, bundleId, signal, relaunchedAt);
|
|
191715
192461
|
if (reason2 !== null && !signal?.aborted) {
|
|
191716
192462
|
return `could not connect to native devtools. ${reason2}`;
|
|
191717
192463
|
}
|
|
@@ -191761,6 +192507,7 @@ async function runLaunch(state3, app) {
|
|
|
191761
192507
|
const key2 = authoringPlatform(device.platform);
|
|
191762
192508
|
const launchArgs = key2 === "ios" ? appLaunchArgs(app, "ios") : key2 === "macos" ? appLaunchArgs(app, "macos") ?? [] : void 0;
|
|
191763
192509
|
let restart;
|
|
192510
|
+
const relaunchedAt = Date.now();
|
|
191764
192511
|
try {
|
|
191765
192512
|
restart = await invokeOnDevice(env, "restart-app", {
|
|
191766
192513
|
bundleId,
|
|
@@ -191775,7 +192522,7 @@ async function runLaunch(state3, app) {
|
|
|
191775
192522
|
}
|
|
191776
192523
|
refreshMacosDeviceKind(state3);
|
|
191777
192524
|
if (!await sleepOrAbort(POST_LAUNCH_SETTLE_MS, signal)) return ABORTED_OUTCOME;
|
|
191778
|
-
const gate = await treeSourceGate(registry2, device, bundleId, signal);
|
|
192525
|
+
const gate = await treeSourceGate(registry2, device, bundleId, signal, relaunchedAt);
|
|
191779
192526
|
if (signal?.aborted) return ABORTED_OUTCOME;
|
|
191780
192527
|
if (gate) return { ok: false, reason: gate };
|
|
191781
192528
|
state3.treeTarget = { bundleId, pinned: true, probeAnswered: false };
|
|
@@ -193848,7 +194595,7 @@ var dismissUpdateTool = {
|
|
|
193848
194595
|
};
|
|
193849
194596
|
|
|
193850
194597
|
// ../tool-server/src/tools/screenshot-diff/index.ts
|
|
193851
|
-
var
|
|
194598
|
+
var import_node_crypto21 = __toESM(require("node:crypto"));
|
|
193852
194599
|
var import_promises23 = __toESM(require("fs/promises"));
|
|
193853
194600
|
var import_node_os18 = __toESM(require("node:os"));
|
|
193854
194601
|
var import_path9 = __toESM(require("path"));
|
|
@@ -194004,7 +194751,7 @@ async function resolveOutputDir(params, options) {
|
|
|
194004
194751
|
const dir = import_path9.default.join(
|
|
194005
194752
|
import_node_os18.default.tmpdir(),
|
|
194006
194753
|
"argent-screenshot-diff",
|
|
194007
|
-
|
|
194754
|
+
import_node_crypto21.default.randomBytes(6).toString("hex")
|
|
194008
194755
|
);
|
|
194009
194756
|
await import_promises23.default.mkdir(dir, { recursive: true });
|
|
194010
194757
|
return dir;
|
|
@@ -194109,7 +194856,7 @@ async function captureIosDeviceLiveInput(params) {
|
|
|
194109
194856
|
return writeLivePng(params.outputDir, params.name, png);
|
|
194110
194857
|
}
|
|
194111
194858
|
async function writeLivePng(outputDir, name, png) {
|
|
194112
|
-
const suffix =
|
|
194859
|
+
const suffix = import_node_crypto21.default.randomBytes(4).toString("hex");
|
|
194113
194860
|
const destination = import_path9.default.join(outputDir, `${name}-${suffix}.live.png`);
|
|
194114
194861
|
await import_promises23.default.mkdir(outputDir, { recursive: true });
|
|
194115
194862
|
await import_promises23.default.writeFile(destination, png);
|
|
@@ -194127,7 +194874,7 @@ async function captureHarmonyLiveInput(params) {
|
|
|
194127
194874
|
}
|
|
194128
194875
|
await ensureDep("hdc");
|
|
194129
194876
|
const captured = await captureHarmonyScreenshotPng({ connectKey: params.connectKey, scale: 1 });
|
|
194130
|
-
const suffix =
|
|
194877
|
+
const suffix = import_node_crypto21.default.randomBytes(4).toString("hex");
|
|
194131
194878
|
const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
|
|
194132
194879
|
try {
|
|
194133
194880
|
await import_promises23.default.mkdir(params.outputDir, { recursive: true });
|
|
@@ -194150,7 +194897,7 @@ async function captureLiveInput(params) {
|
|
|
194150
194897
|
captureScreenshot2,
|
|
194151
194898
|
params.peekFor?.(params.device)
|
|
194152
194899
|
);
|
|
194153
|
-
const suffix =
|
|
194900
|
+
const suffix = import_node_crypto21.default.randomBytes(4).toString("hex");
|
|
194154
194901
|
const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
|
|
194155
194902
|
await import_promises23.default.mkdir(params.outputDir, { recursive: true });
|
|
194156
194903
|
await import_promises23.default.copyFile(capture.path, destination);
|