@lytjs/devtools 4.0.0 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var pe=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var Pe=(s,e)=>{for(var t in e)pe(s,t,{get:e[t],enumerable:!0})},De=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ke(e))!Le.call(s,r)&&r!==t&&pe(s,r,{get:()=>e[r],enumerable:!(n=Me(e,r))||n.enumerable});return s};var He=s=>De(pe({},"__esModule",{value:!0}),s);var it={};Pe(it,{BatchAnalyzer:()=>ie,ComponentProfiler:()=>A,ComponentTreeInspector:()=>I,DevTools:()=>ae,DevToolsPanel:()=>D,EventPanel:()=>te,EventTracker:()=>z,MemoryTracker:()=>oe,PerfPanel:()=>ee,PerformanceCollector:()=>B,RenderTracker:()=>se,RoutePanel:()=>Z,RouterPanel:()=>ne,StateInspector:()=>N,TimeTravelDebugger:()=>$,VirtualComponentTree:()=>re,clearRecords:()=>G,connectToApp:()=>_,createDevTools:()=>st,disconnect:()=>Q,getAllComponents:()=>k,getChildComponents:()=>j,getComponentById:()=>H,getComponentCount:()=>Se,getComponentEvents:()=>Ce,getComponentStateChanges:()=>V,getEventRecords:()=>J,getRootComponent:()=>q,getSelectedComponent:()=>Y,getSelectedComponentId:()=>L,getStateChangeRecords:()=>Te,isAppConnected:()=>Ee,refreshComponentTree:()=>X,selectComponent:()=>W,setComponentState:()=>K});module.exports=He(it);var Ie=`
1
+ "use strict";var pe=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var Pe=(s,e)=>{for(var t in e)pe(s,t,{get:e[t],enumerable:!0})},De=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ke(e))!Le.call(s,r)&&r!==t&&pe(s,r,{get:()=>e[r],enumerable:!(n=Me(e,r))||n.enumerable});return s};var He=s=>De(pe({},"__esModule",{value:!0}),s);var it={};Pe(it,{BatchAnalyzer:()=>ie,ComponentProfiler:()=>A,ComponentTreeInspector:()=>I,DevTools:()=>ae,DevToolsPanel:()=>D,EventPanel:()=>te,EventTracker:()=>$,MemoryTracker:()=>oe,PerfPanel:()=>ee,PerformanceCollector:()=>B,RenderTracker:()=>se,RoutePanel:()=>Z,RouterPanel:()=>ne,StateInspector:()=>N,TimeTravelDebugger:()=>z,VirtualComponentTree:()=>re,clearRecords:()=>G,connectToApp:()=>_,createDevTools:()=>st,disconnect:()=>Q,getAllComponents:()=>k,getChildComponents:()=>j,getComponentById:()=>H,getComponentCount:()=>Se,getComponentEvents:()=>Ce,getComponentStateChanges:()=>V,getEventRecords:()=>J,getRootComponent:()=>q,getSelectedComponent:()=>Y,getSelectedComponentId:()=>L,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
- `,Ne=[{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.onWindowResize=()=>{let e=this.panelEl.getBoundingClientRect(),t=window.innerWidth-100,n=window.innerHeight-36;e.left>t&&(this.panelEl.style.left=`${t}px`),e.top>n&&(this.panelEl.style.top=`${n}px`)};var t,n,r,o,i,l,d,p;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:(o=e==null?void 0:e.x)!=null?o:window.innerWidth-((r=e==null?void 0:e.width)!=null?r:420)-20,y:(i=e==null?void 0:e.y)!=null?i:60,minWidth:(l=e==null?void 0:e.minWidth)!=null?l:320,minHeight:(d=e==null?void 0:e.minHeight)!=null?d:200,title:(p=e==null?void 0:e.title)!=null?p:"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},this.styleEl=document.createElement("style"),this.styleEl.textContent=Ie,document.head.appendChild(this.styleEl),this.panelEl=this.createPanelElement(),this.headerEl=this.panelEl.querySelector(".lyt-devtools-header"),this.tabsEl=this.panelEl.querySelector(".lyt-devtools-tabs"),this.contentEl=this.panelEl.querySelector(".lyt-devtools-content"),this.statusbarEl=this.panelEl.querySelector(".lyt-devtools-statusbar"),this.statusLeftEl=this.statusbarEl.querySelector(".lyt-devtools-status-left"),this.statusRightEl=this.statusbarEl.querySelector(".lyt-devtools-status-right"),document.body.appendChild(this.panelEl),this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize)}createPanelElement(){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 i=document.createElement("button");i.className="lyt-devtools-btn lyt-devtools-btn-close",i.textContent="\u2715",i.title="\u5173\u95ED\u9762\u677F",i.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(i),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Ne){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset.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 d=document.createElement("div");d.className="lyt-devtools-content";let p=document.createElement("div");p.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 c=document.createElement("span");c.className="lyt-devtools-status-right",c.textContent="v0.0.1",p.appendChild(a),p.appendChild(c);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(d),e.appendChild(p),e.appendChild(u),e}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(n=>{n.classList.toggle("active",n.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){this.contentEl.innerHTML="";let e=this.tabRenderers.get(this.activeTab);e?e(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,this.panelEl.style.display="flex"}hide(){this._visible=!1,this.panelEl.style.display="none"}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){this.headerEl.addEventListener("mousedown",e=>{e.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=e.clientX,this.dragState.startY=e.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,e.preventDefault())}),document.addEventListener("mousemove",e=>{if(!this.dragState.isDragging)return;let t=e.clientX-this.dragState.startX,n=e.clientY-this.dragState.startY,r=this.dragState.startLeft+t,o=this.dragState.startTop+n;r=Math.max(0,Math.min(r,window.innerWidth-100)),o=Math.max(0,Math.min(o,window.innerHeight-36)),this.panelEl.style.left=`${r}px`,this.panelEl.style.top=`${o}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1})}bindResizeEvents(){this.panelEl.querySelector(".lyt-devtools-resize-handle").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),i=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${i}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1})}bindKeyboardEvents(){document.addEventListener("keydown",e=>{e.ctrlKey&&e.shiftKey&&e.key==="D"&&(e.preventDefault(),this.toggle()),e.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){this.statusLeftEl.innerHTML=e}setStatusRight(e){this.statusRightEl.textContent=e}setConnected(e){let t=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");t&&t.classList.toggle("disconnected",!e)}highlightElement(e){if(this.clearHighlight(),!e)return;this.highlightOverlay=document.createElement("div"),this.highlightOverlay.style.cssText=`
285
+ `,Ne=[{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.onWindowResize=()=>{let e=this.panelEl.getBoundingClientRect(),t=window.innerWidth-100,n=window.innerHeight-36;e.left>t&&(this.panelEl.style.left=`${t}px`),e.top>n&&(this.panelEl.style.top=`${n}px`)};var t,n,r,o,i,l,d,p;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:(o=e==null?void 0:e.x)!=null?o:window.innerWidth-((r=e==null?void 0:e.width)!=null?r:420)-20,y:(i=e==null?void 0:e.y)!=null?i:60,minWidth:(l=e==null?void 0:e.minWidth)!=null?l:320,minHeight:(d=e==null?void 0:e.minHeight)!=null?d:200,title:(p=e==null?void 0:e.title)!=null?p:"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},this.styleEl=document.createElement("style"),this.styleEl.textContent=Ie,document.head.appendChild(this.styleEl),this.panelEl=this.createPanelElement(),this.headerEl=this.panelEl.querySelector(".lyt-devtools-header")||document.createElement("div"),this.tabsEl=this.panelEl.querySelector(".lyt-devtools-tabs")||document.createElement("div"),this.contentEl=this.panelEl.querySelector(".lyt-devtools-content")||document.createElement("div"),this.statusbarEl=this.panelEl.querySelector(".lyt-devtools-statusbar")||document.createElement("div"),this.statusLeftEl=this.statusbarEl.querySelector(".lyt-devtools-status-left")||document.createElement("span"),this.statusRightEl=this.statusbarEl.querySelector(".lyt-devtools-status-right")||document.createElement("span"),document.body.appendChild(this.panelEl),this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize)}createPanelElement(){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 i=document.createElement("button");i.className="lyt-devtools-btn lyt-devtools-btn-close",i.textContent="\u2715",i.title="\u5173\u95ED\u9762\u677F",i.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(i),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Ne){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset||(f.dataset={}),f.dataset.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 d=document.createElement("div");d.className="lyt-devtools-content";let p=document.createElement("div");p.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 c=document.createElement("span");c.className="lyt-devtools-status-right",c.textContent="v0.0.1",p.appendChild(a),p.appendChild(c);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(d),e.appendChild(p),e.appendChild(u),e}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(n=>{n.dataset||(n.dataset={}),n.classList.toggle("active",n.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){this.contentEl.innerHTML="";let e=this.tabRenderers.get(this.activeTab);e?e(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,this.panelEl.style.display="flex"}hide(){this._visible=!1,this.panelEl.style.display="none"}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){this.headerEl.addEventListener("mousedown",e=>{e.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=e.clientX,this.dragState.startY=e.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,e.preventDefault())}),document.addEventListener("mousemove",e=>{if(!this.dragState.isDragging)return;let t=e.clientX-this.dragState.startX,n=e.clientY-this.dragState.startY,r=this.dragState.startLeft+t,o=this.dragState.startTop+n;r=Math.max(0,Math.min(r,window.innerWidth-100)),o=Math.max(0,Math.min(o,window.innerHeight-36)),this.panelEl.style.left=`${r}px`,this.panelEl.style.top=`${o}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1})}bindResizeEvents(){let e=this.panelEl.querySelector(".lyt-devtools-resize-handle")||document.createElement("div");e&&e.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),i=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${i}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1})}bindKeyboardEvents(){document.addEventListener("keydown",e=>{e.ctrlKey&&e.shiftKey&&e.key==="D"&&(e.preventDefault(),this.toggle()),e.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){this.statusLeftEl.innerHTML=e}setStatusRight(e){this.statusRightEl.textContent=e}setConnected(e){let t=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");t&&t.classList.toggle("disconnected",!e)}highlightElement(e){if(this.clearHighlight(),!e)return;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 t=e.getBoundingClientRect();this.highlightOverlay.style.left=`${t.left}px`,this.highlightOverlay.style.top=`${t.top}px`,this.highlightOverlay.style.width=`${t.width}px`,this.highlightOverlay.style.height=`${t.height}px`,document.body.appendChild(this.highlightOverlay)}clearHighlight(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){this.styleEl.remove(),this.panelEl.remove(),this.clearHighlight(),window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],w=[],xe=0,F=null,C={},U=!1;function ze(){return`comp_${++xe}`}function $e(){return`evt_${++xe}`}function ye(s){var t;if(!s)return"Unknown";let e=s.type||s.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 S(s){if(s===null||typeof s!="object")return s;if(Array.isArray(s))return s.map(t=>S(t));let e={};for(let t of Object.keys(s))e[t]=S(s[t]);return e}function Be(s,e){return s===e?!1:typeof s!=typeof e?!0:s===null||e===null?s!==e:typeof s=="object"?JSON.stringify(s)!==JSON.stringify(e):s!==e}function Ae(s,e){let t=e.split("."),n=s;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Fe(s,e,t){let n=e.split("."),r=s;for(let o=0;o<n.length-1;o++)(r[n[o]]==null||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function _(s,e){U||(e&&Object.assign(C,e),U=!0,Ue(s),s._instance&&(O(s._instance,null),ue()))}function Ue(s){let e=s.mount.bind(s);s.mount=function(t){let n=e(t);return s._instance&&(O(s._instance,null),ue()),n}}function O(s,e){var o,i,l,d,p,a,c,u;if(!s)return;let t=be(s),n=!t;if(n){let h=ze();t={id:h,name:ye(s),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=s.isMounted)!=null?o:!1,isUnmounted:(i=s.isUnmounted)!=null?i:!1,el:(l=s.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:s},E.set(h,t)}else t.parentId=e,t.name=ye(s),t.isMounted=(d=s.isMounted)!=null?d:!1,t.isUnmounted=(p=s.isUnmounted)!=null?p:!1,t.el=(a=s.el)!=null?a:null,t.lastUpdateTime=Date.now();s.props&&(t.props=S(s.props)),s.state&&(t.state=S(s.state)),s.computedCache&&(t.computed=S(s.computedCache)),n&&s.state&&typeof s.state=="object"&&_e(t.id,s),n&&s.emit&&typeof s.emit=="function"&&Oe(t.id,s),n?(c=C.onComponentCreated)==null||c.call(C,t):(u=C.onComponentUpdated)==null||u.call(C,t);let r=s.subTree;r&&ve(r,t.id)}function ve(s,e){if(s){if(s.component){O(s.component,e);let t=E.get(e);if(t&&!t.childIds.includes(s.component.id||s.component._id)){let n=qe(s.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(s.children&&Array.isArray(s.children))for(let t of s.children)t&&typeof t=="object"&&ve(t,e)}}function _e(s,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(s);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,i,l){var a;let d=o[i],p=Reflect.set(o,i,l);if(Be(d,l)){let c=String(i),u={componentId:s,componentName:n.name,path:c,oldValue:S(d),newValue:S(l),timestamp:Date.now()};w.push(u),w.length>1e3&&w.splice(0,w.length-1e3),n.state=S(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return p}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function Oe(s,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(s);n&&(e.emit=function(r,...o){var l;let i={id:$e(),name:r,timestamp:Date.now(),args:S(o),componentId:s,componentName:n.name};return M.push(i),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,i),t.call(this,r,...o)})}function ue(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function be(s){for(let e of E.values())if(e.instance===s)return e;return null}function qe(s){let e=be(s);return e?e.id:null}function k(){return Array.from(E.values())}function q(){for(let s of E.values())if(s.parentId===null)return s;return null}function H(s){var e;return(e=E.get(s))!=null?e:null}function j(s){let e=E.get(s);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function J(){return[...M]}function Te(){return[...w]}function V(s){return w.filter(e=>e.componentId===s)}function Ce(s){return M.filter(e=>e.componentId===s)}function W(s){F=s}function Y(){var s;return F&&(s=E.get(F))!=null?s:null}function L(){return F}function K(s,e,t){var l;let n=E.get(s);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 i={componentId:s,componentName:n.name,path:e,oldValue:S(o),newValue:S(t),timestamp:Date.now()};return w.push(i),n.state=S(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,i),!0}function X(s){E.clear(),s._instance&&(O(s._instance,null),ue())}function G(){M.length=0,w.length=0}function Q(){E.clear(),M.length=0,w.length=0,F=null,U=!1}function Ee(){return U}function Se(){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=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 i=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(i),d=r.id.toLowerCase().includes(i);if(!l&&!d)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 i=t.get(o);i.children.push(r),r.depth=i.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=L(),i=t.id===o,l=document.createElement("div");l.className="lyt-tree-node",l.style.cssText=`
293
+ `;let t=e.getBoundingClientRect();this.highlightOverlay.style.left=`${t.left}px`,this.highlightOverlay.style.top=`${t.top}px`,this.highlightOverlay.style.width=`${t.width}px`,this.highlightOverlay.style.height=`${t.height}px`,document.body.appendChild(this.highlightOverlay)}clearHighlight(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),window.removeEventListener&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],w=[],xe=0,F=null,C={},U=!1;function $e(){return`comp_${++xe}`}function ze(){return`evt_${++xe}`}function ye(s){var t;if(!s)return"Unknown";let e=s.type||s.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 S(s){if(s===null||typeof s!="object")return s;if(Array.isArray(s))return s.map(t=>S(t));let e={};for(let t of Object.keys(s))e[t]=S(s[t]);return e}function Be(s,e){return s===e?!1:typeof s!=typeof e?!0:s===null||e===null?s!==e:typeof s=="object"?JSON.stringify(s)!==JSON.stringify(e):s!==e}function Ae(s,e){let t=e.split("."),n=s;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Fe(s,e,t){let n=e.split("."),r=s;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 _(s,e){U||(e&&Object.assign(C,e),U=!0,Ue(s),s._instance&&(O(s._instance,null),ue()))}function Ue(s){let e=s.mount.bind(s);s.mount=function(t){let n=e(t);return s._instance&&(O(s._instance,null),ue()),n}}function O(s,e){var o,i,l,d,p,a,c,u;if(!s)return;let t=be(s),n=!t;if(n){let h=$e();t={id:h,name:ye(s),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=s.isMounted)!=null?o:!1,isUnmounted:(i=s.isUnmounted)!=null?i:!1,el:(l=s.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:s},E.set(h,t)}else t.parentId=e,t.name=ye(s),t.isMounted=(d=s.isMounted)!=null?d:!1,t.isUnmounted=(p=s.isUnmounted)!=null?p:!1,t.el=(a=s.el)!=null?a:null,t.lastUpdateTime=Date.now();s.props&&(t.props=S(s.props)),s.state&&(t.state=S(s.state)),s.computedCache&&(t.computed=S(s.computedCache)),n&&s.state&&typeof s.state=="object"&&_e(t.id,s),n&&s.emit&&typeof s.emit=="function"&&Oe(t.id,s),n?(c=C.onComponentCreated)==null||c.call(C,t):(u=C.onComponentUpdated)==null||u.call(C,t);let r=s.subTree;r&&ve(r,t.id)}function ve(s,e){if(s){if(s.component){O(s.component,e);let t=E.get(e);if(t&&!t.childIds.includes(s.component.id||s.component._id)){let n=qe(s.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(s.children&&Array.isArray(s.children))for(let t of s.children)t&&typeof t=="object"&&ve(t,e)}}function _e(s,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(s);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,i,l){var a;let d=o[i],p=Reflect.set(o,i,l);if(Be(d,l)){let c=String(i),u={componentId:s,componentName:n.name,path:c,oldValue:S(d),newValue:S(l),timestamp:Date.now()};w.push(u),w.length>1e3&&w.splice(0,w.length-1e3),n.state=S(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return p}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function Oe(s,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(s);n&&(e.emit=function(r,...o){var l;let i={id:ze(),name:r,timestamp:Date.now(),args:S(o),componentId:s,componentName:n.name};return M.push(i),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,i),t.call(this,r,...o)})}function ue(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function be(s){for(let e of E.values())if(e.instance===s)return e;return null}function qe(s){let e=be(s);return e?e.id:null}function k(){return Array.from(E.values())}function q(){for(let s of E.values())if(s.parentId===null)return s;return null}function H(s){var e;return(e=E.get(s))!=null?e:null}function j(s){let e=E.get(s);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function J(){return[...M]}function Te(){return[...w]}function V(s){return w.filter(e=>e.componentId===s)}function Ce(s){return M.filter(e=>e.componentId===s)}function W(s){F=s}function Y(){var s;return F&&(s=E.get(F))!=null?s:null}function L(){return F}function K(s,e,t){var l;let n=E.get(s);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 i={componentId:s,componentName:n.name,path:e,oldValue:S(o),newValue:S(t),timestamp:Date.now()};return w.push(i),n.state=S(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,i),!0}function X(s){E.clear(),s._instance&&(O(s._instance,null),ue())}function G(){M.length=0,w.length=0}function Q(){E.clear(),M.length=0,w.length=0,F=null,U=!1}function Ee(){return U}function Se(){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=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 i=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(i),d=r.id.toLowerCase().includes(i);if(!l&&!d)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 i=t.get(o);i.children.push(r),r.depth=i.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=L(),i=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;
@@ -429,7 +429,7 @@
429
429
  <span style="color: #6c7086;">\u2192</span>
430
430
  <span style="color: #a6e3a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${he(i.newValue,40)}</span>
431
431
  </div>
432
- `,n.appendChild(l)}this.container.appendChild(n)}markChanged(e){this.changedPaths.set(e,Date.now()),this.highlightTimer&&clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>{this.changedPaths.clear(),this.renderState()},3e3)}refresh(){this.renderState()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.highlightTimer&&clearTimeout(this.highlightTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.expandedPaths.clear(),this.changedPaths.clear()}};function Je(s,e=60){if(s===null)return"null";if(s===void 0)return"undefined";if(typeof s=="string")return s.length>e?`"${s.slice(0,e)}..."`:`"${s}"`;if(typeof s=="function")return`fn(${s.name||"anonymous"})`;if(typeof s=="object")try{let t=JSON.stringify(s);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(s)}function Re(s){let e=new Date(s);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}function Ve(s){let t=Date.now()-s;return t<1e3?`${t}ms \u524D`:t<6e4?`${Math.floor(t/1e3)}s \u524D`:`${Math.floor(t/6e4)}m \u524D`}var z=class{constructor(e){this.container=null;this.nameFilter="";this.componentFilter="";this.paused=!1;this.selectedEventId=null;this.updateTimer=null;this.autoScrollTimer=null;this.onUpdate=()=>{this.paused||(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderEvents()},100))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderEvents()}renderEvents(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 6px; margin-bottom: 8px; align-items: center;";let t=document.createElement("input");t.type="text",t.className="lyt-devtools-search",t.placeholder="\u6309\u4E8B\u4EF6\u540D\u79F0\u8FC7\u6EE4...",t.value=this.nameFilter,t.style.marginBottom="0",t.style.flex="1",t.addEventListener("input",a=>{this.nameFilter=a.target.value,this.renderEvents()}),e.appendChild(t);let n=document.createElement("input");n.type="text",n.className="lyt-devtools-search",n.placeholder="\u6309\u7EC4\u4EF6\u8FC7\u6EE4...",n.value=this.componentFilter,n.style.marginBottom="0",n.style.flex="1",n.addEventListener("input",a=>{this.componentFilter=a.target.value,this.renderEvents()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=`
432
+ `,n.appendChild(l)}this.container.appendChild(n)}markChanged(e){this.changedPaths.set(e,Date.now()),this.highlightTimer&&clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>{this.changedPaths.clear(),this.renderState()},3e3)}refresh(){this.renderState()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.highlightTimer&&clearTimeout(this.highlightTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.expandedPaths.clear(),this.changedPaths.clear()}};function Je(s,e=60){if(s===null)return"null";if(s===void 0)return"undefined";if(typeof s=="string")return s.length>e?`"${s.slice(0,e)}..."`:`"${s}"`;if(typeof s=="function")return`fn(${s.name||"anonymous"})`;if(typeof s=="object")try{let t=JSON.stringify(s);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(s)}function Re(s){let e=new Date(s);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}function Ve(s){let t=Date.now()-s;return t<1e3?`${t}ms \u524D`:t<6e4?`${Math.floor(t/1e3)}s \u524D`:`${Math.floor(t/6e4)}m \u524D`}var $=class{constructor(e){this.container=null;this.nameFilter="";this.componentFilter="";this.paused=!1;this.selectedEventId=null;this.updateTimer=null;this.autoScrollTimer=null;this.onUpdate=()=>{this.paused||(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderEvents()},100))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderEvents()}renderEvents(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 6px; margin-bottom: 8px; align-items: center;";let t=document.createElement("input");t.type="text",t.className="lyt-devtools-search",t.placeholder="\u6309\u4E8B\u4EF6\u540D\u79F0\u8FC7\u6EE4...",t.value=this.nameFilter,t.style.marginBottom="0",t.style.flex="1",t.addEventListener("input",a=>{this.nameFilter=a.target.value,this.renderEvents()}),e.appendChild(t);let n=document.createElement("input");n.type="text",n.className="lyt-devtools-search",n.placeholder="\u6309\u7EC4\u4EF6\u8FC7\u6EE4...",n.value=this.componentFilter,n.style.marginBottom="0",n.style.flex="1",n.addEventListener("input",a=>{this.componentFilter=a.target.value,this.renderEvents()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=`
433
433
  background: ${this.paused?"#f38ba8":"transparent"};
434
434
  color: ${this.paused?"#1e1e2e":"#a6adc8"};
435
435
  border: 1px solid ${this.paused?"#f38ba8":"#313244"};
@@ -506,7 +506,7 @@
506
506
  <span style="color: #6c7086;">[${d}]</span>
507
507
  <span style="color: #585b70; margin: 0 4px;">${c}:</span>
508
508
  <span style="color: #a6e3a1; white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(u)}</span>
509
- `,t.appendChild(p)}}else{let l=document.createElement("div");l.style.cssText="color: #585b70; font-size: 11px; font-style: italic;",l.textContent="\u6B64\u4E8B\u4EF6\u65E0\u53C2\u6570\u3002",t.appendChild(l)}this.container.appendChild(t)}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}clearEvents(){this.selectedEventId=null,this.renderEvents()}setPaused(e){this.paused=e}isPaused(){return this.paused}refresh(){this.renderEvents()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.autoScrollTimer&&clearInterval(this.autoScrollTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null}};function P(s){if(s===null||typeof s!="object")return s;if(s instanceof Map){let t=new Map;for(let[n,r]of s)t.set(n,P(r));return t}if(Array.isArray(s))return s.map(t=>P(t));let e={};for(let t of Object.keys(s))e[t]=P(s[t]);return e}function We(s){let e=new Date(s);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}var $=class{constructor(e){this.container=null;this.snapshots=[];this.snapshotCounter=0;this.maxSnapshots=100;this.currentIndex=-1;this.playState="stopped";this.playSpeed=500;this.playTimer=null;this.autoSnapshot=!0;this.updateTimer=null;this.onUpdate=()=>{this.autoSnapshot&&(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.takeSnapshot("\u81EA\u52A8\u5FEB\u7167")},300))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}takeSnapshot(e,t){let n=k(),r=new Map;for(let i of n)r.set(i.id,{id:i.id,name:i.name,state:P(i.state),props:P(i.props),computed:P(i.computed),isMounted:i.isMounted});let o={id:++this.snapshotCounter,timestamp:Date.now(),description:e||`\u5FEB\u7167 #${this.snapshotCounter}`,components:r,trigger:t};return this.snapshots.push(o),this.snapshots.length>this.maxSnapshots&&this.snapshots.splice(0,this.snapshots.length-this.maxSnapshots),(this.currentIndex===-1||this.currentIndex===this.snapshots.length-2)&&(this.currentIndex=this.snapshots.length-1),o}getSnapshots(){return[...this.snapshots]}getSnapshot(e){var t;return(t=this.snapshots[e])!=null?t:null}getCurrentIndex(){return this.currentIndex}clearSnapshots(){this.snapshots=[],this.snapshotCounter=0,this.currentIndex=-1,this.stopPlayback(),this.renderTimeTravel()}setAutoSnapshot(e){this.autoSnapshot=e}travelTo(e){e<0||e>=this.snapshots.length||(this.currentIndex=e,this.renderTimeTravel())}stepBack(){this.currentIndex>0&&this.travelTo(this.currentIndex-1)}stepForward(){this.currentIndex<this.snapshots.length-1&&this.travelTo(this.currentIndex+1)}goToLatest(){this.currentIndex=-1,this.stopPlayback(),this.renderTimeTravel()}restoreSnapshot(e){let t=this.snapshots[e];if(!t)return!1;for(let[n,r]of t.components){let o=H(n);if(!(!o||!o.instance)&&o.instance.state&&typeof o.instance.state=="object"){let i=Object.keys(r.state);for(let l of i)try{o.instance.state[l]=P(r.state[l])}catch(d){}}}return!0}startPlayback(){this.playState!=="playing"&&((this.currentIndex===-1||this.currentIndex>=this.snapshots.length-1)&&(this.currentIndex=0),this.playState="playing",this.renderTimeTravel(),this.playTimer=setInterval(()=>{this.currentIndex<this.snapshots.length-1?(this.currentIndex++,this.renderTimeTravel()):this.stopPlayback()},this.playSpeed))}pausePlayback(){this.playState==="playing"&&(this.playState="paused",this.playTimer&&(clearInterval(this.playTimer),this.playTimer=null),this.renderTimeTravel())}stopPlayback(){this.playState="stopped",this.playTimer&&(clearInterval(this.playTimer),this.playTimer=null),this.renderTimeTravel()}setPlaySpeed(e){this.playSpeed=e,this.playState==="playing"&&(this.pausePlayback(),this.startPlayback())}getPlayState(){return this.playState}render(e){this.container=e,this.renderTimeTravel()}renderTimeTravel(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 4px; margin-bottom: 8px; align-items: center; flex-wrap: wrap;";let t=document.createElement("button");t.style.cssText=this.createButtonStyle("#a6e3a1","#1e1e2e"),t.textContent="\u{1F4F8} \u5FEB\u7167",t.title="\u624B\u52A8\u521B\u5EFA\u5FEB\u7167",t.addEventListener("click",()=>{this.takeSnapshot("\u624B\u52A8\u5FEB\u7167"),this.renderTimeTravel()}),e.appendChild(t);let n=document.createElement("button");n.style.cssText=this.createButtonStyle("#89b4fa","#1e1e2e"),n.textContent="\u{1F504} \u6700\u65B0",n.title="\u56DE\u5230\u6700\u65B0\u72B6\u6001",n.addEventListener("click",()=>{this.goToLatest()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=this.createButtonStyle("#f38ba8","#1e1e2e"),r.textContent="\u{1F5D1} \u6E05\u7A7A",r.title="\u6E05\u7A7A\u6240\u6709\u5FEB\u7167",r.addEventListener("click",()=>{this.clearSnapshots()}),e.appendChild(r);let o=document.createElement("label");o.style.cssText="display: flex; align-items: center; gap: 4px; font-size: 11px; color: #a6adc8; margin-left: 8px; cursor: pointer;";let i=document.createElement("input");i.type="checkbox",i.checked=this.autoSnapshot,i.style.cssText="cursor: pointer;",i.addEventListener("change",()=>{this.autoSnapshot=i.checked}),o.appendChild(i),o.appendChild(document.createTextNode("\u81EA\u52A8\u5FEB\u7167")),e.appendChild(o),this.container.appendChild(e),this.snapshots.length>0&&this.renderPlaybackControls(this.container),this.renderSnapshotList(this.container);let l=this.currentIndex===-1;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${this.snapshots.length} \u4E2A\u5FEB\u7167</span><span style="color: #585b70;">|</span><span>${l?"\u5B9E\u65F6":`\u5386\u53F2 #${this.currentIndex+1}`}</span>`)}renderPlaybackControls(e){let t=document.createElement("div");t.style.cssText=`
509
+ `,t.appendChild(p)}}else{let l=document.createElement("div");l.style.cssText="color: #585b70; font-size: 11px; font-style: italic;",l.textContent="\u6B64\u4E8B\u4EF6\u65E0\u53C2\u6570\u3002",t.appendChild(l)}this.container.appendChild(t)}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}clearEvents(){this.selectedEventId=null,this.renderEvents()}setPaused(e){this.paused=e}isPaused(){return this.paused}refresh(){this.renderEvents()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.autoScrollTimer&&clearInterval(this.autoScrollTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null}};function P(s){if(s===null||typeof s!="object")return s;if(s instanceof Map){let t=new Map;for(let[n,r]of s)t.set(n,P(r));return t}if(Array.isArray(s))return s.map(t=>P(t));let e={};for(let t of Object.keys(s))e[t]=P(s[t]);return e}function We(s){let e=new Date(s);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}var z=class{constructor(e){this.container=null;this.snapshots=[];this.snapshotCounter=0;this.maxSnapshots=100;this.currentIndex=-1;this.playState="stopped";this.playSpeed=500;this.playTimer=null;this.autoSnapshot=!0;this.updateTimer=null;this.onUpdate=()=>{this.autoSnapshot&&(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.takeSnapshot("\u81EA\u52A8\u5FEB\u7167")},300))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}takeSnapshot(e,t){let n=k(),r=new Map;for(let i of n)r.set(i.id,{id:i.id,name:i.name,state:P(i.state),props:P(i.props),computed:P(i.computed),isMounted:i.isMounted});let o={id:++this.snapshotCounter,timestamp:Date.now(),description:e||`\u5FEB\u7167 #${this.snapshotCounter}`,components:r,trigger:t};return this.snapshots.push(o),this.snapshots.length>this.maxSnapshots&&this.snapshots.splice(0,this.snapshots.length-this.maxSnapshots),(this.currentIndex===-1||this.currentIndex===this.snapshots.length-2)&&(this.currentIndex=this.snapshots.length-1),o}getSnapshots(){return[...this.snapshots]}getSnapshot(e){var t;return(t=this.snapshots[e])!=null?t:null}getCurrentIndex(){return this.currentIndex}clearSnapshots(){this.snapshots=[],this.snapshotCounter=0,this.currentIndex=-1,this.stopPlayback(),this.renderTimeTravel()}setAutoSnapshot(e){this.autoSnapshot=e}travelTo(e){e<0||e>=this.snapshots.length||(this.currentIndex=e,this.renderTimeTravel())}stepBack(){this.currentIndex>0&&this.travelTo(this.currentIndex-1)}stepForward(){this.currentIndex<this.snapshots.length-1&&this.travelTo(this.currentIndex+1)}goToLatest(){this.currentIndex=-1,this.stopPlayback(),this.renderTimeTravel()}restoreSnapshot(e){let t=this.snapshots[e];if(!t)return!1;for(let[n,r]of t.components){let o=H(n);if(!(!o||!o.instance)&&o.instance.state&&typeof o.instance.state=="object"){let i=Object.keys(r.state);for(let l of i)try{o.instance.state[l]=P(r.state[l])}catch(d){}}}return!0}startPlayback(){this.playState!=="playing"&&((this.currentIndex===-1||this.currentIndex>=this.snapshots.length-1)&&(this.currentIndex=0),this.playState="playing",this.renderTimeTravel(),this.playTimer=setInterval(()=>{this.currentIndex<this.snapshots.length-1?(this.currentIndex++,this.renderTimeTravel()):this.stopPlayback()},this.playSpeed))}pausePlayback(){this.playState==="playing"&&(this.playState="paused",this.playTimer&&(clearInterval(this.playTimer),this.playTimer=null),this.renderTimeTravel())}stopPlayback(){this.playState="stopped",this.playTimer&&(clearInterval(this.playTimer),this.playTimer=null),this.renderTimeTravel()}setPlaySpeed(e){this.playSpeed=e,this.playState==="playing"&&(this.pausePlayback(),this.startPlayback())}getPlayState(){return this.playState}render(e){this.container=e,this.renderTimeTravel()}renderTimeTravel(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 4px; margin-bottom: 8px; align-items: center; flex-wrap: wrap;";let t=document.createElement("button");t.style.cssText=this.createButtonStyle("#a6e3a1","#1e1e2e"),t.textContent="\u{1F4F8} \u5FEB\u7167",t.title="\u624B\u52A8\u521B\u5EFA\u5FEB\u7167",t.addEventListener("click",()=>{this.takeSnapshot("\u624B\u52A8\u5FEB\u7167"),this.renderTimeTravel()}),e.appendChild(t);let n=document.createElement("button");n.style.cssText=this.createButtonStyle("#89b4fa","#1e1e2e"),n.textContent="\u{1F504} \u6700\u65B0",n.title="\u56DE\u5230\u6700\u65B0\u72B6\u6001",n.addEventListener("click",()=>{this.goToLatest()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=this.createButtonStyle("#f38ba8","#1e1e2e"),r.textContent="\u{1F5D1} \u6E05\u7A7A",r.title="\u6E05\u7A7A\u6240\u6709\u5FEB\u7167",r.addEventListener("click",()=>{this.clearSnapshots()}),e.appendChild(r);let o=document.createElement("label");o.style.cssText="display: flex; align-items: center; gap: 4px; font-size: 11px; color: #a6adc8; margin-left: 8px; cursor: pointer;";let i=document.createElement("input");i.type="checkbox",i.checked=this.autoSnapshot,i.style.cssText="cursor: pointer;",i.addEventListener("change",()=>{this.autoSnapshot=i.checked}),o.appendChild(i),o.appendChild(document.createTextNode("\u81EA\u52A8\u5FEB\u7167")),e.appendChild(o),this.container.appendChild(e),this.snapshots.length>0&&this.renderPlaybackControls(this.container),this.renderSnapshotList(this.container);let l=this.currentIndex===-1;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${this.snapshots.length} \u4E2A\u5FEB\u7167</span><span style="color: #585b70;">|</span><span>${l?"\u5B9E\u65F6":`\u5386\u53F2 #${this.currentIndex+1}`}</span>`)}renderPlaybackControls(e){let t=document.createElement("div");t.style.cssText=`
510
510
  display: flex;
511
511
  align-items: center;
512
512
  gap: 6px;
@@ -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;",i?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let d=document.createElement("span");if(d.textContent=e.node.name,d.style.cssText="font-weight: bold;",n.appendChild(d),e.node.stateSummary){let c=document.createElement("span");c.textContent=` ${e.node.stateSummary}`,c.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(c)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let c=document.createElement("span");c.textContent=` [${e.node.propsCount} props]`,c.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(c)}let p=e.node,a=p.id;return n.addEventListener("click",()=>{var c;if(i){let u=(c=this.expandedMap.get(a))!=null?c:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(p)}),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 i=performance.memory;i&&(e=i.usedJSHeapSize,t=i.totalJSHeapSize,n=i.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,i=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:i}})}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,i=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,i+=b*b,l+=T*T}let d=t*i-n*n,p=d!==0?(t*o-n*r)/d:0,a=r/t,c=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=p*g+(r-p*n)/t;c+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=c!==0?1-u/c:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?p/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,i=0,l=0,d=1/0;for(let c of e)(!r||c.timestamp>r.timestamp)&&(r=c),c.usedJSHeapSize>o&&(o=c.usedJSHeapSize,i=c.timestamp),l+=c.usedJSHeapSize,c.usedJSHeapSize<d&&(d=c.usedJSHeapSize);let p=e.length>0?l/e.length:0;d===1/0&&(d=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:i,averageUsage:p,minUsage:d,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,i=0,l=new Map;for(let p of e){n+=p.duration,p.duration>r&&(r=p.duration),p.duration<o&&(o=p.duration),p.duration>t&&i++;let a=l.get(p.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(p.componentName,a)),a.renderCount++,a.totalDuration+=p.duration,p.duration>a.maxDuration&&(a.maxDuration=p.duration),p.duration<a.minDuration&&(a.minDuration=p.duration),p.duration>t&&a.slowCount++}let d=Array.from(l.entries()).map(([p,a])=>({componentName:p,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((p,a)=>a.avgDuration-p.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:i,slowRenderRatio:i/e.length,byComponent:d}}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 d=o.get(l.name);d||(d={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,d)),d.count++,d.totalDuration+=l.duration,l.duration>d.maxDuration&&(d.maxDuration=l.duration),l.duration<d.minDuration&&(d.minDuration=l.duration),d.durations.push(l.duration)}let i=Array.from(o.entries()).map(([l,d])=>{let p=d.totalDuration/d.count,a=0;for(let u of d.durations)a+=(u-p)*(u-p);a/=d.count;let c=Math.sqrt(a);return{name:l,count:d.count,avgDuration:p,maxDuration:d.maxDuration===-1/0?0:d.maxDuration,minDuration:d.minDuration===1/0?0:d.minDuration,totalDuration:d.totalDuration,stdDev:c}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:i}}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 i=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:i&&i.stdDev>0?(o.duration-i.avgDuration)/i.stdDev:0});continue}if(i&&i.count>=2&&i.stdDev>0){let l=(o.duration-i.avgDuration)/i.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let d=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:d,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,i)=>o.timestamp-i.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,i,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:(i=e==null?void 0:e.autoShow)!=null?i:!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,d=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new N(this.panel),this.eventTracker=new z(this.panel),this.timeTravel=new $(this.panel),this.panel.registerTabRenderer("components",d=>{this.componentTree.render(d)}),this.panel.registerTabRenderer("state",d=>{this.stateInspector.render(d)}),this.panel.registerTabRenderer("events",d=>{this.eventTracker.render(d)}),this.panel.registerTabRenderer("router",d=>{this.renderRouterTab(d)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,_(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;",i?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let d=document.createElement("span");if(d.textContent=e.node.name,d.style.cssText="font-weight: bold;",n.appendChild(d),e.node.stateSummary){let c=document.createElement("span");c.textContent=` ${e.node.stateSummary}`,c.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(c)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let c=document.createElement("span");c.textContent=` [${e.node.propsCount} props]`,c.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(c)}let p=e.node,a=p.id;return n.addEventListener("click",()=>{var c;if(i){let u=(c=this.expandedMap.get(a))!=null?c:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(p)}),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 i=performance.memory;i&&(e=i.usedJSHeapSize,t=i.totalJSHeapSize,n=i.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,i=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:i}})}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,i=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,i+=b*b,l+=T*T}let d=t*i-n*n,p=d!==0?(t*o-n*r)/d:0,a=r/t,c=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=p*g+(r-p*n)/t;c+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=c!==0?1-u/c:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?p/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,i=0,l=0,d=1/0;for(let c of e)(!r||c.timestamp>r.timestamp)&&(r=c),c.usedJSHeapSize>o&&(o=c.usedJSHeapSize,i=c.timestamp),l+=c.usedJSHeapSize,c.usedJSHeapSize<d&&(d=c.usedJSHeapSize);let p=e.length>0?l/e.length:0;d===1/0&&(d=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:i,averageUsage:p,minUsage:d,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,i=0,l=new Map;for(let p of e){n+=p.duration,p.duration>r&&(r=p.duration),p.duration<o&&(o=p.duration),p.duration>t&&i++;let a=l.get(p.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(p.componentName,a)),a.renderCount++,a.totalDuration+=p.duration,p.duration>a.maxDuration&&(a.maxDuration=p.duration),p.duration<a.minDuration&&(a.minDuration=p.duration),p.duration>t&&a.slowCount++}let d=Array.from(l.entries()).map(([p,a])=>({componentName:p,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((p,a)=>a.avgDuration-p.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:i,slowRenderRatio:i/e.length,byComponent:d}}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 d=o.get(l.name);d||(d={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,d)),d.count++,d.totalDuration+=l.duration,l.duration>d.maxDuration&&(d.maxDuration=l.duration),l.duration<d.minDuration&&(d.minDuration=l.duration),d.durations.push(l.duration)}let i=Array.from(o.entries()).map(([l,d])=>{let p=d.totalDuration/d.count,a=0;for(let u of d.durations)a+=(u-p)*(u-p);a/=d.count;let c=Math.sqrt(a);return{name:l,count:d.count,avgDuration:p,maxDuration:d.maxDuration===-1/0?0:d.maxDuration,minDuration:d.minDuration===1/0?0:d.minDuration,totalDuration:d.totalDuration,stdDev:c}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:i}}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 i=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:i&&i.stdDev>0?(o.duration-i.avgDuration)/i.stdDev:0});continue}if(i&&i.count>=2&&i.stdDev>0){let l=(o.duration-i.avgDuration)/i.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let d=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:d,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,i)=>o.timestamp-i.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,i,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:(i=e==null?void 0:e.autoShow)!=null?i:!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,d=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new N(this.panel),this.eventTracker=new $(this.panel),this.timeTravel=new z(this.panel),this.panel.registerTabRenderer("components",d=>{this.componentTree.render(d)}),this.panel.registerTabRenderer("state",d=>{this.stateInspector.render(d)}),this.panel.registerTabRenderer("events",d=>{this.eventTracker.render(d)}),this.panel.registerTabRenderer("router",d=>{this.renderRouterTab(d)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,_(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.onWindowResize=()=>{let e=this.panelEl.getBoundingClientRect(),t=window.innerWidth-100,n=window.innerHeight-36;e.left>t&&(this.panelEl.style.left=`${t}px`),e.top>n&&(this.panelEl.style.top=`${n}px`)};var t,n,r,o,s,l,d,p;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:(o=e==null?void 0:e.x)!=null?o:window.innerWidth-((r=e==null?void 0:e.width)!=null?r:420)-20,y:(s=e==null?void 0:e.y)!=null?s:60,minWidth:(l=e==null?void 0:e.minWidth)!=null?l:320,minHeight:(d=e==null?void 0:e.minHeight)!=null?d:200,title:(p=e==null?void 0:e.title)!=null?p:"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},this.styleEl=document.createElement("style"),this.styleEl.textContent=Ce,document.head.appendChild(this.styleEl),this.panelEl=this.createPanelElement(),this.headerEl=this.panelEl.querySelector(".lyt-devtools-header"),this.tabsEl=this.panelEl.querySelector(".lyt-devtools-tabs"),this.contentEl=this.panelEl.querySelector(".lyt-devtools-content"),this.statusbarEl=this.panelEl.querySelector(".lyt-devtools-statusbar"),this.statusLeftEl=this.statusbarEl.querySelector(".lyt-devtools-status-left"),this.statusRightEl=this.statusbarEl.querySelector(".lyt-devtools-status-right"),document.body.appendChild(this.panelEl),this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize)}createPanelElement(){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.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 d=document.createElement("div");d.className="lyt-devtools-content";let p=document.createElement("div");p.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 c=document.createElement("span");c.className="lyt-devtools-status-right",c.textContent="v0.0.1",p.appendChild(a),p.appendChild(c);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(d),e.appendChild(p),e.appendChild(u),e}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(n=>{n.classList.toggle("active",n.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){this.contentEl.innerHTML="";let e=this.tabRenderers.get(this.activeTab);e?e(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,this.panelEl.style.display="flex"}hide(){this._visible=!1,this.panelEl.style.display="none"}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){this.headerEl.addEventListener("mousedown",e=>{e.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=e.clientX,this.dragState.startY=e.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,e.preventDefault())}),document.addEventListener("mousemove",e=>{if(!this.dragState.isDragging)return;let t=e.clientX-this.dragState.startX,n=e.clientY-this.dragState.startY,r=this.dragState.startLeft+t,o=this.dragState.startTop+n;r=Math.max(0,Math.min(r,window.innerWidth-100)),o=Math.max(0,Math.min(o,window.innerHeight-36)),this.panelEl.style.left=`${r}px`,this.panelEl.style.top=`${o}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1})}bindResizeEvents(){this.panelEl.querySelector(".lyt-devtools-resize-handle").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(){document.addEventListener("keydown",e=>{e.ctrlKey&&e.shiftKey&&e.key==="D"&&(e.preventDefault(),this.toggle()),e.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){this.statusLeftEl.innerHTML=e}setStatusRight(e){this.statusRightEl.textContent=e}setConnected(e){let t=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");t&&t.classList.toggle("disconnected",!e)}highlightElement(e){if(this.clearHighlight(),!e)return;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.onWindowResize=()=>{let e=this.panelEl.getBoundingClientRect(),t=window.innerWidth-100,n=window.innerHeight-36;e.left>t&&(this.panelEl.style.left=`${t}px`),e.top>n&&(this.panelEl.style.top=`${n}px`)};var t,n,r,o,s,l,d,p;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:(o=e==null?void 0:e.x)!=null?o:window.innerWidth-((r=e==null?void 0:e.width)!=null?r:420)-20,y:(s=e==null?void 0:e.y)!=null?s:60,minWidth:(l=e==null?void 0:e.minWidth)!=null?l:320,minHeight:(d=e==null?void 0:e.minHeight)!=null?d:200,title:(p=e==null?void 0:e.title)!=null?p:"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},this.styleEl=document.createElement("style"),this.styleEl.textContent=Ce,document.head.appendChild(this.styleEl),this.panelEl=this.createPanelElement(),this.headerEl=this.panelEl.querySelector(".lyt-devtools-header")||document.createElement("div"),this.tabsEl=this.panelEl.querySelector(".lyt-devtools-tabs")||document.createElement("div"),this.contentEl=this.panelEl.querySelector(".lyt-devtools-content")||document.createElement("div"),this.statusbarEl=this.panelEl.querySelector(".lyt-devtools-statusbar")||document.createElement("div"),this.statusLeftEl=this.statusbarEl.querySelector(".lyt-devtools-status-left")||document.createElement("span"),this.statusRightEl=this.statusbarEl.querySelector(".lyt-devtools-status-right")||document.createElement("span"),document.body.appendChild(this.panelEl),this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize)}createPanelElement(){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={}),f.dataset.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 d=document.createElement("div");d.className="lyt-devtools-content";let p=document.createElement("div");p.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 c=document.createElement("span");c.className="lyt-devtools-status-right",c.textContent="v0.0.1",p.appendChild(a),p.appendChild(c);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(d),e.appendChild(p),e.appendChild(u),e}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(n=>{n.dataset||(n.dataset={}),n.classList.toggle("active",n.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){this.contentEl.innerHTML="";let e=this.tabRenderers.get(this.activeTab);e?e(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,this.panelEl.style.display="flex"}hide(){this._visible=!1,this.panelEl.style.display="none"}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){this.headerEl.addEventListener("mousedown",e=>{e.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=e.clientX,this.dragState.startY=e.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,e.preventDefault())}),document.addEventListener("mousemove",e=>{if(!this.dragState.isDragging)return;let t=e.clientX-this.dragState.startX,n=e.clientY-this.dragState.startY,r=this.dragState.startLeft+t,o=this.dragState.startTop+n;r=Math.max(0,Math.min(r,window.innerWidth-100)),o=Math.max(0,Math.min(o,window.innerHeight-36)),this.panelEl.style.left=`${r}px`,this.panelEl.style.top=`${o}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1})}bindResizeEvents(){let e=this.panelEl.querySelector(".lyt-devtools-resize-handle")||document.createElement("div");e&&e.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(){document.addEventListener("keydown",e=>{e.ctrlKey&&e.shiftKey&&e.key==="D"&&(e.preventDefault(),this.toggle()),e.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){this.statusLeftEl.innerHTML=e}setStatusRight(e){this.statusRightEl.textContent=e}setConnected(e){let t=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");t&&t.classList.toggle("disconnected",!e)}highlightElement(e){if(this.clearHighlight(),!e)return;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 t=e.getBoundingClientRect();this.highlightOverlay.style.left=`${t.left}px`,this.highlightOverlay.style.top=`${t.top}px`,this.highlightOverlay.style.width=`${t.width}px`,this.highlightOverlay.style.height=`${t.height}px`,document.body.appendChild(this.highlightOverlay)}clearHighlight(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){this.styleEl.remove(),this.panelEl.remove(),this.clearHighlight(),window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],w=[],ye=0,H=null,C={},U=!1;function Se(){return`comp_${++ye}`}function we(){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 S(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>S(t));let e={};for(let t of Object.keys(i))e[t]=S(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 ke(i,e,t){let n=e.split("."),r=i;for(let o=0;o<n.length-1;o++)(r[n[o]]==null||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function J(i,e){U||(e&&Object.assign(C,e),U=!0,Le(i),i._instance&&(_(i._instance,null),V()))}function Le(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(_(i._instance,null),V()),n}}function _(i,e){var o,s,l,d,p,a,c,u;if(!i)return;let t=ve(i),n=!t;if(n){let h=Se();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=(d=i.isMounted)!=null?d:!1,t.isUnmounted=(p=i.isUnmounted)!=null?p:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now();i.props&&(t.props=S(i.props)),i.state&&(t.state=S(i.state)),i.computedCache&&(t.computed=S(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?(c=C.onComponentCreated)==null||c.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){_(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 d=o[s],p=Reflect.set(o,s,l);if(Re(d,l)){let c=String(s),u={componentId:i,componentName:n.name,path:c,oldValue:S(d),newValue:S(l),timestamp:Date.now()};w.push(u),w.length>1e3&&w.splice(0,w.length-1e3),n.state=S(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return p}});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:we(),name:r,timestamp:Date.now(),args:S(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 L(){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[...w]}function X(i){return w.filter(e=>e.componentId===i)}function Ne(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);ke(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:S(o),newValue:S(t),timestamp:Date.now()};return w.push(s),n.state=S(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function ee(i){E.clear(),i._instance&&(_(i._instance,null),V())}function te(){M.length=0,w.length=0}function ne(){E.clear(),M.length=0,w.length=0,H=null,U=!1}function ze(){return U}function $e(){return E.size}var N=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=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),d=r.id.toLowerCase().includes(s);if(!l&&!d)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 t=e.getBoundingClientRect();this.highlightOverlay.style.left=`${t.left}px`,this.highlightOverlay.style.top=`${t.top}px`,this.highlightOverlay.style.width=`${t.width}px`,this.highlightOverlay.style.height=`${t.height}px`,document.body.appendChild(this.highlightOverlay)}clearHighlight(){this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),window.removeEventListener&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],w=[],ye=0,H=null,C={},U=!1;function Se(){return`comp_${++ye}`}function we(){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 S(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>S(t));let e={};for(let t of Object.keys(i))e[t]=S(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 ke(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){U||(e&&Object.assign(C,e),U=!0,Le(i),i._instance&&(_(i._instance,null),V()))}function Le(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(_(i._instance,null),V()),n}}function _(i,e){var o,s,l,d,p,a,c,u;if(!i)return;let t=ve(i),n=!t;if(n){let h=Se();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=(d=i.isMounted)!=null?d:!1,t.isUnmounted=(p=i.isUnmounted)!=null?p:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now();i.props&&(t.props=S(i.props)),i.state&&(t.state=S(i.state)),i.computedCache&&(t.computed=S(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?(c=C.onComponentCreated)==null||c.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){_(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 d=o[s],p=Reflect.set(o,s,l);if(Re(d,l)){let c=String(s),u={componentId:i,componentName:n.name,path:c,oldValue:S(d),newValue:S(l),timestamp:Date.now()};w.push(u),w.length>1e3&&w.splice(0,w.length-1e3),n.state=S(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return p}});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:we(),name:r,timestamp:Date.now(),args:S(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 L(){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[...w]}function X(i){return w.filter(e=>e.componentId===i)}function Ne(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);ke(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:S(o),newValue:S(t),timestamp:Date.now()};return w.push(s),n.state=S(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function ee(i){E.clear(),i._instance&&(_(i._instance,null),V())}function te(){M.length=0,w.length=0}function ne(){E.clear(),M.length=0,w.length=0,H=null,U=!1}function $e(){return U}function ze(){return E.size}var N=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=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),d=r.id.toLowerCase().includes(s);if(!l&&!d)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;
@@ -327,7 +327,7 @@ var Ce=`
327
327
  white-space: nowrap;
328
328
  font-size: 12px;
329
329
  color: ${s?"#cba6f7":"#cdd6f4"};
330
- `,u.textContent=t.name,l.appendChild(u);let h=Object.keys(t.state).length;if(h>0){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-blue",m.textContent=`${h}`,m.title=`${h} \u4E2A\u72B6\u6001\u5C5E\u6027`,l.appendChild(m)}let f=Object.keys(t.computed).length;if(f>0){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-green",m.textContent=`C:${f}`,m.title=`${f} \u4E2A\u8BA1\u7B97\u5C5E\u6027`,m.style.marginLeft="3px",l.appendChild(m)}if(!t.isMounted&&!t.isUnmounted){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-yellow",m.textContent="\u672A\u6302\u8F7D",m.style.marginLeft="3px",l.appendChild(m)}else if(t.isUnmounted){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-red",m.textContent="\u5DF2\u5378\u8F7D",m.style.marginLeft="3px",l.appendChild(m)}if(l.addEventListener("click",m=>{m.stopPropagation(),p&&(this.expandedNodes.has(t.id)?this.expandedNodes.delete(t.id):this.expandedNodes.add(t.id)),G(t.id),this.onSelect(t.id),this.panel.highlightElement(t.el),this.renderTree()}),l.addEventListener("mouseenter",()=>{this.panel.highlightElement(t.el)}),l.addEventListener("mouseleave",()=>{var v;let m=P(),x=m?I(m):null;this.panel.highlightElement((v=x==null?void 0:x.el)!=null?v:null)}),r&&p){let m=Y(t.id);for(let x of m){if(this.searchKeyword){let g=this.searchKeyword.toLowerCase(),b=x.name.toLowerCase().includes(g),T=x.id.toLowerCase().includes(g);if(!b&&!T)continue}let v={info:x,children:[],depth:n+1,expanded:this.expandedNodes.has(x.id)},y=this.renderTreeNode(v);y&&l.appendChild(y)}}return l}refresh(){this.renderTree()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null}};function Be(i){return i===null?"null":i===void 0?"undefined":typeof i=="string"?"string":typeof i=="number"?"number":typeof i=="boolean"?"boolean":typeof i=="function"?"function":Array.isArray(i)?`Array[${i.length}]`:i instanceof Date?"Date":i instanceof RegExp?"RegExp":typeof i=="object"?"Object":typeof i}function re(i,e=80){if(i===null)return"null";if(i===void 0)return"undefined";if(typeof i=="string")return i.length>e?`"${i.slice(0,e)}..."`:`"${i}"`;if(typeof i=="function")return`fn(${i.name||"anonymous"})`;if(typeof i=="object")try{let t=JSON.stringify(i);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(i)}function be(i){return i!==null&&typeof i=="object"&&!(i instanceof Date)&&!(i instanceof RegExp)}var z=class{constructor(e){this.container=null;this.expandedPaths=new Set;this.changedPaths=new Map;this.highlightTimer=null;this.showHistory=!1;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderState()},150)};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderState()}renderState(){if(!this.container)return;this.container.innerHTML="";let e=Q();if(!e){let d=document.createElement("div");d.className="lyt-devtools-empty",d.textContent="\u8BF7\u5148\u5728\u7EC4\u4EF6\u6811\u4E2D\u9009\u62E9\u4E00\u4E2A\u7EC4\u4EF6\u3002",this.container.appendChild(d);return}let t=document.createElement("div");t.style.cssText=`
330
+ `,u.textContent=t.name,l.appendChild(u);let h=Object.keys(t.state).length;if(h>0){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-blue",m.textContent=`${h}`,m.title=`${h} \u4E2A\u72B6\u6001\u5C5E\u6027`,l.appendChild(m)}let f=Object.keys(t.computed).length;if(f>0){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-green",m.textContent=`C:${f}`,m.title=`${f} \u4E2A\u8BA1\u7B97\u5C5E\u6027`,m.style.marginLeft="3px",l.appendChild(m)}if(!t.isMounted&&!t.isUnmounted){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-yellow",m.textContent="\u672A\u6302\u8F7D",m.style.marginLeft="3px",l.appendChild(m)}else if(t.isUnmounted){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-red",m.textContent="\u5DF2\u5378\u8F7D",m.style.marginLeft="3px",l.appendChild(m)}if(l.addEventListener("click",m=>{m.stopPropagation(),p&&(this.expandedNodes.has(t.id)?this.expandedNodes.delete(t.id):this.expandedNodes.add(t.id)),G(t.id),this.onSelect(t.id),this.panel.highlightElement(t.el),this.renderTree()}),l.addEventListener("mouseenter",()=>{this.panel.highlightElement(t.el)}),l.addEventListener("mouseleave",()=>{var v;let m=P(),x=m?I(m):null;this.panel.highlightElement((v=x==null?void 0:x.el)!=null?v:null)}),r&&p){let m=Y(t.id);for(let x of m){if(this.searchKeyword){let g=this.searchKeyword.toLowerCase(),b=x.name.toLowerCase().includes(g),T=x.id.toLowerCase().includes(g);if(!b&&!T)continue}let v={info:x,children:[],depth:n+1,expanded:this.expandedNodes.has(x.id)},y=this.renderTreeNode(v);y&&l.appendChild(y)}}return l}refresh(){this.renderTree()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null}};function Be(i){return i===null?"null":i===void 0?"undefined":typeof i=="string"?"string":typeof i=="number"?"number":typeof i=="boolean"?"boolean":typeof i=="function"?"function":Array.isArray(i)?`Array[${i.length}]`:i instanceof Date?"Date":i instanceof RegExp?"RegExp":typeof i=="object"?"Object":typeof i}function re(i,e=80){if(i===null)return"null";if(i===void 0)return"undefined";if(typeof i=="string")return i.length>e?`"${i.slice(0,e)}..."`:`"${i}"`;if(typeof i=="function")return`fn(${i.name||"anonymous"})`;if(typeof i=="object")try{let t=JSON.stringify(i);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(i)}function be(i){return i!==null&&typeof i=="object"&&!(i instanceof Date)&&!(i instanceof RegExp)}var $=class{constructor(e){this.container=null;this.expandedPaths=new Set;this.changedPaths=new Map;this.highlightTimer=null;this.showHistory=!1;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderState()},150)};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderState()}renderState(){if(!this.container)return;this.container.innerHTML="";let e=Q();if(!e){let d=document.createElement("div");d.className="lyt-devtools-empty",d.textContent="\u8BF7\u5148\u5728\u7EC4\u4EF6\u6811\u4E2D\u9009\u62E9\u4E00\u4E2A\u7EC4\u4EF6\u3002",this.container.appendChild(d);return}let t=document.createElement("div");t.style.cssText=`
331
331
  display: flex;
332
332
  align-items: center;
333
333
  justify-content: space-between;
@@ -429,7 +429,7 @@ var Ce=`
429
429
  <span style="color: #6c7086;">\u2192</span>
430
430
  <span style="color: #a6e3a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${re(s.newValue,40)}</span>
431
431
  </div>
432
- `,n.appendChild(l)}this.container.appendChild(n)}markChanged(e){this.changedPaths.set(e,Date.now()),this.highlightTimer&&clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>{this.changedPaths.clear(),this.renderState()},3e3)}refresh(){this.renderState()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.highlightTimer&&clearTimeout(this.highlightTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.expandedPaths.clear(),this.changedPaths.clear()}};function Ae(i,e=60){if(i===null)return"null";if(i===void 0)return"undefined";if(typeof i=="string")return i.length>e?`"${i.slice(0,e)}..."`:`"${i}"`;if(typeof i=="function")return`fn(${i.name||"anonymous"})`;if(typeof i=="object")try{let t=JSON.stringify(i);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(i)}function Te(i){let e=new Date(i);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}function Fe(i){let t=Date.now()-i;return t<1e3?`${t}ms \u524D`:t<6e4?`${Math.floor(t/1e3)}s \u524D`:`${Math.floor(t/6e4)}m \u524D`}var $=class{constructor(e){this.container=null;this.nameFilter="";this.componentFilter="";this.paused=!1;this.selectedEventId=null;this.updateTimer=null;this.autoScrollTimer=null;this.onUpdate=()=>{this.paused||(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderEvents()},100))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderEvents()}renderEvents(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 6px; margin-bottom: 8px; align-items: center;";let t=document.createElement("input");t.type="text",t.className="lyt-devtools-search",t.placeholder="\u6309\u4E8B\u4EF6\u540D\u79F0\u8FC7\u6EE4...",t.value=this.nameFilter,t.style.marginBottom="0",t.style.flex="1",t.addEventListener("input",a=>{this.nameFilter=a.target.value,this.renderEvents()}),e.appendChild(t);let n=document.createElement("input");n.type="text",n.className="lyt-devtools-search",n.placeholder="\u6309\u7EC4\u4EF6\u8FC7\u6EE4...",n.value=this.componentFilter,n.style.marginBottom="0",n.style.flex="1",n.addEventListener("input",a=>{this.componentFilter=a.target.value,this.renderEvents()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=`
432
+ `,n.appendChild(l)}this.container.appendChild(n)}markChanged(e){this.changedPaths.set(e,Date.now()),this.highlightTimer&&clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>{this.changedPaths.clear(),this.renderState()},3e3)}refresh(){this.renderState()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.highlightTimer&&clearTimeout(this.highlightTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.expandedPaths.clear(),this.changedPaths.clear()}};function Ae(i,e=60){if(i===null)return"null";if(i===void 0)return"undefined";if(typeof i=="string")return i.length>e?`"${i.slice(0,e)}..."`:`"${i}"`;if(typeof i=="function")return`fn(${i.name||"anonymous"})`;if(typeof i=="object")try{let t=JSON.stringify(i);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(i)}function Te(i){let e=new Date(i);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}function Fe(i){let t=Date.now()-i;return t<1e3?`${t}ms \u524D`:t<6e4?`${Math.floor(t/1e3)}s \u524D`:`${Math.floor(t/6e4)}m \u524D`}var z=class{constructor(e){this.container=null;this.nameFilter="";this.componentFilter="";this.paused=!1;this.selectedEventId=null;this.updateTimer=null;this.autoScrollTimer=null;this.onUpdate=()=>{this.paused||(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderEvents()},100))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderEvents()}renderEvents(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 6px; margin-bottom: 8px; align-items: center;";let t=document.createElement("input");t.type="text",t.className="lyt-devtools-search",t.placeholder="\u6309\u4E8B\u4EF6\u540D\u79F0\u8FC7\u6EE4...",t.value=this.nameFilter,t.style.marginBottom="0",t.style.flex="1",t.addEventListener("input",a=>{this.nameFilter=a.target.value,this.renderEvents()}),e.appendChild(t);let n=document.createElement("input");n.type="text",n.className="lyt-devtools-search",n.placeholder="\u6309\u7EC4\u4EF6\u8FC7\u6EE4...",n.value=this.componentFilter,n.style.marginBottom="0",n.style.flex="1",n.addEventListener("input",a=>{this.componentFilter=a.target.value,this.renderEvents()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=`
433
433
  background: ${this.paused?"#f38ba8":"transparent"};
434
434
  color: ${this.paused?"#1e1e2e":"#a6adc8"};
435
435
  border: 1px solid ${this.paused?"#f38ba8":"#313244"};
@@ -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 d=document.createElement("span");if(d.textContent=e.node.name,d.style.cssText="font-weight: bold;",n.appendChild(d),e.node.stateSummary){let c=document.createElement("span");c.textContent=` ${e.node.stateSummary}`,c.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(c)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let c=document.createElement("span");c.textContent=` [${e.node.propsCount} props]`,c.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(c)}let p=e.node,a=p.id;return n.addEventListener("click",()=>{var c;if(s){let u=(c=this.expandedMap.get(a))!=null?c:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(p)}),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,ce=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 d=t*s-n*n,p=d!==0?(t*o-n*r)/d:0,a=r/t,c=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=p*g+(r-p*n)/t;c+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=c!==0?1-u/c:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?p/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,d=1/0;for(let c of e)(!r||c.timestamp>r.timestamp)&&(r=c),c.usedJSHeapSize>o&&(o=c.usedJSHeapSize,s=c.timestamp),l+=c.usedJSHeapSize,c.usedJSHeapSize<d&&(d=c.usedJSHeapSize);let p=e.length>0?l/e.length:0;d===1/0&&(d=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:p,minUsage:d,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 pe=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 pe(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 p of e){n+=p.duration,p.duration>r&&(r=p.duration),p.duration<o&&(o=p.duration),p.duration>t&&s++;let a=l.get(p.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(p.componentName,a)),a.renderCount++,a.totalDuration+=p.duration,p.duration>a.maxDuration&&(a.maxDuration=p.duration),p.duration<a.minDuration&&(a.minDuration=p.duration),p.duration>t&&a.slowCount++}let d=Array.from(l.entries()).map(([p,a])=>({componentName:p,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((p,a)=>a.avgDuration-p.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:d}}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 d=o.get(l.name);d||(d={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,d)),d.count++,d.totalDuration+=l.duration,l.duration>d.maxDuration&&(d.maxDuration=l.duration),l.duration<d.minDuration&&(d.minDuration=l.duration),d.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,d])=>{let p=d.totalDuration/d.count,a=0;for(let u of d.durations)a+=(u-p)*(u-p);a/=d.count;let c=Math.sqrt(a);return{name:l,count:d.count,avgDuration:p,maxDuration:d.maxDuration===-1/0?0:d.maxDuration,minDuration:d.minDuration===1/0?0:d.minDuration,totalDuration:d.totalDuration,stdDev:c}});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 d=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:d,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 N(this.panel,d=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new z(this.panel),this.eventTracker=new $(this.panel),this.timeTravel=new B(this.panel),this.panel.registerTabRenderer("components",d=>{this.componentTree.render(d)}),this.panel.registerTabRenderer("state",d=>{this.stateInspector.render(d)}),this.panel.registerTabRenderer("events",d=>{this.eventTracker.render(d)}),this.panel.registerTabRenderer("router",d=>{this.renderRouterTab(d)}),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 d=document.createElement("span");if(d.textContent=e.node.name,d.style.cssText="font-weight: bold;",n.appendChild(d),e.node.stateSummary){let c=document.createElement("span");c.textContent=` ${e.node.stateSummary}`,c.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(c)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let c=document.createElement("span");c.textContent=` [${e.node.propsCount} props]`,c.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(c)}let p=e.node,a=p.id;return n.addEventListener("click",()=>{var c;if(s){let u=(c=this.expandedMap.get(a))!=null?c:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(p)}),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,ce=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 d=t*s-n*n,p=d!==0?(t*o-n*r)/d:0,a=r/t,c=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=p*g+(r-p*n)/t;c+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=c!==0?1-u/c:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?p/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,d=1/0;for(let c of e)(!r||c.timestamp>r.timestamp)&&(r=c),c.usedJSHeapSize>o&&(o=c.usedJSHeapSize,s=c.timestamp),l+=c.usedJSHeapSize,c.usedJSHeapSize<d&&(d=c.usedJSHeapSize);let p=e.length>0?l/e.length:0;d===1/0&&(d=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:p,minUsage:d,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 pe=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 pe(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 p of e){n+=p.duration,p.duration>r&&(r=p.duration),p.duration<o&&(o=p.duration),p.duration>t&&s++;let a=l.get(p.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(p.componentName,a)),a.renderCount++,a.totalDuration+=p.duration,p.duration>a.maxDuration&&(a.maxDuration=p.duration),p.duration<a.minDuration&&(a.minDuration=p.duration),p.duration>t&&a.slowCount++}let d=Array.from(l.entries()).map(([p,a])=>({componentName:p,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((p,a)=>a.avgDuration-p.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:d}}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 d=o.get(l.name);d||(d={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,d)),d.count++,d.totalDuration+=l.duration,l.duration>d.maxDuration&&(d.maxDuration=l.duration),l.duration<d.minDuration&&(d.minDuration=l.duration),d.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,d])=>{let p=d.totalDuration/d.count,a=0;for(let u of d.durations)a+=(u-p)*(u-p);a/=d.count;let c=Math.sqrt(a);return{name:l,count:d.count,avgDuration:p,maxDuration:d.maxDuration===-1/0?0:d.maxDuration,minDuration:d.minDuration===1/0?0:d.minDuration,totalDuration:d.totalDuration,stdDev:c}});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 d=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:d,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 N(this.panel,d=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new $(this.panel),this.eventTracker=new z(this.panel),this.timeTravel=new B(this.panel),this.panel.registerTabRenderer("components",d=>{this.componentTree.render(d)}),this.panel.registerTabRenderer("state",d=>{this.stateInspector.render(d)}),this.panel.registerTabRenderer("events",d=>{this.eventTracker.render(d)}),this.panel.registerTabRenderer("router",d=>{this.renderRouterTab(d)}),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;">
@@ -616,4 +616,4 @@ var Ce=`
616
616
  \u8DEF\u7531\u68C0\u67E5\u5668\u5C06\u663E\u793A\u5F53\u524D\u8DEF\u7531\u4FE1\u606F\u3001<br>
617
617
  \u8DEF\u7531\u5B88\u536B\u548C\u5BFC\u822A\u5386\u53F2\u3002
618
618
  </div>
619
- `,e.appendChild(t)}refreshTree(){this.app&&ee(this.app),this.componentTree.refresh()}clearAllRecords(){te(),this.eventTracker.refresh(),this.stateInspector.refresh()}getPanel(){return this.panel}getComponentTree(){return this.componentTree}getStateInspector(){return this.stateInspector}getEventTracker(){return this.eventTracker}getTimeTravel(){return this.timeTravel}destroy(){this.componentTree.destroy(),this.stateInspector.destroy(),this.eventTracker.destroy(),this.timeTravel.destroy(),this.panel.destroy(),ne(),this._installed=!1,this.app=null}};function Dt(i){let e=null;return{install(t){if(e)return;e=new fe(i),t.globalProperties&&(t.globalProperties.__LYT_DEVTOOLS__=e);let n=t;(n._instance!==void 0||n.mount)&&e.install(n)}}}export{me as BatchAnalyzer,F as ComponentProfiler,N as ComponentTreeInspector,fe as DevTools,D as DevToolsPanel,ie as EventPanel,$ as EventTracker,ce as MemoryTracker,se as PerfPanel,A as PerformanceCollector,ue as RenderTracker,oe as RoutePanel,ae as RouterPanel,z as StateInspector,B as TimeTravelDebugger,le as VirtualComponentTree,te as clearRecords,J as connectToApp,Dt as createDevTools,ne as disconnect,L as getAllComponents,Y as getChildComponents,I as getComponentById,$e as getComponentCount,Ne as getComponentEvents,X as getComponentStateChanges,K as getEventRecords,W as getRootComponent,Q as getSelectedComponent,P as getSelectedComponentId,Ie as getStateChangeRecords,ze as isAppConnected,ee as refreshComponentTree,G as selectComponent,Z as setComponentState};
619
+ `,e.appendChild(t)}refreshTree(){this.app&&ee(this.app),this.componentTree.refresh()}clearAllRecords(){te(),this.eventTracker.refresh(),this.stateInspector.refresh()}getPanel(){return this.panel}getComponentTree(){return this.componentTree}getStateInspector(){return this.stateInspector}getEventTracker(){return this.eventTracker}getTimeTravel(){return this.timeTravel}destroy(){this.componentTree.destroy(),this.stateInspector.destroy(),this.eventTracker.destroy(),this.timeTravel.destroy(),this.panel.destroy(),ne(),this._installed=!1,this.app=null}};function Dt(i){let e=null;return{install(t){if(e)return;e=new fe(i),t.globalProperties&&(t.globalProperties.__LYT_DEVTOOLS__=e);let n=t;(n._instance!==void 0||n.mount)&&e.install(n)}}}export{me as BatchAnalyzer,F as ComponentProfiler,N as ComponentTreeInspector,fe as DevTools,D as DevToolsPanel,ie as EventPanel,z as EventTracker,ce as MemoryTracker,se as PerfPanel,A as PerformanceCollector,ue as RenderTracker,oe as RoutePanel,ae as RouterPanel,$ as StateInspector,B as TimeTravelDebugger,le as VirtualComponentTree,te as clearRecords,J as connectToApp,Dt as createDevTools,ne as disconnect,L as getAllComponents,Y as getChildComponents,I as getComponentById,ze as getComponentCount,Ne as getComponentEvents,X as getComponentStateChanges,K as getEventRecords,W as getRootComponent,Q as getSelectedComponent,P as getSelectedComponentId,Ie as getStateChangeRecords,$e as isAppConnected,ee as refreshComponentTree,G as selectComponent,Z as setComponentState};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lytjs/devtools",
3
- "version": "4.0.0",
3
+ "version": "4.0.4",
4
4
  "description": "Lyt.js 浏览器开发者工具 - 提供组件树检查、状态查看、性能分析和时间旅行调试",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
@@ -12,7 +12,9 @@
12
12
  }
13
13
  },
14
14
  "sideEffects": false,
15
- "files": ["dist"],
15
+ "files": [
16
+ "dist"
17
+ ],
16
18
  "license": "MIT",
17
19
  "author": "lytjs",
18
20
  "repository": {