@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantiq/heartbeat",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Observability, APM & queue monitoring for MantiqJS",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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 (!this.heartbeat.config.widget?.enabled) return response
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
- * Shows request duration, memory, status, query count, and links to Heartbeat.
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
- <div id="__mantiq_widget" style="position:fixed;bottom:16px;right:16px;z-index:99999;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;font-size:12px;pointer-events:auto;">
23
- <div id="__mw_pill" style="display:flex;align-items:center;gap:8px;background:#0a0a0b;border:1px solid #27272a;border-radius:8px;padding:6px 12px;cursor:pointer;box-shadow:0 4px 12px rgba(0,0,0,.4);transition:all .2s ease;color:#a1a1aa;" onclick="document.getElementById('__mw_panel').style.display=document.getElementById('__mw_panel').style.display==='none'?'block':'none'">
24
- <span style="width:6px;height:6px;border-radius:50%;background:${statusColor};flex-shrink:0"></span>
25
- <span style="color:#fafafa;font-weight:600">${durationMs}ms</span>
26
- <span style="color:#52525b">·</span>
27
- <span>${memMB}MB</span>
28
- <span style="color:#52525b">·</span>
29
- <span>${queries}q</span>
30
- <span style="color:#34d399;font-size:10px;margin-left:2px">▲</span>
31
- </div>
32
- <div id="__mw_panel" style="display:none;position:absolute;bottom:calc(100% + 8px);right:0;background:#0a0a0b;border:1px solid #27272a;border-radius:10px;padding:0;min-width:260px;box-shadow:0 8px 24px rgba(0,0,0,.5);overflow:hidden;">
33
- <div style="padding:12px 14px;border-bottom:1px solid #1e1e1e;display:flex;align-items:center;justify-content:space-between;">
34
- <span style="color:#34d399;font-weight:600;font-size:11px;letter-spacing:.03em">● HEARTBEAT</span>
35
- <a href="${dashboardPath}" style="color:#52525b;text-decoration:none;font-size:11px;transition:color .15s" onmouseover="this.style.color='#34d399'" onmouseout="this.style.color='#52525b'">Dashboard →</a>
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">&middot;</span>
52
+ <span>${memMB}MB</span>
53
+ <span id="__mw_sep">&middot;</span>
54
+ <span>${queries}q</span>
36
55
  </div>
37
- <div style="padding:10px 14px;display:grid;grid-template-columns:1fr 1fr;gap:8px;">
38
- <div>
39
- <div style="color:#52525b;font-size:10px;text-transform:uppercase;letter-spacing:.05em;margin-bottom:2px">Duration</div>
40
- <div style="color:#fafafa;font-weight:600;font-size:14px">${durationMs}<span style="color:#52525b;font-size:11px;font-weight:400">ms</span></div>
41
- </div>
42
- <div>
43
- <div style="color:#52525b;font-size:10px;text-transform:uppercase;letter-spacing:.05em;margin-bottom:2px">Memory</div>
44
- <div style="color:#fafafa;font-weight:600;font-size:14px">${memMB}<span style="color:#52525b;font-size:11px;font-weight:400">MB</span></div>
45
- </div>
46
- <div>
47
- <div style="color:#52525b;font-size:10px;text-transform:uppercase;letter-spacing:.05em;margin-bottom:2px">Status</div>
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 &rarr;</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 style="padding:8px 14px;border-top:1px solid #1e1e1e;">
56
- <a href="${dashboardPath}" style="display:block;text-align:center;color:#0a0a0b;background:#34d399;padding:6px;border-radius:6px;font-size:11px;font-weight:600;text-decoration:none;transition:background .15s" onmouseover="this.style.background='#10b981'" onmouseout="this.style.background='#34d399'">Open Heartbeat</a>
68
+ <div id="__mw_cta">
69
+ <a href="${dashboardPath}">Open Heartbeat &rarr;</a>
57
70
  </div>
58
71
  </div>
59
72
  </div>