@mcesystems/apple-kit 1.0.24 → 1.0.25

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.
Files changed (114) hide show
  1. package/README.md +284 -250
  2. package/dist/index.js +156 -22
  3. package/dist/index.js.map +3 -3
  4. package/dist/index.mjs +156 -24
  5. package/dist/index.mjs.map +3 -3
  6. package/dist/resources/bin/darwin/idevice_id +0 -0
  7. package/dist/resources/bin/darwin/idevicedebug +0 -0
  8. package/dist/resources/bin/darwin/idevicediagnostics +0 -0
  9. package/dist/resources/bin/darwin/ideviceinfo +0 -0
  10. package/dist/resources/bin/darwin/ideviceinstaller +0 -0
  11. package/dist/resources/bin/darwin/idevicename +0 -0
  12. package/dist/resources/bin/darwin/idevicepair +0 -0
  13. package/dist/resources/bin/darwin/idevicescreenshot +0 -0
  14. package/dist/resources/bin/darwin/idevicesyslog +0 -0
  15. package/dist/resources/bin/darwin/iproxy +0 -0
  16. package/dist/resources/bin/darwin/libcrypto.3.dylib +0 -0
  17. package/dist/resources/bin/darwin/libimobiledevice-1.0.6.dylib +0 -0
  18. package/dist/resources/bin/darwin/libimobiledevice-glue-1.0.0.dylib +0 -0
  19. package/dist/resources/bin/darwin/liblzma.5.dylib +0 -0
  20. package/dist/resources/bin/darwin/libplist-2.0.4.dylib +0 -0
  21. package/dist/resources/bin/darwin/libssl.3.dylib +0 -0
  22. package/dist/resources/bin/darwin/libusbmuxd-2.0.7.dylib +0 -0
  23. package/dist/resources/bin/darwin/libzip.5.dylib +0 -0
  24. package/dist/resources/bin/darwin/libzstd.1.dylib +0 -0
  25. package/{resources → dist/resources}/licenses/LGPL-2.1.txt +33 -33
  26. package/dist/types/logic/actions/device.d.ts.map +1 -1
  27. package/dist/types/logic/actions/proxy.d.ts.map +1 -1
  28. package/dist/types/logic/appleDeviceKit.d.ts +1 -1
  29. package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
  30. package/package.json +7 -4
  31. package/scripts/README.md +209 -0
  32. package/scripts/build-windows.sh.template +134 -0
  33. package/scripts/export-resources.ts +444 -0
  34. package/dist/types/utils/portManager.d.ts +0 -68
  35. package/dist/types/utils/portManager.d.ts.map +0 -1
  36. package/resources/bin/windows/bz2.dll +0 -0
  37. package/resources/bin/windows/getopt.dll +0 -0
  38. package/resources/bin/windows/iconv-2.dll +0 -0
  39. package/resources/bin/windows/idevice_id.exe +0 -0
  40. package/resources/bin/windows/ideviceactivation.exe +0 -0
  41. package/resources/bin/windows/idevicedebug.exe +0 -0
  42. package/resources/bin/windows/ideviceinfo.exe +0 -0
  43. package/resources/bin/windows/ideviceinstaller.exe +0 -0
  44. package/resources/bin/windows/idevicepair.exe +0 -0
  45. package/resources/bin/windows/imobiledevice.dll +0 -0
  46. package/resources/bin/windows/iproxy.exe +0 -0
  47. package/resources/bin/windows/libcrypto-1_1-x64.dll +0 -0
  48. package/resources/bin/windows/libcurl.dll +0 -0
  49. package/resources/bin/windows/libideviceactivation-1.0.dll +0 -0
  50. package/resources/bin/windows/libimobiledevice-1.0.dll +0 -0
  51. package/resources/bin/windows/libimobiledevice-glue-1.0.dll +0 -0
  52. package/resources/bin/windows/libplist-2.0.dll +0 -0
  53. package/resources/bin/windows/libssl-1_1-x64.dll +0 -0
  54. package/resources/bin/windows/libusb-1.0.dll +0 -0
  55. package/resources/bin/windows/libusb0.dll +0 -0
  56. package/resources/bin/windows/libusbmuxd-2.0.dll +0 -0
  57. package/resources/bin/windows/libxml2.dll +0 -0
  58. package/resources/bin/windows/lzma.dll +0 -0
  59. package/resources/bin/windows/pcre.dll +0 -0
  60. package/resources/bin/windows/pcreposix.dll +0 -0
  61. package/resources/bin/windows/plist.dll +0 -0
  62. package/resources/bin/windows/pthreadVC3.dll +0 -0
  63. package/resources/bin/windows/readline.dll +0 -0
  64. package/resources/bin/windows/usbmuxd.dll +0 -0
  65. package/resources/bin/windows/usbmuxd.exe +0 -0
  66. package/resources/bin/windows/vcruntime140.dll +0 -0
  67. package/resources/bin/windows/zip.dll +0 -0
  68. package/resources/bin/windows/zlib1.dll +0 -0
  69. package/resources/lib/include/libimobiledevice/afc.h +0 -413
  70. package/resources/lib/include/libimobiledevice/bt_packet_logger.h +0 -156
  71. package/resources/lib/include/libimobiledevice/companion_proxy.h +0 -212
  72. package/resources/lib/include/libimobiledevice/debugserver.h +0 -272
  73. package/resources/lib/include/libimobiledevice/diagnostics_relay.h +0 -228
  74. package/resources/lib/include/libimobiledevice/file_relay.h +0 -166
  75. package/resources/lib/include/libimobiledevice/heartbeat.h +0 -137
  76. package/resources/lib/include/libimobiledevice/house_arrest.h +0 -180
  77. package/resources/lib/include/libimobiledevice/installation_proxy.h +0 -505
  78. package/resources/lib/include/libimobiledevice/libimobiledevice.h +0 -444
  79. package/resources/lib/include/libimobiledevice/lockdown.h +0 -577
  80. package/resources/lib/include/libimobiledevice/misagent.h +0 -168
  81. package/resources/lib/include/libimobiledevice/mobile_image_mounter.h +0 -275
  82. package/resources/lib/include/libimobiledevice/mobileactivation.h +0 -192
  83. package/resources/lib/include/libimobiledevice/mobilebackup.h +0 -246
  84. package/resources/lib/include/libimobiledevice/mobilebackup2.h +0 -214
  85. package/resources/lib/include/libimobiledevice/mobilesync.h +0 -359
  86. package/resources/lib/include/libimobiledevice/notification_proxy.h +0 -202
  87. package/resources/lib/include/libimobiledevice/ostrace.h +0 -198
  88. package/resources/lib/include/libimobiledevice/preboard.h +0 -187
  89. package/resources/lib/include/libimobiledevice/property_list_service.h +0 -184
  90. package/resources/lib/include/libimobiledevice/restore.h +0 -179
  91. package/resources/lib/include/libimobiledevice/reverse_proxy.h +0 -213
  92. package/resources/lib/include/libimobiledevice/sbservices.h +0 -175
  93. package/resources/lib/include/libimobiledevice/screenshotr.h +0 -118
  94. package/resources/lib/include/libimobiledevice/service.h +0 -202
  95. package/resources/lib/include/libimobiledevice/syslog_relay.h +0 -184
  96. package/resources/lib/include/libimobiledevice/webinspector.h +0 -137
  97. package/resources/lib/include/plist/Array.h +0 -80
  98. package/resources/lib/include/plist/Boolean.h +0 -48
  99. package/resources/lib/include/plist/Data.h +0 -50
  100. package/resources/lib/include/plist/Date.h +0 -54
  101. package/resources/lib/include/plist/Dictionary.h +0 -73
  102. package/resources/lib/include/plist/Integer.h +0 -54
  103. package/resources/lib/include/plist/Key.h +0 -49
  104. package/resources/lib/include/plist/Node.h +0 -57
  105. package/resources/lib/include/plist/Real.h +0 -48
  106. package/resources/lib/include/plist/String.h +0 -52
  107. package/resources/lib/include/plist/Structure.h +0 -62
  108. package/resources/lib/include/plist/Uid.h +0 -48
  109. package/resources/lib/include/plist/plist++.h +0 -39
  110. package/resources/lib/include/plist/plist.h +0 -1448
  111. package/resources/lib/libimobiledevice-1.0.dll +0 -0
  112. package/resources/lib/libimobiledevice-1.0.dll.a +0 -0
  113. package/resources/lib/libplist-2.0.dll +0 -0
  114. package/resources/lib/libplist-2.0.dll.a +0 -0
package/dist/index.mjs CHANGED
@@ -944,7 +944,7 @@ function logTask(message) {
944
944
  // src/logic/actions/device.ts
945
945
  import { exec as execCallback } from "node:child_process";
946
946
  import { existsSync } from "node:fs";
947
- import { join } from "node:path";
947
+ import { dirname, join } from "node:path";
948
948
  import { promisify } from "node:util";
949
949
 
950
950
  // src/logic/dataParser.ts
@@ -980,6 +980,13 @@ function parseAppList(output) {
980
980
 
981
981
  // src/logic/actions/device.ts
982
982
  var execAsync = promisify(execCallback);
983
+ function getModuleDir() {
984
+ if (typeof import.meta !== "undefined" && import.meta.url) {
985
+ const { fileURLToPath } = __require("node:url");
986
+ return dirname(fileURLToPath(import.meta.url));
987
+ }
988
+ return __dirname;
989
+ }
983
990
  async function getDeviceInfo(udid) {
984
991
  logTask(`Getting device info for ${udid}`);
985
992
  const result = await runIDeviceTool("ideviceinfo", ["-u", udid]);
@@ -1008,12 +1015,17 @@ async function getDeviceInfo(udid) {
1008
1015
  };
1009
1016
  }
1010
1017
  async function runIDeviceTool(toolName, args = [], options = {}) {
1011
- const command = `"${toolName}${process.platform === "win32" ? ".exe" : ""}" ${args.map((a) => `"${a}"`).join(" ")}`;
1018
+ const binPath = getIDeviceBinPath();
1019
+ const ext = process.platform === "win32" ? ".exe" : "";
1020
+ const toolPath = binPath ? join(binPath, `${toolName}${ext}`) : `${toolName}${ext}`;
1021
+ const command = `"${toolPath}" ${args.map((a) => `"${a}"`).join(" ")}`;
1012
1022
  return execIDevice(command, options);
1013
1023
  }
1014
1024
  async function execIDevice(command, options = {}) {
1015
1025
  const binPath = getIDeviceBinPath();
1016
- options.cwd = binPath;
1026
+ if (binPath) {
1027
+ options.cwd = binPath;
1028
+ }
1017
1029
  const result = await execAsync(command, {
1018
1030
  ...options,
1019
1031
  env: process.env,
@@ -1025,12 +1037,66 @@ async function execIDevice(command, options = {}) {
1025
1037
  stderr: result.stderr.toString()
1026
1038
  };
1027
1039
  }
1040
+ function getPlatformDir() {
1041
+ const platform = process.platform;
1042
+ if (platform === "win32") {
1043
+ return "windows";
1044
+ }
1045
+ if (platform === "darwin") {
1046
+ return "darwin";
1047
+ }
1048
+ if (platform === "linux") {
1049
+ return "linux";
1050
+ }
1051
+ return platform;
1052
+ }
1053
+ function getBundledResourcesPath() {
1054
+ const moduleDir = getModuleDir();
1055
+ let packageRoot;
1056
+ if (moduleDir.includes("dist")) {
1057
+ packageRoot = join(moduleDir, "..", "..");
1058
+ } else {
1059
+ packageRoot = join(moduleDir, "..", "..", "..", "..");
1060
+ }
1061
+ const platformDir = getPlatformDir();
1062
+ const distPath = join(packageRoot, "dist", "resources", "bin", platformDir);
1063
+ if (existsSync(join(distPath, "idevice_id")) || existsSync(join(distPath, "idevice_id.exe"))) {
1064
+ return distPath;
1065
+ }
1066
+ const devPath = join(packageRoot, "resources", "bin", platformDir);
1067
+ if (existsSync(join(devPath, "idevice_id")) || existsSync(join(devPath, "idevice_id.exe"))) {
1068
+ return devPath;
1069
+ }
1070
+ return null;
1071
+ }
1028
1072
  function getResourcesBinPath() {
1029
- const binPath = process.env.IDeviceBinPath;
1030
- if (!binPath) {
1031
- throw new Error("IDeviceBinPath is not set");
1073
+ const envBinPath = process.env.IDeviceBinPath;
1074
+ if (envBinPath) {
1075
+ return envBinPath;
1076
+ }
1077
+ const bundledPath = getBundledResourcesPath();
1078
+ if (bundledPath) {
1079
+ return bundledPath;
1080
+ }
1081
+ if (process.platform === "darwin") {
1082
+ const homebrewArmPath = "/opt/homebrew/bin";
1083
+ if (existsSync(join(homebrewArmPath, "idevice_id"))) {
1084
+ return homebrewArmPath;
1085
+ }
1086
+ const homebrewIntelPath = "/usr/local/bin";
1087
+ if (existsSync(join(homebrewIntelPath, "idevice_id"))) {
1088
+ return homebrewIntelPath;
1089
+ }
1032
1090
  }
1033
- return binPath;
1091
+ if (process.platform === "linux") {
1092
+ const linuxPaths = ["/usr/bin", "/usr/local/bin"];
1093
+ for (const linuxPath of linuxPaths) {
1094
+ if (existsSync(join(linuxPath, "idevice_id"))) {
1095
+ return linuxPath;
1096
+ }
1097
+ }
1098
+ }
1099
+ return "";
1034
1100
  }
1035
1101
  function getIDeviceBinPath() {
1036
1102
  return getResourcesBinPath();
@@ -1339,27 +1405,93 @@ async function launchAppWithPymobiledevice3(bundleId, args, udid) {
1339
1405
 
1340
1406
  // src/logic/actions/proxy.ts
1341
1407
  import { spawn } from "node:child_process";
1342
- import { join as join2 } from "node:path";
1408
+ import { existsSync as existsSync2 } from "node:fs";
1409
+ import { dirname as dirname2, join as join2 } from "node:path";
1410
+ function getModuleDir2() {
1411
+ if (typeof import.meta !== "undefined" && import.meta.url) {
1412
+ const { fileURLToPath } = __require("node:url");
1413
+ return dirname2(fileURLToPath(import.meta.url));
1414
+ }
1415
+ return __dirname;
1416
+ }
1417
+ function getPlatformDir2() {
1418
+ const platform = process.platform;
1419
+ if (platform === "win32") {
1420
+ return "windows";
1421
+ }
1422
+ if (platform === "darwin") {
1423
+ return "darwin";
1424
+ }
1425
+ if (platform === "linux") {
1426
+ return "linux";
1427
+ }
1428
+ return platform;
1429
+ }
1430
+ function getBundledResourcesPath2() {
1431
+ const moduleDir = getModuleDir2();
1432
+ let packageRoot;
1433
+ if (moduleDir.includes("dist")) {
1434
+ packageRoot = join2(moduleDir, "..", "..");
1435
+ } else {
1436
+ packageRoot = join2(moduleDir, "..", "..", "..", "..");
1437
+ }
1438
+ const platformDir = getPlatformDir2();
1439
+ const distPath = join2(packageRoot, "dist", "resources", "bin", platformDir);
1440
+ if (existsSync2(join2(distPath, "iproxy")) || existsSync2(join2(distPath, "iproxy.exe"))) {
1441
+ return distPath;
1442
+ }
1443
+ const devPath = join2(packageRoot, "resources", "bin", platformDir);
1444
+ if (existsSync2(join2(devPath, "iproxy")) || existsSync2(join2(devPath, "iproxy.exe"))) {
1445
+ return devPath;
1446
+ }
1447
+ return null;
1448
+ }
1343
1449
  function getResourcesBinPath2() {
1344
- const binPath = process.env.IDeviceBinPath;
1345
- if (!binPath) {
1346
- throw new Error("IDeviceBinPath is not set");
1450
+ const envBinPath = process.env.IDeviceBinPath;
1451
+ if (envBinPath) {
1452
+ return envBinPath;
1453
+ }
1454
+ const bundledPath = getBundledResourcesPath2();
1455
+ if (bundledPath) {
1456
+ return bundledPath;
1457
+ }
1458
+ if (process.platform === "darwin") {
1459
+ const homebrewArmPath = "/opt/homebrew/bin";
1460
+ if (existsSync2(join2(homebrewArmPath, "iproxy"))) {
1461
+ return homebrewArmPath;
1462
+ }
1463
+ const homebrewIntelPath = "/usr/local/bin";
1464
+ if (existsSync2(join2(homebrewIntelPath, "iproxy"))) {
1465
+ return homebrewIntelPath;
1466
+ }
1347
1467
  }
1348
- return binPath;
1468
+ if (process.platform === "linux") {
1469
+ const linuxPaths = ["/usr/bin", "/usr/local/bin"];
1470
+ for (const linuxPath of linuxPaths) {
1471
+ if (existsSync2(join2(linuxPath, "iproxy"))) {
1472
+ return linuxPath;
1473
+ }
1474
+ }
1475
+ }
1476
+ return "";
1349
1477
  }
1350
1478
  function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
1351
1479
  return new Promise((resolve, reject) => {
1352
1480
  logTask(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
1353
1481
  const binPath = getResourcesBinPath2();
1354
- const toolPath = join2(binPath, `iproxy${process.platform === "win32" ? ".exe" : ""}`);
1482
+ const ext = process.platform === "win32" ? ".exe" : "";
1483
+ const toolPath = binPath ? join2(binPath, `iproxy${ext}`) : `iproxy${ext}`;
1484
+ const spawnOptions = {
1485
+ windowsHide: true,
1486
+ stdio: ["ignore", "pipe", "pipe"]
1487
+ };
1488
+ if (binPath) {
1489
+ spawnOptions.cwd = binPath;
1490
+ }
1355
1491
  const child = spawn(
1356
1492
  toolPath,
1357
1493
  [localPort.toString(), devicePort.toString(), "-u", udid],
1358
- {
1359
- cwd: binPath,
1360
- windowsHide: true,
1361
- stdio: ["ignore", "pipe", "pipe"]
1362
- }
1494
+ spawnOptions
1363
1495
  );
1364
1496
  let hasResolved = false;
1365
1497
  let stderrOutput = "";
@@ -1419,7 +1551,7 @@ var AppleDeviceKit = class {
1419
1551
  }
1420
1552
  deviceId;
1421
1553
  proxyProcess = null;
1422
- devicePort = null;
1554
+ localDevicePort = null;
1423
1555
  isDisposed = false;
1424
1556
  /**
1425
1557
  * Throws if the kit has been disposed
@@ -1547,9 +1679,9 @@ var AppleDeviceKit = class {
1547
1679
  async startPortForwardAsync(devicePort, startupTimeout = 500) {
1548
1680
  this.ensureNotDisposed();
1549
1681
  this.killProxyProcess();
1550
- this.devicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
1682
+ this.localDevicePort = await getPorts({ port: portNumbers(3e4, 31e3) });
1551
1683
  const { result, process: process2 } = await startPortForward(
1552
- this.devicePort,
1684
+ this.localDevicePort,
1553
1685
  devicePort,
1554
1686
  this.deviceId,
1555
1687
  startupTimeout
@@ -1571,8 +1703,8 @@ var AppleDeviceKit = class {
1571
1703
  */
1572
1704
  closePortForward() {
1573
1705
  this.killProxyProcess();
1574
- if (this.devicePort) {
1575
- this.devicePort = null;
1706
+ if (this.localDevicePort) {
1707
+ this.localDevicePort = null;
1576
1708
  }
1577
1709
  }
1578
1710
  /**
@@ -1613,7 +1745,7 @@ var AppleDeviceKit = class {
1613
1745
  * Returns undefined if no port forward is active
1614
1746
  */
1615
1747
  getDevicePort() {
1616
- return this.devicePort;
1748
+ return this.localDevicePort;
1617
1749
  }
1618
1750
  /**
1619
1751
  * Check if this kit has been disposed