@lytjs/devtools 4.0.5 → 4.1.0

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.
Files changed (38) hide show
  1. package/dist/index.cjs +5 -5
  2. package/dist/index.mjs +4 -4
  3. package/dist/tsconfig.tsbuildinfo +1 -0
  4. package/dist/types/batch-analyzer.d.ts +150 -0
  5. package/dist/types/batch-analyzer.d.ts.map +1 -0
  6. package/dist/types/component-profiler.d.ts +144 -0
  7. package/dist/types/component-profiler.d.ts.map +1 -0
  8. package/dist/types/component-tree.d.ts +69 -0
  9. package/dist/types/component-tree.d.ts.map +1 -0
  10. package/dist/types/event-panel.d.ts +129 -0
  11. package/dist/types/event-panel.d.ts.map +1 -0
  12. package/dist/types/event-tracker.d.ts +80 -0
  13. package/dist/types/event-tracker.d.ts.map +1 -0
  14. package/dist/types/hooks.d.ts +177 -0
  15. package/dist/types/hooks.d.ts.map +1 -0
  16. package/dist/types/index.d.ts +185 -0
  17. package/dist/types/index.d.ts.map +1 -0
  18. package/dist/types/memory-tracker.d.ts +148 -0
  19. package/dist/types/memory-tracker.d.ts.map +1 -0
  20. package/dist/types/panel.d.ts +182 -0
  21. package/dist/types/panel.d.ts.map +1 -0
  22. package/dist/types/perf-collector.d.ts +328 -0
  23. package/dist/types/perf-collector.d.ts.map +1 -0
  24. package/dist/types/perf-panel.d.ts +231 -0
  25. package/dist/types/perf-panel.d.ts.map +1 -0
  26. package/dist/types/render-tracker.d.ts +147 -0
  27. package/dist/types/render-tracker.d.ts.map +1 -0
  28. package/dist/types/route-panel.d.ts +68 -0
  29. package/dist/types/route-panel.d.ts.map +1 -0
  30. package/dist/types/router-panel-enhanced.d.ts +118 -0
  31. package/dist/types/router-panel-enhanced.d.ts.map +1 -0
  32. package/dist/types/state-inspector.d.ts +80 -0
  33. package/dist/types/state-inspector.d.ts.map +1 -0
  34. package/dist/types/time-travel.d.ts +189 -0
  35. package/dist/types/time-travel.d.ts.map +1 -0
  36. package/dist/types/virtual-tree.d.ts +168 -0
  37. package/dist/types/virtual-tree.d.ts.map +1 -0
  38. package/package.json +5 -3
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ce=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Pe=(i,e)=>{for(var t in e)ce(i,t,{get:e[t],enumerable:!0})},De=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Le(e))!ke.call(i,r)&&r!==t&&ce(i,r,{get:()=>e[r],enumerable:!(n=Me(e,r))||n.enumerable});return i};var He=i=>De(ce({},"__esModule",{value:!0}),i);var it={};Pe(it,{BatchAnalyzer:()=>ie,ComponentProfiler:()=>A,ComponentTreeInspector:()=>I,DevTools:()=>ae,DevToolsPanel:()=>D,EventPanel:()=>te,EventTracker:()=>z,MemoryTracker:()=>oe,PerfPanel:()=>ee,PerformanceCollector:()=>$,RenderTracker:()=>se,RoutePanel:()=>Z,RouterPanel:()=>ne,StateInspector:()=>B,TimeTravelDebugger:()=>N,VirtualComponentTree:()=>re,clearRecords:()=>G,connectToApp:()=>U,createDevTools:()=>st,disconnect:()=>Q,getAllComponents:()=>L,getChildComponents:()=>j,getComponentById:()=>H,getComponentCount:()=>we,getComponentEvents:()=>Ce,getComponentStateChanges:()=>V,getEventRecords:()=>J,getRootComponent:()=>q,getSelectedComponent:()=>Y,getSelectedComponentId:()=>k,getStateChangeRecords:()=>Te,isAppConnected:()=>Ee,refreshComponentTree:()=>X,selectComponent:()=>W,setComponentState:()=>K});module.exports=He(it);var Ie=`
1
+ var ce=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Pe=(i,e)=>{for(var t in e)ce(i,t,{get:e[t],enumerable:!0})},De=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Le(e))!ke.call(i,r)&&r!==t&&ce(i,r,{get:()=>e[r],enumerable:!(n=Me(e,r))||n.enumerable});return i};var He=i=>De(ce({},"__esModule",{value:!0}),i);var it={};Pe(it,{BatchAnalyzer:()=>ie,ComponentProfiler:()=>A,ComponentTreeInspector:()=>I,DevTools:()=>ae,DevToolsPanel:()=>D,EventPanel:()=>te,EventTracker:()=>z,MemoryTracker:()=>oe,PerfPanel:()=>ee,PerformanceCollector:()=>$,RenderTracker:()=>se,RoutePanel:()=>Z,RouterPanel:()=>ne,StateInspector:()=>B,TimeTravelDebugger:()=>N,VirtualComponentTree:()=>re,clearRecords:()=>G,connectToApp:()=>U,createDevTools:()=>st,disconnect:()=>Q,getAllComponents:()=>L,getChildComponents:()=>j,getComponentById:()=>H,getComponentCount:()=>we,getComponentEvents:()=>Ce,getComponentStateChanges:()=>V,getEventRecords:()=>J,getRootComponent:()=>q,getSelectedComponent:()=>Y,getSelectedComponentId:()=>k,getStateChangeRecords:()=>Te,isAppConnected:()=>Ee,refreshComponentTree:()=>X,selectComponent:()=>W,setComponentState:()=>K});module.exports=He(it);var Ie=`
2
2
  /* === Lyt DevTools \u9762\u677F\u57FA\u7840\u6837\u5F0F === */
3
3
  .lyt-devtools-panel {
4
4
  position: fixed;
@@ -282,7 +282,7 @@
282
282
  .lyt-devtools-highlight {
283
283
  animation: lyt-devtools-highlight 1s ease-out;
284
284
  }
285
- `,Be=[{id:"components",label:"\u7EC4\u4EF6\u6811",icon:"\u{1F333}"},{id:"state",label:"\u72B6\u6001",icon:"\u{1F4CA}"},{id:"events",label:"\u4E8B\u4EF6",icon:"\u26A1"},{id:"router",label:"\u8DEF\u7531",icon:"\u{1F517}"}],D=class{constructor(e){this.activeTab="components";this.tabRenderers=new Map;this._visible=!0;this._collapsed=!1;this.highlightOverlay=null;this._resizeHandle=null;this.onWindowResize=()=>{if(!(typeof window!="undefined"&&typeof document!="undefined"))return;let t=this.panelEl.getBoundingClientRect(),n=window.innerWidth-100,r=window.innerHeight-36;t.left>n&&(this.panelEl.style.left=`${n}px`),t.top>r&&(this.panelEl.style.top=`${r}px`)};var n,r,o,s,l,p,c,a;this.config={width:(n=e==null?void 0:e.width)!=null?n:420,height:(r=e==null?void 0:e.height)!=null?r:560,x:(s=e==null?void 0:e.x)!=null?s:typeof window!="undefined"?window.innerWidth-((o=e==null?void 0:e.width)!=null?o:420)-20:100,y:(l=e==null?void 0:e.y)!=null?l:60,minWidth:(p=e==null?void 0:e.minWidth)!=null?p:320,minHeight:(c=e==null?void 0:e.minHeight)!=null?c:200,title:(a=e==null?void 0:e.title)!=null?a:"Lyt DevTools"},this.dragState={isDragging:!1,startX:0,startY:0,startLeft:0,startTop:0},this.resizeState={isResizing:!1,startX:0,startY:0,startWidth:0,startHeight:0};let t=typeof window!="undefined"&&typeof document!="undefined";if(t?(this.styleEl=document.createElement("style"),this.styleEl.textContent=Ie,document.head.appendChild(this.styleEl)):this.styleEl={},t){let{panel:d,header:u,tabs:h,content:f,statusbar:m,statusLeft:x,statusRight:v,resizeHandle:y}=this.createPanelElementWithRefs();this.panelEl=d,this.headerEl=u,this.tabsEl=h,this.contentEl=f,this.statusbarEl=m,this.statusLeftEl=x,this.statusRightEl=v,this._resizeHandle=y}else this.panelEl=this.createMockPanelElement(),this.headerEl=this.panelEl.headerEl,this.tabsEl=this.panelEl.tabsEl,this.contentEl=this.panelEl.contentEl,this.statusbarEl=this.panelEl.statusbarEl,this.statusLeftEl=this.panelEl.statusLeftEl,this.statusRightEl=this.panelEl.statusRightEl,this._resizeHandle=this.panelEl.resizeHandleEl;t&&document.body.appendChild(this.panelEl),t&&(this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize))}createPanelElementWithRefs(){let e=document.createElement("div");e.className="lyt-devtools-panel",e.style.width=`${this.config.width}px`,e.style.height=`${this.config.height}px`,e.style.left=`${this.config.x}px`,e.style.top=`${this.config.y}px`;let t=document.createElement("div");t.className="lyt-devtools-header";let n=document.createElement("span");n.className="lyt-devtools-title",n.innerHTML=`<span class="lyt-devtools-title-icon">\u{1F50D}</span>${this.config.title}`;let r=document.createElement("div");r.className="lyt-devtools-header-actions";let o=document.createElement("button");o.className="lyt-devtools-btn",o.textContent="\u2014",o.title="\u6298\u53E0/\u5C55\u5F00",o.addEventListener("click",h=>{h.stopPropagation(),this.toggleCollapse()});let s=document.createElement("button");s.className="lyt-devtools-btn lyt-devtools-btn-close",s.textContent="\u2715",s.title="\u5173\u95ED\u9762\u677F",s.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(s),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Be){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset?f.dataset.tab=h.id:f.setAttribute("data-tab",h.id),f.innerHTML=`<span class="lyt-devtools-tab-icon">${h.icon}</span>${h.label}`,f.addEventListener("click",()=>this.switchTab(h.id)),l.appendChild(f)}let p=document.createElement("div");p.className="lyt-devtools-content";let c=document.createElement("div");c.className="lyt-devtools-statusbar";let a=document.createElement("span");a.className="lyt-devtools-status-left",a.innerHTML='<span class="lyt-devtools-status-dot"></span><span>\u5C31\u7EEA</span>';let d=document.createElement("span");d.className="lyt-devtools-status-right",d.textContent="v0.0.1",c.appendChild(a),c.appendChild(d);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(p),e.appendChild(c),e.appendChild(u),{panel:e,header:t,tabs:l,content:p,statusbar:c,statusLeft:a,statusRight:d,resizeHandle:u}}createPanelElement(){return this.createPanelElementWithRefs().panel}createMockPanelElement(){let e=n=>({className:n,classList:{add:()=>{},remove:()=>{},toggle:()=>{},contains:()=>!1},style:{},dataset:{},querySelector:r=>r===".lyt-devtools-header"?t.headerEl:r===".lyt-devtools-tabs"?t.tabsEl:r===".lyt-devtools-content"?t.contentEl:r===".lyt-devtools-statusbar"?t.statusbarEl:r===".lyt-devtools-status-left"?t.statusLeftEl:r===".lyt-devtools-status-right"?t.statusRightEl:r===".lyt-devtools-resize-handle"?t.resizeHandleEl:null,querySelectorAll:()=>[],appendChild:()=>{},addEventListener:()=>{},removeEventListener:()=>{},offsetLeft:0,offsetTop:0,offsetWidth:100,offsetHeight:100,getBoundingClientRect:()=>({left:0,top:0,right:100,bottom:100,width:100,height:100})}),t=e("lyt-devtools-panel");return t.headerEl=e("lyt-devtools-header"),t.tabsEl=e("lyt-devtools-tabs"),t.contentEl=e("lyt-devtools-content"),t.statusbarEl=e("lyt-devtools-statusbar"),t.statusLeftEl=e("lyt-devtools-status-left"),t.statusRightEl=e("lyt-devtools-status-right"),t.resizeHandleEl=e("lyt-devtools-resize-handle"),t}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,typeof window!="undefined"&&typeof document!="undefined"&&this.tabsEl&&this.tabsEl.querySelectorAll&&this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(r=>{r.classList&&r.dataset&&r.classList.toggle("active",r.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){if(typeof window!="undefined"&&typeof document!="undefined"&&this.contentEl){this.contentEl.innerHTML="";let t=this.tabRenderers.get(this.activeTab);t?t(this.contentEl):this.contentEl.innerHTML='<div class="lyt-devtools-empty">\u6682\u65E0\u5185\u5BB9</div>'}}getActiveTab(){return this.activeTab}getContentElement(){return this.contentEl}show(){this._visible=!0,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="flex")}hide(){this._visible=!1,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="none")}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.classList&&this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){typeof window!="undefined"&&typeof document!="undefined"&&(this.headerEl.addEventListener("mousedown",t=>{t.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=t.clientX,this.dragState.startY=t.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,t.preventDefault())}),document.addEventListener("mousemove",t=>{if(!this.dragState.isDragging)return;let n=t.clientX-this.dragState.startX,r=t.clientY-this.dragState.startY,o=this.dragState.startLeft+n,s=this.dragState.startTop+r;o=Math.max(0,Math.min(o,window.innerWidth-100)),s=Math.max(0,Math.min(s,window.innerHeight-36)),this.panelEl.style.left=`${o}px`,this.panelEl.style.top=`${s}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1}))}bindResizeEvents(){typeof window!="undefined"&&typeof document!="undefined"&&this._resizeHandle&&(this._resizeHandle.addEventListener("mousedown",t=>{this.resizeState.isResizing=!0,this.resizeState.startX=t.clientX,this.resizeState.startY=t.clientY,this.resizeState.startWidth=this.panelEl.offsetWidth,this.resizeState.startHeight=this.panelEl.offsetHeight,t.preventDefault(),t.stopPropagation()}),document.addEventListener("mousemove",t=>{if(!this.resizeState.isResizing)return;let n=t.clientX-this.resizeState.startX,r=t.clientY-this.resizeState.startY,o=Math.max(this.config.minWidth,this.resizeState.startWidth+n),s=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${s}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1}))}bindKeyboardEvents(){typeof window!="undefined"&&typeof document!="undefined"&&document.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&t.key==="D"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&(this.statusLeftEl.innerHTML=e)}setStatusRight(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusRightEl&&(this.statusRightEl.textContent=e)}setConnected(e){if(typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&this.statusLeftEl.querySelector){let n=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");n&&n.classList&&n.classList.toggle("disconnected",!e)}}highlightElement(e){if(this.clearHighlight(),!e)return;if(typeof window!="undefined"&&typeof document!="undefined"){this.highlightOverlay=document.createElement("div"),this.highlightOverlay.style.cssText=`
285
+ `,Be=[{id:"components",label:"\u7EC4\u4EF6\u6811",icon:"\u{1F333}"},{id:"state",label:"\u72B6\u6001",icon:"\u{1F4CA}"},{id:"events",label:"\u4E8B\u4EF6",icon:"\u26A1"},{id:"router",label:"\u8DEF\u7531",icon:"\u{1F517}"}],D=class{constructor(e){this.activeTab="components";this.tabRenderers=new Map;this._visible=!0;this._collapsed=!1;this.highlightOverlay=null;this._resizeHandle=null;this.onWindowResize=()=>{if(!(typeof window!="undefined"&&typeof document!="undefined"))return;let t=this.panelEl.getBoundingClientRect(),n=window.innerWidth-100,r=window.innerHeight-36;t.left>n&&(this.panelEl.style.left=`${n}px`),t.top>r&&(this.panelEl.style.top=`${r}px`)};var n,r,o,s,l,p,c,a;this.config={width:(n=e==null?void 0:e.width)!=null?n:420,height:(r=e==null?void 0:e.height)!=null?r:560,x:(s=e==null?void 0:e.x)!=null?s:typeof window!="undefined"?window.innerWidth-((o=e==null?void 0:e.width)!=null?o:420)-20:100,y:(l=e==null?void 0:e.y)!=null?l:60,minWidth:(p=e==null?void 0:e.minWidth)!=null?p:320,minHeight:(c=e==null?void 0:e.minHeight)!=null?c:200,title:(a=e==null?void 0:e.title)!=null?a:"Lyt DevTools"},this.dragState={isDragging:!1,startX:0,startY:0,startLeft:0,startTop:0},this.resizeState={isResizing:!1,startX:0,startY:0,startWidth:0,startHeight:0};let t=typeof window!="undefined"&&typeof document!="undefined";if(t?(this.styleEl=document.createElement("style"),this.styleEl.textContent=Ie,document.head.appendChild(this.styleEl)):this.styleEl={},t){let{panel:d,header:u,tabs:h,content:f,statusbar:m,statusLeft:x,statusRight:v,resizeHandle:y}=this.createPanelElementWithRefs();this.panelEl=d,this.headerEl=u,this.tabsEl=h,this.contentEl=f,this.statusbarEl=m,this.statusLeftEl=x,this.statusRightEl=v,this._resizeHandle=y}else this.panelEl=this.createMockPanelElement(),this.headerEl=this.panelEl.headerEl,this.tabsEl=this.panelEl.tabsEl,this.contentEl=this.panelEl.contentEl,this.statusbarEl=this.panelEl.statusbarEl,this.statusLeftEl=this.panelEl.statusLeftEl,this.statusRightEl=this.panelEl.statusRightEl,this._resizeHandle=this.panelEl.resizeHandleEl;t&&document.body.appendChild(this.panelEl),t&&(this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize))}createPanelElementWithRefs(){let e=document.createElement("div");e.className="lyt-devtools-panel",e.style.width=`${this.config.width}px`,e.style.height=`${this.config.height}px`,e.style.left=`${this.config.x}px`,e.style.top=`${this.config.y}px`;let t=document.createElement("div");t.className="lyt-devtools-header";let n=document.createElement("span");n.className="lyt-devtools-title",n.innerHTML=`<span class="lyt-devtools-title-icon">\u{1F50D}</span>${this.config.title}`;let r=document.createElement("div");r.className="lyt-devtools-header-actions";let o=document.createElement("button");o.className="lyt-devtools-btn",o.textContent="\u2014",o.title="\u6298\u53E0/\u5C55\u5F00",o.addEventListener("click",h=>{h.stopPropagation(),this.toggleCollapse()});let s=document.createElement("button");s.className="lyt-devtools-btn lyt-devtools-btn-close",s.textContent="\u2715",s.title="\u5173\u95ED\u9762\u677F",s.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(s),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Be){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset?f.dataset.tab=h.id:f.setAttribute("data-tab",h.id),f.innerHTML=`<span class="lyt-devtools-tab-icon">${h.icon}</span>${h.label}`,f.addEventListener("click",()=>this.switchTab(h.id)),l.appendChild(f)}let p=document.createElement("div");p.className="lyt-devtools-content";let c=document.createElement("div");c.className="lyt-devtools-statusbar";let a=document.createElement("span");a.className="lyt-devtools-status-left",a.innerHTML='<span class="lyt-devtools-status-dot"></span><span>\u5C31\u7EEA</span>';let d=document.createElement("span");d.className="lyt-devtools-status-right",d.textContent="v0.0.1",c.appendChild(a),c.appendChild(d);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(p),e.appendChild(c),e.appendChild(u),{panel:e,header:t,tabs:l,content:p,statusbar:c,statusLeft:a,statusRight:d,resizeHandle:u}}createPanelElement(){return this.createPanelElementWithRefs().panel}createMockPanelElement(){let e=n=>({className:n,classList:{add:()=>{},remove:()=>{},toggle:()=>{},contains:()=>!1},style:{},dataset:{},querySelector:r=>r===".lyt-devtools-header"?t.headerEl:r===".lyt-devtools-tabs"?t.tabsEl:r===".lyt-devtools-content"?t.contentEl:r===".lyt-devtools-statusbar"?t.statusbarEl:r===".lyt-devtools-status-left"?t.statusLeftEl:r===".lyt-devtools-status-right"?t.statusRightEl:r===".lyt-devtools-resize-handle"?t.resizeHandleEl:null,querySelectorAll:()=>[],appendChild:()=>{},addEventListener:()=>{},removeEventListener:()=>{},offsetLeft:0,offsetTop:0,offsetWidth:100,offsetHeight:100,getBoundingClientRect:()=>({left:0,top:0,right:100,bottom:100,width:100,height:100})}),t=e("lyt-devtools-panel");return t.headerEl=e("lyt-devtools-header"),t.tabsEl=e("lyt-devtools-tabs"),t.contentEl=e("lyt-devtools-content"),t.statusbarEl=e("lyt-devtools-statusbar"),t.statusLeftEl=e("lyt-devtools-status-left"),t.statusRightEl=e("lyt-devtools-status-right"),t.resizeHandleEl=e("lyt-devtools-resize-handle"),t}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,typeof window!="undefined"&&typeof document!="undefined"&&this.tabsEl&&this.tabsEl.querySelectorAll&&this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(r=>{let o=r;o.classList&&o.dataset&&o.classList.toggle("active",o.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){if(typeof window!="undefined"&&typeof document!="undefined"&&this.contentEl){this.contentEl.innerHTML="";let t=this.tabRenderers.get(this.activeTab);t?t(this.contentEl):this.contentEl.innerHTML='<div class="lyt-devtools-empty">\u6682\u65E0\u5185\u5BB9</div>'}}getActiveTab(){return this.activeTab}getContentElement(){return this.contentEl}show(){this._visible=!0,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="flex")}hide(){this._visible=!1,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="none")}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.classList&&this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){typeof window!="undefined"&&typeof document!="undefined"&&(this.headerEl.addEventListener("mousedown",t=>{t.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=t.clientX,this.dragState.startY=t.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,t.preventDefault())}),document.addEventListener("mousemove",t=>{if(!this.dragState.isDragging)return;let n=t.clientX-this.dragState.startX,r=t.clientY-this.dragState.startY,o=this.dragState.startLeft+n,s=this.dragState.startTop+r;o=Math.max(0,Math.min(o,window.innerWidth-100)),s=Math.max(0,Math.min(s,window.innerHeight-36)),this.panelEl.style.left=`${o}px`,this.panelEl.style.top=`${s}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1}))}bindResizeEvents(){typeof window!="undefined"&&typeof document!="undefined"&&this._resizeHandle&&(this._resizeHandle.addEventListener("mousedown",t=>{this.resizeState.isResizing=!0,this.resizeState.startX=t.clientX,this.resizeState.startY=t.clientY,this.resizeState.startWidth=this.panelEl.offsetWidth,this.resizeState.startHeight=this.panelEl.offsetHeight,t.preventDefault(),t.stopPropagation()}),document.addEventListener("mousemove",t=>{if(!this.resizeState.isResizing)return;let n=t.clientX-this.resizeState.startX,r=t.clientY-this.resizeState.startY,o=Math.max(this.config.minWidth,this.resizeState.startWidth+n),s=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${s}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1}))}bindKeyboardEvents(){typeof window!="undefined"&&typeof document!="undefined"&&document.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&t.key==="D"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&(this.statusLeftEl.innerHTML=e)}setStatusRight(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusRightEl&&(this.statusRightEl.textContent=e)}setConnected(e){if(typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&this.statusLeftEl.querySelector){let n=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");n&&n.classList&&n.classList.toggle("disconnected",!e)}}highlightElement(e){if(this.clearHighlight(),!e)return;if(typeof window!="undefined"&&typeof document!="undefined"){this.highlightOverlay=document.createElement("div"),this.highlightOverlay.style.cssText=`
286
286
  position: fixed;
287
287
  z-index: 999998;
288
288
  pointer-events: none;
@@ -290,7 +290,7 @@
290
290
  background: rgba(203, 166, 247, 0.1);
291
291
  border-radius: 2px;
292
292
  transition: all 0.15s ease;
293
- `;let n=e.getBoundingClientRect();this.highlightOverlay.style.left=`${n.left}px`,this.highlightOverlay.style.top=`${n.top}px`,this.highlightOverlay.style.width=`${n.width}px`,this.highlightOverlay.style.height=`${n.height}px`,document.body.appendChild(this.highlightOverlay)}}clearHighlight(){typeof window!="undefined"&&typeof document!="undefined"&&this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){let e=typeof window!="undefined"&&typeof document!="undefined";e&&this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),e&&this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),e&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],S=[],xe=0,F=null,C={},_=!1;function ze(){return`comp_${++xe}`}function Ne(){return`evt_${++xe}`}function ye(i){var t;if(!i)return"Unknown";let e=i.type||i.options;return e?e.name?e.name:e.render&&e.render.name?e.render.name:e.setup&&e.setup.name?e.setup.name:e._isComponentDefine&&((t=e.options)!=null&&t.name)?e.options.name:"Anonymous":"Anonymous"}function w(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>w(t));let e={};for(let t of Object.keys(i))e[t]=w(i[t]);return e}function $e(i,e){return i===e?!1:typeof i!=typeof e?!0:i===null||e===null?i!==e:typeof i=="object"?JSON.stringify(i)!==JSON.stringify(e):i!==e}function Ae(i,e){let t=e.split("."),n=i;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Fe(i,e,t){let n=e.split("."),r=i;for(let o=0;o<n.length-1;o++)(r[n[o]]===null||r[n[o]]===void 0||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function U(i,e){_||(e&&Object.assign(C,e),_=!0,_e(i),i._instance&&(O(i._instance,null),ue()))}function _e(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(O(i._instance,null),ue()),n}}function O(i,e){var o,s,l,p,c,a,d,u;if(!i)return;let t=be(i),n=!t;if(n){let h=ze();t={id:h,name:ye(i),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=i.isMounted)!=null?o:!1,isUnmounted:(s=i.isUnmounted)!=null?s:!1,el:(l=i.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:i},E.set(h,t)}else t.parentId=e,t.name=ye(i),t.isMounted=(p=i.isMounted)!=null?p:!1,t.isUnmounted=(c=i.isUnmounted)!=null?c:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now();i.props&&(t.props=w(i.props)),i.state&&(t.state=w(i.state)),i.computedCache&&(t.computed=w(i.computedCache)),n&&i.state&&typeof i.state=="object"&&Ue(t.id,i),n&&i.emit&&typeof i.emit=="function"&&Oe(t.id,i),n?(d=C.onComponentCreated)==null||d.call(C,t):(u=C.onComponentUpdated)==null||u.call(C,t);let r=i.subTree;r&&ve(r,t.id)}function ve(i,e){if(i){if(i.component){O(i.component,e);let t=E.get(e);if(t&&!t.childIds.includes(i.component.id||i.component._id)){let n=qe(i.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(i.children&&Array.isArray(i.children))for(let t of i.children)t&&typeof t=="object"&&ve(t,e)}}function Ue(i,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(i);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,s,l){var a;let p=o[s],c=Reflect.set(o,s,l);if($e(p,l)){let d=String(s),u={componentId:i,componentName:n.name,path:d,oldValue:w(p),newValue:w(l),timestamp:Date.now()};S.push(u),S.length>1e3&&S.splice(0,S.length-1e3),n.state=w(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return c}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function Oe(i,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(i);n&&(e.emit=function(r,...o){var l;let s={id:Ne(),name:r,timestamp:Date.now(),args:w(o),componentId:i,componentName:n.name};return M.push(s),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,s),t.call(this,r,...o)})}function ue(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function be(i){for(let e of E.values())if(e.instance===i)return e;return null}function qe(i){let e=be(i);return e?e.id:null}function L(){return Array.from(E.values())}function q(){for(let i of E.values())if(i.parentId===null)return i;return null}function H(i){var e;return(e=E.get(i))!=null?e:null}function j(i){let e=E.get(i);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function J(){return[...M]}function Te(){return[...S]}function V(i){return S.filter(e=>e.componentId===i)}function Ce(i){return M.filter(e=>e.componentId===i)}function W(i){F=i}function Y(){var i;return F&&(i=E.get(F))!=null?i:null}function k(){return F}function K(i,e,t){var l;let n=E.get(i);if(!n||!n.instance)return!1;let r=n.instance.state;if(!r||typeof r!="object")return!1;let o=Ae(r,e);Fe(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:w(o),newValue:w(t),timestamp:Date.now()};return S.push(s),n.state=w(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function X(i){E.clear(),i._instance&&(O(i._instance,null),ue())}function G(){M.length=0,S.length=0}function Q(){E.clear(),M.length=0,S.length=0,F=null,_=!1}function Ee(){return _}function we(){return E.size}var I=class{constructor(e,t){this.searchKeyword="";this.expandedNodes=new Set;this.container=null;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderTree()},100)};this.panel=e,this.onSelect=t||(()=>{});let n=q();n&&this.expandedNodes.add(n.id),typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderTree()}renderTree(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("input");e.type="text",e.className="lyt-devtools-search",e.placeholder="\u641C\u7D22\u7EC4\u4EF6...",e.value=this.searchKeyword,e.addEventListener("input",r=>{this.searchKeyword=r.target.value,this.renderTree()}),this.container.appendChild(e);let t=L();if(t.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent="\u6682\u65E0\u7EC4\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5E94\u7528\u5DF2\u6302\u8F7D\u3002",this.container.appendChild(r);return}let n=this.buildTree();for(let r of n){let o=this.renderTreeNode(r);o&&this.container.appendChild(o)}this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${t.length} \u4E2A\u7EC4\u4EF6</span>`)}buildTree(){let e=L(),t=new Map,n=[];for(let r of e){if(this.searchKeyword){let s=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(s),p=r.id.toLowerCase().includes(s);if(!l&&!p)continue}let o={info:r,children:[],depth:0,expanded:this.expandedNodes.has(r.id)};t.set(r.id,o)}for(let r of t.values()){let o=r.info.parentId;if(o&&t.has(o)){let s=t.get(o);s.children.push(r),r.depth=s.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=k(),s=t.id===o,l=document.createElement("div");l.className="lyt-tree-node",l.style.cssText=`
293
+ `;let n=e.getBoundingClientRect();this.highlightOverlay.style.left=`${n.left}px`,this.highlightOverlay.style.top=`${n.top}px`,this.highlightOverlay.style.width=`${n.width}px`,this.highlightOverlay.style.height=`${n.height}px`,document.body.appendChild(this.highlightOverlay)}}clearHighlight(){typeof window!="undefined"&&typeof document!="undefined"&&this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){let e=typeof window!="undefined"&&typeof document!="undefined";e&&this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),e&&this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),e&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],S=[],xe=0,F=null,C={},_=!1;function ze(){return`comp_${++xe}`}function Ne(){return`evt_${++xe}`}function ye(i){var t;if(!i)return"Unknown";let e=i.type||i.options;return e?e.name?e.name:e.render&&e.render.name?e.render.name:e.setup&&e.setup.name?e.setup.name:e._isComponentDefine&&((t=e.options)!=null&&t.name)?e.options.name:"Anonymous":"Anonymous"}function w(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>w(t));let e={};for(let t of Object.keys(i))e[t]=w(i[t]);return e}function $e(i,e){return i===e?!1:typeof i!=typeof e?!0:i===null||e===null?i!==e:typeof i=="object"?JSON.stringify(i)!==JSON.stringify(e):i!==e}function Ae(i,e){let t=e.split("."),n=i;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Fe(i,e,t){let n=e.split("."),r=i;for(let o=0;o<n.length-1;o++)(r[n[o]]===null||r[n[o]]===void 0||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function U(i,e){_||(e&&Object.assign(C,e),_=!0,_e(i),i._instance&&(O(i._instance,null),ue()))}function _e(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(O(i._instance,null),ue()),n}}function O(i,e){var o,s,l,p,c,a,d,u;if(!i)return;let t=be(i),n=!t;if(n){let h=ze();t={id:h,name:ye(i),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=i.isMounted)!=null?o:!1,isUnmounted:(s=i.isUnmounted)!=null?s:!1,el:(l=i.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:i},E.set(h,t)}else t&&(t.parentId=e,t.name=ye(i),t.isMounted=(p=i.isMounted)!=null?p:!1,t.isUnmounted=(c=i.isUnmounted)!=null?c:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now());t&&i.props&&(t.props=w(i.props)),t&&i.state&&(t.state=w(i.state)),t&&i.computedCache&&(t.computed=w(i.computedCache)),n&&t&&i.state&&typeof i.state=="object"&&Ue(t.id,i),n&&t&&i.emit&&typeof i.emit=="function"&&Oe(t.id,i),n&&t?(d=C.onComponentCreated)==null||d.call(C,t):t&&((u=C.onComponentUpdated)==null||u.call(C,t));let r=i.subTree;r&&t&&ve(r,t.id)}function ve(i,e){if(i){if(i.component){O(i.component,e);let t=E.get(e);if(t&&!t.childIds.includes(i.component.id||i.component._id)){let n=qe(i.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(i.children&&Array.isArray(i.children))for(let t of i.children)t&&typeof t=="object"&&ve(t,e)}}function Ue(i,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(i);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,s,l){var a;let p=o[s],c=Reflect.set(o,s,l);if($e(p,l)){let d=String(s),u={componentId:i,componentName:n.name,path:d,oldValue:w(p),newValue:w(l),timestamp:Date.now()};S.push(u),S.length>1e3&&S.splice(0,S.length-1e3),n.state=w(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return c}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function Oe(i,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(i);n&&(e.emit=function(r,...o){var l;let s={id:Ne(),name:r,timestamp:Date.now(),args:w(o),componentId:i,componentName:n.name};return M.push(s),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,s),t.call(this,r,...o)})}function ue(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function be(i){for(let e of E.values())if(e.instance===i)return e;return null}function qe(i){let e=be(i);return e?e.id:null}function L(){return Array.from(E.values())}function q(){for(let i of E.values())if(i.parentId===null)return i;return null}function H(i){var e;return(e=E.get(i))!=null?e:null}function j(i){let e=E.get(i);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function J(){return[...M]}function Te(){return[...S]}function V(i){return S.filter(e=>e.componentId===i)}function Ce(i){return M.filter(e=>e.componentId===i)}function W(i){F=i}function Y(){var i;return F&&(i=E.get(F))!=null?i:null}function k(){return F}function K(i,e,t){var l;let n=E.get(i);if(!n||!n.instance)return!1;let r=n.instance.state;if(!r||typeof r!="object")return!1;let o=Ae(r,e);Fe(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:w(o),newValue:w(t),timestamp:Date.now()};return S.push(s),n.state=w(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function X(i){E.clear(),i._instance&&(O(i._instance,null),ue())}function G(){M.length=0,S.length=0}function Q(){E.clear(),M.length=0,S.length=0,F=null,_=!1}function Ee(){return _}function we(){return E.size}var I=class{constructor(e,t){this.searchKeyword="";this.expandedNodes=new Set;this.container=null;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderTree()},100)};this.panel=e,this.onSelect=t||(()=>{});let n=q();n&&this.expandedNodes.add(n.id),typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderTree()}renderTree(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("input");e.type="text",e.className="lyt-devtools-search",e.placeholder="\u641C\u7D22\u7EC4\u4EF6...",e.value=this.searchKeyword,e.addEventListener("input",r=>{this.searchKeyword=r.target.value,this.renderTree()}),this.container.appendChild(e);let t=L();if(t.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent="\u6682\u65E0\u7EC4\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5E94\u7528\u5DF2\u6302\u8F7D\u3002",this.container.appendChild(r);return}let n=this.buildTree();for(let r of n){let o=this.renderTreeNode(r);o&&this.container.appendChild(o)}this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${t.length} \u4E2A\u7EC4\u4EF6</span>`)}buildTree(){let e=L(),t=new Map,n=[];for(let r of e){if(this.searchKeyword){let s=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(s),p=r.id.toLowerCase().includes(s);if(!l&&!p)continue}let o={info:r,children:[],depth:0,expanded:this.expandedNodes.has(r.id)};t.set(r.id,o)}for(let r of t.values()){let o=r.info.parentId;if(o&&t.has(o)){let s=t.get(o);s.children.push(r),r.depth=s.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=k(),s=t.id===o,l=document.createElement("div");l.className="lyt-tree-node",l.style.cssText=`
294
294
  display: flex;
295
295
  align-items: center;
296
296
  padding: 3px 8px;
@@ -345,7 +345,7 @@
345
345
  cursor: pointer;
346
346
  font-size: 11px;
347
347
  font-family: inherit;
348
- `,r.textContent="\u53D8\u5316\u5386\u53F2",r.addEventListener("click",()=>{this.showHistory=!this.showHistory,this.renderState()}),t.appendChild(n),t.appendChild(r),this.container.appendChild(t),this.showHistory?this.renderHistory(e):(this.renderCategory(container,"props",e.props,!0,!1,!1),this.renderCategory(container,"state",e.state,!1,!0,!1),this.renderCategory(container,"computed",e.computed,!1,!1,!0));let o=Object.keys(e.state).length,s=Object.keys(e.props).length,l=Object.keys(e.computed).length;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${e.name}</span><span style="color: #585b70;">|</span><span>P:${s} S:${o} C:${l}</span>`)}renderCategory(e,t,n,r,o,s){let l=Object.keys(n);if(l.length===0)return;let p=document.createElement("div");p.style.cssText=`
348
+ `,r.textContent="\u53D8\u5316\u5386\u53F2",r.addEventListener("click",()=>{this.showHistory=!this.showHistory,this.renderState()}),t.appendChild(n),t.appendChild(r),this.container.appendChild(t),this.showHistory?this.renderHistory(e):(this.renderCategory(this.container,"props",e.props,!0,!1,!1),this.renderCategory(this.container,"state",e.state,!1,!0,!1),this.renderCategory(this.container,"computed",e.computed,!1,!1,!0));let o=Object.keys(e.state).length,s=Object.keys(e.props).length,l=Object.keys(e.computed).length;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${e.name}</span><span style="color: #585b70;">|</span><span>P:${s} S:${o} C:${l}</span>`)}renderCategory(e,t,n,r,o,s){let l=Object.keys(n);if(l.length===0)return;let p=document.createElement("div");p.style.cssText=`
349
349
  display: flex;
350
350
  align-items: center;
351
351
  padding: 4px 8px;
@@ -608,7 +608,7 @@
608
608
  background: ${r?"#313244":"transparent"};
609
609
  color: ${o?"#89b4fa":"#cdd6f4"};
610
610
  border-bottom: 1px solid #1e1e2e;
611
- `;let l=document.createElement("span");l.style.cssText="display: inline-block; width: 14px; text-align: center; margin-right: 4px; font-size: 10px; color: #585b70;",s?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let p=document.createElement("span");if(p.textContent=e.node.name,p.style.cssText="font-weight: bold;",n.appendChild(p),e.node.stateSummary){let d=document.createElement("span");d.textContent=` ${e.node.stateSummary}`,d.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(d)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let d=document.createElement("span");d.textContent=` [${e.node.propsCount} props]`,d.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(d)}let c=e.node,a=c.id;return n.addEventListener("click",()=>{var d;if(s){let u=(d=this.expandedMap.get(a))!=null?d:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(c)}),n}handleScroll(e){if(this.destroyed)return;let t=e.target;this.scrollTop=t.scrollTop,this.renderNodes()}getFlatNodes(){return[...this.flatNodes]}getVisibleNodeCount(){return this.getVisibleNodes().length}getTotalNodeCount(){return this.flatNodes.length}};var me=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},Xe=100,Ge=1024,Qe=.7,Ze=5,oe=class{constructor(e){this.counter=0;var t,n,r,o;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:Xe,leakGrowthThreshold:(n=e==null?void 0:e.leakGrowthThreshold)!=null?n:Ge,leakRSquaredThreshold:(r=e==null?void 0:e.leakRSquaredThreshold)!=null?r:Qe,leakMinSnapshots:(o=e==null?void 0:e.leakMinSnapshots)!=null?o:Ze},this.snapshots=new me(this.config.bufferSize)}trackMemoryUsage(e,t,n,r){if(e===void 0){let s=performance.memory;s&&(e=s.usedJSHeapSize,t=s.totalJSHeapSize,n=s.jsHeapSizeLimit)}if(e===void 0)return null;let o={timestamp:r!=null?r:Date.now(),usedJSHeapSize:e,totalJSHeapSize:t!=null?t:0,jsHeapSizeLimit:n!=null?n:0,index:this.counter++};return this.snapshots.push(o),o}getMemoryTrend(){let e=this.snapshots.getAll();return e.length===0?[]:e.map((t,n)=>{let r=n>0?e[n-1]:null,o=r?t.usedJSHeapSize-r.usedJSHeapSize:0,s=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:s}})}detectMemoryLeak(){let e=this.snapshots.getAll();if(e.length<this.config.leakMinSnapshots)return{hasLeak:!1,severity:"none",description:`\u5FEB\u7167\u6570\u91CF\u4E0D\u8DB3\uFF08\u9700\u8981\u81F3\u5C11 ${this.config.leakMinSnapshots} \u4E2A\uFF0C\u5F53\u524D ${e.length} \u4E2A\uFF09`,snapshotCount:e.length,growthRate:0,rSquared:0};let t=e.length,n=0,r=0,o=0,s=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,s+=b*b,l+=T*T}let p=t*s-n*n,c=p!==0?(t*o-n*r)/p:0,a=r/t,d=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=c*g+(r-c*n)/t;d+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=d!==0?1-u/d:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?c/f:0,x=h>=this.config.leakRSquaredThreshold&&m>=this.config.leakGrowthThreshold,v="none",y="\u672A\u68C0\u6D4B\u5230\u5185\u5B58\u6CC4\u6F0F";return x&&(m>=this.config.leakGrowthThreshold*10?(v="high",y=`\u68C0\u6D4B\u5230\u4E25\u91CD\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):m>=this.config.leakGrowthThreshold*3?(v="medium",y=`\u68C0\u6D4B\u5230\u4E2D\u7B49\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):(v="low",y=`\u68C0\u6D4B\u5230\u8F7B\u5FAE\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`)),{hasLeak:x,severity:v,description:y,snapshotCount:t,growthRate:m,rSquared:h}}getMemoryReport(){let e=this.snapshots.getAll(),t=this.getMemoryTrend(),n=this.detectMemoryLeak(),r=null,o=0,s=0,l=0,p=1/0;for(let d of e)(!r||d.timestamp>r.timestamp)&&(r=d),d.usedJSHeapSize>o&&(o=d.usedJSHeapSize,s=d.timestamp),l+=d.usedJSHeapSize,d.usedJSHeapSize<p&&(p=d.usedJSHeapSize);let c=e.length>0?l/e.length:0;p===1/0&&(p=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:s,averageUsage:c,minUsage:p,totalGrowth:a,trend:t,leakDetection:n,snapshotCount:e.length}}getSnapshots(){return this.snapshots.getAll()}getSnapshotCount(){return this.snapshots.size}clear(){this.snapshots.clear(),this.counter=0}destroy(){this.clear()}};var fe=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},et=200,tt=16,se=class{constructor(e){this.counter=0;var t,n;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:et,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:tt},this.records=new fe(this.config.bufferSize)}trackRender(e,t){this.records.push({componentName:e,duration:t,timestamp:Date.now(),index:this.counter++})}getSlowRenderers(e){let t=e!=null?e:this.config.slowThreshold;return this.records.getAll().filter(r=>r.duration>t).map(r=>({componentName:r.componentName,duration:r.duration,timestamp:r.timestamp,overThreshold:r.duration-t})).sort((r,o)=>o.duration-r.duration)}getRenderStats(){let e=this.records.getAll(),t=this.config.slowThreshold;if(e.length===0)return{totalRenders:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,slowRenderCount:0,slowRenderRatio:0,byComponent:[]};let n=0,r=-1/0,o=1/0,s=0,l=new Map;for(let c of e){n+=c.duration,c.duration>r&&(r=c.duration),c.duration<o&&(o=c.duration),c.duration>t&&s++;let a=l.get(c.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(c.componentName,a)),a.renderCount++,a.totalDuration+=c.duration,c.duration>a.maxDuration&&(a.maxDuration=c.duration),c.duration<a.minDuration&&(a.minDuration=c.duration),c.duration>t&&a.slowCount++}let p=Array.from(l.entries()).map(([c,a])=>({componentName:c,renderCount:a.renderCount,avgDuration:a.totalDuration/a.renderCount,maxDuration:a.maxDuration===-1/0?0:a.maxDuration,minDuration:a.minDuration===1/0?0:a.minDuration,totalDuration:a.totalDuration,slowCount:a.slowCount})).sort((c,a)=>a.avgDuration-c.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:s,slowRenderRatio:s/e.length,byComponent:p}}getRenderTimeline(){let e=this.records.getAll(),t=this.config.slowThreshold;return e.map((n,r)=>({componentName:n.componentName,duration:n.duration,timestamp:n.timestamp,isSlow:n.duration>t,gap:r>0?n.timestamp-e[r-1].timestamp:-1}))}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}clear(){this.records.clear(),this.counter=0}destroy(){this.clear()}};var ge=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},nt=100,rt=1e3,ot=2,ie=class{constructor(e){this.pending=new Map;this.counter=0;var t,n,r;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:nt,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:rt,outlierSigmaThreshold:(r=e==null?void 0:e.outlierSigmaThreshold)!=null?r:ot},this.records=new ge(this.config.bufferSize)}startBatch(e){return this.pending.has(e)?!1:(this.pending.set(e,Date.now()),!0)}endBatch(e){let t=this.pending.get(e);if(t===void 0)return null;let n=Date.now(),r=n-t;this.pending.delete(e);let o={name:e,startTime:t,endTime:n,duration:r,index:this.counter++};return this.records.push(o),o}getBatchStats(){let e=this.records.getAll();if(e.length===0)return{totalBatches:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,byName:[]};let t=0,n=-1/0,r=1/0,o=new Map;for(let l of e){t+=l.duration,l.duration>n&&(n=l.duration),l.duration<r&&(r=l.duration);let p=o.get(l.name);p||(p={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,p)),p.count++,p.totalDuration+=l.duration,l.duration>p.maxDuration&&(p.maxDuration=l.duration),l.duration<p.minDuration&&(p.minDuration=l.duration),p.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,p])=>{let c=p.totalDuration/p.count,a=0;for(let u of p.durations)a+=(u-c)*(u-c);a/=p.count;let d=Math.sqrt(a);return{name:l,count:p.count,avgDuration:c,maxDuration:p.maxDuration===-1/0?0:p.maxDuration,minDuration:p.minDuration===1/0?0:p.minDuration,totalDuration:p.totalDuration,stdDev:d}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:s}}detectAnomalousBatches(){let e=this.records.getAll();if(e.length===0)return[];let t=this.getBatchStats(),n=[],r=new Map;for(let o of t.byName)r.set(o.name,o);for(let o of e){let s=r.get(o.name);if(o.duration>this.config.slowThreshold){n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:"slow",description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u8D85\u8FC7\u6162\u64CD\u4F5C\u9608\u503C ${this.config.slowThreshold}ms`,deviationSigma:s&&s.stdDev>0?(o.duration-s.avgDuration)/s.stdDev:0});continue}if(s&&s.count>=2&&s.stdDev>0){let l=(o.duration-s.avgDuration)/s.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let p=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:p,description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u504F\u79BB\u5E73\u5747\u503C ${l.toFixed(1)} \u4E2A\u6807\u51C6\u5DEE`,deviationSigma:l})}}}return n.sort((o,s)=>o.timestamp-s.timestamp),n}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}getPendingBatches(){return Array.from(this.pending.keys())}clear(){this.records.clear(),this.pending.clear(),this.counter=0}destroy(){this.clear()}};var ae=class{constructor(e){this._installed=!1;this.app=null;var t,n,r,o,s,l;this.config={width:(t=e==null?void 0:e.width)!=null?t:420,height:(n=e==null?void 0:e.height)!=null?n:560,x:(r=e==null?void 0:e.x)!=null?r:void 0,y:(o=e==null?void 0:e.y)!=null?o:void 0,autoShow:(s=e==null?void 0:e.autoShow)!=null?s:!0,title:(l=e==null?void 0:e.title)!=null?l:"Lyt DevTools"},this.panel=new D({width:this.config.width,height:this.config.height,x:this.config.x,y:this.config.y,title:this.config.title}),this.componentTree=new I(this.panel,p=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new B(this.panel),this.eventTracker=new z(this.panel),this.timeTravel=new N(this.panel),this.panel.registerTabRenderer("components",p=>{this.componentTree.render(p)}),this.panel.registerTabRenderer("state",p=>{this.stateInspector.render(p)}),this.panel.registerTabRenderer("events",p=>{this.eventTracker.render(p)}),this.panel.registerTabRenderer("router",p=>{this.renderRouterTab(p)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,U(e,{onComponentCreated:n=>{this.componentTree.refresh()},onComponentUpdated:n=>{this.componentTree.refresh(),this.stateInspector.refresh()},onComponentUnmounted:n=>{this.componentTree.refresh()},onStateChanged:n=>{this.stateInspector.markChanged(`state.${n.path}`),this.stateInspector.refresh()},onEventEmitted:n=>{this.eventTracker.refresh()}}),this.panel.setConnected(!0)}show(){this.panel.show()}hide(){this.panel.hide()}toggle(){this.panel.toggle()}isVisible(){return this.panel.isVisible()}renderRouterTab(e){e.innerHTML="";let t=document.createElement("div");t.className="lyt-devtools-empty",t.style.cssText="padding: 40px 24px;",t.innerHTML=`
611
+ `;let l=document.createElement("span");l.style.cssText="display: inline-block; width: 14px; text-align: center; margin-right: 4px; font-size: 10px; color: #585b70;",s?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let p=document.createElement("span");if(p.textContent=e.node.name,p.style.cssText="font-weight: bold;",n.appendChild(p),e.node.stateSummary){let d=document.createElement("span");d.textContent=` ${e.node.stateSummary}`,d.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(d)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let d=document.createElement("span");d.textContent=` [${e.node.propsCount} props]`,d.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(d)}let c=e.node,a=c.id;return n.addEventListener("click",()=>{var d;if(s){let u=(d=this.expandedMap.get(a))!=null?d:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(c)}),n}handleScroll(e){if(this.destroyed)return;let t=e.target;this.scrollTop=t.scrollTop,this.renderNodes()}getFlatNodes(){return[...this.flatNodes]}getVisibleNodeCount(){return this.getVisibleNodes().length}getTotalNodeCount(){return this.flatNodes.length}};var me=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},Xe=100,Ge=1024,Qe=.7,Ze=5,oe=class{constructor(e){this.counter=0;var t,n,r,o;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:Xe,leakGrowthThreshold:(n=e==null?void 0:e.leakGrowthThreshold)!=null?n:Ge,leakRSquaredThreshold:(r=e==null?void 0:e.leakRSquaredThreshold)!=null?r:Qe,leakMinSnapshots:(o=e==null?void 0:e.leakMinSnapshots)!=null?o:Ze},this.snapshots=new me(this.config.bufferSize)}trackMemoryUsage(e,t,n,r){if(e===void 0){let s=performance.memory;s&&(e=s.usedJSHeapSize,t=s.totalJSHeapSize,n=s.jsHeapSizeLimit)}if(e===void 0)return null;let o={timestamp:r!=null?r:Date.now(),usedJSHeapSize:e,totalJSHeapSize:t!=null?t:0,jsHeapSizeLimit:n!=null?n:0,index:this.counter++};return this.snapshots.push(o),o}getMemoryTrend(){let e=this.snapshots.getAll();return e.length===0?[]:e.map((t,n)=>{let r=n>0?e[n-1]:null,o=r?t.usedJSHeapSize-r.usedJSHeapSize:0,s=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:s}})}detectMemoryLeak(){let e=this.snapshots.getAll();if(e.length<this.config.leakMinSnapshots)return{hasLeak:!1,severity:"none",description:`\u5FEB\u7167\u6570\u91CF\u4E0D\u8DB3\uFF08\u9700\u8981\u81F3\u5C11 ${this.config.leakMinSnapshots} \u4E2A\uFF0C\u5F53\u524D ${e.length} \u4E2A\uFF09`,snapshotCount:e.length,growthRate:0,rSquared:0};let t=e.length,n=0,r=0,o=0,s=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,s+=b*b,l+=T*T}let p=t*s-n*n,c=p!==0?(t*o-n*r)/p:0,a=r/t,d=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=c*g+(r-c*n)/t;d+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=d!==0?1-u/d:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?c/f:0,x=h>=this.config.leakRSquaredThreshold&&m>=this.config.leakGrowthThreshold,v="none",y="\u672A\u68C0\u6D4B\u5230\u5185\u5B58\u6CC4\u6F0F";return x&&(m>=this.config.leakGrowthThreshold*10?(v="high",y=`\u68C0\u6D4B\u5230\u4E25\u91CD\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):m>=this.config.leakGrowthThreshold*3?(v="medium",y=`\u68C0\u6D4B\u5230\u4E2D\u7B49\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):(v="low",y=`\u68C0\u6D4B\u5230\u8F7B\u5FAE\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`)),{hasLeak:x,severity:v,description:y,snapshotCount:t,growthRate:m,rSquared:h}}getMemoryReport(){let e=this.snapshots.getAll(),t=this.getMemoryTrend(),n=this.detectMemoryLeak(),r=null,o=0,s=0,l=0,p=1/0;for(let d of e)(!r||d.timestamp>r.timestamp)&&(r=d),d.usedJSHeapSize>o&&(o=d.usedJSHeapSize,s=d.timestamp),l+=d.usedJSHeapSize,d.usedJSHeapSize<p&&(p=d.usedJSHeapSize);let c=e.length>0?l/e.length:0;p===1/0&&(p=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:s,averageUsage:c,minUsage:p,totalGrowth:a,trend:t,leakDetection:n,snapshotCount:e.length}}getSnapshots(){return this.snapshots.getAll()}getSnapshotCount(){return this.snapshots.size}clear(){this.snapshots.clear(),this.counter=0}destroy(){this.clear()}};var fe=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},et=200,tt=16,se=class{constructor(e){this.counter=0;var t,n;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:et,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:tt},this.records=new fe(this.config.bufferSize)}trackRender(e,t){this.records.push({componentName:e,duration:t,timestamp:Date.now(),index:this.counter++})}getSlowRenderers(e){let t=e!=null?e:this.config.slowThreshold;return this.records.getAll().filter(r=>r.duration>t).map(r=>({componentName:r.componentName,duration:r.duration,timestamp:r.timestamp,overThreshold:r.duration-t})).sort((r,o)=>o.duration-r.duration)}getRenderStats(){let e=this.records.getAll(),t=this.config.slowThreshold;if(e.length===0)return{totalRenders:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,slowRenderCount:0,slowRenderRatio:0,byComponent:[]};let n=0,r=-1/0,o=1/0,s=0,l=new Map;for(let c of e){n+=c.duration,c.duration>r&&(r=c.duration),c.duration<o&&(o=c.duration),c.duration>t&&s++;let a=l.get(c.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(c.componentName,a)),a.renderCount++,a.totalDuration+=c.duration,c.duration>a.maxDuration&&(a.maxDuration=c.duration),c.duration<a.minDuration&&(a.minDuration=c.duration),c.duration>t&&a.slowCount++}let p=Array.from(l.entries()).map(([c,a])=>({componentName:c,renderCount:a.renderCount,avgDuration:a.totalDuration/a.renderCount,maxDuration:a.maxDuration===-1/0?0:a.maxDuration,minDuration:a.minDuration===1/0?0:a.minDuration,totalDuration:a.totalDuration,slowCount:a.slowCount})).sort((c,a)=>a.avgDuration-c.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:s,slowRenderRatio:s/e.length,byComponent:p}}getRenderTimeline(){let e=this.records.getAll(),t=this.config.slowThreshold;return e.map((n,r)=>({componentName:n.componentName,duration:n.duration,timestamp:n.timestamp,isSlow:n.duration>t,gap:r>0?n.timestamp-e[r-1].timestamp:-1}))}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}clear(){this.records.clear(),this.counter=0}destroy(){this.clear()}};var ge=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},nt=100,rt=1e3,ot=2,ie=class{constructor(e){this.pending=new Map;this.counter=0;var t,n,r;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:nt,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:rt,outlierSigmaThreshold:(r=e==null?void 0:e.outlierSigmaThreshold)!=null?r:ot},this.records=new ge(this.config.bufferSize)}startBatch(e){return this.pending.has(e)?!1:(this.pending.set(e,Date.now()),!0)}endBatch(e){let t=this.pending.get(e);if(t===void 0)return null;let n=Date.now(),r=n-t;this.pending.delete(e);let o={name:e,startTime:t,endTime:n,duration:r,index:this.counter++};return this.records.push(o),o}getBatchStats(){let e=this.records.getAll();if(e.length===0)return{totalBatches:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,byName:[]};let t=0,n=-1/0,r=1/0,o=new Map;for(let l of e){t+=l.duration,l.duration>n&&(n=l.duration),l.duration<r&&(r=l.duration);let p=o.get(l.name);p||(p={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,p)),p.count++,p.totalDuration+=l.duration,l.duration>p.maxDuration&&(p.maxDuration=l.duration),l.duration<p.minDuration&&(p.minDuration=l.duration),p.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,p])=>{let c=p.totalDuration/p.count,a=0;for(let u of p.durations)a+=(u-c)*(u-c);a/=p.count;let d=Math.sqrt(a);return{name:l,count:p.count,avgDuration:c,maxDuration:p.maxDuration===-1/0?0:p.maxDuration,minDuration:p.minDuration===1/0?0:p.minDuration,totalDuration:p.totalDuration,stdDev:d}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:s}}detectAnomalousBatches(){let e=this.records.getAll();if(e.length===0)return[];let t=this.getBatchStats(),n=[],r=new Map;for(let o of t.byName)r.set(o.name,o);for(let o of e){let s=r.get(o.name);if(o.duration>this.config.slowThreshold){n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:"slow",description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u8D85\u8FC7\u6162\u64CD\u4F5C\u9608\u503C ${this.config.slowThreshold}ms`,deviationSigma:s&&s.stdDev>0?(o.duration-s.avgDuration)/s.stdDev:0});continue}if(s&&s.count>=2&&s.stdDev>0){let l=(o.duration-s.avgDuration)/s.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let p=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:p,description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u504F\u79BB\u5E73\u5747\u503C ${l.toFixed(1)} \u4E2A\u6807\u51C6\u5DEE`,deviationSigma:l})}}}return n.sort((o,s)=>o.timestamp-s.timestamp),n}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}getPendingBatches(){return Array.from(this.pending.keys())}clear(){this.records.clear(),this.pending.clear(),this.counter=0}destroy(){this.clear()}};var ae=class{constructor(e){this._installed=!1;this.app=null;var t,n,r,o,s,l;this.config={width:(t=e==null?void 0:e.width)!=null?t:420,height:(n=e==null?void 0:e.height)!=null?n:560,x:(r=e==null?void 0:e.x)!=null?r:0,y:(o=e==null?void 0:e.y)!=null?o:0,autoShow:(s=e==null?void 0:e.autoShow)!=null?s:!0,title:(l=e==null?void 0:e.title)!=null?l:"Lyt DevTools"},this.panel=new D({width:this.config.width,height:this.config.height,x:this.config.x,y:this.config.y,title:this.config.title}),this.componentTree=new I(this.panel,p=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new B(this.panel),this.eventTracker=new z(this.panel),this.timeTravel=new N(this.panel),this.panel.registerTabRenderer("components",p=>{this.componentTree.render(p)}),this.panel.registerTabRenderer("state",p=>{this.stateInspector.render(p)}),this.panel.registerTabRenderer("events",p=>{this.eventTracker.render(p)}),this.panel.registerTabRenderer("router",p=>{this.renderRouterTab(p)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,U(e,{onComponentCreated:n=>{this.componentTree.refresh()},onComponentUpdated:n=>{this.componentTree.refresh(),this.stateInspector.refresh()},onComponentUnmounted:n=>{this.componentTree.refresh()},onStateChanged:n=>{this.stateInspector.markChanged(`state.${n.path}`),this.stateInspector.refresh()},onEventEmitted:n=>{this.eventTracker.refresh()}}),this.panel.setConnected(!0)}show(){this.panel.show()}hide(){this.panel.hide()}toggle(){this.panel.toggle()}isVisible(){return this.panel.isVisible()}renderRouterTab(e){e.innerHTML="";let t=document.createElement("div");t.className="lyt-devtools-empty",t.style.cssText="padding: 40px 24px;",t.innerHTML=`
612
612
  <div style="font-size: 32px; margin-bottom: 12px;">\u{1F517}</div>
613
613
  <div style="color: #cdd6f4; font-size: 14px; margin-bottom: 8px; font-style: normal;">\u8DEF\u7531\u68C0\u67E5\u5668</div>
614
614
  <div style="color: #585b70; font-size: 12px;">
package/dist/index.mjs CHANGED
@@ -282,7 +282,7 @@ var Ce=`
282
282
  .lyt-devtools-highlight {
283
283
  animation: lyt-devtools-highlight 1s ease-out;
284
284
  }
285
- `,Ee=[{id:"components",label:"\u7EC4\u4EF6\u6811",icon:"\u{1F333}"},{id:"state",label:"\u72B6\u6001",icon:"\u{1F4CA}"},{id:"events",label:"\u4E8B\u4EF6",icon:"\u26A1"},{id:"router",label:"\u8DEF\u7531",icon:"\u{1F517}"}],D=class{constructor(e){this.activeTab="components";this.tabRenderers=new Map;this._visible=!0;this._collapsed=!1;this.highlightOverlay=null;this._resizeHandle=null;this.onWindowResize=()=>{if(!(typeof window!="undefined"&&typeof document!="undefined"))return;let t=this.panelEl.getBoundingClientRect(),n=window.innerWidth-100,r=window.innerHeight-36;t.left>n&&(this.panelEl.style.left=`${n}px`),t.top>r&&(this.panelEl.style.top=`${r}px`)};var n,r,o,s,l,p,c,a;this.config={width:(n=e==null?void 0:e.width)!=null?n:420,height:(r=e==null?void 0:e.height)!=null?r:560,x:(s=e==null?void 0:e.x)!=null?s:typeof window!="undefined"?window.innerWidth-((o=e==null?void 0:e.width)!=null?o:420)-20:100,y:(l=e==null?void 0:e.y)!=null?l:60,minWidth:(p=e==null?void 0:e.minWidth)!=null?p:320,minHeight:(c=e==null?void 0:e.minHeight)!=null?c:200,title:(a=e==null?void 0:e.title)!=null?a:"Lyt DevTools"},this.dragState={isDragging:!1,startX:0,startY:0,startLeft:0,startTop:0},this.resizeState={isResizing:!1,startX:0,startY:0,startWidth:0,startHeight:0};let t=typeof window!="undefined"&&typeof document!="undefined";if(t?(this.styleEl=document.createElement("style"),this.styleEl.textContent=Ce,document.head.appendChild(this.styleEl)):this.styleEl={},t){let{panel:d,header:u,tabs:h,content:f,statusbar:m,statusLeft:x,statusRight:v,resizeHandle:y}=this.createPanelElementWithRefs();this.panelEl=d,this.headerEl=u,this.tabsEl=h,this.contentEl=f,this.statusbarEl=m,this.statusLeftEl=x,this.statusRightEl=v,this._resizeHandle=y}else this.panelEl=this.createMockPanelElement(),this.headerEl=this.panelEl.headerEl,this.tabsEl=this.panelEl.tabsEl,this.contentEl=this.panelEl.contentEl,this.statusbarEl=this.panelEl.statusbarEl,this.statusLeftEl=this.panelEl.statusLeftEl,this.statusRightEl=this.panelEl.statusRightEl,this._resizeHandle=this.panelEl.resizeHandleEl;t&&document.body.appendChild(this.panelEl),t&&(this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize))}createPanelElementWithRefs(){let e=document.createElement("div");e.className="lyt-devtools-panel",e.style.width=`${this.config.width}px`,e.style.height=`${this.config.height}px`,e.style.left=`${this.config.x}px`,e.style.top=`${this.config.y}px`;let t=document.createElement("div");t.className="lyt-devtools-header";let n=document.createElement("span");n.className="lyt-devtools-title",n.innerHTML=`<span class="lyt-devtools-title-icon">\u{1F50D}</span>${this.config.title}`;let r=document.createElement("div");r.className="lyt-devtools-header-actions";let o=document.createElement("button");o.className="lyt-devtools-btn",o.textContent="\u2014",o.title="\u6298\u53E0/\u5C55\u5F00",o.addEventListener("click",h=>{h.stopPropagation(),this.toggleCollapse()});let s=document.createElement("button");s.className="lyt-devtools-btn lyt-devtools-btn-close",s.textContent="\u2715",s.title="\u5173\u95ED\u9762\u677F",s.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(s),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Ee){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset?f.dataset.tab=h.id:f.setAttribute("data-tab",h.id),f.innerHTML=`<span class="lyt-devtools-tab-icon">${h.icon}</span>${h.label}`,f.addEventListener("click",()=>this.switchTab(h.id)),l.appendChild(f)}let p=document.createElement("div");p.className="lyt-devtools-content";let c=document.createElement("div");c.className="lyt-devtools-statusbar";let a=document.createElement("span");a.className="lyt-devtools-status-left",a.innerHTML='<span class="lyt-devtools-status-dot"></span><span>\u5C31\u7EEA</span>';let d=document.createElement("span");d.className="lyt-devtools-status-right",d.textContent="v0.0.1",c.appendChild(a),c.appendChild(d);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(p),e.appendChild(c),e.appendChild(u),{panel:e,header:t,tabs:l,content:p,statusbar:c,statusLeft:a,statusRight:d,resizeHandle:u}}createPanelElement(){return this.createPanelElementWithRefs().panel}createMockPanelElement(){let e=n=>({className:n,classList:{add:()=>{},remove:()=>{},toggle:()=>{},contains:()=>!1},style:{},dataset:{},querySelector:r=>r===".lyt-devtools-header"?t.headerEl:r===".lyt-devtools-tabs"?t.tabsEl:r===".lyt-devtools-content"?t.contentEl:r===".lyt-devtools-statusbar"?t.statusbarEl:r===".lyt-devtools-status-left"?t.statusLeftEl:r===".lyt-devtools-status-right"?t.statusRightEl:r===".lyt-devtools-resize-handle"?t.resizeHandleEl:null,querySelectorAll:()=>[],appendChild:()=>{},addEventListener:()=>{},removeEventListener:()=>{},offsetLeft:0,offsetTop:0,offsetWidth:100,offsetHeight:100,getBoundingClientRect:()=>({left:0,top:0,right:100,bottom:100,width:100,height:100})}),t=e("lyt-devtools-panel");return t.headerEl=e("lyt-devtools-header"),t.tabsEl=e("lyt-devtools-tabs"),t.contentEl=e("lyt-devtools-content"),t.statusbarEl=e("lyt-devtools-statusbar"),t.statusLeftEl=e("lyt-devtools-status-left"),t.statusRightEl=e("lyt-devtools-status-right"),t.resizeHandleEl=e("lyt-devtools-resize-handle"),t}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,typeof window!="undefined"&&typeof document!="undefined"&&this.tabsEl&&this.tabsEl.querySelectorAll&&this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(r=>{r.classList&&r.dataset&&r.classList.toggle("active",r.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){if(typeof window!="undefined"&&typeof document!="undefined"&&this.contentEl){this.contentEl.innerHTML="";let t=this.tabRenderers.get(this.activeTab);t?t(this.contentEl):this.contentEl.innerHTML='<div class="lyt-devtools-empty">\u6682\u65E0\u5185\u5BB9</div>'}}getActiveTab(){return this.activeTab}getContentElement(){return this.contentEl}show(){this._visible=!0,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="flex")}hide(){this._visible=!1,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="none")}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.classList&&this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){typeof window!="undefined"&&typeof document!="undefined"&&(this.headerEl.addEventListener("mousedown",t=>{t.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=t.clientX,this.dragState.startY=t.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,t.preventDefault())}),document.addEventListener("mousemove",t=>{if(!this.dragState.isDragging)return;let n=t.clientX-this.dragState.startX,r=t.clientY-this.dragState.startY,o=this.dragState.startLeft+n,s=this.dragState.startTop+r;o=Math.max(0,Math.min(o,window.innerWidth-100)),s=Math.max(0,Math.min(s,window.innerHeight-36)),this.panelEl.style.left=`${o}px`,this.panelEl.style.top=`${s}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1}))}bindResizeEvents(){typeof window!="undefined"&&typeof document!="undefined"&&this._resizeHandle&&(this._resizeHandle.addEventListener("mousedown",t=>{this.resizeState.isResizing=!0,this.resizeState.startX=t.clientX,this.resizeState.startY=t.clientY,this.resizeState.startWidth=this.panelEl.offsetWidth,this.resizeState.startHeight=this.panelEl.offsetHeight,t.preventDefault(),t.stopPropagation()}),document.addEventListener("mousemove",t=>{if(!this.resizeState.isResizing)return;let n=t.clientX-this.resizeState.startX,r=t.clientY-this.resizeState.startY,o=Math.max(this.config.minWidth,this.resizeState.startWidth+n),s=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${s}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1}))}bindKeyboardEvents(){typeof window!="undefined"&&typeof document!="undefined"&&document.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&t.key==="D"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&(this.statusLeftEl.innerHTML=e)}setStatusRight(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusRightEl&&(this.statusRightEl.textContent=e)}setConnected(e){if(typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&this.statusLeftEl.querySelector){let n=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");n&&n.classList&&n.classList.toggle("disconnected",!e)}}highlightElement(e){if(this.clearHighlight(),!e)return;if(typeof window!="undefined"&&typeof document!="undefined"){this.highlightOverlay=document.createElement("div"),this.highlightOverlay.style.cssText=`
285
+ `,Ee=[{id:"components",label:"\u7EC4\u4EF6\u6811",icon:"\u{1F333}"},{id:"state",label:"\u72B6\u6001",icon:"\u{1F4CA}"},{id:"events",label:"\u4E8B\u4EF6",icon:"\u26A1"},{id:"router",label:"\u8DEF\u7531",icon:"\u{1F517}"}],D=class{constructor(e){this.activeTab="components";this.tabRenderers=new Map;this._visible=!0;this._collapsed=!1;this.highlightOverlay=null;this._resizeHandle=null;this.onWindowResize=()=>{if(!(typeof window!="undefined"&&typeof document!="undefined"))return;let t=this.panelEl.getBoundingClientRect(),n=window.innerWidth-100,r=window.innerHeight-36;t.left>n&&(this.panelEl.style.left=`${n}px`),t.top>r&&(this.panelEl.style.top=`${r}px`)};var n,r,o,s,l,p,c,a;this.config={width:(n=e==null?void 0:e.width)!=null?n:420,height:(r=e==null?void 0:e.height)!=null?r:560,x:(s=e==null?void 0:e.x)!=null?s:typeof window!="undefined"?window.innerWidth-((o=e==null?void 0:e.width)!=null?o:420)-20:100,y:(l=e==null?void 0:e.y)!=null?l:60,minWidth:(p=e==null?void 0:e.minWidth)!=null?p:320,minHeight:(c=e==null?void 0:e.minHeight)!=null?c:200,title:(a=e==null?void 0:e.title)!=null?a:"Lyt DevTools"},this.dragState={isDragging:!1,startX:0,startY:0,startLeft:0,startTop:0},this.resizeState={isResizing:!1,startX:0,startY:0,startWidth:0,startHeight:0};let t=typeof window!="undefined"&&typeof document!="undefined";if(t?(this.styleEl=document.createElement("style"),this.styleEl.textContent=Ce,document.head.appendChild(this.styleEl)):this.styleEl={},t){let{panel:d,header:u,tabs:h,content:f,statusbar:m,statusLeft:x,statusRight:v,resizeHandle:y}=this.createPanelElementWithRefs();this.panelEl=d,this.headerEl=u,this.tabsEl=h,this.contentEl=f,this.statusbarEl=m,this.statusLeftEl=x,this.statusRightEl=v,this._resizeHandle=y}else this.panelEl=this.createMockPanelElement(),this.headerEl=this.panelEl.headerEl,this.tabsEl=this.panelEl.tabsEl,this.contentEl=this.panelEl.contentEl,this.statusbarEl=this.panelEl.statusbarEl,this.statusLeftEl=this.panelEl.statusLeftEl,this.statusRightEl=this.panelEl.statusRightEl,this._resizeHandle=this.panelEl.resizeHandleEl;t&&document.body.appendChild(this.panelEl),t&&(this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize))}createPanelElementWithRefs(){let e=document.createElement("div");e.className="lyt-devtools-panel",e.style.width=`${this.config.width}px`,e.style.height=`${this.config.height}px`,e.style.left=`${this.config.x}px`,e.style.top=`${this.config.y}px`;let t=document.createElement("div");t.className="lyt-devtools-header";let n=document.createElement("span");n.className="lyt-devtools-title",n.innerHTML=`<span class="lyt-devtools-title-icon">\u{1F50D}</span>${this.config.title}`;let r=document.createElement("div");r.className="lyt-devtools-header-actions";let o=document.createElement("button");o.className="lyt-devtools-btn",o.textContent="\u2014",o.title="\u6298\u53E0/\u5C55\u5F00",o.addEventListener("click",h=>{h.stopPropagation(),this.toggleCollapse()});let s=document.createElement("button");s.className="lyt-devtools-btn lyt-devtools-btn-close",s.textContent="\u2715",s.title="\u5173\u95ED\u9762\u677F",s.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(s),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Ee){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset?f.dataset.tab=h.id:f.setAttribute("data-tab",h.id),f.innerHTML=`<span class="lyt-devtools-tab-icon">${h.icon}</span>${h.label}`,f.addEventListener("click",()=>this.switchTab(h.id)),l.appendChild(f)}let p=document.createElement("div");p.className="lyt-devtools-content";let c=document.createElement("div");c.className="lyt-devtools-statusbar";let a=document.createElement("span");a.className="lyt-devtools-status-left",a.innerHTML='<span class="lyt-devtools-status-dot"></span><span>\u5C31\u7EEA</span>';let d=document.createElement("span");d.className="lyt-devtools-status-right",d.textContent="v0.0.1",c.appendChild(a),c.appendChild(d);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(p),e.appendChild(c),e.appendChild(u),{panel:e,header:t,tabs:l,content:p,statusbar:c,statusLeft:a,statusRight:d,resizeHandle:u}}createPanelElement(){return this.createPanelElementWithRefs().panel}createMockPanelElement(){let e=n=>({className:n,classList:{add:()=>{},remove:()=>{},toggle:()=>{},contains:()=>!1},style:{},dataset:{},querySelector:r=>r===".lyt-devtools-header"?t.headerEl:r===".lyt-devtools-tabs"?t.tabsEl:r===".lyt-devtools-content"?t.contentEl:r===".lyt-devtools-statusbar"?t.statusbarEl:r===".lyt-devtools-status-left"?t.statusLeftEl:r===".lyt-devtools-status-right"?t.statusRightEl:r===".lyt-devtools-resize-handle"?t.resizeHandleEl:null,querySelectorAll:()=>[],appendChild:()=>{},addEventListener:()=>{},removeEventListener:()=>{},offsetLeft:0,offsetTop:0,offsetWidth:100,offsetHeight:100,getBoundingClientRect:()=>({left:0,top:0,right:100,bottom:100,width:100,height:100})}),t=e("lyt-devtools-panel");return t.headerEl=e("lyt-devtools-header"),t.tabsEl=e("lyt-devtools-tabs"),t.contentEl=e("lyt-devtools-content"),t.statusbarEl=e("lyt-devtools-statusbar"),t.statusLeftEl=e("lyt-devtools-status-left"),t.statusRightEl=e("lyt-devtools-status-right"),t.resizeHandleEl=e("lyt-devtools-resize-handle"),t}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,typeof window!="undefined"&&typeof document!="undefined"&&this.tabsEl&&this.tabsEl.querySelectorAll&&this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(r=>{let o=r;o.classList&&o.dataset&&o.classList.toggle("active",o.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){if(typeof window!="undefined"&&typeof document!="undefined"&&this.contentEl){this.contentEl.innerHTML="";let t=this.tabRenderers.get(this.activeTab);t?t(this.contentEl):this.contentEl.innerHTML='<div class="lyt-devtools-empty">\u6682\u65E0\u5185\u5BB9</div>'}}getActiveTab(){return this.activeTab}getContentElement(){return this.contentEl}show(){this._visible=!0,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="flex")}hide(){this._visible=!1,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="none")}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.classList&&this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){typeof window!="undefined"&&typeof document!="undefined"&&(this.headerEl.addEventListener("mousedown",t=>{t.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=t.clientX,this.dragState.startY=t.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,t.preventDefault())}),document.addEventListener("mousemove",t=>{if(!this.dragState.isDragging)return;let n=t.clientX-this.dragState.startX,r=t.clientY-this.dragState.startY,o=this.dragState.startLeft+n,s=this.dragState.startTop+r;o=Math.max(0,Math.min(o,window.innerWidth-100)),s=Math.max(0,Math.min(s,window.innerHeight-36)),this.panelEl.style.left=`${o}px`,this.panelEl.style.top=`${s}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1}))}bindResizeEvents(){typeof window!="undefined"&&typeof document!="undefined"&&this._resizeHandle&&(this._resizeHandle.addEventListener("mousedown",t=>{this.resizeState.isResizing=!0,this.resizeState.startX=t.clientX,this.resizeState.startY=t.clientY,this.resizeState.startWidth=this.panelEl.offsetWidth,this.resizeState.startHeight=this.panelEl.offsetHeight,t.preventDefault(),t.stopPropagation()}),document.addEventListener("mousemove",t=>{if(!this.resizeState.isResizing)return;let n=t.clientX-this.resizeState.startX,r=t.clientY-this.resizeState.startY,o=Math.max(this.config.minWidth,this.resizeState.startWidth+n),s=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${s}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1}))}bindKeyboardEvents(){typeof window!="undefined"&&typeof document!="undefined"&&document.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&t.key==="D"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&(this.statusLeftEl.innerHTML=e)}setStatusRight(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusRightEl&&(this.statusRightEl.textContent=e)}setConnected(e){if(typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&this.statusLeftEl.querySelector){let n=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");n&&n.classList&&n.classList.toggle("disconnected",!e)}}highlightElement(e){if(this.clearHighlight(),!e)return;if(typeof window!="undefined"&&typeof document!="undefined"){this.highlightOverlay=document.createElement("div"),this.highlightOverlay.style.cssText=`
286
286
  position: fixed;
287
287
  z-index: 999998;
288
288
  pointer-events: none;
@@ -290,7 +290,7 @@ var Ce=`
290
290
  background: rgba(203, 166, 247, 0.1);
291
291
  border-radius: 2px;
292
292
  transition: all 0.15s ease;
293
- `;let n=e.getBoundingClientRect();this.highlightOverlay.style.left=`${n.left}px`,this.highlightOverlay.style.top=`${n.top}px`,this.highlightOverlay.style.width=`${n.width}px`,this.highlightOverlay.style.height=`${n.height}px`,document.body.appendChild(this.highlightOverlay)}}clearHighlight(){typeof window!="undefined"&&typeof document!="undefined"&&this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){let e=typeof window!="undefined"&&typeof document!="undefined";e&&this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),e&&this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),e&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],S=[],ye=0,H=null,C={},_=!1;function we(){return`comp_${++ye}`}function Se(){return`evt_${++ye}`}function ge(i){var t;if(!i)return"Unknown";let e=i.type||i.options;return e?e.name?e.name:e.render&&e.render.name?e.render.name:e.setup&&e.setup.name?e.setup.name:e._isComponentDefine&&((t=e.options)!=null&&t.name)?e.options.name:"Anonymous":"Anonymous"}function w(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>w(t));let e={};for(let t of Object.keys(i))e[t]=w(i[t]);return e}function Re(i,e){return i===e?!1:typeof i!=typeof e?!0:i===null||e===null?i!==e:typeof i=="object"?JSON.stringify(i)!==JSON.stringify(e):i!==e}function Me(i,e){let t=e.split("."),n=i;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Le(i,e,t){let n=e.split("."),r=i;for(let o=0;o<n.length-1;o++)(r[n[o]]===null||r[n[o]]===void 0||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function J(i,e){_||(e&&Object.assign(C,e),_=!0,ke(i),i._instance&&(U(i._instance,null),V()))}function ke(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(U(i._instance,null),V()),n}}function U(i,e){var o,s,l,p,c,a,d,u;if(!i)return;let t=ve(i),n=!t;if(n){let h=we();t={id:h,name:ge(i),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=i.isMounted)!=null?o:!1,isUnmounted:(s=i.isUnmounted)!=null?s:!1,el:(l=i.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:i},E.set(h,t)}else t.parentId=e,t.name=ge(i),t.isMounted=(p=i.isMounted)!=null?p:!1,t.isUnmounted=(c=i.isUnmounted)!=null?c:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now();i.props&&(t.props=w(i.props)),i.state&&(t.state=w(i.state)),i.computedCache&&(t.computed=w(i.computedCache)),n&&i.state&&typeof i.state=="object"&&Pe(t.id,i),n&&i.emit&&typeof i.emit=="function"&&De(t.id,i),n?(d=C.onComponentCreated)==null||d.call(C,t):(u=C.onComponentUpdated)==null||u.call(C,t);let r=i.subTree;r&&xe(r,t.id)}function xe(i,e){if(i){if(i.component){U(i.component,e);let t=E.get(e);if(t&&!t.childIds.includes(i.component.id||i.component._id)){let n=He(i.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(i.children&&Array.isArray(i.children))for(let t of i.children)t&&typeof t=="object"&&xe(t,e)}}function Pe(i,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(i);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,s,l){var a;let p=o[s],c=Reflect.set(o,s,l);if(Re(p,l)){let d=String(s),u={componentId:i,componentName:n.name,path:d,oldValue:w(p),newValue:w(l),timestamp:Date.now()};S.push(u),S.length>1e3&&S.splice(0,S.length-1e3),n.state=w(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return c}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function De(i,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(i);n&&(e.emit=function(r,...o){var l;let s={id:Se(),name:r,timestamp:Date.now(),args:w(o),componentId:i,componentName:n.name};return M.push(s),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,s),t.call(this,r,...o)})}function V(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function ve(i){for(let e of E.values())if(e.instance===i)return e;return null}function He(i){let e=ve(i);return e?e.id:null}function k(){return Array.from(E.values())}function W(){for(let i of E.values())if(i.parentId===null)return i;return null}function I(i){var e;return(e=E.get(i))!=null?e:null}function Y(i){let e=E.get(i);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function K(){return[...M]}function Ie(){return[...S]}function X(i){return S.filter(e=>e.componentId===i)}function Be(i){return M.filter(e=>e.componentId===i)}function G(i){H=i}function Q(){var i;return H&&(i=E.get(H))!=null?i:null}function P(){return H}function Z(i,e,t){var l;let n=E.get(i);if(!n||!n.instance)return!1;let r=n.instance.state;if(!r||typeof r!="object")return!1;let o=Me(r,e);Le(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:w(o),newValue:w(t),timestamp:Date.now()};return S.push(s),n.state=w(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function ee(i){E.clear(),i._instance&&(U(i._instance,null),V())}function te(){M.length=0,S.length=0}function ne(){E.clear(),M.length=0,S.length=0,H=null,_=!1}function ze(){return _}function Ne(){return E.size}var B=class{constructor(e,t){this.searchKeyword="";this.expandedNodes=new Set;this.container=null;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderTree()},100)};this.panel=e,this.onSelect=t||(()=>{});let n=W();n&&this.expandedNodes.add(n.id),typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderTree()}renderTree(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("input");e.type="text",e.className="lyt-devtools-search",e.placeholder="\u641C\u7D22\u7EC4\u4EF6...",e.value=this.searchKeyword,e.addEventListener("input",r=>{this.searchKeyword=r.target.value,this.renderTree()}),this.container.appendChild(e);let t=k();if(t.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent="\u6682\u65E0\u7EC4\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5E94\u7528\u5DF2\u6302\u8F7D\u3002",this.container.appendChild(r);return}let n=this.buildTree();for(let r of n){let o=this.renderTreeNode(r);o&&this.container.appendChild(o)}this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${t.length} \u4E2A\u7EC4\u4EF6</span>`)}buildTree(){let e=k(),t=new Map,n=[];for(let r of e){if(this.searchKeyword){let s=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(s),p=r.id.toLowerCase().includes(s);if(!l&&!p)continue}let o={info:r,children:[],depth:0,expanded:this.expandedNodes.has(r.id)};t.set(r.id,o)}for(let r of t.values()){let o=r.info.parentId;if(o&&t.has(o)){let s=t.get(o);s.children.push(r),r.depth=s.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=P(),s=t.id===o,l=document.createElement("div");l.className="lyt-tree-node",l.style.cssText=`
293
+ `;let n=e.getBoundingClientRect();this.highlightOverlay.style.left=`${n.left}px`,this.highlightOverlay.style.top=`${n.top}px`,this.highlightOverlay.style.width=`${n.width}px`,this.highlightOverlay.style.height=`${n.height}px`,document.body.appendChild(this.highlightOverlay)}}clearHighlight(){typeof window!="undefined"&&typeof document!="undefined"&&this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){let e=typeof window!="undefined"&&typeof document!="undefined";e&&this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),e&&this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),e&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],S=[],ye=0,H=null,C={},_=!1;function we(){return`comp_${++ye}`}function Se(){return`evt_${++ye}`}function ge(i){var t;if(!i)return"Unknown";let e=i.type||i.options;return e?e.name?e.name:e.render&&e.render.name?e.render.name:e.setup&&e.setup.name?e.setup.name:e._isComponentDefine&&((t=e.options)!=null&&t.name)?e.options.name:"Anonymous":"Anonymous"}function w(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>w(t));let e={};for(let t of Object.keys(i))e[t]=w(i[t]);return e}function Re(i,e){return i===e?!1:typeof i!=typeof e?!0:i===null||e===null?i!==e:typeof i=="object"?JSON.stringify(i)!==JSON.stringify(e):i!==e}function Me(i,e){let t=e.split("."),n=i;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Le(i,e,t){let n=e.split("."),r=i;for(let o=0;o<n.length-1;o++)(r[n[o]]===null||r[n[o]]===void 0||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function J(i,e){_||(e&&Object.assign(C,e),_=!0,ke(i),i._instance&&(U(i._instance,null),V()))}function ke(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(U(i._instance,null),V()),n}}function U(i,e){var o,s,l,p,c,a,d,u;if(!i)return;let t=ve(i),n=!t;if(n){let h=we();t={id:h,name:ge(i),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=i.isMounted)!=null?o:!1,isUnmounted:(s=i.isUnmounted)!=null?s:!1,el:(l=i.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:i},E.set(h,t)}else t&&(t.parentId=e,t.name=ge(i),t.isMounted=(p=i.isMounted)!=null?p:!1,t.isUnmounted=(c=i.isUnmounted)!=null?c:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now());t&&i.props&&(t.props=w(i.props)),t&&i.state&&(t.state=w(i.state)),t&&i.computedCache&&(t.computed=w(i.computedCache)),n&&t&&i.state&&typeof i.state=="object"&&Pe(t.id,i),n&&t&&i.emit&&typeof i.emit=="function"&&De(t.id,i),n&&t?(d=C.onComponentCreated)==null||d.call(C,t):t&&((u=C.onComponentUpdated)==null||u.call(C,t));let r=i.subTree;r&&t&&xe(r,t.id)}function xe(i,e){if(i){if(i.component){U(i.component,e);let t=E.get(e);if(t&&!t.childIds.includes(i.component.id||i.component._id)){let n=He(i.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(i.children&&Array.isArray(i.children))for(let t of i.children)t&&typeof t=="object"&&xe(t,e)}}function Pe(i,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(i);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,s,l){var a;let p=o[s],c=Reflect.set(o,s,l);if(Re(p,l)){let d=String(s),u={componentId:i,componentName:n.name,path:d,oldValue:w(p),newValue:w(l),timestamp:Date.now()};S.push(u),S.length>1e3&&S.splice(0,S.length-1e3),n.state=w(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return c}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function De(i,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(i);n&&(e.emit=function(r,...o){var l;let s={id:Se(),name:r,timestamp:Date.now(),args:w(o),componentId:i,componentName:n.name};return M.push(s),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,s),t.call(this,r,...o)})}function V(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function ve(i){for(let e of E.values())if(e.instance===i)return e;return null}function He(i){let e=ve(i);return e?e.id:null}function k(){return Array.from(E.values())}function W(){for(let i of E.values())if(i.parentId===null)return i;return null}function I(i){var e;return(e=E.get(i))!=null?e:null}function Y(i){let e=E.get(i);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function K(){return[...M]}function Ie(){return[...S]}function X(i){return S.filter(e=>e.componentId===i)}function Be(i){return M.filter(e=>e.componentId===i)}function G(i){H=i}function Q(){var i;return H&&(i=E.get(H))!=null?i:null}function P(){return H}function Z(i,e,t){var l;let n=E.get(i);if(!n||!n.instance)return!1;let r=n.instance.state;if(!r||typeof r!="object")return!1;let o=Me(r,e);Le(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:w(o),newValue:w(t),timestamp:Date.now()};return S.push(s),n.state=w(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function ee(i){E.clear(),i._instance&&(U(i._instance,null),V())}function te(){M.length=0,S.length=0}function ne(){E.clear(),M.length=0,S.length=0,H=null,_=!1}function ze(){return _}function Ne(){return E.size}var B=class{constructor(e,t){this.searchKeyword="";this.expandedNodes=new Set;this.container=null;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderTree()},100)};this.panel=e,this.onSelect=t||(()=>{});let n=W();n&&this.expandedNodes.add(n.id),typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderTree()}renderTree(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("input");e.type="text",e.className="lyt-devtools-search",e.placeholder="\u641C\u7D22\u7EC4\u4EF6...",e.value=this.searchKeyword,e.addEventListener("input",r=>{this.searchKeyword=r.target.value,this.renderTree()}),this.container.appendChild(e);let t=k();if(t.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent="\u6682\u65E0\u7EC4\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5E94\u7528\u5DF2\u6302\u8F7D\u3002",this.container.appendChild(r);return}let n=this.buildTree();for(let r of n){let o=this.renderTreeNode(r);o&&this.container.appendChild(o)}this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${t.length} \u4E2A\u7EC4\u4EF6</span>`)}buildTree(){let e=k(),t=new Map,n=[];for(let r of e){if(this.searchKeyword){let s=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(s),p=r.id.toLowerCase().includes(s);if(!l&&!p)continue}let o={info:r,children:[],depth:0,expanded:this.expandedNodes.has(r.id)};t.set(r.id,o)}for(let r of t.values()){let o=r.info.parentId;if(o&&t.has(o)){let s=t.get(o);s.children.push(r),r.depth=s.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=P(),s=t.id===o,l=document.createElement("div");l.className="lyt-tree-node",l.style.cssText=`
294
294
  display: flex;
295
295
  align-items: center;
296
296
  padding: 3px 8px;
@@ -345,7 +345,7 @@ var Ce=`
345
345
  cursor: pointer;
346
346
  font-size: 11px;
347
347
  font-family: inherit;
348
- `,r.textContent="\u53D8\u5316\u5386\u53F2",r.addEventListener("click",()=>{this.showHistory=!this.showHistory,this.renderState()}),t.appendChild(n),t.appendChild(r),this.container.appendChild(t),this.showHistory?this.renderHistory(e):(this.renderCategory(container,"props",e.props,!0,!1,!1),this.renderCategory(container,"state",e.state,!1,!0,!1),this.renderCategory(container,"computed",e.computed,!1,!1,!0));let o=Object.keys(e.state).length,s=Object.keys(e.props).length,l=Object.keys(e.computed).length;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${e.name}</span><span style="color: #585b70;">|</span><span>P:${s} S:${o} C:${l}</span>`)}renderCategory(e,t,n,r,o,s){let l=Object.keys(n);if(l.length===0)return;let p=document.createElement("div");p.style.cssText=`
348
+ `,r.textContent="\u53D8\u5316\u5386\u53F2",r.addEventListener("click",()=>{this.showHistory=!this.showHistory,this.renderState()}),t.appendChild(n),t.appendChild(r),this.container.appendChild(t),this.showHistory?this.renderHistory(e):(this.renderCategory(this.container,"props",e.props,!0,!1,!1),this.renderCategory(this.container,"state",e.state,!1,!0,!1),this.renderCategory(this.container,"computed",e.computed,!1,!1,!0));let o=Object.keys(e.state).length,s=Object.keys(e.props).length,l=Object.keys(e.computed).length;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${e.name}</span><span style="color: #585b70;">|</span><span>P:${s} S:${o} C:${l}</span>`)}renderCategory(e,t,n,r,o,s){let l=Object.keys(n);if(l.length===0)return;let p=document.createElement("div");p.style.cssText=`
349
349
  display: flex;
350
350
  align-items: center;
351
351
  padding: 4px 8px;
@@ -608,7 +608,7 @@ var Ce=`
608
608
  background: ${r?"#313244":"transparent"};
609
609
  color: ${o?"#89b4fa":"#cdd6f4"};
610
610
  border-bottom: 1px solid #1e1e2e;
611
- `;let l=document.createElement("span");l.style.cssText="display: inline-block; width: 14px; text-align: center; margin-right: 4px; font-size: 10px; color: #585b70;",s?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let p=document.createElement("span");if(p.textContent=e.node.name,p.style.cssText="font-weight: bold;",n.appendChild(p),e.node.stateSummary){let d=document.createElement("span");d.textContent=` ${e.node.stateSummary}`,d.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(d)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let d=document.createElement("span");d.textContent=` [${e.node.propsCount} props]`,d.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(d)}let c=e.node,a=c.id;return n.addEventListener("click",()=>{var d;if(s){let u=(d=this.expandedMap.get(a))!=null?d:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(c)}),n}handleScroll(e){if(this.destroyed)return;let t=e.target;this.scrollTop=t.scrollTop,this.renderNodes()}getFlatNodes(){return[...this.flatNodes]}getVisibleNodeCount(){return this.getVisibleNodes().length}getTotalNodeCount(){return this.flatNodes.length}};var de=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},qe=100,je=1024,Je=.7,Ve=5,pe=class{constructor(e){this.counter=0;var t,n,r,o;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:qe,leakGrowthThreshold:(n=e==null?void 0:e.leakGrowthThreshold)!=null?n:je,leakRSquaredThreshold:(r=e==null?void 0:e.leakRSquaredThreshold)!=null?r:Je,leakMinSnapshots:(o=e==null?void 0:e.leakMinSnapshots)!=null?o:Ve},this.snapshots=new de(this.config.bufferSize)}trackMemoryUsage(e,t,n,r){if(e===void 0){let s=performance.memory;s&&(e=s.usedJSHeapSize,t=s.totalJSHeapSize,n=s.jsHeapSizeLimit)}if(e===void 0)return null;let o={timestamp:r!=null?r:Date.now(),usedJSHeapSize:e,totalJSHeapSize:t!=null?t:0,jsHeapSizeLimit:n!=null?n:0,index:this.counter++};return this.snapshots.push(o),o}getMemoryTrend(){let e=this.snapshots.getAll();return e.length===0?[]:e.map((t,n)=>{let r=n>0?e[n-1]:null,o=r?t.usedJSHeapSize-r.usedJSHeapSize:0,s=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:s}})}detectMemoryLeak(){let e=this.snapshots.getAll();if(e.length<this.config.leakMinSnapshots)return{hasLeak:!1,severity:"none",description:`\u5FEB\u7167\u6570\u91CF\u4E0D\u8DB3\uFF08\u9700\u8981\u81F3\u5C11 ${this.config.leakMinSnapshots} \u4E2A\uFF0C\u5F53\u524D ${e.length} \u4E2A\uFF09`,snapshotCount:e.length,growthRate:0,rSquared:0};let t=e.length,n=0,r=0,o=0,s=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,s+=b*b,l+=T*T}let p=t*s-n*n,c=p!==0?(t*o-n*r)/p:0,a=r/t,d=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=c*g+(r-c*n)/t;d+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=d!==0?1-u/d:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?c/f:0,x=h>=this.config.leakRSquaredThreshold&&m>=this.config.leakGrowthThreshold,v="none",y="\u672A\u68C0\u6D4B\u5230\u5185\u5B58\u6CC4\u6F0F";return x&&(m>=this.config.leakGrowthThreshold*10?(v="high",y=`\u68C0\u6D4B\u5230\u4E25\u91CD\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):m>=this.config.leakGrowthThreshold*3?(v="medium",y=`\u68C0\u6D4B\u5230\u4E2D\u7B49\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):(v="low",y=`\u68C0\u6D4B\u5230\u8F7B\u5FAE\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`)),{hasLeak:x,severity:v,description:y,snapshotCount:t,growthRate:m,rSquared:h}}getMemoryReport(){let e=this.snapshots.getAll(),t=this.getMemoryTrend(),n=this.detectMemoryLeak(),r=null,o=0,s=0,l=0,p=1/0;for(let d of e)(!r||d.timestamp>r.timestamp)&&(r=d),d.usedJSHeapSize>o&&(o=d.usedJSHeapSize,s=d.timestamp),l+=d.usedJSHeapSize,d.usedJSHeapSize<p&&(p=d.usedJSHeapSize);let c=e.length>0?l/e.length:0;p===1/0&&(p=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:s,averageUsage:c,minUsage:p,totalGrowth:a,trend:t,leakDetection:n,snapshotCount:e.length}}getSnapshots(){return this.snapshots.getAll()}getSnapshotCount(){return this.snapshots.size}clear(){this.snapshots.clear(),this.counter=0}destroy(){this.clear()}};var ce=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},We=200,Ye=16,ue=class{constructor(e){this.counter=0;var t,n;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:We,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:Ye},this.records=new ce(this.config.bufferSize)}trackRender(e,t){this.records.push({componentName:e,duration:t,timestamp:Date.now(),index:this.counter++})}getSlowRenderers(e){let t=e!=null?e:this.config.slowThreshold;return this.records.getAll().filter(r=>r.duration>t).map(r=>({componentName:r.componentName,duration:r.duration,timestamp:r.timestamp,overThreshold:r.duration-t})).sort((r,o)=>o.duration-r.duration)}getRenderStats(){let e=this.records.getAll(),t=this.config.slowThreshold;if(e.length===0)return{totalRenders:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,slowRenderCount:0,slowRenderRatio:0,byComponent:[]};let n=0,r=-1/0,o=1/0,s=0,l=new Map;for(let c of e){n+=c.duration,c.duration>r&&(r=c.duration),c.duration<o&&(o=c.duration),c.duration>t&&s++;let a=l.get(c.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(c.componentName,a)),a.renderCount++,a.totalDuration+=c.duration,c.duration>a.maxDuration&&(a.maxDuration=c.duration),c.duration<a.minDuration&&(a.minDuration=c.duration),c.duration>t&&a.slowCount++}let p=Array.from(l.entries()).map(([c,a])=>({componentName:c,renderCount:a.renderCount,avgDuration:a.totalDuration/a.renderCount,maxDuration:a.maxDuration===-1/0?0:a.maxDuration,minDuration:a.minDuration===1/0?0:a.minDuration,totalDuration:a.totalDuration,slowCount:a.slowCount})).sort((c,a)=>a.avgDuration-c.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:s,slowRenderRatio:s/e.length,byComponent:p}}getRenderTimeline(){let e=this.records.getAll(),t=this.config.slowThreshold;return e.map((n,r)=>({componentName:n.componentName,duration:n.duration,timestamp:n.timestamp,isSlow:n.duration>t,gap:r>0?n.timestamp-e[r-1].timestamp:-1}))}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}clear(){this.records.clear(),this.counter=0}destroy(){this.clear()}};var he=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},Ke=100,Xe=1e3,Ge=2,me=class{constructor(e){this.pending=new Map;this.counter=0;var t,n,r;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:Ke,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:Xe,outlierSigmaThreshold:(r=e==null?void 0:e.outlierSigmaThreshold)!=null?r:Ge},this.records=new he(this.config.bufferSize)}startBatch(e){return this.pending.has(e)?!1:(this.pending.set(e,Date.now()),!0)}endBatch(e){let t=this.pending.get(e);if(t===void 0)return null;let n=Date.now(),r=n-t;this.pending.delete(e);let o={name:e,startTime:t,endTime:n,duration:r,index:this.counter++};return this.records.push(o),o}getBatchStats(){let e=this.records.getAll();if(e.length===0)return{totalBatches:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,byName:[]};let t=0,n=-1/0,r=1/0,o=new Map;for(let l of e){t+=l.duration,l.duration>n&&(n=l.duration),l.duration<r&&(r=l.duration);let p=o.get(l.name);p||(p={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,p)),p.count++,p.totalDuration+=l.duration,l.duration>p.maxDuration&&(p.maxDuration=l.duration),l.duration<p.minDuration&&(p.minDuration=l.duration),p.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,p])=>{let c=p.totalDuration/p.count,a=0;for(let u of p.durations)a+=(u-c)*(u-c);a/=p.count;let d=Math.sqrt(a);return{name:l,count:p.count,avgDuration:c,maxDuration:p.maxDuration===-1/0?0:p.maxDuration,minDuration:p.minDuration===1/0?0:p.minDuration,totalDuration:p.totalDuration,stdDev:d}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:s}}detectAnomalousBatches(){let e=this.records.getAll();if(e.length===0)return[];let t=this.getBatchStats(),n=[],r=new Map;for(let o of t.byName)r.set(o.name,o);for(let o of e){let s=r.get(o.name);if(o.duration>this.config.slowThreshold){n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:"slow",description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u8D85\u8FC7\u6162\u64CD\u4F5C\u9608\u503C ${this.config.slowThreshold}ms`,deviationSigma:s&&s.stdDev>0?(o.duration-s.avgDuration)/s.stdDev:0});continue}if(s&&s.count>=2&&s.stdDev>0){let l=(o.duration-s.avgDuration)/s.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let p=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:p,description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u504F\u79BB\u5E73\u5747\u503C ${l.toFixed(1)} \u4E2A\u6807\u51C6\u5DEE`,deviationSigma:l})}}}return n.sort((o,s)=>o.timestamp-s.timestamp),n}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}getPendingBatches(){return Array.from(this.pending.keys())}clear(){this.records.clear(),this.pending.clear(),this.counter=0}destroy(){this.clear()}};var fe=class{constructor(e){this._installed=!1;this.app=null;var t,n,r,o,s,l;this.config={width:(t=e==null?void 0:e.width)!=null?t:420,height:(n=e==null?void 0:e.height)!=null?n:560,x:(r=e==null?void 0:e.x)!=null?r:void 0,y:(o=e==null?void 0:e.y)!=null?o:void 0,autoShow:(s=e==null?void 0:e.autoShow)!=null?s:!0,title:(l=e==null?void 0:e.title)!=null?l:"Lyt DevTools"},this.panel=new D({width:this.config.width,height:this.config.height,x:this.config.x,y:this.config.y,title:this.config.title}),this.componentTree=new B(this.panel,p=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new z(this.panel),this.eventTracker=new N(this.panel),this.timeTravel=new $(this.panel),this.panel.registerTabRenderer("components",p=>{this.componentTree.render(p)}),this.panel.registerTabRenderer("state",p=>{this.stateInspector.render(p)}),this.panel.registerTabRenderer("events",p=>{this.eventTracker.render(p)}),this.panel.registerTabRenderer("router",p=>{this.renderRouterTab(p)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,J(e,{onComponentCreated:n=>{this.componentTree.refresh()},onComponentUpdated:n=>{this.componentTree.refresh(),this.stateInspector.refresh()},onComponentUnmounted:n=>{this.componentTree.refresh()},onStateChanged:n=>{this.stateInspector.markChanged(`state.${n.path}`),this.stateInspector.refresh()},onEventEmitted:n=>{this.eventTracker.refresh()}}),this.panel.setConnected(!0)}show(){this.panel.show()}hide(){this.panel.hide()}toggle(){this.panel.toggle()}isVisible(){return this.panel.isVisible()}renderRouterTab(e){e.innerHTML="";let t=document.createElement("div");t.className="lyt-devtools-empty",t.style.cssText="padding: 40px 24px;",t.innerHTML=`
611
+ `;let l=document.createElement("span");l.style.cssText="display: inline-block; width: 14px; text-align: center; margin-right: 4px; font-size: 10px; color: #585b70;",s?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let p=document.createElement("span");if(p.textContent=e.node.name,p.style.cssText="font-weight: bold;",n.appendChild(p),e.node.stateSummary){let d=document.createElement("span");d.textContent=` ${e.node.stateSummary}`,d.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(d)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let d=document.createElement("span");d.textContent=` [${e.node.propsCount} props]`,d.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(d)}let c=e.node,a=c.id;return n.addEventListener("click",()=>{var d;if(s){let u=(d=this.expandedMap.get(a))!=null?d:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(c)}),n}handleScroll(e){if(this.destroyed)return;let t=e.target;this.scrollTop=t.scrollTop,this.renderNodes()}getFlatNodes(){return[...this.flatNodes]}getVisibleNodeCount(){return this.getVisibleNodes().length}getTotalNodeCount(){return this.flatNodes.length}};var de=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},qe=100,je=1024,Je=.7,Ve=5,pe=class{constructor(e){this.counter=0;var t,n,r,o;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:qe,leakGrowthThreshold:(n=e==null?void 0:e.leakGrowthThreshold)!=null?n:je,leakRSquaredThreshold:(r=e==null?void 0:e.leakRSquaredThreshold)!=null?r:Je,leakMinSnapshots:(o=e==null?void 0:e.leakMinSnapshots)!=null?o:Ve},this.snapshots=new de(this.config.bufferSize)}trackMemoryUsage(e,t,n,r){if(e===void 0){let s=performance.memory;s&&(e=s.usedJSHeapSize,t=s.totalJSHeapSize,n=s.jsHeapSizeLimit)}if(e===void 0)return null;let o={timestamp:r!=null?r:Date.now(),usedJSHeapSize:e,totalJSHeapSize:t!=null?t:0,jsHeapSizeLimit:n!=null?n:0,index:this.counter++};return this.snapshots.push(o),o}getMemoryTrend(){let e=this.snapshots.getAll();return e.length===0?[]:e.map((t,n)=>{let r=n>0?e[n-1]:null,o=r?t.usedJSHeapSize-r.usedJSHeapSize:0,s=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:s}})}detectMemoryLeak(){let e=this.snapshots.getAll();if(e.length<this.config.leakMinSnapshots)return{hasLeak:!1,severity:"none",description:`\u5FEB\u7167\u6570\u91CF\u4E0D\u8DB3\uFF08\u9700\u8981\u81F3\u5C11 ${this.config.leakMinSnapshots} \u4E2A\uFF0C\u5F53\u524D ${e.length} \u4E2A\uFF09`,snapshotCount:e.length,growthRate:0,rSquared:0};let t=e.length,n=0,r=0,o=0,s=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,s+=b*b,l+=T*T}let p=t*s-n*n,c=p!==0?(t*o-n*r)/p:0,a=r/t,d=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=c*g+(r-c*n)/t;d+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=d!==0?1-u/d:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?c/f:0,x=h>=this.config.leakRSquaredThreshold&&m>=this.config.leakGrowthThreshold,v="none",y="\u672A\u68C0\u6D4B\u5230\u5185\u5B58\u6CC4\u6F0F";return x&&(m>=this.config.leakGrowthThreshold*10?(v="high",y=`\u68C0\u6D4B\u5230\u4E25\u91CD\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):m>=this.config.leakGrowthThreshold*3?(v="medium",y=`\u68C0\u6D4B\u5230\u4E2D\u7B49\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):(v="low",y=`\u68C0\u6D4B\u5230\u8F7B\u5FAE\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`)),{hasLeak:x,severity:v,description:y,snapshotCount:t,growthRate:m,rSquared:h}}getMemoryReport(){let e=this.snapshots.getAll(),t=this.getMemoryTrend(),n=this.detectMemoryLeak(),r=null,o=0,s=0,l=0,p=1/0;for(let d of e)(!r||d.timestamp>r.timestamp)&&(r=d),d.usedJSHeapSize>o&&(o=d.usedJSHeapSize,s=d.timestamp),l+=d.usedJSHeapSize,d.usedJSHeapSize<p&&(p=d.usedJSHeapSize);let c=e.length>0?l/e.length:0;p===1/0&&(p=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:s,averageUsage:c,minUsage:p,totalGrowth:a,trend:t,leakDetection:n,snapshotCount:e.length}}getSnapshots(){return this.snapshots.getAll()}getSnapshotCount(){return this.snapshots.size}clear(){this.snapshots.clear(),this.counter=0}destroy(){this.clear()}};var ce=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},We=200,Ye=16,ue=class{constructor(e){this.counter=0;var t,n;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:We,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:Ye},this.records=new ce(this.config.bufferSize)}trackRender(e,t){this.records.push({componentName:e,duration:t,timestamp:Date.now(),index:this.counter++})}getSlowRenderers(e){let t=e!=null?e:this.config.slowThreshold;return this.records.getAll().filter(r=>r.duration>t).map(r=>({componentName:r.componentName,duration:r.duration,timestamp:r.timestamp,overThreshold:r.duration-t})).sort((r,o)=>o.duration-r.duration)}getRenderStats(){let e=this.records.getAll(),t=this.config.slowThreshold;if(e.length===0)return{totalRenders:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,slowRenderCount:0,slowRenderRatio:0,byComponent:[]};let n=0,r=-1/0,o=1/0,s=0,l=new Map;for(let c of e){n+=c.duration,c.duration>r&&(r=c.duration),c.duration<o&&(o=c.duration),c.duration>t&&s++;let a=l.get(c.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(c.componentName,a)),a.renderCount++,a.totalDuration+=c.duration,c.duration>a.maxDuration&&(a.maxDuration=c.duration),c.duration<a.minDuration&&(a.minDuration=c.duration),c.duration>t&&a.slowCount++}let p=Array.from(l.entries()).map(([c,a])=>({componentName:c,renderCount:a.renderCount,avgDuration:a.totalDuration/a.renderCount,maxDuration:a.maxDuration===-1/0?0:a.maxDuration,minDuration:a.minDuration===1/0?0:a.minDuration,totalDuration:a.totalDuration,slowCount:a.slowCount})).sort((c,a)=>a.avgDuration-c.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:s,slowRenderRatio:s/e.length,byComponent:p}}getRenderTimeline(){let e=this.records.getAll(),t=this.config.slowThreshold;return e.map((n,r)=>({componentName:n.componentName,duration:n.duration,timestamp:n.timestamp,isSlow:n.duration>t,gap:r>0?n.timestamp-e[r-1].timestamp:-1}))}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}clear(){this.records.clear(),this.counter=0}destroy(){this.clear()}};var he=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},Ke=100,Xe=1e3,Ge=2,me=class{constructor(e){this.pending=new Map;this.counter=0;var t,n,r;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:Ke,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:Xe,outlierSigmaThreshold:(r=e==null?void 0:e.outlierSigmaThreshold)!=null?r:Ge},this.records=new he(this.config.bufferSize)}startBatch(e){return this.pending.has(e)?!1:(this.pending.set(e,Date.now()),!0)}endBatch(e){let t=this.pending.get(e);if(t===void 0)return null;let n=Date.now(),r=n-t;this.pending.delete(e);let o={name:e,startTime:t,endTime:n,duration:r,index:this.counter++};return this.records.push(o),o}getBatchStats(){let e=this.records.getAll();if(e.length===0)return{totalBatches:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,byName:[]};let t=0,n=-1/0,r=1/0,o=new Map;for(let l of e){t+=l.duration,l.duration>n&&(n=l.duration),l.duration<r&&(r=l.duration);let p=o.get(l.name);p||(p={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,p)),p.count++,p.totalDuration+=l.duration,l.duration>p.maxDuration&&(p.maxDuration=l.duration),l.duration<p.minDuration&&(p.minDuration=l.duration),p.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,p])=>{let c=p.totalDuration/p.count,a=0;for(let u of p.durations)a+=(u-c)*(u-c);a/=p.count;let d=Math.sqrt(a);return{name:l,count:p.count,avgDuration:c,maxDuration:p.maxDuration===-1/0?0:p.maxDuration,minDuration:p.minDuration===1/0?0:p.minDuration,totalDuration:p.totalDuration,stdDev:d}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:s}}detectAnomalousBatches(){let e=this.records.getAll();if(e.length===0)return[];let t=this.getBatchStats(),n=[],r=new Map;for(let o of t.byName)r.set(o.name,o);for(let o of e){let s=r.get(o.name);if(o.duration>this.config.slowThreshold){n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:"slow",description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u8D85\u8FC7\u6162\u64CD\u4F5C\u9608\u503C ${this.config.slowThreshold}ms`,deviationSigma:s&&s.stdDev>0?(o.duration-s.avgDuration)/s.stdDev:0});continue}if(s&&s.count>=2&&s.stdDev>0){let l=(o.duration-s.avgDuration)/s.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let p=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:p,description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u504F\u79BB\u5E73\u5747\u503C ${l.toFixed(1)} \u4E2A\u6807\u51C6\u5DEE`,deviationSigma:l})}}}return n.sort((o,s)=>o.timestamp-s.timestamp),n}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}getPendingBatches(){return Array.from(this.pending.keys())}clear(){this.records.clear(),this.pending.clear(),this.counter=0}destroy(){this.clear()}};var fe=class{constructor(e){this._installed=!1;this.app=null;var t,n,r,o,s,l;this.config={width:(t=e==null?void 0:e.width)!=null?t:420,height:(n=e==null?void 0:e.height)!=null?n:560,x:(r=e==null?void 0:e.x)!=null?r:0,y:(o=e==null?void 0:e.y)!=null?o:0,autoShow:(s=e==null?void 0:e.autoShow)!=null?s:!0,title:(l=e==null?void 0:e.title)!=null?l:"Lyt DevTools"},this.panel=new D({width:this.config.width,height:this.config.height,x:this.config.x,y:this.config.y,title:this.config.title}),this.componentTree=new B(this.panel,p=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new z(this.panel),this.eventTracker=new N(this.panel),this.timeTravel=new $(this.panel),this.panel.registerTabRenderer("components",p=>{this.componentTree.render(p)}),this.panel.registerTabRenderer("state",p=>{this.stateInspector.render(p)}),this.panel.registerTabRenderer("events",p=>{this.eventTracker.render(p)}),this.panel.registerTabRenderer("router",p=>{this.renderRouterTab(p)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,J(e,{onComponentCreated:n=>{this.componentTree.refresh()},onComponentUpdated:n=>{this.componentTree.refresh(),this.stateInspector.refresh()},onComponentUnmounted:n=>{this.componentTree.refresh()},onStateChanged:n=>{this.stateInspector.markChanged(`state.${n.path}`),this.stateInspector.refresh()},onEventEmitted:n=>{this.eventTracker.refresh()}}),this.panel.setConnected(!0)}show(){this.panel.show()}hide(){this.panel.hide()}toggle(){this.panel.toggle()}isVisible(){return this.panel.isVisible()}renderRouterTab(e){e.innerHTML="";let t=document.createElement("div");t.className="lyt-devtools-empty",t.style.cssText="padding: 40px 24px;",t.innerHTML=`
612
612
  <div style="font-size: 32px; margin-bottom: 12px;">\u{1F517}</div>
613
613
  <div style="color: #cdd6f4; font-size: 14px; margin-bottom: 8px; font-style: normal;">\u8DEF\u7531\u68C0\u67E5\u5668</div>
614
614
  <div style="color: #585b70; font-size: 12px;">
@@ -0,0 +1 @@
1
+ {"fileNames":["../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.full.d.ts","../src/batch-analyzer.ts","../src/component-profiler.ts","../src/hooks.ts","../src/panel.ts","../src/component-tree.ts","../src/event-panel.ts","../src/event-tracker.ts","../src/state-inspector.ts","../src/time-travel.ts","../src/route-panel.ts","../src/perf-collector.ts","../src/perf-panel.ts","../src/router-panel-enhanced.ts","../src/virtual-tree.ts","../src/memory-tracker.ts","../src/render-tracker.ts","../src/index.ts"],"fileIdsList":[[66,67],[64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],[65,74]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","signature":false,"impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","signature":false,"impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","signature":false,"impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","signature":false,"impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","signature":false,"impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","signature":false,"impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","signature":false,"impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","signature":false,"impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","signature":false,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","signature":false,"impliedFormat":1},{"version":"2a2de5b9459b3fc44decd9ce6100b72f1b002ef523126c1d3d8b2a4a63d74d78","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"f13f4b465c99041e912db5c44129a94588e1aafee35a50eab51044833f50b4ee","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"01a30f9e8582b369075c0808df71121e6855cb06fd8d3d39511d9ebb66405205","signature":false,"impliedFormat":1},{"version":"a6e041a2780a8aecbd78274c9ddcefb9f87f178efc1bb4c752747755f6f88d32","signature":false},{"version":"1980e611643cbb1e03db5429245d28ae907c1098bfeff814abe10522740bfb54","signature":false},{"version":"e02f404f1c2c8238b50a66e3e2601d99de949d807894f0e938cc693d376ef965","signature":false},{"version":"b5952addff5e2bb10647961e41e722feeaf11e25dcbeeecf62b827e2c86740dd","signature":false},{"version":"ed243a888f0b125f8404f2e25fa79a6f3ddddc3e5ae4ab33e21fb3b2596a4275","signature":false},{"version":"33c7bddaa41e86cd099c5326a515bb8614dd318c379e50c068f882214306bd55","signature":false},{"version":"08cb3609412f056a01a59e58dd59db3f671c7d73ddf70b5a38cd0dff45c86440","signature":false},{"version":"1ae68744045ed9c25bf0e3c54bb41f24a05c59485cc859775ccca2edae783a25","signature":false},{"version":"df766caaf137b6e009a5e0cdef1936e5b646c787f303d9e9b9ec55781bc2a902","signature":false},{"version":"4ec28514c6995550629804743d6288c13ccbbfc811433c0bb6d48bcdcf0a48b2","signature":false},{"version":"c848a83dcf3a660f3eda553d25f9efaa84288c3594c84f67491fa5311f119878","signature":false},{"version":"d7fe8ff5925664cfe1e96a14db0da41301b382fd3c81d3a775fb73c60ae0b374","signature":false},{"version":"9c844a007f3763d2b054fdd1faa45cf7772d8f0305f27b78ca4b799f60a44acf","signature":false},{"version":"7ef3d46ef5274dc468c796dd017f5764b6528033ffad230d142f0a76fda14a42","signature":false},{"version":"2ea5761a27a10b12199fb0f13012b23f70e229051bb967b451b8e132e849494b","signature":false},{"version":"c3b09e54200b221ab8804947e33a54a397ed9424c1c749481f3711d0ba7ff96a","signature":false},{"version":"4fd36dfd569bd844134322138cc8fce60741ec2c3ad340419762f64975b25b18","signature":false}],"root":[[64,80]],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"module":99,"noEmitOnError":false,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./types","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9,"useDefineForClassFields":true,"verbatimModuleSyntax":true},"referencedMap":[[68,1],[70,1],[80,2],[75,3],[71,1],[72,1]],"changeFileSet":[61,62,12,10,11,16,15,2,17,18,19,20,21,22,23,24,3,25,26,4,27,31,28,29,30,32,33,34,5,35,36,37,38,6,42,39,40,41,43,7,44,49,50,45,46,47,48,8,54,51,52,53,55,9,56,63,57,58,60,59,1,14,13,64,65,68,69,70,66,80,78,67,74,75,79,73,76,71,72,77],"version":"6.0.2"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Lyt.js DevTools - 批量操作分析器
3
+ *
4
+ * 追踪批量操作的执行时间和频率,提供统计分析和异常检测。
5
+ * 使用环形缓冲区限制内存占用。
6
+ *
7
+ * 纯原生零依赖实现。
8
+ */
9
+ /** 批量操作记录 */
10
+ export interface BatchRecord {
11
+ /** 操作名称 */
12
+ name: string;
13
+ /** 开始时间戳 */
14
+ startTime: number;
15
+ /** 结束时间戳 */
16
+ endTime: number;
17
+ /** 持续时间 (ms) */
18
+ duration: number;
19
+ /** 操作序号 */
20
+ index: number;
21
+ }
22
+ /** 批量操作统计(按名称分组) */
23
+ export interface BatchNameStats {
24
+ /** 操作名称 */
25
+ name: string;
26
+ /** 执行次数 */
27
+ count: number;
28
+ /** 平均持续时间 (ms) */
29
+ avgDuration: number;
30
+ /** 最大持续时间 (ms) */
31
+ maxDuration: number;
32
+ /** 最小持续时间 (ms) */
33
+ minDuration: number;
34
+ /** 总持续时间 (ms) */
35
+ totalDuration: number;
36
+ /** 标准差 (ms) */
37
+ stdDev: number;
38
+ }
39
+ /** 整体批量操作统计 */
40
+ export interface BatchStats {
41
+ /** 总操作次数 */
42
+ totalBatches: number;
43
+ /** 总持续时间 (ms) */
44
+ totalDuration: number;
45
+ /** 平均持续时间 (ms) */
46
+ avgDuration: number;
47
+ /** 最大持续时间 (ms) */
48
+ maxDuration: number;
49
+ /** 最小持续时间 (ms) */
50
+ minDuration: number;
51
+ /** 按名称分组的统计 */
52
+ byName: BatchNameStats[];
53
+ }
54
+ /** 异常批量操作条目 */
55
+ export interface AnomalousBatch {
56
+ /** 操作名称 */
57
+ name: string;
58
+ /** 持续时间 (ms) */
59
+ duration: number;
60
+ /** 时间戳 */
61
+ timestamp: number;
62
+ /** 异常类型 */
63
+ anomalyType: 'slow' | 'fast' | 'outlier';
64
+ /** 异常描述 */
65
+ description: string;
66
+ /** 偏离平均值的标准差倍数 */
67
+ deviationSigma: number;
68
+ }
69
+ /** 批量操作分析器配置 */
70
+ export interface BatchAnalyzerConfig {
71
+ /** 环形缓冲区容量,默认 100 */
72
+ bufferSize?: number;
73
+ /** 异常检测的慢操作阈值 (ms),默认 1000 */
74
+ slowThreshold?: number;
75
+ /** 异常检测的标准差倍数阈值,默认 2 */
76
+ outlierSigmaThreshold?: number;
77
+ }
78
+ /**
79
+ * 批量操作分析器
80
+ *
81
+ * 追踪批量操作的执行时间和频率,提供统计分析和异常检测。
82
+ */
83
+ export declare class BatchAnalyzer {
84
+ /** 批量操作记录缓冲区 */
85
+ private records;
86
+ /** 正在进行的操作映射 */
87
+ private pending;
88
+ /** 记录计数器(单调递增) */
89
+ private counter;
90
+ /** 配置 */
91
+ private readonly config;
92
+ constructor(config?: BatchAnalyzerConfig);
93
+ /**
94
+ * 开始一个批量操作
95
+ *
96
+ * @param name - 操作名称
97
+ * @returns 是否成功开始(如果同名操作已在进行中,返回 false)
98
+ */
99
+ startBatch(name: string): boolean;
100
+ /**
101
+ * 结束一个批量操作
102
+ *
103
+ * @param name - 操作名称
104
+ * @returns 操作记录,如果操作未开始则返回 null
105
+ */
106
+ endBatch(name: string): BatchRecord | null;
107
+ /**
108
+ * 获取批量操作统计
109
+ *
110
+ * @returns 批量操作统计信息
111
+ */
112
+ getBatchStats(): BatchStats;
113
+ /**
114
+ * 检测异常批量操作
115
+ *
116
+ * 基于以下规则检测异常:
117
+ * - 慢操作:持续时间超过慢操作阈值
118
+ * - 离群值:持续时间偏离同组平均值超过指定标准差倍数
119
+ *
120
+ * @returns 异常批量操作数组
121
+ */
122
+ detectAnomalousBatches(): AnomalousBatch[];
123
+ /**
124
+ * 获取所有批量操作记录
125
+ *
126
+ * @returns 批量操作记录数组
127
+ */
128
+ getRecords(): BatchRecord[];
129
+ /**
130
+ * 获取记录数量
131
+ *
132
+ * @returns 记录数量
133
+ */
134
+ getRecordCount(): number;
135
+ /**
136
+ * 获取正在进行的操作名称列表
137
+ *
138
+ * @returns 正在进行的操作名称数组
139
+ */
140
+ getPendingBatches(): string[];
141
+ /**
142
+ * 清除所有记录和进行中的操作
143
+ */
144
+ clear(): void;
145
+ /**
146
+ * 销毁分析器
147
+ */
148
+ destroy(): void;
149
+ }
150
+ //# sourceMappingURL=batch-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch-analyzer.d.ts","sourceRoot":"","sources":["../../src/batch-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,aAAa;AACb,MAAM,WAAW,WAAW;IAC1B,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAoB;AACpB,MAAM,WAAW,cAAc;IAC7B,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAe;AACf,MAAM,WAAW,UAAU;IACzB,YAAY;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe;IACf,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B;AAED,eAAe;AACf,MAAM,WAAW,cAAc;IAC7B,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW;IACX,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,WAAW;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAwED;;;;GAIG;AACH,qBAAa,aAAa;IACxB,gBAAgB;IAChB,OAAO,CAAC,OAAO,CAA0B;IACzC,gBAAgB;IAChB,OAAO,CAAC,OAAO,CAAkC;IACjD,kBAAkB;IAClB,OAAO,CAAC,OAAO,CAAa;IAC5B,SAAS;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;gBAE3C,MAAM,CAAC,EAAE,mBAAmB;IAaxC;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQjC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAsB1C;;;;OAIG;IACH,aAAa,IAAI,UAAU;IAsF3B;;;;;;;;OAQG;IACH,sBAAsB,IAAI,cAAc,EAAE;IAuD1C;;;;OAIG;IACH,UAAU,IAAI,WAAW,EAAE;IAI3B;;;;OAIG;IACH,cAAc,IAAI,MAAM;IAIxB;;;;OAIG;IACH,iBAAiB,IAAI,MAAM,EAAE;IAI7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,OAAO,IAAI,IAAI;CAGhB"}