@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.js CHANGED
@@ -38667,6 +38667,44 @@ function parseProfileListOutput(output) {
38667
38667
  }
38668
38668
  return profiles;
38669
38669
  }
38670
+ function parseFsyncTreeStdout(stdout) {
38671
+ 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);
38672
+ }
38673
+ function runIosCommandWithRawStdout(iosBinaryPath, args) {
38674
+ return new Promise((resolve2, reject) => {
38675
+ logDetail(`Running command: ${iosBinaryPath} ${args.join(" ")}`);
38676
+ const child = (0, import_node_child_process3.spawn)(iosBinaryPath, args, {
38677
+ windowsHide: true,
38678
+ stdio: ["ignore", "pipe", "pipe"]
38679
+ });
38680
+ let stdout = "";
38681
+ let stderr = "";
38682
+ child.stdout?.on("data", (data) => {
38683
+ stdout += data.toString();
38684
+ });
38685
+ child.stderr?.on("data", (data) => {
38686
+ stderr += data.toString();
38687
+ });
38688
+ child.on("error", (error) => {
38689
+ reject(error);
38690
+ });
38691
+ child.on("close", (code) => {
38692
+ const logMessages = stderr.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => safeParseJson(line)).filter((item) => Boolean(item)).map((lineJson) => ({
38693
+ level: lineJson.level,
38694
+ msg: lineJson.msg,
38695
+ timestamp: lineJson.timestamp
38696
+ }));
38697
+ const raw = {
38698
+ command: iosBinaryPath,
38699
+ args,
38700
+ output: [],
38701
+ logMessages,
38702
+ exitCode: code ?? 0
38703
+ };
38704
+ resolve2({ stdout, stderr, exitCode: code ?? 0, raw });
38705
+ });
38706
+ });
38707
+ }
38670
38708
  function createIosCli(iosBinaryPath) {
38671
38709
  return {
38672
38710
  async listDevices() {
@@ -38729,6 +38767,85 @@ function createIosCli(iosBinaryPath) {
38729
38767
  },
38730
38768
  async installApp(deviceId, ipaPath) {
38731
38769
  return runIosCommand(iosBinaryPath, ["install", `--path=${ipaPath}`, "--udid", deviceId]);
38770
+ },
38771
+ async tunnelStart(deviceId, userspace = false) {
38772
+ const args = ["tunnel", "start", "--udid", deviceId, ...userspace ? ["--userspace"] : []];
38773
+ logDetail(`Spawning tunnel: ${iosBinaryPath} ${args.join(" ")}`);
38774
+ const child = (0, import_node_child_process3.spawn)(iosBinaryPath, args, {
38775
+ windowsHide: true,
38776
+ stdio: ["ignore", "pipe", "pipe"]
38777
+ });
38778
+ return new Promise((resolve2, reject) => {
38779
+ let settled = false;
38780
+ const cleanup = () => {
38781
+ child.off("error", onError);
38782
+ child.off("exit", onExit);
38783
+ child.stdout?.off("data", onReadyCheck);
38784
+ child.stderr?.off("data", onReadyCheck);
38785
+ clearTimeout(readyTimeout);
38786
+ };
38787
+ const finish = (result) => {
38788
+ if (settled) return;
38789
+ settled = true;
38790
+ cleanup();
38791
+ if (result.reject) reject(result.reject);
38792
+ else if (result.resolve !== void 0) resolve2(result.resolve);
38793
+ };
38794
+ const onError = (err) => finish({ reject: err });
38795
+ const onExit = (code) => finish({ reject: new Error(`Tunnel exited early (code=${code})`) });
38796
+ const onReadyCheck = (data) => {
38797
+ const line = data.toString();
38798
+ const isReady = line.includes("Tunnel server started") || line.includes("tunnel") && (line.includes("listening") || line.includes("connected"));
38799
+ if (isReady) finish({ resolve: child });
38800
+ };
38801
+ const readyTimeout = setTimeout(() => finish({ resolve: child }), 1e4);
38802
+ child.once("error", onError);
38803
+ child.once("exit", onExit);
38804
+ child.stdout?.on("data", onReadyCheck);
38805
+ child.stderr?.on("data", onReadyCheck);
38806
+ });
38807
+ },
38808
+ async fsyncPull(deviceId, app, srcPath, dstPath) {
38809
+ return runIosCommand(iosBinaryPath, [
38810
+ "fsync",
38811
+ "--app",
38812
+ app,
38813
+ "pull",
38814
+ "--srcPath",
38815
+ srcPath,
38816
+ "--dstPath",
38817
+ dstPath,
38818
+ "--udid",
38819
+ deviceId
38820
+ ]);
38821
+ },
38822
+ async fsyncPush(deviceId, app, srcPath, dstPath) {
38823
+ return runIosCommand(iosBinaryPath, [
38824
+ "fsync",
38825
+ "--app",
38826
+ app,
38827
+ "push",
38828
+ "--srcPath",
38829
+ srcPath,
38830
+ "--dstPath",
38831
+ dstPath,
38832
+ "--udid",
38833
+ deviceId
38834
+ ]);
38835
+ },
38836
+ async fsyncTree(deviceId, app, path) {
38837
+ const args = [
38838
+ "fsync",
38839
+ "--app",
38840
+ app,
38841
+ "tree",
38842
+ "--udid",
38843
+ deviceId,
38844
+ ...path !== void 0 && path !== "" ? ["--path", path] : []
38845
+ ];
38846
+ const { stdout, raw } = await runIosCommandWithRawStdout(iosBinaryPath, args);
38847
+ const entries = parseFsyncTreeStdout(stdout);
38848
+ return { entries, raw };
38732
38849
  }
38733
38850
  };
38734
38851
  }