@lytjs/devtools 4.0.4 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +55 -55
- package/dist/index.mjs +46 -46
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/batch-analyzer.d.ts +150 -0
- package/dist/types/batch-analyzer.d.ts.map +1 -0
- package/dist/types/component-profiler.d.ts +144 -0
- package/dist/types/component-profiler.d.ts.map +1 -0
- package/dist/types/component-tree.d.ts +69 -0
- package/dist/types/component-tree.d.ts.map +1 -0
- package/dist/types/event-panel.d.ts +129 -0
- package/dist/types/event-panel.d.ts.map +1 -0
- package/dist/types/event-tracker.d.ts +80 -0
- package/dist/types/event-tracker.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +177 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +185 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/memory-tracker.d.ts +148 -0
- package/dist/types/memory-tracker.d.ts.map +1 -0
- package/dist/types/panel.d.ts +182 -0
- package/dist/types/panel.d.ts.map +1 -0
- package/dist/types/perf-collector.d.ts +328 -0
- package/dist/types/perf-collector.d.ts.map +1 -0
- package/dist/types/perf-panel.d.ts +231 -0
- package/dist/types/perf-panel.d.ts.map +1 -0
- package/dist/types/render-tracker.d.ts +147 -0
- package/dist/types/render-tracker.d.ts.map +1 -0
- package/dist/types/route-panel.d.ts +68 -0
- package/dist/types/route-panel.d.ts.map +1 -0
- package/dist/types/router-panel-enhanced.d.ts +118 -0
- package/dist/types/router-panel-enhanced.d.ts.map +1 -0
- package/dist/types/state-inspector.d.ts +80 -0
- package/dist/types/state-inspector.d.ts.map +1 -0
- package/dist/types/time-travel.d.ts +189 -0
- package/dist/types/time-travel.d.ts.map +1 -0
- package/dist/types/virtual-tree.d.ts +168 -0
- package/dist/types/virtual-tree.d.ts.map +1 -0
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
var ce=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Pe=(i,e)=>{for(var t in e)ce(i,t,{get:e[t],enumerable:!0})},De=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Le(e))!ke.call(i,r)&&r!==t&&ce(i,r,{get:()=>e[r],enumerable:!(n=Me(e,r))||n.enumerable});return i};var He=i=>De(ce({},"__esModule",{value:!0}),i);var it={};Pe(it,{BatchAnalyzer:()=>ie,ComponentProfiler:()=>A,ComponentTreeInspector:()=>I,DevTools:()=>ae,DevToolsPanel:()=>D,EventPanel:()=>te,EventTracker:()=>z,MemoryTracker:()=>oe,PerfPanel:()=>ee,PerformanceCollector:()=>$,RenderTracker:()=>se,RoutePanel:()=>Z,RouterPanel:()=>ne,StateInspector:()=>B,TimeTravelDebugger:()=>N,VirtualComponentTree:()=>re,clearRecords:()=>G,connectToApp:()=>U,createDevTools:()=>st,disconnect:()=>Q,getAllComponents:()=>L,getChildComponents:()=>j,getComponentById:()=>H,getComponentCount:()=>we,getComponentEvents:()=>Ce,getComponentStateChanges:()=>V,getEventRecords:()=>J,getRootComponent:()=>q,getSelectedComponent:()=>Y,getSelectedComponentId:()=>k,getStateChangeRecords:()=>Te,isAppConnected:()=>Ee,refreshComponentTree:()=>X,selectComponent:()=>W,setComponentState:()=>K});module.exports=He(it);var Ie=`
|
|
2
2
|
/* === Lyt DevTools \u9762\u677F\u57FA\u7840\u6837\u5F0F === */
|
|
3
3
|
.lyt-devtools-panel {
|
|
4
4
|
position: fixed;
|
|
@@ -282,15 +282,15 @@
|
|
|
282
282
|
.lyt-devtools-highlight {
|
|
283
283
|
animation: lyt-devtools-highlight 1s ease-out;
|
|
284
284
|
}
|
|
285
|
-
`,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
285
|
+
`,Be=[{id:"components",label:"\u7EC4\u4EF6\u6811",icon:"\u{1F333}"},{id:"state",label:"\u72B6\u6001",icon:"\u{1F4CA}"},{id:"events",label:"\u4E8B\u4EF6",icon:"\u26A1"},{id:"router",label:"\u8DEF\u7531",icon:"\u{1F517}"}],D=class{constructor(e){this.activeTab="components";this.tabRenderers=new Map;this._visible=!0;this._collapsed=!1;this.highlightOverlay=null;this._resizeHandle=null;this.onWindowResize=()=>{if(!(typeof window!="undefined"&&typeof document!="undefined"))return;let t=this.panelEl.getBoundingClientRect(),n=window.innerWidth-100,r=window.innerHeight-36;t.left>n&&(this.panelEl.style.left=`${n}px`),t.top>r&&(this.panelEl.style.top=`${r}px`)};var n,r,o,s,l,p,c,a;this.config={width:(n=e==null?void 0:e.width)!=null?n:420,height:(r=e==null?void 0:e.height)!=null?r:560,x:(s=e==null?void 0:e.x)!=null?s:typeof window!="undefined"?window.innerWidth-((o=e==null?void 0:e.width)!=null?o:420)-20:100,y:(l=e==null?void 0:e.y)!=null?l:60,minWidth:(p=e==null?void 0:e.minWidth)!=null?p:320,minHeight:(c=e==null?void 0:e.minHeight)!=null?c:200,title:(a=e==null?void 0:e.title)!=null?a:"Lyt DevTools"},this.dragState={isDragging:!1,startX:0,startY:0,startLeft:0,startTop:0},this.resizeState={isResizing:!1,startX:0,startY:0,startWidth:0,startHeight:0};let t=typeof window!="undefined"&&typeof document!="undefined";if(t?(this.styleEl=document.createElement("style"),this.styleEl.textContent=Ie,document.head.appendChild(this.styleEl)):this.styleEl={},t){let{panel:d,header:u,tabs:h,content:f,statusbar:m,statusLeft:x,statusRight:v,resizeHandle:y}=this.createPanelElementWithRefs();this.panelEl=d,this.headerEl=u,this.tabsEl=h,this.contentEl=f,this.statusbarEl=m,this.statusLeftEl=x,this.statusRightEl=v,this._resizeHandle=y}else this.panelEl=this.createMockPanelElement(),this.headerEl=this.panelEl.headerEl,this.tabsEl=this.panelEl.tabsEl,this.contentEl=this.panelEl.contentEl,this.statusbarEl=this.panelEl.statusbarEl,this.statusLeftEl=this.panelEl.statusLeftEl,this.statusRightEl=this.panelEl.statusRightEl,this._resizeHandle=this.panelEl.resizeHandleEl;t&&document.body.appendChild(this.panelEl),t&&(this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize))}createPanelElementWithRefs(){let e=document.createElement("div");e.className="lyt-devtools-panel",e.style.width=`${this.config.width}px`,e.style.height=`${this.config.height}px`,e.style.left=`${this.config.x}px`,e.style.top=`${this.config.y}px`;let t=document.createElement("div");t.className="lyt-devtools-header";let n=document.createElement("span");n.className="lyt-devtools-title",n.innerHTML=`<span class="lyt-devtools-title-icon">\u{1F50D}</span>${this.config.title}`;let r=document.createElement("div");r.className="lyt-devtools-header-actions";let o=document.createElement("button");o.className="lyt-devtools-btn",o.textContent="\u2014",o.title="\u6298\u53E0/\u5C55\u5F00",o.addEventListener("click",h=>{h.stopPropagation(),this.toggleCollapse()});let s=document.createElement("button");s.className="lyt-devtools-btn lyt-devtools-btn-close",s.textContent="\u2715",s.title="\u5173\u95ED\u9762\u677F",s.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(s),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Be){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset?f.dataset.tab=h.id:f.setAttribute("data-tab",h.id),f.innerHTML=`<span class="lyt-devtools-tab-icon">${h.icon}</span>${h.label}`,f.addEventListener("click",()=>this.switchTab(h.id)),l.appendChild(f)}let p=document.createElement("div");p.className="lyt-devtools-content";let c=document.createElement("div");c.className="lyt-devtools-statusbar";let a=document.createElement("span");a.className="lyt-devtools-status-left",a.innerHTML='<span class="lyt-devtools-status-dot"></span><span>\u5C31\u7EEA</span>';let d=document.createElement("span");d.className="lyt-devtools-status-right",d.textContent="v0.0.1",c.appendChild(a),c.appendChild(d);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(p),e.appendChild(c),e.appendChild(u),{panel:e,header:t,tabs:l,content:p,statusbar:c,statusLeft:a,statusRight:d,resizeHandle:u}}createPanelElement(){return this.createPanelElementWithRefs().panel}createMockPanelElement(){let e=n=>({className:n,classList:{add:()=>{},remove:()=>{},toggle:()=>{},contains:()=>!1},style:{},dataset:{},querySelector:r=>r===".lyt-devtools-header"?t.headerEl:r===".lyt-devtools-tabs"?t.tabsEl:r===".lyt-devtools-content"?t.contentEl:r===".lyt-devtools-statusbar"?t.statusbarEl:r===".lyt-devtools-status-left"?t.statusLeftEl:r===".lyt-devtools-status-right"?t.statusRightEl:r===".lyt-devtools-resize-handle"?t.resizeHandleEl:null,querySelectorAll:()=>[],appendChild:()=>{},addEventListener:()=>{},removeEventListener:()=>{},offsetLeft:0,offsetTop:0,offsetWidth:100,offsetHeight:100,getBoundingClientRect:()=>({left:0,top:0,right:100,bottom:100,width:100,height:100})}),t=e("lyt-devtools-panel");return t.headerEl=e("lyt-devtools-header"),t.tabsEl=e("lyt-devtools-tabs"),t.contentEl=e("lyt-devtools-content"),t.statusbarEl=e("lyt-devtools-statusbar"),t.statusLeftEl=e("lyt-devtools-status-left"),t.statusRightEl=e("lyt-devtools-status-right"),t.resizeHandleEl=e("lyt-devtools-resize-handle"),t}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,typeof window!="undefined"&&typeof document!="undefined"&&this.tabsEl&&this.tabsEl.querySelectorAll&&this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(r=>{let o=r;o.classList&&o.dataset&&o.classList.toggle("active",o.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){if(typeof window!="undefined"&&typeof document!="undefined"&&this.contentEl){this.contentEl.innerHTML="";let t=this.tabRenderers.get(this.activeTab);t?t(this.contentEl):this.contentEl.innerHTML='<div class="lyt-devtools-empty">\u6682\u65E0\u5185\u5BB9</div>'}}getActiveTab(){return this.activeTab}getContentElement(){return this.contentEl}show(){this._visible=!0,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="flex")}hide(){this._visible=!1,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="none")}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.classList&&this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){typeof window!="undefined"&&typeof document!="undefined"&&(this.headerEl.addEventListener("mousedown",t=>{t.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=t.clientX,this.dragState.startY=t.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,t.preventDefault())}),document.addEventListener("mousemove",t=>{if(!this.dragState.isDragging)return;let n=t.clientX-this.dragState.startX,r=t.clientY-this.dragState.startY,o=this.dragState.startLeft+n,s=this.dragState.startTop+r;o=Math.max(0,Math.min(o,window.innerWidth-100)),s=Math.max(0,Math.min(s,window.innerHeight-36)),this.panelEl.style.left=`${o}px`,this.panelEl.style.top=`${s}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1}))}bindResizeEvents(){typeof window!="undefined"&&typeof document!="undefined"&&this._resizeHandle&&(this._resizeHandle.addEventListener("mousedown",t=>{this.resizeState.isResizing=!0,this.resizeState.startX=t.clientX,this.resizeState.startY=t.clientY,this.resizeState.startWidth=this.panelEl.offsetWidth,this.resizeState.startHeight=this.panelEl.offsetHeight,t.preventDefault(),t.stopPropagation()}),document.addEventListener("mousemove",t=>{if(!this.resizeState.isResizing)return;let n=t.clientX-this.resizeState.startX,r=t.clientY-this.resizeState.startY,o=Math.max(this.config.minWidth,this.resizeState.startWidth+n),s=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${s}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1}))}bindKeyboardEvents(){typeof window!="undefined"&&typeof document!="undefined"&&document.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&t.key==="D"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&(this.statusLeftEl.innerHTML=e)}setStatusRight(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusRightEl&&(this.statusRightEl.textContent=e)}setConnected(e){if(typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&this.statusLeftEl.querySelector){let n=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");n&&n.classList&&n.classList.toggle("disconnected",!e)}}highlightElement(e){if(this.clearHighlight(),!e)return;if(typeof window!="undefined"&&typeof document!="undefined"){this.highlightOverlay=document.createElement("div"),this.highlightOverlay.style.cssText=`
|
|
286
|
+
position: fixed;
|
|
287
|
+
z-index: 999998;
|
|
288
|
+
pointer-events: none;
|
|
289
|
+
border: 2px solid #cba6f7;
|
|
290
|
+
background: rgba(203, 166, 247, 0.1);
|
|
291
|
+
border-radius: 2px;
|
|
292
|
+
transition: all 0.15s ease;
|
|
293
|
+
`;let n=e.getBoundingClientRect();this.highlightOverlay.style.left=`${n.left}px`,this.highlightOverlay.style.top=`${n.top}px`,this.highlightOverlay.style.width=`${n.width}px`,this.highlightOverlay.style.height=`${n.height}px`,document.body.appendChild(this.highlightOverlay)}}clearHighlight(){typeof window!="undefined"&&typeof document!="undefined"&&this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){let e=typeof window!="undefined"&&typeof document!="undefined";e&&this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),e&&this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),e&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],S=[],xe=0,F=null,C={},_=!1;function ze(){return`comp_${++xe}`}function Ne(){return`evt_${++xe}`}function ye(i){var t;if(!i)return"Unknown";let e=i.type||i.options;return e?e.name?e.name:e.render&&e.render.name?e.render.name:e.setup&&e.setup.name?e.setup.name:e._isComponentDefine&&((t=e.options)!=null&&t.name)?e.options.name:"Anonymous":"Anonymous"}function w(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>w(t));let e={};for(let t of Object.keys(i))e[t]=w(i[t]);return e}function $e(i,e){return i===e?!1:typeof i!=typeof e?!0:i===null||e===null?i!==e:typeof i=="object"?JSON.stringify(i)!==JSON.stringify(e):i!==e}function Ae(i,e){let t=e.split("."),n=i;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Fe(i,e,t){let n=e.split("."),r=i;for(let o=0;o<n.length-1;o++)(r[n[o]]===null||r[n[o]]===void 0||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function U(i,e){_||(e&&Object.assign(C,e),_=!0,_e(i),i._instance&&(O(i._instance,null),ue()))}function _e(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(O(i._instance,null),ue()),n}}function O(i,e){var o,s,l,p,c,a,d,u;if(!i)return;let t=be(i),n=!t;if(n){let h=ze();t={id:h,name:ye(i),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=i.isMounted)!=null?o:!1,isUnmounted:(s=i.isUnmounted)!=null?s:!1,el:(l=i.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:i},E.set(h,t)}else t&&(t.parentId=e,t.name=ye(i),t.isMounted=(p=i.isMounted)!=null?p:!1,t.isUnmounted=(c=i.isUnmounted)!=null?c:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now());t&&i.props&&(t.props=w(i.props)),t&&i.state&&(t.state=w(i.state)),t&&i.computedCache&&(t.computed=w(i.computedCache)),n&&t&&i.state&&typeof i.state=="object"&&Ue(t.id,i),n&&t&&i.emit&&typeof i.emit=="function"&&Oe(t.id,i),n&&t?(d=C.onComponentCreated)==null||d.call(C,t):t&&((u=C.onComponentUpdated)==null||u.call(C,t));let r=i.subTree;r&&t&&ve(r,t.id)}function ve(i,e){if(i){if(i.component){O(i.component,e);let t=E.get(e);if(t&&!t.childIds.includes(i.component.id||i.component._id)){let n=qe(i.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(i.children&&Array.isArray(i.children))for(let t of i.children)t&&typeof t=="object"&&ve(t,e)}}function Ue(i,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(i);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,s,l){var a;let p=o[s],c=Reflect.set(o,s,l);if($e(p,l)){let d=String(s),u={componentId:i,componentName:n.name,path:d,oldValue:w(p),newValue:w(l),timestamp:Date.now()};S.push(u),S.length>1e3&&S.splice(0,S.length-1e3),n.state=w(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return c}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function Oe(i,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(i);n&&(e.emit=function(r,...o){var l;let s={id:Ne(),name:r,timestamp:Date.now(),args:w(o),componentId:i,componentName:n.name};return M.push(s),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,s),t.call(this,r,...o)})}function ue(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function be(i){for(let e of E.values())if(e.instance===i)return e;return null}function qe(i){let e=be(i);return e?e.id:null}function L(){return Array.from(E.values())}function q(){for(let i of E.values())if(i.parentId===null)return i;return null}function H(i){var e;return(e=E.get(i))!=null?e:null}function j(i){let e=E.get(i);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function J(){return[...M]}function Te(){return[...S]}function V(i){return S.filter(e=>e.componentId===i)}function Ce(i){return M.filter(e=>e.componentId===i)}function W(i){F=i}function Y(){var i;return F&&(i=E.get(F))!=null?i:null}function k(){return F}function K(i,e,t){var l;let n=E.get(i);if(!n||!n.instance)return!1;let r=n.instance.state;if(!r||typeof r!="object")return!1;let o=Ae(r,e);Fe(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:w(o),newValue:w(t),timestamp:Date.now()};return S.push(s),n.state=w(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function X(i){E.clear(),i._instance&&(O(i._instance,null),ue())}function G(){M.length=0,S.length=0}function Q(){E.clear(),M.length=0,S.length=0,F=null,_=!1}function Ee(){return _}function we(){return E.size}var I=class{constructor(e,t){this.searchKeyword="";this.expandedNodes=new Set;this.container=null;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderTree()},100)};this.panel=e,this.onSelect=t||(()=>{});let n=q();n&&this.expandedNodes.add(n.id),typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderTree()}renderTree(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("input");e.type="text",e.className="lyt-devtools-search",e.placeholder="\u641C\u7D22\u7EC4\u4EF6...",e.value=this.searchKeyword,e.addEventListener("input",r=>{this.searchKeyword=r.target.value,this.renderTree()}),this.container.appendChild(e);let t=L();if(t.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent="\u6682\u65E0\u7EC4\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5E94\u7528\u5DF2\u6302\u8F7D\u3002",this.container.appendChild(r);return}let n=this.buildTree();for(let r of n){let o=this.renderTreeNode(r);o&&this.container.appendChild(o)}this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${t.length} \u4E2A\u7EC4\u4EF6</span>`)}buildTree(){let e=L(),t=new Map,n=[];for(let r of e){if(this.searchKeyword){let s=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(s),p=r.id.toLowerCase().includes(s);if(!l&&!p)continue}let o={info:r,children:[],depth:0,expanded:this.expandedNodes.has(r.id)};t.set(r.id,o)}for(let r of t.values()){let o=r.info.parentId;if(o&&t.has(o)){let s=t.get(o);s.children.push(r),r.depth=s.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=k(),s=t.id===o,l=document.createElement("div");l.className="lyt-tree-node",l.style.cssText=`
|
|
294
294
|
display: flex;
|
|
295
295
|
align-items: center;
|
|
296
296
|
padding: 3px 8px;
|
|
@@ -298,8 +298,8 @@
|
|
|
298
298
|
border-radius: 3px;
|
|
299
299
|
margin-bottom: 1px;
|
|
300
300
|
transition: background 0.1s ease;
|
|
301
|
-
${
|
|
302
|
-
`,l.addEventListener("mouseenter",()=>{
|
|
301
|
+
${s?"background: rgba(203, 166, 247, 0.15); border-left: 2px solid #cba6f7;":""}
|
|
302
|
+
`,l.addEventListener("mouseenter",()=>{s||(l.style.background="rgba(69, 71, 90, 0.5)")}),l.addEventListener("mouseleave",()=>{s||(l.style.background="")});let p=document.createElement("span");p.style.cssText=`display: inline-block; width: ${n*16}px; flex-shrink: 0;`,l.appendChild(p);let c=t.childIds.length>0,a=document.createElement("span");a.style.cssText=`
|
|
303
303
|
display: inline-flex;
|
|
304
304
|
align-items: center;
|
|
305
305
|
justify-content: center;
|
|
@@ -309,9 +309,9 @@
|
|
|
309
309
|
color: #6c7086;
|
|
310
310
|
flex-shrink: 0;
|
|
311
311
|
transition: transform 0.15s ease;
|
|
312
|
-
${
|
|
312
|
+
${c?"":"visibility: hidden;"}
|
|
313
313
|
${r?"transform: rotate(90deg);":""}
|
|
314
|
-
`,a.textContent="\u25B6",l.appendChild(a);let
|
|
314
|
+
`,a.textContent="\u25B6",l.appendChild(a);let d=document.createElement("span");d.style.cssText=`
|
|
315
315
|
display: inline-flex;
|
|
316
316
|
align-items: center;
|
|
317
317
|
justify-content: center;
|
|
@@ -320,14 +320,14 @@
|
|
|
320
320
|
font-size: 12px;
|
|
321
321
|
margin-right: 4px;
|
|
322
322
|
flex-shrink: 0;
|
|
323
|
-
`,
|
|
323
|
+
`,d.textContent=t.isUnmounted?"\u{1F480}":"\u{1F4E6}",l.appendChild(d);let u=document.createElement("span");u.style.cssText=`
|
|
324
324
|
flex: 1;
|
|
325
325
|
overflow: hidden;
|
|
326
326
|
text-overflow: ellipsis;
|
|
327
327
|
white-space: nowrap;
|
|
328
328
|
font-size: 12px;
|
|
329
|
-
color: ${
|
|
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(),
|
|
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(),c&&(this.expandedNodes.has(t.id)?this.expandedNodes.delete(t.id):this.expandedNodes.add(t.id)),W(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=k(),x=m?H(m):null;this.panel.highlightElement((v=x==null?void 0:x.el)!=null?v:null)}),r&&c){let m=j(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 je(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 he(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 Se(i){return i!==null&&typeof i=="object"&&!(i instanceof Date)&&!(i instanceof RegExp)}var B=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=Y();if(!e){let p=document.createElement("div");p.className="lyt-devtools-empty",p.textContent="\u8BF7\u5148\u5728\u7EC4\u4EF6\u6811\u4E2D\u9009\u62E9\u4E00\u4E2A\u7EC4\u4EF6\u3002",this.container.appendChild(p);return}let t=document.createElement("div");t.style.cssText=`
|
|
331
331
|
display: flex;
|
|
332
332
|
align-items: center;
|
|
333
333
|
justify-content: space-between;
|
|
@@ -345,7 +345,7 @@
|
|
|
345
345
|
cursor: pointer;
|
|
346
346
|
font-size: 11px;
|
|
347
347
|
font-family: inherit;
|
|
348
|
-
`,r.textContent="\u53D8\u5316\u5386\u53F2",r.addEventListener("click",()=>{this.showHistory=!this.showHistory,this.renderState()}),t.appendChild(n),t.appendChild(r),this.container.appendChild(t),this.showHistory?this.renderHistory(e):(this.renderCategory(container,"props",e.props,!0,!1,!1),this.renderCategory(container,"state",e.state,!1,!0,!1),this.renderCategory(container,"computed",e.computed,!1,!1,!0));let o=Object.keys(e.state).length,
|
|
348
|
+
`,r.textContent="\u53D8\u5316\u5386\u53F2",r.addEventListener("click",()=>{this.showHistory=!this.showHistory,this.renderState()}),t.appendChild(n),t.appendChild(r),this.container.appendChild(t),this.showHistory?this.renderHistory(e):(this.renderCategory(this.container,"props",e.props,!0,!1,!1),this.renderCategory(this.container,"state",e.state,!1,!0,!1),this.renderCategory(this.container,"computed",e.computed,!1,!1,!0));let o=Object.keys(e.state).length,s=Object.keys(e.props).length,l=Object.keys(e.computed).length;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${e.name}</span><span style="color: #585b70;">|</span><span>P:${s} S:${o} C:${l}</span>`)}renderCategory(e,t,n,r,o,s){let l=Object.keys(n);if(l.length===0)return;let p=document.createElement("div");p.style.cssText=`
|
|
349
349
|
display: flex;
|
|
350
350
|
align-items: center;
|
|
351
351
|
padding: 4px 8px;
|
|
@@ -356,14 +356,14 @@
|
|
|
356
356
|
color: #6c7086;
|
|
357
357
|
text-transform: uppercase;
|
|
358
358
|
letter-spacing: 0.5px;
|
|
359
|
-
`;let
|
|
359
|
+
`;let c={props:"Props",state:"State",computed:"Computed"},a={props:"#89b4fa",state:"#a6e3a1",computed:"#f9e2af"};p.innerHTML=`
|
|
360
360
|
<span style="color: ${a[t]}; margin-right: 6px;">\u25CF</span>
|
|
361
|
-
${
|
|
361
|
+
${c[t]}
|
|
362
362
|
<span style="color: #585b70; margin-left: 4px;">(${l.length})</span>
|
|
363
363
|
${r?'<span style="color: #585b70; margin-left: 6px; font-size: 10px;">[\u53EA\u8BFB]</span>':""}
|
|
364
364
|
${o?'<span style="color: #585b70; margin-left: 6px; font-size: 10px;">[\u54CD\u5E94\u5F0F]</span>':""}
|
|
365
|
-
${
|
|
366
|
-
`,e.appendChild(
|
|
365
|
+
${s?'<span style="color: #585b70; margin-left: 6px; font-size: 10px;">[\u7F13\u5B58]</span>':""}
|
|
366
|
+
`,e.appendChild(p);for(let d of l){let u=n[d],h=`${t}.${d}`,f=this.changedPaths.has(h),m=Se(u);this.renderProperty(e,{key:d,value:u,category:t,isReactive:o,isCached:s,isReadonly:r},h,0,m)}}renderProperty(e,t,n,r,o){let s=document.createElement("div");s.style.cssText=`
|
|
367
367
|
display: flex;
|
|
368
368
|
align-items: flex-start;
|
|
369
369
|
padding: 2px 8px;
|
|
@@ -371,7 +371,7 @@
|
|
|
371
371
|
cursor: default;
|
|
372
372
|
transition: background 0.1s ease;
|
|
373
373
|
${this.changedPaths.has(n)?"background: rgba(249, 226, 175, 0.1);":""}
|
|
374
|
-
`,
|
|
374
|
+
`,s.addEventListener("mouseenter",()=>{s.style.background="rgba(69, 71, 90, 0.3)"}),s.addEventListener("mouseleave",()=>{s.style.background=this.changedPaths.has(n)?"rgba(249, 226, 175, 0.1)":""});let l=document.createElement("span");l.style.cssText=`display: inline-block; width: ${r*16}px; flex-shrink: 0;`,s.appendChild(l);let p=document.createElement("span");p.style.cssText=`
|
|
375
375
|
display: inline-flex;
|
|
376
376
|
align-items: center;
|
|
377
377
|
justify-content: center;
|
|
@@ -383,13 +383,13 @@
|
|
|
383
383
|
transition: transform 0.15s ease;
|
|
384
384
|
${o?"":"visibility: hidden;"}
|
|
385
385
|
${this.expandedPaths.has(n)?"transform: rotate(90deg);":""}
|
|
386
|
-
`,
|
|
386
|
+
`,p.textContent="\u25B6",s.appendChild(p);let c=document.createElement("span");c.style.cssText=`
|
|
387
387
|
color: #89b4fa;
|
|
388
388
|
margin-right: 6px;
|
|
389
389
|
flex-shrink: 0;
|
|
390
390
|
font-size: 12px;
|
|
391
391
|
min-width: 60px;
|
|
392
|
-
`,
|
|
392
|
+
`,c.textContent=t.key,s.appendChild(c);let a=document.createElement("span");a.style.cssText="color: #6c7086; margin-right: 6px; flex-shrink: 0;",a.textContent=":",s.appendChild(a);let d=document.createElement("span"),u=je(t.value),h={string:"#a6e3a1",number:"#fab387",boolean:"#89b4fa",null:"#6c7086",undefined:"#6c7086",function:"#cba6f7",Object:"#cdd6f4",Array:"#f9e2af",Date:"#f38ba8",RegExp:"#f38ba8"};d.style.cssText=`
|
|
393
393
|
color: ${h[u]||"#cdd6f4"};
|
|
394
394
|
font-size: 12px;
|
|
395
395
|
flex: 1;
|
|
@@ -397,12 +397,12 @@
|
|
|
397
397
|
text-overflow: ellipsis;
|
|
398
398
|
white-space: nowrap;
|
|
399
399
|
cursor: ${t.isReadonly?"default":"text"};
|
|
400
|
-
`,
|
|
400
|
+
`,d.textContent=he(t.value),s.appendChild(d);let f=document.createElement("span");if(f.style.cssText=`
|
|
401
401
|
color: #585b70;
|
|
402
402
|
font-size: 10px;
|
|
403
403
|
flex-shrink: 0;
|
|
404
404
|
margin-left: 6px;
|
|
405
|
-
`,f.textContent=u,
|
|
405
|
+
`,f.textContent=u,s.appendChild(f),o&&s.addEventListener("click",m=>{m.stopPropagation(),this.expandedPaths.has(n)?this.expandedPaths.delete(n):this.expandedPaths.add(n),this.renderState()}),!t.isReadonly&&t.category==="state"&&d.addEventListener("dblclick",m=>{m.stopPropagation(),this.startEdit(s,t,n,d)}),e.appendChild(s),o&&this.expandedPaths.has(n)){let m=t.value,x=Object.keys(m);for(let v of x){let y=`${n}.${v}`,g=m[v],b=Se(g);this.renderProperty(e,{key:v,value:g,category:t.category,isReactive:t.isReactive,isCached:t.isCached,isReadonly:t.isReadonly},y,r+1,b)}}}startEdit(e,t,n,r){let o=k();if(!o)return;let s=document.createElement("input");s.type="text",s.style.cssText=`
|
|
406
406
|
background: #181825;
|
|
407
407
|
border: 1px solid #cba6f7;
|
|
408
408
|
color: #cdd6f4;
|
|
@@ -413,23 +413,23 @@
|
|
|
413
413
|
outline: none;
|
|
414
414
|
width: 100%;
|
|
415
415
|
box-sizing: border-box;
|
|
416
|
-
`;let l;typeof t.value=="string"?(l=t.value,
|
|
416
|
+
`;let l;typeof t.value=="string"?(l=t.value,s.value=t.value):(l=JSON.stringify(t.value),s.value=l),r.style.display="none",e.insertBefore(s,r.nextSibling),s.focus(),s.select();let p=()=>{let a,d=s.value;try{a=JSON.parse(d)}catch(h){a=d}let u=n.replace(/^state\./,"");K(o,u,a),s.remove(),r.style.display="",this.renderState()},c=()=>{s.remove(),r.style.display=""};s.addEventListener("keydown",a=>{a.key==="Enter"?(a.preventDefault(),p()):a.key==="Escape"&&(a.preventDefault(),c())}),s.addEventListener("blur",()=>{p()})}renderHistory(e){let t=V(e.id);if(t.length===0){let o=document.createElement("div");o.className="lyt-devtools-empty",o.textContent="\u6682\u65E0\u72B6\u6001\u53D8\u5316\u8BB0\u5F55\u3002",this.container.appendChild(o);return}let n=document.createElement("div");n.style.cssText="max-height: 400px; overflow-y: auto;";let r=[...t].reverse();for(let o=0;o<r.length;o++){let s=r[o],l=document.createElement("div");l.style.cssText=`
|
|
417
417
|
padding: 6px 8px;
|
|
418
418
|
border-bottom: 1px solid #313244;
|
|
419
419
|
font-size: 11px;
|
|
420
420
|
cursor: default;
|
|
421
421
|
transition: background 0.1s ease;
|
|
422
|
-
`,l.addEventListener("mouseenter",()=>{l.style.background="rgba(69, 71, 90, 0.3)"}),l.addEventListener("mouseleave",()=>{l.style.background=""});let
|
|
422
|
+
`,l.addEventListener("mouseenter",()=>{l.style.background="rgba(69, 71, 90, 0.3)"}),l.addEventListener("mouseleave",()=>{l.style.background=""});let p=new Date(s.timestamp).toLocaleTimeString();l.innerHTML=`
|
|
423
423
|
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px;">
|
|
424
|
-
<span style="color: #89b4fa; font-weight: 600;">${
|
|
425
|
-
<span style="color: #585b70;">${
|
|
424
|
+
<span style="color: #89b4fa; font-weight: 600;">${s.path}</span>
|
|
425
|
+
<span style="color: #585b70;">${p}</span>
|
|
426
426
|
</div>
|
|
427
427
|
<div style="display: flex; align-items: center; gap: 6px;">
|
|
428
|
-
<span style="color: #f38ba8; text-decoration: line-through; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${he(
|
|
428
|
+
<span style="color: #f38ba8; text-decoration: line-through; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${he(s.oldValue,40)}</span>
|
|
429
429
|
<span style="color: #6c7086;">\u2192</span>
|
|
430
|
-
<span style="color: #a6e3a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${he(
|
|
430
|
+
<span style="color: #a6e3a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${he(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 Je(
|
|
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(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 Re(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 Ve(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"};
|
|
@@ -451,7 +451,7 @@
|
|
|
451
451
|
font-family: inherit;
|
|
452
452
|
white-space: nowrap;
|
|
453
453
|
flex-shrink: 0;
|
|
454
|
-
`,o.textContent="\u6E05\u7A7A",o.addEventListener("click",()=>{this.clearEvents()}),e.appendChild(o),this.container.appendChild(e);let
|
|
454
|
+
`,o.textContent="\u6E05\u7A7A",o.addEventListener("click",()=>{this.clearEvents()}),e.appendChild(o),this.container.appendChild(e);let s=J();if(this.nameFilter){let a=this.nameFilter.toLowerCase();s=s.filter(d=>d.name.toLowerCase().includes(a))}if(this.componentFilter){let a=this.componentFilter.toLowerCase();s=s.filter(d=>d.componentName.toLowerCase().includes(a))}if(this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${s.length} \u4E2A\u4E8B\u4EF6${this.paused?" (\u5DF2\u6682\u505C)":""}</span>`),s.length===0){let a=document.createElement("div");a.className="lyt-devtools-empty",a.textContent=this.nameFilter||this.componentFilter?"\u6CA1\u6709\u5339\u914D\u7684\u4E8B\u4EF6\u8BB0\u5F55\u3002":"\u6682\u65E0\u4E8B\u4EF6\u8BB0\u5F55\uFF0C\u7B49\u5F85\u7EC4\u4EF6\u89E6\u53D1\u4E8B\u4EF6...",this.container.appendChild(a);return}if(this.selectedEventId){let a=s.find(d=>d.id===this.selectedEventId);a&&this.renderEventDetail(a)}let l=document.createElement("div");l.style.cssText="max-height: 360px; overflow-y: auto;";let p=[...s].reverse(),c=Math.min(p.length,200);for(let a=0;a<c;a++){let d=p[a],u=d.id===this.selectedEventId,h=document.createElement("div");h.style.cssText=`
|
|
455
455
|
display: flex;
|
|
456
456
|
align-items: center;
|
|
457
457
|
padding: 4px 8px;
|
|
@@ -460,7 +460,7 @@
|
|
|
460
460
|
font-size: 11px;
|
|
461
461
|
transition: background 0.1s ease;
|
|
462
462
|
${u?"background: rgba(203, 166, 247, 0.15); border-left: 2px solid #cba6f7;":""}
|
|
463
|
-
`,h.addEventListener("mouseenter",()=>{u||(h.style.background="rgba(69, 71, 90, 0.3)")}),h.addEventListener("mouseleave",()=>{u||(h.style.background="")});let f=document.createElement("span");f.style.cssText="color: #585b70; margin-right: 8px; flex-shrink: 0; font-size: 10px;",f.textContent=Re(
|
|
463
|
+
`,h.addEventListener("mouseenter",()=>{u||(h.style.background="rgba(69, 71, 90, 0.3)")}),h.addEventListener("mouseleave",()=>{u||(h.style.background="")});let f=document.createElement("span");f.style.cssText="color: #585b70; margin-right: 8px; flex-shrink: 0; font-size: 10px;",f.textContent=Re(d.timestamp),h.appendChild(f);let m=document.createElement("span");m.style.cssText=`
|
|
464
464
|
color: #f9e2af;
|
|
465
465
|
font-weight: 600;
|
|
466
466
|
margin-right: 8px;
|
|
@@ -469,7 +469,7 @@
|
|
|
469
469
|
overflow: hidden;
|
|
470
470
|
text-overflow: ellipsis;
|
|
471
471
|
white-space: nowrap;
|
|
472
|
-
`,m.textContent=
|
|
472
|
+
`,m.textContent=d.name,m.title=d.name,h.appendChild(m);let x=document.createElement("span");x.style.cssText=`
|
|
473
473
|
color: #89b4fa;
|
|
474
474
|
margin-right: 8px;
|
|
475
475
|
flex-shrink: 0;
|
|
@@ -477,36 +477,36 @@
|
|
|
477
477
|
overflow: hidden;
|
|
478
478
|
text-overflow: ellipsis;
|
|
479
479
|
white-space: nowrap;
|
|
480
|
-
`,x.textContent=
|
|
480
|
+
`,x.textContent=d.componentName,x.title=d.componentName,h.appendChild(x);let v=d.args.map(b=>Je(b,30)).join(", "),y=document.createElement("span");y.style.cssText=`
|
|
481
481
|
color: #6c7086;
|
|
482
482
|
flex: 1;
|
|
483
483
|
overflow: hidden;
|
|
484
484
|
text-overflow: ellipsis;
|
|
485
485
|
white-space: nowrap;
|
|
486
486
|
font-size: 10px;
|
|
487
|
-
`,y.textContent=
|
|
487
|
+
`,y.textContent=d.args.length>0?`(${v})`:"()",y.title=d.args.length>0?v:"\u65E0\u53C2\u6570",h.appendChild(y);let g=document.createElement("span");g.style.cssText="color: #45475a; flex-shrink: 0; font-size: 10px; margin-left: 4px;",g.textContent=Ve(d.timestamp),h.appendChild(g),h.addEventListener("click",()=>{this.selectedEventId===d.id?this.selectedEventId=null:this.selectedEventId=d.id,this.renderEvents()}),l.appendChild(h)}if(p.length>c){let a=document.createElement("div");a.style.cssText="padding: 6px 8px; text-align: center; color: #585b70; font-size: 11px;",a.textContent=`\u8FD8\u6709 ${p.length-c} \u6761\u8BB0\u5F55\u672A\u663E\u793A...`,l.appendChild(a)}this.container.appendChild(l)}renderEventDetail(e){let t=document.createElement("div");t.style.cssText=`
|
|
488
488
|
background: #181825;
|
|
489
489
|
border: 1px solid #313244;
|
|
490
490
|
border-radius: 4px;
|
|
491
491
|
padding: 8px;
|
|
492
492
|
margin-bottom: 8px;
|
|
493
|
-
`;let n=document.createElement("div");n.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;";let r=document.createElement("span");r.style.cssText="font-weight: 600; color: #f9e2af; font-size: 12px;",r.textContent=`\u4E8B\u4EF6: ${e.name}`;let o=document.createElement("span");o.style.cssText="cursor: pointer; color: #6c7086; font-size: 14px;",o.textContent="\u2715",o.addEventListener("click",()=>{this.selectedEventId=null,this.renderEvents()}),n.appendChild(r),n.appendChild(o),t.appendChild(n);let
|
|
493
|
+
`;let n=document.createElement("div");n.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;";let r=document.createElement("span");r.style.cssText="font-weight: 600; color: #f9e2af; font-size: 12px;",r.textContent=`\u4E8B\u4EF6: ${e.name}`;let o=document.createElement("span");o.style.cssText="cursor: pointer; color: #6c7086; font-size: 14px;",o.textContent="\u2715",o.addEventListener("click",()=>{this.selectedEventId=null,this.renderEvents()}),n.appendChild(r),n.appendChild(o),t.appendChild(n);let s=document.createElement("div");if(s.style.cssText="display: flex; gap: 12px; margin-bottom: 6px; font-size: 11px;",s.innerHTML=`
|
|
494
494
|
<span><span style="color: #6c7086;">\u6765\u6E90\u7EC4\u4EF6:</span> <span style="color: #89b4fa;">${e.componentName}</span></span>
|
|
495
495
|
<span><span style="color: #6c7086;">\u7EC4\u4EF6 ID:</span> <span style="color: #585b70;">${e.componentId}</span></span>
|
|
496
496
|
<span><span style="color: #6c7086;">\u65F6\u95F4:</span> <span style="color: #585b70;">${Re(e.timestamp)}</span></span>
|
|
497
|
-
`,t.appendChild(
|
|
497
|
+
`,t.appendChild(s),e.args.length>0){let l=document.createElement("div");l.style.cssText="color: #6c7086; font-size: 11px; margin-bottom: 4px; font-weight: 600;",l.textContent=`\u53C2\u6570 (${e.args.length}):`,t.appendChild(l);for(let p=0;p<e.args.length;p++){let c=document.createElement("div");c.style.cssText=`
|
|
498
498
|
padding: 3px 8px;
|
|
499
499
|
background: #1e1e2e;
|
|
500
500
|
border-radius: 2px;
|
|
501
501
|
margin-bottom: 2px;
|
|
502
502
|
font-size: 11px;
|
|
503
503
|
font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
|
|
504
|
-
`;let a=e.args[
|
|
505
|
-
... (\u5DF2\u622A\u65AD)`),
|
|
506
|
-
<span style="color: #6c7086;">[${
|
|
507
|
-
<span style="color: #585b70; margin: 0 4px;">${
|
|
504
|
+
`;let a=e.args[p],d=typeof a,u;try{u=JSON.stringify(a,null,2)}catch(h){u=String(a)}u.length>500&&(u=u.slice(0,500)+`
|
|
505
|
+
... (\u5DF2\u622A\u65AD)`),c.innerHTML=`
|
|
506
|
+
<span style="color: #6c7086;">[${p}]</span>
|
|
507
|
+
<span style="color: #585b70; margin: 0 4px;">${d}:</span>
|
|
508
508
|
<span style="color: #a6e3a1; white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(u)}</span>
|
|
509
|
-
`,t.appendChild(
|
|
509
|
+
`,t.appendChild(c)}}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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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(i){if(i===null||typeof i!="object")return i;if(i instanceof Map){let t=new Map;for(let[n,r]of i)t.set(n,P(r));return t}if(Array.isArray(i))return i.map(t=>P(t));let e={};for(let t of Object.keys(i))e[t]=P(i[t]);return e}function We(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")}`}var N=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=L(),r=new Map;for(let s of n)r.set(s.id,{id:s.id,name:s.name,state:P(s.state),props:P(s.props),computed:P(s.computed),isMounted:s.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 s=Object.keys(r.state);for(let l of s)try{o.instance.state[l]=P(r.state[l])}catch(p){}}}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 s=document.createElement("input");s.type="checkbox",s.checked=this.autoSnapshot,s.style.cssText="cursor: pointer;",s.addEventListener("change",()=>{this.autoSnapshot=s.checked}),o.appendChild(s),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;
|
|
@@ -515,7 +515,7 @@
|
|
|
515
515
|
border: 1px solid #313244;
|
|
516
516
|
border-radius: 4px;
|
|
517
517
|
margin-bottom: 8px;
|
|
518
|
-
`;let n=document.createElement("button");n.style.cssText=this.createSmallButtonStyle(),n.textContent="\u23EE",n.title="\u6B65\u9000",n.disabled=this.currentIndex<=0,n.addEventListener("click",()=>this.stepBack()),t.appendChild(n);let r=document.createElement("button");r.style.cssText=this.createSmallButtonStyle(),this.playState==="playing"?(r.textContent="\u23F8",r.title="\u6682\u505C",r.addEventListener("click",()=>this.pausePlayback())):(r.textContent="\u25B6",r.title="\u64AD\u653E",r.addEventListener("click",()=>this.startPlayback())),t.appendChild(r);let o=document.createElement("button");o.style.cssText=this.createSmallButtonStyle(),o.textContent="\u23F9",o.title="\u505C\u6B62",o.disabled=this.playState==="stopped",o.addEventListener("click",()=>this.stopPlayback()),t.appendChild(o);let
|
|
518
|
+
`;let n=document.createElement("button");n.style.cssText=this.createSmallButtonStyle(),n.textContent="\u23EE",n.title="\u6B65\u9000",n.disabled=this.currentIndex<=0,n.addEventListener("click",()=>this.stepBack()),t.appendChild(n);let r=document.createElement("button");r.style.cssText=this.createSmallButtonStyle(),this.playState==="playing"?(r.textContent="\u23F8",r.title="\u6682\u505C",r.addEventListener("click",()=>this.pausePlayback())):(r.textContent="\u25B6",r.title="\u64AD\u653E",r.addEventListener("click",()=>this.startPlayback())),t.appendChild(r);let o=document.createElement("button");o.style.cssText=this.createSmallButtonStyle(),o.textContent="\u23F9",o.title="\u505C\u6B62",o.disabled=this.playState==="stopped",o.addEventListener("click",()=>this.stopPlayback()),t.appendChild(o);let s=document.createElement("button");s.style.cssText=this.createSmallButtonStyle(),s.textContent="\u23ED",s.title="\u6B65\u8FDB",s.disabled=this.currentIndex>=this.snapshots.length-1,s.addEventListener("click",()=>this.stepForward()),t.appendChild(s);let l=document.createElement("input");l.type="range",l.min="0",l.max=String(Math.max(0,this.snapshots.length-1)),l.value=String(Math.max(0,this.currentIndex)),l.style.cssText=`
|
|
519
519
|
flex: 1;
|
|
520
520
|
height: 4px;
|
|
521
521
|
-webkit-appearance: none;
|
|
@@ -524,7 +524,7 @@
|
|
|
524
524
|
border-radius: 2px;
|
|
525
525
|
outline: none;
|
|
526
526
|
cursor: pointer;
|
|
527
|
-
`,l.addEventListener("input",
|
|
527
|
+
`,l.addEventListener("input",d=>{let u=parseInt(d.target.value,10);this.travelTo(u)}),t.appendChild(l);let p=document.createElement("select");p.style.cssText=`
|
|
528
528
|
background: #1e1e2e;
|
|
529
529
|
color: #cdd6f4;
|
|
530
530
|
border: 1px solid #313244;
|
|
@@ -534,7 +534,7 @@
|
|
|
534
534
|
font-family: inherit;
|
|
535
535
|
cursor: pointer;
|
|
536
536
|
outline: none;
|
|
537
|
-
`;let
|
|
537
|
+
`;let c=[{value:200,label:"0.5x"},{value:500,label:"1x"},{value:1e3,label:"2x"},{value:2e3,label:"4x"}];for(let d of c){let u=document.createElement("option");u.value=String(d.value),u.textContent=d.label,d.value===this.playSpeed&&(u.selected=!0),p.appendChild(u)}p.addEventListener("change",d=>{this.setPlaySpeed(parseInt(d.target.value,10))}),t.appendChild(p);let a=document.createElement("span");a.style.cssText="color: #6c7086; font-size: 11px; flex-shrink: 0; min-width: 40px; text-align: right;",a.textContent=this.currentIndex===-1?`--/${this.snapshots.length}`:`${this.currentIndex+1}/${this.snapshots.length}`,t.appendChild(a),e.appendChild(t)}renderSnapshotList(e){if(this.snapshots.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent='\u6682\u65E0\u5FEB\u7167\u3002\u70B9\u51FB"\u5FEB\u7167"\u6309\u94AE\u624B\u52A8\u521B\u5EFA\uFF0C\u6216\u5F00\u542F"\u81EA\u52A8\u5FEB\u7167"\u3002',e.appendChild(r);return}let t=document.createElement("div");t.style.cssText="max-height: 300px; overflow-y: auto;";let n=[...this.snapshots].reverse();for(let r=n.length-1;r>=0;r--){let o=n[r],s=this.snapshots.indexOf(o),l=s===this.currentIndex,p=document.createElement("div");p.style.cssText=`
|
|
538
538
|
display: flex;
|
|
539
539
|
align-items: center;
|
|
540
540
|
padding: 4px 8px;
|
|
@@ -543,7 +543,7 @@
|
|
|
543
543
|
font-size: 11px;
|
|
544
544
|
transition: background 0.1s ease;
|
|
545
545
|
${l?"background: rgba(203, 166, 247, 0.15); border-left: 2px solid #cba6f7;":""}
|
|
546
|
-
`,
|
|
546
|
+
`,p.addEventListener("mouseenter",()=>{l||(p.style.background="rgba(69, 71, 90, 0.3)")}),p.addEventListener("mouseleave",()=>{l||(p.style.background="")});let c=document.createElement("span");c.style.cssText="color: #585b70; margin-right: 6px; flex-shrink: 0; min-width: 24px;",c.textContent=`#${o.id}`,p.appendChild(c);let a=document.createElement("span");a.style.cssText="color: #585b70; margin-right: 8px; flex-shrink: 0; font-size: 10px;",a.textContent=We(o.timestamp),p.appendChild(a);let d=document.createElement("span");d.style.cssText="color: #cdd6f4; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",d.textContent=o.description,p.appendChild(d);let u=document.createElement("span");u.style.cssText="color: #6c7086; flex-shrink: 0; font-size: 10px; margin-left: 4px;",u.textContent=`${o.components.size} \u7EC4\u4EF6`,p.appendChild(u);let h=document.createElement("span");h.style.cssText=`
|
|
547
547
|
color: #585b70;
|
|
548
548
|
cursor: pointer;
|
|
549
549
|
margin-left: 6px;
|
|
@@ -554,7 +554,7 @@
|
|
|
554
554
|
flex-shrink: 0;
|
|
555
555
|
transition: all 0.15s ease;
|
|
556
556
|
`,h.textContent="\u6062\u590D",h.title="\u6062\u590D\u6B64\u5FEB\u7167\u7684\u72B6\u6001",h.addEventListener("mouseenter",()=>{h.style.color="#f9e2af",h.style.borderColor="#f9e2af"}),h.addEventListener("mouseleave",()=>{h.style.color="#585b70",h.style.borderColor="#313244"}),h.addEventListener("click",f=>{f.stopPropagation(),confirm(`\u786E\u5B9A\u8981\u6062\u590D\u5FEB\u7167 #${o.id} \u7684\u72B6\u6001\u5417\uFF1F
|
|
557
|
-
\u8FD9\u5C06\u4FEE\u6539\u7EC4\u4EF6\u7684\u5B9E\u9645\u72B6\u6001\u3002`)&&this.restoreSnapshot(
|
|
557
|
+
\u8FD9\u5C06\u4FEE\u6539\u7EC4\u4EF6\u7684\u5B9E\u9645\u72B6\u6001\u3002`)&&this.restoreSnapshot(s)}),p.appendChild(h),p.addEventListener("click",()=>{this.travelTo(s)}),t.appendChild(p)}e.appendChild(t)}createButtonStyle(e,t){return`
|
|
558
558
|
background: ${e};
|
|
559
559
|
color: ${t};
|
|
560
560
|
border: none;
|
|
@@ -581,7 +581,7 @@
|
|
|
581
581
|
flex-shrink: 0;
|
|
582
582
|
transition: all 0.15s ease;
|
|
583
583
|
padding: 0;
|
|
584
|
-
`}refresh(){this.renderTimeTravel()}destroy(){this.stopPlayback(),this.updateTimer&&clearTimeout(this.updateTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.snapshots=[]}};var Z=class{constructor(e,t){this.history=[];this.currentPath="/";this.currentParams={};this.currentQuery={};var n;this.container=e,this.maxHistory=(n=t==null?void 0:t.maxHistory)!=null?n:50,this.render()}updateRoute(e,t,n){this.history.push({path:e,params:t?{...t}:void 0,query:n?{...n}:void 0,timestamp:Date.now()}),this.history.length>this.maxHistory&&this.history.shift(),this.currentPath=e,this.currentParams=t?{...t}:{},this.currentQuery=n?{...n}:{},this.render()}getHistory(){return[...this.history].reverse()}getCurrentPath(){return this.currentPath}clearHistory(){this.history=[],this.render()}render(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="margin-bottom: 16px;";let t=document.createElement("div");t.style.cssText="font-size: 11px; color: #a6adc8; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;",t.textContent="Current Route",e.appendChild(t);let n=document.createElement("div");n.style.cssText="display: flex; align-items: center; gap: 8px; margin-bottom: 6px;";let r=document.createElement("span");r.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",r.textContent="Path:";let o=document.createElement("span");if(o.style.cssText="color: #cba6f7; font-size: 13px; font-weight: 600;",o.textContent=this.currentPath||"/",n.appendChild(r),n.appendChild(o),e.appendChild(n),Object.keys(this.currentParams).length>0){let p=document.createElement("div");p.style.cssText="display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;";let a=document.createElement("span");a.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",a.textContent="Params:";let c=document.createElement("span");c.style.cssText="color: #a6e3a1; font-size: 12px;",c.textContent=JSON.stringify(this.currentParams),p.appendChild(a),p.appendChild(c),e.appendChild(p)}if(Object.keys(this.currentQuery).length>0){let p=document.createElement("div");p.style.cssText="display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;";let a=document.createElement("span");a.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",a.textContent="Query:";let c=document.createElement("span");c.style.cssText="color: #89b4fa; font-size: 12px;",c.textContent=JSON.stringify(this.currentQuery),p.appendChild(a),p.appendChild(c),e.appendChild(p)}this.container.appendChild(e);let i=document.createElement("div");i.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;";let l=document.createElement("span");l.style.cssText="font-size: 11px; color: #a6adc8; text-transform: uppercase; letter-spacing: 0.5px;",l.textContent=`History (${this.history.length})`,i.appendChild(l);let d=document.createElement("button");if(d.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",d.textContent="Clear",d.addEventListener("click",()=>this.clearHistory()),i.appendChild(d),this.container.appendChild(i),this.history.length===0){let p=document.createElement("div");p.style.cssText="color: #585b70; font-size: 12px; text-align: center; padding: 16px 0; font-style: italic;",p.textContent="No navigation history",this.container.appendChild(p)}else{let p=document.createElement("div");p.style.cssText="max-height: 300px; overflow-y: auto;";let a=[...this.history].reverse();for(let c of a){let u=document.createElement("div");u.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; border-radius: 3px; font-size: 12px; transition: background 0.15s; cursor: default;",u.addEventListener("mouseenter",()=>{u.style.background="#313244"}),u.addEventListener("mouseleave",()=>{u.style.background="transparent"});let h=document.createElement("span");h.style.cssText="color: #cdd6f4; font-family: inherit;",h.textContent=c.path;let f=document.createElement("span");f.style.cssText="color: #585b70; font-size: 10px; white-space: nowrap;";let m=new Date(c.timestamp);f.textContent=`${m.getHours().toString().padStart(2,"0")}:${m.getMinutes().toString().padStart(2,"0")}:${m.getSeconds().toString().padStart(2,"0")}.${m.getMilliseconds().toString().padStart(3,"0")}`,u.appendChild(h),u.appendChild(f),p.appendChild(u)}this.container.appendChild(p)}}destroy(){this.container.innerHTML="",this.history=[]}};var R=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}},Ye=100,Ke=16,B=class{constructor(e=Ye){this.pendingMarks=new Map;this.componentUpdateCounts=new Map;this._isRecording=!1;this.bufferSize=e,this.fcpBuffer=new R(e),this.inpBuffer=new R(e),this.renderBuffer=new R(e),this.updateFrequencyBuffer=new R(e),this.memoryBuffer=new R(e),this.customMarkBuffer=new R(e),this.fpsBuffer=new R(e),this.fpsState={isMonitoring:!1,frameCount:0,lastTime:0,rafId:null}}recordFCP(e){if(e===void 0)if(typeof performance!="undefined"&&performance.getEntriesByType){let n=performance.getEntriesByType("paint").find(r=>r.name==="first-contentful-paint");e=n?n.startTime:0}else e=0;this.fcpBuffer.push({type:"fcp",value:e,timestamp:Date.now()})}recordINP(e,t,n){this.inpBuffer.push({type:"inp",value:e,eventName:t,componentName:n,timestamp:Date.now()})}recordRender(e,t,n="update",r){this.renderBuffer.push({type:"render",value:t,componentName:e,componentId:r,phase:n,timestamp:Date.now()}),this.trackComponentUpdate(e)}trackComponentUpdate(e){let t=Date.now(),n=this.componentUpdateCounts.get(e);if(!n){this.componentUpdateCounts.set(e,{count:1,startTime:t});return}n.count++;let r=t-n.startTime;r>=1e3&&(this.updateFrequencyBuffer.push({type:"update-frequency",componentName:e,count:n.count,windowMs:r,timestamp:t}),n.count=0,n.startTime=t)}recordMemory(e,t){this.memoryBuffer.push({type:"memory",proxyCount:e,reactiveCount:t,timestamp:Date.now()})}startMark(e){this.pendingMarks.set(e,performance.now())}endMark(e){let t=this.pendingMarks.get(e);if(t===void 0)return-1;let n=performance.now()-t;return this.pendingMarks.delete(e),this.customMarkBuffer.push({type:"custom",name:e,value:n,timestamp:Date.now()}),n}startFPSMonitor(){if(this.fpsState.isMonitoring||typeof requestAnimationFrame!="function")return;this.fpsState.isMonitoring=!0,this.fpsState.frameCount=0,this.fpsState.lastTime=performance.now();let e=t=>{if(!this.fpsState.isMonitoring)return;this.fpsState.frameCount++;let n=t-this.fpsState.lastTime;if(n>=1e3){let r=this.fpsState.frameCount/n*1e3;this.fpsBuffer.push({type:"fps",value:Math.round(r),timestamp:Date.now()}),this.fpsState.frameCount=0,this.fpsState.lastTime=t}this.fpsState.rafId=requestAnimationFrame(e)};this.fpsState.rafId=requestAnimationFrame(e)}stopFPSMonitor(){this.fpsState.isMonitoring=!1,this.fpsState.rafId!==null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.fpsState.rafId),this.fpsState.rafId=null)}isFPSMonitoring(){return this.fpsState.isMonitoring}startRecording(){this._isRecording=!0,this.startFPSMonitor()}stopRecording(){this._isRecording=!1,this.stopFPSMonitor()}isRecording(){return this._isRecording}getMetrics(){return[...this.fcpBuffer.getAll(),...this.inpBuffer.getAll(),...this.renderBuffer.getAll(),...this.updateFrequencyBuffer.getAll(),...this.memoryBuffer.getAll(),...this.customMarkBuffer.getAll(),...this.fpsBuffer.getAll()]}getMetricsByType(e){return this.getMetrics().filter(n=>n.type===e)}getCurrentFPS(){let e=this.fpsBuffer.getAll();return e.length===0?0:e[e.length-1].value}getRenderRankings(){let e=new Map;for(let t of this.renderBuffer.getAll()){let n=e.get(t.componentName)||{renderCount:0,totalTime:0,maxTime:0};n.renderCount++,n.totalTime+=t.value,n.maxTime=Math.max(n.maxTime,t.value),e.set(t.componentName,n)}return Array.from(e.entries()).map(([t,n])=>({componentName:t,renderCount:n.renderCount,avgRenderTime:n.renderCount>0?n.totalTime/n.renderCount:0,maxRenderTime:n.maxTime,totalRenderTime:n.totalTime})).sort((t,n)=>n.avgRenderTime-t.avgRenderTime)}getProxyCount(){let e=this.memoryBuffer.getAll();return e.length===0?0:e[e.length-1].proxyCount}getSlowRenders(){return this.renderBuffer.getAll().filter(e=>e.value>Ke)}getReport(){let e=this.fcpBuffer.getAll(),t=e.length>0?e[e.length-1]:null,r=this.inpBuffer.getAll().map(y=>y.value),o={avg:r.length>0?r.reduce((y,g)=>y+g,0)/r.length:0,max:r.length>0?Math.max(...r):0,min:r.length>0?Math.min(...r):0,count:r.length},i=this.getRenderRankings(),l=this.updateFrequencyBuffer.getAll(),d=new Map;for(let y of l){let g=y.count/y.windowMs*1e3,b=d.get(y.componentName)||[];b.push(g),d.set(y.componentName,b)}let p=Array.from(d.entries()).map(([y,g])=>({componentName:y,avgFrequency:g.reduce((b,T)=>b+T,0)/g.length})),a=this.memoryBuffer.getAll(),c=a.length>0?a[a.length-1]:null,h=this.fpsBuffer.getAll().map(y=>y.value),f={avg:h.length>0?h.reduce((y,g)=>y+g,0)/h.length:0,min:h.length>0?Math.min(...h):0,count:h.length},m=this.customMarkBuffer.getAll(),x=new Map;for(let y of m){let g=x.get(y.name)||[];g.push(y.value),x.set(y.name,g)}let v=Array.from(x.entries()).map(([y,g])=>({name:y,avg:g.reduce((b,T)=>b+T,0)/g.length,max:Math.max(...g),count:g.length}));return{generatedAt:Date.now(),fcp:t,inp:o,renderStats:i,updateFrequencyStats:p,memory:c,fps:f,customMarks:v}}exportJSON(){return JSON.stringify({metrics:this.getMetrics(),report:this.getReport()},null,2)}clear(){this.fcpBuffer.clear(),this.inpBuffer.clear(),this.renderBuffer.clear(),this.updateFrequencyBuffer.clear(),this.memoryBuffer.clear(),this.customMarkBuffer.clear(),this.fpsBuffer.clear(),this.pendingMarks.clear(),this.componentUpdateCounts.clear()}destroy(){this.stopFPSMonitor(),this.clear()}};var A=class{constructor(e=16){this.activeProfiles=new Map;this.slowThreshold=e}startProfile(e){return this.activeProfiles.has(e)?!1:(this.activeProfiles.set(e,{componentName:e,startTime:performance.now(),records:[],slowThreshold:this.slowThreshold}),!0)}stopProfile(e){let t=this.activeProfiles.get(e);return t?(this.activeProfiles.delete(e),this.buildResult(t)):null}stopAllProfiles(){let e=[];for(let t of this.activeProfiles.values())e.push(this.buildResult(t));return this.activeProfiles.clear(),e}recordRender(e,t){let n=this.activeProfiles.get(e);if(!n)return;let r={duration:t,timestamp:Date.now(),isSlow:t>n.slowThreshold};n.records.push(r)}getSnapshot(e){let t=this.activeProfiles.get(e);return t?this.buildResult(t):null}isProfiling(e){return this.activeProfiles.has(e)}getActiveProfileNames(){return Array.from(this.activeProfiles.keys())}getActiveProfileCount(){return this.activeProfiles.size}getSlowRenders(e){let t=this.activeProfiles.get(e);return t?t.records.filter(n=>n.isSlow):[]}setSlowThreshold(e){this.slowThreshold=e;for(let t of this.activeProfiles.values()){t.slowThreshold=e;for(let n of t.records)n.isSlow=n.duration>e}}getSlowThreshold(){return this.slowThreshold}clear(){this.activeProfiles.clear()}destroy(){this.clear()}buildResult(e){let t=e.records,n=t.length,r=t.reduce((a,c)=>a+c.duration,0),o=n>0?r/n:0,i=n>0?Math.max(...t.map(a=>a.duration)):0,l=n>0?Math.min(...t.map(a=>a.duration)):0,d=t.filter(a=>a.isSlow).length,p=performance.now()-e.startTime;return{componentName:e.componentName,renderCount:n,avgRenderTime:o,maxRenderTime:i,minRenderTime:l,totalRenderTime:r,slowRenderCount:d,slowThreshold:e.slowThreshold,records:[...t],profileDuration:p}}};var ee=class{constructor(e,t){this.entries=new Map;this.isRecording=!1;this.fpsUpdateTimer=null;var n,r;this.container=e,this.config={autoStartFPS:(n=t==null?void 0:t.autoStartFPS)!=null?n:!1,fpsUpdateInterval:(r=t==null?void 0:t.fpsUpdateInterval)!=null?r:1e3},this.fpsUpdateInterval=this.config.fpsUpdateInterval,this.collector=new B,this.profiler=new A,this.config.autoStartFPS&&this.collector.startFPSMonitor(),this.render()}recordRender(e,t){let n=this.entries.get(e)||{name:e,renders:0,totalTime:0,avgTime:0,maxTime:0,lastTime:0};n.renders++,n.totalTime+=t,n.avgTime=n.totalTime/n.renders,n.maxTime=Math.max(n.maxTime,t),n.lastTime=t,this.entries.set(e,n),this.collector.recordRender(e,t,"update"),this.profiler.recordRender(e,t),this.render()}getStats(){return Array.from(this.entries.values()).sort((e,t)=>t.totalTime-e.totalTime)}getEntry(e){return this.entries.get(e)||null}getTotalRenders(){let e=0;for(let t of this.entries.values())e+=t.renders;return e}getTotalTime(){let e=0;for(let t of this.entries.values())e+=t.totalTime;return e}clear(){this.entries.clear(),this.collector.clear(),this.profiler.clear(),this.render()}getCurrentFPS(){return this.collector.getCurrentFPS()}startFPSMonitor(){this.collector.startFPSMonitor(),this.startFPSUpdateLoop()}stopFPSMonitor(){this.collector.stopFPSMonitor(),this.stopFPSUpdateLoop()}isFPSMonitoring(){return this.collector.isFPSMonitoring()}getRenderRankings(){return this.collector.getRenderRankings()}getUpdateFrequencyStats(){return this.collector.getReport().updateFrequencyStats}recordProxyCount(e,t){this.collector.recordMemory(e,t)}getProxyCount(){return this.collector.getProxyCount()}startRecording(){this.isRecording=!0,this.collector.startRecording(),this.startFPSUpdateLoop(),this.render()}stopRecording(){this.isRecording=!1,this.collector.stopRecording(),this.stopFPSUpdateLoop(),this.render()}isRecordingActive(){return this.isRecording}exportJSON(){return this.collector.exportJSON()}getReport(){return this.collector.getReport()}startProfile(e){return this.profiler.startProfile(e)}stopProfile(e){return this.profiler.stopProfile(e)}getProfileSnapshot(e){return this.profiler.getSnapshot(e)}getSlowRenders(){return this.getStats().filter(e=>e.maxTime>16)}getCollector(){return this.collector}getProfiler(){return this.profiler}render(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;";let t=this.getCurrentFPS(),n=t>=55?"#a6e3a1":t>=30?"#f9e2af":"#f38ba8",r=this.createStatCard("FPS",String(t),n),o=this.createStatCard("Proxies",String(this.getProxyCount()),"#cba6f7"),i=this.createStatCard("Total Renders",String(this.getTotalRenders()),"#89b4fa"),l=this.createStatCard("Total Time",`${this.getTotalTime().toFixed(2)}ms`,"#a6e3a1"),d=this.createStatCard("Components",String(this.entries.size),"#f9e2af");e.appendChild(r),e.appendChild(o),e.appendChild(i),e.appendChild(l),e.appendChild(d),this.container.appendChild(e);let p=document.createElement("div");p.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;";let a=document.createElement("span");a.style.cssText="font-size: 11px; color: #a6adc8; text-transform: uppercase; letter-spacing: 0.5px;",a.textContent="Render Performance",p.appendChild(a);let c=document.createElement("div");c.style.cssText="display: flex; gap: 4px;";let u=document.createElement("button");u.style.cssText=this.getRecordButtonStyle(),u.textContent=this.isRecording?"Stop":"Record",u.addEventListener("click",()=>{this.isRecording?this.stopRecording():this.startRecording()}),c.appendChild(u);let h=document.createElement("button");h.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",h.textContent="Export",h.addEventListener("click",()=>{let x=this.exportJSON(),v=new Blob([x],{type:"application/json"}),y=URL.createObjectURL(v),g=document.createElement("a");g.href=y,g.download=`lyt-perf-${Date.now()}.json`,g.click(),URL.revokeObjectURL(y)}),c.appendChild(h);let f=document.createElement("button");f.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",f.textContent="Clear",f.addEventListener("click",()=>this.clear()),c.appendChild(f),p.appendChild(c),this.container.appendChild(p);let m=this.getStats().sort((x,v)=>v.avgTime-x.avgTime);if(m.length===0){let x=document.createElement("div");x.style.cssText="color: #585b70; font-size: 12px; text-align: center; padding: 16px 0; font-style: italic;",x.textContent="No performance data recorded",this.container.appendChild(x)}else{let x=document.createElement("div");x.style.cssText="display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 4px; padding: 4px 8px; font-size: 10px; color: #585b70; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #313244; margin-bottom: 4px;",x.innerHTML="<span>Component</span><span>Renders</span><span>Avg</span><span>Max</span><span>Last</span>",this.container.appendChild(x);let v=document.createElement("div");v.style.cssText="max-height: 300px; overflow-y: auto;";for(let y of m){let g=document.createElement("div");g.style.cssText="display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 4px; padding: 6px 8px; font-size: 12px; border-radius: 3px; transition: background 0.15s; cursor: default;",g.addEventListener("mouseenter",()=>{g.style.background="#313244"}),g.addEventListener("mouseleave",()=>{g.style.background="transparent"});let b=document.createElement("span");b.style.cssText="color: #cdd6f4; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",b.textContent=y.name;let T=document.createElement("span");T.style.cssText="color: #89b4fa;",T.textContent=String(y.renders);let le=document.createElement("span");le.style.cssText=this.getPerfColor(y.avgTime),le.textContent=`${y.avgTime.toFixed(2)}ms`;let de=document.createElement("span");de.style.cssText=this.getPerfColor(y.maxTime),de.textContent=`${y.maxTime.toFixed(2)}ms`;let ce=document.createElement("span");ce.style.cssText=this.getPerfColor(y.lastTime),ce.textContent=`${y.lastTime.toFixed(2)}ms`,g.appendChild(b),g.appendChild(T),g.appendChild(le),g.appendChild(de),g.appendChild(ce),v.appendChild(g)}this.container.appendChild(v)}}createStatCard(e,t,n){let r=document.createElement("div");r.style.cssText="flex: 1; padding: 8px 12px; background: #181825; border: 1px solid #313244; border-radius: 4px; min-width: 70px;";let o=document.createElement("div");o.style.cssText=`font-size: 16px; font-weight: 600; color: ${n}; margin-bottom: 2px;`,o.textContent=t;let i=document.createElement("div");return i.style.cssText="font-size: 10px; color: #585b70; text-transform: uppercase; letter-spacing: 0.5px;",i.textContent=e,r.appendChild(o),r.appendChild(i),r}getRecordButtonStyle(){return this.isRecording?"background: #f38ba8; border: 1px solid #f38ba8; color: #1e1e2e; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit; font-weight: 600;":"background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;"}getPerfColor(e){return e<1?"color: #a6e3a1;":e<5?"color: #f9e2af;":e<16?"color: #fab387;":"color: #f38ba8;"}startFPSUpdateLoop(){this.stopFPSUpdateLoop(),this.fpsUpdateTimer=window.setInterval(()=>{this.render()},this.fpsUpdateInterval)}stopFPSUpdateLoop(){this.fpsUpdateTimer!==null&&(clearInterval(this.fpsUpdateTimer),this.fpsUpdateTimer=null)}destroy(){this.stopFPSUpdateLoop(),this.collector.destroy(),this.profiler.destroy(),this.container.innerHTML="",this.entries.clear()}};var te=class{constructor(e){this.buffer=[];this._paused=!1;this.filterPattern="";this.counter=0;this.writeIndex=0;this.bufferFull=!1;this.element=null;var t,n,r;this.maxBuffer=(t=e==null?void 0:e.maxBuffer)!=null?t:200,this.autoScroll=(n=e==null?void 0:e.autoScroll)!=null?n:!0,this.title=(r=e==null?void 0:e.title)!=null?r:"\u4E8B\u4EF6\u9762\u677F"}captureEvent(e,t,n){if(this._paused)return;let r={name:e,payload:t,sourceComponent:n,timestamp:Date.now(),index:this.counter++};this.bufferFull?this.buffer[this.writeIndex]=r:(this.buffer.push(r),this.buffer.length>=this.maxBuffer&&(this.bufferFull=!0)),this.writeIndex=(this.writeIndex+1)%this.maxBuffer}getEvents(){let e=this.bufferFull?this.buffer.slice(this.writeIndex).concat(this.buffer.slice(0,this.writeIndex)):[...this.buffer];if(this.filterPattern){let t=this.filterPattern.toLowerCase();e=e.filter(n=>n.name.toLowerCase().includes(t)||n.sourceComponent&&n.sourceComponent.toLowerCase().includes(t))}return e}getAllEvents(){return this.bufferFull?this.buffer.slice(this.writeIndex).concat(this.buffer.slice(0,this.writeIndex)):[...this.buffer]}clear(){this.buffer=[],this.writeIndex=0,this.bufferFull=!1}setFilter(e){this.filterPattern=e}getFilter(){return this.filterPattern}pause(){this._paused=!0}resume(){this._paused=!1}isPaused(){return this._paused}exportJSON(){let e=this.getEvents();return JSON.stringify(e,null,2)}getCount(){return this.bufferFull?this.maxBuffer:this.buffer.length}getMaxBuffer(){return this.maxBuffer}render(){this.element&&this.element.remove();let e=document.createElement("div");e.className="lyt-event-panel",e.style.cssText="font-family: monospace; font-size: 12px; color: #cdd6f4;";let t=document.createElement("div");t.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let n=document.createElement("span");n.textContent=this.title,n.style.cssText="font-weight: bold; font-size: 13px;",t.appendChild(n);let r=document.createElement("div");r.style.cssText="display: flex; gap: 4px;";let o=document.createElement("button");o.textContent=this._paused?"\u6062\u590D":"\u6682\u505C",o.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",o.addEventListener("click",()=>{this._paused?this.resume():this.pause(),o.textContent=this._paused?"\u6062\u590D":"\u6682\u505C",this.render()}),r.appendChild(o);let i=document.createElement("button");i.textContent="\u6E05\u9664",i.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",i.addEventListener("click",()=>{this.clear(),this.render()}),r.appendChild(i);let l=document.createElement("button");l.textContent="\u5BFC\u51FA",l.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",l.addEventListener("click",()=>{let u=this.exportJSON(),h=new Blob([u],{type:"application/json"}),f=URL.createObjectURL(h),m=document.createElement("a");m.href=f,m.download=`lyt-events-${Date.now()}.json`,m.click(),URL.revokeObjectURL(f)}),r.appendChild(l),t.appendChild(r),e.appendChild(t);let d=document.createElement("div");d.style.cssText="padding: 6px 12px; background: #181825; border-bottom: 1px solid #313244;";let p=document.createElement("input");p.type="text",p.placeholder="\u8FC7\u6EE4\u4E8B\u4EF6\u540D\u79F0...",p.value=this.filterPattern,p.style.cssText="width: 100%; padding: 4px 8px; border: 1px solid #45475a; background: #1e1e2e; color: #cdd6f4; border-radius: 3px; font-size: 11px; box-sizing: border-box;",p.addEventListener("input",()=>{this.setFilter(p.value),this.render()}),d.appendChild(p),e.appendChild(d);let a=document.createElement("div");a.style.cssText="max-height: 400px; overflow-y: auto; padding: 4px 0;";let c=this.getEvents();if(c.length===0){let u=document.createElement("div");u.style.cssText="padding: 20px; text-align: center; color: #585b70;",u.textContent="\u6682\u65E0\u4E8B\u4EF6",a.appendChild(u)}else for(let u of c){let h=document.createElement("div");h.style.cssText="padding: 4px 12px; border-bottom: 1px solid #1e1e2e; cursor: pointer;";let f=new Date(u.timestamp),m=`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}.${String(f.getMilliseconds()).padStart(3,"0")}`,x="";try{x=JSON.stringify(u.payload),x.length>50&&(x=x.slice(0,50)+"...")}catch(y){x=String(u.payload)}let v=u.sourceComponent?` [${u.sourceComponent}]`:"";h.textContent=`${m} ${u.name}${v} ${x}`,a.appendChild(h)}return e.appendChild(a),this.autoScroll&&(a.scrollTop=a.scrollHeight),this.element=e,e}destroy(){this.element&&(this.element.remove(),this.element=null),this.clear()}};var ne=class{constructor(e){this.currentRoute=null;this.history=[];this.navCounter=0;this.element=null;this.selectedHistoryIndex=-1;var t,n;this.maxHistory=(t=e==null?void 0:e.maxHistory)!=null?t:50,this.title=(n=e==null?void 0:e.title)!=null?n:"\u8DEF\u7531\u9762\u677F"}onRouteChange(e,t,n){let r={index:this.navCounter++,to:{...e},from:{...t},timestamp:Date.now(),type:n!=null?n:"push"};this.history.push(r),this.history.length>this.maxHistory&&(this.history=this.history.slice(this.history.length-this.maxHistory)),this.currentRoute={...e},this.selectedHistoryIndex=-1}getCurrentRoute(){return this.currentRoute?{...this.currentRoute}:null}getHistory(){return this.history.map(e=>({...e,to:{...e.to},from:{...e.from}}))}clearHistory(){this.history=[],this.navCounter=0,this.selectedHistoryIndex=-1}getHistoryCount(){return this.history.length}getMaxHistory(){return this.maxHistory}selectHistoryEntry(e){e>=0&&e<this.history.length&&(this.selectedHistoryIndex=e)}getSelectedHistoryEntry(){if(this.selectedHistoryIndex>=0&&this.selectedHistoryIndex<this.history.length){let e=this.history[this.selectedHistoryIndex];return{...e,to:{...e.to},from:{...e.from}}}return null}render(){this.element&&this.element.remove();let e=document.createElement("div");e.className="lyt-router-panel",e.style.cssText="font-family: monospace; font-size: 12px; color: #cdd6f4;";let t=document.createElement("div");t.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let n=document.createElement("span");n.textContent=this.title,n.style.cssText="font-weight: bold; font-size: 13px;",t.appendChild(n);let r=document.createElement("button");r.textContent="\u6E05\u9664\u5386\u53F2",r.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",r.addEventListener("click",()=>{this.clearHistory(),this.render()}),t.appendChild(r),e.appendChild(t);let o=document.createElement("div");o.style.cssText="padding: 8px 12px; background: #181825; border-bottom: 1px solid #313244;";let i=document.createElement("div");if(i.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",i.textContent="\u5F53\u524D\u8DEF\u7531",o.appendChild(i),this.currentRoute){let a=document.createElement("div");if(a.style.cssText="font-weight: bold; font-size: 14px; color: #89b4fa;",a.textContent=this.currentRoute.path,o.appendChild(a),this.currentRoute.params&&Object.keys(this.currentRoute.params).length>0){let c=document.createElement("div");c.style.cssText="margin-top: 4px; color: #a6e3a1; font-size: 11px;",c.textContent=`params: ${JSON.stringify(this.currentRoute.params)}`,o.appendChild(c)}if(this.currentRoute.query&&Object.keys(this.currentRoute.query).length>0){let c=document.createElement("div");c.style.cssText="margin-top: 2px; color: #f9e2af; font-size: 11px;",c.textContent=`query: ${JSON.stringify(this.currentRoute.query)}`,o.appendChild(c)}if(this.currentRoute.name){let c=document.createElement("div");c.style.cssText="margin-top: 2px; color: #cba6f7; font-size: 11px;",c.textContent=`name: ${this.currentRoute.name}`,o.appendChild(c)}}else{let a=document.createElement("div");a.style.cssText="color: #585b70; font-size: 11px;",a.textContent="\u6682\u65E0\u8DEF\u7531\u4FE1\u606F",o.appendChild(a)}e.appendChild(o);let l=document.createElement("div");l.style.cssText="padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let d=document.createElement("div");d.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",d.textContent=`\u5BFC\u822A\u5386\u53F2 (${this.history.length})`,l.appendChild(d),e.appendChild(l);let p=document.createElement("div");if(p.style.cssText="max-height: 300px; overflow-y: auto;",this.history.length===0){let a=document.createElement("div");a.style.cssText="padding: 20px; text-align: center; color: #585b70;",a.textContent="\u6682\u65E0\u5BFC\u822A\u8BB0\u5F55",p.appendChild(a)}else for(let a=this.history.length-1;a>=0;a--){let c=this.history[a],u=document.createElement("div"),h=a===this.selectedHistoryIndex;u.style.cssText=`padding: 4px 12px; border-bottom: 1px solid #1e1e2e; cursor: pointer;${h?" background: #313244;":""}`;let f=new Date(c.timestamp),m=`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}`,x=c.type==="pop"?"<-":c.type==="replace"?"=":">";u.textContent=`${m} ${x} ${c.from.path} -> ${c.to.path}`;let v=a;u.addEventListener("click",()=>{this.selectHistoryEntry(v),this.render()}),p.appendChild(u)}if(e.appendChild(p),this.selectedHistoryIndex>=0){let a=this.history[this.selectedHistoryIndex];if(a){let c=document.createElement("div");c.style.cssText="padding: 8px 12px; background: #181825; border-top: 1px solid #313244;";let u=document.createElement("div");u.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",u.textContent="\u5BFC\u822A\u8BE6\u60C5",c.appendChild(u);let h=document.createElement("div");h.style.cssText="font-size: 11px; line-height: 1.6;";let f=a.from,m=a.to;h.innerHTML=`
|
|
584
|
+
`}refresh(){this.renderTimeTravel()}destroy(){this.stopPlayback(),this.updateTimer&&clearTimeout(this.updateTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.snapshots=[]}};var Z=class{constructor(e,t){this.history=[];this.currentPath="/";this.currentParams={};this.currentQuery={};var n;this.container=e,this.maxHistory=(n=t==null?void 0:t.maxHistory)!=null?n:50,this.render()}updateRoute(e,t,n){this.history.push({path:e,params:t?{...t}:void 0,query:n?{...n}:void 0,timestamp:Date.now()}),this.history.length>this.maxHistory&&this.history.shift(),this.currentPath=e,this.currentParams=t?{...t}:{},this.currentQuery=n?{...n}:{},this.render()}getHistory(){return[...this.history].reverse()}getCurrentPath(){return this.currentPath}clearHistory(){this.history=[],this.render()}render(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="margin-bottom: 16px;";let t=document.createElement("div");t.style.cssText="font-size: 11px; color: #a6adc8; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;",t.textContent="Current Route",e.appendChild(t);let n=document.createElement("div");n.style.cssText="display: flex; align-items: center; gap: 8px; margin-bottom: 6px;";let r=document.createElement("span");r.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",r.textContent="Path:";let o=document.createElement("span");if(o.style.cssText="color: #cba6f7; font-size: 13px; font-weight: 600;",o.textContent=this.currentPath||"/",n.appendChild(r),n.appendChild(o),e.appendChild(n),Object.keys(this.currentParams).length>0){let c=document.createElement("div");c.style.cssText="display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;";let a=document.createElement("span");a.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",a.textContent="Params:";let d=document.createElement("span");d.style.cssText="color: #a6e3a1; font-size: 12px;",d.textContent=JSON.stringify(this.currentParams),c.appendChild(a),c.appendChild(d),e.appendChild(c)}if(Object.keys(this.currentQuery).length>0){let c=document.createElement("div");c.style.cssText="display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;";let a=document.createElement("span");a.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",a.textContent="Query:";let d=document.createElement("span");d.style.cssText="color: #89b4fa; font-size: 12px;",d.textContent=JSON.stringify(this.currentQuery),c.appendChild(a),c.appendChild(d),e.appendChild(c)}this.container.appendChild(e);let s=document.createElement("div");s.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;";let l=document.createElement("span");l.style.cssText="font-size: 11px; color: #a6adc8; text-transform: uppercase; letter-spacing: 0.5px;",l.textContent=`History (${this.history.length})`,s.appendChild(l);let p=document.createElement("button");if(p.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",p.textContent="Clear",p.addEventListener("click",()=>this.clearHistory()),s.appendChild(p),this.container.appendChild(s),this.history.length===0){let c=document.createElement("div");c.style.cssText="color: #585b70; font-size: 12px; text-align: center; padding: 16px 0; font-style: italic;",c.textContent="No navigation history",this.container.appendChild(c)}else{let c=document.createElement("div");c.style.cssText="max-height: 300px; overflow-y: auto;";let a=[...this.history].reverse();for(let d of a){let u=document.createElement("div");u.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; border-radius: 3px; font-size: 12px; transition: background 0.15s; cursor: default;",u.addEventListener("mouseenter",()=>{u.style.background="#313244"}),u.addEventListener("mouseleave",()=>{u.style.background="transparent"});let h=document.createElement("span");h.style.cssText="color: #cdd6f4; font-family: inherit;",h.textContent=d.path;let f=document.createElement("span");f.style.cssText="color: #585b70; font-size: 10px; white-space: nowrap;";let m=new Date(d.timestamp);f.textContent=`${m.getHours().toString().padStart(2,"0")}:${m.getMinutes().toString().padStart(2,"0")}:${m.getSeconds().toString().padStart(2,"0")}.${m.getMilliseconds().toString().padStart(3,"0")}`,u.appendChild(h),u.appendChild(f),c.appendChild(u)}this.container.appendChild(c)}}destroy(){this.container.innerHTML="",this.history=[]}};var R=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}},Ye=100,Ke=16,$=class{constructor(e=Ye){this.pendingMarks=new Map;this.componentUpdateCounts=new Map;this._isRecording=!1;this.bufferSize=e,this.fcpBuffer=new R(e),this.inpBuffer=new R(e),this.renderBuffer=new R(e),this.updateFrequencyBuffer=new R(e),this.memoryBuffer=new R(e),this.customMarkBuffer=new R(e),this.fpsBuffer=new R(e),this.fpsState={isMonitoring:!1,frameCount:0,lastTime:0,rafId:null}}recordFCP(e){if(e===void 0)if(typeof performance!="undefined"&&performance.getEntriesByType){let n=performance.getEntriesByType("paint").find(r=>r.name==="first-contentful-paint");e=n?n.startTime:0}else e=0;this.fcpBuffer.push({type:"fcp",value:e,timestamp:Date.now()})}recordINP(e,t,n){this.inpBuffer.push({type:"inp",value:e,eventName:t,componentName:n,timestamp:Date.now()})}recordRender(e,t,n="update",r){this.renderBuffer.push({type:"render",value:t,componentName:e,componentId:r,phase:n,timestamp:Date.now()}),this.trackComponentUpdate(e)}trackComponentUpdate(e){let t=Date.now(),n=this.componentUpdateCounts.get(e);if(!n){this.componentUpdateCounts.set(e,{count:1,startTime:t});return}n.count++;let r=t-n.startTime;r>=1e3&&(this.updateFrequencyBuffer.push({type:"update-frequency",componentName:e,count:n.count,windowMs:r,timestamp:t}),n.count=0,n.startTime=t)}recordMemory(e,t){this.memoryBuffer.push({type:"memory",proxyCount:e,reactiveCount:t,timestamp:Date.now()})}startMark(e){this.pendingMarks.set(e,performance.now())}endMark(e){let t=this.pendingMarks.get(e);if(t===void 0)return-1;let n=performance.now()-t;return this.pendingMarks.delete(e),this.customMarkBuffer.push({type:"custom",name:e,value:n,timestamp:Date.now()}),n}startFPSMonitor(){if(this.fpsState.isMonitoring||typeof requestAnimationFrame!="function")return;this.fpsState.isMonitoring=!0,this.fpsState.frameCount=0,this.fpsState.lastTime=performance.now();let e=t=>{if(!this.fpsState.isMonitoring)return;this.fpsState.frameCount++;let n=t-this.fpsState.lastTime;if(n>=1e3){let r=this.fpsState.frameCount/n*1e3;this.fpsBuffer.push({type:"fps",value:Math.round(r),timestamp:Date.now()}),this.fpsState.frameCount=0,this.fpsState.lastTime=t}this.fpsState.rafId=requestAnimationFrame(e)};this.fpsState.rafId=requestAnimationFrame(e)}stopFPSMonitor(){this.fpsState.isMonitoring=!1,this.fpsState.rafId!==null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.fpsState.rafId),this.fpsState.rafId=null)}isFPSMonitoring(){return this.fpsState.isMonitoring}startRecording(){this._isRecording=!0,this.startFPSMonitor()}stopRecording(){this._isRecording=!1,this.stopFPSMonitor()}isRecording(){return this._isRecording}getMetrics(){return[...this.fcpBuffer.getAll(),...this.inpBuffer.getAll(),...this.renderBuffer.getAll(),...this.updateFrequencyBuffer.getAll(),...this.memoryBuffer.getAll(),...this.customMarkBuffer.getAll(),...this.fpsBuffer.getAll()]}getMetricsByType(e){return this.getMetrics().filter(n=>n.type===e)}getCurrentFPS(){let e=this.fpsBuffer.getAll();return e.length===0?0:e[e.length-1].value}getRenderRankings(){let e=new Map;for(let t of this.renderBuffer.getAll()){let n=e.get(t.componentName)||{renderCount:0,totalTime:0,maxTime:0};n.renderCount++,n.totalTime+=t.value,n.maxTime=Math.max(n.maxTime,t.value),e.set(t.componentName,n)}return Array.from(e.entries()).map(([t,n])=>({componentName:t,renderCount:n.renderCount,avgRenderTime:n.renderCount>0?n.totalTime/n.renderCount:0,maxRenderTime:n.maxTime,totalRenderTime:n.totalTime})).sort((t,n)=>n.avgRenderTime-t.avgRenderTime)}getProxyCount(){let e=this.memoryBuffer.getAll();return e.length===0?0:e[e.length-1].proxyCount}getSlowRenders(){return this.renderBuffer.getAll().filter(e=>e.value>Ke)}getReport(){let e=this.fcpBuffer.getAll(),t=e.length>0?e[e.length-1]:null,r=this.inpBuffer.getAll().map(y=>y.value),o={avg:r.length>0?r.reduce((y,g)=>y+g,0)/r.length:0,max:r.length>0?Math.max(...r):0,min:r.length>0?Math.min(...r):0,count:r.length},s=this.getRenderRankings(),l=this.updateFrequencyBuffer.getAll(),p=new Map;for(let y of l){let g=y.count/y.windowMs*1e3,b=p.get(y.componentName)||[];b.push(g),p.set(y.componentName,b)}let c=Array.from(p.entries()).map(([y,g])=>({componentName:y,avgFrequency:g.reduce((b,T)=>b+T,0)/g.length})),a=this.memoryBuffer.getAll(),d=a.length>0?a[a.length-1]:null,h=this.fpsBuffer.getAll().map(y=>y.value),f={avg:h.length>0?h.reduce((y,g)=>y+g,0)/h.length:0,min:h.length>0?Math.min(...h):0,count:h.length},m=this.customMarkBuffer.getAll(),x=new Map;for(let y of m){let g=x.get(y.name)||[];g.push(y.value),x.set(y.name,g)}let v=Array.from(x.entries()).map(([y,g])=>({name:y,avg:g.reduce((b,T)=>b+T,0)/g.length,max:Math.max(...g),count:g.length}));return{generatedAt:Date.now(),fcp:t,inp:o,renderStats:s,updateFrequencyStats:c,memory:d,fps:f,customMarks:v}}exportJSON(){return JSON.stringify({metrics:this.getMetrics(),report:this.getReport()},null,2)}clear(){this.fcpBuffer.clear(),this.inpBuffer.clear(),this.renderBuffer.clear(),this.updateFrequencyBuffer.clear(),this.memoryBuffer.clear(),this.customMarkBuffer.clear(),this.fpsBuffer.clear(),this.pendingMarks.clear(),this.componentUpdateCounts.clear()}destroy(){this.stopFPSMonitor(),this.clear()}};var A=class{constructor(e=16){this.activeProfiles=new Map;this.slowThreshold=e}startProfile(e){return this.activeProfiles.has(e)?!1:(this.activeProfiles.set(e,{componentName:e,startTime:performance.now(),records:[],slowThreshold:this.slowThreshold}),!0)}stopProfile(e){let t=this.activeProfiles.get(e);return t?(this.activeProfiles.delete(e),this.buildResult(t)):null}stopAllProfiles(){let e=[];for(let t of this.activeProfiles.values())e.push(this.buildResult(t));return this.activeProfiles.clear(),e}recordRender(e,t){let n=this.activeProfiles.get(e);if(!n)return;let r={duration:t,timestamp:Date.now(),isSlow:t>n.slowThreshold};n.records.push(r)}getSnapshot(e){let t=this.activeProfiles.get(e);return t?this.buildResult(t):null}isProfiling(e){return this.activeProfiles.has(e)}getActiveProfileNames(){return Array.from(this.activeProfiles.keys())}getActiveProfileCount(){return this.activeProfiles.size}getSlowRenders(e){let t=this.activeProfiles.get(e);return t?t.records.filter(n=>n.isSlow):[]}setSlowThreshold(e){this.slowThreshold=e;for(let t of this.activeProfiles.values()){t.slowThreshold=e;for(let n of t.records)n.isSlow=n.duration>e}}getSlowThreshold(){return this.slowThreshold}clear(){this.activeProfiles.clear()}destroy(){this.clear()}buildResult(e){let t=e.records,n=t.length,r=t.reduce((a,d)=>a+d.duration,0),o=n>0?r/n:0,s=n>0?Math.max(...t.map(a=>a.duration)):0,l=n>0?Math.min(...t.map(a=>a.duration)):0,p=t.filter(a=>a.isSlow).length,c=performance.now()-e.startTime;return{componentName:e.componentName,renderCount:n,avgRenderTime:o,maxRenderTime:s,minRenderTime:l,totalRenderTime:r,slowRenderCount:p,slowThreshold:e.slowThreshold,records:[...t],profileDuration:c}}};var ee=class{constructor(e,t){this.entries=new Map;this.isRecording=!1;this.fpsUpdateTimer=null;var n,r;this.container=e,this.config={autoStartFPS:(n=t==null?void 0:t.autoStartFPS)!=null?n:!1,fpsUpdateInterval:(r=t==null?void 0:t.fpsUpdateInterval)!=null?r:1e3},this.fpsUpdateInterval=this.config.fpsUpdateInterval,this.collector=new $,this.profiler=new A,this.config.autoStartFPS&&this.collector.startFPSMonitor(),this.render()}recordRender(e,t){let n=this.entries.get(e)||{name:e,renders:0,totalTime:0,avgTime:0,maxTime:0,lastTime:0};n.renders++,n.totalTime+=t,n.avgTime=n.totalTime/n.renders,n.maxTime=Math.max(n.maxTime,t),n.lastTime=t,this.entries.set(e,n),this.collector.recordRender(e,t,"update"),this.profiler.recordRender(e,t),this.render()}getStats(){return Array.from(this.entries.values()).sort((e,t)=>t.totalTime-e.totalTime)}getEntry(e){return this.entries.get(e)||null}getTotalRenders(){let e=0;for(let t of this.entries.values())e+=t.renders;return e}getTotalTime(){let e=0;for(let t of this.entries.values())e+=t.totalTime;return e}clear(){this.entries.clear(),this.collector.clear(),this.profiler.clear(),this.render()}getCurrentFPS(){return this.collector.getCurrentFPS()}startFPSMonitor(){this.collector.startFPSMonitor(),this.startFPSUpdateLoop()}stopFPSMonitor(){this.collector.stopFPSMonitor(),this.stopFPSUpdateLoop()}isFPSMonitoring(){return this.collector.isFPSMonitoring()}getRenderRankings(){return this.collector.getRenderRankings()}getUpdateFrequencyStats(){return this.collector.getReport().updateFrequencyStats}recordProxyCount(e,t){this.collector.recordMemory(e,t)}getProxyCount(){return this.collector.getProxyCount()}startRecording(){this.isRecording=!0,this.collector.startRecording(),this.startFPSUpdateLoop(),this.render()}stopRecording(){this.isRecording=!1,this.collector.stopRecording(),this.stopFPSUpdateLoop(),this.render()}isRecordingActive(){return this.isRecording}exportJSON(){return this.collector.exportJSON()}getReport(){return this.collector.getReport()}startProfile(e){return this.profiler.startProfile(e)}stopProfile(e){return this.profiler.stopProfile(e)}getProfileSnapshot(e){return this.profiler.getSnapshot(e)}getSlowRenders(){return this.getStats().filter(e=>e.maxTime>16)}getCollector(){return this.collector}getProfiler(){return this.profiler}render(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;";let t=this.getCurrentFPS(),n=t>=55?"#a6e3a1":t>=30?"#f9e2af":"#f38ba8",r=this.createStatCard("FPS",String(t),n),o=this.createStatCard("Proxies",String(this.getProxyCount()),"#cba6f7"),s=this.createStatCard("Total Renders",String(this.getTotalRenders()),"#89b4fa"),l=this.createStatCard("Total Time",`${this.getTotalTime().toFixed(2)}ms`,"#a6e3a1"),p=this.createStatCard("Components",String(this.entries.size),"#f9e2af");e.appendChild(r),e.appendChild(o),e.appendChild(s),e.appendChild(l),e.appendChild(p),this.container.appendChild(e);let c=document.createElement("div");c.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;";let a=document.createElement("span");a.style.cssText="font-size: 11px; color: #a6adc8; text-transform: uppercase; letter-spacing: 0.5px;",a.textContent="Render Performance",c.appendChild(a);let d=document.createElement("div");d.style.cssText="display: flex; gap: 4px;";let u=document.createElement("button");u.style.cssText=this.getRecordButtonStyle(),u.textContent=this.isRecording?"Stop":"Record",u.addEventListener("click",()=>{this.isRecording?this.stopRecording():this.startRecording()}),d.appendChild(u);let h=document.createElement("button");h.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",h.textContent="Export",h.addEventListener("click",()=>{let x=this.exportJSON(),v=new Blob([x],{type:"application/json"}),y=URL.createObjectURL(v),g=document.createElement("a");g.href=y,g.download=`lyt-perf-${Date.now()}.json`,g.click(),URL.revokeObjectURL(y)}),d.appendChild(h);let f=document.createElement("button");f.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",f.textContent="Clear",f.addEventListener("click",()=>this.clear()),d.appendChild(f),c.appendChild(d),this.container.appendChild(c);let m=this.getStats().sort((x,v)=>v.avgTime-x.avgTime);if(m.length===0){let x=document.createElement("div");x.style.cssText="color: #585b70; font-size: 12px; text-align: center; padding: 16px 0; font-style: italic;",x.textContent="No performance data recorded",this.container.appendChild(x)}else{let x=document.createElement("div");x.style.cssText="display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 4px; padding: 4px 8px; font-size: 10px; color: #585b70; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #313244; margin-bottom: 4px;",x.innerHTML="<span>Component</span><span>Renders</span><span>Avg</span><span>Max</span><span>Last</span>",this.container.appendChild(x);let v=document.createElement("div");v.style.cssText="max-height: 300px; overflow-y: auto;";for(let y of m){let g=document.createElement("div");g.style.cssText="display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 4px; padding: 6px 8px; font-size: 12px; border-radius: 3px; transition: background 0.15s; cursor: default;",g.addEventListener("mouseenter",()=>{g.style.background="#313244"}),g.addEventListener("mouseleave",()=>{g.style.background="transparent"});let b=document.createElement("span");b.style.cssText="color: #cdd6f4; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",b.textContent=y.name;let T=document.createElement("span");T.style.cssText="color: #89b4fa;",T.textContent=String(y.renders);let le=document.createElement("span");le.style.cssText=this.getPerfColor(y.avgTime),le.textContent=`${y.avgTime.toFixed(2)}ms`;let de=document.createElement("span");de.style.cssText=this.getPerfColor(y.maxTime),de.textContent=`${y.maxTime.toFixed(2)}ms`;let pe=document.createElement("span");pe.style.cssText=this.getPerfColor(y.lastTime),pe.textContent=`${y.lastTime.toFixed(2)}ms`,g.appendChild(b),g.appendChild(T),g.appendChild(le),g.appendChild(de),g.appendChild(pe),v.appendChild(g)}this.container.appendChild(v)}}createStatCard(e,t,n){let r=document.createElement("div");r.style.cssText="flex: 1; padding: 8px 12px; background: #181825; border: 1px solid #313244; border-radius: 4px; min-width: 70px;";let o=document.createElement("div");o.style.cssText=`font-size: 16px; font-weight: 600; color: ${n}; margin-bottom: 2px;`,o.textContent=t;let s=document.createElement("div");return s.style.cssText="font-size: 10px; color: #585b70; text-transform: uppercase; letter-spacing: 0.5px;",s.textContent=e,r.appendChild(o),r.appendChild(s),r}getRecordButtonStyle(){return this.isRecording?"background: #f38ba8; border: 1px solid #f38ba8; color: #1e1e2e; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit; font-weight: 600;":"background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;"}getPerfColor(e){return e<1?"color: #a6e3a1;":e<5?"color: #f9e2af;":e<16?"color: #fab387;":"color: #f38ba8;"}startFPSUpdateLoop(){this.stopFPSUpdateLoop(),this.fpsUpdateTimer=window.setInterval(()=>{this.render()},this.fpsUpdateInterval)}stopFPSUpdateLoop(){this.fpsUpdateTimer!==null&&(clearInterval(this.fpsUpdateTimer),this.fpsUpdateTimer=null)}destroy(){this.stopFPSUpdateLoop(),this.collector.destroy(),this.profiler.destroy(),this.container.innerHTML="",this.entries.clear()}};var te=class{constructor(e){this.buffer=[];this._paused=!1;this.filterPattern="";this.counter=0;this.writeIndex=0;this.bufferFull=!1;this.element=null;var t,n,r;this.maxBuffer=(t=e==null?void 0:e.maxBuffer)!=null?t:200,this.autoScroll=(n=e==null?void 0:e.autoScroll)!=null?n:!0,this.title=(r=e==null?void 0:e.title)!=null?r:"\u4E8B\u4EF6\u9762\u677F"}captureEvent(e,t,n){if(this._paused)return;let r={name:e,payload:t,sourceComponent:n,timestamp:Date.now(),index:this.counter++};this.bufferFull?this.buffer[this.writeIndex]=r:(this.buffer.push(r),this.buffer.length>=this.maxBuffer&&(this.bufferFull=!0)),this.writeIndex=(this.writeIndex+1)%this.maxBuffer}getEvents(){let e=this.bufferFull?this.buffer.slice(this.writeIndex).concat(this.buffer.slice(0,this.writeIndex)):[...this.buffer];if(this.filterPattern){let t=this.filterPattern.toLowerCase();e=e.filter(n=>n.name.toLowerCase().includes(t)||n.sourceComponent&&n.sourceComponent.toLowerCase().includes(t))}return e}getAllEvents(){return this.bufferFull?this.buffer.slice(this.writeIndex).concat(this.buffer.slice(0,this.writeIndex)):[...this.buffer]}clear(){this.buffer=[],this.writeIndex=0,this.bufferFull=!1}setFilter(e){this.filterPattern=e}getFilter(){return this.filterPattern}pause(){this._paused=!0}resume(){this._paused=!1}isPaused(){return this._paused}exportJSON(){let e=this.getEvents();return JSON.stringify(e,null,2)}getCount(){return this.bufferFull?this.maxBuffer:this.buffer.length}getMaxBuffer(){return this.maxBuffer}render(){this.element&&this.element.remove();let e=document.createElement("div");e.className="lyt-event-panel",e.style.cssText="font-family: monospace; font-size: 12px; color: #cdd6f4;";let t=document.createElement("div");t.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let n=document.createElement("span");n.textContent=this.title,n.style.cssText="font-weight: bold; font-size: 13px;",t.appendChild(n);let r=document.createElement("div");r.style.cssText="display: flex; gap: 4px;";let o=document.createElement("button");o.textContent=this._paused?"\u6062\u590D":"\u6682\u505C",o.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",o.addEventListener("click",()=>{this._paused?this.resume():this.pause(),o.textContent=this._paused?"\u6062\u590D":"\u6682\u505C",this.render()}),r.appendChild(o);let s=document.createElement("button");s.textContent="\u6E05\u9664",s.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",s.addEventListener("click",()=>{this.clear(),this.render()}),r.appendChild(s);let l=document.createElement("button");l.textContent="\u5BFC\u51FA",l.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",l.addEventListener("click",()=>{let u=this.exportJSON(),h=new Blob([u],{type:"application/json"}),f=URL.createObjectURL(h),m=document.createElement("a");m.href=f,m.download=`lyt-events-${Date.now()}.json`,m.click(),URL.revokeObjectURL(f)}),r.appendChild(l),t.appendChild(r),e.appendChild(t);let p=document.createElement("div");p.style.cssText="padding: 6px 12px; background: #181825; border-bottom: 1px solid #313244;";let c=document.createElement("input");c.type="text",c.placeholder="\u8FC7\u6EE4\u4E8B\u4EF6\u540D\u79F0...",c.value=this.filterPattern,c.style.cssText="width: 100%; padding: 4px 8px; border: 1px solid #45475a; background: #1e1e2e; color: #cdd6f4; border-radius: 3px; font-size: 11px; box-sizing: border-box;",c.addEventListener("input",()=>{this.setFilter(c.value),this.render()}),p.appendChild(c),e.appendChild(p);let a=document.createElement("div");a.style.cssText="max-height: 400px; overflow-y: auto; padding: 4px 0;";let d=this.getEvents();if(d.length===0){let u=document.createElement("div");u.style.cssText="padding: 20px; text-align: center; color: #585b70;",u.textContent="\u6682\u65E0\u4E8B\u4EF6",a.appendChild(u)}else for(let u of d){let h=document.createElement("div");h.style.cssText="padding: 4px 12px; border-bottom: 1px solid #1e1e2e; cursor: pointer;";let f=new Date(u.timestamp),m=`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}.${String(f.getMilliseconds()).padStart(3,"0")}`,x="";try{x=JSON.stringify(u.payload),x.length>50&&(x=x.slice(0,50)+"...")}catch(y){x=String(u.payload)}let v=u.sourceComponent?` [${u.sourceComponent}]`:"";h.textContent=`${m} ${u.name}${v} ${x}`,a.appendChild(h)}return e.appendChild(a),this.autoScroll&&(a.scrollTop=a.scrollHeight),this.element=e,e}destroy(){this.element&&(this.element.remove(),this.element=null),this.clear()}};var ne=class{constructor(e){this.currentRoute=null;this.history=[];this.navCounter=0;this.element=null;this.selectedHistoryIndex=-1;var t,n;this.maxHistory=(t=e==null?void 0:e.maxHistory)!=null?t:50,this.title=(n=e==null?void 0:e.title)!=null?n:"\u8DEF\u7531\u9762\u677F"}onRouteChange(e,t,n){let r={index:this.navCounter++,to:{...e},from:{...t},timestamp:Date.now(),type:n!=null?n:"push"};this.history.push(r),this.history.length>this.maxHistory&&(this.history=this.history.slice(this.history.length-this.maxHistory)),this.currentRoute={...e},this.selectedHistoryIndex=-1}getCurrentRoute(){return this.currentRoute?{...this.currentRoute}:null}getHistory(){return this.history.map(e=>({...e,to:{...e.to},from:{...e.from}}))}clearHistory(){this.history=[],this.navCounter=0,this.selectedHistoryIndex=-1}getHistoryCount(){return this.history.length}getMaxHistory(){return this.maxHistory}selectHistoryEntry(e){e>=0&&e<this.history.length&&(this.selectedHistoryIndex=e)}getSelectedHistoryEntry(){if(this.selectedHistoryIndex>=0&&this.selectedHistoryIndex<this.history.length){let e=this.history[this.selectedHistoryIndex];return{...e,to:{...e.to},from:{...e.from}}}return null}render(){this.element&&this.element.remove();let e=document.createElement("div");e.className="lyt-router-panel",e.style.cssText="font-family: monospace; font-size: 12px; color: #cdd6f4;";let t=document.createElement("div");t.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let n=document.createElement("span");n.textContent=this.title,n.style.cssText="font-weight: bold; font-size: 13px;",t.appendChild(n);let r=document.createElement("button");r.textContent="\u6E05\u9664\u5386\u53F2",r.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",r.addEventListener("click",()=>{this.clearHistory(),this.render()}),t.appendChild(r),e.appendChild(t);let o=document.createElement("div");o.style.cssText="padding: 8px 12px; background: #181825; border-bottom: 1px solid #313244;";let s=document.createElement("div");if(s.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",s.textContent="\u5F53\u524D\u8DEF\u7531",o.appendChild(s),this.currentRoute){let a=document.createElement("div");if(a.style.cssText="font-weight: bold; font-size: 14px; color: #89b4fa;",a.textContent=this.currentRoute.path,o.appendChild(a),this.currentRoute.params&&Object.keys(this.currentRoute.params).length>0){let d=document.createElement("div");d.style.cssText="margin-top: 4px; color: #a6e3a1; font-size: 11px;",d.textContent=`params: ${JSON.stringify(this.currentRoute.params)}`,o.appendChild(d)}if(this.currentRoute.query&&Object.keys(this.currentRoute.query).length>0){let d=document.createElement("div");d.style.cssText="margin-top: 2px; color: #f9e2af; font-size: 11px;",d.textContent=`query: ${JSON.stringify(this.currentRoute.query)}`,o.appendChild(d)}if(this.currentRoute.name){let d=document.createElement("div");d.style.cssText="margin-top: 2px; color: #cba6f7; font-size: 11px;",d.textContent=`name: ${this.currentRoute.name}`,o.appendChild(d)}}else{let a=document.createElement("div");a.style.cssText="color: #585b70; font-size: 11px;",a.textContent="\u6682\u65E0\u8DEF\u7531\u4FE1\u606F",o.appendChild(a)}e.appendChild(o);let l=document.createElement("div");l.style.cssText="padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let p=document.createElement("div");p.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",p.textContent=`\u5BFC\u822A\u5386\u53F2 (${this.history.length})`,l.appendChild(p),e.appendChild(l);let c=document.createElement("div");if(c.style.cssText="max-height: 300px; overflow-y: auto;",this.history.length===0){let a=document.createElement("div");a.style.cssText="padding: 20px; text-align: center; color: #585b70;",a.textContent="\u6682\u65E0\u5BFC\u822A\u8BB0\u5F55",c.appendChild(a)}else for(let a=this.history.length-1;a>=0;a--){let d=this.history[a],u=document.createElement("div"),h=a===this.selectedHistoryIndex;u.style.cssText=`padding: 4px 12px; border-bottom: 1px solid #1e1e2e; cursor: pointer;${h?" background: #313244;":""}`;let f=new Date(d.timestamp),m=`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}`,x=d.type==="pop"?"<-":d.type==="replace"?"=":">";u.textContent=`${m} ${x} ${d.from.path} -> ${d.to.path}`;let v=a;u.addEventListener("click",()=>{this.selectHistoryEntry(v),this.render()}),c.appendChild(u)}if(e.appendChild(c),this.selectedHistoryIndex>=0){let a=this.history[this.selectedHistoryIndex];if(a){let d=document.createElement("div");d.style.cssText="padding: 8px 12px; background: #181825; border-top: 1px solid #313244;";let u=document.createElement("div");u.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",u.textContent="\u5BFC\u822A\u8BE6\u60C5",d.appendChild(u);let h=document.createElement("div");h.style.cssText="font-size: 11px; line-height: 1.6;";let f=a.from,m=a.to;h.innerHTML=`
|
|
585
585
|
<div><span style="color:#a6adc8;">\u7C7B\u578B:</span> ${a.type}</div>
|
|
586
586
|
<div><span style="color:#a6adc8;">\u6765\u6E90:</span> ${f.path}</div>
|
|
587
587
|
${f.params?`<div><span style="color:#a6adc8;">\u6765\u6E90\u53C2\u6570:</span> ${JSON.stringify(f.params)}</div>`:""}
|
|
@@ -590,7 +590,7 @@
|
|
|
590
590
|
${m.params?`<div><span style="color:#a6adc8;">\u76EE\u6807\u53C2\u6570:</span> ${JSON.stringify(m.params)}</div>`:""}
|
|
591
591
|
${m.query?`<div><span style="color:#a6adc8;">\u76EE\u6807\u67E5\u8BE2:</span> ${JSON.stringify(m.query)}</div>`:""}
|
|
592
592
|
<div><span style="color:#a6adc8;">\u65F6\u95F4:</span> ${new Date(a.timestamp).toLocaleString("zh-CN")}</div>
|
|
593
|
-
`,
|
|
593
|
+
`,d.appendChild(h),e.appendChild(d)}}return this.element=e,e}destroy(){this.element&&(this.element.remove(),this.element=null),this.clearHistory(),this.currentRoute=null}};var re=class{constructor(e,t){this.components=[];this.flatNodes=[];this.expandedMap=new Map;this.filterQuery="";this.selectedId=null;this.scrollTop=0;this.scrollContainer=null;this.contentContainer=null;this.viewportContainer=null;this.destroyed=!1;var n,r,o,s;this.container=e,this.nodeHeight=(n=t==null?void 0:t.nodeHeight)!=null?n:28,this.visibleHeight=(r=t==null?void 0:t.visibleHeight)!=null?r:400,this.indentWidth=(o=t==null?void 0:t.indentWidth)!=null?o:20,this.onNodeClick=t==null?void 0:t.onNodeClick,this.defaultExpandAll=(s=t==null?void 0:t.defaultExpandAll)!=null?s:!1,this.boundScrollHandler=this.handleScroll.bind(this),this.renderContainer()}setComponents(e){this.components=e,this.defaultExpandAll&&this.components.length>0&&this.expandAllInternal(),this.flatten(),this.renderNodes()}setSelectedComponent(e){this.selectedId=e,this.renderNodes()}setFilter(e){this.filterQuery=e,this.flatten(),this.renderNodes()}expandAll(){this.expandAllInternal(),this.flatten(),this.renderNodes()}collapseAll(){this.expandedMap.clear(),this.flatten(),this.renderNodes()}destroy(){this.destroyed=!0,this.scrollContainer&&this.scrollContainer.removeEventListener("scroll",this.boundScrollHandler),this.container.innerHTML="",this.flatNodes=[],this.expandedMap.clear(),this.components=[],this.scrollContainer=null,this.contentContainer=null,this.viewportContainer=null}isAllExpanded(){if(this.components.length===0)return!1;for(let e of this.components)if(!this.expandedMap.get(e.id))return!1;return!0}expandAllInternal(){let e=t=>{for(let n of t)n.children&&n.children.length>0&&(this.expandedMap.set(n.id,!0),e(n.children))};e(this.components)}flatten(){this.flatNodes=[];let e=0,t=this.filterQuery.toLowerCase(),n=o=>!t||o.name.toLowerCase().includes(t)?!0:o.children?o.children.some(s=>n(s)):!1,r=(o,s,l)=>{var p;for(let c of o){let a=!t||c.name.toLowerCase().includes(t),d=n(c),u=(p=this.expandedMap.get(c.id))!=null?p:!1,h;t?h=l&&d:h=l;let f={node:c,depth:s,expanded:u,visible:h,flatIndex:e++};this.flatNodes.push(f),c.children&&c.children.length>0&&(t?r(c.children,s+1,h):r(c.children,s+1,h&&u))}};r(this.components,0,!0)}getVisibleNodes(){return this.flatNodes.filter(e=>e.visible)}renderContainer(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="position: relative; overflow: hidden;",this.scrollContainer=document.createElement("div"),this.scrollContainer.style.cssText=`overflow-y: auto; height: ${this.visibleHeight}px; position: relative;`,this.scrollContainer.addEventListener("scroll",this.boundScrollHandler),this.contentContainer=document.createElement("div"),this.contentContainer.style.cssText="position: relative; width: 100%;",this.viewportContainer=document.createElement("div"),this.viewportContainer.style.cssText="position: absolute; top: 0; left: 0; right: 0;",this.contentContainer.appendChild(this.viewportContainer),this.scrollContainer.appendChild(this.contentContainer),e.appendChild(this.scrollContainer),this.container.appendChild(e)}renderNodes(){if(!this.contentContainer||!this.viewportContainer||this.destroyed)return;let e=this.getVisibleNodes(),t=e.length*this.nodeHeight;this.contentContainer.style.height=`${t}px`;let n=Math.floor(this.scrollTop/this.nodeHeight),r=Math.min(n+Math.ceil(this.visibleHeight/this.nodeHeight)+1,e.length);this.viewportContainer.innerHTML="";for(let o=n;o<r;o++){let s=e[o],l=this.createNodeElement(s,o);this.viewportContainer.appendChild(l)}}createNodeElement(e,t){let n=document.createElement("div"),r=e.node.id===this.selectedId,o=e.node.active,s=e.node.children&&e.node.children.length>0;n.style.cssText=`
|
|
594
594
|
position: absolute;
|
|
595
595
|
top: ${t*this.nodeHeight}px;
|
|
596
596
|
left: 0;
|
|
@@ -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 $(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=`
|
|
611
|
+
`;let l=document.createElement("span");l.style.cssText="display: inline-block; width: 14px; text-align: center; margin-right: 4px; font-size: 10px; color: #585b70;",s?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let p=document.createElement("span");if(p.textContent=e.node.name,p.style.cssText="font-weight: bold;",n.appendChild(p),e.node.stateSummary){let d=document.createElement("span");d.textContent=` ${e.node.stateSummary}`,d.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(d)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let d=document.createElement("span");d.textContent=` [${e.node.propsCount} props]`,d.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(d)}let c=e.node,a=c.id;return n.addEventListener("click",()=>{var d;if(s){let u=(d=this.expandedMap.get(a))!=null?d:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(c)}),n}handleScroll(e){if(this.destroyed)return;let t=e.target;this.scrollTop=t.scrollTop,this.renderNodes()}getFlatNodes(){return[...this.flatNodes]}getVisibleNodeCount(){return this.getVisibleNodes().length}getTotalNodeCount(){return this.flatNodes.length}};var me=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},Xe=100,Ge=1024,Qe=.7,Ze=5,oe=class{constructor(e){this.counter=0;var t,n,r,o;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:Xe,leakGrowthThreshold:(n=e==null?void 0:e.leakGrowthThreshold)!=null?n:Ge,leakRSquaredThreshold:(r=e==null?void 0:e.leakRSquaredThreshold)!=null?r:Qe,leakMinSnapshots:(o=e==null?void 0:e.leakMinSnapshots)!=null?o:Ze},this.snapshots=new me(this.config.bufferSize)}trackMemoryUsage(e,t,n,r){if(e===void 0){let s=performance.memory;s&&(e=s.usedJSHeapSize,t=s.totalJSHeapSize,n=s.jsHeapSizeLimit)}if(e===void 0)return null;let o={timestamp:r!=null?r:Date.now(),usedJSHeapSize:e,totalJSHeapSize:t!=null?t:0,jsHeapSizeLimit:n!=null?n:0,index:this.counter++};return this.snapshots.push(o),o}getMemoryTrend(){let e=this.snapshots.getAll();return e.length===0?[]:e.map((t,n)=>{let r=n>0?e[n-1]:null,o=r?t.usedJSHeapSize-r.usedJSHeapSize:0,s=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:s}})}detectMemoryLeak(){let e=this.snapshots.getAll();if(e.length<this.config.leakMinSnapshots)return{hasLeak:!1,severity:"none",description:`\u5FEB\u7167\u6570\u91CF\u4E0D\u8DB3\uFF08\u9700\u8981\u81F3\u5C11 ${this.config.leakMinSnapshots} \u4E2A\uFF0C\u5F53\u524D ${e.length} \u4E2A\uFF09`,snapshotCount:e.length,growthRate:0,rSquared:0};let t=e.length,n=0,r=0,o=0,s=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,s+=b*b,l+=T*T}let p=t*s-n*n,c=p!==0?(t*o-n*r)/p:0,a=r/t,d=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=c*g+(r-c*n)/t;d+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=d!==0?1-u/d:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?c/f:0,x=h>=this.config.leakRSquaredThreshold&&m>=this.config.leakGrowthThreshold,v="none",y="\u672A\u68C0\u6D4B\u5230\u5185\u5B58\u6CC4\u6F0F";return x&&(m>=this.config.leakGrowthThreshold*10?(v="high",y=`\u68C0\u6D4B\u5230\u4E25\u91CD\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):m>=this.config.leakGrowthThreshold*3?(v="medium",y=`\u68C0\u6D4B\u5230\u4E2D\u7B49\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):(v="low",y=`\u68C0\u6D4B\u5230\u8F7B\u5FAE\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`)),{hasLeak:x,severity:v,description:y,snapshotCount:t,growthRate:m,rSquared:h}}getMemoryReport(){let e=this.snapshots.getAll(),t=this.getMemoryTrend(),n=this.detectMemoryLeak(),r=null,o=0,s=0,l=0,p=1/0;for(let d of e)(!r||d.timestamp>r.timestamp)&&(r=d),d.usedJSHeapSize>o&&(o=d.usedJSHeapSize,s=d.timestamp),l+=d.usedJSHeapSize,d.usedJSHeapSize<p&&(p=d.usedJSHeapSize);let c=e.length>0?l/e.length:0;p===1/0&&(p=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:s,averageUsage:c,minUsage:p,totalGrowth:a,trend:t,leakDetection:n,snapshotCount:e.length}}getSnapshots(){return this.snapshots.getAll()}getSnapshotCount(){return this.snapshots.size}clear(){this.snapshots.clear(),this.counter=0}destroy(){this.clear()}};var fe=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},et=200,tt=16,se=class{constructor(e){this.counter=0;var t,n;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:et,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:tt},this.records=new fe(this.config.bufferSize)}trackRender(e,t){this.records.push({componentName:e,duration:t,timestamp:Date.now(),index:this.counter++})}getSlowRenderers(e){let t=e!=null?e:this.config.slowThreshold;return this.records.getAll().filter(r=>r.duration>t).map(r=>({componentName:r.componentName,duration:r.duration,timestamp:r.timestamp,overThreshold:r.duration-t})).sort((r,o)=>o.duration-r.duration)}getRenderStats(){let e=this.records.getAll(),t=this.config.slowThreshold;if(e.length===0)return{totalRenders:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,slowRenderCount:0,slowRenderRatio:0,byComponent:[]};let n=0,r=-1/0,o=1/0,s=0,l=new Map;for(let c of e){n+=c.duration,c.duration>r&&(r=c.duration),c.duration<o&&(o=c.duration),c.duration>t&&s++;let a=l.get(c.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(c.componentName,a)),a.renderCount++,a.totalDuration+=c.duration,c.duration>a.maxDuration&&(a.maxDuration=c.duration),c.duration<a.minDuration&&(a.minDuration=c.duration),c.duration>t&&a.slowCount++}let p=Array.from(l.entries()).map(([c,a])=>({componentName:c,renderCount:a.renderCount,avgDuration:a.totalDuration/a.renderCount,maxDuration:a.maxDuration===-1/0?0:a.maxDuration,minDuration:a.minDuration===1/0?0:a.minDuration,totalDuration:a.totalDuration,slowCount:a.slowCount})).sort((c,a)=>a.avgDuration-c.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:s,slowRenderRatio:s/e.length,byComponent:p}}getRenderTimeline(){let e=this.records.getAll(),t=this.config.slowThreshold;return e.map((n,r)=>({componentName:n.componentName,duration:n.duration,timestamp:n.timestamp,isSlow:n.duration>t,gap:r>0?n.timestamp-e[r-1].timestamp:-1}))}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}clear(){this.records.clear(),this.counter=0}destroy(){this.clear()}};var ge=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},nt=100,rt=1e3,ot=2,ie=class{constructor(e){this.pending=new Map;this.counter=0;var t,n,r;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:nt,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:rt,outlierSigmaThreshold:(r=e==null?void 0:e.outlierSigmaThreshold)!=null?r:ot},this.records=new ge(this.config.bufferSize)}startBatch(e){return this.pending.has(e)?!1:(this.pending.set(e,Date.now()),!0)}endBatch(e){let t=this.pending.get(e);if(t===void 0)return null;let n=Date.now(),r=n-t;this.pending.delete(e);let o={name:e,startTime:t,endTime:n,duration:r,index:this.counter++};return this.records.push(o),o}getBatchStats(){let e=this.records.getAll();if(e.length===0)return{totalBatches:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,byName:[]};let t=0,n=-1/0,r=1/0,o=new Map;for(let l of e){t+=l.duration,l.duration>n&&(n=l.duration),l.duration<r&&(r=l.duration);let p=o.get(l.name);p||(p={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,p)),p.count++,p.totalDuration+=l.duration,l.duration>p.maxDuration&&(p.maxDuration=l.duration),l.duration<p.minDuration&&(p.minDuration=l.duration),p.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,p])=>{let c=p.totalDuration/p.count,a=0;for(let u of p.durations)a+=(u-c)*(u-c);a/=p.count;let d=Math.sqrt(a);return{name:l,count:p.count,avgDuration:c,maxDuration:p.maxDuration===-1/0?0:p.maxDuration,minDuration:p.minDuration===1/0?0:p.minDuration,totalDuration:p.totalDuration,stdDev:d}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:s}}detectAnomalousBatches(){let e=this.records.getAll();if(e.length===0)return[];let t=this.getBatchStats(),n=[],r=new Map;for(let o of t.byName)r.set(o.name,o);for(let o of e){let s=r.get(o.name);if(o.duration>this.config.slowThreshold){n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:"slow",description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u8D85\u8FC7\u6162\u64CD\u4F5C\u9608\u503C ${this.config.slowThreshold}ms`,deviationSigma:s&&s.stdDev>0?(o.duration-s.avgDuration)/s.stdDev:0});continue}if(s&&s.count>=2&&s.stdDev>0){let l=(o.duration-s.avgDuration)/s.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let p=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:p,description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u504F\u79BB\u5E73\u5747\u503C ${l.toFixed(1)} \u4E2A\u6807\u51C6\u5DEE`,deviationSigma:l})}}}return n.sort((o,s)=>o.timestamp-s.timestamp),n}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}getPendingBatches(){return Array.from(this.pending.keys())}clear(){this.records.clear(),this.pending.clear(),this.counter=0}destroy(){this.clear()}};var ae=class{constructor(e){this._installed=!1;this.app=null;var t,n,r,o,s,l;this.config={width:(t=e==null?void 0:e.width)!=null?t:420,height:(n=e==null?void 0:e.height)!=null?n:560,x:(r=e==null?void 0:e.x)!=null?r:0,y:(o=e==null?void 0:e.y)!=null?o:0,autoShow:(s=e==null?void 0:e.autoShow)!=null?s:!0,title:(l=e==null?void 0:e.title)!=null?l:"Lyt DevTools"},this.panel=new D({width:this.config.width,height:this.config.height,x:this.config.x,y:this.config.y,title:this.config.title}),this.componentTree=new I(this.panel,p=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new B(this.panel),this.eventTracker=new z(this.panel),this.timeTravel=new N(this.panel),this.panel.registerTabRenderer("components",p=>{this.componentTree.render(p)}),this.panel.registerTabRenderer("state",p=>{this.stateInspector.render(p)}),this.panel.registerTabRenderer("events",p=>{this.eventTracker.render(p)}),this.panel.registerTabRenderer("router",p=>{this.renderRouterTab(p)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,U(e,{onComponentCreated:n=>{this.componentTree.refresh()},onComponentUpdated:n=>{this.componentTree.refresh(),this.stateInspector.refresh()},onComponentUnmounted:n=>{this.componentTree.refresh()},onStateChanged:n=>{this.stateInspector.markChanged(`state.${n.path}`),this.stateInspector.refresh()},onEventEmitted:n=>{this.eventTracker.refresh()}}),this.panel.setConnected(!0)}show(){this.panel.show()}hide(){this.panel.hide()}toggle(){this.panel.toggle()}isVisible(){return this.panel.isVisible()}renderRouterTab(e){e.innerHTML="";let t=document.createElement("div");t.className="lyt-devtools-empty",t.style.cssText="padding: 40px 24px;",t.innerHTML=`
|
|
612
612
|
<div style="font-size: 32px; margin-bottom: 12px;">\u{1F517}</div>
|
|
613
613
|
<div style="color: #cdd6f4; font-size: 14px; margin-bottom: 8px; font-style: normal;">\u8DEF\u7531\u68C0\u67E5\u5668</div>
|
|
614
614
|
<div style="color: #585b70; font-size: 12px;">
|
|
@@ -616,4 +616,4 @@
|
|
|
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&&X(this.app),this.componentTree.refresh()}clearAllRecords(){G(),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(),Q(),this._installed=!1,this.app=null}};function st(
|
|
619
|
+
`,e.appendChild(t)}refreshTree(){this.app&&X(this.app),this.componentTree.refresh()}clearAllRecords(){G(),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(),Q(),this._installed=!1,this.app=null}};function st(i){let e=null;return{install(t){if(e)return;e=new ae(i),t.globalProperties&&(t.globalProperties.__LYT_DEVTOOLS__=e);let n=t;(n._instance!==void 0||n.mount)&&e.install(n)}}}
|