pinggy 0.1.5 → 0.1.6

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