@swmansion/argent 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -9
- package/bin/argent-simulator-server.cjs +56 -0
- package/bin/{ax-service → darwin/ax-service} +0 -0
- package/bin/{simulator-server → darwin/simulator-server} +0 -0
- package/bin/linux/simulator-server +0 -0
- package/dist/argent-android-devtools-0.1.0.apk +0 -0
- package/dist/cli-cmds.mjs +2364 -76
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +23 -2
- package/dist/cli.js.map +1 -1
- package/dist/installer.mjs +232 -107
- package/dist/mcp-server.mjs +163 -51
- package/dist/tool-server.cjs +1491 -946
- package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/libKeyboardPatch.dylib +0 -0
- package/dylibs/libNativeDevtoolsIos.dylib +0 -0
- package/package.json +2 -2
- package/skills/argent-android-emulator-setup/SKILL.md +1 -1
package/dist/tool-server.cjs
CHANGED
|
@@ -33,7 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
// ../../node_modules/depd/index.js
|
|
34
34
|
var require_depd = __commonJS({
|
|
35
35
|
"../../node_modules/depd/index.js"(exports2, module2) {
|
|
36
|
-
var
|
|
36
|
+
var relative3 = require("path").relative;
|
|
37
37
|
module2.exports = depd;
|
|
38
38
|
var basePath = process.cwd();
|
|
39
39
|
function containsNamespace(str, namespace) {
|
|
@@ -225,7 +225,7 @@ var require_depd = __commonJS({
|
|
|
225
225
|
return formatted;
|
|
226
226
|
}
|
|
227
227
|
function formatLocation(callSite) {
|
|
228
|
-
return
|
|
228
|
+
return relative3(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
|
|
229
229
|
}
|
|
230
230
|
function getStack() {
|
|
231
231
|
var limit = Error.stackTraceLimit;
|
|
@@ -1290,8 +1290,8 @@ var require_node = __commonJS({
|
|
|
1290
1290
|
}
|
|
1291
1291
|
break;
|
|
1292
1292
|
case "FILE":
|
|
1293
|
-
var
|
|
1294
|
-
stream2 = new
|
|
1293
|
+
var fs27 = require("fs");
|
|
1294
|
+
stream2 = new fs27.SyncWriteStream(fd2, { autoClose: false });
|
|
1295
1295
|
stream2._type = "fs";
|
|
1296
1296
|
break;
|
|
1297
1297
|
case "PIPE":
|
|
@@ -4943,10 +4943,10 @@ var require_raw_body = __commonJS({
|
|
|
4943
4943
|
if (done) {
|
|
4944
4944
|
return readStream(stream, encoding, length, limit, wrap(done));
|
|
4945
4945
|
}
|
|
4946
|
-
return new Promise(function executor(
|
|
4946
|
+
return new Promise(function executor(resolve3, reject) {
|
|
4947
4947
|
readStream(stream, encoding, length, limit, function onRead(err, buf) {
|
|
4948
4948
|
if (err) return reject(err);
|
|
4949
|
-
|
|
4949
|
+
resolve3(buf);
|
|
4950
4950
|
});
|
|
4951
4951
|
});
|
|
4952
4952
|
}
|
|
@@ -14028,7 +14028,7 @@ var require_mime_types = __commonJS({
|
|
|
14028
14028
|
"../../node_modules/mime-types/index.js"(exports2) {
|
|
14029
14029
|
"use strict";
|
|
14030
14030
|
var db = require_mime_db();
|
|
14031
|
-
var
|
|
14031
|
+
var extname2 = require("path").extname;
|
|
14032
14032
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
14033
14033
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
14034
14034
|
exports2.charset = charset;
|
|
@@ -14078,11 +14078,11 @@ var require_mime_types = __commonJS({
|
|
|
14078
14078
|
}
|
|
14079
14079
|
return exts[0];
|
|
14080
14080
|
}
|
|
14081
|
-
function lookup(
|
|
14082
|
-
if (!
|
|
14081
|
+
function lookup(path16) {
|
|
14082
|
+
if (!path16 || typeof path16 !== "string") {
|
|
14083
14083
|
return false;
|
|
14084
14084
|
}
|
|
14085
|
-
var extension2 =
|
|
14085
|
+
var extension2 = extname2("x." + path16).toLowerCase().substr(1);
|
|
14086
14086
|
if (!extension2) {
|
|
14087
14087
|
return false;
|
|
14088
14088
|
}
|
|
@@ -17597,7 +17597,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
17597
17597
|
"../../node_modules/path-to-regexp/index.js"(exports2, module2) {
|
|
17598
17598
|
module2.exports = pathToRegexp;
|
|
17599
17599
|
var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
|
|
17600
|
-
function pathToRegexp(
|
|
17600
|
+
function pathToRegexp(path16, keys, options) {
|
|
17601
17601
|
options = options || {};
|
|
17602
17602
|
keys = keys || [];
|
|
17603
17603
|
var strict = options.strict;
|
|
@@ -17611,8 +17611,8 @@ var require_path_to_regexp = __commonJS({
|
|
|
17611
17611
|
var pos = 0;
|
|
17612
17612
|
var backtrack = "";
|
|
17613
17613
|
var m;
|
|
17614
|
-
if (
|
|
17615
|
-
while (m = MATCHING_GROUP_REGEXP.exec(
|
|
17614
|
+
if (path16 instanceof RegExp) {
|
|
17615
|
+
while (m = MATCHING_GROUP_REGEXP.exec(path16.source)) {
|
|
17616
17616
|
if (m[0][0] === "\\") continue;
|
|
17617
17617
|
keys.push({
|
|
17618
17618
|
name: m[1] || name++,
|
|
@@ -17620,18 +17620,18 @@ var require_path_to_regexp = __commonJS({
|
|
|
17620
17620
|
offset: m.index
|
|
17621
17621
|
});
|
|
17622
17622
|
}
|
|
17623
|
-
return
|
|
17623
|
+
return path16;
|
|
17624
17624
|
}
|
|
17625
|
-
if (Array.isArray(
|
|
17626
|
-
|
|
17625
|
+
if (Array.isArray(path16)) {
|
|
17626
|
+
path16 = path16.map(function(value) {
|
|
17627
17627
|
return pathToRegexp(value, keys, options).source;
|
|
17628
17628
|
});
|
|
17629
|
-
return new RegExp(
|
|
17629
|
+
return new RegExp(path16.join("|"), flags);
|
|
17630
17630
|
}
|
|
17631
|
-
if (typeof
|
|
17631
|
+
if (typeof path16 !== "string") {
|
|
17632
17632
|
throw new TypeError("path must be a string, array of strings, or regular expression");
|
|
17633
17633
|
}
|
|
17634
|
-
|
|
17634
|
+
path16 = path16.replace(
|
|
17635
17635
|
/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,
|
|
17636
17636
|
function(match, slash, format, key, capture, star, optional2, offset) {
|
|
17637
17637
|
if (match[0] === "\\") {
|
|
@@ -17648,7 +17648,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
17648
17648
|
if (slash || format) {
|
|
17649
17649
|
backtrack = "";
|
|
17650
17650
|
} else {
|
|
17651
|
-
backtrack +=
|
|
17651
|
+
backtrack += path16.slice(pos, offset);
|
|
17652
17652
|
}
|
|
17653
17653
|
pos = offset + match.length;
|
|
17654
17654
|
if (match === "*") {
|
|
@@ -17678,7 +17678,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
17678
17678
|
return result;
|
|
17679
17679
|
}
|
|
17680
17680
|
);
|
|
17681
|
-
while (m = MATCHING_GROUP_REGEXP.exec(
|
|
17681
|
+
while (m = MATCHING_GROUP_REGEXP.exec(path16)) {
|
|
17682
17682
|
if (m[0][0] === "\\") continue;
|
|
17683
17683
|
if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
|
|
17684
17684
|
keys.splice(keysOffset + i, 0, {
|
|
@@ -17690,13 +17690,13 @@ var require_path_to_regexp = __commonJS({
|
|
|
17690
17690
|
}
|
|
17691
17691
|
i++;
|
|
17692
17692
|
}
|
|
17693
|
-
|
|
17693
|
+
path16 += strict ? "" : path16[path16.length - 1] === "/" ? "?" : "/?";
|
|
17694
17694
|
if (end) {
|
|
17695
|
-
|
|
17696
|
-
} else if (
|
|
17697
|
-
|
|
17695
|
+
path16 += "$";
|
|
17696
|
+
} else if (path16[path16.length - 1] !== "/") {
|
|
17697
|
+
path16 += lookahead ? "(?=/|$)" : "(?:/|$)";
|
|
17698
17698
|
}
|
|
17699
|
-
return new RegExp("^" +
|
|
17699
|
+
return new RegExp("^" + path16, flags);
|
|
17700
17700
|
}
|
|
17701
17701
|
}
|
|
17702
17702
|
});
|
|
@@ -17709,19 +17709,19 @@ var require_layer = __commonJS({
|
|
|
17709
17709
|
var debug = require_src()("express:router:layer");
|
|
17710
17710
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
17711
17711
|
module2.exports = Layer;
|
|
17712
|
-
function Layer(
|
|
17712
|
+
function Layer(path16, options, fn) {
|
|
17713
17713
|
if (!(this instanceof Layer)) {
|
|
17714
|
-
return new Layer(
|
|
17714
|
+
return new Layer(path16, options, fn);
|
|
17715
17715
|
}
|
|
17716
|
-
debug("new %o",
|
|
17716
|
+
debug("new %o", path16);
|
|
17717
17717
|
var opts = options || {};
|
|
17718
17718
|
this.handle = fn;
|
|
17719
17719
|
this.name = fn.name || "<anonymous>";
|
|
17720
17720
|
this.params = void 0;
|
|
17721
17721
|
this.path = void 0;
|
|
17722
|
-
this.regexp = pathRegexp(
|
|
17723
|
-
this.regexp.fast_star =
|
|
17724
|
-
this.regexp.fast_slash =
|
|
17722
|
+
this.regexp = pathRegexp(path16, this.keys = [], opts);
|
|
17723
|
+
this.regexp.fast_star = path16 === "*";
|
|
17724
|
+
this.regexp.fast_slash = path16 === "/" && opts.end === false;
|
|
17725
17725
|
}
|
|
17726
17726
|
Layer.prototype.handle_error = function handle_error(error51, req, res, next) {
|
|
17727
17727
|
var fn = this.handle;
|
|
@@ -17745,20 +17745,20 @@ var require_layer = __commonJS({
|
|
|
17745
17745
|
next(err);
|
|
17746
17746
|
}
|
|
17747
17747
|
};
|
|
17748
|
-
Layer.prototype.match = function match(
|
|
17748
|
+
Layer.prototype.match = function match(path16) {
|
|
17749
17749
|
var match2;
|
|
17750
|
-
if (
|
|
17750
|
+
if (path16 != null) {
|
|
17751
17751
|
if (this.regexp.fast_slash) {
|
|
17752
17752
|
this.params = {};
|
|
17753
17753
|
this.path = "";
|
|
17754
17754
|
return true;
|
|
17755
17755
|
}
|
|
17756
17756
|
if (this.regexp.fast_star) {
|
|
17757
|
-
this.params = { "0": decode_param(
|
|
17758
|
-
this.path =
|
|
17757
|
+
this.params = { "0": decode_param(path16) };
|
|
17758
|
+
this.path = path16;
|
|
17759
17759
|
return true;
|
|
17760
17760
|
}
|
|
17761
|
-
match2 = this.regexp.exec(
|
|
17761
|
+
match2 = this.regexp.exec(path16);
|
|
17762
17762
|
}
|
|
17763
17763
|
if (!match2) {
|
|
17764
17764
|
this.params = void 0;
|
|
@@ -17851,10 +17851,10 @@ var require_route = __commonJS({
|
|
|
17851
17851
|
var slice = Array.prototype.slice;
|
|
17852
17852
|
var toString = Object.prototype.toString;
|
|
17853
17853
|
module2.exports = Route;
|
|
17854
|
-
function Route(
|
|
17855
|
-
this.path =
|
|
17854
|
+
function Route(path16) {
|
|
17855
|
+
this.path = path16;
|
|
17856
17856
|
this.stack = [];
|
|
17857
|
-
debug("new %o",
|
|
17857
|
+
debug("new %o", path16);
|
|
17858
17858
|
this.methods = {};
|
|
17859
17859
|
}
|
|
17860
17860
|
Route.prototype._handles_method = function _handles_method(method) {
|
|
@@ -18066,8 +18066,8 @@ var require_router = __commonJS({
|
|
|
18066
18066
|
if (++sync > 100) {
|
|
18067
18067
|
return setImmediate(next, err);
|
|
18068
18068
|
}
|
|
18069
|
-
var
|
|
18070
|
-
if (
|
|
18069
|
+
var path16 = getPathname(req);
|
|
18070
|
+
if (path16 == null) {
|
|
18071
18071
|
return done(layerError);
|
|
18072
18072
|
}
|
|
18073
18073
|
var layer;
|
|
@@ -18075,7 +18075,7 @@ var require_router = __commonJS({
|
|
|
18075
18075
|
var route;
|
|
18076
18076
|
while (match !== true && idx < stack.length) {
|
|
18077
18077
|
layer = stack[idx++];
|
|
18078
|
-
match = matchLayer(layer,
|
|
18078
|
+
match = matchLayer(layer, path16);
|
|
18079
18079
|
route = layer.route;
|
|
18080
18080
|
if (typeof match !== "boolean") {
|
|
18081
18081
|
layerError = layerError || match;
|
|
@@ -18113,18 +18113,18 @@ var require_router = __commonJS({
|
|
|
18113
18113
|
} else if (route) {
|
|
18114
18114
|
layer.handle_request(req, res, next);
|
|
18115
18115
|
} else {
|
|
18116
|
-
trim_prefix(layer, layerError, layerPath,
|
|
18116
|
+
trim_prefix(layer, layerError, layerPath, path16);
|
|
18117
18117
|
}
|
|
18118
18118
|
sync = 0;
|
|
18119
18119
|
});
|
|
18120
18120
|
}
|
|
18121
|
-
function trim_prefix(layer, layerError, layerPath,
|
|
18121
|
+
function trim_prefix(layer, layerError, layerPath, path16) {
|
|
18122
18122
|
if (layerPath.length !== 0) {
|
|
18123
|
-
if (layerPath !==
|
|
18123
|
+
if (layerPath !== path16.slice(0, layerPath.length)) {
|
|
18124
18124
|
next(layerError);
|
|
18125
18125
|
return;
|
|
18126
18126
|
}
|
|
18127
|
-
var c =
|
|
18127
|
+
var c = path16[layerPath.length];
|
|
18128
18128
|
if (c && c !== "/" && c !== ".") return next(layerError);
|
|
18129
18129
|
debug("trim prefix (%s) from url %s", layerPath, req.url);
|
|
18130
18130
|
removed = layerPath;
|
|
@@ -18202,7 +18202,7 @@ var require_router = __commonJS({
|
|
|
18202
18202
|
};
|
|
18203
18203
|
proto.use = function use(fn) {
|
|
18204
18204
|
var offset = 0;
|
|
18205
|
-
var
|
|
18205
|
+
var path16 = "/";
|
|
18206
18206
|
if (typeof fn !== "function") {
|
|
18207
18207
|
var arg = fn;
|
|
18208
18208
|
while (Array.isArray(arg) && arg.length !== 0) {
|
|
@@ -18210,7 +18210,7 @@ var require_router = __commonJS({
|
|
|
18210
18210
|
}
|
|
18211
18211
|
if (typeof arg !== "function") {
|
|
18212
18212
|
offset = 1;
|
|
18213
|
-
|
|
18213
|
+
path16 = fn;
|
|
18214
18214
|
}
|
|
18215
18215
|
}
|
|
18216
18216
|
var callbacks = flatten(slice.call(arguments, offset));
|
|
@@ -18222,8 +18222,8 @@ var require_router = __commonJS({
|
|
|
18222
18222
|
if (typeof fn !== "function") {
|
|
18223
18223
|
throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
|
|
18224
18224
|
}
|
|
18225
|
-
debug("use %o %s",
|
|
18226
|
-
var layer = new Layer(
|
|
18225
|
+
debug("use %o %s", path16, fn.name || "<anonymous>");
|
|
18226
|
+
var layer = new Layer(path16, {
|
|
18227
18227
|
sensitive: this.caseSensitive,
|
|
18228
18228
|
strict: false,
|
|
18229
18229
|
end: false
|
|
@@ -18233,9 +18233,9 @@ var require_router = __commonJS({
|
|
|
18233
18233
|
}
|
|
18234
18234
|
return this;
|
|
18235
18235
|
};
|
|
18236
|
-
proto.route = function route(
|
|
18237
|
-
var route2 = new Route(
|
|
18238
|
-
var layer = new Layer(
|
|
18236
|
+
proto.route = function route(path16) {
|
|
18237
|
+
var route2 = new Route(path16);
|
|
18238
|
+
var layer = new Layer(path16, {
|
|
18239
18239
|
sensitive: this.caseSensitive,
|
|
18240
18240
|
strict: this.strict,
|
|
18241
18241
|
end: true
|
|
@@ -18245,8 +18245,8 @@ var require_router = __commonJS({
|
|
|
18245
18245
|
return route2;
|
|
18246
18246
|
};
|
|
18247
18247
|
methods.concat("all").forEach(function(method) {
|
|
18248
|
-
proto[method] = function(
|
|
18249
|
-
var route = this.route(
|
|
18248
|
+
proto[method] = function(path16) {
|
|
18249
|
+
var route = this.route(path16);
|
|
18250
18250
|
route[method].apply(route, slice.call(arguments, 1));
|
|
18251
18251
|
return this;
|
|
18252
18252
|
};
|
|
@@ -18282,9 +18282,9 @@ var require_router = __commonJS({
|
|
|
18282
18282
|
}
|
|
18283
18283
|
return toString.call(obj).replace(objectRegExp, "$1");
|
|
18284
18284
|
}
|
|
18285
|
-
function matchLayer(layer,
|
|
18285
|
+
function matchLayer(layer, path16) {
|
|
18286
18286
|
try {
|
|
18287
|
-
return layer.match(
|
|
18287
|
+
return layer.match(path16);
|
|
18288
18288
|
} catch (err) {
|
|
18289
18289
|
return err;
|
|
18290
18290
|
}
|
|
@@ -18402,18 +18402,18 @@ var require_view = __commonJS({
|
|
|
18402
18402
|
"../../node_modules/express/lib/view.js"(exports2, module2) {
|
|
18403
18403
|
"use strict";
|
|
18404
18404
|
var debug = require_src()("express:view");
|
|
18405
|
-
var
|
|
18406
|
-
var
|
|
18407
|
-
var dirname4 =
|
|
18408
|
-
var basename5 =
|
|
18409
|
-
var
|
|
18410
|
-
var
|
|
18411
|
-
var
|
|
18405
|
+
var path16 = require("path");
|
|
18406
|
+
var fs27 = require("fs");
|
|
18407
|
+
var dirname4 = path16.dirname;
|
|
18408
|
+
var basename5 = path16.basename;
|
|
18409
|
+
var extname2 = path16.extname;
|
|
18410
|
+
var join17 = path16.join;
|
|
18411
|
+
var resolve3 = path16.resolve;
|
|
18412
18412
|
module2.exports = View;
|
|
18413
18413
|
function View(name, options) {
|
|
18414
18414
|
var opts = options || {};
|
|
18415
18415
|
this.defaultEngine = opts.defaultEngine;
|
|
18416
|
-
this.ext =
|
|
18416
|
+
this.ext = extname2(name);
|
|
18417
18417
|
this.name = name;
|
|
18418
18418
|
this.root = opts.root;
|
|
18419
18419
|
if (!this.ext && !this.defaultEngine) {
|
|
@@ -18437,39 +18437,39 @@ var require_view = __commonJS({
|
|
|
18437
18437
|
this.path = this.lookup(fileName);
|
|
18438
18438
|
}
|
|
18439
18439
|
View.prototype.lookup = function lookup(name) {
|
|
18440
|
-
var
|
|
18440
|
+
var path17;
|
|
18441
18441
|
var roots = [].concat(this.root);
|
|
18442
18442
|
debug('lookup "%s"', name);
|
|
18443
|
-
for (var i = 0; i < roots.length && !
|
|
18443
|
+
for (var i = 0; i < roots.length && !path17; i++) {
|
|
18444
18444
|
var root = roots[i];
|
|
18445
|
-
var loc =
|
|
18445
|
+
var loc = resolve3(root, name);
|
|
18446
18446
|
var dir = dirname4(loc);
|
|
18447
18447
|
var file2 = basename5(loc);
|
|
18448
|
-
|
|
18448
|
+
path17 = this.resolve(dir, file2);
|
|
18449
18449
|
}
|
|
18450
|
-
return
|
|
18450
|
+
return path17;
|
|
18451
18451
|
};
|
|
18452
18452
|
View.prototype.render = function render(options, callback) {
|
|
18453
18453
|
debug('render "%s"', this.path);
|
|
18454
18454
|
this.engine(this.path, options, callback);
|
|
18455
18455
|
};
|
|
18456
|
-
View.prototype.resolve = function
|
|
18456
|
+
View.prototype.resolve = function resolve4(dir, file2) {
|
|
18457
18457
|
var ext = this.ext;
|
|
18458
|
-
var
|
|
18459
|
-
var stat2 = tryStat(
|
|
18458
|
+
var path17 = join17(dir, file2);
|
|
18459
|
+
var stat2 = tryStat(path17);
|
|
18460
18460
|
if (stat2 && stat2.isFile()) {
|
|
18461
|
-
return
|
|
18461
|
+
return path17;
|
|
18462
18462
|
}
|
|
18463
|
-
|
|
18464
|
-
stat2 = tryStat(
|
|
18463
|
+
path17 = join17(dir, basename5(file2, ext), "index" + ext);
|
|
18464
|
+
stat2 = tryStat(path17);
|
|
18465
18465
|
if (stat2 && stat2.isFile()) {
|
|
18466
|
-
return
|
|
18466
|
+
return path17;
|
|
18467
18467
|
}
|
|
18468
18468
|
};
|
|
18469
|
-
function tryStat(
|
|
18470
|
-
debug('stat "%s"',
|
|
18469
|
+
function tryStat(path17) {
|
|
18470
|
+
debug('stat "%s"', path17);
|
|
18471
18471
|
try {
|
|
18472
|
-
return
|
|
18472
|
+
return fs27.statSync(path17);
|
|
18473
18473
|
} catch (e) {
|
|
18474
18474
|
return void 0;
|
|
18475
18475
|
}
|
|
@@ -18823,8 +18823,8 @@ var require_types = __commonJS({
|
|
|
18823
18823
|
// ../../node_modules/mime/mime.js
|
|
18824
18824
|
var require_mime = __commonJS({
|
|
18825
18825
|
"../../node_modules/mime/mime.js"(exports2, module2) {
|
|
18826
|
-
var
|
|
18827
|
-
var
|
|
18826
|
+
var path16 = require("path");
|
|
18827
|
+
var fs27 = require("fs");
|
|
18828
18828
|
function Mime() {
|
|
18829
18829
|
this.types = /* @__PURE__ */ Object.create(null);
|
|
18830
18830
|
this.extensions = /* @__PURE__ */ Object.create(null);
|
|
@@ -18845,7 +18845,7 @@ var require_mime = __commonJS({
|
|
|
18845
18845
|
};
|
|
18846
18846
|
Mime.prototype.load = function(file2) {
|
|
18847
18847
|
this._loading = file2;
|
|
18848
|
-
var map2 = {}, content =
|
|
18848
|
+
var map2 = {}, content = fs27.readFileSync(file2, "ascii"), lines = content.split(/[\r\n]+/);
|
|
18849
18849
|
lines.forEach(function(line) {
|
|
18850
18850
|
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, "").split(/\s+/);
|
|
18851
18851
|
map2[fields.shift()] = fields;
|
|
@@ -18853,8 +18853,8 @@ var require_mime = __commonJS({
|
|
|
18853
18853
|
this.define(map2);
|
|
18854
18854
|
this._loading = null;
|
|
18855
18855
|
};
|
|
18856
|
-
Mime.prototype.lookup = function(
|
|
18857
|
-
var ext =
|
|
18856
|
+
Mime.prototype.lookup = function(path17, fallback) {
|
|
18857
|
+
var ext = path17.replace(/^.*[\.\/\\]/, "").toLowerCase();
|
|
18858
18858
|
return this.types[ext] || fallback || this.default_type;
|
|
18859
18859
|
};
|
|
18860
18860
|
Mime.prototype.extension = function(mimeType) {
|
|
@@ -19083,33 +19083,33 @@ var require_send = __commonJS({
|
|
|
19083
19083
|
var escapeHtml = require_escape_html();
|
|
19084
19084
|
var etag = require_etag();
|
|
19085
19085
|
var fresh = require_fresh();
|
|
19086
|
-
var
|
|
19086
|
+
var fs27 = require("fs");
|
|
19087
19087
|
var mime = require_mime();
|
|
19088
19088
|
var ms = require_ms2();
|
|
19089
19089
|
var onFinished = require_on_finished();
|
|
19090
19090
|
var parseRange = require_range_parser();
|
|
19091
|
-
var
|
|
19091
|
+
var path16 = require("path");
|
|
19092
19092
|
var statuses = require_statuses();
|
|
19093
19093
|
var Stream = require("stream");
|
|
19094
19094
|
var util = require("util");
|
|
19095
|
-
var
|
|
19096
|
-
var
|
|
19097
|
-
var normalize =
|
|
19098
|
-
var
|
|
19099
|
-
var sep =
|
|
19095
|
+
var extname2 = path16.extname;
|
|
19096
|
+
var join17 = path16.join;
|
|
19097
|
+
var normalize = path16.normalize;
|
|
19098
|
+
var resolve3 = path16.resolve;
|
|
19099
|
+
var sep = path16.sep;
|
|
19100
19100
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
19101
19101
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
19102
19102
|
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
19103
19103
|
module2.exports = send;
|
|
19104
19104
|
module2.exports.mime = mime;
|
|
19105
|
-
function send(req,
|
|
19106
|
-
return new SendStream(req,
|
|
19105
|
+
function send(req, path17, options) {
|
|
19106
|
+
return new SendStream(req, path17, options);
|
|
19107
19107
|
}
|
|
19108
|
-
function SendStream(req,
|
|
19108
|
+
function SendStream(req, path17, options) {
|
|
19109
19109
|
Stream.call(this);
|
|
19110
19110
|
var opts = options || {};
|
|
19111
19111
|
this.options = opts;
|
|
19112
|
-
this.path =
|
|
19112
|
+
this.path = path17;
|
|
19113
19113
|
this.req = req;
|
|
19114
19114
|
this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
|
|
19115
19115
|
this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
|
|
@@ -19132,7 +19132,7 @@ var require_send = __commonJS({
|
|
|
19132
19132
|
this._maxage = opts.maxAge || opts.maxage;
|
|
19133
19133
|
this._maxage = typeof this._maxage === "string" ? ms(this._maxage) : Number(this._maxage);
|
|
19134
19134
|
this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
|
|
19135
|
-
this._root = opts.root ?
|
|
19135
|
+
this._root = opts.root ? resolve3(opts.root) : null;
|
|
19136
19136
|
if (!this._root && opts.from) {
|
|
19137
19137
|
this.from(opts.from);
|
|
19138
19138
|
}
|
|
@@ -19155,8 +19155,8 @@ var require_send = __commonJS({
|
|
|
19155
19155
|
this._index = index2;
|
|
19156
19156
|
return this;
|
|
19157
19157
|
}, "send.index: pass index as option");
|
|
19158
|
-
SendStream.prototype.root = function root(
|
|
19159
|
-
this._root =
|
|
19158
|
+
SendStream.prototype.root = function root(path17) {
|
|
19159
|
+
this._root = resolve3(String(path17));
|
|
19160
19160
|
debug("root %s", this._root);
|
|
19161
19161
|
return this;
|
|
19162
19162
|
};
|
|
@@ -19269,10 +19269,10 @@ var require_send = __commonJS({
|
|
|
19269
19269
|
var lastModified = this.res.getHeader("Last-Modified");
|
|
19270
19270
|
return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
|
|
19271
19271
|
};
|
|
19272
|
-
SendStream.prototype.redirect = function redirect(
|
|
19272
|
+
SendStream.prototype.redirect = function redirect(path17) {
|
|
19273
19273
|
var res = this.res;
|
|
19274
19274
|
if (hasListeners(this, "directory")) {
|
|
19275
|
-
this.emit("directory", res,
|
|
19275
|
+
this.emit("directory", res, path17);
|
|
19276
19276
|
return;
|
|
19277
19277
|
}
|
|
19278
19278
|
if (this.hasTrailingSlash()) {
|
|
@@ -19292,42 +19292,42 @@ var require_send = __commonJS({
|
|
|
19292
19292
|
SendStream.prototype.pipe = function pipe2(res) {
|
|
19293
19293
|
var root = this._root;
|
|
19294
19294
|
this.res = res;
|
|
19295
|
-
var
|
|
19296
|
-
if (
|
|
19295
|
+
var path17 = decode3(this.path);
|
|
19296
|
+
if (path17 === -1) {
|
|
19297
19297
|
this.error(400);
|
|
19298
19298
|
return res;
|
|
19299
19299
|
}
|
|
19300
|
-
if (~
|
|
19300
|
+
if (~path17.indexOf("\0")) {
|
|
19301
19301
|
this.error(400);
|
|
19302
19302
|
return res;
|
|
19303
19303
|
}
|
|
19304
19304
|
var parts;
|
|
19305
19305
|
if (root !== null) {
|
|
19306
|
-
if (
|
|
19307
|
-
|
|
19306
|
+
if (path17) {
|
|
19307
|
+
path17 = normalize("." + sep + path17);
|
|
19308
19308
|
}
|
|
19309
|
-
if (UP_PATH_REGEXP.test(
|
|
19310
|
-
debug('malicious path "%s"',
|
|
19309
|
+
if (UP_PATH_REGEXP.test(path17)) {
|
|
19310
|
+
debug('malicious path "%s"', path17);
|
|
19311
19311
|
this.error(403);
|
|
19312
19312
|
return res;
|
|
19313
19313
|
}
|
|
19314
|
-
parts =
|
|
19315
|
-
|
|
19314
|
+
parts = path17.split(sep);
|
|
19315
|
+
path17 = normalize(join17(root, path17));
|
|
19316
19316
|
} else {
|
|
19317
|
-
if (UP_PATH_REGEXP.test(
|
|
19318
|
-
debug('malicious path "%s"',
|
|
19317
|
+
if (UP_PATH_REGEXP.test(path17)) {
|
|
19318
|
+
debug('malicious path "%s"', path17);
|
|
19319
19319
|
this.error(403);
|
|
19320
19320
|
return res;
|
|
19321
19321
|
}
|
|
19322
|
-
parts = normalize(
|
|
19323
|
-
|
|
19322
|
+
parts = normalize(path17).split(sep);
|
|
19323
|
+
path17 = resolve3(path17);
|
|
19324
19324
|
}
|
|
19325
19325
|
if (containsDotFile(parts)) {
|
|
19326
19326
|
var access4 = this._dotfiles;
|
|
19327
19327
|
if (access4 === void 0) {
|
|
19328
19328
|
access4 = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
|
|
19329
19329
|
}
|
|
19330
|
-
debug('%s dotfile "%s"', access4,
|
|
19330
|
+
debug('%s dotfile "%s"', access4, path17);
|
|
19331
19331
|
switch (access4) {
|
|
19332
19332
|
case "allow":
|
|
19333
19333
|
break;
|
|
@@ -19341,13 +19341,13 @@ var require_send = __commonJS({
|
|
|
19341
19341
|
}
|
|
19342
19342
|
}
|
|
19343
19343
|
if (this._index.length && this.hasTrailingSlash()) {
|
|
19344
|
-
this.sendIndex(
|
|
19344
|
+
this.sendIndex(path17);
|
|
19345
19345
|
return res;
|
|
19346
19346
|
}
|
|
19347
|
-
this.sendFile(
|
|
19347
|
+
this.sendFile(path17);
|
|
19348
19348
|
return res;
|
|
19349
19349
|
};
|
|
19350
|
-
SendStream.prototype.send = function send2(
|
|
19350
|
+
SendStream.prototype.send = function send2(path17, stat2) {
|
|
19351
19351
|
var len = stat2.size;
|
|
19352
19352
|
var options = this.options;
|
|
19353
19353
|
var opts = {};
|
|
@@ -19359,9 +19359,9 @@ var require_send = __commonJS({
|
|
|
19359
19359
|
this.headersAlreadySent();
|
|
19360
19360
|
return;
|
|
19361
19361
|
}
|
|
19362
|
-
debug('pipe "%s"',
|
|
19363
|
-
this.setHeader(
|
|
19364
|
-
this.type(
|
|
19362
|
+
debug('pipe "%s"', path17);
|
|
19363
|
+
this.setHeader(path17, stat2);
|
|
19364
|
+
this.type(path17);
|
|
19365
19365
|
if (this.isConditionalGET()) {
|
|
19366
19366
|
if (this.isPreconditionFailure()) {
|
|
19367
19367
|
this.error(412);
|
|
@@ -19410,28 +19410,28 @@ var require_send = __commonJS({
|
|
|
19410
19410
|
res.end();
|
|
19411
19411
|
return;
|
|
19412
19412
|
}
|
|
19413
|
-
this.stream(
|
|
19413
|
+
this.stream(path17, opts);
|
|
19414
19414
|
};
|
|
19415
|
-
SendStream.prototype.sendFile = function sendFile(
|
|
19415
|
+
SendStream.prototype.sendFile = function sendFile(path17) {
|
|
19416
19416
|
var i = 0;
|
|
19417
19417
|
var self = this;
|
|
19418
|
-
debug('stat "%s"',
|
|
19419
|
-
|
|
19420
|
-
if (err && err.code === "ENOENT" && !
|
|
19418
|
+
debug('stat "%s"', path17);
|
|
19419
|
+
fs27.stat(path17, function onstat(err, stat2) {
|
|
19420
|
+
if (err && err.code === "ENOENT" && !extname2(path17) && path17[path17.length - 1] !== sep) {
|
|
19421
19421
|
return next(err);
|
|
19422
19422
|
}
|
|
19423
19423
|
if (err) return self.onStatError(err);
|
|
19424
|
-
if (stat2.isDirectory()) return self.redirect(
|
|
19425
|
-
self.emit("file",
|
|
19426
|
-
self.send(
|
|
19424
|
+
if (stat2.isDirectory()) return self.redirect(path17);
|
|
19425
|
+
self.emit("file", path17, stat2);
|
|
19426
|
+
self.send(path17, stat2);
|
|
19427
19427
|
});
|
|
19428
19428
|
function next(err) {
|
|
19429
19429
|
if (self._extensions.length <= i) {
|
|
19430
19430
|
return err ? self.onStatError(err) : self.error(404);
|
|
19431
19431
|
}
|
|
19432
|
-
var p =
|
|
19432
|
+
var p = path17 + "." + self._extensions[i++];
|
|
19433
19433
|
debug('stat "%s"', p);
|
|
19434
|
-
|
|
19434
|
+
fs27.stat(p, function(err2, stat2) {
|
|
19435
19435
|
if (err2) return next(err2);
|
|
19436
19436
|
if (stat2.isDirectory()) return next();
|
|
19437
19437
|
self.emit("file", p, stat2);
|
|
@@ -19439,7 +19439,7 @@ var require_send = __commonJS({
|
|
|
19439
19439
|
});
|
|
19440
19440
|
}
|
|
19441
19441
|
};
|
|
19442
|
-
SendStream.prototype.sendIndex = function sendIndex(
|
|
19442
|
+
SendStream.prototype.sendIndex = function sendIndex(path17) {
|
|
19443
19443
|
var i = -1;
|
|
19444
19444
|
var self = this;
|
|
19445
19445
|
function next(err) {
|
|
@@ -19447,9 +19447,9 @@ var require_send = __commonJS({
|
|
|
19447
19447
|
if (err) return self.onStatError(err);
|
|
19448
19448
|
return self.error(404);
|
|
19449
19449
|
}
|
|
19450
|
-
var p =
|
|
19450
|
+
var p = join17(path17, self._index[i]);
|
|
19451
19451
|
debug('stat "%s"', p);
|
|
19452
|
-
|
|
19452
|
+
fs27.stat(p, function(err2, stat2) {
|
|
19453
19453
|
if (err2) return next(err2);
|
|
19454
19454
|
if (stat2.isDirectory()) return next();
|
|
19455
19455
|
self.emit("file", p, stat2);
|
|
@@ -19458,10 +19458,10 @@ var require_send = __commonJS({
|
|
|
19458
19458
|
}
|
|
19459
19459
|
next();
|
|
19460
19460
|
};
|
|
19461
|
-
SendStream.prototype.stream = function stream(
|
|
19461
|
+
SendStream.prototype.stream = function stream(path17, options) {
|
|
19462
19462
|
var self = this;
|
|
19463
19463
|
var res = this.res;
|
|
19464
|
-
var stream2 =
|
|
19464
|
+
var stream2 = fs27.createReadStream(path17, options);
|
|
19465
19465
|
this.emit("stream", stream2);
|
|
19466
19466
|
stream2.pipe(res);
|
|
19467
19467
|
function cleanup() {
|
|
@@ -19476,10 +19476,10 @@ var require_send = __commonJS({
|
|
|
19476
19476
|
self.emit("end");
|
|
19477
19477
|
});
|
|
19478
19478
|
};
|
|
19479
|
-
SendStream.prototype.type = function type(
|
|
19479
|
+
SendStream.prototype.type = function type(path17) {
|
|
19480
19480
|
var res = this.res;
|
|
19481
19481
|
if (res.getHeader("Content-Type")) return;
|
|
19482
|
-
var type2 = mime.lookup(
|
|
19482
|
+
var type2 = mime.lookup(path17);
|
|
19483
19483
|
if (!type2) {
|
|
19484
19484
|
debug("no content-type");
|
|
19485
19485
|
return;
|
|
@@ -19488,9 +19488,9 @@ var require_send = __commonJS({
|
|
|
19488
19488
|
debug("content-type %s", type2);
|
|
19489
19489
|
res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
|
|
19490
19490
|
};
|
|
19491
|
-
SendStream.prototype.setHeader = function setHeader(
|
|
19491
|
+
SendStream.prototype.setHeader = function setHeader(path17, stat2) {
|
|
19492
19492
|
var res = this.res;
|
|
19493
|
-
this.emit("headers", res,
|
|
19493
|
+
this.emit("headers", res, path17, stat2);
|
|
19494
19494
|
if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
|
|
19495
19495
|
debug("accept ranges");
|
|
19496
19496
|
res.setHeader("Accept-Ranges", "bytes");
|
|
@@ -19549,9 +19549,9 @@ var require_send = __commonJS({
|
|
|
19549
19549
|
}
|
|
19550
19550
|
return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
|
|
19551
19551
|
}
|
|
19552
|
-
function decode3(
|
|
19552
|
+
function decode3(path17) {
|
|
19553
19553
|
try {
|
|
19554
|
-
return decodeURIComponent(
|
|
19554
|
+
return decodeURIComponent(path17);
|
|
19555
19555
|
} catch (err) {
|
|
19556
19556
|
return -1;
|
|
19557
19557
|
}
|
|
@@ -20460,10 +20460,10 @@ var require_utils2 = __commonJS({
|
|
|
20460
20460
|
var querystring = require("querystring");
|
|
20461
20461
|
exports2.etag = createETagGenerator({ weak: false });
|
|
20462
20462
|
exports2.wetag = createETagGenerator({ weak: true });
|
|
20463
|
-
exports2.isAbsolute = function(
|
|
20464
|
-
if ("/" ===
|
|
20465
|
-
if (":" ===
|
|
20466
|
-
if ("\\\\" ===
|
|
20463
|
+
exports2.isAbsolute = function(path16) {
|
|
20464
|
+
if ("/" === path16[0]) return true;
|
|
20465
|
+
if (":" === path16[1] && ("\\" === path16[2] || "/" === path16[2])) return true;
|
|
20466
|
+
if ("\\\\" === path16.substring(0, 2)) return true;
|
|
20467
20467
|
};
|
|
20468
20468
|
exports2.flatten = deprecate.function(
|
|
20469
20469
|
flatten,
|
|
@@ -20599,7 +20599,7 @@ var require_application = __commonJS({
|
|
|
20599
20599
|
var deprecate = require_depd()("express");
|
|
20600
20600
|
var flatten = require_array_flatten();
|
|
20601
20601
|
var merge2 = require_utils_merge();
|
|
20602
|
-
var
|
|
20602
|
+
var resolve3 = require("path").resolve;
|
|
20603
20603
|
var setPrototypeOf = require_setprototypeof();
|
|
20604
20604
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
20605
20605
|
var slice = Array.prototype.slice;
|
|
@@ -20638,7 +20638,7 @@ var require_application = __commonJS({
|
|
|
20638
20638
|
this.mountpath = "/";
|
|
20639
20639
|
this.locals.settings = this.settings;
|
|
20640
20640
|
this.set("view", View);
|
|
20641
|
-
this.set("views",
|
|
20641
|
+
this.set("views", resolve3("views"));
|
|
20642
20642
|
this.set("jsonp callback name", "callback");
|
|
20643
20643
|
if (env === "production") {
|
|
20644
20644
|
this.enable("view cache");
|
|
@@ -20674,7 +20674,7 @@ var require_application = __commonJS({
|
|
|
20674
20674
|
};
|
|
20675
20675
|
app.use = function use(fn) {
|
|
20676
20676
|
var offset = 0;
|
|
20677
|
-
var
|
|
20677
|
+
var path16 = "/";
|
|
20678
20678
|
if (typeof fn !== "function") {
|
|
20679
20679
|
var arg = fn;
|
|
20680
20680
|
while (Array.isArray(arg) && arg.length !== 0) {
|
|
@@ -20682,7 +20682,7 @@ var require_application = __commonJS({
|
|
|
20682
20682
|
}
|
|
20683
20683
|
if (typeof arg !== "function") {
|
|
20684
20684
|
offset = 1;
|
|
20685
|
-
|
|
20685
|
+
path16 = fn;
|
|
20686
20686
|
}
|
|
20687
20687
|
}
|
|
20688
20688
|
var fns = flatten(slice.call(arguments, offset));
|
|
@@ -20693,12 +20693,12 @@ var require_application = __commonJS({
|
|
|
20693
20693
|
var router = this._router;
|
|
20694
20694
|
fns.forEach(function(fn2) {
|
|
20695
20695
|
if (!fn2 || !fn2.handle || !fn2.set) {
|
|
20696
|
-
return router.use(
|
|
20696
|
+
return router.use(path16, fn2);
|
|
20697
20697
|
}
|
|
20698
|
-
debug(".use app under %s",
|
|
20699
|
-
fn2.mountpath =
|
|
20698
|
+
debug(".use app under %s", path16);
|
|
20699
|
+
fn2.mountpath = path16;
|
|
20700
20700
|
fn2.parent = this;
|
|
20701
|
-
router.use(
|
|
20701
|
+
router.use(path16, function mounted_app(req, res, next) {
|
|
20702
20702
|
var orig = req.app;
|
|
20703
20703
|
fn2.handle(req, res, function(err) {
|
|
20704
20704
|
setPrototypeOf(req, orig.request);
|
|
@@ -20710,9 +20710,9 @@ var require_application = __commonJS({
|
|
|
20710
20710
|
}, this);
|
|
20711
20711
|
return this;
|
|
20712
20712
|
};
|
|
20713
|
-
app.route = function route(
|
|
20713
|
+
app.route = function route(path16) {
|
|
20714
20714
|
this.lazyrouter();
|
|
20715
|
-
return this._router.route(
|
|
20715
|
+
return this._router.route(path16);
|
|
20716
20716
|
};
|
|
20717
20717
|
app.engine = function engine(ext, fn) {
|
|
20718
20718
|
if (typeof fn !== "function") {
|
|
@@ -20763,7 +20763,7 @@ var require_application = __commonJS({
|
|
|
20763
20763
|
}
|
|
20764
20764
|
return this;
|
|
20765
20765
|
};
|
|
20766
|
-
app.path = function
|
|
20766
|
+
app.path = function path16() {
|
|
20767
20767
|
return this.parent ? this.parent.path() + this.mountpath : "";
|
|
20768
20768
|
};
|
|
20769
20769
|
app.enabled = function enabled(setting) {
|
|
@@ -20779,19 +20779,19 @@ var require_application = __commonJS({
|
|
|
20779
20779
|
return this.set(setting, false);
|
|
20780
20780
|
};
|
|
20781
20781
|
methods.forEach(function(method) {
|
|
20782
|
-
app[method] = function(
|
|
20782
|
+
app[method] = function(path16) {
|
|
20783
20783
|
if (method === "get" && arguments.length === 1) {
|
|
20784
|
-
return this.set(
|
|
20784
|
+
return this.set(path16);
|
|
20785
20785
|
}
|
|
20786
20786
|
this.lazyrouter();
|
|
20787
|
-
var route = this._router.route(
|
|
20787
|
+
var route = this._router.route(path16);
|
|
20788
20788
|
route[method].apply(route, slice.call(arguments, 1));
|
|
20789
20789
|
return this;
|
|
20790
20790
|
};
|
|
20791
20791
|
});
|
|
20792
|
-
app.all = function all(
|
|
20792
|
+
app.all = function all(path16) {
|
|
20793
20793
|
this.lazyrouter();
|
|
20794
|
-
var route = this._router.route(
|
|
20794
|
+
var route = this._router.route(path16);
|
|
20795
20795
|
var args = slice.call(arguments, 1);
|
|
20796
20796
|
for (var i = 0; i < methods.length; i++) {
|
|
20797
20797
|
route[methods[i]].apply(route, args);
|
|
@@ -21550,7 +21550,7 @@ var require_request = __commonJS({
|
|
|
21550
21550
|
var subdomains2 = !isIP(hostname3) ? hostname3.split(".").reverse() : [hostname3];
|
|
21551
21551
|
return subdomains2.slice(offset);
|
|
21552
21552
|
});
|
|
21553
|
-
defineGetter(req, "path", function
|
|
21553
|
+
defineGetter(req, "path", function path16() {
|
|
21554
21554
|
return parse3(this).pathname;
|
|
21555
21555
|
});
|
|
21556
21556
|
defineGetter(req, "hostname", function hostname3() {
|
|
@@ -21872,7 +21872,7 @@ var require_response = __commonJS({
|
|
|
21872
21872
|
var http2 = require("http");
|
|
21873
21873
|
var isAbsolute3 = require_utils2().isAbsolute;
|
|
21874
21874
|
var onFinished = require_on_finished();
|
|
21875
|
-
var
|
|
21875
|
+
var path16 = require("path");
|
|
21876
21876
|
var statuses = require_statuses();
|
|
21877
21877
|
var merge2 = require_utils_merge();
|
|
21878
21878
|
var sign = require_cookie_signature().sign;
|
|
@@ -21881,9 +21881,9 @@ var require_response = __commonJS({
|
|
|
21881
21881
|
var setCharset = require_utils2().setCharset;
|
|
21882
21882
|
var cookie = require_cookie();
|
|
21883
21883
|
var send = require_send();
|
|
21884
|
-
var
|
|
21884
|
+
var extname2 = path16.extname;
|
|
21885
21885
|
var mime = send.mime;
|
|
21886
|
-
var
|
|
21886
|
+
var resolve3 = path16.resolve;
|
|
21887
21887
|
var vary = require_vary();
|
|
21888
21888
|
var res = Object.create(http2.ServerResponse.prototype);
|
|
21889
21889
|
module2.exports = res;
|
|
@@ -22060,26 +22060,26 @@ var require_response = __commonJS({
|
|
|
22060
22060
|
this.type("txt");
|
|
22061
22061
|
return this.send(body);
|
|
22062
22062
|
};
|
|
22063
|
-
res.sendFile = function sendFile(
|
|
22063
|
+
res.sendFile = function sendFile(path17, options, callback) {
|
|
22064
22064
|
var done = callback;
|
|
22065
22065
|
var req = this.req;
|
|
22066
22066
|
var res2 = this;
|
|
22067
22067
|
var next = req.next;
|
|
22068
22068
|
var opts = options || {};
|
|
22069
|
-
if (!
|
|
22069
|
+
if (!path17) {
|
|
22070
22070
|
throw new TypeError("path argument is required to res.sendFile");
|
|
22071
22071
|
}
|
|
22072
|
-
if (typeof
|
|
22072
|
+
if (typeof path17 !== "string") {
|
|
22073
22073
|
throw new TypeError("path must be a string to res.sendFile");
|
|
22074
22074
|
}
|
|
22075
22075
|
if (typeof options === "function") {
|
|
22076
22076
|
done = options;
|
|
22077
22077
|
opts = {};
|
|
22078
22078
|
}
|
|
22079
|
-
if (!opts.root && !isAbsolute3(
|
|
22079
|
+
if (!opts.root && !isAbsolute3(path17)) {
|
|
22080
22080
|
throw new TypeError("path must be absolute or specify root to res.sendFile");
|
|
22081
22081
|
}
|
|
22082
|
-
var pathname = encodeURI(
|
|
22082
|
+
var pathname = encodeURI(path17);
|
|
22083
22083
|
var file2 = send(req, pathname, opts);
|
|
22084
22084
|
sendfile(res2, file2, opts, function(err) {
|
|
22085
22085
|
if (done) return done(err);
|
|
@@ -22089,7 +22089,7 @@ var require_response = __commonJS({
|
|
|
22089
22089
|
}
|
|
22090
22090
|
});
|
|
22091
22091
|
};
|
|
22092
|
-
res.sendfile = function(
|
|
22092
|
+
res.sendfile = function(path17, options, callback) {
|
|
22093
22093
|
var done = callback;
|
|
22094
22094
|
var req = this.req;
|
|
22095
22095
|
var res2 = this;
|
|
@@ -22099,7 +22099,7 @@ var require_response = __commonJS({
|
|
|
22099
22099
|
done = options;
|
|
22100
22100
|
opts = {};
|
|
22101
22101
|
}
|
|
22102
|
-
var file2 = send(req,
|
|
22102
|
+
var file2 = send(req, path17, opts);
|
|
22103
22103
|
sendfile(res2, file2, opts, function(err) {
|
|
22104
22104
|
if (done) return done(err);
|
|
22105
22105
|
if (err && err.code === "EISDIR") return next();
|
|
@@ -22112,7 +22112,7 @@ var require_response = __commonJS({
|
|
|
22112
22112
|
res.sendfile,
|
|
22113
22113
|
"res.sendfile: Use res.sendFile instead"
|
|
22114
22114
|
);
|
|
22115
|
-
res.download = function download(
|
|
22115
|
+
res.download = function download(path17, filename, options, callback) {
|
|
22116
22116
|
var done = callback;
|
|
22117
22117
|
var name = filename;
|
|
22118
22118
|
var opts = options || null;
|
|
@@ -22129,7 +22129,7 @@ var require_response = __commonJS({
|
|
|
22129
22129
|
opts = filename;
|
|
22130
22130
|
}
|
|
22131
22131
|
var headers = {
|
|
22132
|
-
"Content-Disposition": contentDisposition(name ||
|
|
22132
|
+
"Content-Disposition": contentDisposition(name || path17)
|
|
22133
22133
|
};
|
|
22134
22134
|
if (opts && opts.headers) {
|
|
22135
22135
|
var keys = Object.keys(opts.headers);
|
|
@@ -22142,7 +22142,7 @@ var require_response = __commonJS({
|
|
|
22142
22142
|
}
|
|
22143
22143
|
opts = Object.create(opts);
|
|
22144
22144
|
opts.headers = headers;
|
|
22145
|
-
var fullPath = !opts.root ?
|
|
22145
|
+
var fullPath = !opts.root ? resolve3(path17) : path17;
|
|
22146
22146
|
return this.sendFile(fullPath, opts, done);
|
|
22147
22147
|
};
|
|
22148
22148
|
res.contentType = res.type = function contentType(type) {
|
|
@@ -22173,7 +22173,7 @@ var require_response = __commonJS({
|
|
|
22173
22173
|
};
|
|
22174
22174
|
res.attachment = function attachment(filename) {
|
|
22175
22175
|
if (filename) {
|
|
22176
|
-
this.type(
|
|
22176
|
+
this.type(extname2(filename));
|
|
22177
22177
|
}
|
|
22178
22178
|
this.set("Content-Disposition", contentDisposition(filename));
|
|
22179
22179
|
return this;
|
|
@@ -22408,7 +22408,7 @@ var require_serve_static = __commonJS({
|
|
|
22408
22408
|
var encodeUrl = require_encodeurl();
|
|
22409
22409
|
var escapeHtml = require_escape_html();
|
|
22410
22410
|
var parseUrl = require_parseurl();
|
|
22411
|
-
var
|
|
22411
|
+
var resolve3 = require("path").resolve;
|
|
22412
22412
|
var send = require_send();
|
|
22413
22413
|
var url2 = require("url");
|
|
22414
22414
|
module2.exports = serveStatic;
|
|
@@ -22428,7 +22428,7 @@ var require_serve_static = __commonJS({
|
|
|
22428
22428
|
throw new TypeError("option setHeaders must be function");
|
|
22429
22429
|
}
|
|
22430
22430
|
opts.maxage = opts.maxage || opts.maxAge || 0;
|
|
22431
|
-
opts.root =
|
|
22431
|
+
opts.root = resolve3(root);
|
|
22432
22432
|
var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
|
|
22433
22433
|
return function serveStatic2(req, res, next) {
|
|
22434
22434
|
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
@@ -22443,11 +22443,11 @@ var require_serve_static = __commonJS({
|
|
|
22443
22443
|
}
|
|
22444
22444
|
var forwardError = !fallthrough;
|
|
22445
22445
|
var originalUrl = parseUrl.original(req);
|
|
22446
|
-
var
|
|
22447
|
-
if (
|
|
22448
|
-
|
|
22446
|
+
var path16 = parseUrl(req).pathname;
|
|
22447
|
+
if (path16 === "/" && originalUrl.pathname.substr(-1) !== "/") {
|
|
22448
|
+
path16 = "";
|
|
22449
22449
|
}
|
|
22450
|
-
var stream = send(req,
|
|
22450
|
+
var stream = send(req, path16, opts);
|
|
22451
22451
|
stream.on("directory", onDirectory);
|
|
22452
22452
|
if (setHeaders) {
|
|
22453
22453
|
stream.on("headers", setHeaders);
|
|
@@ -23420,10 +23420,10 @@ var require_truncate = __commonJS({
|
|
|
23420
23420
|
"../../node_modules/semver/functions/truncate.js"(exports2, module2) {
|
|
23421
23421
|
"use strict";
|
|
23422
23422
|
var parse3 = require_parse2();
|
|
23423
|
-
var
|
|
23423
|
+
var constants2 = require_constants();
|
|
23424
23424
|
var SemVer = require_semver();
|
|
23425
23425
|
var truncate = (version3, truncation, options) => {
|
|
23426
|
-
if (!
|
|
23426
|
+
if (!constants2.RELEASE_TYPES.includes(truncation)) {
|
|
23427
23427
|
return null;
|
|
23428
23428
|
}
|
|
23429
23429
|
const clonedVersion = cloneInputVersion(version3, options);
|
|
@@ -24464,7 +24464,7 @@ var require_semver2 = __commonJS({
|
|
|
24464
24464
|
"../../node_modules/semver/index.js"(exports2, module2) {
|
|
24465
24465
|
"use strict";
|
|
24466
24466
|
var internalRe = require_re();
|
|
24467
|
-
var
|
|
24467
|
+
var constants2 = require_constants();
|
|
24468
24468
|
var SemVer = require_semver();
|
|
24469
24469
|
var identifiers = require_identifiers();
|
|
24470
24470
|
var parse3 = require_parse2();
|
|
@@ -24548,8 +24548,8 @@ var require_semver2 = __commonJS({
|
|
|
24548
24548
|
re: internalRe.re,
|
|
24549
24549
|
src: internalRe.src,
|
|
24550
24550
|
tokens: internalRe.t,
|
|
24551
|
-
SEMVER_SPEC_VERSION:
|
|
24552
|
-
RELEASE_TYPES:
|
|
24551
|
+
SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
|
|
24552
|
+
RELEASE_TYPES: constants2.RELEASE_TYPES,
|
|
24553
24553
|
compareIdentifiers: identifiers.compareIdentifiers,
|
|
24554
24554
|
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
24555
24555
|
};
|
|
@@ -24661,13 +24661,13 @@ var require_min_release_age = __commonJS({
|
|
|
24661
24661
|
return Number.isFinite(days) && days > 0 ? days * config_parse_1.DAY_MS : 0;
|
|
24662
24662
|
}
|
|
24663
24663
|
function probe3(p) {
|
|
24664
|
-
return new Promise((
|
|
24664
|
+
return new Promise((resolve3) => {
|
|
24665
24665
|
(0, node_child_process_1.exec)(p.command, { timeout: PROBE_TIMEOUT_MS, windowsHide: true }, (err, stdout) => {
|
|
24666
24666
|
if (err) {
|
|
24667
|
-
|
|
24667
|
+
resolve3(0);
|
|
24668
24668
|
return;
|
|
24669
24669
|
}
|
|
24670
|
-
|
|
24670
|
+
resolve3(p.parse(stdout));
|
|
24671
24671
|
});
|
|
24672
24672
|
});
|
|
24673
24673
|
}
|
|
@@ -24700,12 +24700,12 @@ var require_registry = __commonJS({
|
|
|
24700
24700
|
var node_https_1 = __importDefault(require("node:https"));
|
|
24701
24701
|
var REQUEST_TIMEOUT_MS = 1e4;
|
|
24702
24702
|
function fetchRegistryInfo2(url2) {
|
|
24703
|
-
return new Promise((
|
|
24703
|
+
return new Promise((resolve3) => {
|
|
24704
24704
|
let resolved = false;
|
|
24705
24705
|
const safeResolve = (value) => {
|
|
24706
24706
|
if (!resolved) {
|
|
24707
24707
|
resolved = true;
|
|
24708
|
-
|
|
24708
|
+
resolve3(value);
|
|
24709
24709
|
}
|
|
24710
24710
|
};
|
|
24711
24711
|
const req = node_https_1.default.get(url2, { timeout: REQUEST_TIMEOUT_MS }, (res) => {
|
|
@@ -24841,72 +24841,6 @@ var require_dist = __commonJS({
|
|
|
24841
24841
|
}
|
|
24842
24842
|
});
|
|
24843
24843
|
|
|
24844
|
-
// ../native-devtools-android/dist/index.js
|
|
24845
|
-
var require_dist2 = __commonJS({
|
|
24846
|
-
"../native-devtools-android/dist/index.js"(exports2) {
|
|
24847
|
-
"use strict";
|
|
24848
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
24849
|
-
if (k2 === void 0) k2 = k;
|
|
24850
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24851
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24852
|
-
desc = { enumerable: true, get: function() {
|
|
24853
|
-
return m[k];
|
|
24854
|
-
} };
|
|
24855
|
-
}
|
|
24856
|
-
Object.defineProperty(o, k2, desc);
|
|
24857
|
-
}) : (function(o, m, k, k2) {
|
|
24858
|
-
if (k2 === void 0) k2 = k;
|
|
24859
|
-
o[k2] = m[k];
|
|
24860
|
-
}));
|
|
24861
|
-
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
24862
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24863
|
-
}) : function(o, v) {
|
|
24864
|
-
o["default"] = v;
|
|
24865
|
-
});
|
|
24866
|
-
var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
|
|
24867
|
-
var ownKeys = function(o) {
|
|
24868
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
24869
|
-
var ar = [];
|
|
24870
|
-
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
24871
|
-
return ar;
|
|
24872
|
-
};
|
|
24873
|
-
return ownKeys(o);
|
|
24874
|
-
};
|
|
24875
|
-
return function(mod) {
|
|
24876
|
-
if (mod && mod.__esModule) return mod;
|
|
24877
|
-
var result = {};
|
|
24878
|
-
if (mod != null) {
|
|
24879
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
24880
|
-
}
|
|
24881
|
-
__setModuleDefault(result, mod);
|
|
24882
|
-
return result;
|
|
24883
|
-
};
|
|
24884
|
-
})();
|
|
24885
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24886
|
-
exports2.helperManifest = helperManifest3;
|
|
24887
|
-
exports2.bundledHelperApkPath = bundledHelperApkPath2;
|
|
24888
|
-
var path15 = __importStar(require("node:path"));
|
|
24889
|
-
var fs25 = __importStar(require("node:fs"));
|
|
24890
|
-
var DIST_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_DIR ?? path15.join(__dirname, "..", "dist");
|
|
24891
|
-
var cachedManifest = null;
|
|
24892
|
-
function helperManifest3() {
|
|
24893
|
-
if (cachedManifest)
|
|
24894
|
-
return cachedManifest;
|
|
24895
|
-
const manifestPath = path15.join(__dirname, "..", "manifest.json");
|
|
24896
|
-
cachedManifest = JSON.parse(fs25.readFileSync(manifestPath, "utf-8"));
|
|
24897
|
-
return cachedManifest;
|
|
24898
|
-
}
|
|
24899
|
-
function bundledHelperApkPath2() {
|
|
24900
|
-
const manifest = helperManifest3();
|
|
24901
|
-
const apk = path15.join(DIST_DIR, `argent-android-devtools-${manifest.versionName}.apk`);
|
|
24902
|
-
if (!fs25.existsSync(apk)) {
|
|
24903
|
-
throw new Error(`Bundled Android devtools helper APK not found at ${apk}. Run \`bash packages/native-devtools-android/scripts/build.sh\` to build it.`);
|
|
24904
|
-
}
|
|
24905
|
-
return apk;
|
|
24906
|
-
}
|
|
24907
|
-
}
|
|
24908
|
-
});
|
|
24909
|
-
|
|
24910
24844
|
// ../../node_modules/ws/lib/constants.js
|
|
24911
24845
|
var require_constants2 = __commonJS({
|
|
24912
24846
|
"../../node_modules/ws/lib/constants.js"(exports2, module2) {
|
|
@@ -28692,27 +28626,27 @@ var require_util = __commonJS({
|
|
|
28692
28626
|
};
|
|
28693
28627
|
}
|
|
28694
28628
|
var normalize = lruMemoize(function normalize2(aPath) {
|
|
28695
|
-
var
|
|
28629
|
+
var path16 = aPath;
|
|
28696
28630
|
var url2 = urlParse(aPath);
|
|
28697
28631
|
if (url2) {
|
|
28698
28632
|
if (!url2.path) {
|
|
28699
28633
|
return aPath;
|
|
28700
28634
|
}
|
|
28701
|
-
|
|
28635
|
+
path16 = url2.path;
|
|
28702
28636
|
}
|
|
28703
|
-
var isAbsolute3 = exports2.isAbsolute(
|
|
28637
|
+
var isAbsolute3 = exports2.isAbsolute(path16);
|
|
28704
28638
|
var parts = [];
|
|
28705
28639
|
var start2 = 0;
|
|
28706
28640
|
var i = 0;
|
|
28707
28641
|
while (true) {
|
|
28708
28642
|
start2 = i;
|
|
28709
|
-
i =
|
|
28643
|
+
i = path16.indexOf("/", start2);
|
|
28710
28644
|
if (i === -1) {
|
|
28711
|
-
parts.push(
|
|
28645
|
+
parts.push(path16.slice(start2));
|
|
28712
28646
|
break;
|
|
28713
28647
|
} else {
|
|
28714
|
-
parts.push(
|
|
28715
|
-
while (i <
|
|
28648
|
+
parts.push(path16.slice(start2, i));
|
|
28649
|
+
while (i < path16.length && path16[i] === "/") {
|
|
28716
28650
|
i++;
|
|
28717
28651
|
}
|
|
28718
28652
|
}
|
|
@@ -28733,18 +28667,18 @@ var require_util = __commonJS({
|
|
|
28733
28667
|
}
|
|
28734
28668
|
}
|
|
28735
28669
|
}
|
|
28736
|
-
|
|
28737
|
-
if (
|
|
28738
|
-
|
|
28670
|
+
path16 = parts.join("/");
|
|
28671
|
+
if (path16 === "") {
|
|
28672
|
+
path16 = isAbsolute3 ? "/" : ".";
|
|
28739
28673
|
}
|
|
28740
28674
|
if (url2) {
|
|
28741
|
-
url2.path =
|
|
28675
|
+
url2.path = path16;
|
|
28742
28676
|
return urlGenerate(url2);
|
|
28743
28677
|
}
|
|
28744
|
-
return
|
|
28678
|
+
return path16;
|
|
28745
28679
|
});
|
|
28746
28680
|
exports2.normalize = normalize;
|
|
28747
|
-
function
|
|
28681
|
+
function join17(aRoot, aPath) {
|
|
28748
28682
|
if (aRoot === "") {
|
|
28749
28683
|
aRoot = ".";
|
|
28750
28684
|
}
|
|
@@ -28776,11 +28710,11 @@ var require_util = __commonJS({
|
|
|
28776
28710
|
}
|
|
28777
28711
|
return joined;
|
|
28778
28712
|
}
|
|
28779
|
-
exports2.join =
|
|
28713
|
+
exports2.join = join17;
|
|
28780
28714
|
exports2.isAbsolute = function(aPath) {
|
|
28781
28715
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
28782
28716
|
};
|
|
28783
|
-
function
|
|
28717
|
+
function relative3(aRoot, aPath) {
|
|
28784
28718
|
if (aRoot === "") {
|
|
28785
28719
|
aRoot = ".";
|
|
28786
28720
|
}
|
|
@@ -28799,7 +28733,7 @@ var require_util = __commonJS({
|
|
|
28799
28733
|
}
|
|
28800
28734
|
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
|
28801
28735
|
}
|
|
28802
|
-
exports2.relative =
|
|
28736
|
+
exports2.relative = relative3;
|
|
28803
28737
|
var supportsNullProto = (function() {
|
|
28804
28738
|
var obj = /* @__PURE__ */ Object.create(null);
|
|
28805
28739
|
return !("__proto__" in obj);
|
|
@@ -28990,7 +28924,7 @@ var require_util = __commonJS({
|
|
|
28990
28924
|
parsed.path = parsed.path.substring(0, index + 1);
|
|
28991
28925
|
}
|
|
28992
28926
|
}
|
|
28993
|
-
sourceURL =
|
|
28927
|
+
sourceURL = join17(urlGenerate(parsed), sourceURL);
|
|
28994
28928
|
}
|
|
28995
28929
|
return normalize(sourceURL);
|
|
28996
28930
|
}
|
|
@@ -30503,17 +30437,17 @@ var require_visit = __commonJS({
|
|
|
30503
30437
|
visit.BREAK = BREAK;
|
|
30504
30438
|
visit.SKIP = SKIP;
|
|
30505
30439
|
visit.REMOVE = REMOVE;
|
|
30506
|
-
function visit_(key, node, visitor,
|
|
30507
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
30440
|
+
function visit_(key, node, visitor, path16) {
|
|
30441
|
+
const ctrl = callVisitor(key, node, visitor, path16);
|
|
30508
30442
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
30509
|
-
replaceNode(key,
|
|
30510
|
-
return visit_(key, ctrl, visitor,
|
|
30443
|
+
replaceNode(key, path16, ctrl);
|
|
30444
|
+
return visit_(key, ctrl, visitor, path16);
|
|
30511
30445
|
}
|
|
30512
30446
|
if (typeof ctrl !== "symbol") {
|
|
30513
30447
|
if (identity.isCollection(node)) {
|
|
30514
|
-
|
|
30448
|
+
path16 = Object.freeze(path16.concat(node));
|
|
30515
30449
|
for (let i = 0; i < node.items.length; ++i) {
|
|
30516
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
30450
|
+
const ci = visit_(i, node.items[i], visitor, path16);
|
|
30517
30451
|
if (typeof ci === "number")
|
|
30518
30452
|
i = ci - 1;
|
|
30519
30453
|
else if (ci === BREAK)
|
|
@@ -30524,13 +30458,13 @@ var require_visit = __commonJS({
|
|
|
30524
30458
|
}
|
|
30525
30459
|
}
|
|
30526
30460
|
} else if (identity.isPair(node)) {
|
|
30527
|
-
|
|
30528
|
-
const ck = visit_("key", node.key, visitor,
|
|
30461
|
+
path16 = Object.freeze(path16.concat(node));
|
|
30462
|
+
const ck = visit_("key", node.key, visitor, path16);
|
|
30529
30463
|
if (ck === BREAK)
|
|
30530
30464
|
return BREAK;
|
|
30531
30465
|
else if (ck === REMOVE)
|
|
30532
30466
|
node.key = null;
|
|
30533
|
-
const cv = visit_("value", node.value, visitor,
|
|
30467
|
+
const cv = visit_("value", node.value, visitor, path16);
|
|
30534
30468
|
if (cv === BREAK)
|
|
30535
30469
|
return BREAK;
|
|
30536
30470
|
else if (cv === REMOVE)
|
|
@@ -30551,17 +30485,17 @@ var require_visit = __commonJS({
|
|
|
30551
30485
|
visitAsync.BREAK = BREAK;
|
|
30552
30486
|
visitAsync.SKIP = SKIP;
|
|
30553
30487
|
visitAsync.REMOVE = REMOVE;
|
|
30554
|
-
async function visitAsync_(key, node, visitor,
|
|
30555
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
30488
|
+
async function visitAsync_(key, node, visitor, path16) {
|
|
30489
|
+
const ctrl = await callVisitor(key, node, visitor, path16);
|
|
30556
30490
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
30557
|
-
replaceNode(key,
|
|
30558
|
-
return visitAsync_(key, ctrl, visitor,
|
|
30491
|
+
replaceNode(key, path16, ctrl);
|
|
30492
|
+
return visitAsync_(key, ctrl, visitor, path16);
|
|
30559
30493
|
}
|
|
30560
30494
|
if (typeof ctrl !== "symbol") {
|
|
30561
30495
|
if (identity.isCollection(node)) {
|
|
30562
|
-
|
|
30496
|
+
path16 = Object.freeze(path16.concat(node));
|
|
30563
30497
|
for (let i = 0; i < node.items.length; ++i) {
|
|
30564
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
30498
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path16);
|
|
30565
30499
|
if (typeof ci === "number")
|
|
30566
30500
|
i = ci - 1;
|
|
30567
30501
|
else if (ci === BREAK)
|
|
@@ -30572,13 +30506,13 @@ var require_visit = __commonJS({
|
|
|
30572
30506
|
}
|
|
30573
30507
|
}
|
|
30574
30508
|
} else if (identity.isPair(node)) {
|
|
30575
|
-
|
|
30576
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
30509
|
+
path16 = Object.freeze(path16.concat(node));
|
|
30510
|
+
const ck = await visitAsync_("key", node.key, visitor, path16);
|
|
30577
30511
|
if (ck === BREAK)
|
|
30578
30512
|
return BREAK;
|
|
30579
30513
|
else if (ck === REMOVE)
|
|
30580
30514
|
node.key = null;
|
|
30581
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
30515
|
+
const cv = await visitAsync_("value", node.value, visitor, path16);
|
|
30582
30516
|
if (cv === BREAK)
|
|
30583
30517
|
return BREAK;
|
|
30584
30518
|
else if (cv === REMOVE)
|
|
@@ -30605,23 +30539,23 @@ var require_visit = __commonJS({
|
|
|
30605
30539
|
}
|
|
30606
30540
|
return visitor;
|
|
30607
30541
|
}
|
|
30608
|
-
function callVisitor(key, node, visitor,
|
|
30542
|
+
function callVisitor(key, node, visitor, path16) {
|
|
30609
30543
|
if (typeof visitor === "function")
|
|
30610
|
-
return visitor(key, node,
|
|
30544
|
+
return visitor(key, node, path16);
|
|
30611
30545
|
if (identity.isMap(node))
|
|
30612
|
-
return visitor.Map?.(key, node,
|
|
30546
|
+
return visitor.Map?.(key, node, path16);
|
|
30613
30547
|
if (identity.isSeq(node))
|
|
30614
|
-
return visitor.Seq?.(key, node,
|
|
30548
|
+
return visitor.Seq?.(key, node, path16);
|
|
30615
30549
|
if (identity.isPair(node))
|
|
30616
|
-
return visitor.Pair?.(key, node,
|
|
30550
|
+
return visitor.Pair?.(key, node, path16);
|
|
30617
30551
|
if (identity.isScalar(node))
|
|
30618
|
-
return visitor.Scalar?.(key, node,
|
|
30552
|
+
return visitor.Scalar?.(key, node, path16);
|
|
30619
30553
|
if (identity.isAlias(node))
|
|
30620
|
-
return visitor.Alias?.(key, node,
|
|
30554
|
+
return visitor.Alias?.(key, node, path16);
|
|
30621
30555
|
return void 0;
|
|
30622
30556
|
}
|
|
30623
|
-
function replaceNode(key,
|
|
30624
|
-
const parent =
|
|
30557
|
+
function replaceNode(key, path16, node) {
|
|
30558
|
+
const parent = path16[path16.length - 1];
|
|
30625
30559
|
if (identity.isCollection(parent)) {
|
|
30626
30560
|
parent.items[key] = node;
|
|
30627
30561
|
} else if (identity.isPair(parent)) {
|
|
@@ -31231,10 +31165,10 @@ var require_Collection = __commonJS({
|
|
|
31231
31165
|
var createNode = require_createNode();
|
|
31232
31166
|
var identity = require_identity();
|
|
31233
31167
|
var Node = require_Node();
|
|
31234
|
-
function collectionFromPath(schema,
|
|
31168
|
+
function collectionFromPath(schema, path16, value) {
|
|
31235
31169
|
let v = value;
|
|
31236
|
-
for (let i =
|
|
31237
|
-
const k =
|
|
31170
|
+
for (let i = path16.length - 1; i >= 0; --i) {
|
|
31171
|
+
const k = path16[i];
|
|
31238
31172
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
31239
31173
|
const a = [];
|
|
31240
31174
|
a[k] = v;
|
|
@@ -31253,7 +31187,7 @@ var require_Collection = __commonJS({
|
|
|
31253
31187
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
31254
31188
|
});
|
|
31255
31189
|
}
|
|
31256
|
-
var isEmptyPath = (
|
|
31190
|
+
var isEmptyPath = (path16) => path16 == null || typeof path16 === "object" && !!path16[Symbol.iterator]().next().done;
|
|
31257
31191
|
var Collection = class extends Node.NodeBase {
|
|
31258
31192
|
constructor(type, schema) {
|
|
31259
31193
|
super(type);
|
|
@@ -31283,11 +31217,11 @@ var require_Collection = __commonJS({
|
|
|
31283
31217
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
31284
31218
|
* that already exists in the map.
|
|
31285
31219
|
*/
|
|
31286
|
-
addIn(
|
|
31287
|
-
if (isEmptyPath(
|
|
31220
|
+
addIn(path16, value) {
|
|
31221
|
+
if (isEmptyPath(path16))
|
|
31288
31222
|
this.add(value);
|
|
31289
31223
|
else {
|
|
31290
|
-
const [key, ...rest] =
|
|
31224
|
+
const [key, ...rest] = path16;
|
|
31291
31225
|
const node = this.get(key, true);
|
|
31292
31226
|
if (identity.isCollection(node))
|
|
31293
31227
|
node.addIn(rest, value);
|
|
@@ -31301,8 +31235,8 @@ var require_Collection = __commonJS({
|
|
|
31301
31235
|
* Removes a value from the collection.
|
|
31302
31236
|
* @returns `true` if the item was found and removed.
|
|
31303
31237
|
*/
|
|
31304
|
-
deleteIn(
|
|
31305
|
-
const [key, ...rest] =
|
|
31238
|
+
deleteIn(path16) {
|
|
31239
|
+
const [key, ...rest] = path16;
|
|
31306
31240
|
if (rest.length === 0)
|
|
31307
31241
|
return this.delete(key);
|
|
31308
31242
|
const node = this.get(key, true);
|
|
@@ -31316,8 +31250,8 @@ var require_Collection = __commonJS({
|
|
|
31316
31250
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
31317
31251
|
* `true` (collections are always returned intact).
|
|
31318
31252
|
*/
|
|
31319
|
-
getIn(
|
|
31320
|
-
const [key, ...rest] =
|
|
31253
|
+
getIn(path16, keepScalar) {
|
|
31254
|
+
const [key, ...rest] = path16;
|
|
31321
31255
|
const node = this.get(key, true);
|
|
31322
31256
|
if (rest.length === 0)
|
|
31323
31257
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -31335,8 +31269,8 @@ var require_Collection = __commonJS({
|
|
|
31335
31269
|
/**
|
|
31336
31270
|
* Checks if the collection includes a value with the key `key`.
|
|
31337
31271
|
*/
|
|
31338
|
-
hasIn(
|
|
31339
|
-
const [key, ...rest] =
|
|
31272
|
+
hasIn(path16) {
|
|
31273
|
+
const [key, ...rest] = path16;
|
|
31340
31274
|
if (rest.length === 0)
|
|
31341
31275
|
return this.has(key);
|
|
31342
31276
|
const node = this.get(key, true);
|
|
@@ -31346,8 +31280,8 @@ var require_Collection = __commonJS({
|
|
|
31346
31280
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
31347
31281
|
* boolean to add/remove the item from the set.
|
|
31348
31282
|
*/
|
|
31349
|
-
setIn(
|
|
31350
|
-
const [key, ...rest] =
|
|
31283
|
+
setIn(path16, value) {
|
|
31284
|
+
const [key, ...rest] = path16;
|
|
31351
31285
|
if (rest.length === 0) {
|
|
31352
31286
|
this.set(key, value);
|
|
31353
31287
|
} else {
|
|
@@ -33862,9 +33796,9 @@ var require_Document = __commonJS({
|
|
|
33862
33796
|
this.contents.add(value);
|
|
33863
33797
|
}
|
|
33864
33798
|
/** Adds a value to the document. */
|
|
33865
|
-
addIn(
|
|
33799
|
+
addIn(path16, value) {
|
|
33866
33800
|
if (assertCollection(this.contents))
|
|
33867
|
-
this.contents.addIn(
|
|
33801
|
+
this.contents.addIn(path16, value);
|
|
33868
33802
|
}
|
|
33869
33803
|
/**
|
|
33870
33804
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -33939,14 +33873,14 @@ var require_Document = __commonJS({
|
|
|
33939
33873
|
* Removes a value from the document.
|
|
33940
33874
|
* @returns `true` if the item was found and removed.
|
|
33941
33875
|
*/
|
|
33942
|
-
deleteIn(
|
|
33943
|
-
if (Collection.isEmptyPath(
|
|
33876
|
+
deleteIn(path16) {
|
|
33877
|
+
if (Collection.isEmptyPath(path16)) {
|
|
33944
33878
|
if (this.contents == null)
|
|
33945
33879
|
return false;
|
|
33946
33880
|
this.contents = null;
|
|
33947
33881
|
return true;
|
|
33948
33882
|
}
|
|
33949
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
33883
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path16) : false;
|
|
33950
33884
|
}
|
|
33951
33885
|
/**
|
|
33952
33886
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -33961,10 +33895,10 @@ var require_Document = __commonJS({
|
|
|
33961
33895
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
33962
33896
|
* `true` (collections are always returned intact).
|
|
33963
33897
|
*/
|
|
33964
|
-
getIn(
|
|
33965
|
-
if (Collection.isEmptyPath(
|
|
33898
|
+
getIn(path16, keepScalar) {
|
|
33899
|
+
if (Collection.isEmptyPath(path16))
|
|
33966
33900
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
33967
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
33901
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path16, keepScalar) : void 0;
|
|
33968
33902
|
}
|
|
33969
33903
|
/**
|
|
33970
33904
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -33975,10 +33909,10 @@ var require_Document = __commonJS({
|
|
|
33975
33909
|
/**
|
|
33976
33910
|
* Checks if the document includes a value at `path`.
|
|
33977
33911
|
*/
|
|
33978
|
-
hasIn(
|
|
33979
|
-
if (Collection.isEmptyPath(
|
|
33912
|
+
hasIn(path16) {
|
|
33913
|
+
if (Collection.isEmptyPath(path16))
|
|
33980
33914
|
return this.contents !== void 0;
|
|
33981
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
33915
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path16) : false;
|
|
33982
33916
|
}
|
|
33983
33917
|
/**
|
|
33984
33918
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -33995,13 +33929,13 @@ var require_Document = __commonJS({
|
|
|
33995
33929
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
33996
33930
|
* boolean to add/remove the item from the set.
|
|
33997
33931
|
*/
|
|
33998
|
-
setIn(
|
|
33999
|
-
if (Collection.isEmptyPath(
|
|
33932
|
+
setIn(path16, value) {
|
|
33933
|
+
if (Collection.isEmptyPath(path16)) {
|
|
34000
33934
|
this.contents = value;
|
|
34001
33935
|
} else if (this.contents == null) {
|
|
34002
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
33936
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path16), value);
|
|
34003
33937
|
} else if (assertCollection(this.contents)) {
|
|
34004
|
-
this.contents.setIn(
|
|
33938
|
+
this.contents.setIn(path16, value);
|
|
34005
33939
|
}
|
|
34006
33940
|
}
|
|
34007
33941
|
/**
|
|
@@ -35961,9 +35895,9 @@ var require_cst_visit = __commonJS({
|
|
|
35961
35895
|
visit.BREAK = BREAK;
|
|
35962
35896
|
visit.SKIP = SKIP;
|
|
35963
35897
|
visit.REMOVE = REMOVE;
|
|
35964
|
-
visit.itemAtPath = (cst,
|
|
35898
|
+
visit.itemAtPath = (cst, path16) => {
|
|
35965
35899
|
let item = cst;
|
|
35966
|
-
for (const [field, index] of
|
|
35900
|
+
for (const [field, index] of path16) {
|
|
35967
35901
|
const tok = item?.[field];
|
|
35968
35902
|
if (tok && "items" in tok) {
|
|
35969
35903
|
item = tok.items[index];
|
|
@@ -35972,23 +35906,23 @@ var require_cst_visit = __commonJS({
|
|
|
35972
35906
|
}
|
|
35973
35907
|
return item;
|
|
35974
35908
|
};
|
|
35975
|
-
visit.parentCollection = (cst,
|
|
35976
|
-
const parent = visit.itemAtPath(cst,
|
|
35977
|
-
const field =
|
|
35909
|
+
visit.parentCollection = (cst, path16) => {
|
|
35910
|
+
const parent = visit.itemAtPath(cst, path16.slice(0, -1));
|
|
35911
|
+
const field = path16[path16.length - 1][0];
|
|
35978
35912
|
const coll = parent?.[field];
|
|
35979
35913
|
if (coll && "items" in coll)
|
|
35980
35914
|
return coll;
|
|
35981
35915
|
throw new Error("Parent collection not found");
|
|
35982
35916
|
};
|
|
35983
|
-
function _visit(
|
|
35984
|
-
let ctrl = visitor(item,
|
|
35917
|
+
function _visit(path16, item, visitor) {
|
|
35918
|
+
let ctrl = visitor(item, path16);
|
|
35985
35919
|
if (typeof ctrl === "symbol")
|
|
35986
35920
|
return ctrl;
|
|
35987
35921
|
for (const field of ["key", "value"]) {
|
|
35988
35922
|
const token = item[field];
|
|
35989
35923
|
if (token && "items" in token) {
|
|
35990
35924
|
for (let i = 0; i < token.items.length; ++i) {
|
|
35991
|
-
const ci = _visit(Object.freeze(
|
|
35925
|
+
const ci = _visit(Object.freeze(path16.concat([[field, i]])), token.items[i], visitor);
|
|
35992
35926
|
if (typeof ci === "number")
|
|
35993
35927
|
i = ci - 1;
|
|
35994
35928
|
else if (ci === BREAK)
|
|
@@ -35999,10 +35933,10 @@ var require_cst_visit = __commonJS({
|
|
|
35999
35933
|
}
|
|
36000
35934
|
}
|
|
36001
35935
|
if (typeof ctrl === "function" && field === "key")
|
|
36002
|
-
ctrl = ctrl(item,
|
|
35936
|
+
ctrl = ctrl(item, path16);
|
|
36003
35937
|
}
|
|
36004
35938
|
}
|
|
36005
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
35939
|
+
return typeof ctrl === "function" ? ctrl(item, path16) : ctrl;
|
|
36006
35940
|
}
|
|
36007
35941
|
exports2.visit = visit;
|
|
36008
35942
|
}
|
|
@@ -37304,14 +37238,14 @@ var require_parser = __commonJS({
|
|
|
37304
37238
|
case "scalar":
|
|
37305
37239
|
case "single-quoted-scalar":
|
|
37306
37240
|
case "double-quoted-scalar": {
|
|
37307
|
-
const
|
|
37241
|
+
const fs27 = this.flowScalar(this.type);
|
|
37308
37242
|
if (atNextItem || it.value) {
|
|
37309
|
-
map2.items.push({ start: start2, key:
|
|
37243
|
+
map2.items.push({ start: start2, key: fs27, sep: [] });
|
|
37310
37244
|
this.onKeyLine = true;
|
|
37311
37245
|
} else if (it.sep) {
|
|
37312
|
-
this.stack.push(
|
|
37246
|
+
this.stack.push(fs27);
|
|
37313
37247
|
} else {
|
|
37314
|
-
Object.assign(it, { key:
|
|
37248
|
+
Object.assign(it, { key: fs27, sep: [] });
|
|
37315
37249
|
this.onKeyLine = true;
|
|
37316
37250
|
}
|
|
37317
37251
|
return;
|
|
@@ -37439,13 +37373,13 @@ var require_parser = __commonJS({
|
|
|
37439
37373
|
case "scalar":
|
|
37440
37374
|
case "single-quoted-scalar":
|
|
37441
37375
|
case "double-quoted-scalar": {
|
|
37442
|
-
const
|
|
37376
|
+
const fs27 = this.flowScalar(this.type);
|
|
37443
37377
|
if (!it || it.value)
|
|
37444
|
-
fc.items.push({ start: [], key:
|
|
37378
|
+
fc.items.push({ start: [], key: fs27, sep: [] });
|
|
37445
37379
|
else if (it.sep)
|
|
37446
|
-
this.stack.push(
|
|
37380
|
+
this.stack.push(fs27);
|
|
37447
37381
|
else
|
|
37448
|
-
Object.assign(it, { key:
|
|
37382
|
+
Object.assign(it, { key: fs27, sep: [] });
|
|
37449
37383
|
return;
|
|
37450
37384
|
}
|
|
37451
37385
|
case "flow-map-end":
|
|
@@ -37702,7 +37636,7 @@ var require_public_api = __commonJS({
|
|
|
37702
37636
|
});
|
|
37703
37637
|
|
|
37704
37638
|
// ../../node_modules/yaml/dist/index.js
|
|
37705
|
-
var
|
|
37639
|
+
var require_dist2 = __commonJS({
|
|
37706
37640
|
"../../node_modules/yaml/dist/index.js"(exports2) {
|
|
37707
37641
|
"use strict";
|
|
37708
37642
|
var composer = require_composer();
|
|
@@ -38240,7 +38174,7 @@ var require_crc = __commonJS({
|
|
|
38240
38174
|
var require_parser2 = __commonJS({
|
|
38241
38175
|
"../../node_modules/pngjs/lib/parser.js"(exports2, module2) {
|
|
38242
38176
|
"use strict";
|
|
38243
|
-
var
|
|
38177
|
+
var constants2 = require_constants3();
|
|
38244
38178
|
var CrcCalculator = require_crc();
|
|
38245
38179
|
var Parser = module2.exports = function(options, dependencies) {
|
|
38246
38180
|
this._options = options;
|
|
@@ -38251,12 +38185,12 @@ var require_parser2 = __commonJS({
|
|
|
38251
38185
|
this._palette = [];
|
|
38252
38186
|
this._colorType = 0;
|
|
38253
38187
|
this._chunks = {};
|
|
38254
|
-
this._chunks[
|
|
38255
|
-
this._chunks[
|
|
38256
|
-
this._chunks[
|
|
38257
|
-
this._chunks[
|
|
38258
|
-
this._chunks[
|
|
38259
|
-
this._chunks[
|
|
38188
|
+
this._chunks[constants2.TYPE_IHDR] = this._handleIHDR.bind(this);
|
|
38189
|
+
this._chunks[constants2.TYPE_IEND] = this._handleIEND.bind(this);
|
|
38190
|
+
this._chunks[constants2.TYPE_IDAT] = this._handleIDAT.bind(this);
|
|
38191
|
+
this._chunks[constants2.TYPE_PLTE] = this._handlePLTE.bind(this);
|
|
38192
|
+
this._chunks[constants2.TYPE_tRNS] = this._handleTRNS.bind(this);
|
|
38193
|
+
this._chunks[constants2.TYPE_gAMA] = this._handleGAMA.bind(this);
|
|
38260
38194
|
this.read = dependencies.read;
|
|
38261
38195
|
this.error = dependencies.error;
|
|
38262
38196
|
this.metadata = dependencies.metadata;
|
|
@@ -38271,10 +38205,10 @@ var require_parser2 = __commonJS({
|
|
|
38271
38205
|
};
|
|
38272
38206
|
};
|
|
38273
38207
|
Parser.prototype.start = function() {
|
|
38274
|
-
this.read(
|
|
38208
|
+
this.read(constants2.PNG_SIGNATURE.length, this._parseSignature.bind(this));
|
|
38275
38209
|
};
|
|
38276
38210
|
Parser.prototype._parseSignature = function(data) {
|
|
38277
|
-
let signature =
|
|
38211
|
+
let signature = constants2.PNG_SIGNATURE;
|
|
38278
38212
|
for (let i = 0; i < signature.length; i++) {
|
|
38279
38213
|
if (data[i] !== signature[i]) {
|
|
38280
38214
|
this.error(new Error("Invalid file signature"));
|
|
@@ -38291,7 +38225,7 @@ var require_parser2 = __commonJS({
|
|
|
38291
38225
|
name += String.fromCharCode(data[i]);
|
|
38292
38226
|
}
|
|
38293
38227
|
let ancillary = Boolean(data[4] & 32);
|
|
38294
|
-
if (!this._hasIHDR && type !==
|
|
38228
|
+
if (!this._hasIHDR && type !== constants2.TYPE_IHDR) {
|
|
38295
38229
|
this.error(new Error("Expected IHDR on beggining"));
|
|
38296
38230
|
return;
|
|
38297
38231
|
}
|
|
@@ -38339,7 +38273,7 @@ var require_parser2 = __commonJS({
|
|
|
38339
38273
|
this.error(new Error("Unsupported bit depth " + depth));
|
|
38340
38274
|
return;
|
|
38341
38275
|
}
|
|
38342
|
-
if (!(colorType in
|
|
38276
|
+
if (!(colorType in constants2.COLORTYPE_TO_BPP_MAP)) {
|
|
38343
38277
|
this.error(new Error("Unsupported color type"));
|
|
38344
38278
|
return;
|
|
38345
38279
|
}
|
|
@@ -38356,16 +38290,16 @@ var require_parser2 = __commonJS({
|
|
|
38356
38290
|
return;
|
|
38357
38291
|
}
|
|
38358
38292
|
this._colorType = colorType;
|
|
38359
|
-
let bpp =
|
|
38293
|
+
let bpp = constants2.COLORTYPE_TO_BPP_MAP[this._colorType];
|
|
38360
38294
|
this._hasIHDR = true;
|
|
38361
38295
|
this.metadata({
|
|
38362
38296
|
width,
|
|
38363
38297
|
height,
|
|
38364
38298
|
depth,
|
|
38365
38299
|
interlace: Boolean(interlace),
|
|
38366
|
-
palette: Boolean(colorType &
|
|
38367
|
-
color: Boolean(colorType &
|
|
38368
|
-
alpha: Boolean(colorType &
|
|
38300
|
+
palette: Boolean(colorType & constants2.COLORTYPE_PALETTE),
|
|
38301
|
+
color: Boolean(colorType & constants2.COLORTYPE_COLOR),
|
|
38302
|
+
alpha: Boolean(colorType & constants2.COLORTYPE_ALPHA),
|
|
38369
38303
|
bpp,
|
|
38370
38304
|
colorType
|
|
38371
38305
|
});
|
|
@@ -38389,7 +38323,7 @@ var require_parser2 = __commonJS({
|
|
|
38389
38323
|
};
|
|
38390
38324
|
Parser.prototype._parseTRNS = function(data) {
|
|
38391
38325
|
this._crc.write(data);
|
|
38392
|
-
if (this._colorType ===
|
|
38326
|
+
if (this._colorType === constants2.COLORTYPE_PALETTE_COLOR) {
|
|
38393
38327
|
if (this._palette.length === 0) {
|
|
38394
38328
|
this.error(new Error("Transparency chunk must be after palette"));
|
|
38395
38329
|
return;
|
|
@@ -38403,10 +38337,10 @@ var require_parser2 = __commonJS({
|
|
|
38403
38337
|
}
|
|
38404
38338
|
this.palette(this._palette);
|
|
38405
38339
|
}
|
|
38406
|
-
if (this._colorType ===
|
|
38340
|
+
if (this._colorType === constants2.COLORTYPE_GRAYSCALE) {
|
|
38407
38341
|
this.transColor([data.readUInt16BE(0)]);
|
|
38408
38342
|
}
|
|
38409
|
-
if (this._colorType ===
|
|
38343
|
+
if (this._colorType === constants2.COLORTYPE_COLOR) {
|
|
38410
38344
|
this.transColor([
|
|
38411
38345
|
data.readUInt16BE(0),
|
|
38412
38346
|
data.readUInt16BE(2),
|
|
@@ -38420,7 +38354,7 @@ var require_parser2 = __commonJS({
|
|
|
38420
38354
|
};
|
|
38421
38355
|
Parser.prototype._parseGAMA = function(data) {
|
|
38422
38356
|
this._crc.write(data);
|
|
38423
|
-
this.gamma(data.readUInt32BE(0) /
|
|
38357
|
+
this.gamma(data.readUInt32BE(0) / constants2.GAMMA_DIVISION);
|
|
38424
38358
|
this._handleChunkEnd();
|
|
38425
38359
|
};
|
|
38426
38360
|
Parser.prototype._handleIDAT = function(length) {
|
|
@@ -38432,7 +38366,7 @@ var require_parser2 = __commonJS({
|
|
|
38432
38366
|
};
|
|
38433
38367
|
Parser.prototype._parseIDAT = function(length, data) {
|
|
38434
38368
|
this._crc.write(data);
|
|
38435
|
-
if (this._colorType ===
|
|
38369
|
+
if (this._colorType === constants2.COLORTYPE_PALETTE_COLOR && this._palette.length === 0) {
|
|
38436
38370
|
throw new Error("Expected palette not found");
|
|
38437
38371
|
}
|
|
38438
38372
|
this.inflateData(data);
|
|
@@ -38920,9 +38854,9 @@ var require_parser_async = __commonJS({
|
|
|
38920
38854
|
var require_bitpacker = __commonJS({
|
|
38921
38855
|
"../../node_modules/pngjs/lib/bitpacker.js"(exports2, module2) {
|
|
38922
38856
|
"use strict";
|
|
38923
|
-
var
|
|
38857
|
+
var constants2 = require_constants3();
|
|
38924
38858
|
module2.exports = function(dataIn, width, height, options) {
|
|
38925
|
-
let outHasAlpha = [
|
|
38859
|
+
let outHasAlpha = [constants2.COLORTYPE_COLOR_ALPHA, constants2.COLORTYPE_ALPHA].indexOf(
|
|
38926
38860
|
options.colorType
|
|
38927
38861
|
) !== -1;
|
|
38928
38862
|
if (options.colorType === options.inputColorType) {
|
|
@@ -38942,11 +38876,11 @@ var require_bitpacker = __commonJS({
|
|
|
38942
38876
|
}
|
|
38943
38877
|
let data = options.bitDepth !== 16 ? dataIn : new Uint16Array(dataIn.buffer);
|
|
38944
38878
|
let maxValue = 255;
|
|
38945
|
-
let inBpp =
|
|
38879
|
+
let inBpp = constants2.COLORTYPE_TO_BPP_MAP[options.inputColorType];
|
|
38946
38880
|
if (inBpp === 4 && !options.inputHasAlpha) {
|
|
38947
38881
|
inBpp = 3;
|
|
38948
38882
|
}
|
|
38949
|
-
let outBpp =
|
|
38883
|
+
let outBpp = constants2.COLORTYPE_TO_BPP_MAP[options.colorType];
|
|
38950
38884
|
if (options.bitDepth === 16) {
|
|
38951
38885
|
maxValue = 65535;
|
|
38952
38886
|
outBpp *= 2;
|
|
@@ -38970,24 +38904,24 @@ var require_bitpacker = __commonJS({
|
|
|
38970
38904
|
let blue;
|
|
38971
38905
|
let alpha = maxValue;
|
|
38972
38906
|
switch (options.inputColorType) {
|
|
38973
|
-
case
|
|
38907
|
+
case constants2.COLORTYPE_COLOR_ALPHA:
|
|
38974
38908
|
alpha = data[inIndex + 3];
|
|
38975
38909
|
red = data[inIndex];
|
|
38976
38910
|
green = data[inIndex + 1];
|
|
38977
38911
|
blue = data[inIndex + 2];
|
|
38978
38912
|
break;
|
|
38979
|
-
case
|
|
38913
|
+
case constants2.COLORTYPE_COLOR:
|
|
38980
38914
|
red = data[inIndex];
|
|
38981
38915
|
green = data[inIndex + 1];
|
|
38982
38916
|
blue = data[inIndex + 2];
|
|
38983
38917
|
break;
|
|
38984
|
-
case
|
|
38918
|
+
case constants2.COLORTYPE_ALPHA:
|
|
38985
38919
|
alpha = data[inIndex + 1];
|
|
38986
38920
|
red = data[inIndex];
|
|
38987
38921
|
green = red;
|
|
38988
38922
|
blue = red;
|
|
38989
38923
|
break;
|
|
38990
|
-
case
|
|
38924
|
+
case constants2.COLORTYPE_GRAYSCALE:
|
|
38991
38925
|
red = data[inIndex];
|
|
38992
38926
|
green = red;
|
|
38993
38927
|
blue = red;
|
|
@@ -39020,8 +38954,8 @@ var require_bitpacker = __commonJS({
|
|
|
39020
38954
|
for (let x = 0; x < width; x++) {
|
|
39021
38955
|
let rgba = getRGBA(data, inIndex);
|
|
39022
38956
|
switch (options.colorType) {
|
|
39023
|
-
case
|
|
39024
|
-
case
|
|
38957
|
+
case constants2.COLORTYPE_COLOR_ALPHA:
|
|
38958
|
+
case constants2.COLORTYPE_COLOR:
|
|
39025
38959
|
if (options.bitDepth === 8) {
|
|
39026
38960
|
outData[outIndex] = rgba.red;
|
|
39027
38961
|
outData[outIndex + 1] = rgba.green;
|
|
@@ -39038,8 +38972,8 @@ var require_bitpacker = __commonJS({
|
|
|
39038
38972
|
}
|
|
39039
38973
|
}
|
|
39040
38974
|
break;
|
|
39041
|
-
case
|
|
39042
|
-
case
|
|
38975
|
+
case constants2.COLORTYPE_ALPHA:
|
|
38976
|
+
case constants2.COLORTYPE_GRAYSCALE: {
|
|
39043
38977
|
let grayscale = (rgba.red + rgba.green + rgba.blue) / 3;
|
|
39044
38978
|
if (options.bitDepth === 8) {
|
|
39045
38979
|
outData[outIndex] = grayscale;
|
|
@@ -39212,7 +39146,7 @@ var require_filter_pack = __commonJS({
|
|
|
39212
39146
|
var require_packer = __commonJS({
|
|
39213
39147
|
"../../node_modules/pngjs/lib/packer.js"(exports2, module2) {
|
|
39214
39148
|
"use strict";
|
|
39215
|
-
var
|
|
39149
|
+
var constants2 = require_constants3();
|
|
39216
39150
|
var CrcStream = require_crc();
|
|
39217
39151
|
var bitPacker = require_bitpacker();
|
|
39218
39152
|
var filter = require_filter_pack();
|
|
@@ -39225,23 +39159,23 @@ var require_packer = __commonJS({
|
|
|
39225
39159
|
options.inputHasAlpha = options.inputHasAlpha != null ? options.inputHasAlpha : true;
|
|
39226
39160
|
options.deflateFactory = options.deflateFactory || zlib.createDeflate;
|
|
39227
39161
|
options.bitDepth = options.bitDepth || 8;
|
|
39228
|
-
options.colorType = typeof options.colorType === "number" ? options.colorType :
|
|
39229
|
-
options.inputColorType = typeof options.inputColorType === "number" ? options.inputColorType :
|
|
39162
|
+
options.colorType = typeof options.colorType === "number" ? options.colorType : constants2.COLORTYPE_COLOR_ALPHA;
|
|
39163
|
+
options.inputColorType = typeof options.inputColorType === "number" ? options.inputColorType : constants2.COLORTYPE_COLOR_ALPHA;
|
|
39230
39164
|
if ([
|
|
39231
|
-
|
|
39232
|
-
|
|
39233
|
-
|
|
39234
|
-
|
|
39165
|
+
constants2.COLORTYPE_GRAYSCALE,
|
|
39166
|
+
constants2.COLORTYPE_COLOR,
|
|
39167
|
+
constants2.COLORTYPE_COLOR_ALPHA,
|
|
39168
|
+
constants2.COLORTYPE_ALPHA
|
|
39235
39169
|
].indexOf(options.colorType) === -1) {
|
|
39236
39170
|
throw new Error(
|
|
39237
39171
|
"option color type:" + options.colorType + " is not supported at present"
|
|
39238
39172
|
);
|
|
39239
39173
|
}
|
|
39240
39174
|
if ([
|
|
39241
|
-
|
|
39242
|
-
|
|
39243
|
-
|
|
39244
|
-
|
|
39175
|
+
constants2.COLORTYPE_GRAYSCALE,
|
|
39176
|
+
constants2.COLORTYPE_COLOR,
|
|
39177
|
+
constants2.COLORTYPE_COLOR_ALPHA,
|
|
39178
|
+
constants2.COLORTYPE_ALPHA
|
|
39245
39179
|
].indexOf(options.inputColorType) === -1) {
|
|
39246
39180
|
throw new Error(
|
|
39247
39181
|
"option input color type:" + options.inputColorType + " is not supported at present"
|
|
@@ -39265,7 +39199,7 @@ var require_packer = __commonJS({
|
|
|
39265
39199
|
};
|
|
39266
39200
|
Packer.prototype.filterData = function(data, width, height) {
|
|
39267
39201
|
let packedData = bitPacker(data, width, height, this._options);
|
|
39268
|
-
let bpp =
|
|
39202
|
+
let bpp = constants2.COLORTYPE_TO_BPP_MAP[this._options.colorType];
|
|
39269
39203
|
let filteredData = filter(packedData, width, height, this._options, bpp);
|
|
39270
39204
|
return filteredData;
|
|
39271
39205
|
};
|
|
@@ -39285,8 +39219,8 @@ var require_packer = __commonJS({
|
|
|
39285
39219
|
};
|
|
39286
39220
|
Packer.prototype.packGAMA = function(gamma) {
|
|
39287
39221
|
let buf = Buffer.alloc(4);
|
|
39288
|
-
buf.writeUInt32BE(Math.floor(gamma *
|
|
39289
|
-
return this._packChunk(
|
|
39222
|
+
buf.writeUInt32BE(Math.floor(gamma * constants2.GAMMA_DIVISION), 0);
|
|
39223
|
+
return this._packChunk(constants2.TYPE_gAMA, buf);
|
|
39290
39224
|
};
|
|
39291
39225
|
Packer.prototype.packIHDR = function(width, height) {
|
|
39292
39226
|
let buf = Buffer.alloc(13);
|
|
@@ -39297,13 +39231,13 @@ var require_packer = __commonJS({
|
|
|
39297
39231
|
buf[10] = 0;
|
|
39298
39232
|
buf[11] = 0;
|
|
39299
39233
|
buf[12] = 0;
|
|
39300
|
-
return this._packChunk(
|
|
39234
|
+
return this._packChunk(constants2.TYPE_IHDR, buf);
|
|
39301
39235
|
};
|
|
39302
39236
|
Packer.prototype.packIDAT = function(data) {
|
|
39303
|
-
return this._packChunk(
|
|
39237
|
+
return this._packChunk(constants2.TYPE_IDAT, data);
|
|
39304
39238
|
};
|
|
39305
39239
|
Packer.prototype.packIEND = function() {
|
|
39306
|
-
return this._packChunk(
|
|
39240
|
+
return this._packChunk(constants2.TYPE_IEND, null);
|
|
39307
39241
|
};
|
|
39308
39242
|
}
|
|
39309
39243
|
});
|
|
@@ -39314,7 +39248,7 @@ var require_packer_async = __commonJS({
|
|
|
39314
39248
|
"use strict";
|
|
39315
39249
|
var util = require("util");
|
|
39316
39250
|
var Stream = require("stream");
|
|
39317
|
-
var
|
|
39251
|
+
var constants2 = require_constants3();
|
|
39318
39252
|
var Packer = require_packer();
|
|
39319
39253
|
var PackerAsync = module2.exports = function(opt) {
|
|
39320
39254
|
Stream.call(this);
|
|
@@ -39325,7 +39259,7 @@ var require_packer_async = __commonJS({
|
|
|
39325
39259
|
};
|
|
39326
39260
|
util.inherits(PackerAsync, Stream);
|
|
39327
39261
|
PackerAsync.prototype.pack = function(data, width, height, gamma) {
|
|
39328
|
-
this.emit("data", Buffer.from(
|
|
39262
|
+
this.emit("data", Buffer.from(constants2.PNG_SIGNATURE));
|
|
39329
39263
|
this.emit("data", this._packer.packIHDR(width, height));
|
|
39330
39264
|
if (gamma) {
|
|
39331
39265
|
this.emit("data", this._packer.packGAMA(gamma));
|
|
@@ -39653,7 +39587,7 @@ var require_packer_sync = __commonJS({
|
|
|
39653
39587
|
if (!zlib.deflateSync) {
|
|
39654
39588
|
hasSyncZlib = false;
|
|
39655
39589
|
}
|
|
39656
|
-
var
|
|
39590
|
+
var constants2 = require_constants3();
|
|
39657
39591
|
var Packer = require_packer();
|
|
39658
39592
|
module2.exports = function(metaData, opt) {
|
|
39659
39593
|
if (!hasSyncZlib) {
|
|
@@ -39664,7 +39598,7 @@ var require_packer_sync = __commonJS({
|
|
|
39664
39598
|
let options = opt || {};
|
|
39665
39599
|
let packer = new Packer(options);
|
|
39666
39600
|
let chunks = [];
|
|
39667
|
-
chunks.push(Buffer.from(
|
|
39601
|
+
chunks.push(Buffer.from(constants2.PNG_SIGNATURE));
|
|
39668
39602
|
chunks.push(packer.packIHDR(metaData.width, metaData.height));
|
|
39669
39603
|
if (metaData.gamma) {
|
|
39670
39604
|
chunks.push(packer.packGAMA(metaData.gamma));
|
|
@@ -40690,10 +40624,10 @@ function mergeDefs(...defs) {
|
|
|
40690
40624
|
function cloneDef(schema) {
|
|
40691
40625
|
return mergeDefs(schema._zod.def);
|
|
40692
40626
|
}
|
|
40693
|
-
function getElementAtPath(obj,
|
|
40694
|
-
if (!
|
|
40627
|
+
function getElementAtPath(obj, path16) {
|
|
40628
|
+
if (!path16)
|
|
40695
40629
|
return obj;
|
|
40696
|
-
return
|
|
40630
|
+
return path16.reduce((acc, key) => acc?.[key], obj);
|
|
40697
40631
|
}
|
|
40698
40632
|
function promiseAllObject(promisesObj) {
|
|
40699
40633
|
const keys = Object.keys(promisesObj);
|
|
@@ -41102,11 +41036,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
41102
41036
|
}
|
|
41103
41037
|
return false;
|
|
41104
41038
|
}
|
|
41105
|
-
function prefixIssues(
|
|
41039
|
+
function prefixIssues(path16, issues) {
|
|
41106
41040
|
return issues.map((iss) => {
|
|
41107
41041
|
var _a3;
|
|
41108
41042
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
41109
|
-
iss.path.unshift(
|
|
41043
|
+
iss.path.unshift(path16);
|
|
41110
41044
|
return iss;
|
|
41111
41045
|
});
|
|
41112
41046
|
}
|
|
@@ -41253,16 +41187,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
41253
41187
|
}
|
|
41254
41188
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
41255
41189
|
const fieldErrors = { _errors: [] };
|
|
41256
|
-
const processError = (error52,
|
|
41190
|
+
const processError = (error52, path16 = []) => {
|
|
41257
41191
|
for (const issue2 of error52.issues) {
|
|
41258
41192
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
41259
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
41193
|
+
issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
|
|
41260
41194
|
} else if (issue2.code === "invalid_key") {
|
|
41261
|
-
processError({ issues: issue2.issues }, [...
|
|
41195
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
41262
41196
|
} else if (issue2.code === "invalid_element") {
|
|
41263
|
-
processError({ issues: issue2.issues }, [...
|
|
41197
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
41264
41198
|
} else {
|
|
41265
|
-
const fullpath = [...
|
|
41199
|
+
const fullpath = [...path16, ...issue2.path];
|
|
41266
41200
|
if (fullpath.length === 0) {
|
|
41267
41201
|
fieldErrors._errors.push(mapper(issue2));
|
|
41268
41202
|
} else {
|
|
@@ -41289,17 +41223,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
41289
41223
|
}
|
|
41290
41224
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
41291
41225
|
const result = { errors: [] };
|
|
41292
|
-
const processError = (error52,
|
|
41226
|
+
const processError = (error52, path16 = []) => {
|
|
41293
41227
|
var _a3, _b;
|
|
41294
41228
|
for (const issue2 of error52.issues) {
|
|
41295
41229
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
41296
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
41230
|
+
issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
|
|
41297
41231
|
} else if (issue2.code === "invalid_key") {
|
|
41298
|
-
processError({ issues: issue2.issues }, [...
|
|
41232
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
41299
41233
|
} else if (issue2.code === "invalid_element") {
|
|
41300
|
-
processError({ issues: issue2.issues }, [...
|
|
41234
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
41301
41235
|
} else {
|
|
41302
|
-
const fullpath = [...
|
|
41236
|
+
const fullpath = [...path16, ...issue2.path];
|
|
41303
41237
|
if (fullpath.length === 0) {
|
|
41304
41238
|
result.errors.push(mapper(issue2));
|
|
41305
41239
|
continue;
|
|
@@ -41331,8 +41265,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
41331
41265
|
}
|
|
41332
41266
|
function toDotPath(_path) {
|
|
41333
41267
|
const segs = [];
|
|
41334
|
-
const
|
|
41335
|
-
for (const seg of
|
|
41268
|
+
const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
41269
|
+
for (const seg of path16) {
|
|
41336
41270
|
if (typeof seg === "number")
|
|
41337
41271
|
segs.push(`[${seg}]`);
|
|
41338
41272
|
else if (typeof seg === "symbol")
|
|
@@ -54024,13 +53958,13 @@ function resolveRef(ref, ctx) {
|
|
|
54024
53958
|
if (!ref.startsWith("#")) {
|
|
54025
53959
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
54026
53960
|
}
|
|
54027
|
-
const
|
|
54028
|
-
if (
|
|
53961
|
+
const path16 = ref.slice(1).split("/").filter(Boolean);
|
|
53962
|
+
if (path16.length === 0) {
|
|
54029
53963
|
return ctx.rootSchema;
|
|
54030
53964
|
}
|
|
54031
53965
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
54032
|
-
if (
|
|
54033
|
-
const key =
|
|
53966
|
+
if (path16[0] === defsKey) {
|
|
53967
|
+
const key = path16[1];
|
|
54034
53968
|
if (!key || !ctx.defs[key]) {
|
|
54035
53969
|
throw new Error(`Reference not found: ${ref}`);
|
|
54036
53970
|
}
|
|
@@ -54528,14 +54462,22 @@ var Registry = class {
|
|
|
54528
54462
|
const startTime = performance.now();
|
|
54529
54463
|
this.events.emit("toolInvoked", id);
|
|
54530
54464
|
try {
|
|
54531
|
-
|
|
54465
|
+
let effectiveParams = params;
|
|
54466
|
+
if (definition.zodSchema) {
|
|
54467
|
+
const parsed = definition.zodSchema.safeParse(params ?? {});
|
|
54468
|
+
if (!parsed.success) {
|
|
54469
|
+
throw new Error(`Invalid params for tool "${id}": ${parsed.error.message}`);
|
|
54470
|
+
}
|
|
54471
|
+
effectiveParams = parsed.data;
|
|
54472
|
+
}
|
|
54473
|
+
const aliasToRef = definition.services(effectiveParams);
|
|
54532
54474
|
const resolvedServices = {};
|
|
54533
54475
|
for (const [alias, ref] of Object.entries(aliasToRef)) {
|
|
54534
54476
|
const urn = typeof ref === "string" ? ref : ref.urn;
|
|
54535
54477
|
const resolveOptions = typeof ref === "string" ? void 0 : ref.options;
|
|
54536
54478
|
resolvedServices[alias] = await this.resolveService(urn, resolveOptions);
|
|
54537
54479
|
}
|
|
54538
|
-
const result = await definition.execute(resolvedServices,
|
|
54480
|
+
const result = await definition.execute(resolvedServices, effectiveParams, options);
|
|
54539
54481
|
const duration3 = performance.now() - startTime;
|
|
54540
54482
|
this.events.emit("toolCompleted", id, duration3);
|
|
54541
54483
|
return result;
|
|
@@ -54760,7 +54702,6 @@ var import_express2 = __toESM(require_express2());
|
|
|
54760
54702
|
|
|
54761
54703
|
// ../tool-server/src/utils/idle-timer.ts
|
|
54762
54704
|
var IDLE_CHECK_INTERVAL_MS = 6e4;
|
|
54763
|
-
var DEFAULT_IDLE_TIMEOUT_MINUTES = 30;
|
|
54764
54705
|
function createIdleTimer(timeoutMs, onIdle) {
|
|
54765
54706
|
let lastActivityAt = Date.now();
|
|
54766
54707
|
let interval2 = null;
|
|
@@ -54801,6 +54742,7 @@ var import_node_util2 = require("node:util");
|
|
|
54801
54742
|
var import_node_child_process = require("node:child_process");
|
|
54802
54743
|
var import_promises = require("node:fs/promises");
|
|
54803
54744
|
var import_node_fs = require("node:fs");
|
|
54745
|
+
var import_node_os = require("node:os");
|
|
54804
54746
|
var import_node_path = require("node:path");
|
|
54805
54747
|
var import_node_util = require("node:util");
|
|
54806
54748
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
@@ -54838,9 +54780,31 @@ async function probe(name) {
|
|
|
54838
54780
|
return null;
|
|
54839
54781
|
}
|
|
54840
54782
|
function androidRoots() {
|
|
54841
|
-
|
|
54783
|
+
const envRoots = [process.env.ANDROID_HOME, process.env.ANDROID_SDK_ROOT].filter(
|
|
54842
54784
|
(v) => Boolean(v && v.trim())
|
|
54843
54785
|
);
|
|
54786
|
+
return [...envRoots, ...defaultAndroidRoots()];
|
|
54787
|
+
}
|
|
54788
|
+
function defaultAndroidRoots() {
|
|
54789
|
+
const home = (0, import_node_os.homedir)();
|
|
54790
|
+
const roots = [
|
|
54791
|
+
// Android Studio defaults (the two big ones — covers the majority of
|
|
54792
|
+
// user installs that arrive without any env-var setup).
|
|
54793
|
+
(0, import_node_path.join)(home, "Library", "Android", "sdk"),
|
|
54794
|
+
// macOS Android Studio default
|
|
54795
|
+
(0, import_node_path.join)(home, "Android", "Sdk"),
|
|
54796
|
+
// Linux Android Studio default
|
|
54797
|
+
// Common manual install convention. Not picked by any installer but used
|
|
54798
|
+
// often enough in tutorials and Dockerfiles that probing it costs little.
|
|
54799
|
+
(0, import_node_path.join)(home, "android-sdk"),
|
|
54800
|
+
// System-wide locations (Linux package managers, Homebrew on macOS).
|
|
54801
|
+
"/opt/android-sdk",
|
|
54802
|
+
"/usr/lib/android-sdk",
|
|
54803
|
+
// Debian/Ubuntu `android-sdk` apt package
|
|
54804
|
+
"/usr/local/share/android-sdk"
|
|
54805
|
+
// Homebrew cask
|
|
54806
|
+
];
|
|
54807
|
+
return roots;
|
|
54844
54808
|
}
|
|
54845
54809
|
|
|
54846
54810
|
// ../tool-server/src/utils/check-deps.ts
|
|
@@ -54933,12 +54897,12 @@ function toSimulatorNetworkError(toolLabel, err, apiUrl, fallbackHint) {
|
|
|
54933
54897
|
|
|
54934
54898
|
// ../tool-server/src/utils/update-checker.ts
|
|
54935
54899
|
var import_node_fs2 = __toESM(require("node:fs"));
|
|
54936
|
-
var
|
|
54900
|
+
var import_node_os2 = __toESM(require("node:os"));
|
|
54937
54901
|
var import_node_path2 = __toESM(require("node:path"));
|
|
54938
54902
|
var import_semver = __toESM(require_semver2());
|
|
54939
54903
|
|
|
54940
54904
|
// ../tool-server/package.json
|
|
54941
|
-
var version2 = "0.
|
|
54905
|
+
var version2 = "0.10.0";
|
|
54942
54906
|
|
|
54943
54907
|
// ../tool-server/src/utils/update-checker.ts
|
|
54944
54908
|
var import_update_core = __toESM(require_dist());
|
|
@@ -54946,7 +54910,7 @@ var PACKAGE_NAME = "@swmansion/argent";
|
|
|
54946
54910
|
var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}`;
|
|
54947
54911
|
var CHECK_INTERVAL_MS = 60 * 60 * 1e3 * 24;
|
|
54948
54912
|
function getSuppressionFilePath() {
|
|
54949
|
-
return import_node_path2.default.join(
|
|
54913
|
+
return import_node_path2.default.join(import_node_os2.default.homedir(), ".argent", "update-suppression.json");
|
|
54950
54914
|
}
|
|
54951
54915
|
function loadSuppressUntil() {
|
|
54952
54916
|
try {
|
|
@@ -55059,38 +55023,71 @@ var import_express = __toESM(require_express2());
|
|
|
55059
55023
|
|
|
55060
55024
|
// ../tool-server/src/blueprints/simulator-server.ts
|
|
55061
55025
|
var import_node_child_process4 = require("node:child_process");
|
|
55062
|
-
var
|
|
55026
|
+
var readline2 = __toESM(require("node:readline"));
|
|
55063
55027
|
|
|
55064
55028
|
// ../native-devtools-ios/src/index.ts
|
|
55065
55029
|
var path2 = __toESM(require("node:path"));
|
|
55066
55030
|
var fs2 = __toESM(require("node:fs"));
|
|
55067
55031
|
var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path2.join(__dirname, "..", "dylibs");
|
|
55068
|
-
|
|
55069
|
-
|
|
55032
|
+
var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path2.join(__dirname, "..", "bin");
|
|
55033
|
+
var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path2.join(DYLIB_DIR, "tcp");
|
|
55034
|
+
function requireDarwin(what) {
|
|
55035
|
+
if (process.platform !== "darwin") {
|
|
55036
|
+
throw new Error(
|
|
55037
|
+
`${what} requires a macOS host (iOS Simulator is unavailable on ${process.platform})`
|
|
55038
|
+
);
|
|
55039
|
+
}
|
|
55040
|
+
}
|
|
55041
|
+
function requireDylibIn(dir, name) {
|
|
55042
|
+
const p = path2.join(dir, name);
|
|
55070
55043
|
if (!fs2.existsSync(p)) {
|
|
55071
55044
|
throw new Error(`Native devtools dylib not found: ${p}`);
|
|
55072
55045
|
}
|
|
55073
55046
|
return p;
|
|
55074
55047
|
}
|
|
55075
|
-
var bootstrapDylibPath = () =>
|
|
55076
|
-
|
|
55048
|
+
var bootstrapDylibPath = () => {
|
|
55049
|
+
requireDarwin("bootstrapDylibPath");
|
|
55050
|
+
return requireDylibIn(DYLIB_DIR, "libArgentInjectionBootstrap.dylib");
|
|
55051
|
+
};
|
|
55052
|
+
var bootstrapDylibPathTcp = () => {
|
|
55053
|
+
requireDarwin("bootstrapDylibPathTcp");
|
|
55054
|
+
return requireDylibIn(DYLIB_TCP_DIR, "libArgentInjectionBootstrap.dylib");
|
|
55055
|
+
};
|
|
55056
|
+
function platformBinDir() {
|
|
55057
|
+
return path2.join(BIN_DIR, process.platform);
|
|
55058
|
+
}
|
|
55059
|
+
function platformTcpBinDir() {
|
|
55060
|
+
return process.env.ARGENT_SIMULATOR_SERVER_TCP_DIR ?? path2.join(platformBinDir(), "tcp");
|
|
55061
|
+
}
|
|
55077
55062
|
function simulatorServerBinaryPath() {
|
|
55078
|
-
const p = path2.join(
|
|
55063
|
+
const p = path2.join(platformBinDir(), "simulator-server");
|
|
55079
55064
|
if (!fs2.existsSync(p)) {
|
|
55080
|
-
|
|
55065
|
+
const flat = path2.join(BIN_DIR, "simulator-server");
|
|
55066
|
+
const migrationHint = fs2.existsSync(flat) ? ` Found a binary at the old flat path ${flat}; move it to ${p} or update ARGENT_SIMULATOR_SERVER_DIR to point at the parent of the platform subdirectory.` : "";
|
|
55067
|
+
throw new Error(
|
|
55068
|
+
`simulator-server binary not found for platform "${process.platform}" at ${p}. Supported hosts today: darwin, linux.${migrationHint}`
|
|
55069
|
+
);
|
|
55081
55070
|
}
|
|
55082
55071
|
return p;
|
|
55083
55072
|
}
|
|
55084
55073
|
function simulatorServerBinaryDir() {
|
|
55085
|
-
return
|
|
55074
|
+
return platformBinDir();
|
|
55086
55075
|
}
|
|
55087
|
-
function
|
|
55088
|
-
const p = path2.join(
|
|
55076
|
+
function requireBinIn(dir, name) {
|
|
55077
|
+
const p = path2.join(dir, name);
|
|
55089
55078
|
if (!fs2.existsSync(p)) {
|
|
55090
|
-
throw new Error(
|
|
55079
|
+
throw new Error(`${name} binary not found: ${p}`);
|
|
55091
55080
|
}
|
|
55092
55081
|
return p;
|
|
55093
55082
|
}
|
|
55083
|
+
function axServiceBinaryPath() {
|
|
55084
|
+
requireDarwin("ax-service");
|
|
55085
|
+
return requireBinIn(platformBinDir(), "ax-service");
|
|
55086
|
+
}
|
|
55087
|
+
function axServiceBinaryPathTcp() {
|
|
55088
|
+
requireDarwin("ax-service (tcp)");
|
|
55089
|
+
return requireBinIn(platformTcpBinDir(), "ax-service");
|
|
55090
|
+
}
|
|
55094
55091
|
|
|
55095
55092
|
// ../tool-server/src/blueprints/ax-service.ts
|
|
55096
55093
|
var net = __toESM(require("node:net"));
|
|
@@ -55098,6 +55095,7 @@ var fs3 = __toESM(require("node:fs"));
|
|
|
55098
55095
|
var fsAsync = __toESM(require("node:fs/promises"));
|
|
55099
55096
|
var os2 = __toESM(require("node:os"));
|
|
55100
55097
|
var path3 = __toESM(require("node:path"));
|
|
55098
|
+
var readline = __toESM(require("node:readline"));
|
|
55101
55099
|
var import_node_util3 = require("node:util");
|
|
55102
55100
|
var import_node_child_process3 = require("node:child_process");
|
|
55103
55101
|
|
|
@@ -55107,57 +55105,17 @@ var SIMCTL_SPAWN_TIMEOUT_MS = 1e4;
|
|
|
55107
55105
|
// ../tool-server/src/blueprints/ax-service.ts
|
|
55108
55106
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
55109
55107
|
var AX_SERVICE_NAMESPACE = "AXService";
|
|
55110
|
-
|
|
55108
|
+
var AX_SERVICE_TCP_PORT = Number(process.env.AX_SERVICE_TCP_PORT) || 9231;
|
|
55109
|
+
function axServiceRef(device, { transport = "unix" } = {}) {
|
|
55110
|
+
const transportSuffix = transport === "tcp" ? ":tcp" : "";
|
|
55111
55111
|
return {
|
|
55112
|
-
urn: `${AX_SERVICE_NAMESPACE}:${device.id}`,
|
|
55113
|
-
options: { device }
|
|
55112
|
+
urn: `${AX_SERVICE_NAMESPACE}:${device.id}${transportSuffix}`,
|
|
55113
|
+
options: { device, transport }
|
|
55114
55114
|
};
|
|
55115
55115
|
}
|
|
55116
55116
|
function getSocketPath(udid) {
|
|
55117
55117
|
return `/tmp/ax-${udid.slice(0, 8)}.sock`;
|
|
55118
55118
|
}
|
|
55119
|
-
function querySocket(socketPath, command, timeoutMs = 5e3) {
|
|
55120
|
-
return new Promise((resolve2, reject) => {
|
|
55121
|
-
let data = "";
|
|
55122
|
-
let settled = false;
|
|
55123
|
-
const timer = setTimeout(() => {
|
|
55124
|
-
if (!settled) {
|
|
55125
|
-
settled = true;
|
|
55126
|
-
client.destroy();
|
|
55127
|
-
reject(new Error(`ax-service query timed out: ${command}`));
|
|
55128
|
-
}
|
|
55129
|
-
}, timeoutMs);
|
|
55130
|
-
const client = net.createConnection(socketPath, () => {
|
|
55131
|
-
client.write(command + "\n");
|
|
55132
|
-
});
|
|
55133
|
-
client.on("data", (chunk) => {
|
|
55134
|
-
data += chunk.toString();
|
|
55135
|
-
});
|
|
55136
|
-
client.on("end", () => {
|
|
55137
|
-
if (!settled) {
|
|
55138
|
-
settled = true;
|
|
55139
|
-
clearTimeout(timer);
|
|
55140
|
-
resolve2(data.trim());
|
|
55141
|
-
}
|
|
55142
|
-
});
|
|
55143
|
-
client.on("error", (err) => {
|
|
55144
|
-
if (!settled) {
|
|
55145
|
-
settled = true;
|
|
55146
|
-
clearTimeout(timer);
|
|
55147
|
-
reject(err);
|
|
55148
|
-
}
|
|
55149
|
-
});
|
|
55150
|
-
});
|
|
55151
|
-
}
|
|
55152
|
-
async function pingDaemon(socketPath) {
|
|
55153
|
-
try {
|
|
55154
|
-
const raw = await querySocket(socketPath, "ping", 2e3);
|
|
55155
|
-
const parsed = JSON.parse(raw);
|
|
55156
|
-
return parsed.status === "ok";
|
|
55157
|
-
} catch {
|
|
55158
|
-
return false;
|
|
55159
|
-
}
|
|
55160
|
-
}
|
|
55161
55119
|
async function ensureAutomationEnabled(udid) {
|
|
55162
55120
|
await execFileAsync3(
|
|
55163
55121
|
"xcrun",
|
|
@@ -55214,76 +55172,77 @@ async function setAccessibilityPrefsPreBoot(udid) {
|
|
|
55214
55172
|
await execFileAsync3("plutil", ["-replace", key, "-bool", "true", plistPath]);
|
|
55215
55173
|
}
|
|
55216
55174
|
}
|
|
55217
|
-
|
|
55218
|
-
|
|
55219
|
-
|
|
55220
|
-
|
|
55221
|
-
|
|
55222
|
-
|
|
55223
|
-
|
|
55224
|
-
|
|
55225
|
-
|
|
55226
|
-
|
|
55227
|
-
|
|
55228
|
-
|
|
55229
|
-
|
|
55230
|
-
|
|
55231
|
-
|
|
55232
|
-
|
|
55233
|
-
|
|
55234
|
-
|
|
55235
|
-
reject(err);
|
|
55236
|
-
return;
|
|
55175
|
+
function startListener(endpoint, onConnection) {
|
|
55176
|
+
return new Promise((resolve3, reject) => {
|
|
55177
|
+
if (endpoint.transport === "unix") {
|
|
55178
|
+
try {
|
|
55179
|
+
fs3.unlinkSync(endpoint.socketPath);
|
|
55180
|
+
} catch {
|
|
55181
|
+
}
|
|
55182
|
+
}
|
|
55183
|
+
const server = net.createServer(onConnection);
|
|
55184
|
+
server.once("error", reject);
|
|
55185
|
+
const onListening = () => {
|
|
55186
|
+
server.off("error", reject);
|
|
55187
|
+
resolve3(server);
|
|
55188
|
+
};
|
|
55189
|
+
if (endpoint.transport === "tcp") {
|
|
55190
|
+
server.listen(endpoint.port, "127.0.0.1", onListening);
|
|
55191
|
+
} else {
|
|
55192
|
+
server.listen(endpoint.socketPath, onListening);
|
|
55237
55193
|
}
|
|
55194
|
+
});
|
|
55195
|
+
}
|
|
55196
|
+
function spawnDaemon(udid, endpoint) {
|
|
55197
|
+
const binaryPath = endpoint.transport === "tcp" ? axServiceBinaryPathTcp() : axServiceBinaryPath();
|
|
55198
|
+
const endpointArgs = endpoint.transport === "tcp" ? ["--port", String(endpoint.port)] : ["--socket", endpoint.socketPath];
|
|
55199
|
+
const proc = (0, import_node_child_process3.execFile)(
|
|
55200
|
+
"xcrun",
|
|
55201
|
+
["simctl", "spawn", udid, binaryPath, ...endpointArgs, "--timeout", "3600"],
|
|
55202
|
+
{ encoding: "utf8" }
|
|
55203
|
+
);
|
|
55204
|
+
const udidTag = typeof udid === "string" && udid.length > 0 ? udid.slice(0, 8) : "?";
|
|
55205
|
+
proc.stderr?.on("data", (data) => {
|
|
55206
|
+
process.stderr.write(`[ax-service ${udidTag}] ${data}`);
|
|
55207
|
+
});
|
|
55208
|
+
return proc;
|
|
55209
|
+
}
|
|
55210
|
+
function waitForDaemonConnection(server, proc, timeoutMs) {
|
|
55211
|
+
return new Promise((resolve3, reject) => {
|
|
55238
55212
|
let settled = false;
|
|
55239
|
-
const
|
|
55240
|
-
|
|
55241
|
-
|
|
55242
|
-
|
|
55243
|
-
|
|
55213
|
+
const onConnection = (socket) => {
|
|
55214
|
+
if (settled) return;
|
|
55215
|
+
settled = true;
|
|
55216
|
+
cleanup();
|
|
55217
|
+
resolve3(socket);
|
|
55218
|
+
};
|
|
55219
|
+
const onExit = (code) => {
|
|
55220
|
+
if (settled) return;
|
|
55221
|
+
settled = true;
|
|
55222
|
+
cleanup();
|
|
55223
|
+
reject(new Error(`ax-service exited with code ${code} before connecting`));
|
|
55224
|
+
};
|
|
55225
|
+
const onError = (err) => {
|
|
55226
|
+
if (settled) return;
|
|
55227
|
+
settled = true;
|
|
55228
|
+
cleanup();
|
|
55229
|
+
reject(err);
|
|
55230
|
+
};
|
|
55244
55231
|
const timer = setTimeout(() => {
|
|
55245
|
-
if (
|
|
55246
|
-
|
|
55247
|
-
|
|
55248
|
-
|
|
55249
|
-
|
|
55250
|
-
|
|
55251
|
-
|
|
55252
|
-
|
|
55253
|
-
|
|
55254
|
-
|
|
55255
|
-
|
|
55256
|
-
|
|
55257
|
-
|
|
55258
|
-
|
|
55259
|
-
if (msg.status === "ready" && !settled) {
|
|
55260
|
-
settled = true;
|
|
55261
|
-
clearTimeout(timer);
|
|
55262
|
-
resolve2(proc);
|
|
55263
|
-
return;
|
|
55264
|
-
}
|
|
55265
|
-
} catch {
|
|
55266
|
-
}
|
|
55267
|
-
}
|
|
55268
|
-
});
|
|
55269
|
-
const udidTag = typeof udid === "string" && udid.length > 0 ? udid.slice(0, 8) : "?";
|
|
55270
|
-
proc.stderr?.on("data", (data) => {
|
|
55271
|
-
process.stderr.write(`[ax-service ${udidTag}] ${data}`);
|
|
55272
|
-
});
|
|
55273
|
-
proc.on("exit", (code) => {
|
|
55274
|
-
if (!settled) {
|
|
55275
|
-
settled = true;
|
|
55276
|
-
clearTimeout(timer);
|
|
55277
|
-
reject(new Error(`ax-service exited with code ${code} before becoming ready`));
|
|
55278
|
-
}
|
|
55279
|
-
});
|
|
55280
|
-
proc.on("error", (err) => {
|
|
55281
|
-
if (!settled) {
|
|
55282
|
-
settled = true;
|
|
55283
|
-
clearTimeout(timer);
|
|
55284
|
-
reject(err);
|
|
55285
|
-
}
|
|
55286
|
-
});
|
|
55232
|
+
if (settled) return;
|
|
55233
|
+
settled = true;
|
|
55234
|
+
cleanup();
|
|
55235
|
+
reject(new Error("Timed out waiting for ax-service to connect"));
|
|
55236
|
+
}, timeoutMs);
|
|
55237
|
+
const cleanup = () => {
|
|
55238
|
+
clearTimeout(timer);
|
|
55239
|
+
server.off("connection", onConnection);
|
|
55240
|
+
proc.off("exit", onExit);
|
|
55241
|
+
proc.off("error", onError);
|
|
55242
|
+
};
|
|
55243
|
+
server.on("connection", onConnection);
|
|
55244
|
+
proc.on("exit", onExit);
|
|
55245
|
+
proc.on("error", onError);
|
|
55287
55246
|
});
|
|
55288
55247
|
}
|
|
55289
55248
|
var axServiceBlueprint = {
|
|
@@ -55310,32 +55269,108 @@ var axServiceBlueprint = {
|
|
|
55310
55269
|
);
|
|
55311
55270
|
}
|
|
55312
55271
|
const udid = device.id;
|
|
55313
|
-
const
|
|
55272
|
+
const transport = opts.transport ?? "unix";
|
|
55273
|
+
const endpoint = transport === "tcp" ? { transport: "tcp", port: AX_SERVICE_TCP_PORT } : { transport: "unix", socketPath: getSocketPath(udid) };
|
|
55314
55274
|
const events = new TypedEventEmitter();
|
|
55275
|
+
const pendingRpc = /* @__PURE__ */ new Map();
|
|
55276
|
+
let nextRpcId = 1;
|
|
55277
|
+
let daemonSocket = null;
|
|
55278
|
+
let disposed = false;
|
|
55279
|
+
const failPending = (err) => {
|
|
55280
|
+
for (const { reject, timer } of pendingRpc.values()) {
|
|
55281
|
+
clearTimeout(timer);
|
|
55282
|
+
reject(err);
|
|
55283
|
+
}
|
|
55284
|
+
pendingRpc.clear();
|
|
55285
|
+
};
|
|
55315
55286
|
await ensureAutomationEnabled(udid);
|
|
55316
55287
|
const entitlementBypassActive = await isEntitlementBypassActive(udid);
|
|
55317
|
-
await
|
|
55318
|
-
|
|
55288
|
+
const server = await startListener(endpoint, (socket) => {
|
|
55289
|
+
if (daemonSocket && !daemonSocket.destroyed) {
|
|
55290
|
+
daemonSocket.destroy();
|
|
55291
|
+
}
|
|
55292
|
+
daemonSocket = socket;
|
|
55293
|
+
const rl = readline.createInterface({ input: socket });
|
|
55294
|
+
rl.on("line", (raw) => {
|
|
55295
|
+
let msg;
|
|
55296
|
+
try {
|
|
55297
|
+
msg = JSON.parse(raw);
|
|
55298
|
+
} catch {
|
|
55299
|
+
return;
|
|
55300
|
+
}
|
|
55301
|
+
if (typeof msg.id !== "number") return;
|
|
55302
|
+
const pending = pendingRpc.get(msg.id);
|
|
55303
|
+
if (!pending) return;
|
|
55304
|
+
pendingRpc.delete(msg.id);
|
|
55305
|
+
clearTimeout(pending.timer);
|
|
55306
|
+
if (msg.error !== void 0 && msg.error !== null) {
|
|
55307
|
+
pending.reject(
|
|
55308
|
+
new Error(typeof msg.error === "string" ? msg.error : JSON.stringify(msg.error))
|
|
55309
|
+
);
|
|
55310
|
+
} else {
|
|
55311
|
+
pending.resolve(msg.result);
|
|
55312
|
+
}
|
|
55313
|
+
});
|
|
55314
|
+
socket.on("close", () => {
|
|
55315
|
+
rl.close();
|
|
55316
|
+
if (daemonSocket === socket) {
|
|
55317
|
+
daemonSocket = null;
|
|
55318
|
+
if (!disposed) {
|
|
55319
|
+
const err = new Error("ax-service daemon disconnected");
|
|
55320
|
+
failPending(err);
|
|
55321
|
+
events.emit("terminated", err);
|
|
55322
|
+
}
|
|
55323
|
+
}
|
|
55324
|
+
});
|
|
55325
|
+
socket.on("error", () => {
|
|
55326
|
+
});
|
|
55327
|
+
});
|
|
55328
|
+
const proc = spawnDaemon(udid, endpoint);
|
|
55319
55329
|
proc.on("exit", (code) => {
|
|
55320
|
-
|
|
55330
|
+
if (disposed) return;
|
|
55331
|
+
const err = new Error(`ax-service exited with code ${code}`);
|
|
55332
|
+
failPending(err);
|
|
55333
|
+
events.emit("terminated", err);
|
|
55321
55334
|
});
|
|
55322
55335
|
proc.on("error", (err) => {
|
|
55336
|
+
if (disposed) return;
|
|
55337
|
+
failPending(err);
|
|
55323
55338
|
events.emit("terminated", err);
|
|
55324
55339
|
});
|
|
55325
|
-
|
|
55326
|
-
|
|
55327
|
-
|
|
55328
|
-
|
|
55329
|
-
|
|
55330
|
-
|
|
55331
|
-
|
|
55340
|
+
try {
|
|
55341
|
+
daemonSocket = await waitForDaemonConnection(server, proc, 1e4);
|
|
55342
|
+
} catch (err) {
|
|
55343
|
+
if (!proc.killed) proc.kill("SIGTERM");
|
|
55344
|
+
server.close();
|
|
55345
|
+
if (endpoint.transport === "unix") {
|
|
55346
|
+
try {
|
|
55347
|
+
fs3.unlinkSync(endpoint.socketPath);
|
|
55348
|
+
} catch {
|
|
55349
|
+
}
|
|
55332
55350
|
}
|
|
55351
|
+
throw err;
|
|
55352
|
+
}
|
|
55353
|
+
function query(command, timeoutMs = 5e3) {
|
|
55354
|
+
return new Promise((resolve3, reject) => {
|
|
55355
|
+
if (!daemonSocket || daemonSocket.destroyed) {
|
|
55356
|
+
reject(new Error("ax-service not connected"));
|
|
55357
|
+
return;
|
|
55358
|
+
}
|
|
55359
|
+
const id = nextRpcId++;
|
|
55360
|
+
const timer = setTimeout(() => {
|
|
55361
|
+
if (pendingRpc.has(id)) {
|
|
55362
|
+
pendingRpc.delete(id);
|
|
55363
|
+
reject(new Error(`ax-service query timed out: ${command}`));
|
|
55364
|
+
}
|
|
55365
|
+
}, timeoutMs);
|
|
55366
|
+
pendingRpc.set(id, { resolve: resolve3, reject, timer });
|
|
55367
|
+
daemonSocket.write(JSON.stringify({ id, command }) + "\n");
|
|
55368
|
+
});
|
|
55333
55369
|
}
|
|
55334
55370
|
const api = {
|
|
55335
55371
|
degraded: !entitlementBypassActive,
|
|
55336
55372
|
async describe() {
|
|
55337
|
-
const result = await query("describe");
|
|
55338
|
-
if (result.error) throw new Error(`ax-service describe error: ${result.error}`);
|
|
55373
|
+
const result = await query("describe", 1e4);
|
|
55339
55374
|
return {
|
|
55340
55375
|
alertVisible: result.alertVisible ?? false,
|
|
55341
55376
|
screenFrame: result.screenFrame,
|
|
@@ -55347,18 +55382,31 @@ var axServiceBlueprint = {
|
|
|
55347
55382
|
return result.alertVisible ?? false;
|
|
55348
55383
|
},
|
|
55349
55384
|
async ping() {
|
|
55350
|
-
|
|
55385
|
+
try {
|
|
55386
|
+
const result = await query("ping", 2e3);
|
|
55387
|
+
return result.status === "ok";
|
|
55388
|
+
} catch {
|
|
55389
|
+
return false;
|
|
55390
|
+
}
|
|
55351
55391
|
}
|
|
55352
55392
|
};
|
|
55353
55393
|
const instance = {
|
|
55354
55394
|
api,
|
|
55355
55395
|
dispose: async () => {
|
|
55396
|
+
disposed = true;
|
|
55397
|
+
failPending(new Error("ax-service disposed"));
|
|
55398
|
+
if (daemonSocket && !daemonSocket.destroyed) {
|
|
55399
|
+
daemonSocket.destroy();
|
|
55400
|
+
}
|
|
55356
55401
|
if (proc && !proc.killed) {
|
|
55357
55402
|
proc.kill("SIGTERM");
|
|
55358
55403
|
}
|
|
55359
|
-
|
|
55360
|
-
|
|
55361
|
-
|
|
55404
|
+
server.close();
|
|
55405
|
+
if (endpoint.transport === "unix") {
|
|
55406
|
+
try {
|
|
55407
|
+
fs3.unlinkSync(endpoint.socketPath);
|
|
55408
|
+
} catch {
|
|
55409
|
+
}
|
|
55362
55410
|
}
|
|
55363
55411
|
},
|
|
55364
55412
|
events
|
|
@@ -55381,9 +55429,15 @@ var getPaths = () => {
|
|
|
55381
55429
|
return { BINARY_PATH, BINARY_DIR };
|
|
55382
55430
|
};
|
|
55383
55431
|
var READY_TIMEOUT_MS = 3e4;
|
|
55432
|
+
var SAFE_SIMULATOR_DEVICE_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/;
|
|
55384
55433
|
function spawnSimulatorServerProcess(udid, platform) {
|
|
55434
|
+
if (!SAFE_SIMULATOR_DEVICE_ID.test(udid)) {
|
|
55435
|
+
return Promise.reject(
|
|
55436
|
+
new Error(`Refusing to start simulator-server for unsafe device id "${udid}".`)
|
|
55437
|
+
);
|
|
55438
|
+
}
|
|
55385
55439
|
const { BINARY_PATH, BINARY_DIR } = getPaths();
|
|
55386
|
-
return new Promise((
|
|
55440
|
+
return new Promise((resolve3, reject) => {
|
|
55387
55441
|
const args = [platform, "--id", udid];
|
|
55388
55442
|
const proc = (0, import_node_child_process4.spawn)(BINARY_PATH, args, {
|
|
55389
55443
|
cwd: BINARY_DIR,
|
|
@@ -55394,7 +55448,7 @@ function spawnSimulatorServerProcess(udid, platform) {
|
|
|
55394
55448
|
let settled = false;
|
|
55395
55449
|
const STREAM_GRACE_MS = 500;
|
|
55396
55450
|
let apiReadyTimer = null;
|
|
55397
|
-
const rl =
|
|
55451
|
+
const rl = readline2.createInterface({ input: proc.stdout });
|
|
55398
55452
|
const settle = (fn, cleanup) => {
|
|
55399
55453
|
if (settled) return;
|
|
55400
55454
|
settled = true;
|
|
@@ -55406,7 +55460,7 @@ function spawnSimulatorServerProcess(udid, platform) {
|
|
|
55406
55460
|
};
|
|
55407
55461
|
const resolveWhenReady = () => {
|
|
55408
55462
|
if (apiUrl == null) return;
|
|
55409
|
-
settle(() =>
|
|
55463
|
+
settle(() => resolve3({ proc, apiUrl, streamUrl }));
|
|
55410
55464
|
};
|
|
55411
55465
|
rl.on("line", (rawLine) => {
|
|
55412
55466
|
const line = rawLine.trim();
|
|
@@ -55513,22 +55567,48 @@ var import_node_child_process5 = require("node:child_process");
|
|
|
55513
55567
|
var import_node_util4 = require("node:util");
|
|
55514
55568
|
var execFileAsync4 = (0, import_node_util4.promisify)(import_node_child_process5.execFile);
|
|
55515
55569
|
async function resolveAdbOrThrow() {
|
|
55516
|
-
const
|
|
55517
|
-
if (!
|
|
55570
|
+
const path16 = await resolveAndroidBinary("adb");
|
|
55571
|
+
if (!path16) {
|
|
55518
55572
|
throw new Error(
|
|
55519
55573
|
"`adb` not found on PATH or under `$ANDROID_HOME/platform-tools`. Install Android SDK Platform Tools or set `$ANDROID_HOME` to your SDK root."
|
|
55520
55574
|
);
|
|
55521
55575
|
}
|
|
55522
|
-
return
|
|
55576
|
+
return path16;
|
|
55523
55577
|
}
|
|
55524
55578
|
async function resolveEmulatorOrThrow() {
|
|
55525
|
-
const
|
|
55526
|
-
if (!
|
|
55579
|
+
const path16 = await resolveAndroidBinary("emulator");
|
|
55580
|
+
if (!path16) {
|
|
55527
55581
|
throw new Error(
|
|
55528
55582
|
"`emulator` not found on PATH or under `$ANDROID_HOME/emulator`. Install the Android Emulator package or set `$ANDROID_HOME` to your SDK root."
|
|
55529
55583
|
);
|
|
55530
55584
|
}
|
|
55531
|
-
return
|
|
55585
|
+
return path16;
|
|
55586
|
+
}
|
|
55587
|
+
var emulatorFlagSupportCache = /* @__PURE__ */ new Map();
|
|
55588
|
+
async function emulatorSupportsFlag(flag, options = {}) {
|
|
55589
|
+
let emulatorPath;
|
|
55590
|
+
try {
|
|
55591
|
+
emulatorPath = await resolveEmulatorOrThrow();
|
|
55592
|
+
} catch {
|
|
55593
|
+
return false;
|
|
55594
|
+
}
|
|
55595
|
+
const cacheKey3 = `${emulatorPath}|${flag}`;
|
|
55596
|
+
const cached2 = emulatorFlagSupportCache.get(cacheKey3);
|
|
55597
|
+
if (cached2 !== void 0) return cached2;
|
|
55598
|
+
let output = "";
|
|
55599
|
+
try {
|
|
55600
|
+
const { stdout, stderr } = await execFileAsync4(emulatorPath, ["-help"], {
|
|
55601
|
+
timeout: options.timeoutMs ?? 1e4,
|
|
55602
|
+
maxBuffer: 8 * 1024 * 1024
|
|
55603
|
+
});
|
|
55604
|
+
output = stdout + stderr;
|
|
55605
|
+
} catch (err) {
|
|
55606
|
+
const e = err;
|
|
55607
|
+
output = (e.stdout ?? "") + (e.stderr ?? "");
|
|
55608
|
+
}
|
|
55609
|
+
const supported = output.includes(flag);
|
|
55610
|
+
emulatorFlagSupportCache.set(cacheKey3, supported);
|
|
55611
|
+
return supported;
|
|
55532
55612
|
}
|
|
55533
55613
|
var ADB_KILL_SIGNAL = "SIGKILL";
|
|
55534
55614
|
function describeAdbFailure(args, err) {
|
|
@@ -55572,6 +55652,9 @@ async function runAdbBinary(args, options = {}) {
|
|
|
55572
55652
|
throw describeAdbFailure(args, err);
|
|
55573
55653
|
}
|
|
55574
55654
|
}
|
|
55655
|
+
function shellQuote(value) {
|
|
55656
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
55657
|
+
}
|
|
55575
55658
|
async function adbShell(serial, shellCommand, options = {}) {
|
|
55576
55659
|
const { stdout } = await runAdb(["-s", serial, "shell", shellCommand], options);
|
|
55577
55660
|
return stdout;
|
|
@@ -55896,6 +55979,12 @@ function createPreviewRouter(registry2) {
|
|
|
55896
55979
|
router.get("/simulator-server/:udid", async (req, res) => {
|
|
55897
55980
|
const udid = req.params.udid;
|
|
55898
55981
|
try {
|
|
55982
|
+
const data = await registry2.invokeTool(listDevicesTool.id);
|
|
55983
|
+
const known = data.devices.some((d) => (d.platform === "ios" ? d.udid : d.serial) === udid);
|
|
55984
|
+
if (!known) {
|
|
55985
|
+
res.status(400).json({ error: `Unknown device "${udid}". Use a udid/serial from /preview/simulators.` });
|
|
55986
|
+
return;
|
|
55987
|
+
}
|
|
55899
55988
|
const { urn, options } = simulatorServerRef(resolveDevice(udid));
|
|
55900
55989
|
const api = await registry2.resolveService(urn, options);
|
|
55901
55990
|
res.json({
|
|
@@ -55964,6 +56053,20 @@ function assertSupported(toolId, capability18, device) {
|
|
|
55964
56053
|
|
|
55965
56054
|
// ../tool-server/src/http.ts
|
|
55966
56055
|
var AUTO_SUPPRESS_MS = 30 * 60 * 1e3;
|
|
56056
|
+
var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
|
|
56057
|
+
var BEARER_PREFIX = "Bearer ";
|
|
56058
|
+
function constantTimeEqual(a, b) {
|
|
56059
|
+
if (a.length !== b.length) return false;
|
|
56060
|
+
let diff = 0;
|
|
56061
|
+
for (let i = 0; i < a.length; i++) {
|
|
56062
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
56063
|
+
}
|
|
56064
|
+
return diff === 0;
|
|
56065
|
+
}
|
|
56066
|
+
function extractBearerToken(authHeader) {
|
|
56067
|
+
if (!authHeader || !authHeader.startsWith(BEARER_PREFIX)) return null;
|
|
56068
|
+
return authHeader.slice(BEARER_PREFIX.length).trim() || null;
|
|
56069
|
+
}
|
|
55967
56070
|
function findDependencyMissing(err) {
|
|
55968
56071
|
let current = err;
|
|
55969
56072
|
for (let depth = 0; depth < 8 && current instanceof Error; depth++) {
|
|
@@ -55972,16 +56075,71 @@ function findDependencyMissing(err) {
|
|
|
55972
56075
|
}
|
|
55973
56076
|
return null;
|
|
55974
56077
|
}
|
|
56078
|
+
var LOOPBACK_HOSTNAMES = ["127.0.0.1", "localhost", "::1"];
|
|
56079
|
+
function isLoopbackHost(host) {
|
|
56080
|
+
return host === "" || LOOPBACK_HOSTNAMES.includes(host);
|
|
56081
|
+
}
|
|
56082
|
+
function isWildcardHost(host) {
|
|
56083
|
+
return host === "0.0.0.0" || host === "::" || host === "::0";
|
|
56084
|
+
}
|
|
56085
|
+
function extractHostname(host) {
|
|
56086
|
+
if (host.startsWith("[")) {
|
|
56087
|
+
const end = host.indexOf("]");
|
|
56088
|
+
return end === -1 ? host : host.slice(1, end);
|
|
56089
|
+
}
|
|
56090
|
+
const colon = host.indexOf(":");
|
|
56091
|
+
return colon === -1 ? host : host.slice(0, colon);
|
|
56092
|
+
}
|
|
55975
56093
|
function createHttpApp(registry2, options) {
|
|
55976
56094
|
const app = (0, import_express2.default)();
|
|
55977
56095
|
app.use(import_express2.default.json());
|
|
55978
56096
|
const idleTimer = createIdleTimer(options?.idleTimeoutMs ?? 0, options?.onIdle);
|
|
55979
|
-
|
|
55980
|
-
|
|
55981
|
-
|
|
55982
|
-
|
|
55983
|
-
|
|
55984
|
-
|
|
56097
|
+
const bindHost = options?.bindHost ?? "127.0.0.1";
|
|
56098
|
+
const hostGuardDisabled = isWildcardHost(bindHost);
|
|
56099
|
+
const allowedHostnames = new Set(LOOPBACK_HOSTNAMES);
|
|
56100
|
+
if (!isLoopbackHost(bindHost) && !isWildcardHost(bindHost)) {
|
|
56101
|
+
allowedHostnames.add(bindHost);
|
|
56102
|
+
}
|
|
56103
|
+
app.use((req, res, next) => {
|
|
56104
|
+
if (hostGuardDisabled) {
|
|
56105
|
+
next();
|
|
56106
|
+
return;
|
|
56107
|
+
}
|
|
56108
|
+
const host = req.headers.host;
|
|
56109
|
+
if (!host) {
|
|
56110
|
+
res.status(400).json({ error: "Missing Host header" });
|
|
56111
|
+
return;
|
|
56112
|
+
}
|
|
56113
|
+
const hostname3 = extractHostname(host);
|
|
56114
|
+
if (!allowedHostnames.has(hostname3)) {
|
|
56115
|
+
res.status(403).json({
|
|
56116
|
+
error: `Refusing request with Host "${host}". The tool-server accepts loopback hostnames (127.0.0.1, localhost, ::1)` + (isLoopbackHost(bindHost) ? "" : ` and its bind host (${bindHost})`) + ` to defend against DNS-rebinding. If you are reaching this from your own client, use one of those instead of a public hostname.`
|
|
56117
|
+
});
|
|
56118
|
+
return;
|
|
56119
|
+
}
|
|
56120
|
+
next();
|
|
56121
|
+
});
|
|
56122
|
+
const expectedToken = process.env[AUTH_TOKEN_ENV] ?? "";
|
|
56123
|
+
if (!expectedToken) {
|
|
56124
|
+
process.stderr.write(
|
|
56125
|
+
`[tool-server] WARNING: ${AUTH_TOKEN_ENV} is not set; running with authentication disabled. Any local process can drive the tool-server. This is only safe for development.
|
|
56126
|
+
`
|
|
56127
|
+
);
|
|
56128
|
+
}
|
|
56129
|
+
app.use((req, res, next) => {
|
|
56130
|
+
if (!expectedToken) {
|
|
56131
|
+
next();
|
|
56132
|
+
return;
|
|
56133
|
+
}
|
|
56134
|
+
if (req.path === "/preview" || req.path.startsWith("/preview/")) {
|
|
56135
|
+
next();
|
|
56136
|
+
return;
|
|
56137
|
+
}
|
|
56138
|
+
const provided = extractBearerToken(req.headers.authorization);
|
|
56139
|
+
if (!provided || !constantTimeEqual(provided, expectedToken)) {
|
|
56140
|
+
res.status(401).json({
|
|
56141
|
+
error: "Missing or invalid Authorization header. Tool-server requires `Authorization: Bearer <token>` where <token> matches the value in ~/.argent/tool-server.json."
|
|
56142
|
+
});
|
|
55985
56143
|
return;
|
|
55986
56144
|
}
|
|
55987
56145
|
next();
|
|
@@ -56128,9 +56286,10 @@ function createHttpApp(registry2, options) {
|
|
|
56128
56286
|
var net2 = __toESM(require("node:net"));
|
|
56129
56287
|
var fs5 = __toESM(require("node:fs"));
|
|
56130
56288
|
var path5 = __toESM(require("node:path"));
|
|
56131
|
-
var
|
|
56289
|
+
var readline3 = __toESM(require("node:readline"));
|
|
56132
56290
|
var import_node_child_process7 = require("node:child_process");
|
|
56133
56291
|
var import_node_util6 = require("node:util");
|
|
56292
|
+
var NATIVE_DEVTOOLS_TCP_PORT = Number(process.env.NATIVE_DEVTOOLS_TCP_PORT) || 9230;
|
|
56134
56293
|
var execFileAsync6 = (0, import_node_util6.promisify)(import_node_child_process7.execFile);
|
|
56135
56294
|
var NATIVE_DEVTOOLS_NAMESPACE = "NativeDevtools";
|
|
56136
56295
|
var MAX_NATIVE_DEVTOOLS_INIT_ATTEMPTS = 3;
|
|
@@ -56163,10 +56322,11 @@ async function precheckNativeDevtools(api, udid, bundleId) {
|
|
|
56163
56322
|
}
|
|
56164
56323
|
return null;
|
|
56165
56324
|
}
|
|
56166
|
-
function nativeDevtoolsRef(device) {
|
|
56325
|
+
function nativeDevtoolsRef(device, { transport = "unix" } = {}) {
|
|
56326
|
+
const transportSuffix = transport === "tcp" ? ":tcp" : "";
|
|
56167
56327
|
return {
|
|
56168
|
-
urn: `${NATIVE_DEVTOOLS_NAMESPACE}:${device.id}`,
|
|
56169
|
-
options: { device }
|
|
56328
|
+
urn: `${NATIVE_DEVTOOLS_NAMESPACE}:${device.id}${transportSuffix}`,
|
|
56329
|
+
options: { device, transport }
|
|
56170
56330
|
};
|
|
56171
56331
|
}
|
|
56172
56332
|
var ARGENT_BOOTSTRAP_DYLIB_BASENAMES = /* @__PURE__ */ new Set([
|
|
@@ -56219,8 +56379,8 @@ async function ensureAccessibilityEnabled(udid) {
|
|
|
56219
56379
|
)
|
|
56220
56380
|
);
|
|
56221
56381
|
}
|
|
56222
|
-
async function ensureEnv(udid,
|
|
56223
|
-
const bootstrapPath = bootstrapDylibPath();
|
|
56382
|
+
async function ensureEnv(udid, endpoint) {
|
|
56383
|
+
const bootstrapPath = endpoint.transport === "tcp" ? bootstrapDylibPathTcp() : bootstrapDylibPath();
|
|
56224
56384
|
const result = await execFileAsync6(
|
|
56225
56385
|
"xcrun",
|
|
56226
56386
|
["simctl", "spawn", udid, "launchctl", "getenv", "DYLD_INSERT_LIBRARIES"],
|
|
@@ -56235,11 +56395,35 @@ async function ensureEnv(udid, socketPath) {
|
|
|
56235
56395
|
{ timeout: SIMCTL_SPAWN_TIMEOUT_MS }
|
|
56236
56396
|
);
|
|
56237
56397
|
}
|
|
56238
|
-
|
|
56239
|
-
|
|
56240
|
-
|
|
56241
|
-
|
|
56242
|
-
|
|
56398
|
+
if (endpoint.transport === "tcp") {
|
|
56399
|
+
await execFileAsync6(
|
|
56400
|
+
"xcrun",
|
|
56401
|
+
[
|
|
56402
|
+
"simctl",
|
|
56403
|
+
"spawn",
|
|
56404
|
+
udid,
|
|
56405
|
+
"launchctl",
|
|
56406
|
+
"setenv",
|
|
56407
|
+
"NATIVE_DEVTOOLS_IOS_CDP_PORT",
|
|
56408
|
+
String(endpoint.port)
|
|
56409
|
+
],
|
|
56410
|
+
{ timeout: SIMCTL_SPAWN_TIMEOUT_MS }
|
|
56411
|
+
);
|
|
56412
|
+
} else {
|
|
56413
|
+
await execFileAsync6(
|
|
56414
|
+
"xcrun",
|
|
56415
|
+
[
|
|
56416
|
+
"simctl",
|
|
56417
|
+
"spawn",
|
|
56418
|
+
udid,
|
|
56419
|
+
"launchctl",
|
|
56420
|
+
"setenv",
|
|
56421
|
+
"NATIVE_DEVTOOLS_IOS_CDP_SOCKET",
|
|
56422
|
+
endpoint.socketPath
|
|
56423
|
+
],
|
|
56424
|
+
{ timeout: SIMCTL_SPAWN_TIMEOUT_MS }
|
|
56425
|
+
);
|
|
56426
|
+
}
|
|
56243
56427
|
await ensureAccessibilityEnabled(udid);
|
|
56244
56428
|
}
|
|
56245
56429
|
async function listRunningUIKitApplicationBundleIds(udid) {
|
|
@@ -56268,6 +56452,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
56268
56452
|
);
|
|
56269
56453
|
}
|
|
56270
56454
|
const { device } = opts;
|
|
56455
|
+
const transport = opts.transport ?? "unix";
|
|
56271
56456
|
if (device.platform !== "ios") {
|
|
56272
56457
|
throw new Error(
|
|
56273
56458
|
`${NATIVE_DEVTOOLS_NAMESPACE} is iOS-only. The target '${device.id}' classifies as Android \u2014 native-devtools tools (native-describe-screen, native-find-views, etc.) only drive iOS simulators. Pick an iOS udid from list-devices.`
|
|
@@ -56275,6 +56460,8 @@ var nativeDevtoolsBlueprint = {
|
|
|
56275
56460
|
}
|
|
56276
56461
|
const udid = device.id;
|
|
56277
56462
|
const socketPath = getNativeDevtoolsSocketPath(udid);
|
|
56463
|
+
const tcpPort = NATIVE_DEVTOOLS_TCP_PORT;
|
|
56464
|
+
const endpoint = transport === "tcp" ? { transport: "tcp", port: tcpPort } : { transport: "unix", socketPath };
|
|
56278
56465
|
const MAX_LOG_ENTRIES = 1e3;
|
|
56279
56466
|
const connections2 = /* @__PURE__ */ new Map();
|
|
56280
56467
|
const pendingRpc = /* @__PURE__ */ new Map();
|
|
@@ -56297,7 +56484,7 @@ var nativeDevtoolsBlueprint = {
|
|
|
56297
56484
|
const ensureEnvReady = () => {
|
|
56298
56485
|
if (envSetup || initFailure?.givenUp) return Promise.resolve();
|
|
56299
56486
|
if (inFlight) return inFlight;
|
|
56300
|
-
inFlight = Promise.resolve().then(() => ensureEnv(udid,
|
|
56487
|
+
inFlight = Promise.resolve().then(() => ensureEnv(udid, endpoint)).then(() => {
|
|
56301
56488
|
envSetup = true;
|
|
56302
56489
|
initFailure = null;
|
|
56303
56490
|
}).catch((err) => {
|
|
@@ -56320,8 +56507,8 @@ var nativeDevtoolsBlueprint = {
|
|
|
56320
56507
|
);
|
|
56321
56508
|
}
|
|
56322
56509
|
const id = nextRpcId++;
|
|
56323
|
-
return new Promise((
|
|
56324
|
-
pendingRpc.set(id, { resolve:
|
|
56510
|
+
return new Promise((resolve3, reject) => {
|
|
56511
|
+
pendingRpc.set(id, { resolve: resolve3, reject });
|
|
56325
56512
|
conn.socket.write(
|
|
56326
56513
|
JSON.stringify({
|
|
56327
56514
|
type: "ViewInspector",
|
|
@@ -56336,13 +56523,15 @@ var nativeDevtoolsBlueprint = {
|
|
|
56336
56523
|
}, 5e3);
|
|
56337
56524
|
});
|
|
56338
56525
|
}
|
|
56339
|
-
|
|
56340
|
-
|
|
56341
|
-
|
|
56526
|
+
if (transport === "unix") {
|
|
56527
|
+
try {
|
|
56528
|
+
fs5.unlinkSync(socketPath);
|
|
56529
|
+
} catch {
|
|
56530
|
+
}
|
|
56342
56531
|
}
|
|
56343
56532
|
const server = net2.createServer((socket) => {
|
|
56344
56533
|
let bundleId = null;
|
|
56345
|
-
const rl =
|
|
56534
|
+
const rl = readline3.createInterface({ input: socket });
|
|
56346
56535
|
rl.on("line", (raw) => {
|
|
56347
56536
|
let msg;
|
|
56348
56537
|
try {
|
|
@@ -56404,7 +56593,11 @@ var nativeDevtoolsBlueprint = {
|
|
|
56404
56593
|
socket.on("error", () => {
|
|
56405
56594
|
});
|
|
56406
56595
|
});
|
|
56407
|
-
|
|
56596
|
+
if (transport === "tcp") {
|
|
56597
|
+
server.listen(tcpPort, "127.0.0.1");
|
|
56598
|
+
} else {
|
|
56599
|
+
server.listen(socketPath);
|
|
56600
|
+
}
|
|
56408
56601
|
await ensureEnvReady().catch(() => {
|
|
56409
56602
|
});
|
|
56410
56603
|
const api = {
|
|
@@ -56489,9 +56682,11 @@ var nativeDevtoolsBlueprint = {
|
|
|
56489
56682
|
connections2.clear();
|
|
56490
56683
|
activatedBundleIds.clear();
|
|
56491
56684
|
server.close();
|
|
56492
|
-
|
|
56493
|
-
|
|
56494
|
-
|
|
56685
|
+
if (transport === "unix") {
|
|
56686
|
+
try {
|
|
56687
|
+
fs5.unlinkSync(socketPath);
|
|
56688
|
+
} catch {
|
|
56689
|
+
}
|
|
56495
56690
|
}
|
|
56496
56691
|
for (const { reject } of pendingRpc.values()) {
|
|
56497
56692
|
reject(new Error("NativeDevtools service disposed"));
|
|
@@ -56505,11 +56700,31 @@ var nativeDevtoolsBlueprint = {
|
|
|
56505
56700
|
|
|
56506
56701
|
// ../tool-server/src/blueprints/android-devtools.ts
|
|
56507
56702
|
var import_node_child_process8 = require("node:child_process");
|
|
56508
|
-
var
|
|
56509
|
-
|
|
56703
|
+
var readline5 = __toESM(require("node:readline"));
|
|
56704
|
+
|
|
56705
|
+
// ../native-devtools-android/src/index.ts
|
|
56706
|
+
var path6 = __toESM(require("node:path"));
|
|
56707
|
+
var fs6 = __toESM(require("node:fs"));
|
|
56708
|
+
var DIST_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_DIR ?? path6.join(__dirname, "..", "dist");
|
|
56709
|
+
var cachedManifest = null;
|
|
56710
|
+
function helperManifest() {
|
|
56711
|
+
if (cachedManifest) return cachedManifest;
|
|
56712
|
+
const manifestPath = path6.join(__dirname, "..", "manifest.json");
|
|
56713
|
+
cachedManifest = JSON.parse(fs6.readFileSync(manifestPath, "utf-8"));
|
|
56714
|
+
return cachedManifest;
|
|
56715
|
+
}
|
|
56716
|
+
function bundledHelperApkPath() {
|
|
56717
|
+
const manifest = helperManifest();
|
|
56718
|
+
const apk = path6.join(DIST_DIR, `argent-android-devtools-${manifest.versionName}.apk`);
|
|
56719
|
+
if (!fs6.existsSync(apk)) {
|
|
56720
|
+
throw new Error(
|
|
56721
|
+
`Bundled Android devtools helper APK not found at ${apk}. Run \`bash packages/native-devtools-android/scripts/build.sh\` to build it.`
|
|
56722
|
+
);
|
|
56723
|
+
}
|
|
56724
|
+
return apk;
|
|
56725
|
+
}
|
|
56510
56726
|
|
|
56511
56727
|
// ../tool-server/src/utils/android-helper-install.ts
|
|
56512
|
-
var import_native_devtools_android = __toESM(require_dist2());
|
|
56513
56728
|
var installedHelpers = /* @__PURE__ */ new Map();
|
|
56514
56729
|
function cacheKey(serial, versionCode) {
|
|
56515
56730
|
return `${serial}|${versionCode}`;
|
|
@@ -56537,7 +56752,7 @@ async function probeInstalledVersion(serial, packageName) {
|
|
|
56537
56752
|
return { installed: false, versionCode: null };
|
|
56538
56753
|
}
|
|
56539
56754
|
async function ensureAndroidDevtoolsInstalled(serial) {
|
|
56540
|
-
const manifest =
|
|
56755
|
+
const manifest = helperManifest();
|
|
56541
56756
|
const key = cacheKey(serial, manifest.versionCode);
|
|
56542
56757
|
if (installedHelpers.has(key)) return;
|
|
56543
56758
|
const probe3 = await probeInstalledVersion(serial, manifest.packageName);
|
|
@@ -56545,7 +56760,7 @@ async function ensureAndroidDevtoolsInstalled(serial) {
|
|
|
56545
56760
|
installedHelpers.set(key, true);
|
|
56546
56761
|
return;
|
|
56547
56762
|
}
|
|
56548
|
-
const apkPath =
|
|
56763
|
+
const apkPath = bundledHelperApkPath();
|
|
56549
56764
|
const args = ["-s", serial, "install", ...manifest.installFlags, apkPath];
|
|
56550
56765
|
try {
|
|
56551
56766
|
await runAdb(args, { timeoutMs: 6e4 });
|
|
@@ -56566,11 +56781,11 @@ async function ensureAndroidDevtoolsInstalled(serial) {
|
|
|
56566
56781
|
|
|
56567
56782
|
// ../tool-server/src/utils/android-devtools-client.ts
|
|
56568
56783
|
var net3 = __toESM(require("node:net"));
|
|
56569
|
-
var
|
|
56784
|
+
var readline4 = __toESM(require("node:readline"));
|
|
56570
56785
|
var DEFAULT_RPC_TIMEOUT_MS = 5e3;
|
|
56571
56786
|
var LONG_RPC_TIMEOUT_MS = 15e3;
|
|
56572
56787
|
function connectAndroidDevtoolsClient(localPort, onTerminated) {
|
|
56573
|
-
return new Promise((
|
|
56788
|
+
return new Promise((resolve3, reject) => {
|
|
56574
56789
|
const socket = net3.createConnection({ host: "127.0.0.1", port: localPort });
|
|
56575
56790
|
socket.setNoDelay(true);
|
|
56576
56791
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -56592,7 +56807,7 @@ function connectAndroidDevtoolsClient(localPort, onTerminated) {
|
|
|
56592
56807
|
onTerminated(error51);
|
|
56593
56808
|
};
|
|
56594
56809
|
socket.once("connect", () => {
|
|
56595
|
-
const rl =
|
|
56810
|
+
const rl = readline4.createInterface({ input: socket });
|
|
56596
56811
|
rl.on("line", (line) => {
|
|
56597
56812
|
if (!line.trim()) return;
|
|
56598
56813
|
let parsed;
|
|
@@ -56615,7 +56830,7 @@ function connectAndroidDevtoolsClient(localPort, onTerminated) {
|
|
|
56615
56830
|
}
|
|
56616
56831
|
});
|
|
56617
56832
|
rl.on("close", () => cleanup());
|
|
56618
|
-
|
|
56833
|
+
resolve3({
|
|
56619
56834
|
request(method, params = {}) {
|
|
56620
56835
|
const send = () => {
|
|
56621
56836
|
if (closed) return Promise.reject(new Error("AndroidDevtools client closed"));
|
|
@@ -56675,7 +56890,7 @@ var READY_TIMEOUT_MS2 = 3e4;
|
|
|
56675
56890
|
var HELPER_PORT_MARKER = /^INSTRUMENTATION_STATUS:\s*port=(\d+)/;
|
|
56676
56891
|
var ADB_FORWARD_PORT_MARKER = /^(\d+)\s*$/;
|
|
56677
56892
|
async function spawnHelper(serial) {
|
|
56678
|
-
const manifest =
|
|
56893
|
+
const manifest = helperManifest();
|
|
56679
56894
|
const adbPath = await resolveAndroidBinary("adb");
|
|
56680
56895
|
if (!adbPath) {
|
|
56681
56896
|
throw new Error(
|
|
@@ -56687,7 +56902,7 @@ async function spawnHelper(serial) {
|
|
|
56687
56902
|
["-s", serial, "shell", "am", "instrument", "-w", manifest.instrumentationRunner],
|
|
56688
56903
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
56689
56904
|
);
|
|
56690
|
-
return new Promise((
|
|
56905
|
+
return new Promise((resolve3, reject) => {
|
|
56691
56906
|
let devicePort = null;
|
|
56692
56907
|
let localPort = null;
|
|
56693
56908
|
let settled = false;
|
|
@@ -56700,7 +56915,7 @@ async function spawnHelper(serial) {
|
|
|
56700
56915
|
cleanup?.();
|
|
56701
56916
|
fn();
|
|
56702
56917
|
};
|
|
56703
|
-
const rl =
|
|
56918
|
+
const rl = readline5.createInterface({ input: proc.stdout });
|
|
56704
56919
|
rl.on("line", async (rawLine) => {
|
|
56705
56920
|
const line = rawLine.trim();
|
|
56706
56921
|
const portMatch = HELPER_PORT_MARKER.exec(line);
|
|
@@ -56715,7 +56930,7 @@ async function spawnHelper(serial) {
|
|
|
56715
56930
|
throw new Error(`adb forward returned unexpected output: ${stdout.trim()}`);
|
|
56716
56931
|
}
|
|
56717
56932
|
localPort = parseInt(lpMatch[1], 10);
|
|
56718
|
-
settle(() =>
|
|
56933
|
+
settle(() => resolve3({ proc, devicePort, localPort }));
|
|
56719
56934
|
} catch (err) {
|
|
56720
56935
|
settle(
|
|
56721
56936
|
() => reject(err instanceof Error ? err : new Error(String(err))),
|
|
@@ -57346,7 +57561,7 @@ var CDPClient = class {
|
|
|
57346
57561
|
this.wsUrl = wsUrl;
|
|
57347
57562
|
}
|
|
57348
57563
|
connect() {
|
|
57349
|
-
return new Promise((
|
|
57564
|
+
return new Promise((resolve3, reject) => {
|
|
57350
57565
|
const { protocol, host } = new URL(this.wsUrl);
|
|
57351
57566
|
const origin = (protocol === "wss:" ? "https://" : "http://") + host.replace("localhost", "127.0.0.1");
|
|
57352
57567
|
const ws = new wrapper_default(this.wsUrl, { headers: { Origin: origin } });
|
|
@@ -57354,7 +57569,7 @@ var CDPClient = class {
|
|
|
57354
57569
|
const onOpen = () => {
|
|
57355
57570
|
cleanup();
|
|
57356
57571
|
this.events.emit("connected");
|
|
57357
|
-
|
|
57572
|
+
resolve3();
|
|
57358
57573
|
};
|
|
57359
57574
|
const onError = (err) => {
|
|
57360
57575
|
cleanup();
|
|
@@ -57387,17 +57602,17 @@ var CDPClient = class {
|
|
|
57387
57602
|
if (!this.ws) return;
|
|
57388
57603
|
const ws = this.ws;
|
|
57389
57604
|
this.ws = null;
|
|
57390
|
-
return new Promise((
|
|
57391
|
-
ws.once("close", () =>
|
|
57605
|
+
return new Promise((resolve3) => {
|
|
57606
|
+
ws.once("close", () => resolve3());
|
|
57392
57607
|
ws.close();
|
|
57393
|
-
setTimeout(
|
|
57608
|
+
setTimeout(resolve3, 1e3);
|
|
57394
57609
|
});
|
|
57395
57610
|
}
|
|
57396
57611
|
isConnected() {
|
|
57397
57612
|
return this.ws?.readyState === wrapper_default.OPEN;
|
|
57398
57613
|
}
|
|
57399
57614
|
send(method, params, timeout = DEFAULT_TIMEOUT_MS) {
|
|
57400
|
-
return new Promise((
|
|
57615
|
+
return new Promise((resolve3, reject) => {
|
|
57401
57616
|
if (!this.ws || this.ws.readyState !== wrapper_default.OPEN) {
|
|
57402
57617
|
return reject(new Error("CDP not connected"));
|
|
57403
57618
|
}
|
|
@@ -57409,7 +57624,7 @@ var CDPClient = class {
|
|
|
57409
57624
|
this.pending.set(id, {
|
|
57410
57625
|
resolve: (result) => {
|
|
57411
57626
|
this.trackDomain(method);
|
|
57412
|
-
|
|
57627
|
+
resolve3(result);
|
|
57413
57628
|
},
|
|
57414
57629
|
reject,
|
|
57415
57630
|
timer
|
|
@@ -57434,12 +57649,12 @@ var CDPClient = class {
|
|
|
57434
57649
|
evaluateWithBinding(expression, requestId, options) {
|
|
57435
57650
|
const id = requestId ?? crypto.randomUUID();
|
|
57436
57651
|
const timeout = options?.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
57437
|
-
return new Promise((
|
|
57652
|
+
return new Promise((resolve3, reject) => {
|
|
57438
57653
|
const timer = setTimeout(() => {
|
|
57439
57654
|
this.pendingBindings.delete(id);
|
|
57440
57655
|
reject(new Error(`Binding response for requestId=${id} timed out`));
|
|
57441
57656
|
}, timeout);
|
|
57442
|
-
this.pendingBindings.set(id, { resolve:
|
|
57657
|
+
this.pendingBindings.set(id, { resolve: resolve3, reject, timer });
|
|
57443
57658
|
this.evaluate(expression, { timeout }).catch((err) => {
|
|
57444
57659
|
this.pendingBindings.delete(id);
|
|
57445
57660
|
clearTimeout(timer);
|
|
@@ -57547,8 +57762,18 @@ var CDPClient = class {
|
|
|
57547
57762
|
};
|
|
57548
57763
|
|
|
57549
57764
|
// ../tool-server/src/utils/debugger/source-resolver.ts
|
|
57550
|
-
var
|
|
57551
|
-
var
|
|
57765
|
+
var fs7 = __toESM(require("node:fs/promises"));
|
|
57766
|
+
var path7 = __toESM(require("node:path"));
|
|
57767
|
+
var ALLOWED_SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]);
|
|
57768
|
+
function isInsideProject(absFile, projectRoot) {
|
|
57769
|
+
const resolvedRoot = path7.resolve(projectRoot);
|
|
57770
|
+
const resolvedFile = path7.resolve(absFile);
|
|
57771
|
+
const rel = path7.relative(resolvedRoot, resolvedFile);
|
|
57772
|
+
return !!rel && !rel.startsWith("..") && !path7.isAbsolute(rel);
|
|
57773
|
+
}
|
|
57774
|
+
function hasAllowedExtension(filePath) {
|
|
57775
|
+
return ALLOWED_SOURCE_EXTENSIONS.has(path7.extname(filePath).toLowerCase());
|
|
57776
|
+
}
|
|
57552
57777
|
function parseDebugStack(stack) {
|
|
57553
57778
|
const lines = stack.split("\n").filter((l) => l.trim().startsWith("at "));
|
|
57554
57779
|
return lines.map((line) => {
|
|
@@ -57608,8 +57833,12 @@ function createSourceResolver(port, projectRoot) {
|
|
|
57608
57833
|
symbolicate: symbolicateFrame,
|
|
57609
57834
|
async readSourceFragment(location, contextLines = 3) {
|
|
57610
57835
|
try {
|
|
57611
|
-
const absPath =
|
|
57612
|
-
const
|
|
57836
|
+
const absPath = path7.isAbsolute(location.file) ? path7.resolve(location.file) : path7.resolve(projectRoot, location.file);
|
|
57837
|
+
const realRoot = await fs7.realpath(projectRoot);
|
|
57838
|
+
const realPath = await fs7.realpath(absPath);
|
|
57839
|
+
if (!isInsideProject(realPath, realRoot)) return null;
|
|
57840
|
+
if (!hasAllowedExtension(realPath)) return null;
|
|
57841
|
+
const content = await fs7.readFile(realPath, "utf-8");
|
|
57613
57842
|
const lines = content.split("\n");
|
|
57614
57843
|
const start2 = Math.max(0, location.line - 1 - contextLines);
|
|
57615
57844
|
const end = Math.min(lines.length, location.line + contextLines);
|
|
@@ -57627,6 +57856,46 @@ function createSourceResolver(port, projectRoot) {
|
|
|
57627
57856
|
|
|
57628
57857
|
// ../tool-server/src/utils/debugger/source-maps.ts
|
|
57629
57858
|
var import_source_map_js = __toESM(require_source_map());
|
|
57859
|
+
var ALLOWED_SOURCE_MAP_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
|
|
57860
|
+
function isAllowedSourceMapURL(raw) {
|
|
57861
|
+
let parsed;
|
|
57862
|
+
try {
|
|
57863
|
+
parsed = new URL(raw);
|
|
57864
|
+
} catch {
|
|
57865
|
+
return false;
|
|
57866
|
+
}
|
|
57867
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
|
|
57868
|
+
if (!parsed.pathname.endsWith(".map")) return false;
|
|
57869
|
+
const hostname3 = parsed.hostname.startsWith("[") && parsed.hostname.endsWith("]") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
57870
|
+
return ALLOWED_SOURCE_MAP_HOSTS.has(hostname3);
|
|
57871
|
+
}
|
|
57872
|
+
var MAX_SOURCE_MAP_BYTES = 64 * 1024 * 1024;
|
|
57873
|
+
async function readCappedJson(res, maxBytes = MAX_SOURCE_MAP_BYTES) {
|
|
57874
|
+
const declared = Number(res.headers.get("content-length"));
|
|
57875
|
+
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
57876
|
+
throw new Error(`source map body too large (content-length ${declared} > ${maxBytes})`);
|
|
57877
|
+
}
|
|
57878
|
+
const body = res.body;
|
|
57879
|
+
if (!body || typeof body.getReader !== "function") {
|
|
57880
|
+
return res.json();
|
|
57881
|
+
}
|
|
57882
|
+
const reader = body.getReader();
|
|
57883
|
+
const chunks = [];
|
|
57884
|
+
let total = 0;
|
|
57885
|
+
for (; ; ) {
|
|
57886
|
+
const { done, value } = await reader.read();
|
|
57887
|
+
if (done) break;
|
|
57888
|
+
if (value) {
|
|
57889
|
+
total += value.byteLength;
|
|
57890
|
+
if (total > maxBytes) {
|
|
57891
|
+
await reader.cancel();
|
|
57892
|
+
throw new Error(`source map body exceeded ${maxBytes} bytes`);
|
|
57893
|
+
}
|
|
57894
|
+
chunks.push(value);
|
|
57895
|
+
}
|
|
57896
|
+
}
|
|
57897
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf-8"));
|
|
57898
|
+
}
|
|
57630
57899
|
var SourceMapsRegistry = class {
|
|
57631
57900
|
maps = [];
|
|
57632
57901
|
pendingRegistrations = [];
|
|
@@ -57723,9 +57992,10 @@ var SourceMapsRegistry = class {
|
|
|
57723
57992
|
const decoded = Buffer.from(base64Part, "base64").toString("utf-8");
|
|
57724
57993
|
rawData = JSON.parse(decoded);
|
|
57725
57994
|
} else {
|
|
57726
|
-
|
|
57995
|
+
if (!isAllowedSourceMapURL(sourceMapURL)) return;
|
|
57996
|
+
const res = await fetch(sourceMapURL, { redirect: "error" });
|
|
57727
57997
|
if (!res.ok) return;
|
|
57728
|
-
rawData = await res
|
|
57998
|
+
rawData = await readCappedJson(res);
|
|
57729
57999
|
}
|
|
57730
58000
|
const consumer = new import_source_map_js.SourceMapConsumer(rawData);
|
|
57731
58001
|
const consumerSources = consumer.sources;
|
|
@@ -57794,8 +58064,8 @@ var DISABLE_LOGBOX_SCRIPT = `(function() {
|
|
|
57794
58064
|
})()`;
|
|
57795
58065
|
|
|
57796
58066
|
// ../tool-server/src/utils/debugger/log-file-writer.ts
|
|
57797
|
-
var
|
|
57798
|
-
var
|
|
58067
|
+
var fs8 = __toESM(require("node:fs"));
|
|
58068
|
+
var path8 = __toESM(require("node:path"));
|
|
57799
58069
|
var os3 = __toESM(require("node:os"));
|
|
57800
58070
|
var MAX_ENTRIES = 5e4;
|
|
57801
58071
|
var CLUSTER_KEY_LENGTH = 80;
|
|
@@ -57820,14 +58090,14 @@ var LogFileWriter = class {
|
|
|
57820
58090
|
closed = false;
|
|
57821
58091
|
constructor(port) {
|
|
57822
58092
|
const timestamp = Date.now();
|
|
57823
|
-
const dir =
|
|
57824
|
-
|
|
57825
|
-
this.filePath =
|
|
58093
|
+
const dir = path8.join(os3.homedir(), ".argent", "tmp");
|
|
58094
|
+
fs8.mkdirSync(dir, { recursive: true });
|
|
58095
|
+
this.filePath = path8.join(dir, `argent-logs-${port}-${timestamp}.log`);
|
|
57826
58096
|
this.open();
|
|
57827
58097
|
}
|
|
57828
58098
|
open() {
|
|
57829
58099
|
try {
|
|
57830
|
-
this.fd =
|
|
58100
|
+
this.fd = fs8.openSync(this.filePath, "w");
|
|
57831
58101
|
this.ready = true;
|
|
57832
58102
|
this.flushBuffer();
|
|
57833
58103
|
} catch {
|
|
@@ -57837,7 +58107,7 @@ var LogFileWriter = class {
|
|
|
57837
58107
|
if (!this.ready || this.fd === null) return;
|
|
57838
58108
|
for (const line of this.writeBuffer) {
|
|
57839
58109
|
const buf = Buffer.from(line);
|
|
57840
|
-
|
|
58110
|
+
fs8.writeSync(this.fd, buf);
|
|
57841
58111
|
}
|
|
57842
58112
|
this.writeBuffer = [];
|
|
57843
58113
|
}
|
|
@@ -57860,7 +58130,7 @@ var LogFileWriter = class {
|
|
|
57860
58130
|
`;
|
|
57861
58131
|
if (this.ready && this.fd !== null) {
|
|
57862
58132
|
const buf = Buffer.from(line);
|
|
57863
|
-
|
|
58133
|
+
fs8.writeSync(this.fd, buf);
|
|
57864
58134
|
} else {
|
|
57865
58135
|
this.writeBuffer.push(line);
|
|
57866
58136
|
}
|
|
@@ -57912,7 +58182,7 @@ var LogFileWriter = class {
|
|
|
57912
58182
|
if (this.closed || !this.ready) return [];
|
|
57913
58183
|
this.flushBuffer();
|
|
57914
58184
|
try {
|
|
57915
|
-
const content =
|
|
58185
|
+
const content = fs8.readFileSync(this.filePath, "utf-8");
|
|
57916
58186
|
return content.split("\n").filter((line) => line.length > 0).map(parseFlatLine).filter((entry) => entry !== null);
|
|
57917
58187
|
} catch {
|
|
57918
58188
|
return [];
|
|
@@ -57932,13 +58202,13 @@ var LogFileWriter = class {
|
|
|
57932
58202
|
this.closed = true;
|
|
57933
58203
|
if (this.fd !== null) {
|
|
57934
58204
|
try {
|
|
57935
|
-
|
|
58205
|
+
fs8.closeSync(this.fd);
|
|
57936
58206
|
} catch {
|
|
57937
58207
|
}
|
|
57938
58208
|
this.fd = null;
|
|
57939
58209
|
}
|
|
57940
58210
|
try {
|
|
57941
|
-
|
|
58211
|
+
fs8.unlinkSync(this.filePath);
|
|
57942
58212
|
} catch {
|
|
57943
58213
|
}
|
|
57944
58214
|
}
|
|
@@ -57979,7 +58249,7 @@ function formatConsoleArgs(params) {
|
|
|
57979
58249
|
}).join(" ");
|
|
57980
58250
|
}
|
|
57981
58251
|
function createConsoleLogServer(consoleEvents, logWriter) {
|
|
57982
|
-
return new Promise((
|
|
58252
|
+
return new Promise((resolve3, reject) => {
|
|
57983
58253
|
const server = http.createServer();
|
|
57984
58254
|
const wss = new import_websocket_server.default({ server });
|
|
57985
58255
|
wss.on("connection", (ws) => {
|
|
@@ -58001,7 +58271,7 @@ function createConsoleLogServer(consoleEvents, logWriter) {
|
|
|
58001
58271
|
return;
|
|
58002
58272
|
}
|
|
58003
58273
|
const url2 = `ws://127.0.0.1:${addr.port}`;
|
|
58004
|
-
|
|
58274
|
+
resolve3({
|
|
58005
58275
|
url: url2,
|
|
58006
58276
|
close: () => new Promise((res) => {
|
|
58007
58277
|
wss.clients.forEach((c) => c.close());
|
|
@@ -58985,6 +59255,72 @@ function clearCachedProfilerPaths(port, deviceId) {
|
|
|
58985
59255
|
// ../tool-server/src/tools/devices/boot-device.ts
|
|
58986
59256
|
var import_node_child_process9 = require("node:child_process");
|
|
58987
59257
|
var import_node_util7 = require("node:util");
|
|
59258
|
+
|
|
59259
|
+
// ../tool-server/src/utils/linux-preflight.ts
|
|
59260
|
+
var fs9 = __toESM(require("node:fs"));
|
|
59261
|
+
var import_node_os3 = require("node:os");
|
|
59262
|
+
var import_node_path4 = require("node:path");
|
|
59263
|
+
function linuxBootDiagnostics(avdName) {
|
|
59264
|
+
if (process.platform !== "linux") return null;
|
|
59265
|
+
const diags = [];
|
|
59266
|
+
const kvm = checkKvm();
|
|
59267
|
+
if (kvm) diags.push(kvm);
|
|
59268
|
+
if (avdName) {
|
|
59269
|
+
const sizing = checkAvdSizing(avdName);
|
|
59270
|
+
if (sizing) diags.push(sizing);
|
|
59271
|
+
}
|
|
59272
|
+
return diags;
|
|
59273
|
+
}
|
|
59274
|
+
function checkKvm() {
|
|
59275
|
+
try {
|
|
59276
|
+
fs9.accessSync("/dev/kvm", fs9.constants.R_OK | fs9.constants.W_OK);
|
|
59277
|
+
return null;
|
|
59278
|
+
} catch (err) {
|
|
59279
|
+
const code = err.code;
|
|
59280
|
+
if (code === "ENOENT") {
|
|
59281
|
+
return "/dev/kvm is missing \u2014 KVM module is not loaded or virtualization is disabled in BIOS/UEFI. The emulator will fall back to TCG software emulation (10\u201350\xD7 slower). Enable VT-x/AMD-V in BIOS and load the kvm module (`modprobe kvm_intel` or `modprobe kvm_amd`).";
|
|
59282
|
+
}
|
|
59283
|
+
return `/dev/kvm exists but is not readable/writable by this user (code=${code ?? "unknown"}). KVM acceleration unavailable; emulator will fall back to TCG software emulation (10\u201350\xD7 slower). Add your user to the \`kvm\` group: \`sudo usermod -aG kvm $USER\` and re-login.`;
|
|
59284
|
+
}
|
|
59285
|
+
}
|
|
59286
|
+
var MIN_RAM_MB = 4096;
|
|
59287
|
+
var MIN_HEAP_MB = 512;
|
|
59288
|
+
function checkAvdSizing(avdName) {
|
|
59289
|
+
const configPath = (0, import_node_path4.join)((0, import_node_os3.homedir)(), ".android", "avd", `${avdName}.avd`, "config.ini");
|
|
59290
|
+
let content;
|
|
59291
|
+
try {
|
|
59292
|
+
content = fs9.readFileSync(configPath, "utf8");
|
|
59293
|
+
} catch {
|
|
59294
|
+
return null;
|
|
59295
|
+
}
|
|
59296
|
+
return diagnoseAvdSizing(avdName, content, configPath);
|
|
59297
|
+
}
|
|
59298
|
+
function diagnoseAvdSizing(avdName, configContent, configPath) {
|
|
59299
|
+
const ramMb = readMb(configContent, "hw.ramSize");
|
|
59300
|
+
const heapMb = readMb(configContent, "vm.heapSize");
|
|
59301
|
+
const issues = [];
|
|
59302
|
+
if (ramMb !== null && ramMb < MIN_RAM_MB) {
|
|
59303
|
+
issues.push(`hw.ramSize=${ramMb} MB (recommended \u2265 ${MIN_RAM_MB})`);
|
|
59304
|
+
}
|
|
59305
|
+
if (heapMb !== null && heapMb < MIN_HEAP_MB) {
|
|
59306
|
+
issues.push(`vm.heapSize=${heapMb} MB (recommended \u2265 ${MIN_HEAP_MB})`);
|
|
59307
|
+
}
|
|
59308
|
+
if (issues.length === 0) return null;
|
|
59309
|
+
return `AVD "${avdName}" is undersized: ${issues.join(", ")}. Under load (Hermes JIT, Metro bundling, swiftshader rendering) Android's Watchdog can suicide-restart system_server, leaving the device transiently unresponsive. Edit ${configPath} to raise hw.ramSize to ${MIN_RAM_MB} and vm.heapSize to ${MIN_HEAP_MB} (see README "Linux host: extra prerequisites").`;
|
|
59310
|
+
}
|
|
59311
|
+
function readMb(content, key) {
|
|
59312
|
+
const re = new RegExp(
|
|
59313
|
+
`^\\s*${key.replace(/\./g, "\\.")}\\s*=\\s*(\\d+)\\s*([MmGg][Bb]?)?\\s*$`,
|
|
59314
|
+
"m"
|
|
59315
|
+
);
|
|
59316
|
+
const m = content.match(re);
|
|
59317
|
+
if (!m) return null;
|
|
59318
|
+
const n = Number(m[1]);
|
|
59319
|
+
if (!Number.isFinite(n)) return null;
|
|
59320
|
+
return (m[2] || "M").toLowerCase().startsWith("g") ? n * 1024 : n;
|
|
59321
|
+
}
|
|
59322
|
+
|
|
59323
|
+
// ../tool-server/src/tools/devices/boot-device.ts
|
|
58988
59324
|
var execFileAsync7 = (0, import_node_util7.promisify)(import_node_child_process9.execFile);
|
|
58989
59325
|
var zodSchema9 = external_exports.object({
|
|
58990
59326
|
udid: external_exports.string().optional().describe(
|
|
@@ -59011,9 +59347,48 @@ var STAGE_BUDGET = {
|
|
|
59011
59347
|
// adb devices sees the serial for this AVD
|
|
59012
59348
|
deviceReady: 18e4,
|
|
59013
59349
|
// adb -s wait-for-device returns (state === "device")
|
|
59014
|
-
bootCompleted: 3e5
|
|
59350
|
+
bootCompleted: 3e5,
|
|
59015
59351
|
// sys.boot_completed = 1
|
|
59352
|
+
pmReady: 45e3,
|
|
59353
|
+
// pm path android answers (retried; non-fatal on the final attempt)
|
|
59354
|
+
firstRealFrame: 9e4,
|
|
59355
|
+
// screencap returns ≥1 non-zero pixel after cold boot
|
|
59356
|
+
firstRealFrameHot: 8e3
|
|
59357
|
+
// tighter budget for snapshot-restore composite —
|
|
59358
|
+
// the broken state is sticky (per assertScreencapAlive's docstring), so a
|
|
59359
|
+
// few seconds is enough to discriminate transient blanks from genuine wedge.
|
|
59016
59360
|
};
|
|
59361
|
+
var VALID_GPU_MODES = /* @__PURE__ */ new Set([
|
|
59362
|
+
"auto",
|
|
59363
|
+
"host",
|
|
59364
|
+
"guest",
|
|
59365
|
+
"off",
|
|
59366
|
+
"swiftshader",
|
|
59367
|
+
"swiftshader_indirect",
|
|
59368
|
+
"angle",
|
|
59369
|
+
"angle_indirect",
|
|
59370
|
+
"angle9",
|
|
59371
|
+
"angle9_indirect",
|
|
59372
|
+
"swangle",
|
|
59373
|
+
"swangle_indirect"
|
|
59374
|
+
]);
|
|
59375
|
+
function selectGpuMode() {
|
|
59376
|
+
const override = process.env.ARGENT_EMULATOR_GPU_MODE;
|
|
59377
|
+
if (override && override.trim()) {
|
|
59378
|
+
const value = override.trim();
|
|
59379
|
+
if (!VALID_GPU_MODES.has(value)) {
|
|
59380
|
+
throw new Error(
|
|
59381
|
+
`ARGENT_EMULATOR_GPU_MODE=${JSON.stringify(value)} is not a known emulator -gpu value. Valid values: ${[...VALID_GPU_MODES].join(", ")}.`
|
|
59382
|
+
);
|
|
59383
|
+
}
|
|
59384
|
+
return value;
|
|
59385
|
+
}
|
|
59386
|
+
return process.platform === "linux" ? "swiftshader" : "auto";
|
|
59387
|
+
}
|
|
59388
|
+
function selectExtraEmulatorArgs() {
|
|
59389
|
+
const trimmed = (process.env.ARGENT_EMULATOR_NO_WINDOW ?? "").trim().toLowerCase();
|
|
59390
|
+
return ["1", "true", "yes"].includes(trimmed) ? ["-no-window"] : [];
|
|
59391
|
+
}
|
|
59017
59392
|
var BOOT_POLL_INTERVALS_MS = {
|
|
59018
59393
|
serialByAvd: 1500,
|
|
59019
59394
|
// findSerialByAvdName: re-scan when >1 new emulator appeared
|
|
@@ -59022,6 +59397,7 @@ var BOOT_POLL_INTERVALS_MS = {
|
|
|
59022
59397
|
earlyExit: 500
|
|
59023
59398
|
// createEarlyExitRacer: re-check the crash latch during a blocking adb call
|
|
59024
59399
|
};
|
|
59400
|
+
var FRAME_PROBE = "screencap -p 2>/dev/null | wc -c | awk '$1>20000{print 1;exit} {print 0}'";
|
|
59025
59401
|
async function killEmulatorQuietly(serial, child) {
|
|
59026
59402
|
if (serial) {
|
|
59027
59403
|
await runAdb(["-s", serial, "emu", "kill"], { timeoutMs: 15e3 }).catch(() => {
|
|
@@ -59041,16 +59417,43 @@ function killDetachedEmulator(child) {
|
|
|
59041
59417
|
} catch {
|
|
59042
59418
|
}
|
|
59043
59419
|
}
|
|
59044
|
-
async function assertScreencapAlive(serial) {
|
|
59045
|
-
const
|
|
59046
|
-
|
|
59420
|
+
async function assertScreencapAlive(serial, budgetMs = STAGE_BUDGET.firstRealFrameHot) {
|
|
59421
|
+
const deadline = Date.now() + budgetMs;
|
|
59422
|
+
let lastReading = null;
|
|
59423
|
+
while (Date.now() < deadline) {
|
|
59424
|
+
try {
|
|
59425
|
+
const out = await adbShell(serial, FRAME_PROBE, { timeoutMs: 1e4 });
|
|
59426
|
+
lastReading = out.trim();
|
|
59427
|
+
if (lastReading === "1") return;
|
|
59428
|
+
} catch (err) {
|
|
59429
|
+
lastReading = err instanceof Error ? err.message : String(err);
|
|
59430
|
+
}
|
|
59431
|
+
if (Date.now() >= deadline) break;
|
|
59432
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
59433
|
+
}
|
|
59434
|
+
await killEmulatorQuietly(serial);
|
|
59435
|
+
throw new Error(
|
|
59436
|
+
`hot-boot composite did not restore within ${budgetMs / 1e3}s \u2014 \`screencap\` last returned ${JSON.stringify(lastReading ?? "no probe response")}. Falling back to cold boot so screenshots are usable.`
|
|
59437
|
+
);
|
|
59438
|
+
}
|
|
59439
|
+
async function awaitFirstRealFrame(serial, timeoutMs) {
|
|
59440
|
+
await adbShell(serial, "input keyevent 224", { timeoutMs: 5e3 }).catch(() => {
|
|
59047
59441
|
});
|
|
59048
|
-
|
|
59049
|
-
|
|
59050
|
-
|
|
59051
|
-
|
|
59052
|
-
|
|
59442
|
+
const deadline = Date.now() + timeoutMs;
|
|
59443
|
+
let lastError = null;
|
|
59444
|
+
while (Date.now() < deadline) {
|
|
59445
|
+
try {
|
|
59446
|
+
const out = await adbShell(serial, FRAME_PROBE, { timeoutMs: 1e4 });
|
|
59447
|
+
if (out.trim() === "1") return;
|
|
59448
|
+
lastError = `screencap reading was "${out.trim()}"`;
|
|
59449
|
+
} catch (err) {
|
|
59450
|
+
lastError = err instanceof Error ? err.message : String(err);
|
|
59451
|
+
}
|
|
59452
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
59053
59453
|
}
|
|
59454
|
+
throw new Error(
|
|
59455
|
+
`SurfaceFlinger did not composite a real frame within ${timeoutMs / 1e3}s of boot_completed (${lastError ?? "no probe response"}). The emulator booted but every screenshot would be all-black.`
|
|
59456
|
+
);
|
|
59054
59457
|
}
|
|
59055
59458
|
async function findSerialByAvdName(avdName, deadline) {
|
|
59056
59459
|
while (Date.now() < deadline) {
|
|
@@ -59075,6 +59478,11 @@ async function listNewEmulatorSerials(before) {
|
|
|
59075
59478
|
return now.filter((s) => !before.has(s));
|
|
59076
59479
|
}
|
|
59077
59480
|
async function bootIos(udid, registry2, force) {
|
|
59481
|
+
if (process.platform !== "darwin") {
|
|
59482
|
+
throw new Error(
|
|
59483
|
+
`iOS Simulator is unavailable on ${process.platform}: it requires a macOS host. Pass \`avdName\` (Android) instead of \`udid\` (iOS) to boot a device from this host.`
|
|
59484
|
+
);
|
|
59485
|
+
}
|
|
59078
59486
|
await ensureDep("xcrun");
|
|
59079
59487
|
const simState = await listIosSimulators().then((sims) => sims.find((s) => s.udid === udid)?.state).catch(() => void 0);
|
|
59080
59488
|
if (force && simState === "Booted") {
|
|
@@ -59198,22 +59606,47 @@ async function attemptBoot(params) {
|
|
|
59198
59606
|
await killEmulatorQuietly(serial, child);
|
|
59199
59607
|
throw err instanceof Error ? err : new Error(String(err));
|
|
59200
59608
|
}
|
|
59201
|
-
const
|
|
59202
|
-
|
|
59203
|
-
|
|
59204
|
-
|
|
59205
|
-
|
|
59206
|
-
|
|
59207
|
-
|
|
59208
|
-
|
|
59209
|
-
|
|
59210
|
-
|
|
59609
|
+
const pmBudgetMs = Math.max(1e4, params.pmProbeBudgetMs);
|
|
59610
|
+
const pmDeadline = Math.min(params.attemptDeadline, Date.now() + pmBudgetMs);
|
|
59611
|
+
let pmReady = false;
|
|
59612
|
+
let pmCrash = null;
|
|
59613
|
+
while (Date.now() < pmDeadline && !earlyExitError) {
|
|
59614
|
+
const stage5Racer = createEarlyExitRacer(() => earlyExitError);
|
|
59615
|
+
try {
|
|
59616
|
+
await Promise.race([
|
|
59617
|
+
adbShell(serial, "pm path android", {
|
|
59618
|
+
timeoutMs: Math.max(2e3, Math.min(1e4, pmDeadline - Date.now()))
|
|
59619
|
+
}),
|
|
59620
|
+
stage5Racer.promise
|
|
59621
|
+
]);
|
|
59622
|
+
pmReady = true;
|
|
59623
|
+
break;
|
|
59624
|
+
} catch (err) {
|
|
59625
|
+
if (err instanceof Error && /^emulator binary (exited|terminated)/.test(err.message)) {
|
|
59626
|
+
pmCrash = err;
|
|
59627
|
+
break;
|
|
59628
|
+
}
|
|
59629
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
59630
|
+
} finally {
|
|
59631
|
+
stage5Racer.cancel();
|
|
59211
59632
|
}
|
|
59212
|
-
|
|
59213
|
-
|
|
59633
|
+
}
|
|
59634
|
+
if (!pmReady) {
|
|
59635
|
+
const crash = pmCrash ?? earlyExitError;
|
|
59636
|
+
if (crash) {
|
|
59637
|
+
await killEmulatorQuietly(serial, child);
|
|
59638
|
+
throw crash;
|
|
59639
|
+
}
|
|
59640
|
+
if (params.tearDownIfUnready) {
|
|
59641
|
+
await killEmulatorQuietly(serial, child);
|
|
59642
|
+
throw new Error(
|
|
59643
|
+
`PackageManager did not respond on ${serial} within ${Math.round(pmBudgetMs / 1e3)}s after boot_completed. Emulator has been terminated.`
|
|
59644
|
+
);
|
|
59645
|
+
}
|
|
59646
|
+
process.stderr.write(
|
|
59647
|
+
`[boot-device] ${serial} reached boot_completed and registered with adb, but PackageManager stayed slow for ${Math.round(pmBudgetMs / 1e3)}s; returning it as booted rather than tearing it down. Give it a few seconds to settle if taps or screenshots misbehave.
|
|
59648
|
+
`
|
|
59214
59649
|
);
|
|
59215
|
-
} finally {
|
|
59216
|
-
stage5Racer.cancel();
|
|
59217
59650
|
}
|
|
59218
59651
|
return { serial };
|
|
59219
59652
|
}
|
|
@@ -59230,6 +59663,11 @@ async function bootAndroid(params) {
|
|
|
59230
59663
|
async function bootAndroidImpl(params) {
|
|
59231
59664
|
await ensureDep("adb");
|
|
59232
59665
|
await ensureDep("emulator");
|
|
59666
|
+
const gpuMode = selectGpuMode();
|
|
59667
|
+
const extraEmulatorArgs = selectExtraEmulatorArgs();
|
|
59668
|
+
for (const msg of linuxBootDiagnostics(params.avdName) ?? []) {
|
|
59669
|
+
console.warn(`[boot-device:linux] ${msg}`);
|
|
59670
|
+
}
|
|
59233
59671
|
const emulatorBinary = await resolveEmulatorOrThrow();
|
|
59234
59672
|
const overallDeadline = Date.now() + params.bootTimeoutMs;
|
|
59235
59673
|
const avds = await listAvds();
|
|
@@ -59279,11 +59717,12 @@ async function bootAndroidImpl(params) {
|
|
|
59279
59717
|
}
|
|
59280
59718
|
}
|
|
59281
59719
|
const serialsBefore = new Set(existingDevices.map((d) => d.serial));
|
|
59720
|
+
const crashReportArgs = await emulatorSupportsFlag("-crash-report-mode") ? ["-crash-report-mode", "never"] : [];
|
|
59282
59721
|
const hasSnapshot = await hasDefaultBootSnapshot(params.avdName);
|
|
59283
59722
|
if (!hasSnapshot) {
|
|
59284
59723
|
hotBootFailureReason = "no default_boot snapshot exists";
|
|
59285
59724
|
} else {
|
|
59286
|
-
const RENDERER_ARGS = ["-gpu",
|
|
59725
|
+
const RENDERER_ARGS = ["-gpu", gpuMode, ...extraEmulatorArgs];
|
|
59287
59726
|
const probe3 = await checkSnapshotLoadable(params.avdName, "default_boot", {
|
|
59288
59727
|
extraArgs: [...RENDERER_ARGS, ...LAUNCH_HARDENING_ARGS]
|
|
59289
59728
|
});
|
|
@@ -59296,7 +59735,8 @@ async function bootAndroidImpl(params) {
|
|
|
59296
59735
|
"-force-snapshot-load",
|
|
59297
59736
|
"-no-snapshot-save",
|
|
59298
59737
|
...RENDERER_ARGS,
|
|
59299
|
-
...LAUNCH_HARDENING_ARGS
|
|
59738
|
+
...LAUNCH_HARDENING_ARGS,
|
|
59739
|
+
...crashReportArgs
|
|
59300
59740
|
];
|
|
59301
59741
|
const hotAttemptDeadline = Math.min(overallDeadline, Date.now() + HOT_BOOT_BUDGET_MS);
|
|
59302
59742
|
try {
|
|
@@ -59311,7 +59751,11 @@ async function bootAndroidImpl(params) {
|
|
|
59311
59751
|
// scenario where load fails and the child silently cold-boots.
|
|
59312
59752
|
adbRegisterBudgetMs: 3e4,
|
|
59313
59753
|
deviceReadyBudgetMs: 3e4,
|
|
59314
|
-
bootCompletedBudgetMs: 3e4
|
|
59754
|
+
bootCompletedBudgetMs: 3e4,
|
|
59755
|
+
// Keep the hot path tight: a single ~10 s PM window, and tear down on
|
|
59756
|
+
// failure so we fall through to the cold boot below.
|
|
59757
|
+
pmProbeBudgetMs: 1e4,
|
|
59758
|
+
tearDownIfUnready: true
|
|
59315
59759
|
});
|
|
59316
59760
|
await assertScreencapAlive(result.serial);
|
|
59317
59761
|
return {
|
|
@@ -59334,8 +59778,10 @@ async function bootAndroidImpl(params) {
|
|
|
59334
59778
|
params.avdName,
|
|
59335
59779
|
"-no-snapshot-load",
|
|
59336
59780
|
"-gpu",
|
|
59337
|
-
|
|
59338
|
-
...
|
|
59781
|
+
gpuMode,
|
|
59782
|
+
...extraEmulatorArgs,
|
|
59783
|
+
...LAUNCH_HARDENING_ARGS,
|
|
59784
|
+
...crashReportArgs
|
|
59339
59785
|
];
|
|
59340
59786
|
let coldResult;
|
|
59341
59787
|
try {
|
|
@@ -59347,7 +59793,12 @@ async function bootAndroidImpl(params) {
|
|
|
59347
59793
|
serialsBefore,
|
|
59348
59794
|
adbRegisterBudgetMs: STAGE_BUDGET.adbRegister,
|
|
59349
59795
|
deviceReadyBudgetMs: STAGE_BUDGET.deviceReady,
|
|
59350
|
-
bootCompletedBudgetMs: STAGE_BUDGET.bootCompleted
|
|
59796
|
+
bootCompletedBudgetMs: STAGE_BUDGET.bootCompleted,
|
|
59797
|
+
// Final attempt: retry PM for longer, and do NOT tear the emulator down
|
|
59798
|
+
// if it stays slow — a guest that reached boot_completed is usable, and
|
|
59799
|
+
// there is no further fallback to justify destroying it.
|
|
59800
|
+
pmProbeBudgetMs: STAGE_BUDGET.pmReady,
|
|
59801
|
+
tearDownIfUnready: false
|
|
59351
59802
|
});
|
|
59352
59803
|
} catch (err) {
|
|
59353
59804
|
const base = err instanceof Error ? err.message : String(err);
|
|
@@ -59356,6 +59807,16 @@ async function bootAndroidImpl(params) {
|
|
|
59356
59807
|
`${base} Emulator has been terminated so the next boot starts clean. If this keeps happening, wipe the AVD with \`emulator -avd ${params.avdName} -wipe-data\`.${suffix}`
|
|
59357
59808
|
);
|
|
59358
59809
|
}
|
|
59810
|
+
const frameWaitBudget = Math.min(
|
|
59811
|
+
STAGE_BUDGET.firstRealFrame,
|
|
59812
|
+
Math.max(0, overallDeadline - Date.now())
|
|
59813
|
+
);
|
|
59814
|
+
try {
|
|
59815
|
+
await awaitFirstRealFrame(coldResult.serial, frameWaitBudget);
|
|
59816
|
+
} catch (err) {
|
|
59817
|
+
await killEmulatorQuietly(coldResult.serial);
|
|
59818
|
+
throw err;
|
|
59819
|
+
}
|
|
59359
59820
|
return {
|
|
59360
59821
|
platform: "android",
|
|
59361
59822
|
serial: coldResult.serial,
|
|
@@ -59468,7 +59929,7 @@ function assertAmStartOk(out) {
|
|
|
59468
59929
|
}
|
|
59469
59930
|
}
|
|
59470
59931
|
async function resolveLauncherActivity(udid, bundleId) {
|
|
59471
|
-
const raw = await adbShell(udid, `cmd package resolve-activity --brief ${bundleId}`, {
|
|
59932
|
+
const raw = await adbShell(udid, `cmd package resolve-activity --brief ${shellQuote(bundleId)}`, {
|
|
59472
59933
|
timeoutMs: 1e4
|
|
59473
59934
|
});
|
|
59474
59935
|
const last = raw.split("\n").map((l) => l.trim()).filter(Boolean).pop();
|
|
@@ -59497,7 +59958,7 @@ var androidImpl = {
|
|
|
59497
59958
|
} else {
|
|
59498
59959
|
component = await resolveLauncherActivity(params.udid, params.bundleId);
|
|
59499
59960
|
}
|
|
59500
|
-
const out = await adbShell(params.udid, `am start -W -n ${component}`, {
|
|
59961
|
+
const out = await adbShell(params.udid, `am start -W -n ${shellQuote(component)}`, {
|
|
59501
59962
|
timeoutMs: 3e4
|
|
59502
59963
|
});
|
|
59503
59964
|
assertAmStartOk(out);
|
|
@@ -59571,14 +60032,16 @@ var androidImpl2 = {
|
|
|
59571
60032
|
requires: ["adb"],
|
|
59572
60033
|
handler: async (_services, params) => {
|
|
59573
60034
|
const { udid, bundleId, activity } = params;
|
|
59574
|
-
await adbShell(udid, `am force-stop ${bundleId}`, { timeoutMs: 15e3 });
|
|
60035
|
+
await adbShell(udid, `am force-stop ${shellQuote(bundleId)}`, { timeoutMs: 15e3 });
|
|
59575
60036
|
let component;
|
|
59576
60037
|
if (activity) {
|
|
59577
60038
|
component = activity.startsWith(".") ? `${bundleId}/${activity}` : activity.includes("/") ? activity : `${bundleId}/${activity}`;
|
|
59578
60039
|
} else {
|
|
59579
60040
|
component = await resolveLauncherActivity(udid, bundleId);
|
|
59580
60041
|
}
|
|
59581
|
-
const out = await adbShell(udid, `am start -W -n ${component}`, {
|
|
60042
|
+
const out = await adbShell(udid, `am start -W -n ${shellQuote(component)}`, {
|
|
60043
|
+
timeoutMs: 3e4
|
|
60044
|
+
});
|
|
59582
60045
|
try {
|
|
59583
60046
|
assertAmStartOk(out);
|
|
59584
60047
|
} catch (err) {
|
|
@@ -59627,13 +60090,13 @@ Returns { restarted, bundleId }. Fails if the app is not installed.`,
|
|
|
59627
60090
|
// ../tool-server/src/tools/reinstall-app/platforms/ios.ts
|
|
59628
60091
|
var import_node_child_process12 = require("node:child_process");
|
|
59629
60092
|
var import_node_util10 = require("node:util");
|
|
59630
|
-
var
|
|
60093
|
+
var import_node_path5 = require("node:path");
|
|
59631
60094
|
var execFileAsync10 = (0, import_node_util10.promisify)(import_node_child_process12.execFile);
|
|
59632
60095
|
var iosImpl3 = {
|
|
59633
60096
|
requires: ["xcrun"],
|
|
59634
60097
|
handler: async (_services, params) => {
|
|
59635
60098
|
const { udid, bundleId, appPath } = params;
|
|
59636
|
-
const absolute = (0,
|
|
60099
|
+
const absolute = (0, import_node_path5.resolve)(appPath);
|
|
59637
60100
|
try {
|
|
59638
60101
|
await execFileAsync10("xcrun", ["simctl", "uninstall", udid, bundleId]);
|
|
59639
60102
|
} catch {
|
|
@@ -59644,12 +60107,12 @@ var iosImpl3 = {
|
|
|
59644
60107
|
};
|
|
59645
60108
|
|
|
59646
60109
|
// ../tool-server/src/tools/reinstall-app/platforms/android.ts
|
|
59647
|
-
var
|
|
60110
|
+
var import_node_path6 = require("node:path");
|
|
59648
60111
|
var androidImpl3 = {
|
|
59649
60112
|
requires: ["adb"],
|
|
59650
60113
|
handler: async (_services, params) => {
|
|
59651
60114
|
const { udid, bundleId, appPath } = params;
|
|
59652
|
-
const absolute = (0,
|
|
60115
|
+
const absolute = (0, import_node_path6.resolve)(appPath);
|
|
59653
60116
|
try {
|
|
59654
60117
|
await runAdb(["-s", udid, "uninstall", bundleId], { timeoutMs: 3e4 });
|
|
59655
60118
|
} catch {
|
|
@@ -60633,7 +61096,7 @@ Use when you want to apply code changes or reset JS state. Returns { reloaded, p
|
|
|
60633
61096
|
async execute(services, params) {
|
|
60634
61097
|
const api = services.debugger;
|
|
60635
61098
|
const port = api.port;
|
|
60636
|
-
const disableLogBox = () => new Promise((
|
|
61099
|
+
const disableLogBox = () => new Promise((resolve3) => setTimeout(resolve3, 2e3)).then(
|
|
60637
61100
|
() => api.cdp.evaluate(DISABLE_LOGBOX_SCRIPT).catch(() => {
|
|
60638
61101
|
})
|
|
60639
61102
|
);
|
|
@@ -63092,30 +63555,30 @@ var jsonReplacer = (_key, value) => {
|
|
|
63092
63555
|
};
|
|
63093
63556
|
async function writeDump(dir, filename, data) {
|
|
63094
63557
|
try {
|
|
63095
|
-
const
|
|
63558
|
+
const path16 = (0, import_path.join)(dir, filename);
|
|
63096
63559
|
const json2 = JSON.stringify(data, jsonReplacer, 2);
|
|
63097
|
-
await import_fs.promises.writeFile(
|
|
63098
|
-
return
|
|
63560
|
+
await import_fs.promises.writeFile(path16, json2, "utf8");
|
|
63561
|
+
return path16;
|
|
63099
63562
|
} catch {
|
|
63100
63563
|
return null;
|
|
63101
63564
|
}
|
|
63102
63565
|
}
|
|
63103
63566
|
async function writeDumpCompact(dir, filename, data) {
|
|
63104
63567
|
try {
|
|
63105
|
-
const
|
|
63568
|
+
const path16 = (0, import_path.join)(dir, filename);
|
|
63106
63569
|
const json2 = JSON.stringify(data, jsonReplacer);
|
|
63107
|
-
await import_fs.promises.writeFile(
|
|
63108
|
-
return
|
|
63570
|
+
await import_fs.promises.writeFile(path16, json2, "utf8");
|
|
63571
|
+
return path16;
|
|
63109
63572
|
} catch {
|
|
63110
63573
|
return null;
|
|
63111
63574
|
}
|
|
63112
63575
|
}
|
|
63113
|
-
async function readCpuProfile(
|
|
63114
|
-
const json2 = await import_fs.promises.readFile(
|
|
63576
|
+
async function readCpuProfile(path16) {
|
|
63577
|
+
const json2 = await import_fs.promises.readFile(path16, "utf8");
|
|
63115
63578
|
return JSON.parse(json2);
|
|
63116
63579
|
}
|
|
63117
|
-
async function readCommitTree(
|
|
63118
|
-
const json2 = await import_fs.promises.readFile(
|
|
63580
|
+
async function readCommitTree(path16) {
|
|
63581
|
+
const json2 = await import_fs.promises.readFile(path16, "utf8");
|
|
63119
63582
|
return JSON.parse(json2);
|
|
63120
63583
|
}
|
|
63121
63584
|
|
|
@@ -63493,9 +63956,9 @@ var import_fs5 = require("fs");
|
|
|
63493
63956
|
// ../tool-server/src/utils/react-profiler/pipeline/session-context.ts
|
|
63494
63957
|
var import_fs2 = require("fs");
|
|
63495
63958
|
var import_path2 = require("path");
|
|
63496
|
-
async function readFileSafe(
|
|
63959
|
+
async function readFileSafe(path16) {
|
|
63497
63960
|
try {
|
|
63498
|
-
return await import_fs2.promises.readFile(
|
|
63961
|
+
return await import_fs2.promises.readFile(path16, "utf8");
|
|
63499
63962
|
} catch {
|
|
63500
63963
|
return null;
|
|
63501
63964
|
}
|
|
@@ -64812,9 +65275,9 @@ function shortenPath(file2) {
|
|
|
64812
65275
|
const parts = file2.replace(/\\/g, "/").split("/");
|
|
64813
65276
|
return parts.slice(-2).join("/");
|
|
64814
65277
|
}
|
|
64815
|
-
async function writeReport(
|
|
65278
|
+
async function writeReport(path16, content) {
|
|
64816
65279
|
try {
|
|
64817
|
-
await import_fs4.promises.writeFile(
|
|
65280
|
+
await import_fs4.promises.writeFile(path16, content, "utf8");
|
|
64818
65281
|
return true;
|
|
64819
65282
|
} catch {
|
|
64820
65283
|
return false;
|
|
@@ -65404,21 +65867,21 @@ Fails if the React DevTools hook is not present or no fiber roots have been comm
|
|
|
65404
65867
|
|
|
65405
65868
|
// ../tool-server/src/tools/profiler/native-profiler/native-profiler-start.ts
|
|
65406
65869
|
var import_child_process2 = require("child_process");
|
|
65407
|
-
var
|
|
65870
|
+
var path9 = __toESM(require("path"));
|
|
65408
65871
|
|
|
65409
65872
|
// ../tool-server/src/utils/ios-profiler/lifecycle.ts
|
|
65410
65873
|
function waitForChildExit(child, ms) {
|
|
65411
65874
|
if (child.exitCode !== null || child.signalCode !== null) {
|
|
65412
65875
|
return Promise.resolve(true);
|
|
65413
65876
|
}
|
|
65414
|
-
return new Promise((
|
|
65877
|
+
return new Promise((resolve3) => {
|
|
65415
65878
|
const onExit = () => {
|
|
65416
65879
|
clearTimeout(timer);
|
|
65417
|
-
|
|
65880
|
+
resolve3(true);
|
|
65418
65881
|
};
|
|
65419
65882
|
const timer = setTimeout(() => {
|
|
65420
65883
|
child.removeListener("exit", onExit);
|
|
65421
|
-
|
|
65884
|
+
resolve3(false);
|
|
65422
65885
|
}, ms);
|
|
65423
65886
|
child.once("exit", onExit);
|
|
65424
65887
|
});
|
|
@@ -65572,7 +66035,7 @@ function listenForDarwinNotification(name) {
|
|
|
65572
66035
|
|
|
65573
66036
|
// ../tool-server/src/utils/ios-profiler/startup.ts
|
|
65574
66037
|
function waitForXctraceReady(child, { notify, timeoutMs }) {
|
|
65575
|
-
return new Promise((
|
|
66038
|
+
return new Promise((resolve3, reject) => {
|
|
65576
66039
|
let settled = false;
|
|
65577
66040
|
let stderrBuffer = "";
|
|
65578
66041
|
const settle = (run) => {
|
|
@@ -65585,7 +66048,7 @@ function waitForXctraceReady(child, { notify, timeoutMs }) {
|
|
|
65585
66048
|
child.stdout?.on("data", (data) => {
|
|
65586
66049
|
const text = data.toString();
|
|
65587
66050
|
if (text.includes("Ctrl-C to stop") || text.includes("Starting recording")) {
|
|
65588
|
-
settle(() =>
|
|
66051
|
+
settle(() => resolve3({ stderrBuffer }));
|
|
65589
66052
|
}
|
|
65590
66053
|
});
|
|
65591
66054
|
child.stderr?.on("data", (data) => {
|
|
@@ -65617,14 +66080,14 @@ function waitForXctraceReady(child, { notify, timeoutMs }) {
|
|
|
65617
66080
|
});
|
|
65618
66081
|
}, timeoutMs);
|
|
65619
66082
|
if (notify) {
|
|
65620
|
-
notify.fired.then(() => settle(() =>
|
|
66083
|
+
notify.fired.then(() => settle(() => resolve3({ stderrBuffer }))).catch(() => {
|
|
65621
66084
|
});
|
|
65622
66085
|
}
|
|
65623
66086
|
});
|
|
65624
66087
|
}
|
|
65625
66088
|
|
|
65626
66089
|
// ../tool-server/src/tools/profiler/native-profiler/native-profiler-start.ts
|
|
65627
|
-
var DEFAULT_TEMPLATE_PATH =
|
|
66090
|
+
var DEFAULT_TEMPLATE_PATH = path9.resolve(__dirname, "Argent.tracetemplate");
|
|
65628
66091
|
var STARTUP_TIMEOUT_MS = 1e4;
|
|
65629
66092
|
var DETECT_RUNNING_APP_TIMEOUT_MS = 1e4;
|
|
65630
66093
|
var NOTIFY_REGISTER_TIMEOUT_MS = 2e3;
|
|
@@ -65642,7 +66105,7 @@ var zodSchema42 = external_exports.object({
|
|
|
65642
66105
|
function detectRunningApp(udid) {
|
|
65643
66106
|
let launchctlOutput;
|
|
65644
66107
|
try {
|
|
65645
|
-
launchctlOutput = (0, import_child_process2.
|
|
66108
|
+
launchctlOutput = (0, import_child_process2.execFileSync)("xcrun", ["simctl", "spawn", udid, "launchctl", "list"], {
|
|
65646
66109
|
encoding: "utf-8",
|
|
65647
66110
|
timeout: DETECT_RUNNING_APP_TIMEOUT_MS
|
|
65648
66111
|
});
|
|
@@ -65666,8 +66129,13 @@ function detectRunningApp(udid) {
|
|
|
65666
66129
|
}
|
|
65667
66130
|
let listAppsOutput;
|
|
65668
66131
|
try {
|
|
65669
|
-
|
|
66132
|
+
const rawPlist = (0, import_child_process2.execFileSync)("xcrun", ["simctl", "listapps", udid], {
|
|
66133
|
+
encoding: "utf-8",
|
|
66134
|
+
timeout: DETECT_RUNNING_APP_TIMEOUT_MS
|
|
66135
|
+
});
|
|
66136
|
+
listAppsOutput = (0, import_child_process2.execFileSync)("plutil", ["-convert", "json", "-o", "-", "--", "-"], {
|
|
65670
66137
|
encoding: "utf-8",
|
|
66138
|
+
input: rawPlist,
|
|
65671
66139
|
timeout: DETECT_RUNNING_APP_TIMEOUT_MS
|
|
65672
66140
|
});
|
|
65673
66141
|
} catch (err) {
|
|
@@ -65767,7 +66235,7 @@ Fails if no app is running on the device, the platform is not supported yet, or
|
|
|
65767
66235
|
const appProcess = params.app_process ?? detectRunningApp(params.device_id);
|
|
65768
66236
|
const debugDir = await getDebugDir();
|
|
65769
66237
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, (m) => m === "T" ? "-" : "").slice(0, 15);
|
|
65770
|
-
const outputFile =
|
|
66238
|
+
const outputFile = path9.join(debugDir, `native-profiler-${timestamp}.trace`);
|
|
65771
66239
|
api.recordingTimedOut = false;
|
|
65772
66240
|
api.recordingExitedUnexpectedly = false;
|
|
65773
66241
|
api.lastExitInfo = null;
|
|
@@ -65858,7 +66326,7 @@ Fails if no app is running on the device, the platform is not supported yet, or
|
|
|
65858
66326
|
};
|
|
65859
66327
|
|
|
65860
66328
|
// ../tool-server/src/utils/ios-profiler/export.ts
|
|
65861
|
-
var
|
|
66329
|
+
var path10 = __toESM(require("path"));
|
|
65862
66330
|
|
|
65863
66331
|
// ../tool-server/src/utils/ios-profiler/run-with-timeout.ts
|
|
65864
66332
|
var import_child_process3 = require("child_process");
|
|
@@ -65956,10 +66424,10 @@ function exportIosTraceData(traceFile) {
|
|
|
65956
66424
|
cpuSchemaUsed: null,
|
|
65957
66425
|
errors: {}
|
|
65958
66426
|
};
|
|
65959
|
-
const dir =
|
|
65960
|
-
const baseName =
|
|
66427
|
+
const dir = path10.dirname(traceFile);
|
|
66428
|
+
const baseName = path10.basename(traceFile, ".trace");
|
|
65961
66429
|
for (const [key, config2] of Object.entries(EXPORTS)) {
|
|
65962
|
-
const outPath =
|
|
66430
|
+
const outPath = path10.join(dir, `${baseName}${config2.suffix}`);
|
|
65963
66431
|
if (key === "cpu") {
|
|
65964
66432
|
const resolvedXpath = resolveCpuXpath(traceFile, diagnostics);
|
|
65965
66433
|
if (resolvedXpath) {
|
|
@@ -66141,8 +66609,8 @@ function extractRows(xml) {
|
|
|
66141
66609
|
}
|
|
66142
66610
|
return rows;
|
|
66143
66611
|
}
|
|
66144
|
-
function isSystemLibraryPath(
|
|
66145
|
-
return SYSTEM_LIBRARY_PATH_PREFIXES.some((prefix) =>
|
|
66612
|
+
function isSystemLibraryPath(path16) {
|
|
66613
|
+
return SYSTEM_LIBRARY_PATH_PREFIXES.some((prefix) => path16.startsWith(prefix));
|
|
66146
66614
|
}
|
|
66147
66615
|
function parseCpuXml(xml) {
|
|
66148
66616
|
const frameRegistry = /* @__PURE__ */ new Map();
|
|
@@ -66599,7 +67067,7 @@ async function runIosProfilerPipeline(files) {
|
|
|
66599
67067
|
|
|
66600
67068
|
// ../tool-server/src/utils/ios-profiler/render.ts
|
|
66601
67069
|
var import_fs8 = require("fs");
|
|
66602
|
-
var
|
|
67070
|
+
var path11 = __toESM(require("path"));
|
|
66603
67071
|
var MAX_INLINE_HOTSPOTS = 5;
|
|
66604
67072
|
var MAX_INLINE_HANGS = 3;
|
|
66605
67073
|
async function renderIosProfilerReport(input) {
|
|
@@ -66625,7 +67093,7 @@ async function renderIosProfilerReport(input) {
|
|
|
66625
67093
|
return { report, reportFile: wroteFile ? reportFile : null, bottlenecksTotal };
|
|
66626
67094
|
}
|
|
66627
67095
|
function renderAllClear2(payload, exportErrors) {
|
|
66628
|
-
const traceName = payload.metadata.traceFile ? `\`${
|
|
67096
|
+
const traceName = payload.metadata.traceFile ? `\`${path11.basename(payload.metadata.traceFile)}\`` : "unknown";
|
|
66629
67097
|
const lines = [
|
|
66630
67098
|
`# iOS Instruments Analysis`,
|
|
66631
67099
|
``,
|
|
@@ -66646,7 +67114,7 @@ function renderAllClear2(payload, exportErrors) {
|
|
|
66646
67114
|
return lines.join("\n");
|
|
66647
67115
|
}
|
|
66648
67116
|
function renderFullReport(payload, exportErrors, cap = { hotspotLimit: Infinity, hangLimit: Infinity }) {
|
|
66649
|
-
const traceName = payload.metadata.traceFile ? `\`${
|
|
67117
|
+
const traceName = payload.metadata.traceFile ? `\`${path11.basename(payload.metadata.traceFile)}\`` : "unknown";
|
|
66650
67118
|
const cpuHotspots = payload.bottlenecks.filter(
|
|
66651
67119
|
(b) => b.type === "ios_cpu_hotspot"
|
|
66652
67120
|
);
|
|
@@ -66860,9 +67328,9 @@ function formatBytes2(sizeBytes) {
|
|
|
66860
67328
|
return `${(sizeBytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
66861
67329
|
}
|
|
66862
67330
|
function deriveReportPath(traceFile) {
|
|
66863
|
-
const dir =
|
|
66864
|
-
const baseName =
|
|
66865
|
-
return
|
|
67331
|
+
const dir = path11.dirname(traceFile);
|
|
67332
|
+
const baseName = path11.basename(traceFile, ".trace");
|
|
67333
|
+
return path11.join(dir, `${baseName}-report.md`);
|
|
66866
67334
|
}
|
|
66867
67335
|
async function writeReport2(filePath, content) {
|
|
66868
67336
|
try {
|
|
@@ -68021,12 +68489,20 @@ function formatBytes4(bytes) {
|
|
|
68021
68489
|
|
|
68022
68490
|
// ../tool-server/src/tools/profiler/query/profiler-load.ts
|
|
68023
68491
|
var import_fs11 = require("fs");
|
|
68024
|
-
var
|
|
68492
|
+
var path12 = __toESM(require("path"));
|
|
68493
|
+
var SESSION_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
68494
|
+
function assertSafeSessionId(sessionId) {
|
|
68495
|
+
if (!SESSION_ID_PATTERN.test(sessionId)) {
|
|
68496
|
+
throw new Error(
|
|
68497
|
+
`Invalid session_id "${sessionId}". Allowed: letters, digits, '_' and '-' (no path separators, no "..").`
|
|
68498
|
+
);
|
|
68499
|
+
}
|
|
68500
|
+
}
|
|
68025
68501
|
var zodSchema49 = external_exports.object({
|
|
68026
68502
|
mode: external_exports.enum(["list", "load_react", "load_native"]).describe(
|
|
68027
68503
|
"list: show available sessions on disk. load_react: load a React profiler session into memory for query tools. load_native: re-parse native profiler XML files (xctrace on iOS) into memory for query tools."
|
|
68028
68504
|
),
|
|
68029
|
-
session_id: external_exports.string().optional().describe(
|
|
68505
|
+
session_id: external_exports.string().regex(SESSION_ID_PATTERN, "session_id may only contain letters, digits, '_' and '-'").optional().describe(
|
|
68030
68506
|
"Timestamp-based session identifier (e.g. '20250313-143022') from the list output. Required for load_react and load_native modes."
|
|
68031
68507
|
),
|
|
68032
68508
|
port: external_exports.coerce.number().default(8081).describe(
|
|
@@ -68075,7 +68551,7 @@ async function listSessions(debugDir) {
|
|
|
68075
68551
|
const commitsFile = files.find((f) => f.includes("_commits.json"));
|
|
68076
68552
|
if (commitsFile) {
|
|
68077
68553
|
try {
|
|
68078
|
-
const onDisk = await readCommitTree(
|
|
68554
|
+
const onDisk = await readCommitTree(path12.join(debugDir, commitsFile));
|
|
68079
68555
|
if (onDisk.meta) {
|
|
68080
68556
|
appName = onDisk.meta.appName ?? null;
|
|
68081
68557
|
deviceName = onDisk.meta.deviceName ?? null;
|
|
@@ -68084,7 +68560,7 @@ async function listSessions(debugDir) {
|
|
|
68084
68560
|
} catch {
|
|
68085
68561
|
}
|
|
68086
68562
|
}
|
|
68087
|
-
const project = projectRoot ?
|
|
68563
|
+
const project = projectRoot ? path12.basename(projectRoot) : null;
|
|
68088
68564
|
lines.push(`| \`${sid}\` | ${appName ?? "\u2014"} | ${deviceName ?? "\u2014"} | ${project ?? "\u2014"} |`);
|
|
68089
68565
|
}
|
|
68090
68566
|
lines.push("");
|
|
@@ -68113,9 +68589,10 @@ async function listSessions(debugDir) {
|
|
|
68113
68589
|
return lines.join("\n");
|
|
68114
68590
|
}
|
|
68115
68591
|
async function loadReactSession(debugDir, sessionId, port, deviceId) {
|
|
68116
|
-
|
|
68117
|
-
const
|
|
68118
|
-
const
|
|
68592
|
+
assertSafeSessionId(sessionId);
|
|
68593
|
+
const cpuPath = path12.join(debugDir, `react-profiler-${sessionId}_cpu.json`);
|
|
68594
|
+
const commitsPath = path12.join(debugDir, `react-profiler-${sessionId}_commits.json`);
|
|
68595
|
+
const cpuIndexPath = path12.join(debugDir, `react-profiler-${sessionId}_cpu-index.json`);
|
|
68119
68596
|
let hasCpu = false;
|
|
68120
68597
|
let hasCommits = false;
|
|
68121
68598
|
let hasCpuIndex = false;
|
|
@@ -68192,7 +68669,7 @@ async function loadReactSession(debugDir, sessionId, port, deviceId) {
|
|
|
68192
68669
|
"",
|
|
68193
68670
|
`- Runtime: ${appName ?? "unknown"}`,
|
|
68194
68671
|
`- Device: ${deviceName ?? "unknown"}`,
|
|
68195
|
-
`- Metro bundle: ${projectRoot ?
|
|
68672
|
+
`- Metro bundle: ${projectRoot ? path12.basename(projectRoot) : "unknown"}`,
|
|
68196
68673
|
`- CPU profile: ${sampleInfo}`,
|
|
68197
68674
|
`- Commits persisted (hot \xB11 margin, \u226516ms): ${commitCount}`,
|
|
68198
68675
|
`- Total React commits: ${totalReactCommits ?? "unknown"}`,
|
|
@@ -68203,9 +68680,10 @@ async function loadReactSession(debugDir, sessionId, port, deviceId) {
|
|
|
68203
68680
|
return lines.join("\n");
|
|
68204
68681
|
}
|
|
68205
68682
|
async function loadNativeSession(debugDir, sessionId, api) {
|
|
68206
|
-
|
|
68207
|
-
const
|
|
68208
|
-
const
|
|
68683
|
+
assertSafeSessionId(sessionId);
|
|
68684
|
+
const cpuXml = path12.join(debugDir, `native-profiler-${sessionId}_raw_cpu.xml`);
|
|
68685
|
+
const hangsXml = path12.join(debugDir, `native-profiler-${sessionId}_raw_hangs.xml`);
|
|
68686
|
+
const leaksXml = path12.join(debugDir, `native-profiler-${sessionId}_raw_leaks.xml`);
|
|
68209
68687
|
const files = {
|
|
68210
68688
|
cpu: null,
|
|
68211
68689
|
hangs: null,
|
|
@@ -68355,7 +68833,7 @@ var stopMetroTool = {
|
|
|
68355
68833
|
async execute(_services, params) {
|
|
68356
68834
|
const port = params.port;
|
|
68357
68835
|
try {
|
|
68358
|
-
const output = (0, import_node_child_process14.
|
|
68836
|
+
const output = (0, import_node_child_process14.execFileSync)("lsof", ["-ti", `tcp:${port}`], {
|
|
68359
68837
|
encoding: "utf-8",
|
|
68360
68838
|
timeout: 5e3
|
|
68361
68839
|
}).trim();
|
|
@@ -68380,21 +68858,24 @@ var stopMetroTool = {
|
|
|
68380
68858
|
};
|
|
68381
68859
|
|
|
68382
68860
|
// ../tool-server/src/tools/flows/flow-start-recording.ts
|
|
68383
|
-
var
|
|
68861
|
+
var fs21 = __toESM(require("node:fs/promises"));
|
|
68384
68862
|
|
|
68385
68863
|
// ../tool-server/src/tools/flows/flow-utils.ts
|
|
68386
|
-
var
|
|
68387
|
-
var
|
|
68388
|
-
var import_yaml = __toESM(
|
|
68389
|
-
var FLOWS_DIR_NAME =
|
|
68864
|
+
var path13 = __toESM(require("node:path"));
|
|
68865
|
+
var fs20 = __toESM(require("node:fs/promises"));
|
|
68866
|
+
var import_yaml = __toESM(require_dist2());
|
|
68867
|
+
var FLOWS_DIR_NAME = path13.join(".argent", "flows");
|
|
68390
68868
|
var activeFlowName = null;
|
|
68391
68869
|
var activeProjectRoot = null;
|
|
68392
68870
|
function setActiveProjectRoot(root) {
|
|
68393
|
-
if (!
|
|
68871
|
+
if (!path13.isAbsolute(root)) {
|
|
68394
68872
|
throw new Error(
|
|
68395
68873
|
`project_root must be an absolute path (got "${root}"). Pass the absolute path to the project root directory \u2014 the same cwd the calling agent is working in.`
|
|
68396
68874
|
);
|
|
68397
68875
|
}
|
|
68876
|
+
if (root.split(/[\\/]+/).includes("..")) {
|
|
68877
|
+
throw new Error(`project_root must not contain ".." segments (got "${root}").`);
|
|
68878
|
+
}
|
|
68398
68879
|
activeProjectRoot = root;
|
|
68399
68880
|
}
|
|
68400
68881
|
function requireActiveProjectRoot() {
|
|
@@ -68406,10 +68887,24 @@ function requireActiveProjectRoot() {
|
|
|
68406
68887
|
return activeProjectRoot;
|
|
68407
68888
|
}
|
|
68408
68889
|
function getFlowsDir() {
|
|
68409
|
-
return
|
|
68890
|
+
return path13.join(requireActiveProjectRoot(), FLOWS_DIR_NAME);
|
|
68891
|
+
}
|
|
68892
|
+
var FLOW_NAME_PATTERN = /^[A-Za-z0-9_\-]+$/;
|
|
68893
|
+
function assertSafeFlowName(name) {
|
|
68894
|
+
if (!FLOW_NAME_PATTERN.test(name)) {
|
|
68895
|
+
throw new Error(
|
|
68896
|
+
`Invalid flow name "${name}". Flow names must match ${FLOW_NAME_PATTERN} (letters, digits, underscore, hyphen \u2014 no path separators, no "..", no spaces).`
|
|
68897
|
+
);
|
|
68898
|
+
}
|
|
68410
68899
|
}
|
|
68411
68900
|
function getFlowPath(name) {
|
|
68412
|
-
|
|
68901
|
+
assertSafeFlowName(name);
|
|
68902
|
+
const filePath = path13.join(getFlowsDir(), `${name}.yaml`);
|
|
68903
|
+
const rel = path13.relative(getFlowsDir(), filePath);
|
|
68904
|
+
if (rel.startsWith("..") || path13.isAbsolute(rel)) {
|
|
68905
|
+
throw new Error(`Invalid flow name "${name}": resolves outside the flows directory.`);
|
|
68906
|
+
}
|
|
68907
|
+
return filePath;
|
|
68413
68908
|
}
|
|
68414
68909
|
function setActiveFlow(name) {
|
|
68415
68910
|
activeFlowName = name;
|
|
@@ -68472,11 +68967,11 @@ function parseFlow(content) {
|
|
|
68472
68967
|
};
|
|
68473
68968
|
}
|
|
68474
68969
|
async function appendStep(filePath, step) {
|
|
68475
|
-
const content = await
|
|
68970
|
+
const content = await fs20.readFile(filePath, "utf8");
|
|
68476
68971
|
const flow = parseFlow(content);
|
|
68477
68972
|
flow.steps.push(step);
|
|
68478
68973
|
const updated = serializeFlow(flow);
|
|
68479
|
-
await
|
|
68974
|
+
await fs20.writeFile(filePath, updated, "utf8");
|
|
68480
68975
|
return updated;
|
|
68481
68976
|
}
|
|
68482
68977
|
|
|
@@ -68509,13 +69004,13 @@ to remove or reorder steps.`,
|
|
|
68509
69004
|
setActiveProjectRoot(params.project_root);
|
|
68510
69005
|
const previousFlow = getActiveFlowOrNull();
|
|
68511
69006
|
const dir = getFlowsDir();
|
|
68512
|
-
await
|
|
69007
|
+
await fs21.mkdir(dir, { recursive: true });
|
|
68513
69008
|
const filePath = getFlowPath(params.name);
|
|
68514
69009
|
const flowFile = serializeFlow({
|
|
68515
69010
|
executionPrerequisite: params.executionPrerequisite,
|
|
68516
69011
|
steps: []
|
|
68517
69012
|
});
|
|
68518
|
-
await
|
|
69013
|
+
await fs21.writeFile(filePath, flowFile, "utf8");
|
|
68519
69014
|
setActiveFlow(params.name);
|
|
68520
69015
|
if (previousFlow && previousFlow !== params.name) {
|
|
68521
69016
|
return {
|
|
@@ -68592,7 +69087,7 @@ Returns { message, flowFile }. Fails if no active flow recording is in progress.
|
|
|
68592
69087
|
};
|
|
68593
69088
|
|
|
68594
69089
|
// ../tool-server/src/tools/flows/flow-finish-recording.ts
|
|
68595
|
-
var
|
|
69090
|
+
var fs22 = __toESM(require("node:fs/promises"));
|
|
68596
69091
|
var zodSchema55 = external_exports.object({});
|
|
68597
69092
|
var flowFinishRecordingTool = {
|
|
68598
69093
|
id: "flow-finish-recording",
|
|
@@ -68603,7 +69098,7 @@ You can still edit the .yaml file directly afterwards to remove or reorder steps
|
|
|
68603
69098
|
async execute(_services, _params) {
|
|
68604
69099
|
const flowName = getActiveFlow();
|
|
68605
69100
|
const filePath = getFlowPath(flowName);
|
|
68606
|
-
const flowFile = await
|
|
69101
|
+
const flowFile = await fs22.readFile(filePath, "utf8");
|
|
68607
69102
|
const flow = parseFlow(flowFile);
|
|
68608
69103
|
const summary = flow.steps.map((step, i) => {
|
|
68609
69104
|
if (step.kind === "echo") {
|
|
@@ -68624,7 +69119,7 @@ You can still edit the .yaml file directly afterwards to remove or reorder steps
|
|
|
68624
69119
|
};
|
|
68625
69120
|
|
|
68626
69121
|
// ../tool-server/src/tools/flows/flow-run.ts
|
|
68627
|
-
var
|
|
69122
|
+
var fs23 = __toESM(require("node:fs/promises"));
|
|
68628
69123
|
var zodSchema56 = external_exports.object({
|
|
68629
69124
|
name: external_exports.string().describe('Name of the flow to run (e.g. "settings-explore")'),
|
|
68630
69125
|
project_root: external_exports.string().describe(
|
|
@@ -68653,7 +69148,7 @@ Use flow-read-prerequisite to inspect the prerequisite beforehand.`,
|
|
|
68653
69148
|
async execute(_services, params) {
|
|
68654
69149
|
setActiveProjectRoot(params.project_root);
|
|
68655
69150
|
const filePath = getFlowPath(params.name);
|
|
68656
|
-
const fileContent = await
|
|
69151
|
+
const fileContent = await fs23.readFile(filePath, "utf8");
|
|
68657
69152
|
const flow = parseFlow(fileContent);
|
|
68658
69153
|
if (flow.executionPrerequisite && !params.prerequisiteAcknowledged) {
|
|
68659
69154
|
return {
|
|
@@ -68696,7 +69191,7 @@ Use flow-read-prerequisite to inspect the prerequisite beforehand.`,
|
|
|
68696
69191
|
}
|
|
68697
69192
|
|
|
68698
69193
|
// ../tool-server/src/tools/flows/flow-read-prerequisite.ts
|
|
68699
|
-
var
|
|
69194
|
+
var fs24 = __toESM(require("node:fs/promises"));
|
|
68700
69195
|
var zodSchema57 = external_exports.object({
|
|
68701
69196
|
name: external_exports.string().describe('Name of the flow to inspect (e.g. "settings-explore")'),
|
|
68702
69197
|
project_root: external_exports.string().describe(
|
|
@@ -68714,7 +69209,7 @@ Fails if the flow file does not exist in the .argent/flows/ directory.`,
|
|
|
68714
69209
|
async execute(_services, params) {
|
|
68715
69210
|
setActiveProjectRoot(params.project_root);
|
|
68716
69211
|
const filePath = getFlowPath(params.name);
|
|
68717
|
-
const fileContent = await
|
|
69212
|
+
const fileContent = await fs24.readFile(filePath, "utf8");
|
|
68718
69213
|
const flow = parseFlow(fileContent);
|
|
68719
69214
|
return {
|
|
68720
69215
|
flow: params.name,
|
|
@@ -68725,42 +69220,42 @@ Fails if the flow file does not exist in the .argent/flows/ directory.`,
|
|
|
68725
69220
|
|
|
68726
69221
|
// ../tool-server/src/utils/workspace-reader.ts
|
|
68727
69222
|
var import_promises2 = require("node:fs/promises");
|
|
68728
|
-
var
|
|
69223
|
+
var import_node_path7 = require("node:path");
|
|
68729
69224
|
var import_node_child_process15 = require("node:child_process");
|
|
68730
|
-
async function exists(
|
|
69225
|
+
async function exists(path16) {
|
|
68731
69226
|
try {
|
|
68732
|
-
await (0, import_promises2.access)(
|
|
69227
|
+
await (0, import_promises2.access)(path16);
|
|
68733
69228
|
return true;
|
|
68734
69229
|
} catch {
|
|
68735
69230
|
return false;
|
|
68736
69231
|
}
|
|
68737
69232
|
}
|
|
68738
|
-
async function isDirectory(
|
|
69233
|
+
async function isDirectory(path16) {
|
|
68739
69234
|
try {
|
|
68740
|
-
const s = await (0, import_promises2.stat)(
|
|
69235
|
+
const s = await (0, import_promises2.stat)(path16);
|
|
68741
69236
|
return s.isDirectory();
|
|
68742
69237
|
} catch {
|
|
68743
69238
|
return false;
|
|
68744
69239
|
}
|
|
68745
69240
|
}
|
|
68746
|
-
async function readJsonFile(
|
|
69241
|
+
async function readJsonFile(path16) {
|
|
68747
69242
|
try {
|
|
68748
|
-
const raw = await (0, import_promises2.readFile)(
|
|
69243
|
+
const raw = await (0, import_promises2.readFile)(path16, "utf-8");
|
|
68749
69244
|
return JSON.parse(raw);
|
|
68750
69245
|
} catch {
|
|
68751
69246
|
return null;
|
|
68752
69247
|
}
|
|
68753
69248
|
}
|
|
68754
|
-
async function readTextFile(
|
|
69249
|
+
async function readTextFile(path16) {
|
|
68755
69250
|
try {
|
|
68756
|
-
return await (0, import_promises2.readFile)(
|
|
69251
|
+
return await (0, import_promises2.readFile)(path16, "utf-8");
|
|
68757
69252
|
} catch {
|
|
68758
69253
|
return null;
|
|
68759
69254
|
}
|
|
68760
69255
|
}
|
|
68761
|
-
async function listDir(
|
|
69256
|
+
async function listDir(path16) {
|
|
68762
69257
|
try {
|
|
68763
|
-
const entries = await (0, import_promises2.readdir)(
|
|
69258
|
+
const entries = await (0, import_promises2.readdir)(path16);
|
|
68764
69259
|
return entries;
|
|
68765
69260
|
} catch {
|
|
68766
69261
|
return null;
|
|
@@ -68768,15 +69263,15 @@ async function listDir(path15) {
|
|
|
68768
69263
|
}
|
|
68769
69264
|
var COMMAND_TIMEOUT_MS = 3e3;
|
|
68770
69265
|
function runVersionCommand(cmd, args, cwd) {
|
|
68771
|
-
return new Promise((
|
|
69266
|
+
return new Promise((resolve3) => {
|
|
68772
69267
|
const child = (0, import_node_child_process15.execFile)(cmd, args, { cwd, timeout: COMMAND_TIMEOUT_MS }, (err, stdout) => {
|
|
68773
69268
|
if (err) {
|
|
68774
|
-
|
|
69269
|
+
resolve3(null);
|
|
68775
69270
|
return;
|
|
68776
69271
|
}
|
|
68777
|
-
|
|
69272
|
+
resolve3(stdout.trim().replace(/^v/, ""));
|
|
68778
69273
|
});
|
|
68779
|
-
child.on("error", () =>
|
|
69274
|
+
child.on("error", () => resolve3(null));
|
|
68780
69275
|
});
|
|
68781
69276
|
}
|
|
68782
69277
|
var METRO_PORT_PATTERNS = [/server\s*:\s*\{[^}]*?port\s*:\s*(\d+)/s, /port\s*:\s*(\d+)/];
|
|
@@ -68824,7 +69319,7 @@ async function detectLockfile(workspacePath) {
|
|
|
68824
69319
|
const checks = await Promise.all(
|
|
68825
69320
|
LOCKFILES.map(async (name) => ({
|
|
68826
69321
|
name,
|
|
68827
|
-
exists: await exists((0,
|
|
69322
|
+
exists: await exists((0, import_node_path7.join)(workspacePath, name))
|
|
68828
69323
|
}))
|
|
68829
69324
|
);
|
|
68830
69325
|
return checks.find((c) => c.exists)?.name ?? null;
|
|
@@ -68843,7 +69338,7 @@ var CI_CONFIGS = [
|
|
|
68843
69338
|
];
|
|
68844
69339
|
async function detectCiConfig(workspacePath) {
|
|
68845
69340
|
for (const ci of CI_CONFIGS) {
|
|
68846
|
-
if (await exists((0,
|
|
69341
|
+
if (await exists((0, import_node_path7.join)(workspacePath, ci.path))) return ci.label;
|
|
68847
69342
|
}
|
|
68848
69343
|
return null;
|
|
68849
69344
|
}
|
|
@@ -68864,7 +69359,7 @@ async function detectLintStagedConfig(workspacePath, packageJson) {
|
|
|
68864
69359
|
return packageJson["lint-staged"];
|
|
68865
69360
|
}
|
|
68866
69361
|
for (const file2 of LINT_STAGED_FILES) {
|
|
68867
|
-
const full = (0,
|
|
69362
|
+
const full = (0, import_node_path7.join)(workspacePath, file2);
|
|
68868
69363
|
if (await exists(full)) {
|
|
68869
69364
|
if (file2.endsWith(".json") || file2 === ".lintstagedrc") {
|
|
68870
69365
|
return readJsonFile(full);
|
|
@@ -68906,7 +69401,7 @@ var CONFIG_FILES = [
|
|
|
68906
69401
|
async function detectConfigFiles(workspacePath) {
|
|
68907
69402
|
const results = await Promise.allSettled(
|
|
68908
69403
|
CONFIG_FILES.map(async (file2) => {
|
|
68909
|
-
if (await exists((0,
|
|
69404
|
+
if (await exists((0, import_node_path7.join)(workspacePath, file2))) return file2;
|
|
68910
69405
|
return null;
|
|
68911
69406
|
})
|
|
68912
69407
|
);
|
|
@@ -68945,7 +69440,7 @@ async function detectEnvFiles(workspacePath) {
|
|
|
68945
69440
|
const envFileNames = entries.filter((e) => e === ".env" || e.startsWith(".env."));
|
|
68946
69441
|
const results = await Promise.all(
|
|
68947
69442
|
envFileNames.map(async (name) => {
|
|
68948
|
-
const content = await readTextFile((0,
|
|
69443
|
+
const content = await readTextFile((0, import_node_path7.join)(workspacePath, name));
|
|
68949
69444
|
return {
|
|
68950
69445
|
name,
|
|
68951
69446
|
keys: content ? extractEnvKeys(content) : []
|
|
@@ -68972,34 +69467,34 @@ async function readWorkspaceSnapshot(workspacePath) {
|
|
|
68972
69467
|
ciConfig,
|
|
68973
69468
|
configFilesFound
|
|
68974
69469
|
] = await Promise.all([
|
|
68975
|
-
readJsonFile((0,
|
|
68976
|
-
readJsonFile((0,
|
|
68977
|
-
readJsonFile((0,
|
|
68978
|
-
readJsonFile((0,
|
|
68979
|
-
readTextFile((0,
|
|
68980
|
-
(r) => r ?? readTextFile((0,
|
|
69470
|
+
readJsonFile((0, import_node_path7.join)(workspacePath, "package.json")),
|
|
69471
|
+
readJsonFile((0, import_node_path7.join)(workspacePath, "app.json")),
|
|
69472
|
+
readJsonFile((0, import_node_path7.join)(workspacePath, "eas.json")),
|
|
69473
|
+
readJsonFile((0, import_node_path7.join)(workspacePath, "tsconfig.json")),
|
|
69474
|
+
readTextFile((0, import_node_path7.join)(workspacePath, "metro.config.js")).then(
|
|
69475
|
+
(r) => r ?? readTextFile((0, import_node_path7.join)(workspacePath, "metro.config.ts"))
|
|
68981
69476
|
),
|
|
68982
|
-
readTextFile((0,
|
|
68983
|
-
(r) => r ?? readTextFile((0,
|
|
69477
|
+
readTextFile((0, import_node_path7.join)(workspacePath, "babel.config.js")).then(
|
|
69478
|
+
(r) => r ?? readTextFile((0, import_node_path7.join)(workspacePath, "babel.config.cjs"))
|
|
68984
69479
|
),
|
|
68985
|
-
isDirectory((0,
|
|
68986
|
-
isDirectory((0,
|
|
69480
|
+
isDirectory((0, import_node_path7.join)(workspacePath, "ios")),
|
|
69481
|
+
isDirectory((0, import_node_path7.join)(workspacePath, "android")),
|
|
68987
69482
|
detectLockfile(workspacePath),
|
|
68988
69483
|
detectEnvFiles(workspacePath),
|
|
68989
69484
|
detectToolVersions(workspacePath),
|
|
68990
|
-
listDir((0,
|
|
68991
|
-
listDir((0,
|
|
69485
|
+
listDir((0, import_node_path7.join)(workspacePath, "scripts")),
|
|
69486
|
+
listDir((0, import_node_path7.join)(workspacePath, ".husky")),
|
|
68992
69487
|
detectCiConfig(workspacePath),
|
|
68993
69488
|
detectConfigFiles(workspacePath)
|
|
68994
69489
|
]);
|
|
68995
|
-
const iosDir = (0,
|
|
68996
|
-
const androidDir = (0,
|
|
69490
|
+
const iosDir = (0, import_node_path7.join)(workspacePath, "ios");
|
|
69491
|
+
const androidDir = (0, import_node_path7.join)(workspacePath, "android");
|
|
68997
69492
|
const [iosWorkspace, iosHasPodfile, makefileText, lintStagedConfig, androidHasGradle] = await Promise.all([
|
|
68998
69493
|
hasIosDir ? findIosWorkspace(iosDir) : Promise.resolve(null),
|
|
68999
|
-
exists((0,
|
|
69000
|
-
readTextFile((0,
|
|
69494
|
+
exists((0, import_node_path7.join)(workspacePath, "ios", "Podfile")),
|
|
69495
|
+
readTextFile((0, import_node_path7.join)(workspacePath, "Makefile")),
|
|
69001
69496
|
detectLintStagedConfig(workspacePath, packageJson),
|
|
69002
|
-
hasAndroidDir ? exists((0,
|
|
69497
|
+
hasAndroidDir ? exists((0, import_node_path7.join)(androidDir, "gradlew")) : Promise.resolve(false)
|
|
69003
69498
|
]);
|
|
69004
69499
|
const metroPort = metroConfigRaw ? extractMetroPort(metroConfigRaw) : null;
|
|
69005
69500
|
const makefileTargets = makefileText ? extractMakefileTargets(makefileText) : null;
|
|
@@ -70650,6 +71145,161 @@ function formatPercentage(value) {
|
|
|
70650
71145
|
})}%`;
|
|
70651
71146
|
}
|
|
70652
71147
|
|
|
71148
|
+
// ../tool-server/src/tools/screenshot-diff/resize.ts
|
|
71149
|
+
var ASPECT_RATIO_TOLERANCE = 0.01;
|
|
71150
|
+
function normalizeToCommonSize(baseline, current) {
|
|
71151
|
+
if (baseline.width === current.width && baseline.height === current.height) {
|
|
71152
|
+
return { baseline, current };
|
|
71153
|
+
}
|
|
71154
|
+
if (!aspectRatiosMatch(baseline, current)) {
|
|
71155
|
+
return null;
|
|
71156
|
+
}
|
|
71157
|
+
const baselineArea = baseline.width * baseline.height;
|
|
71158
|
+
const currentArea = current.width * current.height;
|
|
71159
|
+
if (baselineArea <= currentArea) {
|
|
71160
|
+
return {
|
|
71161
|
+
baseline,
|
|
71162
|
+
current: resizeDecodedPng(current, baseline.width, baseline.height)
|
|
71163
|
+
};
|
|
71164
|
+
}
|
|
71165
|
+
return {
|
|
71166
|
+
baseline: resizeDecodedPng(baseline, current.width, current.height),
|
|
71167
|
+
current
|
|
71168
|
+
};
|
|
71169
|
+
}
|
|
71170
|
+
function aspectRatiosMatch(a, b) {
|
|
71171
|
+
if (a.width <= 0 || a.height <= 0 || b.width <= 0 || b.height <= 0) {
|
|
71172
|
+
return false;
|
|
71173
|
+
}
|
|
71174
|
+
const aspectA = a.width / a.height;
|
|
71175
|
+
const aspectB = b.width / b.height;
|
|
71176
|
+
const largest = Math.max(aspectA, aspectB);
|
|
71177
|
+
if (largest === 0) return false;
|
|
71178
|
+
return Math.abs(aspectA - aspectB) / largest <= ASPECT_RATIO_TOLERANCE;
|
|
71179
|
+
}
|
|
71180
|
+
function resizeDecodedPng(src, width, height) {
|
|
71181
|
+
const targetWidth = Math.max(1, Math.round(width));
|
|
71182
|
+
const targetHeight = Math.max(1, Math.round(height));
|
|
71183
|
+
if (targetWidth === src.width && targetHeight === src.height) {
|
|
71184
|
+
return { width: src.width, height: src.height, data: Buffer.from(src.data) };
|
|
71185
|
+
}
|
|
71186
|
+
const horizontal = buildLanczos3AxisWeights(src.width, targetWidth);
|
|
71187
|
+
const vertical = buildLanczos3AxisWeights(src.height, targetHeight);
|
|
71188
|
+
const intermediate = new Float32Array(targetWidth * src.height * 4);
|
|
71189
|
+
resampleHorizontalRgba({
|
|
71190
|
+
sourceData: src.data,
|
|
71191
|
+
sourceWidth: src.width,
|
|
71192
|
+
sourceHeight: src.height,
|
|
71193
|
+
targetWidth,
|
|
71194
|
+
weights: horizontal,
|
|
71195
|
+
output: intermediate
|
|
71196
|
+
});
|
|
71197
|
+
const output = Buffer.alloc(targetWidth * targetHeight * 4);
|
|
71198
|
+
resampleVerticalRgba({
|
|
71199
|
+
intermediate,
|
|
71200
|
+
targetWidth,
|
|
71201
|
+
targetHeight,
|
|
71202
|
+
weights: vertical,
|
|
71203
|
+
output
|
|
71204
|
+
});
|
|
71205
|
+
return { width: targetWidth, height: targetHeight, data: output };
|
|
71206
|
+
}
|
|
71207
|
+
function resampleHorizontalRgba(params) {
|
|
71208
|
+
for (let y = 0; y < params.sourceHeight; y++) {
|
|
71209
|
+
const rowOffset = y * params.sourceWidth * 4;
|
|
71210
|
+
const targetRowOffset = y * params.targetWidth * 4;
|
|
71211
|
+
for (let x = 0; x < params.targetWidth; x++) {
|
|
71212
|
+
const { start: start2, weights } = params.weights[x];
|
|
71213
|
+
let r = 0;
|
|
71214
|
+
let g = 0;
|
|
71215
|
+
let b = 0;
|
|
71216
|
+
let a = 0;
|
|
71217
|
+
const baseOffset = rowOffset + start2 * 4;
|
|
71218
|
+
for (let k = 0; k < weights.length; k++) {
|
|
71219
|
+
const sampleOffset = baseOffset + k * 4;
|
|
71220
|
+
const w = weights[k];
|
|
71221
|
+
r += params.sourceData[sampleOffset] * w;
|
|
71222
|
+
g += params.sourceData[sampleOffset + 1] * w;
|
|
71223
|
+
b += params.sourceData[sampleOffset + 2] * w;
|
|
71224
|
+
a += params.sourceData[sampleOffset + 3] * w;
|
|
71225
|
+
}
|
|
71226
|
+
const targetOffset = targetRowOffset + x * 4;
|
|
71227
|
+
params.output[targetOffset] = r;
|
|
71228
|
+
params.output[targetOffset + 1] = g;
|
|
71229
|
+
params.output[targetOffset + 2] = b;
|
|
71230
|
+
params.output[targetOffset + 3] = a;
|
|
71231
|
+
}
|
|
71232
|
+
}
|
|
71233
|
+
}
|
|
71234
|
+
function resampleVerticalRgba(params) {
|
|
71235
|
+
const rowStride = params.targetWidth * 4;
|
|
71236
|
+
for (let y = 0; y < params.targetHeight; y++) {
|
|
71237
|
+
const { start: start2, weights } = params.weights[y];
|
|
71238
|
+
const targetRowOffset = y * rowStride;
|
|
71239
|
+
for (let x = 0; x < params.targetWidth; x++) {
|
|
71240
|
+
let r = 0;
|
|
71241
|
+
let g = 0;
|
|
71242
|
+
let b = 0;
|
|
71243
|
+
let a = 0;
|
|
71244
|
+
const columnOffset = start2 * rowStride + x * 4;
|
|
71245
|
+
for (let k = 0; k < weights.length; k++) {
|
|
71246
|
+
const sampleOffset = columnOffset + k * rowStride;
|
|
71247
|
+
const w = weights[k];
|
|
71248
|
+
r += params.intermediate[sampleOffset] * w;
|
|
71249
|
+
g += params.intermediate[sampleOffset + 1] * w;
|
|
71250
|
+
b += params.intermediate[sampleOffset + 2] * w;
|
|
71251
|
+
a += params.intermediate[sampleOffset + 3] * w;
|
|
71252
|
+
}
|
|
71253
|
+
const targetOffset = targetRowOffset + x * 4;
|
|
71254
|
+
params.output[targetOffset] = clampToByte(r);
|
|
71255
|
+
params.output[targetOffset + 1] = clampToByte(g);
|
|
71256
|
+
params.output[targetOffset + 2] = clampToByte(b);
|
|
71257
|
+
params.output[targetOffset + 3] = clampToByte(a);
|
|
71258
|
+
}
|
|
71259
|
+
}
|
|
71260
|
+
}
|
|
71261
|
+
function buildLanczos3AxisWeights(sourceSize, targetSize) {
|
|
71262
|
+
const scale = targetSize / sourceSize;
|
|
71263
|
+
const filterScale = scale < 1 ? scale : 1;
|
|
71264
|
+
const supportInSource = LANCZOS3_RADIUS / filterScale;
|
|
71265
|
+
const axis = new Array(targetSize);
|
|
71266
|
+
for (let i = 0; i < targetSize; i++) {
|
|
71267
|
+
const center = (i + 0.5) / scale - 0.5;
|
|
71268
|
+
const start2 = Math.max(0, Math.ceil(center - supportInSource - LANCZOS3_EPSILON));
|
|
71269
|
+
const end = Math.min(sourceSize - 1, Math.floor(center + supportInSource + LANCZOS3_EPSILON));
|
|
71270
|
+
const length = Math.max(1, end - start2 + 1);
|
|
71271
|
+
const weights = new Float32Array(length);
|
|
71272
|
+
let sum = 0;
|
|
71273
|
+
for (let k = 0; k < length; k++) {
|
|
71274
|
+
const sampleIndex = start2 + k;
|
|
71275
|
+
const w = lanczos3Kernel((sampleIndex - center) * filterScale);
|
|
71276
|
+
weights[k] = w;
|
|
71277
|
+
sum += w;
|
|
71278
|
+
}
|
|
71279
|
+
if (sum !== 0) {
|
|
71280
|
+
const inverseSum = 1 / sum;
|
|
71281
|
+
for (let k = 0; k < length; k++) {
|
|
71282
|
+
weights[k] *= inverseSum;
|
|
71283
|
+
}
|
|
71284
|
+
}
|
|
71285
|
+
axis[i] = { start: start2, weights };
|
|
71286
|
+
}
|
|
71287
|
+
return axis;
|
|
71288
|
+
}
|
|
71289
|
+
var LANCZOS3_RADIUS = 3;
|
|
71290
|
+
var LANCZOS3_EPSILON = 1e-9;
|
|
71291
|
+
function lanczos3Kernel(x) {
|
|
71292
|
+
if (x === 0) return 1;
|
|
71293
|
+
if (x <= -LANCZOS3_RADIUS || x >= LANCZOS3_RADIUS) return 0;
|
|
71294
|
+
const piX = Math.PI * x;
|
|
71295
|
+
return LANCZOS3_RADIUS * Math.sin(piX) * Math.sin(piX / LANCZOS3_RADIUS) / (piX * piX);
|
|
71296
|
+
}
|
|
71297
|
+
function clampToByte(value) {
|
|
71298
|
+
if (value <= 0) return 0;
|
|
71299
|
+
if (value >= 255) return 255;
|
|
71300
|
+
return Math.round(value);
|
|
71301
|
+
}
|
|
71302
|
+
|
|
70653
71303
|
// ../tool-server/src/tools/screenshot-diff/screenshot-diff.ts
|
|
70654
71304
|
var MAX_RGB_DISTANCE_SQUARED = 255 * 255 * 3;
|
|
70655
71305
|
var DEFAULT_THRESHOLD = 0.1;
|
|
@@ -70669,18 +71319,21 @@ var HORIZONTAL_TEXT_MERGE_MAX_GAP = 120;
|
|
|
70669
71319
|
var UNIFORM_BRIGHTNESS_DELTA_TOLERANCE = 4;
|
|
70670
71320
|
async function diffPngFiles(options) {
|
|
70671
71321
|
const settings = resolveDiffSettings();
|
|
70672
|
-
const [
|
|
71322
|
+
const [decodedBaseline, decodedCurrent] = await Promise.all([
|
|
70673
71323
|
decodePngFile(options.baselinePath),
|
|
70674
71324
|
decodePngFile(options.currentPath)
|
|
70675
71325
|
]);
|
|
70676
|
-
|
|
71326
|
+
const normalized = normalizeToCommonSize(decodedBaseline, decodedCurrent);
|
|
71327
|
+
if (!normalized) {
|
|
70677
71328
|
return summarizeResult(
|
|
70678
71329
|
buildDimensionMismatchResult({
|
|
70679
|
-
baseline,
|
|
70680
|
-
current
|
|
71330
|
+
baseline: decodedBaseline,
|
|
71331
|
+
current: decodedCurrent
|
|
70681
71332
|
})
|
|
70682
71333
|
);
|
|
70683
71334
|
}
|
|
71335
|
+
const baseline = normalized.baseline;
|
|
71336
|
+
const current = normalized.current;
|
|
70684
71337
|
const totalPixels = baseline.width * baseline.height;
|
|
70685
71338
|
const pixelDiff = markChangedPixels({
|
|
70686
71339
|
baseline,
|
|
@@ -70708,9 +71361,9 @@ async function diffPngFiles(options) {
|
|
|
70708
71361
|
baselinePath: options.baselinePath,
|
|
70709
71362
|
currentPath: options.currentPath,
|
|
70710
71363
|
hasPixelDiff: pixelDiff.differentPixels > 0,
|
|
70711
|
-
baselineImage:
|
|
70712
|
-
currentImage:
|
|
70713
|
-
ignoreTopPixels:
|
|
71364
|
+
baselineImage: decodedBaseline,
|
|
71365
|
+
currentImage: decodedCurrent,
|
|
71366
|
+
ignoreTopPixels: ignoredTopRowsFor(decodedBaseline.height, settings.ignoreTopNormalizedY),
|
|
70714
71367
|
textChangeMinConfidence: DEFAULT_TEXT_CHANGE_MIN_CONFIDENCE
|
|
70715
71368
|
});
|
|
70716
71369
|
return summarizeResult({
|
|
@@ -70757,10 +71410,7 @@ function markChangedPixels(params) {
|
|
|
70757
71410
|
const baselineData = params.baseline.data;
|
|
70758
71411
|
const currentData = params.current.data;
|
|
70759
71412
|
const mask = new Uint8Array(totalPixels);
|
|
70760
|
-
const ignoredTopRows =
|
|
70761
|
-
params.baseline.height,
|
|
70762
|
-
Math.ceil(params.baseline.height * params.ignoreTopNormalizedY)
|
|
70763
|
-
);
|
|
71413
|
+
const ignoredTopRows = ignoredTopRowsFor(params.baseline.height, params.ignoreTopNormalizedY);
|
|
70764
71414
|
let differentPixels = 0;
|
|
70765
71415
|
for (let y = ignoredTopRows; y < params.baseline.height; y++) {
|
|
70766
71416
|
for (let x = 0; x < params.baseline.width; x++) {
|
|
@@ -70778,6 +71428,9 @@ function markChangedPixels(params) {
|
|
|
70778
71428
|
}
|
|
70779
71429
|
return { mask, differentPixels, ignoredTopRows };
|
|
70780
71430
|
}
|
|
71431
|
+
function ignoredTopRowsFor(height, ignoreTopNormalizedY) {
|
|
71432
|
+
return Math.min(height, Math.ceil(height * ignoreTopNormalizedY));
|
|
71433
|
+
}
|
|
70781
71434
|
function getChangedRegions(params) {
|
|
70782
71435
|
const rawRegions = traceChangeRegions({
|
|
70783
71436
|
mask: params.mask,
|
|
@@ -70869,139 +71522,13 @@ async function writePngFile(filePath, png) {
|
|
|
70869
71522
|
await import_promises3.default.writeFile(filePath, import_pngjs.PNG.sync.write(png));
|
|
70870
71523
|
}
|
|
70871
71524
|
function downscalePng(source, scale) {
|
|
70872
|
-
const
|
|
70873
|
-
|
|
70874
|
-
|
|
70875
|
-
|
|
70876
|
-
|
|
70877
|
-
|
|
70878
|
-
|
|
70879
|
-
sourceWidth: source.width,
|
|
70880
|
-
sourceHeight: source.height,
|
|
70881
|
-
targetWidth,
|
|
70882
|
-
targetHeight
|
|
70883
|
-
});
|
|
70884
|
-
}
|
|
70885
|
-
function lanczos3ResizeRgba(params) {
|
|
70886
|
-
const horizontal = buildLanczos3AxisWeights(params.sourceWidth, params.targetWidth);
|
|
70887
|
-
const vertical = buildLanczos3AxisWeights(params.sourceHeight, params.targetHeight);
|
|
70888
|
-
const intermediate = new Float32Array(params.targetWidth * params.sourceHeight * 4);
|
|
70889
|
-
resampleHorizontalRgba({
|
|
70890
|
-
sourceData: params.sourceData,
|
|
70891
|
-
sourceWidth: params.sourceWidth,
|
|
70892
|
-
sourceHeight: params.sourceHeight,
|
|
70893
|
-
targetWidth: params.targetWidth,
|
|
70894
|
-
weights: horizontal,
|
|
70895
|
-
output: intermediate
|
|
70896
|
-
});
|
|
70897
|
-
const target = new import_pngjs.PNG({ width: params.targetWidth, height: params.targetHeight });
|
|
70898
|
-
resampleVerticalRgba({
|
|
70899
|
-
intermediate,
|
|
70900
|
-
targetWidth: params.targetWidth,
|
|
70901
|
-
targetHeight: params.targetHeight,
|
|
70902
|
-
weights: vertical,
|
|
70903
|
-
output: target.data
|
|
70904
|
-
});
|
|
70905
|
-
return target;
|
|
70906
|
-
}
|
|
70907
|
-
function resampleHorizontalRgba(params) {
|
|
70908
|
-
for (let y = 0; y < params.sourceHeight; y++) {
|
|
70909
|
-
const rowOffset = y * params.sourceWidth * 4;
|
|
70910
|
-
const targetRowOffset = y * params.targetWidth * 4;
|
|
70911
|
-
for (let x = 0; x < params.targetWidth; x++) {
|
|
70912
|
-
const { start: start2, weights } = params.weights[x];
|
|
70913
|
-
let r = 0;
|
|
70914
|
-
let g = 0;
|
|
70915
|
-
let b = 0;
|
|
70916
|
-
let a = 0;
|
|
70917
|
-
const baseOffset = rowOffset + start2 * 4;
|
|
70918
|
-
for (let k = 0; k < weights.length; k++) {
|
|
70919
|
-
const sampleOffset = baseOffset + k * 4;
|
|
70920
|
-
const w = weights[k];
|
|
70921
|
-
r += params.sourceData[sampleOffset] * w;
|
|
70922
|
-
g += params.sourceData[sampleOffset + 1] * w;
|
|
70923
|
-
b += params.sourceData[sampleOffset + 2] * w;
|
|
70924
|
-
a += params.sourceData[sampleOffset + 3] * w;
|
|
70925
|
-
}
|
|
70926
|
-
const targetOffset = targetRowOffset + x * 4;
|
|
70927
|
-
params.output[targetOffset] = r;
|
|
70928
|
-
params.output[targetOffset + 1] = g;
|
|
70929
|
-
params.output[targetOffset + 2] = b;
|
|
70930
|
-
params.output[targetOffset + 3] = a;
|
|
70931
|
-
}
|
|
70932
|
-
}
|
|
70933
|
-
}
|
|
70934
|
-
function resampleVerticalRgba(params) {
|
|
70935
|
-
const rowStride = params.targetWidth * 4;
|
|
70936
|
-
for (let y = 0; y < params.targetHeight; y++) {
|
|
70937
|
-
const { start: start2, weights } = params.weights[y];
|
|
70938
|
-
const targetRowOffset = y * rowStride;
|
|
70939
|
-
for (let x = 0; x < params.targetWidth; x++) {
|
|
70940
|
-
let r = 0;
|
|
70941
|
-
let g = 0;
|
|
70942
|
-
let b = 0;
|
|
70943
|
-
let a = 0;
|
|
70944
|
-
const columnOffset = start2 * rowStride + x * 4;
|
|
70945
|
-
for (let k = 0; k < weights.length; k++) {
|
|
70946
|
-
const sampleOffset = columnOffset + k * rowStride;
|
|
70947
|
-
const w = weights[k];
|
|
70948
|
-
r += params.intermediate[sampleOffset] * w;
|
|
70949
|
-
g += params.intermediate[sampleOffset + 1] * w;
|
|
70950
|
-
b += params.intermediate[sampleOffset + 2] * w;
|
|
70951
|
-
a += params.intermediate[sampleOffset + 3] * w;
|
|
70952
|
-
}
|
|
70953
|
-
const targetOffset = targetRowOffset + x * 4;
|
|
70954
|
-
params.output[targetOffset] = clampToByte(r);
|
|
70955
|
-
params.output[targetOffset + 1] = clampToByte(g);
|
|
70956
|
-
params.output[targetOffset + 2] = clampToByte(b);
|
|
70957
|
-
params.output[targetOffset + 3] = clampToByte(a);
|
|
70958
|
-
}
|
|
70959
|
-
}
|
|
70960
|
-
}
|
|
70961
|
-
function buildLanczos3AxisWeights(sourceSize, targetSize) {
|
|
70962
|
-
const scale = targetSize / sourceSize;
|
|
70963
|
-
const filterScale = scale < 1 ? scale : 1;
|
|
70964
|
-
const supportInSource = LANCZOS3_RADIUS / filterScale;
|
|
70965
|
-
const axis = new Array(targetSize);
|
|
70966
|
-
for (let i = 0; i < targetSize; i++) {
|
|
70967
|
-
const center = (i + 0.5) / scale - 0.5;
|
|
70968
|
-
const start2 = Math.max(0, Math.ceil(center - supportInSource - LANCZOS3_EPSILON));
|
|
70969
|
-
const end = Math.min(sourceSize - 1, Math.floor(center + supportInSource + LANCZOS3_EPSILON));
|
|
70970
|
-
const length = Math.max(1, end - start2 + 1);
|
|
70971
|
-
const weights = new Float32Array(length);
|
|
70972
|
-
let sum = 0;
|
|
70973
|
-
for (let k = 0; k < length; k++) {
|
|
70974
|
-
const sampleIndex = start2 + k;
|
|
70975
|
-
const w = lanczos3Kernel((sampleIndex - center) * filterScale);
|
|
70976
|
-
weights[k] = w;
|
|
70977
|
-
sum += w;
|
|
70978
|
-
}
|
|
70979
|
-
if (sum !== 0) {
|
|
70980
|
-
const inverseSum = 1 / sum;
|
|
70981
|
-
for (let k = 0; k < length; k++) {
|
|
70982
|
-
weights[k] *= inverseSum;
|
|
70983
|
-
}
|
|
70984
|
-
}
|
|
70985
|
-
axis[i] = { start: start2, weights };
|
|
70986
|
-
}
|
|
70987
|
-
return axis;
|
|
70988
|
-
}
|
|
70989
|
-
var LANCZOS3_RADIUS = 3;
|
|
70990
|
-
var LANCZOS3_EPSILON = 1e-9;
|
|
70991
|
-
function lanczos3Kernel(x) {
|
|
70992
|
-
if (x === 0) return 1;
|
|
70993
|
-
if (x <= -LANCZOS3_RADIUS || x >= LANCZOS3_RADIUS) return 0;
|
|
70994
|
-
const piX = Math.PI * x;
|
|
70995
|
-
return LANCZOS3_RADIUS * Math.sin(piX) * Math.sin(piX / LANCZOS3_RADIUS) / (piX * piX);
|
|
70996
|
-
}
|
|
70997
|
-
function clampToByte(value) {
|
|
70998
|
-
if (value <= 0) return 0;
|
|
70999
|
-
if (value >= 255) return 255;
|
|
71000
|
-
return Math.round(value);
|
|
71001
|
-
}
|
|
71002
|
-
function clonePng(source) {
|
|
71003
|
-
const target = new import_pngjs.PNG({ width: source.width, height: source.height });
|
|
71004
|
-
source.data.copy(target.data);
|
|
71525
|
+
const resized = resizeDecodedPng(
|
|
71526
|
+
{ width: source.width, height: source.height, data: source.data },
|
|
71527
|
+
source.width * scale,
|
|
71528
|
+
source.height * scale
|
|
71529
|
+
);
|
|
71530
|
+
const target = new import_pngjs.PNG({ width: resized.width, height: resized.height });
|
|
71531
|
+
resized.data.copy(target.data);
|
|
71005
71532
|
return target;
|
|
71006
71533
|
}
|
|
71007
71534
|
function drawRegionRectangles(png, regions) {
|
|
@@ -71508,6 +72035,13 @@ function startSimulatorWatcher(registry2) {
|
|
|
71508
72035
|
|
|
71509
72036
|
// ../tool-server/src/index.ts
|
|
71510
72037
|
var PROCESS_TIMEOUT_MS = 5e3;
|
|
72038
|
+
var DEFAULT_PORT = "3001";
|
|
72039
|
+
var DEFAULT_HOST = "127.0.0.1";
|
|
72040
|
+
var DEFAULT_IDLE_TIMEOUT_MINUTES = "0";
|
|
72041
|
+
function formatOrigin(host, port) {
|
|
72042
|
+
const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
72043
|
+
return `http://${h}:${port}`;
|
|
72044
|
+
}
|
|
71511
72045
|
function initializeStdioTimestampWrapper() {
|
|
71512
72046
|
if (process.env.WRAP_STDIO_DISABLED) return;
|
|
71513
72047
|
for (const stream of [process.stdout, process.stderr]) {
|
|
@@ -71540,9 +72074,10 @@ function start() {
|
|
|
71540
72074
|
reason instanceof Error ? reason.stack ?? reason.message : String(reason)
|
|
71541
72075
|
);
|
|
71542
72076
|
});
|
|
71543
|
-
const PORT = parseInt(process.env.
|
|
72077
|
+
const PORT = parseInt(process.env.ARGENT_PORT ?? DEFAULT_PORT, 10);
|
|
72078
|
+
const HOST = process.env.ARGENT_HOST ?? DEFAULT_HOST;
|
|
71544
72079
|
const idleMinutes = parseInt(
|
|
71545
|
-
process.env.ARGENT_IDLE_TIMEOUT_MINUTES ??
|
|
72080
|
+
process.env.ARGENT_IDLE_TIMEOUT_MINUTES ?? DEFAULT_IDLE_TIMEOUT_MINUTES,
|
|
71546
72081
|
10
|
|
71547
72082
|
);
|
|
71548
72083
|
const idleTimeoutMs = idleMinutes > 0 ? idleMinutes * 6e4 : 0;
|
|
@@ -71558,7 +72093,7 @@ function start() {
|
|
|
71558
72093
|
await registry2.dispose();
|
|
71559
72094
|
if (server) {
|
|
71560
72095
|
const forceExit = setTimeout(() => process.exit(exitCode), PROCESS_TIMEOUT_MS);
|
|
71561
|
-
await new Promise((
|
|
72096
|
+
await new Promise((resolve3) => server.close(() => resolve3()));
|
|
71562
72097
|
clearTimeout(forceExit);
|
|
71563
72098
|
}
|
|
71564
72099
|
process.exit(exitCode);
|
|
@@ -71566,23 +72101,33 @@ function start() {
|
|
|
71566
72101
|
const httpHandle = createHttpApp(registry2, {
|
|
71567
72102
|
idleTimeoutMs,
|
|
71568
72103
|
onIdle: shutdown,
|
|
71569
|
-
onShutdown: shutdown
|
|
72104
|
+
onShutdown: shutdown,
|
|
72105
|
+
bindHost: HOST
|
|
71570
72106
|
});
|
|
71571
72107
|
watcherReady.then(() => {
|
|
71572
|
-
server = httpHandle.app.listen(PORT,
|
|
72108
|
+
server = httpHandle.app.listen(PORT, HOST, () => {
|
|
71573
72109
|
const addr = server.address();
|
|
71574
72110
|
const boundPort = typeof addr === "object" && addr ? addr.port : PORT;
|
|
71575
|
-
|
|
72111
|
+
const origin = formatOrigin(HOST, boundPort);
|
|
72112
|
+
process.stdout.write(`Tools server listening on ${origin}
|
|
71576
72113
|
`);
|
|
71577
|
-
process.stderr.write(` GET
|
|
72114
|
+
process.stderr.write(` GET ${origin}/tools
|
|
71578
72115
|
`);
|
|
71579
|
-
process.stderr.write(` POST
|
|
72116
|
+
process.stderr.write(` POST ${origin}/tools/:name
|
|
71580
72117
|
`);
|
|
71581
72118
|
if (idleTimeoutMs > 0) {
|
|
71582
72119
|
process.stderr.write(` Idle timeout: ${idleMinutes}min
|
|
71583
72120
|
`);
|
|
71584
72121
|
}
|
|
71585
72122
|
});
|
|
72123
|
+
server.on("error", (err) => {
|
|
72124
|
+
const code = err.code ? `${err.code}: ` : "";
|
|
72125
|
+
process.stderr.write(
|
|
72126
|
+
`[tool-server] Failed to bind ${HOST}:${PORT} \u2014 ${code}${err.message}
|
|
72127
|
+
`
|
|
72128
|
+
);
|
|
72129
|
+
process.exit(1);
|
|
72130
|
+
});
|
|
71586
72131
|
}).catch((err) => {
|
|
71587
72132
|
process.stderr.write(
|
|
71588
72133
|
`[tool-server] Failed to start: ${err instanceof Error ? err.message : err}
|