pinggy 0.3.5 → 0.3.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 (68) hide show
  1. package/README.md +1 -1
  2. package/dist/chunk-65R2GMKQ.js +2101 -0
  3. package/dist/index.cjs +1798 -1349
  4. package/dist/index.d.cts +616 -0
  5. package/dist/index.d.ts +616 -0
  6. package/dist/index.js +24 -2
  7. package/dist/{main-K44C44NW.js → main-2QDG7PWL.js} +166 -1705
  8. package/package.json +2 -3
  9. package/.github/workflows/npm-publish-github-packages.yml +0 -34
  10. package/.github/workflows/publish-binaries.yml +0 -223
  11. package/Makefile +0 -4
  12. package/caxa_build.js +0 -24
  13. package/dist/chunk-T5ESYDJY.js +0 -121
  14. package/ent.plist +0 -14
  15. package/jest.config.js +0 -19
  16. package/src/_tests_/build_config.test.ts +0 -91
  17. package/src/cli/buildConfig.ts +0 -535
  18. package/src/cli/defaults.ts +0 -20
  19. package/src/cli/extendedOptions.ts +0 -153
  20. package/src/cli/help.ts +0 -43
  21. package/src/cli/options.ts +0 -50
  22. package/src/cli/starCli.ts +0 -229
  23. package/src/index.ts +0 -31
  24. package/src/logger.ts +0 -138
  25. package/src/main.ts +0 -87
  26. package/src/remote_management/handler.ts +0 -244
  27. package/src/remote_management/remoteManagement.ts +0 -226
  28. package/src/remote_management/remote_schema.ts +0 -176
  29. package/src/remote_management/websocket_handlers.ts +0 -180
  30. package/src/tui/blessed/TunnelTui.ts +0 -340
  31. package/src/tui/blessed/components/DisplayUpdaters.ts +0 -189
  32. package/src/tui/blessed/components/KeyBindings.ts +0 -236
  33. package/src/tui/blessed/components/Modals.ts +0 -302
  34. package/src/tui/blessed/components/UIComponents.ts +0 -306
  35. package/src/tui/blessed/components/index.ts +0 -4
  36. package/src/tui/blessed/config.ts +0 -53
  37. package/src/tui/blessed/headerFetcher.ts +0 -42
  38. package/src/tui/blessed/index.ts +0 -2
  39. package/src/tui/blessed/qrCodeGenerator.ts +0 -20
  40. package/src/tui/blessed/webDebuggerConnection.ts +0 -128
  41. package/src/tui/ink/asciArt.ts +0 -7
  42. package/src/tui/ink/hooks/useQrCodes.ts +0 -27
  43. package/src/tui/ink/hooks/useReqResHeaders.ts +0 -27
  44. package/src/tui/ink/hooks/useTerminalSize.ts +0 -26
  45. package/src/tui/ink/hooks/useTerminalStats.ts +0 -24
  46. package/src/tui/ink/hooks/useWebDebugger.ts +0 -98
  47. package/src/tui/ink/index.tsx +0 -243
  48. package/src/tui/ink/layout/Borders.tsx +0 -15
  49. package/src/tui/ink/layout/Container.tsx +0 -15
  50. package/src/tui/ink/sections/DebuggerDetailModal.tsx +0 -53
  51. package/src/tui/ink/sections/KeyBindings.tsx +0 -58
  52. package/src/tui/ink/sections/QrCodeSection.tsx +0 -28
  53. package/src/tui/ink/sections/StatsSection.tsx +0 -20
  54. package/src/tui/ink/sections/URLsSection.tsx +0 -53
  55. package/src/tui/ink/utils/utils.ts +0 -35
  56. package/src/tui/spinner/spinner.ts +0 -64
  57. package/src/tunnel_manager/TunnelManager.ts +0 -1212
  58. package/src/types.ts +0 -255
  59. package/src/utils/FileServer.ts +0 -112
  60. package/src/utils/detect_vc_redist_on_windows.ts +0 -111
  61. package/src/utils/getFreePort.ts +0 -41
  62. package/src/utils/htmlTemplates.ts +0 -146
  63. package/src/utils/parseArgs.ts +0 -79
  64. package/src/utils/printer.ts +0 -81
  65. package/src/utils/util.ts +0 -18
  66. package/src/workers/file_serve_worker.ts +0 -33
  67. package/tsconfig.json +0 -17
  68. package/tsup.config.ts +0 -12
@@ -1,79 +0,0 @@
1
- import { parseArgs } from "util";
2
- import * as os from "os";
3
-
4
- export type OptionSpec = {
5
- type: 'string' | 'boolean';
6
- multiple?: boolean;
7
- short?: string;
8
- description?: string;
9
- hidden?: boolean;
10
- };
11
-
12
-
13
- export type ParsedValues<T extends Record<string, OptionSpec>> = {
14
- [K in keyof T]:
15
- T[K]['type'] extends 'string'
16
- ? (T[K]['multiple'] extends true ? string[] : string | undefined)
17
- : (T[K]['type'] extends 'boolean' ? boolean | undefined : never);
18
- };
19
-
20
- // Check if arg starts with -R, -Ra, -Rhost, -Rh..., etc.
21
- function isInlineColonFlag(arg: string): boolean {
22
- return /^-([RL])[A-Za-z0-9._-]*:?$/.test(arg);
23
- }
24
-
25
-
26
- // Pre-processes command-line arguments to fix Windows-cmd-specific issues(arguments get split by ':')
27
- export function preprocessWindowsArgs(args: string[]): string[] {
28
- // if the os is not windows skip everything and return args. Problem is currently noticed only in windows
29
- if (os.platform() !== "win32") return args;
30
-
31
- const out: string[] = [];
32
- let i = 0;
33
- while (i < args.length) {
34
- const arg = args[i];
35
- // CASE 1: inline flags: -Rhost: -Ra.test.com:
36
- if (isInlineColonFlag(arg)) {
37
- // If next arg exists and is NOT a flag, merge it
38
- if (i + 1 < args.length && !args[i + 1].startsWith("-")) {
39
- let merged = arg + args[i + 1];
40
- i += 2;
41
- out.push(merged);
42
- continue;
43
- }
44
- out.push(arg);
45
- i++;
46
- continue;
47
- }
48
- // Default: push arg
49
- out.push(arg);
50
- i++;
51
- }
52
-
53
- return out;
54
- }
55
-
56
- export function parseCliArgs<T extends Record<string, OptionSpec>>(options: T) {
57
- const rawArgs = process.argv.slice(2);
58
-
59
- // Pre-process arguments for Windows compatibility
60
- const processedArgs = preprocessWindowsArgs(rawArgs);
61
- const parsed = parseArgs({
62
- args: processedArgs,
63
- options,
64
- allowPositionals: true,
65
- }) as unknown as {
66
- values: ParsedValues<T>;
67
- positionals: string[];
68
- };
69
-
70
- const hasAnyArgs =
71
- parsed.positionals.length > 0 ||
72
- Object.values(parsed.values).some(v => v !== undefined && v !== false);
73
-
74
- return {
75
- ...parsed,
76
- hasAnyArgs,
77
- }
78
-
79
- }
@@ -1,81 +0,0 @@
1
- import pico from "picocolors";
2
- import { startSpinner, stopSpinnerSuccess as stopSpinnerSuccessCustom, stopSpinnerFail as stopSpinnerFailCustom } from "../tui/spinner/spinner.js";
3
-
4
- interface CLIErrorDefinition {
5
- match: (err: unknown) => boolean;
6
- message: (err: unknown) => string;
7
- }
8
-
9
- class CLIPrinter {
10
-
11
- private static isCLIError(err: unknown): err is Error & { code?: string; option?: string; value?: string } {
12
- return err instanceof Error;
13
- }
14
- private static errorDefinitions: CLIErrorDefinition[] = [
15
- {
16
- match: (err) => this.isCLIError(err) && err.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION",
17
- message: (err) => {
18
- const match = /Unknown option '(.+?)'/.exec((err as any).message);
19
- const option = match ? match[1] : '(unknown)';
20
- return `Unknown option '${option}'. Please check your command or use pinggy --h for guidance.`;
21
- },
22
- },
23
- {
24
- match: (err) => this.isCLIError(err) && err.code === "ERR_PARSE_ARGS_MISSING_OPTION_VALUE",
25
- message: (err) => `Missing required argument for option '${(err as any).option}'.`,
26
- },
27
- {
28
- match: (err) => this.isCLIError(err) && err.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE",
29
- message: (err) => `Invalid argument'${(err as any).message}'.`,
30
- },
31
- {
32
- match: (err) => this.isCLIError(err) && err.code === "ENOENT",
33
- message: (err) => `File or directory not found: ${(err as any).message}`,
34
- },
35
- {
36
- match: () => true, // fallback
37
- message: (err) => (this.isCLIError(err) ? err.message : String(err)),
38
- },
39
- ];
40
-
41
- static print(message: string, ...args: any[]) {
42
- console.log(message, ...args);
43
- }
44
-
45
- static error(err: unknown) {
46
- const def = this.errorDefinitions.find((d) => d.match(err))!;
47
- const msg = def.message(err);
48
- console.error(pico.red(pico.bold("✖ Error:")), pico.red(msg));
49
- process.exit(1);
50
- }
51
-
52
- static warn(message: string) {
53
- console.warn(pico.yellow(pico.bold("⚠ Warning:")), pico.yellow(message));
54
- }
55
-
56
- static warnTxt(message: string) {
57
- console.warn(pico.yellow(pico.bold("⚠ Warning:")), pico.yellow(message));
58
- }
59
-
60
- static success(message: string) {
61
- console.log(pico.green(pico.bold(" ✔ Success:")), pico.green(message));
62
- }
63
-
64
- static async info(message: string) {
65
- console.log(pico.blue(message));
66
- }
67
-
68
- static startSpinner(message: string) {
69
- startSpinner('dots', message);
70
- }
71
-
72
- static stopSpinnerSuccess(message: string) {
73
- stopSpinnerSuccessCustom(message);
74
- }
75
-
76
- static stopSpinnerFail(message: string) {
77
- stopSpinnerFailCustom(message);
78
- }
79
- }
80
-
81
- export default CLIPrinter;
package/src/utils/util.ts DELETED
@@ -1,18 +0,0 @@
1
- import { readFileSync } from 'fs';
2
- import { createRequire } from 'module';
3
- import { randomUUID } from 'crypto';
4
-
5
- export function getRandomId() {
6
- return randomUUID();
7
- }
8
-
9
- export function isValidPort(p: number): boolean {
10
- return Number.isInteger(p) && p > 0 && p < 65536;
11
- }
12
-
13
- const require = createRequire(import.meta.url);
14
- const pkg = require('../package.json');
15
-
16
- export function getVersion(): string {
17
- return pkg.version ?? '';
18
- }
@@ -1,33 +0,0 @@
1
- import { parentPort, workerData } from "worker_threads";
2
- import { FileServerError, startFileServer } from "../utils/FileServer.js";
3
- import { logger } from "../logger.js";
4
-
5
- (async () => {
6
- try {
7
- const { dir, port } = workerData;
8
- const portNum = parseInt(port.split(":")[1]);
9
- const result = await startFileServer(dir, portNum);
10
- parentPort?.postMessage({ type: "started", portNum });
11
- if (result.hasInvalidPath && result.error) {
12
- parentPort?.postMessage({
13
- type: "warning",
14
- message: result.error.message,
15
- code: result.error.code,
16
- });
17
- }
18
-
19
-
20
-
21
- } catch (err) {
22
- console.log(err);
23
- if (err instanceof FileServerError) {
24
- parentPort?.postMessage({ type: "error", error: err.message, code: err.code });
25
- } else if (err instanceof Error) {
26
- parentPort?.postMessage({ type: "error", error: err.message });
27
- } else {
28
- parentPort?.postMessage({ type: "error", error: String(err) });
29
- }
30
- logger.debug("Error in FileServer thread", err);
31
- process.exit(1);
32
- }
33
- })();
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2020",
4
- "module": "nodenext",
5
- "moduleResolution": "nodenext",
6
- "esModuleInterop": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "outDir": "dist_tsc",
11
- "lib": ["es2017", "dom"],
12
- "types": ["node"],
13
- "jsx": "react-jsx",
14
- },
15
- "include": ["src/**/*", ".test"],
16
- "exclude": ["node_modules", "**/*.test.ts"]
17
- }
package/tsup.config.ts DELETED
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- entry: ["./src/index.ts","./src/workers/file_serve_worker.ts"],
5
- format: ["cjs", "esm"],
6
- dts: true,
7
- shims: true,
8
- skipNodeModulesBundle: true,
9
- clean: true,
10
- bundle: true,
11
- outDir: "dist",
12
- });