@mantiq/heartbeat 0.3.0 → 0.3.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/package.json
CHANGED
|
@@ -215,7 +215,7 @@ export class HeartbeatMiddleware implements Middleware {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
private async injectWidget(response: Response, duration: number, memory: number): Promise<Response> {
|
|
218
|
-
if (
|
|
218
|
+
if (this.heartbeat.config.widget?.enabled === false) return response
|
|
219
219
|
|
|
220
220
|
try {
|
|
221
221
|
const html = await response.text()
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Floating debug widget — injected into HTML responses when APP_DEBUG=true.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Renders as a small pill at bottom-right that expands on hover/click.
|
|
6
|
-
* Minimal footprint — all inline, no external deps.
|
|
3
|
+
* Compact pill with mantiq branding, expands to stats panel on click.
|
|
7
4
|
*/
|
|
8
5
|
|
|
9
6
|
export function renderWidget(data: {
|
|
@@ -19,41 +16,57 @@ export function renderWidget(data: {
|
|
|
19
16
|
const statusColor = status >= 500 ? '#f87171' : status >= 400 ? '#fbbf24' : '#34d399'
|
|
20
17
|
|
|
21
18
|
return `<!-- mantiq:heartbeat-widget -->
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
<style>
|
|
20
|
+
#__mw{position:fixed;bottom:16px;right:16px;z-index:99999;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;font-size:12px}
|
|
21
|
+
#__mw_pill{display:flex;align-items:center;gap:6px;background:#0a0a0b;border:1px solid #27272a;border-radius:100px;padding:7px 14px 7px 10px;cursor:pointer;box-shadow:0 4px 16px rgba(0,0,0,.5);color:#71717a;transition:border-color .2s;user-select:none}
|
|
22
|
+
#__mw_pill:hover{border-color:#34d399}
|
|
23
|
+
#__mw_logo{display:flex;align-items:center;gap:5px;color:#34d399;font-weight:700;font-size:11px;letter-spacing:-.01em;border-right:1px solid #27272a;padding-right:8px;margin-right:2px}
|
|
24
|
+
#__mw_logo span{width:5px;height:5px;border-radius:50%;background:#34d399}
|
|
25
|
+
#__mw_stats{display:flex;align-items:center;gap:6px}
|
|
26
|
+
#__mw_stats b{color:#fafafa;font-weight:600}
|
|
27
|
+
#__mw_dot{width:5px;height:5px;border-radius:50%;flex-shrink:0}
|
|
28
|
+
#__mw_sep{color:#27272a}
|
|
29
|
+
#__mw_panel{display:none;position:absolute;bottom:calc(100% + 10px);right:0;background:#0a0a0b;border:1px solid #27272a;border-radius:12px;min-width:280px;box-shadow:0 12px 32px rgba(0,0,0,.6);overflow:hidden}
|
|
30
|
+
#__mw_panel header{padding:14px 16px;border-bottom:1px solid #1e1e1e;display:flex;align-items:center;justify-content:space-between}
|
|
31
|
+
#__mw_panel header .brand{display:flex;align-items:center;gap:6px;color:#fafafa;font-weight:700;font-size:12px;letter-spacing:-.01em}
|
|
32
|
+
#__mw_panel header .brand i{width:6px;height:6px;border-radius:50%;background:#34d399}
|
|
33
|
+
#__mw_panel header a{color:#52525b;text-decoration:none;font-size:11px}
|
|
34
|
+
#__mw_panel header a:hover{color:#34d399}
|
|
35
|
+
#__mw_grid{display:grid;grid-template-columns:1fr 1fr;gap:0}
|
|
36
|
+
#__mw_grid .cell{padding:14px 16px;border-bottom:1px solid #1e1e1e}
|
|
37
|
+
#__mw_grid .cell:nth-child(odd){border-right:1px solid #1e1e1e}
|
|
38
|
+
#__mw_grid .cell label{display:block;color:#52525b;font-size:10px;text-transform:uppercase;letter-spacing:.06em;margin-bottom:4px}
|
|
39
|
+
#__mw_grid .cell .val{color:#fafafa;font-weight:700;font-size:18px;letter-spacing:-.02em}
|
|
40
|
+
#__mw_grid .cell .val small{color:#52525b;font-size:11px;font-weight:400;margin-left:1px}
|
|
41
|
+
#__mw_cta{padding:12px 16px}
|
|
42
|
+
#__mw_cta a{display:flex;align-items:center;justify-content:center;gap:6px;color:#0a0a0b;background:#34d399;padding:8px;border-radius:8px;font-size:12px;font-weight:600;text-decoration:none;transition:background .15s}
|
|
43
|
+
#__mw_cta a:hover{background:#10b981}
|
|
44
|
+
</style>
|
|
45
|
+
<div id="__mw">
|
|
46
|
+
<div id="__mw_pill" onclick="document.getElementById('__mw_panel').style.display=document.getElementById('__mw_panel').style.display==='none'?'block':'none'">
|
|
47
|
+
<div id="__mw_logo"><span></span>mantiq</div>
|
|
48
|
+
<div id="__mw_stats">
|
|
49
|
+
<span id="__mw_dot" style="background:${statusColor}"></span>
|
|
50
|
+
<b>${durationMs}ms</b>
|
|
51
|
+
<span id="__mw_sep">·</span>
|
|
52
|
+
<span>${memMB}MB</span>
|
|
53
|
+
<span id="__mw_sep">·</span>
|
|
54
|
+
<span>${queries}q</span>
|
|
36
55
|
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</div>
|
|
46
|
-
<div>
|
|
47
|
-
|
|
48
|
-
<div style="color:${statusColor};font-weight:600;font-size:14px">${status}</div>
|
|
49
|
-
</div>
|
|
50
|
-
<div>
|
|
51
|
-
<div style="color:#52525b;font-size:10px;text-transform:uppercase;letter-spacing:.05em;margin-bottom:2px">Queries</div>
|
|
52
|
-
<div style="color:#fafafa;font-weight:600;font-size:14px">${queries}</div>
|
|
53
|
-
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<div id="__mw_panel">
|
|
58
|
+
<header>
|
|
59
|
+
<div class="brand"><i></i>mantiq</div>
|
|
60
|
+
<a href="${dashboardPath}">Dashboard →</a>
|
|
61
|
+
</header>
|
|
62
|
+
<div id="__mw_grid">
|
|
63
|
+
<div class="cell"><label>Duration</label><div class="val">${durationMs}<small>ms</small></div></div>
|
|
64
|
+
<div class="cell"><label>Memory</label><div class="val">${memMB}<small>MB</small></div></div>
|
|
65
|
+
<div class="cell"><label>Status</label><div class="val" style="color:${statusColor}">${status}</div></div>
|
|
66
|
+
<div class="cell"><label>Queries</label><div class="val">${queries}</div></div>
|
|
54
67
|
</div>
|
|
55
|
-
<div
|
|
56
|
-
<a href="${dashboardPath}"
|
|
68
|
+
<div id="__mw_cta">
|
|
69
|
+
<a href="${dashboardPath}">Open Heartbeat →</a>
|
|
57
70
|
</div>
|
|
58
71
|
</div>
|
|
59
72
|
</div>
|