@ereo/dev-inspector 0.1.27 → 0.1.28

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DevToolsPanel.d.ts","sourceRoot":"","sources":["../../src/devtools/DevToolsPanel.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EACV,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACT,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAgFzE;AAgaD;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,QAElE"}
1
+ {"version":3,"file":"DevToolsPanel.d.ts","sourceRoot":"","sources":["../../src/devtools/DevToolsPanel.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EACV,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACT,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAqFzE;AAqiBD;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,QAElE"}
package/dist/index.js CHANGED
@@ -1819,6 +1819,7 @@ function generateDevToolsPanelHTML(data) {
1819
1819
  <button class="nav-btn" data-tab="islands">Islands</button>
1820
1820
  <button class="nav-btn" data-tab="cache">Cache</button>
1821
1821
  <button class="nav-btn" data-tab="hmr">HMR</button>
1822
+ <button class="nav-btn" data-tab="traces">Traces</button>
1822
1823
  </nav>
1823
1824
  <div class="devtools-actions">
1824
1825
  <button class="action-icon" onclick="window.__EREO_DEVTOOLS__.refresh()" title="Refresh">
@@ -1859,6 +1860,10 @@ function generateDevToolsPanelHTML(data) {
1859
1860
  <div class="tab-panel" id="hmr-panel">
1860
1861
  ${generateHMRTabHTML(hmrEvents)}
1861
1862
  </div>
1863
+
1864
+ <div class="tab-panel" id="traces-panel">
1865
+ ${generateTracesTabHTML()}
1866
+ </div>
1862
1867
  </main>
1863
1868
  </div>
1864
1869
 
@@ -1936,6 +1941,134 @@ function formatTime(timestamp) {
1936
1941
  function escapeHtml5(str) {
1937
1942
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1938
1943
  }
1944
+ function generateTracesTabHTML() {
1945
+ return `
1946
+ <div class="traces-container" id="traces-root">
1947
+ <div class="traces-header">
1948
+ <h3>Request Traces</h3>
1949
+ <button class="traces-refresh" onclick="window.__EREO_DEVTOOLS_TRACES__.refresh()">Refresh</button>
1950
+ </div>
1951
+ <div class="traces-layout">
1952
+ <div class="traces-list" id="traces-list">
1953
+ <div class="no-events">
1954
+ <span class="no-events-icon">\uD83D\uDD0D</span>
1955
+ <span class="no-events-text">Loading traces...</span>
1956
+ </div>
1957
+ </div>
1958
+ <div class="traces-detail" id="traces-detail">
1959
+ <div class="no-events">
1960
+ <span class="no-events-text">Select a trace to view its waterfall</span>
1961
+ </div>
1962
+ </div>
1963
+ </div>
1964
+ </div>
1965
+ <script>
1966
+ (function() {
1967
+ const TRACES_API = '/__devtools/api/traces';
1968
+ let traces = [];
1969
+ let selectedId = null;
1970
+
1971
+ function durClass(ms) { return ms < 50 ? 'dur-fast' : ms < 200 ? 'dur-medium' : 'dur-slow'; }
1972
+ function statusClass(c) { return c < 300 ? 'status-ok' : c < 400 ? 'status-redirect' : 'status-error'; }
1973
+ function fmtDur(ms) { return ms < 1 ? (ms*1000).toFixed(0)+'us' : ms < 1000 ? ms.toFixed(1)+'ms' : (ms/1000).toFixed(2)+'s'; }
1974
+
1975
+ function renderList() {
1976
+ const el = document.getElementById('traces-list');
1977
+ if (!traces.length) { el.innerHTML = '<div class="no-events"><span class="no-events-icon">\uD83D\uDD0D</span><span class="no-events-text">No traces yet</span><span class="no-events-hint">Make requests to your app to see traces</span></div>'; return; }
1978
+ el.innerHTML = traces.map(t => {
1979
+ const s = t.metadata.statusCode || 200;
1980
+ return '<div class="trace-row'+(t.id===selectedId?' active':'')+'" data-id="'+t.id+'">' +
1981
+ '<span class="trace-method">'+(t.metadata.method||'GET')+'</span>' +
1982
+ '<span class="trace-path">'+(t.metadata.pathname||'/')+'</span>' +
1983
+ '<span class="trace-status '+statusClass(s)+'">'+s+'</span>' +
1984
+ '<span class="trace-dur '+durClass(t.duration)+'">'+fmtDur(t.duration)+'</span></div>';
1985
+ }).join('');
1986
+ el.querySelectorAll('.trace-row').forEach(r => { r.onclick = () => { selectedId = r.dataset.id; renderList(); renderDetail(); }; });
1987
+ }
1988
+
1989
+ function renderDetail() {
1990
+ const el = document.getElementById('traces-detail');
1991
+ const t = traces.find(x => x.id === selectedId);
1992
+ if (!t) { el.innerHTML = '<div class="no-events"><span class="no-events-text">Select a trace</span></div>'; return; }
1993
+ const spans = Object.values(t.spans);
1994
+ const root = spans.find(s => s.id === t.rootSpanId);
1995
+ if (!root) return;
1996
+ const flat = []; const minT = t.startTime; const dur = t.duration || 1;
1997
+ function walk(s, d) { flat.push({...s, depth: d}); spans.filter(c => c.parentId === s.id && c.id !== s.id).sort((a,b)=>a.startTime-b.startTime).forEach(c => walk(c, d+1)); }
1998
+ walk(root, 0);
1999
+ el.innerHTML = '<div class="waterfall">' + flat.map(s => {
2000
+ const l = ((s.startTime-minT)/dur*100).toFixed(2);
2001
+ const w = Math.max(0.5, s.duration/dur*100).toFixed(2);
2002
+ return '<div class="wf-row"><div class="wf-name" style="padding-left:'+(s.depth*12)+'px">'+s.name+'</div>' +
2003
+ '<div class="wf-bar-bg"><div class="wf-bar layer-'+s.layer+'" style="left:'+l+'%;width:'+w+'%"></div></div>' +
2004
+ '<div class="wf-dur '+durClass(s.duration)+'">'+fmtDur(s.duration)+'</div></div>';
2005
+ }).join('') + '</div>';
2006
+ }
2007
+
2008
+ async function load() {
2009
+ try {
2010
+ const res = await fetch(TRACES_API);
2011
+ const data = await res.json();
2012
+ traces = (data.traces || []).reverse();
2013
+ renderList();
2014
+ if (selectedId) renderDetail();
2015
+ } catch {}
2016
+ }
2017
+
2018
+ window.__EREO_DEVTOOLS_TRACES__ = { refresh: load };
2019
+ load();
2020
+
2021
+ // Live updates via WebSocket
2022
+ try {
2023
+ const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
2024
+ const ws = new WebSocket(proto + '//' + location.host + '/__ereo/trace-ws');
2025
+ ws.onmessage = (e) => { try { const d = JSON.parse(e.data); if (d.type === 'trace:end') { traces.unshift(d.trace); renderList(); } } catch {} };
2026
+ } catch {}
2027
+ })();
2028
+ </script>
2029
+ <style>
2030
+ .traces-container { height: 100%; display: flex; flex-direction: column; }
2031
+ .traces-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid #2a2f3a; }
2032
+ .traces-header h3 { font-size: 13px; color: #e2e8f0; }
2033
+ .traces-refresh { background: #2563eb; color: white; border: none; padding: 4px 10px; border-radius: 4px; font-size: 11px; cursor: pointer; }
2034
+ .traces-layout { display: flex; flex: 1; overflow: hidden; }
2035
+ .traces-list { width: 320px; border-right: 1px solid #2a2f3a; overflow-y: auto; }
2036
+ .traces-detail { flex: 1; overflow-y: auto; padding: 8px; }
2037
+ .trace-row { display: flex; align-items: center; padding: 6px 10px; font-size: 12px; cursor: pointer; border-bottom: 1px solid #1e2330; gap: 6px; }
2038
+ .trace-row:hover { background: #1e293b; }
2039
+ .trace-row.active { background: #1e3a5f; border-left: 2px solid #3b82f6; }
2040
+ .trace-method { font-weight: 600; width: 40px; color: #93c5fd; }
2041
+ .trace-path { flex: 1; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2042
+ .trace-status { width: 30px; text-align: center; }
2043
+ .trace-dur { width: 55px; text-align: right; font-size: 11px; }
2044
+ .status-ok { color: #4ade80; }
2045
+ .status-redirect { color: #60a5fa; }
2046
+ .status-error { color: #f87171; }
2047
+ .dur-fast { color: #4ade80; }
2048
+ .dur-medium { color: #facc15; }
2049
+ .dur-slow { color: #f87171; }
2050
+ .waterfall { padding: 4px 0; }
2051
+ .wf-row { display: flex; align-items: center; padding: 3px 6px; font-size: 11px; }
2052
+ .wf-row:hover { background: #1e293b; }
2053
+ .wf-name { width: 160px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cbd5e1; }
2054
+ .wf-bar-bg { flex: 1; height: 14px; position: relative; margin: 0 8px; background: #1e2330; border-radius: 2px; }
2055
+ .wf-bar { position: absolute; height: 10px; top: 2px; border-radius: 2px; min-width: 2px; }
2056
+ .wf-dur { width: 50px; text-align: right; flex-shrink: 0; font-size: 10px; }
2057
+ .layer-request { background: #64748b; }
2058
+ .layer-routing { background: #60a5fa; }
2059
+ .layer-data { background: #3b82f6; }
2060
+ .layer-database { background: #a78bfa; }
2061
+ .layer-auth { background: #facc15; }
2062
+ .layer-rpc { background: #60a5fa; }
2063
+ .layer-forms { background: #4ade80; }
2064
+ .layer-islands { background: #a78bfa; }
2065
+ .layer-build { background: #3b82f6; }
2066
+ .layer-errors { background: #f87171; }
2067
+ .layer-signals { background: #4ade80; }
2068
+ .layer-custom { background: #64748b; }
2069
+ </style>
2070
+ `;
2071
+ }
1939
2072
  var DEVTOOLS_BASE_STYLES = `
1940
2073
  * {
1941
2074
  box-sizing: border-box;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ereo/dev-inspector",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "license": "MIT",
5
5
  "author": "Ereo Team",
6
6
  "homepage": "https://ereo.dev",
@@ -33,9 +33,9 @@
33
33
  "typecheck": "tsc --noEmit"
34
34
  },
35
35
  "dependencies": {
36
- "@ereo/core": "^0.1.27",
37
- "@ereo/router": "^0.1.27",
38
- "@ereo/data": "^0.1.27"
36
+ "@ereo/core": "^0.1.28",
37
+ "@ereo/router": "^0.1.28",
38
+ "@ereo/data": "^0.1.28"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/bun": "^1.1.0",