pinggy 0.3.2 → 0.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/chunk-T5ESYDJY.js +121 -0
- package/dist/index.cjs +2544 -1837
- package/dist/index.d.cts +0 -550
- package/dist/index.d.ts +0 -550
- package/dist/index.js +105 -3493
- package/dist/main-CZY6GID4.js +3726 -0
- package/package.json +1 -1
- package/src/cli/buildConfig.ts +124 -17
- package/src/index.ts +21 -78
- package/src/main.ts +87 -0
- package/src/tui/blessed/TunnelTui.ts +47 -5
- package/src/tui/blessed/components/DisplayUpdaters.ts +80 -9
- package/src/tui/blessed/components/KeyBindings.ts +124 -22
- package/src/tui/blessed/components/Modals.ts +87 -1
- package/src/tui/blessed/config.ts +53 -0
- package/src/tui/blessed/headerFetcher.ts +9 -2
- package/src/tui/blessed/webDebuggerConnection.ts +41 -13
- package/src/tui/ink/utils/utils.ts +1 -1
- package/src/tunnel_manager/TunnelManager.ts +3 -3
- package/src/types.ts +4 -10
- package/src/utils/detect_vc_redist_on_windows.ts +167 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// src/utils/printer.ts
|
|
2
|
+
import pico2 from "picocolors";
|
|
3
|
+
|
|
4
|
+
// src/tui/spinner/spinner.ts
|
|
5
|
+
import pico from "picocolors";
|
|
6
|
+
var spinners = {
|
|
7
|
+
dots: {
|
|
8
|
+
interval: 80,
|
|
9
|
+
frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"]
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var currentTimer = null;
|
|
13
|
+
var currentText = "";
|
|
14
|
+
function startSpinner(name = "dots", text = "Loading") {
|
|
15
|
+
const spinner = spinners[name];
|
|
16
|
+
let i = 0;
|
|
17
|
+
currentText = text;
|
|
18
|
+
if (currentTimer) {
|
|
19
|
+
clearInterval(currentTimer);
|
|
20
|
+
}
|
|
21
|
+
currentTimer = setInterval(() => {
|
|
22
|
+
const frame = spinner.frames[i = ++i % spinner.frames.length];
|
|
23
|
+
process.stdout.write(`\r${pico.cyan(frame)} ${text}`);
|
|
24
|
+
}, spinner.interval);
|
|
25
|
+
return () => stopSpinner();
|
|
26
|
+
}
|
|
27
|
+
function stopSpinner() {
|
|
28
|
+
if (currentTimer) {
|
|
29
|
+
clearInterval(currentTimer);
|
|
30
|
+
currentTimer = null;
|
|
31
|
+
process.stdout.write("\r\x1B[K");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function stopSpinnerSuccess(message) {
|
|
35
|
+
if (currentTimer) {
|
|
36
|
+
clearInterval(currentTimer);
|
|
37
|
+
currentTimer = null;
|
|
38
|
+
const finalMessage = message || currentText;
|
|
39
|
+
process.stdout.write(`\r${pico.green("\u2714")} ${finalMessage}
|
|
40
|
+
`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function stopSpinnerFail(message) {
|
|
44
|
+
if (currentTimer) {
|
|
45
|
+
clearInterval(currentTimer);
|
|
46
|
+
currentTimer = null;
|
|
47
|
+
const finalMessage = message || currentText;
|
|
48
|
+
process.stdout.write(`\r${pico.red("\u2716")} ${finalMessage}
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/utils/printer.ts
|
|
54
|
+
var _CLIPrinter = class _CLIPrinter {
|
|
55
|
+
static isCLIError(err) {
|
|
56
|
+
return err instanceof Error;
|
|
57
|
+
}
|
|
58
|
+
static print(message, ...args) {
|
|
59
|
+
console.log(message, ...args);
|
|
60
|
+
}
|
|
61
|
+
static error(err) {
|
|
62
|
+
const def = this.errorDefinitions.find((d) => d.match(err));
|
|
63
|
+
const msg = def.message(err);
|
|
64
|
+
console.error(pico2.red(pico2.bold("\u2716 Error:")), pico2.red(msg));
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
static warn(message) {
|
|
68
|
+
console.warn(pico2.yellow(pico2.bold("\u26A0 Warning:")), pico2.yellow(message));
|
|
69
|
+
}
|
|
70
|
+
static warnTxt(message) {
|
|
71
|
+
console.warn(pico2.yellow(pico2.bold("\u26A0 Warning:")), pico2.yellow(message));
|
|
72
|
+
}
|
|
73
|
+
static success(message) {
|
|
74
|
+
console.log(pico2.green(pico2.bold(" \u2714 Success:")), pico2.green(message));
|
|
75
|
+
}
|
|
76
|
+
static async info(message) {
|
|
77
|
+
console.log(pico2.blue(message));
|
|
78
|
+
}
|
|
79
|
+
static startSpinner(message) {
|
|
80
|
+
startSpinner("dots", message);
|
|
81
|
+
}
|
|
82
|
+
static stopSpinnerSuccess(message) {
|
|
83
|
+
stopSpinnerSuccess(message);
|
|
84
|
+
}
|
|
85
|
+
static stopSpinnerFail(message) {
|
|
86
|
+
stopSpinnerFail(message);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
_CLIPrinter.errorDefinitions = [
|
|
90
|
+
{
|
|
91
|
+
match: (err) => _CLIPrinter.isCLIError(err) && err.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION",
|
|
92
|
+
message: (err) => {
|
|
93
|
+
const match = /Unknown option '(.+?)'/.exec(err.message);
|
|
94
|
+
const option = match ? match[1] : "(unknown)";
|
|
95
|
+
return `Unknown option '${option}'. Please check your command or use pinggy --h for guidance.`;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
match: (err) => _CLIPrinter.isCLIError(err) && err.code === "ERR_PARSE_ARGS_MISSING_OPTION_VALUE",
|
|
100
|
+
message: (err) => `Missing required argument for option '${err.option}'.`
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
match: (err) => _CLIPrinter.isCLIError(err) && err.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE",
|
|
104
|
+
message: (err) => `Invalid argument'${err.message}'.`
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
match: (err) => _CLIPrinter.isCLIError(err) && err.code === "ENOENT",
|
|
108
|
+
message: (err) => `File or directory not found: ${err.message}`
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
match: () => true,
|
|
112
|
+
// fallback
|
|
113
|
+
message: (err) => _CLIPrinter.isCLIError(err) ? err.message : String(err)
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
var CLIPrinter = _CLIPrinter;
|
|
117
|
+
var printer_default = CLIPrinter;
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
printer_default
|
|
121
|
+
};
|