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