@mcesystems/apple-kit 1.0.41 → 1.0.44

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 CHANGED
@@ -951,46 +951,15 @@ function logError(message) {
951
951
  debugError(message);
952
952
  }
953
953
 
954
- // src/logic/actions/device.ts
954
+ // src/logic/actions/tool.ts
955
955
  var import_node_child_process = require("node:child_process");
956
- var import_node_fs = require("node:fs");
957
- var import_node_path = require("node:path");
956
+ var import_node_path2 = require("node:path");
958
957
  var import_node_util = require("node:util");
959
958
 
960
- // src/logic/dataParser.ts
961
- function parsePlistOutput(output) {
962
- const result = {};
963
- const lines = output.split("\n");
964
- for (const line of lines) {
965
- const colonIndex = line.indexOf(":");
966
- if (colonIndex > 0) {
967
- const key = line.substring(0, colonIndex).trim();
968
- const value = line.substring(colonIndex + 1).trim();
969
- result[key] = value;
970
- }
971
- }
972
- return result;
973
- }
974
- function parseAppList(output) {
975
- const apps = [];
976
- const lines = output.trim().split("\n");
977
- for (const line of lines) {
978
- const match = line.match(/^([^,]+),\s*([^,]+),\s*"?([^"]+)"?/);
979
- if (match) {
980
- apps.push({
981
- bundleId: match[1].trim(),
982
- version: match[2].trim(),
983
- displayName: match[3].trim(),
984
- bundleVersion: ""
985
- });
986
- }
987
- }
988
- return apps;
989
- }
990
-
991
- // src/logic/actions/device.ts
959
+ // src/logic/utils/resolvePath.ts
960
+ var import_node_fs = require("node:fs");
961
+ var import_node_path = require("node:path");
992
962
  var import_meta = {};
993
- var execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
994
963
  function getModuleDir() {
995
964
  if (typeof import_meta !== "undefined" && import_meta.url) {
996
965
  const { fileURLToPath } = require("node:url");
@@ -998,56 +967,6 @@ function getModuleDir() {
998
967
  }
999
968
  return __dirname;
1000
969
  }
1001
- async function getDeviceInfo(udid) {
1002
- logTask(`Getting device info for ${udid}`);
1003
- const result = await runIDeviceTool("ideviceinfo", ["-u", udid]);
1004
- if (!result) {
1005
- throw new Error("Failed to get device info");
1006
- }
1007
- const props = parsePlistOutput(result.stdout);
1008
- return {
1009
- deviceName: props.DeviceName || "",
1010
- productType: props.ProductType || "",
1011
- productVersion: props.ProductVersion || "",
1012
- buildVersion: props.BuildVersion || "",
1013
- serialNumber: props.SerialNumber || "",
1014
- udid: props.UniqueDeviceID || udid,
1015
- wifiAddress: props.WiFiAddress || "",
1016
- bluetoothAddress: props.BluetoothAddress || "",
1017
- phoneNumber: props.PhoneNumber || "",
1018
- cpuArchitecture: props.CPUArchitecture || "",
1019
- hardwareModel: props.HardwareModel || "",
1020
- modelNumber: props.ModelNumber || "",
1021
- regionInfo: props.RegionInfo || "",
1022
- timeZone: props.TimeZone || "",
1023
- uniqueChipID: props.UniqueChipID || "",
1024
- isPaired: true
1025
- // If we can get info, device is paired
1026
- };
1027
- }
1028
- async function runIDeviceTool(toolName, args = [], options = {}) {
1029
- const binPath = getIDeviceBinPath();
1030
- const ext = process.platform === "win32" ? ".exe" : "";
1031
- const toolPath = binPath ? (0, import_node_path.join)(binPath, `${toolName}${ext}`) : `${toolName}${ext}`;
1032
- const command = `"${toolPath}" ${args.map((a) => `"${a}"`).join(" ")}`;
1033
- return execIDevice(command, options);
1034
- }
1035
- async function execIDevice(command, options = {}) {
1036
- const binPath = getIDeviceBinPath();
1037
- if (binPath) {
1038
- options.cwd = binPath;
1039
- }
1040
- const result = await execAsync(command, {
1041
- ...options,
1042
- env: process.env,
1043
- windowsHide: true,
1044
- encoding: "utf8"
1045
- });
1046
- return {
1047
- stdout: result.stdout.toString(),
1048
- stderr: result.stderr.toString()
1049
- };
1050
- }
1051
970
  function getPlatformDir() {
1052
971
  const platform = process.platform;
1053
972
  if (platform === "win32") {
@@ -1061,29 +980,19 @@ function getPlatformDir() {
1061
980
  }
1062
981
  return platform;
1063
982
  }
1064
- function getBundledResourcesPath() {
1065
- const moduleDir = getModuleDir();
1066
- let packageRoot;
1067
- if (moduleDir.includes("dist")) {
1068
- packageRoot = (0, import_node_path.join)(moduleDir, "..", "..");
1069
- } else {
1070
- packageRoot = (0, import_node_path.join)(moduleDir, "..", "..", "..", "..");
1071
- }
1072
- const platformDir = getPlatformDir();
1073
- const distPath = (0, import_node_path.join)(packageRoot, "dist", "resources", "bin", platformDir);
1074
- if ((0, import_node_fs.existsSync)((0, import_node_path.join)(distPath, "idevice_id")) || (0, import_node_fs.existsSync)((0, import_node_path.join)(distPath, "idevice_id.exe"))) {
1075
- return distPath;
1076
- }
1077
- const devPath = (0, import_node_path.join)(packageRoot, "resources", "bin", platformDir);
1078
- if ((0, import_node_fs.existsSync)((0, import_node_path.join)(devPath, "idevice_id")) || (0, import_node_fs.existsSync)((0, import_node_path.join)(devPath, "idevice_id.exe"))) {
1079
- return devPath;
1080
- }
1081
- return null;
1082
- }
1083
983
  function getResourcesBinPath() {
1084
984
  const envBinPath = process.env.IDeviceBinPath;
1085
985
  if (envBinPath) {
1086
- return envBinPath;
986
+ if ((0, import_node_path.isAbsolute)(envBinPath)) {
987
+ return envBinPath;
988
+ }
989
+ const absolutePath = (0, import_node_path.join)(process.cwd(), envBinPath);
990
+ logInfo(`Using absolute path: ${absolutePath}`);
991
+ if ((0, import_node_fs.existsSync)(absolutePath)) {
992
+ return absolutePath;
993
+ }
994
+ logError(`Absolute path does not exist: ${absolutePath}`);
995
+ return "";
1087
996
  }
1088
997
  const bundledPath = getBundledResourcesPath();
1089
998
  if (bundledPath) {
@@ -1109,8 +1018,50 @@ function getResourcesBinPath() {
1109
1018
  }
1110
1019
  return "";
1111
1020
  }
1112
- function getIDeviceBinPath() {
1113
- return getResourcesBinPath();
1021
+ function getBundledResourcesPath() {
1022
+ const moduleDir = getModuleDir();
1023
+ let packageRoot;
1024
+ if (moduleDir.includes("dist")) {
1025
+ packageRoot = (0, import_node_path.join)(moduleDir, "..", "..");
1026
+ } else {
1027
+ packageRoot = (0, import_node_path.join)(moduleDir, "..", "..", "..", "..");
1028
+ }
1029
+ const platformDir = getPlatformDir();
1030
+ const distPath = (0, import_node_path.join)(packageRoot, "dist", "resources", "bin", platformDir);
1031
+ if ((0, import_node_fs.existsSync)((0, import_node_path.join)(distPath, "idevice_id")) || (0, import_node_fs.existsSync)((0, import_node_path.join)(distPath, "idevice_id.exe"))) {
1032
+ return distPath;
1033
+ }
1034
+ const devPath = (0, import_node_path.join)(packageRoot, "resources", "bin", platformDir);
1035
+ if ((0, import_node_fs.existsSync)((0, import_node_path.join)(devPath, "idevice_id")) || (0, import_node_fs.existsSync)((0, import_node_path.join)(devPath, "idevice_id.exe"))) {
1036
+ return devPath;
1037
+ }
1038
+ return null;
1039
+ }
1040
+
1041
+ // src/logic/actions/tool.ts
1042
+ var execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
1043
+ async function runIDeviceTool(toolName, args = [], options = {}) {
1044
+ const binPath = getResourcesBinPath();
1045
+ const ext = process.platform === "win32" ? ".exe" : "";
1046
+ const toolPath = binPath ? (0, import_node_path2.join)(binPath, `${toolName}${ext}`) : `${toolName}${ext}`;
1047
+ const command = `"${toolPath}" ${args.map((a) => `"${a}"`).join(" ")}`;
1048
+ return execIDevice(command, options);
1049
+ }
1050
+ async function execIDevice(command, options = {}) {
1051
+ const binPath = getResourcesBinPath();
1052
+ if (binPath) {
1053
+ options.cwd = binPath;
1054
+ }
1055
+ const result = await execAsync(command, {
1056
+ ...options,
1057
+ env: process.env,
1058
+ windowsHide: true,
1059
+ encoding: "utf8"
1060
+ });
1061
+ return {
1062
+ stdout: result.stdout.toString(),
1063
+ stderr: result.stderr.toString()
1064
+ };
1114
1065
  }
1115
1066
 
1116
1067
  // src/logic/actions/activation.ts
@@ -1151,6 +1102,70 @@ async function activate(udid) {
1151
1102
  }
1152
1103
  }
1153
1104
 
1105
+ // src/logic/actions/device.ts
1106
+ var import_node_fs2 = require("node:fs");
1107
+ var import_node_path3 = require("node:path");
1108
+
1109
+ // src/logic/dataParser.ts
1110
+ function parsePlistOutput(output) {
1111
+ const result = {};
1112
+ const lines = output.split("\n");
1113
+ for (const line of lines) {
1114
+ const colonIndex = line.indexOf(":");
1115
+ if (colonIndex > 0) {
1116
+ const key = line.substring(0, colonIndex).trim();
1117
+ const value = line.substring(colonIndex + 1).trim();
1118
+ result[key] = value;
1119
+ }
1120
+ }
1121
+ return result;
1122
+ }
1123
+ function parseAppList(output) {
1124
+ const apps = [];
1125
+ const lines = output.trim().split("\n");
1126
+ for (const line of lines) {
1127
+ const match = line.match(/^([^,]+),\s*([^,]+),\s*"?([^"]+)"?/);
1128
+ if (match) {
1129
+ apps.push({
1130
+ bundleId: match[1].trim(),
1131
+ version: match[2].trim(),
1132
+ displayName: match[3].trim(),
1133
+ bundleVersion: ""
1134
+ });
1135
+ }
1136
+ }
1137
+ return apps;
1138
+ }
1139
+
1140
+ // src/logic/actions/device.ts
1141
+ async function getDeviceInfo(udid) {
1142
+ logTask(`Getting device info for ${udid}`);
1143
+ const result = await runIDeviceTool("ideviceinfo", ["-u", udid]);
1144
+ if (!result) {
1145
+ throw new Error("Failed to get device info");
1146
+ }
1147
+ const props = parsePlistOutput(result.stdout);
1148
+ return {
1149
+ deviceName: props.DeviceName || "",
1150
+ productType: props.ProductType || "",
1151
+ productVersion: props.ProductVersion || "",
1152
+ buildVersion: props.BuildVersion || "",
1153
+ serialNumber: props.SerialNumber || "",
1154
+ udid: props.UniqueDeviceID || udid,
1155
+ wifiAddress: props.WiFiAddress || "",
1156
+ bluetoothAddress: props.BluetoothAddress || "",
1157
+ phoneNumber: props.PhoneNumber || "",
1158
+ cpuArchitecture: props.CPUArchitecture || "",
1159
+ hardwareModel: props.HardwareModel || "",
1160
+ modelNumber: props.ModelNumber || "",
1161
+ regionInfo: props.RegionInfo || "",
1162
+ timeZone: props.TimeZone || "",
1163
+ uniqueChipID: props.UniqueChipID || "",
1164
+ isPaired: true
1165
+ // If we can get info, device is paired
1166
+ };
1167
+ }
1168
+
1154
1169
  // src/logic/actions/pair.ts
1155
1170
  async function isPaired(udid) {
1156
1171
  logTask(`Checking pairing status for ${udid}`);
@@ -1426,83 +1441,13 @@ async function launchAppWithPymobiledevice3(bundleId, args, udid) {
1426
1441
 
1427
1442
  // src/logic/actions/proxy.ts
1428
1443
  var import_node_child_process2 = require("node:child_process");
1429
- var import_node_fs2 = require("node:fs");
1430
- var import_node_path2 = require("node:path");
1431
- var import_meta2 = {};
1432
- function getModuleDir2() {
1433
- if (typeof import_meta2 !== "undefined" && import_meta2.url) {
1434
- const { fileURLToPath } = require("node:url");
1435
- return (0, import_node_path2.dirname)(fileURLToPath(import_meta2.url));
1436
- }
1437
- return __dirname;
1438
- }
1439
- function getPlatformDir2() {
1440
- const platform = process.platform;
1441
- if (platform === "win32") {
1442
- return "windows";
1443
- }
1444
- if (platform === "darwin") {
1445
- return "darwin";
1446
- }
1447
- if (platform === "linux") {
1448
- return "linux";
1449
- }
1450
- return platform;
1451
- }
1452
- function getBundledResourcesPath2() {
1453
- const moduleDir = getModuleDir2();
1454
- let packageRoot;
1455
- if (moduleDir.includes("dist")) {
1456
- packageRoot = (0, import_node_path2.join)(moduleDir, "..", "..");
1457
- } else {
1458
- packageRoot = (0, import_node_path2.join)(moduleDir, "..", "..", "..", "..");
1459
- }
1460
- const platformDir = getPlatformDir2();
1461
- const distPath = (0, import_node_path2.join)(packageRoot, "dist", "resources", "bin", platformDir);
1462
- if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(distPath, "iproxy")) || (0, import_node_fs2.existsSync)((0, import_node_path2.join)(distPath, "iproxy.exe"))) {
1463
- return distPath;
1464
- }
1465
- const devPath = (0, import_node_path2.join)(packageRoot, "resources", "bin", platformDir);
1466
- if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(devPath, "iproxy")) || (0, import_node_fs2.existsSync)((0, import_node_path2.join)(devPath, "iproxy.exe"))) {
1467
- return devPath;
1468
- }
1469
- return null;
1470
- }
1471
- function getResourcesBinPath2() {
1472
- const envBinPath = process.env.IDeviceBinPath;
1473
- if (envBinPath) {
1474
- return envBinPath;
1475
- }
1476
- const bundledPath = getBundledResourcesPath2();
1477
- if (bundledPath) {
1478
- return bundledPath;
1479
- }
1480
- if (process.platform === "darwin") {
1481
- const homebrewArmPath = "/opt/homebrew/bin";
1482
- if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(homebrewArmPath, "iproxy"))) {
1483
- return homebrewArmPath;
1484
- }
1485
- const homebrewIntelPath = "/usr/local/bin";
1486
- if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(homebrewIntelPath, "iproxy"))) {
1487
- return homebrewIntelPath;
1488
- }
1489
- }
1490
- if (process.platform === "linux") {
1491
- const linuxPaths = ["/usr/bin", "/usr/local/bin"];
1492
- for (const linuxPath of linuxPaths) {
1493
- if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(linuxPath, "iproxy"))) {
1494
- return linuxPath;
1495
- }
1496
- }
1497
- }
1498
- return "";
1499
- }
1444
+ var import_node_path4 = require("node:path");
1500
1445
  function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
1501
1446
  return new Promise((resolve, reject) => {
1502
1447
  logTask(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
1503
- const binPath = getResourcesBinPath2();
1448
+ const binPath = getResourcesBinPath();
1504
1449
  const ext = process.platform === "win32" ? ".exe" : "";
1505
- const toolPath = binPath ? (0, import_node_path2.join)(binPath, `iproxy${ext}`) : `iproxy${ext}`;
1450
+ const toolPath = binPath ? (0, import_node_path4.join)(binPath, `iproxy${ext}`) : `iproxy${ext}`;
1506
1451
  const spawnOptions = {
1507
1452
  windowsHide: true,
1508
1453
  stdio: ["ignore", "pipe", "pipe"]
@@ -1510,6 +1455,9 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
1510
1455
  if (binPath) {
1511
1456
  spawnOptions.cwd = binPath;
1512
1457
  }
1458
+ logInfo(`Spawning iproxy with path: ${toolPath}`);
1459
+ logInfo(`Arguments: ${[localPort.toString(), devicePort.toString(), "-u", udid].join(" ")}`);
1460
+ logInfo(`Options: ${JSON.stringify(spawnOptions)}`);
1513
1461
  const child = (0, import_node_child_process2.spawn)(
1514
1462
  toolPath,
1515
1463
  [localPort.toString(), devicePort.toString(), "-u", udid],
@@ -1517,7 +1465,11 @@ function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
1517
1465
  );
1518
1466
  let hasResolved = false;
1519
1467
  let stderrOutput = "";
1468
+ child.stdout?.on("data", (data) => {
1469
+ logTask(`${data.toString()}`);
1470
+ });
1520
1471
  child.stderr?.on("data", (data) => {
1472
+ logError(`${data.toString()}`);
1521
1473
  const msg = data.toString();
1522
1474
  stderrOutput += msg;
1523
1475
  if (msg.toLowerCase().includes("error") && !hasResolved) {