@memlab/lens 1.0.1 → 1.0.3
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/README.md +136 -38
- package/dist/core/react-memory-scan.d.ts +1 -0
- package/dist/extensions/dom-visualization-extension.d.ts +1 -0
- package/dist/index.js +9 -18
- package/dist/memlens.lib.bundle.js +128 -79
- package/dist/memlens.lib.bundle.min.js +26 -1
- package/dist/memlens.run.bundle.js +172 -88
- package/dist/memlens.run.bundle.min.js +26 -1
- package/dist/visual/dom-element-visualizer-interactive.d.ts +1 -0
- package/dist/visual/dom-element-visualizer.d.ts +1 -0
- package/package.json +11 -2
|
@@ -1 +1,26 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MemLens=t():e.MemLens=t()}(self,(()=>(()=>{"use strict";var e={54:function(e,t,n){var o,i,s,r,a,l,c,u,f,d,h,p,v=this&&this.__classPrivateFieldSet||function(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n},m=this&&this.__classPrivateFieldGet||function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.DOMObserver=void 0;const g=n(313),b=n(498),w=(0,g.isWeakAPINative)(),y=void 0!==window.MutationObserver;t.DOMObserver=class{constructor(){o.add(this),i.set(this,void 0),s.set(this,void 0),r.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),u.set(this,void 0),v(this,i,0,"f"),v(this,s,0,"f"),v(this,a,[],"f"),v(this,l,new WeakSet,"f"),v(this,u,[],"f"),this.startMonitoring()}register(e){m(this,u,"f").push(e)}startMonitoring(){if(!w||!y)return;if(null!=m(this,r,"f"))return;v(this,r,new MutationObserver((e=>{let t=[];const n=e=>{if(null==e)return;if(e.nodeType!=Node.ELEMENT_NODE)return;const n=e;if(!(0,b.isVisualizerElement)(n)){const e=m(this,o,"m",p).call(this,n);t=[...t,...e]}};e.forEach((e=>{e.addedNodes.forEach(n),e.removedNodes.forEach(n)})),m(this,u,"f").forEach((e=>e(t)))})),"f");const e=()=>{var t;document.body?null===(t=m(this,r,"f"))||void 0===t||t.observe(document.body,{childList:!0,subtree:!0}):setTimeout(e,0)};e(),v(this,c,window.setInterval((()=>{m(this,o,"m",f).call(this)}),3e3),"f")}stopMonitoring(){null!=m(this,r,"f")&&(m(this,r,"f").disconnect(),v(this,r,null,"f")),null!=m(this,c,"f")&&(window.clearInterval(m(this,c,"f")),v(this,c,null,"f"))}getDOMElements(){return[...m(this,a,"f")]}getStats(){try{v(this,i,m(this,o,"m",d).call(this),"f"),v(this,s,m(this,o,"m",h).call(this),"f")}catch(e){}return{elements:m(this,i,"f"),detachedElements:m(this,s,"f")}}},i=new WeakMap,s=new WeakMap,r=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,o=new WeakSet,f=function(){const e=[],t=new Set;for(const n of m(this,a,"f")){const o=n.deref();null==o||t.has(o)||(e.push(n),t.add(o))}v(this,a,e,"f")},d=function(){var e,t;return v(this,i,null!==(t=null===(e=null===document||void 0===document?void 0:document.getElementsByTagName("*"))||void 0===e?void 0:e.length)&&void 0!==t?t:0,"f")},h=function(){let e=0;for(const t of m(this,a,"f")){const n=t.deref();n&&!1===n.isConnected&&++e}return v(this,s,e,"f")},p=function(e){const t=[e],n=new Set,o=[];for(;t.length>0;){const e=t.pop();if(null==e||n.has(e))continue;if((null==e?void 0:e.nodeType)!==Node.ELEMENT_NODE)continue;const i=e;if((0,b.isVisualizerElement)(i))continue;if(n.add(i),!m(this,l,"f").has(i)){const e=new WeakRef(i);m(this,a,"f").push(e),m(this,l,"f").add(i),o.push(e)}const s=i.childNodes;for(let e=0;e<s.length;++e)t.push(s[e])}return o}},235:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createReactMemoryScan=function(e={}){return new i.default(e)};const i=o(n(282))},282:function(e,t,n){var o,i,s,r,a,l,c,u,f,d,h,p,v,m,g,b,w,y,M,k,_,E,O,C,T=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),W=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),S=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),i=0;i<n.length;i++)"default"!==n[i]&&T(t,e,n[i]);return W(t,e),t}),N=this&&this.__classPrivateFieldSet||function(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n},F=this&&this.__classPrivateFieldGet||function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)},R=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const D=S(n(476)),I=P(n(302)),j=n(737),L=n(54),H=n(346),x=n(953);class A{constructor(e={}){var t,n,o,b;i.add(this),s.set(this,void 0),r.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),u.set(this,void 0),f.set(this,void 0),d.set(this,void 0),h.set(this,void 0),p.set(this,void 0),v.set(this,void 0),m.set(this,void 0),g.set(this,void 0),N(this,s,[],"f"),N(this,r,!1,"f"),N(this,l,new WeakMap,"f"),N(this,c,new WeakMap,"f"),N(this,u,[],"f"),N(this,g,e.trackEventListenerLeaks?x.EventListenerTracker.getInstance():null,"f"),N(this,f,new I.default,"f"),N(this,a,0,"f"),N(this,d,null!==(t=e.isDevMode)&&void 0!==t&&t,"f"),N(this,h,null!==(n=e.subscribers)&&void 0!==n?n:[],"f"),N(this,p,null!==(o=e.extensions)&&void 0!==o?o:[],"f"),N(this,v,null!==(b=e.scanIntervalMs)&&void 0!==b?b:H.config.performance.scanIntervalMs,"f")}subscribe(e){return F(this,h,"f").push(e),()=>this.unsubscribe(e)}unsubscribe(e){N(this,h,F(this,h,"f").filter((t=>t!==e)),"f")}registerExtension(e){return F(this,p,"f").push(e),()=>this.unregisterExtension(e)}unregisterExtension(e){N(this,p,F(this,p,"f").filter((t=>t!==e)),"f")}start(){N(this,r,!0,"f"),N(this,a,setInterval(F(this,i,"m",k).bind(this),F(this,v,"f")),"f"),H.config.features.enableMutationObserver&&(null==F(this,m,"f")&&N(this,m,new L.DOMObserver,"f"),F(this,m,"f").startMonitoring()),console.log("[Memory] Tracking React and DOM memory...")}pause(){N(this,r,!1,"f")}stop(){var e;N(this,r,!1,"f"),clearInterval(F(this,a,"f")),N(this,s,[],"f"),null===(e=F(this,m,"f"))||void 0===e||e.stopMonitoring()}recordBoundingRectangles(e){for(const t of e){const e=t.deref();if(null==e||F(this,l,"f").has(e))continue;const n=D.getBoundingClientRect(e);null!=n&&F(this,l,"f").set(e,n)}}getDetachedDOMInfo(){var e;const t=[];for(const n of F(this,s,"f")){const o=n.deref();if(null==o||o.isConnected)continue;const i=o;if(null==i.detachedElementId){const e=A.nextElementId++;i.detachedElementIdStr=`memory-id-${e}@`,i.detachedElementId=e}const s=null!==(e=F(this,c,"f").get(o))&&void 0!==e?e:[];t.push({element:n,boundingRect:F(this,l,"f").get(o),componentStack:s})}return t}isDevMode(){return F(this,d,"f")}getCachedComponentName(e){var t;const n="<Unknown>",o=e.deref();if(null==o)return n;const i=F(this,c,"f").get(o);return null==i?n:null!==(t=i[0])&&void 0!==t?t:n}updateFiberNodes(e){const t=new WeakSet;for(const e of F(this,u,"f")){const n=e.deref();null!=n&&t.add(n)}const n=new WeakSet;for(const t of e){const e=t.deref();null!=e&&n.add(e)}const o=[],s=[];for(const e of F(this,u,"f")){const t=e.deref();null!=t&&(n.has(t)?(s.push(e),null==t.return&&o.push(e)):o.push(e))}for(const n of e){const e=n.deref();null!=e&&(t.has(e)||s.push(n))}return N(this,u,s,"f"),F(this,i,"m",b).call(this,"known fibers: ",F(this,u,"f").length),F(this,i,"m",b).call(this,"leaked fibers: ",o.length),o}packLeakedFibers(e){const t=[];for(const n of e)t.push(new B(n));return t}scan(){const e=Date.now();F(this,i,"m",O).call(this);const t=F(this,s,"f"),n=F(this,i,"m",E).call(this);F(this,i,"m",_).call(this,n),this.recordBoundingRectangles(n),D.updateWeakRefList(t,n);const o=F(this,f,"f").scan(t,F(this,c,"f")),r=this.updateFiberNodes(o.fiberNodes);o.leakedFibers=r,o.eventListenerLeaks=F(this,i,"m",C).call(this),window.leakedFibers=this.packLeakedFibers(r);const a=Date.now();return F(this,i,"m",b).call(this,`scan took ${a-e}ms`),o}}s=new WeakMap,r=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,f=new WeakMap,d=new WeakMap,h=new WeakMap,p=new WeakMap,v=new WeakMap,m=new WeakMap,g=new WeakMap,i=new WeakSet,b=function(...e){F(this,d,"f")&&H.config.features.enableConsoleLogs&&D.consoleLog(...e)},w=function(e){for(const t of F(this,h,"f"))t(e);const t=e.end-e.start;F(this,i,"m",b).call(this,"duration: ",`${t} ms`);const{scanner:n,leakedFibers:o,fiberNodes:s}=e,r=R(e,["scanner","leakedFibers","fiberNodes"]);F(this,i,"m",b).call(this,r)},y=function(){for(const e of F(this,p,"f"))null==e||e.beforeScan()},M=function(e){for(const t of F(this,p,"f"))null==t||t.afterScan(e)},k=function(){if(!F(this,r,"f"))return;F(this,i,"m",y).call(this);const e=performance.now(),t=this.scan(),n=performance.now(),o=Object.assign(Object.assign({},t),{start:e,end:n,scanner:this});F(this,i,"m",w).call(this,o),F(this,i,"m",M).call(this,o)},_=function(e){for(const t of e){const e=t.deref();if(null==e||F(this,c,"f").has(e))continue;const n=(0,j.getFiberNodeFromElement)(e);null!=n&&F(this,c,"f").set(e,(0,j.getReactComponentStack)(n))}},E=function(){return null==F(this,m,"f")?D.getDOMElements():[...D.getDOMElements(),...F(this,m,"f").getDOMElements()]},O=function(){null!=(null===window||void 0===window?void 0:window.gc)&&window.gc()},C=function(){var e;if(null==F(this,g,"f"))return[];const t=F(this,g,"f").scan(this.getCachedComponentName.bind(this)),n=[];for(const[o,i]of t.entries()){const t=new Map;for(const n of i){const o=null!==(e=t.get(n.type))&&void 0!==e?e:0;t.set(n.type,o+1)}for(const[e,i]of t.entries())n.push({type:e,componentName:o,count:i})}return n},A.nextElementId=0,t.default=A;class B{constructor(e){this.leakedFiber=e}}},302:function(e,t,n){var o,i=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),r=0;r<n.length;r++)"default"!==n[r]&&i(t,e,n[r]);return s(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(476)),l=n(737),c=n(847);t.default=class{scan(e,t){var n;const o=new Set,i=new Set,s=new Map,r=new Map,u=new Set,f=new Set,d=[];let h=0,p=0;function v(e){(0,l.traverseFiber)(e,(e=>{if(f.has(e))return!0;f.add(e);const t=(0,l.getDisplayNameOfFiberNode)(e);return null!=t&&(0,c.isValidComponentName)(t)?(i.add(t),a.addCountbyKey(s,t,1),!0):void 0}),!0)}for(const i of e){const e=i.deref();if(null==e)continue;if(++h,!e.isConnected){if(t.has(e)){const o=(null!==(n=t.get(e))&&void 0!==n?n:[])[0];e.__component_name=o,a.addCountbyKey(r,o,1)}++p}const s=(0,l.getFiberNodeFromElement)(e);if(null==s)continue;v(s);const c=(0,l.getTopMostFiberWithChild)(s);null!=c&&(o.has(c)||(o.add(c),(0,l.traverseFiber)(c,(e=>{if(u.has(e))return!0;u.add(e),d.push(new WeakRef(e)),v(e)}),!1)))}return u.clear(),f.clear(),o.clear(),{components:i,componentToFiberNodeCount:s,totalElements:h,totalDetachedElements:p,detachedComponentToFiberNodeCount:r,fiberNodes:d,leakedFibers:[]}}}},313:(e,t)=>{var n,o,i;Object.defineProperty(t,"__esModule",{value:!0}),t.WeakMapPlus=t.WeakMapNoOp=t.WeakSetNoOp=t.WeakRefNoOp=void 0,t.getNativeWeakMap=function(){return a?r:null},t.getNativeWeakMapOrFallback=function(){return a&&r?r:v},t.getNativeWeakSet=function(){return c?l:null},t.getNativeWeakSetOrFallback=function(){return c&&l?l:p},t.getNativeWeakRef=function(){return f?u:null},t.getNativeWeakRefOrFallback=function(){return f&&u?u:h},t.isWeakMapNative=g,t.isWeakSetNative=b,t.isWeakRefNative=w,t.isWeakAPINative=function(){return d};const s="undefined"!=typeof window?window:self,r=null!==(n=s.WeakMap)&&void 0!==n?n:null,a=g(),l=null!==(o=s.WeakSet)&&void 0!==o?o:null,c=b(),u=null!==(i=s.WeakRef)&&void 0!==i?i:null,f=w(),d=a&&c&&f;class h{constructor(e){}deref(){}}t.WeakRefNoOp=h;class p{constructor(e){}add(e){return this}delete(e){return!1}has(e){return!1}}t.WeakSetNoOp=p;class v{constructor(e){}delete(e){return!1}get(e){}has(e){return!1}set(e,t){return this}}function m(e){return"function"==typeof e.replace?e.replace(/\n/g," ").replace(/\s+/g," "):null}function g(){return null!==r&&"function"==typeof r.toString&&"function WeakMap() { [native code] }"===m(r.toString())}function b(){return null!==l&&"function"==typeof l.toString&&"function WeakSet() { [native code] }"===m(l.toString())}function w(){return null!==u&&"function"==typeof u.toString&&"function WeakRef() { [native code] }"===m(u.toString())}t.WeakMapNoOp=v;class y{constructor(e={}){this.strongMap=null,this.noopMap=!1,this.entriesMap=new Map,this.keyToId=new WeakMap;const{fallback:t="strong",cleanupMs:n=1e3}=e;this.isWeak=d,this.fallbackMode=t,this.isWeak?this.cleanupInterval=setInterval((()=>this.cleanup()),n):("strong"===t?this.strongMap=new Map:"noop"===t&&(this.noopMap=!0),this.cleanupInterval=-1)}getOrCreateId(e){let t=this.keyToId.get(e);return t||(t=Symbol(),this.keyToId.set(e,t)),t}set(e,t){var n;if(!this.isWeak)return this.noopMap||null===(n=this.strongMap)||void 0===n||n.set(e,t),this;const o=this.getOrCreateId(e);return this.entriesMap.set(o,{ref:new WeakRef(e),value:t}),this}get(e){var t,n;if(!this.isWeak){if(this.noopMap)return;return null===(t=this.strongMap)||void 0===t?void 0:t.get(e)}const o=this.keyToId.get(e);if(!o)return;const i=this.entriesMap.get(o);return(null===(n=null==i?void 0:i.ref)||void 0===n?void 0:n.deref())?null==i?void 0:i.value:void 0}has(e){var t,n;if(!this.isWeak)return!this.noopMap&&null!==(n=null===(t=this.strongMap)||void 0===t?void 0:t.has(e))&&void 0!==n&&n;const o=this.keyToId.get(e);if(!o)return!1;const i=this.entriesMap.get(o);return!(!i||!i.ref.deref())}delete(e){var t,n;if(!this.isWeak)return!this.noopMap&&null!==(n=null===(t=this.strongMap)||void 0===t?void 0:t.delete(e))&&void 0!==n&&n;const o=this.keyToId.get(e);return!!o&&(this.keyToId.delete(e),this.entriesMap.delete(o))}*liveEntries(){for(const[,e]of this.entriesMap){const t=e.ref.deref();t&&(yield[t,e.value])}}entries(){var e,t;return this.isWeak?this.liveEntries():this.noopMap?[][Symbol.iterator]():null!==(t=null===(e=this.strongMap)||void 0===e?void 0:e.entries())&&void 0!==t?t:[][Symbol.iterator]()}keys(){return function*(e){for(const[t]of e.entries())yield t}(this)}values(){return function*(e){for(const[,t]of e.entries())yield t}(this)}[Symbol.iterator](){return this.entries()}get size(){var e,t;if(!this.isWeak)return this.noopMap?0:null!==(t=null===(e=this.strongMap)||void 0===e?void 0:e.size)&&void 0!==t?t:0;let n=0;for(const e of this.liveEntries())n++;return n}getFallbackMode(){return this.fallbackMode}cleanup(){if(this.isWeak)for(const[e,t]of this.entriesMap)t.ref.deref()||this.entriesMap.delete(e)}destroy(){this.isWeak&&clearInterval(this.cleanupInterval)}}t.WeakMapPlus=y},346:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.config=t.featureFlags=t.performanceConfig=void 0,t.performanceConfig={scanIntervalMs:1e3,maxComponentStackDepth:100,memoryMeasurementIntervalMs:5e3},t.featureFlags={enableMutationObserver:!0,enableMemoryTracking:!0,enableComponentStack:!0,enableConsoleLogs:null===window||void 0===window?void 0:window.TEST_MEMORY_SCAN},t.config={performance:t.performanceConfig,features:t.featureFlags}},476:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDOMElements=function(){const e=Array.from(document.querySelectorAll("*")),t=[];for(const n of e)(0,o.isVisualizerElement)(n)||t.push(new WeakRef(n));return t},t.getDOMElementCount=function(){const e=Array.from(document.querySelectorAll("*"));let t=0;for(const n of e)(0,o.isVisualizerElement)(n)||++t;return t},t.getMeaningfulName=function(e){return null==e||i(e)?null:e},t.isMinifiedName=i,t.addCountbyKey=function(e,t,n){var o;e.set(t,(null!==(o=e.get(t))&&void 0!==o?o:0)+n)},t.updateWeakRefList=function(e,t){!function(e){const t=[];for(const n of e)null!=n.deref()&&t.push(n);for(;e.length>0;)e.pop();for(const n of t)e.push(n)}(e);const n=function(e){const t=new Set;for(const n of e)t.add(n.deref());return t}(e);for(const o of t){const t=o.deref();null==t||n.has(t)||(n.add(t),e.push(new WeakRef(t)))}return e},t.getBoundingClientRect=function(e){if(null==e)return null;if("function"!=typeof e.getBoundingClientRect)return null;let t=null;try{t=e.getBoundingClientRect()}catch(e){}if(null==t)return null;const n=window.scrollY,o=window.scrollX,i={};return i.bottom=t.bottom,i.height=t.height,i.left=t.left,i.right=t.right,i.top=t.top,i.width=t.width,i.x=t.x,i.y=t.y,i.scrollLeft=o,i.scrollTop=n,i},t.consoleLog=function(...e){r.apply(s,e)},t.hasRunInSession=function(){if(!l())return!1;try{return"true"===sessionStorage.getItem(a)}catch(e){return!1}},t.setRunInSession=function(){if(l())try{sessionStorage.setItem(a,"true")}catch(e){}};const o=n(498);function i(e){return!(e.length>=5)&&(e.length<=3||!/[^a-zA-Z0-9$_]/.test(e)&&!/^[A-Z][a-z]+([A-Z][a-z]*)*$|^[a-z]+([A-Z][a-z]*)*$/.test(e))}const s=console,r=s.log,a="memory_lens_session";function l(){try{const e="__memory_lens_session_test__";return sessionStorage.setItem(e,"1"),sessionStorage.removeItem(e),!0}catch(e){return!1}}},498:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isVisualizerElement=function(e){return"true"===e.getAttribute(n)},t.createVisualizerElement=function(e){const t=document.createElement(e);return function(e){e.setAttribute(n,"true"),e.setAttribute("data-visualcompletion","ignore")}(t),t},t.tryToAttachOverlay=function(e){document.body&&document.body.appendChild(e)},t.addTrackedListener=function(e,t,n,i){var s;const r=e.deref();r&&(r.addEventListener(t,n,i),o.has(r)||o.set(r,[]),null===(s=o.get(r))||void 0===s||s.push({type:t,cb:n,options:i}))},t.removeAllListeners=function(e){const t=e.deref();if(!t)return;const n=o.get(t);if(n){for(const{type:e,cb:o,options:i}of n)t.removeEventListener(e,o,i);o.delete(t)}},t.debounce=function(e,t){let n=null;return(...o)=>{n&&clearTimeout(n),n=setTimeout((()=>{e(...o)}),t)}};const n="data-visualizer",o=new WeakMap},737:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.traverseFiber=t.getTopMostFiberWithChild=t.getTopMostHostFiber=t.getNearestHostFiber=t.isHostFiber=t.MutationMask=t.Visibility=t.Snapshot=t.Ref=t.ContentReset=t.ChildDeletion=t.Cloned=t.Update=t.Hydrating=t.DidCapture=t.Placement=t.PerformedWork=t.DEPRECATED_ASYNC_MODE_SYMBOL_STRING=t.CONCURRENT_MODE_SYMBOL_STRING=t.CONCURRENT_MODE_NUMBER=t.HostRoot=t.OffscreenComponent=t.LegacyHiddenComponent=t.Fragment=t.HostText=t.DehydratedSuspenseComponent=t.HostSingletonTag=t.HostHoistableTag=t.HostComponentTag=t.SimpleMemoComponentTag=t.MemoComponentTag=t.ForwardRefTag=t.OffscreenComponentTag=t.SuspenseComponentTag=t.ContextConsumerTag=t.FunctionComponentTag=t.ClassComponentTag=void 0,t.getFiberNodeFromElement=function(e){for(const t of s){const n=r(e).find((e=>e.startsWith(t)));if(n)return e[n]}return null},t.getReactComponentStack=function(e){const t=[],n=new Set;let o=e;for(;o&&!n.has(o);){n.add(o);const e=a(o);e&&t.push(e),o=o.return}return t},t.getDisplayNameOfFiberNode=a,t.isFunctionalComponent=function(e){return"function"==typeof(null==e?void 0:e.elementType)},t.extractReactComponentName=l;const o=n(476),i=n(847);t.ClassComponentTag=1,t.FunctionComponentTag=0,t.ContextConsumerTag=9,t.SuspenseComponentTag=13,t.OffscreenComponentTag=22,t.ForwardRefTag=11,t.MemoComponentTag=14,t.SimpleMemoComponentTag=15,t.HostComponentTag=5,t.HostHoistableTag=26,t.HostSingletonTag=27,t.DehydratedSuspenseComponent=18,t.HostText=6,t.Fragment=7,t.LegacyHiddenComponent=23,t.OffscreenComponent=22,t.HostRoot=3,t.CONCURRENT_MODE_NUMBER=60111,t.CONCURRENT_MODE_SYMBOL_STRING="Symbol(react.concurrent_mode)",t.DEPRECATED_ASYNC_MODE_SYMBOL_STRING="Symbol(react.async_mode)",t.PerformedWork=1,t.Placement=2,t.DidCapture=128,t.Hydrating=4096,t.Update=4,t.Cloned=8,t.ChildDeletion=16,t.ContentReset=32,t.Ref=512,t.Snapshot=1024,t.Visibility=8192,t.MutationMask=t.Placement|t.Update|t.ChildDeletion|t.ContentReset|t.Hydrating|t.Visibility|t.Snapshot,t.isHostFiber=e=>e.tag===t.HostComponentTag||e.tag===t.HostHoistableTag||e.tag===t.HostSingletonTag||"string"==typeof e.type,t.getNearestHostFiber=e=>{let n=(0,t.traverseFiber)(e,t.isHostFiber);return n||(n=(0,t.traverseFiber)(e,t.isHostFiber,!0)),n},t.getTopMostHostFiber=e=>{let n=null;return(0,t.traverseFiber)(e,(function(e){(0,t.isHostFiber)(e)&&(n=e)}),!0),n},t.getTopMostFiberWithChild=e=>{let n=null;return(0,t.traverseFiber)(e,(function(e){null!=e.child&&(n=e)}),!0),n},t.traverseFiber=(e,n,o=!1)=>{if(!e)return null;if(!0===n(e))return e;let i=o?e.return:e.child;for(;i;){const e=(0,t.traverseFiber)(i,n,o);if(e)return e;i=o?null:i.sibling}return null};const s=["__reactFiber$","__reactInternalInstance$","_reactRootContainer"],r=Object.getOwnPropertyNames.bind(Object);function a(e){var t,n,s,r;const a=null!==(t=e.type)&&void 0!==t?t:e.elementType;let c=null!==(n=null==a?void 0:a.displayName)&&void 0!==n?n:null==a?void 0:a.name;if(null==c)if(null==a?void 0:a.render){const e=null==a?void 0:a.render;c=null!==(s=null==e?void 0:e.displayName)&&void 0!==s?s:null==e?void 0:e.name}else(null==a?void 0:a.type)&&(c=null!==(r=a.type.displayName)&&void 0!==r?r:a.type.name);c||"function"!=typeof a||(c=a.name);const u=(0,o.getMeaningfulName)(l(c));return(0,i.isValidComponentName)(u)?u:null}function l(e){if("string"!=typeof e)return null;if(!e.includes("[")||!e.includes("]"))return e;const t=e.indexOf("["),n=e.indexOf("]");if(t>n)return e;const o=e.substring(t+1,n);return o.startsWith("from ")?o.substring(5):o}},847:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isValidComponentName=function(e){return null!=e&&!n.has(e)};const n=new Set},953:function(e,t,n){var o,i,s,r,a,l,c,u=this&&this.__classPrivateFieldSet||function(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n},f=this&&this.__classPrivateFieldGet||function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.EventListenerTracker=void 0;const d=n(737),h=n(313);class p{constructor(){o.add(this),i.set(this,void 0),s.set(this,void 0),r.set(this,void 0),a.set(this,void 0),u(this,i,new h.WeakMapPlus({fallback:"noop",cleanupMs:100}),"f"),u(this,s,new Map,"f"),u(this,r,EventTarget.prototype.addEventListener,"f"),u(this,a,EventTarget.prototype.removeEventListener,"f"),f(this,o,"m",l).call(this)}static getInstance(){return p.instance||(p.instance=new p),p.instance}addListener(e,t,n,o){e.addEventListener(t,n,o)}removeListener(e,t,n,o){e.removeEventListener(t,n,o)}scan(e){const t=new Map;for(const[n,o]of f(this,i,"f").entries())if(n instanceof Element&&!n.isConnected)for(const i of o){if(!i.cb.deref())continue;const o=e(new WeakRef(n));t.has(o)||t.set(o,[]);const s=t.get(o);let r=null==s?void 0:s.find((e=>e.type===i.type));r||(r={type:i.type,count:0,entries:[]},null==s||s.push(r)),r.count++,r.entries.push(new WeakRef(i))}return u(this,s,t,"f"),t}getDetachedListeners(){return f(this,s,"f")}destroy(){f(this,o,"m",c).call(this),f(this,i,"f").destroy(),f(this,s,"f").clear(),p.instance=null}}t.EventListenerTracker=p,i=new WeakMap,s=new WeakMap,r=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){const e=this;EventTarget.prototype.addEventListener=function(t,n,o){var s;if(f(e,r,"f").call(this,t,n,o),this instanceof Element){const r=(0,d.getFiberNodeFromElement)(this),a={type:t,cb:new WeakRef(n),options:o,fiber:r?new WeakRef(r):void 0},l=null!==(s=f(e,i,"f").get(this))&&void 0!==s?s:[];l.push(a),f(e,i,"f").set(this,l)}},EventTarget.prototype.removeEventListener=function(t,n,o){if(f(e,a,"f").call(this,t,n,o),this instanceof Element){const s=f(e,i,"f").get(this);if(s){const r=s.findIndex((e=>e.type===t&&e.cb.deref()===n&&e.options===o));-1!==r&&s.splice(r,1),0===s.length?f(e,i,"f").delete(this):f(e,i,"f").set(this,s)}}}},c=function(){EventTarget.prototype.addEventListener=f(this,r,"f"),EventTarget.prototype.removeEventListener=f(this,a,"f")},p.instance=null}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var s=t[o]={exports:{}};return e[o].call(s.exports,s,s.exports,n),s.exports}(235)})()));
|
|
1
|
+
/**
|
|
2
|
+
* @license MemLab
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MemLens=t():e.MemLens=t()}(self,(()=>(()=>{"use strict";var e={54:function(e,t,n){var o,i,s,r,a,l,c,u,f,d,h,p,v=this&&this.__classPrivateFieldSet||function(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n},m=this&&this.__classPrivateFieldGet||function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.DOMObserver=void 0;const g=n(313),b=n(498),y=(0,g.isWeakAPINative)(),w=void 0!==window.MutationObserver;t.DOMObserver=class{constructor(){o.add(this),i.set(this,void 0),s.set(this,void 0),r.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),u.set(this,void 0),v(this,i,0,"f"),v(this,s,0,"f"),v(this,a,[],"f"),v(this,l,new WeakSet,"f"),v(this,u,[],"f"),this.startMonitoring()}register(e){m(this,u,"f").push(e)}startMonitoring(){if(!y||!w)return;if(null!=m(this,r,"f"))return;v(this,r,new MutationObserver((e=>{let t=[];const n=e=>{if(null==e)return;if(e.nodeType!=Node.ELEMENT_NODE)return;const n=e;if(!(0,b.isVisualizerElement)(n)){const e=m(this,o,"m",p).call(this,n);t=[...t,...e]}};e.forEach((e=>{e.addedNodes.forEach(n),e.removedNodes.forEach(n)})),m(this,u,"f").forEach((e=>e(t)))})),"f");const e=()=>{var t;document.body?null===(t=m(this,r,"f"))||void 0===t||t.observe(document.body,{childList:!0,subtree:!0}):setTimeout(e,0)};e(),v(this,c,window.setInterval((()=>{m(this,o,"m",f).call(this)}),3e3),"f")}stopMonitoring(){null!=m(this,r,"f")&&(m(this,r,"f").disconnect(),v(this,r,null,"f")),null!=m(this,c,"f")&&(window.clearInterval(m(this,c,"f")),v(this,c,null,"f"))}getDOMElements(){return[...m(this,a,"f")]}getStats(){try{v(this,i,m(this,o,"m",d).call(this),"f"),v(this,s,m(this,o,"m",h).call(this),"f")}catch(e){}return{elements:m(this,i,"f"),detachedElements:m(this,s,"f")}}},i=new WeakMap,s=new WeakMap,r=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,o=new WeakSet,f=function(){const e=[],t=new Set;for(const n of m(this,a,"f")){const o=n.deref();null==o||t.has(o)||(e.push(n),t.add(o))}v(this,a,e,"f")},d=function(){var e,t;return v(this,i,null!==(t=null===(e=null===document||void 0===document?void 0:document.getElementsByTagName("*"))||void 0===e?void 0:e.length)&&void 0!==t?t:0,"f")},h=function(){let e=0;for(const t of m(this,a,"f")){const n=t.deref();n&&!1===n.isConnected&&++e}return v(this,s,e,"f")},p=function(e){const t=[e],n=new Set,o=[];for(;t.length>0;){const e=t.pop();if(null==e||n.has(e))continue;if((null==e?void 0:e.nodeType)!==Node.ELEMENT_NODE)continue;const i=e;if((0,b.isVisualizerElement)(i))continue;if(n.add(i),!m(this,l,"f").has(i)){const e=new WeakRef(i);m(this,a,"f").push(e),m(this,l,"f").add(i),o.push(e)}const s=i.childNodes;for(let e=0;e<s.length;++e)t.push(s[e])}return o}},235:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createReactMemoryScan=void 0;const i=o(n(282));t.createReactMemoryScan=function(e={}){return new i.default(e)}},282:function(e,t,n){var o,i,s,r,a,l,c,u,f,d,h,p,v,m,g,b,y,w,M,k,E,_,C,O,W=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),T=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),N=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&W(t,e,n);return T(t,e),t},S=this&&this.__classPrivateFieldSet||function(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n},R=this&&this.__classPrivateFieldGet||function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)},F=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const D=N(n(476)),I=P(n(302)),L=n(737),j=n(54),H=n(346),x=n(953);class A{constructor(e={}){var t,n,b,y;o.add(this),i.set(this,void 0),s.set(this,void 0),r.set(this,void 0),a.set(this,void 0),l.set(this,void 0),c.set(this,void 0),u.set(this,void 0),f.set(this,void 0),d.set(this,void 0),h.set(this,void 0),p.set(this,void 0),v.set(this,void 0),m.set(this,void 0),g.set(this,void 0),S(this,i,[],"f"),S(this,s,!1,"f"),S(this,a,new WeakMap,"f"),S(this,l,new WeakMap,"f"),S(this,c,[],"f"),S(this,m,e.trackEventListenerLeaks?x.EventListenerTracker.getInstance():null,"f"),S(this,r,null,"f"),S(this,g,!1,"f"),S(this,u,new I.default,"f"),S(this,f,null!==(t=e.isDevMode)&&void 0!==t&&t,"f"),S(this,d,null!==(n=e.subscribers)&&void 0!==n?n:[],"f"),S(this,h,null!==(b=e.extensions)&&void 0!==b?b:[],"f"),S(this,p,null!==(y=e.scanIntervalMs)&&void 0!==y?y:H.config.performance.scanIntervalMs,"f")}subscribe(e){return R(this,d,"f").push(e),()=>this.unsubscribe(e)}unsubscribe(e){S(this,d,R(this,d,"f").filter((t=>t!==e)),"f")}registerExtension(e){return R(this,h,"f").push(e),()=>this.unregisterExtension(e)}unregisterExtension(e){S(this,h,R(this,h,"f").filter((t=>t!==e)),"f")}start(){R(this,g,"f")?console.warn("[Memory] ReactMemoryScan has been disposed and cannot be started again"):(S(this,s,!0,"f"),S(this,r,setInterval(R(this,o,"m",k).bind(this),R(this,p,"f")),"f"),H.config.features.enableMutationObserver&&(null==R(this,v,"f")&&S(this,v,new j.DOMObserver,"f"),R(this,v,"f").startMonitoring()),console.log("[Memory] Tracking React and DOM memory..."))}pause(){S(this,s,!1,"f")}stop(){S(this,s,!1,"f"),null!==R(this,r,"f")&&(clearInterval(R(this,r,"f")),S(this,r,null,"f")),S(this,i,[],"f"),S(this,c,[],"f"),R(this,v,"f")&&(R(this,v,"f").stopMonitoring(),S(this,v,null,"f")),S(this,a,new WeakMap,"f"),S(this,l,new WeakMap,"f"),console.log("[Memory] ReactMemoryScan stopped")}dispose(){this.stop(),S(this,d,[],"f");for(const e of R(this,h,"f"))e&&"function"==typeof e.cleanup&&e.cleanup();S(this,h,[],"f"),R(this,m,"f")&&(R(this,m,"f").destroy(),S(this,m,null,"f")),S(this,g,!0,"f"),console.log("[Memory] ReactMemoryScan disposed")}recordBoundingRectangles(e){for(const t of e){const e=t.deref();if(null==e||R(this,a,"f").has(e))continue;const n=D.getBoundingClientRect(e);null!=n&&R(this,a,"f").set(e,n)}}getDetachedDOMInfo(){var e;const t=[];for(const n of R(this,i,"f")){const o=n.deref();if(null==o||o.isConnected)continue;const i=o;if(null==i.detachedElementId){const e=A.nextElementId++;i.detachedElementIdStr=`memory-id-${e}@`,i.detachedElementId=e}const s=null!==(e=R(this,l,"f").get(o))&&void 0!==e?e:[];t.push({element:n,boundingRect:R(this,a,"f").get(o),componentStack:s})}return t}isDevMode(){return R(this,f,"f")}getCachedComponentName(e){var t;const n="<Unknown>",o=e.deref();if(null==o)return n;const i=R(this,l,"f").get(o);return null==i?n:null!==(t=i[0])&&void 0!==t?t:n}updateFiberNodes(e){const t=new WeakSet;for(const e of R(this,c,"f")){const n=e.deref();null!=n&&t.add(n)}const n=new WeakSet;for(const t of e){const e=t.deref();null!=e&&n.add(e)}const i=[],s=[];for(const e of R(this,c,"f")){const t=e.deref();null!=t&&(n.has(t)?(s.push(e),null==t.return&&i.push(e)):i.push(e))}for(const n of e){const e=n.deref();null!=e&&(t.has(e)||s.push(n))}return S(this,c,s,"f"),R(this,o,"m",b).call(this,"known fibers: ",R(this,c,"f").length),R(this,o,"m",b).call(this,"leaked fibers: ",i.length),i}packLeakedFibers(e){const t=[];for(const n of e)t.push(new z(n));return t}scan(){const e=Date.now();R(this,o,"m",C).call(this);const t=R(this,i,"f"),n=R(this,o,"m",_).call(this);R(this,o,"m",E).call(this,n),this.recordBoundingRectangles(n),D.updateWeakRefList(t,n);const s=R(this,u,"f").scan(t,R(this,l,"f")),r=this.updateFiberNodes(s.fiberNodes);s.leakedFibers=r,s.eventListenerLeaks=R(this,o,"m",O).call(this),window.leakedFibers=this.packLeakedFibers(r);const a=Date.now();return R(this,o,"m",b).call(this,`scan took ${a-e}ms`),s}}t.default=A,i=new WeakMap,s=new WeakMap,r=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,f=new WeakMap,d=new WeakMap,h=new WeakMap,p=new WeakMap,v=new WeakMap,m=new WeakMap,g=new WeakMap,o=new WeakSet,b=function(...e){R(this,f,"f")&&H.config.features.enableConsoleLogs&&D.consoleLog(...e)},y=function(e){for(const t of R(this,d,"f"))t(e);const t=e.end-e.start;R(this,o,"m",b).call(this,"duration: ",`${t} ms`);const{scanner:n,leakedFibers:i,fiberNodes:s}=e,r=F(e,["scanner","leakedFibers","fiberNodes"]);R(this,o,"m",b).call(this,r)},w=function(){for(const e of R(this,h,"f"))null==e||e.beforeScan()},M=function(e){for(const t of R(this,h,"f"))null==t||t.afterScan(e)},k=function(){if(!R(this,s,"f"))return;R(this,o,"m",w).call(this);const e=performance.now(),t=this.scan(),n=performance.now(),i=Object.assign(Object.assign({},t),{start:e,end:n,scanner:this});R(this,o,"m",y).call(this,i),R(this,o,"m",M).call(this,i)},E=function(e){for(const t of e){const e=t.deref();if(null==e||R(this,l,"f").has(e))continue;const n=(0,L.getFiberNodeFromElement)(e);null!=n&&R(this,l,"f").set(e,(0,L.getReactComponentStack)(n))}},_=function(){return null==R(this,v,"f")?D.getDOMElements():[...D.getDOMElements(),...R(this,v,"f").getDOMElements()]},C=function(){null!=(null===window||void 0===window?void 0:window.gc)&&window.gc()},O=function(){var e;if(null==R(this,m,"f"))return[];const t=R(this,m,"f").scan(this.getCachedComponentName.bind(this)),n=[];for(const[o,i]of t.entries()){const t=new Map;for(const n of i){const o=null!==(e=t.get(n.type))&&void 0!==e?e:0;t.set(n.type,o+1)}for(const[e,i]of t.entries())n.push({type:e,componentName:o,count:i})}return n},A.nextElementId=0;class z{constructor(e){this.leakedFiber=e}}},302:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(476)),a=n(737),l=n(847);t.default=class{scan(e,t){var n;const o=new Set,i=new Set,s=new Map,c=new Map,u=new Set,f=new Set,d=[];let h=0,p=0;function v(e){(0,a.traverseFiber)(e,(e=>{if(f.has(e))return!0;f.add(e);const t=(0,a.getDisplayNameOfFiberNode)(e);return null!=t&&(0,l.isValidComponentName)(t)?(i.add(t),r.addCountbyKey(s,t,1),!0):void 0}),!0)}for(const i of e){const e=i.deref();if(null==e)continue;if(++h,!e.isConnected){if(t.has(e)){const o=(null!==(n=t.get(e))&&void 0!==n?n:[])[0];e.__component_name=o,r.addCountbyKey(c,o,1)}++p}const s=(0,a.getFiberNodeFromElement)(e);if(null==s)continue;v(s);const l=(0,a.getTopMostFiberWithChild)(s);null!=l&&(o.has(l)||(o.add(l),(0,a.traverseFiber)(l,(e=>{if(u.has(e))return!0;u.add(e),d.push(new WeakRef(e)),v(e)}),!1)))}return u.clear(),f.clear(),o.clear(),{components:i,componentToFiberNodeCount:s,totalElements:h,totalDetachedElements:p,detachedComponentToFiberNodeCount:c,fiberNodes:d,leakedFibers:[]}}}},313:(e,t)=>{var n,o,i;Object.defineProperty(t,"__esModule",{value:!0}),t.WeakMapPlus=t.isWeakAPINative=t.isWeakRefNative=t.isWeakSetNative=t.isWeakMapNative=t.getNativeWeakRefOrFallback=t.getNativeWeakRef=t.getNativeWeakSetOrFallback=t.getNativeWeakSet=t.getNativeWeakMapOrFallback=t.getNativeWeakMap=t.WeakMapNoOp=t.WeakSetNoOp=t.WeakRefNoOp=void 0;const s="undefined"!=typeof window?window:self,r=null!==(n=s.WeakMap)&&void 0!==n?n:null,a=g(),l=null!==(o=s.WeakSet)&&void 0!==o?o:null,c=b(),u=null!==(i=s.WeakRef)&&void 0!==i?i:null,f=y(),d=a&&c&&f;class h{constructor(e){}deref(){}}t.WeakRefNoOp=h;class p{constructor(e){}add(e){return this}delete(e){return!1}has(e){return!1}}t.WeakSetNoOp=p;class v{constructor(e){}delete(e){return!1}get(e){}has(e){return!1}set(e,t){return this}}function m(e){return"function"==typeof e.replace?e.replace(/\n/g," ").replace(/\s+/g," "):null}function g(){return null!==r&&"function"==typeof r.toString&&"function WeakMap() { [native code] }"===m(r.toString())}function b(){return null!==l&&"function"==typeof l.toString&&"function WeakSet() { [native code] }"===m(l.toString())}function y(){return null!==u&&"function"==typeof u.toString&&"function WeakRef() { [native code] }"===m(u.toString())}t.WeakMapNoOp=v,t.getNativeWeakMap=function(){return a?r:null},t.getNativeWeakMapOrFallback=function(){return a&&r?r:v},t.getNativeWeakSet=function(){return c?l:null},t.getNativeWeakSetOrFallback=function(){return c&&l?l:p},t.getNativeWeakRef=function(){return f?u:null},t.getNativeWeakRefOrFallback=function(){return f&&u?u:h},t.isWeakMapNative=g,t.isWeakSetNative=b,t.isWeakRefNative=y,t.isWeakAPINative=function(){return d};class w{constructor(e={}){this.strongMap=null,this.noopMap=!1,this.entriesMap=new Map,this.keyToId=new WeakMap;const{fallback:t="strong",cleanupMs:n=1e3}=e;this.isWeak=d,this.fallbackMode=t,this.isWeak?this.cleanupInterval=setInterval((()=>this.cleanup()),n):("strong"===t?this.strongMap=new Map:"noop"===t&&(this.noopMap=!0),this.cleanupInterval=-1)}getOrCreateId(e){let t=this.keyToId.get(e);return t||(t=Symbol(),this.keyToId.set(e,t)),t}set(e,t){var n;if(!this.isWeak)return this.noopMap||null===(n=this.strongMap)||void 0===n||n.set(e,t),this;const o=this.getOrCreateId(e);return this.entriesMap.set(o,{ref:new WeakRef(e),value:t}),this}get(e){var t,n;if(!this.isWeak){if(this.noopMap)return;return null===(t=this.strongMap)||void 0===t?void 0:t.get(e)}const o=this.keyToId.get(e);if(!o)return;const i=this.entriesMap.get(o);return(null===(n=null==i?void 0:i.ref)||void 0===n?void 0:n.deref())?null==i?void 0:i.value:void 0}has(e){var t,n;if(!this.isWeak)return!this.noopMap&&null!==(n=null===(t=this.strongMap)||void 0===t?void 0:t.has(e))&&void 0!==n&&n;const o=this.keyToId.get(e);if(!o)return!1;const i=this.entriesMap.get(o);return!(!i||!i.ref.deref())}delete(e){var t,n;if(!this.isWeak)return!this.noopMap&&null!==(n=null===(t=this.strongMap)||void 0===t?void 0:t.delete(e))&&void 0!==n&&n;const o=this.keyToId.get(e);return!!o&&(this.keyToId.delete(e),this.entriesMap.delete(o))}*liveEntries(){for(const[,e]of this.entriesMap){const t=e.ref.deref();t&&(yield[t,e.value])}}entries(){var e,t;return this.isWeak?this.liveEntries():this.noopMap?[][Symbol.iterator]():null!==(t=null===(e=this.strongMap)||void 0===e?void 0:e.entries())&&void 0!==t?t:[][Symbol.iterator]()}keys(){return function*(e){for(const[t]of e.entries())yield t}(this)}values(){return function*(e){for(const[,t]of e.entries())yield t}(this)}[Symbol.iterator](){return this.entries()}get size(){var e,t;if(!this.isWeak)return this.noopMap?0:null!==(t=null===(e=this.strongMap)||void 0===e?void 0:e.size)&&void 0!==t?t:0;let n=0;for(const e of this.liveEntries())n++;return n}getFallbackMode(){return this.fallbackMode}cleanup(){if(this.isWeak)for(const[e,t]of this.entriesMap)t.ref.deref()||this.entriesMap.delete(e)}destroy(){this.isWeak&&clearInterval(this.cleanupInterval)}}t.WeakMapPlus=w},346:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.config=t.featureFlags=t.performanceConfig=void 0,t.performanceConfig={scanIntervalMs:1e3,maxComponentStackDepth:100,memoryMeasurementIntervalMs:5e3},t.featureFlags={enableMutationObserver:!0,enableMemoryTracking:!0,enableComponentStack:!0,enableConsoleLogs:null===window||void 0===window?void 0:window.TEST_MEMORY_SCAN},t.config={performance:t.performanceConfig,features:t.featureFlags}},476:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setRunInSession=t.hasRunInSession=t.consoleLog=t.getBoundingClientRect=t.updateWeakRefList=t.addCountbyKey=t.isMinifiedName=t.getMeaningfulName=t.getDOMElementCount=t.getDOMElements=void 0;const o=n(498);function i(e){return!(e.length>=5)&&(e.length<=3||!/[^a-zA-Z0-9$_]/.test(e)&&!/^[A-Z][a-z]+([A-Z][a-z]*)*$|^[a-z]+([A-Z][a-z]*)*$/.test(e))}t.getDOMElements=function(){const e=Array.from(document.querySelectorAll("*")),t=[];for(const n of e)(0,o.isVisualizerElement)(n)||t.push(new WeakRef(n));return t},t.getDOMElementCount=function(){const e=Array.from(document.querySelectorAll("*"));let t=0;for(const n of e)(0,o.isVisualizerElement)(n)||++t;return t},t.getMeaningfulName=function(e){return null==e||i(e)?null:e},t.isMinifiedName=i,t.addCountbyKey=function(e,t,n){var o;e.set(t,(null!==(o=e.get(t))&&void 0!==o?o:0)+n)},t.updateWeakRefList=function(e,t){!function(e){const t=[];for(const n of e)null!=n.deref()&&t.push(n);for(;e.length>0;)e.pop();for(const n of t)e.push(n)}(e);const n=function(e){const t=new Set;for(const n of e)t.add(n.deref());return t}(e);for(const o of t){const t=o.deref();null==t||n.has(t)||(n.add(t),e.push(new WeakRef(t)))}return e},t.getBoundingClientRect=function(e){if(null==e)return null;if("function"!=typeof e.getBoundingClientRect)return null;let t=null;try{t=e.getBoundingClientRect()}catch(e){}if(null==t)return null;const n=window.scrollY,o=window.scrollX,i={};return i.bottom=t.bottom,i.height=t.height,i.left=t.left,i.right=t.right,i.top=t.top,i.width=t.width,i.x=t.x,i.y=t.y,i.scrollLeft=o,i.scrollTop=n,i};const s=console,r=s.log;t.consoleLog=function(...e){r.apply(s,e)};const a="memory_lens_session";function l(){try{const e="__memory_lens_session_test__";return sessionStorage.setItem(e,"1"),sessionStorage.removeItem(e),!0}catch(e){return!1}}t.hasRunInSession=function(){if(!l())return!1;try{return"true"===sessionStorage.getItem(a)}catch(e){return!1}},t.setRunInSession=function(){if(l())try{sessionStorage.setItem(a,"true")}catch(e){}}},498:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=t.removeAllListeners=t.addTrackedListener=t.tryToAttachOverlay=t.createVisualizerElement=t.isVisualizerElement=void 0;const n="data-visualizer";t.isVisualizerElement=function(e){return"true"===e.getAttribute(n)},t.createVisualizerElement=function(e){const t=document.createElement(e);return function(e){e.setAttribute(n,"true"),e.setAttribute("data-visualcompletion","ignore")}(t),t},t.tryToAttachOverlay=function(e){document.body&&document.body.appendChild(e)};const o=new WeakMap;t.addTrackedListener=function(e,t,n,i){var s;const r=e.deref();r&&(r.addEventListener(t,n,i),o.has(r)||o.set(r,[]),null===(s=o.get(r))||void 0===s||s.push({type:t,cb:n,options:i}))},t.removeAllListeners=function(e){const t=e.deref();if(!t)return;const n=o.get(t);if(n){for(const{type:e,cb:o,options:i}of n)t.removeEventListener(e,o,i);o.delete(t)}},t.debounce=function(e,t){let n=null;return(...o)=>{n&&clearTimeout(n),n=setTimeout((()=>{e(...o)}),t)}}},737:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractReactComponentName=t.isFunctionalComponent=t.getDisplayNameOfFiberNode=t.getReactComponentStack=t.getFiberNodeFromElement=t.traverseFiber=t.getTopMostFiberWithChild=t.getTopMostHostFiber=t.getNearestHostFiber=t.isHostFiber=t.MutationMask=t.Visibility=t.Snapshot=t.Ref=t.ContentReset=t.ChildDeletion=t.Cloned=t.Update=t.Hydrating=t.DidCapture=t.Placement=t.PerformedWork=t.DEPRECATED_ASYNC_MODE_SYMBOL_STRING=t.CONCURRENT_MODE_SYMBOL_STRING=t.CONCURRENT_MODE_NUMBER=t.HostRoot=t.OffscreenComponent=t.LegacyHiddenComponent=t.Fragment=t.HostText=t.DehydratedSuspenseComponent=t.HostSingletonTag=t.HostHoistableTag=t.HostComponentTag=t.SimpleMemoComponentTag=t.MemoComponentTag=t.ForwardRefTag=t.OffscreenComponentTag=t.SuspenseComponentTag=t.ContextConsumerTag=t.FunctionComponentTag=t.ClassComponentTag=void 0;const o=n(476),i=n(847);t.ClassComponentTag=1,t.FunctionComponentTag=0,t.ContextConsumerTag=9,t.SuspenseComponentTag=13,t.OffscreenComponentTag=22,t.ForwardRefTag=11,t.MemoComponentTag=14,t.SimpleMemoComponentTag=15,t.HostComponentTag=5,t.HostHoistableTag=26,t.HostSingletonTag=27,t.DehydratedSuspenseComponent=18,t.HostText=6,t.Fragment=7,t.LegacyHiddenComponent=23,t.OffscreenComponent=22,t.HostRoot=3,t.CONCURRENT_MODE_NUMBER=60111,t.CONCURRENT_MODE_SYMBOL_STRING="Symbol(react.concurrent_mode)",t.DEPRECATED_ASYNC_MODE_SYMBOL_STRING="Symbol(react.async_mode)",t.PerformedWork=1,t.Placement=2,t.DidCapture=128,t.Hydrating=4096,t.Update=4,t.Cloned=8,t.ChildDeletion=16,t.ContentReset=32,t.Ref=512,t.Snapshot=1024,t.Visibility=8192,t.MutationMask=t.Placement|t.Update|t.ChildDeletion|t.ContentReset|t.Hydrating|t.Visibility|t.Snapshot,t.isHostFiber=e=>e.tag===t.HostComponentTag||e.tag===t.HostHoistableTag||e.tag===t.HostSingletonTag||"string"==typeof e.type,t.getNearestHostFiber=e=>{let n=(0,t.traverseFiber)(e,t.isHostFiber);return n||(n=(0,t.traverseFiber)(e,t.isHostFiber,!0)),n},t.getTopMostHostFiber=e=>{let n=null;return(0,t.traverseFiber)(e,(function(e){(0,t.isHostFiber)(e)&&(n=e)}),!0),n},t.getTopMostFiberWithChild=e=>{let n=null;return(0,t.traverseFiber)(e,(function(e){null!=e.child&&(n=e)}),!0),n},t.traverseFiber=(e,n,o=!1)=>{if(!e)return null;if(!0===n(e))return e;let i=o?e.return:e.child;for(;i;){const e=(0,t.traverseFiber)(i,n,o);if(e)return e;i=o?null:i.sibling}return null};const s=["__reactFiber$","__reactInternalInstance$","_reactRootContainer"],r=Object.getOwnPropertyNames.bind(Object);function a(e){var t,n,s,r;const a=null!==(t=e.type)&&void 0!==t?t:e.elementType;let c=null!==(n=null==a?void 0:a.displayName)&&void 0!==n?n:null==a?void 0:a.name;if(null==c)if(null==a?void 0:a.render){const e=null==a?void 0:a.render;c=null!==(s=null==e?void 0:e.displayName)&&void 0!==s?s:null==e?void 0:e.name}else(null==a?void 0:a.type)&&(c=null!==(r=a.type.displayName)&&void 0!==r?r:a.type.name);c||"function"!=typeof a||(c=a.name);const u=(0,o.getMeaningfulName)(l(c));return(0,i.isValidComponentName)(u)?u:null}function l(e){if("string"!=typeof e)return null;if(!e.includes("[")||!e.includes("]"))return e;const t=e.indexOf("["),n=e.indexOf("]");if(t>n)return e;const o=e.substring(t+1,n);return o.startsWith("from ")?o.substring(5):o}t.getFiberNodeFromElement=function(e){for(const t of s){const n=r(e).find((e=>e.startsWith(t)));if(n)return e[n]}return null},t.getReactComponentStack=function(e){const t=[],n=new Set;let o=e;for(;o&&!n.has(o);){n.add(o);const e=a(o);e&&t.push(e),o=o.return}return t},t.getDisplayNameOfFiberNode=a,t.isFunctionalComponent=function(e){return"function"==typeof(null==e?void 0:e.elementType)},t.extractReactComponentName=l},847:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isValidComponentName=void 0;const n=new Set;t.isValidComponentName=function(e){return null!=e&&!n.has(e)}},953:function(e,t,n){var o,i,s,r,a,l,c,u=this&&this.__classPrivateFieldSet||function(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n},f=this&&this.__classPrivateFieldGet||function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.EventListenerTracker=void 0;const d=n(737),h=n(313);class p{constructor(){o.add(this),i.set(this,void 0),s.set(this,void 0),r.set(this,void 0),a.set(this,void 0),u(this,i,new h.WeakMapPlus({fallback:"noop",cleanupMs:100}),"f"),u(this,s,new Map,"f"),u(this,r,EventTarget.prototype.addEventListener,"f"),u(this,a,EventTarget.prototype.removeEventListener,"f"),f(this,o,"m",l).call(this)}static getInstance(){return p.instance||(p.instance=new p),p.instance}addListener(e,t,n,o){e.addEventListener(t,n,o)}removeListener(e,t,n,o){e.removeEventListener(t,n,o)}scan(e){const t=new Map;for(const[n,o]of f(this,i,"f").entries())if(n instanceof Element&&!n.isConnected)for(const i of o){if(!i.cb.deref())continue;const o=e(new WeakRef(n));t.has(o)||t.set(o,[]);const s=t.get(o);let r=null==s?void 0:s.find((e=>e.type===i.type));r||(r={type:i.type,count:0,entries:[]},null==s||s.push(r)),r.count++,r.entries.push(new WeakRef(i))}return u(this,s,t,"f"),t}getDetachedListeners(){return f(this,s,"f")}destroy(){f(this,o,"m",c).call(this),f(this,i,"f").destroy(),f(this,s,"f").clear(),p.instance=null}}t.EventListenerTracker=p,i=new WeakMap,s=new WeakMap,r=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){const e=this;EventTarget.prototype.addEventListener=function(t,n,o){var s;if(f(e,r,"f").call(this,t,n,o),this instanceof Element){const r=(0,d.getFiberNodeFromElement)(this),a={type:t,cb:new WeakRef(n),options:o,fiber:r?new WeakRef(r):void 0},l=null!==(s=f(e,i,"f").get(this))&&void 0!==s?s:[];l.push(a),f(e,i,"f").set(this,l)}},EventTarget.prototype.removeEventListener=function(t,n,o){if(f(e,a,"f").call(this,t,n,o),this instanceof Element){const s=f(e,i,"f").get(this);if(s){const r=s.findIndex((e=>e.type===t&&e.cb.deref()===n&&e.options===o));-1!==r&&s.splice(r,1),0===s.length?f(e,i,"f").delete(this):f(e,i,"f").set(this,s)}}}},c=function(){EventTarget.prototype.addEventListener=f(this,r,"f"),EventTarget.prototype.removeEventListener=f(this,a,"f")},p.instance=null}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var s=t[o]={exports:{}};return e[o].call(s.exports,s,s.exports,n),s.exports}(235)})()));
|