pinggy 0.1.5 → 0.1.7

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 (58) hide show
  1. package/dist/chunk-HUN2MRZO.js +101 -0
  2. package/dist/index.cjs +3105 -0
  3. package/dist/index.d.cts +384 -0
  4. package/dist/index.d.ts +384 -0
  5. package/dist/index.js +2206 -55
  6. package/dist/tui-TJXEPR3U.js +584 -0
  7. package/package.json +16 -4
  8. package/src/cli/buildConfig.ts +3 -4
  9. package/src/cli/starCli.tsx +46 -32
  10. package/src/index.ts +25 -2
  11. package/src/logger.ts +64 -31
  12. package/src/remote_management/handler.ts +24 -10
  13. package/src/remote_management/remote_schema.ts +3 -3
  14. package/src/tui/sections/URLsSection.tsx +1 -1
  15. package/src/tunnel_manager/TunnelManager.ts +81 -43
  16. package/src/utils/esmOnlyPackageLoader.ts +29 -0
  17. package/src/utils/parseArgs.ts +42 -0
  18. package/src/utils/printer.ts +18 -10
  19. package/src/utils/util.ts +1 -1
  20. package/tsconfig.json +2 -2
  21. package/tsup.config.ts +12 -0
  22. package/dist/TunnelConfig.js +0 -39
  23. package/dist/cli/buildConfig.js +0 -336
  24. package/dist/cli/defaults.js +0 -18
  25. package/dist/cli/extendedOptions.js +0 -149
  26. package/dist/cli/help.js +0 -37
  27. package/dist/cli/options.js +0 -38
  28. package/dist/cli/starCli.js +0 -135
  29. package/dist/logger.js +0 -85
  30. package/dist/remote_management/handler.js +0 -141
  31. package/dist/remote_management/remoteManagement.js +0 -159
  32. package/dist/remote_management/remote_schema.js +0 -122
  33. package/dist/remote_management/websocket_handlers.js +0 -163
  34. package/dist/tui/asciArt.js +0 -7
  35. package/dist/tui/hooks/useQrCodes.js +0 -32
  36. package/dist/tui/hooks/useReqResHeaders.js +0 -36
  37. package/dist/tui/hooks/useTerminalSize.js +0 -21
  38. package/dist/tui/hooks/useTerminalStats.js +0 -20
  39. package/dist/tui/hooks/useWebDebugger.js +0 -82
  40. package/dist/tui/index.js +0 -106
  41. package/dist/tui/layout/Borders.js +0 -3
  42. package/dist/tui/layout/Container.js +0 -5
  43. package/dist/tui/sections/DebuggerDetailModal.js +0 -5
  44. package/dist/tui/sections/KeyBindings.js +0 -5
  45. package/dist/tui/sections/QrCodeSection.js +0 -7
  46. package/dist/tui/sections/StatsSection.js +0 -4
  47. package/dist/tui/sections/URLsSection.js +0 -26
  48. package/dist/tui/utils/utils.js +0 -30
  49. package/dist/tunnel_manager/TunnelManager.js +0 -808
  50. package/dist/types.js +0 -106
  51. package/dist/utils/FileServer.js +0 -112
  52. package/dist/utils/getFreePort.js +0 -38
  53. package/dist/utils/htmlTemplates.js +0 -135
  54. package/dist/utils/parseArgs.js +0 -10
  55. package/dist/utils/printer.js +0 -68
  56. package/dist/utils/util.js +0 -10
  57. package/dist/workers/file_serve_worker.js +0 -41
  58. package/src/TunnelConfig.ts +0 -40
@@ -0,0 +1,101 @@
1
+ // src/logger.ts
2
+ import winston from "winston";
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import { pinggy, LogLevel } from "@pinggy/pinggy";
6
+ var _logger = null;
7
+ function getLogger() {
8
+ if (!_logger) {
9
+ _logger = winston.createLogger({ level: "info", silent: true });
10
+ }
11
+ return _logger;
12
+ }
13
+ var logger = getLogger();
14
+ function applyLoggingConfig(cfg) {
15
+ const {
16
+ level,
17
+ filePath,
18
+ stdout = false,
19
+ source = false,
20
+ silent = false,
21
+ enableSdkLog = false
22
+ } = cfg;
23
+ if (enableSdkLog) {
24
+ enableLoggingByLogLevelInSdk(level ?? "info", filePath);
25
+ }
26
+ if (filePath) {
27
+ const dir = path.dirname(filePath);
28
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
29
+ }
30
+ const transports = [];
31
+ if (stdout) {
32
+ transports.push(
33
+ new winston.transports.Console({
34
+ format: winston.format.combine(
35
+ winston.format.colorize(),
36
+ winston.format.timestamp(),
37
+ winston.format.printf(({ level: level2, message, timestamp, ...meta }) => {
38
+ const srcLabel = source ? "[CLI] " : "";
39
+ return `${timestamp} ${srcLabel}[${level2}] ${message} ${Object.keys(meta).length ? JSON.stringify(meta) : ""}`;
40
+ })
41
+ )
42
+ })
43
+ );
44
+ }
45
+ if (filePath) {
46
+ transports.push(
47
+ new winston.transports.File({
48
+ filename: filePath,
49
+ format: winston.format.combine(
50
+ winston.format.timestamp(),
51
+ winston.format.printf(({ level: level2, message, timestamp, ...meta }) => {
52
+ return `${timestamp} [${level2}] ${message} ${Object.keys(meta).length ? JSON.stringify(meta) : ""}`;
53
+ })
54
+ )
55
+ })
56
+ );
57
+ }
58
+ const log = getLogger();
59
+ log.clear();
60
+ for (const t of transports) {
61
+ log.add(t);
62
+ }
63
+ log.level = (level || process.env.PINGGY_LOG_LEVEL || "info").toLowerCase();
64
+ log.silent = silent || transports.length === 0;
65
+ return log;
66
+ }
67
+ function configureLogger(values, silent = false) {
68
+ const level = values.loglevel || void 0;
69
+ const filePath = values.logfile || process.env.PINGGY_LOG_FILE || void 0;
70
+ const stdout = values.v || values.vvv || void 0;
71
+ const source = values.vvv ?? false;
72
+ const enableSdkLog = values.vv || values.vvv;
73
+ return applyLoggingConfig({
74
+ level,
75
+ filePath,
76
+ stdout,
77
+ source,
78
+ silent,
79
+ enableSdkLog
80
+ });
81
+ }
82
+ function enablePackageLogging(opts) {
83
+ return applyLoggingConfig(opts ?? {});
84
+ }
85
+ function enableLoggingByLogLevelInSdk(loglevel, logFilePath) {
86
+ if (!loglevel) return;
87
+ const l = loglevel.toUpperCase();
88
+ if (loglevel === "DEBUG") {
89
+ pinggy.setDebugLogging(true, LogLevel.DEBUG, logFilePath);
90
+ } else if (loglevel === "ERROR") {
91
+ pinggy.setDebugLogging(true, LogLevel.ERROR, logFilePath);
92
+ } else {
93
+ pinggy.setDebugLogging(true, LogLevel.INFO, logFilePath);
94
+ }
95
+ }
96
+
97
+ export {
98
+ logger,
99
+ configureLogger,
100
+ enablePackageLogging
101
+ };