@mcesystems/adb-kit 1.0.41 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +226 -226
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +226 -226
- package/dist/index.mjs.map +4 -4
- package/dist/types/logic/adbDeviceKit.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -30174,7 +30174,7 @@ var require_dist = __commonJS({
|
|
|
30174
30174
|
});
|
|
30175
30175
|
|
|
30176
30176
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
|
|
30177
|
-
var
|
|
30177
|
+
var require_common3 = __commonJS({
|
|
30178
30178
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports2, module2) {
|
|
30179
30179
|
function setup(env2) {
|
|
30180
30180
|
createDebug.debug = createDebug;
|
|
@@ -30351,7 +30351,7 @@ var require_common2 = __commonJS({
|
|
|
30351
30351
|
});
|
|
30352
30352
|
|
|
30353
30353
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
|
|
30354
|
-
var
|
|
30354
|
+
var require_browser3 = __commonJS({
|
|
30355
30355
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports2, module2) {
|
|
30356
30356
|
exports2.formatArgs = formatArgs;
|
|
30357
30357
|
exports2.save = save;
|
|
@@ -30508,7 +30508,7 @@ var require_browser2 = __commonJS({
|
|
|
30508
30508
|
} catch (error) {
|
|
30509
30509
|
}
|
|
30510
30510
|
}
|
|
30511
|
-
module2.exports =
|
|
30511
|
+
module2.exports = require_common3()(exports2);
|
|
30512
30512
|
var { formatters } = module2.exports;
|
|
30513
30513
|
formatters.j = function(v) {
|
|
30514
30514
|
try {
|
|
@@ -30521,7 +30521,7 @@ var require_browser2 = __commonJS({
|
|
|
30521
30521
|
});
|
|
30522
30522
|
|
|
30523
30523
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
|
|
30524
|
-
var
|
|
30524
|
+
var require_node3 = __commonJS({
|
|
30525
30525
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports2, module2) {
|
|
30526
30526
|
var tty = require("tty");
|
|
30527
30527
|
var util = require("util");
|
|
@@ -30681,7 +30681,7 @@ var require_node2 = __commonJS({
|
|
|
30681
30681
|
debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
30682
30682
|
}
|
|
30683
30683
|
}
|
|
30684
|
-
module2.exports =
|
|
30684
|
+
module2.exports = require_common3()(exports2);
|
|
30685
30685
|
var { formatters } = module2.exports;
|
|
30686
30686
|
formatters.o = function(v) {
|
|
30687
30687
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -30695,12 +30695,12 @@ var require_node2 = __commonJS({
|
|
|
30695
30695
|
});
|
|
30696
30696
|
|
|
30697
30697
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
|
|
30698
|
-
var
|
|
30698
|
+
var require_src3 = __commonJS({
|
|
30699
30699
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports2, module2) {
|
|
30700
30700
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
30701
|
-
module2.exports =
|
|
30701
|
+
module2.exports = require_browser3();
|
|
30702
30702
|
} else {
|
|
30703
|
-
module2.exports =
|
|
30703
|
+
module2.exports = require_node3();
|
|
30704
30704
|
}
|
|
30705
30705
|
}
|
|
30706
30706
|
});
|
|
@@ -30715,193 +30715,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30715
30715
|
// src/logic/adbDeviceKit.ts
|
|
30716
30716
|
var adbkit = __toESM(require_dist());
|
|
30717
30717
|
|
|
30718
|
-
// ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
30719
|
-
var import_node_net = __toESM(require("node:net"), 1);
|
|
30720
|
-
var import_node_os = __toESM(require("node:os"), 1);
|
|
30721
|
-
var Locked = class extends Error {
|
|
30722
|
-
constructor(port) {
|
|
30723
|
-
super(`${port} is locked`);
|
|
30724
|
-
}
|
|
30725
|
-
};
|
|
30726
|
-
var lockedPorts = {
|
|
30727
|
-
old: /* @__PURE__ */ new Set(),
|
|
30728
|
-
young: /* @__PURE__ */ new Set()
|
|
30729
|
-
};
|
|
30730
|
-
var releaseOldLockedPortsIntervalMs = 1e3 * 15;
|
|
30731
|
-
var minPort = 1024;
|
|
30732
|
-
var maxPort = 65535;
|
|
30733
|
-
var timeout;
|
|
30734
|
-
var getLocalHosts = () => {
|
|
30735
|
-
const interfaces = import_node_os.default.networkInterfaces();
|
|
30736
|
-
const results = /* @__PURE__ */ new Set([void 0, "0.0.0.0"]);
|
|
30737
|
-
for (const _interface of Object.values(interfaces)) {
|
|
30738
|
-
for (const config of _interface) {
|
|
30739
|
-
results.add(config.address);
|
|
30740
|
-
}
|
|
30741
|
-
}
|
|
30742
|
-
return results;
|
|
30743
|
-
};
|
|
30744
|
-
var checkAvailablePort = (options) => new Promise((resolve, reject) => {
|
|
30745
|
-
const server = import_node_net.default.createServer();
|
|
30746
|
-
server.unref();
|
|
30747
|
-
server.on("error", reject);
|
|
30748
|
-
server.listen(options, () => {
|
|
30749
|
-
const { port } = server.address();
|
|
30750
|
-
server.close(() => {
|
|
30751
|
-
resolve(port);
|
|
30752
|
-
});
|
|
30753
|
-
});
|
|
30754
|
-
});
|
|
30755
|
-
var getAvailablePort = async (options, hosts) => {
|
|
30756
|
-
if (options.host || options.port === 0) {
|
|
30757
|
-
return checkAvailablePort(options);
|
|
30758
|
-
}
|
|
30759
|
-
for (const host of hosts) {
|
|
30760
|
-
try {
|
|
30761
|
-
await checkAvailablePort({ port: options.port, host });
|
|
30762
|
-
} catch (error) {
|
|
30763
|
-
if (!["EADDRNOTAVAIL", "EINVAL"].includes(error.code)) {
|
|
30764
|
-
throw error;
|
|
30765
|
-
}
|
|
30766
|
-
}
|
|
30767
|
-
}
|
|
30768
|
-
return options.port;
|
|
30769
|
-
};
|
|
30770
|
-
var portCheckSequence = function* (ports) {
|
|
30771
|
-
if (ports) {
|
|
30772
|
-
yield* ports;
|
|
30773
|
-
}
|
|
30774
|
-
yield 0;
|
|
30775
|
-
};
|
|
30776
|
-
async function getPorts(options) {
|
|
30777
|
-
let ports;
|
|
30778
|
-
let exclude = /* @__PURE__ */ new Set();
|
|
30779
|
-
if (options) {
|
|
30780
|
-
if (options.port) {
|
|
30781
|
-
ports = typeof options.port === "number" ? [options.port] : options.port;
|
|
30782
|
-
}
|
|
30783
|
-
if (options.exclude) {
|
|
30784
|
-
const excludeIterable = options.exclude;
|
|
30785
|
-
if (typeof excludeIterable[Symbol.iterator] !== "function") {
|
|
30786
|
-
throw new TypeError("The `exclude` option must be an iterable.");
|
|
30787
|
-
}
|
|
30788
|
-
for (const element of excludeIterable) {
|
|
30789
|
-
if (typeof element !== "number") {
|
|
30790
|
-
throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");
|
|
30791
|
-
}
|
|
30792
|
-
if (!Number.isSafeInteger(element)) {
|
|
30793
|
-
throw new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);
|
|
30794
|
-
}
|
|
30795
|
-
}
|
|
30796
|
-
exclude = new Set(excludeIterable);
|
|
30797
|
-
}
|
|
30798
|
-
}
|
|
30799
|
-
if (timeout === void 0) {
|
|
30800
|
-
timeout = setTimeout(() => {
|
|
30801
|
-
timeout = void 0;
|
|
30802
|
-
lockedPorts.old = lockedPorts.young;
|
|
30803
|
-
lockedPorts.young = /* @__PURE__ */ new Set();
|
|
30804
|
-
}, releaseOldLockedPortsIntervalMs);
|
|
30805
|
-
if (timeout.unref) {
|
|
30806
|
-
timeout.unref();
|
|
30807
|
-
}
|
|
30808
|
-
}
|
|
30809
|
-
const hosts = getLocalHosts();
|
|
30810
|
-
for (const port of portCheckSequence(ports)) {
|
|
30811
|
-
try {
|
|
30812
|
-
if (exclude.has(port)) {
|
|
30813
|
-
continue;
|
|
30814
|
-
}
|
|
30815
|
-
let availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
30816
|
-
while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
|
|
30817
|
-
if (port !== 0) {
|
|
30818
|
-
throw new Locked(port);
|
|
30819
|
-
}
|
|
30820
|
-
availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
30821
|
-
}
|
|
30822
|
-
lockedPorts.young.add(availablePort);
|
|
30823
|
-
return availablePort;
|
|
30824
|
-
} catch (error) {
|
|
30825
|
-
if (!["EADDRINUSE", "EACCES"].includes(error.code) && !(error instanceof Locked)) {
|
|
30826
|
-
throw error;
|
|
30827
|
-
}
|
|
30828
|
-
}
|
|
30829
|
-
}
|
|
30830
|
-
throw new Error("No available ports found");
|
|
30831
|
-
}
|
|
30832
|
-
function portNumbers(from, to) {
|
|
30833
|
-
if (!Number.isInteger(from) || !Number.isInteger(to)) {
|
|
30834
|
-
throw new TypeError("`from` and `to` must be integer numbers");
|
|
30835
|
-
}
|
|
30836
|
-
if (from < minPort || from > maxPort) {
|
|
30837
|
-
throw new RangeError(`'from' must be between ${minPort} and ${maxPort}`);
|
|
30838
|
-
}
|
|
30839
|
-
if (to < minPort || to > maxPort) {
|
|
30840
|
-
throw new RangeError(`'to' must be between ${minPort} and ${maxPort}`);
|
|
30841
|
-
}
|
|
30842
|
-
if (from > to) {
|
|
30843
|
-
throw new RangeError("`to` must be greater than or equal to `from`");
|
|
30844
|
-
}
|
|
30845
|
-
const generator = function* (from2, to2) {
|
|
30846
|
-
for (let port = from2; port <= to2; port++) {
|
|
30847
|
-
yield port;
|
|
30848
|
-
}
|
|
30849
|
-
};
|
|
30850
|
-
return generator(from, to);
|
|
30851
|
-
}
|
|
30852
|
-
|
|
30853
|
-
// src/utils/adbPath.ts
|
|
30854
|
-
var import_node_fs = require("node:fs");
|
|
30855
|
-
var import_node_path = __toESM(require("node:path"));
|
|
30856
|
-
var import_node_url = require("node:url");
|
|
30857
|
-
var __filename = (0, import_node_url.fileURLToPath)(__importMetaUrl);
|
|
30858
|
-
var __dirname = import_node_path.default.dirname(__filename);
|
|
30859
|
-
function getPlatformDir() {
|
|
30860
|
-
const platform = process.platform;
|
|
30861
|
-
if (platform === "win32") {
|
|
30862
|
-
return "windows";
|
|
30863
|
-
}
|
|
30864
|
-
if (platform === "darwin") {
|
|
30865
|
-
return "darwin";
|
|
30866
|
-
}
|
|
30867
|
-
if (platform === "linux") {
|
|
30868
|
-
return "linux";
|
|
30869
|
-
}
|
|
30870
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
30871
|
-
}
|
|
30872
|
-
function getAdbBinaryName() {
|
|
30873
|
-
if (process.platform === "win32") {
|
|
30874
|
-
return "adb.exe";
|
|
30875
|
-
}
|
|
30876
|
-
return "adb";
|
|
30877
|
-
}
|
|
30878
|
-
function getAdbBinaryPath() {
|
|
30879
|
-
let packageRoot;
|
|
30880
|
-
if (__dirname.includes("dist")) {
|
|
30881
|
-
packageRoot = import_node_path.default.resolve(__dirname, "..", "..");
|
|
30882
|
-
} else {
|
|
30883
|
-
packageRoot = import_node_path.default.resolve(__dirname, "..", "..");
|
|
30884
|
-
}
|
|
30885
|
-
const platformDir = getPlatformDir();
|
|
30886
|
-
const binaryName = getAdbBinaryName();
|
|
30887
|
-
const distPath = import_node_path.default.join(packageRoot, "dist", "resources", "bin", platformDir, binaryName);
|
|
30888
|
-
if ((0, import_node_fs.existsSync)(distPath)) {
|
|
30889
|
-
return distPath;
|
|
30890
|
-
}
|
|
30891
|
-
return null;
|
|
30892
|
-
}
|
|
30893
|
-
|
|
30894
|
-
// src/utils/debug.ts
|
|
30895
|
-
var import_debug = __toESM(require_src2());
|
|
30896
|
-
var logTask = (0, import_debug.default)("adb-kit:task");
|
|
30897
|
-
var logInfo = (0, import_debug.default)("adb-kit:info");
|
|
30898
|
-
var logWarning = (0, import_debug.default)("adb-kit:warning");
|
|
30899
|
-
var logError = (0, import_debug.default)("adb-kit:error");
|
|
30900
|
-
logTask.color = "40";
|
|
30901
|
-
logInfo.color = "45";
|
|
30902
|
-
logWarning.color = "214";
|
|
30903
|
-
logError.color = "160";
|
|
30904
|
-
|
|
30905
30718
|
// ../tool-debug/dist/index.mjs
|
|
30906
30719
|
var __create2 = Object.create;
|
|
30907
30720
|
var __defProp2 = Object.defineProperty;
|
|
@@ -31048,7 +30861,7 @@ var require_ms2 = __commonJS2({
|
|
|
31048
30861
|
}
|
|
31049
30862
|
}
|
|
31050
30863
|
});
|
|
31051
|
-
var
|
|
30864
|
+
var require_common2 = __commonJS2({
|
|
31052
30865
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports2, module2) {
|
|
31053
30866
|
function setup(env2) {
|
|
31054
30867
|
createDebug2.debug = createDebug2;
|
|
@@ -31223,7 +31036,7 @@ var require_common3 = __commonJS2({
|
|
|
31223
31036
|
module2.exports = setup;
|
|
31224
31037
|
}
|
|
31225
31038
|
});
|
|
31226
|
-
var
|
|
31039
|
+
var require_browser2 = __commonJS2({
|
|
31227
31040
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports2, module2) {
|
|
31228
31041
|
exports2.formatArgs = formatArgs;
|
|
31229
31042
|
exports2.save = save;
|
|
@@ -31380,7 +31193,7 @@ var require_browser3 = __commonJS2({
|
|
|
31380
31193
|
} catch (error) {
|
|
31381
31194
|
}
|
|
31382
31195
|
}
|
|
31383
|
-
module2.exports =
|
|
31196
|
+
module2.exports = require_common2()(exports2);
|
|
31384
31197
|
var { formatters } = module2.exports;
|
|
31385
31198
|
formatters.j = function(v) {
|
|
31386
31199
|
try {
|
|
@@ -31502,7 +31315,7 @@ var require_supports_color2 = __commonJS2({
|
|
|
31502
31315
|
};
|
|
31503
31316
|
}
|
|
31504
31317
|
});
|
|
31505
|
-
var
|
|
31318
|
+
var require_node2 = __commonJS2({
|
|
31506
31319
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports2, module2) {
|
|
31507
31320
|
var tty = __require("tty");
|
|
31508
31321
|
var util = __require("util");
|
|
@@ -31662,7 +31475,7 @@ var require_node3 = __commonJS2({
|
|
|
31662
31475
|
debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
31663
31476
|
}
|
|
31664
31477
|
}
|
|
31665
|
-
module2.exports =
|
|
31478
|
+
module2.exports = require_common2()(exports2);
|
|
31666
31479
|
var { formatters } = module2.exports;
|
|
31667
31480
|
formatters.o = function(v) {
|
|
31668
31481
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -31674,37 +31487,224 @@ var require_node3 = __commonJS2({
|
|
|
31674
31487
|
};
|
|
31675
31488
|
}
|
|
31676
31489
|
});
|
|
31677
|
-
var
|
|
31490
|
+
var require_src2 = __commonJS2({
|
|
31678
31491
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports2, module2) {
|
|
31679
31492
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
31680
|
-
module2.exports =
|
|
31493
|
+
module2.exports = require_browser2();
|
|
31681
31494
|
} else {
|
|
31682
|
-
module2.exports =
|
|
31495
|
+
module2.exports = require_node2();
|
|
31683
31496
|
}
|
|
31684
31497
|
}
|
|
31685
31498
|
});
|
|
31686
|
-
var
|
|
31687
|
-
var
|
|
31688
|
-
var
|
|
31689
|
-
var
|
|
31690
|
-
var logDetail = (0,
|
|
31499
|
+
var import_debug = __toESM2(require_src2());
|
|
31500
|
+
var logInfo = (0, import_debug.default)("info");
|
|
31501
|
+
var logTask = (0, import_debug.default)("task");
|
|
31502
|
+
var logError = (0, import_debug.default)("error");
|
|
31503
|
+
var logDetail = (0, import_debug.default)("detail");
|
|
31691
31504
|
function logNamespace(namespace) {
|
|
31692
|
-
|
|
31693
|
-
|
|
31694
|
-
|
|
31695
|
-
logDetail.namespace =
|
|
31696
|
-
|
|
31697
|
-
|
|
31698
|
-
|
|
31505
|
+
logInfo.namespace = `${namespace}:INFO`;
|
|
31506
|
+
logTask.namespace = `${namespace}:TASK`;
|
|
31507
|
+
logError.namespace = `${namespace}:ERROR`;
|
|
31508
|
+
logDetail.namespace = `${namespace}:DETAIL`;
|
|
31509
|
+
logInfo.color = "45";
|
|
31510
|
+
logTask.color = "40";
|
|
31511
|
+
logError.color = "160";
|
|
31699
31512
|
logDetail.color = "240";
|
|
31700
31513
|
}
|
|
31701
31514
|
|
|
31515
|
+
// ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
31516
|
+
var import_node_net = __toESM(require("node:net"), 1);
|
|
31517
|
+
var import_node_os = __toESM(require("node:os"), 1);
|
|
31518
|
+
var Locked = class extends Error {
|
|
31519
|
+
constructor(port) {
|
|
31520
|
+
super(`${port} is locked`);
|
|
31521
|
+
}
|
|
31522
|
+
};
|
|
31523
|
+
var lockedPorts = {
|
|
31524
|
+
old: /* @__PURE__ */ new Set(),
|
|
31525
|
+
young: /* @__PURE__ */ new Set()
|
|
31526
|
+
};
|
|
31527
|
+
var releaseOldLockedPortsIntervalMs = 1e3 * 15;
|
|
31528
|
+
var minPort = 1024;
|
|
31529
|
+
var maxPort = 65535;
|
|
31530
|
+
var timeout;
|
|
31531
|
+
var getLocalHosts = () => {
|
|
31532
|
+
const interfaces = import_node_os.default.networkInterfaces();
|
|
31533
|
+
const results = /* @__PURE__ */ new Set([void 0, "0.0.0.0"]);
|
|
31534
|
+
for (const _interface of Object.values(interfaces)) {
|
|
31535
|
+
for (const config of _interface) {
|
|
31536
|
+
results.add(config.address);
|
|
31537
|
+
}
|
|
31538
|
+
}
|
|
31539
|
+
return results;
|
|
31540
|
+
};
|
|
31541
|
+
var checkAvailablePort = (options) => new Promise((resolve, reject) => {
|
|
31542
|
+
const server = import_node_net.default.createServer();
|
|
31543
|
+
server.unref();
|
|
31544
|
+
server.on("error", reject);
|
|
31545
|
+
server.listen(options, () => {
|
|
31546
|
+
const { port } = server.address();
|
|
31547
|
+
server.close(() => {
|
|
31548
|
+
resolve(port);
|
|
31549
|
+
});
|
|
31550
|
+
});
|
|
31551
|
+
});
|
|
31552
|
+
var getAvailablePort = async (options, hosts) => {
|
|
31553
|
+
if (options.host || options.port === 0) {
|
|
31554
|
+
return checkAvailablePort(options);
|
|
31555
|
+
}
|
|
31556
|
+
for (const host of hosts) {
|
|
31557
|
+
try {
|
|
31558
|
+
await checkAvailablePort({ port: options.port, host });
|
|
31559
|
+
} catch (error) {
|
|
31560
|
+
if (!["EADDRNOTAVAIL", "EINVAL"].includes(error.code)) {
|
|
31561
|
+
throw error;
|
|
31562
|
+
}
|
|
31563
|
+
}
|
|
31564
|
+
}
|
|
31565
|
+
return options.port;
|
|
31566
|
+
};
|
|
31567
|
+
var portCheckSequence = function* (ports) {
|
|
31568
|
+
if (ports) {
|
|
31569
|
+
yield* ports;
|
|
31570
|
+
}
|
|
31571
|
+
yield 0;
|
|
31572
|
+
};
|
|
31573
|
+
async function getPorts(options) {
|
|
31574
|
+
let ports;
|
|
31575
|
+
let exclude = /* @__PURE__ */ new Set();
|
|
31576
|
+
if (options) {
|
|
31577
|
+
if (options.port) {
|
|
31578
|
+
ports = typeof options.port === "number" ? [options.port] : options.port;
|
|
31579
|
+
}
|
|
31580
|
+
if (options.exclude) {
|
|
31581
|
+
const excludeIterable = options.exclude;
|
|
31582
|
+
if (typeof excludeIterable[Symbol.iterator] !== "function") {
|
|
31583
|
+
throw new TypeError("The `exclude` option must be an iterable.");
|
|
31584
|
+
}
|
|
31585
|
+
for (const element of excludeIterable) {
|
|
31586
|
+
if (typeof element !== "number") {
|
|
31587
|
+
throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");
|
|
31588
|
+
}
|
|
31589
|
+
if (!Number.isSafeInteger(element)) {
|
|
31590
|
+
throw new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);
|
|
31591
|
+
}
|
|
31592
|
+
}
|
|
31593
|
+
exclude = new Set(excludeIterable);
|
|
31594
|
+
}
|
|
31595
|
+
}
|
|
31596
|
+
if (timeout === void 0) {
|
|
31597
|
+
timeout = setTimeout(() => {
|
|
31598
|
+
timeout = void 0;
|
|
31599
|
+
lockedPorts.old = lockedPorts.young;
|
|
31600
|
+
lockedPorts.young = /* @__PURE__ */ new Set();
|
|
31601
|
+
}, releaseOldLockedPortsIntervalMs);
|
|
31602
|
+
if (timeout.unref) {
|
|
31603
|
+
timeout.unref();
|
|
31604
|
+
}
|
|
31605
|
+
}
|
|
31606
|
+
const hosts = getLocalHosts();
|
|
31607
|
+
for (const port of portCheckSequence(ports)) {
|
|
31608
|
+
try {
|
|
31609
|
+
if (exclude.has(port)) {
|
|
31610
|
+
continue;
|
|
31611
|
+
}
|
|
31612
|
+
let availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
31613
|
+
while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
|
|
31614
|
+
if (port !== 0) {
|
|
31615
|
+
throw new Locked(port);
|
|
31616
|
+
}
|
|
31617
|
+
availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
31618
|
+
}
|
|
31619
|
+
lockedPorts.young.add(availablePort);
|
|
31620
|
+
return availablePort;
|
|
31621
|
+
} catch (error) {
|
|
31622
|
+
if (!["EADDRINUSE", "EACCES"].includes(error.code) && !(error instanceof Locked)) {
|
|
31623
|
+
throw error;
|
|
31624
|
+
}
|
|
31625
|
+
}
|
|
31626
|
+
}
|
|
31627
|
+
throw new Error("No available ports found");
|
|
31628
|
+
}
|
|
31629
|
+
function portNumbers(from, to) {
|
|
31630
|
+
if (!Number.isInteger(from) || !Number.isInteger(to)) {
|
|
31631
|
+
throw new TypeError("`from` and `to` must be integer numbers");
|
|
31632
|
+
}
|
|
31633
|
+
if (from < minPort || from > maxPort) {
|
|
31634
|
+
throw new RangeError(`'from' must be between ${minPort} and ${maxPort}`);
|
|
31635
|
+
}
|
|
31636
|
+
if (to < minPort || to > maxPort) {
|
|
31637
|
+
throw new RangeError(`'to' must be between ${minPort} and ${maxPort}`);
|
|
31638
|
+
}
|
|
31639
|
+
if (from > to) {
|
|
31640
|
+
throw new RangeError("`to` must be greater than or equal to `from`");
|
|
31641
|
+
}
|
|
31642
|
+
const generator = function* (from2, to2) {
|
|
31643
|
+
for (let port = from2; port <= to2; port++) {
|
|
31644
|
+
yield port;
|
|
31645
|
+
}
|
|
31646
|
+
};
|
|
31647
|
+
return generator(from, to);
|
|
31648
|
+
}
|
|
31649
|
+
|
|
31650
|
+
// src/utils/adbPath.ts
|
|
31651
|
+
var import_node_fs = require("node:fs");
|
|
31652
|
+
var import_node_path = __toESM(require("node:path"));
|
|
31653
|
+
var import_node_url = require("node:url");
|
|
31654
|
+
var __filename = (0, import_node_url.fileURLToPath)(__importMetaUrl);
|
|
31655
|
+
var __dirname = import_node_path.default.dirname(__filename);
|
|
31656
|
+
function getPlatformDir() {
|
|
31657
|
+
const platform = process.platform;
|
|
31658
|
+
if (platform === "win32") {
|
|
31659
|
+
return "windows";
|
|
31660
|
+
}
|
|
31661
|
+
if (platform === "darwin") {
|
|
31662
|
+
return "darwin";
|
|
31663
|
+
}
|
|
31664
|
+
if (platform === "linux") {
|
|
31665
|
+
return "linux";
|
|
31666
|
+
}
|
|
31667
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
31668
|
+
}
|
|
31669
|
+
function getAdbBinaryName() {
|
|
31670
|
+
if (process.platform === "win32") {
|
|
31671
|
+
return "adb.exe";
|
|
31672
|
+
}
|
|
31673
|
+
return "adb";
|
|
31674
|
+
}
|
|
31675
|
+
function getAdbBinaryPath() {
|
|
31676
|
+
let packageRoot;
|
|
31677
|
+
if (__dirname.includes("dist")) {
|
|
31678
|
+
packageRoot = import_node_path.default.resolve(__dirname, "..", "..");
|
|
31679
|
+
} else {
|
|
31680
|
+
packageRoot = import_node_path.default.resolve(__dirname, "..", "..");
|
|
31681
|
+
}
|
|
31682
|
+
const platformDir = getPlatformDir();
|
|
31683
|
+
const binaryName = getAdbBinaryName();
|
|
31684
|
+
const distPath = import_node_path.default.join(packageRoot, "dist", "resources", "bin", platformDir, binaryName);
|
|
31685
|
+
if ((0, import_node_fs.existsSync)(distPath)) {
|
|
31686
|
+
return distPath;
|
|
31687
|
+
}
|
|
31688
|
+
return null;
|
|
31689
|
+
}
|
|
31690
|
+
|
|
31691
|
+
// src/utils/debug.ts
|
|
31692
|
+
var import_debug2 = __toESM(require_src3());
|
|
31693
|
+
var logTask2 = (0, import_debug2.default)("adb-kit:task");
|
|
31694
|
+
var logInfo2 = (0, import_debug2.default)("adb-kit:info");
|
|
31695
|
+
var logWarning = (0, import_debug2.default)("adb-kit:warning");
|
|
31696
|
+
var logError2 = (0, import_debug2.default)("adb-kit:error");
|
|
31697
|
+
logTask2.color = "40";
|
|
31698
|
+
logInfo2.color = "45";
|
|
31699
|
+
logWarning.color = "214";
|
|
31700
|
+
logError2.color = "160";
|
|
31701
|
+
|
|
31702
31702
|
// src/logic/adbDeviceKit.ts
|
|
31703
31703
|
function ensureAdbPathFromResources() {
|
|
31704
31704
|
const adbPath = getAdbBinaryPath();
|
|
31705
31705
|
if (adbPath && !process.env.ADB_PATH) {
|
|
31706
31706
|
process.env.ADB_PATH = adbPath;
|
|
31707
|
-
|
|
31707
|
+
logInfo2(`Using ADB from resources: ${adbPath}`);
|
|
31708
31708
|
}
|
|
31709
31709
|
}
|
|
31710
31710
|
var deviceProps = {
|
|
@@ -31743,7 +31743,7 @@ var AdbDeviceKit = class {
|
|
|
31743
31743
|
bin: process.env.ADB_PATH ?? getAdbBinaryPath() ?? "."
|
|
31744
31744
|
});
|
|
31745
31745
|
this.deviceId = deviceId.split("\\").pop() ?? deviceId;
|
|
31746
|
-
|
|
31746
|
+
logInfo2(`Device ID: ${this.deviceId}`);
|
|
31747
31747
|
this.device = this.client.getDevice(this.deviceId);
|
|
31748
31748
|
}
|
|
31749
31749
|
client;
|
|
@@ -31756,16 +31756,16 @@ var AdbDeviceKit = class {
|
|
|
31756
31756
|
}
|
|
31757
31757
|
async getProperty(adbDevice, property) {
|
|
31758
31758
|
try {
|
|
31759
|
-
|
|
31759
|
+
logTask2(`Getting property ${property} for device ${this.deviceId}`);
|
|
31760
31760
|
const stream = await adbDevice.shell(`getprop ${deviceProps[property]}`);
|
|
31761
|
-
|
|
31761
|
+
logTask2(`Stream: ${stream}`);
|
|
31762
31762
|
const chunks = [];
|
|
31763
31763
|
for await (const chunk of stream) {
|
|
31764
31764
|
chunks.push(chunk);
|
|
31765
31765
|
}
|
|
31766
31766
|
return Buffer.concat(chunks).toString().trim();
|
|
31767
31767
|
} catch (error) {
|
|
31768
|
-
|
|
31768
|
+
logError2(`Error getting property ${property} for device ${this.deviceId}: ${error}`);
|
|
31769
31769
|
return "";
|
|
31770
31770
|
}
|
|
31771
31771
|
}
|
|
@@ -31773,22 +31773,22 @@ var AdbDeviceKit = class {
|
|
|
31773
31773
|
return this.device.getProperties();
|
|
31774
31774
|
}
|
|
31775
31775
|
async getDeviceProperties(properties) {
|
|
31776
|
-
|
|
31776
|
+
logTask2(`Getting properties ${properties.join(", ")} for device ${this.deviceId}`);
|
|
31777
31777
|
const propertiesValues = await Promise.all(
|
|
31778
31778
|
properties.map((property) => this.getProperty(this.device, property))
|
|
31779
31779
|
);
|
|
31780
31780
|
return propertiesValues;
|
|
31781
31781
|
}
|
|
31782
31782
|
async installApp(appPath) {
|
|
31783
|
-
|
|
31783
|
+
logTask2(`Installing app ${appPath} on device ${this.deviceId}`);
|
|
31784
31784
|
await this.device.install(appPath);
|
|
31785
31785
|
}
|
|
31786
31786
|
async uninstallApp(packageName) {
|
|
31787
|
-
|
|
31787
|
+
logTask2(`Uninstalling app ${packageName} on device ${this.deviceId}`);
|
|
31788
31788
|
await this.device.uninstall(packageName);
|
|
31789
31789
|
}
|
|
31790
31790
|
async isAppInstalled(packageName) {
|
|
31791
|
-
|
|
31791
|
+
logTask2(`Checking if app ${packageName} is installed on device ${this.deviceId}`);
|
|
31792
31792
|
return await this.device.isInstalled(packageName);
|
|
31793
31793
|
}
|
|
31794
31794
|
/**
|
|
@@ -31811,12 +31811,12 @@ var AdbDeviceKit = class {
|
|
|
31811
31811
|
const tracker = await this.client.trackDevices();
|
|
31812
31812
|
return new Promise((resolve, reject) => {
|
|
31813
31813
|
const timeoutId = setTimeout(() => {
|
|
31814
|
-
|
|
31814
|
+
logError2("Timeout waiting for USB debugging");
|
|
31815
31815
|
reject(new Error("Timeout waiting for USB debugging"));
|
|
31816
31816
|
}, timeout2);
|
|
31817
31817
|
tracker.on("remove", (_) => {
|
|
31818
31818
|
clearTimeout(timeoutId);
|
|
31819
|
-
|
|
31819
|
+
logError2("Device removed from tracker");
|
|
31820
31820
|
});
|
|
31821
31821
|
tracker.on("add", (device) => {
|
|
31822
31822
|
if (device.type === "device") {
|