@swmansion/argent 0.32.1-next.15 → 0.32.1-next.17
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.3.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 +7 -5
- package/dist/tool-server.cjs +1792 -934
- 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/skills/argent-create-e2e/references/reliability-and-recovery.md +2 -2
- package/skills/argent-device-interact/references/chromium.md +1 -1
- package/skills/argent-react-native-optimization/SKILL.md +2 -3
- package/skills/argent-react-native-profiler/SKILL.md +7 -7
package/dist/tool-server.cjs
CHANGED
|
@@ -24653,7 +24653,7 @@ var require_src = __commonJS({
|
|
|
24653
24653
|
// ../../node_modules/depd/index.js
|
|
24654
24654
|
var require_depd = __commonJS({
|
|
24655
24655
|
"../../node_modules/depd/index.js"(exports2, module2) {
|
|
24656
|
-
var
|
|
24656
|
+
var relative9 = require("path").relative;
|
|
24657
24657
|
module2.exports = depd;
|
|
24658
24658
|
var basePath = process.cwd();
|
|
24659
24659
|
function containsNamespace(str3, namespace) {
|
|
@@ -24805,7 +24805,7 @@ var require_depd = __commonJS({
|
|
|
24805
24805
|
var callSite = site.callSite;
|
|
24806
24806
|
var funcName = site.name;
|
|
24807
24807
|
if (!funcName) {
|
|
24808
|
-
funcName = "<anonymous@" +
|
|
24808
|
+
funcName = "<anonymous@" + formatLocation2(site) + ">";
|
|
24809
24809
|
}
|
|
24810
24810
|
var context2 = callSite.getThis();
|
|
24811
24811
|
var typeName = context2 && callSite.getTypeName();
|
|
@@ -24827,7 +24827,7 @@ var require_depd = __commonJS({
|
|
|
24827
24827
|
return formatted;
|
|
24828
24828
|
}
|
|
24829
24829
|
if (caller) {
|
|
24830
|
-
formatted += " at " +
|
|
24830
|
+
formatted += " at " + formatLocation2(caller);
|
|
24831
24831
|
}
|
|
24832
24832
|
return formatted;
|
|
24833
24833
|
}
|
|
@@ -24840,12 +24840,12 @@ var require_depd = __commonJS({
|
|
|
24840
24840
|
return formatted;
|
|
24841
24841
|
}
|
|
24842
24842
|
if (caller) {
|
|
24843
|
-
formatted += " \x1B[36m" +
|
|
24843
|
+
formatted += " \x1B[36m" + formatLocation2(caller) + "\x1B[39m";
|
|
24844
24844
|
}
|
|
24845
24845
|
return formatted;
|
|
24846
24846
|
}
|
|
24847
|
-
function
|
|
24848
|
-
return
|
|
24847
|
+
function formatLocation2(callSite) {
|
|
24848
|
+
return relative9(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
|
|
24849
24849
|
}
|
|
24850
24850
|
function getStack() {
|
|
24851
24851
|
var limit = Error.stackTraceLimit;
|
|
@@ -40996,7 +40996,7 @@ var require_get_intrinsic = __commonJS({
|
|
|
40996
40996
|
var max = require_max();
|
|
40997
40997
|
var min = require_min();
|
|
40998
40998
|
var pow = require_pow();
|
|
40999
|
-
var
|
|
40999
|
+
var round3 = require_round();
|
|
41000
41000
|
var sign = require_sign();
|
|
41001
41001
|
var $Function = Function;
|
|
41002
41002
|
var getEvalledConstructor = function(expressionSyntax) {
|
|
@@ -41110,7 +41110,7 @@ var require_get_intrinsic = __commonJS({
|
|
|
41110
41110
|
"%Math.max%": max,
|
|
41111
41111
|
"%Math.min%": min,
|
|
41112
41112
|
"%Math.pow%": pow,
|
|
41113
|
-
"%Math.round%":
|
|
41113
|
+
"%Math.round%": round3,
|
|
41114
41114
|
"%Math.sign%": sign,
|
|
41115
41115
|
"%Reflect.getPrototypeOf%": $ReflectGPO
|
|
41116
41116
|
};
|
|
@@ -43048,8 +43048,8 @@ var require_view = __commonJS({
|
|
|
43048
43048
|
var debug = require_src()("express:view");
|
|
43049
43049
|
var path63 = require("node:path");
|
|
43050
43050
|
var fs78 = require("node:fs");
|
|
43051
|
-
var
|
|
43052
|
-
var
|
|
43051
|
+
var dirname23 = path63.dirname;
|
|
43052
|
+
var basename19 = path63.basename;
|
|
43053
43053
|
var extname7 = path63.extname;
|
|
43054
43054
|
var join68 = path63.join;
|
|
43055
43055
|
var resolve19 = path63.resolve;
|
|
@@ -43087,8 +43087,8 @@ var require_view = __commonJS({
|
|
|
43087
43087
|
for (var i = 0; i < roots.length && !path64; i++) {
|
|
43088
43088
|
var root = roots[i];
|
|
43089
43089
|
var loc = resolve19(root, name);
|
|
43090
|
-
var dir =
|
|
43091
|
-
var file2 =
|
|
43090
|
+
var dir = dirname23(loc);
|
|
43091
|
+
var file2 = basename19(loc);
|
|
43092
43092
|
path64 = this.resolve(dir, file2);
|
|
43093
43093
|
}
|
|
43094
43094
|
return path64;
|
|
@@ -43118,7 +43118,7 @@ var require_view = __commonJS({
|
|
|
43118
43118
|
if (stat10 && stat10.isFile()) {
|
|
43119
43119
|
return path64;
|
|
43120
43120
|
}
|
|
43121
|
-
path64 = join68(dir,
|
|
43121
|
+
path64 = join68(dir, basename19(file2, ext), "index" + ext);
|
|
43122
43122
|
stat10 = tryStat(path64);
|
|
43123
43123
|
if (stat10 && stat10.isFile()) {
|
|
43124
43124
|
return path64;
|
|
@@ -75576,7 +75576,7 @@ var require_send = __commonJS({
|
|
|
75576
75576
|
var join68 = path63.join;
|
|
75577
75577
|
var normalize = path63.normalize;
|
|
75578
75578
|
var resolve19 = path63.resolve;
|
|
75579
|
-
var
|
|
75579
|
+
var sep10 = path63.sep;
|
|
75580
75580
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
75581
75581
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
75582
75582
|
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
@@ -75737,14 +75737,14 @@ var require_send = __commonJS({
|
|
|
75737
75737
|
var parts2;
|
|
75738
75738
|
if (root !== null) {
|
|
75739
75739
|
if (path64) {
|
|
75740
|
-
path64 = normalize("." +
|
|
75740
|
+
path64 = normalize("." + sep10 + path64);
|
|
75741
75741
|
}
|
|
75742
75742
|
if (UP_PATH_REGEXP.test(path64)) {
|
|
75743
75743
|
debug('malicious path "%s"', path64);
|
|
75744
75744
|
this.error(403);
|
|
75745
75745
|
return res;
|
|
75746
75746
|
}
|
|
75747
|
-
parts2 = path64.split(
|
|
75747
|
+
parts2 = path64.split(sep10);
|
|
75748
75748
|
path64 = normalize(join68(root, path64));
|
|
75749
75749
|
} else {
|
|
75750
75750
|
if (UP_PATH_REGEXP.test(path64)) {
|
|
@@ -75752,7 +75752,7 @@ var require_send = __commonJS({
|
|
|
75752
75752
|
this.error(403);
|
|
75753
75753
|
return res;
|
|
75754
75754
|
}
|
|
75755
|
-
parts2 = normalize(path64).split(
|
|
75755
|
+
parts2 = normalize(path64).split(sep10);
|
|
75756
75756
|
path64 = resolve19(path64);
|
|
75757
75757
|
}
|
|
75758
75758
|
if (containsDotFile(parts2)) {
|
|
@@ -75846,7 +75846,7 @@ var require_send = __commonJS({
|
|
|
75846
75846
|
var self2 = this;
|
|
75847
75847
|
debug('stat "%s"', path64);
|
|
75848
75848
|
fs78.stat(path64, function onstat(err, stat10) {
|
|
75849
|
-
var pathEndsWithSep = path64[path64.length - 1] ===
|
|
75849
|
+
var pathEndsWithSep = path64[path64.length - 1] === sep10;
|
|
75850
75850
|
if (err && err.code === "ENOENT" && !extname7(path64) && !pathEndsWithSep) {
|
|
75851
75851
|
return next(err);
|
|
75852
75852
|
}
|
|
@@ -76132,7 +76132,7 @@ var require_response = __commonJS({
|
|
|
76132
76132
|
var send = require_send();
|
|
76133
76133
|
var extname7 = path63.extname;
|
|
76134
76134
|
var resolve19 = path63.resolve;
|
|
76135
|
-
var
|
|
76135
|
+
var basename19 = path63.basename;
|
|
76136
76136
|
var vary = require_vary();
|
|
76137
76137
|
var { Buffer: Buffer2 } = require("node:buffer");
|
|
76138
76138
|
var res = Object.create(http6.ServerResponse.prototype);
|
|
@@ -76323,7 +76323,7 @@ var require_response = __commonJS({
|
|
|
76323
76323
|
opts = filename;
|
|
76324
76324
|
}
|
|
76325
76325
|
var headers = {
|
|
76326
|
-
"Content-Disposition": contentDisposition.create(
|
|
76326
|
+
"Content-Disposition": contentDisposition.create(basename19(name || path64))
|
|
76327
76327
|
};
|
|
76328
76328
|
if (opts && opts.headers) {
|
|
76329
76329
|
var keys = Object.keys(opts.headers);
|
|
@@ -76366,7 +76366,7 @@ var require_response = __commonJS({
|
|
|
76366
76366
|
return this;
|
|
76367
76367
|
};
|
|
76368
76368
|
res.attachment = function attachment(filename) {
|
|
76369
|
-
const name = filename !== void 0 ?
|
|
76369
|
+
const name = filename !== void 0 ? basename19(filename) : void 0;
|
|
76370
76370
|
if (name) {
|
|
76371
76371
|
this.type(extname7(name));
|
|
76372
76372
|
}
|
|
@@ -86684,20 +86684,20 @@ var require_ncp = __commonJS({
|
|
|
86684
86684
|
}
|
|
86685
86685
|
function onLink(link) {
|
|
86686
86686
|
var target = link.replace(currentPath, targetPath);
|
|
86687
|
-
fs78.readlink(link, function(err,
|
|
86687
|
+
fs78.readlink(link, function(err, resolvedPath2) {
|
|
86688
86688
|
if (err) {
|
|
86689
86689
|
return onError(err);
|
|
86690
86690
|
}
|
|
86691
|
-
checkLink(
|
|
86691
|
+
checkLink(resolvedPath2, target);
|
|
86692
86692
|
});
|
|
86693
86693
|
}
|
|
86694
|
-
function checkLink(
|
|
86694
|
+
function checkLink(resolvedPath2, target) {
|
|
86695
86695
|
if (dereference) {
|
|
86696
|
-
|
|
86696
|
+
resolvedPath2 = path63.resolve(basePath, resolvedPath2);
|
|
86697
86697
|
}
|
|
86698
86698
|
isWritable2(target, function(writable) {
|
|
86699
86699
|
if (writable) {
|
|
86700
|
-
return makeLink(
|
|
86700
|
+
return makeLink(resolvedPath2, target);
|
|
86701
86701
|
}
|
|
86702
86702
|
fs78.readlink(target, function(err, targetDest) {
|
|
86703
86703
|
if (err) {
|
|
@@ -86706,11 +86706,11 @@ var require_ncp = __commonJS({
|
|
|
86706
86706
|
if (dereference) {
|
|
86707
86707
|
targetDest = path63.resolve(basePath, targetDest);
|
|
86708
86708
|
}
|
|
86709
|
-
if (targetDest ===
|
|
86709
|
+
if (targetDest === resolvedPath2) {
|
|
86710
86710
|
return cb();
|
|
86711
86711
|
}
|
|
86712
86712
|
return rmFile(target, function() {
|
|
86713
|
-
makeLink(
|
|
86713
|
+
makeLink(resolvedPath2, target);
|
|
86714
86714
|
});
|
|
86715
86715
|
});
|
|
86716
86716
|
});
|
|
@@ -87691,7 +87691,7 @@ var require_common2 = __commonJS({
|
|
|
87691
87691
|
}
|
|
87692
87692
|
var path63 = require("path");
|
|
87693
87693
|
var minimatch = require_minimatch();
|
|
87694
|
-
var
|
|
87694
|
+
var isAbsolute13 = require_path_is_absolute();
|
|
87695
87695
|
var Minimatch = minimatch.Minimatch;
|
|
87696
87696
|
function alphasorti(a, b) {
|
|
87697
87697
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
|
@@ -87834,7 +87834,7 @@ var require_common2 = __commonJS({
|
|
|
87834
87834
|
var abs = f;
|
|
87835
87835
|
if (f.charAt(0) === "/") {
|
|
87836
87836
|
abs = path63.join(self2.root, f);
|
|
87837
|
-
} else if (
|
|
87837
|
+
} else if (isAbsolute13(f) || f === "") {
|
|
87838
87838
|
abs = f;
|
|
87839
87839
|
} else if (self2.changedCwd) {
|
|
87840
87840
|
abs = path63.resolve(self2.cwd, f);
|
|
@@ -87872,7 +87872,7 @@ var require_sync = __commonJS({
|
|
|
87872
87872
|
var util = require("util");
|
|
87873
87873
|
var path63 = require("path");
|
|
87874
87874
|
var assert2 = require("assert");
|
|
87875
|
-
var
|
|
87875
|
+
var isAbsolute13 = require_path_is_absolute();
|
|
87876
87876
|
var common = require_common2();
|
|
87877
87877
|
var alphasort = common.alphasort;
|
|
87878
87878
|
var alphasorti = common.alphasorti;
|
|
@@ -87946,8 +87946,8 @@ var require_sync = __commonJS({
|
|
|
87946
87946
|
var read;
|
|
87947
87947
|
if (prefix === null)
|
|
87948
87948
|
read = ".";
|
|
87949
|
-
else if (
|
|
87950
|
-
if (!prefix || !
|
|
87949
|
+
else if (isAbsolute13(prefix) || isAbsolute13(pattern.join("/"))) {
|
|
87950
|
+
if (!prefix || !isAbsolute13(prefix))
|
|
87951
87951
|
prefix = "/" + prefix;
|
|
87952
87952
|
read = prefix;
|
|
87953
87953
|
} else
|
|
@@ -88132,7 +88132,7 @@ var require_sync = __commonJS({
|
|
|
88132
88132
|
this.matches[index] = /* @__PURE__ */ Object.create(null);
|
|
88133
88133
|
if (!exists3)
|
|
88134
88134
|
return;
|
|
88135
|
-
if (prefix &&
|
|
88135
|
+
if (prefix && isAbsolute13(prefix) && !this.nomount) {
|
|
88136
88136
|
var trail = /[\/\\]$/.test(prefix);
|
|
88137
88137
|
if (prefix.charAt(0) === "/") {
|
|
88138
88138
|
prefix = path63.join(this.root, prefix);
|
|
@@ -88252,7 +88252,7 @@ var require_glob = __commonJS({
|
|
|
88252
88252
|
var EE = require("events").EventEmitter;
|
|
88253
88253
|
var path63 = require("path");
|
|
88254
88254
|
var assert2 = require("assert");
|
|
88255
|
-
var
|
|
88255
|
+
var isAbsolute13 = require_path_is_absolute();
|
|
88256
88256
|
var globSync = require_sync();
|
|
88257
88257
|
var common = require_common2();
|
|
88258
88258
|
var alphasort = common.alphasort;
|
|
@@ -88466,8 +88466,8 @@ var require_glob = __commonJS({
|
|
|
88466
88466
|
var read;
|
|
88467
88467
|
if (prefix === null)
|
|
88468
88468
|
read = ".";
|
|
88469
|
-
else if (
|
|
88470
|
-
if (!prefix || !
|
|
88469
|
+
else if (isAbsolute13(prefix) || isAbsolute13(pattern.join("/"))) {
|
|
88470
|
+
if (!prefix || !isAbsolute13(prefix))
|
|
88471
88471
|
prefix = "/" + prefix;
|
|
88472
88472
|
read = prefix;
|
|
88473
88473
|
} else
|
|
@@ -88699,7 +88699,7 @@ var require_glob = __commonJS({
|
|
|
88699
88699
|
this.matches[index] = /* @__PURE__ */ Object.create(null);
|
|
88700
88700
|
if (!exists3)
|
|
88701
88701
|
return cb();
|
|
88702
|
-
if (prefix &&
|
|
88702
|
+
if (prefix && isAbsolute13(prefix) && !this.nomount) {
|
|
88703
88703
|
var trail = /[\/\\]$/.test(prefix);
|
|
88704
88704
|
if (prefix.charAt(0) === "/") {
|
|
88705
88705
|
prefix = path63.join(this.root, prefix);
|
|
@@ -94322,10 +94322,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
94322
94322
|
let offset = bm.offset;
|
|
94323
94323
|
let commentEnd = null;
|
|
94324
94324
|
for (const collItem of bm.items) {
|
|
94325
|
-
const { start: start2, key: key2, sep:
|
|
94325
|
+
const { start: start2, key: key2, sep: sep10, value } = collItem;
|
|
94326
94326
|
const keyProps = resolveProps.resolveProps(start2, {
|
|
94327
94327
|
indicator: "explicit-key-ind",
|
|
94328
|
-
next: key2 ??
|
|
94328
|
+
next: key2 ?? sep10?.[0],
|
|
94329
94329
|
offset,
|
|
94330
94330
|
onError,
|
|
94331
94331
|
parentIndent: bm.indent,
|
|
@@ -94339,7 +94339,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
94339
94339
|
else if ("indent" in key2 && key2.indent !== bm.indent)
|
|
94340
94340
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
94341
94341
|
}
|
|
94342
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
94342
|
+
if (!keyProps.anchor && !keyProps.tag && !sep10) {
|
|
94343
94343
|
commentEnd = keyProps.end;
|
|
94344
94344
|
if (keyProps.comment) {
|
|
94345
94345
|
if (map2.comment)
|
|
@@ -94363,7 +94363,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
94363
94363
|
ctx.atKey = false;
|
|
94364
94364
|
if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode))
|
|
94365
94365
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
94366
|
-
const valueProps = resolveProps.resolveProps(
|
|
94366
|
+
const valueProps = resolveProps.resolveProps(sep10 ?? [], {
|
|
94367
94367
|
indicator: "map-value-ind",
|
|
94368
94368
|
next: value,
|
|
94369
94369
|
offset: keyNode.range[2],
|
|
@@ -94379,7 +94379,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
94379
94379
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
94380
94380
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
94381
94381
|
}
|
|
94382
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
94382
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep10, null, valueProps, onError);
|
|
94383
94383
|
if (ctx.schema.compat)
|
|
94384
94384
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
94385
94385
|
offset = valueNode.range[2];
|
|
@@ -94470,7 +94470,7 @@ var require_resolve_end = __commonJS({
|
|
|
94470
94470
|
let comment = "";
|
|
94471
94471
|
if (end) {
|
|
94472
94472
|
let hasSpace = false;
|
|
94473
|
-
let
|
|
94473
|
+
let sep10 = "";
|
|
94474
94474
|
for (const token of end) {
|
|
94475
94475
|
const { source, type } = token;
|
|
94476
94476
|
switch (type) {
|
|
@@ -94484,13 +94484,13 @@ var require_resolve_end = __commonJS({
|
|
|
94484
94484
|
if (!comment)
|
|
94485
94485
|
comment = cb;
|
|
94486
94486
|
else
|
|
94487
|
-
comment +=
|
|
94488
|
-
|
|
94487
|
+
comment += sep10 + cb;
|
|
94488
|
+
sep10 = "";
|
|
94489
94489
|
break;
|
|
94490
94490
|
}
|
|
94491
94491
|
case "newline":
|
|
94492
94492
|
if (comment)
|
|
94493
|
-
|
|
94493
|
+
sep10 += source;
|
|
94494
94494
|
hasSpace = true;
|
|
94495
94495
|
break;
|
|
94496
94496
|
default:
|
|
@@ -94533,18 +94533,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
94533
94533
|
let offset = fc.offset + fc.start.source.length;
|
|
94534
94534
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
94535
94535
|
const collItem = fc.items[i];
|
|
94536
|
-
const { start: start2, key: key2, sep:
|
|
94536
|
+
const { start: start2, key: key2, sep: sep10, value } = collItem;
|
|
94537
94537
|
const props = resolveProps.resolveProps(start2, {
|
|
94538
94538
|
flow: fcName,
|
|
94539
94539
|
indicator: "explicit-key-ind",
|
|
94540
|
-
next: key2 ??
|
|
94540
|
+
next: key2 ?? sep10?.[0],
|
|
94541
94541
|
offset,
|
|
94542
94542
|
onError,
|
|
94543
94543
|
parentIndent: fc.indent,
|
|
94544
94544
|
startOnNewline: false
|
|
94545
94545
|
});
|
|
94546
94546
|
if (!props.found) {
|
|
94547
|
-
if (!props.anchor && !props.tag && !
|
|
94547
|
+
if (!props.anchor && !props.tag && !sep10 && !value) {
|
|
94548
94548
|
if (i === 0 && props.comma)
|
|
94549
94549
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
94550
94550
|
else if (i < fc.items.length - 1)
|
|
@@ -94598,8 +94598,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
94598
94598
|
}
|
|
94599
94599
|
}
|
|
94600
94600
|
}
|
|
94601
|
-
if (!isMap && !
|
|
94602
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
94601
|
+
if (!isMap && !sep10 && !props.found) {
|
|
94602
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep10, null, props, onError);
|
|
94603
94603
|
coll.items.push(valueNode);
|
|
94604
94604
|
offset = valueNode.range[2];
|
|
94605
94605
|
if (isBlock(value))
|
|
@@ -94611,7 +94611,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
94611
94611
|
if (isBlock(key2))
|
|
94612
94612
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
94613
94613
|
ctx.atKey = false;
|
|
94614
|
-
const valueProps = resolveProps.resolveProps(
|
|
94614
|
+
const valueProps = resolveProps.resolveProps(sep10 ?? [], {
|
|
94615
94615
|
flow: fcName,
|
|
94616
94616
|
indicator: "map-value-ind",
|
|
94617
94617
|
next: value,
|
|
@@ -94622,8 +94622,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
94622
94622
|
});
|
|
94623
94623
|
if (valueProps.found) {
|
|
94624
94624
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
94625
|
-
if (
|
|
94626
|
-
for (const st of
|
|
94625
|
+
if (sep10)
|
|
94626
|
+
for (const st of sep10) {
|
|
94627
94627
|
if (st === valueProps.found)
|
|
94628
94628
|
break;
|
|
94629
94629
|
if (st.type === "newline") {
|
|
@@ -94640,7 +94640,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
94640
94640
|
else
|
|
94641
94641
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
94642
94642
|
}
|
|
94643
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
94643
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep10, null, valueProps, onError) : null;
|
|
94644
94644
|
if (valueNode) {
|
|
94645
94645
|
if (isBlock(value))
|
|
94646
94646
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -94820,7 +94820,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
94820
94820
|
chompStart = i + 1;
|
|
94821
94821
|
}
|
|
94822
94822
|
let value = "";
|
|
94823
|
-
let
|
|
94823
|
+
let sep10 = "";
|
|
94824
94824
|
let prevMoreIndented = false;
|
|
94825
94825
|
for (let i = 0; i < contentStart; ++i)
|
|
94826
94826
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -94837,24 +94837,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
94837
94837
|
indent = "";
|
|
94838
94838
|
}
|
|
94839
94839
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
94840
|
-
value +=
|
|
94841
|
-
|
|
94840
|
+
value += sep10 + indent.slice(trimIndent) + content;
|
|
94841
|
+
sep10 = "\n";
|
|
94842
94842
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
94843
|
-
if (
|
|
94844
|
-
|
|
94845
|
-
else if (!prevMoreIndented &&
|
|
94846
|
-
|
|
94847
|
-
value +=
|
|
94848
|
-
|
|
94843
|
+
if (sep10 === " ")
|
|
94844
|
+
sep10 = "\n";
|
|
94845
|
+
else if (!prevMoreIndented && sep10 === "\n")
|
|
94846
|
+
sep10 = "\n\n";
|
|
94847
|
+
value += sep10 + indent.slice(trimIndent) + content;
|
|
94848
|
+
sep10 = "\n";
|
|
94849
94849
|
prevMoreIndented = true;
|
|
94850
94850
|
} else if (content === "") {
|
|
94851
|
-
if (
|
|
94851
|
+
if (sep10 === "\n")
|
|
94852
94852
|
value += "\n";
|
|
94853
94853
|
else
|
|
94854
|
-
|
|
94854
|
+
sep10 = "\n";
|
|
94855
94855
|
} else {
|
|
94856
|
-
value +=
|
|
94857
|
-
|
|
94856
|
+
value += sep10 + content;
|
|
94857
|
+
sep10 = " ";
|
|
94858
94858
|
prevMoreIndented = false;
|
|
94859
94859
|
}
|
|
94860
94860
|
}
|
|
@@ -95037,25 +95037,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
95037
95037
|
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
95038
95038
|
}
|
|
95039
95039
|
let res = match[1].replace(trimEnd, "");
|
|
95040
|
-
let
|
|
95040
|
+
let sep10 = " ";
|
|
95041
95041
|
let pos = line.lastIndex;
|
|
95042
95042
|
while (match = line.exec(source)) {
|
|
95043
95043
|
const lm = match[1].replace(trimBoth, "");
|
|
95044
95044
|
if (lm === "") {
|
|
95045
|
-
if (
|
|
95046
|
-
res +=
|
|
95045
|
+
if (sep10 === "\n")
|
|
95046
|
+
res += sep10;
|
|
95047
95047
|
else
|
|
95048
|
-
|
|
95048
|
+
sep10 = "\n";
|
|
95049
95049
|
} else {
|
|
95050
|
-
res +=
|
|
95051
|
-
|
|
95050
|
+
res += sep10 + lm;
|
|
95051
|
+
sep10 = " ";
|
|
95052
95052
|
}
|
|
95053
95053
|
pos = line.lastIndex;
|
|
95054
95054
|
}
|
|
95055
95055
|
const last = /[ \t]*(.*)/sy;
|
|
95056
95056
|
last.lastIndex = pos;
|
|
95057
95057
|
match = last.exec(source);
|
|
95058
|
-
return res +
|
|
95058
|
+
return res + sep10 + (match?.[1] ?? "");
|
|
95059
95059
|
}
|
|
95060
95060
|
function doubleQuotedValue(source, onError) {
|
|
95061
95061
|
let res = "";
|
|
@@ -95865,14 +95865,14 @@ var require_cst_stringify = __commonJS({
|
|
|
95865
95865
|
}
|
|
95866
95866
|
}
|
|
95867
95867
|
}
|
|
95868
|
-
function stringifyItem({ start: start2, key: key2, sep:
|
|
95868
|
+
function stringifyItem({ start: start2, key: key2, sep: sep10, value }) {
|
|
95869
95869
|
let res = "";
|
|
95870
95870
|
for (const st of start2)
|
|
95871
95871
|
res += st.source;
|
|
95872
95872
|
if (key2)
|
|
95873
95873
|
res += stringifyToken(key2);
|
|
95874
|
-
if (
|
|
95875
|
-
for (const st of
|
|
95874
|
+
if (sep10)
|
|
95875
|
+
for (const st of sep10)
|
|
95876
95876
|
res += st.source;
|
|
95877
95877
|
if (value)
|
|
95878
95878
|
res += stringifyToken(value);
|
|
@@ -97039,18 +97039,18 @@ var require_parser2 = __commonJS({
|
|
|
97039
97039
|
if (this.type === "map-value-ind") {
|
|
97040
97040
|
const prev = getPrevProps(this.peek(2));
|
|
97041
97041
|
const start2 = getFirstKeyStartProps(prev);
|
|
97042
|
-
let
|
|
97042
|
+
let sep10;
|
|
97043
97043
|
if (scalar.end) {
|
|
97044
|
-
|
|
97045
|
-
|
|
97044
|
+
sep10 = scalar.end;
|
|
97045
|
+
sep10.push(this.sourceToken);
|
|
97046
97046
|
delete scalar.end;
|
|
97047
97047
|
} else
|
|
97048
|
-
|
|
97048
|
+
sep10 = [this.sourceToken];
|
|
97049
97049
|
const map2 = {
|
|
97050
97050
|
type: "block-map",
|
|
97051
97051
|
offset: scalar.offset,
|
|
97052
97052
|
indent: scalar.indent,
|
|
97053
|
-
items: [{ start: start2, key: scalar, sep:
|
|
97053
|
+
items: [{ start: start2, key: scalar, sep: sep10 }]
|
|
97054
97054
|
};
|
|
97055
97055
|
this.onKeyLine = true;
|
|
97056
97056
|
this.stack[this.stack.length - 1] = map2;
|
|
@@ -97203,15 +97203,15 @@ var require_parser2 = __commonJS({
|
|
|
97203
97203
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
97204
97204
|
const start3 = getFirstKeyStartProps(it.start);
|
|
97205
97205
|
const key2 = it.key;
|
|
97206
|
-
const
|
|
97207
|
-
|
|
97206
|
+
const sep10 = it.sep;
|
|
97207
|
+
sep10.push(this.sourceToken);
|
|
97208
97208
|
delete it.key;
|
|
97209
97209
|
delete it.sep;
|
|
97210
97210
|
this.stack.push({
|
|
97211
97211
|
type: "block-map",
|
|
97212
97212
|
offset: this.offset,
|
|
97213
97213
|
indent: this.indent,
|
|
97214
|
-
items: [{ start: start3, key: key2, sep:
|
|
97214
|
+
items: [{ start: start3, key: key2, sep: sep10 }]
|
|
97215
97215
|
});
|
|
97216
97216
|
} else if (start2.length > 0) {
|
|
97217
97217
|
it.sep = it.sep.concat(start2, this.sourceToken);
|
|
@@ -97405,13 +97405,13 @@ var require_parser2 = __commonJS({
|
|
|
97405
97405
|
const prev = getPrevProps(parent);
|
|
97406
97406
|
const start2 = getFirstKeyStartProps(prev);
|
|
97407
97407
|
fixFlowSeqItems(fc);
|
|
97408
|
-
const
|
|
97409
|
-
|
|
97408
|
+
const sep10 = fc.end.splice(1, fc.end.length);
|
|
97409
|
+
sep10.push(this.sourceToken);
|
|
97410
97410
|
const map2 = {
|
|
97411
97411
|
type: "block-map",
|
|
97412
97412
|
offset: fc.offset,
|
|
97413
97413
|
indent: fc.indent,
|
|
97414
|
-
items: [{ start: start2, key: fc, sep:
|
|
97414
|
+
items: [{ start: start2, key: fc, sep: sep10 }]
|
|
97415
97415
|
};
|
|
97416
97416
|
this.onKeyLine = true;
|
|
97417
97417
|
this.stack[this.stack.length - 1] = map2;
|
|
@@ -101252,7 +101252,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
|
|
|
101252
101252
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
101253
101253
|
function readCliVersion() {
|
|
101254
101254
|
if (true) {
|
|
101255
|
-
return "0.32.1-next.
|
|
101255
|
+
return "0.32.1-next.17";
|
|
101256
101256
|
}
|
|
101257
101257
|
return "0.0.0";
|
|
101258
101258
|
}
|
|
@@ -102534,9 +102534,9 @@ async function isExecutable2(p) {
|
|
|
102534
102534
|
return false;
|
|
102535
102535
|
}
|
|
102536
102536
|
}
|
|
102537
|
-
async function resolveDevecoBinary(
|
|
102537
|
+
async function resolveDevecoBinary(relative9) {
|
|
102538
102538
|
for (const root of devecoRoots()) {
|
|
102539
|
-
const candidate = (0, import_node_path6.join)(root,
|
|
102539
|
+
const candidate = (0, import_node_path6.join)(root, relative9) + BIN_EXT2;
|
|
102540
102540
|
if (await isExecutable2(candidate)) return candidate;
|
|
102541
102541
|
}
|
|
102542
102542
|
return null;
|
|
@@ -103045,7 +103045,14 @@ function loadSuppressUntil() {
|
|
|
103045
103045
|
function persistSuppressUntil(value) {
|
|
103046
103046
|
const filePath = getSuppressionFilePath();
|
|
103047
103047
|
import_node_fs5.default.mkdirSync(import_node_path8.default.dirname(filePath), { recursive: true });
|
|
103048
|
-
|
|
103048
|
+
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
103049
|
+
try {
|
|
103050
|
+
import_node_fs5.default.writeFileSync(tempPath, JSON.stringify({ suppressUntil: value }));
|
|
103051
|
+
import_node_fs5.default.renameSync(tempPath, filePath);
|
|
103052
|
+
} catch (error63) {
|
|
103053
|
+
import_node_fs5.default.rmSync(tempPath, { force: true });
|
|
103054
|
+
throw error63;
|
|
103055
|
+
}
|
|
103049
103056
|
}
|
|
103050
103057
|
var state2 = {
|
|
103051
103058
|
updateAvailable: false,
|
|
@@ -103057,17 +103064,23 @@ var state2 = {
|
|
|
103057
103064
|
currentVersion: version2
|
|
103058
103065
|
};
|
|
103059
103066
|
var interval = null;
|
|
103060
|
-
var
|
|
103067
|
+
var unpersistedUntil = 0;
|
|
103061
103068
|
function getUpdateState() {
|
|
103062
103069
|
return { ...state2 };
|
|
103063
103070
|
}
|
|
103064
103071
|
function isUpdateNoteSuppressed() {
|
|
103065
|
-
return Date.now() <
|
|
103072
|
+
return Date.now() < Math.max(loadSuppressUntil(), unpersistedUntil);
|
|
103066
103073
|
}
|
|
103067
103074
|
function suppressUpdateNote(durationMs) {
|
|
103068
|
-
const
|
|
103069
|
-
|
|
103070
|
-
|
|
103075
|
+
const until = Date.now() + durationMs;
|
|
103076
|
+
try {
|
|
103077
|
+
persistSuppressUntil(until);
|
|
103078
|
+
unpersistedUntil = 0;
|
|
103079
|
+
return { until, persisted: true };
|
|
103080
|
+
} catch {
|
|
103081
|
+
unpersistedUntil = until;
|
|
103082
|
+
return { until, persisted: false };
|
|
103083
|
+
}
|
|
103071
103084
|
}
|
|
103072
103085
|
function isNewerVersion(latest, current) {
|
|
103073
103086
|
if (!import_semver2.default.valid(latest) || !import_semver2.default.valid(current)) return false;
|
|
@@ -103129,11 +103142,9 @@ IMPORTANT \u2014 Updates must only be applied with the user's explicit, informed
|
|
|
103129
103142
|
How to update:
|
|
103130
103143
|
- Manual (user-initiated): run \`npx @swmansion/argent update\` in the terminal
|
|
103131
103144
|
- Agent-assisted (requires explicit user consent): call the \`update-argent\` tool \u2014 only after the user has explicitly asked you to update Argent in this conversation
|
|
103132
|
-
- To postpone
|
|
103133
|
-
|
|
103134
|
-
ACTION REQUIRED: Save a note (via TODO, task list) that an Argent update to v${latestVersion} is available so you can remind the user about it later. This notification will not repeat for the next 30 minutes.
|
|
103145
|
+
- To postpone it (later, tomorrow, stop, never): call the \`dismiss-update\` tool with the hours to wait, 87600 for never. That is the only thing that changes when this reminder appears; a memory or a reminder of your own does not
|
|
103135
103146
|
|
|
103136
|
-
|
|
103147
|
+
This reminder comes from Argent itself. It will not repeat for the next 30 minutes and then repeats on its own, so it needs no task, memory entry or scheduled reminder.`;
|
|
103137
103148
|
}
|
|
103138
103149
|
|
|
103139
103150
|
// ../tool-server/src/utils/screen-recording-reminder.ts
|
|
@@ -128074,11 +128085,11 @@ function parseVegaDeviceList(stdout) {
|
|
|
128074
128085
|
const devices = [];
|
|
128075
128086
|
for (const raw of stdout.split("\n")) {
|
|
128076
128087
|
const line = raw.trim();
|
|
128077
|
-
const
|
|
128078
|
-
if (
|
|
128079
|
-
const type = line.slice(0,
|
|
128088
|
+
const sep10 = line.indexOf(" : ");
|
|
128089
|
+
if (sep10 < 0) continue;
|
|
128090
|
+
const type = line.slice(0, sep10).trim();
|
|
128080
128091
|
if (!/^[A-Za-z]+$/.test(type)) continue;
|
|
128081
|
-
const rhs = line.slice(
|
|
128092
|
+
const rhs = line.slice(sep10 + 3).trim();
|
|
128082
128093
|
const parts2 = rhs.split(/\s+-\s+/);
|
|
128083
128094
|
const serial = parts2[parts2.length - 1]?.trim();
|
|
128084
128095
|
if (!serial) continue;
|
|
@@ -128801,9 +128812,9 @@ var VariantProposalStore = class {
|
|
|
128801
128812
|
this.completed = true;
|
|
128802
128813
|
if (!wasResubmit) this.consumed = false;
|
|
128803
128814
|
this.lastOutcome = this.buildOutcome();
|
|
128804
|
-
const
|
|
128805
|
-
const toSettle = this.waitersList.filter((w) => !w.settled && w.round ===
|
|
128806
|
-
this.waitersList = this.waitersList.filter((w) => w.round !==
|
|
128815
|
+
const round3 = this.round;
|
|
128816
|
+
const toSettle = this.waitersList.filter((w) => !w.settled && w.round === round3);
|
|
128817
|
+
this.waitersList = this.waitersList.filter((w) => w.round !== round3 || w.settled);
|
|
128807
128818
|
if (toSettle.length > 0) {
|
|
128808
128819
|
this.consumed = true;
|
|
128809
128820
|
for (const w of toSettle) {
|
|
@@ -128813,7 +128824,7 @@ var VariantProposalStore = class {
|
|
|
128813
128824
|
} else if (this.cliSession) {
|
|
128814
128825
|
this.consumed = true;
|
|
128815
128826
|
} else if (!this.consumed) {
|
|
128816
|
-
this.pendingOutcomes = this.pendingOutcomes.filter((o) => o.round !==
|
|
128827
|
+
this.pendingOutcomes = this.pendingOutcomes.filter((o) => o.round !== round3);
|
|
128817
128828
|
this.pendingOutcomes.push(this.lastOutcome);
|
|
128818
128829
|
if (this.pendingOutcomes.length > MAX_PENDING_OUTCOMES) {
|
|
128819
128830
|
this.pendingOutcomes.shift();
|
|
@@ -128842,7 +128853,7 @@ var VariantProposalStore = class {
|
|
|
128842
128853
|
platform: this.device ? classifyDeviceForTelemetry(this.device) : void 0
|
|
128843
128854
|
});
|
|
128844
128855
|
}
|
|
128845
|
-
return { ok: true, round:
|
|
128856
|
+
return { ok: true, round: round3, resolved: this.submitted.length };
|
|
128846
128857
|
}
|
|
128847
128858
|
buildOutcome() {
|
|
128848
128859
|
const selections = [];
|
|
@@ -131394,12 +131405,12 @@ function isSafeTarMember(memberPath2, destDir) {
|
|
|
131394
131405
|
const normalized = normalizeTarMemberPath(memberPath2);
|
|
131395
131406
|
if (!normalized || normalized === "." || normalized === "./") return false;
|
|
131396
131407
|
if (normalized.startsWith("/") || /^[A-Za-z]:[\\/]/.test(normalized)) return false;
|
|
131397
|
-
const
|
|
131398
|
-
if (
|
|
131408
|
+
const relative9 = import_node_path12.posix.normalize(normalized);
|
|
131409
|
+
if (relative9 === ".." || relative9.startsWith("../") || relative9.split("/").includes("..")) {
|
|
131399
131410
|
return false;
|
|
131400
131411
|
}
|
|
131401
131412
|
const root = (0, import_node_path12.resolve)(destDir);
|
|
131402
|
-
const resolved = (0, import_node_path12.resolve)(destDir,
|
|
131413
|
+
const resolved = (0, import_node_path12.resolve)(destDir, relative9);
|
|
131403
131414
|
return resolved === root || resolved.startsWith(root + import_node_path12.sep);
|
|
131404
131415
|
}
|
|
131405
131416
|
async function listTarMembers(tarPath) {
|
|
@@ -137885,21 +137896,21 @@ var Matcher = class {
|
|
|
137885
137896
|
* @returns {string}
|
|
137886
137897
|
*/
|
|
137887
137898
|
toString(separator, includeNamespace = true) {
|
|
137888
|
-
const
|
|
137889
|
-
const isDefault =
|
|
137899
|
+
const sep10 = separator || this.separator;
|
|
137900
|
+
const isDefault = sep10 === this.separator && includeNamespace === true;
|
|
137890
137901
|
if (isDefault) {
|
|
137891
137902
|
if (this._pathStringCache !== null) {
|
|
137892
137903
|
return this._pathStringCache;
|
|
137893
137904
|
}
|
|
137894
137905
|
const result = this.path.map(
|
|
137895
137906
|
(n) => n.namespace ? `${n.namespace}:${n.tag}` : n.tag
|
|
137896
|
-
).join(
|
|
137907
|
+
).join(sep10);
|
|
137897
137908
|
this._pathStringCache = result;
|
|
137898
137909
|
return result;
|
|
137899
137910
|
}
|
|
137900
137911
|
return this.path.map(
|
|
137901
137912
|
(n) => includeNamespace && n.namespace ? `${n.namespace}:${n.tag}` : n.tag
|
|
137902
|
-
).join(
|
|
137913
|
+
).join(sep10);
|
|
137903
137914
|
}
|
|
137904
137915
|
/**
|
|
137905
137916
|
* Get path as array of tag names.
|
|
@@ -142434,12 +142445,12 @@ function evaluateCondition(condition, expectedText, matches2, textMatch = "conta
|
|
|
142434
142445
|
}
|
|
142435
142446
|
function treeFingerprint(root, include) {
|
|
142436
142447
|
const parts2 = [];
|
|
142437
|
-
const
|
|
142448
|
+
const round3 = (n) => Math.round(n * 1e3) / 1e3;
|
|
142438
142449
|
const walk = (node2) => {
|
|
142439
142450
|
if (!include || include(node2)) {
|
|
142440
142451
|
const f = node2.frame;
|
|
142441
142452
|
parts2.push(
|
|
142442
|
-
`${node2.role}|${
|
|
142453
|
+
`${node2.role}|${round3(f.x)},${round3(f.y)},${round3(f.width)},${round3(f.height)}|${node2.label ?? ""}|${node2.value ?? ""}|${node2.identifier ?? ""}`
|
|
142443
142454
|
);
|
|
142444
142455
|
}
|
|
142445
142456
|
for (const child of node2.children) walk(child);
|
|
@@ -144152,10 +144163,7 @@ function createHttpApp(registry2, options) {
|
|
|
144152
144163
|
const { updateInstallable, currentVersion, installableVersion } = getUpdateState();
|
|
144153
144164
|
const shouldNotify = updateInstallable && !isUpdateNoteSuppressed();
|
|
144154
144165
|
if (shouldNotify) {
|
|
144155
|
-
|
|
144156
|
-
suppressUpdateNote(AUTO_SUPPRESS_MS);
|
|
144157
|
-
} catch {
|
|
144158
|
-
}
|
|
144166
|
+
suppressUpdateNote(AUTO_SUPPRESS_MS);
|
|
144159
144167
|
}
|
|
144160
144168
|
const notes = shouldNotify ? [buildUpdateNote(currentVersion, installableVersion ?? "unknown")] : [];
|
|
144161
144169
|
const activeRecordings2 = getActiveScreenRecordings();
|
|
@@ -146138,6 +146146,13 @@ Returns { status: "init_failed", message, attempts } instead when the simulator'
|
|
|
146138
146146
|
Fails if the simulator server is not running for the given UDID.`,
|
|
146139
146147
|
zodSchema: zodSchema3,
|
|
146140
146148
|
readOnly: true,
|
|
146149
|
+
// When the app is not connected, the native-* tools that use native devtools
|
|
146150
|
+
// run the same precheck and return the same `message` (buildAppStateMessage),
|
|
146151
|
+
// so agents need no separate status call. Their `status` names the remedy,
|
|
146152
|
+
// where this tool gives `state`. They fail instead for an Apple system app and
|
|
146153
|
+
// for an app that a device provider did not lend. The SDK and the e2e-full
|
|
146154
|
+
// suite still call it.
|
|
146155
|
+
hideFromMcp: true,
|
|
146141
146156
|
interaction: {
|
|
146142
146157
|
startedMsg: ({ params }) => `Checking native inspection for ${params.bundleId}`,
|
|
146143
146158
|
completedMsg: ({ params }) => `Checked native inspection for ${params.bundleId}`,
|
|
@@ -146328,7 +146343,7 @@ On iOS: returns { status, count, events } where each event contains URL, method,
|
|
|
146328
146343
|
<flag:macos-apps>On a Mac app it records NSURLSession requests, react-native-macos fetch included, with the same event fields. The first call turns capture on and earlier requests are not logged: call it once, then repeat the action. Capture stays on across restart-app with an empty log per process, and requests sent while the app starts can be missing. The statuses below are iOS only.
|
|
146329
146344
|
</flag:macos-apps>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.
|
|
146330
146345
|
On a device whose devtools agent argent attached to rather than armed itself, 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).
|
|
146331
|
-
On Android: needs a debuggable build
|
|
146346
|
+
On Android: needs a debuggable build. The first call starts capture and usually returns armed: false. Call it again every few seconds until armed is true, then repeat the action whose requests you need: earlier requests are not captured.
|
|
146332
146347
|
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.
|
|
146333
146348
|
Returns { status, header, armed, capture, captureDetail, count, total, requests }. When capture is active, captureDetail and the header can say that only some requests are captured: then an empty or short list does not mean the app sent nothing. Pass a request's ID (android-3f9a-12) to view-network-request-details for its headers, redirects and bodies.
|
|
146334
146349
|
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 there ends only when stop-all-simulator-servers stops this device's services and the app restarts.
|
|
@@ -146770,8 +146785,17 @@ An Apple system app is rejected outright (terminal: never retry it).`,
|
|
|
146770
146785
|
init_src2();
|
|
146771
146786
|
|
|
146772
146787
|
// ../tool-server/src/utils/debugger/discovery.ts
|
|
146788
|
+
var import_node_fs13 = require("node:fs");
|
|
146773
146789
|
init_src2();
|
|
146774
146790
|
var DECOY_VM = "don't use";
|
|
146791
|
+
function decodeProjectRoot(raw) {
|
|
146792
|
+
if (!raw.includes("%") || (0, import_node_fs13.existsSync)(raw)) return raw;
|
|
146793
|
+
try {
|
|
146794
|
+
return decodeURIComponent(raw);
|
|
146795
|
+
} catch {
|
|
146796
|
+
return raw;
|
|
146797
|
+
}
|
|
146798
|
+
}
|
|
146775
146799
|
async function discoverMetro(port) {
|
|
146776
146800
|
let statusRes;
|
|
146777
146801
|
try {
|
|
@@ -146813,7 +146837,7 @@ async function discoverMetro(port) {
|
|
|
146813
146837
|
}
|
|
146814
146838
|
);
|
|
146815
146839
|
}
|
|
146816
|
-
const projectRoot = statusRes.headers.get("X-React-Native-Project-Root") ?? "";
|
|
146840
|
+
const projectRoot = decodeProjectRoot(statusRes.headers.get("X-React-Native-Project-Root") ?? "");
|
|
146817
146841
|
let listRes;
|
|
146818
146842
|
try {
|
|
146819
146843
|
listRes = await fetch(`http://localhost:${port}/json/list`);
|
|
@@ -149421,7 +149445,7 @@ function clearLostProfilerRun(port, deviceId) {
|
|
|
149421
149445
|
|
|
149422
149446
|
// ../tool-server/src/tools/devices/boot-device.ts
|
|
149423
149447
|
var import_node_child_process34 = require("node:child_process");
|
|
149424
|
-
var
|
|
149448
|
+
var import_node_fs15 = require("node:fs");
|
|
149425
149449
|
var import_promises13 = require("node:fs/promises");
|
|
149426
149450
|
var import_node_os14 = require("node:os");
|
|
149427
149451
|
var import_node_path19 = require("node:path");
|
|
@@ -149534,7 +149558,7 @@ function readMb(config2, key2) {
|
|
|
149534
149558
|
|
|
149535
149559
|
// ../tool-server/src/utils/simulator-app-launch.ts
|
|
149536
149560
|
var import_node_child_process32 = require("node:child_process");
|
|
149537
|
-
var
|
|
149561
|
+
var import_node_fs14 = __toESM(require("node:fs"));
|
|
149538
149562
|
var import_node_os13 = __toESM(require("node:os"));
|
|
149539
149563
|
var import_node_path18 = __toESM(require("node:path"));
|
|
149540
149564
|
var import_node_util23 = require("node:util");
|
|
@@ -149548,7 +149572,7 @@ function verdictFilePath() {
|
|
|
149548
149572
|
}
|
|
149549
149573
|
function loadVerdicts() {
|
|
149550
149574
|
try {
|
|
149551
|
-
const parsed = JSON.parse(
|
|
149575
|
+
const parsed = JSON.parse(import_node_fs14.default.readFileSync(verdictFilePath(), "utf8"));
|
|
149552
149576
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
149553
149577
|
} catch {
|
|
149554
149578
|
return {};
|
|
@@ -149556,13 +149580,13 @@ function loadVerdicts() {
|
|
|
149556
149580
|
}
|
|
149557
149581
|
function persistVerdict(key2, verdict) {
|
|
149558
149582
|
const filePath = verdictFilePath();
|
|
149559
|
-
|
|
149583
|
+
import_node_fs14.default.mkdirSync(import_node_path18.default.dirname(filePath), { recursive: true });
|
|
149560
149584
|
const tmpPath = `${filePath}.${process.pid}.tmp`;
|
|
149561
149585
|
try {
|
|
149562
|
-
|
|
149563
|
-
|
|
149586
|
+
import_node_fs14.default.writeFileSync(tmpPath, JSON.stringify({ ...loadVerdicts(), [key2]: verdict }, null, 2));
|
|
149587
|
+
import_node_fs14.default.renameSync(tmpPath, filePath);
|
|
149564
149588
|
} catch (err) {
|
|
149565
|
-
|
|
149589
|
+
import_node_fs14.default.rmSync(tmpPath, { force: true });
|
|
149566
149590
|
throw err;
|
|
149567
149591
|
}
|
|
149568
149592
|
}
|
|
@@ -150344,9 +150368,9 @@ async function bootIos(udid, registry2, force, headless) {
|
|
|
150344
150368
|
async function openSimulatorWindow(udid) {
|
|
150345
150369
|
const timeout = 5e3;
|
|
150346
150370
|
const { stdout } = await execFileAsync24("xcode-select", ["-p"], { timeout });
|
|
150347
|
-
const developerDir2 = (0,
|
|
150371
|
+
const developerDir2 = (0, import_node_fs15.realpathSync)(stdout.trim());
|
|
150348
150372
|
const simulatorApp = (0, import_node_path19.join)(developerDir2, "Applications", "Simulator.app");
|
|
150349
|
-
if ((0,
|
|
150373
|
+
if ((0, import_node_fs15.existsSync)(simulatorApp)) {
|
|
150350
150374
|
const launched = await launchSimulatorApp(
|
|
150351
150375
|
simulatorApp,
|
|
150352
150376
|
() => execFileAsync24("open", ["-a", simulatorApp], { timeout })
|
|
@@ -150354,7 +150378,7 @@ async function openSimulatorWindow(udid) {
|
|
|
150354
150378
|
return launched ? void 0 : `${simulatorApp} exits right after launch on this host, so Argent no longer opens it and the device runs without a window. Delete ~/.argent/simulator-app-launch.json to try opening it again.`;
|
|
150355
150379
|
}
|
|
150356
150380
|
const deviceHubApp = (0, import_node_path19.join)(developerDir2, "..", "Applications", "DeviceHub.app");
|
|
150357
|
-
if ((0,
|
|
150381
|
+
if ((0, import_node_fs15.existsSync)(deviceHubApp)) {
|
|
150358
150382
|
const url2 = `devices://device/open?id=${encodeURIComponent(udid)}`;
|
|
150359
150383
|
await execFileAsync24("open", ["-a", deviceHubApp, url2], { timeout });
|
|
150360
150384
|
}
|
|
@@ -150402,7 +150426,7 @@ async function attemptBoot(params) {
|
|
|
150402
150426
|
if (process.platform === "win32") {
|
|
150403
150427
|
const safeName = params.avdName.replace(/[^\w.-]/g, "_");
|
|
150404
150428
|
const logPath = (0, import_node_path19.join)((0, import_node_os14.tmpdir)(), `argent-emulator-${safeName}.log`);
|
|
150405
|
-
emulatorLogFd = (0,
|
|
150429
|
+
emulatorLogFd = (0, import_node_fs15.openSync)(logPath, "w");
|
|
150406
150430
|
stdio = ["ignore", emulatorLogFd, emulatorLogFd];
|
|
150407
150431
|
}
|
|
150408
150432
|
const child = (0, import_node_child_process34.spawn)(params.emulatorBinary, params.emulatorArgs, {
|
|
@@ -150412,7 +150436,7 @@ async function attemptBoot(params) {
|
|
|
150412
150436
|
child.unref();
|
|
150413
150437
|
if (emulatorLogFd !== void 0) {
|
|
150414
150438
|
try {
|
|
150415
|
-
(0,
|
|
150439
|
+
(0, import_node_fs15.closeSync)(emulatorLogFd);
|
|
150416
150440
|
} catch {
|
|
150417
150441
|
}
|
|
150418
150442
|
}
|
|
@@ -150930,11 +150954,11 @@ async function startHarmonyEmulator(instanceName) {
|
|
|
150930
150954
|
});
|
|
150931
150955
|
}
|
|
150932
150956
|
try {
|
|
150933
|
-
for (const entry of (0,
|
|
150957
|
+
for (const entry of (0, import_node_fs15.readdirSync)((0, import_node_os14.tmpdir)())) {
|
|
150934
150958
|
if (!entry.startsWith("argent-harmony-") || !entry.endsWith(".log")) continue;
|
|
150935
150959
|
try {
|
|
150936
|
-
if (Date.now() - (0,
|
|
150937
|
-
(0,
|
|
150960
|
+
if (Date.now() - (0, import_node_fs15.statSync)((0, import_node_path19.join)((0, import_node_os14.tmpdir)(), entry)).mtimeMs > HARMONY_LOG_TTL_MS) {
|
|
150961
|
+
(0, import_node_fs15.rmSync)((0, import_node_path19.join)((0, import_node_os14.tmpdir)(), entry), { force: true });
|
|
150938
150962
|
}
|
|
150939
150963
|
} catch {
|
|
150940
150964
|
}
|
|
@@ -150945,7 +150969,7 @@ async function startHarmonyEmulator(instanceName) {
|
|
|
150945
150969
|
const logPath = (0, import_node_path19.join)((0, import_node_os14.tmpdir)(), `argent-harmony-${safeName}-${process.hrtime.bigint()}.log`);
|
|
150946
150970
|
let logFd;
|
|
150947
150971
|
try {
|
|
150948
|
-
logFd = (0,
|
|
150972
|
+
logFd = (0, import_node_fs15.openSync)(logPath, "w");
|
|
150949
150973
|
} catch {
|
|
150950
150974
|
logFd = null;
|
|
150951
150975
|
}
|
|
@@ -150956,7 +150980,7 @@ async function startHarmonyEmulator(instanceName) {
|
|
|
150956
150980
|
child.unref();
|
|
150957
150981
|
if (logFd !== null) {
|
|
150958
150982
|
try {
|
|
150959
|
-
(0,
|
|
150983
|
+
(0, import_node_fs15.closeSync)(logFd);
|
|
150960
150984
|
} catch {
|
|
150961
150985
|
}
|
|
150962
150986
|
}
|
|
@@ -150965,7 +150989,7 @@ async function startHarmonyEmulator(instanceName) {
|
|
|
150965
150989
|
if (exit) return;
|
|
150966
150990
|
let output2 = "";
|
|
150967
150991
|
try {
|
|
150968
|
-
output2 = (0,
|
|
150992
|
+
output2 = (0, import_node_fs15.readFileSync)(logPath, "utf8");
|
|
150969
150993
|
} catch {
|
|
150970
150994
|
}
|
|
150971
150995
|
exit = { reason: reason2, output: output2 };
|
|
@@ -153521,7 +153545,7 @@ init_device_info();
|
|
|
153521
153545
|
init_adb();
|
|
153522
153546
|
|
|
153523
153547
|
// ../tool-server/src/utils/device-orientation.ts
|
|
153524
|
-
var
|
|
153548
|
+
var import_node_fs16 = require("node:fs");
|
|
153525
153549
|
init_adb();
|
|
153526
153550
|
var SURFACE_ROTATION_TO_NAME = {
|
|
153527
153551
|
0: "Portrait",
|
|
@@ -153566,7 +153590,7 @@ function captureRotationForSurface(rotation) {
|
|
|
153566
153590
|
async function readPngSize2(path63) {
|
|
153567
153591
|
let handle;
|
|
153568
153592
|
try {
|
|
153569
|
-
handle = await
|
|
153593
|
+
handle = await import_node_fs16.promises.open(path63, "r");
|
|
153570
153594
|
const buf = Buffer.alloc(24);
|
|
153571
153595
|
const { bytesRead } = await handle.read(buf, 0, 24, 0);
|
|
153572
153596
|
if (bytesRead < 24) return null;
|
|
@@ -157723,8 +157747,9 @@ var zodSchema33 = external_exports.object({
|
|
|
157723
157747
|
var debuggerEvaluateTool = {
|
|
157724
157748
|
id: "debugger-evaluate",
|
|
157725
157749
|
description: `Execute arbitrary JavaScript in the app's JS runtime via CDP: Hermes on iOS / Android / Vega, V8 on Chromium.
|
|
157726
|
-
Returns the result serialized by value as JSON, with deviceName, appName, and logicalDeviceId. Use when you need to read app state, call app functions, or test logic at runtime. Cyclic objects, which many RN runtime values are (fiber nodes, navigation refs, global), fail with a serialization error. Fails if the expression throws or the runtime is not connected.`,
|
|
157750
|
+
Returns the result serialized by value as JSON, with deviceName, appName, and logicalDeviceId. Use when you need to read app state, including localStorage and sessionStorage on Chromium, call app functions, or test logic at runtime. Cyclic objects, which many RN runtime values are (fiber nodes, navigation refs, global), fail with a serialization error. Fails if the expression throws or the runtime is not connected.`,
|
|
157727
157751
|
zodSchema: zodSchema33,
|
|
157752
|
+
searchHint: "javascript js eval expression runtime app state localstorage sessionstorage web storage",
|
|
157728
157753
|
interaction: {
|
|
157729
157754
|
startedMsg: () => "Running JavaScript in the app",
|
|
157730
157755
|
completedMsg: () => "Ran JavaScript in the app",
|
|
@@ -161276,12 +161301,12 @@ var capability29 = {
|
|
|
161276
161301
|
macos: { app: true }
|
|
161277
161302
|
};
|
|
161278
161303
|
function treeSignature(root) {
|
|
161279
|
-
const
|
|
161304
|
+
const round3 = (n) => Math.round(n * 100) / 100;
|
|
161280
161305
|
const parts2 = [];
|
|
161281
161306
|
const walk = (node2) => {
|
|
161282
161307
|
const f = node2.frame;
|
|
161283
161308
|
parts2.push(
|
|
161284
|
-
`${node2.role}|${node2.label ?? ""}|${node2.value ?? ""}|${
|
|
161309
|
+
`${node2.role}|${node2.label ?? ""}|${node2.value ?? ""}|${round3(f.x)},${round3(f.y)},${round3(f.width)},${round3(f.height)}`
|
|
161285
161310
|
);
|
|
161286
161311
|
for (const child of node2.children) walk(child);
|
|
161287
161312
|
};
|
|
@@ -161956,6 +161981,185 @@ async function readCommitTree(path63) {
|
|
|
161956
161981
|
return JSON.parse(json2);
|
|
161957
161982
|
}
|
|
161958
161983
|
|
|
161984
|
+
// ../tool-server/src/utils/react-profiler/pipeline/00-cpu-correlate.ts
|
|
161985
|
+
var ARGENT_PROFILER_PREFIX = "__argent_";
|
|
161986
|
+
var MIN_STALE_GAP_US = 1e6;
|
|
161987
|
+
function isArgentProfilerFunction(name) {
|
|
161988
|
+
return name.startsWith(ARGENT_PROFILER_PREFIX);
|
|
161989
|
+
}
|
|
161990
|
+
function dropStaleLeadingGap(profile) {
|
|
161991
|
+
const { timeDeltas } = profile;
|
|
161992
|
+
const first = timeDeltas.findIndex((delta, i) => i > 0 && delta > 0);
|
|
161993
|
+
if (first < 0) return;
|
|
161994
|
+
const gap = timeDeltas[first];
|
|
161995
|
+
if (gap < MIN_STALE_GAP_US || gap <= profile.endTime - profile.startTime - gap) return;
|
|
161996
|
+
timeDeltas[first] = 0;
|
|
161997
|
+
profile.startTime += gap;
|
|
161998
|
+
}
|
|
161999
|
+
function buildCpuSampleIndex(cpuProfile) {
|
|
162000
|
+
const { nodes, samples, timeDeltas, startTime, endTime } = cpuProfile;
|
|
162001
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
162002
|
+
for (const node2 of nodes) {
|
|
162003
|
+
nodeMap.set(node2.id, node2);
|
|
162004
|
+
}
|
|
162005
|
+
const timestampsMs = new Float64Array(samples.length);
|
|
162006
|
+
const intervalStartsMs = new Float64Array(samples.length);
|
|
162007
|
+
let accumulatedUs = 0;
|
|
162008
|
+
for (let i = 0; i < samples.length; i++) {
|
|
162009
|
+
const raw = timeDeltas[i];
|
|
162010
|
+
const delta = Number.isFinite(raw) && (raw ?? 0) >= 0 ? raw : 0;
|
|
162011
|
+
intervalStartsMs[i] = accumulatedUs / 1e3;
|
|
162012
|
+
accumulatedUs += delta;
|
|
162013
|
+
timestampsMs[i] = accumulatedUs / 1e3;
|
|
162014
|
+
}
|
|
162015
|
+
return {
|
|
162016
|
+
childToParent: buildChildToParent(nodeMap),
|
|
162017
|
+
timestampsMs,
|
|
162018
|
+
intervalStartsMs,
|
|
162019
|
+
sampleNodeIds: samples,
|
|
162020
|
+
nodeMap,
|
|
162021
|
+
durationMs: (endTime - startTime) / 1e3
|
|
162022
|
+
};
|
|
162023
|
+
}
|
|
162024
|
+
var IDLE_FRAME_NAMES = /* @__PURE__ */ new Set(["(idle)", "(program)", "(root)", "[idle]", "[root]"]);
|
|
162025
|
+
function isIdleFrame(name) {
|
|
162026
|
+
return !name || IDLE_FRAME_NAMES.has(name);
|
|
162027
|
+
}
|
|
162028
|
+
function queryCpuWindow(index, startMs, endMs, topN2 = 5) {
|
|
162029
|
+
const { timestampsMs, intervalStartsMs, sampleNodeIds, nodeMap } = index;
|
|
162030
|
+
const n = timestampsMs.length;
|
|
162031
|
+
const sampleRangeMs = {
|
|
162032
|
+
start: n > 0 ? intervalStartsMs[0] : 0,
|
|
162033
|
+
end: n > 0 ? timestampsMs[n - 1] : 0
|
|
162034
|
+
};
|
|
162035
|
+
const empty2 = {
|
|
162036
|
+
hotspots: [],
|
|
162037
|
+
samplesInWindow: 0,
|
|
162038
|
+
coveredMs: 0,
|
|
162039
|
+
idleMs: 0,
|
|
162040
|
+
sampleRangeMs,
|
|
162041
|
+
medianIntervalMs: 0,
|
|
162042
|
+
maxIntervalMs: 0
|
|
162043
|
+
};
|
|
162044
|
+
if (n === 0) return empty2;
|
|
162045
|
+
let lo = 0;
|
|
162046
|
+
let hi = n;
|
|
162047
|
+
while (lo < hi) {
|
|
162048
|
+
const mid = lo + hi >>> 1;
|
|
162049
|
+
if (timestampsMs[mid] < startMs) lo = mid + 1;
|
|
162050
|
+
else hi = mid;
|
|
162051
|
+
}
|
|
162052
|
+
const selfMsByNode = /* @__PURE__ */ new Map();
|
|
162053
|
+
const intervals = [];
|
|
162054
|
+
let samplesInWindow = 0;
|
|
162055
|
+
let coveredMs = 0;
|
|
162056
|
+
let idleMs = 0;
|
|
162057
|
+
let maxIntervalMs = 0;
|
|
162058
|
+
for (let i = lo; i < n; i++) {
|
|
162059
|
+
const from2 = intervalStartsMs[i];
|
|
162060
|
+
if (from2 > endMs) break;
|
|
162061
|
+
const overlap = Math.min(endMs, timestampsMs[i]) - Math.max(startMs, from2);
|
|
162062
|
+
if (overlap <= 0) continue;
|
|
162063
|
+
samplesInWindow++;
|
|
162064
|
+
coveredMs += overlap;
|
|
162065
|
+
intervals.push(timestampsMs[i] - from2);
|
|
162066
|
+
if (timestampsMs[i] - from2 > maxIntervalMs) maxIntervalMs = timestampsMs[i] - from2;
|
|
162067
|
+
const nodeId = sampleNodeIds[i];
|
|
162068
|
+
const node2 = nodeMap.get(nodeId);
|
|
162069
|
+
if (isIdleFrame(node2?.callFrame.functionName)) {
|
|
162070
|
+
idleMs += overlap;
|
|
162071
|
+
continue;
|
|
162072
|
+
}
|
|
162073
|
+
selfMsByNode.set(nodeId, (selfMsByNode.get(nodeId) ?? 0) + overlap);
|
|
162074
|
+
}
|
|
162075
|
+
if (samplesInWindow === 0) return { ...empty2, sampleRangeMs };
|
|
162076
|
+
intervals.sort((a, b) => a - b);
|
|
162077
|
+
const medianIntervalMs = intervals[Math.floor(intervals.length / 2)] ?? 0;
|
|
162078
|
+
const childToParent = index.childToParent ?? buildChildToParent(nodeMap);
|
|
162079
|
+
const totalMsByNode = /* @__PURE__ */ new Map();
|
|
162080
|
+
for (const [nodeId, ms] of selfMsByNode) {
|
|
162081
|
+
totalMsByNode.set(nodeId, (totalMsByNode.get(nodeId) ?? 0) + ms);
|
|
162082
|
+
let current = nodeId;
|
|
162083
|
+
const seen = /* @__PURE__ */ new Set([current]);
|
|
162084
|
+
while (childToParent.has(current)) {
|
|
162085
|
+
const parent = childToParent.get(current);
|
|
162086
|
+
if (seen.has(parent)) break;
|
|
162087
|
+
seen.add(parent);
|
|
162088
|
+
totalMsByNode.set(parent, (totalMsByNode.get(parent) ?? 0) + ms);
|
|
162089
|
+
current = parent;
|
|
162090
|
+
}
|
|
162091
|
+
}
|
|
162092
|
+
const entries = [];
|
|
162093
|
+
for (const [nodeId, ms] of selfMsByNode) {
|
|
162094
|
+
const node2 = nodeMap.get(nodeId);
|
|
162095
|
+
if (!node2) continue;
|
|
162096
|
+
const name = node2.callFrame.functionName;
|
|
162097
|
+
if (isArgentProfilerFunction(name)) continue;
|
|
162098
|
+
entries.push({
|
|
162099
|
+
name,
|
|
162100
|
+
selfMs: Math.round(ms * 100) / 100,
|
|
162101
|
+
totalMs: Math.round((totalMsByNode.get(nodeId) ?? ms) * 100) / 100,
|
|
162102
|
+
url: node2.callFrame.url || void 0,
|
|
162103
|
+
lineNumber: node2.callFrame.lineNumber >= 0 ? node2.callFrame.lineNumber : void 0
|
|
162104
|
+
});
|
|
162105
|
+
}
|
|
162106
|
+
entries.sort((a, b) => b.selfMs - a.selfMs);
|
|
162107
|
+
return {
|
|
162108
|
+
hotspots: entries.slice(0, topN2),
|
|
162109
|
+
samplesInWindow,
|
|
162110
|
+
coveredMs,
|
|
162111
|
+
idleMs,
|
|
162112
|
+
sampleRangeMs,
|
|
162113
|
+
medianIntervalMs,
|
|
162114
|
+
maxIntervalMs
|
|
162115
|
+
};
|
|
162116
|
+
}
|
|
162117
|
+
function buildChildToParent(nodeMap) {
|
|
162118
|
+
const childToParent = /* @__PURE__ */ new Map();
|
|
162119
|
+
for (const node2 of nodeMap.values()) {
|
|
162120
|
+
for (const childId of node2.children ?? []) childToParent.set(childId, node2.id);
|
|
162121
|
+
}
|
|
162122
|
+
return childToParent;
|
|
162123
|
+
}
|
|
162124
|
+
function correlateCpuWithCommits(summaries, index, topNPerCommit = 5) {
|
|
162125
|
+
if (!index) return summaries;
|
|
162126
|
+
return summaries.map((summary) => {
|
|
162127
|
+
if (summary.isMargin) return summary;
|
|
162128
|
+
const startMs = summary.timestampMs;
|
|
162129
|
+
const endMs = summary.timestampMs + summary.totalRenderMs;
|
|
162130
|
+
const { hotspots } = queryCpuWindow(index, startMs, endMs, topNPerCommit);
|
|
162131
|
+
if (hotspots.length === 0) return summary;
|
|
162132
|
+
return { ...summary, cpuHotspots: hotspots };
|
|
162133
|
+
});
|
|
162134
|
+
}
|
|
162135
|
+
function serializeCpuSampleIndex(index) {
|
|
162136
|
+
return {
|
|
162137
|
+
version: 2,
|
|
162138
|
+
timestampsMs: Array.from(index.timestampsMs),
|
|
162139
|
+
intervalStartsMs: Array.from(index.intervalStartsMs),
|
|
162140
|
+
sampleNodeIds: index.sampleNodeIds,
|
|
162141
|
+
nodes: [...index.nodeMap.values()],
|
|
162142
|
+
durationMs: index.durationMs
|
|
162143
|
+
};
|
|
162144
|
+
}
|
|
162145
|
+
function deserializeCpuSampleIndex(raw) {
|
|
162146
|
+
if (raw?.version !== 2 || !Array.isArray(raw.timestampsMs) || !Array.isArray(raw.nodes)) {
|
|
162147
|
+
throw new Error("unsupported CPU sample index format");
|
|
162148
|
+
}
|
|
162149
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
162150
|
+
for (const node2 of raw.nodes) {
|
|
162151
|
+
nodeMap.set(node2.id, node2);
|
|
162152
|
+
}
|
|
162153
|
+
return {
|
|
162154
|
+
timestampsMs: new Float64Array(raw.timestampsMs),
|
|
162155
|
+
intervalStartsMs: new Float64Array(raw.intervalStartsMs ?? []),
|
|
162156
|
+
sampleNodeIds: raw.sampleNodeIds,
|
|
162157
|
+
nodeMap,
|
|
162158
|
+
childToParent: buildChildToParent(nodeMap),
|
|
162159
|
+
durationMs: raw.durationMs
|
|
162160
|
+
};
|
|
162161
|
+
}
|
|
162162
|
+
|
|
161959
162163
|
// ../tool-server/src/utils/react-profiler/last-run.ts
|
|
161960
162164
|
function savedSessionInfo(paths) {
|
|
161961
162165
|
return {
|
|
@@ -162005,6 +162209,424 @@ function lastRunText(saved, lost) {
|
|
|
162005
162209
|
return null;
|
|
162006
162210
|
}
|
|
162007
162211
|
|
|
162212
|
+
// ../tool-server/src/utils/react-profiler/pipeline/utils.ts
|
|
162213
|
+
function deriveReason(cd, hookTypes) {
|
|
162214
|
+
if (cd === null) return "unknown";
|
|
162215
|
+
if (cd.props !== null && cd.props.length > 0) return "props";
|
|
162216
|
+
if (cd.didHooksChange || cd.hooks !== null && cd.hooks.length > 0) {
|
|
162217
|
+
if (hookTypes && cd.hooks) {
|
|
162218
|
+
const isState = cd.hooks.some((idx) => {
|
|
162219
|
+
const ht = hookTypes[idx];
|
|
162220
|
+
return ht === "State" || ht === "Reducer" || ht === "useState" || ht === "useReducer";
|
|
162221
|
+
});
|
|
162222
|
+
if (isState) return "state";
|
|
162223
|
+
}
|
|
162224
|
+
return "hooks";
|
|
162225
|
+
}
|
|
162226
|
+
if (cd.context === true) return "context";
|
|
162227
|
+
if (cd.state === true) return "state";
|
|
162228
|
+
return "parent";
|
|
162229
|
+
}
|
|
162230
|
+
function emptyReasonHistogram() {
|
|
162231
|
+
return { parent: 0, props: 0, hooks: 0, context: 0, state: 0, force_update: 0, unknown: 0 };
|
|
162232
|
+
}
|
|
162233
|
+
function dominantReason(histogram) {
|
|
162234
|
+
let best = "unknown";
|
|
162235
|
+
let bestCount = -1;
|
|
162236
|
+
for (const [reason2, count2] of Object.entries(histogram)) {
|
|
162237
|
+
if (count2 > bestCount) {
|
|
162238
|
+
bestCount = count2;
|
|
162239
|
+
best = reason2;
|
|
162240
|
+
}
|
|
162241
|
+
}
|
|
162242
|
+
return best;
|
|
162243
|
+
}
|
|
162244
|
+
|
|
162245
|
+
// ../tool-server/src/utils/react-profiler/component-names.ts
|
|
162246
|
+
var WRAPPER_PATTERNS = [/^Forget\((.+)\)$/, /^Memo\((.+)\)$/, /^ForwardRef\((.+)\)$/];
|
|
162247
|
+
var MAX_WRAPPER_DEPTH = 4;
|
|
162248
|
+
function stripComponentWrappers(raw) {
|
|
162249
|
+
let name = raw;
|
|
162250
|
+
let hasForget = false;
|
|
162251
|
+
let hasMemo = false;
|
|
162252
|
+
let hasForwardRef = false;
|
|
162253
|
+
for (let i = 0; i < MAX_WRAPPER_DEPTH; i++) {
|
|
162254
|
+
const m = WRAPPER_PATTERNS.map((re2) => name.match(re2)).find(Boolean);
|
|
162255
|
+
if (!m) break;
|
|
162256
|
+
if (name.startsWith("Forget(")) hasForget = true;
|
|
162257
|
+
else if (name.startsWith("Memo(")) hasMemo = true;
|
|
162258
|
+
else if (name.startsWith("ForwardRef(")) hasForwardRef = true;
|
|
162259
|
+
name = m[1];
|
|
162260
|
+
}
|
|
162261
|
+
return { baseName: name, hasForget, hasMemo, hasForwardRef };
|
|
162262
|
+
}
|
|
162263
|
+
function annotateComponentName(raw) {
|
|
162264
|
+
const { baseName, hasForget, hasMemo, hasForwardRef } = stripComponentWrappers(raw);
|
|
162265
|
+
const parts2 = [];
|
|
162266
|
+
if (hasMemo) parts2.push("React.memo");
|
|
162267
|
+
if (hasForget) parts2.push("React Compiler");
|
|
162268
|
+
if (hasForwardRef) parts2.push("forwardRef");
|
|
162269
|
+
const tag3 = parts2.length > 0 ? ` [${parts2.join(" + ")}]` : "";
|
|
162270
|
+
return { displayName: baseName, tag: tag3, rawName: raw };
|
|
162271
|
+
}
|
|
162272
|
+
function resolveComponentName(query, recordedNames) {
|
|
162273
|
+
const names = [...new Set(recordedNames)];
|
|
162274
|
+
const sharingDisplayName = (raw) => {
|
|
162275
|
+
const display = annotateComponentName(raw).displayName;
|
|
162276
|
+
return names.filter((n) => n !== raw && annotateComponentName(n).displayName === display);
|
|
162277
|
+
};
|
|
162278
|
+
if (names.includes(query)) {
|
|
162279
|
+
return { kind: "exact", rawName: query, alsoMatching: sharingDisplayName(query) };
|
|
162280
|
+
}
|
|
162281
|
+
const candidates = names.filter((n) => annotateComponentName(n).displayName === query);
|
|
162282
|
+
if (candidates.length === 1) {
|
|
162283
|
+
return { kind: "display", rawName: candidates[0], query };
|
|
162284
|
+
}
|
|
162285
|
+
if (candidates.length > 1) {
|
|
162286
|
+
return { kind: "ambiguous", query, candidates };
|
|
162287
|
+
}
|
|
162288
|
+
return { kind: "missing", query, suggestions: suggestNames(query, names) };
|
|
162289
|
+
}
|
|
162290
|
+
function suggestNames(query, names, limit = 5) {
|
|
162291
|
+
const needle = query.toLowerCase();
|
|
162292
|
+
if (needle.length < 2) return [];
|
|
162293
|
+
return names.filter((n) => {
|
|
162294
|
+
const hay = `${n} ${annotateComponentName(n).displayName}`.toLowerCase();
|
|
162295
|
+
return hay.includes(needle) || needle.includes(annotateComponentName(n).displayName.toLowerCase());
|
|
162296
|
+
}).slice(0, limit);
|
|
162297
|
+
}
|
|
162298
|
+
function describeResolution(resolution) {
|
|
162299
|
+
if (resolution.kind === "display") {
|
|
162300
|
+
const { tag: tag3 } = annotateComponentName(resolution.rawName);
|
|
162301
|
+
const why = tag3 ? ` (${tag3.trim().slice(1, -1)})` : "";
|
|
162302
|
+
return `> Resolved \`${resolution.query}\` to the recorded component \`${resolution.rawName}\`${why}. Either name works here.`;
|
|
162303
|
+
}
|
|
162304
|
+
if (resolution.alsoMatching.length > 0) {
|
|
162305
|
+
const others = resolution.alsoMatching.map((n) => `\`${n}\``).join(", ");
|
|
162306
|
+
return `> Showing \`${resolution.rawName}\` only. ${others} also appear${resolution.alsoMatching.length === 1 ? "s" : ""} under this name once wrappers are stripped; they are separate fibers, so pass the exact name to target one.`;
|
|
162307
|
+
}
|
|
162308
|
+
return "";
|
|
162309
|
+
}
|
|
162310
|
+
function renderComponentNameMiss(resolution, context2 = {}) {
|
|
162311
|
+
if (resolution.kind === "ambiguous") {
|
|
162312
|
+
const list = resolution.candidates.map((c) => `- \`${c}\``).join("\n");
|
|
162313
|
+
return `_Component \`${resolution.query}\` is ambiguous: ${resolution.candidates.length} recorded components share this name once \`Memo(...)\` / \`ForwardRef(...)\` / \`Forget(...)\` wrappers are stripped. They are separate fibers and are not merged, because a combined total would not describe any real component. Re-run with one of these exact \`component_name\` values:_
|
|
162314
|
+
|
|
162315
|
+
${list}`;
|
|
162316
|
+
}
|
|
162317
|
+
const recorded = context2.fiberRenders != null && context2.commits != null ? ` The session recorded ${context2.fiberRenders} fiber renders across ${context2.commits} commits.` : "";
|
|
162318
|
+
const suggestions = resolution.suggestions.length > 0 ? `
|
|
162319
|
+
|
|
162320
|
+
Closest recorded names \u2014 pass one verbatim as \`component_name\`:
|
|
162321
|
+
` + resolution.suggestions.map((s) => `- \`${s}\``).join("\n") : "";
|
|
162322
|
+
return `_Component \`${resolution.query}\` not found in this profiling session \u2014 no exact match, and no component whose displayed name is \`${resolution.query}\` once \`Memo(...)\` / \`ForwardRef(...)\` / \`Forget(...)\` wrappers are stripped.${recorded}_${suggestions}
|
|
162323
|
+
|
|
162324
|
+
` + (context2.nextStep ?? `To list every component in a commit instead, run \`profiler-commit-query mode=by_index commit_index=<n>\`.`);
|
|
162325
|
+
}
|
|
162326
|
+
function astLookupCandidates(raw) {
|
|
162327
|
+
const keys = [raw];
|
|
162328
|
+
const { baseName } = stripComponentWrappers(raw);
|
|
162329
|
+
if (baseName !== raw) keys.push(baseName);
|
|
162330
|
+
const withoutSuffix = baseName.replace(/\(.*\)$/, "");
|
|
162331
|
+
if (withoutSuffix !== baseName && /^[A-Za-z_$][\w$]*$/.test(withoutSuffix)) {
|
|
162332
|
+
keys.push(withoutSuffix);
|
|
162333
|
+
}
|
|
162334
|
+
return keys;
|
|
162335
|
+
}
|
|
162336
|
+
|
|
162337
|
+
// ../tool-server/src/utils/react-profiler/render-summary.ts
|
|
162338
|
+
var RENDER_SUMMARY_VERSION = 1;
|
|
162339
|
+
var MIN_FREQUENT_RERENDER_COMMITS = 10;
|
|
162340
|
+
var MIN_FREQUENT_SELF_MS_PER_S = 1;
|
|
162341
|
+
var MAX_FREQUENT_ROWS = 5;
|
|
162342
|
+
var MAX_TOP_PROPS = 3;
|
|
162343
|
+
var MAX_TOP_HOOKS = 3;
|
|
162344
|
+
var PEAK_WINDOW_MS = 1e3;
|
|
162345
|
+
function round2(n) {
|
|
162346
|
+
return Math.round(n * 100) / 100;
|
|
162347
|
+
}
|
|
162348
|
+
function topKeys(freq, n) {
|
|
162349
|
+
return [...freq.entries()].sort((a, b) => b[1] - a[1]).slice(0, n).map(([k]) => k);
|
|
162350
|
+
}
|
|
162351
|
+
function validDuration(ms) {
|
|
162352
|
+
return Number.isFinite(ms) && ms > 0 ? ms : 0;
|
|
162353
|
+
}
|
|
162354
|
+
function commitRenderMs(commit) {
|
|
162355
|
+
return Math.max(validDuration(commit.durationMs), validDuration(commit.selfMs ?? 0));
|
|
162356
|
+
}
|
|
162357
|
+
function peakWindowMs(commitTimings) {
|
|
162358
|
+
const sorted = commitTimings.filter((c) => Number.isFinite(c.timestamp)).sort((a, b) => a.timestamp - b.timestamp);
|
|
162359
|
+
let peak = 0;
|
|
162360
|
+
let inWindow = 0;
|
|
162361
|
+
let first = 0;
|
|
162362
|
+
for (const commit of sorted) {
|
|
162363
|
+
inWindow += commitRenderMs(commit);
|
|
162364
|
+
while (sorted[first].timestamp <= commit.timestamp - PEAK_WINDOW_MS) {
|
|
162365
|
+
inWindow -= commitRenderMs(sorted[first]);
|
|
162366
|
+
first++;
|
|
162367
|
+
}
|
|
162368
|
+
if (inWindow > peak) peak = inWindow;
|
|
162369
|
+
}
|
|
162370
|
+
return peak;
|
|
162371
|
+
}
|
|
162372
|
+
function summarizeRenders(commits, commitTimings, recordingMs) {
|
|
162373
|
+
const byName = /* @__PURE__ */ new Map();
|
|
162374
|
+
let fiberRenders = 0;
|
|
162375
|
+
let rerenders = 0;
|
|
162376
|
+
let mounts = 0;
|
|
162377
|
+
let untrackedRenders = 0;
|
|
162378
|
+
for (const c of commits) {
|
|
162379
|
+
if (!c.didRender) continue;
|
|
162380
|
+
fiberRenders++;
|
|
162381
|
+
let acc = byName.get(c.componentName);
|
|
162382
|
+
if (!acc) {
|
|
162383
|
+
acc = {
|
|
162384
|
+
rerenders: 0,
|
|
162385
|
+
rerenderSelfMs: 0,
|
|
162386
|
+
maxRerenderSelfMs: 0,
|
|
162387
|
+
untrackedRenders: 0,
|
|
162388
|
+
mounts: 0,
|
|
162389
|
+
mountSelfMs: 0,
|
|
162390
|
+
lastRerenderCommit: -1,
|
|
162391
|
+
rerenderCommits: 0,
|
|
162392
|
+
reasons: emptyReasonHistogram(),
|
|
162393
|
+
props: /* @__PURE__ */ new Map(),
|
|
162394
|
+
hooks: /* @__PURE__ */ new Map()
|
|
162395
|
+
};
|
|
162396
|
+
byName.set(c.componentName, acc);
|
|
162397
|
+
}
|
|
162398
|
+
const cd = c.changeDescription;
|
|
162399
|
+
if (cd === null) {
|
|
162400
|
+
untrackedRenders++;
|
|
162401
|
+
acc.untrackedRenders++;
|
|
162402
|
+
continue;
|
|
162403
|
+
}
|
|
162404
|
+
if (cd.isFirstMount === true) {
|
|
162405
|
+
mounts++;
|
|
162406
|
+
acc.mounts++;
|
|
162407
|
+
acc.mountSelfMs += c.selfDuration;
|
|
162408
|
+
continue;
|
|
162409
|
+
}
|
|
162410
|
+
rerenders++;
|
|
162411
|
+
acc.rerenders++;
|
|
162412
|
+
acc.rerenderSelfMs += c.selfDuration;
|
|
162413
|
+
if (c.selfDuration > acc.maxRerenderSelfMs) acc.maxRerenderSelfMs = c.selfDuration;
|
|
162414
|
+
if (c.commitIndex !== acc.lastRerenderCommit) {
|
|
162415
|
+
acc.rerenderCommits++;
|
|
162416
|
+
acc.lastRerenderCommit = c.commitIndex;
|
|
162417
|
+
}
|
|
162418
|
+
acc.reasons[deriveReason(cd, c.hookTypes ?? null)]++;
|
|
162419
|
+
for (const p of cd.props ?? []) acc.props.set(p, (acc.props.get(p) ?? 0) + 1);
|
|
162420
|
+
if (cd.hooks && c.hookTypes) {
|
|
162421
|
+
for (const idx of cd.hooks) {
|
|
162422
|
+
const hook = c.hookTypes[idx] ?? `hook[${idx}]`;
|
|
162423
|
+
acc.hooks.set(hook, (acc.hooks.get(hook) ?? 0) + 1);
|
|
162424
|
+
}
|
|
162425
|
+
}
|
|
162426
|
+
}
|
|
162427
|
+
const components = [];
|
|
162428
|
+
for (const [name, acc] of byName) {
|
|
162429
|
+
const reason2 = acc.rerenders > 0 ? dominantReason(acc.reasons) : null;
|
|
162430
|
+
const row = {
|
|
162431
|
+
name,
|
|
162432
|
+
rerenders: acc.rerenders,
|
|
162433
|
+
untrackedRenders: acc.untrackedRenders,
|
|
162434
|
+
rerenderCommits: acc.rerenderCommits,
|
|
162435
|
+
rerenderSelfMs: round2(acc.rerenderSelfMs),
|
|
162436
|
+
maxRerenderSelfMs: round2(acc.maxRerenderSelfMs),
|
|
162437
|
+
mounts: acc.mounts,
|
|
162438
|
+
mountSelfMs: round2(acc.mountSelfMs),
|
|
162439
|
+
reason: reason2
|
|
162440
|
+
};
|
|
162441
|
+
const topProps = topKeys(acc.props, MAX_TOP_PROPS);
|
|
162442
|
+
if (topProps.length > 0) row.topProps = topProps;
|
|
162443
|
+
const topHooks = topKeys(acc.hooks, MAX_TOP_HOOKS);
|
|
162444
|
+
if (topHooks.length > 0) row.topHooks = topHooks;
|
|
162445
|
+
components.push(row);
|
|
162446
|
+
}
|
|
162447
|
+
components.sort(
|
|
162448
|
+
(a, b) => b.rerenderSelfMs - a.rerenderSelfMs || b.rerenders - a.rerenders || b.mountSelfMs - a.mountSelfMs || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
|
|
162449
|
+
);
|
|
162450
|
+
let totalRenderMs = 0;
|
|
162451
|
+
let maxCommitMs = 0;
|
|
162452
|
+
for (const commit of commitTimings) {
|
|
162453
|
+
totalRenderMs += commitRenderMs(commit);
|
|
162454
|
+
const ms = validDuration(commit.durationMs);
|
|
162455
|
+
if (ms > maxCommitMs) maxCommitMs = ms;
|
|
162456
|
+
}
|
|
162457
|
+
return {
|
|
162458
|
+
version: RENDER_SUMMARY_VERSION,
|
|
162459
|
+
recordingMs: round2(recordingMs),
|
|
162460
|
+
totalCommits: commitTimings.length,
|
|
162461
|
+
totalRenderMs: round2(totalRenderMs),
|
|
162462
|
+
peakSecondRenderMs: round2(peakWindowMs(commitTimings)),
|
|
162463
|
+
// Rounded down: 15.996 ms did not reach the 16 ms floor.
|
|
162464
|
+
maxCommitMs: Math.floor(maxCommitMs * 100) / 100,
|
|
162465
|
+
fiberRenders,
|
|
162466
|
+
rerenders,
|
|
162467
|
+
mounts,
|
|
162468
|
+
untrackedRenders,
|
|
162469
|
+
components
|
|
162470
|
+
};
|
|
162471
|
+
}
|
|
162472
|
+
function isFiniteNumber(v) {
|
|
162473
|
+
return typeof v === "number" && Number.isFinite(v);
|
|
162474
|
+
}
|
|
162475
|
+
function parseRenderSummary(raw) {
|
|
162476
|
+
if (!raw || typeof raw !== "object") return null;
|
|
162477
|
+
const s = raw;
|
|
162478
|
+
if (s.version !== RENDER_SUMMARY_VERSION) return null;
|
|
162479
|
+
for (const key2 of [
|
|
162480
|
+
"recordingMs",
|
|
162481
|
+
"totalCommits",
|
|
162482
|
+
"totalRenderMs",
|
|
162483
|
+
"peakSecondRenderMs",
|
|
162484
|
+
"maxCommitMs",
|
|
162485
|
+
"fiberRenders",
|
|
162486
|
+
"rerenders",
|
|
162487
|
+
"mounts",
|
|
162488
|
+
"untrackedRenders"
|
|
162489
|
+
]) {
|
|
162490
|
+
if (!isFiniteNumber(s[key2])) return null;
|
|
162491
|
+
}
|
|
162492
|
+
if (!Array.isArray(s.components)) return null;
|
|
162493
|
+
for (const c of s.components) {
|
|
162494
|
+
if (!c || typeof c !== "object") return null;
|
|
162495
|
+
const row = c;
|
|
162496
|
+
if (typeof row.name !== "string") return null;
|
|
162497
|
+
for (const key2 of [
|
|
162498
|
+
"rerenders",
|
|
162499
|
+
"untrackedRenders",
|
|
162500
|
+
"rerenderCommits",
|
|
162501
|
+
"rerenderSelfMs",
|
|
162502
|
+
"maxRerenderSelfMs",
|
|
162503
|
+
"mounts",
|
|
162504
|
+
"mountSelfMs"
|
|
162505
|
+
]) {
|
|
162506
|
+
if (!isFiniteNumber(row[key2])) return null;
|
|
162507
|
+
}
|
|
162508
|
+
if (row.reason !== null && typeof row.reason !== "string") return null;
|
|
162509
|
+
for (const key2 of ["topProps", "topHooks"]) {
|
|
162510
|
+
if (row[key2] !== void 0 && !Array.isArray(row[key2])) return null;
|
|
162511
|
+
}
|
|
162512
|
+
}
|
|
162513
|
+
return raw;
|
|
162514
|
+
}
|
|
162515
|
+
function renderTimeShare(summary) {
|
|
162516
|
+
return summary.recordingMs > 0 ? summary.totalRenderMs / summary.recordingMs : 0;
|
|
162517
|
+
}
|
|
162518
|
+
function peakRenderShare(summary) {
|
|
162519
|
+
const windowMs = Math.min(PEAK_WINDOW_MS, summary.recordingMs);
|
|
162520
|
+
return windowMs > 0 ? Math.min(summary.peakSecondRenderMs / windowMs, 1) : 0;
|
|
162521
|
+
}
|
|
162522
|
+
var SLOW_COMMIT_MS = 16;
|
|
162523
|
+
function hasUnnamedSlowCommit(summary) {
|
|
162524
|
+
return summary.maxCommitMs >= SLOW_COMMIT_MS;
|
|
162525
|
+
}
|
|
162526
|
+
function formatShare(share) {
|
|
162527
|
+
const pct = share * 100;
|
|
162528
|
+
if (pct <= 0) return "0%";
|
|
162529
|
+
const rounded = Math.round(pct * 10) / 10;
|
|
162530
|
+
if (rounded >= 10) return `${Math.round(pct)}%`;
|
|
162531
|
+
if (rounded < 0.1) return "<0.1%";
|
|
162532
|
+
return `${rounded.toFixed(1)}%`;
|
|
162533
|
+
}
|
|
162534
|
+
function formatPeakCommit(ms) {
|
|
162535
|
+
return `${(Math.floor(ms * 10) / 10).toFixed(1)}ms`;
|
|
162536
|
+
}
|
|
162537
|
+
function formatMs(ms) {
|
|
162538
|
+
return ms >= 10 ? `${Math.round(ms).toLocaleString("en-US")} ms` : `${ms.toFixed(1)} ms`;
|
|
162539
|
+
}
|
|
162540
|
+
function formatCount(n) {
|
|
162541
|
+
return n.toLocaleString("en-US");
|
|
162542
|
+
}
|
|
162543
|
+
function formatRenderTime(summary) {
|
|
162544
|
+
const commits = summary.totalCommits === 1 ? "commit" : "commits";
|
|
162545
|
+
const peak = summary.totalCommits > 0 ? `, peak ${formatShare(peakRenderShare(summary))} in 1 s` : "";
|
|
162546
|
+
return `${formatMs(summary.totalRenderMs)} of ${(summary.recordingMs / 1e3).toFixed(1)} s (${formatShare(renderTimeShare(summary))})${peak}, ${formatCount(summary.totalCommits)} ${commits}`;
|
|
162547
|
+
}
|
|
162548
|
+
function renderSummaryNameMiss(resolution, summary) {
|
|
162549
|
+
return renderComponentNameMiss(resolution, {
|
|
162550
|
+
fiberRenders: summary.fiberRenders,
|
|
162551
|
+
commits: summary.totalCommits,
|
|
162552
|
+
nextStep: "Run `profiler-commit-query` mode=`render_counts` without `component_name` to list every component."
|
|
162553
|
+
});
|
|
162554
|
+
}
|
|
162555
|
+
function allRenderCount(row) {
|
|
162556
|
+
return row.rerenders + row.mounts + row.untrackedRenders;
|
|
162557
|
+
}
|
|
162558
|
+
function renderNameOutsideStoredCommits(query, summary, nextStep = "") {
|
|
162559
|
+
const resolution = resolveComponentName(
|
|
162560
|
+
query,
|
|
162561
|
+
summary.components.map((c) => c.name)
|
|
162562
|
+
);
|
|
162563
|
+
if (resolution.kind !== "exact" && resolution.kind !== "display") {
|
|
162564
|
+
return renderSummaryNameMiss(resolution, summary);
|
|
162565
|
+
}
|
|
162566
|
+
const row = summary.components.find((c) => c.name === resolution.rawName);
|
|
162567
|
+
const renders = allRenderCount(row);
|
|
162568
|
+
return `_\`${row.name}\` rendered ${formatCount(renders)} ${renders === 1 ? "time" : "times"} in this session, but never in a stored commit: only commits of 16ms or more and their neighbours are stored._
|
|
162569
|
+
|
|
162570
|
+
Run \`profiler-commit-query\` mode=\`render_counts\` component_name=\`${row.name}\` for its counts over all commits.${nextStep}`;
|
|
162571
|
+
}
|
|
162572
|
+
function describeStoredResolution(resolution, summary) {
|
|
162573
|
+
const separate = resolution.kind === "display" ? summary?.components.find(
|
|
162574
|
+
(c) => c.name !== resolution.rawName && annotateComponentName(c.name).displayName === resolution.query
|
|
162575
|
+
) : void 0;
|
|
162576
|
+
if (resolution.kind !== "display" || !separate) return describeResolution(resolution);
|
|
162577
|
+
const renders = allRenderCount(separate);
|
|
162578
|
+
return `> Showing \`${resolution.rawName}\`, the only stored component named \`${resolution.query}\`. A separate \`${separate.name}\` rendered ${formatCount(renders)} ${renders === 1 ? "time" : "times"} outside the stored commits. Run \`profiler-commit-query\` mode=\`render_counts\` component_name=\`${separate.name}\` for its counts.`;
|
|
162579
|
+
}
|
|
162580
|
+
function storedOnlyNote(name, storedRenders, summary, renderCounts = "mode=`render_counts`") {
|
|
162581
|
+
const row = summary?.components.find((c) => c.name === name);
|
|
162582
|
+
if (!summary || !row) return "";
|
|
162583
|
+
const allRenders = allRenderCount(row);
|
|
162584
|
+
if (allRenders <= storedRenders) return "";
|
|
162585
|
+
return ` (stored commits only; ${formatCount(allRenders)} renders over all ${formatCount(summary.totalCommits)} commits, see ${renderCounts})`;
|
|
162586
|
+
}
|
|
162587
|
+
function formatRenderSummaryReason(c) {
|
|
162588
|
+
switch (c.reason) {
|
|
162589
|
+
case null:
|
|
162590
|
+
return c.mounts > 0 ? "mount only" : "no change data";
|
|
162591
|
+
case "props":
|
|
162592
|
+
return c.topProps && c.topProps.length > 0 ? `props: ${c.topProps.join(", ")}` : "props";
|
|
162593
|
+
case "hooks":
|
|
162594
|
+
case "state":
|
|
162595
|
+
return c.topHooks && c.topHooks.length > 0 ? `${c.reason}: ${c.topHooks.join(", ")}` : c.reason;
|
|
162596
|
+
case "context":
|
|
162597
|
+
return "context changed";
|
|
162598
|
+
case "parent":
|
|
162599
|
+
return "parent re-render";
|
|
162600
|
+
case "force_update":
|
|
162601
|
+
return "forceUpdate()";
|
|
162602
|
+
default:
|
|
162603
|
+
return c.reason;
|
|
162604
|
+
}
|
|
162605
|
+
}
|
|
162606
|
+
function frequentCandidates(summary) {
|
|
162607
|
+
const seconds = Math.max(summary.recordingMs / 1e3, 1e-3);
|
|
162608
|
+
const candidates = [];
|
|
162609
|
+
for (const component of summary.components) {
|
|
162610
|
+
if (component.rerenderCommits < MIN_FREQUENT_RERENDER_COMMITS) continue;
|
|
162611
|
+
const selfMsPerSecond = component.rerenderSelfMs / seconds;
|
|
162612
|
+
if (selfMsPerSecond < MIN_FREQUENT_SELF_MS_PER_S) continue;
|
|
162613
|
+
candidates.push({ component, perSecond: component.rerenders / seconds, selfMsPerSecond });
|
|
162614
|
+
}
|
|
162615
|
+
return candidates;
|
|
162616
|
+
}
|
|
162617
|
+
function selectFrequentRerenders(summary, classify, limit = MAX_FREQUENT_ROWS) {
|
|
162618
|
+
const rows = [];
|
|
162619
|
+
for (const candidate of frequentCandidates(summary)) {
|
|
162620
|
+
const origin = classify(candidate.component.name);
|
|
162621
|
+
if (origin.origin !== "library") rows.push({ ...candidate, origin });
|
|
162622
|
+
}
|
|
162623
|
+
rows.sort((a, b) => b.selfMsPerSecond - a.selfMsPerSecond);
|
|
162624
|
+
return rows.slice(0, limit);
|
|
162625
|
+
}
|
|
162626
|
+
function selectFrequentOutsideSource(summary, classify) {
|
|
162627
|
+
return frequentCandidates(summary).map((candidate) => candidate.component.name).filter((name) => classify(name).notInSource);
|
|
162628
|
+
}
|
|
162629
|
+
|
|
162008
162630
|
// ../tool-server/src/tools/profiler/react/react-profiler-stop.ts
|
|
162009
162631
|
function normalizeChangeDescription(raw) {
|
|
162010
162632
|
if (!raw || typeof raw !== "object") return null;
|
|
@@ -162020,6 +162642,7 @@ function normalizeChangeDescription(raw) {
|
|
|
162020
162642
|
function flattenProfilingData(merged, displayNameById, fiberMeta) {
|
|
162021
162643
|
const commits = [];
|
|
162022
162644
|
const unattributedByCommit = [];
|
|
162645
|
+
const commitTimings = [];
|
|
162023
162646
|
let flatCommitIndex = 0;
|
|
162024
162647
|
for (const root of merged.dataForRoots) {
|
|
162025
162648
|
for (const c of root.commitData) {
|
|
@@ -162038,7 +162661,9 @@ function flattenProfilingData(merged, displayNameById, fiberMeta) {
|
|
|
162038
162661
|
const commitDuration = typeof c.duration === "number" ? c.duration : 0;
|
|
162039
162662
|
let droppedCount = 0;
|
|
162040
162663
|
let droppedMs = 0;
|
|
162664
|
+
let selfMs = 0;
|
|
162041
162665
|
for (const [fiberID, actualDuration] of actualMap) {
|
|
162666
|
+
if (actualDuration > 0) selfMs += selfMap.get(fiberID) ?? 0;
|
|
162042
162667
|
const componentName = displayNameById[String(fiberID)] ?? null;
|
|
162043
162668
|
if (!componentName) {
|
|
162044
162669
|
droppedCount++;
|
|
@@ -162062,6 +162687,7 @@ function flattenProfilingData(merged, displayNameById, fiberMeta) {
|
|
|
162062
162687
|
isCompilerOptimized: meta3?.isCompilerOptimized === true
|
|
162063
162688
|
});
|
|
162064
162689
|
}
|
|
162690
|
+
commitTimings.push({ timestamp: c.timestamp, durationMs: commitDuration, selfMs });
|
|
162065
162691
|
if (droppedCount > 0) {
|
|
162066
162692
|
unattributedByCommit.push([
|
|
162067
162693
|
flatCommitIndex,
|
|
@@ -162072,7 +162698,7 @@ function flattenProfilingData(merged, displayNameById, fiberMeta) {
|
|
|
162072
162698
|
flatCommitIndex++;
|
|
162073
162699
|
}
|
|
162074
162700
|
}
|
|
162075
|
-
return { commits, totalCommits: flatCommitIndex, unattributedByCommit };
|
|
162701
|
+
return { commits, totalCommits: flatCommitIndex, unattributedByCommit, commitTimings };
|
|
162076
162702
|
}
|
|
162077
162703
|
var COLLECT_TIMEOUT_MS = 6e4;
|
|
162078
162704
|
function stopInProgressError() {
|
|
@@ -162093,9 +162719,9 @@ function createReactProfilerStopTool(registry2) {
|
|
|
162093
162719
|
return {
|
|
162094
162720
|
id: "react-profiler-stop",
|
|
162095
162721
|
description: `Stop CPU profiling and collect the cpuProfile + React commit tree.
|
|
162096
|
-
Stores the results for react-profiler-analyze
|
|
162722
|
+
Stores the results for react-profiler-analyze, profiler-commit-query and profiler-cpu-query.
|
|
162097
162723
|
Call react-profiler-start first, then exercise the app, then call this.
|
|
162098
|
-
Returns { duration_ms, sample_count, fiber_renders_captured, total_react_commits, hot_commit_indices }.
|
|
162724
|
+
Returns { duration_ms, sample_count, fiber_renders_captured, total_react_commits, hot_commit_indices, react_render_ms, react_render_share_pct, react_render_peak_1s_pct }.
|
|
162099
162725
|
If some fibers' display names could not be resolved (typically modals, tooltips or animations that unmounted before stop), it also returns { unattributed_ms, unattributed_fiber_count, unattributed_commit_count }: the work missing from the per-component breakdown. Per-commit durations stay correct.
|
|
162100
162726
|
Fails if no active profiling session exists, another stop is running, the CDP connection was lost during recording, or another session took the run over.`,
|
|
162101
162727
|
zodSchema: zodSchema46,
|
|
@@ -162217,6 +162843,7 @@ Fails if no active profiling session exists, another stop is running, the CDP co
|
|
|
162217
162843
|
}
|
|
162218
162844
|
);
|
|
162219
162845
|
}
|
|
162846
|
+
dropStaleLeadingGap(profile);
|
|
162220
162847
|
const stopReadStr = await cdp.send(
|
|
162221
162848
|
"Runtime.evaluate",
|
|
162222
162849
|
{ expression: STOP_AND_READ_SCRIPT, returnByValue: true },
|
|
@@ -162265,18 +162892,24 @@ Fails if no active profiling session exists, another stop is running, the CDP co
|
|
|
162265
162892
|
const {
|
|
162266
162893
|
commits: allCommits,
|
|
162267
162894
|
totalCommits,
|
|
162268
|
-
unattributedByCommit
|
|
162895
|
+
unattributedByCommit,
|
|
162896
|
+
commitTimings
|
|
162269
162897
|
} = flattenProfilingData(merged, stopRead.displayNameById, fiberMeta);
|
|
162898
|
+
const renderSummary = summarizeRenders(
|
|
162899
|
+
allCommits,
|
|
162900
|
+
commitTimings,
|
|
162901
|
+
(profile.endTime - profile.startTime) / 1e3
|
|
162902
|
+
);
|
|
162270
162903
|
const commitHeat = /* @__PURE__ */ new Map();
|
|
162271
162904
|
let anyCompilerOptimized = false;
|
|
162272
162905
|
for (const c of allCommits) {
|
|
162906
|
+
if (c.isCompilerOptimized) anyCompilerOptimized = true;
|
|
162907
|
+
if (!c.didRender) continue;
|
|
162273
162908
|
const prev = commitHeat.get(c.commitIndex) ?? 0;
|
|
162274
162909
|
if (c.commitDuration > prev) commitHeat.set(c.commitIndex, c.commitDuration);
|
|
162275
|
-
if (c.isCompilerOptimized) anyCompilerOptimized = true;
|
|
162276
162910
|
}
|
|
162277
|
-
const ABSOLUTE_FLOOR_MS = 16;
|
|
162278
162911
|
const interestingKeys = [...commitHeat.keys()].filter(
|
|
162279
|
-
(k) => (commitHeat.get(k) ?? 0) >=
|
|
162912
|
+
(k) => (commitHeat.get(k) ?? 0) >= SLOW_COMMIT_MS
|
|
162280
162913
|
);
|
|
162281
162914
|
const hotSet = new Set(interestingKeys);
|
|
162282
162915
|
const marginSet = /* @__PURE__ */ new Set();
|
|
@@ -162313,7 +162946,8 @@ Fails if no active profiling session exists, another stop is running, the CDP co
|
|
|
162313
162946
|
port: api.port,
|
|
162314
162947
|
appName: api.appName,
|
|
162315
162948
|
deviceName: api.deviceName,
|
|
162316
|
-
unattributedByCommit: unattributedByCommit.length > 0 ? unattributedByCommit : null
|
|
162949
|
+
unattributedByCommit: unattributedByCommit.length > 0 ? unattributedByCommit : null,
|
|
162950
|
+
renderSummary
|
|
162317
162951
|
}
|
|
162318
162952
|
}
|
|
162319
162953
|
);
|
|
@@ -162345,9 +162979,15 @@ Fails if no active profiling session exists, another stop is running, the CDP co
|
|
|
162345
162979
|
response["hot_commit_indices"] = api.hotCommitIndices ?? [];
|
|
162346
162980
|
response["any_compiler_optimized"] = api.anyCompilerOptimized ?? false;
|
|
162347
162981
|
response["fiber_renders_analyzed"] = filteredCommits.length;
|
|
162982
|
+
response["react_render_ms"] = renderSummary.totalRenderMs;
|
|
162983
|
+
response["react_render_share_pct"] = Math.round(renderTimeShare(renderSummary) * 1e3) / 10;
|
|
162984
|
+
response["react_render_peak_1s_pct"] = Math.round(peakRenderShare(renderSummary) * 1e3) / 10;
|
|
162348
162985
|
const hotCount = api.hotCommitIndices?.length ?? 0;
|
|
162349
|
-
|
|
162350
|
-
|
|
162986
|
+
const share = formatShare(renderTimeShare(renderSummary));
|
|
162987
|
+
if (hotCount === 0 && hasUnnamedSlowCommit(renderSummary)) {
|
|
162988
|
+
response["selection_note"] = `The slowest commit took ${formatPeakCommit(renderSummary.maxCommitMs)}, but none of its components could be named, so no commit was kept. React rendered for ${share} of the session`;
|
|
162989
|
+
} else if (hotCount === 0) {
|
|
162990
|
+
response["selection_note"] = `No commit reached 16ms. React rendered for ${share} of the session, peak ${formatShare(peakRenderShare(renderSummary))} in 1 s`;
|
|
162351
162991
|
} else if (hotCount < totalCommits) {
|
|
162352
162992
|
response["selection_note"] = `${hotCount} of ${totalCommits} commits at \u226516ms absolute floor`;
|
|
162353
162993
|
}
|
|
@@ -162586,6 +163226,7 @@ function createReactProfilerStatusTool(registry2) {
|
|
|
162586
163226
|
// ../tool-server/src/tools/profiler/react/react-profiler-analyze.ts
|
|
162587
163227
|
init_zod();
|
|
162588
163228
|
var import_fs5 = require("fs");
|
|
163229
|
+
var import_path6 = require("path");
|
|
162589
163230
|
init_src2();
|
|
162590
163231
|
|
|
162591
163232
|
// ../tool-server/src/utils/react-profiler/pipeline/session-context.ts
|
|
@@ -162670,25 +163311,6 @@ async function detectSessionContext(input2) {
|
|
|
162670
163311
|
};
|
|
162671
163312
|
}
|
|
162672
163313
|
|
|
162673
|
-
// ../tool-server/src/utils/react-profiler/pipeline/utils.ts
|
|
162674
|
-
function deriveReason(cd, hookTypes) {
|
|
162675
|
-
if (cd === null) return "unknown";
|
|
162676
|
-
if (cd.props !== null && cd.props.length > 0) return "props";
|
|
162677
|
-
if (cd.didHooksChange || cd.hooks !== null && cd.hooks.length > 0) {
|
|
162678
|
-
if (hookTypes && cd.hooks) {
|
|
162679
|
-
const isState = cd.hooks.some((idx) => {
|
|
162680
|
-
const ht = hookTypes[idx];
|
|
162681
|
-
return ht === "State" || ht === "Reducer" || ht === "useState" || ht === "useReducer";
|
|
162682
|
-
});
|
|
162683
|
-
if (isState) return "state";
|
|
162684
|
-
}
|
|
162685
|
-
return "hooks";
|
|
162686
|
-
}
|
|
162687
|
-
if (cd.context === true) return "context";
|
|
162688
|
-
if (cd.state === true) return "state";
|
|
162689
|
-
return "parent";
|
|
162690
|
-
}
|
|
162691
|
-
|
|
162692
163314
|
// ../tool-server/src/utils/react-profiler/pipeline/00-preprocess.ts
|
|
162693
163315
|
function preprocess2(commits) {
|
|
162694
163316
|
const commitMap = /* @__PURE__ */ new Map();
|
|
@@ -162768,10 +163390,10 @@ function buildHotCommitSummaries(commits, hotCommitIndices, unattributedByCommit
|
|
|
162768
163390
|
const cd = e.changeDescription;
|
|
162769
163391
|
return !(cd === null || cd.isFirstMount === true);
|
|
162770
163392
|
});
|
|
163393
|
+
const rerenderNames = new Set(rerenderEntries.map((e) => e.componentName));
|
|
162771
163394
|
const componentMap = /* @__PURE__ */ new Map();
|
|
162772
163395
|
for (const e of entries) {
|
|
162773
|
-
const
|
|
162774
|
-
const isFirstMount = cd === null || cd.isFirstMount === true;
|
|
163396
|
+
const isFirstMount = e.changeDescription?.isFirstMount === true;
|
|
162775
163397
|
const existing = componentMap.get(e.componentName);
|
|
162776
163398
|
if (existing) {
|
|
162777
163399
|
existing.totalSelf += e.selfDuration ?? 0;
|
|
@@ -162791,9 +163413,10 @@ function buildHotCommitSummaries(commits, hotCommitIndices, unattributedByCommit
|
|
|
162791
163413
|
const totalComponentCount = componentMap.size;
|
|
162792
163414
|
const componentEntries = Array.from(componentMap.entries()).sort((a, b) => b[1].totalSelf - a[1].totalSelf).slice(0, MAX_COMPONENT_ENTRIES).map(([name, { totalSelf, totalActual, count: count2, firstEntry, isFirstMount }]) => {
|
|
162793
163415
|
const cd = firstEntry.changeDescription;
|
|
162794
|
-
const
|
|
163416
|
+
const rerendered = rerenderNames.has(name);
|
|
163417
|
+
const reason2 = rerendered && cd ? deriveReason(cd, firstEntry.hookTypes) : void 0;
|
|
162795
163418
|
let topChangedHookNames;
|
|
162796
|
-
if (
|
|
163419
|
+
if (rerendered && cd?.hooks && cd.hooks.length > 0 && firstEntry.hookTypes) {
|
|
162797
163420
|
const seen = /* @__PURE__ */ new Set();
|
|
162798
163421
|
topChangedHookNames = [];
|
|
162799
163422
|
for (const idx of cd.hooks.slice(0, 3)) {
|
|
@@ -162812,7 +163435,7 @@ function buildHotCommitSummaries(commits, hotCommitIndices, unattributedByCommit
|
|
|
162812
163435
|
count: count2,
|
|
162813
163436
|
...isFirstMount && { isFirstMount: true },
|
|
162814
163437
|
...reason2 !== void 0 && { reason: reason2 },
|
|
162815
|
-
|
|
163438
|
+
...rerendered && cd?.props && cd.props.length > 0 && { topChangedProps: cd.props.slice(0, 3) },
|
|
162816
163439
|
...topChangedHookNames && { topChangedHookNames },
|
|
162817
163440
|
...firstEntry.isCompilerOptimized && { isCompilerOptimized: true }
|
|
162818
163441
|
};
|
|
@@ -162881,185 +163504,7 @@ function buildHotCommitSummaries(commits, hotCommitIndices, unattributedByCommit
|
|
|
162881
163504
|
return summaries.sort((a, b) => a.commitIndex - b.commitIndex);
|
|
162882
163505
|
}
|
|
162883
163506
|
|
|
162884
|
-
// ../tool-server/src/utils/react-profiler/pipeline/00-cpu-correlate.ts
|
|
162885
|
-
var ARGENT_PROFILER_PREFIX = "__argent_";
|
|
162886
|
-
function isArgentProfilerFunction(name) {
|
|
162887
|
-
return name.startsWith(ARGENT_PROFILER_PREFIX);
|
|
162888
|
-
}
|
|
162889
|
-
function buildCpuSampleIndex(cpuProfile) {
|
|
162890
|
-
const { nodes, samples, timeDeltas, startTime, endTime } = cpuProfile;
|
|
162891
|
-
const nodeMap = /* @__PURE__ */ new Map();
|
|
162892
|
-
for (const node2 of nodes) {
|
|
162893
|
-
nodeMap.set(node2.id, node2);
|
|
162894
|
-
}
|
|
162895
|
-
const timestampsMs = new Float64Array(samples.length);
|
|
162896
|
-
const intervalStartsMs = new Float64Array(samples.length);
|
|
162897
|
-
let accumulatedUs = 0;
|
|
162898
|
-
for (let i = 0; i < samples.length; i++) {
|
|
162899
|
-
const raw = timeDeltas[i];
|
|
162900
|
-
const delta = Number.isFinite(raw) && (raw ?? 0) >= 0 ? raw : 0;
|
|
162901
|
-
intervalStartsMs[i] = accumulatedUs / 1e3;
|
|
162902
|
-
accumulatedUs += delta;
|
|
162903
|
-
timestampsMs[i] = accumulatedUs / 1e3;
|
|
162904
|
-
}
|
|
162905
|
-
return {
|
|
162906
|
-
childToParent: buildChildToParent(nodeMap),
|
|
162907
|
-
timestampsMs,
|
|
162908
|
-
intervalStartsMs,
|
|
162909
|
-
sampleNodeIds: samples,
|
|
162910
|
-
nodeMap,
|
|
162911
|
-
durationMs: (endTime - startTime) / 1e3
|
|
162912
|
-
};
|
|
162913
|
-
}
|
|
162914
|
-
var IDLE_FRAME_NAMES = /* @__PURE__ */ new Set(["(idle)", "(program)", "(root)", "[idle]", "[root]"]);
|
|
162915
|
-
function isIdleFrame(name) {
|
|
162916
|
-
return !name || IDLE_FRAME_NAMES.has(name);
|
|
162917
|
-
}
|
|
162918
|
-
function queryCpuWindow(index, startMs, endMs, topN2 = 5) {
|
|
162919
|
-
const { timestampsMs, intervalStartsMs, sampleNodeIds, nodeMap } = index;
|
|
162920
|
-
const n = timestampsMs.length;
|
|
162921
|
-
const sampleRangeMs = {
|
|
162922
|
-
start: n > 0 ? intervalStartsMs[0] : 0,
|
|
162923
|
-
end: n > 0 ? timestampsMs[n - 1] : 0
|
|
162924
|
-
};
|
|
162925
|
-
const empty2 = {
|
|
162926
|
-
hotspots: [],
|
|
162927
|
-
samplesInWindow: 0,
|
|
162928
|
-
coveredMs: 0,
|
|
162929
|
-
idleMs: 0,
|
|
162930
|
-
sampleRangeMs,
|
|
162931
|
-
medianIntervalMs: 0,
|
|
162932
|
-
maxIntervalMs: 0
|
|
162933
|
-
};
|
|
162934
|
-
if (n === 0) return empty2;
|
|
162935
|
-
let lo = 0;
|
|
162936
|
-
let hi = n;
|
|
162937
|
-
while (lo < hi) {
|
|
162938
|
-
const mid = lo + hi >>> 1;
|
|
162939
|
-
if (timestampsMs[mid] < startMs) lo = mid + 1;
|
|
162940
|
-
else hi = mid;
|
|
162941
|
-
}
|
|
162942
|
-
const selfMsByNode = /* @__PURE__ */ new Map();
|
|
162943
|
-
const intervals = [];
|
|
162944
|
-
let samplesInWindow = 0;
|
|
162945
|
-
let coveredMs = 0;
|
|
162946
|
-
let idleMs = 0;
|
|
162947
|
-
let maxIntervalMs = 0;
|
|
162948
|
-
for (let i = lo; i < n; i++) {
|
|
162949
|
-
const from2 = intervalStartsMs[i];
|
|
162950
|
-
if (from2 > endMs) break;
|
|
162951
|
-
const overlap = Math.min(endMs, timestampsMs[i]) - Math.max(startMs, from2);
|
|
162952
|
-
if (overlap <= 0) continue;
|
|
162953
|
-
samplesInWindow++;
|
|
162954
|
-
coveredMs += overlap;
|
|
162955
|
-
intervals.push(timestampsMs[i] - from2);
|
|
162956
|
-
if (timestampsMs[i] - from2 > maxIntervalMs) maxIntervalMs = timestampsMs[i] - from2;
|
|
162957
|
-
const nodeId = sampleNodeIds[i];
|
|
162958
|
-
const node2 = nodeMap.get(nodeId);
|
|
162959
|
-
if (isIdleFrame(node2?.callFrame.functionName)) {
|
|
162960
|
-
idleMs += overlap;
|
|
162961
|
-
continue;
|
|
162962
|
-
}
|
|
162963
|
-
selfMsByNode.set(nodeId, (selfMsByNode.get(nodeId) ?? 0) + overlap);
|
|
162964
|
-
}
|
|
162965
|
-
if (samplesInWindow === 0) return { ...empty2, sampleRangeMs };
|
|
162966
|
-
intervals.sort((a, b) => a - b);
|
|
162967
|
-
const medianIntervalMs = intervals[Math.floor(intervals.length / 2)] ?? 0;
|
|
162968
|
-
const childToParent = index.childToParent ?? buildChildToParent(nodeMap);
|
|
162969
|
-
const totalMsByNode = /* @__PURE__ */ new Map();
|
|
162970
|
-
for (const [nodeId, ms] of selfMsByNode) {
|
|
162971
|
-
totalMsByNode.set(nodeId, (totalMsByNode.get(nodeId) ?? 0) + ms);
|
|
162972
|
-
let current = nodeId;
|
|
162973
|
-
const seen = /* @__PURE__ */ new Set([current]);
|
|
162974
|
-
while (childToParent.has(current)) {
|
|
162975
|
-
const parent = childToParent.get(current);
|
|
162976
|
-
if (seen.has(parent)) break;
|
|
162977
|
-
seen.add(parent);
|
|
162978
|
-
totalMsByNode.set(parent, (totalMsByNode.get(parent) ?? 0) + ms);
|
|
162979
|
-
current = parent;
|
|
162980
|
-
}
|
|
162981
|
-
}
|
|
162982
|
-
const entries = [];
|
|
162983
|
-
for (const [nodeId, ms] of selfMsByNode) {
|
|
162984
|
-
const node2 = nodeMap.get(nodeId);
|
|
162985
|
-
if (!node2) continue;
|
|
162986
|
-
const name = node2.callFrame.functionName;
|
|
162987
|
-
if (isArgentProfilerFunction(name)) continue;
|
|
162988
|
-
entries.push({
|
|
162989
|
-
name,
|
|
162990
|
-
selfMs: Math.round(ms * 100) / 100,
|
|
162991
|
-
totalMs: Math.round((totalMsByNode.get(nodeId) ?? ms) * 100) / 100,
|
|
162992
|
-
url: node2.callFrame.url || void 0,
|
|
162993
|
-
lineNumber: node2.callFrame.lineNumber >= 0 ? node2.callFrame.lineNumber : void 0
|
|
162994
|
-
});
|
|
162995
|
-
}
|
|
162996
|
-
entries.sort((a, b) => b.selfMs - a.selfMs);
|
|
162997
|
-
return {
|
|
162998
|
-
hotspots: entries.slice(0, topN2),
|
|
162999
|
-
samplesInWindow,
|
|
163000
|
-
coveredMs,
|
|
163001
|
-
idleMs,
|
|
163002
|
-
sampleRangeMs,
|
|
163003
|
-
medianIntervalMs,
|
|
163004
|
-
maxIntervalMs
|
|
163005
|
-
};
|
|
163006
|
-
}
|
|
163007
|
-
function buildChildToParent(nodeMap) {
|
|
163008
|
-
const childToParent = /* @__PURE__ */ new Map();
|
|
163009
|
-
for (const node2 of nodeMap.values()) {
|
|
163010
|
-
for (const childId of node2.children ?? []) childToParent.set(childId, node2.id);
|
|
163011
|
-
}
|
|
163012
|
-
return childToParent;
|
|
163013
|
-
}
|
|
163014
|
-
function correlateCpuWithCommits(summaries, index, topNPerCommit = 5) {
|
|
163015
|
-
if (!index) return summaries;
|
|
163016
|
-
return summaries.map((summary) => {
|
|
163017
|
-
if (summary.isMargin) return summary;
|
|
163018
|
-
const startMs = summary.timestampMs;
|
|
163019
|
-
const endMs = summary.timestampMs + summary.totalRenderMs;
|
|
163020
|
-
const { hotspots } = queryCpuWindow(index, startMs, endMs, topNPerCommit);
|
|
163021
|
-
if (hotspots.length === 0) return summary;
|
|
163022
|
-
return { ...summary, cpuHotspots: hotspots };
|
|
163023
|
-
});
|
|
163024
|
-
}
|
|
163025
|
-
function serializeCpuSampleIndex(index) {
|
|
163026
|
-
return {
|
|
163027
|
-
version: 2,
|
|
163028
|
-
timestampsMs: Array.from(index.timestampsMs),
|
|
163029
|
-
intervalStartsMs: Array.from(index.intervalStartsMs),
|
|
163030
|
-
sampleNodeIds: index.sampleNodeIds,
|
|
163031
|
-
nodes: [...index.nodeMap.values()],
|
|
163032
|
-
durationMs: index.durationMs
|
|
163033
|
-
};
|
|
163034
|
-
}
|
|
163035
|
-
function deserializeCpuSampleIndex(raw) {
|
|
163036
|
-
if (raw?.version !== 2 || !Array.isArray(raw.timestampsMs) || !Array.isArray(raw.nodes)) {
|
|
163037
|
-
throw new Error("unsupported CPU sample index format");
|
|
163038
|
-
}
|
|
163039
|
-
const nodeMap = /* @__PURE__ */ new Map();
|
|
163040
|
-
for (const node2 of raw.nodes) {
|
|
163041
|
-
nodeMap.set(node2.id, node2);
|
|
163042
|
-
}
|
|
163043
|
-
return {
|
|
163044
|
-
timestampsMs: new Float64Array(raw.timestampsMs),
|
|
163045
|
-
intervalStartsMs: new Float64Array(raw.intervalStartsMs ?? []),
|
|
163046
|
-
sampleNodeIds: raw.sampleNodeIds,
|
|
163047
|
-
nodeMap,
|
|
163048
|
-
childToParent: buildChildToParent(nodeMap),
|
|
163049
|
-
durationMs: raw.durationMs
|
|
163050
|
-
};
|
|
163051
|
-
}
|
|
163052
|
-
|
|
163053
163507
|
// ../tool-server/src/utils/react-profiler/pipeline/01-reduce.ts
|
|
163054
|
-
var EMPTY_REASON_HISTOGRAM = () => ({
|
|
163055
|
-
parent: 0,
|
|
163056
|
-
props: 0,
|
|
163057
|
-
hooks: 0,
|
|
163058
|
-
context: 0,
|
|
163059
|
-
state: 0,
|
|
163060
|
-
force_update: 0,
|
|
163061
|
-
unknown: 0
|
|
163062
|
-
});
|
|
163063
163508
|
function reduce(commitTree, sessionContext, recordingMs, sessionAnyCompilerOptimized) {
|
|
163064
163509
|
const components = /* @__PURE__ */ new Map();
|
|
163065
163510
|
const componentHadRerender = /* @__PURE__ */ new Set();
|
|
@@ -163096,7 +163541,7 @@ function reduce(commitTree, sessionContext, recordingMs, sessionAnyCompilerOptim
|
|
|
163096
163541
|
sumSq: 0,
|
|
163097
163542
|
min: Infinity,
|
|
163098
163543
|
max: -Infinity,
|
|
163099
|
-
reasonHistogram:
|
|
163544
|
+
reasonHistogram: emptyReasonHistogram(),
|
|
163100
163545
|
propFreq: /* @__PURE__ */ new Map(),
|
|
163101
163546
|
hookFreq: /* @__PURE__ */ new Map(),
|
|
163102
163547
|
parentFreq: /* @__PURE__ */ new Map(),
|
|
@@ -163166,17 +163611,6 @@ function reduce(commitTree, sessionContext, recordingMs, sessionAnyCompilerOptim
|
|
|
163166
163611
|
function topN(freq, n) {
|
|
163167
163612
|
return Array.from(freq.entries()).sort((a, b) => b[1] - a[1]).slice(0, n).map(([k]) => k);
|
|
163168
163613
|
}
|
|
163169
|
-
function dominantReason(histogram) {
|
|
163170
|
-
let best = "unknown";
|
|
163171
|
-
let bestCount = -1;
|
|
163172
|
-
for (const [reason2, count2] of Object.entries(histogram)) {
|
|
163173
|
-
if (count2 > bestCount) {
|
|
163174
|
-
bestCount = count2;
|
|
163175
|
-
best = reason2;
|
|
163176
|
-
}
|
|
163177
|
-
}
|
|
163178
|
-
return best;
|
|
163179
|
-
}
|
|
163180
163614
|
function topParent(parentFreq) {
|
|
163181
163615
|
let best;
|
|
163182
163616
|
let bestCount = -1;
|
|
@@ -163371,10 +163805,10 @@ async function runPipeline(input2, options) {
|
|
|
163371
163805
|
componentFindings,
|
|
163372
163806
|
sessionContext: tagOutput.sessionContext,
|
|
163373
163807
|
recordingMs: tagOutput.recordingMs,
|
|
163374
|
-
|
|
163808
|
+
noHotCommits: input2.sessionMeta.noHotCommits ?? false,
|
|
163375
163809
|
maxCommitMs: input2.sessionMeta.maxCommitMs,
|
|
163376
163810
|
anyRuntimeCompilerDetected: tagOutput.anyRuntimeCompilerDetected,
|
|
163377
|
-
//
|
|
163811
|
+
// With no hot commit no commits are kept, so tagOutput.reactCommits is 0
|
|
163378
163812
|
reactCommits: input2.sessionMeta.totalReactCommits ?? tagOutput.reactCommits,
|
|
163379
163813
|
fiberRenders: tagOutput.fiberRenders,
|
|
163380
163814
|
totalFirstMounts: tagOutput.totalFirstMounts,
|
|
@@ -163382,98 +163816,6 @@ async function runPipeline(input2, options) {
|
|
|
163382
163816
|
};
|
|
163383
163817
|
}
|
|
163384
163818
|
|
|
163385
|
-
// ../tool-server/src/utils/react-profiler/component-names.ts
|
|
163386
|
-
var WRAPPER_PATTERNS = [/^Forget\((.+)\)$/, /^Memo\((.+)\)$/, /^ForwardRef\((.+)\)$/];
|
|
163387
|
-
var MAX_WRAPPER_DEPTH = 4;
|
|
163388
|
-
function stripComponentWrappers(raw) {
|
|
163389
|
-
let name = raw;
|
|
163390
|
-
let hasForget = false;
|
|
163391
|
-
let hasMemo = false;
|
|
163392
|
-
let hasForwardRef = false;
|
|
163393
|
-
for (let i = 0; i < MAX_WRAPPER_DEPTH; i++) {
|
|
163394
|
-
const m = WRAPPER_PATTERNS.map((re2) => name.match(re2)).find(Boolean);
|
|
163395
|
-
if (!m) break;
|
|
163396
|
-
if (name.startsWith("Forget(")) hasForget = true;
|
|
163397
|
-
else if (name.startsWith("Memo(")) hasMemo = true;
|
|
163398
|
-
else if (name.startsWith("ForwardRef(")) hasForwardRef = true;
|
|
163399
|
-
name = m[1];
|
|
163400
|
-
}
|
|
163401
|
-
return { baseName: name, hasForget, hasMemo, hasForwardRef };
|
|
163402
|
-
}
|
|
163403
|
-
function annotateComponentName(raw) {
|
|
163404
|
-
const { baseName, hasForget, hasMemo, hasForwardRef } = stripComponentWrappers(raw);
|
|
163405
|
-
const parts2 = [];
|
|
163406
|
-
if (hasMemo) parts2.push("React.memo");
|
|
163407
|
-
if (hasForget) parts2.push("React Compiler");
|
|
163408
|
-
if (hasForwardRef) parts2.push("forwardRef");
|
|
163409
|
-
const tag3 = parts2.length > 0 ? ` [${parts2.join(" + ")}]` : "";
|
|
163410
|
-
return { displayName: baseName, tag: tag3, rawName: raw };
|
|
163411
|
-
}
|
|
163412
|
-
function resolveComponentName(query, recordedNames) {
|
|
163413
|
-
const names = [...new Set(recordedNames)];
|
|
163414
|
-
const sharingDisplayName = (raw) => {
|
|
163415
|
-
const display = annotateComponentName(raw).displayName;
|
|
163416
|
-
return names.filter((n) => n !== raw && annotateComponentName(n).displayName === display);
|
|
163417
|
-
};
|
|
163418
|
-
if (names.includes(query)) {
|
|
163419
|
-
return { kind: "exact", rawName: query, alsoMatching: sharingDisplayName(query) };
|
|
163420
|
-
}
|
|
163421
|
-
const candidates = names.filter((n) => annotateComponentName(n).displayName === query);
|
|
163422
|
-
if (candidates.length === 1) {
|
|
163423
|
-
return { kind: "display", rawName: candidates[0], query };
|
|
163424
|
-
}
|
|
163425
|
-
if (candidates.length > 1) {
|
|
163426
|
-
return { kind: "ambiguous", query, candidates };
|
|
163427
|
-
}
|
|
163428
|
-
return { kind: "missing", query, suggestions: suggestNames(query, names) };
|
|
163429
|
-
}
|
|
163430
|
-
function suggestNames(query, names, limit = 5) {
|
|
163431
|
-
const needle = query.toLowerCase();
|
|
163432
|
-
if (needle.length < 2) return [];
|
|
163433
|
-
return names.filter((n) => {
|
|
163434
|
-
const hay = `${n} ${annotateComponentName(n).displayName}`.toLowerCase();
|
|
163435
|
-
return hay.includes(needle) || needle.includes(annotateComponentName(n).displayName.toLowerCase());
|
|
163436
|
-
}).slice(0, limit);
|
|
163437
|
-
}
|
|
163438
|
-
function describeResolution(resolution) {
|
|
163439
|
-
if (resolution.kind === "display") {
|
|
163440
|
-
const { tag: tag3 } = annotateComponentName(resolution.rawName);
|
|
163441
|
-
const why = tag3 ? ` (${tag3.trim().slice(1, -1)})` : "";
|
|
163442
|
-
return `> Resolved \`${resolution.query}\` to the recorded component \`${resolution.rawName}\`${why}. Either name works here.`;
|
|
163443
|
-
}
|
|
163444
|
-
if (resolution.alsoMatching.length > 0) {
|
|
163445
|
-
const others = resolution.alsoMatching.map((n) => `\`${n}\``).join(", ");
|
|
163446
|
-
return `> Showing \`${resolution.rawName}\` only. ${others} also appear${resolution.alsoMatching.length === 1 ? "s" : ""} under this name once wrappers are stripped; they are separate fibers, so pass the exact name to target one.`;
|
|
163447
|
-
}
|
|
163448
|
-
return "";
|
|
163449
|
-
}
|
|
163450
|
-
function renderComponentNameMiss(resolution, context2 = {}) {
|
|
163451
|
-
if (resolution.kind === "ambiguous") {
|
|
163452
|
-
const list = resolution.candidates.map((c) => `- \`${c}\``).join("\n");
|
|
163453
|
-
return `_Component \`${resolution.query}\` is ambiguous: ${resolution.candidates.length} recorded components share this name once \`Memo(...)\` / \`ForwardRef(...)\` / \`Forget(...)\` wrappers are stripped. They are separate fibers and are not merged, because a combined total would not describe any real component. Re-run with one of these exact \`component_name\` values:_
|
|
163454
|
-
|
|
163455
|
-
${list}`;
|
|
163456
|
-
}
|
|
163457
|
-
const recorded = context2.fiberRenders != null && context2.commits != null ? ` The session recorded ${context2.fiberRenders} fiber renders across ${context2.commits} commits.` : "";
|
|
163458
|
-
const suggestions = resolution.suggestions.length > 0 ? `
|
|
163459
|
-
|
|
163460
|
-
Closest recorded names \u2014 pass one verbatim as \`component_name\`:
|
|
163461
|
-
` + resolution.suggestions.map((s) => `- \`${s}\``).join("\n") : "";
|
|
163462
|
-
return `_Component \`${resolution.query}\` not found in this profiling session \u2014 no exact match, and no component whose displayed name is \`${resolution.query}\` once \`Memo(...)\` / \`ForwardRef(...)\` / \`Forget(...)\` wrappers are stripped.${recorded}_${suggestions}
|
|
163463
|
-
|
|
163464
|
-
To list every component in a commit instead, run \`profiler-commit-query mode=by_index commit_index=<n>\`.`;
|
|
163465
|
-
}
|
|
163466
|
-
function astLookupCandidates(raw) {
|
|
163467
|
-
const keys = [raw];
|
|
163468
|
-
const { baseName } = stripComponentWrappers(raw);
|
|
163469
|
-
if (baseName !== raw) keys.push(baseName);
|
|
163470
|
-
const withoutSuffix = baseName.replace(/\(.*\)$/, "");
|
|
163471
|
-
if (withoutSuffix !== baseName && /^[A-Za-z_$][\w$]*$/.test(withoutSuffix)) {
|
|
163472
|
-
keys.push(withoutSuffix);
|
|
163473
|
-
}
|
|
163474
|
-
return keys;
|
|
163475
|
-
}
|
|
163476
|
-
|
|
163477
163819
|
// ../tool-server/src/utils/react-profiler/pipeline/06-resolve/ast-index.ts
|
|
163478
163820
|
var import_fs3 = require("fs");
|
|
163479
163821
|
var import_path4 = require("path");
|
|
@@ -163500,9 +163842,21 @@ function loadTreeSitter() {
|
|
|
163500
163842
|
if (!_ParserClass || !_tsLanguage || !_tsxLanguage) return null;
|
|
163501
163843
|
return { ParserClass: _ParserClass, ts: _tsLanguage, tsx: _tsxLanguage };
|
|
163502
163844
|
}
|
|
163503
|
-
var EXCLUDE_DIRS = /* @__PURE__ */ new Set([
|
|
163845
|
+
var EXCLUDE_DIRS = /* @__PURE__ */ new Set([
|
|
163846
|
+
"node_modules",
|
|
163847
|
+
".git",
|
|
163848
|
+
"android",
|
|
163849
|
+
"ios",
|
|
163850
|
+
"dist",
|
|
163851
|
+
"build",
|
|
163852
|
+
".expo",
|
|
163853
|
+
"__tests__",
|
|
163854
|
+
"__mocks__"
|
|
163855
|
+
]);
|
|
163856
|
+
var TEST_FILE = /\.(test|spec)\.[jt]sx?$/;
|
|
163504
163857
|
async function findSourceFiles(dir) {
|
|
163505
163858
|
const result = [];
|
|
163859
|
+
const nestedPackages = [];
|
|
163506
163860
|
async function walk(current) {
|
|
163507
163861
|
let entries;
|
|
163508
163862
|
try {
|
|
@@ -163510,6 +163864,9 @@ async function findSourceFiles(dir) {
|
|
|
163510
163864
|
} catch {
|
|
163511
163865
|
return;
|
|
163512
163866
|
}
|
|
163867
|
+
if (current !== dir && entries.some((e) => e.isFile() && e.name === "package.json")) {
|
|
163868
|
+
nestedPackages.push(current + import_path4.sep);
|
|
163869
|
+
}
|
|
163513
163870
|
for (const entry of entries) {
|
|
163514
163871
|
if (entry.isDirectory()) {
|
|
163515
163872
|
if (!EXCLUDE_DIRS.has(entry.name)) {
|
|
@@ -163517,14 +163874,14 @@ async function findSourceFiles(dir) {
|
|
|
163517
163874
|
}
|
|
163518
163875
|
} else if (entry.isFile()) {
|
|
163519
163876
|
const name = entry.name;
|
|
163520
|
-
if (name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".js") || name.endsWith(".jsx")) {
|
|
163877
|
+
if ((name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".js") || name.endsWith(".jsx")) && !TEST_FILE.test(name)) {
|
|
163521
163878
|
result.push((0, import_path4.join)(current, name));
|
|
163522
163879
|
}
|
|
163523
163880
|
}
|
|
163524
163881
|
}
|
|
163525
163882
|
}
|
|
163526
163883
|
await walk(dir);
|
|
163527
|
-
return result;
|
|
163884
|
+
return { files: result, nestedPackages };
|
|
163528
163885
|
}
|
|
163529
163886
|
function isCapitalized(name) {
|
|
163530
163887
|
if (name.length === 0) return false;
|
|
@@ -163571,12 +163928,47 @@ function collectMemoizedNames(root) {
|
|
|
163571
163928
|
return names;
|
|
163572
163929
|
}
|
|
163573
163930
|
var PLATFORM_SUFFIX = /\.(web|ios|android|native)\.[jt]sx?$/;
|
|
163574
|
-
|
|
163575
|
-
|
|
163931
|
+
var EXTENSION = /\.[jt]sx?$/;
|
|
163932
|
+
var NOT_APP_CODE = /\.(test|spec|stories)\.[jt]sx?$/;
|
|
163933
|
+
var NOT_BUNDLED = 3;
|
|
163934
|
+
function variantRank(file2, platform) {
|
|
163935
|
+
const suffix = PLATFORM_SUFFIX.exec(file2)?.[1];
|
|
163936
|
+
if (!platform) return suffix ? 1 : 0;
|
|
163937
|
+
if (suffix === platform) return 0;
|
|
163938
|
+
if (suffix === "native") return 1;
|
|
163939
|
+
return suffix ? NOT_BUNDLED : 2;
|
|
163940
|
+
}
|
|
163941
|
+
function moduleOf(file2) {
|
|
163942
|
+
return file2.replace(PLATFORM_SUFFIX, "").replace(EXTENSION, "");
|
|
163943
|
+
}
|
|
163944
|
+
function bundledFilter(files, platform) {
|
|
163945
|
+
if (!platform) return () => true;
|
|
163946
|
+
const best = /* @__PURE__ */ new Map();
|
|
163947
|
+
for (const file2 of files) {
|
|
163948
|
+
const module2 = moduleOf(file2);
|
|
163949
|
+
best.set(module2, Math.min(best.get(module2) ?? NOT_BUNDLED, variantRank(file2, platform)));
|
|
163950
|
+
}
|
|
163951
|
+
return (file2) => {
|
|
163952
|
+
const rank2 = variantRank(file2, platform);
|
|
163953
|
+
return rank2 !== NOT_BUNDLED && rank2 === best.get(moduleOf(file2));
|
|
163954
|
+
};
|
|
163576
163955
|
}
|
|
163577
|
-
function
|
|
163956
|
+
function fileNameKey(name) {
|
|
163957
|
+
return name.replace(/[-_]/g, "").toLowerCase();
|
|
163958
|
+
}
|
|
163959
|
+
function isNamedAfter(file2, component) {
|
|
163960
|
+
const base = (0, import_path4.basename)(moduleOf(file2));
|
|
163961
|
+
const stem = base === "index" ? (0, import_path4.basename)((0, import_path4.dirname)(file2)) : base;
|
|
163962
|
+
return fileNameKey(stem) === fileNameKey(component);
|
|
163963
|
+
}
|
|
163964
|
+
function pickPrimary(name, entries, platform, nestedPackages) {
|
|
163965
|
+
const foreign = (file2) => NOT_APP_CODE.test(file2) || nestedPackages.some((dir) => file2.startsWith(dir)) ? 1 : 0;
|
|
163578
163966
|
const sorted = entries.slice().sort((a, b) => {
|
|
163579
|
-
const
|
|
163967
|
+
const foreignDelta = foreign(a.file) - foreign(b.file);
|
|
163968
|
+
if (foreignDelta !== 0) return foreignDelta;
|
|
163969
|
+
const nameDelta = Number(isNamedAfter(b.file, name)) - Number(isNamedAfter(a.file, name));
|
|
163970
|
+
if (nameDelta !== 0) return nameDelta;
|
|
163971
|
+
const variantDelta = variantRank(a.file, platform) - variantRank(b.file, platform);
|
|
163580
163972
|
if (variantDelta !== 0) return variantDelta;
|
|
163581
163973
|
if (a.file !== b.file) return a.file < b.file ? -1 : 1;
|
|
163582
163974
|
if (a.line !== b.line) return a.line - b.line;
|
|
@@ -163588,12 +163980,14 @@ function pickPrimary(entries) {
|
|
|
163588
163980
|
others: rest.map((e) => ({ file: e.file, line: e.line, col: e.col }))
|
|
163589
163981
|
};
|
|
163590
163982
|
}
|
|
163591
|
-
|
|
163983
|
+
var DEFAULT_PARSE_BUFFER_CHARS = 32 * 1024 - 1;
|
|
163984
|
+
var MAX_JSX_FILE_CHARS = 512 * 1024;
|
|
163985
|
+
async function buildAstIndexWithDiagnostics(projectRoot, platform) {
|
|
163592
163986
|
const index = /* @__PURE__ */ new Map();
|
|
163593
163987
|
const ts = loadTreeSitter();
|
|
163594
163988
|
if (!ts) return { index, treeSitterAvailable: false, indexedFiles: 0 };
|
|
163595
163989
|
const { ParserClass, ts: tsLang, tsx: tsxLang } = ts;
|
|
163596
|
-
const files = await findSourceFiles(projectRoot);
|
|
163990
|
+
const { files, nestedPackages } = await findSourceFiles(projectRoot);
|
|
163597
163991
|
const candidates = /* @__PURE__ */ new Map();
|
|
163598
163992
|
function addCandidate(name, entry) {
|
|
163599
163993
|
const existing = candidates.get(name);
|
|
@@ -163642,24 +164036,33 @@ async function buildAstIndexWithDiagnostics(projectRoot) {
|
|
|
163642
164036
|
} catch {
|
|
163643
164037
|
continue;
|
|
163644
164038
|
}
|
|
163645
|
-
const
|
|
163646
|
-
const language =
|
|
164039
|
+
const isJsxFile = file2.endsWith(".tsx") || file2.endsWith(".jsx");
|
|
164040
|
+
const language = isJsxFile || file2.endsWith(".js") ? tsxLang : tsLang;
|
|
164041
|
+
if (source.length > (isJsxFile ? MAX_JSX_FILE_CHARS : DEFAULT_PARSE_BUFFER_CHARS)) continue;
|
|
163647
164042
|
let tree;
|
|
163648
164043
|
try {
|
|
163649
164044
|
const parser2 = new ParserClass();
|
|
163650
164045
|
parser2.setLanguage(language);
|
|
163651
|
-
tree = parser2.parse(source);
|
|
164046
|
+
tree = parser2.parse(source, void 0, { bufferSize: source.length + 1 });
|
|
164047
|
+
} catch {
|
|
164048
|
+
continue;
|
|
164049
|
+
}
|
|
164050
|
+
let memoizedNames;
|
|
164051
|
+
try {
|
|
164052
|
+
memoizedNames = collectMemoizedNames(tree.rootNode);
|
|
163652
164053
|
} catch {
|
|
163653
164054
|
continue;
|
|
163654
164055
|
}
|
|
163655
|
-
const memoizedNames = collectMemoizedNames(tree.rootNode);
|
|
163656
164056
|
try {
|
|
163657
164057
|
findComponents2(tree.rootNode);
|
|
163658
164058
|
} catch {
|
|
163659
164059
|
}
|
|
163660
164060
|
}
|
|
164061
|
+
const isBundled = bundledFilter(files, platform);
|
|
163661
164062
|
for (const [name, entries] of candidates) {
|
|
163662
|
-
const {
|
|
164063
|
+
const bundled = entries.filter(({ file: file2 }) => isBundled(file2));
|
|
164064
|
+
if (bundled.length === 0) continue;
|
|
164065
|
+
const { primary, others } = pickPrimary(name, bundled, platform, nestedPackages);
|
|
163663
164066
|
index.set(name, others.length > 0 ? { ...primary, otherMatches: others } : primary);
|
|
163664
164067
|
}
|
|
163665
164068
|
return { index, treeSitterAvailable: true, indexedFiles: files.length };
|
|
@@ -163668,13 +164071,77 @@ async function buildAstIndexWithDiagnostics(projectRoot) {
|
|
|
163668
164071
|
// ../tool-server/src/utils/react-profiler/pipeline/05-render.ts
|
|
163669
164072
|
var import_fs4 = require("fs");
|
|
163670
164073
|
var import_path5 = require("path");
|
|
164074
|
+
|
|
164075
|
+
// ../tool-server/src/utils/react-profiler/component-origin.ts
|
|
164076
|
+
var RN_CORE_NAMES = /* @__PURE__ */ new Set([
|
|
164077
|
+
"ActivityIndicator",
|
|
164078
|
+
"AppContainer",
|
|
164079
|
+
"Button",
|
|
164080
|
+
"DrawerLayoutAndroid",
|
|
164081
|
+
"Image",
|
|
164082
|
+
"ImageBackground",
|
|
164083
|
+
"InputAccessoryView",
|
|
164084
|
+
"InternalTextInput",
|
|
164085
|
+
"KeyboardAvoidingView",
|
|
164086
|
+
"Modal",
|
|
164087
|
+
"Pressable",
|
|
164088
|
+
"RefreshControl",
|
|
164089
|
+
"SafeAreaView",
|
|
164090
|
+
"ScrollView",
|
|
164091
|
+
"ScrollViewBase",
|
|
164092
|
+
"ScrollViewStickyHeader",
|
|
164093
|
+
"StatusBar",
|
|
164094
|
+
"Switch",
|
|
164095
|
+
"Text",
|
|
164096
|
+
"TextImpl",
|
|
164097
|
+
"TextInput",
|
|
164098
|
+
"TouchableHighlight",
|
|
164099
|
+
"TouchableNativeFeedback",
|
|
164100
|
+
"TouchableOpacity",
|
|
164101
|
+
"TouchableWithoutFeedback",
|
|
164102
|
+
"View",
|
|
164103
|
+
// React built-ins.
|
|
164104
|
+
"Fragment",
|
|
164105
|
+
"Profiler",
|
|
164106
|
+
"StrictMode",
|
|
164107
|
+
"Suspense"
|
|
164108
|
+
]);
|
|
164109
|
+
var LIST_INTERNALS_PATTERN = /^(FlatList|SectionList|VirtualizedList\w*|VirtualizedSectionList\w*|CellRenderer\w*|FlashList\w*|AutoLayoutView|CellContainer|RecyclerListView\w*)$/;
|
|
164110
|
+
var PROVIDER_PATTERN = /(Provider|Context|\.Consumer)$/;
|
|
164111
|
+
var DEV_ONLY_PATTERN = /^(PressabilityDebugView|LogBox\w*|DebuggingOverlay\w*|ReactDevToolsOverlay|Inspector\w*|DebugContainer)$/;
|
|
164112
|
+
var UNRESOLVED_NAME = "Anonymous";
|
|
164113
|
+
function isRoleExcluded(baseName) {
|
|
164114
|
+
return baseName === UNRESOLVED_NAME || ANIMATED_PATTERN.test(baseName) || PROVIDER_PATTERN.test(baseName) || DEV_ONLY_PATTERN.test(baseName);
|
|
164115
|
+
}
|
|
164116
|
+
function isReactNativeName(baseName) {
|
|
164117
|
+
return RN_CORE_NAMES.has(baseName) || LIST_INTERNALS_PATTERN.test(baseName);
|
|
164118
|
+
}
|
|
164119
|
+
function createComponentOriginClassifier(index) {
|
|
164120
|
+
const usableIndex = index && index.size > 0 ? index : null;
|
|
164121
|
+
return (rawName) => {
|
|
164122
|
+
const { baseName, hasForget } = stripComponentWrappers(rawName);
|
|
164123
|
+
if (isRoleExcluded(baseName)) return { origin: "library" };
|
|
164124
|
+
const entry = usableIndex ? astLookupCandidates(rawName).map((k) => usableIndex.get(k)).find(Boolean) : void 0;
|
|
164125
|
+
const located = entry ? { file: entry.file, line: entry.line } : {};
|
|
164126
|
+
if (isReactNativeName(baseName)) {
|
|
164127
|
+
return hasForget ? { origin: "app", ...located } : { origin: "library" };
|
|
164128
|
+
}
|
|
164129
|
+
if (hasForget) return { origin: "app", ...located };
|
|
164130
|
+
if (!usableIndex) return { origin: "unknown" };
|
|
164131
|
+
return entry ? { origin: "app", ...located } : { origin: "library", notInSource: true };
|
|
164132
|
+
};
|
|
164133
|
+
}
|
|
164134
|
+
|
|
164135
|
+
// ../tool-server/src/utils/react-profiler/pipeline/05-render.ts
|
|
163671
164136
|
var MAX_INLINE_COMMITS = 10;
|
|
164137
|
+
var MAX_OTHER_MATCHES = 3;
|
|
164138
|
+
var MAX_OUTSIDE_SOURCE_NAMES = 5;
|
|
163672
164139
|
var REPORT_FILENAME = "react-profiler-report.md";
|
|
163673
164140
|
async function renderProfilingReport(input2) {
|
|
163674
164141
|
const reportFile = (0, import_path5.join)(input2.debugDir, REPORT_FILENAME);
|
|
163675
|
-
if (input2.
|
|
164142
|
+
if (input2.noHotCommits) {
|
|
163676
164143
|
const maxMs = input2.maxCommitMs ?? 0;
|
|
163677
|
-
const report2 =
|
|
164144
|
+
const report2 = renderNoHotCommits(input2, maxMs);
|
|
163678
164145
|
const wroteFile2 = await writeReport(reportFile, report2);
|
|
163679
164146
|
return {
|
|
163680
164147
|
report: report2,
|
|
@@ -163686,7 +164153,7 @@ async function renderProfilingReport(input2) {
|
|
|
163686
164153
|
const hotCommits = input2.hotCommitSummaries.filter((s) => !s.isMargin);
|
|
163687
164154
|
const hotCommitsTotal = hotCommits.length;
|
|
163688
164155
|
if (hotCommitsTotal === 0) {
|
|
163689
|
-
const report2 =
|
|
164156
|
+
const report2 = input2.renderSummary ? renderNoHotCommits(input2, input2.maxCommitMs ?? 0) : renderNoCommitData(input2);
|
|
163690
164157
|
const wroteFile2 = await writeReport(reportFile, report2);
|
|
163691
164158
|
return {
|
|
163692
164159
|
report: report2,
|
|
@@ -163719,30 +164186,132 @@ async function renderProfilingReport(input2) {
|
|
|
163719
164186
|
}
|
|
163720
164187
|
return { report, reportFile: wroteFile ? reportFile : null, hotCommitsTotal, hotCommitsShown };
|
|
163721
164188
|
}
|
|
163722
|
-
function
|
|
164189
|
+
function renderTimeLine(input2, summary) {
|
|
164190
|
+
const label = input2.sessionContext.buildMode === "dev" ? " (dev build)" : "";
|
|
164191
|
+
return `**React render time${label}:** ${formatRenderTime(summary)}`;
|
|
164192
|
+
}
|
|
164193
|
+
function renderReportHeader(input2) {
|
|
163723
164194
|
const durationS = (input2.recordingMs / 1e3).toFixed(1);
|
|
163724
164195
|
const compilerLine = renderCompilerStatus(
|
|
163725
164196
|
input2.sessionContext.reactCompilerEnabled,
|
|
163726
164197
|
input2.anyRuntimeCompilerDetected
|
|
163727
164198
|
);
|
|
163728
|
-
const maxNote = maxMs > 0 ? ` (peak commit: ${maxMs.toFixed(1)}ms)` : "";
|
|
163729
164199
|
const lines = [
|
|
163730
164200
|
`# Profiling Analysis \u2014 ${durationS}s session`,
|
|
163731
|
-
`${compilerLine} **Hot commits:** 0 of ${input2.reactCommits} total
|
|
163732
|
-
|
|
163733
|
-
|
|
163734
|
-
|
|
164201
|
+
`${compilerLine} **Hot commits:** 0 of ${input2.reactCommits} total`
|
|
164202
|
+
];
|
|
164203
|
+
if (input2.renderSummary) lines.push(renderTimeLine(input2, input2.renderSummary));
|
|
164204
|
+
lines.push(``);
|
|
164205
|
+
return lines;
|
|
164206
|
+
}
|
|
164207
|
+
function renderNoCommitData(input2) {
|
|
164208
|
+
return [
|
|
164209
|
+
...renderReportHeader(input2),
|
|
164210
|
+
`No React commit data could be read for this session, so no commit durations were measured. Re-profile to measure them.`
|
|
164211
|
+
].join("\n");
|
|
164212
|
+
}
|
|
164213
|
+
function renderNoHotCommits(input2, maxMs) {
|
|
164214
|
+
const summary = input2.renderSummary ?? null;
|
|
164215
|
+
const lines = renderReportHeader(input2);
|
|
164216
|
+
if (summary?.totalCommits === 0 || input2.noReactCommits) {
|
|
164217
|
+
lines.push(
|
|
164218
|
+
`No React commits were recorded, so there is nothing to measure. Interact with the app while the profiler records.`
|
|
164219
|
+
);
|
|
164220
|
+
return lines.join("\n");
|
|
164221
|
+
}
|
|
164222
|
+
const maxNote = maxMs > 0 ? ` (peak commit: ${formatPeakCommit(maxMs)})` : "";
|
|
164223
|
+
lines.push(
|
|
164224
|
+
summary && hasUnnamedSlowCommit(summary) ? `\u26A0\uFE0F **Slow commit with no component names** \u2014 the slowest commit took ${formatPeakCommit(summary.maxCommitMs)}, but none of its components could be named, so it has no breakdown.` : `No commit reached 16ms${maxNote}.`
|
|
164225
|
+
);
|
|
164226
|
+
if (!summary) {
|
|
164227
|
+
lines.push(
|
|
164228
|
+
``,
|
|
164229
|
+
`> This session has no render summary, usually because an older version saved it, so commits under 16ms were not measured: many cheap re-renders can still add up. Re-profile to measure them.`
|
|
164230
|
+
);
|
|
164231
|
+
} else if (summary.components.length === 0) {
|
|
164232
|
+
lines.push(``, `No component in this session could be named, so there is nothing to list.`);
|
|
164233
|
+
}
|
|
164234
|
+
const { rows, cut } = frequentRerenderRows(input2);
|
|
164235
|
+
lines.push(
|
|
164236
|
+
...renderFrequentRerenders(
|
|
164237
|
+
summary,
|
|
164238
|
+
rows,
|
|
164239
|
+
frequentOutsideSource(input2),
|
|
164240
|
+
input2.sessionContext.projectRoot,
|
|
164241
|
+
cut
|
|
164242
|
+
)
|
|
164243
|
+
);
|
|
164244
|
+
lines.push(``, `---`, `## Next Steps`, ``);
|
|
164245
|
+
if (rows.length > 0) {
|
|
164246
|
+
lines.push(
|
|
164247
|
+
`Ask the user which path to take:`,
|
|
164248
|
+
``,
|
|
164249
|
+
`1. **Investigate further** \u2014 \`profiler-commit-query\` mode=\`render_counts\` for every component's counts, or \`profiler-cpu-query\` mode=\`top_functions\` for the JS work behind them.`,
|
|
164250
|
+
`2. **Cut re-renders** \u2014 if the top rows re-render more often than the screen needs (the Reason column names what changes each time, e.g. a timer or animation kept in React state), reduce that, then re-profile the same scenario and compare.`,
|
|
164251
|
+
`3. **Done for now** \u2014 save the report for reference.`
|
|
164252
|
+
);
|
|
164253
|
+
} else {
|
|
164254
|
+
lines.push(
|
|
164255
|
+
`- Re-profile under heavier load (longer interaction, more data) if this run did not cover the flow you care about.`,
|
|
164256
|
+
`- \`profiler-cpu-query\` mode=\`top_functions\` shows the JS work during the recording.`
|
|
164257
|
+
);
|
|
164258
|
+
if (summary) {
|
|
164259
|
+
lines.push(
|
|
164260
|
+
`- \`profiler-commit-query\` mode=\`render_counts\` lists each component's render count over all ${formatCount(summary.totalCommits)} commits. A high count matters only when its time adds up.`
|
|
164261
|
+
);
|
|
164262
|
+
}
|
|
164263
|
+
}
|
|
164264
|
+
return lines.join("\n");
|
|
164265
|
+
}
|
|
164266
|
+
function frequentRerenderRows(input2) {
|
|
164267
|
+
const all = input2.renderSummary ? selectFrequentRerenders(
|
|
164268
|
+
input2.renderSummary,
|
|
164269
|
+
input2.componentOrigin ?? createComponentOriginClassifier(null),
|
|
164270
|
+
Infinity
|
|
164271
|
+
) : [];
|
|
164272
|
+
return { rows: all.slice(0, MAX_FREQUENT_ROWS), cut: all.slice(MAX_FREQUENT_ROWS) };
|
|
164273
|
+
}
|
|
164274
|
+
function frequentOutsideSource(input2) {
|
|
164275
|
+
return input2.renderSummary ? selectFrequentOutsideSource(
|
|
164276
|
+
input2.renderSummary,
|
|
164277
|
+
input2.componentOrigin ?? createComponentOriginClassifier(null)
|
|
164278
|
+
) : [];
|
|
164279
|
+
}
|
|
164280
|
+
function renderFrequentRerenders(summary, rows, outsideSource, projectRoot, cut = []) {
|
|
164281
|
+
if (!summary) return [];
|
|
164282
|
+
const outsideNote = outsideSource.length > 0 ? [``, renderOutsideSourceNote(outsideSource)] : [];
|
|
164283
|
+
const cutNote = cut.length > 0 ? [``, renderCutNote(cut)] : [];
|
|
164284
|
+
if (rows.length === 0) return [...cutNote, ...outsideNote];
|
|
164285
|
+
const unplaced = rows.some((row) => row.origin.origin === "unknown");
|
|
164286
|
+
return [
|
|
163735
164287
|
``,
|
|
163736
164288
|
`---`,
|
|
163737
|
-
`##
|
|
164289
|
+
`## Most Frequent Re-renders`,
|
|
163738
164290
|
``,
|
|
163739
|
-
`
|
|
164291
|
+
`${unplaced ? "Components" : "App components"} that re-rendered in at least 10 of the ${formatCount(summary.totalCommits)} commits and used at least 1 ms of self time per second of recording, by self time per second. This shows where frequent re-renders add up, not that it is a problem. ${unplaced ? "The project source could not be indexed (check `project_root`), so library components may be listed. " : ""}React Native primitives, list internals, animation wrappers, providers and dev-only components are left out; \`profiler-commit-query\` mode=\`render_counts\` lists every component.`,
|
|
163740
164292
|
``,
|
|
163741
|
-
|
|
163742
|
-
|
|
163743
|
-
|
|
164293
|
+
`| Component | Re-renders | Per second | Self ms/s | Self total | Reason | File |`,
|
|
164294
|
+
`|---|---|---|---|---|---|---|`,
|
|
164295
|
+
...rows.map((row) => renderFrequentRow(row, projectRoot)),
|
|
164296
|
+
...cutNote,
|
|
164297
|
+
...outsideNote
|
|
163744
164298
|
];
|
|
163745
|
-
|
|
164299
|
+
}
|
|
164300
|
+
function renderCutNote(cut) {
|
|
164301
|
+
const shown = cut.slice(0, MAX_OUTSIDE_SOURCE_NAMES).map((row) => `\`${row.component.name}\``).join(", ");
|
|
164302
|
+
const more = cut.length > MAX_OUTSIDE_SOURCE_NAMES ? ` and ${cut.length - MAX_OUTSIDE_SOURCE_NAMES} more` : "";
|
|
164303
|
+
return `Also re-rendered often (in at least 10 commits, with at least 1 ms of self time per second) but not listed above: ${shown}${more}. \`profiler-commit-query\` mode=\`render_counts\` has the counts.`;
|
|
164304
|
+
}
|
|
164305
|
+
function renderOutsideSourceNote(names) {
|
|
164306
|
+
const shown = names.slice(0, MAX_OUTSIDE_SOURCE_NAMES).map((name) => `\`${name}\``).join(", ");
|
|
164307
|
+
const more = names.length > MAX_OUTSIDE_SOURCE_NAMES ? ` and ${names.length - MAX_OUTSIDE_SOURCE_NAMES} more` : "";
|
|
164308
|
+
return `Frequent re-renders left out because the source index has no definition for the name: ${shown}${more}. These are usually library components. Class components, components made by a wrapper such as \`observer()\`, and all of your components when \`project_root\` is wrong land here too. \`profiler-commit-query\` mode=\`render_counts\` has the counts.`;
|
|
164309
|
+
}
|
|
164310
|
+
function renderFrequentRow(row, projectRoot) {
|
|
164311
|
+
const c = row.component;
|
|
164312
|
+
const ann = annotateComponentName(c.name);
|
|
164313
|
+
const file2 = row.origin.file !== void 0 ? `\`${pathFromProject(row.origin.file, projectRoot)}${row.origin.line !== void 0 ? `:${row.origin.line}` : ""}\`` : "\u2014";
|
|
164314
|
+
return `| \`${ann.displayName}\`${ann.tag} | ${formatCount(c.rerenders)} | ${row.perSecond.toFixed(1)} | ${row.selfMsPerSecond.toFixed(1)} | ${c.rerenderSelfMs.toFixed(1)}ms | ${formatRenderSummaryReason(c)} | ${file2} |`;
|
|
163746
164315
|
}
|
|
163747
164316
|
function renderCompilerStatus(enabled, detectedAtRuntime) {
|
|
163748
164317
|
if (enabled && detectedAtRuntime) return "**React Compiler:** \u2713";
|
|
@@ -163761,6 +164330,7 @@ function buildFullMarkdown(input2, annotations, totalHotCommits) {
|
|
|
163761
164330
|
const lines = [
|
|
163762
164331
|
`# Profiling Analysis \u2014 ${durationS}s session`,
|
|
163763
164332
|
`${compilerLine} **Hot commits:** ${totalHotCommits} of ${input2.reactCommits} total`,
|
|
164333
|
+
...input2.renderSummary ? [renderTimeLine(input2, input2.renderSummary)] : [],
|
|
163764
164334
|
``,
|
|
163765
164335
|
`> **Duration columns:** \`self\` = this component's own render work only (exclusive).`,
|
|
163766
164336
|
`> \`w/children\` = self + the entire subtree it owns (inclusive).`,
|
|
@@ -163779,15 +164349,25 @@ function buildFullMarkdown(input2, annotations, totalHotCommits) {
|
|
|
163779
164349
|
lines.push("---");
|
|
163780
164350
|
lines.push("## Top Components by Total Render Cost");
|
|
163781
164351
|
lines.push("");
|
|
164352
|
+
const renderSummary = input2.renderSummary ?? null;
|
|
164353
|
+
const allRerenders = renderSummary ? new Map(renderSummary.components.map((c) => [c.name, c.rerenders])) : null;
|
|
164354
|
+
if (renderSummary) {
|
|
164355
|
+
lines.push(
|
|
164356
|
+
`> \`Renders\` = re-renders in the stored commits (hot and \xB11 neighbours, which Total/Avg/Max cover) / re-renders in all ${formatCount(renderSummary.totalCommits)} commits.`
|
|
164357
|
+
);
|
|
164358
|
+
lines.push("");
|
|
164359
|
+
}
|
|
163782
164360
|
lines.push("| Component | Renders | Total | Avg | Max | Reason | File |");
|
|
163783
164361
|
lines.push("|---|---|---|---|---|---|---|");
|
|
163784
164362
|
for (const f of input2.componentFindings) {
|
|
163785
|
-
const file2 = f.sourceLocation ?
|
|
164363
|
+
const file2 = f.sourceLocation ? formatLocation(f.sourceLocation, sessionContext.projectRoot) : "\u2014";
|
|
163786
164364
|
const reasonStr = formatReason(f.dominantReason, f.topChangedProps, f.topChangedHookNames);
|
|
163787
164365
|
const compilerFlag = f.compilerBailoutSuspected ? " \u26A0\uFE0F" : f.isCompilerOptimized ? " \u2713" : "";
|
|
163788
164366
|
const ann = annotateComponentName(f.component);
|
|
164367
|
+
const all = allRerenders?.get(f.component);
|
|
164368
|
+
const renders = all !== void 0 ? `${f.renders} / ${formatCount(all)}` : `${f.renders}`;
|
|
163789
164369
|
lines.push(
|
|
163790
|
-
`| \`${ann.displayName}\`${ann.tag}${compilerFlag} | ${
|
|
164370
|
+
`| \`${ann.displayName}\`${ann.tag}${compilerFlag} | ${renders} | ${f.totalMs}ms | ${f.avgMs}ms | ${f.maxMs}ms | ${reasonStr} | ${file2} |`
|
|
163791
164371
|
);
|
|
163792
164372
|
}
|
|
163793
164373
|
if (sessionContext.reactCompilerEnabled && !anyRuntimeCompilerDetected) {
|
|
@@ -163797,9 +164377,26 @@ function buildFullMarkdown(input2, annotations, totalHotCommits) {
|
|
|
163797
164377
|
);
|
|
163798
164378
|
}
|
|
163799
164379
|
}
|
|
164380
|
+
const { rows: frequent, cut } = frequentRerenderRows(input2);
|
|
164381
|
+
const inTopComponents = new Set(input2.componentFindings.map((f) => f.component));
|
|
164382
|
+
const cutNew = cut.filter((row) => !inTopComponents.has(row.component.name));
|
|
164383
|
+
const outsideSource = frequentOutsideSource(input2).filter((name) => !inTopComponents.has(name));
|
|
164384
|
+
const tableAddsRow = frequent.some((row) => !inTopComponents.has(row.component.name));
|
|
164385
|
+
if (tableAddsRow || outsideSource.length > 0 || cutNew.length > 0) {
|
|
164386
|
+
lines.push(
|
|
164387
|
+
...renderFrequentRerenders(
|
|
164388
|
+
input2.renderSummary ?? null,
|
|
164389
|
+
tableAddsRow ? frequent : [],
|
|
164390
|
+
outsideSource,
|
|
164391
|
+
sessionContext.projectRoot,
|
|
164392
|
+
cutNew
|
|
164393
|
+
)
|
|
164394
|
+
);
|
|
164395
|
+
}
|
|
163800
164396
|
const suggestionsSection = renderSuggestedImprovements(
|
|
163801
164397
|
input2.componentFindings,
|
|
163802
|
-
sessionContext.reactCompilerEnabled
|
|
164398
|
+
sessionContext.reactCompilerEnabled,
|
|
164399
|
+
sessionContext.projectRoot
|
|
163803
164400
|
);
|
|
163804
164401
|
if (suggestionsSection) {
|
|
163805
164402
|
lines.push(suggestionsSection);
|
|
@@ -163973,12 +164570,12 @@ function findPriorAnnotation(annotations, relativeMs) {
|
|
|
163973
164570
|
}
|
|
163974
164571
|
return result;
|
|
163975
164572
|
}
|
|
163976
|
-
function renderSuggestedImprovements(findings, compilerEnabled) {
|
|
164573
|
+
function renderSuggestedImprovements(findings, compilerEnabled, projectRoot) {
|
|
163977
164574
|
if (findings.length === 0) return "";
|
|
163978
164575
|
const topFindings = findings.slice().sort((a, b) => b.totalMs - a.totalMs).slice(0, 5);
|
|
163979
164576
|
const lines = ["", "---", "## Suggested Improvements", ""];
|
|
163980
164577
|
for (const f of topFindings) {
|
|
163981
|
-
const loc = f.sourceLocation ?
|
|
164578
|
+
const loc = f.sourceLocation ? formatLocation(f.sourceLocation, projectRoot) : null;
|
|
163982
164579
|
const ann = annotateComponentName(f.component);
|
|
163983
164580
|
const heading = `\`${ann.displayName}\`${ann.tag}`;
|
|
163984
164581
|
lines.push(loc ? `### ${heading} \u2014 ${loc}` : `### ${heading}`);
|
|
@@ -164042,7 +164639,7 @@ function renderSuggestedImprovements(findings, compilerEnabled) {
|
|
|
164042
164639
|
}
|
|
164043
164640
|
}
|
|
164044
164641
|
if (f.sourceSnippet && f.sourceLocation) {
|
|
164045
|
-
const snippetPath = `${
|
|
164642
|
+
const snippetPath = `${pathFromProject(f.sourceLocation.file, projectRoot)}:${f.sourceLocation.line}`;
|
|
164046
164643
|
lines.push("");
|
|
164047
164644
|
lines.push(`<details><summary>Source \u2014 \`${snippetPath}\`</summary>`);
|
|
164048
164645
|
lines.push("");
|
|
@@ -164056,10 +164653,23 @@ function renderSuggestedImprovements(findings, compilerEnabled) {
|
|
|
164056
164653
|
}
|
|
164057
164654
|
return lines.join("\n");
|
|
164058
164655
|
}
|
|
164656
|
+
function formatLocation(loc, projectRoot) {
|
|
164657
|
+
const main = `\`${pathFromProject(loc.file, projectRoot)}:${loc.line}\``;
|
|
164658
|
+
const others = loc.otherMatches ?? [];
|
|
164659
|
+
if (others.length === 0) return main;
|
|
164660
|
+
const shown = others.slice(0, MAX_OTHER_MATCHES).map((m) => `${pathFromProject(m.file, projectRoot)}:${m.line}`);
|
|
164661
|
+
const rest = others.length - shown.length;
|
|
164662
|
+
return `${main} (name also in ${shown.join(", ")}${rest > 0 ? `, +${rest} more` : ""})`;
|
|
164663
|
+
}
|
|
164059
164664
|
function shortenPath(file2) {
|
|
164060
164665
|
const parts2 = file2.replace(/\\/g, "/").split("/");
|
|
164061
164666
|
return parts2.slice(-2).join("/");
|
|
164062
164667
|
}
|
|
164668
|
+
function pathFromProject(file2, projectRoot) {
|
|
164669
|
+
const fromRoot = (0, import_path5.relative)(projectRoot, file2);
|
|
164670
|
+
const outsideRoot = !fromRoot || fromRoot.split(import_path5.sep)[0] === ".." || (0, import_path5.isAbsolute)(fromRoot);
|
|
164671
|
+
return outsideRoot ? file2 : fromRoot;
|
|
164672
|
+
}
|
|
164063
164673
|
async function writeReport(path63, content) {
|
|
164064
164674
|
try {
|
|
164065
164675
|
await import_fs4.promises.writeFile(path63, content, "utf8");
|
|
@@ -164073,6 +164683,21 @@ async function writeReport(path63, content) {
|
|
|
164073
164683
|
async function fileArtifact(store, p, kind) {
|
|
164074
164684
|
return p ? store.register({ hostPath: p, kind }) : null;
|
|
164075
164685
|
}
|
|
164686
|
+
function recordedPlatform(profile) {
|
|
164687
|
+
for (const node2 of profile?.nodes ?? []) {
|
|
164688
|
+
const match = /[?&]platform=(ios|android)\b/.exec(node2.callFrame.url);
|
|
164689
|
+
if (match) return match[1];
|
|
164690
|
+
}
|
|
164691
|
+
return void 0;
|
|
164692
|
+
}
|
|
164693
|
+
async function resolvedPath(path63) {
|
|
164694
|
+
return import_fs5.promises.realpath(path63).catch(() => path63);
|
|
164695
|
+
}
|
|
164696
|
+
async function unrelatedPaths(a, b) {
|
|
164697
|
+
const [from2, to] = await Promise.all([resolvedPath(a), resolvedPath(b)]);
|
|
164698
|
+
const outside = (rel) => rel.startsWith("..") || (0, import_path6.isAbsolute)(rel);
|
|
164699
|
+
return outside((0, import_path6.relative)(from2, to)) && outside((0, import_path6.relative)(to, from2));
|
|
164700
|
+
}
|
|
164076
164701
|
var annotationSchema = external_exports.object({
|
|
164077
164702
|
offsetMs: external_exports.coerce.number().describe(
|
|
164078
164703
|
"Milliseconds since profiling started: tapTimestampMs - startedAtEpochMs, where tapTimestampMs is the timestampMs a tap/swipe tool returned and startedAtEpochMs is the value react-profiler-start returned."
|
|
@@ -164085,7 +164710,7 @@ var zodSchema48 = external_exports.object({
|
|
|
164085
164710
|
"Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
|
|
164086
164711
|
),
|
|
164087
164712
|
project_root: external_exports.string().describe("Absolute path to the RN project root for session context detection"),
|
|
164088
|
-
platform: external_exports.enum(["ios", "android"]).
|
|
164713
|
+
platform: external_exports.enum(["ios", "android"]).optional().describe("Target platform"),
|
|
164089
164714
|
rn_version: external_exports.coerce.string().default("unknown").describe('React Native version (e.g. "0.73.4")'),
|
|
164090
164715
|
annotations: external_exports.array(annotationSchema).optional().describe(
|
|
164091
164716
|
"User actions to annotate the report's commits with: each commit shows the action that preceded it."
|
|
@@ -164134,16 +164759,21 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
|
|
|
164134
164759
|
}
|
|
164135
164760
|
let commitTree;
|
|
164136
164761
|
let unattributedByCommit;
|
|
164762
|
+
let metroRoot;
|
|
164763
|
+
let renderSummary = null;
|
|
164137
164764
|
if (sessionPaths.commitsPath) {
|
|
164138
164765
|
const onDisk = await readCommitTree(sessionPaths.commitsPath);
|
|
164139
164766
|
commitTree = { commits: onDisk.commits, hookNames: /* @__PURE__ */ new Map() };
|
|
164140
164767
|
if (onDisk.meta?.unattributedByCommit) {
|
|
164141
164768
|
unattributedByCommit = onDisk.meta.unattributedByCommit;
|
|
164142
164769
|
}
|
|
164770
|
+
metroRoot = onDisk.meta?.projectRoot || void 0;
|
|
164771
|
+
renderSummary = parseRenderSummary(onDisk.meta?.renderSummary);
|
|
164143
164772
|
} else {
|
|
164144
164773
|
commitTree = { commits: [], hookNames: /* @__PURE__ */ new Map() };
|
|
164145
164774
|
}
|
|
164146
164775
|
const { detectedArchitecture, anyCompilerOptimized, hotCommitIndices, totalReactCommits } = sessionPaths;
|
|
164776
|
+
const platform = recordedPlatform(cpuProfile) ?? params.platform;
|
|
164147
164777
|
const recordingDurationMs = cpuProfile ? (cpuProfile.endTime - cpuProfile.startTime) / 1e3 : 0;
|
|
164148
164778
|
const input2 = {
|
|
164149
164779
|
...cpuProfile !== null && { flamegraph: cpuProfile },
|
|
@@ -164151,7 +164781,7 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
|
|
|
164151
164781
|
sessionMeta: {
|
|
164152
164782
|
recordingDurationMs,
|
|
164153
164783
|
deviceId: "simulator",
|
|
164154
|
-
platform:
|
|
164784
|
+
platform: platform ?? "ios",
|
|
164155
164785
|
rnVersion: params.rn_version,
|
|
164156
164786
|
projectRoot: params.project_root,
|
|
164157
164787
|
...detectedArchitecture !== null && {
|
|
@@ -164166,7 +164796,10 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
|
|
|
164166
164796
|
...totalReactCommits !== null && {
|
|
164167
164797
|
totalReactCommits
|
|
164168
164798
|
},
|
|
164169
|
-
...unattributedByCommit && { unattributedByCommit }
|
|
164799
|
+
...unattributedByCommit && { unattributedByCommit },
|
|
164800
|
+
// [] means stop ran and no commit reached the floor; null means no commit data.
|
|
164801
|
+
noHotCommits: hotCommitIndices !== null && hotCommitIndices.length === 0,
|
|
164802
|
+
...renderSummary && { maxCommitMs: renderSummary.maxCommitMs }
|
|
164170
164803
|
}
|
|
164171
164804
|
};
|
|
164172
164805
|
const pipelineOutput = await runPipeline(input2);
|
|
@@ -164178,10 +164811,23 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
|
|
|
164178
164811
|
);
|
|
164179
164812
|
sessionPaths.cpuSampleIndexPath = indexPath;
|
|
164180
164813
|
}
|
|
164814
|
+
const needsSourceIndex = pipelineOutput.componentFindings.length > 0 || renderSummary !== null && selectFrequentRerenders(renderSummary, createComponentOriginClassifier(null)).length > 0;
|
|
164815
|
+
let sourceIndex = null;
|
|
164816
|
+
let sourceWarning;
|
|
164817
|
+
let sourceRoot = params.project_root;
|
|
164181
164818
|
try {
|
|
164182
|
-
|
|
164819
|
+
let astIndex = needsSourceIndex ? await buildAstIndexWithDiagnostics(sourceRoot, platform) : null;
|
|
164820
|
+
if (astIndex && astIndex.index.size === 0 && metroRoot && metroRoot !== sourceRoot) {
|
|
164821
|
+
const fromMetro = await buildAstIndexWithDiagnostics(metroRoot, platform);
|
|
164822
|
+
if (fromMetro.index.size > 0) {
|
|
164823
|
+
astIndex = fromMetro;
|
|
164824
|
+
sourceRoot = metroRoot;
|
|
164825
|
+
sourceWarning = `project_root "${params.project_root}" holds no components on the tool-server host, so the File column comes from Metro's project root "${metroRoot}".`;
|
|
164826
|
+
}
|
|
164827
|
+
}
|
|
164828
|
+
if (astIndex?.treeSitterAvailable) sourceIndex = astIndex.index;
|
|
164183
164829
|
for (const finding of pipelineOutput.componentFindings) {
|
|
164184
|
-
const entry = astLookupCandidates(finding.component).map((k) => astIndex
|
|
164830
|
+
const entry = astLookupCandidates(finding.component).map((k) => astIndex?.index.get(k)).find(Boolean);
|
|
164185
164831
|
if (entry) {
|
|
164186
164832
|
finding.sourceLocation = {
|
|
164187
164833
|
file: entry.file,
|
|
@@ -164189,11 +164835,24 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
|
|
|
164189
164835
|
col: entry.col,
|
|
164190
164836
|
isMemoized: entry.isMemoized,
|
|
164191
164837
|
hasUseCallback: entry.hasUseCallback,
|
|
164192
|
-
hasUseMemo: entry.hasUseMemo
|
|
164838
|
+
hasUseMemo: entry.hasUseMemo,
|
|
164839
|
+
...entry.otherMatches?.length ? { otherMatches: entry.otherMatches } : {}
|
|
164193
164840
|
};
|
|
164194
164841
|
}
|
|
164195
164842
|
}
|
|
164843
|
+
const findings = pipelineOutput.componentFindings;
|
|
164844
|
+
if (!astIndex) {
|
|
164845
|
+
} else if (!astIndex.treeSitterAvailable) {
|
|
164846
|
+
sourceWarning = "The tree-sitter parser could not be loaded, so the report gives no file for any component.";
|
|
164847
|
+
} else if (findings.length > 0 && !findings.some((f) => f.sourceLocation)) {
|
|
164848
|
+
const searched = sourceRoot === params.project_root ? "project_root" : "Metro's project root";
|
|
164849
|
+
const noFile = `No component in the report's table is defined under ${searched} "${sourceRoot}" (${astIndex.indexedFiles} source files on the tool-server host, ${astIndex.index.size} components), so the report gives no file for any of them. They may all be library components. If any of them is from the app, check project_root.`;
|
|
164850
|
+
sourceWarning = sourceWarning ? `${sourceWarning} ${noFile}` : noFile;
|
|
164851
|
+
} else if (metroRoot && await unrelatedPaths(metroRoot, sourceRoot)) {
|
|
164852
|
+
sourceWarning = `Metro serves this app from "${metroRoot}", but project_root is "${sourceRoot}", so the files in this report may be from another project.`;
|
|
164853
|
+
}
|
|
164196
164854
|
} catch {
|
|
164855
|
+
sourceWarning = "Reading the project's source failed, so the report may lack file locations.";
|
|
164197
164856
|
}
|
|
164198
164857
|
const top5 = pipelineOutput.componentFindings.slice().sort((a, b) => b.totalMs - a.totalMs).slice(0, 5);
|
|
164199
164858
|
await Promise.all(
|
|
@@ -164213,17 +164872,22 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
|
|
|
164213
164872
|
const { report, reportFile, hotCommitsTotal, hotCommitsShown } = await renderProfilingReport({
|
|
164214
164873
|
hotCommitSummaries: pipelineOutput.hotCommitSummaries,
|
|
164215
164874
|
componentFindings: pipelineOutput.componentFindings,
|
|
164216
|
-
|
|
164875
|
+
// Paths in the report count from the root the files were read from.
|
|
164876
|
+
sessionContext: { ...pipelineOutput.sessionContext, projectRoot: sourceRoot },
|
|
164217
164877
|
recordingMs: pipelineOutput.recordingMs,
|
|
164218
164878
|
anyRuntimeCompilerDetected: pipelineOutput.anyRuntimeCompilerDetected,
|
|
164219
164879
|
reactCommits: pipelineOutput.reactCommits,
|
|
164220
164880
|
annotations: params.annotations,
|
|
164221
164881
|
debugDir,
|
|
164222
|
-
|
|
164223
|
-
|
|
164882
|
+
noHotCommits: pipelineOutput.noHotCommits,
|
|
164883
|
+
noReactCommits: totalReactCommits === 0,
|
|
164884
|
+
maxCommitMs: pipelineOutput.maxCommitMs,
|
|
164885
|
+
renderSummary,
|
|
164886
|
+
componentOrigin: createComponentOriginClassifier(sourceIndex)
|
|
164224
164887
|
});
|
|
164225
164888
|
const artifacts = requireArtifacts(ctx);
|
|
164226
164889
|
const result = {
|
|
164890
|
+
...sourceWarning ? { warning: sourceWarning } : {},
|
|
164227
164891
|
report,
|
|
164228
164892
|
reportFile: await fileArtifact(artifacts, reportFile, "react-profile-report"),
|
|
164229
164893
|
hotCommitsTotal,
|
|
@@ -164235,7 +164899,8 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
|
|
|
164235
164899
|
}
|
|
164236
164900
|
};
|
|
164237
164901
|
if (hotCommitIndices === null) {
|
|
164238
|
-
|
|
164902
|
+
const noCommits = "No React commit data \u2014 the DevTools hook may not be present in this runtime, or the commit-capture script failed to inject (check react-profiler-start output for errors).";
|
|
164903
|
+
result["warning"] = sourceWarning ? `${noCommits} ${sourceWarning}` : noCommits;
|
|
164239
164904
|
}
|
|
164240
164905
|
return result;
|
|
164241
164906
|
}
|
|
@@ -164259,6 +164924,11 @@ Returns found: false if the component is not found in user-owned code (e.g. live
|
|
|
164259
164924
|
When several files define a component with the same name (e.g. platform variants like List.tsx and List.web.tsx), returns the primary match and lists the rest under otherMatches[] (file/line/col). Check it before assuming the returned file is the one you meant.`,
|
|
164260
164925
|
zodSchema: zodSchema49,
|
|
164261
164926
|
readOnly: true,
|
|
164927
|
+
// react-profiler-analyze runs the same AST lookup for each component in its
|
|
164928
|
+
// table (file, line and other matches) and adds the source of the located ones
|
|
164929
|
+
// among the top five; agents read any other file themselves. The SDK still
|
|
164930
|
+
// calls it.
|
|
164931
|
+
hideFromMcp: true,
|
|
164262
164932
|
interaction: {
|
|
164263
164933
|
startedMsg: ({ params }) => `Finding source for ${params.component_name}`,
|
|
164264
164934
|
completedMsg: ({ params, result }) => `${result.found ? "Found" : "Could not find"} source for ${params.component_name}`,
|
|
@@ -164373,11 +165043,11 @@ function buildHotspots(nodes, samples, timeDeltas, topN2, reactOnly) {
|
|
|
164373
165043
|
function renderMarkdownTable(entries) {
|
|
164374
165044
|
if (entries.length === 0) return "_No hotspots found._";
|
|
164375
165045
|
const header = "| Function | Location | Self (ms) | Total (ms) | Self % |";
|
|
164376
|
-
const
|
|
165046
|
+
const sep10 = "|---|---|---|---|---|";
|
|
164377
165047
|
const rows = entries.map(
|
|
164378
165048
|
(e) => `| \`${e.function}\` | ${e.url || "\u2014"} | ${e.self_ms} | ${e.total_ms} | ${e.self_pct} |`
|
|
164379
165049
|
);
|
|
164380
|
-
return [header,
|
|
165050
|
+
return [header, sep10, ...rows].join("\n");
|
|
164381
165051
|
}
|
|
164382
165052
|
var zodSchema50 = external_exports.object({
|
|
164383
165053
|
port: metroPortField,
|
|
@@ -164396,6 +165066,11 @@ Use when you specifically need to investigate JS CPU hotspots that are NOT tied
|
|
|
164396
165066
|
Fails if react-profiler-stop has not been called or no CPU profile is stored.`,
|
|
164397
165067
|
zodSchema: zodSchema50,
|
|
164398
165068
|
readOnly: true,
|
|
165069
|
+
// Agents use profiler-cpu-query mode top_functions, which reads the same
|
|
165070
|
+
// profile with per-sample intervals and idle filtered out, and has the same
|
|
165071
|
+
// react_only filter and Self % column. The SDK and the e2e-full suite still
|
|
165072
|
+
// call it.
|
|
165073
|
+
hideFromMcp: true,
|
|
164399
165074
|
interaction: {
|
|
164400
165075
|
startedMsg: () => "Summarizing React CPU profile",
|
|
164401
165076
|
completedMsg: () => "Summarized React CPU profile",
|
|
@@ -164490,11 +165165,11 @@ function renderMarkdownTable2(entries) {
|
|
|
164490
165165
|
if (entries.length === 0)
|
|
164491
165166
|
return "_No render data found. Ensure React DevTools global hook is present._";
|
|
164492
165167
|
const header = "| Component | Instances | Total (ms) | Self Base (ms) |";
|
|
164493
|
-
const
|
|
165168
|
+
const sep10 = "|---|---|---|---|";
|
|
164494
165169
|
const rows = entries.map(
|
|
164495
165170
|
(e) => `| \`${e.component}\` | ${e.renderCount} | ${e.totalActualDuration_ms.toFixed(2)} | ${e.selfBaseDuration_ms.toFixed(2)} |`
|
|
164496
165171
|
);
|
|
164497
|
-
return [header,
|
|
165172
|
+
return [header, sep10, ...rows].join("\n");
|
|
164498
165173
|
}
|
|
164499
165174
|
var zodSchema51 = external_exports.object({
|
|
164500
165175
|
port: metroPortField,
|
|
@@ -164511,6 +165186,11 @@ Use when you want a quick look at what is mounted in a live connected app, witho
|
|
|
164511
165186
|
Fails if the React DevTools hook is not present in the runtime or the app is not connected.`,
|
|
164512
165187
|
zodSchema: zodSchema51,
|
|
164513
165188
|
readOnly: true,
|
|
165189
|
+
// It walks only the top 30 fiber levels, above the screens of a real app
|
|
165190
|
+
// (Bluesky's first feed item sits at depth 446), and its totals double-count
|
|
165191
|
+
// nested instances. Agents read render counts from a profiling session
|
|
165192
|
+
// (profiler-commit-query mode=render_counts); HTTP and SDK callers keep it.
|
|
165193
|
+
hideFromMcp: true,
|
|
164514
165194
|
interaction: {
|
|
164515
165195
|
startedMsg: () => "Reading React render activity",
|
|
164516
165196
|
completedMsg: () => "Read React render activity",
|
|
@@ -164969,7 +165649,7 @@ init_capability();
|
|
|
164969
165649
|
var import_child_process4 = require("child_process");
|
|
164970
165650
|
init_src2();
|
|
164971
165651
|
var import_fs9 = require("fs");
|
|
164972
|
-
var
|
|
165652
|
+
var import_node_fs17 = require("node:fs");
|
|
164973
165653
|
var path40 = __toESM(require("path"));
|
|
164974
165654
|
init_external_devices();
|
|
164975
165655
|
|
|
@@ -166154,7 +166834,7 @@ async function renderNativeProfilerReport(input2) {
|
|
|
166154
166834
|
const status = Object.keys(exportErrors).length > 0 ? "analysis_failed" : "ok";
|
|
166155
166835
|
const cpuHotspotsCount = payload.bottlenecks.filter((b) => b.type === "cpu_hotspot").length;
|
|
166156
166836
|
const uiHangsCount = payload.bottlenecks.filter((b) => b.type === "ui_hang").length;
|
|
166157
|
-
const fullReport = bottlenecksTotal === 0 ?
|
|
166837
|
+
const fullReport = bottlenecksTotal === 0 ? renderAllClear(payload, exportErrors, freshnessNote, cpuDiagnostic, leaksRecorded) : renderFullReport(
|
|
166158
166838
|
payload,
|
|
166159
166839
|
exportErrors,
|
|
166160
166840
|
{
|
|
@@ -166168,7 +166848,7 @@ async function renderNativeProfilerReport(input2) {
|
|
|
166168
166848
|
);
|
|
166169
166849
|
const reportFile = traceFile ? deriveReportPath(traceFile) : null;
|
|
166170
166850
|
const wroteFile = reportFile ? await writeReport2(reportFile, fullReport) : false;
|
|
166171
|
-
const inlineReport = bottlenecksTotal === 0 ?
|
|
166851
|
+
const inlineReport = bottlenecksTotal === 0 ? renderAllClear(payload, exportErrors, freshnessNote, cpuDiagnostic, leaksRecorded) : renderFullReport(
|
|
166172
166852
|
payload,
|
|
166173
166853
|
exportErrors,
|
|
166174
166854
|
{
|
|
@@ -166229,7 +166909,7 @@ function renderTraceProcessorUnavailable(err) {
|
|
|
166229
166909
|
function reportTitle(payload) {
|
|
166230
166910
|
return payload.metadata.platform.toLowerCase() === "android" ? "Android Perfetto Analysis" : "iOS Instruments Analysis";
|
|
166231
166911
|
}
|
|
166232
|
-
function
|
|
166912
|
+
function renderAllClear(payload, exportErrors, freshnessNote, cpuDiagnostic, leaksRecorded) {
|
|
166233
166913
|
const traceName = payload.metadata.traceFile ? `\`${path39.basename(payload.metadata.traceFile)}\`` : "unknown";
|
|
166234
166914
|
const lines = [
|
|
166235
166915
|
`# ${reportTitle(payload)}`,
|
|
@@ -166640,7 +167320,7 @@ function resolveDefaultTemplatePath() {
|
|
|
166640
167320
|
)
|
|
166641
167321
|
];
|
|
166642
167322
|
for (const candidate of candidates) {
|
|
166643
|
-
if ((0,
|
|
167323
|
+
if ((0, import_node_fs17.existsSync)(candidate)) return candidate;
|
|
166644
167324
|
}
|
|
166645
167325
|
throw new FailureError(
|
|
166646
167326
|
`Argent.tracetemplate not found. Looked in:
|
|
@@ -169195,7 +169875,7 @@ var import_fs16 = require("fs");
|
|
|
169195
169875
|
var import_child_process6 = require("child_process");
|
|
169196
169876
|
var import_util15 = require("util");
|
|
169197
169877
|
var import_os2 = __toESM(require("os"));
|
|
169198
|
-
var
|
|
169878
|
+
var import_path7 = __toESM(require("path"));
|
|
169199
169879
|
|
|
169200
169880
|
// ../tool-server/src/tools/screen-recording/watermark-asset.ts
|
|
169201
169881
|
var WATERMARK_PNG_WIDTH = 900;
|
|
@@ -169297,7 +169977,7 @@ function buildWatermarkGraph(dims, opts) {
|
|
|
169297
169977
|
].join(";");
|
|
169298
169978
|
}
|
|
169299
169979
|
async function writeLogoTemp() {
|
|
169300
|
-
const file2 =
|
|
169980
|
+
const file2 = import_path7.default.join(
|
|
169301
169981
|
import_os2.default.tmpdir(),
|
|
169302
169982
|
`argent-watermark-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.png`
|
|
169303
169983
|
);
|
|
@@ -170312,7 +170992,469 @@ Fails if no recording (running or finished-but-unretrieved) exists for the given
|
|
|
170312
170992
|
// ../tool-server/src/tools/profiler/query/profiler-cpu-query.ts
|
|
170313
170993
|
init_zod();
|
|
170314
170994
|
init_src2();
|
|
170995
|
+
|
|
170996
|
+
// ../tool-server/src/tools/profiler/query/profiler-commit-query.ts
|
|
170997
|
+
init_zod();
|
|
170998
|
+
init_src2();
|
|
170999
|
+
async function getCommitData(port, deviceId) {
|
|
171000
|
+
const sessionPaths = getCachedProfilerPaths(port, deviceId);
|
|
171001
|
+
if (!sessionPaths?.commitsPath) {
|
|
171002
|
+
throw new FailureError(
|
|
171003
|
+
"No commit data stored. Run react-profiler-start \u2192 exercise app \u2192 react-profiler-stop first.",
|
|
171004
|
+
{
|
|
171005
|
+
error_code: FAILURE_CODES.PROFILER_DATA_NOT_LOADED,
|
|
171006
|
+
failure_stage: "profiler_commit_query_load_data",
|
|
171007
|
+
failure_area: "tool_server",
|
|
171008
|
+
error_kind: "validation"
|
|
171009
|
+
}
|
|
171010
|
+
);
|
|
171011
|
+
}
|
|
171012
|
+
const onDisk = await readCommitTree(sessionPaths.commitsPath);
|
|
171013
|
+
return {
|
|
171014
|
+
commits: Array.isArray(onDisk.commits) ? onDisk.commits : [],
|
|
171015
|
+
hookNames: /* @__PURE__ */ new Map(),
|
|
171016
|
+
renderSummary: parseRenderSummary(onDisk.meta?.renderSummary),
|
|
171017
|
+
totalReactCommits: onDisk.meta?.totalReactCommits ?? sessionPaths.totalReactCommits ?? null
|
|
171018
|
+
};
|
|
171019
|
+
}
|
|
171020
|
+
var NO_COMMITS_RECORDED = "_No React commits were recorded in this session, so there is no commit data to query. Interact with the app while the profiler records._";
|
|
171021
|
+
function renderNoStoredCommits(data) {
|
|
171022
|
+
const summary = data.renderSummary;
|
|
171023
|
+
const total = summary?.totalCommits ?? data.totalReactCommits;
|
|
171024
|
+
if (total === 0) return NO_COMMITS_RECORDED;
|
|
171025
|
+
const peak = summary && summary.maxCommitMs > 0 ? ` (peak ${formatPeakCommit(summary.maxCommitMs)})` : "";
|
|
171026
|
+
const count2 = total !== null ? `its ${formatCount(total)} React commits` : "its React commits";
|
|
171027
|
+
const unnamedSlowCommit = summary !== null && hasUnnamedSlowCommit(summary);
|
|
171028
|
+
const lines = [
|
|
171029
|
+
unnamedSlowCommit ? `_No per-commit detail is stored for this session: among ${count2}, those of 16ms or more${peak} have no component that could be named, so react-profiler-stop kept none of them. This is not a missing session._` : `_No per-commit detail is stored for this session: none of ${count2} reached 16ms${peak}, so react-profiler-stop kept none of them. This is not a missing session._`,
|
|
171030
|
+
""
|
|
171031
|
+
];
|
|
171032
|
+
if (summary) {
|
|
171033
|
+
lines.push(
|
|
171034
|
+
`**React render time:** ${formatRenderTime(summary)}.`,
|
|
171035
|
+
...unnamedSlowCommit ? ["A commit was slow, but it has no breakdown."] : [],
|
|
171036
|
+
"",
|
|
171037
|
+
"Run `profiler-commit-query` mode=`render_counts` for render counts per component over all commits."
|
|
171038
|
+
);
|
|
171039
|
+
} else {
|
|
171040
|
+
lines.push(
|
|
171041
|
+
"This session has no render summary, usually because an older version saved it, so mode=`render_counts` has no data for it either. Re-profile to get counts over all commits."
|
|
171042
|
+
);
|
|
171043
|
+
}
|
|
171044
|
+
return lines.join("\n");
|
|
171045
|
+
}
|
|
171046
|
+
function renderRenderCounts(summary, componentName, topN2) {
|
|
171047
|
+
if (!summary) {
|
|
171048
|
+
return "_This session has no render summary, usually because an older version saved it. Re-profile to get render counts over all commits; the other modes still cover the commits of 16ms or more._";
|
|
171049
|
+
}
|
|
171050
|
+
if (summary.totalCommits === 0) return NO_COMMITS_RECORDED;
|
|
171051
|
+
if (summary.components.length === 0) {
|
|
171052
|
+
return `**React render time:** ${formatRenderTime(summary)}
|
|
171053
|
+
|
|
171054
|
+
No component in this session could be named, so there is nothing to list.`;
|
|
171055
|
+
}
|
|
171056
|
+
const seconds = Math.max(summary.recordingMs / 1e3, 1e-3);
|
|
171057
|
+
let rows = summary.components;
|
|
171058
|
+
let heading = `## Render Counts \u2014 all ${formatCount(summary.totalCommits)} commits`;
|
|
171059
|
+
const lines = [];
|
|
171060
|
+
if (componentName) {
|
|
171061
|
+
const resolution = resolveComponentName(
|
|
171062
|
+
componentName,
|
|
171063
|
+
summary.components.map((c) => c.name)
|
|
171064
|
+
);
|
|
171065
|
+
if (resolution.kind === "ambiguous" || resolution.kind === "missing") {
|
|
171066
|
+
return renderSummaryNameMiss(resolution, summary);
|
|
171067
|
+
}
|
|
171068
|
+
rows = summary.components.filter((c) => c.name === resolution.rawName);
|
|
171069
|
+
heading = `## Render Counts for \`${resolution.rawName}\` \u2014 all ${formatCount(summary.totalCommits)} commits`;
|
|
171070
|
+
const note = describeResolution(resolution);
|
|
171071
|
+
if (note) lines.push(note, "");
|
|
171072
|
+
}
|
|
171073
|
+
const shown = rows.slice(0, topN2);
|
|
171074
|
+
lines.unshift(heading, "");
|
|
171075
|
+
lines.push(
|
|
171076
|
+
`**React render time:** ${formatRenderTime(summary)}`,
|
|
171077
|
+
`**Fiber renders:** ${formatCount(summary.fiberRenders)} (${formatCount(summary.rerenders)} re-renders, ${formatCount(summary.mounts)} mounts, ${formatCount(summary.untrackedRenders)} with no change data) across ${formatCount(summary.components.length)} components`,
|
|
171078
|
+
"",
|
|
171079
|
+
"Every component that rendered, library components included, by re-render self time. The other modes see only commits of 16ms or more and their neighbours; these counts cover every commit.",
|
|
171080
|
+
"",
|
|
171081
|
+
"| Component | Re-renders | Per second | Re-render commits | Self total (ms) | Self ms/s | Max (ms) | Mounts | No change data | Reason |",
|
|
171082
|
+
"|---|---|---|---|---|---|---|---|---|---|"
|
|
171083
|
+
);
|
|
171084
|
+
for (const c of shown) {
|
|
171085
|
+
lines.push(
|
|
171086
|
+
`| \`${c.name}\` | ${formatCount(c.rerenders)} | ${(c.rerenders / seconds).toFixed(1)} | ${formatCount(c.rerenderCommits)} | ${c.rerenderSelfMs.toFixed(1)} | ${(c.rerenderSelfMs / seconds).toFixed(1)} | ${c.maxRerenderSelfMs.toFixed(1)} | ${formatCount(c.mounts)} | ${formatCount(c.untrackedRenders)} | ${formatRenderSummaryReason(c)} |`
|
|
171087
|
+
);
|
|
171088
|
+
}
|
|
171089
|
+
if (rows.length > shown.length) {
|
|
171090
|
+
lines.push("", `_Showing ${shown.length} of ${rows.length} components; raise top_n for more._`);
|
|
171091
|
+
}
|
|
171092
|
+
return lines.join("\n");
|
|
171093
|
+
}
|
|
171094
|
+
function formatReason2(commit) {
|
|
171095
|
+
const cd = commit.changeDescription;
|
|
171096
|
+
if (!cd) return "unknown";
|
|
171097
|
+
if (cd.isFirstMount) return "mount";
|
|
171098
|
+
const reason2 = deriveReason(cd, commit.hookTypes ?? null);
|
|
171099
|
+
const parts2 = [reason2];
|
|
171100
|
+
if (cd.props && cd.props.length > 0) {
|
|
171101
|
+
parts2.push(`[${cd.props.slice(0, 3).join(", ")}]`);
|
|
171102
|
+
}
|
|
171103
|
+
if (cd.hooks && cd.hooks.length > 0 && commit.hookTypes) {
|
|
171104
|
+
const hookNames = cd.hooks.slice(0, 3).map((i) => commit.hookTypes?.[i] ?? `hook[${i}]`);
|
|
171105
|
+
parts2.push(`[${hookNames.join(", ")}]`);
|
|
171106
|
+
}
|
|
171107
|
+
if (cd.context) parts2.push("(context)");
|
|
171108
|
+
return parts2.join(" ");
|
|
171109
|
+
}
|
|
171110
|
+
function renderByComponent(commits, componentName, topN2, summary = null) {
|
|
171111
|
+
const resolution = resolveComponentName(
|
|
171112
|
+
componentName,
|
|
171113
|
+
commits.map((c) => c.componentName)
|
|
171114
|
+
);
|
|
171115
|
+
if (resolution.kind === "missing" && summary) {
|
|
171116
|
+
return renderNameOutsideStoredCommits(componentName, summary);
|
|
171117
|
+
}
|
|
171118
|
+
if (resolution.kind === "ambiguous" || resolution.kind === "missing") {
|
|
171119
|
+
return renderComponentNameMiss(resolution, {
|
|
171120
|
+
fiberRenders: commits.length,
|
|
171121
|
+
commits: new Set(commits.map((c) => c.commitIndex)).size
|
|
171122
|
+
});
|
|
171123
|
+
}
|
|
171124
|
+
const resolvedName = resolution.rawName;
|
|
171125
|
+
const resolutionNote = describeStoredResolution(resolution, summary);
|
|
171126
|
+
const matching = commits.filter((c) => c.componentName === resolvedName);
|
|
171127
|
+
if (matching.length === 0) {
|
|
171128
|
+
return `_Component \`${resolvedName}\` not found in commit data._`;
|
|
171129
|
+
}
|
|
171130
|
+
const byCommit = /* @__PURE__ */ new Map();
|
|
171131
|
+
for (const c of matching) {
|
|
171132
|
+
let group = byCommit.get(c.commitIndex);
|
|
171133
|
+
if (!group) {
|
|
171134
|
+
group = [];
|
|
171135
|
+
byCommit.set(c.commitIndex, group);
|
|
171136
|
+
}
|
|
171137
|
+
group.push(c);
|
|
171138
|
+
}
|
|
171139
|
+
const sortedCommits = [...byCommit.entries()].map(([idx, entries]) => ({
|
|
171140
|
+
commitIndex: idx,
|
|
171141
|
+
instances: entries.length,
|
|
171142
|
+
totalDuration: entries.reduce((s, e) => s + e.actualDuration, 0),
|
|
171143
|
+
commitDuration: entries[0].commitDuration,
|
|
171144
|
+
timestamp: entries[0].timestamp,
|
|
171145
|
+
reason: formatReason2(entries[0]),
|
|
171146
|
+
parentName: entries[0].parentName ?? "\u2014"
|
|
171147
|
+
})).sort((a, b) => b.totalDuration - a.totalDuration).slice(0, topN2);
|
|
171148
|
+
const lines = [
|
|
171149
|
+
`## Commits for \`${resolvedName}\``,
|
|
171150
|
+
"",
|
|
171151
|
+
...resolutionNote ? [resolutionNote, ""] : [],
|
|
171152
|
+
`**Total occurrences:** ${matching.length} across ${byCommit.size} commits${storedOnlyNote(resolvedName, matching.filter((c) => c.didRender).length, summary)}`,
|
|
171153
|
+
"",
|
|
171154
|
+
"| Commit | Instances | Duration (ms) | Commit Total (ms) | Time (ms) | Reason | Parent |",
|
|
171155
|
+
"|---|---|---|---|---|---|---|"
|
|
171156
|
+
];
|
|
171157
|
+
for (const c of sortedCommits) {
|
|
171158
|
+
lines.push(
|
|
171159
|
+
`| #${c.commitIndex} | ${c.instances} | ${c.totalDuration.toFixed(1)} | ${c.commitDuration.toFixed(1)} | ${c.timestamp.toFixed(0)} | ${c.reason} | \`${c.parentName}\` |`
|
|
171160
|
+
);
|
|
171161
|
+
}
|
|
171162
|
+
return lines.join("\n");
|
|
171163
|
+
}
|
|
171164
|
+
function unstoredCommits(data) {
|
|
171165
|
+
const stored = new Set(data.commits.map((c) => c.commitIndex)).size;
|
|
171166
|
+
if (data.totalReactCommits === null || data.totalReactCommits <= stored) return null;
|
|
171167
|
+
return {
|
|
171168
|
+
stored,
|
|
171169
|
+
total: data.totalReactCommits,
|
|
171170
|
+
counts: data.renderSummary ? " mode=`render_counts` counts them over the whole session, without timing." : ""
|
|
171171
|
+
};
|
|
171172
|
+
}
|
|
171173
|
+
function renderEmptyTimeRange(data, start2, end) {
|
|
171174
|
+
const range = `${start2.toFixed(0)}ms \u2192 ${end.toFixed(0)}ms`;
|
|
171175
|
+
const unstored = unstoredCommits(data);
|
|
171176
|
+
if (!unstored) {
|
|
171177
|
+
return `_No commits found in the range ${range}._`;
|
|
171178
|
+
}
|
|
171179
|
+
return `_No stored commits in the range ${range}: only commits of 16ms or more and their neighbours are stored, so commits under 16ms in this range are not listed.${unstored.counts}_`;
|
|
171180
|
+
}
|
|
171181
|
+
function renderByTimeRange(data, start2, end, topN2) {
|
|
171182
|
+
const { commits } = data;
|
|
171183
|
+
const matching = commits.filter((c) => c.timestamp >= start2 && c.timestamp <= end);
|
|
171184
|
+
if (matching.length === 0) return renderEmptyTimeRange(data, start2, end);
|
|
171185
|
+
const byCommit = /* @__PURE__ */ new Map();
|
|
171186
|
+
for (const c of matching) {
|
|
171187
|
+
let group = byCommit.get(c.commitIndex);
|
|
171188
|
+
if (!group) {
|
|
171189
|
+
group = [];
|
|
171190
|
+
byCommit.set(c.commitIndex, group);
|
|
171191
|
+
}
|
|
171192
|
+
group.push(c);
|
|
171193
|
+
}
|
|
171194
|
+
const summaries = [...byCommit.entries()].map(([idx, entries]) => ({
|
|
171195
|
+
commitIndex: idx,
|
|
171196
|
+
componentCount: new Set(entries.map((e) => e.componentName)).size,
|
|
171197
|
+
commitDuration: entries[0].commitDuration,
|
|
171198
|
+
timestamp: entries[0].timestamp,
|
|
171199
|
+
topComponents: getTopComponents(entries, 5)
|
|
171200
|
+
})).sort((a, b) => b.commitDuration - a.commitDuration).slice(0, topN2);
|
|
171201
|
+
const unstored = unstoredCommits(data);
|
|
171202
|
+
const lines = [
|
|
171203
|
+
`## Commits in ${start2.toFixed(0)}ms \u2192 ${end.toFixed(0)}ms`,
|
|
171204
|
+
"",
|
|
171205
|
+
`**Commits:** ${byCommit.size} **Fiber renders:** ${matching.length}`,
|
|
171206
|
+
"",
|
|
171207
|
+
...unstored ? [
|
|
171208
|
+
`_Only commits of 16ms or more and their neighbours are stored (${formatCount(unstored.stored)} of ${formatCount(unstored.total)} commits in this session), so this range can hold commits that are not listed.${unstored.counts}_`,
|
|
171209
|
+
""
|
|
171210
|
+
] : []
|
|
171211
|
+
];
|
|
171212
|
+
for (const s of summaries) {
|
|
171213
|
+
lines.push(
|
|
171214
|
+
`### Commit #${s.commitIndex} \u2014 ${s.commitDuration.toFixed(1)}ms (t=${s.timestamp.toFixed(0)}ms, ${s.componentCount} components)`
|
|
171215
|
+
);
|
|
171216
|
+
lines.push("");
|
|
171217
|
+
for (const comp of s.topComponents) {
|
|
171218
|
+
lines.push(
|
|
171219
|
+
`- \`${comp.name}\` \xD7${comp.count} ${comp.totalDuration.toFixed(1)}ms \u2014 ${comp.reason}`
|
|
171220
|
+
);
|
|
171221
|
+
}
|
|
171222
|
+
lines.push("");
|
|
171223
|
+
}
|
|
171224
|
+
return lines.join("\n");
|
|
171225
|
+
}
|
|
171226
|
+
function renderByIndex(commits, commitIndex, topN2) {
|
|
171227
|
+
const matching = commits.filter((c) => c.commitIndex === commitIndex);
|
|
171228
|
+
if (matching.length === 0) {
|
|
171229
|
+
return `_Commit #${commitIndex} not found in stored data._`;
|
|
171230
|
+
}
|
|
171231
|
+
const commitDuration = matching[0].commitDuration;
|
|
171232
|
+
const timestamp = matching[0].timestamp;
|
|
171233
|
+
const sorted = [...matching].sort((a, b) => b.actualDuration - a.actualDuration);
|
|
171234
|
+
const shown = topN2 !== void 0 ? sorted.slice(0, topN2) : sorted;
|
|
171235
|
+
const hidden = sorted.length - shown.length;
|
|
171236
|
+
const lines = [
|
|
171237
|
+
`## Commit #${commitIndex} \u2014 ${hidden > 0 ? "Top Fibers" : "Full Detail"}`,
|
|
171238
|
+
"",
|
|
171239
|
+
`**Time:** ${timestamp.toFixed(0)}ms **Duration:** ${commitDuration.toFixed(1)}ms **Fibers:** ${matching.length}${hidden > 0 ? ` (showing ${shown.length})` : ""}`,
|
|
171240
|
+
"",
|
|
171241
|
+
"| Component | Duration (ms) | Self (ms) | Reason | Parent | Compiler |",
|
|
171242
|
+
"|---|---|---|---|---|---|"
|
|
171243
|
+
];
|
|
171244
|
+
for (const c of shown) {
|
|
171245
|
+
const reason2 = formatReason2(c);
|
|
171246
|
+
const parent = c.parentName ?? "\u2014";
|
|
171247
|
+
const compiler = c.isCompilerOptimized ? "\u2713" : "";
|
|
171248
|
+
lines.push(
|
|
171249
|
+
`| \`${c.componentName}\` | ${c.actualDuration.toFixed(1)} | ${c.selfDuration.toFixed(1)} | ${reason2} | \`${parent}\` | ${compiler} |`
|
|
171250
|
+
);
|
|
171251
|
+
}
|
|
171252
|
+
if (hidden > 0) {
|
|
171253
|
+
lines.push("");
|
|
171254
|
+
lines.push(
|
|
171255
|
+
`_Showing the ${shown.length} costliest of ${sorted.length} fibers \u2014 ${hidden} cheaper fibers hidden. Note these are fibers, not components: the full set covers ${new Set(sorted.map((c) => c.componentName)).size} distinct components and this view covers ${new Set(shown.map((c) => c.componentName)).size}. Omit top_n for everything._`
|
|
171256
|
+
);
|
|
171257
|
+
}
|
|
171258
|
+
const withRootCause = matching.find((c) => c.rootCauseParent);
|
|
171259
|
+
if (withRootCause?.rootCauseChain && withRootCause.rootCauseChain.length > 0) {
|
|
171260
|
+
lines.push("");
|
|
171261
|
+
lines.push(
|
|
171262
|
+
`**Root cause chain:** ${withRootCause.rootCauseChain.map((n) => `\`${n}\``).join(" \u2192 ")} \u2192 \`${withRootCause.rootCauseParent}\``
|
|
171263
|
+
);
|
|
171264
|
+
if (withRootCause.rootCauseReason) {
|
|
171265
|
+
lines.push(`**Root cause reason:** ${withRootCause.rootCauseReason}`);
|
|
171266
|
+
}
|
|
171267
|
+
}
|
|
171268
|
+
return lines.join("\n");
|
|
171269
|
+
}
|
|
171270
|
+
function renderCascadeTree(commits, commitIndex) {
|
|
171271
|
+
const matching = commits.filter((c) => c.commitIndex === commitIndex);
|
|
171272
|
+
if (matching.length === 0) {
|
|
171273
|
+
return `_Commit #${commitIndex} not found in stored data._`;
|
|
171274
|
+
}
|
|
171275
|
+
const children = /* @__PURE__ */ new Map();
|
|
171276
|
+
const roots = [];
|
|
171277
|
+
for (const c of matching) {
|
|
171278
|
+
const parentName = c.parentName;
|
|
171279
|
+
if (!parentName || !matching.some((m) => m.componentName === parentName)) {
|
|
171280
|
+
roots.push(c);
|
|
171281
|
+
} else {
|
|
171282
|
+
let list = children.get(parentName);
|
|
171283
|
+
if (!list) {
|
|
171284
|
+
list = [];
|
|
171285
|
+
children.set(parentName, list);
|
|
171286
|
+
}
|
|
171287
|
+
list.push(c);
|
|
171288
|
+
}
|
|
171289
|
+
}
|
|
171290
|
+
const lines = [`## Cascade Tree \u2014 Commit #${commitIndex}`, ""];
|
|
171291
|
+
const rendered = /* @__PURE__ */ new Set();
|
|
171292
|
+
function renderNode(name, depth) {
|
|
171293
|
+
if (rendered.has(`${name}:${depth}`)) return;
|
|
171294
|
+
rendered.add(`${name}:${depth}`);
|
|
171295
|
+
const instances = matching.filter((c) => c.componentName === name);
|
|
171296
|
+
const totalSelf = instances.reduce((s, c) => s + c.selfDuration, 0);
|
|
171297
|
+
const count2 = instances.length;
|
|
171298
|
+
const reason2 = instances[0] ? formatReason2(instances[0]) : "";
|
|
171299
|
+
const indent = " ".repeat(depth);
|
|
171300
|
+
const countStr = count2 > 1 ? ` \xD7${count2}` : "";
|
|
171301
|
+
lines.push(`${indent}- \`${name}\`${countStr} self=${totalSelf.toFixed(1)}ms \u2014 ${reason2}`);
|
|
171302
|
+
const childCommits = children.get(name) ?? [];
|
|
171303
|
+
const childNames = new Set(childCommits.map((c) => c.componentName));
|
|
171304
|
+
for (const childName of childNames) {
|
|
171305
|
+
renderNode(childName, depth + 1);
|
|
171306
|
+
}
|
|
171307
|
+
}
|
|
171308
|
+
const rootNames = new Set(roots.map((r) => r.componentName));
|
|
171309
|
+
for (const name of rootNames) {
|
|
171310
|
+
renderNode(name, 0);
|
|
171311
|
+
}
|
|
171312
|
+
return lines.join("\n");
|
|
171313
|
+
}
|
|
171314
|
+
function getTopComponents(entries, topN2) {
|
|
171315
|
+
const byName = /* @__PURE__ */ new Map();
|
|
171316
|
+
for (const e of entries) {
|
|
171317
|
+
const existing = byName.get(e.componentName);
|
|
171318
|
+
if (existing) {
|
|
171319
|
+
existing.count++;
|
|
171320
|
+
existing.totalDuration += e.actualDuration;
|
|
171321
|
+
} else {
|
|
171322
|
+
byName.set(e.componentName, { count: 1, totalDuration: e.actualDuration, first: e });
|
|
171323
|
+
}
|
|
171324
|
+
}
|
|
171325
|
+
return [...byName.entries()].sort((a, b) => b[1].totalDuration - a[1].totalDuration).slice(0, topN2).map(([name, { count: count2, totalDuration, first }]) => ({
|
|
171326
|
+
name,
|
|
171327
|
+
count: count2,
|
|
171328
|
+
totalDuration,
|
|
171329
|
+
reason: formatReason2(first)
|
|
171330
|
+
}));
|
|
171331
|
+
}
|
|
171332
|
+
var timeRangeSchema = external_exports.object({
|
|
171333
|
+
start: external_exports.coerce.number().describe("Start of range in ms"),
|
|
171334
|
+
end: external_exports.coerce.number().describe("End of range in ms")
|
|
171335
|
+
});
|
|
171336
|
+
var zodSchema58 = external_exports.object({
|
|
171337
|
+
port: metroPortField,
|
|
171338
|
+
device_id: metroDeviceIdParam(
|
|
171339
|
+
"Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
|
|
171340
|
+
),
|
|
171341
|
+
mode: external_exports.enum(["by_component", "by_time_range", "by_index", "cascade_tree", "render_counts"]).describe("Query mode; see Modes in the tool description."),
|
|
171342
|
+
component_name: external_exports.string().optional().describe("Component name; optional for render_counts, which it narrows to one component"),
|
|
171343
|
+
time_range_ms: timeRangeSchema.optional().describe("Time range in ms since profiling started, the clock this tool prints"),
|
|
171344
|
+
commit_index: external_exports.coerce.number().int().optional().describe("Commit index"),
|
|
171345
|
+
top_n: external_exports.coerce.number().int().positive().optional().describe(
|
|
171346
|
+
"Max results to return. Defaults to 20 for by_component / by_time_range, which count commits, and render_counts, which counts components. by_index counts individual fibers and returns all of them unless this is set; a small cap there can show less than the analyze report it is meant to expand on."
|
|
171347
|
+
)
|
|
171348
|
+
});
|
|
171349
|
+
var profilerCommitQueryTool = {
|
|
171350
|
+
id: "profiler-commit-query",
|
|
171351
|
+
description: `Query React commit data for iterative investigation of render performance.
|
|
171352
|
+
Modes:
|
|
171353
|
+
- by_component: All commits where component_name rendered, with causes and durations.
|
|
171354
|
+
- by_time_range: What happened in time_range_ms.
|
|
171355
|
+
- by_index: Full detail dump of the commit at commit_index (all components, props changed, parent cascade).
|
|
171356
|
+
- cascade_tree: Parent-child cascade tree for the commit at commit_index, showing who triggered whom.
|
|
171357
|
+
- render_counts: Re-render count, rate and self time per component over ALL commits, including those under 16ms that the other modes cannot see. Library components included.
|
|
171358
|
+
Use when drilling into specific components or time windows after react-profiler-analyze.
|
|
171359
|
+
Returns a markdown table or tree of commit data matching the requested mode.
|
|
171360
|
+
Fails if react-profiler-stop has not been called.`,
|
|
171361
|
+
zodSchema: zodSchema58,
|
|
171362
|
+
readOnly: true,
|
|
171363
|
+
interaction: {
|
|
171364
|
+
startedMsg: ({ params }) => `Querying React commits ${params.mode.replace(/^by_/, "by ").replaceAll("_", " ")}`,
|
|
171365
|
+
completedMsg: ({ params }) => `Queried React commits ${params.mode.replace(/^by_/, "by ").replaceAll("_", " ")}`,
|
|
171366
|
+
failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to query React commits: ${failureSignal2.error_code}`
|
|
171367
|
+
},
|
|
171368
|
+
// Reads React commit data captured via the React DevTools backend.
|
|
171369
|
+
capability: RN_ONLY_TOOL_CAPABILITY,
|
|
171370
|
+
services: () => ({}),
|
|
171371
|
+
async execute(_services, params) {
|
|
171372
|
+
const commitTree = await getCommitData(metroPort(params), params.device_id);
|
|
171373
|
+
if (params.mode === "render_counts") {
|
|
171374
|
+
return renderRenderCounts(
|
|
171375
|
+
commitTree.renderSummary,
|
|
171376
|
+
params.component_name,
|
|
171377
|
+
params.top_n ?? 20
|
|
171378
|
+
);
|
|
171379
|
+
}
|
|
171380
|
+
if (commitTree.commits.length === 0) return renderNoStoredCommits(commitTree);
|
|
171381
|
+
switch (params.mode) {
|
|
171382
|
+
case "by_component": {
|
|
171383
|
+
if (!params.component_name) {
|
|
171384
|
+
throw new FailureError("by_component mode requires the component_name parameter.", {
|
|
171385
|
+
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
171386
|
+
failure_stage: "profiler_commit_query_params",
|
|
171387
|
+
failure_area: "tool_server",
|
|
171388
|
+
error_kind: "validation"
|
|
171389
|
+
});
|
|
171390
|
+
}
|
|
171391
|
+
return renderByComponent(
|
|
171392
|
+
commitTree.commits,
|
|
171393
|
+
params.component_name,
|
|
171394
|
+
params.top_n ?? 20,
|
|
171395
|
+
commitTree.renderSummary
|
|
171396
|
+
);
|
|
171397
|
+
}
|
|
171398
|
+
case "by_time_range": {
|
|
171399
|
+
if (!params.time_range_ms) {
|
|
171400
|
+
throw new FailureError("by_time_range mode requires the time_range_ms parameter.", {
|
|
171401
|
+
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
171402
|
+
failure_stage: "profiler_commit_query_params",
|
|
171403
|
+
failure_area: "tool_server",
|
|
171404
|
+
error_kind: "validation"
|
|
171405
|
+
});
|
|
171406
|
+
}
|
|
171407
|
+
return renderByTimeRange(
|
|
171408
|
+
commitTree,
|
|
171409
|
+
params.time_range_ms.start,
|
|
171410
|
+
params.time_range_ms.end,
|
|
171411
|
+
params.top_n ?? 20
|
|
171412
|
+
);
|
|
171413
|
+
}
|
|
171414
|
+
case "by_index": {
|
|
171415
|
+
if (params.commit_index == null) {
|
|
171416
|
+
throw new FailureError("by_index mode requires the commit_index parameter.", {
|
|
171417
|
+
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
171418
|
+
failure_stage: "profiler_commit_query_params",
|
|
171419
|
+
failure_area: "tool_server",
|
|
171420
|
+
error_kind: "validation"
|
|
171421
|
+
});
|
|
171422
|
+
}
|
|
171423
|
+
return renderByIndex(commitTree.commits, params.commit_index, params.top_n);
|
|
171424
|
+
}
|
|
171425
|
+
case "cascade_tree": {
|
|
171426
|
+
if (params.commit_index == null) {
|
|
171427
|
+
throw new FailureError("cascade_tree mode requires the commit_index parameter.", {
|
|
171428
|
+
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
171429
|
+
failure_stage: "profiler_commit_query_params",
|
|
171430
|
+
failure_area: "tool_server",
|
|
171431
|
+
error_kind: "validation"
|
|
171432
|
+
});
|
|
171433
|
+
}
|
|
171434
|
+
return renderCascadeTree(commitTree.commits, params.commit_index);
|
|
171435
|
+
}
|
|
171436
|
+
default:
|
|
171437
|
+
throw new FailureError(`Unknown mode: ${params.mode}`, {
|
|
171438
|
+
error_code: FAILURE_CODES.PROFILER_QUERY_MODE_INVALID,
|
|
171439
|
+
failure_stage: "profiler_commit_query_mode",
|
|
171440
|
+
failure_area: "tool_server",
|
|
171441
|
+
error_kind: "validation"
|
|
171442
|
+
});
|
|
171443
|
+
}
|
|
171444
|
+
}
|
|
171445
|
+
};
|
|
171446
|
+
|
|
171447
|
+
// ../tool-server/src/tools/profiler/query/profiler-cpu-query.ts
|
|
170315
171448
|
var import_fs19 = require("fs");
|
|
171449
|
+
async function readStoredCommits(sessionPaths) {
|
|
171450
|
+
if (!sessionPaths.commitsPath) return null;
|
|
171451
|
+
const onDisk = await readCommitTree(sessionPaths.commitsPath);
|
|
171452
|
+
return {
|
|
171453
|
+
commits: onDisk.commits,
|
|
171454
|
+
renderSummary: parseRenderSummary(onDisk.meta?.renderSummary),
|
|
171455
|
+
totalReactCommits: onDisk.meta?.totalReactCommits ?? sessionPaths.totalReactCommits ?? null
|
|
171456
|
+
};
|
|
171457
|
+
}
|
|
170316
171458
|
async function getIndex(sessionPaths) {
|
|
170317
171459
|
if (!sessionPaths?.cpuProfilePath) {
|
|
170318
171460
|
throw new FailureError(
|
|
@@ -170329,22 +171471,15 @@ async function getIndex(sessionPaths) {
|
|
|
170329
171471
|
try {
|
|
170330
171472
|
const raw = JSON.parse(await import_fs19.promises.readFile(sessionPaths.cpuSampleIndexPath, "utf8"));
|
|
170331
171473
|
const index = deserializeCpuSampleIndex(raw);
|
|
170332
|
-
|
|
170333
|
-
if (sessionPaths.commitsPath) {
|
|
170334
|
-
const onDisk = await readCommitTree(sessionPaths.commitsPath);
|
|
170335
|
-
commitTree2 = { commits: onDisk.commits };
|
|
170336
|
-
}
|
|
170337
|
-
return { index, commitTree: commitTree2 };
|
|
171474
|
+
return { index, commitTree: await readStoredCommits(sessionPaths) };
|
|
170338
171475
|
} catch {
|
|
170339
171476
|
}
|
|
170340
171477
|
}
|
|
170341
171478
|
const cpuProfile = await readCpuProfile(sessionPaths.cpuProfilePath);
|
|
170342
|
-
|
|
170343
|
-
|
|
170344
|
-
|
|
170345
|
-
|
|
170346
|
-
}
|
|
170347
|
-
return { index: buildCpuSampleIndex(cpuProfile), commitTree };
|
|
171479
|
+
return {
|
|
171480
|
+
index: buildCpuSampleIndex(cpuProfile),
|
|
171481
|
+
commitTree: await readStoredCommits(sessionPaths)
|
|
171482
|
+
};
|
|
170348
171483
|
}
|
|
170349
171484
|
function explainEmptyWindow(res, startMs, endMs) {
|
|
170350
171485
|
const range = `${res.sampleRangeMs.start.toFixed(1)}\u2013${res.sampleRangeMs.end.toFixed(1)}ms`;
|
|
@@ -170360,12 +171495,18 @@ function explainEmptyWindow(res, startMs, endMs) {
|
|
|
170360
171495
|
}
|
|
170361
171496
|
return `_No CPU samples fell inside ${window2} (${(endMs - startMs).toFixed(1)}ms wide), although it lies within the recorded range (${range}). The sampler runs roughly every ${res.medianIntervalMs > 0 ? res.medianIntervalMs.toFixed(1) : "13"}ms, so a window this narrow can contain none at all. **Absence of samples is not evidence that this commit was cheap.** Widen the window, or use \`mode=component_cpu\`._`;
|
|
170362
171497
|
}
|
|
170363
|
-
function
|
|
171498
|
+
function isReactComponentName(name) {
|
|
171499
|
+
return /^[A-Z][A-Za-z0-9]*$/.test(name);
|
|
171500
|
+
}
|
|
171501
|
+
function coverageNote(res, startMs, endMs, reactOnly) {
|
|
170364
171502
|
const widthMs = endMs - startMs;
|
|
170365
171503
|
const lines = [
|
|
170366
171504
|
`**Window:** ${startMs.toFixed(1)}ms \u2192 ${endMs.toFixed(1)}ms (${widthMs.toFixed(1)}ms)`,
|
|
170367
|
-
`**Samples:** ${res.samplesInWindow} covering ${res.coveredMs.toFixed(1)}ms` + (res.idleMs > 0 ? `, of which ${res.idleMs.toFixed(1)}ms idle` : "") + ` \u2014 sampling interval ~${res.medianIntervalMs.toFixed(1)}ms. Self-times sum to sampled coverage, not to the window width.`
|
|
171505
|
+
`**Samples:** ${res.samplesInWindow} covering ${res.coveredMs.toFixed(1)}ms` + (res.idleMs > 0 ? `, of which ${res.idleMs.toFixed(1)}ms idle` : "") + ` \u2014 sampling interval ~${res.medianIntervalMs.toFixed(1)}ms. Self-times sum to sampled coverage, not to the window width. Self % is a share of that coverage.`
|
|
170368
171506
|
];
|
|
171507
|
+
if (reactOnly) {
|
|
171508
|
+
lines.push("**Filter:** React components only (PascalCase function names)");
|
|
171509
|
+
}
|
|
170369
171510
|
if (widthMs > 0 && widthMs < 3 * res.medianIntervalMs) {
|
|
170370
171511
|
lines.push(
|
|
170371
171512
|
`> This window is narrower than ~3 sampling intervals, so every figure carries \xB11 sample (\u2248${res.medianIntervalMs.toFixed(1)}ms).`
|
|
@@ -170378,23 +171519,28 @@ function coverageNote(res, startMs, endMs) {
|
|
|
170378
171519
|
}
|
|
170379
171520
|
return lines.join("\n\n");
|
|
170380
171521
|
}
|
|
170381
|
-
function renderTopFunctions(index, topN2, startMs, endMs) {
|
|
171522
|
+
function renderTopFunctions(index, topN2, startMs, endMs, reactOnly = false) {
|
|
170382
171523
|
const windowStart = startMs ?? index.intervalStartsMs[0] ?? 0;
|
|
170383
171524
|
const windowEnd = endMs ?? index.timestampsMs[index.timestampsMs.length - 1] ?? 0;
|
|
170384
|
-
const res = queryCpuWindow(index, windowStart, windowEnd, topN2);
|
|
171525
|
+
const res = queryCpuWindow(index, windowStart, windowEnd, reactOnly ? Infinity : topN2);
|
|
170385
171526
|
if (res.hotspots.length === 0) return explainEmptyWindow(res, windowStart, windowEnd);
|
|
170386
|
-
const
|
|
170387
|
-
|
|
170388
|
-
|
|
171527
|
+
const hotspots = reactOnly ? res.hotspots.filter((hs) => isReactComponentName(hs.name)).slice(0, topN2) : res.hotspots;
|
|
171528
|
+
if (hotspots.length === 0) {
|
|
171529
|
+
return `_No function sampled in ${windowStart.toFixed(1)}\u2013${windowEnd.toFixed(1)}ms has a PascalCase (React component) name. Query again without react_only to see the JS work._`;
|
|
171530
|
+
}
|
|
171531
|
+
const header = "| Function | Self (ms) | Self % | Total (ms) | Location |";
|
|
171532
|
+
const sep10 = "|---|---|---|---|---|";
|
|
171533
|
+
const rows = hotspots.map((hs) => {
|
|
170389
171534
|
const loc = hs.url ? `${shortenUrl(hs.url)}${hs.lineNumber != null ? `:${hs.lineNumber}` : ""}` : "\u2014";
|
|
170390
|
-
|
|
171535
|
+
const selfPct = res.coveredMs > 0 ? `${(hs.selfMs / res.coveredMs * 100).toFixed(1)}%` : "\u2014";
|
|
171536
|
+
return `| \`${hs.name}\` | ${hs.selfMs} | ${selfPct} | ${hs.totalMs} | ${loc} |`;
|
|
170391
171537
|
});
|
|
170392
171538
|
return `## CPU Hotspots
|
|
170393
171539
|
|
|
170394
|
-
${coverageNote(res, windowStart, windowEnd)}
|
|
171540
|
+
${coverageNote(res, windowStart, windowEnd, reactOnly)}
|
|
170395
171541
|
|
|
170396
171542
|
${header}
|
|
170397
|
-
${
|
|
171543
|
+
${sep10}
|
|
170398
171544
|
${rows.join("\n")}`;
|
|
170399
171545
|
}
|
|
170400
171546
|
function renderCallTree(index, functionName, topN2, includeCallers) {
|
|
@@ -170492,13 +171638,25 @@ function renderCallTree(index, functionName, topN2, includeCallers) {
|
|
|
170492
171638
|
return lines.join("\n");
|
|
170493
171639
|
}
|
|
170494
171640
|
function renderComponentCpu(index, commitTree, componentName, topN2) {
|
|
170495
|
-
if (!commitTree
|
|
171641
|
+
if (!commitTree) {
|
|
170496
171642
|
return "_No commit data available. Run react-profiler-analyze first._";
|
|
170497
171643
|
}
|
|
171644
|
+
if (commitTree.commits.length === 0) {
|
|
171645
|
+
return `${renderNoStoredCommits(commitTree)}
|
|
171646
|
+
|
|
171647
|
+
Use mode=\`top_functions\` for JS CPU.`;
|
|
171648
|
+
}
|
|
170498
171649
|
const resolution = resolveComponentName(
|
|
170499
171650
|
componentName,
|
|
170500
171651
|
commitTree.commits.map((c) => c.componentName)
|
|
170501
171652
|
);
|
|
171653
|
+
if (resolution.kind === "missing" && commitTree.renderSummary) {
|
|
171654
|
+
return renderNameOutsideStoredCommits(
|
|
171655
|
+
componentName,
|
|
171656
|
+
commitTree.renderSummary,
|
|
171657
|
+
" Use mode=`top_functions` for JS CPU over the whole session."
|
|
171658
|
+
);
|
|
171659
|
+
}
|
|
170502
171660
|
if (resolution.kind === "ambiguous" || resolution.kind === "missing") {
|
|
170503
171661
|
return renderComponentNameMiss(resolution, {
|
|
170504
171662
|
fiberRenders: commitTree.commits.length,
|
|
@@ -170506,7 +171664,7 @@ function renderComponentCpu(index, commitTree, componentName, topN2) {
|
|
|
170506
171664
|
});
|
|
170507
171665
|
}
|
|
170508
171666
|
const resolvedName = resolution.rawName;
|
|
170509
|
-
const resolutionNote =
|
|
171667
|
+
const resolutionNote = describeStoredResolution(resolution, commitTree.renderSummary);
|
|
170510
171668
|
const componentCommits = commitTree.commits.filter((c) => c.componentName === resolvedName);
|
|
170511
171669
|
if (componentCommits.length === 0) {
|
|
170512
171670
|
return `_Component \`${resolvedName}\` not found in commit data._`;
|
|
@@ -170548,7 +171706,12 @@ function renderComponentCpu(index, commitTree, componentName, topN2) {
|
|
|
170548
171706
|
`## CPU During \`${resolvedName}\` Commits`,
|
|
170549
171707
|
"",
|
|
170550
171708
|
...resolutionNote ? [resolutionNote, ""] : [],
|
|
170551
|
-
`**Commits:** ${commitWindows.size} **Total commit time:** ${totalCommitMs.toFixed(1)}ms
|
|
171709
|
+
`**Commits:** ${commitWindows.size} **Total commit time:** ${totalCommitMs.toFixed(1)}ms` + storedOnlyNote(
|
|
171710
|
+
resolvedName,
|
|
171711
|
+
componentCommits.filter((c) => c.didRender).length,
|
|
171712
|
+
commitTree.renderSummary,
|
|
171713
|
+
"`profiler-commit-query` mode=`render_counts`"
|
|
171714
|
+
),
|
|
170552
171715
|
"",
|
|
170553
171716
|
"| Function | Self (ms) | Total (ms) | Location |",
|
|
170554
171717
|
"|---|---|---|---|"
|
|
@@ -170569,7 +171732,7 @@ var timeWindowSchema = external_exports.object({
|
|
|
170569
171732
|
start: external_exports.coerce.number().describe("Start of window in ms"),
|
|
170570
171733
|
end: external_exports.coerce.number().describe("End of window in ms")
|
|
170571
171734
|
});
|
|
170572
|
-
var
|
|
171735
|
+
var zodSchema59 = external_exports.object({
|
|
170573
171736
|
port: metroPortField,
|
|
170574
171737
|
device_id: metroDeviceIdParam(
|
|
170575
171738
|
"Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
|
|
@@ -170581,7 +171744,10 @@ var zodSchema58 = external_exports.object({
|
|
|
170581
171744
|
component_name: external_exports.string().optional().describe("Component name"),
|
|
170582
171745
|
function_name: external_exports.string().optional().describe("Function name"),
|
|
170583
171746
|
top_n: external_exports.coerce.number().int().positive().default(15).describe("Number of results to return"),
|
|
170584
|
-
include_callers: external_exports.boolean().default(false).describe("Also show callers of the function")
|
|
171747
|
+
include_callers: external_exports.boolean().default(false).describe("Also show callers of the function"),
|
|
171748
|
+
react_only: external_exports.boolean().default(false).describe(
|
|
171749
|
+
"top_functions and time_window: list only React component functions (PascalCase names)"
|
|
171750
|
+
)
|
|
170585
171751
|
});
|
|
170586
171752
|
var profilerCpuQueryTool = {
|
|
170587
171753
|
id: "profiler-cpu-query",
|
|
@@ -170590,14 +171756,15 @@ Modes:
|
|
|
170590
171756
|
- top_functions: Global CPU hotspots ranked by self-time. Optional time_window_ms to filter.
|
|
170591
171757
|
- time_window: CPU breakdown for time_window_ms (e.g. during a slow commit or hang).
|
|
170592
171758
|
- call_tree: For a given function_name, show its callees, and its callers with include_callers.
|
|
170593
|
-
- component_cpu: For a given component_name, aggregate CPU activity across
|
|
171759
|
+
- component_cpu: For a given component_name, aggregate CPU activity across its stored commits.
|
|
170594
171760
|
In top_functions and time_window, self-times are the summed sampling intervals of the samples that
|
|
170595
171761
|
landed in the window, so they measure sampled coverage rather than the window's width and do not
|
|
170596
171762
|
change if you widen the query. Their tables state how many samples they cover and how much was idle.
|
|
171763
|
+
Each row is one call path, so a function can have several rows and top_n counts rows.
|
|
170597
171764
|
Use when investigating JS CPU hotspots or correlating CPU cost with specific components.
|
|
170598
171765
|
Returns a markdown table of CPU hotspots, call tree, or per-component CPU breakdown.
|
|
170599
171766
|
Fails if no CPU profile is stored; run react-profiler-stop (and ideally react-profiler-analyze) first.`,
|
|
170600
|
-
zodSchema:
|
|
171767
|
+
zodSchema: zodSchema59,
|
|
170601
171768
|
readOnly: true,
|
|
170602
171769
|
interaction: {
|
|
170603
171770
|
startedMsg: ({ params }) => `Querying CPU profile by ${params.mode.replaceAll("_", " ")}`,
|
|
@@ -170627,7 +171794,8 @@ Fails if no CPU profile is stored; run react-profiler-stop (and ideally react-pr
|
|
|
170627
171794
|
index,
|
|
170628
171795
|
params.top_n,
|
|
170629
171796
|
params.time_window_ms?.start,
|
|
170630
|
-
params.time_window_ms?.end
|
|
171797
|
+
params.time_window_ms?.end,
|
|
171798
|
+
params.react_only
|
|
170631
171799
|
);
|
|
170632
171800
|
case "time_window": {
|
|
170633
171801
|
if (!params.time_window_ms) {
|
|
@@ -170642,7 +171810,8 @@ Fails if no CPU profile is stored; run react-profiler-stop (and ideally react-pr
|
|
|
170642
171810
|
index,
|
|
170643
171811
|
params.top_n,
|
|
170644
171812
|
params.time_window_ms.start,
|
|
170645
|
-
params.time_window_ms.end
|
|
171813
|
+
params.time_window_ms.end,
|
|
171814
|
+
params.react_only
|
|
170646
171815
|
);
|
|
170647
171816
|
}
|
|
170648
171817
|
case "call_tree": {
|
|
@@ -170678,351 +171847,6 @@ Fails if no CPU profile is stored; run react-profiler-stop (and ideally react-pr
|
|
|
170678
171847
|
}
|
|
170679
171848
|
};
|
|
170680
171849
|
|
|
170681
|
-
// ../tool-server/src/tools/profiler/query/profiler-commit-query.ts
|
|
170682
|
-
init_zod();
|
|
170683
|
-
init_src2();
|
|
170684
|
-
async function getCommitTree(port, deviceId) {
|
|
170685
|
-
const sessionPaths = getCachedProfilerPaths(port, deviceId);
|
|
170686
|
-
if (!sessionPaths?.commitsPath) {
|
|
170687
|
-
throw new FailureError(
|
|
170688
|
-
"No commit data stored. Run react-profiler-start \u2192 exercise app \u2192 react-profiler-stop first.",
|
|
170689
|
-
{
|
|
170690
|
-
error_code: FAILURE_CODES.PROFILER_DATA_NOT_LOADED,
|
|
170691
|
-
failure_stage: "profiler_commit_query_load_data",
|
|
170692
|
-
failure_area: "tool_server",
|
|
170693
|
-
error_kind: "validation"
|
|
170694
|
-
}
|
|
170695
|
-
);
|
|
170696
|
-
}
|
|
170697
|
-
const onDisk = await readCommitTree(sessionPaths.commitsPath);
|
|
170698
|
-
if (onDisk.commits.length === 0) {
|
|
170699
|
-
throw new FailureError(
|
|
170700
|
-
"No commit data stored. Run react-profiler-start \u2192 exercise app \u2192 react-profiler-stop first.",
|
|
170701
|
-
{
|
|
170702
|
-
error_code: FAILURE_CODES.PROFILER_DATA_NOT_LOADED,
|
|
170703
|
-
failure_stage: "profiler_commit_query_load_data",
|
|
170704
|
-
failure_area: "tool_server",
|
|
170705
|
-
error_kind: "validation"
|
|
170706
|
-
}
|
|
170707
|
-
);
|
|
170708
|
-
}
|
|
170709
|
-
return { commits: onDisk.commits, hookNames: /* @__PURE__ */ new Map() };
|
|
170710
|
-
}
|
|
170711
|
-
function formatReason2(commit) {
|
|
170712
|
-
const cd = commit.changeDescription;
|
|
170713
|
-
if (!cd) return "unknown";
|
|
170714
|
-
if (cd.isFirstMount) return "mount";
|
|
170715
|
-
const reason2 = deriveReason(cd, commit.hookTypes ?? null);
|
|
170716
|
-
const parts2 = [reason2];
|
|
170717
|
-
if (cd.props && cd.props.length > 0) {
|
|
170718
|
-
parts2.push(`[${cd.props.slice(0, 3).join(", ")}]`);
|
|
170719
|
-
}
|
|
170720
|
-
if (cd.hooks && cd.hooks.length > 0 && commit.hookTypes) {
|
|
170721
|
-
const hookNames = cd.hooks.slice(0, 3).map((i) => commit.hookTypes?.[i] ?? `hook[${i}]`);
|
|
170722
|
-
parts2.push(`[${hookNames.join(", ")}]`);
|
|
170723
|
-
}
|
|
170724
|
-
if (cd.context) parts2.push("(context)");
|
|
170725
|
-
return parts2.join(" ");
|
|
170726
|
-
}
|
|
170727
|
-
function renderByComponent(commits, componentName, topN2) {
|
|
170728
|
-
const resolution = resolveComponentName(
|
|
170729
|
-
componentName,
|
|
170730
|
-
commits.map((c) => c.componentName)
|
|
170731
|
-
);
|
|
170732
|
-
if (resolution.kind === "ambiguous" || resolution.kind === "missing") {
|
|
170733
|
-
return renderComponentNameMiss(resolution, {
|
|
170734
|
-
fiberRenders: commits.length,
|
|
170735
|
-
commits: new Set(commits.map((c) => c.commitIndex)).size
|
|
170736
|
-
});
|
|
170737
|
-
}
|
|
170738
|
-
const resolvedName = resolution.rawName;
|
|
170739
|
-
const resolutionNote = describeResolution(resolution);
|
|
170740
|
-
const matching = commits.filter((c) => c.componentName === resolvedName);
|
|
170741
|
-
if (matching.length === 0) {
|
|
170742
|
-
return `_Component \`${resolvedName}\` not found in commit data._`;
|
|
170743
|
-
}
|
|
170744
|
-
const byCommit = /* @__PURE__ */ new Map();
|
|
170745
|
-
for (const c of matching) {
|
|
170746
|
-
let group = byCommit.get(c.commitIndex);
|
|
170747
|
-
if (!group) {
|
|
170748
|
-
group = [];
|
|
170749
|
-
byCommit.set(c.commitIndex, group);
|
|
170750
|
-
}
|
|
170751
|
-
group.push(c);
|
|
170752
|
-
}
|
|
170753
|
-
const sortedCommits = [...byCommit.entries()].map(([idx, entries]) => ({
|
|
170754
|
-
commitIndex: idx,
|
|
170755
|
-
instances: entries.length,
|
|
170756
|
-
totalDuration: entries.reduce((s, e) => s + e.actualDuration, 0),
|
|
170757
|
-
commitDuration: entries[0].commitDuration,
|
|
170758
|
-
timestamp: entries[0].timestamp,
|
|
170759
|
-
reason: formatReason2(entries[0]),
|
|
170760
|
-
parentName: entries[0].parentName ?? "\u2014"
|
|
170761
|
-
})).sort((a, b) => b.totalDuration - a.totalDuration).slice(0, topN2);
|
|
170762
|
-
const lines = [
|
|
170763
|
-
`## Commits for \`${resolvedName}\``,
|
|
170764
|
-
"",
|
|
170765
|
-
...resolutionNote ? [resolutionNote, ""] : [],
|
|
170766
|
-
`**Total occurrences:** ${matching.length} across ${byCommit.size} commits`,
|
|
170767
|
-
"",
|
|
170768
|
-
"| Commit | Instances | Duration (ms) | Commit Total (ms) | Time (ms) | Reason | Parent |",
|
|
170769
|
-
"|---|---|---|---|---|---|---|"
|
|
170770
|
-
];
|
|
170771
|
-
for (const c of sortedCommits) {
|
|
170772
|
-
lines.push(
|
|
170773
|
-
`| #${c.commitIndex} | ${c.instances} | ${c.totalDuration.toFixed(1)} | ${c.commitDuration.toFixed(1)} | ${c.timestamp.toFixed(0)} | ${c.reason} | \`${c.parentName}\` |`
|
|
170774
|
-
);
|
|
170775
|
-
}
|
|
170776
|
-
return lines.join("\n");
|
|
170777
|
-
}
|
|
170778
|
-
function renderByTimeRange(commits, start2, end, topN2) {
|
|
170779
|
-
const matching = commits.filter((c) => c.timestamp >= start2 && c.timestamp <= end);
|
|
170780
|
-
if (matching.length === 0) {
|
|
170781
|
-
return `_No commits found in the range ${start2.toFixed(0)}ms \u2192 ${end.toFixed(0)}ms._`;
|
|
170782
|
-
}
|
|
170783
|
-
const byCommit = /* @__PURE__ */ new Map();
|
|
170784
|
-
for (const c of matching) {
|
|
170785
|
-
let group = byCommit.get(c.commitIndex);
|
|
170786
|
-
if (!group) {
|
|
170787
|
-
group = [];
|
|
170788
|
-
byCommit.set(c.commitIndex, group);
|
|
170789
|
-
}
|
|
170790
|
-
group.push(c);
|
|
170791
|
-
}
|
|
170792
|
-
const summaries = [...byCommit.entries()].map(([idx, entries]) => ({
|
|
170793
|
-
commitIndex: idx,
|
|
170794
|
-
componentCount: new Set(entries.map((e) => e.componentName)).size,
|
|
170795
|
-
commitDuration: entries[0].commitDuration,
|
|
170796
|
-
timestamp: entries[0].timestamp,
|
|
170797
|
-
topComponents: getTopComponents(entries, 5)
|
|
170798
|
-
})).sort((a, b) => b.commitDuration - a.commitDuration).slice(0, topN2);
|
|
170799
|
-
const lines = [
|
|
170800
|
-
`## Commits in ${start2.toFixed(0)}ms \u2192 ${end.toFixed(0)}ms`,
|
|
170801
|
-
"",
|
|
170802
|
-
`**Commits:** ${byCommit.size} **Fiber renders:** ${matching.length}`,
|
|
170803
|
-
""
|
|
170804
|
-
];
|
|
170805
|
-
for (const s of summaries) {
|
|
170806
|
-
lines.push(
|
|
170807
|
-
`### Commit #${s.commitIndex} \u2014 ${s.commitDuration.toFixed(1)}ms (t=${s.timestamp.toFixed(0)}ms, ${s.componentCount} components)`
|
|
170808
|
-
);
|
|
170809
|
-
lines.push("");
|
|
170810
|
-
for (const comp of s.topComponents) {
|
|
170811
|
-
lines.push(
|
|
170812
|
-
`- \`${comp.name}\` \xD7${comp.count} ${comp.totalDuration.toFixed(1)}ms \u2014 ${comp.reason}`
|
|
170813
|
-
);
|
|
170814
|
-
}
|
|
170815
|
-
lines.push("");
|
|
170816
|
-
}
|
|
170817
|
-
return lines.join("\n");
|
|
170818
|
-
}
|
|
170819
|
-
function renderByIndex(commits, commitIndex, topN2) {
|
|
170820
|
-
const matching = commits.filter((c) => c.commitIndex === commitIndex);
|
|
170821
|
-
if (matching.length === 0) {
|
|
170822
|
-
return `_Commit #${commitIndex} not found in stored data._`;
|
|
170823
|
-
}
|
|
170824
|
-
const commitDuration = matching[0].commitDuration;
|
|
170825
|
-
const timestamp = matching[0].timestamp;
|
|
170826
|
-
const sorted = [...matching].sort((a, b) => b.actualDuration - a.actualDuration);
|
|
170827
|
-
const shown = topN2 !== void 0 ? sorted.slice(0, topN2) : sorted;
|
|
170828
|
-
const hidden = sorted.length - shown.length;
|
|
170829
|
-
const lines = [
|
|
170830
|
-
`## Commit #${commitIndex} \u2014 ${hidden > 0 ? "Top Fibers" : "Full Detail"}`,
|
|
170831
|
-
"",
|
|
170832
|
-
`**Time:** ${timestamp.toFixed(0)}ms **Duration:** ${commitDuration.toFixed(1)}ms **Fibers:** ${matching.length}${hidden > 0 ? ` (showing ${shown.length})` : ""}`,
|
|
170833
|
-
"",
|
|
170834
|
-
"| Component | Duration (ms) | Self (ms) | Reason | Parent | Compiler |",
|
|
170835
|
-
"|---|---|---|---|---|---|"
|
|
170836
|
-
];
|
|
170837
|
-
for (const c of shown) {
|
|
170838
|
-
const reason2 = formatReason2(c);
|
|
170839
|
-
const parent = c.parentName ?? "\u2014";
|
|
170840
|
-
const compiler = c.isCompilerOptimized ? "\u2713" : "";
|
|
170841
|
-
lines.push(
|
|
170842
|
-
`| \`${c.componentName}\` | ${c.actualDuration.toFixed(1)} | ${c.selfDuration.toFixed(1)} | ${reason2} | \`${parent}\` | ${compiler} |`
|
|
170843
|
-
);
|
|
170844
|
-
}
|
|
170845
|
-
if (hidden > 0) {
|
|
170846
|
-
lines.push("");
|
|
170847
|
-
lines.push(
|
|
170848
|
-
`_Showing the ${shown.length} costliest of ${sorted.length} fibers \u2014 ${hidden} cheaper fibers hidden. Note these are fibers, not components: the full set covers ${new Set(sorted.map((c) => c.componentName)).size} distinct components and this view covers ${new Set(shown.map((c) => c.componentName)).size}. Omit top_n for everything._`
|
|
170849
|
-
);
|
|
170850
|
-
}
|
|
170851
|
-
const withRootCause = matching.find((c) => c.rootCauseParent);
|
|
170852
|
-
if (withRootCause?.rootCauseChain && withRootCause.rootCauseChain.length > 0) {
|
|
170853
|
-
lines.push("");
|
|
170854
|
-
lines.push(
|
|
170855
|
-
`**Root cause chain:** ${withRootCause.rootCauseChain.map((n) => `\`${n}\``).join(" \u2192 ")} \u2192 \`${withRootCause.rootCauseParent}\``
|
|
170856
|
-
);
|
|
170857
|
-
if (withRootCause.rootCauseReason) {
|
|
170858
|
-
lines.push(`**Root cause reason:** ${withRootCause.rootCauseReason}`);
|
|
170859
|
-
}
|
|
170860
|
-
}
|
|
170861
|
-
return lines.join("\n");
|
|
170862
|
-
}
|
|
170863
|
-
function renderCascadeTree(commits, commitIndex) {
|
|
170864
|
-
const matching = commits.filter((c) => c.commitIndex === commitIndex);
|
|
170865
|
-
if (matching.length === 0) {
|
|
170866
|
-
return `_Commit #${commitIndex} not found in stored data._`;
|
|
170867
|
-
}
|
|
170868
|
-
const children = /* @__PURE__ */ new Map();
|
|
170869
|
-
const roots = [];
|
|
170870
|
-
for (const c of matching) {
|
|
170871
|
-
const parentName = c.parentName;
|
|
170872
|
-
if (!parentName || !matching.some((m) => m.componentName === parentName)) {
|
|
170873
|
-
roots.push(c);
|
|
170874
|
-
} else {
|
|
170875
|
-
let list = children.get(parentName);
|
|
170876
|
-
if (!list) {
|
|
170877
|
-
list = [];
|
|
170878
|
-
children.set(parentName, list);
|
|
170879
|
-
}
|
|
170880
|
-
list.push(c);
|
|
170881
|
-
}
|
|
170882
|
-
}
|
|
170883
|
-
const lines = [`## Cascade Tree \u2014 Commit #${commitIndex}`, ""];
|
|
170884
|
-
const rendered = /* @__PURE__ */ new Set();
|
|
170885
|
-
function renderNode(name, depth) {
|
|
170886
|
-
if (rendered.has(`${name}:${depth}`)) return;
|
|
170887
|
-
rendered.add(`${name}:${depth}`);
|
|
170888
|
-
const instances = matching.filter((c) => c.componentName === name);
|
|
170889
|
-
const totalSelf = instances.reduce((s, c) => s + c.selfDuration, 0);
|
|
170890
|
-
const count2 = instances.length;
|
|
170891
|
-
const reason2 = instances[0] ? formatReason2(instances[0]) : "";
|
|
170892
|
-
const indent = " ".repeat(depth);
|
|
170893
|
-
const countStr = count2 > 1 ? ` \xD7${count2}` : "";
|
|
170894
|
-
lines.push(`${indent}- \`${name}\`${countStr} self=${totalSelf.toFixed(1)}ms \u2014 ${reason2}`);
|
|
170895
|
-
const childCommits = children.get(name) ?? [];
|
|
170896
|
-
const childNames = new Set(childCommits.map((c) => c.componentName));
|
|
170897
|
-
for (const childName of childNames) {
|
|
170898
|
-
renderNode(childName, depth + 1);
|
|
170899
|
-
}
|
|
170900
|
-
}
|
|
170901
|
-
const rootNames = new Set(roots.map((r) => r.componentName));
|
|
170902
|
-
for (const name of rootNames) {
|
|
170903
|
-
renderNode(name, 0);
|
|
170904
|
-
}
|
|
170905
|
-
return lines.join("\n");
|
|
170906
|
-
}
|
|
170907
|
-
function getTopComponents(entries, topN2) {
|
|
170908
|
-
const byName = /* @__PURE__ */ new Map();
|
|
170909
|
-
for (const e of entries) {
|
|
170910
|
-
const existing = byName.get(e.componentName);
|
|
170911
|
-
if (existing) {
|
|
170912
|
-
existing.count++;
|
|
170913
|
-
existing.totalDuration += e.actualDuration;
|
|
170914
|
-
} else {
|
|
170915
|
-
byName.set(e.componentName, { count: 1, totalDuration: e.actualDuration, first: e });
|
|
170916
|
-
}
|
|
170917
|
-
}
|
|
170918
|
-
return [...byName.entries()].sort((a, b) => b[1].totalDuration - a[1].totalDuration).slice(0, topN2).map(([name, { count: count2, totalDuration, first }]) => ({
|
|
170919
|
-
name,
|
|
170920
|
-
count: count2,
|
|
170921
|
-
totalDuration,
|
|
170922
|
-
reason: formatReason2(first)
|
|
170923
|
-
}));
|
|
170924
|
-
}
|
|
170925
|
-
var timeRangeSchema = external_exports.object({
|
|
170926
|
-
start: external_exports.coerce.number().describe("Start of range in ms"),
|
|
170927
|
-
end: external_exports.coerce.number().describe("End of range in ms")
|
|
170928
|
-
});
|
|
170929
|
-
var zodSchema59 = external_exports.object({
|
|
170930
|
-
port: metroPortField,
|
|
170931
|
-
device_id: metroDeviceIdParam(
|
|
170932
|
-
"Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
|
|
170933
|
-
),
|
|
170934
|
-
mode: external_exports.enum(["by_component", "by_time_range", "by_index", "cascade_tree"]).describe("Query mode; see Modes in the tool description."),
|
|
170935
|
-
component_name: external_exports.string().optional().describe("Component name"),
|
|
170936
|
-
time_range_ms: timeRangeSchema.optional().describe("Time range in ms since profiling started, the clock this tool prints"),
|
|
170937
|
-
commit_index: external_exports.coerce.number().int().optional().describe("Commit index"),
|
|
170938
|
-
top_n: external_exports.coerce.number().int().positive().optional().describe(
|
|
170939
|
-
"Max results to return. Defaults to 20 for by_component / by_time_range, which count commits. by_index counts individual fibers and returns all of them unless this is set; a small cap there can show less than the analyze report it is meant to expand on."
|
|
170940
|
-
)
|
|
170941
|
-
});
|
|
170942
|
-
var profilerCommitQueryTool = {
|
|
170943
|
-
id: "profiler-commit-query",
|
|
170944
|
-
description: `Query React commit data for iterative investigation of render performance.
|
|
170945
|
-
Modes:
|
|
170946
|
-
- by_component: All commits where component_name rendered, with causes and durations.
|
|
170947
|
-
- by_time_range: What happened in time_range_ms.
|
|
170948
|
-
- by_index: Full detail dump of the commit at commit_index (all components, props changed, parent cascade).
|
|
170949
|
-
- cascade_tree: Parent-child cascade tree for the commit at commit_index, showing who triggered whom.
|
|
170950
|
-
Use when drilling into specific components or time windows after react-profiler-analyze.
|
|
170951
|
-
Returns a markdown table or tree of commit data matching the requested mode.
|
|
170952
|
-
Fails if react-profiler-stop has not been called or no commit data is stored.`,
|
|
170953
|
-
zodSchema: zodSchema59,
|
|
170954
|
-
readOnly: true,
|
|
170955
|
-
interaction: {
|
|
170956
|
-
startedMsg: ({ params }) => `Querying React commits ${params.mode.replace(/^by_/, "by ").replaceAll("_", " ")}`,
|
|
170957
|
-
completedMsg: ({ params }) => `Queried React commits ${params.mode.replace(/^by_/, "by ").replaceAll("_", " ")}`,
|
|
170958
|
-
failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to query React commits: ${failureSignal2.error_code}`
|
|
170959
|
-
},
|
|
170960
|
-
// Reads React commit data captured via the React DevTools backend.
|
|
170961
|
-
capability: RN_ONLY_TOOL_CAPABILITY,
|
|
170962
|
-
services: () => ({}),
|
|
170963
|
-
async execute(_services, params) {
|
|
170964
|
-
const commitTree = await getCommitTree(metroPort(params), params.device_id);
|
|
170965
|
-
switch (params.mode) {
|
|
170966
|
-
case "by_component": {
|
|
170967
|
-
if (!params.component_name) {
|
|
170968
|
-
throw new FailureError("by_component mode requires the component_name parameter.", {
|
|
170969
|
-
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
170970
|
-
failure_stage: "profiler_commit_query_params",
|
|
170971
|
-
failure_area: "tool_server",
|
|
170972
|
-
error_kind: "validation"
|
|
170973
|
-
});
|
|
170974
|
-
}
|
|
170975
|
-
return renderByComponent(commitTree.commits, params.component_name, params.top_n ?? 20);
|
|
170976
|
-
}
|
|
170977
|
-
case "by_time_range": {
|
|
170978
|
-
if (!params.time_range_ms) {
|
|
170979
|
-
throw new FailureError("by_time_range mode requires the time_range_ms parameter.", {
|
|
170980
|
-
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
170981
|
-
failure_stage: "profiler_commit_query_params",
|
|
170982
|
-
failure_area: "tool_server",
|
|
170983
|
-
error_kind: "validation"
|
|
170984
|
-
});
|
|
170985
|
-
}
|
|
170986
|
-
return renderByTimeRange(
|
|
170987
|
-
commitTree.commits,
|
|
170988
|
-
params.time_range_ms.start,
|
|
170989
|
-
params.time_range_ms.end,
|
|
170990
|
-
params.top_n ?? 20
|
|
170991
|
-
);
|
|
170992
|
-
}
|
|
170993
|
-
case "by_index": {
|
|
170994
|
-
if (params.commit_index == null) {
|
|
170995
|
-
throw new FailureError("by_index mode requires the commit_index parameter.", {
|
|
170996
|
-
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
170997
|
-
failure_stage: "profiler_commit_query_params",
|
|
170998
|
-
failure_area: "tool_server",
|
|
170999
|
-
error_kind: "validation"
|
|
171000
|
-
});
|
|
171001
|
-
}
|
|
171002
|
-
return renderByIndex(commitTree.commits, params.commit_index, params.top_n);
|
|
171003
|
-
}
|
|
171004
|
-
case "cascade_tree": {
|
|
171005
|
-
if (params.commit_index == null) {
|
|
171006
|
-
throw new FailureError("cascade_tree mode requires the commit_index parameter.", {
|
|
171007
|
-
error_code: FAILURE_CODES.PROFILER_QUERY_REQUIRED_PARAM_MISSING,
|
|
171008
|
-
failure_stage: "profiler_commit_query_params",
|
|
171009
|
-
failure_area: "tool_server",
|
|
171010
|
-
error_kind: "validation"
|
|
171011
|
-
});
|
|
171012
|
-
}
|
|
171013
|
-
return renderCascadeTree(commitTree.commits, params.commit_index);
|
|
171014
|
-
}
|
|
171015
|
-
default:
|
|
171016
|
-
throw new FailureError(`Unknown mode: ${params.mode}`, {
|
|
171017
|
-
error_code: FAILURE_CODES.PROFILER_QUERY_MODE_INVALID,
|
|
171018
|
-
failure_stage: "profiler_commit_query_mode",
|
|
171019
|
-
failure_area: "tool_server",
|
|
171020
|
-
error_kind: "validation"
|
|
171021
|
-
});
|
|
171022
|
-
}
|
|
171023
|
-
}
|
|
171024
|
-
};
|
|
171025
|
-
|
|
171026
171850
|
// ../tool-server/src/tools/profiler/query/profiler-stack-query.ts
|
|
171027
171851
|
init_zod();
|
|
171028
171852
|
init_src2();
|
|
@@ -171425,7 +172249,7 @@ var profilerCombinedReportTool = {
|
|
|
171425
172249
|
Maps native hangs to React commits using wall-clock time alignment.
|
|
171426
172250
|
Call this tool when both profilers were run in parallel on the same session.
|
|
171427
172251
|
Returns a markdown report correlating hangs with React commits, memory leaks, and investigation hints.
|
|
171428
|
-
Fails if either react-profiler-analyze or native-profiler-analyze has not been called first.`,
|
|
172252
|
+
Fails if either react-profiler-analyze or native-profiler-analyze has not been called first, or if the session stored no React commits.`,
|
|
171429
172253
|
zodSchema: zodSchema61,
|
|
171430
172254
|
readOnly: true,
|
|
171431
172255
|
interaction: {
|
|
@@ -171517,7 +172341,8 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
|
|
|
171517
172341
|
const onDisk = await readCommitTree(sessionPaths.commitsPath);
|
|
171518
172342
|
const commitTree = { commits: onDisk.commits, hookNames: /* @__PURE__ */ new Map() };
|
|
171519
172343
|
if (commitTree.commits.length === 0) {
|
|
171520
|
-
|
|
172344
|
+
const message = "No React commits are stored for this session: only commits of 16ms or more with named components, and their neighbours, are kept. There is nothing to correlate with the native profile. Use the native-profiler-analyze report on its own.";
|
|
172345
|
+
throw new FailureError(message, {
|
|
171521
172346
|
error_code: FAILURE_CODES.PROFILER_DATA_NOT_LOADED,
|
|
171522
172347
|
failure_stage: "profiler_combined_report_load_react_data",
|
|
171523
172348
|
failure_area: "tool_server",
|
|
@@ -171903,11 +172728,12 @@ async function loadReactSession(debugDir, sessionId, port, deviceId) {
|
|
|
171903
172728
|
let deviceName = null;
|
|
171904
172729
|
let projectRoot = null;
|
|
171905
172730
|
let commitCount = 0;
|
|
172731
|
+
let renderSummary = null;
|
|
171906
172732
|
let sampleInfo = "not available";
|
|
171907
172733
|
if (hasCommits) {
|
|
171908
172734
|
try {
|
|
171909
172735
|
const onDisk = await readCommitTree(commitsPath);
|
|
171910
|
-
commitCount = onDisk.commits.
|
|
172736
|
+
commitCount = new Set(onDisk.commits.map((c) => c.commitIndex)).size;
|
|
171911
172737
|
if (onDisk.meta) {
|
|
171912
172738
|
detectedArchitecture = onDisk.meta.detectedArchitecture ?? null;
|
|
171913
172739
|
anyCompilerOptimized = onDisk.meta.anyCompilerOptimized ?? null;
|
|
@@ -171916,6 +172742,7 @@ async function loadReactSession(debugDir, sessionId, port, deviceId) {
|
|
|
171916
172742
|
appName = onDisk.meta.appName ?? null;
|
|
171917
172743
|
deviceName = onDisk.meta.deviceName ?? null;
|
|
171918
172744
|
projectRoot = onDisk.meta.projectRoot ?? null;
|
|
172745
|
+
renderSummary = parseRenderSummary(onDisk.meta.renderSummary);
|
|
171919
172746
|
}
|
|
171920
172747
|
} catch {
|
|
171921
172748
|
}
|
|
@@ -171951,6 +172778,8 @@ async function loadReactSession(debugDir, sessionId, port, deviceId) {
|
|
|
171951
172778
|
`- CPU profile: ${sampleInfo}`,
|
|
171952
172779
|
`- Commits persisted (hot \xB11 margin, \u226516ms): ${commitCount}`,
|
|
171953
172780
|
`- Total React commits: ${totalReactCommits ?? "unknown"}`,
|
|
172781
|
+
// Older sessions lack the summary; say so here, before render_counts does.
|
|
172782
|
+
renderSummary ? `- React render time (all commits): ${formatRenderTime(renderSummary)}` : `- Render counts over all commits: not available for this session`,
|
|
171954
172783
|
`- Architecture: ${detectedArchitecture ?? "unknown"}`,
|
|
171955
172784
|
"",
|
|
171956
172785
|
"Query tools (`profiler-cpu-query`, `profiler-commit-query`) are now ready to use against this data."
|
|
@@ -172393,7 +173222,7 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
|
|
|
172393
173222
|
// ../tool-server/src/tools/simulator/stop-metro.ts
|
|
172394
173223
|
init_zod();
|
|
172395
173224
|
var import_node_child_process47 = require("node:child_process");
|
|
172396
|
-
var
|
|
173225
|
+
var import_node_fs18 = require("node:fs");
|
|
172397
173226
|
init_src2();
|
|
172398
173227
|
function parseNetstatListeningPids(netstatOutput, port) {
|
|
172399
173228
|
const pids = /* @__PURE__ */ new Set();
|
|
@@ -172413,7 +173242,7 @@ function procListeningPids(port, proc = "/proc") {
|
|
|
172413
173242
|
for (const table of ["tcp", "tcp6"]) {
|
|
172414
173243
|
let rows;
|
|
172415
173244
|
try {
|
|
172416
|
-
rows = (0,
|
|
173245
|
+
rows = (0, import_node_fs18.readFileSync)(`${proc}/net/${table}`, "utf-8");
|
|
172417
173246
|
} catch (error63) {
|
|
172418
173247
|
if (table === "tcp6" && error63.code === "ENOENT") continue;
|
|
172419
173248
|
throw error63;
|
|
@@ -172428,11 +173257,11 @@ function procListeningPids(port, proc = "/proc") {
|
|
|
172428
173257
|
if (inodes.size === 0) return [];
|
|
172429
173258
|
const owned = /* @__PURE__ */ new Set();
|
|
172430
173259
|
const pids = [];
|
|
172431
|
-
for (const entry of (0,
|
|
173260
|
+
for (const entry of (0, import_node_fs18.readdirSync)(proc)) {
|
|
172432
173261
|
if (!/^\d+$/.test(entry)) continue;
|
|
172433
173262
|
let fds;
|
|
172434
173263
|
try {
|
|
172435
|
-
fds = (0,
|
|
173264
|
+
fds = (0, import_node_fs18.readdirSync)(`${proc}/${entry}/fd`);
|
|
172436
173265
|
} catch {
|
|
172437
173266
|
continue;
|
|
172438
173267
|
}
|
|
@@ -172440,7 +173269,7 @@ function procListeningPids(port, proc = "/proc") {
|
|
|
172440
173269
|
for (const fd of fds) {
|
|
172441
173270
|
let target;
|
|
172442
173271
|
try {
|
|
172443
|
-
target = (0,
|
|
173272
|
+
target = (0, import_node_fs18.readlinkSync)(`${proc}/${entry}/fd/${fd}`);
|
|
172444
173273
|
} catch {
|
|
172445
173274
|
continue;
|
|
172446
173275
|
}
|
|
@@ -172459,8 +173288,8 @@ function procListeningPids(port, proc = "/proc") {
|
|
|
172459
173288
|
}
|
|
172460
173289
|
return pids;
|
|
172461
173290
|
}
|
|
172462
|
-
var LSOF_BIN = ["/usr/sbin/lsof", "/usr/bin/lsof"].find((p) => (0,
|
|
172463
|
-
var DARWIN_NETSTAT_BIN = (0,
|
|
173291
|
+
var LSOF_BIN = ["/usr/sbin/lsof", "/usr/bin/lsof"].find((p) => (0, import_node_fs18.existsSync)(p)) ?? "lsof";
|
|
173292
|
+
var DARWIN_NETSTAT_BIN = (0, import_node_fs18.existsSync)("/usr/sbin/netstat") ? "/usr/sbin/netstat" : "netstat";
|
|
172464
173293
|
function parseDarwinNetstatHasListener(netstatOutput, port) {
|
|
172465
173294
|
return netstatOutput.split("\n").some((line) => {
|
|
172466
173295
|
const cols = line.trim().split(/\s+/);
|
|
@@ -172579,7 +173408,7 @@ init_zod();
|
|
|
172579
173408
|
// ../tool-server/src/tools/flows/flow-utils.ts
|
|
172580
173409
|
var path48 = __toESM(require("node:path"));
|
|
172581
173410
|
var fs63 = __toESM(require("node:fs/promises"));
|
|
172582
|
-
var
|
|
173411
|
+
var import_node_fs19 = require("node:fs");
|
|
172583
173412
|
init_src();
|
|
172584
173413
|
init_src2();
|
|
172585
173414
|
var import_yaml = __toESM(require_dist8());
|
|
@@ -174744,11 +175573,11 @@ function parseFlow(content) {
|
|
|
174744
175573
|
);
|
|
174745
175574
|
}
|
|
174746
175575
|
if (!("steps" in parsed) || !Array.isArray(parsed.steps)) throw notAFlow();
|
|
174747
|
-
const
|
|
174748
|
-
const unknownTop = Object.keys(parsed).filter((k) => !
|
|
175576
|
+
const topKeys2 = ["version", "executionPrerequisite", "requires", "steps"];
|
|
175577
|
+
const unknownTop = Object.keys(parsed).filter((k) => !topKeys2.includes(k));
|
|
174749
175578
|
if (unknownTop.length > 0) {
|
|
174750
175579
|
throw new FailureError(
|
|
174751
|
-
`Invalid e2e test file: ${describeUnknownKeys(unknownTop,
|
|
175580
|
+
`Invalid e2e test file: ${describeUnknownKeys(unknownTop, topKeys2)} \u2014 allowed top-level keys: ${topKeys2.join(", ")}`,
|
|
174752
175581
|
{
|
|
174753
175582
|
error_code: FAILURE_CODES.FLOW_FILE_INVALID,
|
|
174754
175583
|
failure_stage: "flow_file_parse",
|
|
@@ -174820,7 +175649,7 @@ async function followDanglingLink(linkPath) {
|
|
|
174820
175649
|
return current;
|
|
174821
175650
|
}
|
|
174822
175651
|
async function isWritable(filePath) {
|
|
174823
|
-
return fs63.access(filePath,
|
|
175652
|
+
return fs63.access(filePath, import_node_fs19.constants.W_OK).then(
|
|
174824
175653
|
() => true,
|
|
174825
175654
|
() => false
|
|
174826
175655
|
);
|
|
@@ -179775,9 +180604,9 @@ function readableFrame(frame2, roots) {
|
|
|
179775
180604
|
return match;
|
|
179776
180605
|
}
|
|
179777
180606
|
for (const root of roots) {
|
|
179778
|
-
const
|
|
179779
|
-
if (
|
|
179780
|
-
return `${
|
|
180607
|
+
const relative9 = path54.relative(root, file2);
|
|
180608
|
+
if (relative9 !== "" && !relative9.startsWith("..") && !path54.isAbsolute(relative9)) {
|
|
180609
|
+
return `${relative9}${position}`;
|
|
179781
180610
|
}
|
|
179782
180611
|
}
|
|
179783
180612
|
return `${file2}${position}`;
|
|
@@ -180124,7 +180953,7 @@ init_src2();
|
|
|
180124
180953
|
|
|
180125
180954
|
// ../tool-server/src/tools/screenshot-diff/screenshot-diff.ts
|
|
180126
180955
|
var import_promises18 = __toESM(require("fs/promises"));
|
|
180127
|
-
var
|
|
180956
|
+
var import_path8 = __toESM(require("path"));
|
|
180128
180957
|
var import_pngjs6 = __toESM(require_png());
|
|
180129
180958
|
init_src2();
|
|
180130
180959
|
|
|
@@ -181845,12 +182674,12 @@ function topRegionsByPixelCount(regions, limit) {
|
|
|
181845
182674
|
function resolveDiffArtifactPaths(options) {
|
|
181846
182675
|
const currentName = outputArtifactBaseName(options.currentPath);
|
|
181847
182676
|
return {
|
|
181848
|
-
diffPath:
|
|
181849
|
-
contextDiffPath:
|
|
182677
|
+
diffPath: import_path8.default.join(options.outputDir, `${currentName}-diff.png`),
|
|
182678
|
+
contextDiffPath: import_path8.default.join(options.outputDir, `${currentName}-context-diff.png`)
|
|
181850
182679
|
};
|
|
181851
182680
|
}
|
|
181852
182681
|
function outputArtifactBaseName(filePath) {
|
|
181853
|
-
const parsed =
|
|
182682
|
+
const parsed = import_path8.default.parse(import_path8.default.basename(filePath));
|
|
181854
182683
|
return parsed.name || parsed.base;
|
|
181855
182684
|
}
|
|
181856
182685
|
async function writeDiffArtifacts(params) {
|
|
@@ -181923,7 +182752,7 @@ function luminanceFromOffset(data, offset) {
|
|
|
181923
182752
|
return 0.2126 * data[offset] + 0.7152 * data[offset + 1] + 0.0722 * data[offset + 2];
|
|
181924
182753
|
}
|
|
181925
182754
|
async function writePngFile(filePath, png) {
|
|
181926
|
-
await import_promises18.default.mkdir(
|
|
182755
|
+
await import_promises18.default.mkdir(import_path8.default.dirname(filePath), { recursive: true });
|
|
181927
182756
|
await import_promises18.default.writeFile(filePath, import_pngjs6.PNG.sync.write(png));
|
|
181928
182757
|
}
|
|
181929
182758
|
function downscalePng(source, scale) {
|
|
@@ -183056,7 +183885,7 @@ var zodSchema71 = external_exports.object({
|
|
|
183056
183885
|
"Write/refresh screenshot baselines for `snapshot` steps instead of diffing against them, also in the e2e tests that tool: e2e-execute steps run, unless such a step sets updateBaselines itself. Over a link, the client writes the new baselines when the run ends."
|
|
183057
183886
|
),
|
|
183058
183887
|
prerequisiteAcknowledged: external_exports.boolean().optional().describe(
|
|
183059
|
-
"Set to true to confirm the execution prerequisite has been met. Required when a fragment defines an executionPrerequisite."
|
|
183888
|
+
"Set to true to confirm the execution prerequisite has been met. Required when a fragment defines an executionPrerequisite: without it, the call runs no step and returns the prerequisite text. Not a dry run: an e2e test with no prerequisite runs in full. To read a prerequisite without running, read executionPrerequisite in the YAML file."
|
|
183060
183889
|
)
|
|
183061
183890
|
}).superRefine((params, ctx) => {
|
|
183062
183891
|
if (params.name === void 0 === (params.e2e_test_path === void 0)) {
|
|
@@ -184177,6 +185006,12 @@ Fails if the e2e test file does not exist.
|
|
|
184177
185006
|
Address the e2e test exactly as you will address it in e2e-execute: name or e2e_test_path, one and only one; supplying both or neither is rejected.`,
|
|
184178
185007
|
zodSchema: zodSchema72,
|
|
184179
185008
|
readOnly: true,
|
|
185009
|
+
// When its gates pass, e2e-execute without prerequisiteAcknowledged returns
|
|
185010
|
+
// the same executionPrerequisite, from the same resolveFlowSource, before any
|
|
185011
|
+
// device work. An invalid test gets the gate's error, and a test with no
|
|
185012
|
+
// prerequisite runs. The SDK, `argent run` and e2e tool: steps still call it,
|
|
185013
|
+
// by its id or its alias.
|
|
185014
|
+
hideFromMcp: true,
|
|
184180
185015
|
aliases: ["flow-read-prerequisite"],
|
|
184181
185016
|
interaction: {
|
|
184182
185017
|
startedMsg: () => "Reading e2e test prerequisite",
|
|
@@ -184698,12 +185533,15 @@ var updateArgentTool = {
|
|
|
184698
185533
|
|
|
184699
185534
|
// ../tool-server/src/tools/system/dismiss-update.ts
|
|
184700
185535
|
init_zod();
|
|
185536
|
+
var MAX_HOURS = 24 * 365 * 10;
|
|
184701
185537
|
var zodSchema75 = external_exports.object({
|
|
184702
|
-
hours: external_exports.number().min(0).describe(
|
|
185538
|
+
hours: external_exports.number().min(0).describe(
|
|
185539
|
+
"Hours until reminders resume: 168 is a week, 87600 is the longest, 0 turns them back on"
|
|
185540
|
+
)
|
|
184703
185541
|
});
|
|
184704
185542
|
var dismissUpdateTool = {
|
|
184705
185543
|
id: "dismiss-update",
|
|
184706
|
-
description: "
|
|
185544
|
+
description: "Postpone the Argent update reminder, on every tool-server on this machine, when the user wants it later or tomorrow, wants it stopped, or never wants it (87600 hours). Installs nothing. A memory or a reminder of your own does not change it. Returns { message, remindersResumeAt, persisted, pendingVersion }: tell the user when reminders resume, and if persisted is false, that it did not fully hold.",
|
|
184707
185545
|
zodSchema: zodSchema75,
|
|
184708
185546
|
interaction: {
|
|
184709
185547
|
startedMsg: () => "Dismissing Argent update",
|
|
@@ -184712,10 +185550,27 @@ var dismissUpdateTool = {
|
|
|
184712
185550
|
},
|
|
184713
185551
|
services: () => ({}),
|
|
184714
185552
|
async execute(_services, params, _options) {
|
|
184715
|
-
const
|
|
184716
|
-
suppressUpdateNote(
|
|
185553
|
+
const hours = Math.min(params.hours, MAX_HOURS);
|
|
185554
|
+
const { until, persisted } = suppressUpdateNote(hours * 60 * 60 * 1e3);
|
|
185555
|
+
const { updateInstallable, installableVersion } = getUpdateState();
|
|
185556
|
+
const pendingVersion = updateInstallable ? installableVersion : null;
|
|
185557
|
+
const end = new Date(until);
|
|
185558
|
+
const local = end.toLocaleString("en-US", { dateStyle: "medium", timeStyle: "short" });
|
|
185559
|
+
if (hours === 0) {
|
|
185560
|
+
return {
|
|
185561
|
+
message: pendingVersion ? `Update reminders are back on, so the reminder for v${pendingVersion} shows again.` : "Update reminders are back on. No update is pending right now.",
|
|
185562
|
+
remindersResumeAt: null,
|
|
185563
|
+
persisted,
|
|
185564
|
+
pendingVersion
|
|
185565
|
+
};
|
|
185566
|
+
}
|
|
185567
|
+
const pending = pendingVersion ? `v${pendingVersion} stays available and nothing was installed.` : `No update is pending right now; one that appears before then stays silent too.`;
|
|
185568
|
+
const scope = persisted ? `on every Argent tool-server on this machine` : `in this tool-server only, and only until it restarts: ~/.argent could not be written, so other tool-servers still show reminders`;
|
|
184717
185569
|
return {
|
|
184718
|
-
message:
|
|
185570
|
+
message: `Update reminders are off until ${local} (${end.toISOString()}) ${scope}. ${pending} Tell the user when reminders resume. Remove any saved reminder about this update from your task list and do not bring it up again unless the user asks.`,
|
|
185571
|
+
remindersResumeAt: end.toISOString(),
|
|
185572
|
+
persisted,
|
|
185573
|
+
pendingVersion
|
|
184719
185574
|
};
|
|
184720
185575
|
}
|
|
184721
185576
|
};
|
|
@@ -184724,7 +185579,7 @@ var dismissUpdateTool = {
|
|
|
184724
185579
|
var import_node_crypto16 = __toESM(require("node:crypto"));
|
|
184725
185580
|
var import_promises20 = __toESM(require("fs/promises"));
|
|
184726
185581
|
var import_node_os17 = __toESM(require("node:os"));
|
|
184727
|
-
var
|
|
185582
|
+
var import_path9 = __toESM(require("path"));
|
|
184728
185583
|
init_zod();
|
|
184729
185584
|
init_src2();
|
|
184730
185585
|
init_device_info();
|
|
@@ -184873,7 +185728,7 @@ async function resolveOutputDir(params, options) {
|
|
|
184873
185728
|
if (err.code === "EEXIST") return params.outputDir;
|
|
184874
185729
|
}
|
|
184875
185730
|
}
|
|
184876
|
-
const dir =
|
|
185731
|
+
const dir = import_path9.default.join(
|
|
184877
185732
|
import_node_os17.default.tmpdir(),
|
|
184878
185733
|
"argent-screenshot-diff",
|
|
184879
185734
|
import_node_crypto16.default.randomBytes(6).toString("hex")
|
|
@@ -184982,7 +185837,7 @@ async function captureIosDeviceLiveInput(params) {
|
|
|
184982
185837
|
}
|
|
184983
185838
|
async function writeLivePng(outputDir, name, png) {
|
|
184984
185839
|
const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
|
|
184985
|
-
const destination =
|
|
185840
|
+
const destination = import_path9.default.join(outputDir, `${name}-${suffix}.live.png`);
|
|
184986
185841
|
await import_promises20.default.mkdir(outputDir, { recursive: true });
|
|
184987
185842
|
await import_promises20.default.writeFile(destination, png);
|
|
184988
185843
|
return destination;
|
|
@@ -185000,7 +185855,7 @@ async function captureHarmonyLiveInput(params) {
|
|
|
185000
185855
|
await ensureDep("hdc");
|
|
185001
185856
|
const captured = await captureHarmonyScreenshotPng({ connectKey: params.connectKey, scale: 1 });
|
|
185002
185857
|
const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
|
|
185003
|
-
const destination =
|
|
185858
|
+
const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
|
|
185004
185859
|
try {
|
|
185005
185860
|
await import_promises20.default.mkdir(params.outputDir, { recursive: true });
|
|
185006
185861
|
await import_promises20.default.copyFile(captured, destination);
|
|
@@ -185036,7 +185891,7 @@ async function captureLiveInput(params) {
|
|
|
185036
185891
|
);
|
|
185037
185892
|
}
|
|
185038
185893
|
const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
|
|
185039
|
-
const destination =
|
|
185894
|
+
const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
|
|
185040
185895
|
await import_promises20.default.mkdir(params.outputDir, { recursive: true });
|
|
185041
185896
|
await import_promises20.default.copyFile(capture.path, destination);
|
|
185042
185897
|
return {
|
|
@@ -185554,6 +186409,9 @@ Use when seeding feature flags / auth tokens before an e2e test or asserting per
|
|
|
185554
186409
|
Returns { value } for one key, { entries, count } for all keys, and { set } / { removed } / { cleared } for the writes. Fails if the device is not a Chromium (CDP) device, or the action is missing the \`key\` / \`value\` it needs.`,
|
|
185555
186410
|
zodSchema: zodSchema81,
|
|
185556
186411
|
searchHint: "storage localstorage sessionstorage local session get set remove clear key value chromium",
|
|
186412
|
+
// Agents read and write Web Storage with debugger-evaluate, which runs the same
|
|
186413
|
+
// Runtime.evaluate on the active page. The SDK and the e2e-full suite still call it.
|
|
186414
|
+
hideFromMcp: true,
|
|
185557
186415
|
interaction: {
|
|
185558
186416
|
startedMsg: ({ params }) => `${storageAction[params.action].started} ${params.store} storage`,
|
|
185559
186417
|
completedMsg: ({ params }) => `${storageAction[params.action].completed} ${params.store} storage`,
|