@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.mjs
CHANGED
|
@@ -30173,7 +30173,7 @@ var require_dist = __commonJS({
|
|
|
30173
30173
|
});
|
|
30174
30174
|
|
|
30175
30175
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
|
|
30176
|
-
var
|
|
30176
|
+
var require_common3 = __commonJS({
|
|
30177
30177
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports2, module2) {
|
|
30178
30178
|
function setup(env2) {
|
|
30179
30179
|
createDebug.debug = createDebug;
|
|
@@ -30350,7 +30350,7 @@ var require_common2 = __commonJS({
|
|
|
30350
30350
|
});
|
|
30351
30351
|
|
|
30352
30352
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
|
|
30353
|
-
var
|
|
30353
|
+
var require_browser3 = __commonJS({
|
|
30354
30354
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports2, module2) {
|
|
30355
30355
|
exports2.formatArgs = formatArgs;
|
|
30356
30356
|
exports2.save = save;
|
|
@@ -30507,7 +30507,7 @@ var require_browser2 = __commonJS({
|
|
|
30507
30507
|
} catch (error) {
|
|
30508
30508
|
}
|
|
30509
30509
|
}
|
|
30510
|
-
module2.exports =
|
|
30510
|
+
module2.exports = require_common3()(exports2);
|
|
30511
30511
|
var { formatters } = module2.exports;
|
|
30512
30512
|
formatters.j = function(v) {
|
|
30513
30513
|
try {
|
|
@@ -30520,7 +30520,7 @@ var require_browser2 = __commonJS({
|
|
|
30520
30520
|
});
|
|
30521
30521
|
|
|
30522
30522
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
|
|
30523
|
-
var
|
|
30523
|
+
var require_node3 = __commonJS({
|
|
30524
30524
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports2, module2) {
|
|
30525
30525
|
var tty = __require("tty");
|
|
30526
30526
|
var util = __require("util");
|
|
@@ -30680,7 +30680,7 @@ var require_node2 = __commonJS({
|
|
|
30680
30680
|
debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
30681
30681
|
}
|
|
30682
30682
|
}
|
|
30683
|
-
module2.exports =
|
|
30683
|
+
module2.exports = require_common3()(exports2);
|
|
30684
30684
|
var { formatters } = module2.exports;
|
|
30685
30685
|
formatters.o = function(v) {
|
|
30686
30686
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -30694,12 +30694,12 @@ var require_node2 = __commonJS({
|
|
|
30694
30694
|
});
|
|
30695
30695
|
|
|
30696
30696
|
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
|
|
30697
|
-
var
|
|
30697
|
+
var require_src3 = __commonJS({
|
|
30698
30698
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports2, module2) {
|
|
30699
30699
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
30700
|
-
module2.exports =
|
|
30700
|
+
module2.exports = require_browser3();
|
|
30701
30701
|
} else {
|
|
30702
|
-
module2.exports =
|
|
30702
|
+
module2.exports = require_node3();
|
|
30703
30703
|
}
|
|
30704
30704
|
}
|
|
30705
30705
|
});
|
|
@@ -30707,193 +30707,6 @@ var require_src2 = __commonJS({
|
|
|
30707
30707
|
// src/logic/adbDeviceKit.ts
|
|
30708
30708
|
var adbkit = __toESM(require_dist());
|
|
30709
30709
|
|
|
30710
|
-
// ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
30711
|
-
import net from "node:net";
|
|
30712
|
-
import os from "node:os";
|
|
30713
|
-
var Locked = class extends Error {
|
|
30714
|
-
constructor(port) {
|
|
30715
|
-
super(`${port} is locked`);
|
|
30716
|
-
}
|
|
30717
|
-
};
|
|
30718
|
-
var lockedPorts = {
|
|
30719
|
-
old: /* @__PURE__ */ new Set(),
|
|
30720
|
-
young: /* @__PURE__ */ new Set()
|
|
30721
|
-
};
|
|
30722
|
-
var releaseOldLockedPortsIntervalMs = 1e3 * 15;
|
|
30723
|
-
var minPort = 1024;
|
|
30724
|
-
var maxPort = 65535;
|
|
30725
|
-
var timeout;
|
|
30726
|
-
var getLocalHosts = () => {
|
|
30727
|
-
const interfaces = os.networkInterfaces();
|
|
30728
|
-
const results = /* @__PURE__ */ new Set([void 0, "0.0.0.0"]);
|
|
30729
|
-
for (const _interface of Object.values(interfaces)) {
|
|
30730
|
-
for (const config of _interface) {
|
|
30731
|
-
results.add(config.address);
|
|
30732
|
-
}
|
|
30733
|
-
}
|
|
30734
|
-
return results;
|
|
30735
|
-
};
|
|
30736
|
-
var checkAvailablePort = (options) => new Promise((resolve, reject) => {
|
|
30737
|
-
const server = net.createServer();
|
|
30738
|
-
server.unref();
|
|
30739
|
-
server.on("error", reject);
|
|
30740
|
-
server.listen(options, () => {
|
|
30741
|
-
const { port } = server.address();
|
|
30742
|
-
server.close(() => {
|
|
30743
|
-
resolve(port);
|
|
30744
|
-
});
|
|
30745
|
-
});
|
|
30746
|
-
});
|
|
30747
|
-
var getAvailablePort = async (options, hosts) => {
|
|
30748
|
-
if (options.host || options.port === 0) {
|
|
30749
|
-
return checkAvailablePort(options);
|
|
30750
|
-
}
|
|
30751
|
-
for (const host of hosts) {
|
|
30752
|
-
try {
|
|
30753
|
-
await checkAvailablePort({ port: options.port, host });
|
|
30754
|
-
} catch (error) {
|
|
30755
|
-
if (!["EADDRNOTAVAIL", "EINVAL"].includes(error.code)) {
|
|
30756
|
-
throw error;
|
|
30757
|
-
}
|
|
30758
|
-
}
|
|
30759
|
-
}
|
|
30760
|
-
return options.port;
|
|
30761
|
-
};
|
|
30762
|
-
var portCheckSequence = function* (ports) {
|
|
30763
|
-
if (ports) {
|
|
30764
|
-
yield* ports;
|
|
30765
|
-
}
|
|
30766
|
-
yield 0;
|
|
30767
|
-
};
|
|
30768
|
-
async function getPorts(options) {
|
|
30769
|
-
let ports;
|
|
30770
|
-
let exclude = /* @__PURE__ */ new Set();
|
|
30771
|
-
if (options) {
|
|
30772
|
-
if (options.port) {
|
|
30773
|
-
ports = typeof options.port === "number" ? [options.port] : options.port;
|
|
30774
|
-
}
|
|
30775
|
-
if (options.exclude) {
|
|
30776
|
-
const excludeIterable = options.exclude;
|
|
30777
|
-
if (typeof excludeIterable[Symbol.iterator] !== "function") {
|
|
30778
|
-
throw new TypeError("The `exclude` option must be an iterable.");
|
|
30779
|
-
}
|
|
30780
|
-
for (const element of excludeIterable) {
|
|
30781
|
-
if (typeof element !== "number") {
|
|
30782
|
-
throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");
|
|
30783
|
-
}
|
|
30784
|
-
if (!Number.isSafeInteger(element)) {
|
|
30785
|
-
throw new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);
|
|
30786
|
-
}
|
|
30787
|
-
}
|
|
30788
|
-
exclude = new Set(excludeIterable);
|
|
30789
|
-
}
|
|
30790
|
-
}
|
|
30791
|
-
if (timeout === void 0) {
|
|
30792
|
-
timeout = setTimeout(() => {
|
|
30793
|
-
timeout = void 0;
|
|
30794
|
-
lockedPorts.old = lockedPorts.young;
|
|
30795
|
-
lockedPorts.young = /* @__PURE__ */ new Set();
|
|
30796
|
-
}, releaseOldLockedPortsIntervalMs);
|
|
30797
|
-
if (timeout.unref) {
|
|
30798
|
-
timeout.unref();
|
|
30799
|
-
}
|
|
30800
|
-
}
|
|
30801
|
-
const hosts = getLocalHosts();
|
|
30802
|
-
for (const port of portCheckSequence(ports)) {
|
|
30803
|
-
try {
|
|
30804
|
-
if (exclude.has(port)) {
|
|
30805
|
-
continue;
|
|
30806
|
-
}
|
|
30807
|
-
let availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
30808
|
-
while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
|
|
30809
|
-
if (port !== 0) {
|
|
30810
|
-
throw new Locked(port);
|
|
30811
|
-
}
|
|
30812
|
-
availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
30813
|
-
}
|
|
30814
|
-
lockedPorts.young.add(availablePort);
|
|
30815
|
-
return availablePort;
|
|
30816
|
-
} catch (error) {
|
|
30817
|
-
if (!["EADDRINUSE", "EACCES"].includes(error.code) && !(error instanceof Locked)) {
|
|
30818
|
-
throw error;
|
|
30819
|
-
}
|
|
30820
|
-
}
|
|
30821
|
-
}
|
|
30822
|
-
throw new Error("No available ports found");
|
|
30823
|
-
}
|
|
30824
|
-
function portNumbers(from, to) {
|
|
30825
|
-
if (!Number.isInteger(from) || !Number.isInteger(to)) {
|
|
30826
|
-
throw new TypeError("`from` and `to` must be integer numbers");
|
|
30827
|
-
}
|
|
30828
|
-
if (from < minPort || from > maxPort) {
|
|
30829
|
-
throw new RangeError(`'from' must be between ${minPort} and ${maxPort}`);
|
|
30830
|
-
}
|
|
30831
|
-
if (to < minPort || to > maxPort) {
|
|
30832
|
-
throw new RangeError(`'to' must be between ${minPort} and ${maxPort}`);
|
|
30833
|
-
}
|
|
30834
|
-
if (from > to) {
|
|
30835
|
-
throw new RangeError("`to` must be greater than or equal to `from`");
|
|
30836
|
-
}
|
|
30837
|
-
const generator = function* (from2, to2) {
|
|
30838
|
-
for (let port = from2; port <= to2; port++) {
|
|
30839
|
-
yield port;
|
|
30840
|
-
}
|
|
30841
|
-
};
|
|
30842
|
-
return generator(from, to);
|
|
30843
|
-
}
|
|
30844
|
-
|
|
30845
|
-
// src/utils/adbPath.ts
|
|
30846
|
-
import { existsSync } from "node:fs";
|
|
30847
|
-
import path from "node:path";
|
|
30848
|
-
import { fileURLToPath } from "node:url";
|
|
30849
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
30850
|
-
var __dirname = path.dirname(__filename);
|
|
30851
|
-
function getPlatformDir() {
|
|
30852
|
-
const platform = process.platform;
|
|
30853
|
-
if (platform === "win32") {
|
|
30854
|
-
return "windows";
|
|
30855
|
-
}
|
|
30856
|
-
if (platform === "darwin") {
|
|
30857
|
-
return "darwin";
|
|
30858
|
-
}
|
|
30859
|
-
if (platform === "linux") {
|
|
30860
|
-
return "linux";
|
|
30861
|
-
}
|
|
30862
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
30863
|
-
}
|
|
30864
|
-
function getAdbBinaryName() {
|
|
30865
|
-
if (process.platform === "win32") {
|
|
30866
|
-
return "adb.exe";
|
|
30867
|
-
}
|
|
30868
|
-
return "adb";
|
|
30869
|
-
}
|
|
30870
|
-
function getAdbBinaryPath() {
|
|
30871
|
-
let packageRoot;
|
|
30872
|
-
if (__dirname.includes("dist")) {
|
|
30873
|
-
packageRoot = path.resolve(__dirname, "..", "..");
|
|
30874
|
-
} else {
|
|
30875
|
-
packageRoot = path.resolve(__dirname, "..", "..");
|
|
30876
|
-
}
|
|
30877
|
-
const platformDir = getPlatformDir();
|
|
30878
|
-
const binaryName = getAdbBinaryName();
|
|
30879
|
-
const distPath = path.join(packageRoot, "dist", "resources", "bin", platformDir, binaryName);
|
|
30880
|
-
if (existsSync(distPath)) {
|
|
30881
|
-
return distPath;
|
|
30882
|
-
}
|
|
30883
|
-
return null;
|
|
30884
|
-
}
|
|
30885
|
-
|
|
30886
|
-
// src/utils/debug.ts
|
|
30887
|
-
var import_debug = __toESM(require_src2());
|
|
30888
|
-
var logTask = (0, import_debug.default)("adb-kit:task");
|
|
30889
|
-
var logInfo = (0, import_debug.default)("adb-kit:info");
|
|
30890
|
-
var logWarning = (0, import_debug.default)("adb-kit:warning");
|
|
30891
|
-
var logError = (0, import_debug.default)("adb-kit:error");
|
|
30892
|
-
logTask.color = "40";
|
|
30893
|
-
logInfo.color = "45";
|
|
30894
|
-
logWarning.color = "214";
|
|
30895
|
-
logError.color = "160";
|
|
30896
|
-
|
|
30897
30710
|
// ../tool-debug/dist/index.mjs
|
|
30898
30711
|
var __create2 = Object.create;
|
|
30899
30712
|
var __defProp2 = Object.defineProperty;
|
|
@@ -31040,7 +30853,7 @@ var require_ms2 = __commonJS2({
|
|
|
31040
30853
|
}
|
|
31041
30854
|
}
|
|
31042
30855
|
});
|
|
31043
|
-
var
|
|
30856
|
+
var require_common2 = __commonJS2({
|
|
31044
30857
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports2, module2) {
|
|
31045
30858
|
function setup(env2) {
|
|
31046
30859
|
createDebug2.debug = createDebug2;
|
|
@@ -31215,7 +31028,7 @@ var require_common3 = __commonJS2({
|
|
|
31215
31028
|
module2.exports = setup;
|
|
31216
31029
|
}
|
|
31217
31030
|
});
|
|
31218
|
-
var
|
|
31031
|
+
var require_browser2 = __commonJS2({
|
|
31219
31032
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports2, module2) {
|
|
31220
31033
|
exports2.formatArgs = formatArgs;
|
|
31221
31034
|
exports2.save = save;
|
|
@@ -31372,7 +31185,7 @@ var require_browser3 = __commonJS2({
|
|
|
31372
31185
|
} catch (error) {
|
|
31373
31186
|
}
|
|
31374
31187
|
}
|
|
31375
|
-
module2.exports =
|
|
31188
|
+
module2.exports = require_common2()(exports2);
|
|
31376
31189
|
var { formatters } = module2.exports;
|
|
31377
31190
|
formatters.j = function(v) {
|
|
31378
31191
|
try {
|
|
@@ -31494,7 +31307,7 @@ var require_supports_color2 = __commonJS2({
|
|
|
31494
31307
|
};
|
|
31495
31308
|
}
|
|
31496
31309
|
});
|
|
31497
|
-
var
|
|
31310
|
+
var require_node2 = __commonJS2({
|
|
31498
31311
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports2, module2) {
|
|
31499
31312
|
var tty = __require2("tty");
|
|
31500
31313
|
var util = __require2("util");
|
|
@@ -31654,7 +31467,7 @@ var require_node3 = __commonJS2({
|
|
|
31654
31467
|
debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
31655
31468
|
}
|
|
31656
31469
|
}
|
|
31657
|
-
module2.exports =
|
|
31470
|
+
module2.exports = require_common2()(exports2);
|
|
31658
31471
|
var { formatters } = module2.exports;
|
|
31659
31472
|
formatters.o = function(v) {
|
|
31660
31473
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -31666,37 +31479,224 @@ var require_node3 = __commonJS2({
|
|
|
31666
31479
|
};
|
|
31667
31480
|
}
|
|
31668
31481
|
});
|
|
31669
|
-
var
|
|
31482
|
+
var require_src2 = __commonJS2({
|
|
31670
31483
|
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports2, module2) {
|
|
31671
31484
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
31672
|
-
module2.exports =
|
|
31485
|
+
module2.exports = require_browser2();
|
|
31673
31486
|
} else {
|
|
31674
|
-
module2.exports =
|
|
31487
|
+
module2.exports = require_node2();
|
|
31675
31488
|
}
|
|
31676
31489
|
}
|
|
31677
31490
|
});
|
|
31678
|
-
var
|
|
31679
|
-
var
|
|
31680
|
-
var
|
|
31681
|
-
var
|
|
31682
|
-
var logDetail = (0,
|
|
31491
|
+
var import_debug = __toESM2(require_src2());
|
|
31492
|
+
var logInfo = (0, import_debug.default)("info");
|
|
31493
|
+
var logTask = (0, import_debug.default)("task");
|
|
31494
|
+
var logError = (0, import_debug.default)("error");
|
|
31495
|
+
var logDetail = (0, import_debug.default)("detail");
|
|
31683
31496
|
function logNamespace(namespace) {
|
|
31684
|
-
|
|
31685
|
-
|
|
31686
|
-
|
|
31687
|
-
logDetail.namespace =
|
|
31688
|
-
|
|
31689
|
-
|
|
31690
|
-
|
|
31497
|
+
logInfo.namespace = `${namespace}:INFO`;
|
|
31498
|
+
logTask.namespace = `${namespace}:TASK`;
|
|
31499
|
+
logError.namespace = `${namespace}:ERROR`;
|
|
31500
|
+
logDetail.namespace = `${namespace}:DETAIL`;
|
|
31501
|
+
logInfo.color = "45";
|
|
31502
|
+
logTask.color = "40";
|
|
31503
|
+
logError.color = "160";
|
|
31691
31504
|
logDetail.color = "240";
|
|
31692
31505
|
}
|
|
31693
31506
|
|
|
31507
|
+
// ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
31508
|
+
import net from "node:net";
|
|
31509
|
+
import os from "node:os";
|
|
31510
|
+
var Locked = class extends Error {
|
|
31511
|
+
constructor(port) {
|
|
31512
|
+
super(`${port} is locked`);
|
|
31513
|
+
}
|
|
31514
|
+
};
|
|
31515
|
+
var lockedPorts = {
|
|
31516
|
+
old: /* @__PURE__ */ new Set(),
|
|
31517
|
+
young: /* @__PURE__ */ new Set()
|
|
31518
|
+
};
|
|
31519
|
+
var releaseOldLockedPortsIntervalMs = 1e3 * 15;
|
|
31520
|
+
var minPort = 1024;
|
|
31521
|
+
var maxPort = 65535;
|
|
31522
|
+
var timeout;
|
|
31523
|
+
var getLocalHosts = () => {
|
|
31524
|
+
const interfaces = os.networkInterfaces();
|
|
31525
|
+
const results = /* @__PURE__ */ new Set([void 0, "0.0.0.0"]);
|
|
31526
|
+
for (const _interface of Object.values(interfaces)) {
|
|
31527
|
+
for (const config of _interface) {
|
|
31528
|
+
results.add(config.address);
|
|
31529
|
+
}
|
|
31530
|
+
}
|
|
31531
|
+
return results;
|
|
31532
|
+
};
|
|
31533
|
+
var checkAvailablePort = (options) => new Promise((resolve, reject) => {
|
|
31534
|
+
const server = net.createServer();
|
|
31535
|
+
server.unref();
|
|
31536
|
+
server.on("error", reject);
|
|
31537
|
+
server.listen(options, () => {
|
|
31538
|
+
const { port } = server.address();
|
|
31539
|
+
server.close(() => {
|
|
31540
|
+
resolve(port);
|
|
31541
|
+
});
|
|
31542
|
+
});
|
|
31543
|
+
});
|
|
31544
|
+
var getAvailablePort = async (options, hosts) => {
|
|
31545
|
+
if (options.host || options.port === 0) {
|
|
31546
|
+
return checkAvailablePort(options);
|
|
31547
|
+
}
|
|
31548
|
+
for (const host of hosts) {
|
|
31549
|
+
try {
|
|
31550
|
+
await checkAvailablePort({ port: options.port, host });
|
|
31551
|
+
} catch (error) {
|
|
31552
|
+
if (!["EADDRNOTAVAIL", "EINVAL"].includes(error.code)) {
|
|
31553
|
+
throw error;
|
|
31554
|
+
}
|
|
31555
|
+
}
|
|
31556
|
+
}
|
|
31557
|
+
return options.port;
|
|
31558
|
+
};
|
|
31559
|
+
var portCheckSequence = function* (ports) {
|
|
31560
|
+
if (ports) {
|
|
31561
|
+
yield* ports;
|
|
31562
|
+
}
|
|
31563
|
+
yield 0;
|
|
31564
|
+
};
|
|
31565
|
+
async function getPorts(options) {
|
|
31566
|
+
let ports;
|
|
31567
|
+
let exclude = /* @__PURE__ */ new Set();
|
|
31568
|
+
if (options) {
|
|
31569
|
+
if (options.port) {
|
|
31570
|
+
ports = typeof options.port === "number" ? [options.port] : options.port;
|
|
31571
|
+
}
|
|
31572
|
+
if (options.exclude) {
|
|
31573
|
+
const excludeIterable = options.exclude;
|
|
31574
|
+
if (typeof excludeIterable[Symbol.iterator] !== "function") {
|
|
31575
|
+
throw new TypeError("The `exclude` option must be an iterable.");
|
|
31576
|
+
}
|
|
31577
|
+
for (const element of excludeIterable) {
|
|
31578
|
+
if (typeof element !== "number") {
|
|
31579
|
+
throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");
|
|
31580
|
+
}
|
|
31581
|
+
if (!Number.isSafeInteger(element)) {
|
|
31582
|
+
throw new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);
|
|
31583
|
+
}
|
|
31584
|
+
}
|
|
31585
|
+
exclude = new Set(excludeIterable);
|
|
31586
|
+
}
|
|
31587
|
+
}
|
|
31588
|
+
if (timeout === void 0) {
|
|
31589
|
+
timeout = setTimeout(() => {
|
|
31590
|
+
timeout = void 0;
|
|
31591
|
+
lockedPorts.old = lockedPorts.young;
|
|
31592
|
+
lockedPorts.young = /* @__PURE__ */ new Set();
|
|
31593
|
+
}, releaseOldLockedPortsIntervalMs);
|
|
31594
|
+
if (timeout.unref) {
|
|
31595
|
+
timeout.unref();
|
|
31596
|
+
}
|
|
31597
|
+
}
|
|
31598
|
+
const hosts = getLocalHosts();
|
|
31599
|
+
for (const port of portCheckSequence(ports)) {
|
|
31600
|
+
try {
|
|
31601
|
+
if (exclude.has(port)) {
|
|
31602
|
+
continue;
|
|
31603
|
+
}
|
|
31604
|
+
let availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
31605
|
+
while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
|
|
31606
|
+
if (port !== 0) {
|
|
31607
|
+
throw new Locked(port);
|
|
31608
|
+
}
|
|
31609
|
+
availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
31610
|
+
}
|
|
31611
|
+
lockedPorts.young.add(availablePort);
|
|
31612
|
+
return availablePort;
|
|
31613
|
+
} catch (error) {
|
|
31614
|
+
if (!["EADDRINUSE", "EACCES"].includes(error.code) && !(error instanceof Locked)) {
|
|
31615
|
+
throw error;
|
|
31616
|
+
}
|
|
31617
|
+
}
|
|
31618
|
+
}
|
|
31619
|
+
throw new Error("No available ports found");
|
|
31620
|
+
}
|
|
31621
|
+
function portNumbers(from, to) {
|
|
31622
|
+
if (!Number.isInteger(from) || !Number.isInteger(to)) {
|
|
31623
|
+
throw new TypeError("`from` and `to` must be integer numbers");
|
|
31624
|
+
}
|
|
31625
|
+
if (from < minPort || from > maxPort) {
|
|
31626
|
+
throw new RangeError(`'from' must be between ${minPort} and ${maxPort}`);
|
|
31627
|
+
}
|
|
31628
|
+
if (to < minPort || to > maxPort) {
|
|
31629
|
+
throw new RangeError(`'to' must be between ${minPort} and ${maxPort}`);
|
|
31630
|
+
}
|
|
31631
|
+
if (from > to) {
|
|
31632
|
+
throw new RangeError("`to` must be greater than or equal to `from`");
|
|
31633
|
+
}
|
|
31634
|
+
const generator = function* (from2, to2) {
|
|
31635
|
+
for (let port = from2; port <= to2; port++) {
|
|
31636
|
+
yield port;
|
|
31637
|
+
}
|
|
31638
|
+
};
|
|
31639
|
+
return generator(from, to);
|
|
31640
|
+
}
|
|
31641
|
+
|
|
31642
|
+
// src/utils/adbPath.ts
|
|
31643
|
+
import { existsSync } from "node:fs";
|
|
31644
|
+
import path from "node:path";
|
|
31645
|
+
import { fileURLToPath } from "node:url";
|
|
31646
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
31647
|
+
var __dirname = path.dirname(__filename);
|
|
31648
|
+
function getPlatformDir() {
|
|
31649
|
+
const platform = process.platform;
|
|
31650
|
+
if (platform === "win32") {
|
|
31651
|
+
return "windows";
|
|
31652
|
+
}
|
|
31653
|
+
if (platform === "darwin") {
|
|
31654
|
+
return "darwin";
|
|
31655
|
+
}
|
|
31656
|
+
if (platform === "linux") {
|
|
31657
|
+
return "linux";
|
|
31658
|
+
}
|
|
31659
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
31660
|
+
}
|
|
31661
|
+
function getAdbBinaryName() {
|
|
31662
|
+
if (process.platform === "win32") {
|
|
31663
|
+
return "adb.exe";
|
|
31664
|
+
}
|
|
31665
|
+
return "adb";
|
|
31666
|
+
}
|
|
31667
|
+
function getAdbBinaryPath() {
|
|
31668
|
+
let packageRoot;
|
|
31669
|
+
if (__dirname.includes("dist")) {
|
|
31670
|
+
packageRoot = path.resolve(__dirname, "..", "..");
|
|
31671
|
+
} else {
|
|
31672
|
+
packageRoot = path.resolve(__dirname, "..", "..");
|
|
31673
|
+
}
|
|
31674
|
+
const platformDir = getPlatformDir();
|
|
31675
|
+
const binaryName = getAdbBinaryName();
|
|
31676
|
+
const distPath = path.join(packageRoot, "dist", "resources", "bin", platformDir, binaryName);
|
|
31677
|
+
if (existsSync(distPath)) {
|
|
31678
|
+
return distPath;
|
|
31679
|
+
}
|
|
31680
|
+
return null;
|
|
31681
|
+
}
|
|
31682
|
+
|
|
31683
|
+
// src/utils/debug.ts
|
|
31684
|
+
var import_debug2 = __toESM(require_src3());
|
|
31685
|
+
var logTask2 = (0, import_debug2.default)("adb-kit:task");
|
|
31686
|
+
var logInfo2 = (0, import_debug2.default)("adb-kit:info");
|
|
31687
|
+
var logWarning = (0, import_debug2.default)("adb-kit:warning");
|
|
31688
|
+
var logError2 = (0, import_debug2.default)("adb-kit:error");
|
|
31689
|
+
logTask2.color = "40";
|
|
31690
|
+
logInfo2.color = "45";
|
|
31691
|
+
logWarning.color = "214";
|
|
31692
|
+
logError2.color = "160";
|
|
31693
|
+
|
|
31694
31694
|
// src/logic/adbDeviceKit.ts
|
|
31695
31695
|
function ensureAdbPathFromResources() {
|
|
31696
31696
|
const adbPath = getAdbBinaryPath();
|
|
31697
31697
|
if (adbPath && !process.env.ADB_PATH) {
|
|
31698
31698
|
process.env.ADB_PATH = adbPath;
|
|
31699
|
-
|
|
31699
|
+
logInfo2(`Using ADB from resources: ${adbPath}`);
|
|
31700
31700
|
}
|
|
31701
31701
|
}
|
|
31702
31702
|
var deviceProps = {
|
|
@@ -31735,7 +31735,7 @@ var AdbDeviceKit = class {
|
|
|
31735
31735
|
bin: process.env.ADB_PATH ?? getAdbBinaryPath() ?? "."
|
|
31736
31736
|
});
|
|
31737
31737
|
this.deviceId = deviceId.split("\\").pop() ?? deviceId;
|
|
31738
|
-
|
|
31738
|
+
logInfo2(`Device ID: ${this.deviceId}`);
|
|
31739
31739
|
this.device = this.client.getDevice(this.deviceId);
|
|
31740
31740
|
}
|
|
31741
31741
|
client;
|
|
@@ -31748,16 +31748,16 @@ var AdbDeviceKit = class {
|
|
|
31748
31748
|
}
|
|
31749
31749
|
async getProperty(adbDevice, property) {
|
|
31750
31750
|
try {
|
|
31751
|
-
|
|
31751
|
+
logTask2(`Getting property ${property} for device ${this.deviceId}`);
|
|
31752
31752
|
const stream = await adbDevice.shell(`getprop ${deviceProps[property]}`);
|
|
31753
|
-
|
|
31753
|
+
logTask2(`Stream: ${stream}`);
|
|
31754
31754
|
const chunks = [];
|
|
31755
31755
|
for await (const chunk of stream) {
|
|
31756
31756
|
chunks.push(chunk);
|
|
31757
31757
|
}
|
|
31758
31758
|
return Buffer.concat(chunks).toString().trim();
|
|
31759
31759
|
} catch (error) {
|
|
31760
|
-
|
|
31760
|
+
logError2(`Error getting property ${property} for device ${this.deviceId}: ${error}`);
|
|
31761
31761
|
return "";
|
|
31762
31762
|
}
|
|
31763
31763
|
}
|
|
@@ -31765,22 +31765,22 @@ var AdbDeviceKit = class {
|
|
|
31765
31765
|
return this.device.getProperties();
|
|
31766
31766
|
}
|
|
31767
31767
|
async getDeviceProperties(properties) {
|
|
31768
|
-
|
|
31768
|
+
logTask2(`Getting properties ${properties.join(", ")} for device ${this.deviceId}`);
|
|
31769
31769
|
const propertiesValues = await Promise.all(
|
|
31770
31770
|
properties.map((property) => this.getProperty(this.device, property))
|
|
31771
31771
|
);
|
|
31772
31772
|
return propertiesValues;
|
|
31773
31773
|
}
|
|
31774
31774
|
async installApp(appPath) {
|
|
31775
|
-
|
|
31775
|
+
logTask2(`Installing app ${appPath} on device ${this.deviceId}`);
|
|
31776
31776
|
await this.device.install(appPath);
|
|
31777
31777
|
}
|
|
31778
31778
|
async uninstallApp(packageName) {
|
|
31779
|
-
|
|
31779
|
+
logTask2(`Uninstalling app ${packageName} on device ${this.deviceId}`);
|
|
31780
31780
|
await this.device.uninstall(packageName);
|
|
31781
31781
|
}
|
|
31782
31782
|
async isAppInstalled(packageName) {
|
|
31783
|
-
|
|
31783
|
+
logTask2(`Checking if app ${packageName} is installed on device ${this.deviceId}`);
|
|
31784
31784
|
return await this.device.isInstalled(packageName);
|
|
31785
31785
|
}
|
|
31786
31786
|
/**
|
|
@@ -31803,12 +31803,12 @@ var AdbDeviceKit = class {
|
|
|
31803
31803
|
const tracker = await this.client.trackDevices();
|
|
31804
31804
|
return new Promise((resolve, reject) => {
|
|
31805
31805
|
const timeoutId = setTimeout(() => {
|
|
31806
|
-
|
|
31806
|
+
logError2("Timeout waiting for USB debugging");
|
|
31807
31807
|
reject(new Error("Timeout waiting for USB debugging"));
|
|
31808
31808
|
}, timeout2);
|
|
31809
31809
|
tracker.on("remove", (_) => {
|
|
31810
31810
|
clearTimeout(timeoutId);
|
|
31811
|
-
|
|
31811
|
+
logError2("Device removed from tracker");
|
|
31812
31812
|
});
|
|
31813
31813
|
tracker.on("add", (device) => {
|
|
31814
31814
|
if (device.type === "device") {
|