portprism 2.0.3 → 2.0.5
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/README.md +144 -0
- package/dist/index.js +557 -107
- package/package.json +22 -6
- package/dist/__tests__/inspector.test.d.ts +0 -2
- package/dist/__tests__/inspector.test.d.ts.map +0 -1
- package/dist/__tests__/inspector.test.js +0 -80
- package/dist/__tests__/inspector.test.js.map +0 -1
- package/dist/agent.d.ts +0 -78
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -357
- package/dist/agent.js.map +0 -1
- package/dist/authStore.d.ts +0 -14
- package/dist/authStore.d.ts.map +0 -1
- package/dist/authStore.js +0 -34
- package/dist/authStore.js.map +0 -1
- package/dist/config.d.ts +0 -13
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -32
- package/dist/config.js.map +0 -1
- package/dist/display.d.ts +0 -37
- package/dist/display.d.ts.map +0 -1
- package/dist/display.js +0 -113
- package/dist/display.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inspector.d.ts +0 -58
- package/dist/inspector.d.ts.map +0 -1
- package/dist/inspector.js +0 -328
- package/dist/inspector.js.map +0 -1
package/dist/authStore.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authStore.js","sourceRoot":"","sources":["../src/authStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAYzB,MAAM,QAAQ,GAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE1D,MAAM,UAAU,QAAQ;IACtB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAa,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1E,gDAAgD;IAChD,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;IACrE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,6BAA6B;IAC/B,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface PortLensConfig {
|
|
2
|
-
relay: string;
|
|
3
|
-
defaultName: string;
|
|
4
|
-
defaultDesc: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Read ~/.portlens/config.json.
|
|
8
|
-
* If the file doesn't exist or is malformed, write defaults first then return them.
|
|
9
|
-
*/
|
|
10
|
-
export declare function readConfig(): PortLensConfig;
|
|
11
|
-
export declare function writeConfig(config: PortLensConfig): void;
|
|
12
|
-
export declare function configFilePath(): string;
|
|
13
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAWD;;;GAGG;AACH,wBAAgB,UAAU,IAAI,cAAc,CAQ3C;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAGxD;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
package/dist/config.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
const CONFIG_DIR = path.join(os.homedir(), ".portlens");
|
|
5
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
6
|
-
const DEFAULTS = {
|
|
7
|
-
relay: "wss://relay.portlens.net",
|
|
8
|
-
defaultName: "My App",
|
|
9
|
-
defaultDesc: "",
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Read ~/.portlens/config.json.
|
|
13
|
-
* If the file doesn't exist or is malformed, write defaults first then return them.
|
|
14
|
-
*/
|
|
15
|
-
export function readConfig() {
|
|
16
|
-
try {
|
|
17
|
-
const raw = fs.readFileSync(CONFIG_FILE, "utf8");
|
|
18
|
-
return { ...DEFAULTS, ...JSON.parse(raw) };
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
writeConfig(DEFAULTS);
|
|
22
|
-
return { ...DEFAULTS };
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export function writeConfig(config) {
|
|
26
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
27
|
-
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
28
|
-
}
|
|
29
|
-
export function configFilePath() {
|
|
30
|
-
return CONFIG_FILE;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAQzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACxD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEzD,MAAM,QAAQ,GAAmB;IAC/B,KAAK,EAAE,0BAA0B;IACjC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,EAAE;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAsB;IAChD,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/display.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export type TunnelStatus = "connected" | "reconnecting" | "disconnected";
|
|
2
|
-
export interface ReconnectInfo {
|
|
3
|
-
/** Milliseconds until the next attempt fires. */
|
|
4
|
-
delayMs: number;
|
|
5
|
-
/** Zero-based attempt index (0 = first retry). */
|
|
6
|
-
attempt: number;
|
|
7
|
-
maxAttempts: number;
|
|
8
|
-
}
|
|
9
|
-
export interface BoxOptions {
|
|
10
|
-
shareUrl: string;
|
|
11
|
-
localPort: number;
|
|
12
|
-
expiresAt: string | null;
|
|
13
|
-
status: TunnelStatus;
|
|
14
|
-
/**
|
|
15
|
-
* Most-recently measured ping round-trip time in milliseconds.
|
|
16
|
-
* Absent until the first ping/pong cycle completes (~30 s after connect).
|
|
17
|
-
*/
|
|
18
|
-
rtt?: number;
|
|
19
|
-
/**
|
|
20
|
-
* Present while status === "reconnecting"; drives the countdown display
|
|
21
|
-
* in the Status row without adding extra lines below the box.
|
|
22
|
-
*/
|
|
23
|
-
reconnectInfo?: ReconnectInfo;
|
|
24
|
-
}
|
|
25
|
-
/** Render the info box and return it as a string (ends with \n). */
|
|
26
|
-
export declare function renderBox(opts: BoxOptions): string;
|
|
27
|
-
/** Number of terminal lines the box occupies (used for cursor repositioning). */
|
|
28
|
-
export declare function boxLineCount(_opts: BoxOptions): number;
|
|
29
|
-
/** Print the box for the first time. */
|
|
30
|
-
export declare function printBox(opts: BoxOptions): void;
|
|
31
|
-
/**
|
|
32
|
-
* Overwrite the previously printed box in-place.
|
|
33
|
-
* Call this only when the box is the last thing printed to stdout
|
|
34
|
-
* (no other writes since the previous printBox / updateBox).
|
|
35
|
-
*/
|
|
36
|
-
export declare function updateBox(opts: BoxOptions): void;
|
|
37
|
-
//# sourceMappingURL=display.d.ts.map
|
package/dist/display.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AA6BA,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAEzE,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,OAAO,EAAM,MAAM,CAAC;IACpB,kDAAkD;IAClD,OAAO,EAAM,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAG,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAK,YAAY,CAAC;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAqDD,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CA+BlD;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAGtD;AAED,wCAAwC;AACxC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAIhD"}
|
package/dist/display.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
3
|
-
/** Strip ANSI escape codes to get the printable width of a string. */
|
|
4
|
-
function visibleLength(s) {
|
|
5
|
-
return s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
6
|
-
}
|
|
7
|
-
function padRight(s, width) {
|
|
8
|
-
const extra = width - visibleLength(s);
|
|
9
|
-
return extra > 0 ? s + " ".repeat(extra) : s;
|
|
10
|
-
}
|
|
11
|
-
function formatExpiry(expiresAt) {
|
|
12
|
-
if (!expiresAt)
|
|
13
|
-
return "No expiry";
|
|
14
|
-
const ms = new Date(expiresAt).getTime() - Date.now();
|
|
15
|
-
if (ms <= 0)
|
|
16
|
-
return "Expired";
|
|
17
|
-
const totalSec = Math.floor(ms / 1000);
|
|
18
|
-
const hours = Math.floor(totalSec / 3600);
|
|
19
|
-
const mins = Math.floor((totalSec % 3600) / 60);
|
|
20
|
-
const secs = totalSec % 60;
|
|
21
|
-
if (hours > 0)
|
|
22
|
-
return `${hours}h ${String(mins).padStart(2, "0")}m`;
|
|
23
|
-
if (mins > 0)
|
|
24
|
-
return `${mins}m ${String(secs).padStart(2, "0")}s`;
|
|
25
|
-
return `${secs}s`;
|
|
26
|
-
}
|
|
27
|
-
// ── Status line ───────────────────────────────────────────────────────────────
|
|
28
|
-
function rttLabel(rtt) {
|
|
29
|
-
const text = `(${rtt}ms)`;
|
|
30
|
-
if (rtt > 2_000)
|
|
31
|
-
return chalk.red(text);
|
|
32
|
-
if (rtt > 500)
|
|
33
|
-
return chalk.yellow(text);
|
|
34
|
-
return chalk.greenBright(text);
|
|
35
|
-
}
|
|
36
|
-
function statusLine(opts) {
|
|
37
|
-
switch (opts.status) {
|
|
38
|
-
case "connected": {
|
|
39
|
-
const base = chalk.greenBright("● Connected");
|
|
40
|
-
return opts.rtt !== undefined
|
|
41
|
-
? `${base} ${rttLabel(opts.rtt)}`
|
|
42
|
-
: base;
|
|
43
|
-
}
|
|
44
|
-
case "reconnecting": {
|
|
45
|
-
if (opts.reconnectInfo) {
|
|
46
|
-
const { delayMs, attempt, maxAttempts } = opts.reconnectInfo;
|
|
47
|
-
const secs = Math.floor(delayMs / 1000) || "<1";
|
|
48
|
-
return chalk.yellow(`◌ Reconnecting... (in ${secs}s, ${attempt + 1}/${maxAttempts})`);
|
|
49
|
-
}
|
|
50
|
-
return chalk.yellow("◌ Reconnecting...");
|
|
51
|
-
}
|
|
52
|
-
case "disconnected":
|
|
53
|
-
return chalk.red("○ Disconnected");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// ── Box renderer ──────────────────────────────────────────────────────────────
|
|
57
|
-
const LABEL_COL = 9; // length of "Share URL"
|
|
58
|
-
const LEFT_PAD = 2;
|
|
59
|
-
const RIGHT_PAD = 2;
|
|
60
|
-
function buildRows(opts) {
|
|
61
|
-
return [
|
|
62
|
-
{ label: "Share URL", value: opts.shareUrl },
|
|
63
|
-
{ label: "Local", value: `http://localhost:${opts.localPort}` },
|
|
64
|
-
{ label: "Expires", value: formatExpiry(opts.expiresAt) },
|
|
65
|
-
{ label: "Status", value: statusLine(opts) },
|
|
66
|
-
];
|
|
67
|
-
}
|
|
68
|
-
/** Render the info box and return it as a string (ends with \n). */
|
|
69
|
-
export function renderBox(opts) {
|
|
70
|
-
const rows = buildRows(opts);
|
|
71
|
-
const title = chalk.white.bold("PortLens tunnel active");
|
|
72
|
-
const rowLines = rows.map(({ label, value }) => {
|
|
73
|
-
const lbl = chalk.dim(label.padEnd(LABEL_COL));
|
|
74
|
-
const val = label === "Share URL"
|
|
75
|
-
? chalk.greenBright.bold(value)
|
|
76
|
-
: label === "Status"
|
|
77
|
-
? value // already coloured by statusLine()
|
|
78
|
-
: chalk.white(value);
|
|
79
|
-
return `${lbl} ${val}`;
|
|
80
|
-
});
|
|
81
|
-
const allLines = [title, "", ...rowLines];
|
|
82
|
-
const contentWidth = Math.max(...allLines.map(visibleLength));
|
|
83
|
-
const innerWidth = LEFT_PAD + contentWidth + RIGHT_PAD;
|
|
84
|
-
const border = chalk.green;
|
|
85
|
-
const h = "─".repeat(innerWidth);
|
|
86
|
-
const out = [];
|
|
87
|
-
out.push(border(`╭${h}╮`));
|
|
88
|
-
for (const line of allLines) {
|
|
89
|
-
out.push(`${border("│")}${" ".repeat(LEFT_PAD)}${padRight(line, contentWidth)}${" ".repeat(RIGHT_PAD)}${border("│")}`);
|
|
90
|
-
}
|
|
91
|
-
out.push(border(`╰${h}╯`));
|
|
92
|
-
return out.join("\n") + "\n";
|
|
93
|
-
}
|
|
94
|
-
/** Number of terminal lines the box occupies (used for cursor repositioning). */
|
|
95
|
-
export function boxLineCount(_opts) {
|
|
96
|
-
// top border + title + blank + 4 rows + bottom border = 8
|
|
97
|
-
return 8;
|
|
98
|
-
}
|
|
99
|
-
/** Print the box for the first time. */
|
|
100
|
-
export function printBox(opts) {
|
|
101
|
-
process.stdout.write(renderBox(opts));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Overwrite the previously printed box in-place.
|
|
105
|
-
* Call this only when the box is the last thing printed to stdout
|
|
106
|
-
* (no other writes since the previous printBox / updateBox).
|
|
107
|
-
*/
|
|
108
|
-
export function updateBox(opts) {
|
|
109
|
-
const lines = boxLineCount(opts);
|
|
110
|
-
process.stdout.write(`\x1b[${lines}A`); // cursor up
|
|
111
|
-
process.stdout.write(renderBox(opts));
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=display.js.map
|
package/dist/display.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,iFAAiF;AAEjF,sEAAsE;AACtE,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,KAAa;IACxC,MAAM,KAAK,GAAG,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACvC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,YAAY,CAAC,SAAwB;IAC5C,IAAI,CAAC,SAAS;QAAE,OAAO,WAAW,CAAC;IACnC,MAAM,EAAE,GA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C,GAAG,CAAC,CAAC,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,GAAG,CAAC,IAAI,CACN,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAC7G,CAAC;IACJ,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAC/B,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,0DAA0D;IAC1D,OAAO,CAAC,CAAC;AACX,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,QAAQ,CAAC,IAAgB;IACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAG,YAAY;IACtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRo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4EAA4E;IAC5E,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,aAAa,GAAG,WAAW,CAAC;QAC5B,aAAa,GAAG,SAAS,CAAC;QAC1B,IAAI,UAAU;YAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,2EAA2E;IAC3E,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAU,EAAE,EAAE;QAC7B,UAAU,GAAG,EAAE,CAAC;QAChB,IAAI,UAAU,IAAI,aAAa,KAAK,WAAW;YAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,IAAI,YAAY;YAAE,aAAa,CAAC,YAAY,CAAC,CAAC;QAC9C,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,OAAO,EAAE,CAAC;AAClB,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/inspector.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/** Raw event the Agent emits on its `traffic` channel. */
|
|
2
|
-
export interface TrafficEvent {
|
|
3
|
-
phase: "request" | "response";
|
|
4
|
-
id: string;
|
|
5
|
-
ts?: number;
|
|
6
|
-
method?: string;
|
|
7
|
-
path?: string;
|
|
8
|
-
/** base64 (as it travels on the wire); decoded for display. */
|
|
9
|
-
body?: string;
|
|
10
|
-
headers?: Record<string, string>;
|
|
11
|
-
status?: number;
|
|
12
|
-
durationMs?: number;
|
|
13
|
-
}
|
|
14
|
-
/** A decoded request/response body plus how to interpret it. */
|
|
15
|
-
interface DecodedBody {
|
|
16
|
-
/** Decoded UTF-8 text, or base64 for binary payloads. `null` when empty. */
|
|
17
|
-
text: string | null;
|
|
18
|
-
binary: boolean;
|
|
19
|
-
/** Byte length of the full (pre-truncation) payload. */
|
|
20
|
-
size: number;
|
|
21
|
-
truncated: boolean;
|
|
22
|
-
}
|
|
23
|
-
/** One fully-merged entry in the ledger. */
|
|
24
|
-
export interface RequestRecord {
|
|
25
|
-
id: string;
|
|
26
|
-
ts: number;
|
|
27
|
-
method: string;
|
|
28
|
-
path: string;
|
|
29
|
-
query: Record<string, string> | null;
|
|
30
|
-
reqHeaders: Record<string, string>;
|
|
31
|
-
reqBody: DecodedBody;
|
|
32
|
-
status?: number;
|
|
33
|
-
resHeaders?: Record<string, string>;
|
|
34
|
-
resBody?: DecodedBody;
|
|
35
|
-
durationMs?: number;
|
|
36
|
-
pending: boolean;
|
|
37
|
-
}
|
|
38
|
-
export declare class Inspector {
|
|
39
|
-
private readonly records;
|
|
40
|
-
private readonly byId;
|
|
41
|
-
private readonly sseClients;
|
|
42
|
-
private server;
|
|
43
|
-
private boundPort;
|
|
44
|
-
/** Ingest one traffic event from the agent, merging by request id. */
|
|
45
|
-
record(evt: TrafficEvent): void;
|
|
46
|
-
/** Compact summary used by the list view. */
|
|
47
|
-
private summary;
|
|
48
|
-
private broadcast;
|
|
49
|
-
/**
|
|
50
|
-
* Start the inspector HTTP server. Resolves with the bound URL, or `null` if the
|
|
51
|
-
* port is already taken (the tunnel must never fail because :4040 is busy).
|
|
52
|
-
*/
|
|
53
|
-
start(port: number): Promise<string | null>;
|
|
54
|
-
stop(): void;
|
|
55
|
-
private handle;
|
|
56
|
-
}
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=inspector.d.ts.map
|
package/dist/inspector.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":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uB;IAC/C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoC;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkC;IAC7D,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,SAAS,CAAuB;IAExC,sEAAsE;IACtE,MAAM,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI;IAmC/B,6CAA6C;IAC7C,OAAO,CAAC,OAAO;IAef,OAAO,CAAC,SAAS;IAYjB;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAkB3C,IAAI,IAAI,IAAI;IAaZ,OAAO,CAAC,MAAM;CA8Cf"}
|
package/dist/inspector.js
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inspector.ts — the `--inspect` Local Request Inspector.
|
|
3
|
-
*
|
|
4
|
-
* An ngrok-style traffic ledger served on localhost:4040. Every HTTP request the
|
|
5
|
-
* agent forwards to the local server is recorded here with its headers, query
|
|
6
|
-
* params, and (decoded) bodies, then surfaced through a small web UI and a JSON
|
|
7
|
-
* API — handy for webhook / API debugging.
|
|
8
|
-
*
|
|
9
|
-
* The agent emits `traffic` events ({ phase: "request" | "response", ... }); this
|
|
10
|
-
* module records them, merges the two phases by id, and pushes live updates to any
|
|
11
|
-
* connected browser over Server-Sent Events. Built on Node's native `http` — no
|
|
12
|
-
* extra dependency ships in the published CLI.
|
|
13
|
-
*/
|
|
14
|
-
import http from "node:http";
|
|
15
|
-
const MAX_RECORDS = 200;
|
|
16
|
-
const MAX_BODY_BYTES = 256 * 1024;
|
|
17
|
-
/** Content types we render as text rather than base64. */
|
|
18
|
-
const TEXT_CONTENT_RE = /(json|text\/|xml|x-www-form-urlencoded|javascript|html|csv|graphql)/i;
|
|
19
|
-
/** Split a raw request path into its pathname and parsed query object. */
|
|
20
|
-
function splitPath(rawPath) {
|
|
21
|
-
const qIdx = rawPath.indexOf("?");
|
|
22
|
-
if (qIdx === -1)
|
|
23
|
-
return { path: rawPath, query: null };
|
|
24
|
-
const path = rawPath.slice(0, qIdx);
|
|
25
|
-
const query = {};
|
|
26
|
-
const params = new URLSearchParams(rawPath.slice(qIdx + 1));
|
|
27
|
-
for (const [k, v] of params)
|
|
28
|
-
query[k] = v;
|
|
29
|
-
return { path, query: Object.keys(query).length ? query : null };
|
|
30
|
-
}
|
|
31
|
-
/** Decode a base64 wire body into text (or capped base64 for binary). */
|
|
32
|
-
function decodeBody(base64, headers) {
|
|
33
|
-
if (!base64)
|
|
34
|
-
return { text: null, binary: false, size: 0, truncated: false };
|
|
35
|
-
const buf = Buffer.from(base64, "base64");
|
|
36
|
-
const size = buf.length;
|
|
37
|
-
const truncated = size > MAX_BODY_BYTES;
|
|
38
|
-
const slice = truncated ? buf.subarray(0, MAX_BODY_BYTES) : buf;
|
|
39
|
-
const contentType = (headers?.["content-type"] ?? "").toLowerCase();
|
|
40
|
-
const looksText = contentType
|
|
41
|
-
? TEXT_CONTENT_RE.test(contentType)
|
|
42
|
-
: !slice.includes(0); // no content-type: treat as text unless it has NUL bytes
|
|
43
|
-
if (looksText) {
|
|
44
|
-
return { text: slice.toString("utf8"), binary: false, size, truncated };
|
|
45
|
-
}
|
|
46
|
-
return { text: slice.toString("base64"), binary: true, size, truncated };
|
|
47
|
-
}
|
|
48
|
-
export class Inspector {
|
|
49
|
-
records = [];
|
|
50
|
-
byId = new Map();
|
|
51
|
-
sseClients = new Set();
|
|
52
|
-
server = null;
|
|
53
|
-
boundPort = null;
|
|
54
|
-
/** Ingest one traffic event from the agent, merging by request id. */
|
|
55
|
-
record(evt) {
|
|
56
|
-
if (evt.phase === "request") {
|
|
57
|
-
const { path, query } = splitPath(evt.path ?? "");
|
|
58
|
-
const rec = {
|
|
59
|
-
id: evt.id,
|
|
60
|
-
ts: evt.ts ?? Date.now(),
|
|
61
|
-
method: evt.method ?? "GET",
|
|
62
|
-
path,
|
|
63
|
-
query,
|
|
64
|
-
reqHeaders: evt.headers ?? {},
|
|
65
|
-
reqBody: decodeBody(evt.body, evt.headers),
|
|
66
|
-
pending: true,
|
|
67
|
-
};
|
|
68
|
-
this.byId.set(rec.id, rec);
|
|
69
|
-
this.records.push(rec);
|
|
70
|
-
// Evict oldest beyond the cap.
|
|
71
|
-
while (this.records.length > MAX_RECORDS) {
|
|
72
|
-
const dropped = this.records.shift();
|
|
73
|
-
if (dropped)
|
|
74
|
-
this.byId.delete(dropped.id);
|
|
75
|
-
}
|
|
76
|
-
this.broadcast(rec);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
// response phase — merge into the existing record.
|
|
80
|
-
const rec = this.byId.get(evt.id);
|
|
81
|
-
if (!rec)
|
|
82
|
-
return;
|
|
83
|
-
rec.status = evt.status;
|
|
84
|
-
rec.resHeaders = evt.headers ?? {};
|
|
85
|
-
rec.resBody = decodeBody(evt.body, evt.headers);
|
|
86
|
-
rec.durationMs = evt.durationMs;
|
|
87
|
-
rec.pending = false;
|
|
88
|
-
this.broadcast(rec);
|
|
89
|
-
}
|
|
90
|
-
/** Compact summary used by the list view. */
|
|
91
|
-
summary(r) {
|
|
92
|
-
return {
|
|
93
|
-
id: r.id,
|
|
94
|
-
ts: r.ts,
|
|
95
|
-
method: r.method,
|
|
96
|
-
path: r.path,
|
|
97
|
-
status: r.status ?? null,
|
|
98
|
-
durationMs: r.durationMs ?? null,
|
|
99
|
-
pending: r.pending,
|
|
100
|
-
reqSize: r.reqBody.size,
|
|
101
|
-
resSize: r.resBody?.size ?? 0,
|
|
102
|
-
resContentType: r.resHeaders?.["content-type"] ?? null,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
broadcast(rec) {
|
|
106
|
-
if (this.sseClients.size === 0)
|
|
107
|
-
return;
|
|
108
|
-
const line = `data: ${JSON.stringify(this.summary(rec))}\n\n`;
|
|
109
|
-
for (const res of this.sseClients) {
|
|
110
|
-
try {
|
|
111
|
-
res.write(line);
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
/* client gone; cleaned up on close */
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Start the inspector HTTP server. Resolves with the bound URL, or `null` if the
|
|
120
|
-
* port is already taken (the tunnel must never fail because :4040 is busy).
|
|
121
|
-
*/
|
|
122
|
-
start(port) {
|
|
123
|
-
return new Promise((resolve) => {
|
|
124
|
-
const server = http.createServer((req, res) => this.handle(req, res));
|
|
125
|
-
server.once("error", (err) => {
|
|
126
|
-
if (err.code === "EADDRINUSE") {
|
|
127
|
-
resolve(null);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
resolve(null);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
server.listen(port, "127.0.0.1", () => {
|
|
134
|
-
this.server = server;
|
|
135
|
-
this.boundPort = server.address().port;
|
|
136
|
-
resolve(`http://localhost:${this.boundPort}`);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
stop() {
|
|
141
|
-
for (const res of this.sseClients) {
|
|
142
|
-
try {
|
|
143
|
-
res.end();
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
/* ignore */
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
this.sseClients.clear();
|
|
150
|
-
this.server?.close();
|
|
151
|
-
this.server = null;
|
|
152
|
-
}
|
|
153
|
-
handle(req, res) {
|
|
154
|
-
const url = req.url ?? "/";
|
|
155
|
-
if (url === "/" || url === "/index.html") {
|
|
156
|
-
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
157
|
-
res.end(INDEX_HTML);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (url === "/__pp/requests") {
|
|
161
|
-
const body = JSON.stringify(this.records.map((r) => this.summary(r)).reverse());
|
|
162
|
-
res.writeHead(200, { "content-type": "application/json" });
|
|
163
|
-
res.end(body);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (url.startsWith("/__pp/requests/")) {
|
|
167
|
-
const id = decodeURIComponent(url.slice("/__pp/requests/".length));
|
|
168
|
-
const rec = this.byId.get(id);
|
|
169
|
-
if (!rec) {
|
|
170
|
-
res.writeHead(404, { "content-type": "application/json" });
|
|
171
|
-
res.end(JSON.stringify({ error: "not found" }));
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
res.writeHead(200, { "content-type": "application/json" });
|
|
175
|
-
res.end(JSON.stringify(rec));
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (url === "/__pp/stream") {
|
|
179
|
-
res.writeHead(200, {
|
|
180
|
-
"content-type": "text/event-stream",
|
|
181
|
-
"cache-control": "no-cache",
|
|
182
|
-
connection: "keep-alive",
|
|
183
|
-
});
|
|
184
|
-
res.write("retry: 3000\n\n");
|
|
185
|
-
this.sseClients.add(res);
|
|
186
|
-
req.on("close", () => this.sseClients.delete(res));
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
res.writeHead(404, { "content-type": "text/plain" });
|
|
190
|
-
res.end("Not found");
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// ── Web UI ──────────────────────────────────────────────────────────────────────
|
|
194
|
-
// Single self-contained page. Client JS uses string concatenation (no template
|
|
195
|
-
// literals) so it survives being embedded in this module's own template literal.
|
|
196
|
-
const INDEX_HTML = `<!doctype html>
|
|
197
|
-
<html lang="en">
|
|
198
|
-
<head>
|
|
199
|
-
<meta charset="utf-8">
|
|
200
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
201
|
-
<title>PortPrism Inspector</title>
|
|
202
|
-
<style>
|
|
203
|
-
:root { color-scheme: dark; }
|
|
204
|
-
* { box-sizing: border-box; }
|
|
205
|
-
body { margin:0; font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
|
|
206
|
-
background:#0b0d12; color:#e6e8ee; }
|
|
207
|
-
header { display:flex; align-items:center; gap:10px; padding:12px 16px;
|
|
208
|
-
border-bottom:1px solid #1c2030; background:#0e1017; position:sticky; top:0; }
|
|
209
|
-
header .logo { font-weight:700; background:linear-gradient(90deg,#6366f1,#8b5cf6,#34d399);
|
|
210
|
-
-webkit-background-clip:text; background-clip:text; color:transparent; }
|
|
211
|
-
header .dim { color:#7b8194; font-size:12px; }
|
|
212
|
-
header .live { margin-left:auto; display:flex; align-items:center; gap:6px; color:#7b8194; }
|
|
213
|
-
header .dot { width:8px; height:8px; border-radius:50%; background:#34d399; box-shadow:0 0 8px #34d399; }
|
|
214
|
-
.layout { display:grid; grid-template-columns: 1fr; }
|
|
215
|
-
table { width:100%; border-collapse:collapse; }
|
|
216
|
-
th,td { text-align:left; padding:7px 12px; border-bottom:1px solid #151824; white-space:nowrap; }
|
|
217
|
-
th { color:#7b8194; font-weight:600; font-size:11px; text-transform:uppercase; letter-spacing:.05em; }
|
|
218
|
-
tr.row { cursor:pointer; }
|
|
219
|
-
tr.row:hover { background:#12151f; }
|
|
220
|
-
.method { font-weight:700; }
|
|
221
|
-
.m-GET{color:#34d399} .m-POST{color:#60a5fa} .m-PUT{color:#fbbf24}
|
|
222
|
-
.m-DELETE{color:#f87171} .m-PATCH{color:#c084fc}
|
|
223
|
-
.st-2{color:#34d399} .st-3{color:#60a5fa} .st-4{color:#fbbf24} .st-5{color:#f87171}
|
|
224
|
-
.pending{color:#7b8194}
|
|
225
|
-
.path { color:#e6e8ee; max-width:48vw; overflow:hidden; text-overflow:ellipsis; }
|
|
226
|
-
.empty { padding:48px 16px; text-align:center; color:#7b8194; }
|
|
227
|
-
dialog { width:min(860px,92vw); max-height:86vh; overflow:auto; background:#0e1017;
|
|
228
|
-
color:#e6e8ee; border:1px solid #262b3d; border-radius:12px; padding:0; }
|
|
229
|
-
dialog::backdrop { background:rgba(0,0,0,.6); }
|
|
230
|
-
.d-head { display:flex; align-items:center; gap:10px; padding:14px 18px; border-bottom:1px solid #1c2030;
|
|
231
|
-
position:sticky; top:0; background:#0e1017; }
|
|
232
|
-
.d-head .x { margin-left:auto; cursor:pointer; color:#7b8194; background:none; border:none; font-size:18px; }
|
|
233
|
-
.d-body { padding:14px 18px; }
|
|
234
|
-
h4 { margin:18px 0 6px; color:#7b8194; font-size:11px; text-transform:uppercase; letter-spacing:.05em; }
|
|
235
|
-
h4:first-child { margin-top:0; }
|
|
236
|
-
pre { margin:0; padding:10px 12px; background:#0b0d12; border:1px solid #151824; border-radius:8px;
|
|
237
|
-
overflow:auto; white-space:pre-wrap; word-break:break-word; }
|
|
238
|
-
.kv { display:grid; grid-template-columns:200px 1fr; gap:2px 12px; }
|
|
239
|
-
.kv .k { color:#7b8194; } .kv .v { word-break:break-word; }
|
|
240
|
-
.tag { font-size:11px; color:#7b8194; }
|
|
241
|
-
</style>
|
|
242
|
-
</head>
|
|
243
|
-
<body>
|
|
244
|
-
<header>
|
|
245
|
-
<span class="logo">PortPrism</span><span class="dim">Request Inspector</span>
|
|
246
|
-
<span class="live"><span class="dot"></span> live</span>
|
|
247
|
-
</header>
|
|
248
|
-
<div class="layout">
|
|
249
|
-
<table>
|
|
250
|
-
<thead><tr><th>Time</th><th>Method</th><th>Status</th><th>Path</th><th>Dur</th><th>Size</th></tr></thead>
|
|
251
|
-
<tbody id="rows"></tbody>
|
|
252
|
-
</table>
|
|
253
|
-
<div class="empty" id="empty">Waiting for requests… send traffic through your tunnel.</div>
|
|
254
|
-
</div>
|
|
255
|
-
<dialog id="dlg"><div class="d-head"><b id="d-title"></b><button class="x" id="d-close">✕</button></div><div class="d-body" id="d-body"></div></dialog>
|
|
256
|
-
<script>
|
|
257
|
-
(function(){
|
|
258
|
-
var rows = document.getElementById("rows");
|
|
259
|
-
var empty = document.getElementById("empty");
|
|
260
|
-
var dlg = document.getElementById("dlg");
|
|
261
|
-
var seen = {};
|
|
262
|
-
|
|
263
|
-
function esc(s){ return String(s).replace(/[&<>"]/g, function(c){
|
|
264
|
-
return {"&":"&","<":"<",">":">","\\"":"""}[c]; }); }
|
|
265
|
-
function mclass(m){ return "method m-" + esc(m); }
|
|
266
|
-
function sclass(s){ return s ? "st-" + String(s)[0] : "pending"; }
|
|
267
|
-
function fmtTime(ts){ var d = new Date(ts); return d.toLocaleTimeString(); }
|
|
268
|
-
function fmtSize(n){ if(!n) return "—"; if(n<1024) return n+" B"; return (n/1024).toFixed(1)+" KB"; }
|
|
269
|
-
function fmtDur(d){ return d==null ? "…" : d+" ms"; }
|
|
270
|
-
|
|
271
|
-
function upsert(s){
|
|
272
|
-
empty.style.display = "none";
|
|
273
|
-
var id = s.id;
|
|
274
|
-
var tr = document.getElementById("r-"+id);
|
|
275
|
-
var html = "<td>"+fmtTime(s.ts)+"</td>"
|
|
276
|
-
+ "<td class='"+mclass(s.method)+"'>"+esc(s.method)+"</td>"
|
|
277
|
-
+ "<td class='"+sclass(s.status)+"'>"+(s.status||"…")+"</td>"
|
|
278
|
-
+ "<td class='path'>"+esc(s.path)+"</td>"
|
|
279
|
-
+ "<td class='tag'>"+fmtDur(s.durationMs)+"</td>"
|
|
280
|
-
+ "<td class='tag'>"+fmtSize(s.resSize||s.reqSize)+"</td>";
|
|
281
|
-
if(tr){ tr.innerHTML = html; }
|
|
282
|
-
else {
|
|
283
|
-
tr = document.createElement("tr");
|
|
284
|
-
tr.className = "row"; tr.id = "r-"+id; tr.innerHTML = html;
|
|
285
|
-
tr.onclick = function(){ openDetail(id); };
|
|
286
|
-
rows.insertBefore(tr, rows.firstChild);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function section(title, obj){
|
|
291
|
-
if(!obj || !Object.keys(obj).length) return "";
|
|
292
|
-
var out = "<h4>"+esc(title)+"</h4><div class='kv'>";
|
|
293
|
-
Object.keys(obj).forEach(function(k){
|
|
294
|
-
out += "<div class='k'>"+esc(k)+"</div><div class='v'>"+esc(obj[k])+"</div>";
|
|
295
|
-
});
|
|
296
|
-
return out + "</div>";
|
|
297
|
-
}
|
|
298
|
-
function bodySection(title, b){
|
|
299
|
-
if(!b || !b.text) return "";
|
|
300
|
-
var note = (b.binary ? " (binary, base64)" : "") + (b.truncated ? " (truncated)" : "");
|
|
301
|
-
return "<h4>"+esc(title)+note+"</h4><pre>"+esc(b.text)+"</pre>";
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function openDetail(id){
|
|
305
|
-
fetch("/__pp/requests/"+encodeURIComponent(id)).then(function(r){return r.json();}).then(function(d){
|
|
306
|
-
document.getElementById("d-title").textContent = d.method+" "+d.path
|
|
307
|
-
+ (d.status ? " → "+d.status : "");
|
|
308
|
-
var html = section("Query", d.query)
|
|
309
|
-
+ section("Request headers", d.reqHeaders)
|
|
310
|
-
+ bodySection("Request body", d.reqBody)
|
|
311
|
-
+ section("Response headers", d.resHeaders)
|
|
312
|
-
+ bodySection("Response body", d.resBody);
|
|
313
|
-
document.getElementById("d-body").innerHTML = html || "<p class='tag'>No details.</p>";
|
|
314
|
-
dlg.showModal();
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
document.getElementById("d-close").onclick = function(){ dlg.close(); };
|
|
318
|
-
|
|
319
|
-
fetch("/__pp/requests").then(function(r){return r.json();}).then(function(list){
|
|
320
|
-
list.reverse().forEach(upsert);
|
|
321
|
-
});
|
|
322
|
-
var es = new EventSource("/__pp/stream");
|
|
323
|
-
es.onmessage = function(e){ try { upsert(JSON.parse(e.data)); } catch(_){} };
|
|
324
|
-
})();
|
|
325
|
-
</script>
|
|
326
|
-
</body>
|
|
327
|
-
</html>`;
|
|
328
|
-
//# sourceMappingURL=inspector.js.map
|