@stacksjs/debugbar 0.0.1-stage → 0.75.730

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.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2023 Open Web Foundation
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/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Stacks Debugbar
2
+
3
+ The request inspector drawn at the foot of every page in development: queries, timeline, logs, exceptions, events, cache, mail and jobs for each request, plus a "Sign in as" tab. The Stacks counterpart of Laravel Debugbar.
4
+
5
+ It runs when the app environment is `local` or `development` and `APP_DEBUG` is not false. It cannot run in production: there the package registers nothing, whatever its configuration says.
6
+
7
+ ## Usage
8
+
9
+ A Stacks app needs no setup. Both servers wire the debugbar in, and the bar appears on every page.
10
+
11
+ ```ts
12
+ import { debugbar } from '@stacksjs/debugbar'
13
+
14
+ debugbar.info('cart recalculated', { items: cart.items.length })
15
+
16
+ const rates = await debugbar.measure('shipping rates', () => carrier.rates(cart))
17
+ ```
18
+
19
+ Every call is a no-op outside a collected request.
20
+
21
+ Add a section of your own:
22
+
23
+ ```ts
24
+ import { registerCollector } from '@stacksjs/debugbar'
25
+
26
+ registerCollector({
27
+ name: 'tenant',
28
+ label: 'Tenant',
29
+ collect: () => ({ id: currentTenant()?.id }),
30
+ })
31
+ ```
32
+
33
+ Configure it in `config/debugbar.ts`. See the [debugbar docs](https://stacksjs.com/docs/packages/debugbar).
34
+
35
+ ## Testing
36
+
37
+ ```bash
38
+ bun test
39
+ ```
40
+
41
+ ## License
42
+
43
+ MIT. See [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md).
package/dist/api.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import type { MessageLevel } from './types';
2
+ /**
3
+ * Add a line to the Messages tab.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * debugbar.addMessage('cart recalculated', 'cart')
8
+ * debugbar.info('resolved tenant', { id: tenant.id })
9
+ * ```
10
+ */
11
+ export declare function addMessage(message: unknown, label?: string, level?: MessageLevel, context?: unknown): void;
12
+ export declare function debug(message: unknown, context?: unknown): void;
13
+ export declare function info(message: unknown, context?: unknown): void;
14
+ export declare function warn(message: unknown, context?: unknown): void;
15
+ export declare function error(message: unknown, context?: unknown): void;
16
+ /** Start a named span on the timeline. End it with {@link stopMeasure}. */
17
+ export declare function startMeasure(name: string, label?: string): void;
18
+ export declare function stopMeasure(name: string): void;
19
+ /** Add a span whose start and duration are already known, in milliseconds. */
20
+ export declare function addMeasure(label: string, start: number, duration: number, group?: string): void;
21
+ /**
22
+ * Time `fn` and put it on the timeline. Returns what `fn` returns, and
23
+ * records the span whether it resolves or throws.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const rates = await debugbar.measure('shipping rates', () => carrier.rates(cart))
28
+ * ```
29
+ */
30
+ export declare function measure<T>(label: string, fn: () => T): T;
@@ -0,0 +1,9 @@
1
+ /** The loaded bundle's version, or '0' until it has loaded. Never waits. */
2
+ export declare function clientVersion(): string;
3
+ export declare function clientBundle(): Promise<ClientBundle>;
4
+ /** Forget the bundle, so the next request rebuilds it. For tests and client development. */
5
+ export declare function resetClientBundle(): void;
6
+ export declare interface ClientBundle {
7
+ body: string
8
+ version: string
9
+ }
@@ -0,0 +1,234 @@
1
+ (()=>{function u(e){return(...t)=>{try{let n=e(...t);if(n instanceof Promise)n.catch(()=>{})}catch{}}}function N(e,t){if(t===null||t===void 0||t===!1)return;if(Array.isArray(t)){for(let n of t)N(e,n);return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}function r(e,t,...n){let s=document.createElement(e);if(t)for(let[a,i]of Object.entries(t)){if(i===null||i===void 0||i===!1)continue;if(a==="class")s.className=String(i);else if(a.startsWith("on")&&typeof i==="function")s.addEventListener(a.slice(2).toLowerCase(),u(i));else if(a==="value"&&"value"in s)s.value=String(i);else if(i===!0)s.setAttribute(a,"");else s.setAttribute(a,String(i))}for(let a of n)N(s,a);return s}function E(e){while(e.firstChild)e.removeChild(e.firstChild)}function x(e){if(e===void 0||!Number.isFinite(e))return"-";if(e>=1000)return`${(e/1000).toFixed(2)}s`;if(e>=100)return`${Math.round(e)}ms`;if(e>=10)return`${e.toFixed(1)}ms`;return`${e.toFixed(2)}ms`}function R(e){if(e===void 0||!Number.isFinite(e))return"-";if(e>=1048576)return`${(e/1048576).toFixed(1)}MB`;if(e>=1024)return`${(e/1024).toFixed(1)}KB`;return`${e}B`}function P(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function S(e,t=0){if(e===null||e===void 0)return r("span",{class:"j-null"},"null");if(typeof e==="string")return r("span",{class:e==="[redacted]"?"j-redacted":"j-string"},e==="[redacted]"?e:JSON.stringify(e));if(typeof e==="number"||typeof e==="boolean")return r("span",{class:"j-number"},String(e));if(typeof e!=="object")return r("span",null,String(e));let n=Array.isArray(e)?e.map((i,o)=>[String(o),i]):Object.entries(e);if(n.length===0)return r("span",{class:"j-null"},Array.isArray(e)?"[]":"{}");let s=Array.isArray(e)?`Array(${n.length})`:`{${n.length}}`;return r("details",{class:"j-node",open:t<1},r("summary",null,s),r("div",{class:"j-children"},n.map(([i,o])=>r("div",{class:"j-row"},r("span",{class:"j-key"},`${i}: `),S(o,t+1)))))}function T(e){return r("table",{class:"kv"},r("tbody",null,e.filter(([,t])=>t!==void 0).map(([t,n])=>r("tr",null,r("th",{scope:"row"},t),r("td",null,n instanceof Node?n:typeof n==="object"&&n!==null?S(n):String(n??"-"))))))}function w(e){return r("p",{class:"empty"},e)}async function ue(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function C(e,t="Copy"){let n=r("button",{class:"btn",type:"button"},t);return n.addEventListener("click",u(async(s)=>{s.stopPropagation();let a=await ue(e());n.textContent=a?"Copied":"Copy failed",setTimeout(()=>{n.textContent=t},1200)})),n}var pe=new Set("select from where and or not in is null like ilike between exists insert into values update set delete join inner left right full outer cross on as distinct group by order having limit offset union all case when then else end create table alter drop index primary key foreign references default returning with recursive asc desc count sum avg min max begin commit rollback transaction savepoint release pragma explain analyze true false conflict do nothing replace using".split(" ")),ge=new Set(["from","where","group","order","having","limit","offset","values","set","returning","union"]),O=new Set(["and","or","join","inner","left","right","full","cross"]),B=/(--[^\n]*|\/\*[\s\S]*?\*\/)|('(?:[^']|'')*')|("(?:[^"]|"")*"|`[^`]*`)|(\$\d+|\?)|(\b\d+(?:\.\d+)?\b)|([A-Za-z_][\w$]*)|(\s+)|([\s\S])/g;function H(e){let t=[];B.lastIndex=0;let n;while((n=B.exec(e))!==null){let s=n[1]!==void 0?"comment":n[2]!==void 0?"string":n[3]!==void 0?"ident":n[4]!==void 0?"param":n[5]!==void 0?"number":n[6]!==void 0?"word":n[7]!==void 0?"space":"other";if(t.push({type:s,text:n[0]}),t.length>20000)break}return t}function he(e){if(e===null||e===void 0)return"NULL";if(typeof e==="number")return String(e);if(typeof e==="boolean")return e?"TRUE":"FALSE";return`'${(typeof e==="string"?e:JSON.stringify(e)).replace(/'/g,"''")}'`}function A(e,t){if(!t||t.length===0)return e;let n=0;return H(e).map((s)=>{if(s.type!=="param")return s.text;let a=s.text==="?"?n++:Number(s.text.slice(1))-1;return a>=0&&a<t.length?he(t[a]):s.text}).join("")}function F(e){let t=H(e.replace(/\s+/g," ").trim()),n=0,s="",a="";for(let i of t){if(i.type==="other"){if(i.text==="(")n++;else if(i.text===")")n=Math.max(0,n-1)}if(i.type==="word"&&n===0){let o=i.text.toLowerCase(),d=O.has(a)&&(o==="join"||o==="outer");if(ge.has(o)&&s.trim()!==""&&!(o==="set"&&a==="conflict"))s=`${s.trimEnd()}
2
+ `;else if(O.has(o)&&s.trim()!==""&&!d&&a!=="between")s=`${s.trimEnd()}
3
+ `;a=o}s+=i.text}return s}var fe={comment:"q-c",string:"q-s",ident:"q-i",param:"q-p",number:"q-n"};function D(e){let t=r("code",{class:"sql"});for(let n of H(e)){let s=n.type==="word"&&pe.has(n.text.toLowerCase())?"q-k":fe[n.type];if(s)t.appendChild(r("span",{class:s},n.text));else t.appendChild(document.createTextNode(n.text))}return t}function k(e,t){return e.collectors[t]}function q(e){return r("span",{class:"num dim",title:"Time since the request began"},`+${x(e)}`)}function K(e){if(e==="error"||e==="fatal"||e==="critical")return"tag bad";if(e==="warning"||e==="warn")return"tag warn";return"tag"}function z(e,t,n,s,a){let i=r("ul",{class:"rows"}),o=r("input",{class:"input",type:"search",placeholder:s,"aria-label":s}),d=r("span",{class:"stat"}),l=r("div",{class:"toolbar"},o),g,m=()=>{let b=o.value.trim().toLowerCase();E(i);let c=0;if(e.forEach((p,h)=>{if(b&&!t(p).toLowerCase().includes(b))return;if(g&&!g(p))return;c++,i.appendChild(n(p,h))}),d.textContent=c===e.length?P(e.length,"entry","entries"):`${c} of ${e.length}`,c===0)i.appendChild(r("li",{class:"empty"},"Nothing matches."))};return g=a?.(l,m),l.append(r("span",{class:"grow"}),d),o.addEventListener("input",u(m)),m(),r("div",null,l,i)}function _(e){let t=k(e,"messages")??[];if(t.length===0)return w("No messages. Call debugbar.info(), .warn(), .error() or .addMessage() during a request.");return z(t,(n)=>`${n.level} ${n.label??""} ${n.message}`,(n)=>r("li",{class:"row"},r("div",{class:"main"},r("div",{class:"mono"},n.message),n.context!==void 0&&r("div",{class:"meta"},S(n.context))),r("div",{class:"side"},n.label&&r("span",{class:"tag accent"},n.label),r("span",{class:K(n.level)},n.level),q(n.at))),"Filter messages")}function Q(e){let t=k(e,"logs")??[];if(t.length===0)return w("Nothing was logged during this request.");return z(t,(n)=>`${n.level} ${n.message}`,(n)=>r("li",{class:"row"},r("div",{class:"main"},r("div",{class:"mono"},n.message),n.context!==void 0&&r("div",{class:"meta"},S(n.context))),r("div",{class:"side"},r("span",{class:K(n.level)},n.level),q(n.at))),"Filter logs")}function me(e,t,n,s){let a=()=>s.prefs.interpolate?A(e.sql,e.params):e.sql,i=r("li",{class:"row q","data-slow":e.slow,"data-failed":Boolean(e.error)}),o=r("div",{role:"button",tabindex:"0","aria-expanded":"false",title:"Show the whole statement"}),d=r("div",{class:"bindings",hidden:!0}),l=()=>{let b=i.hasAttribute("data-open");E(o),o.appendChild(D(b?F(a()):a())),o.setAttribute("aria-expanded",String(b)),d.hidden=!b||e.params.length===0},g=()=>{i.toggleAttribute("data-open"),l()};if(o.addEventListener("click",u(g)),o.addEventListener("keydown",u((b)=>{if(b.key==="Enter"||b.key===" ")b.preventDefault(),g()})),e.params.length>0)d.append(r("span",{class:"dim"},"Bindings "),S(e.params,1));l();let m=n>0?Math.max(2,Math.round(e.duration/n*100)):0;return i.append(r("div",{class:"main"},r("div",{class:"line"},r("span",{class:"idx"},String(t+1)),o),d,r("div",{class:"meta"},e.source&&r("span",{class:"mono"},e.source),e.rows!==void 0&&r("span",null,P(e.rows,"row")),e.duplicates&&r("span",{class:"tag warn",title:"Identical statement and bindings ran this many times"},`duplicate x${e.duplicates}`),!e.duplicates&&e.similar&&e.similar>1&&r("span",{class:"tag",title:"Statements with this shape in the request"},`similar x${e.similar}`),e.slow&&r("span",{class:"tag warn"},"slow"),e.error&&r("span",{class:"tag bad"},e.error))),r("div",{class:"side"},r("span",{class:`meter${e.slow?" warn":""}`,title:"Share of the slowest statement"},r("i",{style:`width:${m}%`})),r("span",{class:"num"},x(e.duration)),C(()=>A(e.sql,e.params)))),i}function U(e,t){let n=k(e,"queries");if(!n||n.statements.length===0)return w("No queries ran during this request.");let s=Math.max(...n.statements.map((c)=>c.duration)),a=r("ul",{class:"rows"}),i=r("input",{class:"input",type:"search",placeholder:"Filter statements","aria-label":"Filter statements"}),o={slow:!1,duplicates:!1,sortByTime:!1},d=(c,p,h)=>{let f=r("button",{class:"btn",type:"button","aria-pressed":"false"},h===void 0?c:`${c} ${h}`);return f.addEventListener("click",u(()=>{o[p]=!o[p],f.setAttribute("aria-pressed",String(o[p])),m()})),f},l=r("button",{class:"btn",type:"button","aria-pressed":String(t.prefs.interpolate),title:"Write bound values into each statement"},"Bindings inline");l.addEventListener("click",u(()=>{t.prefs.interpolate=!t.prefs.interpolate,t.savePrefs(),l.setAttribute("aria-pressed",String(t.prefs.interpolate)),m()}));let g=r("span",{class:"stat"});function m(){let c=i.value.trim().toLowerCase(),p=n.statements.map((h,f)=>({query:h,index:f}));if(c)p=p.filter(({query:h})=>h.sql.toLowerCase().includes(c)||(h.source??"").toLowerCase().includes(c));if(o.slow)p=p.filter(({query:h})=>h.slow);if(o.duplicates)p=p.filter(({query:h})=>h.duplicates||(h.similar??0)>1);if(o.sortByTime)p=[...p].sort((h,f)=>f.query.duration-h.query.duration);E(a);for(let{query:h,index:f}of p)a.appendChild(me(h,f,s,t));if(p.length===0)a.appendChild(r("li",{class:"empty"},"Nothing matches."));g.textContent=p.length===n.statements.length?"":`${p.length} shown`}i.addEventListener("input",u(m)),m();let b=n.nPlusOne.map((c)=>r("div",{class:"callout"},r("p",null,r("b",null,`Possible N+1: ${c.count} statements with one shape`),c.source?` from ${c.source}`:""),D(c.sample)));if(n.dropped>0)b.push(r("div",{class:"callout"},r("p",null,`${n.dropped} more statements ran and were not kept. Raise debugbar.queries.maxQueries to see them.`)));return r("div",null,r("div",{class:"toolbar"},i,d("Slow","slow",n.slow),d("Repeated","duplicates",n.duplicates),d("Slowest first","sortByTime"),l,r("span",{class:"grow"}),g,r("span",{class:"stat"},r("b",null,String(n.count))," statements in ",r("b",null,x(n.duration))),n.failed>0&&r("span",{class:"tag bad"},`${n.failed} failed`),C(()=>n.statements.map((c)=>`${A(c.sql,c.params)};`).join(`
4
+ `),"Copy all")),b,a)}function W(e){let t=k(e,"timeline"),n=k(e,"queries"),s=Math.max(t?.duration??e.summary.duration,0.01),a=[{label:`${e.summary.method} ${e.summary.path}`,start:0,duration:s,group:"request"},...t?.measures??[],...(n?.statements??[]).map((o,d)=>({label:`query ${d+1}: ${o.sql.replace(/\s+/g," ").slice(0,60)}`,start:o.start,duration:o.duration,group:"query",slow:o.slow}))];a.sort((o,d)=>o.start-d.start||d.duration-o.duration);let i=(o)=>`${Math.min(100,Math.max(0,o/s*100)).toFixed(3)}%`;return r("div",{class:"tl"},r("div",{class:"toolbar",style:"position:static;padding:0 0 8px;border:0"},r("span",{class:"stat"},"Total ",r("b",null,x(s))),n&&n.count>0&&r("span",{class:"stat"},"Queries ",r("b",null,x(n.duration))),t?.memory&&r("span",{class:"stat"},"Memory ",r("b",null,R(t.memory.rss))," resident, ",r("b",null,R(t.memory.heapUsed))," heap")),r("div",{class:"tl-axis"},r("div",null,"Span"),r("div",null,r("span",null,"0"),r("span",null,x(s/2)),r("span",null,x(s))),r("div",{class:"num"},"Time")),a.map((o)=>r("div",{class:"tl-row",title:`${o.label}
5
+ Starts at ${x(o.start)}, takes ${x(o.duration)}`},r("div",{class:"tl-label"},o.group==="middleware"?`middleware: ${o.label}`:o.label),r("div",{class:"tl-track"},r("span",{class:`tl-bar g-${o.group}${o.slow?" slow":""}`,style:`left:${i(o.start)};width:${i(o.duration)}`})),r("div",{class:"num"},x(o.duration)))))}function X(e){let t=k(e,"exceptions")??[];if(t.length===0)return w("No exceptions were reported during this request.");return r("div",null,t.map((n)=>{let s=()=>`${n.name}: ${n.message}
6
+ ${n.frames.map((a)=>` at ${a.function??"<anonymous>"} (${a.file}:${a.line??0})`).join(`
7
+ `)}`;return r("div",{class:"ex"},r("div",{class:"toolbar",style:"position:static;padding:0 0 4px;border:0"},r("p",{class:"ex-title"},`${n.name}: ${n.message}`),r("span",{class:"grow"}),q(n.at),C(s)),n.excerpt&&r("div",null,r("div",{class:"mono dim"},`${n.excerpt.file}:${n.excerpt.line}`),r("div",{class:"excerpt"},n.excerpt.lines.map((a,i)=>{let o=n.excerpt.start+i;return r("div",{"data-hit":o===n.excerpt.line},r("span",null,String(o)),r("span",null,a||" "))}))),n.context!==void 0&&r("div",null,r("span",{class:"dim"},"Context "),S(n.context)),r("ol",{class:"frames"},n.frames.map((a)=>r("li",{"data-app":a.app},`${a.function??"<anonymous>"} `,r("span",{class:"dim"},`${a.file}${a.line?`:${a.line}`:""}`)))))}))}function J(e){let t=k(e,"events")??[];if(t.length===0)return w("No events were dispatched during this request.");return z(t,(n)=>n.name,(n)=>r("li",{class:"row"},r("div",{class:"main"},r("div",{class:"mono"},n.name),n.payload!==void 0&&r("div",{class:"meta"},S(n.payload,1))),r("div",{class:"side"},q(n.at))),"Filter events")}function V(e){let t=k(e,"cache");if(!t||t.operations.length===0)return w("The cache was not touched during this request.");let n={hit:"tag ok",miss:"tag warn",write:"tag accent",forget:"tag"};return z(t.operations,(s)=>`${s.type} ${s.key}`,(s)=>r("li",{class:"row"},r("div",{class:"main"},r("span",{class:"mono"},s.key)),r("div",{class:"side"},s.ttl!==void 0&&r("span",{class:"dim"},s.ttl===0?"forever":`ttl ${s.ttl}s`),r("span",{class:n[s.type]??"tag"},s.type),s.duration!==void 0&&r("span",{class:"num"},x(s.duration)),q(s.at))),"Filter keys",(s)=>{s.append(r("span",{class:"stat"},r("b",null,String(t.hits))," hits, ",r("b",null,String(t.misses))," misses, ",r("b",null,String(t.writes))," writes"))})}function G(e){let t=k(e,"mail")??[];if(t.length===0)return w("No mail was sent during this request.");return r("ul",{class:"rows"},t.map((n)=>r("li",{class:"row"},r("div",{class:"main"},r("div",null,r("b",null,n.subject||"(no subject)")),r("div",{class:"meta mono"},`to ${n.to.join(", ")||"-"}`,n.from&&` from ${n.from}`,n.message&&!n.success&&r("span",{class:"tag bad"},n.message))),r("div",{class:"side"},r("span",{class:"tag"},n.driver),r("span",{class:n.success?"tag ok":"tag bad"},n.success?"sent":"failed"),r("span",{class:"num"},x(n.duration)),q(n.at)))))}function Y(e){let t=k(e,"jobs")??[];if(t.length===0)return w("No jobs were dispatched during this request.");return r("ul",{class:"rows"},t.map((n)=>r("li",{class:"row"},r("div",{class:"main"},r("div",{class:"mono"},n.name),r("div",{class:"meta"},n.payload!==void 0&&S(n.payload,1),n.error&&r("span",{class:"tag bad"},n.error))),r("div",{class:"side"},r("span",{class:"tag"},n.queue),r("span",{class:n.event.endsWith("failed")?"tag bad":"tag accent"},n.event.replace(/^job:/,"")),q(n.at)))))}function Z(e){let t=k(e,"route"),n=k(e,"views"),s=[];if(t)s.push(["method",t.method],["pattern",t.path],["handler",t.handler],["middleware",t.middleware.length>0?t.middleware.join(", "):"none"]);if(n)s.push(["template",n.template??"not resolved (dynamic route)"],["layout",n.layout],["response",n.fragment?"fragment for a router navigation":"full document"],["render",x(n.renderMs)]);if(s.length===0)return w("No route matched this request.");return r("div",{class:"pad"},T(s))}function ee(e){let t=k(e,"auth");if(!t)return w("Nothing is known about who made this request.");return r("div",{class:"pad"},T([["authenticated",t.authenticated?"yes":"no"],["identified by",t.guard],["id",t.user?.id],["name",t.user?.name],["email",t.user?.email]]))}function te(e){let t=k(e,"request");if(!t)return w("The request section was not collected.");let n=(s)=>Object.entries(s).sort(([a],[i])=>a.localeCompare(i));return r("div",{class:"pad"},r("h3",null,"Request"),T([["method",t.method],["url",t.url],["host",t.host],["content type",t.contentType],["record",e.id],["served by",e.summary.process==="views"?"views server":"API server"]]),Object.keys(t.query).length>0&&[r("h3",null,"Query"),T(n(t.query))],t.input!==void 0&&[r("h3",null,"Input"),S(t.input)],r("h3",null,"Request headers"),T(n(t.headers)),t.cookies.length>0&&[r("h3",null,"Cookies (names only)"),r("div",{class:"mono"},t.cookies.join(", "))],r("h3",null,"Response"),T([["status",t.response.status],["content type",t.response.contentType],["size",t.response.size===void 0?"streamed":R(t.response.size)]]),r("h3",null,"Response headers"),T(n(t.response.headers)))}function ne(e){let t=k(e,"environment");if(!t)return w("The environment section was not collected.");let n=t.git;return r("div",{class:"pad"},T([["environment",t.environment],["stacks",t.stacks],["bun",t.bun],["platform",t.platform],["git",n?.branch||n?.sha?`${n.branch??"detached"}${n.sha?` @ ${n.sha}`:""}`:void 0],["process",`${String(t.process)} (pid ${String(t.pid)})`]]),r("h3",null,"Config"),S(t.config))}function re(e,t){let n=e.collectors[t];return n===void 0?w("This collector returned nothing for this request."):r("div",{class:"pad"},S(n))}function be(e){if(!e)return"tag";if(e>=500)return"tag bad";if(e>=400)return"tag warn";return"tag ok"}function se(e){let t=r("tbody"),n=r("table",{class:"grid"},r("thead",null,r("tr",null,r("th",null,"Status"),r("th",null,"Method"),r("th",null,"URL"),r("th",null,"Kind"),r("th",{class:"num"},"Time"),r("th",{class:"num"},"Queries"))),t),s=r("span",{class:"stat"}),a=()=>{E(t);let l=e.entries(),g=new Set(l.map((c)=>c.id)),m=e.serverEntries,b=[...l].reverse().concat((m??[]).filter((c)=>!g.has(c.id)));for(let c of b){let p=c.record?.summary,h=r("tr",{tabindex:"0","data-current":c.id===e.currentId()},r("td",null,r("span",{class:be(c.status)},c.status?String(c.status):"...")),r("td",{class:"mono"},c.method),r("td",{class:"mono"},c.url),r("td",null,c.kind),r("td",{class:"num"},x(p?.duration??c.duration)),r("td",{class:"num"},p?String(p.queries):"-")),f=()=>e.select(c.id);h.addEventListener("click",u(f)),h.addEventListener("keydown",u((y)=>{if(y.key==="Enter"||y.key===" ")y.preventDefault(),f()})),t.appendChild(h)}s.textContent=`${P(l.length,"request")} from this page${m?`, ${m.length} recent on the server`:""}`},i=r("input",{type:"checkbox"});i.checked=e.prefs.follow,i.addEventListener("change",u(()=>{e.prefs.follow=i.checked,e.savePrefs()}));let o=r("button",{class:"btn",type:"button"},"Load recent");o.addEventListener("click",u(async()=>{o.disabled=!0;try{e.serverEntries=(await e.recent()).map((l)=>({id:l.id,method:l.summary.method,url:l.summary.url,status:l.summary.status,kind:l.summary.kind,duration:l.summary.duration,at:Date.parse(l.startedAt)}))}finally{o.disabled=!1}a()}));let d=r("button",{class:"btn",type:"button",title:"Delete every stored record"},"Clear stored");return d.addEventListener("click",u(async()=>{await e.clearRecords(),e.serverEntries=[],a()})),a(),r("div",null,r("div",{class:"toolbar"},r("label",{class:"check"},i,"Follow the latest request"),r("span",{class:"grow"}),s,o,d),n)}function ie(e,t){let n=r("div"),s=r("p",{class:"error",role:"alert",hidden:!0}),a=r("input",{class:"input",type:"search",placeholder:"Filter users","aria-label":"Filter users"}),i=r("span",{class:"stat"}),o=r("button",{class:"btn",type:"button",hidden:!0},"Sign out"),d,l=(f)=>{s.textContent=f,s.hidden=!1},g=()=>{try{return e.options.tokenStorageKey?localStorage.getItem(e.options.tokenStorageKey):null}catch{return null}},m=async(f,y)=>{s.hidden=!0;let v=await e.request(f,{method:"POST",headers:{"Content-Type":"application/json","X-Debugbar-Token":e.token},body:JSON.stringify(y??{})}),L=await v.json().catch(()=>({}));if(!v.ok){l(typeof L.error==="string"?L.error:`The request failed with status ${v.status}.`);return}return L},b=async(f)=>{let y=await m("sign-in-as",{id:f});if(!y)return;let v=typeof y.tokenStorageKey==="string"?y.tokenStorageKey:e.options.tokenStorageKey;try{if(v&&typeof y.token==="string")localStorage.setItem(v,y.token)}catch{}window.dispatchEvent(new CustomEvent("stacks:debugbar:signed-in",{detail:{user:y.user,token:y.token}})),t(),location.reload()};o.addEventListener("click",u(async()=>{if(!await m("sign-out"))return;try{if(e.options.tokenStorageKey)localStorage.removeItem(e.options.tokenStorageKey)}catch{}window.dispatchEvent(new CustomEvent("stacks:debugbar:signed-out")),t(),location.reload()}));let c=()=>{if(E(n),!d)return;i.textContent=d.current?`Signed in as ${d.current.name}`:"Not signed in",o.hidden=!d.current;let f=a.value.trim().toLowerCase(),y=d.users.filter((v)=>!f||`${v.name} ${v.email??""} ${v.badge??""} ${v.description??""} ${v.id}`.toLowerCase().includes(f));if(d.users.length===0)n.appendChild(w("No users to offer. Seed the users table, or return some from debugbar.signInAs.users."));else if(y.length===0)n.appendChild(w("Nothing matches."));for(let v of y){let L=d.current!==null&&String(d.current.id)===String(v.id),M=r("button",{class:L?"btn":"btn primary",type:"button",disabled:L},L?"Current":"Sign in");M.addEventListener("click",u(async()=>{M.disabled=!0,await b(v.id).finally(()=>{M.disabled=L})})),n.appendChild(r("div",{class:"user","data-current":L},r("div",{style:"min-width:0"},r("div",null,r("span",{class:"name"},v.name)," ",v.badge&&r("span",{class:"tag accent"},v.badge)," ",r("span",{class:"dim mono"},`#${v.id}`)),r("div",{class:"sub"},[v.email,v.description].filter(Boolean).join(" · "))),M))}},p=async()=>{let f=g(),y=await e.request("users",f?{headers:{Authorization:`Bearer ${f}`}}:void 0);if(!y.ok){l(`Could not load users (status ${y.status}).`);return}if(d=await y.json(),!d.enabled)l("Sign in as is disabled in config/debugbar.ts.");c()};a.addEventListener("input",u(c));let h=r("button",{class:"btn",type:"button"},"Refresh");return h.addEventListener("click",u(p)),p().catch(()=>l("Could not load users.")),r("div",null,r("div",{class:"toolbar"},a,r("span",{class:"grow"}),i,o,h),s,n)}var I=`
8
+ :host {
9
+ all: initial;
10
+ --bg: #ffffff;
11
+ --bg-2: #f5f6f7;
12
+ --bg-3: #ebedf0;
13
+ --fg: #15171a;
14
+ --fg-2: #4a5058;
15
+ --fg-3: #7a818b;
16
+ --line: #dfe2e6;
17
+ --accent: #2f5bea;
18
+ --accent-bg: #e8eeff;
19
+ --ok: #17803d;
20
+ --warn: #a35a00;
21
+ --warn-bg: #fff4de;
22
+ --bad: #c5221f;
23
+ --bad-bg: #fde9e8;
24
+ --shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(15, 20, 30, 0.08);
25
+ --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
26
+ --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
27
+ --bar: 34px;
28
+ position: fixed;
29
+ left: 0;
30
+ right: 0;
31
+ bottom: 0;
32
+ z-index: 2147483000;
33
+ display: block;
34
+ font: 12px/1.45 var(--sans);
35
+ color: var(--fg);
36
+ color-scheme: light dark;
37
+ -webkit-text-size-adjust: 100%;
38
+ pointer-events: none;
39
+ }
40
+ @media (prefers-color-scheme: dark) {
41
+ :host {
42
+ --bg: #16181c;
43
+ --bg-2: #1d2025;
44
+ --bg-3: #272b31;
45
+ --fg: #e8eaed;
46
+ --fg-2: #b3b9c2;
47
+ --fg-3: #858c96;
48
+ --line: #2e3238;
49
+ --accent: #8eaaff;
50
+ --accent-bg: #222b45;
51
+ --ok: #5fce85;
52
+ --warn: #e8a84a;
53
+ --warn-bg: #3a2c12;
54
+ --bad: #ff8078;
55
+ --bad-bg: #401d1b;
56
+ --shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(0, 0, 0, 0.4);
57
+ }
58
+ }
59
+ *, *::before, *::after { box-sizing: border-box; }
60
+ .root { pointer-events: auto; background: var(--bg); box-shadow: var(--shadow); display: flex; flex-direction: column; }
61
+ .root[data-min] { display: none; }
62
+ button, input, select { font: inherit; color: inherit; margin: 0; }
63
+ button { cursor: pointer; }
64
+ :focus { outline: none; }
65
+ :focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 3px; }
66
+ [hidden] { display: none !important; }
67
+
68
+ /* Bar */
69
+ .bar { height: var(--bar); display: flex; align-items: stretch; gap: 0; border-top: 1px solid var(--line); background: var(--bg); white-space: nowrap; overflow: hidden; }
70
+ .brand { border: 0; background: var(--fg); color: var(--bg); padding: 0 12px; font-weight: 600; letter-spacing: 0.01em; display: flex; align-items: center; gap: 6px; flex: none; }
71
+ .brand .caret { display: inline-block; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 5px solid currentColor; }
72
+ .root[data-open] .brand .caret { border-bottom: 0; border-top: 5px solid currentColor; }
73
+ .chips { display: flex; align-items: stretch; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 1; }
74
+ .chips::-webkit-scrollbar { display: none; }
75
+ .chip { border: 0; border-right: 1px solid var(--line); background: transparent; padding: 0 10px; display: flex; align-items: center; gap: 6px; flex: none; color: var(--fg-2); font-variant-numeric: tabular-nums; }
76
+ .chip:hover, .chip[aria-pressed="true"] { background: var(--bg-2); color: var(--fg); }
77
+ .chip b { font-weight: 600; color: var(--fg); font-family: var(--mono); font-size: 11.5px; }
78
+ .chip .lbl { color: var(--fg-3); }
79
+ .chip.ok b { color: var(--ok); }
80
+ .chip.warn b { color: var(--warn); }
81
+ .chip.bad b { color: var(--bad); }
82
+ .chip.bad { background: var(--bad-bg); }
83
+ .chip .route { max-width: 320px; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 11.5px; color: var(--fg); }
84
+ .tools { display: flex; align-items: stretch; flex: none; border-left: 1px solid var(--line); }
85
+ .switch { border: 0; border-right: 1px solid var(--line); background: var(--bg); padding: 0 6px 0 8px; max-width: 300px; font-family: var(--mono); font-size: 11.5px; color: var(--fg-2); }
86
+ .icon { border: 0; background: transparent; width: var(--bar); display: grid; place-items: center; color: var(--fg-3); }
87
+ .icon:hover { background: var(--bg-2); color: var(--fg); }
88
+ .icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
89
+
90
+ /* Minimised badge */
91
+ .badge { pointer-events: auto; position: absolute; left: 12px; bottom: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 6px; padding: 5px 9px; display: none; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11.5px; box-shadow: 0 2px 10px rgba(15, 20, 30, 0.14); }
92
+ .badge[data-show] { display: flex; }
93
+ .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
94
+ .dot.warn { background: var(--warn); }
95
+ .dot.bad { background: var(--bad); }
96
+
97
+ /* Panel */
98
+ .panel { display: none; flex-direction: column; min-height: 0; position: relative; }
99
+ .root[data-open] .panel { display: flex; }
100
+ .resize { height: 7px; margin-top: -3px; cursor: ns-resize; position: absolute; top: 0; left: 0; right: 0; z-index: 2; touch-action: none; }
101
+ .resize::after { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 1px; background: transparent; }
102
+ .resize:hover::after, .resize:focus-visible::after, .resize[data-drag]::after { background: var(--accent); height: 2px; top: 2px; }
103
+ .tabs { display: flex; align-items: stretch; background: var(--bg-2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; flex: none; }
104
+ .tab { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 7px 11px 5px; color: var(--fg-2); display: flex; align-items: center; gap: 6px; flex: none; }
105
+ .tab:hover { color: var(--fg); }
106
+ .tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); background: var(--bg); }
107
+ .count { font-family: var(--mono); font-size: 10.5px; background: var(--bg-3); color: var(--fg-2); border-radius: 8px; padding: 0 5px; min-width: 16px; text-align: center; line-height: 15px; }
108
+ .count.bad { background: var(--bad-bg); color: var(--bad); }
109
+ .count.warn { background: var(--warn-bg); color: var(--warn); }
110
+ .body { overflow: auto; flex: 1; min-height: 0; background: var(--bg); overscroll-behavior: contain; }
111
+ .pad { padding: 10px 12px; }
112
+ .empty { color: var(--fg-3); padding: 18px 12px; margin: 0; }
113
+ .note { color: var(--fg-3); margin: 0 0 8px; }
114
+ h3 { font: 600 11px/1.4 var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-3); margin: 14px 0 6px; }
115
+ h3:first-child { margin-top: 0; }
116
+
117
+ /* Toolbars and controls */
118
+ .toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 1; flex-wrap: wrap; }
119
+ .toolbar .stat { color: var(--fg-2); font-variant-numeric: tabular-nums; }
120
+ .toolbar .stat b { font-family: var(--mono); color: var(--fg); font-weight: 600; }
121
+ .toolbar .grow { flex: 1; }
122
+ .input { border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 3px 7px; min-width: 180px; height: 24px; }
123
+ .input:focus-visible { outline-offset: 0; border-color: var(--accent); }
124
+ .btn { border: 1px solid var(--line); background: var(--bg); border-radius: 4px; padding: 2px 8px; height: 24px; color: var(--fg-2); white-space: nowrap; }
125
+ .btn:hover { background: var(--bg-2); color: var(--fg); }
126
+ .btn[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
127
+ .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
128
+ .btn.primary:hover { filter: brightness(1.08); }
129
+ .btn:disabled { opacity: 0.5; cursor: default; }
130
+ .check { display: inline-flex; align-items: center; gap: 5px; color: var(--fg-2); }
131
+ .tag { display: inline-block; font-family: var(--mono); font-size: 10.5px; line-height: 15px; padding: 0 5px; border-radius: 3px; background: var(--bg-3); color: var(--fg-2); white-space: nowrap; }
132
+ .tag.warn { background: var(--warn-bg); color: var(--warn); }
133
+ .tag.bad { background: var(--bad-bg); color: var(--bad); }
134
+ .tag.ok { color: var(--ok); }
135
+ .tag.accent { background: var(--accent-bg); color: var(--accent); }
136
+ .mono { font-family: var(--mono); font-size: 11.5px; }
137
+ .dim { color: var(--fg-3); }
138
+ .num { font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
139
+
140
+ /* Rows and tables */
141
+ .rows { list-style: none; margin: 0; padding: 0; }
142
+ .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 6px 12px; border-bottom: 1px solid var(--line); align-items: start; }
143
+ .row:hover { background: var(--bg-2); }
144
+ .row .main { min-width: 0; }
145
+ .row .meta { display: flex; align-items: center; gap: 6px; color: var(--fg-3); flex-wrap: wrap; margin-top: 2px; }
146
+ .row .side { display: flex; align-items: center; gap: 8px; }
147
+ table { border-collapse: collapse; width: 100%; }
148
+ .grid th { text-align: left; font-weight: 600; color: var(--fg-3); font-size: 11px; padding: 5px 12px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; }
149
+ .grid td { padding: 5px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
150
+ .grid tr:hover td { background: var(--bg-2); }
151
+ .grid tr[data-current] td { background: var(--accent-bg); }
152
+ .grid tr[tabindex] { cursor: pointer; }
153
+ .kv th { text-align: left; font-weight: 500; color: var(--fg-3); padding: 3px 14px 3px 0; white-space: nowrap; vertical-align: top; width: 1%; font-family: var(--mono); font-size: 11.5px; }
154
+ .kv td { padding: 3px 0; font-family: var(--mono); font-size: 11.5px; word-break: break-word; }
155
+
156
+ /* JSON */
157
+ .j-node { display: inline-block; vertical-align: top; }
158
+ .j-node > summary { cursor: pointer; color: var(--fg-3); list-style: none; }
159
+ .j-node > summary::before { content: "+ "; }
160
+ .j-node[open] > summary::before { content: "- "; }
161
+ .j-node > summary::-webkit-details-marker { display: none; }
162
+ .j-children { padding-left: 14px; border-left: 1px solid var(--line); margin-left: 3px; }
163
+ .j-row { font-family: var(--mono); font-size: 11.5px; }
164
+ .j-key { color: var(--fg-2); }
165
+ .j-string { color: var(--ok); word-break: break-word; }
166
+ .j-number { color: var(--accent); }
167
+ .j-null { color: var(--fg-3); }
168
+ .j-redacted { color: var(--warn); }
169
+
170
+ /* SQL */
171
+ .sql { font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; display: block; }
172
+ .q .sql { cursor: pointer; }
173
+ .q:not([data-open]) .sql { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
174
+ .q-k { color: var(--accent); font-weight: 600; }
175
+ .q-s { color: var(--ok); }
176
+ .q-n { color: var(--warn); }
177
+ .q-p { color: var(--bad); font-weight: 600; }
178
+ .q-i { color: var(--fg); }
179
+ .q-c { color: var(--fg-3); font-style: italic; }
180
+ .q[data-slow] { box-shadow: inset 3px 0 0 var(--warn); }
181
+ .q[data-failed] { box-shadow: inset 3px 0 0 var(--bad); background: var(--bad-bg); }
182
+ .q .idx { color: var(--fg-3); font-family: var(--mono); font-size: 10.5px; min-width: 22px; }
183
+ .q .line { display: flex; gap: 8px; align-items: baseline; }
184
+ .q .bindings { margin-top: 5px; font-family: var(--mono); font-size: 11.5px; color: var(--fg-2); }
185
+ .q .bindings, .q .meta { margin-left: 30px; }
186
+ .meter { width: 64px; height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; flex: none; }
187
+ .meter i { display: block; height: 100%; background: var(--accent); min-width: 1px; }
188
+ .meter.warn i { background: var(--warn); }
189
+ .callout { margin: 8px 12px; padding: 7px 10px; border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 3px; background: var(--warn-bg); }
190
+ .callout.bad { border-left-color: var(--bad); background: var(--bad-bg); }
191
+ .callout p { margin: 0 0 3px; }
192
+
193
+ /* Timeline */
194
+ .tl { padding: 8px 12px 12px; }
195
+ .tl-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) 70px; gap: 10px; align-items: center; height: 20px; }
196
+ .tl-row:hover { background: var(--bg-2); }
197
+ .tl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11.5px; }
198
+ .tl-track { position: relative; height: 10px; background: var(--bg-2); border-radius: 2px; }
199
+ .tl-bar { position: absolute; top: 0; bottom: 0; min-width: 2px; background: var(--accent); border-radius: 2px; }
200
+ .tl-bar.g-middleware { background: var(--fg-3); }
201
+ .tl-bar.g-query { background: var(--ok); }
202
+ .tl-bar.g-render, .tl-bar.g-handler { background: var(--fg-2); }
203
+ .tl-bar.slow { background: var(--warn); }
204
+ .tl-axis { display: grid; grid-template-columns: 200px minmax(0, 1fr) 70px; gap: 10px; color: var(--fg-3); font-family: var(--mono); font-size: 10.5px; margin-bottom: 4px; }
205
+ .tl-axis div:nth-child(2) { display: flex; justify-content: space-between; }
206
+
207
+ /* Exceptions */
208
+ .ex { border-bottom: 1px solid var(--line); padding: 10px 12px; }
209
+ .ex-title { font-weight: 600; color: var(--bad); margin: 0 0 2px; font-family: var(--mono); font-size: 12px; word-break: break-word; }
210
+ .excerpt { margin: 8px 0; border: 1px solid var(--line); border-radius: 4px; overflow: auto; font-family: var(--mono); font-size: 11.5px; }
211
+ .excerpt div { display: grid; grid-template-columns: 44px 1fr; white-space: pre; }
212
+ .excerpt div span:first-child { color: var(--fg-3); text-align: right; padding-right: 10px; user-select: none; background: var(--bg-2); }
213
+ .excerpt div[data-hit] { background: var(--bad-bg); }
214
+ .frames { list-style: none; margin: 6px 0 0; padding: 0; font-family: var(--mono); font-size: 11.5px; }
215
+ .frames li { padding: 1px 0; color: var(--fg-3); }
216
+ .frames li[data-app] { color: var(--fg); }
217
+
218
+ /* Sign in as */
219
+ .user { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); }
220
+ .user:hover { background: var(--bg-2); }
221
+ .user[data-current] { background: var(--accent-bg); }
222
+ .user .name { font-weight: 600; }
223
+ .user .sub { color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
224
+ .error { color: var(--bad); margin: 8px 12px; }
225
+
226
+ @media (prefers-reduced-motion: no-preference) {
227
+ .chip, .tab, .btn, .icon { transition: background-color 90ms ease, color 90ms ease; }
228
+ }
229
+ @media (max-width: 640px) {
230
+ .switch { display: none; }
231
+ .tl-row, .tl-axis { grid-template-columns: 110px minmax(0, 1fr) 60px; }
232
+ }
233
+ @media print { :host { display: none; } }
234
+ `;var ve="x-debugbar-id",oe="/__debugbar/",le="stacks-debugbar",ye=60,j=34,ae=[["messages","Messages"],["timeline","Timeline"],["queries","Queries"],["exceptions","Exceptions"],["logs","Logs"],["route","Route"],["events","Events"],["cache","Cache"],["mail","Mail"],["jobs","Jobs"],["auth","Auth"],["request","Request"],["environment","Environment"]],we=new Set(["views"]),xe=new Set(["timeline","queries","request"]);function ke(){let e={open:!1,minimized:!1,tab:"queries",height:320,follow:!1,interpolate:!1};try{let t=JSON.parse(localStorage.getItem(le)??"{}");return{open:t.open===!0,minimized:t.minimized===!0,tab:typeof t.tab==="string"?t.tab:e.tab,height:typeof t.height==="number"&&t.height>=120?t.height:e.height,follow:t.follow===!0,interpolate:t.interpolate===!0}}catch{return e}}function Ee(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 16 16"),t.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",e),t.appendChild(n),t}function Se(e){if(!e)return;let t=e.toLowerCase().split("+").map((a)=>a.trim()).filter(Boolean),n=t.pop();if(!n)return;let s=(a)=>t.includes(a);return(a)=>a.altKey===s("alt")&&a.shiftKey===s("shift")&&a.ctrlKey===(s("ctrl")||s("control"))&&a.metaKey===(s("meta")||s("cmd"))&&(a.key.toLowerCase()===n||a.code.toLowerCase()===`key${n}`||a.code.toLowerCase()===n)}class de{options;token;prefs;serverEntries;nativeFetch;list=[];current;pageId;host;root;chips;tabs;body;panel;switcher;badge;brand;resizer;originalPadding;renderedFor;tabsSignature;listVersion=0;signInDirty=!0;constructor(e,t,n,s){this.options=n,this.token=t,this.pageId=e,this.nativeFetch=s,this.prefs=ke(),this.host=document.createElement("stacks-debugbar"),this.host.setAttribute("data-stacks-debugbar-host","");let a=this.host.attachShadow({mode:"closed"});this.adoptStyles(a),this.brand=r("button",{class:"brand",type:"button","aria-expanded":"false",title:this.shortcutHint("Toggle the panel")},"Stacks",r("span",{class:"caret"})),this.chips=r("div",{class:"chips"}),this.switcher=r("select",{class:"switch","aria-label":"Request to inspect",title:"Requests made by this page"}),this.resizer=r("div",{class:"resize",role:"separator",tabindex:"0","aria-orientation":"horizontal","aria-label":"Resize the panel"}),this.tabs=r("div",{class:"tabs",role:"tablist","aria-label":"Debugbar sections"}),this.body=r("div",{class:"body",role:"tabpanel",tabindex:"0"}),this.panel=r("div",{class:"panel"},this.resizer,this.tabs,this.body);let i=r("button",{class:"icon",type:"button","aria-label":"Minimise the debugbar",title:"Minimise"},Ee("M3 12h10"));this.badge=r("button",{class:"badge",type:"button","aria-label":"Show the debugbar"}),this.root=r("div",{class:"root"},this.panel,r("div",{class:"bar",role:"toolbar","aria-label":"Stacks debugbar"},this.brand,this.chips,r("div",{class:"tools"},this.switcher,i))),a.append(this.root,this.badge),this.brand.addEventListener("click",u(()=>this.toggle())),i.addEventListener("click",u(()=>this.setMinimized(!0))),this.badge.addEventListener("click",u(()=>this.setMinimized(!1))),this.switcher.addEventListener("change",u(()=>this.select(this.switcher.value))),this.root.addEventListener("keydown",u((o)=>this.onKey(o))),this.bindResize(),this.bindShortcut(),this.mount(),this.note({id:e,method:"GET",url:location.pathname+location.search,kind:"page",status:void 0}),this.current=e,this.apply(),this.load(e)}entries(){return this.list}currentId(){return this.current}select(e){if(!this.list.some((t)=>t.id===e))this.list.push({id:e,method:"",url:"",kind:"api",at:Date.now()});this.current=e,this.render(),this.load(e)}savePrefs(){try{localStorage.setItem(le,JSON.stringify(this.prefs))}catch{}}request(e,t){return this.nativeFetch(oe+e,{credentials:"same-origin",...t})}async recent(){let e=await this.request("requests?limit=50");return e.ok?(await e.json()).requests:[]}async clearRecords(){await this.request("requests",{method:"DELETE",headers:{"X-Debugbar-Token":this.token}})}page(e,t){if(t)this.token=t;this.pageId=e,this.signInDirty=!0;let n=this.list.find((s)=>s.id===e);if(n)n.kind=n.kind==="api"?"fragment":n.kind;else this.note({id:e,method:"GET",url:location.pathname+location.search,kind:"page",status:void 0});this.mount(),this.select(e)}note(e){let t=this.list.find((n)=>n.id===e.id);if(t){t.status??=e.status;return}if(this.list.push({...e,at:Date.now()}),!e.method)this.load(e.id);if(this.list.length>ye){let n=this.list.findIndex((s)=>s.id!==this.pageId&&s.id!==this.current);if(n>=0)this.list.splice(n,1)}if(this.prefs.follow&&e.kind==="api"&&this.current!==void 0)this.select(e.id);else if(this.current!==void 0)this.render()}navigated(e){let t;try{let a=new URL(e??location.href,location.href);t=a.pathname+a.search}catch{}let n=this.list.filter((a)=>a.kind!=="api"&&a.id!==this.pageId),s=[...n].reverse().find((a)=>a.url===t)??n[n.length-1];if(s)this.page(s.id);else this.mount()}mount(){if(!this.host.isConnected)(document.documentElement??document.body).appendChild(this.host)}adoptStyles(e){try{let t=new CSSStyleSheet;t.replaceSync(I),e.adoptedStyleSheets=[t]}catch{e.appendChild(r("style",null,I))}}async load(e){let t=this.list.find((n)=>n.id===e);if(!t||t.record)return;for(let n of[0,60,140,300,600,1200]){if(n>0)await new Promise((s)=>setTimeout(s,n));try{let s=await this.request(`requests/${e}`);if(s.ok){t.record=await s.json(),t.status=t.record.summary.status,t.method=t.record.summary.method,t.url=t.record.summary.url,t.kind=t.record.summary.kind;break}if(s.status!==404)break}catch{break}}if(!t.record)t.missing=!0;this.listVersion++,this.render()}toggle(e){if(e&&(this.prefs.tab!==e||!this.prefs.open))this.prefs.tab=e,this.prefs.open=!0;else this.prefs.open=!this.prefs.open;this.prefs.minimized=!1,this.savePrefs(),this.apply()}setMinimized(e){this.prefs.minimized=e,this.savePrefs(),this.apply(),(e?this.badge:this.brand).focus()}maxHeight(){return Math.max(160,window.innerHeight-j-40)}apply(){let e=this.prefs.open&&!this.prefs.minimized;this.root.toggleAttribute("data-open",e),this.root.toggleAttribute("data-min",this.prefs.minimized),this.badge.toggleAttribute("data-show",this.prefs.minimized),this.brand.setAttribute("aria-expanded",String(e));let t=Math.min(this.prefs.height,this.maxHeight());this.panel.style.height=`${t}px`,this.resizer.setAttribute("aria-valuenow",String(Math.round(t))),this.resizer.setAttribute("aria-valuemin","120"),this.resizer.setAttribute("aria-valuemax",String(this.maxHeight())),this.pad(e?t+j:0),this.render()}pad(e){let t=document.documentElement;if(e>0){if(this.originalPadding===void 0)this.originalPadding=t.style.paddingBottom;t.style.paddingBottom=`${e}px`}else if(this.originalPadding!==void 0)t.style.paddingBottom=this.originalPadding,this.originalPadding=void 0}shortcutHint(e){return this.options.shortcut?`${e} (${this.options.shortcut})`:e}bindShortcut(){let e=Se(this.options.shortcut);if(!e)return;window.addEventListener("keydown",u((t)=>{if(!e(t))return;if(t.preventDefault(),this.prefs.minimized)this.setMinimized(!1);else this.toggle();if(this.prefs.open)this.brand.focus()}),!0)}onKey(e){if(e.key==="Escape"&&this.prefs.open){e.stopPropagation(),this.toggle(),this.brand.focus();return}let t=e.target;if(t?.getAttribute("role")!=="tab")return;let n=[...this.tabs.querySelectorAll('[role="tab"]')],s=n.indexOf(t),a=e.key==="ArrowRight"?n[(s+1)%n.length]:e.key==="ArrowLeft"?n[(s-1+n.length)%n.length]:e.key==="Home"?n[0]:e.key==="End"?n[n.length-1]:void 0;if(!a)return;e.preventDefault(),this.prefs.tab=a.dataset.tab??this.prefs.tab,this.savePrefs(),this.render(),this.tabs.querySelector('[aria-selected="true"]')?.focus()}bindResize(){let e=(t)=>{this.prefs.height=Math.round(Math.min(this.maxHeight(),Math.max(120,t))),this.apply()};this.resizer.addEventListener("pointerdown",u((t)=>{t.preventDefault();let n=t.clientY,s=this.panel.getBoundingClientRect().height;this.resizer.setAttribute("data-drag",""),this.resizer.setPointerCapture(t.pointerId);let a=u((o)=>{this.prefs.height=Math.round(Math.min(this.maxHeight(),Math.max(120,s+n-o.clientY))),this.panel.style.height=`${this.prefs.height}px`,this.pad(this.prefs.height+j)}),i=u(()=>{this.resizer.removeAttribute("data-drag"),this.resizer.removeEventListener("pointermove",a),this.resizer.removeEventListener("pointerup",i),this.resizer.removeEventListener("pointercancel",i),this.savePrefs(),this.apply()});this.resizer.addEventListener("pointermove",a),this.resizer.addEventListener("pointerup",i),this.resizer.addEventListener("pointercancel",i)})),this.resizer.addEventListener("keydown",u((t)=>{let n=t.shiftKey?80:24;if(t.key==="ArrowUp")e(this.prefs.height+n);else if(t.key==="ArrowDown")e(this.prefs.height-n);else return;t.preventDefault(),this.savePrefs()})),window.addEventListener("resize",u(()=>{if(this.prefs.open&&!this.prefs.minimized)this.apply()}))}record(){return this.list.find((e)=>e.id===this.current)?.record}tabSpecs(e){let t=[],n=e?.collectors??{},s=(i)=>Array.isArray(n[i])?n[i].length:void 0;for(let[i,o]of ae){if(!(i==="route"?n.route!==void 0||n.views!==void 0:n[i]!==void 0)&&!xe.has(i))continue;let l={id:i,label:o};if(i==="queries"){let g=n.queries;if(l.count=g?.count??0,(g?.failed??0)>0)l.tone="bad";else if((g?.nPlusOne?.length??0)>0||(g?.slow??0)>0)l.tone="warn"}else if(i==="cache")l.count=n.cache?.operations?.length;else if(i==="exceptions")l.count=s(i),l.tone="bad";else if(i==="messages"||i==="logs"||i==="events"||i==="mail"||i==="jobs")l.count=s(i);t.push(l)}let a=new Set(ae.map(([i])=>i));for(let i of Object.keys(n))if(!a.has(i)&&!we.has(i))t.push({id:`custom:${i}`,label:e?.labels?.[i]??i});if(t.push({id:"requests",label:"Requests",count:this.list.length}),this.options.signInAs!==!1)t.push({id:"signin",label:"Sign in as"});return t}render(){let e=this.record();if(this.renderChips(e),this.renderSwitcher(),this.renderBadge(e),!this.prefs.open||this.prefs.minimized)return;let t=this.tabSpecs(e);if(!t.some((i)=>i.id===this.prefs.tab))this.prefs.tab=t.some((i)=>i.id==="queries")?"queries":t[0].id;let n=JSON.stringify([t,this.prefs.tab]),s=n===this.tabsSignature;if(this.tabsSignature=n,!s)E(this.tabs);for(let i of s?[]:t){let o=i.id===this.prefs.tab,d=r("button",{class:"tab",type:"button",role:"tab","aria-selected":String(o),tabindex:o?"0":"-1","data-tab":i.id},i.label,i.count!==void 0&&i.count>0&&r("span",{class:`count${i.tone?` ${i.tone}`:""}`},String(i.count)));d.addEventListener("click",u(()=>{this.prefs.tab=i.id,this.savePrefs(),this.render()})),this.tabs.appendChild(d)}let a=`${this.prefs.tab}|${this.current}|${e?"r":"n"}|${this.prefs.tab==="requests"?`${this.list.length}.${this.listVersion}`:0}`;if(this.prefs.tab==="signin"&&this.renderedFor?.startsWith("signin|")&&!this.signInDirty)return;if(a===this.renderedFor)return;this.renderedFor=a,E(this.body),this.body.scrollTop=0,this.body.setAttribute("aria-label",t.find((i)=>i.id===this.prefs.tab)?.label??"Section"),this.body.appendChild(this.panelFor(this.prefs.tab,e))}panelFor(e,t){try{if(e==="requests")return se(this);if(e==="signin")return this.signInDirty=!1,ie(this,()=>{this.signInDirty=!0});if(!t){let n=this.list.find((s)=>s.id===this.current);return w(n?.missing?"This request's record is not on disk. It may have been pruned, or the server restarted before it was written.":"Loading the record...")}switch(e){case"messages":return _(t);case"timeline":return W(t);case"queries":return U(t,this);case"exceptions":return X(t);case"logs":return Q(t);case"route":return Z(t);case"events":return J(t);case"cache":return V(t);case"mail":return G(t);case"jobs":return Y(t);case"auth":return ee(t);case"request":return te(t);case"environment":return ne(t)}if(e.startsWith("custom:"))return re(t,e.slice(7));return w("Nothing to show.")}catch{return w("This section could not be drawn.")}}chip(e,t,n,...s){let a=this.prefs.open&&!this.prefs.minimized&&this.prefs.tab===e,i=r("button",{class:`chip${n?` ${n}`:""}`,type:"button",title:t,"aria-pressed":String(a)},...s);return i.addEventListener("click",u(()=>this.toggle(e))),i}renderChips(e){if(E(this.chips),!e){let i=this.list.find((o)=>o.id===this.current);this.chips.appendChild(r("span",{class:"chip"},r("span",{class:"lbl"},i?.missing?"No record for this request":"Loading...")));return}let t=e.summary,n=e.collectors.queries,s=t.status>=500?"bad":t.status>=400?"warn":"ok",a=(n?.failed??0)>0?"bad":(n?.nPlusOne?.length??0)>0||(n?.slow??0)>0?"warn":"";if(this.chips.append(this.chip("request","Response status. Opens Request.",s,r("b",null,String(t.status))),this.chip("route","Route. Opens Route.","",r("span",{class:"route"},t.route??`${t.method} ${t.path}`)),this.chip("timeline","Total time. Opens Timeline.","",r("b",null,x(t.duration))),this.chip("queries","Queries. Opens Queries.",a,r("span",{class:"lbl"},"SQL"),r("b",null,String(t.queries)),t.queries>0&&r("span",{class:"lbl"},x(t.queryDuration))),this.chip("timeline","Resident memory of the server process. Opens Timeline.","",r("span",{class:"lbl"},"MEM"),r("b",null,R(t.memory*1048576)))),t.logs>0)this.chips.appendChild(this.chip(e.collectors.messages?"messages":"logs","Messages and log lines.","",r("span",{class:"lbl"},"LOG"),r("b",null,String(t.logs))));if(t.exceptions>0)this.chips.appendChild(this.chip("exceptions","Exceptions. Opens Exceptions.","bad",r("span",{class:"lbl"},"ERR"),r("b",null,String(t.exceptions))));this.chips.appendChild(this.chip(this.options.signInAs!==!1?"signin":"auth","Who this request was signed in as.","",r("span",{class:"lbl"},"USER"),r("b",null,t.user?t.user.name??`#${t.user.id}`:"guest")))}renderSwitcher(){let e=[...this.list].reverse().map((n)=>{let s=n.id===this.pageId?"page":n.kind,a=`${n.status??"..."} ${n.method} ${n.url.length>60?`${n.url.slice(0,57)}...`:n.url} (${s})`,i=r("option",{value:n.id},a);return i.selected=n.id===this.current,i});E(this.switcher),this.switcher.append(...e);let t=this.list.length-1;this.switcher.title=t>0?`${t} more ${t===1?"request":"requests"} made by this page`:"Requests made by this page"}renderBadge(e){E(this.badge);let t=e?.summary.status??0,n=t>=500||(e?.summary.exceptions??0)>0?"bad":t>=400?"warn":"";this.badge.title=this.shortcutHint("Show the debugbar"),this.badge.append(r("span",{class:`dot ${n}`}),e?`${x(e.summary.duration)} ${e.summary.queries} SQL`:"Stacks")}}function ce(e){try{let t=new URL(e,location.href);return{path:t.origin===location.origin?t.pathname+t.search:t.href,internal:t.origin===location.origin&&t.pathname.startsWith(oe)}}catch{return}}function Le(e,t){let n=(o,d,l,g,m)=>{try{let b=ce(l);if(!o||!b||b.internal||!/^[0-9a-z]{20,32}$/.test(o))return;e()?.note({id:o,method:d.toUpperCase(),url:b.path,status:g,kind:m?"fragment":"api"})}catch{}};window.fetch=function(d,l){let g=t(d,l);try{let m=typeof Request<"u"&&d instanceof Request?d:void 0,b=m?m.url:String(d),c=l?.method??m?.method??"GET";g.then((p)=>{let h=p.headers.get("content-type")??"";n(p.headers.get(ve),c,b,p.status,h.startsWith("text/html"))},()=>{})}catch{}return g};let s=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send,i=new WeakMap;XMLHttpRequest.prototype.open=function(d,l,...g){try{i.set(this,{method:d,url:String(l)})}catch{}return s.call(this,d,l,...g)},XMLHttpRequest.prototype.send=function(d){try{this.addEventListener("loadend",()=>{try{let l=i.get(this),g=/^x-debugbar-id:\s*(\S+)/im.exec(this.getAllResponseHeaders()||"");if(l&&g)n(g[1],l.method,l.url,this.status,(this.getResponseHeader("content-type")??"").startsWith("text/html"))}catch{}})}catch{}return a.call(this,d)}}function Te(e){let t=(n)=>{for(let s of n){if(s.initiatorType!=="fetch"&&s.initiatorType!=="xmlhttprequest")continue;let a=s.serverTiming?.find((o)=>o.name==="debugbar")?.description,i=a?ce(s.name):void 0;if(!a||!i||i.internal||!/^[0-9a-z]{20,32}$/.test(a))continue;e.note({id:a,method:"",url:i.path,status:s.responseStatus||void 0,kind:"api"})}};try{new PerformanceObserver(u((n)=>t(n.getEntries()))).observe({type:"resource",buffered:!0})}catch{try{t(performance.getEntriesByType("resource"))}catch{}}}function $e(){let e=window,t=document.currentScript??document.querySelector("script[data-stacks-debugbar]:last-of-type"),n=t?.dataset.id,s=t?.dataset.token??"";if(!n)return;if(e.__stacksDebugbar){e.__stacksDebugbar.page(n,s);return}let a={};try{a=JSON.parse(t?.dataset.options??"{}")}catch{}let i=window.fetch.bind(window),o;Le(()=>o,i),e.__stacksDebugbar={page:(l,g)=>o?.page(l,g)};let d=()=>{o=new de(n,s,a,i),Te(o),window.addEventListener("stx:navigate",u((l)=>{o?.navigated(l.detail?.url)}))};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",u(d),{once:!0});else d()}try{$e()}catch{}})();
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const authCollector: Collector;
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const cacheCollector: Collector;
@@ -0,0 +1,4 @@
1
+ import type { Collector } from '../collectors';
2
+ /** Branch and commit, read from `.git` directly: no process is spawned per boot. */
3
+ export declare function readGitHead(root: string): { branch?: string, sha?: string };
4
+ export declare const environmentCollector: Collector;
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const eventsCollector: Collector;
@@ -0,0 +1,5 @@
1
+ import type { Collection } from '../context';
2
+ import type { Collector } from '../collectors';
3
+ /** Record a thrown value against a request, once however many layers report it. */
4
+ export declare function recordException(collection: Collection, thrown: unknown, context?: unknown): void;
5
+ export declare const exceptionsCollector: Collector;
@@ -0,0 +1,5 @@
1
+ import type { Collector } from '../collectors';
2
+ import type { ResolvedDebugbarConfig } from '../types';
3
+ /** The built-in collectors this app has not switched off. */
4
+ export declare function builtInCollectors(config: ResolvedDebugbarConfig): Collector[];
5
+ export declare const BUILT_IN_COLLECTOR_NAMES: readonly string[];
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const jobsCollector: Collector;
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const logsCollector: Collector;
@@ -0,0 +1,4 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const mailCollector: Collector;
3
+ declare type Address = string | { address?: string, name?: string }
4
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const messagesCollector: Collector;
@@ -0,0 +1,18 @@
1
+ import type { Collector, CollectorContext } from '../collectors';
2
+ /** The hooks handed to the query builder. Separate so they can be driven directly. */
3
+ export declare function createQueryHooks({ current, config }: Pick<CollectorContext, 'current' | 'config'>): QueryHooks;
4
+ export declare const queriesCollector: Collector;
5
+ export declare interface QueryEvent {
6
+ sql: string
7
+ params?: unknown[]
8
+ kind?: string
9
+ durationMs?: number
10
+ rowCount?: number
11
+ error?: unknown
12
+ }
13
+ export declare interface QueryHooks {
14
+ onQueryStart?: (event: QueryEvent) => void
15
+ onQueryEnd: (event: QueryEvent) => void
16
+ onQueryError: (event: QueryEvent) => void
17
+ onModelQuery: (event: QueryEvent) => void
18
+ }
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const requestCollector: Collector;
@@ -0,0 +1,2 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare const routeCollector: Collector;
@@ -0,0 +1,4 @@
1
+ import type { Collector } from '../collectors';
2
+ /** `total;dur=12.3, mw_auth;dur=1.2` to its entries. */
3
+ export declare function parseServerTiming(header: string | null): Array<{ name: string, duration: number }>;
4
+ export declare const timelineCollector: Collector;
@@ -0,0 +1,11 @@
1
+ import type { Collector } from '../collectors';
2
+ export declare function setViewsRoot(root: string): void;
3
+ /**
4
+ * The template a path maps to by the file-routing convention.
5
+ *
6
+ * stx does not say which file it rendered, so this looks for the two files a
7
+ * static path can be: `cars.stx` or `cars/index.stx`. A dynamic route
8
+ * (`cars/[id].stx`) is not guessed at, and the section then names no template.
9
+ */
10
+ export declare function conventionalTemplate(path: string): string | undefined;
11
+ export declare const viewsCollector: Collector;
@@ -0,0 +1,47 @@
1
+ import type { Collection } from './context';
2
+ import type { DebugbarProcess, DebugbarRequestKind, ResolvedDebugbarConfig } from './types';
3
+ /**
4
+ * Add a collector, replacing any with the same name. Returns a function that
5
+ * removes it.
6
+ *
7
+ * Safe to call anywhere, including in production: registering only records
8
+ * the collector. Nothing is attached unless the debugbar is enabled.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * registerCollector({
13
+ * name: 'tenant',
14
+ * label: 'Tenant',
15
+ * collect: () => ({ id: currentTenant()?.id }),
16
+ * })
17
+ * ```
18
+ */
19
+ export declare function registerCollector(collector: Collector): () => void;
20
+ export declare function collectors(): Collector[];
21
+ /** Attach every registered collector. Idempotent. */
22
+ export declare function installCollectors(config: ResolvedDebugbarConfig, process: DebugbarProcess): void;
23
+ /** Detach every collector's hooks. The registry itself is kept. */
24
+ export declare function uninstallCollectors(): void;
25
+ export declare function collectorsInstalled(): boolean;
26
+ /** Tell every collector that wants to know that a request has begun. */
27
+ export declare function beginCollectors(collection: Collection): void;
28
+ /** Run every collector over a finished request. One that throws loses only its own section. */
29
+ export declare function runCollectors(collection: Collection, response: ResponseSnapshot): Promise<{ sections: Record<string, unknown>, labels: Record<string, string> }>;
30
+ /** What is known about the response when a request finishes. */
31
+ export declare interface ResponseSnapshot {
32
+ status: number
33
+ headers: Headers
34
+ kind: DebugbarRequestKind
35
+ }
36
+ export declare interface CollectorContext {
37
+ config: ResolvedDebugbarConfig
38
+ process: DebugbarProcess
39
+ current: () => Collection | undefined
40
+ }
41
+ export declare interface Collector {
42
+ name: string
43
+ label?: string
44
+ install?: (context: CollectorContext) => void | (() => void) | Promise<void | (() => void)>
45
+ begin?: (collection: Collection) => void
46
+ collect?: (collection: Collection, response: ResponseSnapshot) => unknown | Promise<unknown>
47
+ }