@memlab/lens 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/dist/config/config.d.ts +22 -0
  3. package/dist/core/dom-observer.d.ts +10 -0
  4. package/dist/core/event-listener-tracker.d.ts +33 -0
  5. package/dist/core/react-fiber-analysis.d.ts +4 -0
  6. package/dist/core/react-memory-scan.d.ts +36 -0
  7. package/{src/core/types.ts → dist/core/types.d.ts} +56 -80
  8. package/{src/index.ts → dist/core/valid-component-name.d.ts} +2 -7
  9. package/dist/extensions/basic-extension.d.ts +30 -0
  10. package/dist/extensions/dom-visualization-extension.d.ts +17 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/memlens.lib.bundle.js +1695 -0
  13. package/dist/memlens.lib.bundle.min.js +1 -0
  14. package/dist/memlens.lib.d.ts +12 -0
  15. package/dist/memlens.run.bundle.js +2673 -0
  16. package/dist/memlens.run.bundle.min.js +1 -0
  17. package/dist/memlens.run.d.ts +1 -0
  18. package/dist/tests/bundle/lib.bundle.test.d.ts +1 -0
  19. package/dist/tests/bundle/run.bundle.start.head.test.d.ts +1 -0
  20. package/dist/tests/bundle/run.bundle.start.test.d.ts +1 -0
  21. package/dist/tests/bundle/run.bundle.test.d.ts +1 -0
  22. package/dist/tests/fiber/dev.fiber.complex.dev.test.d.ts +1 -0
  23. package/dist/tests/fiber/dev.fiber.complex.list.dev.test.d.ts +1 -0
  24. package/dist/tests/fiber/dev.fiber.complex.prod.test.d.ts +1 -0
  25. package/dist/tests/fiber/dev.fiber.name.dev.test.d.ts +1 -0
  26. package/dist/tests/fiber/dev.fiber.name.prod.test.d.ts +1 -0
  27. package/dist/tests/utils/test-utils.d.ts +11 -0
  28. package/dist/utils/intersection-observer.d.ts +18 -0
  29. package/dist/utils/react-fiber-utils.d.ts +56 -0
  30. package/dist/utils/utils.d.ts +26 -0
  31. package/dist/utils/weak-ref-utils.d.ts +67 -0
  32. package/dist/visual/components/component-stack-panel.d.ts +11 -0
  33. package/dist/visual/components/control-widget.d.ts +13 -0
  34. package/dist/visual/components/overlay-rectangle.d.ts +11 -0
  35. package/dist/visual/components/status-text.d.ts +2 -0
  36. package/dist/visual/components/toggle-button.d.ts +3 -0
  37. package/dist/visual/components/visual-overlay.d.ts +1 -0
  38. package/dist/visual/dom-element-visualizer-interactive.d.ts +26 -0
  39. package/{src/core/valid-component-name.ts → dist/visual/dom-element-visualizer.d.ts} +5 -7
  40. package/dist/visual/visual-utils.d.ts +16 -0
  41. package/package.json +5 -1
  42. package/explainer.md +0 -54
  43. package/playwright.config.ts +0 -21
  44. package/src/config/config.ts +0 -32
  45. package/src/core/dom-observer.ts +0 -189
  46. package/src/core/event-listener-tracker.ts +0 -171
  47. package/src/core/react-fiber-analysis.ts +0 -123
  48. package/src/core/react-memory-scan.ts +0 -366
  49. package/src/extensions/basic-extension.ts +0 -41
  50. package/src/extensions/dom-visualization-extension.ts +0 -42
  51. package/src/memlens.lib.js.flow +0 -75
  52. package/src/memlens.lib.ts +0 -22
  53. package/src/memlens.run.ts +0 -21
  54. package/src/tests/bundle/lib.bundle.test.ts +0 -31
  55. package/src/tests/bundle/run.bundle.start.head.test.ts +0 -48
  56. package/src/tests/bundle/run.bundle.start.test.ts +0 -48
  57. package/src/tests/bundle/run.bundle.test.ts +0 -51
  58. package/src/tests/fiber/dev.fiber.complex.dev.test.ts +0 -92
  59. package/src/tests/fiber/dev.fiber.complex.list.dev.test.ts +0 -118
  60. package/src/tests/fiber/dev.fiber.complex.prod.test.ts +0 -92
  61. package/src/tests/fiber/dev.fiber.name.dev.test.ts +0 -77
  62. package/src/tests/fiber/dev.fiber.name.prod.test.ts +0 -79
  63. package/src/tests/lib/babel.prod.js +0 -4
  64. package/src/tests/lib/react-dom-v18.dev.js +0 -29926
  65. package/src/tests/lib/react-dom-v18.prod.js +0 -269
  66. package/src/tests/lib/react-v18.dev.js +0 -3345
  67. package/src/tests/lib/react-v18.prod.js +0 -33
  68. package/src/tests/manual/playwright-open-manual.js +0 -40
  69. package/src/tests/manual/todo-list/todo-with-run.bundle.html +0 -80
  70. package/src/tests/utils/test-utils.ts +0 -28
  71. package/src/utils/intersection-observer.ts +0 -65
  72. package/src/utils/react-fiber-utils.ts +0 -212
  73. package/src/utils/utils.ts +0 -201
  74. package/src/utils/weak-ref-utils.ts +0 -308
  75. package/src/visual/components/component-stack-panel.ts +0 -85
  76. package/src/visual/components/control-widget.ts +0 -96
  77. package/src/visual/components/overlay-rectangle.ts +0 -167
  78. package/src/visual/components/status-text.ts +0 -53
  79. package/src/visual/components/toggle-button.ts +0 -57
  80. package/src/visual/components/visual-overlay.ts +0 -19
  81. package/src/visual/dom-element-visualizer-interactive.ts +0 -358
  82. package/src/visual/dom-element-visualizer.ts +0 -130
  83. package/src/visual/visual-utils.ts +0 -89
  84. package/tsconfig.json +0 -18
  85. package/webpack.config.js +0 -105
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={23:function(e,t,n){var i,o=this&&this.__classPrivateFieldSet||function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n},s=this&&this.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DOMVisualizationExtension=void 0,r(n(150));const l=r(n(271)),a=n(860);class c extends a.BasicExtension{constructor(e){super(e),i.set(this,void 0),o(this,i,new l.default,"f")}afterScan(e){const t=this.scanner;if(t.isDevMode()){const e=t.getDetachedDOMInfo();s(this,i,"f").repaint(e)}}}t.DOMVisualizationExtension=c,i=new WeakMap},54:function(e,t,n){var i,o,s,r,l,a,c,u,d,f,h,p,v=this&&this.__classPrivateFieldSet||function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n},m=this&&this.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.DOMObserver=void 0;const y=n(313),g=n(498),w=(0,y.isWeakAPINative)(),b=void 0!==window.MutationObserver;t.DOMObserver=class{constructor(){i.add(this),o.set(this,void 0),s.set(this,void 0),r.set(this,void 0),l.set(this,void 0),a.set(this,void 0),c.set(this,void 0),u.set(this,void 0),v(this,o,0,"f"),v(this,s,0,"f"),v(this,l,[],"f"),v(this,a,new WeakSet,"f"),v(this,u,[],"f"),this.startMonitoring()}register(e){m(this,u,"f").push(e)}startMonitoring(){if(!w||!b)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,g.isVisualizerElement)(n)){const e=m(this,i,"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,i,"m",d).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,l,"f")]}getStats(){try{v(this,o,m(this,i,"m",f).call(this),"f"),v(this,s,m(this,i,"m",h).call(this),"f")}catch(e){}return{elements:m(this,o,"f"),detachedElements:m(this,s,"f")}}},o=new WeakMap,s=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap,i=new WeakSet,d=function(){const e=[],t=new Set;for(const n of m(this,l,"f")){const i=n.deref();null==i||t.has(i)||(e.push(n),t.add(i))}v(this,l,e,"f")},f=function(){var e,t;return v(this,o,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,l,"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,i=[];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 o=e;if((0,g.isVisualizerElement)(o))continue;if(n.add(o),!m(this,a,"f").has(o)){const e=new WeakRef(o);m(this,l,"f").push(e),m(this,a,"f").add(o),i.push(e)}const s=o.childNodes;for(let e=0;e<s.length;++e)t.push(s[e])}return i}},150:function(e,t,n){var i,o,s,r,l,a,c,u,d=this&&this.__classPrivateFieldSet||function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n},f=this&&this.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0});const h=n(498);o=new WeakMap,i=new WeakSet,s=function(e){if(!f(this,o,"f")){const e=f(this,i,"m",l).call(this);d(this,o,e,"f")}f(this,i,"m",c).call(this,e)},r=function(e){document.body&&document.body.appendChild(e)},l=function(){const e=(0,h.createVisualizerElement)("canvas");return e.id="overlayCanvas",f(this,i,"m",r).call(this,e),e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="none",e.style.zIndex="99999",e.width=window.innerWidth,e.height=window.innerHeight,e},a=function(e){const{boundingRect:t}=e;return JSON.stringify({boundingRect:t})},c=function(e){const t=f(this,o,"f");if(!t)return;const n=t.getContext("2d");if(null==n)return;n.strokeStyle="rgba(75, 192, 192, 0.8)",n.lineWidth=2,n.fillStyle="rgba(75, 192, 192, 0.05)",n.font="11px Inter, system-ui, -apple-system, sans-serif";const s=new Set;e.forEach((e=>{var t;const o=e.boundingRect;if(null==o)return;const r=f(this,i,"m",a).call(this,e);if(s.has(r))return;s.add(r),n.fillRect(o.left,o.top,o.width,o.height),n.strokeRect(o.left,o.top,o.width,o.height);const l=null===(t=e.componentStack)||void 0===t?void 0:t[0];if(l){const t=e.element.deref(),i=null==t?void 0:t.detachedElementId,s=`${l}${i?` (${i})`:""}`;n.fillStyle="rgba(74, 131, 224, 1)",n.fillText(s,o.left+5,o.top+15),n.fillStyle="rgba(75, 192, 192, 0.05)"}}))},u=function(){var e;const t=f(this,o,"f");if(t){const n=t.getContext("2d");null==n||n.clearRect(0,0,t.width,t.height),null===(e=t.parentNode)||void 0===e||e.removeChild(t)}d(this,o,null,"f")},t.default=class{constructor(){i.add(this),o.set(this,void 0),d(this,o,null,"f")}repaint(e){f(this,i,"m",u).call(this),f(this,i,"m",s).call(this,e)}}},271:function(e,t,n){var i,o,s,r,l,a,c,u,d,f,h,p,v,m,y,g,w,b,M=this&&this.__classPrivateFieldSet||function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n},E=this&&this.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},k=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const _=k(n(150)),C=n(368),O=n(341),S=n(701),T=n(476),x=n(498);class W extends _.default{constructor(){super(),i.add(this),o.set(this,void 0),s.set(this,void 0),r.set(this,void 0),l.set(this,void 0),a.set(this,void 0),c.set(this,void 0),u.set(this,[]),M(this,c,{value:!1},"f"),M(this,s,(0,C.createOverlayDiv)(),"f"),(0,x.tryToAttachOverlay)(E(this,s,"f")),M(this,r,(0,O.createControlWidget)(E(this,s,"f"),E(this,c,"f"),(e=>{E(this,u,"f").push(e)})),"f"),(0,x.tryToAttachOverlay)(E(this,r,"f")),M(this,o,new Map,"f"),M(this,a,E(this,i,"m",f).call(this),"f"),M(this,l,new Set,"f"),E(this,i,"m",d).call(this)}repaint(e){E(this,s,"f").remove(),E(this,i,"m",y).call(this,e),E(this,i,"m",w).call(this,e),E(this,i,"m",b).call(this),(0,x.tryToAttachOverlay)(E(this,s,"f"))}}o=new WeakMap,s=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap,i=new WeakSet,d=function(){document.addEventListener("keydown",(e=>{"d"!==e.key&&"D"!==e.key||null!=E(this,a,"f").selectedElementId&&E(this,l,"f").add(E(this,a,"f").selectedElementId)}))},f=function(){const e={detachedDOMElementsCount:0,totalDOMElementsCount:(0,T.getDOMElementCount)(),selectedElementId:null,selectedReactComponentStack:[],pinnedElementId:null,setPinnedElementId:t=>{var n,o;if(e.pinnedElementId==t)return;const s=E(this,i,"m",h).call(this,e.pinnedElementId);null===(n=null==s?void 0:s.__unpinned)||void 0===n||n.call(s);const r=E(this,i,"m",h).call(this,t);null===(o=null==r?void 0:r.__pinned)||void 0===o||o.call(r),e.pinnedElementId=t}};return e},h=function(e){if(null==e)return null;const t=E(this,o,"f").get(e);return null==t?null:t.visualizerElementRef.deref()},p=function(e){const t=new Set;for(const n of e){const e=n.element.deref();if(null==e)continue;const i=e.detachedElementId;null!=i&&t.add(i)}return t},v=function(e,t){const n=E(this,o,"f").get(e);if(null==n)return;const i=new Set;let s=n.elementInfo.element.deref();for(;s&&!s.isConnected;){const e=s.detachedElementId,n=parseInt(e,10);if(i.has(n))break;i.add(n);const r=E(this,o,"f").get(n);if(null==r)break;const l=r.visualizerElementRef.deref();if(null==l)break;t(l),s=s.parentElement}},m=function(e){var t;const n=E(this,o,"f").get(e);if(E(this,o,"f").delete(e),null==n)return;const i=n.visualizerElementRef.deref();null!=i&&(null===(t=null==i?void 0:i.__cleanup)||void 0===t||t.call(i),i.remove())},y=function(e){for(const[e,t]of E(this,o,"f").entries())null!=e&&null==t.elementInfo.element.deref()&&E(this,i,"m",m).call(this,e);const t=E(this,i,"m",p).call(this,e);for(const[e]of E(this,o,"f").entries())null!=e&&(t.has(e)&&!E(this,l,"f").has(e)||E(this,i,"m",m).call(this,e))},g=function(e){var t;const n=e.element.deref();if(null==n)return 0;const i=n.detachedElementId;if(null==i)return 0;const o=null!==(t=e.boundingRect)&&void 0!==t?t:{width:50,height:50};let s=9999;return s+=parseInt(i,10),s+=Math.floor(1e7/(o.width*o.height)),s},w=function(e){for(const t of e){const e=t.element.deref();if(null==e)continue;const n=e.detachedElementId;if(null==n)continue;if(E(this,l,"f").has(n))continue;if(E(this,o,"f").has(n))continue;if(null==e)continue;if(e.isConnected)continue;const r=E(this,i,"m",g).call(this,t),c=(0,S.createOverlayRectangle)(n,t,E(this,s,"f"),(e=>{E(this,a,"f").selectedElementId=e,E(this,i,"m",b).call(this),null!=e&&E(this,i,"m",v).call(this,e,(e=>{var t;null===(t=null==e?void 0:e.__selected)||void 0===t||t.call(e)}))}),(e=>{E(this,a,"f").selectedElementId===e&&(E(this,a,"f").selectedElementId=null,E(this,i,"m",b).call(this)),null!=e&&E(this,i,"m",v).call(this,e,(e=>{var t;null===(t=null==e?void 0:e.__unselected)||void 0===t||t.call(e)}))}),(e=>{E(this,a,"f").pinnedElementId===e?E(this,a,"f").setPinnedElementId(null):E(this,a,"f").setPinnedElementId(e),E(this,i,"m",b).call(this)}),r);if(null==c||null==c.deref())return null;const u={elementInfo:t,visualizerElementRef:c};E(this,o,"f").set(n,u)}},b=function(){var e,t,n;const i=E(this,a,"f");null!=i.pinnedElementId&&(i.selectedElementId=i.pinnedElementId),i.detachedDOMElementsCount=E(this,o,"f").size,i.totalDOMElementsCount=(0,T.getDOMElementCount)();const s=null===(t=E(this,o,"f").get(null!==(e=i.selectedElementId)&&void 0!==e?e:-1))||void 0===t?void 0:t.elementInfo;i.selectedReactComponentStack=null!==(n=null==s?void 0:s.componentStack)&&void 0!==n?n:[];for(const e of E(this,u,"f"))e(Object.assign({},E(this,a,"f")))},t.default=W},282:function(e,t,n){var i,o,s,r,l,a,c,u,d,f,h,p,v,m,y,g,w,b,M,E,k,_,C,O,S=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=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}),x=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),o=0;o<n.length;o++)"default"!==n[o]&&S(t,e,n[o]);return T(t,e),t}),W=this&&this.__classPrivateFieldSet||function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n},I=this&&this.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},R=this&&this.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const N=x(n(476)),F=P(n(302)),D=n(737),j=n(54),L=n(346),z=n(953);class H{constructor(e={}){var t,n,i,g;o.add(this),s.set(this,void 0),r.set(this,void 0),l.set(this,void 0),a.set(this,void 0),c.set(this,void 0),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),h.set(this,void 0),p.set(this,void 0),v.set(this,void 0),m.set(this,void 0),y.set(this,void 0),W(this,s,[],"f"),W(this,r,!1,"f"),W(this,a,new WeakMap,"f"),W(this,c,new WeakMap,"f"),W(this,u,[],"f"),W(this,y,e.trackEventListenerLeaks?z.EventListenerTracker.getInstance():null,"f"),W(this,d,new F.default,"f"),W(this,l,0,"f"),W(this,f,null!==(t=e.isDevMode)&&void 0!==t&&t,"f"),W(this,h,null!==(n=e.subscribers)&&void 0!==n?n:[],"f"),W(this,p,null!==(i=e.extensions)&&void 0!==i?i:[],"f"),W(this,v,null!==(g=e.scanIntervalMs)&&void 0!==g?g:L.config.performance.scanIntervalMs,"f")}subscribe(e){return I(this,h,"f").push(e),()=>this.unsubscribe(e)}unsubscribe(e){W(this,h,I(this,h,"f").filter((t=>t!==e)),"f")}registerExtension(e){return I(this,p,"f").push(e),()=>this.unregisterExtension(e)}unregisterExtension(e){W(this,p,I(this,p,"f").filter((t=>t!==e)),"f")}start(){W(this,r,!0,"f"),W(this,l,setInterval(I(this,o,"m",E).bind(this),I(this,v,"f")),"f"),L.config.features.enableMutationObserver&&(null==I(this,m,"f")&&W(this,m,new j.DOMObserver,"f"),I(this,m,"f").startMonitoring()),console.log("[Memory] Tracking React and DOM memory...")}pause(){W(this,r,!1,"f")}stop(){var e;W(this,r,!1,"f"),clearInterval(I(this,l,"f")),W(this,s,[],"f"),null===(e=I(this,m,"f"))||void 0===e||e.stopMonitoring()}recordBoundingRectangles(e){for(const t of e){const e=t.deref();if(null==e||I(this,a,"f").has(e))continue;const n=N.getBoundingClientRect(e);null!=n&&I(this,a,"f").set(e,n)}}getDetachedDOMInfo(){var e;const t=[];for(const n of I(this,s,"f")){const i=n.deref();if(null==i||i.isConnected)continue;const o=i;if(null==o.detachedElementId){const e=H.nextElementId++;o.detachedElementIdStr=`memory-id-${e}@`,o.detachedElementId=e}const s=null!==(e=I(this,c,"f").get(i))&&void 0!==e?e:[];t.push({element:n,boundingRect:I(this,a,"f").get(i),componentStack:s})}return t}isDevMode(){return I(this,f,"f")}getCachedComponentName(e){var t;const n="<Unknown>",i=e.deref();if(null==i)return n;const o=I(this,c,"f").get(i);return null==o?n:null!==(t=o[0])&&void 0!==t?t:n}updateFiberNodes(e){const t=new WeakSet;for(const e of I(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 i=[],s=[];for(const e of I(this,u,"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 W(this,u,s,"f"),I(this,o,"m",g).call(this,"known fibers: ",I(this,u,"f").length),I(this,o,"m",g).call(this,"leaked fibers: ",i.length),i}packLeakedFibers(e){const t=[];for(const n of e)t.push(new B(n));return t}scan(){const e=Date.now();I(this,o,"m",C).call(this);const t=I(this,s,"f"),n=I(this,o,"m",_).call(this);I(this,o,"m",k).call(this,n),this.recordBoundingRectangles(n),N.updateWeakRefList(t,n);const i=I(this,d,"f").scan(t,I(this,c,"f")),r=this.updateFiberNodes(i.fiberNodes);i.leakedFibers=r,i.eventListenerLeaks=I(this,o,"m",O).call(this),window.leakedFibers=this.packLeakedFibers(r);const l=Date.now();return I(this,o,"m",g).call(this,`scan took ${l-e}ms`),i}}s=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakMap,h=new WeakMap,p=new WeakMap,v=new WeakMap,m=new WeakMap,y=new WeakMap,o=new WeakSet,g=function(...e){I(this,f,"f")&&L.config.features.enableConsoleLogs&&N.consoleLog(...e)},w=function(e){for(const t of I(this,h,"f"))t(e);const t=e.end-e.start;I(this,o,"m",g).call(this,"duration: ",`${t} ms`);const{scanner:n,leakedFibers:i,fiberNodes:s}=e,r=R(e,["scanner","leakedFibers","fiberNodes"]);I(this,o,"m",g).call(this,r)},b=function(){for(const e of I(this,p,"f"))null==e||e.beforeScan()},M=function(e){for(const t of I(this,p,"f"))null==t||t.afterScan(e)},E=function(){if(!I(this,r,"f"))return;I(this,o,"m",b).call(this);const e=performance.now(),t=this.scan(),n=performance.now(),i=Object.assign(Object.assign({},t),{start:e,end:n,scanner:this});I(this,o,"m",w).call(this,i),I(this,o,"m",M).call(this,i)},k=function(e){for(const t of e){const e=t.deref();if(null==e||I(this,c,"f").has(e))continue;const n=(0,D.getFiberNodeFromElement)(e);null!=n&&I(this,c,"f").set(e,(0,D.getReactComponentStack)(n))}},_=function(){return null==I(this,m,"f")?N.getDOMElements():[...N.getDOMElements(),...I(this,m,"f").getDOMElements()]},C=function(){null!=(null===window||void 0===window?void 0:window.gc)&&window.gc()},O=function(){var e;if(null==I(this,y,"f"))return[];const t=I(this,y,"f").scan(this.getCachedComponentName.bind(this)),n=[];for(const[i,o]of t.entries()){const t=new Map;for(const n of o){const i=null!==(e=t.get(n.type))&&void 0!==e?e:0;t.set(n.type,i+1)}for(const[e,o]of t.entries())n.push({type:e,componentName:i,count:o})}return n},H.nextElementId=0,t.default=H;class B{constructor(e){this.leakedFiber=e}}},302:function(e,t,n){var i,o=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=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||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),r=0;r<n.length;r++)"default"!==n[r]&&o(t,e,n[r]);return s(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const l=r(n(476)),a=n(737),c=n(847);t.default=class{scan(e,t){var n;const i=new Set,o=new Set,s=new Map,r=new Map,u=new Set,d=new Set,f=[];let h=0,p=0;function v(e){(0,a.traverseFiber)(e,(e=>{if(d.has(e))return!0;d.add(e);const t=(0,a.getDisplayNameOfFiberNode)(e);return null!=t&&(0,c.isValidComponentName)(t)?(o.add(t),l.addCountbyKey(s,t,1),!0):void 0}),!0)}for(const o of e){const e=o.deref();if(null==e)continue;if(++h,!e.isConnected){if(t.has(e)){const i=(null!==(n=t.get(e))&&void 0!==n?n:[])[0];e.__component_name=i,l.addCountbyKey(r,i,1)}++p}const s=(0,a.getFiberNodeFromElement)(e);if(null==s)continue;v(s);const c=(0,a.getTopMostFiberWithChild)(s);null!=c&&(i.has(c)||(i.add(c),(0,a.traverseFiber)(c,(e=>{if(u.has(e))return!0;u.add(e),f.push(new WeakRef(e)),v(e)}),!1)))}return u.clear(),d.clear(),i.clear(),{components:o,componentToFiberNodeCount:s,totalElements:h,totalDetachedElements:p,detachedComponentToFiberNodeCount:r,fiberNodes:f,leakedFibers:[]}}}},313:(e,t)=>{var n,i,o;Object.defineProperty(t,"__esModule",{value:!0}),t.WeakMapPlus=t.WeakMapNoOp=t.WeakSetNoOp=t.WeakRefNoOp=void 0,t.getNativeWeakMap=function(){return l?r:null},t.getNativeWeakMapOrFallback=function(){return l&&r?r:v},t.getNativeWeakSet=function(){return c?a:null},t.getNativeWeakSetOrFallback=function(){return c&&a?a:p},t.getNativeWeakRef=function(){return d?u:null},t.getNativeWeakRefOrFallback=function(){return d&&u?u:h},t.isWeakMapNative=y,t.isWeakSetNative=g,t.isWeakRefNative=w,t.isWeakAPINative=function(){return f};const s="undefined"!=typeof window?window:self,r=null!==(n=s.WeakMap)&&void 0!==n?n:null,l=y(),a=null!==(i=s.WeakSet)&&void 0!==i?i:null,c=g(),u=null!==(o=s.WeakRef)&&void 0!==o?o:null,d=w(),f=l&&c&&d;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 y(){return null!==r&&"function"==typeof r.toString&&"function WeakMap() { [native code] }"===m(r.toString())}function g(){return null!==a&&"function"==typeof a.toString&&"function WeakSet() { [native code] }"===m(a.toString())}function w(){return null!==u&&"function"==typeof u.toString&&"function WeakRef() { [native code] }"===m(u.toString())}t.WeakMapNoOp=v;class b{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=f,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 i=this.getOrCreateId(e);return this.entriesMap.set(i,{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 i=this.keyToId.get(e);if(!i)return;const o=this.entriesMap.get(i);return(null===(n=null==o?void 0:o.ref)||void 0===n?void 0:n.deref())?null==o?void 0:o.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 i=this.keyToId.get(e);if(!i)return!1;const o=this.entriesMap.get(i);return!(!o||!o.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 i=this.keyToId.get(e);return!!i&&(this.keyToId.delete(e),this.entriesMap.delete(i))}*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=b},341:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createControlWidget=function(e,t,n){const l=(0,i.createVisualizerElement)("div");l.style.position="fixed",l.style.top="50px",l.style.right="50px",l.style.width="400px",l.style.background="rgba(0, 0, 0, 0.7)",l.style.border="none",l.style.borderRadius="8px",l.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.3)",l.style.zIndex="999999999",l.style.display="flex",l.style.flexDirection="column",l.style.textShadow="none",l.style.boxSizing="border-box",l.style.font="9px Inter, system-ui, -apple-system, sans-serif",l.id="memory-visualization-control-widget";const a=(0,i.createVisualizerElement)("div");a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="flex-start",a.style.padding="0 8px",a.style.height="36px",l.appendChild(a);const c=(0,r.createComponentStackPanel)(n);l.appendChild(c),function(e){let t=!1,n=0,i=0;e.addEventListener("mousedown",(o=>{o.target.closest("#memory-visualization-control-widget > div:first-child")&&(t=!0,n=o.clientX-e.offsetLeft,i=o.clientY-e.offsetTop,e.style.cursor="move")})),document.addEventListener("mousemove",(o=>{t&&(e.style.left=o.clientX-n+"px",e.style.top=o.clientY-i+"px",e.style.right="")})),document.addEventListener("mouseup",(()=>{t=!1,e.style.cursor="default"}))}(l);const u=(0,s.createToggleButton)(e,t);a.appendChild(u);const d=(0,o.createStatusText)(n);return a.appendChild(d),l};const i=n(498),o=n(775),s=n(946),r=n(904)},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}},368:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createOverlayDiv=function(){const e=(0,i.createVisualizerElement)("div");return e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.id="memory-visualization-overlay",e};const i=n(498)},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,i.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,i.isVisualizerElement)(n)||++t;return t},t.getMeaningfulName=function(e){return null==e||o(e)?null:e},t.isMinifiedName=o,t.addCountbyKey=function(e,t,n){var i;e.set(t,(null!==(i=e.get(t))&&void 0!==i?i: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 i of t){const t=i.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,i=window.scrollX,o={};return o.bottom=t.bottom,o.height=t.height,o.left=t.left,o.right=t.right,o.top=t.top,o.width=t.width,o.x=t.x,o.y=t.y,o.scrollLeft=i,o.scrollTop=n,o},t.consoleLog=function(...e){r.apply(s,e)},t.hasRunInSession=function(){if(!a())return!1;try{return"true"===sessionStorage.getItem(l)}catch(e){return!1}},t.setRunInSession=function(){if(a())try{sessionStorage.setItem(l,"true")}catch(e){}};const i=n(498);function o(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,l="memory_lens_session";function a(){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,o){var s;const r=e.deref();r&&(r.addEventListener(t,n,o),i.has(r)||i.set(r,[]),null===(s=i.get(r))||void 0===s||s.push({type:t,cb:n,options:o}))},t.removeAllListeners=function(e){const t=e.deref();if(!t)return;const n=i.get(t);if(n){for(const{type:e,cb:i,options:o}of n)t.removeEventListener(e,i,o);i.delete(t)}},t.debounce=function(e,t){let n=null;return(...i)=>{n&&clearTimeout(n),n=setTimeout((()=>{e(...i)}),t)}};const n="data-visualizer",i=new WeakMap},701:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createOverlayRectangle=function(e,t,n,i,s,c,u){var d,f;const h=t.boundingRect;if(!h)return null;const p=(0,o.createVisualizerElement)("div");p.style.position="absolute",p.style.width=`${h.width}px`,p.style.height=`${h.height}px`,p.style.top=`${h.top+h.scrollTop}px`,p.style.left=`${h.left+h.scrollLeft}px`,p.style.border="1px dotted rgba(75, 192, 192, 0.8)",p.style.borderRadius="1px",p.style.zIndex=u.toString();const v=null!==(f=(null!==(d=t.componentStack)&&void 0!==d?d:[])[0])&&void 0!==f?f:"";let m=!1,y=!1;const g=new WeakRef(p);return(0,o.addTrackedListener)(g,"mouseover",(()=>{var t;const n=`memory-id-${e}@`;l.remove(),null===(t=g.deref())||void 0===t||t.appendChild(l),l.textContent=`${v} (${n})`,l.style.display="inline-block",i(e)})),(0,o.addTrackedListener)(g,"mouseout",(()=>{l.style.display="none",l.remove(),s(e)})),(0,o.addTrackedListener)(g,"click",(()=>{c(e)})),p.__selected=()=>{y=!0,a(g,{selected:y,pinned:m})},p.__unselected=()=>{y=!1,a(g,{selected:y,pinned:m})},p.__pinned=()=>{m=!0,a(g,{selected:y,pinned:m})},p.__unpinned=()=>{m=!1,a(g,{selected:y,pinned:m})},r.observe(g,(e=>{e.isIntersecting?p.style.visibility="visible":p.style.visibility="hidden"})),p.__cleanup=()=>{const e=g.deref();null!=e&&((0,o.removeAllListeners)(g),r.unobserve(g),e.__cleanup=null,e.__selected=null,e.__unselected=null,e.__pinned=null,e.__unpinned=null)},n.appendChild(p),g};const i=n(979),o=n(498),s=""+(Math.pow(2,30)-1),r=i.IntersectionObserverManager.getInstance(),l=function(){const e=(0,o.createVisualizerElement)("div");return e.style.color="white",e.style.background="rgba(75, 192, 192, 0.8)",e.style.textShadow="none",e.style.font="9px Inter, system-ui, -apple-system, sans-serif",e.style.padding="2px 6px",e.style.borderRadius="2px",e.style.whiteSpace="nowrap",e.style.position="absolute",e.style.bottom="100%",e.style.left="0",e.style.marginBottom="2px",e.style.display="none",e.style.zIndex=s,e}();function a(e,t){const n=e.deref();if(null==n)return;const{pinned:i,selected:o}=t;i?(n.style.border="1px solid rgba(255, 215, 0, 0.9)",n.style.background="rgba(255, 215, 0, 0.08)"):o?(n.style.border="1px solid rgba(75, 192, 192, 0.8)",n.style.background="rgba(75, 192, 192, 0.02)"):(n.style.border="1px dotted rgba(75, 192, 192, 0.8)",n.style.background="")}},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 i=e;for(;i&&!n.has(i);){n.add(i);const e=l(i);e&&t.push(e),i=i.return}return t},t.getDisplayNameOfFiberNode=l,t.isFunctionalComponent=function(e){return"function"==typeof(null==e?void 0:e.elementType)},t.extractReactComponentName=a;const i=n(476),o=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,i=!1)=>{if(!e)return null;if(!0===n(e))return e;let o=i?e.return:e.child;for(;o;){const e=(0,t.traverseFiber)(o,n,i);if(e)return e;o=i?null:o.sibling}return null};const s=["__reactFiber$","__reactInternalInstance$","_reactRootContainer"],r=Object.getOwnPropertyNames.bind(Object);function l(e){var t,n,s,r;const l=null!==(t=e.type)&&void 0!==t?t:e.elementType;let c=null!==(n=null==l?void 0:l.displayName)&&void 0!==n?n:null==l?void 0:l.name;if(null==c)if(null==l?void 0:l.render){const e=null==l?void 0:l.render;c=null!==(s=null==e?void 0:e.displayName)&&void 0!==s?s:null==e?void 0:e.name}else(null==l?void 0:l.type)&&(c=null!==(r=l.type.displayName)&&void 0!==r?r:l.type.name);c||"function"!=typeof l||(c=l.name);const u=(0,i.getMeaningfulName)(a(c));return(0,o.isValidComponentName)(u)?u:null}function a(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 i=e.substring(t+1,n);return i.startsWith("from ")?i.substring(5):i}},775:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createStatusText=function(e){const t=(0,i.createVisualizerElement)("div");return t.style.marginLeft="10px",t.style.color="white",t.style.fontSize="10px",t.style.fontFamily="Inter, system-ui, sans-serif",t.style.overflow="hidden",t.style.whiteSpace="nowrap",t.style.textOverflow="ellipsis",t.textContent="",e((e=>{var n,i,s,r;const l=window.performance,a=null==l?void 0:l.memory,c=null!==(n=null==a?void 0:a.usedJSHeapSize)&&void 0!==n?n:0,u=null!==(i=null==a?void 0:a.totalJSHeapSize)&&void 0!==i?i:0,d=null!==(s=e.totalDOMElementsCount)&&void 0!==s?s:0,f=null!==(r=e.detachedDOMElementsCount)&&void 0!==r?r:0;t.textContent=`DOM: ${d} total, ${f} detached | Heap: ${o(c)} / ${o(u)}`})),t};const i=n(498);function o(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}},847:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isValidComponentName=function(e){return null!=e&&!n.has(e)};const n=new Set},860:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BasicExtension=void 0,t.BasicExtension=class{constructor(e){this.scanner=e}beforeScan(){}afterScan(e){}}},904:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createComponentStackPanel=function(e){const t=(0,i.createVisualizerElement)("div");t.style.width="100%",t.style.maxHeight="80vh",t.style.background="rgba(0, 0, 0, 0.5)",t.style.borderTop="1px solid rgba(255, 255, 255, 0.1)",t.style.display="none",t.style.flexDirection="column",t.style.padding="8px",t.style.boxSizing="border-box",t.style.borderRadius="8px",t.style.overflowY="scroll",t.style.overflowX="hidden",t.style.textShadow="none",t.style.font="9px Inter, system-ui, -apple-system, sans-serif",t.style.color="white",t.id="memory-visualization-component-stack-panel";let n=!1;return t.addEventListener("mouseenter",(()=>{n=!0})),t.addEventListener("mouseleave",(()=>{n=!1})),e((0,i.debounce)((e=>{var o;if(n)return;if(t.style.display=null!=e.selectedElementId?"flex":"none",t.innerHTML="",null==e.selectedElementId||!(null===(o=e.selectedReactComponentStack)||void 0===o?void 0:o.length))return;const s=(0,i.createVisualizerElement)("div");s.textContent="Component Stack:",s.style.fontWeight="bold",s.style.marginBottom="8px",t.appendChild(s);let r=0;e.selectedReactComponentStack.forEach((e=>{const n=(0,i.createVisualizerElement)("div");n.style.marginBottom="4px",n.textContent=e,t.appendChild(n),++r})),0===r&&s.remove()}),1)),t};const i=n(498)},933:function(e,t,n){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(n(282)),s=n(23),r=n(476);if(!(0,r.hasRunInSession)()){const e=new o.default({isDevMode:!0}),t=new s.DOMVisualizationExtension(e);e.registerExtension(t),e.start(),(0,r.setRunInSession)()}},946:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createToggleButton=function(e,t){const n=(0,i.createVisualizerElement)("div");n.style.width="40px",n.style.height="24px",n.style.borderRadius="9999px",n.style.backgroundColor="#34C759",n.style.cursor="pointer",n.style.position="relative",n.style.transition="background-color 0.3s ease";const o=(0,i.createVisualizerElement)("div");return o.style.width="18px",o.style.height="18px",o.style.backgroundColor="white",o.style.borderRadius="50%",o.style.position="absolute",o.style.top="3px",o.style.left="3px",o.style.transition="left 0.25s ease",n.appendChild(o),n.addEventListener("click",(()=>{t.value=!t.value,t.value?(e.style.display="none",e.style.pointerEvents="none",e.style.userSelect="none",o.style.left="19px",n.style.backgroundColor="#FF3B30"):(e.style.display="block",e.style.pointerEvents="auto",e.style.userSelect="auto",o.style.left="3px",n.style.backgroundColor="#34C759")})),n};const i=n(498)},953:function(e,t,n){var i,o,s,r,l,a,c,u=this&&this.__classPrivateFieldSet||function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n},d=this&&this.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.EventListenerTracker=void 0;const f=n(737),h=n(313);class p{constructor(){i.add(this),o.set(this,void 0),s.set(this,void 0),r.set(this,void 0),l.set(this,void 0),u(this,o,new h.WeakMapPlus({fallback:"noop",cleanupMs:100}),"f"),u(this,s,new Map,"f"),u(this,r,EventTarget.prototype.addEventListener,"f"),u(this,l,EventTarget.prototype.removeEventListener,"f"),d(this,i,"m",a).call(this)}static getInstance(){return p.instance||(p.instance=new p),p.instance}addListener(e,t,n,i){e.addEventListener(t,n,i)}removeListener(e,t,n,i){e.removeEventListener(t,n,i)}scan(e){const t=new Map;for(const[n,i]of d(this,o,"f").entries())if(n instanceof Element&&!n.isConnected)for(const o of i){if(!o.cb.deref())continue;const i=e(new WeakRef(n));t.has(i)||t.set(i,[]);const s=t.get(i);let r=null==s?void 0:s.find((e=>e.type===o.type));r||(r={type:o.type,count:0,entries:[]},null==s||s.push(r)),r.count++,r.entries.push(new WeakRef(o))}return u(this,s,t,"f"),t}getDetachedListeners(){return d(this,s,"f")}destroy(){d(this,i,"m",c).call(this),d(this,o,"f").destroy(),d(this,s,"f").clear(),p.instance=null}}t.EventListenerTracker=p,o=new WeakMap,s=new WeakMap,r=new WeakMap,l=new WeakMap,i=new WeakSet,a=function(){const e=this;EventTarget.prototype.addEventListener=function(t,n,i){var s;if(d(e,r,"f").call(this,t,n,i),this instanceof Element){const r=(0,f.getFiberNodeFromElement)(this),l={type:t,cb:new WeakRef(n),options:i,fiber:r?new WeakRef(r):void 0},a=null!==(s=d(e,o,"f").get(this))&&void 0!==s?s:[];a.push(l),d(e,o,"f").set(this,a)}},EventTarget.prototype.removeEventListener=function(t,n,i){if(d(e,l,"f").call(this,t,n,i),this instanceof Element){const s=d(e,o,"f").get(this);if(s){const r=s.findIndex((e=>e.type===t&&e.cb.deref()===n&&e.options===i));-1!==r&&s.splice(r,1),0===s.length?d(e,o,"f").delete(this):d(e,o,"f").set(this,s)}}}},c=function(){EventTarget.prototype.addEventListener=d(this,r,"f"),EventTarget.prototype.removeEventListener=d(this,l,"f")},p.instance=null},979:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntersectionObserverManager=void 0;class n{constructor(){this.observedElements=new Map,this.observer=new IntersectionObserver((e=>{e.forEach((e=>{const t=e.target,n=this.observedElements.get(t);n&&n(e)}))}),{threshold:0,rootMargin:"50px"})}static getInstance(){return n.instance||(n.instance=new n),n.instance}observe(e,t){const n=e.deref();null!=n&&(this.observedElements.set(n,t),this.observer.observe(n))}unobserve(e){const t=e.deref();null!=t&&(this.observedElements.delete(t),this.observer.unobserve(t))}}t.IntersectionObserverManager=n}},t={};!function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(933)})();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export declare const distPath: string;
2
+ export declare const srcPath: string;
3
+ export declare function wait(timeoutInMs: number): Promise<void>;
4
+ export declare const libBundleFile = "memlens.lib.bundle.js";
5
+ export declare const libBundleFilePath: string;
6
+ export declare const libBundleMinFile = "memlens.lib.bundle.min.js";
7
+ export declare const libBundleMinFilePath: string;
8
+ export declare const runBundleFile = "memlens.run.bundle.js";
9
+ export declare const runBundleFilePath: string;
10
+ export declare const runBundleMinFile = "memlens.run.bundle.min.js";
11
+ export declare const runBundleMinFilePath: string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ export declare class IntersectionObserverManager {
11
+ private static instance;
12
+ private observer;
13
+ private observedElements;
14
+ private constructor();
15
+ static getInstance(): IntersectionObserverManager;
16
+ observe(elementRef: WeakRef<HTMLElement>, callback: (entry: IntersectionObserverEntry) => void): void;
17
+ unobserve(elementRef: WeakRef<HTMLElement>): void;
18
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import type { Fiber } from 'react-reconciler';
11
+ import type { Nullable, Optional } from '../core/types';
12
+ export declare const ClassComponentTag = 1;
13
+ export declare const FunctionComponentTag = 0;
14
+ export declare const ContextConsumerTag = 9;
15
+ export declare const SuspenseComponentTag = 13;
16
+ export declare const OffscreenComponentTag = 22;
17
+ export declare const ForwardRefTag = 11;
18
+ export declare const MemoComponentTag = 14;
19
+ export declare const SimpleMemoComponentTag = 15;
20
+ export declare const HostComponentTag = 5;
21
+ export declare const HostHoistableTag = 26;
22
+ export declare const HostSingletonTag = 27;
23
+ export declare const DehydratedSuspenseComponent = 18;
24
+ export declare const HostText = 6;
25
+ export declare const Fragment = 7;
26
+ export declare const LegacyHiddenComponent = 23;
27
+ export declare const OffscreenComponent = 22;
28
+ export declare const HostRoot = 3;
29
+ export declare const CONCURRENT_MODE_NUMBER = 60111;
30
+ export declare const CONCURRENT_MODE_SYMBOL_STRING = "Symbol(react.concurrent_mode)";
31
+ export declare const DEPRECATED_ASYNC_MODE_SYMBOL_STRING = "Symbol(react.async_mode)";
32
+ export declare const PerformedWork = 1;
33
+ export declare const Placement = 2;
34
+ export declare const DidCapture = 128;
35
+ export declare const Hydrating = 4096;
36
+ export declare const Update = 4;
37
+ export declare const Cloned = 8;
38
+ export declare const ChildDeletion = 16;
39
+ export declare const ContentReset = 32;
40
+ export declare const Ref = 512;
41
+ export declare const Snapshot = 1024;
42
+ export declare const Visibility = 8192;
43
+ export declare const MutationMask: number;
44
+ /**
45
+ * @see https://reactnative.dev/architecture/glossary#host-view-tree-and-host-view
46
+ */
47
+ export declare const isHostFiber: (fiber: Fiber) => boolean;
48
+ export declare const getNearestHostFiber: (fiber: Fiber) => Nullable<Fiber>;
49
+ export declare const getTopMostHostFiber: (fiber: Fiber) => Nullable<Fiber>;
50
+ export declare const getTopMostFiberWithChild: (fiber: Fiber) => Nullable<Fiber>;
51
+ export declare const traverseFiber: (fiber: Nullable<Fiber>, selector: (node: Fiber) => boolean | void, ascending?: boolean) => Nullable<Fiber>;
52
+ export declare function getFiberNodeFromElement(element: Element): any;
53
+ export declare function getReactComponentStack(node: Fiber): Array<string>;
54
+ export declare function getDisplayNameOfFiberNode(node: Fiber): string | null;
55
+ export declare function isFunctionalComponent(node: Fiber): boolean;
56
+ export declare function extractReactComponentName(displayName: Optional<string>): Nullable<string>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import type { BoundingRect, Nullable, AnyValue, ObjectValue } from '../core/types';
11
+ export declare function getDOMElements(): Array<WeakRef<Element>>;
12
+ export declare function getDOMElementCount(): number;
13
+ export declare function getMeaningfulName(name: Nullable<string>): string | null;
14
+ /**
15
+ * Determines if a given function or class name is minified.
16
+ *
17
+ * @param {string} name - The function or class name to check.
18
+ * @return {boolean} - Returns true if the name is likely minified, otherwise false.
19
+ */
20
+ export declare function isMinifiedName(name: string): boolean;
21
+ export declare function addCountbyKey<K extends ObjectValue>(map: WeakMap<K, number>, key: K, count: number): void;
22
+ export declare function updateWeakRefList(weakRefList: Array<WeakRef<Element>>, elementRefs: Array<WeakRef<Element>>): WeakRef<Element>[];
23
+ export declare function getBoundingClientRect(element: Element): Nullable<BoundingRect>;
24
+ export declare function consoleLog(...args: AnyValue[]): void;
25
+ export declare function hasRunInSession(): boolean;
26
+ export declare function setRunInSession(): void;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import { FallbackMode, WeakMapPlusOptions } from '../core/types';
11
+ export declare class WeakRefNoOp<T extends object | ReadonlyArray<unknown>> {
12
+ constructor(_targetObject: T);
13
+ deref(): T | undefined;
14
+ }
15
+ export declare class WeakSetNoOp<T extends object | ReadonlyArray<unknown>> {
16
+ constructor(_iterable?: Iterable<T> | null);
17
+ add(_value: T): this;
18
+ delete(_value: T): boolean;
19
+ has(_value: T): boolean;
20
+ }
21
+ export declare class WeakMapNoOp<K extends object | ReadonlyArray<unknown>, V> {
22
+ constructor(_iterable?: Iterable<[K, V]> | null);
23
+ delete(_key: K): boolean;
24
+ get(_key: K): V | undefined;
25
+ has(_key: K): boolean;
26
+ set(_key: K, _value: V): this;
27
+ }
28
+ export type WeakMapOrNoOp<TK extends object, TV> = WeakMap<TK, TV> | WeakMapNoOp<TK, TV>;
29
+ export type WeakSetOrNoOp<T extends object> = WeakSet<T> | WeakSetNoOp<T>;
30
+ export type WeakRefOrNoOp<T extends object> = WeakRef<T> | WeakRefNoOp<T>;
31
+ export type WeakMapOrFallback = typeof WeakMap | typeof WeakMapNoOp;
32
+ export type WeakSetOrFallback = typeof WeakSet | typeof WeakSetNoOp;
33
+ export type WeakRefOrFallback = typeof WeakRef | typeof WeakRefNoOp;
34
+ export declare function getNativeWeakMap(): typeof WeakMap | null;
35
+ export declare function getNativeWeakMapOrFallback(): WeakMapOrFallback;
36
+ export declare function getNativeWeakSet(): typeof WeakSet | null;
37
+ export declare function getNativeWeakSetOrFallback(): WeakSetOrFallback;
38
+ export declare function getNativeWeakRef(): typeof WeakRef | null;
39
+ export declare function getNativeWeakRefOrFallback(): WeakRefOrFallback;
40
+ export declare function isWeakMapNative(): boolean;
41
+ export declare function isWeakSetNative(): boolean;
42
+ export declare function isWeakRefNative(): boolean;
43
+ export declare function isWeakAPINative(): boolean;
44
+ export declare class WeakMapPlus<K extends object, V> {
45
+ private isWeak;
46
+ private fallbackMode;
47
+ private strongMap;
48
+ private noopMap;
49
+ private entriesMap;
50
+ private keyToId;
51
+ private cleanupInterval;
52
+ constructor(options?: WeakMapPlusOptions);
53
+ private getOrCreateId;
54
+ set(key: K, value: V): this;
55
+ get(key: K): V | undefined;
56
+ has(key: K): boolean;
57
+ delete(key: K): boolean;
58
+ private liveEntries;
59
+ entries(): IterableIterator<[K, V]>;
60
+ keys(): IterableIterator<K>;
61
+ values(): IterableIterator<V>;
62
+ [Symbol.iterator](): IterableIterator<[K, V]>;
63
+ get size(): number;
64
+ getFallbackMode(): FallbackMode;
65
+ cleanup(): void;
66
+ destroy(): void;
67
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import { RegisterDataUpdateCallback } from '../dom-element-visualizer-interactive';
11
+ export declare function createComponentStackPanel(registerDataUpdateCallback: RegisterDataUpdateCallback): HTMLDivElement;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import { RegisterDataUpdateCallback } from '../dom-element-visualizer-interactive';
11
+ export declare function createControlWidget(overlayDiv: HTMLDivElement, hideAllRef: {
12
+ value: boolean;
13
+ }, registerDataUpdateCallback: RegisterDataUpdateCallback): HTMLDivElement;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import type { DOMElementInfo } from '../../core/types';
11
+ export declare function createOverlayRectangle(elementId: number, info: DOMElementInfo, container: HTMLDivElement, setSelectedId: (id: number | null) => void, setUnSelectedId: (id: number | null) => void, setClickedId: (id: number | null) => void, zIndex: number): WeakRef<Element> | null;
@@ -0,0 +1,2 @@
1
+ import { RegisterDataUpdateCallback } from '../dom-element-visualizer-interactive';
2
+ export declare function createStatusText(registerDataUpdateCallback: RegisterDataUpdateCallback): HTMLDivElement;
@@ -0,0 +1,3 @@
1
+ export declare function createToggleButton(overlayDiv: HTMLDivElement, hideAllRef: {
2
+ value: boolean;
3
+ }): HTMLDivElement;
@@ -0,0 +1 @@
1
+ export declare function createOverlayDiv(): HTMLDivElement;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import type { DOMElementInfo, Nullable } from '../core/types';
11
+ import DOMElementVisualizer from './dom-element-visualizer';
12
+ export type VisualizerData = {
13
+ detachedDOMElementsCount: number;
14
+ totalDOMElementsCount: number;
15
+ selectedElementId: Nullable<number>;
16
+ pinnedElementId: Nullable<number>;
17
+ selectedReactComponentStack: Array<string>;
18
+ setPinnedElementId: (elementId: Nullable<number>) => void;
19
+ };
20
+ export type DateUpdateCallback = (data: VisualizerData) => void;
21
+ export type RegisterDataUpdateCallback = (cb: DateUpdateCallback) => void;
22
+ export default class DOMElementVisualizerInteractive extends DOMElementVisualizer {
23
+ #private;
24
+ constructor();
25
+ repaint(domElementInfoList: Array<DOMElementInfo>): void;
26
+ }
@@ -7,11 +7,9 @@
7
7
  * @format
8
8
  * @oncall memory_lab
9
9
  */
10
-
11
- import {Optional} from './types';
12
-
13
- const displayNameBlockList = new Set();
14
-
15
- export function isValidComponentName(name: Optional<string>): boolean {
16
- return name != null && !displayNameBlockList.has(name);
10
+ import type { DOMElementInfo } from '../core/types';
11
+ export default class DOMElementVisualizer {
12
+ #private;
13
+ constructor();
14
+ repaint(domElementInfoList: Array<DOMElementInfo>): void;
17
15
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import type { AnyValue } from '../core/types';
11
+ export declare function isVisualizerElement(element: Element): boolean;
12
+ export declare function createVisualizerElement(tag: string): HTMLElement;
13
+ export declare function tryToAttachOverlay(overlayDiv: HTMLDivElement): void;
14
+ export declare function addTrackedListener(elRef: WeakRef<EventTarget>, type: string, cb: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
15
+ export declare function removeAllListeners(elRef: WeakRef<EventTarget>): void;
16
+ export declare function debounce<T extends (...args: AnyValue[]) => AnyValue>(callback: T, delay: number): (...args: Parameters<T>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/lens",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "description": "MemLens is a tool for inspecting memory leaks in browser",
6
6
  "author": "Liang Gong <lgong@meta.com>",
@@ -9,6 +9,10 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
+ "files": [
13
+ "dist",
14
+ "LICENSE"
15
+ ],
12
16
  "scripts": {
13
17
  "build": "webpack",
14
18
  "rebuild": "webpack",
package/explainer.md DELETED
@@ -1,54 +0,0 @@
1
-
2
-
3
- ### Purpose and Core Functionality
4
- This project is a specialized production memory diagnostic collection and local dev debugging tool designed to detect and visualize memory leaks in React applications, with a particular focus on identifying detached components that should have been garbage collected but remain in memory.
5
-
6
- ### How It Works
7
-
8
- #### Detection System
9
- The module operates through multiple layers of monitoring:
10
- * **DOM Scanning**: Continuously scans the Document Object Model to create a comprehensive map of all elements present in the application.
11
- * **React Fiber Analysis**: Specifically tracks React's internal fiber tree structure, which represents the component hierarchy and their relationships.
12
- * **Memory Leak Detection**: Identifies components that are no longer attached to the main DOM tree but still persist in memory, indicating potential memory leaks.
13
-
14
- #### Monitoring Process
15
- The system employs a dual-monitoring approach:
16
- * **Periodic Scanning**: Runs regular scans at configurable intervals to check for detached components.
17
- * **Real-time Observation**: Uses mutation observers to detect DOM changes as they happen, ensuring immediate detection of potential issues.
18
-
19
- #### Visualization System
20
- The visualization component provides real-time feedback through:
21
- * **Overlay Layer**: Creates a transparent canvas overlay that sits above the application.
22
- * **Visual Indicators**: Draws highlighting boxes around problematic components.
23
- * **Component Information**: Displays relevant information about detected issues, including component names and their locations.
24
-
25
- ### Key Features
26
-
27
- #### Memory Safety
28
- - Implements memory-safe tracking mechanisms using weak references
29
- - Avoids creating memory leaks while detecting them
30
- - Ensures the debugging tool itself doesn't impact application performance
31
-
32
- #### Non-Intrusive Design
33
- - Operates without interfering with the application's normal functionality
34
- - Uses a transparent overlay that doesn't block user interactions
35
- - Can be easily enabled or disabled as needed
36
-
37
- #### Developer Tools Integration
38
- - Provides detailed debugging information in development mode
39
- - Offers subscription capabilities for external monitoring tools
40
- - Maintains detailed statistics about detected issues
41
-
42
- ### Use Cases
43
-
44
- * **Production Performance Monitoring**
45
- - Monitoring application memory usage patterns
46
- - Detecting gradual memory leaks in long-running applications
47
- - Identifying patterns in component detachment
48
-
49
- * **Development Debugging**
50
- - Identifying component cleanup issues during development
51
- - Tracking down memory leaks in complex component hierarchies
52
- - Visualizing component lifecycle issues
53
-
54
- This tool serves as an essential debugging aid for React developers, helping them maintain efficient and leak-free applications while providing valuable insights into component behavior and memory management patterns.
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall memory_lab
9
- */
10
- import process from 'process';
11
- import {PlaywrightTestConfig} from '@playwright/test';
12
-
13
- const config: PlaywrightTestConfig = {
14
- testDir: './src/tests',
15
- use: {
16
- // Serve files from the root directory
17
- baseURL: `file://${process.cwd()}`,
18
- },
19
- };
20
-
21
- export default config;
@@ -1,32 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall memory_lab
9
- */
10
-
11
- import {AnyValue, Config} from '../core/types';
12
-
13
- // Performance Configuration
14
- export const performanceConfig = {
15
- scanIntervalMs: 1000,
16
- maxComponentStackDepth: 100,
17
- memoryMeasurementIntervalMs: 5000,
18
- };
19
-
20
- // Feature Flags
21
- export const featureFlags = {
22
- enableMutationObserver: true,
23
- enableMemoryTracking: true,
24
- enableComponentStack: true,
25
- enableConsoleLogs: (window as AnyValue)?.TEST_MEMORY_SCAN,
26
- };
27
-
28
- // overall Config
29
- export const config: Config = {
30
- performance: performanceConfig,
31
- features: featureFlags,
32
- };