@mcesystems/apple-kit 1.0.72 → 1.0.73

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
@@ -38635,6 +38635,44 @@ function parseProfileListOutput(output) {
38635
38635
  }
38636
38636
  return profiles;
38637
38637
  }
38638
+ function parseFsyncTreeStdout(stdout) {
38639
+ return stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).map((line) => line.replace(/^\|\s*\|-\s*/, "").replace(/^\|-\s*/, "")).filter((name) => name.length > 0);
38640
+ }
38641
+ function runIosCommandWithRawStdout(iosBinaryPath, args) {
38642
+ return new Promise((resolve2, reject) => {
38643
+ logDetail(`Running command: ${iosBinaryPath} ${args.join(" ")}`);
38644
+ const child = spawn2(iosBinaryPath, args, {
38645
+ windowsHide: true,
38646
+ stdio: ["ignore", "pipe", "pipe"]
38647
+ });
38648
+ let stdout = "";
38649
+ let stderr = "";
38650
+ child.stdout?.on("data", (data) => {
38651
+ stdout += data.toString();
38652
+ });
38653
+ child.stderr?.on("data", (data) => {
38654
+ stderr += data.toString();
38655
+ });
38656
+ child.on("error", (error) => {
38657
+ reject(error);
38658
+ });
38659
+ child.on("close", (code) => {
38660
+ const logMessages = stderr.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item)).map((lineJson) => ({
38661
+ level: lineJson.level,
38662
+ msg: lineJson.msg,
38663
+ timestamp: lineJson.timestamp
38664
+ }));
38665
+ const raw = {
38666
+ command: iosBinaryPath,
38667
+ args,
38668
+ output: [],
38669
+ logMessages,
38670
+ exitCode: code ?? 0
38671
+ };
38672
+ resolve2({ stdout, stderr, exitCode: code ?? 0, raw });
38673
+ });
38674
+ });
38675
+ }
38638
38676
  function createIosCli(iosBinaryPath) {
38639
38677
  return {
38640
38678
  async listDevices() {
@@ -38697,6 +38735,85 @@ function createIosCli(iosBinaryPath) {
38697
38735
  },
38698
38736
  async installApp(deviceId, ipaPath) {
38699
38737
  return runIosCommand(iosBinaryPath, ["install", `--path=${ipaPath}`, "--udid", deviceId]);
38738
+ },
38739
+ async tunnelStart(deviceId, userspace = false) {
38740
+ const args = ["tunnel", "start", "--udid", deviceId, ...userspace ? ["--userspace"] : []];
38741
+ logDetail(`Spawning tunnel: ${iosBinaryPath} ${args.join(" ")}`);
38742
+ const child = spawn2(iosBinaryPath, args, {
38743
+ windowsHide: true,
38744
+ stdio: ["ignore", "pipe", "pipe"]
38745
+ });
38746
+ return new Promise((resolve2, reject) => {
38747
+ let settled = false;
38748
+ const cleanup = () => {
38749
+ child.off("error", onError);
38750
+ child.off("exit", onExit);
38751
+ child.stdout?.off("data", onReadyCheck);
38752
+ child.stderr?.off("data", onReadyCheck);
38753
+ clearTimeout(readyTimeout);
38754
+ };
38755
+ const finish = (result) => {
38756
+ if (settled) return;
38757
+ settled = true;
38758
+ cleanup();
38759
+ if (result.reject) reject(result.reject);
38760
+ else if (result.resolve !== void 0) resolve2(result.resolve);
38761
+ };
38762
+ const onError = (err) => finish({ reject: err });
38763
+ const onExit = (code) => finish({ reject: new Error(`Tunnel exited early (code=${code})`) });
38764
+ const onReadyCheck = (data) => {
38765
+ const line = data.toString();
38766
+ const isReady = line.includes("Tunnel server started") || line.includes("tunnel") && (line.includes("listening") || line.includes("connected"));
38767
+ if (isReady) finish({ resolve: child });
38768
+ };
38769
+ const readyTimeout = setTimeout(() => finish({ resolve: child }), 1e4);
38770
+ child.once("error", onError);
38771
+ child.once("exit", onExit);
38772
+ child.stdout?.on("data", onReadyCheck);
38773
+ child.stderr?.on("data", onReadyCheck);
38774
+ });
38775
+ },
38776
+ async fsyncPull(deviceId, app, srcPath, dstPath) {
38777
+ return runIosCommand(iosBinaryPath, [
38778
+ "fsync",
38779
+ "--app",
38780
+ app,
38781
+ "pull",
38782
+ "--srcPath",
38783
+ srcPath,
38784
+ "--dstPath",
38785
+ dstPath,
38786
+ "--udid",
38787
+ deviceId
38788
+ ]);
38789
+ },
38790
+ async fsyncPush(deviceId, app, srcPath, dstPath) {
38791
+ return runIosCommand(iosBinaryPath, [
38792
+ "fsync",
38793
+ "--app",
38794
+ app,
38795
+ "push",
38796
+ "--srcPath",
38797
+ srcPath,
38798
+ "--dstPath",
38799
+ dstPath,
38800
+ "--udid",
38801
+ deviceId
38802
+ ]);
38803
+ },
38804
+ async fsyncTree(deviceId, app, path) {
38805
+ const args = [
38806
+ "fsync",
38807
+ "--app",
38808
+ app,
38809
+ "tree",
38810
+ "--udid",
38811
+ deviceId,
38812
+ ...path !== void 0 && path !== "" ? ["--path", path] : []
38813
+ ];
38814
+ const { stdout, raw } = await runIosCommandWithRawStdout(iosBinaryPath, args);
38815
+ const entries = parseFsyncTreeStdout(stdout);
38816
+ return { entries, raw };
38700
38817
  }
38701
38818
  };
38702
38819
  }