@tongil_kim/clautunnel 1.3.2 → 1.3.4
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 +23 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -2624,6 +2624,7 @@ import {
|
|
|
2624
2624
|
import { join as join5 } from "path";
|
|
2625
2625
|
import { homedir as homedir5 } from "os";
|
|
2626
2626
|
import { get } from "http";
|
|
2627
|
+
import qrcode from "qrcode-terminal";
|
|
2627
2628
|
var REPO_URL = "https://github.com/TongilKim/ClauTunnel.git";
|
|
2628
2629
|
var DEFAULT_MOBILE_DIR = join5(homedir5(), ".clautunnel", "mobile");
|
|
2629
2630
|
var MobileServerManager = class {
|
|
@@ -2789,38 +2790,40 @@ var MobileServerManager = class {
|
|
|
2789
2790
|
this.expoProcess.on("error", () => {
|
|
2790
2791
|
});
|
|
2791
2792
|
return new Promise((resolve3) => {
|
|
2792
|
-
let
|
|
2793
|
-
let qrFinished = false;
|
|
2793
|
+
let ready = false;
|
|
2794
2794
|
let resolved = false;
|
|
2795
|
+
let qrActive = false;
|
|
2795
2796
|
const timeout = setTimeout(() => {
|
|
2796
2797
|
if (!resolved) {
|
|
2797
2798
|
resolved = true;
|
|
2798
2799
|
this.expoProcess?.stdout?.pipe(this.expoLogStream);
|
|
2799
2800
|
this.expoProcess?.stderr?.pipe(this.expoLogStream);
|
|
2800
|
-
resolve3(
|
|
2801
|
+
resolve3(false);
|
|
2801
2802
|
}
|
|
2802
|
-
},
|
|
2803
|
+
}, 6e4);
|
|
2803
2804
|
this.expoProcess?.stdout?.on("data", (data) => {
|
|
2804
2805
|
const text = data.toString();
|
|
2805
2806
|
const lines = text.split("\n");
|
|
2806
2807
|
for (const line of lines) {
|
|
2807
|
-
if (
|
|
2808
|
+
if (ready) {
|
|
2808
2809
|
this.expoLogStream?.write(line + "\n");
|
|
2809
2810
|
continue;
|
|
2810
2811
|
}
|
|
2811
2812
|
if (this.isQrCodeLine(line)) {
|
|
2812
|
-
|
|
2813
|
+
qrActive = true;
|
|
2814
|
+
process.stdout.write(line + "\n");
|
|
2815
|
+
} else if (qrActive && !this.isExpoReadyLine(line) && line.trim()) {
|
|
2813
2816
|
process.stdout.write(line + "\n");
|
|
2814
|
-
} else if (
|
|
2817
|
+
} else if (this.isExpoReadyLine(line)) {
|
|
2815
2818
|
process.stdout.write(line + "\n");
|
|
2816
|
-
|
|
2819
|
+
ready = true;
|
|
2817
2820
|
if (!resolved) {
|
|
2818
2821
|
resolved = true;
|
|
2819
2822
|
clearTimeout(timeout);
|
|
2823
|
+
this.expoProcess?.stdout?.pipe(this.expoLogStream);
|
|
2824
|
+
this.expoProcess?.stderr?.pipe(this.expoLogStream);
|
|
2820
2825
|
resolve3(true);
|
|
2821
2826
|
}
|
|
2822
|
-
} else if (qrDetected && !qrFinished) {
|
|
2823
|
-
process.stdout.write(line + "\n");
|
|
2824
2827
|
} else {
|
|
2825
2828
|
this.expoLogStream?.write(line + "\n");
|
|
2826
2829
|
}
|
|
@@ -2870,6 +2873,16 @@ var MobileServerManager = class {
|
|
|
2870
2873
|
await this.stop();
|
|
2871
2874
|
return { started: false, error: "Failed to start Expo server" };
|
|
2872
2875
|
}
|
|
2876
|
+
const expoUrl = `exp+${tunnelUrl}`;
|
|
2877
|
+
console.log("");
|
|
2878
|
+
console.log(" Scan with Expo Go:");
|
|
2879
|
+
qrcode.generate(expoUrl, { small: true }, (code) => {
|
|
2880
|
+
for (const line of code.split("\n")) {
|
|
2881
|
+
console.log(` ${line}`);
|
|
2882
|
+
}
|
|
2883
|
+
});
|
|
2884
|
+
console.log(` ${expoUrl}`);
|
|
2885
|
+
console.log("");
|
|
2873
2886
|
return { started: true, tunnelUrl };
|
|
2874
2887
|
}
|
|
2875
2888
|
async stop() {
|