@hydration-audit/dashboard 0.2.0 → 0.2.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Harshal AP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ module.exports = __toCommonJS(index_exports);
38
38
  var import_node_http = __toESM(require("http"), 1);
39
39
  var import_node_fs = __toESM(require("fs"), 1);
40
40
  var import_node_path = __toESM(require("path"), 1);
41
+ var import_node_url = require("url");
41
42
  var import_ws = require("ws");
42
43
  var import_meta = {};
43
44
  var MIME_TYPES = {
@@ -56,10 +57,8 @@ async function startDashboard(reportPath, port = 4173) {
56
57
  } catch {
57
58
  console.warn(`Could not read report at ${absoluteReportPath}`);
58
59
  }
59
- const staticDir = import_node_path.default.resolve(
60
- import_node_path.default.dirname(new URL(import_meta.url).pathname),
61
- "app"
62
- );
60
+ const currentDir = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
61
+ const staticDir = import_node_fs.default.existsSync(import_node_path.default.join(currentDir, "app")) ? import_node_path.default.join(currentDir, "app") : currentDir;
63
62
  const server = import_node_http.default.createServer((req, res) => {
64
63
  const url = req.url ?? "/";
65
64
  if (url === "/api/report") {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/server.ts"],"sourcesContent":["export { startDashboard } from './server.js';\n","import http from 'node:http';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { WebSocketServer } from 'ws';\nimport type { AnalysisReport } from '@hydration-audit/core';\n\nconst MIME_TYPES: Record<string, string> = {\n '.html': 'text/html',\n '.js': 'application/javascript',\n '.css': 'text/css',\n '.json': 'application/json',\n '.svg': 'image/svg+xml',\n};\n\n/**\n * Start the dashboard server.\n * Serves a static SPA and provides a WebSocket for live report updates.\n */\nexport async function startDashboard(\n reportPath: string,\n port = 4173,\n): Promise<{ url: string; close: () => void }> {\n const absoluteReportPath = path.resolve(reportPath);\n\n // Read the initial report\n let currentReport: AnalysisReport | null = null;\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n } catch {\n console.warn(`Could not read report at ${absoluteReportPath}`);\n }\n\n const staticDir = path.resolve(\n path.dirname(new URL(import.meta.url).pathname),\n 'app',\n );\n\n const server = http.createServer((req, res) => {\n const url = req.url ?? '/';\n\n // API endpoint for report data\n if (url === '/api/report') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(currentReport ?? { error: 'No report loaded' }));\n return;\n }\n\n // Serve static files\n let filePath = path.join(staticDir, url === '/' ? 'index.html' : url);\n const ext = path.extname(filePath);\n\n // SPA fallback — serve index.html for non-file routes\n if (!ext) {\n filePath = path.join(staticDir, 'index.html');\n }\n\n try {\n const content = fs.readFileSync(filePath);\n const mime = MIME_TYPES[path.extname(filePath)] ?? 'text/plain';\n res.writeHead(200, { 'Content-Type': mime });\n res.end(content);\n } catch {\n res.writeHead(404);\n res.end('Not found');\n }\n });\n\n // WebSocket for live reload\n const wss = new WebSocketServer({ server });\n\n // Watch report file for changes\n let watcher: fs.FSWatcher | null = null;\n try {\n watcher = fs.watch(absoluteReportPath, () => {\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n // Notify all connected clients\n for (const client of wss.clients) {\n if (client.readyState === 1) {\n client.send(JSON.stringify({ type: 'update', report: currentReport }));\n }\n }\n } catch {\n // Ignore parse errors during write\n }\n });\n } catch {\n console.warn('Could not watch report file for changes');\n }\n\n return new Promise((resolve) => {\n server.listen(port, () => {\n const url = `http://localhost:${port}`;\n console.log(`\\n Dashboard running at ${url}\\n`);\n resolve({\n url,\n close: () => {\n watcher?.close();\n wss.close();\n server.close();\n },\n });\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAiB;AACjB,qBAAe;AACf,uBAAiB;AACjB,gBAAgC;AAHhC;AAMA,IAAM,aAAqC;AAAA,EACzC,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AACV;AAMA,eAAsB,eACpB,YACA,OAAO,MACsC;AAC7C,QAAM,qBAAqB,iBAAAA,QAAK,QAAQ,UAAU;AAGlD,MAAI,gBAAuC;AAC3C,MAAI;AACF,UAAM,UAAU,eAAAC,QAAG,aAAa,oBAAoB,OAAO;AAC3D,oBAAgB,KAAK,MAAM,OAAO;AAAA,EACpC,QAAQ;AACN,YAAQ,KAAK,4BAA4B,kBAAkB,EAAE;AAAA,EAC/D;AAEA,QAAM,YAAY,iBAAAD,QAAK;AAAA,IACrB,iBAAAA,QAAK,QAAQ,IAAI,IAAI,YAAY,GAAG,EAAE,QAAQ;AAAA,IAC9C;AAAA,EACF;AAEA,QAAM,SAAS,iBAAAE,QAAK,aAAa,CAAC,KAAK,QAAQ;AAC7C,UAAM,MAAM,IAAI,OAAO;AAGvB,QAAI,QAAQ,eAAe;AACzB,UAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,UAAI,IAAI,KAAK,UAAU,iBAAiB,EAAE,OAAO,mBAAmB,CAAC,CAAC;AACtE;AAAA,IACF;AAGA,QAAI,WAAW,iBAAAF,QAAK,KAAK,WAAW,QAAQ,MAAM,eAAe,GAAG;AACpE,UAAM,MAAM,iBAAAA,QAAK,QAAQ,QAAQ;AAGjC,QAAI,CAAC,KAAK;AACR,iBAAW,iBAAAA,QAAK,KAAK,WAAW,YAAY;AAAA,IAC9C;AAEA,QAAI;AACF,YAAM,UAAU,eAAAC,QAAG,aAAa,QAAQ;AACxC,YAAM,OAAO,WAAW,iBAAAD,QAAK,QAAQ,QAAQ,CAAC,KAAK;AACnD,UAAI,UAAU,KAAK,EAAE,gBAAgB,KAAK,CAAC;AAC3C,UAAI,IAAI,OAAO;AAAA,IACjB,QAAQ;AACN,UAAI,UAAU,GAAG;AACjB,UAAI,IAAI,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAGD,QAAM,MAAM,IAAI,0BAAgB,EAAE,OAAO,CAAC;AAG1C,MAAI,UAA+B;AACnC,MAAI;AACF,cAAU,eAAAC,QAAG,MAAM,oBAAoB,MAAM;AAC3C,UAAI;AACF,cAAM,UAAU,eAAAA,QAAG,aAAa,oBAAoB,OAAO;AAC3D,wBAAgB,KAAK,MAAM,OAAO;AAElC,mBAAW,UAAU,IAAI,SAAS;AAChC,cAAI,OAAO,eAAe,GAAG;AAC3B,mBAAO,KAAK,KAAK,UAAU,EAAE,MAAM,UAAU,QAAQ,cAAc,CAAC,CAAC;AAAA,UACvE;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF,CAAC;AAAA,EACH,QAAQ;AACN,YAAQ,KAAK,yCAAyC;AAAA,EACxD;AAEA,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,WAAO,OAAO,MAAM,MAAM;AACxB,YAAM,MAAM,oBAAoB,IAAI;AACpC,cAAQ,IAAI;AAAA,yBAA4B,GAAG;AAAA,CAAI;AAC/C,cAAQ;AAAA,QACN;AAAA,QACA,OAAO,MAAM;AACX,mBAAS,MAAM;AACf,cAAI,MAAM;AACV,iBAAO,MAAM;AAAA,QACf;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;","names":["path","fs","http"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/server.ts"],"sourcesContent":["export { startDashboard } from './server.js';\n","import http from 'node:http';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { WebSocketServer } from 'ws';\nimport type { AnalysisReport } from '@hydration-audit/core';\n\nconst MIME_TYPES: Record<string, string> = {\n '.html': 'text/html',\n '.js': 'application/javascript',\n '.css': 'text/css',\n '.json': 'application/json',\n '.svg': 'image/svg+xml',\n};\n\n/**\n * Start the dashboard server.\n * Serves a static SPA and provides a WebSocket for live report updates.\n */\nexport async function startDashboard(\n reportPath: string,\n port = 4173,\n): Promise<{ url: string; close: () => void }> {\n const absoluteReportPath = path.resolve(reportPath);\n\n // Read the initial report\n let currentReport: AnalysisReport | null = null;\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n } catch {\n console.warn(`Could not read report at ${absoluteReportPath}`);\n }\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n const staticDir = fs.existsSync(path.join(currentDir, 'app'))\n ? path.join(currentDir, 'app')\n : currentDir;\n\n const server = http.createServer((req, res) => {\n const url = req.url ?? '/';\n\n // API endpoint for report data\n if (url === '/api/report') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(currentReport ?? { error: 'No report loaded' }));\n return;\n }\n\n // Serve static files\n let filePath = path.join(staticDir, url === '/' ? 'index.html' : url);\n const ext = path.extname(filePath);\n\n // SPA fallback — serve index.html for non-file routes\n if (!ext) {\n filePath = path.join(staticDir, 'index.html');\n }\n\n try {\n const content = fs.readFileSync(filePath);\n const mime = MIME_TYPES[path.extname(filePath)] ?? 'text/plain';\n res.writeHead(200, { 'Content-Type': mime });\n res.end(content);\n } catch {\n res.writeHead(404);\n res.end('Not found');\n }\n });\n\n // WebSocket for live reload\n const wss = new WebSocketServer({ server });\n\n // Watch report file for changes\n let watcher: fs.FSWatcher | null = null;\n try {\n watcher = fs.watch(absoluteReportPath, () => {\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n // Notify all connected clients\n for (const client of wss.clients) {\n if (client.readyState === 1) {\n client.send(JSON.stringify({ type: 'update', report: currentReport }));\n }\n }\n } catch {\n // Ignore parse errors during write\n }\n });\n } catch {\n console.warn('Could not watch report file for changes');\n }\n\n return new Promise((resolve) => {\n server.listen(port, () => {\n const url = `http://localhost:${port}`;\n console.log(`\\n Dashboard running at ${url}\\n`);\n resolve({\n url,\n close: () => {\n watcher?.close();\n wss.close();\n server.close();\n },\n });\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAAiB;AACjB,qBAAe;AACf,uBAAiB;AACjB,sBAA8B;AAC9B,gBAAgC;AAJhC;AAOA,IAAM,aAAqC;AAAA,EACzC,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AACV;AAMA,eAAsB,eACpB,YACA,OAAO,MACsC;AAC7C,QAAM,qBAAqB,iBAAAA,QAAK,QAAQ,UAAU;AAGlD,MAAI,gBAAuC;AAC3C,MAAI;AACF,UAAM,UAAU,eAAAC,QAAG,aAAa,oBAAoB,OAAO;AAC3D,oBAAgB,KAAK,MAAM,OAAO;AAAA,EACpC,QAAQ;AACN,YAAQ,KAAK,4BAA4B,kBAAkB,EAAE;AAAA,EAC/D;AAEA,QAAM,aAAa,iBAAAD,QAAK,YAAQ,+BAAc,YAAY,GAAG,CAAC;AAC9D,QAAM,YAAY,eAAAC,QAAG,WAAW,iBAAAD,QAAK,KAAK,YAAY,KAAK,CAAC,IACxD,iBAAAA,QAAK,KAAK,YAAY,KAAK,IAC3B;AAEJ,QAAM,SAAS,iBAAAE,QAAK,aAAa,CAAC,KAAK,QAAQ;AAC7C,UAAM,MAAM,IAAI,OAAO;AAGvB,QAAI,QAAQ,eAAe;AACzB,UAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,UAAI,IAAI,KAAK,UAAU,iBAAiB,EAAE,OAAO,mBAAmB,CAAC,CAAC;AACtE;AAAA,IACF;AAGA,QAAI,WAAW,iBAAAF,QAAK,KAAK,WAAW,QAAQ,MAAM,eAAe,GAAG;AACpE,UAAM,MAAM,iBAAAA,QAAK,QAAQ,QAAQ;AAGjC,QAAI,CAAC,KAAK;AACR,iBAAW,iBAAAA,QAAK,KAAK,WAAW,YAAY;AAAA,IAC9C;AAEA,QAAI;AACF,YAAM,UAAU,eAAAC,QAAG,aAAa,QAAQ;AACxC,YAAM,OAAO,WAAW,iBAAAD,QAAK,QAAQ,QAAQ,CAAC,KAAK;AACnD,UAAI,UAAU,KAAK,EAAE,gBAAgB,KAAK,CAAC;AAC3C,UAAI,IAAI,OAAO;AAAA,IACjB,QAAQ;AACN,UAAI,UAAU,GAAG;AACjB,UAAI,IAAI,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAGD,QAAM,MAAM,IAAI,0BAAgB,EAAE,OAAO,CAAC;AAG1C,MAAI,UAA+B;AACnC,MAAI;AACF,cAAU,eAAAC,QAAG,MAAM,oBAAoB,MAAM;AAC3C,UAAI;AACF,cAAM,UAAU,eAAAA,QAAG,aAAa,oBAAoB,OAAO;AAC3D,wBAAgB,KAAK,MAAM,OAAO;AAElC,mBAAW,UAAU,IAAI,SAAS;AAChC,cAAI,OAAO,eAAe,GAAG;AAC3B,mBAAO,KAAK,KAAK,UAAU,EAAE,MAAM,UAAU,QAAQ,cAAc,CAAC,CAAC;AAAA,UACvE;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF,CAAC;AAAA,EACH,QAAQ;AACN,YAAQ,KAAK,yCAAyC;AAAA,EACxD;AAEA,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,WAAO,OAAO,MAAM,MAAM;AACxB,YAAM,MAAM,oBAAoB,IAAI;AACpC,cAAQ,IAAI;AAAA,yBAA4B,GAAG;AAAA,CAAI;AAC/C,cAAQ;AAAA,QACN;AAAA,QACA,OAAO,MAAM;AACX,mBAAS,MAAM;AACf,cAAI,MAAM;AACV,iBAAO,MAAM;AAAA,QACf;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;","names":["path","fs","http"]}
@@ -0,0 +1,439 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Hydration Tax Dashboard</title>
7
+ <style>
8
+ :root {
9
+ --bg: #0f1117;
10
+ --surface: #1a1d27;
11
+ --surface-2: #242833;
12
+ --border: #2e3345;
13
+ --text: #e1e4ed;
14
+ --text-dim: #8b90a0;
15
+ --green: #4ade80;
16
+ --yellow: #facc15;
17
+ --red: #f87171;
18
+ --blue: #60a5fa;
19
+ --purple: #c084fc;
20
+ }
21
+
22
+ * { box-sizing: border-box; margin: 0; padding: 0; }
23
+ body {
24
+ font-family: 'Inter', system-ui, -apple-system, sans-serif;
25
+ background: var(--bg);
26
+ color: var(--text);
27
+ line-height: 1.5;
28
+ }
29
+
30
+ .header {
31
+ padding: 1.5rem 2rem;
32
+ border-bottom: 1px solid var(--border);
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: space-between;
36
+ }
37
+ .header h1 { font-size: 1.25rem; font-weight: 600; }
38
+ .header .meta { color: var(--text-dim); font-size: 0.85rem; }
39
+ .live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; animation: pulse 2s infinite; }
40
+ @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
41
+
42
+ .dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; padding: 1.5rem 2rem; }
43
+ .card {
44
+ background: var(--surface);
45
+ border: 1px solid var(--border);
46
+ border-radius: 12px;
47
+ padding: 1.25rem;
48
+ }
49
+ .card h2 { font-size: 0.9rem; font-weight: 500; color: var(--text-dim); margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.05em; }
50
+ .card.full { grid-column: 1 / -1; }
51
+
52
+ /* Summary Cards */
53
+ .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; grid-column: 1 / -1; }
54
+ .stat-card {
55
+ background: var(--surface);
56
+ border: 1px solid var(--border);
57
+ border-radius: 12px;
58
+ padding: 1rem 1.25rem;
59
+ }
60
+ .stat-card .label { font-size: 0.8rem; color: var(--text-dim); }
61
+ .stat-card .value { font-size: 1.75rem; font-weight: 700; margin-top: 0.25rem; }
62
+ .stat-card .value.green { color: var(--green); }
63
+ .stat-card .value.yellow { color: var(--yellow); }
64
+ .stat-card .value.red { color: var(--red); }
65
+
66
+ /* Treemap */
67
+ .treemap-container { width: 100%; aspect-ratio: 2/1; position: relative; }
68
+ .treemap-node {
69
+ position: absolute;
70
+ border: 1px solid var(--bg);
71
+ border-radius: 4px;
72
+ display: flex;
73
+ flex-direction: column;
74
+ align-items: center;
75
+ justify-content: center;
76
+ font-size: 0.75rem;
77
+ font-weight: 500;
78
+ overflow: hidden;
79
+ transition: opacity 0.2s;
80
+ cursor: pointer;
81
+ }
82
+ .treemap-node:hover { opacity: 0.85; }
83
+ .treemap-node .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90%; }
84
+ .treemap-node .size { font-size: 0.7rem; opacity: 0.8; }
85
+
86
+ /* Island Table */
87
+ table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
88
+ th { text-align: left; padding: 0.6rem 0.75rem; color: var(--text-dim); font-weight: 500; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
89
+ th:hover { color: var(--text); }
90
+ td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
91
+ tr:hover td { background: var(--surface-2); }
92
+ .directive { padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 500; }
93
+ .directive-load { background: rgba(248, 113, 113, 0.15); color: var(--red); }
94
+ .directive-idle { background: rgba(250, 204, 21, 0.15); color: var(--yellow); }
95
+ .directive-visible { background: rgba(74, 222, 128, 0.15); color: var(--green); }
96
+ .directive-media { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
97
+ .directive-only { background: rgba(192, 132, 252, 0.15); color: var(--purple); }
98
+
99
+ /* Issues */
100
+ .issue { padding: 0.75rem 1rem; margin-bottom: 0.5rem; border-radius: 8px; font-size: 0.85rem; }
101
+ .issue-error { background: rgba(248, 113, 113, 0.1); border-left: 3px solid var(--red); }
102
+ .issue-warning { background: rgba(250, 204, 21, 0.1); border-left: 3px solid var(--yellow); }
103
+ .issue-info { background: rgba(96, 165, 250, 0.1); border-left: 3px solid var(--blue); }
104
+ .issue .rec { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.25rem; }
105
+
106
+ /* Budget Gauge */
107
+ .gauge { position: relative; height: 24px; background: var(--surface-2); border-radius: 12px; overflow: hidden; margin-top: 0.5rem; }
108
+ .gauge-fill { height: 100%; border-radius: 12px; transition: width 0.5s ease; }
109
+ .gauge-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 0.75rem; font-weight: 600; }
110
+
111
+ .loading { text-align: center; padding: 4rem; color: var(--text-dim); }
112
+
113
+ @media (max-width: 768px) {
114
+ .dashboard { grid-template-columns: 1fr; }
115
+ .stats { grid-template-columns: repeat(2, 1fr); }
116
+ }
117
+ </style>
118
+ </head>
119
+ <body>
120
+ <div id="app">
121
+ <div class="loading">Loading report...</div>
122
+ </div>
123
+
124
+ <script type="module">
125
+ let report = null;
126
+ let sortColumn = 'gzip';
127
+ let sortAsc = false;
128
+
129
+ // ─── Data Loading ──────────────────────────────────────────
130
+ async function loadReport() {
131
+ try {
132
+ const res = await fetch('/api/report');
133
+ report = await res.json();
134
+ render();
135
+ } catch (e) {
136
+ document.getElementById('app').innerHTML = '<div class="loading">Failed to load report. Make sure the report file exists.</div>';
137
+ }
138
+ }
139
+
140
+ // WebSocket live reload
141
+ function connectWS() {
142
+ try {
143
+ const ws = new WebSocket(`ws://${location.host}`);
144
+ ws.onmessage = (event) => {
145
+ const data = JSON.parse(event.data);
146
+ if (data.type === 'update') {
147
+ report = data.report;
148
+ render();
149
+ }
150
+ };
151
+ ws.onclose = () => setTimeout(connectWS, 3000);
152
+ } catch {}
153
+ }
154
+
155
+ // ─── Rendering ─────────────────────────────────────────────
156
+ function render() {
157
+ if (!report || report.error) {
158
+ document.getElementById('app').innerHTML = '<div class="loading">No report data available. Run <code>hydration-audit analyze</code> first.</div>';
159
+ return;
160
+ }
161
+
162
+ const app = document.getElementById('app');
163
+ app.innerHTML = `
164
+ ${renderHeader()}
165
+ ${renderStats()}
166
+ <div class="dashboard">
167
+ <div class="card">
168
+ <h2>Bundle Size Treemap</h2>
169
+ <div class="treemap-container" id="treemap"></div>
170
+ </div>
171
+ <div class="card">
172
+ <h2>Budget Usage</h2>
173
+ ${renderBudgetGauges()}
174
+ </div>
175
+ <div class="card full">
176
+ <h2>Islands</h2>
177
+ ${renderIslandTable()}
178
+ </div>
179
+ <div class="card full">
180
+ <h2>Issues (${getAllIssues().length})</h2>
181
+ ${renderIssues()}
182
+ </div>
183
+ </div>
184
+ `;
185
+
186
+ renderTreemap();
187
+ attachSortHandlers();
188
+ }
189
+
190
+ function renderHeader() {
191
+ return `<div class="header">
192
+ <div>
193
+ <h1>Hydration Tax Dashboard</h1>
194
+ <div class="meta">${report.projectName} &middot; ${report.framework} &middot; ${new Date(report.timestamp).toLocaleString()}</div>
195
+ </div>
196
+ <div class="meta"><span class="live-dot"></span>Live</div>
197
+ </div>`;
198
+ }
199
+
200
+ function renderStats() {
201
+ const t = report.totals;
202
+ const sizeClass = t.totalGzipSize > 300000 ? 'red' : t.totalGzipSize > 150000 ? 'yellow' : 'green';
203
+ const issueClass = t.issuesBySeverity.error > 0 ? 'red' : t.issuesBySeverity.warning > 0 ? 'yellow' : 'green';
204
+
205
+ return `<div class="stats">
206
+ <div class="stat-card">
207
+ <div class="label">Total Islands</div>
208
+ <div class="value">${t.totalIslands}</div>
209
+ </div>
210
+ <div class="stat-card">
211
+ <div class="label">Total JS (gzip)</div>
212
+ <div class="value ${sizeClass}">${formatBytes(t.totalGzipSize)}</div>
213
+ </div>
214
+ <div class="stat-card">
215
+ <div class="label">Total JS (brotli)</div>
216
+ <div class="value">${formatBytes(t.totalBrotliSize)}</div>
217
+ </div>
218
+ <div class="stat-card">
219
+ <div class="label">Issues</div>
220
+ <div class="value ${issueClass}">${t.totalIssues}</div>
221
+ </div>
222
+ </div>`;
223
+ }
224
+
225
+ function renderBudgetGauges() {
226
+ const config = report.config;
227
+ if (!config) return '<p style="color:var(--text-dim)">No budget config</p>';
228
+
229
+ const gauges = [];
230
+
231
+ // Per-page budgets
232
+ for (const page of report.pages) {
233
+ const pct = Math.min((page.totalGzipSize / config.thresholds.pageBudget) * 100, 100);
234
+ const color = pct > 100 ? 'var(--red)' : pct > 66 ? 'var(--yellow)' : 'var(--green)';
235
+ gauges.push(`
236
+ <div style="margin-bottom:1rem">
237
+ <div style="display:flex;justify-content:space-between;font-size:0.8rem;margin-bottom:4px">
238
+ <span>${page.route}</span>
239
+ <span>${formatBytes(page.totalGzipSize)} / ${formatBytes(config.thresholds.pageBudget)}</span>
240
+ </div>
241
+ <div class="gauge">
242
+ <div class="gauge-fill" style="width:${Math.min(pct, 100)}%;background:${color}"></div>
243
+ </div>
244
+ </div>
245
+ `);
246
+ }
247
+
248
+ // Total budget
249
+ const totalPct = Math.min((report.totals.totalGzipSize / config.thresholds.totalBudget) * 100, 100);
250
+ const totalColor = totalPct > 100 ? 'var(--red)' : totalPct > 66 ? 'var(--yellow)' : 'var(--green)';
251
+ gauges.push(`
252
+ <div style="margin-top:1.5rem">
253
+ <div style="display:flex;justify-content:space-between;font-size:0.8rem;margin-bottom:4px">
254
+ <strong>Total Site Budget</strong>
255
+ <span>${formatBytes(report.totals.totalGzipSize)} / ${formatBytes(config.thresholds.totalBudget)}</span>
256
+ </div>
257
+ <div class="gauge">
258
+ <div class="gauge-fill" style="width:${Math.min(totalPct, 100)}%;background:${totalColor}"></div>
259
+ </div>
260
+ </div>
261
+ `);
262
+
263
+ return gauges.join('');
264
+ }
265
+
266
+ function renderIslandTable() {
267
+ const islands = getSortedIslands();
268
+ if (islands.length === 0) return '<p style="color:var(--text-dim)">No islands found</p>';
269
+
270
+ const arrow = (col) => sortColumn === col ? (sortAsc ? ' ↑' : ' ↓') : '';
271
+
272
+ return `<table>
273
+ <thead>
274
+ <tr>
275
+ <th data-sort="name">Name${arrow('name')}</th>
276
+ <th data-sort="directive">Directive${arrow('directive')}</th>
277
+ <th data-sort="framework">Framework${arrow('framework')}</th>
278
+ <th data-sort="gzip">Gzip${arrow('gzip')}</th>
279
+ <th data-sort="brotli">Brotli${arrow('brotli')}</th>
280
+ <th data-sort="issues">Issues${arrow('issues')}</th>
281
+ <th>Pages</th>
282
+ </tr>
283
+ </thead>
284
+ <tbody>
285
+ ${islands.map(i => `<tr>
286
+ <td><strong>${i.component.name}</strong></td>
287
+ <td><span class="directive directive-${i.component.directive.split(':')[1]}">${i.component.directive}</span></td>
288
+ <td>${i.component.uiFramework}</td>
289
+ <td>${formatBytes(i.bundle.totalGzipSize)}</td>
290
+ <td style="color:var(--text-dim)">${formatBytes(i.bundle.totalBrotliSize)}</td>
291
+ <td>${i.issues.length > 0 ? `<span style="color:var(--yellow)">${i.issues.length}</span>` : '<span style="color:var(--green)">0</span>'}</td>
292
+ <td style="color:var(--text-dim);font-size:0.8rem">${i.component.pages.join(', ')}</td>
293
+ </tr>`).join('')}
294
+ </tbody>
295
+ </table>`;
296
+ }
297
+
298
+ function renderIssues() {
299
+ const issues = getAllIssues();
300
+ if (issues.length === 0) return '<p style="color:var(--green)">No issues found!</p>';
301
+
302
+ return issues.map(issue => `
303
+ <div class="issue issue-${issue.severity}">
304
+ <div>${issue.message}</div>
305
+ <div class="rec">${issue.recommendation}</div>
306
+ </div>
307
+ `).join('');
308
+ }
309
+
310
+ // ─── Treemap ───────────────────────────────────────────────
311
+ function renderTreemap() {
312
+ const container = document.getElementById('treemap');
313
+ if (!container || !report.islands.length) return;
314
+
315
+ const width = container.offsetWidth;
316
+ const height = container.offsetHeight;
317
+
318
+ // Build hierarchy data
319
+ const data = {
320
+ name: 'root',
321
+ children: report.islands.map(i => ({
322
+ name: i.component.name,
323
+ value: Math.max(i.bundle.totalGzipSize, 100), // min size for visibility
324
+ gzip: i.bundle.totalGzipSize,
325
+ directive: i.component.directive,
326
+ issues: i.issues.length,
327
+ })),
328
+ };
329
+
330
+ // Simple treemap layout (no d3 dependency — inline squarify)
331
+ const nodes = squarify(data.children, 0, 0, width, height);
332
+
333
+ container.innerHTML = nodes.map(n => {
334
+ const color = getNodeColor(n);
335
+ const textColor = '#fff';
336
+ return `<div class="treemap-node" style="left:${n.x}px;top:${n.y}px;width:${n.w}px;height:${n.h}px;background:${color}" title="${n.name}: ${formatBytes(n.gzip)}">
337
+ ${n.w > 60 && n.h > 30 ? `<div class="name">${n.name}</div>` : ''}
338
+ ${n.w > 50 && n.h > 45 ? `<div class="size">${formatBytes(n.gzip)}</div>` : ''}
339
+ </div>`;
340
+ }).join('');
341
+ }
342
+
343
+ function getNodeColor(node) {
344
+ if (node.issues > 0) {
345
+ return node.gzip > 100000 ? 'rgba(248,113,113,0.6)' : 'rgba(250,204,21,0.5)';
346
+ }
347
+ if (node.gzip > 50000) return 'rgba(250,204,21,0.4)';
348
+ if (node.gzip > 20000) return 'rgba(96,165,250,0.4)';
349
+ return 'rgba(74,222,128,0.4)';
350
+ }
351
+
352
+ // Simple squarified treemap layout
353
+ function squarify(items, x, y, w, h) {
354
+ const total = items.reduce((s, i) => s + i.value, 0);
355
+ if (total === 0 || items.length === 0) return [];
356
+
357
+ const sorted = [...items].sort((a, b) => b.value - a.value);
358
+ const result = [];
359
+ let cx = x, cy = y, cw = w, ch = h;
360
+
361
+ for (const item of sorted) {
362
+ const ratio = item.value / total;
363
+ const isWide = cw >= ch;
364
+
365
+ let nw, nh;
366
+ if (isWide) {
367
+ nw = cw * ratio;
368
+ nh = ch;
369
+ result.push({ ...item, x: cx, y: cy, w: Math.max(nw - 2, 0), h: Math.max(nh - 2, 0) });
370
+ cx += nw;
371
+ cw -= nw;
372
+ } else {
373
+ nw = cw;
374
+ nh = ch * ratio;
375
+ result.push({ ...item, x: cx, y: cy, w: Math.max(nw - 2, 0), h: Math.max(nh - 2, 0) });
376
+ cy += nh;
377
+ ch -= nh;
378
+ }
379
+ }
380
+
381
+ return result;
382
+ }
383
+
384
+ // ─── Sorting ───────────────────────────────────────────────
385
+ function getSortedIslands() {
386
+ const islands = [...(report.islands || [])];
387
+ islands.sort((a, b) => {
388
+ let va, vb;
389
+ switch (sortColumn) {
390
+ case 'name': va = a.component.name; vb = b.component.name; break;
391
+ case 'directive': va = a.component.directive; vb = b.component.directive; break;
392
+ case 'framework': va = a.component.uiFramework; vb = b.component.uiFramework; break;
393
+ case 'gzip': va = a.bundle.totalGzipSize; vb = b.bundle.totalGzipSize; break;
394
+ case 'brotli': va = a.bundle.totalBrotliSize; vb = b.bundle.totalBrotliSize; break;
395
+ case 'issues': va = a.issues.length; vb = b.issues.length; break;
396
+ default: va = a.bundle.totalGzipSize; vb = b.bundle.totalGzipSize;
397
+ }
398
+ if (typeof va === 'string') return sortAsc ? va.localeCompare(vb) : vb.localeCompare(va);
399
+ return sortAsc ? va - vb : vb - va;
400
+ });
401
+ return islands;
402
+ }
403
+
404
+ function attachSortHandlers() {
405
+ document.querySelectorAll('th[data-sort]').forEach(th => {
406
+ th.addEventListener('click', () => {
407
+ const col = th.dataset.sort;
408
+ if (sortColumn === col) { sortAsc = !sortAsc; }
409
+ else { sortColumn = col; sortAsc = false; }
410
+ render();
411
+ });
412
+ });
413
+ }
414
+
415
+ // ─── Helpers ───────────────────────────────────────────────
416
+ function getAllIssues() {
417
+ if (!report) return [];
418
+ return [
419
+ ...(report.islands || []).flatMap(i => i.issues),
420
+ ...(report.pages || []).flatMap(p => p.issues),
421
+ ...(report.issues || []),
422
+ ];
423
+ }
424
+
425
+ function formatBytes(bytes) {
426
+ if (!bytes || bytes === 0) return '0 B';
427
+ if (bytes < 1024) return bytes + ' B';
428
+ const kb = bytes / 1024;
429
+ if (kb < 1024) return kb.toFixed(1) + ' KB';
430
+ return (kb / 1024).toFixed(2) + ' MB';
431
+ }
432
+
433
+ // ─── Init ──────────────────────────────────────────────────
434
+ loadReport();
435
+ connectWS();
436
+ window.addEventListener('resize', () => { if (report) renderTreemap(); });
437
+ </script>
438
+ </body>
439
+ </html>
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  import http from "http";
3
3
  import fs from "fs";
4
4
  import path from "path";
5
+ import { fileURLToPath } from "url";
5
6
  import { WebSocketServer } from "ws";
6
7
  var MIME_TYPES = {
7
8
  ".html": "text/html",
@@ -19,10 +20,8 @@ async function startDashboard(reportPath, port = 4173) {
19
20
  } catch {
20
21
  console.warn(`Could not read report at ${absoluteReportPath}`);
21
22
  }
22
- const staticDir = path.resolve(
23
- path.dirname(new URL(import.meta.url).pathname),
24
- "app"
25
- );
23
+ const currentDir = path.dirname(fileURLToPath(import.meta.url));
24
+ const staticDir = fs.existsSync(path.join(currentDir, "app")) ? path.join(currentDir, "app") : currentDir;
26
25
  const server = http.createServer((req, res) => {
27
26
  const url = req.url ?? "/";
28
27
  if (url === "/api/report") {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import http from 'node:http';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { WebSocketServer } from 'ws';\nimport type { AnalysisReport } from '@hydration-audit/core';\n\nconst MIME_TYPES: Record<string, string> = {\n '.html': 'text/html',\n '.js': 'application/javascript',\n '.css': 'text/css',\n '.json': 'application/json',\n '.svg': 'image/svg+xml',\n};\n\n/**\n * Start the dashboard server.\n * Serves a static SPA and provides a WebSocket for live report updates.\n */\nexport async function startDashboard(\n reportPath: string,\n port = 4173,\n): Promise<{ url: string; close: () => void }> {\n const absoluteReportPath = path.resolve(reportPath);\n\n // Read the initial report\n let currentReport: AnalysisReport | null = null;\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n } catch {\n console.warn(`Could not read report at ${absoluteReportPath}`);\n }\n\n const staticDir = path.resolve(\n path.dirname(new URL(import.meta.url).pathname),\n 'app',\n );\n\n const server = http.createServer((req, res) => {\n const url = req.url ?? '/';\n\n // API endpoint for report data\n if (url === '/api/report') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(currentReport ?? { error: 'No report loaded' }));\n return;\n }\n\n // Serve static files\n let filePath = path.join(staticDir, url === '/' ? 'index.html' : url);\n const ext = path.extname(filePath);\n\n // SPA fallback — serve index.html for non-file routes\n if (!ext) {\n filePath = path.join(staticDir, 'index.html');\n }\n\n try {\n const content = fs.readFileSync(filePath);\n const mime = MIME_TYPES[path.extname(filePath)] ?? 'text/plain';\n res.writeHead(200, { 'Content-Type': mime });\n res.end(content);\n } catch {\n res.writeHead(404);\n res.end('Not found');\n }\n });\n\n // WebSocket for live reload\n const wss = new WebSocketServer({ server });\n\n // Watch report file for changes\n let watcher: fs.FSWatcher | null = null;\n try {\n watcher = fs.watch(absoluteReportPath, () => {\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n // Notify all connected clients\n for (const client of wss.clients) {\n if (client.readyState === 1) {\n client.send(JSON.stringify({ type: 'update', report: currentReport }));\n }\n }\n } catch {\n // Ignore parse errors during write\n }\n });\n } catch {\n console.warn('Could not watch report file for changes');\n }\n\n return new Promise((resolve) => {\n server.listen(port, () => {\n const url = `http://localhost:${port}`;\n console.log(`\\n Dashboard running at ${url}\\n`);\n resolve({\n url,\n close: () => {\n watcher?.close();\n wss.close();\n server.close();\n },\n });\n });\n });\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,uBAAuB;AAGhC,IAAM,aAAqC;AAAA,EACzC,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AACV;AAMA,eAAsB,eACpB,YACA,OAAO,MACsC;AAC7C,QAAM,qBAAqB,KAAK,QAAQ,UAAU;AAGlD,MAAI,gBAAuC;AAC3C,MAAI;AACF,UAAM,UAAU,GAAG,aAAa,oBAAoB,OAAO;AAC3D,oBAAgB,KAAK,MAAM,OAAO;AAAA,EACpC,QAAQ;AACN,YAAQ,KAAK,4BAA4B,kBAAkB,EAAE;AAAA,EAC/D;AAEA,QAAM,YAAY,KAAK;AAAA,IACrB,KAAK,QAAQ,IAAI,IAAI,YAAY,GAAG,EAAE,QAAQ;AAAA,IAC9C;AAAA,EACF;AAEA,QAAM,SAAS,KAAK,aAAa,CAAC,KAAK,QAAQ;AAC7C,UAAM,MAAM,IAAI,OAAO;AAGvB,QAAI,QAAQ,eAAe;AACzB,UAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,UAAI,IAAI,KAAK,UAAU,iBAAiB,EAAE,OAAO,mBAAmB,CAAC,CAAC;AACtE;AAAA,IACF;AAGA,QAAI,WAAW,KAAK,KAAK,WAAW,QAAQ,MAAM,eAAe,GAAG;AACpE,UAAM,MAAM,KAAK,QAAQ,QAAQ;AAGjC,QAAI,CAAC,KAAK;AACR,iBAAW,KAAK,KAAK,WAAW,YAAY;AAAA,IAC9C;AAEA,QAAI;AACF,YAAM,UAAU,GAAG,aAAa,QAAQ;AACxC,YAAM,OAAO,WAAW,KAAK,QAAQ,QAAQ,CAAC,KAAK;AACnD,UAAI,UAAU,KAAK,EAAE,gBAAgB,KAAK,CAAC;AAC3C,UAAI,IAAI,OAAO;AAAA,IACjB,QAAQ;AACN,UAAI,UAAU,GAAG;AACjB,UAAI,IAAI,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAGD,QAAM,MAAM,IAAI,gBAAgB,EAAE,OAAO,CAAC;AAG1C,MAAI,UAA+B;AACnC,MAAI;AACF,cAAU,GAAG,MAAM,oBAAoB,MAAM;AAC3C,UAAI;AACF,cAAM,UAAU,GAAG,aAAa,oBAAoB,OAAO;AAC3D,wBAAgB,KAAK,MAAM,OAAO;AAElC,mBAAW,UAAU,IAAI,SAAS;AAChC,cAAI,OAAO,eAAe,GAAG;AAC3B,mBAAO,KAAK,KAAK,UAAU,EAAE,MAAM,UAAU,QAAQ,cAAc,CAAC,CAAC;AAAA,UACvE;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF,CAAC;AAAA,EACH,QAAQ;AACN,YAAQ,KAAK,yCAAyC;AAAA,EACxD;AAEA,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,WAAO,OAAO,MAAM,MAAM;AACxB,YAAM,MAAM,oBAAoB,IAAI;AACpC,cAAQ,IAAI;AAAA,yBAA4B,GAAG;AAAA,CAAI;AAC/C,cAAQ;AAAA,QACN;AAAA,QACA,OAAO,MAAM;AACX,mBAAS,MAAM;AACf,cAAI,MAAM;AACV,iBAAO,MAAM;AAAA,QACf;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import http from 'node:http';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { WebSocketServer } from 'ws';\nimport type { AnalysisReport } from '@hydration-audit/core';\n\nconst MIME_TYPES: Record<string, string> = {\n '.html': 'text/html',\n '.js': 'application/javascript',\n '.css': 'text/css',\n '.json': 'application/json',\n '.svg': 'image/svg+xml',\n};\n\n/**\n * Start the dashboard server.\n * Serves a static SPA and provides a WebSocket for live report updates.\n */\nexport async function startDashboard(\n reportPath: string,\n port = 4173,\n): Promise<{ url: string; close: () => void }> {\n const absoluteReportPath = path.resolve(reportPath);\n\n // Read the initial report\n let currentReport: AnalysisReport | null = null;\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n } catch {\n console.warn(`Could not read report at ${absoluteReportPath}`);\n }\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n const staticDir = fs.existsSync(path.join(currentDir, 'app'))\n ? path.join(currentDir, 'app')\n : currentDir;\n\n const server = http.createServer((req, res) => {\n const url = req.url ?? '/';\n\n // API endpoint for report data\n if (url === '/api/report') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(currentReport ?? { error: 'No report loaded' }));\n return;\n }\n\n // Serve static files\n let filePath = path.join(staticDir, url === '/' ? 'index.html' : url);\n const ext = path.extname(filePath);\n\n // SPA fallback — serve index.html for non-file routes\n if (!ext) {\n filePath = path.join(staticDir, 'index.html');\n }\n\n try {\n const content = fs.readFileSync(filePath);\n const mime = MIME_TYPES[path.extname(filePath)] ?? 'text/plain';\n res.writeHead(200, { 'Content-Type': mime });\n res.end(content);\n } catch {\n res.writeHead(404);\n res.end('Not found');\n }\n });\n\n // WebSocket for live reload\n const wss = new WebSocketServer({ server });\n\n // Watch report file for changes\n let watcher: fs.FSWatcher | null = null;\n try {\n watcher = fs.watch(absoluteReportPath, () => {\n try {\n const content = fs.readFileSync(absoluteReportPath, 'utf-8');\n currentReport = JSON.parse(content);\n // Notify all connected clients\n for (const client of wss.clients) {\n if (client.readyState === 1) {\n client.send(JSON.stringify({ type: 'update', report: currentReport }));\n }\n }\n } catch {\n // Ignore parse errors during write\n }\n });\n } catch {\n console.warn('Could not watch report file for changes');\n }\n\n return new Promise((resolve) => {\n server.listen(port, () => {\n const url = `http://localhost:${port}`;\n console.log(`\\n Dashboard running at ${url}\\n`);\n resolve({\n url,\n close: () => {\n watcher?.close();\n wss.close();\n server.close();\n },\n });\n });\n });\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAGhC,IAAM,aAAqC;AAAA,EACzC,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AACV;AAMA,eAAsB,eACpB,YACA,OAAO,MACsC;AAC7C,QAAM,qBAAqB,KAAK,QAAQ,UAAU;AAGlD,MAAI,gBAAuC;AAC3C,MAAI;AACF,UAAM,UAAU,GAAG,aAAa,oBAAoB,OAAO;AAC3D,oBAAgB,KAAK,MAAM,OAAO;AAAA,EACpC,QAAQ;AACN,YAAQ,KAAK,4BAA4B,kBAAkB,EAAE;AAAA,EAC/D;AAEA,QAAM,aAAa,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC9D,QAAM,YAAY,GAAG,WAAW,KAAK,KAAK,YAAY,KAAK,CAAC,IACxD,KAAK,KAAK,YAAY,KAAK,IAC3B;AAEJ,QAAM,SAAS,KAAK,aAAa,CAAC,KAAK,QAAQ;AAC7C,UAAM,MAAM,IAAI,OAAO;AAGvB,QAAI,QAAQ,eAAe;AACzB,UAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,UAAI,IAAI,KAAK,UAAU,iBAAiB,EAAE,OAAO,mBAAmB,CAAC,CAAC;AACtE;AAAA,IACF;AAGA,QAAI,WAAW,KAAK,KAAK,WAAW,QAAQ,MAAM,eAAe,GAAG;AACpE,UAAM,MAAM,KAAK,QAAQ,QAAQ;AAGjC,QAAI,CAAC,KAAK;AACR,iBAAW,KAAK,KAAK,WAAW,YAAY;AAAA,IAC9C;AAEA,QAAI;AACF,YAAM,UAAU,GAAG,aAAa,QAAQ;AACxC,YAAM,OAAO,WAAW,KAAK,QAAQ,QAAQ,CAAC,KAAK;AACnD,UAAI,UAAU,KAAK,EAAE,gBAAgB,KAAK,CAAC;AAC3C,UAAI,IAAI,OAAO;AAAA,IACjB,QAAQ;AACN,UAAI,UAAU,GAAG;AACjB,UAAI,IAAI,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAGD,QAAM,MAAM,IAAI,gBAAgB,EAAE,OAAO,CAAC;AAG1C,MAAI,UAA+B;AACnC,MAAI;AACF,cAAU,GAAG,MAAM,oBAAoB,MAAM;AAC3C,UAAI;AACF,cAAM,UAAU,GAAG,aAAa,oBAAoB,OAAO;AAC3D,wBAAgB,KAAK,MAAM,OAAO;AAElC,mBAAW,UAAU,IAAI,SAAS;AAChC,cAAI,OAAO,eAAe,GAAG;AAC3B,mBAAO,KAAK,KAAK,UAAU,EAAE,MAAM,UAAU,QAAQ,cAAc,CAAC,CAAC;AAAA,UACvE;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF,CAAC;AAAA,EACH,QAAQ;AACN,YAAQ,KAAK,yCAAyC;AAAA,EACxD;AAEA,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,WAAO,OAAO,MAAM,MAAM;AACxB,YAAM,MAAM,oBAAoB,IAAI;AACpC,cAAQ,IAAI;AAAA,yBAA4B,GAAG;AAAA,CAAI;AAC/C,cAAQ;AAAA,QACN;AAAA,QACA,OAAO,MAAM;AACX,mBAAS,MAAM;AACf,cAAI,MAAM;AACV,iBAAO,MAAM;AAAA,QACf;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydration-audit/dashboard",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Web dashboard for visualizing JavaScript hydration costs",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,18 +17,11 @@
17
17
  "engines": {
18
18
  "node": ">=18"
19
19
  },
20
- "scripts": {
21
- "build": "tsup",
22
- "dev": "vite",
23
- "test": "vitest run",
24
- "typecheck": "tsc --noEmit",
25
- "clean": "rm -rf dist"
26
- },
27
20
  "dependencies": {
28
- "@hydration-audit/core": "workspace:*",
29
21
  "preact": "^10.24.0",
30
22
  "d3-hierarchy": "^3.1.2",
31
- "ws": "^8.18.0"
23
+ "ws": "^8.18.0",
24
+ "@hydration-audit/core": "0.2.2"
32
25
  },
33
26
  "devDependencies": {
34
27
  "@preact/preset-vite": "^2.9.0",
@@ -38,5 +31,12 @@
38
31
  "tsup": "^8.3.0",
39
32
  "typescript": "^5.7.0",
40
33
  "vitest": "^2.1.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "dev": "vite",
38
+ "test": "vitest run",
39
+ "typecheck": "tsc --noEmit",
40
+ "clean": "rm -rf dist"
41
41
  }
42
- }
42
+ }