@buoy-gg/highlight-updates 7.0.63 → 7.0.65

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 (22) hide show
  1. package/README.md +9 -0
  2. package/lib/commonjs/highlight-updates/components/HighlightUpdatesModal.js +1 -1
  3. package/lib/commonjs/highlight-updates/utils/CommitProfiler.js +1 -1
  4. package/lib/commonjs/highlight-updates/utils/HighlightUpdatesController.js +1 -1
  5. package/lib/commonjs/highlight-updates/utils/PerformanceLogger.js +2 -2
  6. package/lib/commonjs/highlight-updates/utils/ProfilerInterceptor.js +1 -1
  7. package/lib/commonjs/highlight-updates/utils/RenderCauseDetector.js +4 -4
  8. package/lib/commonjs/highlight-updates/utils/RenderTracker.js +1 -1
  9. package/lib/commonjs/highlight-updates/utils/namedComposite.js +1 -1
  10. package/lib/module/highlight-updates/components/HighlightUpdatesModal.js +1 -1
  11. package/lib/module/highlight-updates/utils/CommitProfiler.js +1 -1
  12. package/lib/module/highlight-updates/utils/HighlightUpdatesController.js +1 -1
  13. package/lib/module/highlight-updates/utils/PerformanceLogger.js +2 -2
  14. package/lib/module/highlight-updates/utils/ProfilerInterceptor.js +1 -1
  15. package/lib/module/highlight-updates/utils/RenderCauseDetector.js +4 -4
  16. package/lib/module/highlight-updates/utils/RenderTracker.js +1 -1
  17. package/lib/module/highlight-updates/utils/namedComposite.js +1 -1
  18. package/lib/typescript/highlight-updates/utils/HighlightUpdatesController.d.ts +12 -0
  19. package/lib/typescript/highlight-updates/utils/RenderTracker.d.ts +3 -0
  20. package/lib/typescript/highlight-updates/utils/namedComposite.d.ts +1 -0
  21. package/lib/web/index.mjs +28 -28
  22. package/package.json +6 -6
package/README.md CHANGED
@@ -6,6 +6,8 @@ Highlight observed React component updates in development builds and inspect the
6
6
 
7
7
  Your search stays in view when you leave a render.
8
8
 
9
+ Names use `displayName` when the app sets it.
10
+
9
11
  <a href="https://buoy.gg/buoy/latest/docs/tools/highlight-updates"><b>Highlight Updates guide</b></a> &nbsp;·&nbsp; <a href="https://buoy.gg">buoy.gg</a> &nbsp;·&nbsp; <a href="https://github.com/Buoy-gg/buoy">All tools</a>
10
12
 
11
13
  [![npm version](https://img.shields.io/npm/v/@buoy-gg/highlight-updates?style=flat-square&labelColor=10302a&color=2a9d78)](https://www.npmjs.com/package/@buoy-gg/highlight-updates) [![npm downloads](https://img.shields.io/npm/dm/@buoy-gg/highlight-updates?style=flat-square&labelColor=10302a&color=2a9d78&label=downloads%2Fmonth)](https://www.npmjs.com/package/@buoy-gg/highlight-updates)
@@ -24,6 +26,13 @@ It appears in the menu once installed. You don't need a React DevTools connectio
24
26
 
25
27
  The [Highlight Updates guide](https://buoy.gg/buoy/latest/docs/tools/highlight-updates) covers setup, what it captures and its limits. New to Buoy? Start with the [Quick start](https://buoy.gg/buoy/latest/docs/quick-start).
26
28
 
29
+ ## Angular dev builds
30
+
31
+ The Angular port can feed this tool's boxes and counts.
32
+ Use `connectBuoyHighlights` from `@buoy-gg/angular/highlights` in dev.
33
+ It leaves React and React Native setup as it is.
34
+ See the [Angular setup](https://buoy.gg/buoy/latest/docs/web/angular#router-and-highlight).
35
+
27
36
  ---
28
37
 
29
38
  <sub>Part of <a href="https://buoy.gg">Buoy</a>, developer tools that live inside your app. Proprietary software. © Buoy LLC. <a href="https://buoy.gg/terms">Terms</a></sub>
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.HighlightToolView=HighlightToolView;exports.HighlightUpdatesModal=HighlightUpdatesModal;exports.default=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _HighlightUpdatesController=_interopRequireDefault(require("../utils/HighlightUpdatesController"));var _RenderTracker=require("../utils/RenderTracker");var _RenderDetailView=require("./RenderDetailView");var _HighlightFilterView=require("./HighlightFilterView");var _IsolatedRenderList=require("./IsolatedRenderList");var _ModalHeaderContent=require("./ModalHeaderContent");var _RenderHistoryViewer=require("./RenderHistoryViewer");var _RendersCopySettingsView=require("./RendersCopySettingsView");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(n){return n&&n.__esModule?n:{default:n}}function _interopRequireWildcard(n,k){if("function"==typeof WeakMap)var w=new WeakMap,F=new WeakMap;return(_interopRequireWildcard=function(a,T){if(!T&&a&&a.__esModule)return a;var l,u,g={__proto__:null,default:a};if(null===a||"object"!=typeof a&&"function"!=typeof a)return g;if(l=T?F:w){if(l.has(a))return l.get(a);l.set(a,g)}for(const o in a)"default"!==o&&{}.hasOwnProperty.call(a,o)&&((u=(l=Object.defineProperty)&&Object.getOwnPropertyDescriptor(a,o))&&(u.get||u.set)?l(g,o,u):g[o]=a[o]);return g})(n,k)}const DisabledBanner=_react.default.memo(function n(){return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"buoy-highlight-disabled-banner",style:styles.disabledBanner,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"buoy-highlight-disabled-text",style:styles.disabledText,children:"Render tracking is disabled"})]})});function HighlightUpdatesModal({visible:n,onClose:k,onBack:w,onMinimize:F,enableSharedModalDimensions:a=false,initialNativeTag:T,onInitialNativeTagHandled:l,onRenderSelect:u,inline:g=false}){const o=(0,_license.useIsPro)();const[R,de]=(0,_react.useState)(false);const[q,ue]=(0,_react.useState)(()=>_HighlightUpdatesController.default.getFrozen());const[z,N]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getStats().totalComponents>0);const[s,f]=(0,_react.useState)(null);const[h,x]=(0,_react.useState)(0);const[m,I]=(0,_react.useState)(false);const[P,M]=(0,_react.useState)(false);const[ge,fe]=(0,_react.useState)([]);const[V,he]=(0,_react.useState)("filters");const[y,O]=(0,_react.useState)("details");const[B,_]=(0,_react.useState)(0);const[S,Se]=(0,_react.useState)("");const[b,D]=(0,_react.useState)(false);const L=(0,_react.useRef)(null);const C=(0,_react.useRef)([]);const U=(0,_react.useRef)(_RenderTracker.RenderTracker.getFilters());const[j,K]=(0,_react.useState)(()=>{const e=_RenderTracker.RenderTracker.getFilters();return e.includePatterns.length+e.excludePatterns.length});const[i,W]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getFilters());const[H,J]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getSettings());const G=(0,_react.useRef)(false);const A=(0,_react.useRef)(false);const v=(0,_react.useRef)(false);(0,_react.useEffect)(()=>{if(!n||G.current)return;G.current=true},[n]);(0,_react.useEffect)(()=>{if(!n||A.current)return;const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.highlightUpdates.filters());if(t){const r=JSON.parse(t);const c={includeTestID:new Set(r.includeTestID||[]),includeNativeID:new Set(r.includeNativeID||[]),includeViewType:new Set(r.includeViewType||[]),includeComponent:new Set(r.includeComponent||[]),excludeTestID:new Set(r.excludeTestID||[]),excludeNativeID:new Set(r.excludeNativeID||[]),excludeViewType:new Set(r.excludeViewType||[]),excludeComponent:new Set(r.excludeComponent||[]),includePatterns:r.includePatterns||[],excludePatterns:r.excludePatterns||[]};_RenderTracker.RenderTracker.setFilters(c);const d=_RenderTracker.RenderTracker.getFilters();U.current=d;W(d);K(d.includePatterns.length+d.excludePatterns.length)}A.current=true}catch(t){}};e()},[n]);(0,_react.useEffect)(()=>{if(!A.current)return;const e=async()=>{try{const t={includeTestID:Array.from(i.includeTestID),includeNativeID:Array.from(i.includeNativeID),includeViewType:Array.from(i.includeViewType),includeComponent:Array.from(i.includeComponent),excludeTestID:Array.from(i.excludeTestID),excludeNativeID:Array.from(i.excludeNativeID),excludeViewType:Array.from(i.excludeViewType),excludeComponent:Array.from(i.excludeComponent),includePatterns:i.includePatterns,excludePatterns:i.excludePatterns};await _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.highlightUpdates.filters(),JSON.stringify(t))}catch(t){}};e()},[i]);(0,_react.useEffect)(()=>{if(!n||v.current)return;const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.highlightUpdates.settings());if(t){const r=JSON.parse(t);const{performanceLogging:c,excludeDevTools:d,...p}=r;_RenderTracker.RenderTracker.setSettings(p);J(_RenderTracker.RenderTracker.getSettings())}v.current=true}catch(t){v.current=true}};e()},[n]);(0,_react.useEffect)(()=>{if(!v.current)return;const e=async()=>{try{const{performanceLogging:t,excludeDevTools:r,...c}=H;await _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.highlightUpdates.settings(),JSON.stringify(c))}catch(t){}};e()},[H]);(0,_react.useEffect)(()=>{const e=_RenderTracker.RenderTracker.subscribeToState(t=>{de(t.isTracking)});return()=>{e()}},[]);(0,_react.useEffect)(()=>{const e=_HighlightUpdatesController.default.subscribeToFreeze(t=>{ue(t)});return()=>{e()}},[]);(0,_react.useEffect)(()=>{if(b){requestAnimationFrame(()=>{L.current?.focus()})}},[b]);(0,_react.useEffect)(()=>{if(!n){_HighlightUpdatesController.default.setSpotlight(null)}},[n]);(0,_react.useEffect)(()=>{if(n&&T!=null){const e=_RenderTracker.RenderTracker.getRender(String(T));if(e){f(e);x(0);I(false);_HighlightUpdatesController.default.setSpotlight(e.nativeTag)}l?.()}},[n,T,l]);const Q=(0,_react.useCallback)(()=>{if(!_HighlightUpdatesController.default.isInitialized()){_HighlightUpdatesController.default.initialize()}_HighlightUpdatesController.default.toggle()},[]);const X=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.toggleFreeze()},[]);const Y=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.clearRenderCounts();N(false)},[]);const Z=(0,_react.useCallback)(()=>{fe(_RenderTracker.RenderTracker.getFilteredRenders(S));M(true)},[S]);const $=(0,_react.useCallback)(()=>{M(false)},[]);const ee=(0,_react.useCallback)(e=>{Se(e)},[]);const pe=(0,_react.useCallback)((e,t,r)=>{f(e);x(t);O("details");_(0);C.current=r;_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},[]);(0,_react.useEffect)(()=>{if(!s)return;const e=String(s.nativeTag);return _RenderTracker.RenderTracker.subscribe(()=>{const t=_RenderTracker.RenderTracker.getRender(e);if(t)f({...t})})},[s?.nativeTag]);const te=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!u||!s)return;if(te.current===s.nativeTag)return;te.current=s.nativeTag;u(s)},[s,u]);const Te=(0,_react.useCallback)(e=>{C.current=e},[]);const re=(0,_react.useCallback)(()=>{f(null);x(0);if(S)D(true);_HighlightUpdatesController.default.setSpotlight(null)},[S]);const xe=(0,_react.useCallback)(()=>{const e=C.current;if(h>0){const t=h-1;const r=e[t];if(r){f(r);x(t);_HighlightUpdatesController.default.setSpotlight(r.nativeTag)}}},[h]);const ye=(0,_react.useCallback)(()=>{const e=C.current;if(h<e.length-1){const t=h+1;const r=e[t];if(r){f(r);x(t);_HighlightUpdatesController.default.setSpotlight(r.nativeTag)}}},[h]);const ne=(0,_react.useCallback)(()=>{I(false)},[]);const se=(0,_react.useCallback)(()=>{I(true)},[]);const ae=(0,_react.useCallback)(()=>{D(true)},[]);const ie=(0,_react.useCallback)(()=>{D(false)},[]);const E=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setFilters(e);const t=_RenderTracker.RenderTracker.getFilters();U.current=t;W(t);K(t.includePatterns.length+t.excludePatterns.length)},[]);const Ce=(0,_react.useCallback)((e,t)=>{const r=_RenderTracker.RenderTracker.getFilters();const c={};if(t==="include"){const d=r.includePatterns.some(p=>p.type===e.type&&p.value===e.value);if(!d){c.includePatterns=[...r.includePatterns,e]}}else{const d=r.excludePatterns.some(p=>p.type===e.type&&p.value===e.value);if(!d){c.excludePatterns=[...r.excludePatterns,e]}}if(Object.keys(c).length>0){E(c);f(null);x(0);_HighlightUpdatesController.default.setSpotlight(null)}},[E]);const we=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setSettings(e);J(_RenderTracker.RenderTracker.getSettings())},[]);const Re=(0,_react.useCallback)(e=>{N(e.totalComponents>0)},[]);const oe=(0,_react.useCallback)(()=>{if(P){return(0,_jsxRuntime.jsx)(_ModalHeaderContent.CopySettingsViewHeader,{onBack:$})}if(m){return(0,_jsxRuntime.jsx)(_ModalHeaderContent.FilterViewHeader,{onBack:ne,activeTab:V,onTabChange:he,activeFilterCount:j})}if(s){return(0,_jsxRuntime.jsx)(_ModalHeaderContent.DetailViewHeader,{onBack:re,activeTab:y,onTabChange:O,hasHistory:(s.renderHistory?.length??0)>0})}return(0,_jsxRuntime.jsx)(_ModalHeaderContent.MainListHeader,{onBack:w,isSearchActive:b,searchText:S,onSearchChange:ee,onSearchToggle:ae,onSearchClose:ie,onFilterToggle:se,onToggleTracking:Q,onToggleFreeze:X,onClear:Y,onOpenCopySettings:Z,isTracking:R,isFrozen:q,activeFilterCount:j,hasRenders:z,searchInputRef:L})},[P,m,s,w,b,S,R,q,j,z,V,y,ne,re,$,ee,ae,ie,se,Q,X,Y,Z]);const be=a?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.highlightUpdates.modal();if(!n)return null;const ve=C.current.length;const le=s?y==="details"?(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:h,totalItems:ve,onPrevious:xe,onNext:ye,itemLabel:"Component",subtitle:s.componentName||s.displayName||s.viewType}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryFooter,{render:s,selectedEventIndex:B,onEventIndexChange:_,isPro:o}):null;const ce=(0,_jsxRuntime.jsx)(_reactNative.View,{nativeID:"__rn_buoy__highlight-modal",testID:"buoy-highlight-body",style:styles.container,children:P?(0,_jsxRuntime.jsx)(_RendersCopySettingsView.RendersCopySettingsView,{renders:ge}):s?y==="details"?(0,_jsxRuntime.jsx)(_RenderDetailView.RenderDetailView,{render:s,disableInternalFooter:true,onAddFilter:Ce,isPro:o}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryViewer,{render:s,disableInternalFooter:true,selectedEventIndex:B,onEventIndexChange:_,isPro:o}):m?(0,_jsxRuntime.jsx)(_HighlightFilterView.HighlightFilterView,{filters:i,onFilterChange:E,settings:H,onSettingsChange:we,availableProps:_RenderTracker.RenderTracker.getAvailableProps(),activeTab:V}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[!R&&(0,_jsxRuntime.jsx)(DisabledBanner,{}),(0,_jsxRuntime.jsx)(_IsolatedRenderList.IsolatedRenderList,{searchText:S,filters:i,onSelectRender:pe,onStatsChange:Re,onRendersChange:Te,isTracking:R,isPro:o})]})});if(g){return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:oe()}),ce,le]})})}return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:n,onClose:k,onMinimize:F,persistenceKey:be,header:{showToggleButton:true,customContent:oe()},enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:_reactNative.Platform.OS==="web",styles:{},footer:le,footerHeight:s?y==="details"?68:(s.renderHistory?.length??0)>1?68:0:0,children:ce})})}function HighlightToolView(n={}){return(0,_jsxRuntime.jsx)(HighlightUpdatesModal,{...n,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.border,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.warning+"20"},disabledText:{color:_sharedUi.night.color.warning,fontSize:11,flex:1}});var _default=exports.default=HighlightUpdatesModal;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.HighlightToolView=HighlightToolView;exports.HighlightUpdatesModal=HighlightUpdatesModal;exports.default=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _HighlightUpdatesController=_interopRequireDefault(require("../utils/HighlightUpdatesController"));var _RenderTracker=require("../utils/RenderTracker");var _RenderDetailView=require("./RenderDetailView");var _HighlightFilterView=require("./HighlightFilterView");var _IsolatedRenderList=require("./IsolatedRenderList");var _ModalHeaderContent=require("./ModalHeaderContent");var _RenderHistoryViewer=require("./RenderHistoryViewer");var _RendersCopySettingsView=require("./RendersCopySettingsView");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(n){return n&&n.__esModule?n:{default:n}}function _interopRequireWildcard(n,k){if("function"==typeof WeakMap)var w=new WeakMap,F=new WeakMap;return(_interopRequireWildcard=function(a,T){if(!T&&a&&a.__esModule)return a;var l,u,g={__proto__:null,default:a};if(null===a||"object"!=typeof a&&"function"!=typeof a)return g;if(l=T?F:w){if(l.has(a))return l.get(a);l.set(a,g)}for(const o in a)"default"!==o&&{}.hasOwnProperty.call(a,o)&&((u=(l=Object.defineProperty)&&Object.getOwnPropertyDescriptor(a,o))&&(u.get||u.set)?l(g,o,u):g[o]=a[o]);return g})(n,k)}const DisabledBanner=_react.default.memo(function n(){return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"buoy-highlight-disabled-banner",style:styles.disabledBanner,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"buoy-highlight-disabled-text",style:styles.disabledText,children:"Render tracking is disabled"})]})});function HighlightUpdatesModal({visible:n,onClose:k,onBack:w,onMinimize:F,enableSharedModalDimensions:a=false,initialNativeTag:T,onInitialNativeTagHandled:l,onRenderSelect:u,inline:g=false}){const o=(0,_license.useIsPro)();const[R,de]=(0,_react.useState)(false);const[N,ue]=(0,_react.useState)(()=>_HighlightUpdatesController.default.getFrozen());const[q,z]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getStats().totalComponents>0);const[s,f]=(0,_react.useState)(null);const[h,x]=(0,_react.useState)(0);const[m,I]=(0,_react.useState)(false);const[P,M]=(0,_react.useState)(false);const[ge,fe]=(0,_react.useState)([]);const[V,he]=(0,_react.useState)("filters");const[y,O]=(0,_react.useState)("details");const[B,_]=(0,_react.useState)(0);const[S,Se]=(0,_react.useState)("");const[b,D]=(0,_react.useState)(false);const L=(0,_react.useRef)(null);const C=(0,_react.useRef)([]);const U=(0,_react.useRef)(_RenderTracker.RenderTracker.getFilters());const[j,K]=(0,_react.useState)(()=>{const e=_RenderTracker.RenderTracker.getFilters();return e.includePatterns.length+e.excludePatterns.length});const[i,W]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getFilters());const[H,J]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getSettings());const G=(0,_react.useRef)(false);const A=(0,_react.useRef)(false);const v=(0,_react.useRef)(false);(0,_react.useEffect)(()=>{if(!n||G.current)return;G.current=true},[n]);(0,_react.useEffect)(()=>{if(!n||A.current)return;const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.highlightUpdates.filters());if(t){const r=JSON.parse(t);const c={includeTestID:new Set(r.includeTestID||[]),includeNativeID:new Set(r.includeNativeID||[]),includeViewType:new Set(r.includeViewType||[]),includeComponent:new Set(r.includeComponent||[]),excludeTestID:new Set(r.excludeTestID||[]),excludeNativeID:new Set(r.excludeNativeID||[]),excludeViewType:new Set(r.excludeViewType||[]),excludeComponent:new Set(r.excludeComponent||[]),includePatterns:r.includePatterns||[],excludePatterns:r.excludePatterns||[]};_RenderTracker.RenderTracker.setFilters(c);const d=_RenderTracker.RenderTracker.getFilters();U.current=d;W(d);K(d.includePatterns.length+d.excludePatterns.length)}A.current=true}catch(t){}};e()},[n]);(0,_react.useEffect)(()=>{if(!A.current)return;const e=async()=>{try{const t={includeTestID:Array.from(i.includeTestID),includeNativeID:Array.from(i.includeNativeID),includeViewType:Array.from(i.includeViewType),includeComponent:Array.from(i.includeComponent),excludeTestID:Array.from(i.excludeTestID),excludeNativeID:Array.from(i.excludeNativeID),excludeViewType:Array.from(i.excludeViewType),excludeComponent:Array.from(i.excludeComponent),includePatterns:i.includePatterns,excludePatterns:i.excludePatterns};await _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.highlightUpdates.filters(),JSON.stringify(t))}catch(t){}};e()},[i]);(0,_react.useEffect)(()=>{if(!n||v.current)return;const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.highlightUpdates.settings());if(t){const r=JSON.parse(t);const{performanceLogging:c,excludeDevTools:d,...p}=r;_RenderTracker.RenderTracker.setSettings(p);J(_RenderTracker.RenderTracker.getSettings())}v.current=true}catch(t){v.current=true}};e()},[n]);(0,_react.useEffect)(()=>{if(!v.current)return;const e=async()=>{try{const{performanceLogging:t,excludeDevTools:r,...c}=H;await _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.highlightUpdates.settings(),JSON.stringify(c))}catch(t){}};e()},[H]);(0,_react.useEffect)(()=>{const e=_RenderTracker.RenderTracker.subscribeToState(t=>{de(t.isTracking)});return()=>{e()}},[]);(0,_react.useEffect)(()=>{const e=_HighlightUpdatesController.default.subscribeToFreeze(t=>{ue(t)});return()=>{e()}},[]);(0,_react.useEffect)(()=>{if(b){requestAnimationFrame(()=>{L.current?.focus()})}},[b]);(0,_react.useEffect)(()=>{if(!n){_HighlightUpdatesController.default.setSpotlight(null)}},[n]);(0,_react.useEffect)(()=>{if(n&&T!=null){const e=_RenderTracker.RenderTracker.getRender(String(T));if(e){f(e);x(0);I(false);_HighlightUpdatesController.default.setSpotlight(e.nativeTag)}l?.()}},[n,T,l]);const Q=(0,_react.useCallback)(()=>{if(!_HighlightUpdatesController.default.isInitialized()){_HighlightUpdatesController.default.initialize()}_HighlightUpdatesController.default.toggle()},[]);const X=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.toggleFreeze()},[]);const Y=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.clearRenderCounts();z(false)},[]);const Z=(0,_react.useCallback)(()=>{fe(_RenderTracker.RenderTracker.getFilteredRenders(S));M(true)},[S]);const $=(0,_react.useCallback)(()=>{M(false)},[]);const ee=(0,_react.useCallback)(e=>{Se(e)},[]);const pe=(0,_react.useCallback)((e,t,r)=>{f(e);x(t);O("details");_(0);C.current=r;_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},[]);(0,_react.useEffect)(()=>{if(!s)return;const e=String(s.nativeTag);return _RenderTracker.RenderTracker.subscribe(()=>{const t=_RenderTracker.RenderTracker.getRender(e);if(t)f({...t})})},[s?.nativeTag]);const te=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!u||!s)return;if(te.current===s.nativeTag)return;te.current=s.nativeTag;u(s)},[s,u]);const Te=(0,_react.useCallback)(e=>{C.current=e},[]);const re=(0,_react.useCallback)(()=>{f(null);x(0);if(S)D(true);_HighlightUpdatesController.default.setSpotlight(null)},[S]);const xe=(0,_react.useCallback)(()=>{const e=C.current;if(h>0){const t=h-1;const r=e[t];if(r){f(r);x(t);_HighlightUpdatesController.default.setSpotlight(r.nativeTag)}}},[h]);const ye=(0,_react.useCallback)(()=>{const e=C.current;if(h<e.length-1){const t=h+1;const r=e[t];if(r){f(r);x(t);_HighlightUpdatesController.default.setSpotlight(r.nativeTag)}}},[h]);const ne=(0,_react.useCallback)(()=>{I(false)},[]);const se=(0,_react.useCallback)(()=>{I(true)},[]);const ae=(0,_react.useCallback)(()=>{D(true)},[]);const ie=(0,_react.useCallback)(()=>{D(false)},[]);const E=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setFilters(e);const t=_RenderTracker.RenderTracker.getFilters();U.current=t;W(t);K(t.includePatterns.length+t.excludePatterns.length)},[]);const Ce=(0,_react.useCallback)((e,t)=>{const r=_RenderTracker.RenderTracker.getFilters();const c={};if(t==="include"){const d=r.includePatterns.some(p=>p.type===e.type&&p.value===e.value);if(!d){c.includePatterns=[...r.includePatterns,e]}}else{const d=r.excludePatterns.some(p=>p.type===e.type&&p.value===e.value);if(!d){c.excludePatterns=[...r.excludePatterns,e]}}if(Object.keys(c).length>0){E(c);f(null);x(0);_HighlightUpdatesController.default.setSpotlight(null)}},[E]);const we=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setSettings(e);J(_RenderTracker.RenderTracker.getSettings())},[]);const Re=(0,_react.useCallback)(e=>{z(e.totalComponents>0)},[]);const oe=(0,_react.useCallback)(()=>{if(P){return(0,_jsxRuntime.jsx)(_ModalHeaderContent.CopySettingsViewHeader,{onBack:$})}if(m){return(0,_jsxRuntime.jsx)(_ModalHeaderContent.FilterViewHeader,{onBack:ne,activeTab:V,onTabChange:he,activeFilterCount:j})}if(s){return(0,_jsxRuntime.jsx)(_ModalHeaderContent.DetailViewHeader,{onBack:re,activeTab:y,onTabChange:O,hasHistory:(s.renderHistory?.length??0)>0})}return(0,_jsxRuntime.jsx)(_ModalHeaderContent.MainListHeader,{onBack:w,isSearchActive:b,searchText:S,onSearchChange:ee,onSearchToggle:ae,onSearchClose:ie,onFilterToggle:se,onToggleTracking:Q,onToggleFreeze:X,onClear:Y,onOpenCopySettings:Z,isTracking:R,isFrozen:N,activeFilterCount:j,hasRenders:q,searchInputRef:L})},[P,m,s,w,b,S,R,N,j,q,V,y,ne,re,$,ee,ae,ie,se,Q,X,Y,Z]);const be=a?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.highlightUpdates.modal();if(!n)return null;const ve=C.current.length;const le=s?y==="details"?(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:h,totalItems:ve,onPrevious:xe,onNext:ye,itemLabel:"Component",subtitle:s.componentName||s.displayName||s.viewType}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryFooter,{render:s,selectedEventIndex:B,onEventIndexChange:_,isPro:o}):null;const ce=(0,_jsxRuntime.jsx)(_reactNative.View,{nativeID:"__rn_buoy__highlight-modal",testID:"buoy-highlight-body",style:styles.container,children:P?(0,_jsxRuntime.jsx)(_RendersCopySettingsView.RendersCopySettingsView,{renders:ge}):s?y==="details"?(0,_jsxRuntime.jsx)(_RenderDetailView.RenderDetailView,{render:s,disableInternalFooter:true,onAddFilter:Ce,isPro:o}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryViewer,{render:s,disableInternalFooter:true,selectedEventIndex:B,onEventIndexChange:_,isPro:o}):m?(0,_jsxRuntime.jsx)(_HighlightFilterView.HighlightFilterView,{filters:i,onFilterChange:E,settings:H,onSettingsChange:we,availableProps:_RenderTracker.RenderTracker.getAvailableProps(),activeTab:V}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[_HighlightUpdatesController.default.getRenderSourceStatus()==="unavailable"?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:_sharedUi.night.color.warning,padding:16},children:"Not in this app"}):!R&&(0,_jsxRuntime.jsx)(DisabledBanner,{}),(0,_jsxRuntime.jsx)(_IsolatedRenderList.IsolatedRenderList,{searchText:S,filters:i,onSelectRender:pe,onStatsChange:Re,onRendersChange:Te,isTracking:R,isPro:o})]})});if(g){return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:oe()}),ce,le]})})}return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:n,onClose:k,onMinimize:F,persistenceKey:be,header:{showToggleButton:true,customContent:oe()},enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:_reactNative.Platform.OS==="web",styles:{},footer:le,footerHeight:s?y==="details"?68:(s.renderHistory?.length??0)>1?68:0:0,children:ce})})}function HighlightToolView(n={}){return(0,_jsxRuntime.jsx)(HighlightUpdatesModal,{...n,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.border,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.warning+"20"},disabledText:{color:_sharedUi.night.color.warning,fontSize:11,flex:1}});var _default=exports.default=HighlightUpdatesModal;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CommitProfiler=void 0;var _devtoolsComponentNames=require("./devtoolsComponentNames");var _ownStateChanged=require("./ownStateChanged");const FunctionComponent=0;const ClassComponent=1;const ForwardRef=11;const MemoComponent=14;const SimpleMemoComponent=15;const PerformedWork=1;const MAX_FIBERS_PER_COMMIT=1e4;const MAX_TRACKED_NAMES=300;const TOP_COMPONENTS_CAP=20;let hookInstalled=false;let active=false;let sawDurations=false;let captureDetail=false;let totalCommits=0;let totalRenders=0;let totalRenderMs=0;let totalCauses={};let buckets=new Map;function getHook(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}function getFlags(e){const t=e.flags??e.effectTag;return typeof t==="number"?t:0}function isCompositeTag(e){return e===FunctionComponent||e===ClassComponent||e===ForwardRef||e===MemoComponent||e===SimpleMemoComponent}function getComponentName(e){const t=e.type;try{switch(e.tag){case FunctionComponent:case ClassComponent:return t?.displayName||t?.name||"Anonymous";case ForwardRef:return t?.displayName||t?.render?.displayName||t?.render?.name||"ForwardRef";case MemoComponent:case SimpleMemoComponent:{const o=t?.type??e.elementType?.type;return t?.displayName||o?.displayName||o?.name||"Memo"}default:return"Anonymous"}}catch{return"Anonymous"}}function computeSelfMs(e){const t=e.actualDuration;if(typeof t!=="number")return null;let o=t;for(let n=e.child;n!=null;n=n.sibling){if(typeof n.actualDuration==="number")o-=n.actualDuration}return o>0?o:0}const FRAMEWORK_WRAPPER_NAMES=new Set(["View","Text","Image","ImageBackground","ScrollView","FlatList","SectionList","SafeAreaView","KeyboardAvoidingView","StatusBar","ActivityIndicator","RefreshControl","Modal","Switch","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","PressabilityDebugView","AnimatedComponent","Wrapper"]);const FRAMEWORK_WRAPPER_PREFIXES=["Animated(","Pressability","Virtualized","CellRenderer"];function isFrameworkWrapperName(e){if(FRAMEWORK_WRAPPER_NAMES.has(e))return true;for(let t=0;t<FRAMEWORK_WRAPPER_PREFIXES.length;t++){if(e.startsWith(FRAMEWORK_WRAPPER_PREFIXES[t]))return true}return false}const MAX_PROPS_COMPARED=40;const MAX_CHANGED_KEYS=5;function isEquivalentValue(e,t){if(Object.is(e,t))return true;const o=typeof e;if(o!==typeof t)return false;if(o==="function")return true;if(e===null||t===null||o!=="object")return false;const n=Array.isArray(e);if(n!==Array.isArray(t))return false;if(n){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!Object.is(e[a],t[a]))return false;return true}const r=Object.keys(e);const i=Object.keys(t);if(r.length!==i.length)return false;for(let a=0;a<r.length;a++){const s=r[a];if(!Object.prototype.hasOwnProperty.call(t,s))return false;if(!Object.is(e[s],t[s]))return false}return true}function detectCause(e,t){const o=e.alternate;if(!o)return{cause:"mount"};const n=e.memoizedProps;const r=o.memoizedProps;if(n!==r&&n&&r){let i=false;let a=false;let s;const l=Object.keys(n);const p=l.length<MAX_PROPS_COMPARED?l.length:MAX_PROPS_COMPARED;for(let u=0;u<p;u++){const c=l[u];const f=r[c];const d=n[c];if(Object.is(f,d))continue;i=true;if(t){if(!s)s=[];if(s.length<MAX_CHANGED_KEYS)s.push(c)}if(!isEquivalentValue(f,d)){a=true;if(!t)break}}if(!a&&Object.keys(r).length!==l.length){i=true;a=true}if(i){return{cause:a?"props":"propsUnstable",changedKeys:s}}}if((0,_ownStateChanged.ownStateChanged)(o,e))return{cause:"hooks"};return{cause:"parent"}}function nearestRenderedAncestorName(e){for(let t=e.return;t!=null;t=t.return){if(!isCompositeTag(t.tag))continue;if((getFlags(t)&PerformedWork)===0)continue;const o=getComponentName(t);if(isFrameworkWrapperName(o))continue;return o}return void 0}function recordRender(e,t){const o=getComponentName(e);const n=computeSelfMs(e);if(n!==null)sawDurations=true;const r=n??0;totalRenders+=1;totalRenderMs+=r;const{cause:i,changedKeys:a}=detectCause(e,captureDetail);totalCauses[i]=(totalCauses[i]??0)+1;if(isFrameworkWrapperName(o))return;let s=buckets.get(o);if(!s){if(buckets.size>=MAX_TRACKED_NAMES)return;s={renders:0,totalSelfMs:0,maxSelfMs:0,causes:{}};buckets.set(o,s)}s.renders+=1;s.totalSelfMs+=r;if(r>s.maxSelfMs)s.maxSelfMs=r;s.causes[i]=(s.causes[i]??0)+1;if(captureDetail){if(a){if(!s.changedProps)s.changedProps=new Set;for(let l=0;l<a.length;l++){if(s.changedProps.size>=MAX_CHANGED_KEYS)break;s.changedProps.add(a[l])}}if(t&&!s.parentName)s.parentName=t}}function handleCommit(e){const t=e?.current;if(!t)return;const o=totalRenders;let n=0;let r=t;while(r!=null){n+=1;if(n>MAX_FIBERS_PER_COMMIT)break;let i=false;const a=isCompositeTag(r.tag);if(r.memoizedProps?.__buoyDevToolsRoot){i=true}else if(a){const s=getComponentName(r);if((0,_devtoolsComponentNames.isRenderLoopUnsafeName)(s)){i=true}else if((0,_devtoolsComponentNames.isDevToolsComponentName)(s)){}else if((getFlags(r)&PerformedWork)!==0){recordRender(r,captureDetail?nearestRenderedAncestorName(r):void 0)}}if(!i){const s=r.subtreeFlags;const l=typeof s==="number"&&(s&PerformedWork)===0&&(getFlags(r)&PerformedWork)===0;if(!l&&r.child!=null){r=r.child;continue}}while(r!=null){if(r===t)return finalizeCommit(o);if(r.sibling!=null){r=r.sibling;break}r=r.return}}finalizeCommit(o)}function finalizeCommit(e){if(totalRenders>e)totalCommits+=1}function ensureHookInstalled(){if(hookInstalled)return true;const e=getHook();if(!e)return false;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(o,n,...r){if(active){try{handleCommit(n)}catch{}}return typeof t==="function"?t.call(e,o,n,...r):void 0};hookInstalled=true;return true}function isSupported(){if(typeof __DEV__!=="undefined"&&!__DEV__)return false;const e=getHook();return Boolean(e&&e.renderers&&e.renderers.size>0)}function isCapturing(){return active}function startCapture(e){if(!ensureHookInstalled())return;buckets=new Map;sawDurations=false;captureDetail=e?.detail===true;totalCommits=0;totalRenders=0;totalRenderMs=0;totalCauses={};active=true}function stopCapture(){if(!active&&totalRenders===0&&buckets.size===0)return null;active=false;const e=Array.from(buckets.entries()).sort((o,n)=>{const r=n[1].totalSelfMs-o[1].totalSelfMs;return r!==0?r:n[1].renders-o[1].renders}).slice(0,TOP_COMPONENTS_CAP).map(([o,n])=>({name:o,renders:n.renders,totalMs:round2(n.totalSelfMs),maxMs:round2(n.maxSelfMs),avgMs:n.renders>0?round2(n.totalSelfMs/n.renders):0,causes:n.causes,...n.changedProps&&n.changedProps.size>0?{changedProps:Array.from(n.changedProps)}:null,...n.parentName?{parentName:n.parentName}:null}));const t={totalCommits,totalRenders,capturedDurations:sawDurations,totalRenderMs:round2(totalRenderMs),wastedRenders:(totalCauses.parent??0)+(totalCauses.propsUnstable??0),causes:totalCauses,topComponents:e};buckets=new Map;totalCommits=0;totalRenders=0;totalRenderMs=0;totalCauses={};return t}function round2(e){return Math.round(e*100)/100}const CommitProfiler=exports.CommitProfiler={isSupported,isCapturing,startCapture,stopCapture};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CommitProfiler=void 0;var _devtoolsComponentNames=require("./devtoolsComponentNames");var _ownStateChanged=require("./ownStateChanged");const FunctionComponent=0;const ClassComponent=1;const ForwardRef=11;const MemoComponent=14;const SimpleMemoComponent=15;const PerformedWork=1;const MAX_FIBERS_PER_COMMIT=1e4;const MAX_TRACKED_NAMES=300;const TOP_COMPONENTS_CAP=20;let hookInstalled=false;let active=false;let sawDurations=false;let captureDetail=false;let totalCommits=0;let totalRenders=0;let totalRenderMs=0;let totalCauses={};let buckets=new Map;function getHook(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}function getFlags(e){const t=e.flags??e.effectTag;return typeof t==="number"?t:0}function isCompositeTag(e){return e===FunctionComponent||e===ClassComponent||e===ForwardRef||e===MemoComponent||e===SimpleMemoComponent}function getComponentName(e){const t=e.type;try{switch(e.tag){case FunctionComponent:case ClassComponent:return t?.displayName||t?.name||"Anonymous";case ForwardRef:return t?.displayName||t?.render?.displayName||t?.render?.name||"ForwardRef";case MemoComponent:case SimpleMemoComponent:{const o=t?.type??e.elementType?.type;return t?.displayName||o?.displayName||o?.name||"Memo"}default:return"Anonymous"}}catch{return"Anonymous"}}function computeSelfMs(e){const t=e.actualDuration;if(typeof t!=="number")return null;let o=t;for(let r=e.child;r!=null;r=r.sibling){if(typeof r.actualDuration==="number")o-=r.actualDuration}return o>0?o:0}const FRAMEWORK_WRAPPER_NAMES=new Set(["View","Text","Image","ImageBackground","ScrollView","FlatList","SectionList","SafeAreaView","KeyboardAvoidingView","StatusBar","ActivityIndicator","RefreshControl","Modal","Switch","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","PressabilityDebugView","AnimatedComponent","Wrapper"]);const FRAMEWORK_WRAPPER_PREFIXES=["Animated(","Pressability","Virtualized","CellRenderer"];function isFrameworkWrapperName(e){if(FRAMEWORK_WRAPPER_NAMES.has(e))return true;for(let t=0;t<FRAMEWORK_WRAPPER_PREFIXES.length;t++){if(e.startsWith(FRAMEWORK_WRAPPER_PREFIXES[t]))return true}return false}const MAX_PROPS_COMPARED=40;const MAX_CHANGED_KEYS=5;function isEquivalentValue(e,t){if(Object.is(e,t))return true;const o=typeof e;if(o!==typeof t)return false;if(o==="function")return true;if(e===null||t===null||o!=="object")return false;const r=Array.isArray(e);if(r!==Array.isArray(t))return false;if(r){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!Object.is(e[a],t[a]))return false;return true}const n=Object.keys(e);const i=Object.keys(t);if(n.length!==i.length)return false;for(let a=0;a<n.length;a++){const s=n[a];if(!Object.prototype.hasOwnProperty.call(t,s))return false;if(!Object.is(e[s],t[s]))return false}return true}function detectCause(e,t){const o=e.alternate;if(!o)return{cause:"mount"};const r=e.memoizedProps;const n=o.memoizedProps;if(r!==n&&r&&n){let i=false;let a=false;let s;const l=Object.keys(r);const m=l.length<MAX_PROPS_COMPARED?l.length:MAX_PROPS_COMPARED;for(let u=0;u<m;u++){const c=l[u];const f=n[c];const d=r[c];if(Object.is(f,d))continue;i=true;if(t){if(!s)s=[];if(s.length<MAX_CHANGED_KEYS)s.push(c)}if(!isEquivalentValue(f,d)){a=true;if(!t)break}}if(!a&&Object.keys(n).length!==l.length){i=true;a=true}if(i){return{cause:a?"props":"propsUnstable",changedKeys:s}}}if((0,_ownStateChanged.ownStateChanged)(o,e))return{cause:"hooks"};return{cause:"parent"}}function nearestRenderedAncestorName(e){for(let t=e.return;t!=null;t=t.return){if(!isCompositeTag(t.tag))continue;if((getFlags(t)&PerformedWork)===0)continue;const o=getComponentName(t);if(isFrameworkWrapperName(o))continue;return o}return void 0}function recordRender(e,t){const o=getComponentName(e);const r=computeSelfMs(e);if(r!==null)sawDurations=true;const n=r??0;totalRenders+=1;totalRenderMs+=n;const{cause:i,changedKeys:a}=detectCause(e,captureDetail);totalCauses[i]=(totalCauses[i]??0)+1;if(isFrameworkWrapperName(o))return;let s=buckets.get(o);if(!s){if(buckets.size>=MAX_TRACKED_NAMES)return;s={renders:0,totalSelfMs:0,maxSelfMs:0,causes:{}};buckets.set(o,s)}s.renders+=1;s.totalSelfMs+=n;if(n>s.maxSelfMs)s.maxSelfMs=n;s.causes[i]=(s.causes[i]??0)+1;if(captureDetail){if(a){if(!s.changedProps)s.changedProps=new Set;for(let l=0;l<a.length;l++){if(s.changedProps.size>=MAX_CHANGED_KEYS)break;s.changedProps.add(a[l])}}if(t&&!s.parentName)s.parentName=t}}function handleCommit(e){const t=e?.current;if(!t)return;const o=totalRenders;let r=0;let n=t;while(n!=null){r+=1;if(r>MAX_FIBERS_PER_COMMIT)break;let i=false;const a=isCompositeTag(n.tag);if(n.memoizedProps?.__buoyDevToolsRoot||n.memoizedProps?.["data-buoy-root"]!==void 0){i=true}else if(a){const s=getComponentName(n);if((0,_devtoolsComponentNames.isRenderLoopUnsafeName)(s)){i=true}else if((0,_devtoolsComponentNames.isDevToolsComponentName)(s)){}else if((getFlags(n)&PerformedWork)!==0){recordRender(n,captureDetail?nearestRenderedAncestorName(n):void 0)}}if(!i){const s=n.subtreeFlags;const l=typeof s==="number"&&(s&PerformedWork)===0&&(getFlags(n)&PerformedWork)===0;if(!l&&n.child!=null){n=n.child;continue}}while(n!=null){if(n===t)return finalizeCommit(o);if(n.sibling!=null){n=n.sibling;break}n=n.return}}finalizeCommit(o)}function finalizeCommit(e){if(totalRenders>e)totalCommits+=1}function ensureHookInstalled(){if(hookInstalled)return true;const e=getHook();if(!e)return false;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(o,r,...n){if(active){try{handleCommit(r)}catch{}}return typeof t==="function"?t.call(e,o,r,...n):void 0};hookInstalled=true;return true}function isSupported(){if(typeof __DEV__!=="undefined"&&!__DEV__)return false;const e=getHook();return Boolean(e&&e.renderers&&e.renderers.size>0)}function isCapturing(){return active}function startCapture(e){if(!ensureHookInstalled())return;buckets=new Map;sawDurations=false;captureDetail=e?.detail===true;totalCommits=0;totalRenders=0;totalRenderMs=0;totalCauses={};active=true}function stopCapture(){if(!active&&totalRenders===0&&buckets.size===0)return null;active=false;const e=Array.from(buckets.entries()).sort((o,r)=>{const n=r[1].totalSelfMs-o[1].totalSelfMs;return n!==0?n:r[1].renders-o[1].renders}).slice(0,TOP_COMPONENTS_CAP).map(([o,r])=>({name:o,renders:r.renders,totalMs:round2(r.totalSelfMs),maxMs:round2(r.maxSelfMs),avgMs:r.renders>0?round2(r.totalSelfMs/r.renders):0,causes:r.causes,...r.changedProps&&r.changedProps.size>0?{changedProps:Array.from(r.changedProps)}:null,...r.parentName?{parentName:r.parentName}:null}));const t={totalCommits,totalRenders,capturedDurations:sawDurations,totalRenderMs:round2(totalRenderMs),wastedRenders:(totalCauses.parent??0)+(totalCauses.propsUnstable??0),causes:totalCauses,topComponents:e};buckets=new Map;totalCommits=0;totalRenders=0;totalRenderMs=0;totalCauses={};return t}function round2(e){return Math.round(e*100)/100}const CommitProfiler=exports.CommitProfiler={isSupported,isCapturing,startCapture,stopCapture};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _utils=require("@buoy-gg/shared-ui/utils");var _ProfilerInterceptor=require("./ProfilerInterceptor");var _reactNative=require("react-native");var _RenderTracker=require("./RenderTracker");var _screenElements=require("./screenElements");var _tapMatch=require("./tapMatch");var _PerformanceLogger=require("./PerformanceLogger");var _RenderCauseDetector=require("./RenderCauseDetector");var _sharedUi=require("@buoy-gg/shared-ui");var _devtoolsComponentNames=require("./devtoolsComponentNames");"use strict";let globalEnabled=false;let highlightsSuppressed=false;let backgroundTrackingEnabled=false;let initialized=false;let hook=null;let highlightCallback=null;let badgePressCallback=null;let traceUpdatesUnsubscribe=null;let isProcessing=false;let isFrozen=false;const freezeListeners=new Set;const stateListeners=new Set;const nodeRenderCounts=new Map;const COLORS=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"];const DEBUG=false;function debugLog(e,n){if(!DEBUG)return;if(n!==void 0){console.log(`[HighlightUpdates] ${e}`,n)}else{console.log(`[HighlightUpdates] ${e}`)}}function getPublicInstance(e){const n=(0,_utils.getDOMPublicInstance)(e);if(n)return n;if(!e)return null;const r=e;if(r.canonical?.publicInstance){return r.canonical.publicInstance}if(r.canonical&&typeof r.canonical.measure==="function"){return r.canonical}if(typeof r.measure==="function"){return r}return null}function getNativeTag(e){const n=(0,_utils.getDOMNodeHandle)(e);if(n!==null)return n;if(e==null)return null;const r=e;if(r.__nativeTag!=null)return r.__nativeTag;if(r._nativeTag!=null)return r._nativeTag;if(r.nativeTag!=null)return r.nativeTag;if(r.canonical){if(r.canonical.__nativeTag!=null)return r.canonical.__nativeTag;if(r.canonical._nativeTag!=null)return r.canonical._nativeTag;if(r.canonical.nativeTag!=null)return r.canonical.nativeTag}return null}function extractComponentInfo(e){const n=e;const r={viewType:"Unknown"};if(n?.canonical?.viewConfig?.uiViewClassName){r.viewType=n.canonical.viewConfig.uiViewClassName}else if(n?.viewConfig?.uiViewClassName){r.viewType=n.viewConfig.uiViewClassName}else if((0,_utils.isDOMElement)(n)){r.viewType=n.tagName.toLowerCase()}const o=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||(0,_utils.getDOMFiber)(n);const i=n?.canonical?.currentProps;const a=n?.canonical?.pendingProps;const t=o?.pendingProps;const c=o?.memoizedProps;r.testID=i?.testID||a?.testID||t?.testID||c?.testID||t?.["data-testid"]||c?.["data-testid"]||void 0;r.nativeID=i?.nativeID||a?.nativeID||t?.nativeID||c?.nativeID||t?.id||c?.id||void 0;r.accessibilityLabel=i?.accessibilityLabel||a?.accessibilityLabel||t?.accessibilityLabel||c?.accessibilityLabel||t?.["aria-label"]||c?.["aria-label"]||void 0;r.componentName=getOwningComponentName(o)||void 0;return r}function describeNodeForLog(e){const n=e;const r=getPublicInstance(e);const o=getNativeTag(e)||getNativeTag(r);const i={nativeTag:o??"unknown",type:n?.canonical?"Fabric":"Legacy",hasMeasure:typeof r?.measure==="function"};if(n){i.stateNodeKeys=Object.keys(n).slice(0,20);if(n.node){i.nodeKeys=Object.keys(n.node).slice(0,20)}if(n.viewConfig){i.viewConfig={uiViewClassName:n.viewConfig.uiViewClassName,validAttributes:n.viewConfig.validAttributes?Object.keys(n.viewConfig.validAttributes).slice(0,10):void 0}}if(n.canonical){const a=n.canonical;i.canonicalKeys=Object.keys(a).slice(0,20);if(a.viewConfig){i.canonicalViewConfig={uiViewClassName:a.viewConfig.uiViewClassName}}if(a.nativeTag!=null){i.canonicalNativeTag=a.nativeTag}if(a.internalInstanceHandle){const t=a.internalInstanceHandle;i.fiberKeys=Object.keys(t).slice(0,30);if(t.type){i.fiberType=typeof t.type==="function"?t.type.name||t.type.displayName||"function":t.type}if(t.elementType){i.fiberElementType=typeof t.elementType==="function"?t.elementType.name||t.elementType.displayName||"function":t.elementType}if(t._debugOwner){const c=t._debugOwner;i.fiberDebugOwner=c.type?.name||c.type?.displayName||c.elementType?.name||"unknown"}if(t._debugSource){i.fiberDebugSource=t._debugSource}if(t.tag!=null){i.fiberTag=t.tag}if(t.pendingProps){if(t.pendingProps.nativeID)i.fiberPendingNativeID=t.pendingProps.nativeID;if(t.pendingProps.testID)i.fiberPendingTestID=t.pendingProps.testID}if(t.memoizedProps){if(t.memoizedProps.nativeID)i.fiberMemoizedNativeID=t.memoizedProps.nativeID;if(t.memoizedProps.testID)i.fiberMemoizedTestID=t.memoizedProps.testID}}if(a.publicInstance){const t=a.publicInstance;i.publicInstanceKeys=Object.keys(t).slice(0,20);if(t.nativeID!=null)i.nativeID=t.nativeID;if(t._nativeID!=null)i._nativeID=t._nativeID;if(t.props){i.publicInstanceProps=Object.keys(t.props).slice(0,15);if(t.props.nativeID)i.propsNativeID=t.props.nativeID;if(t.props.testID)i.propsTestID=t.props.testID;if(t.props.accessibilityLabel)i.accessibilityLabel=t.props.accessibilityLabel}}if(a.currentProps){i.currentPropsKeys=Object.keys(a.currentProps).slice(0,15);if(a.currentProps.nativeID!=null)i.currentPropsNativeID=a.currentProps.nativeID;if(a.currentProps.testID!=null)i.currentPropsTestID=a.currentProps.testID;if(a.currentProps.accessibilityLabel!=null)i.currentPropsAccessLabel=a.currentProps.accessibilityLabel}if(a.pendingProps){i.pendingPropsKeys=Object.keys(a.pendingProps).slice(0,15);if(a.pendingProps.nativeID!=null)i.pendingPropsNativeID=a.pendingProps.nativeID;if(a.pendingProps.testID!=null)i.pendingPropsTestID=a.pendingProps.testID}}if(n._debugOwner){const a=n._debugOwner;i.debugOwnerType=a.type?.name||a.type?.displayName||typeof a.type}if(n._debugSource){i.debugSource=n._debugSource}}return i}const DEBUG_LOGGING=false;let renderingLock=false;let renderingLockTimeout=null;const RENDER_LOCK_DURATION=350;const renderedOverlayTags=new Set;function isOurOverlayTag(e){if(e==null)return false;return renderedOverlayTags.has(e)}const HIGHLIGHT_OVERLAY_NATIVE_IDS=new Set(["highlight-updates-overlay","__rn_buoy__highlight-modal"]);const OTHER_DEV_TOOLS_NATIVE_IDS=new Set(["jsmodal-root","image-overlay-standalone","logbox_inspector","logbox"]);const devToolsNodeCache=new Map;const CACHE_MAX_SIZE=500;function clearDevToolsCache(){devToolsNodeCache.clear()}function isHighlightOverlayNativeID(e){if(!e)return false;if(HIGHLIGHT_OVERLAY_NATIVE_IDS.has(e))return true;if(e.startsWith("__highlight_"))return true;return false}function isOtherDevToolsNativeID(e){if(!e)return false;if(OTHER_DEV_TOOLS_NATIVE_IDS.has(e))return true;const n=e.charCodeAt(0);if(n===95){if(e.startsWith("__rn_buoy__"))return true}if(n===108&&e.startsWith("logbox")){return true}return false}function getComponentName(e){if(!e)return null;const n=e.type;if(n){if(typeof n==="string")return n;if(n.name)return n.name;if(n.displayName)return n.displayName}const r=e.elementType;if(r){if(r.name)return r.name;if(r.displayName)return r.displayName}return null}const INTERNAL_COMPONENT_NAMES=new Set(["View","Text","TextImpl","Image","ScrollView","FlatList","SectionList","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","Pressable","TextInput","Switch","ActivityIndicator","Modal","StatusBar","KeyboardAvoidingView","AnimatedComponent","AnimatedComponentWrapper","ScreenContainer","ScreenStack","Screen","ScreenContentWrapper","Svg","G","Path","Rect","Circle","Line","Polygon","Polyline","Ellipse","Text as SVGText","TSpan","TextPath","Use","Symbol","Defs","ClipPath","LinearGradient","RadialGradient","Stop","Mask","Pattern","Image as SVGImage","SafeAreaProvider","SafeAreaView","SafeAreaListener","GestureHandlerRootView","GestureDetector","ReanimatedView","ReanimatedText","ReanimatedImage","ReanimatedScrollView","Fragment","Suspense","Provider","Consumer","Context","ForwardRef"]);function isInternalComponent(e){if(!e)return true;if(INTERNAL_COMPONENT_NAMES.has(e))return true;if(e==="Unknown"||e==="Component")return true;if(e.startsWith("Animated"))return true;return false}function getOwningComponentName(e){if(!e)return null;let n=e._debugOwner||e.return;let r=0;let o=null;while(n&&r<30){const i=getComponentName(n);if(i&&typeof n.type!=="string"){if(!o){o=i}if(!isInternalComponent(i)){return i}}n=n.return;r++}return o}function isOurOverlayNode(e){const n=e;const r=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||(0,_utils.getDOMFiber)(n);const o=getNativeTag(e)||getNativeTag(n?.canonical?.publicInstance);const i=(0,_devtoolsComponentNames.isCapturingBuoyToolRenders)();const a=!i&&_RenderTracker.RenderTracker.getSettings().excludeDevTools;if(a&&(0,_utils.isDOMElement)(e)&&e.closest("[data-buoy-root]"))return true;if(o!=null&&a){const g=devToolsNodeCache.get(o);if(g!==void 0){return g}}let t=false;const c=r?.pendingProps?.nativeID||r?.memoizedProps?.nativeID||n?.canonical?.currentProps?.nativeID||null;if(isHighlightOverlayNativeID(c)){t=true}else if(a&&isOtherDevToolsNativeID(c)){t=true}if(!t&&r){let g=r;let m=0;while(g&&m<30){const s=getComponentName(g);if(s){if(_devtoolsComponentNames.HIGHLIGHT_OVERLAY_COMPONENTS.has(s)){t=true;break}for(const d of _devtoolsComponentNames.HIGHLIGHT_OVERLAY_PREFIXES){if(s.startsWith(d)){t=true;break}}if(t)break;if(i&&(0,_devtoolsComponentNames.isPerfMonitorComponentName)(s)){t=true;break}if(a){if(_devtoolsComponentNames.OTHER_DEV_TOOLS_COMPONENTS.has(s)||_devtoolsComponentNames.OTHER_DEV_TOOLS_EXACT.has(s)){t=true;break}for(const d of _devtoolsComponentNames.OTHER_DEV_TOOLS_PREFIXES){if(s.startsWith(d)){t=true;break}}if(t)break}}const f=g.pendingProps?.nativeID||g.memoizedProps?.nativeID;if(isHighlightOverlayNativeID(f)){t=true;break}if(a&&isOtherDevToolsNativeID(f)){t=true;break}g=g.return;m++}}if(t&&o!=null&&a){if(devToolsNodeCache.size>=CACHE_MAX_SIZE){const g=Array.from(devToolsNodeCache.keys());for(let m=0;m<CACHE_MAX_SIZE/2;m++){devToolsNodeCache.delete(g[m])}}devToolsNodeCache.set(o,t)}return t}function getColorForRenderCount(e){const n=Math.min(e-1,COLORS.length-1);return COLORS[Math.max(0,n)]}function handleTraceUpdates(e){if(e.size===0){return}if(!globalEnabled&&!backgroundTrackingEnabled){return}const n=_RenderTracker.RenderTracker.getState();if(n.isPaused){return}if(_PerformanceLogger.PerformanceLogger.isEnabled()){(0,_PerformanceLogger.markEventReceived)()}const r=_RenderTracker.RenderTracker.getBatchSize();const o=_PerformanceLogger.PerformanceLogger.startBatch(e.size,r);const i=[];let a=0;let t=0;const c=_RenderTracker.RenderTracker.hasActiveFilters();for(const s of e){if(s&&typeof s==="object"){try{if(isOurOverlayNode(s)){a++;continue}const f=getPublicInstance(s);const d=getNativeTag(s)||getNativeTag(f);if(d==null){continue}const y=extractComponentInfo(s);if(c&&!_RenderTracker.RenderTracker.passesFilters(y)){t++;continue}const I=_RenderTracker.RenderTracker.getSettings().showRenderCount;let p;let u;if(I){const l=nodeRenderCounts.get(d)||0;p=l+1;nodeRenderCounts.set(d,p);u=getColorForRenderCount(p)}else{p=0;u=COLORS[0]}i.push({node:s,color:u,count:p})}catch{}}}o.markFilteringComplete(a+t,i.length);if(i.length===0){o.finish();return}if(DEBUG_LOGGING){console.log(`[HighlightUpdates] ${i.length} component(s) re-rendered`)}const g=_RenderTracker.RenderTracker.getRenderEventCallbackCount()>0;if(!highlightCallback&&!g){if(DEBUG_LOGGING){console.log(`[HighlightUpdates] No highlightCallback and no event callbacks - skipping render`)}isProcessing=false;return}o.markMeasurementStart();const m=i.slice(0,r*4).map(({node:s,color:f,count:d})=>new Promise(y=>{let I=false;const p=b=>{if(I)return;I=true;clearTimeout(u);y(b)};const u=setTimeout(()=>p({rect:null,stateNode:s,color:f,count:d}),500);const l=getPublicInstance(s);const v=getNativeTag(s)||getNativeTag(l);if(v==null){p({rect:null,stateNode:s,color:f,count:d});return}const T=(b,_,h,D,w,C)=>{if(w==null||C==null||h==null||D==null){p({rect:null,stateNode:s,color:f,count:d});return}p({rect:{id:v,x:w,y:C,width:h,height:D,color:f,count:d},stateNode:s,color:f,count:d})};if(!l){const b=s.node;const _=globalThis.nativeFabricUIManager;if(b&&_?.measure){try{_.measure(b,T)}catch(h){p({rect:null,stateNode:s,color:f,count:d})}return}p({rect:null,stateNode:s,color:f,count:d});return}try{l.measure(T)}catch(b){p({rect:null,stateNode:s,color:f,count:d})}}));Promise.all(m).then(s=>{const f=s.filter(y=>y.rect!==null);const d=f.map(y=>y.rect);o.markMeasurementComplete(f.length,s.length-f.length);if(d.length>0&&highlightCallback&&globalEnabled&&!highlightsSuppressed){highlightCallback(d)}setTimeout(()=>{try{for(const u of f){if(u.rect)registerTrackedNode(u.rect.id,u.stateNode)}}catch(u){debugLog("registerTrackedNode batch failed",u)}const y=_RenderTracker.RenderTracker.getSettings();const I=y.trackRenderCauses&&y.showRenderCount;let p=null;if(I){p=new Set;for(const{rect:u}of f){if(u){p.add(u.id)}}}if(globalEnabled){_RenderTracker.RenderTracker.startBatch();for(const{rect:u,stateNode:l,color:v,count:T}of f){if(u){const b=extractComponentInfo(l);let _;if(I&&p){const h=l;const D=getFiberFromNode(h);_=(0,_RenderCauseDetector.detectRenderCause)(u.id,D,p,y.debugLogLevel)}_RenderTracker.RenderTracker.trackRender({nativeTag:u.id,viewType:b.viewType,testID:b.testID,nativeID:b.nativeID,accessibilityLabel:b.accessibilityLabel,componentName:b.componentName,measurements:{x:u.x,y:u.y,width:u.width,height:u.height},color:v,count:T,renderCause:_})}}_RenderTracker.RenderTracker.endBatch()}else{for(const{rect:u,stateNode:l,color:v,count:T}of f){if(u){const b=extractComponentInfo(l);let _;if(I&&p){const h=l;const D=getFiberFromNode(h);_=(0,_RenderCauseDetector.detectRenderCause)(u.id,D,p,y.debugLogLevel)}_RenderTracker.RenderTracker.emitRenderEvent({nativeTag:u.id,viewType:b.viewType,testID:b.testID,nativeID:b.nativeID,accessibilityLabel:b.accessibilityLabel,componentName:b.componentName,measurements:{x:u.x,y:u.y,width:u.width,height:u.height},color:v,count:T,renderCause:_})}}}o.markTrackingComplete();o.markCallbackComplete();o.finish()},0)}).catch(s=>{console.error("[HighlightUpdates] Error in measurement pipeline:",s);o.finish()})}const WeakRefCtor=globalThis.WeakRef;const nodeRegistry=new Map;function registerTrackedNode(e,n){if(e==null||n==null||typeof n!=="object"){return}try{nodeRegistry.set(e,WeakRefCtor?new WeakRefCtor(n):{deref:()=>n})}catch{nodeRegistry.set(e,{deref:()=>n})}}function derefNode(e){const n=nodeRegistry.get(e);const r=n?.deref();if(!r)nodeRegistry.delete(e);return r??null}function measureNode(e){return new Promise(n=>{try{e.measure((r,o,i,a,t,c)=>{if(t==null||c==null||i==null||a==null){n(null)}else{n({x:t,y:c,width:i,height:a})}})}catch{n(null)}})}function getFiberFromNode(e){const n=e;return n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||(0,_utils.getDOMFiber)(n)||null}function findScrollAncestor(e){let n=getFiberFromNode(e);let r=0;while(n&&r++<200){const o=n.stateNode;if(o&&typeof o.scrollTo==="function"){const i=typeof o.getNativeScrollRef==="function"&&o.getNativeScrollRef()||null;const a=typeof o.getInnerViewNode==="function"&&o.getInnerViewNode()||typeof o.getScrollableNode==="function"&&o.getScrollableNode()||o;return{instance:o,nativeRef:i,innerNode:a}}n=n.return}return null}async function scrollDescendantIntoView(e,n,r){try{const o=findScrollAncestor(e);if(!o)return false;const i=n;let a=null;const t=c=>new Promise(g=>{let m=false;const s=d=>{if(m)return;m=true;g(d)};const f=setTimeout(()=>s(null),600);try{c(d=>{clearTimeout(f);s(d)})}catch{clearTimeout(f);s(null)}});if(o.nativeRef&&typeof i.measureLayout==="function"){a=await t(c=>i.measureLayout(o.nativeRef,(g,m)=>c(m),()=>c(null)))}if(a==null){const c=(0,_reactNative.findNodeHandle)(n);const g=typeof o.innerNode==="number"?o.innerNode:(0,_reactNative.findNodeHandle)(o.innerNode);if(c!=null&&g!=null){a=await t(m=>_reactNative.UIManager.measureLayout(c,g,()=>m(null),(s,f)=>m(f)))}}if(a==null)return false;o.instance.scrollTo({y:Math.max(0,a-r),animated:false});await new Promise(c=>setTimeout(c,80));return true}catch{return false}}function matchScore(e,n){const r=[e.testID,e.nativeID,e.accessibilityLabel,e.componentName,e.viewType,String(e.nativeTag)];let o=0;for(const i of r){if(!i)continue;const a=i.toLowerCase();if(a===n)return 3;if(a.startsWith(n))o=Math.max(o,2);else if(a.includes(n))o=Math.max(o,1)}return o}async function locateComponent(e){const n=e.scrollIntoView!==false;const r=typeof e.margin==="number"?e.margin:12;const o=_RenderTracker.RenderTracker.getRenders();const i=async()=>{const l=await(0,_screenElements.describeScreen)();const v=(e.query??"").trim().toLowerCase();let T;for(const h of l.elements){if(e.nativeTag!=null&&h.nativeTag===e.nativeTag){T={el:h,score:1e3};break}const D=(0,_tapMatch.scoreTapMatch)({nativeTag:h.nativeTag,testID:h.testID,label:h.label,text:h.text,name:h.name,tap:h.tap},{query:v||void 0,nativeTag:e.nativeTag});if(D<=0)continue;if(!T||D>T.score)T={el:h,score:D}}if(!T?.el.frame){return{matched:false,reason:"no-match",candidates:[]}}const b=l.screen;const _=T.el.frame;return{matched:true,live:true,rect:{x:_.x*b.width,y:_.y*b.height,width:_.width*b.width,height:_.height*b.height},scale:_reactNative.PixelRatio.get(),screen:{width:b.width,height:b.height},nativeTag:T.el.nativeTag??void 0,componentName:T.el.name,testID:T.el.testID}};if(o.length===0)return i();const a=(e.query??"").trim().toLowerCase();const t=a?o.map(l=>({r:l,score:matchScore(l,a)})).filter(l=>l.score>0).sort((l,v)=>v.score-l.score||v.r.lastRenderTime-l.r.lastRenderTime):[];const c=t.slice(0,8).map(({r:l})=>({nativeTag:l.nativeTag,componentName:l.componentName,testID:l.testID,nativeID:l.nativeID,viewType:l.viewType,renderCount:l.renderCount}));const g=e.nativeTag??(t.length>0?t[0].r.nativeTag:void 0);if(g==null){const l=await i();return l.matched?l:{matched:false,reason:"no-match",candidates:c}}const m=o.find(l=>l.nativeTag===g);let s=null;let f=false;let d=false;const y=derefNode(g);if(y){const l=getPublicInstance(y);if(l){if(n){d=await scrollDescendantIntoView(y,l,r)}s=await measureNode(l);f=!!s}}if(!s&&m?.measurements){s={...m.measurements}}if(!s){return{matched:false,reason:"no-measurement",nativeTag:g,candidates:c}}const I=_reactNative.PixelRatio.get();const p=_reactNative.Dimensions.get("window");const u=s.x>=-1&&s.y>=-1&&s.x+s.width<=p.width+1&&s.y+s.height<=p.height+1;return{matched:true,live:f,scrolled:d,inView:u,rect:s,scale:I,screen:{width:p.width,height:p.height},nativeTag:g,componentName:m?.componentName,testID:m?.testID,candidates:c}}function setTraceUpdatesOnRenderers(e){if(!hook?.rendererInterfaces){debugLog("No rendererInterfaces available");return}let n=0;hook.rendererInterfaces.forEach((r,o)=>{if(typeof r.setTraceUpdatesEnabled==="function"){try{r.setTraceUpdatesEnabled(e);n++;debugLog(`Renderer ${o}: setTraceUpdatesEnabled(${e})`)}catch(i){debugLog(`Renderer ${o}: error setting trace updates`,i)}}else{debugLog(`Renderer ${o}: no setTraceUpdatesEnabled method`)}});debugLog(`Set trace updates ${e?"enabled":"disabled"} on ${n} renderer(s)`);if(hook.reactDevtoolsAgent?.setTraceUpdatesEnabled){try{hook.reactDevtoolsAgent.setTraceUpdatesEnabled(e);debugLog("Also set trace updates on agent")}catch(r){debugLog("Error setting trace updates on agent",r)}}}function subscribeToTraceUpdates(){if(!hook)return;if(traceUpdatesUnsubscribe)return;debugLog("Subscribing to traceUpdates event");if(typeof hook.sub==="function"){traceUpdatesUnsubscribe=hook.sub("traceUpdates",handleTraceUpdates);debugLog("Subscribed using hook.sub()")}else{debugLog("hook.sub not available, traceUpdates may not work")}setTraceUpdatesOnRenderers(true)}function unsubscribeFromTraceUpdates(){setTraceUpdatesOnRenderers(false);if(traceUpdatesUnsubscribe){traceUpdatesUnsubscribe();traceUpdatesUnsubscribe=null;debugLog("Unsubscribed from traceUpdates event")}}function setHighlightCallback(e){highlightCallback=e;debugLog(`Highlight callback ${e?"set":"cleared"}`)}function setBadgePressCallback(e){badgePressCallback=e;debugLog(`Badge press callback ${e?"set":"cleared"}`)}function getBadgePressCallback(){return badgePressCallback}function handleBadgePress(e){if(badgePressCallback){badgePressCallback(e)}}let spotlightCallback=null;let currentSpotlightTag=null;function setSpotlightCallback(e){spotlightCallback=e;if(e&&currentSpotlightTag!==null){e(currentSpotlightTag)}}function setSpotlight(e){if(remoteHandler){remoteHandler("setSpotlight",{nativeTag:e});return}currentSpotlightTag=e;if(spotlightCallback){spotlightCallback(e)}}let remoteHandler=null;function setRemoteHandler(e){remoteHandler=e}function replaceRemoteState(e){if(globalEnabled!==e.enabled){globalEnabled=e.enabled;notifyStateListeners()}if(isFrozen!==e.frozen){isFrozen=e.frozen;notifyFreezeListeners()}}function getSpotlight(){return currentSpotlightTag}function notifyStateListeners(){stateListeners.forEach(e=>{try{e(globalEnabled)}catch(n){console.error("[HighlightUpdates] Error in state listener:",n)}})}function subscribe(e){stateListeners.add(e);e(globalEnabled);return()=>{stateListeners.delete(e)}}function initialize(){if(typeof __DEV__!=="undefined"&&!__DEV__){debugLog("Only available in development builds");return false}if(remoteHandler){return true}if(initialized){return true}hook=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null;if(!hook){debugLog("React DevTools hook not found");return false}debugLog("Hook found");debugLog(`Hook has sub: ${typeof hook.sub==="function"}`);debugLog(`Hook has on: ${typeof hook.on==="function"}`);debugLog(`Hook has emit: ${typeof hook.emit==="function"}`);(0,_ProfilerInterceptor.installProfilerInterceptor)();if(hook.rendererInterfaces&&hook.rendererInterfaces.size>0){initialized=true;debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`);exposeGlobally();return true}const e=setInterval(()=>{if(hook?.rendererInterfaces&&hook.rendererInterfaces.size>0){clearInterval(e);initialized=true;debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`);exposeGlobally()}},100);setTimeout(()=>clearInterval(e),1e4);return false}function exposeGlobally(){if(typeof window!=="undefined"){window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable,disable,toggle,isEnabled,setEnabled,subscribe,initialize,destroy,isInitialized:()=>initialized,setHighlightCallback}}}function enable(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!initialized){initialize()}if(highlightsSuppressed){highlightsSuppressed=false}if(globalEnabled){return}debugLog("Enabling highlights");if(!backgroundTrackingEnabled){subscribeToTraceUpdates()}_RenderTracker.RenderTracker.start();globalEnabled=true;notifyStateListeners();(0,_sharedUi.notifySubscriberCountChange)("render")}function disable(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!globalEnabled){return}debugLog("Disabling highlights");renderingLock=false;isProcessing=false;if(renderingLockTimeout){clearTimeout(renderingLockTimeout);renderingLockTimeout=null}renderedOverlayTags.clear();devToolsNodeCache.clear();(0,_RenderCauseDetector.clearRenderCauseState)();if(isFrozen){isFrozen=false;notifyFreezeListeners()}if(!backgroundTrackingEnabled){unsubscribeFromTraceUpdates()}_RenderTracker.RenderTracker.stop();globalEnabled=false;notifyStateListeners();(0,_sharedUi.notifySubscriberCountChange)("render")}function enableBackgroundTracking(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(backgroundTrackingEnabled){return}if(!initialized){initialize()}debugLog("Enabling background tracking");if(!globalEnabled){subscribeToTraceUpdates()}backgroundTrackingEnabled=true}function disableBackgroundTracking(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!backgroundTrackingEnabled){return}debugLog("Disabling background tracking");backgroundTrackingEnabled=false;if(!globalEnabled){unsubscribeFromTraceUpdates()}}function isBackgroundTrackingEnabled(){return backgroundTrackingEnabled}function toggle(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(remoteHandler){remoteHandler("toggle");return}if(globalEnabled){disable()}else{enable()}}function clearRenderCounts(){if(remoteHandler){remoteHandler("clearRenderCounts");return}nodeRenderCounts.clear();_RenderTracker.RenderTracker.clear();debugLog("Cleared render counts")}function isEnabled(){return globalEnabled}function setEnabled(e){if(remoteHandler){remoteHandler("setEnabled",{enabled:e});return}if(e)enable();else disable()}function setHighlightsSuppressed(e){if(highlightsSuppressed===e)return;highlightsSuppressed=e;if(e&&highlightCallback){highlightCallback([])}}function getHighlightsSuppressed(){return highlightsSuppressed}function setSilentTracking(e){if(remoteHandler){remoteHandler("setSilentTracking",{enabled:e});return}if(e){enable();setHighlightsSuppressed(true)}else{setHighlightsSuppressed(false);disable()}}function isInitialized(){return initialized}function notifyFreezeListeners(){freezeListeners.forEach(e=>{try{e(isFrozen)}catch(n){console.error("[HighlightUpdates] Error in freeze listener:",n)}})}function subscribeToFreeze(e){freezeListeners.add(e);e(isFrozen);return()=>{freezeListeners.delete(e)}}function freeze(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(isFrozen)return;isFrozen=true;debugLog("Freeze mode enabled");notifyFreezeListeners()}function unfreeze(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!isFrozen)return;isFrozen=false;debugLog("Freeze mode disabled");if(highlightCallback){highlightCallback([])}notifyFreezeListeners()}function toggleFreeze(){if(remoteHandler){remoteHandler("toggleFreeze");return}if(isFrozen){unfreeze()}else{freeze()}}function getFrozen(){return isFrozen}function destroy(){if(!initialized)return;unsubscribeFromTraceUpdates();(0,_ProfilerInterceptor.uninstallProfilerInterceptor)();(0,_ProfilerInterceptor.setComparisonCallback)(null);isFrozen=false;freezeListeners.clear();globalEnabled=false;hook=null;highlightCallback=null;initialized=false;if(typeof window!=="undefined"){delete window.__HIGHLIGHT_UPDATES_CONTROLLER__}debugLog("Destroyed")}const HighlightUpdatesController={subscribe,enable,disable,toggle,isEnabled,setEnabled,initialize,destroy,isInitialized,setHighlightCallback,clearRenderCounts,freeze,unfreeze,toggleFreeze,getFrozen,subscribeToFreeze,setBadgePressCallback,getBadgePressCallback,handleBadgePress,setSpotlightCallback,setSpotlight,getSpotlight,clearDevToolsCache,enableBackgroundTracking,disableBackgroundTracking,isBackgroundTrackingEnabled,setRemoteHandler,replaceRemoteState,locateComponent,setHighlightsSuppressed,getHighlightsSuppressed,setSilentTracking};var _default=exports.default=HighlightUpdatesController;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _utils=require("@buoy-gg/shared-ui/utils");var _ProfilerInterceptor=require("./ProfilerInterceptor");var _reactNative=require("react-native");var _RenderTracker=require("./RenderTracker");var _screenElements=require("./screenElements");var _tapMatch=require("./tapMatch");var _PerformanceLogger=require("./PerformanceLogger");var _RenderCauseDetector=require("./RenderCauseDetector");var _sharedUi=require("@buoy-gg/shared-ui");var _devtoolsComponentNames=require("./devtoolsComponentNames");"use strict";let globalEnabled=false;let highlightsSuppressed=false;let backgroundTrackingEnabled=false;let initialized=false;let hook=null;let highlightCallback=null;let badgePressCallback=null;let traceUpdatesUnsubscribe=null;let isProcessing=false;let isFrozen=false;const freezeListeners=new Set;const stateListeners=new Set;const nodeRenderCounts=new Map;const COLORS=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"];const DEBUG=false;function debugLog(e,n){if(!DEBUG)return;if(n!==void 0){console.log("[Buoy]",`[HighlightUpdates] ${e}`,n)}else{console.log("[Buoy]",`[HighlightUpdates] ${e}`)}}function getPublicInstance(e){const n=(0,_utils.getDOMPublicInstance)(e);if(n)return n;if(!e)return null;const r=e;if(r.canonical?.publicInstance){return r.canonical.publicInstance}if(r.canonical&&typeof r.canonical.measure==="function"){return r.canonical}if(typeof r.measure==="function"){return r}return null}function getNativeTag(e){const n=(0,_utils.getDOMNodeHandle)(e);if(n!==null)return n;if(e==null)return null;const r=e;if(r.__nativeTag!=null)return r.__nativeTag;if(r._nativeTag!=null)return r._nativeTag;if(r.nativeTag!=null)return r.nativeTag;if(r.canonical){if(r.canonical.__nativeTag!=null)return r.canonical.__nativeTag;if(r.canonical._nativeTag!=null)return r.canonical._nativeTag;if(r.canonical.nativeTag!=null)return r.canonical.nativeTag}return null}function extractComponentInfo(e){const n=e;const r={viewType:"Unknown"};if(n?.canonical?.viewConfig?.uiViewClassName){r.viewType=n.canonical.viewConfig.uiViewClassName}else if(n?.viewConfig?.uiViewClassName){r.viewType=n.viewConfig.uiViewClassName}else if((0,_utils.isDOMElement)(n)){r.viewType=n.tagName.toLowerCase()}const o=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||(0,_utils.getDOMFiber)(n);const i=n?.canonical?.currentProps;const a=n?.canonical?.pendingProps;const t=o?.pendingProps;const l=o?.memoizedProps;r.testID=i?.testID||a?.testID||t?.testID||l?.testID||t?.["data-testid"]||l?.["data-testid"]||void 0;r.nativeID=i?.nativeID||a?.nativeID||t?.nativeID||l?.nativeID||t?.id||l?.id||void 0;r.accessibilityLabel=i?.accessibilityLabel||a?.accessibilityLabel||t?.accessibilityLabel||l?.accessibilityLabel||t?.["aria-label"]||l?.["aria-label"]||void 0;r.componentName=getOwningComponentName(o)||void 0;return r}function describeNodeForLog(e){const n=e;const r=getPublicInstance(e);const o=getNativeTag(e)||getNativeTag(r);const i={nativeTag:o??"unknown",type:n?.canonical?"Fabric":"Legacy",hasMeasure:typeof r?.measure==="function"};if(n){i.stateNodeKeys=Object.keys(n).slice(0,20);if(n.node){i.nodeKeys=Object.keys(n.node).slice(0,20)}if(n.viewConfig){i.viewConfig={uiViewClassName:n.viewConfig.uiViewClassName,validAttributes:n.viewConfig.validAttributes?Object.keys(n.viewConfig.validAttributes).slice(0,10):void 0}}if(n.canonical){const a=n.canonical;i.canonicalKeys=Object.keys(a).slice(0,20);if(a.viewConfig){i.canonicalViewConfig={uiViewClassName:a.viewConfig.uiViewClassName}}if(a.nativeTag!=null){i.canonicalNativeTag=a.nativeTag}if(a.internalInstanceHandle){const t=a.internalInstanceHandle;i.fiberKeys=Object.keys(t).slice(0,30);if(t.type){i.fiberType=typeof t.type==="function"?t.type.name||t.type.displayName||"function":t.type}if(t.elementType){i.fiberElementType=typeof t.elementType==="function"?t.elementType.name||t.elementType.displayName||"function":t.elementType}if(t._debugOwner){const l=t._debugOwner;i.fiberDebugOwner=l.type?.name||l.type?.displayName||l.elementType?.name||"unknown"}if(t._debugSource){i.fiberDebugSource=t._debugSource}if(t.tag!=null){i.fiberTag=t.tag}if(t.pendingProps){if(t.pendingProps.nativeID)i.fiberPendingNativeID=t.pendingProps.nativeID;if(t.pendingProps.testID)i.fiberPendingTestID=t.pendingProps.testID}if(t.memoizedProps){if(t.memoizedProps.nativeID)i.fiberMemoizedNativeID=t.memoizedProps.nativeID;if(t.memoizedProps.testID)i.fiberMemoizedTestID=t.memoizedProps.testID}}if(a.publicInstance){const t=a.publicInstance;i.publicInstanceKeys=Object.keys(t).slice(0,20);if(t.nativeID!=null)i.nativeID=t.nativeID;if(t._nativeID!=null)i._nativeID=t._nativeID;if(t.props){i.publicInstanceProps=Object.keys(t.props).slice(0,15);if(t.props.nativeID)i.propsNativeID=t.props.nativeID;if(t.props.testID)i.propsTestID=t.props.testID;if(t.props.accessibilityLabel)i.accessibilityLabel=t.props.accessibilityLabel}}if(a.currentProps){i.currentPropsKeys=Object.keys(a.currentProps).slice(0,15);if(a.currentProps.nativeID!=null)i.currentPropsNativeID=a.currentProps.nativeID;if(a.currentProps.testID!=null)i.currentPropsTestID=a.currentProps.testID;if(a.currentProps.accessibilityLabel!=null)i.currentPropsAccessLabel=a.currentProps.accessibilityLabel}if(a.pendingProps){i.pendingPropsKeys=Object.keys(a.pendingProps).slice(0,15);if(a.pendingProps.nativeID!=null)i.pendingPropsNativeID=a.pendingProps.nativeID;if(a.pendingProps.testID!=null)i.pendingPropsTestID=a.pendingProps.testID}}if(n._debugOwner){const a=n._debugOwner;i.debugOwnerType=a.type?.name||a.type?.displayName||typeof a.type}if(n._debugSource){i.debugSource=n._debugSource}}return i}const DEBUG_LOGGING=false;let renderingLock=false;let renderingLockTimeout=null;const RENDER_LOCK_DURATION=350;const renderedOverlayTags=new Set;function isOurOverlayTag(e){if(e==null)return false;return renderedOverlayTags.has(e)}const HIGHLIGHT_OVERLAY_NATIVE_IDS=new Set(["highlight-updates-overlay","__rn_buoy__highlight-modal"]);const OTHER_DEV_TOOLS_NATIVE_IDS=new Set(["jsmodal-root","image-overlay-standalone","logbox_inspector","logbox"]);const devToolsNodeCache=new Map;const CACHE_MAX_SIZE=500;function clearDevToolsCache(){devToolsNodeCache.clear()}function isHighlightOverlayNativeID(e){if(!e)return false;if(HIGHLIGHT_OVERLAY_NATIVE_IDS.has(e))return true;if(e.startsWith("__highlight_"))return true;return false}function isOtherDevToolsNativeID(e){if(!e)return false;if(OTHER_DEV_TOOLS_NATIVE_IDS.has(e))return true;const n=e.charCodeAt(0);if(n===95){if(e.startsWith("__rn_buoy__"))return true}if(n===108&&e.startsWith("logbox")){return true}return false}function getComponentName(e){if(!e)return null;const n=e.type;if(n){if(typeof n==="string")return n;if(n.displayName)return n.displayName;if(n.name)return n.name}const r=e.elementType;if(r){if(r.displayName)return r.displayName;if(r.name)return r.name}return null}const INTERNAL_COMPONENT_NAMES=new Set(["View","Text","TextImpl","Image","ScrollView","FlatList","SectionList","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","Pressable","TextInput","Switch","ActivityIndicator","Modal","StatusBar","KeyboardAvoidingView","AnimatedComponent","AnimatedComponentWrapper","ScreenContainer","ScreenStack","Screen","ScreenContentWrapper","Svg","G","Path","Rect","Circle","Line","Polygon","Polyline","Ellipse","Text as SVGText","TSpan","TextPath","Use","Symbol","Defs","ClipPath","LinearGradient","RadialGradient","Stop","Mask","Pattern","Image as SVGImage","SafeAreaProvider","SafeAreaView","SafeAreaListener","GestureHandlerRootView","GestureDetector","ReanimatedView","ReanimatedText","ReanimatedImage","ReanimatedScrollView","Fragment","Suspense","Provider","Consumer","Context","ForwardRef"]);function isInternalComponent(e){if(!e)return true;if(INTERNAL_COMPONENT_NAMES.has(e))return true;if(e==="Unknown"||e==="Component")return true;if(e.startsWith("Animated"))return true;return false}function getOwningComponentName(e){if(!e)return null;let n=e._debugOwner||e.return;let r=0;let o=null;while(n&&r<30){const i=getComponentName(n);if(i&&typeof n.type!=="string"){if(!o){o=i}if(!isInternalComponent(i)){return i}}n=n.return;r++}return o}function isOurOverlayNode(e){const n=e;const r=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||(0,_utils.getDOMFiber)(n);const o=getNativeTag(e)||getNativeTag(n?.canonical?.publicInstance);const i=(0,_devtoolsComponentNames.isCapturingBuoyToolRenders)();const a=!i&&_RenderTracker.RenderTracker.getSettings().excludeDevTools;if(a&&(0,_utils.isDOMElement)(e)&&e.closest("[data-buoy-root]"))return true;if(o!=null&&a){const u=devToolsNodeCache.get(o);if(u!==void 0){return u}}let t=false;const l=r?.pendingProps?.nativeID||r?.memoizedProps?.nativeID||n?.canonical?.currentProps?.nativeID||null;if(isHighlightOverlayNativeID(l)){t=true}else if(a&&isOtherDevToolsNativeID(l)){t=true}if(!t&&r){let u=r;let m=0;while(u&&m<30){const s=getComponentName(u);if(s){if(_devtoolsComponentNames.HIGHLIGHT_OVERLAY_COMPONENTS.has(s)){t=true;break}for(const g of _devtoolsComponentNames.HIGHLIGHT_OVERLAY_PREFIXES){if(s.startsWith(g)){t=true;break}}if(t)break;if(i&&(0,_devtoolsComponentNames.isPerfMonitorComponentName)(s)){t=true;break}if(a){if(_devtoolsComponentNames.OTHER_DEV_TOOLS_COMPONENTS.has(s)||_devtoolsComponentNames.OTHER_DEV_TOOLS_EXACT.has(s)){t=true;break}for(const g of _devtoolsComponentNames.OTHER_DEV_TOOLS_PREFIXES){if(s.startsWith(g)){t=true;break}}if(t)break}}const d=u.pendingProps?.nativeID||u.memoizedProps?.nativeID;if(isHighlightOverlayNativeID(d)){t=true;break}if(a&&isOtherDevToolsNativeID(d)){t=true;break}u=u.return;m++}}if(t&&o!=null&&a){if(devToolsNodeCache.size>=CACHE_MAX_SIZE){const u=Array.from(devToolsNodeCache.keys());for(let m=0;m<CACHE_MAX_SIZE/2;m++){devToolsNodeCache.delete(u[m])}}devToolsNodeCache.set(o,t)}return t}function getColorForRenderCount(e){const n=Math.min(e-1,COLORS.length-1);return COLORS[Math.max(0,n)]}function handleTraceUpdates(e){if(e.size===0){return}if(!globalEnabled&&!backgroundTrackingEnabled){return}const n=_RenderTracker.RenderTracker.getState();if(n.isPaused){return}if(_PerformanceLogger.PerformanceLogger.isEnabled()){(0,_PerformanceLogger.markEventReceived)()}const r=_RenderTracker.RenderTracker.getBatchSize();const o=_PerformanceLogger.PerformanceLogger.startBatch(e.size,r);const i=[];let a=0;let t=0;const l=_RenderTracker.RenderTracker.hasActiveFilters();for(const s of e){if(s&&typeof s==="object"){try{if(isOurOverlayNode(s)){a++;continue}const d=getPublicInstance(s);const g=getNativeTag(s)||getNativeTag(d);if(g==null){continue}const h=extractComponentInfo(s);if(l&&!_RenderTracker.RenderTracker.passesFilters(h)){t++;continue}const v=_RenderTracker.RenderTracker.getSettings().showRenderCount;let p;let f;if(v){const c=nodeRenderCounts.get(g)||0;p=c+1;nodeRenderCounts.set(g,p);f=getColorForRenderCount(p)}else{p=0;f=COLORS[0]}i.push({node:s,color:f,count:p})}catch{}}}o.markFilteringComplete(a+t,i.length);if(i.length===0){o.finish();return}if(DEBUG_LOGGING){console.log("[Buoy]",`[HighlightUpdates] ${i.length} component(s) re-rendered`)}const u=_RenderTracker.RenderTracker.getRenderEventCallbackCount()>0;if(!highlightCallback&&!u){if(DEBUG_LOGGING){console.log("[Buoy]",`[HighlightUpdates] No highlightCallback and no event callbacks - skipping render`)}isProcessing=false;return}o.markMeasurementStart();const m=i.slice(0,r*4).map(({node:s,color:d,count:g})=>new Promise(h=>{let v=false;const p=b=>{if(v)return;v=true;clearTimeout(f);h(b)};const f=setTimeout(()=>p({rect:null,stateNode:s,color:d,count:g}),500);const c=getPublicInstance(s);const I=getNativeTag(s)||getNativeTag(c);if(I==null){p({rect:null,stateNode:s,color:d,count:g});return}const T=(b,_,y,w,D,C)=>{if(D==null||C==null||y==null||w==null){p({rect:null,stateNode:s,color:d,count:g});return}p({rect:{id:I,x:D,y:C,width:y,height:w,color:d,count:g},stateNode:s,color:d,count:g})};if(!c){const b=s.node;const _=globalThis.nativeFabricUIManager;if(b&&_?.measure){try{_.measure(b,T)}catch(y){p({rect:null,stateNode:s,color:d,count:g})}return}p({rect:null,stateNode:s,color:d,count:g});return}try{c.measure(T)}catch(b){p({rect:null,stateNode:s,color:d,count:g})}}));Promise.all(m).then(s=>{const d=s.filter(h=>h.rect!==null);const g=d.map(h=>h.rect);o.markMeasurementComplete(d.length,s.length-d.length);if(g.length>0&&highlightCallback&&globalEnabled&&!highlightsSuppressed){highlightCallback(g)}setTimeout(()=>{try{for(const f of d){if(f.rect)registerTrackedNode(f.rect.id,f.stateNode)}}catch(f){debugLog("registerTrackedNode batch failed",f)}const h=_RenderTracker.RenderTracker.getSettings();const v=h.trackRenderCauses&&h.showRenderCount;let p=null;if(v){p=new Set;for(const{rect:f}of d){if(f){p.add(f.id)}}}if(globalEnabled){_RenderTracker.RenderTracker.startBatch();for(const{rect:f,stateNode:c,color:I,count:T}of d){if(f){const b=extractComponentInfo(c);let _;if(v&&p){const y=c;const w=getFiberFromNode(y);_=(0,_RenderCauseDetector.detectRenderCause)(f.id,w,p,h.debugLogLevel)}_RenderTracker.RenderTracker.trackRender({nativeTag:f.id,viewType:b.viewType,testID:b.testID,nativeID:b.nativeID,accessibilityLabel:b.accessibilityLabel,componentName:b.componentName,measurements:{x:f.x,y:f.y,width:f.width,height:f.height},color:I,count:T,renderCause:_})}}_RenderTracker.RenderTracker.endBatch()}else{for(const{rect:f,stateNode:c,color:I,count:T}of d){if(f){const b=extractComponentInfo(c);let _;if(v&&p){const y=c;const w=getFiberFromNode(y);_=(0,_RenderCauseDetector.detectRenderCause)(f.id,w,p,h.debugLogLevel)}_RenderTracker.RenderTracker.emitRenderEvent({nativeTag:f.id,viewType:b.viewType,testID:b.testID,nativeID:b.nativeID,accessibilityLabel:b.accessibilityLabel,componentName:b.componentName,measurements:{x:f.x,y:f.y,width:f.width,height:f.height},color:I,count:T,renderCause:_})}}}o.markTrackingComplete();o.markCallbackComplete();o.finish()},0)}).catch(s=>{console.error("[Buoy]","[HighlightUpdates] Error in measurement pipeline:",s);o.finish()})}const WeakRefCtor=globalThis.WeakRef;const nodeRegistry=new Map;function registerTrackedNode(e,n){if(e==null||n==null||typeof n!=="object"){return}try{nodeRegistry.set(e,WeakRefCtor?new WeakRefCtor(n):{deref:()=>n})}catch{nodeRegistry.set(e,{deref:()=>n})}}function derefNode(e){const n=nodeRegistry.get(e);const r=n?.deref();if(!r)nodeRegistry.delete(e);return r??null}function measureNode(e){return new Promise(n=>{try{e.measure((r,o,i,a,t,l)=>{if(t==null||l==null||i==null||a==null){n(null)}else{n({x:t,y:l,width:i,height:a})}})}catch{n(null)}})}function getFiberFromNode(e){const n=e;return n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||(0,_utils.getDOMFiber)(n)||null}function findScrollAncestor(e){let n=getFiberFromNode(e);let r=0;while(n&&r++<200){const o=n.stateNode;if(o&&typeof o.scrollTo==="function"){const i=typeof o.getNativeScrollRef==="function"&&o.getNativeScrollRef()||null;const a=typeof o.getInnerViewNode==="function"&&o.getInnerViewNode()||typeof o.getScrollableNode==="function"&&o.getScrollableNode()||o;return{instance:o,nativeRef:i,innerNode:a}}n=n.return}return null}async function scrollDescendantIntoView(e,n,r){try{const o=findScrollAncestor(e);if(!o)return false;const i=n;let a=null;const t=l=>new Promise(u=>{let m=false;const s=g=>{if(m)return;m=true;u(g)};const d=setTimeout(()=>s(null),600);try{l(g=>{clearTimeout(d);s(g)})}catch{clearTimeout(d);s(null)}});if(o.nativeRef&&typeof i.measureLayout==="function"){a=await t(l=>i.measureLayout(o.nativeRef,(u,m)=>l(m),()=>l(null)))}if(a==null){const l=(0,_reactNative.findNodeHandle)(n);const u=typeof o.innerNode==="number"?o.innerNode:(0,_reactNative.findNodeHandle)(o.innerNode);if(l!=null&&u!=null){a=await t(m=>_reactNative.UIManager.measureLayout(l,u,()=>m(null),(s,d)=>m(d)))}}if(a==null)return false;o.instance.scrollTo({y:Math.max(0,a-r),animated:false});await new Promise(l=>setTimeout(l,80));return true}catch{return false}}function matchScore(e,n){const r=[e.testID,e.nativeID,e.accessibilityLabel,e.componentName,e.viewType,String(e.nativeTag)];let o=0;for(const i of r){if(!i)continue;const a=i.toLowerCase();if(a===n)return 3;if(a.startsWith(n))o=Math.max(o,2);else if(a.includes(n))o=Math.max(o,1)}return o}async function locateComponent(e){const n=e.scrollIntoView!==false;const r=typeof e.margin==="number"?e.margin:12;const o=_RenderTracker.RenderTracker.getRenders();const i=async()=>{const c=await(0,_screenElements.describeScreen)();const I=(e.query??"").trim().toLowerCase();let T;for(const y of c.elements){if(e.nativeTag!=null&&y.nativeTag===e.nativeTag){T={el:y,score:1e3};break}const w=(0,_tapMatch.scoreTapMatch)({nativeTag:y.nativeTag,testID:y.testID,label:y.label,text:y.text,name:y.name,tap:y.tap},{query:I||void 0,nativeTag:e.nativeTag});if(w<=0)continue;if(!T||w>T.score)T={el:y,score:w}}if(!T?.el.frame){return{matched:false,reason:"no-match",candidates:[]}}const b=c.screen;const _=T.el.frame;return{matched:true,live:true,rect:{x:_.x*b.width,y:_.y*b.height,width:_.width*b.width,height:_.height*b.height},scale:_reactNative.PixelRatio.get(),screen:{width:b.width,height:b.height},nativeTag:T.el.nativeTag??void 0,componentName:T.el.name,testID:T.el.testID}};if(o.length===0)return i();const a=(e.query??"").trim().toLowerCase();const t=a?o.map(c=>({r:c,score:matchScore(c,a)})).filter(c=>c.score>0).sort((c,I)=>I.score-c.score||I.r.lastRenderTime-c.r.lastRenderTime):[];const l=t.slice(0,8).map(({r:c})=>({nativeTag:c.nativeTag,componentName:c.componentName,testID:c.testID,nativeID:c.nativeID,viewType:c.viewType,renderCount:c.renderCount}));const u=e.nativeTag??(t.length>0?t[0].r.nativeTag:void 0);if(u==null){const c=await i();return c.matched?c:{matched:false,reason:"no-match",candidates:l}}const m=o.find(c=>c.nativeTag===u);let s=null;let d=false;let g=false;const h=derefNode(u);if(h){const c=getPublicInstance(h);if(c){if(n){g=await scrollDescendantIntoView(h,c,r)}s=await measureNode(c);d=!!s}}if(!s&&m?.measurements){s={...m.measurements}}if(!s){return{matched:false,reason:"no-measurement",nativeTag:u,candidates:l}}const v=_reactNative.PixelRatio.get();const p=_reactNative.Dimensions.get("window");const f=s.x>=-1&&s.y>=-1&&s.x+s.width<=p.width+1&&s.y+s.height<=p.height+1;return{matched:true,live:d,scrolled:g,inView:f,rect:s,scale:v,screen:{width:p.width,height:p.height},nativeTag:u,componentName:m?.componentName,testID:m?.testID,candidates:l}}function setTraceUpdatesOnRenderers(e){if(!hook?.rendererInterfaces){debugLog("No rendererInterfaces available");return}let n=0;hook.rendererInterfaces.forEach((r,o)=>{if(typeof r.setTraceUpdatesEnabled==="function"){try{r.setTraceUpdatesEnabled(e);n++;debugLog(`Renderer ${o}: setTraceUpdatesEnabled(${e})`)}catch(i){debugLog(`Renderer ${o}: error setting trace updates`,i)}}else{debugLog(`Renderer ${o}: no setTraceUpdatesEnabled method`)}});debugLog(`Set trace updates ${e?"enabled":"disabled"} on ${n} renderer(s)`);if(hook.reactDevtoolsAgent?.setTraceUpdatesEnabled){try{hook.reactDevtoolsAgent.setTraceUpdatesEnabled(e);debugLog("Also set trace updates on agent")}catch(r){debugLog("Error setting trace updates on agent",r)}}}function subscribeToTraceUpdates(){if(!hook)return;if(traceUpdatesUnsubscribe)return;debugLog("Subscribing to traceUpdates event");if(typeof hook.sub==="function"){traceUpdatesUnsubscribe=hook.sub("traceUpdates",handleTraceUpdates);debugLog("Subscribed using hook.sub()")}else{debugLog("hook.sub not available, traceUpdates may not work")}setTraceUpdatesOnRenderers(true)}function unsubscribeFromTraceUpdates(){setTraceUpdatesOnRenderers(false);if(traceUpdatesUnsubscribe){traceUpdatesUnsubscribe();traceUpdatesUnsubscribe=null;debugLog("Unsubscribed from traceUpdates event")}}function setHighlightCallback(e){highlightCallback=e;debugLog(`Highlight callback ${e?"set":"cleared"}`)}function setBadgePressCallback(e){badgePressCallback=e;debugLog(`Badge press callback ${e?"set":"cleared"}`)}function getBadgePressCallback(){return badgePressCallback}function handleBadgePress(e){if(badgePressCallback){badgePressCallback(e)}}let spotlightCallback=null;let currentSpotlightTag=null;function setSpotlightCallback(e){spotlightCallback=e;if(e&&currentSpotlightTag!==null){e(currentSpotlightTag)}}function setSpotlight(e){if(remoteHandler){remoteHandler("setSpotlight",{nativeTag:e});return}currentSpotlightTag=e;if(spotlightCallback){spotlightCallback(e)}}let remoteHandler=null;function setRemoteHandler(e){remoteHandler=e}function replaceRemoteState(e){if(globalEnabled!==e.enabled){globalEnabled=e.enabled;notifyStateListeners()}if(isFrozen!==e.frozen){isFrozen=e.frozen;notifyFreezeListeners()}}function getSpotlight(){return currentSpotlightTag}function notifyStateListeners(){stateListeners.forEach(e=>{try{e(globalEnabled)}catch(n){console.error("[Buoy]","[HighlightUpdates] Error in state listener:",n)}})}function subscribe(e){stateListeners.add(e);e(globalEnabled);return()=>{stateListeners.delete(e)}}function connectRenderSource(e){if(typeof __DEV__!=="undefined"&&!__DEV__){return{recordRenders:()=>{},disconnect:()=>{}}}if(renderSource!==void 0||initialized)throw new Error("Connect the render source before Highlight starts.");renderSource=e;let n=true;const r=new Set;initialize();return{recordRenders(o){if(!n||!e||!globalEnabled||_RenderTracker.RenderTracker.getState().isPaused)return;const i=[];_RenderTracker.RenderTracker.startBatch();try{for(const{host:a,name:t,count:l}of o){if(!a.isConnected)continue;const u=(0,_utils.getDOMNodeHandle)(a);if(u===null)continue;const m=(_RenderTracker.RenderTracker.getRender(String(u))?.renderCount??0)+l;const s=getColorForRenderCount(m);const{x:d,y:g,width:h,height:v}=a.getBoundingClientRect();const p={x:d,y:g,width:h,height:v};_RenderTracker.RenderTracker.trackRender({nativeTag:u,viewType:t,componentName:t,isComponent:true,testID:a.getAttribute("data-testid")??void 0,measurements:p,color:s,count:m});registerTrackedNode(u,a);r.add(u);if(h>0&&v>0)i.push({id:u,...p,color:s,count:_RenderTracker.RenderTracker.getSettings().showRenderCount?m:0})}}finally{_RenderTracker.RenderTracker.endBatch()}for(const a of r){if(!_RenderTracker.RenderTracker.getRender(String(a))){r.delete(a);nodeRegistry.delete(a)}}if(!highlightsSuppressed&&i.length)highlightCallback?.(i)},disconnect(){if(!n)return;n=false;disable();highlightCallback?.([]);clearRenderCounts();for(const o of r)nodeRegistry.delete(o);r.clear();renderSource=void 0;initialized=false}}}let renderSource;function getRenderSourceStatus(){return renderSource===void 0?void 0:renderSource?"ready":"unavailable"}function initialize(){if(typeof __DEV__!=="undefined"&&!__DEV__){debugLog("Only available in development builds");return false}if(remoteHandler){return true}if(initialized){return true}if(renderSource!==void 0){initialized=renderSource;exposeGlobally();return initialized}hook=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null;if(!hook){debugLog("React DevTools hook not found");return false}debugLog("Hook found");debugLog(`Hook has sub: ${typeof hook.sub==="function"}`);debugLog(`Hook has on: ${typeof hook.on==="function"}`);debugLog(`Hook has emit: ${typeof hook.emit==="function"}`);(0,_ProfilerInterceptor.installProfilerInterceptor)();if(hook.rendererInterfaces&&hook.rendererInterfaces.size>0){initialized=true;debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`);exposeGlobally();return true}const e=setInterval(()=>{if(hook?.rendererInterfaces&&hook.rendererInterfaces.size>0){clearInterval(e);initialized=true;debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`);exposeGlobally()}},100);setTimeout(()=>clearInterval(e),1e4);return false}function exposeGlobally(){if(typeof window!=="undefined"){window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable,disable,toggle,isEnabled,setEnabled,subscribe,initialize,destroy,isInitialized:()=>initialized,setHighlightCallback}}}function enable(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(renderSource===false)return;if(!initialized){initialize()}if(highlightsSuppressed){highlightsSuppressed=false}if(globalEnabled){return}debugLog("Enabling highlights");if(!backgroundTrackingEnabled){subscribeToTraceUpdates()}_RenderTracker.RenderTracker.start();globalEnabled=true;notifyStateListeners();(0,_sharedUi.notifySubscriberCountChange)("render")}function disable(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!globalEnabled){return}debugLog("Disabling highlights");renderingLock=false;isProcessing=false;if(renderingLockTimeout){clearTimeout(renderingLockTimeout);renderingLockTimeout=null}renderedOverlayTags.clear();devToolsNodeCache.clear();(0,_RenderCauseDetector.clearRenderCauseState)();if(isFrozen){isFrozen=false;notifyFreezeListeners()}if(!backgroundTrackingEnabled){unsubscribeFromTraceUpdates()}_RenderTracker.RenderTracker.stop();globalEnabled=false;notifyStateListeners();(0,_sharedUi.notifySubscriberCountChange)("render")}function enableBackgroundTracking(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(backgroundTrackingEnabled){return}if(!initialized){initialize()}debugLog("Enabling background tracking");if(!globalEnabled){subscribeToTraceUpdates()}backgroundTrackingEnabled=true}function disableBackgroundTracking(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!backgroundTrackingEnabled){return}debugLog("Disabling background tracking");backgroundTrackingEnabled=false;if(!globalEnabled){unsubscribeFromTraceUpdates()}}function isBackgroundTrackingEnabled(){return backgroundTrackingEnabled}function toggle(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(remoteHandler){remoteHandler("toggle");return}if(globalEnabled){disable()}else{enable()}}function clearRenderCounts(){if(remoteHandler){remoteHandler("clearRenderCounts");return}nodeRenderCounts.clear();_RenderTracker.RenderTracker.clear();debugLog("Cleared render counts")}function isEnabled(){return globalEnabled}function setEnabled(e){if(remoteHandler){remoteHandler("setEnabled",{enabled:e});return}if(e)enable();else disable()}function setHighlightsSuppressed(e){if(highlightsSuppressed===e)return;highlightsSuppressed=e;if(e&&highlightCallback){highlightCallback([])}}function getHighlightsSuppressed(){return highlightsSuppressed}function setSilentTracking(e){if(remoteHandler){remoteHandler("setSilentTracking",{enabled:e});return}if(e){enable();setHighlightsSuppressed(true)}else{setHighlightsSuppressed(false);disable()}}function isInitialized(){return initialized}function notifyFreezeListeners(){freezeListeners.forEach(e=>{try{e(isFrozen)}catch(n){console.error("[Buoy]","[HighlightUpdates] Error in freeze listener:",n)}})}function subscribeToFreeze(e){freezeListeners.add(e);e(isFrozen);return()=>{freezeListeners.delete(e)}}function freeze(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(isFrozen)return;isFrozen=true;debugLog("Freeze mode enabled");notifyFreezeListeners()}function unfreeze(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!isFrozen)return;isFrozen=false;debugLog("Freeze mode disabled");if(highlightCallback){highlightCallback([])}notifyFreezeListeners()}function toggleFreeze(){if(remoteHandler){remoteHandler("toggleFreeze");return}if(isFrozen){unfreeze()}else{freeze()}}function getFrozen(){return isFrozen}function destroy(){if(!initialized)return;unsubscribeFromTraceUpdates();(0,_ProfilerInterceptor.uninstallProfilerInterceptor)();(0,_ProfilerInterceptor.setComparisonCallback)(null);isFrozen=false;freezeListeners.clear();globalEnabled=false;hook=null;highlightCallback=null;initialized=false;if(typeof window!=="undefined"){delete window.__HIGHLIGHT_UPDATES_CONTROLLER__}debugLog("Destroyed")}const HighlightUpdatesController={connectRenderSource,getRenderSourceStatus,subscribe,enable,disable,toggle,isEnabled,setEnabled,initialize,destroy,isInitialized,setHighlightCallback,clearRenderCounts,freeze,unfreeze,toggleFreeze,getFrozen,subscribeToFreeze,setBadgePressCallback,getBadgePressCallback,handleBadgePress,setSpotlightCallback,setSpotlight,getSpotlight,clearDevToolsCache,enableBackgroundTracking,disableBackgroundTracking,isBackgroundTrackingEnabled,setRemoteHandler,replaceRemoteState,locateComponent,setHighlightsSuppressed,getHighlightsSuppressed,setSilentTracking};var _default=exports.default=HighlightUpdatesController;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.PerformanceLogger=void 0;exports.markEventReceived=markEventReceived;exports.markOverlayRendered=markOverlayRendered;let lastEventTimestamp=0;let pendingBatchId=null;function markEventReceived(){lastEventTimestamp=performance.now();return lastEventTimestamp}function markOverlayRendered(S,e){if(lastEventTimestamp>0&&S>0){lastEventTimestamp=0}}class PerformanceLoggerSingleton{enabled=false;batchCounter=0;listeners=new Set;rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0};recentBatches=[];MAX_HISTORY=100;summaryInterval=null;SUMMARY_INTERVAL_MS=1e4;setEnabled(e){const a=this.enabled;this.enabled=e;if(e&&!a){this.resetStats()}else if(!e&&a){this.stopSummaryInterval()}}isEnabled(){return this.enabled}startBatch(e,a){const r=`batch_${++this.batchCounter}`;const h=performance.now();let o=null;let l=null;let s=null;let i=null;let t=null;let n=0;let m=0;let u=0;let T=0;let g;const f={markFilteringComplete:(c,d)=>{o=performance.now();n=c;m=d},markMeasurementStart:()=>{l=performance.now()},markMeasurementComplete:(c,d)=>{s=performance.now();u=c;T=d},markTrackingComplete:()=>{i=performance.now()},markCallbackComplete:()=>{t=performance.now()},setOverlayRenderTime:c=>{g=c},getBatchId:()=>r,finish:()=>{const c=performance.now();const d={batchId:r,timestamp:Date.now(),nodesReceived:e,nodesFiltered:n,nodesToProcess:m,batchSize:a,nodesInBatch:Math.min(m,a),filteringTime:o?o-h:0,measurementTime:l&&s?s-l:0,trackingTime:s&&i?i-s:0,callbackTime:i&&t?t-i:0,totalTime:c-h,measurementSuccessCount:u,measurementFailCount:T,overlayRenderTime:g};if(this.enabled){this.recordMetrics(d)}return d}};return f}recordMetrics(e){this.rollingStats.batchCount++;this.rollingStats.totalNodes+=e.nodesReceived;this.rollingStats.totalFiltered+=e.nodesFiltered;this.rollingStats.totalProcessed+=e.nodesInBatch;this.rollingStats.totalTime+=e.totalTime;this.rollingStats.maxTime=Math.max(this.rollingStats.maxTime,e.totalTime);this.rollingStats.minTime=Math.min(this.rollingStats.minTime,e.totalTime);const a=this.rollingStats.avgMeasurementTime;const r=this.rollingStats.batchCount;this.rollingStats.avgMeasurementTime=a+(e.measurementTime-a)/r;this.recentBatches.push(e);if(this.recentBatches.length>this.MAX_HISTORY){this.recentBatches.shift()}this.notifyListeners(e)}logBatch(e){const{batchId:a,nodesReceived:r,nodesFiltered:h,nodesInBatch:o,batchSize:l,filteringTime:s,measurementTime:i,trackingTime:t,callbackTime:n,totalTime:m,measurementSuccessCount:u,measurementFailCount:T,overlayRenderTime:g}=e;console.log(`[HighlightPerf] ${a} | In:${r} Filt:${h} Proc:${o}/${l} | Filter:${s.toFixed(1)}ms Measure:${i.toFixed(1)}ms Track:${t.toFixed(1)}ms Callback:${n.toFixed(1)}ms | Total:${m.toFixed(1)}ms`+(g?` Render:${g.toFixed(1)}ms`:"")+` | Success:${u} Fail:${T}`);if(m>100){console.warn(`[HighlightPerf] \u26A0\uFE0F SLOW BATCH: ${m.toFixed(1)}ms - Measurement phase: ${i.toFixed(1)}ms (${(i/m*100).toFixed(0)}%)`)}}logSummary(){if(this.rollingStats.batchCount===0)return;const e=this.rollingStats;const a=e.totalTime/e.batchCount;const r=e.totalNodes/e.batchCount;console.log(`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.PerformanceLogger=void 0;exports.markEventReceived=markEventReceived;exports.markOverlayRendered=markOverlayRendered;let lastEventTimestamp=0;let pendingBatchId=null;function markEventReceived(){lastEventTimestamp=performance.now();return lastEventTimestamp}function markOverlayRendered(S,e){if(lastEventTimestamp>0&&S>0){lastEventTimestamp=0}}class PerformanceLoggerSingleton{enabled=false;batchCounter=0;listeners=new Set;rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0};recentBatches=[];MAX_HISTORY=100;summaryInterval=null;SUMMARY_INTERVAL_MS=1e4;setEnabled(e){const a=this.enabled;this.enabled=e;if(e&&!a){this.resetStats()}else if(!e&&a){this.stopSummaryInterval()}}isEnabled(){return this.enabled}startBatch(e,a){const r=`batch_${++this.batchCounter}`;const h=performance.now();let o=null;let l=null;let s=null;let i=null;let t=null;let n=0;let m=0;let g=0;let T=0;let u;const f={markFilteringComplete:(c,d)=>{o=performance.now();n=c;m=d},markMeasurementStart:()=>{l=performance.now()},markMeasurementComplete:(c,d)=>{s=performance.now();g=c;T=d},markTrackingComplete:()=>{i=performance.now()},markCallbackComplete:()=>{t=performance.now()},setOverlayRenderTime:c=>{u=c},getBatchId:()=>r,finish:()=>{const c=performance.now();const d={batchId:r,timestamp:Date.now(),nodesReceived:e,nodesFiltered:n,nodesToProcess:m,batchSize:a,nodesInBatch:Math.min(m,a),filteringTime:o?o-h:0,measurementTime:l&&s?s-l:0,trackingTime:s&&i?i-s:0,callbackTime:i&&t?t-i:0,totalTime:c-h,measurementSuccessCount:g,measurementFailCount:T,overlayRenderTime:u};if(this.enabled){this.recordMetrics(d)}return d}};return f}recordMetrics(e){this.rollingStats.batchCount++;this.rollingStats.totalNodes+=e.nodesReceived;this.rollingStats.totalFiltered+=e.nodesFiltered;this.rollingStats.totalProcessed+=e.nodesInBatch;this.rollingStats.totalTime+=e.totalTime;this.rollingStats.maxTime=Math.max(this.rollingStats.maxTime,e.totalTime);this.rollingStats.minTime=Math.min(this.rollingStats.minTime,e.totalTime);const a=this.rollingStats.avgMeasurementTime;const r=this.rollingStats.batchCount;this.rollingStats.avgMeasurementTime=a+(e.measurementTime-a)/r;this.recentBatches.push(e);if(this.recentBatches.length>this.MAX_HISTORY){this.recentBatches.shift()}this.notifyListeners(e)}logBatch(e){const{batchId:a,nodesReceived:r,nodesFiltered:h,nodesInBatch:o,batchSize:l,filteringTime:s,measurementTime:i,trackingTime:t,callbackTime:n,totalTime:m,measurementSuccessCount:g,measurementFailCount:T,overlayRenderTime:u}=e;console.log("[Buoy]",`[HighlightPerf] ${a} | In:${r} Filt:${h} Proc:${o}/${l} | Filter:${s.toFixed(1)}ms Measure:${i.toFixed(1)}ms Track:${t.toFixed(1)}ms Callback:${n.toFixed(1)}ms | Total:${m.toFixed(1)}ms`+(u?` Render:${u.toFixed(1)}ms`:"")+` | Success:${g} Fail:${T}`);if(m>100){console.warn("[Buoy]",`[HighlightPerf] \u26A0\uFE0F SLOW BATCH: ${m.toFixed(1)}ms - Measurement phase: ${i.toFixed(1)}ms (${(i/m*100).toFixed(0)}%)`)}}logSummary(){if(this.rollingStats.batchCount===0)return;const e=this.rollingStats;const a=e.totalTime/e.batchCount;const r=e.totalNodes/e.batchCount;console.log("[Buoy]",`
2
2
  [HighlightPerf] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 SUMMARY (last ${this.SUMMARY_INTERVAL_MS/1e3}s) \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
3
3
  Batches: ${e.batchCount}
4
4
  Avg nodes/batch: ${r.toFixed(1)} (filtered: ${(e.totalFiltered/e.batchCount).toFixed(1)})
@@ -6,7 +6,7 @@
6
6
  Avg measurement time: ${e.avgMeasurementTime.toFixed(1)}ms
7
7
  Min/Max time: ${e.minTime.toFixed(1)}ms / ${e.maxTime.toFixed(1)}ms
8
8
  \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9
- `);this.resetStats()}resetStats(){this.rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0}}startSummaryInterval(){this.stopSummaryInterval();this.summaryInterval=setInterval(()=>{this.logSummary()},this.SUMMARY_INTERVAL_MS)}stopSummaryInterval(){if(this.summaryInterval){clearInterval(this.summaryInterval);this.summaryInterval=null}}subscribe(e){this.listeners.add(e);return()=>{this.listeners.delete(e)}}notifyListeners(e){for(const a of this.listeners){try{a(e)}catch(r){console.error("[HighlightPerf] Error in metrics listener:",r)}}}getRecentBatches(){return[...this.recentBatches]}getRollingStats(){return{...this.rollingStats}}clear(){this.recentBatches=[];this.resetStats();this.batchCounter=0}generateReport(){const e=this.recentBatches;if(e.length===0){return"No performance data collected yet."}const a=e.reduce((t,n)=>t+n.totalTime,0);const r=a/e.length;const h=e.reduce((t,n)=>t+n.measurementTime,0);const o=h/e.length;const l=e.filter(t=>t.totalTime>100);const s=e.filter(t=>t.totalTime<20);const i=`
9
+ `);this.resetStats()}resetStats(){this.rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0}}startSummaryInterval(){this.stopSummaryInterval();this.summaryInterval=setInterval(()=>{this.logSummary()},this.SUMMARY_INTERVAL_MS)}stopSummaryInterval(){if(this.summaryInterval){clearInterval(this.summaryInterval);this.summaryInterval=null}}subscribe(e){this.listeners.add(e);return()=>{this.listeners.delete(e)}}notifyListeners(e){for(const a of this.listeners){try{a(e)}catch(r){console.error("[Buoy]","[HighlightPerf] Error in metrics listener:",r)}}}getRecentBatches(){return[...this.recentBatches]}getRollingStats(){return{...this.rollingStats}}clear(){this.recentBatches=[];this.resetStats();this.batchCounter=0}generateReport(){const e=this.recentBatches;if(e.length===0){return"No performance data collected yet."}const a=e.reduce((t,n)=>t+n.totalTime,0);const r=a/e.length;const h=e.reduce((t,n)=>t+n.measurementTime,0);const o=h/e.length;const l=e.filter(t=>t.totalTime>100);const s=e.filter(t=>t.totalTime<20);const i=`
10
10
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
11
11
  \u2551 HIGHLIGHT UPDATES PERFORMANCE REPORT \u2551
12
12
  \u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;exports.disableProfilerLogging=disableProfilerLogging;exports.enableProfilerLogging=enableProfilerLogging;exports.installProfilerInterceptor=installProfilerInterceptor;exports.isInterceptorInstalled=isInterceptorInstalled;exports.isLoggingEnabled=isLoggingEnabled;exports.logHookStructure=logHookStructure;exports.logRendererInterfaces=logRendererInterfaces;exports.setComparisonCallback=setComparisonCallback;exports.uninstallProfilerInterceptor=uninstallProfilerInterceptor;let originalHookEmit=null;let originalAgentEmit=null;let isInstalled=false;let loggingEnabled=false;let comparisonCallback=null;function describeNode(n){if(!n)return{type:"null"};const e=n;const t={};if(e.canonical){t.type="Fabric";const o=e.canonical;if(o.publicInstance){const r=o.publicInstance;t.hasMeasure=typeof r.measure==="function";t.nativeTag=r.__nativeTag??r._nativeTag??"unknown"}}else if(typeof e.measure==="function"){t.type="Legacy";t.hasMeasure=true;t.nativeTag=e.__nativeTag??e._nativeTag??e.nativeTag??"unknown"}else{t.type="Unknown";t.keys=Object.keys(e).slice(0,10)}return t}function swizzleHookEmit(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n||typeof n.emit!=="function"){return}if(originalHookEmit){return}originalHookEmit=n.emit.bind(n);n.emit=function(e,...t){if(e==="traceUpdates"&&loggingEnabled){const o=t[0];if(o.size>0){console.log(`[PROFILER] traceUpdates: ${o.size} nodes`,Array.from(o).map((r,i)=>({index:i,...describeNode(r)})))}if(comparisonCallback){comparisonCallback(o)}}return originalHookEmit(e,...t)}}function swizzleAgentEmit(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;const e=n?.reactDevtoolsAgent;if(!e||typeof e.emit!=="function"){return}if(originalAgentEmit){return}originalAgentEmit=e.emit.bind(e);e.emit=function(t,...o){if(loggingEnabled&&t==="drawTraceUpdates"){const r=o[0];if(r.length>0){console.log(`[PROFILER] drawTraceUpdates: ${r.length} nodes`,r.map((i,l)=>({index:l,color:i.color,...describeNode(i.node)})))}}return originalAgentEmit(t,...o)}}function logRendererInterfaces(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces){console.log("[ProfilerInterceptor] No rendererInterfaces available");return}const e=[];n.rendererInterfaces.forEach((t,o)=>{const r=Object.keys(t).filter(i=>typeof t[i]==="function");e.push({id:o,hasSetTraceUpdatesEnabled:typeof t.setTraceUpdatesEnabled==="function",methods:r.slice(0,20)})});console.log(`[ProfilerInterceptor] Found ${n.rendererInterfaces.size} renderer interface(s)`,e)}function logHookStructure(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n){console.log("[ProfilerInterceptor] No hook available");return}const e={};for(const t in n){const o=n[t];if(typeof o==="function"){e[t]="function"}else if(o instanceof Map){e[t]=`Map(${o.size})`}else if(o instanceof Set){e[t]=`Set(${o.size})`}else if(typeof o==="object"&&o!==null){e[t]="object"}else{e[t]=typeof o}}console.log("[ProfilerInterceptor] Hook structure:",e)}function enableTracingOnAllRenderers(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces){return}n.rendererInterfaces.forEach(e=>{if(typeof e.setTraceUpdatesEnabled==="function"){try{e.setTraceUpdatesEnabled(true)}catch{}}})}function disableTracingOnAllRenderers(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces)return;n.rendererInterfaces.forEach(e=>{if(typeof e.setTraceUpdatesEnabled==="function"){try{e.setTraceUpdatesEnabled(false)}catch{}}})}function setComparisonCallback(n){comparisonCallback=n}function installProfilerInterceptor(){if(typeof __DEV__!=="undefined"&&!__DEV__){return}if(isInstalled){return}swizzleHookEmit();swizzleAgentEmit();isInstalled=true}function uninstallProfilerInterceptor(){if(!isInstalled)return;const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(originalHookEmit&&n){n.emit=originalHookEmit;originalHookEmit=null}if(originalAgentEmit&&n?.reactDevtoolsAgent){n.reactDevtoolsAgent.emit=originalAgentEmit;originalAgentEmit=null}disableTracingOnAllRenderers();comparisonCallback=null;isInstalled=false}function isInterceptorInstalled(){return isInstalled}function enableProfilerLogging(){loggingEnabled=true}function disableProfilerLogging(){loggingEnabled=false}function isLoggingEnabled(){return loggingEnabled}var _default=exports.default={install:installProfilerInterceptor,uninstall:uninstallProfilerInterceptor,isInstalled:isInterceptorInstalled,setComparisonCallback,enableTracing:enableTracingOnAllRenderers,disableTracing:disableTracingOnAllRenderers,enableLogging:enableProfilerLogging,disableLogging:disableProfilerLogging,isLoggingEnabled};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;exports.disableProfilerLogging=disableProfilerLogging;exports.enableProfilerLogging=enableProfilerLogging;exports.installProfilerInterceptor=installProfilerInterceptor;exports.isInterceptorInstalled=isInterceptorInstalled;exports.isLoggingEnabled=isLoggingEnabled;exports.logHookStructure=logHookStructure;exports.logRendererInterfaces=logRendererInterfaces;exports.setComparisonCallback=setComparisonCallback;exports.uninstallProfilerInterceptor=uninstallProfilerInterceptor;let originalHookEmit=null;let originalAgentEmit=null;let isInstalled=false;let loggingEnabled=false;let comparisonCallback=null;function describeNode(n){if(!n)return{type:"null"};const e=n;const t={};if(e.canonical){t.type="Fabric";const o=e.canonical;if(o.publicInstance){const r=o.publicInstance;t.hasMeasure=typeof r.measure==="function";t.nativeTag=r.__nativeTag??r._nativeTag??"unknown"}}else if(typeof e.measure==="function"){t.type="Legacy";t.hasMeasure=true;t.nativeTag=e.__nativeTag??e._nativeTag??e.nativeTag??"unknown"}else{t.type="Unknown";t.keys=Object.keys(e).slice(0,10)}return t}function swizzleHookEmit(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n||typeof n.emit!=="function"){return}if(originalHookEmit){return}originalHookEmit=n.emit.bind(n);n.emit=function(e,...t){if(e==="traceUpdates"&&loggingEnabled){const o=t[0];if(o.size>0){console.log("[Buoy]",`[PROFILER] traceUpdates: ${o.size} nodes`,Array.from(o).map((r,i)=>({index:i,...describeNode(r)})))}if(comparisonCallback){comparisonCallback(o)}}return originalHookEmit(e,...t)}}function swizzleAgentEmit(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;const e=n?.reactDevtoolsAgent;if(!e||typeof e.emit!=="function"){return}if(originalAgentEmit){return}originalAgentEmit=e.emit.bind(e);e.emit=function(t,...o){if(loggingEnabled&&t==="drawTraceUpdates"){const r=o[0];if(r.length>0){console.log("[Buoy]",`[PROFILER] drawTraceUpdates: ${r.length} nodes`,r.map((i,l)=>({index:l,color:i.color,...describeNode(i.node)})))}}return originalAgentEmit(t,...o)}}function logRendererInterfaces(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces){console.log("[Buoy]","[ProfilerInterceptor] No rendererInterfaces available");return}const e=[];n.rendererInterfaces.forEach((t,o)=>{const r=Object.keys(t).filter(i=>typeof t[i]==="function");e.push({id:o,hasSetTraceUpdatesEnabled:typeof t.setTraceUpdatesEnabled==="function",methods:r.slice(0,20)})});console.log("[Buoy]",`[ProfilerInterceptor] Found ${n.rendererInterfaces.size} renderer interface(s)`,e)}function logHookStructure(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n){console.log("[Buoy]","[ProfilerInterceptor] No hook available");return}const e={};for(const t in n){const o=n[t];if(typeof o==="function"){e[t]="function"}else if(o instanceof Map){e[t]=`Map(${o.size})`}else if(o instanceof Set){e[t]=`Set(${o.size})`}else if(typeof o==="object"&&o!==null){e[t]="object"}else{e[t]=typeof o}}console.log("[Buoy]","[ProfilerInterceptor] Hook structure:",e)}function enableTracingOnAllRenderers(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces){return}n.rendererInterfaces.forEach(e=>{if(typeof e.setTraceUpdatesEnabled==="function"){try{e.setTraceUpdatesEnabled(true)}catch{}}})}function disableTracingOnAllRenderers(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces)return;n.rendererInterfaces.forEach(e=>{if(typeof e.setTraceUpdatesEnabled==="function"){try{e.setTraceUpdatesEnabled(false)}catch{}}})}function setComparisonCallback(n){comparisonCallback=n}function installProfilerInterceptor(){if(typeof __DEV__!=="undefined"&&!__DEV__){return}if(isInstalled){return}swizzleHookEmit();swizzleAgentEmit();isInstalled=true}function uninstallProfilerInterceptor(){if(!isInstalled)return;const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(originalHookEmit&&n){n.emit=originalHookEmit;originalHookEmit=null}if(originalAgentEmit&&n?.reactDevtoolsAgent){n.reactDevtoolsAgent.emit=originalAgentEmit;originalAgentEmit=null}disableTracingOnAllRenderers();comparisonCallback=null;isInstalled=false}function isInterceptorInstalled(){return isInstalled}function enableProfilerLogging(){loggingEnabled=true}function disableProfilerLogging(){loggingEnabled=false}function isLoggingEnabled(){return loggingEnabled}var _default=exports.default={install:installProfilerInterceptor,uninstall:uninstallProfilerInterceptor,isInstalled:isInterceptorInstalled,setComparisonCallback,enableTracing:enableTracingOnAllRenderers,disableTracing:disableTracingOnAllRenderers,enableLogging:enableProfilerLogging,disableLogging:disableProfilerLogging,isLoggingEnabled};
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.capturePropsSnapshot=capturePropsSnapshot;exports.captureStateSnapshot=captureStateSnapshot;exports.clearRenderCauseState=clearRenderCauseState;exports.detectRenderCause=detectRenderCause;exports.getRenderCauseStats=getRenderCauseStats;exports.removeRenderCauseState=removeRenderCauseState;exports.safeCloneForHistory=safeCloneForHistory;var _ownStateChanged=require("./ownStateChanged");const COMPONENT_PROP_CONFIGS={RCTText:{alwaysTrack:["children"],skip:[],description:"Text component - children is the displayed content"},RCTVirtualText:{alwaysTrack:["children"],skip:[],description:"Virtual Text (nested) - children is the displayed content"},RCTView:{alwaysTrack:[],skip:["children"],description:"View container - children are React elements"},RCTImageView:{alwaysTrack:["source"],skip:["children"],description:"Image - source contains the image URL/require"},RCTTextInput:{alwaysTrack:["value","defaultValue"],skip:["children"],description:"TextInput - value is the input content"},RCTSwitch:{alwaysTrack:["value"],skip:["children"],description:"Switch - value is the toggle state"},default:{alwaysTrack:[],skip:["children"],description:"Unknown component type"}};function getComponentPropConfig(e){if(!e)return COMPONENT_PROP_CONFIGS.default;return COMPONENT_PROP_CONFIGS[e]||COMPONENT_PROP_CONFIGS.default}const componentFiberStates=new WeakMap;function getComponentFiberPrevState(e){if(!e)return void 0;let t=componentFiberStates.get(e);if(t)return t;if(e.alternate){t=componentFiberStates.get(e.alternate);if(t)return t}return void 0}function setComponentFiberState(e,t){if(!e)return;componentFiberStates.set(e,t);if(e.alternate){componentFiberStates.set(e.alternate,t)}}const previousStates=new Map;const MAX_STORED_STATES=500;const MAX_CHANGED_KEYS=10;const MAX_HOOK_DEPTH=50;const MAX_PARENT_DEPTH=50;const INTERNAL_COMPONENT_NAMES=new Set(["View","Text","TextImpl","Image","ScrollView","FlatList","SectionList","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","Pressable","TextInput","Switch","ActivityIndicator","Modal","StatusBar","KeyboardAvoidingView","AnimatedComponent","AnimatedComponentWrapper","Fragment","Suspense","Provider","Consumer","Context","ForwardRef","Unknown","Component"]);function isInternalComponentName(e){if(!e)return true;if(INTERNAL_COMPONENT_NAMES.has(e))return true;if(e.startsWith("Animated"))return true;return false}function getOwningComponentFiber(e){if(!e)return null;let t=e._debugOwner||e.return;let o=0;let r=null;while(t&&o<30){const n=t.tag;if(n===0||n===1||n===11||n===15){const s=getComponentNameFromFiber(t);if(!r){r=t}if(!isInternalComponentName(s)){return t}}t=t.return;o++}return r}function getComponentNameFromFiber(e){if(!e)return null;const t=e.type;if(t){if(typeof t==="string")return t;if(t.name)return t.name;if(t.displayName)return t.displayName}return null}function detectHookType(e){if(!e||typeof e!=="object"){return"unknown"}if(e.queue!==null&&e.queue!==void 0){return"useState"}const t=e.memoizedState;if(t!==null&&typeof t==="object"&&!Array.isArray(t)&&"current"in t&&Object.keys(t).length===1){return"useRef"}if(Array.isArray(t)&&t.length===2){const[,o]=t;if(Array.isArray(o)||o===null){if(typeof t[0]==="function"){return"useCallback"}return"useMemo"}}if(t!==null&&typeof t==="object"&&!Array.isArray(t)&&("tag"in t||"create"in t||"destroy"in t)){return"useEffect"}return"unknown"}function extractHookValue(e,t){const o=e?.memoizedState;switch(t){case"useState":case"useReducer":return o;case"useRef":return o?.current;case"useMemo":case"useCallback":return Array.isArray(o)?o[0]:o;case"useEffect":return"[effect]";default:return o}}function extractHookStates(e){if(!e?.memoizedState)return null;const t=e.memoizedState;if(typeof t!=="object"||t===null){return null}if(!("next"in t)&&!("queue"in t)&&!("memoizedState"in t)){return null}const o=[];let r=t;let n=0;while(r!==null&&n<MAX_HOOK_DEPTH){const s=detectHookType(r);const l=extractHookValue(r,s);o.push({index:n,type:s,value:l,rawState:r.memoizedState});r=r.next;n++}return o.length>0?o:null}function compareHookStates(e,t){if(!e||!t)return null;const o=[];const r=Math.max(e.length,t.length);for(let n=0;n<r;n++){const s=e[n];const l=t[n];if(!s&&l){o.push({index:n,type:l.type,currentValue:formatHookValue(l.value,l.type),description:`Hook[${n}] added`});continue}if(s&&!l){o.push({index:n,type:s.type,previousValue:formatHookValue(s.value,s.type),description:`Hook[${n}] removed`});continue}if(s&&l){if(s.rawState===l.rawState){continue}if(l.type==="useEffect"){continue}if(l.type==="useMemo"||l.type==="useCallback"){continue}if(l.type==="useState"||l.type==="useReducer"||l.type==="useRef"){const a=formatHookValue(s.value,s.type);const i=formatHookValue(l.value,l.type);o.push({index:n,type:l.type,previousValue:a,currentValue:i,description:`${a} \u2192 ${i}`})}}}return o.length>0?o:null}function formatHookValue(e,t){if(t==="useRef"){return formatDisplayValue(e)}return formatDisplayValue(e)}function formatDisplayValue(e){if(e===null)return null;if(e===void 0)return void 0;if(typeof e==="boolean")return e;if(typeof e==="number")return e;if(typeof e==="string"){return e.length>30?e.slice(0,30)+"...":e}if(typeof e==="function"){return`[Function: ${e.name||"anonymous"}]`}if(Array.isArray(e)){return`[Array: ${e.length} items]`}if(typeof e==="object"){const t=Object.keys(e);return`{Object: ${t.length} keys}`}return String(e)}function detectComponentCause(e){if(!e)return{cause:"unknown",hookChanges:null};let t=e;let o=e.alternate;const r=getComponentFiberPrevState(e);if(r&&o){const u=extractHookStates(e);const h=extractHookStates(o);const g=r.extractedHooks;if(u&&h&&g&&g.length>0){const m=g.find(f=>f.type==="useState");if(m){const f=u.find(d=>d.index===m.index);const S=h.find(d=>d.index===m.index);if(f&&S){const d=f.value===m.value;const p=S.value===m.value;if(d&&!p){t=o;o=e}}}}}const n=extractHookStates(t);let s=null;let l=null;let a=null;if(o){s=o.memoizedProps;l=o.memoizedState;a=extractHookStates(o)}else{if(r){s=r.memoizedProps;l=r.memoizedState;a=r.extractedHooks}}setComponentFiberState(t,{memoizedProps:t.memoizedProps,memoizedState:t.memoizedState,extractedHooks:n});if(s===null){return{cause:"mount",hookChanges:null}}const i=!shallowEqual(s,t.memoizedProps);if(i){return{cause:"props",hookChanges:null}}if((0,_ownStateChanged.hookStateChanged)(l,t.memoizedState,{isClassComponent:t.tag===1})){const u=compareHookStates(a,n);return{cause:"state",hookChanges:u}}return{cause:"parent",hookChanges:null}}function shallowEqual(e,t){if(e===t)return true;if(!e||!t)return false;if(typeof e!=="object"||typeof t!=="object")return false;const o=Object.keys(e);const r=Object.keys(t);if(o.length!==r.length)return false;for(const n of o){if(e[n]!==t[n])return false}return true}function safeStringify(e,t=3){const o=new WeakSet;function r(n,s){if(s>t)return"[MAX_DEPTH]";if(n===null)return null;if(n===void 0)return void 0;if(typeof n==="function")return`[Function: ${n.name||"anonymous"}]`;if(typeof n==="symbol")return`[Symbol: ${n.toString()}]`;if(typeof n!=="object")return n;if(o.has(n))return"[Circular]";o.add(n);if(Array.isArray(n)){return n.slice(0,10).map(i=>r(i,s+1))}const l={};const a=Object.keys(n).slice(0,20);for(const i of a){try{l[i]=r(n[i],s+1)}catch{l[i]="[Error accessing]"}}return l}return r(e,0)}function logRawFiberData(e,t,o,r,n,s){const l=getComponentNameFromFiber(o)||"Unknown";console.log("\n========================================");console.log("[RN-BUOY DEBUG] RENDER EVENT");console.log("========================================");console.log(`Native Tag: ${e}`);console.log(`Component Name: ${l}`);console.log(`Is First Render: ${!r}`);console.log(`Component Cause Detected: ${s}`);console.log("----------------------------------------");console.log("\n--- NATIVE FIBER (Host Component) ---");console.log("fiber.type:",t?.type);console.log("fiber.tag:",t?.tag);console.log("fiber.memoizedProps (CURRENT):",safeStringify(t?.memoizedProps));console.log("fiber.memoizedState:",safeStringify(t?.memoizedState));if(r){console.log("PREVIOUS memoizedProps:",safeStringify(r.memoizedProps));console.log("PREVIOUS memoizedState:",safeStringify(r.memoizedState))}console.log("\n--- COMPONENT FIBER (React Component) ---");if(o){console.log("componentFiber.type:",o?.type?.name||o?.type);console.log("componentFiber.tag:",o?.tag);console.log("componentFiber.memoizedProps:",safeStringify(o?.memoizedProps));console.log("componentFiber.memoizedState:",safeStringify(o?.memoizedState));console.log("\n--- HOOKS STATE (linked list walk) ---");let i=o?.memoizedState;let u=0;while(i&&u<10){console.log(`Hook[${u}]:`,safeStringify({memoizedState:i.memoizedState,baseState:i.baseState,queue:i.queue?"[Queue object]":null}));i=i.next;u++}console.log("\n--- EXTRACTED HOOKS (Phase 3) ---");const h=extractHookStates(o);if(h){for(const g of h){console.log(`Hook[${g.index}] (${g.type}):`,formatDisplayValue(g.value))}}else{console.log("(No hooks extracted)")}}else{console.log("(No component fiber found)")}console.log("\n--- CHILDREN/TEXT CONTENT ---");const a=t?.memoizedProps?.children;console.log("children type:",typeof a);console.log("children value:",safeStringify(a));console.log("\n========================================\n")}function getTagName(e){if(e===void 0)return"undefined";const t={0:"FunctionComponent",1:"ClassComponent",2:"IndeterminateComponent",3:"HostRoot",4:"HostPortal",5:"HostComponent",6:"HostText",7:"Fragment",8:"Mode",9:"ContextConsumer",10:"ContextProvider",11:"ForwardRef",12:"Profiler",13:"SuspenseComponent",14:"MemoComponent",15:"SimpleMemoComponent"};return t[e]||`Unknown(${e})`}function logMinimal(e,t){if(!t.hookChanges||t.hookChanges.length===0){return}for(const o of t.hookChanges){console.log(`[${e||"Unknown"}] ${o.type}[${o.index}]: ${o.previousValue} \u2192 ${o.currentValue}`)}}function logVerbose(e,t,o,r,n){const s=getComponentNameFromFiber(o)||"Unknown";const l=typeof t?.type==="string"?t.type:"Unknown";const{cause:a,hookChanges:i}=r;console.log(`[RENDER] ${s} (${l}:${e}) | Cause: ${a.toUpperCase()}`+(n&&n.length>0?` | Props: [${n.join(", ")}]`:""));if(i&&i.length>0){for(const u of i){console.log(` \u2514\u2500 ${u.type}[${u.index}]: ${u.previousValue} \u2192 ${u.currentValue}`)}}}function logComprehensiveRenderData(e,t,o,r,n,s,l){const a=getComponentNameFromFiber(o)||"Unknown";const i=typeof t?.type==="string"?t.type:"Unknown";console.log(`
2
- [RN-BUOY RENDER DEBUG] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);console.log(`Render #${l} for ${i} (nativeTag: ${e})`);console.log(`Timestamp: ${new Date().toISOString()}`);console.log(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
3
- `);console.log(`NATIVE FIBER (${i}):`);console.log(` type: "${t?.type}"`);console.log(` tag: ${t?.tag} (${getTagName(t?.tag)})`);const u=t?.alternate;const h=u?"alternate":r?"storage":"none";console.log(` Previous values source: ${h}`);const g=t?.memoizedProps?.children;const m=u?.memoizedProps?.children;const f=m!==void 0?m:r?.memoizedProps?.children;const S=f!==void 0?g!==f:false;console.log(` memoizedProps.children: ${formatDisplayValue(g)}${S?` (was: ${formatDisplayValue(f)})`:f!==void 0?" (unchanged)":" (first render)"}`);const d=t?.memoizedProps?.style;const p=u?.memoizedProps?.style;const $=p!==void 0?p:r?.memoizedProps?.style;const _=$!==void 0?d!==$:false;if(d){console.log(` memoizedProps.style: ${JSON.stringify(safeStringify(d,2))}${_?" (REFERENCE CHANGED)":""}`);if(_&&$){const c=deepEqual(d,$);console.log(` \u2514\u2500 Values actually changed: ${!c}`)}}console.log(` All memoizedProps keys: [${Object.keys(t?.memoizedProps||{}).join(", ")}]`);const C=t?.memoizedProps?.testID;const O=t?.memoizedProps?.nativeID;const A=t?.memoizedProps?.accessibilityLabel;if(C)console.log(` testID: "${C}"`);if(O)console.log(` nativeID: "${O}"`);if(A)console.log(` accessibilityLabel: "${A}"`);console.log(` alternate: ${u?"YES":"NO"}`);if(u){console.log(` alternate.memoizedProps.children: ${formatDisplayValue(m)}`)}console.log(` Tree structure:`);console.log(` return (parent): ${t?.return?getTagName(t.return.tag):"null"}`);console.log(` child: ${t?.child?getTagName(t.child.tag):"null"}`);console.log(` sibling: ${t?.sibling?getTagName(t.sibling.tag):"null"}`);console.log("");console.log(`COMPONENT FIBER (${a}):`);if(o){console.log(` name: "${a}"`);console.log(` type: ${typeof o.type} (${o.type?.name||o.type?.displayName||"anonymous"})`);console.log(` tag: ${o.tag} (${getTagName(o.tag)})`);console.log(` memoizedProps: ${JSON.stringify(safeStringify(o.memoizedProps,2))}`);console.log(` alternate: ${o.alternate?"YES":"NO"}`);if(o.alternate){console.log(` ALTERNATE memoizedProps: ${JSON.stringify(safeStringify(o.alternate.memoizedProps,2))}`);const P=!shallowEqual(o.alternate.memoizedProps,o.memoizedProps);console.log(` Props changed (vs alternate): ${P?"YES":"NO"}`);console.log(` ALTERNATE memoizedState: ${o.alternate.memoizedState===o.memoizedState?"SAME":"DIFFERENT"}`)}const c=getComponentFiberPrevState(o);if(c){console.log(` WeakMap PREVIOUS memoizedProps: ${JSON.stringify(safeStringify(c.memoizedProps,2))}`);const P=!shallowEqual(c.memoizedProps,o.memoizedProps);console.log(` Props changed (vs WeakMap): ${P?"YES":"NO"}`)}else{console.log(` WeakMap PREVIOUS state: (not found - first render or WeakMap cleared)`)}if(o._debugOwner){const P=getComponentNameFromFiber(o._debugOwner);console.log(` _debugOwner: "${P}"`);let E=o._debugOwner;let T=1;while(E&&T<5){const x=getComponentNameFromFiber(E);console.log(` \u2514\u2500[${T}] ${x||"unknown"} (tag: ${E.tag})`);E=E._debugOwner;T++}}let y=0;let z=t._debugOwner||t.return;while(z&&z!==o&&y<30){z=z.return;y++}console.log(` Depth from native fiber: ${y}`)}else{console.log(` (No component fiber found - could not walk up tree)`)}console.log("");console.log(`HOOKS:`);if(o?.memoizedState){const c=extractHookStates(o);const y=o.alternate?extractHookStates(o.alternate):null;const z=getComponentFiberPrevState(o);const P=y||z?.extractedHooks;const E=y?"alternate":z?"WeakMap":"none";if(c&&c.length>0){console.log(` Total hooks: ${c.length}`);console.log(` Previous values source: ${E}`);c.forEach((T,x)=>{const H=P?.[x];const M=H?H.rawState!==T.rawState:false;const I=H?formatDisplayValue(H.value):"N/A";const D=M?" \u2190 CHANGED":"";console.log(` [${x}] ${T.type}: ${formatDisplayValue(T.value)}${H?` (was: ${I})`:" (first render)"}${D}`)})}else{console.log(` (Could not extract hooks - memoizedState structure not recognized)`);console.log(` Raw memoizedState type: ${typeof o.memoizedState}`);console.log(` Has 'next' property: ${"next"in(o.memoizedState||{})}`);console.log(` Has 'queue' property: ${"queue"in(o.memoizedState||{})}`)}}else{console.log(` (No memoizedState - class component, no hooks, or not a function component)`)}console.log("");console.log(`RAW HOOKS DATA:`);if(o?.memoizedState&&typeof o.memoizedState==="object"){let c=o.memoizedState;let y=0;while(c&&y<10){console.log(` Hook[${y}]:`);console.log(` memoizedState: ${safeStringify(c.memoizedState,2)}`);console.log(` baseState: ${safeStringify(c.baseState,2)}`);console.log(` queue: ${c.queue?"[Queue present]":"null"}`);console.log(` next: ${c.next?"[Next hook]":"null"}`);c=c.next;y++}if(y===0){console.log(` (memoizedState is not a hooks linked list)`)}}console.log("");console.log(`DETECTION RESULTS:`);console.log(` Component Cause: ${n.cause.toUpperCase()}`);if(n.hookChanges&&n.hookChanges.length>0){console.log(` Hook Changes Detected:`);n.hookChanges.forEach(c=>{console.log(` [${c.index}] ${c.type}: ${c.previousValue} \u2192 ${c.currentValue}`);if(c.description){console.log(` ${c.description}`)}})}const k=typeof t?.type==="string"?t.type:void 0;const R=getChangedKeys(r?.memoizedProps,t?.memoizedProps,k);if(R&&R.length>0){console.log(` Native Props Changed: [${R.join(", ")}]`)}else if(r){console.log(` Native Props Changed: (none detected)`)}console.log("");console.log(`BATCH CONTEXT:`);console.log(` Batch size: ${s.size}`);console.log(` All tags in batch: [${Array.from(s).slice(0,20).join(", ")}${s.size>20?"...":""}]`);const N=getParentNativeTag(t);const w=N!==null&&s.has(N);console.log(` Parent nativeTag: ${N??"not found"}`);console.log(` Parent in batch: ${w?"YES":"NO"}`);if(s.size>1){console.log(` Components in same batch:`);let c=t?.return;let y=0;while(c&&y<10){const z=getNativeTagFromStateNode(c.stateNode);if(z!==null&&s.has(z)){const P=getComponentNameFromFiber(c)||c.type;console.log(` [depth ${y}] ${P} (tag: ${z})`)}c=c.return;y++}}console.log(`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.capturePropsSnapshot=capturePropsSnapshot;exports.captureStateSnapshot=captureStateSnapshot;exports.clearRenderCauseState=clearRenderCauseState;exports.detectRenderCause=detectRenderCause;exports.getRenderCauseStats=getRenderCauseStats;exports.removeRenderCauseState=removeRenderCauseState;exports.safeCloneForHistory=safeCloneForHistory;var _ownStateChanged=require("./ownStateChanged");const COMPONENT_PROP_CONFIGS={RCTText:{alwaysTrack:["children"],skip:[],description:"Text component - children is the displayed content"},RCTVirtualText:{alwaysTrack:["children"],skip:[],description:"Virtual Text (nested) - children is the displayed content"},RCTView:{alwaysTrack:[],skip:["children"],description:"View container - children are React elements"},RCTImageView:{alwaysTrack:["source"],skip:["children"],description:"Image - source contains the image URL/require"},RCTTextInput:{alwaysTrack:["value","defaultValue"],skip:["children"],description:"TextInput - value is the input content"},RCTSwitch:{alwaysTrack:["value"],skip:["children"],description:"Switch - value is the toggle state"},default:{alwaysTrack:[],skip:["children"],description:"Unknown component type"}};function getComponentPropConfig(e){if(!e)return COMPONENT_PROP_CONFIGS.default;return COMPONENT_PROP_CONFIGS[e]||COMPONENT_PROP_CONFIGS.default}const componentFiberStates=new WeakMap;function getComponentFiberPrevState(e){if(!e)return void 0;let t=componentFiberStates.get(e);if(t)return t;if(e.alternate){t=componentFiberStates.get(e.alternate);if(t)return t}return void 0}function setComponentFiberState(e,t){if(!e)return;componentFiberStates.set(e,t);if(e.alternate){componentFiberStates.set(e.alternate,t)}}const previousStates=new Map;const MAX_STORED_STATES=500;const MAX_CHANGED_KEYS=10;const MAX_HOOK_DEPTH=50;const MAX_PARENT_DEPTH=50;const INTERNAL_COMPONENT_NAMES=new Set(["View","Text","TextImpl","Image","ScrollView","FlatList","SectionList","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","Pressable","TextInput","Switch","ActivityIndicator","Modal","StatusBar","KeyboardAvoidingView","AnimatedComponent","AnimatedComponentWrapper","Fragment","Suspense","Provider","Consumer","Context","ForwardRef","Unknown","Component"]);function isInternalComponentName(e){if(!e)return true;if(INTERNAL_COMPONENT_NAMES.has(e))return true;if(e.startsWith("Animated"))return true;return false}function getOwningComponentFiber(e){if(!e)return null;let t=e._debugOwner||e.return;let o=0;let r=null;while(t&&o<30){const n=t.tag;if(n===0||n===1||n===11||n===15){const s=getComponentNameFromFiber(t);if(!r){r=t}if(!isInternalComponentName(s)){return t}}t=t.return;o++}return r}function getComponentNameFromFiber(e){if(!e)return null;const t=e.type;if(t){if(typeof t==="string")return t;if(t.displayName)return t.displayName;if(t.name)return t.name}return null}function detectHookType(e){if(!e||typeof e!=="object"){return"unknown"}if(e.queue!==null&&e.queue!==void 0){return"useState"}const t=e.memoizedState;if(t!==null&&typeof t==="object"&&!Array.isArray(t)&&"current"in t&&Object.keys(t).length===1){return"useRef"}if(Array.isArray(t)&&t.length===2){const[,o]=t;if(Array.isArray(o)||o===null){if(typeof t[0]==="function"){return"useCallback"}return"useMemo"}}if(t!==null&&typeof t==="object"&&!Array.isArray(t)&&("tag"in t||"create"in t||"destroy"in t)){return"useEffect"}return"unknown"}function extractHookValue(e,t){const o=e?.memoizedState;switch(t){case"useState":case"useReducer":return o;case"useRef":return o?.current;case"useMemo":case"useCallback":return Array.isArray(o)?o[0]:o;case"useEffect":return"[effect]";default:return o}}function extractHookStates(e){if(!e?.memoizedState)return null;const t=e.memoizedState;if(typeof t!=="object"||t===null){return null}if(!("next"in t)&&!("queue"in t)&&!("memoizedState"in t)){return null}const o=[];let r=t;let n=0;while(r!==null&&n<MAX_HOOK_DEPTH){const s=detectHookType(r);const l=extractHookValue(r,s);o.push({index:n,type:s,value:l,rawState:r.memoizedState});r=r.next;n++}return o.length>0?o:null}function compareHookStates(e,t){if(!e||!t)return null;const o=[];const r=Math.max(e.length,t.length);for(let n=0;n<r;n++){const s=e[n];const l=t[n];if(!s&&l){o.push({index:n,type:l.type,currentValue:formatHookValue(l.value,l.type),description:`Hook[${n}] added`});continue}if(s&&!l){o.push({index:n,type:s.type,previousValue:formatHookValue(s.value,s.type),description:`Hook[${n}] removed`});continue}if(s&&l){if(s.rawState===l.rawState){continue}if(l.type==="useEffect"){continue}if(l.type==="useMemo"||l.type==="useCallback"){continue}if(l.type==="useState"||l.type==="useReducer"||l.type==="useRef"){const c=formatHookValue(s.value,s.type);const i=formatHookValue(l.value,l.type);o.push({index:n,type:l.type,previousValue:c,currentValue:i,description:`${c} \u2192 ${i}`})}}}return o.length>0?o:null}function formatHookValue(e,t){if(t==="useRef"){return formatDisplayValue(e)}return formatDisplayValue(e)}function formatDisplayValue(e){if(e===null)return null;if(e===void 0)return void 0;if(typeof e==="boolean")return e;if(typeof e==="number")return e;if(typeof e==="string"){return e.length>30?e.slice(0,30)+"...":e}if(typeof e==="function"){return`[Function: ${e.name||"anonymous"}]`}if(Array.isArray(e)){return`[Array: ${e.length} items]`}if(typeof e==="object"){const t=Object.keys(e);return`{Object: ${t.length} keys}`}return String(e)}function detectComponentCause(e){if(!e)return{cause:"unknown",hookChanges:null};let t=e;let o=e.alternate;const r=getComponentFiberPrevState(e);if(r&&o){const a=extractHookStates(e);const h=extractHookStates(o);const g=r.extractedHooks;if(a&&h&&g&&g.length>0){const y=g.find(f=>f.type==="useState");if(y){const f=a.find(d=>d.index===y.index);const S=h.find(d=>d.index===y.index);if(f&&S){const d=f.value===y.value;const m=S.value===y.value;if(d&&!m){t=o;o=e}}}}}const n=extractHookStates(t);let s=null;let l=null;let c=null;if(o){s=o.memoizedProps;l=o.memoizedState;c=extractHookStates(o)}else{if(r){s=r.memoizedProps;l=r.memoizedState;c=r.extractedHooks}}setComponentFiberState(t,{memoizedProps:t.memoizedProps,memoizedState:t.memoizedState,extractedHooks:n});if(s===null){return{cause:"mount",hookChanges:null}}const i=!shallowEqual(s,t.memoizedProps);if(i){return{cause:"props",hookChanges:null}}if((0,_ownStateChanged.hookStateChanged)(l,t.memoizedState,{isClassComponent:t.tag===1})){const a=compareHookStates(c,n);return{cause:"state",hookChanges:a}}return{cause:"parent",hookChanges:null}}function shallowEqual(e,t){if(e===t)return true;if(!e||!t)return false;if(typeof e!=="object"||typeof t!=="object")return false;const o=Object.keys(e);const r=Object.keys(t);if(o.length!==r.length)return false;for(const n of o){if(e[n]!==t[n])return false}return true}function safeStringify(e,t=3){const o=new WeakSet;function r(n,s){if(s>t)return"[MAX_DEPTH]";if(n===null)return null;if(n===void 0)return void 0;if(typeof n==="function")return`[Function: ${n.name||"anonymous"}]`;if(typeof n==="symbol")return`[Symbol: ${n.toString()}]`;if(typeof n!=="object")return n;if(o.has(n))return"[Circular]";o.add(n);if(Array.isArray(n)){return n.slice(0,10).map(i=>r(i,s+1))}const l={};const c=Object.keys(n).slice(0,20);for(const i of c){try{l[i]=r(n[i],s+1)}catch{l[i]="[Error accessing]"}}return l}return r(e,0)}function logRawFiberData(e,t,o,r,n,s){const l=getComponentNameFromFiber(o)||"Unknown";console.log("[Buoy]","\n========================================");console.log("[Buoy]","[RN-BUOY DEBUG] RENDER EVENT");console.log("[Buoy]","========================================");console.log("[Buoy]",`Native Tag: ${e}`);console.log("[Buoy]",`Component Name: ${l}`);console.log("[Buoy]",`Is First Render: ${!r}`);console.log("[Buoy]",`Component Cause Detected: ${s}`);console.log("[Buoy]","----------------------------------------");console.log("[Buoy]","\n--- NATIVE FIBER (Host Component) ---");console.log("[Buoy]","fiber.type:",t?.type);console.log("[Buoy]","fiber.tag:",t?.tag);console.log("[Buoy]","fiber.memoizedProps (CURRENT):",safeStringify(t?.memoizedProps));console.log("[Buoy]","fiber.memoizedState:",safeStringify(t?.memoizedState));if(r){console.log("[Buoy]","PREVIOUS memoizedProps:",safeStringify(r.memoizedProps));console.log("[Buoy]","PREVIOUS memoizedState:",safeStringify(r.memoizedState))}console.log("[Buoy]","\n--- COMPONENT FIBER (React Component) ---");if(o){console.log("[Buoy]","componentFiber.type:",o?.type?.name||o?.type);console.log("[Buoy]","componentFiber.tag:",o?.tag);console.log("[Buoy]","componentFiber.memoizedProps:",safeStringify(o?.memoizedProps));console.log("[Buoy]","componentFiber.memoizedState:",safeStringify(o?.memoizedState));console.log("[Buoy]","\n--- HOOKS STATE (linked list walk) ---");let i=o?.memoizedState;let a=0;while(i&&a<10){console.log("[Buoy]",`Hook[${a}]:`,safeStringify({memoizedState:i.memoizedState,baseState:i.baseState,queue:i.queue?"[Queue object]":null}));i=i.next;a++}console.log("[Buoy]","\n--- EXTRACTED HOOKS (Phase 3) ---");const h=extractHookStates(o);if(h){for(const g of h){console.log("[Buoy]",`Hook[${g.index}] (${g.type}):`,formatDisplayValue(g.value))}}else{console.log("[Buoy]","(No hooks extracted)")}}else{console.log("[Buoy]","(No component fiber found)")}console.log("[Buoy]","\n--- CHILDREN/TEXT CONTENT ---");const c=t?.memoizedProps?.children;console.log("[Buoy]","children type:",typeof c);console.log("[Buoy]","children value:",safeStringify(c));console.log("[Buoy]","\n========================================\n")}function getTagName(e){if(e===void 0)return"undefined";const t={0:"FunctionComponent",1:"ClassComponent",2:"IndeterminateComponent",3:"HostRoot",4:"HostPortal",5:"HostComponent",6:"HostText",7:"Fragment",8:"Mode",9:"ContextConsumer",10:"ContextProvider",11:"ForwardRef",12:"Profiler",13:"SuspenseComponent",14:"MemoComponent",15:"SimpleMemoComponent"};return t[e]||`Unknown(${e})`}function logMinimal(e,t){if(!t.hookChanges||t.hookChanges.length===0){return}for(const o of t.hookChanges){console.log("[Buoy]",`[${e||"Unknown"}] ${o.type}[${o.index}]: ${o.previousValue} \u2192 ${o.currentValue}`)}}function logVerbose(e,t,o,r,n){const s=getComponentNameFromFiber(o)||"Unknown";const l=typeof t?.type==="string"?t.type:"Unknown";const{cause:c,hookChanges:i}=r;console.log("[Buoy]",`[RENDER] ${s} (${l}:${e}) | Cause: ${c.toUpperCase()}`+(n&&n.length>0?` | Props: [${n.join(", ")}]`:""));if(i&&i.length>0){for(const a of i){console.log("[Buoy]",` \u2514\u2500 ${a.type}[${a.index}]: ${a.previousValue} \u2192 ${a.currentValue}`)}}}function logComprehensiveRenderData(e,t,o,r,n,s,l){const c=getComponentNameFromFiber(o)||"Unknown";const i=typeof t?.type==="string"?t.type:"Unknown";console.log("[Buoy]",`
2
+ [RN-BUOY RENDER DEBUG] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);console.log("[Buoy]",`Render #${l} for ${i} (nativeTag: ${e})`);console.log("[Buoy]",`Timestamp: ${new Date().toISOString()}`);console.log("[Buoy]",`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
3
+ `);console.log("[Buoy]",`NATIVE FIBER (${i}):`);console.log("[Buoy]",` type: "${t?.type}"`);console.log("[Buoy]",` tag: ${t?.tag} (${getTagName(t?.tag)})`);const a=t?.alternate;const h=a?"alternate":r?"storage":"none";console.log("[Buoy]",` Previous values source: ${h}`);const g=t?.memoizedProps?.children;const y=a?.memoizedProps?.children;const f=y!==void 0?y:r?.memoizedProps?.children;const S=f!==void 0?g!==f:false;console.log("[Buoy]",` memoizedProps.children: ${formatDisplayValue(g)}${S?` (was: ${formatDisplayValue(f)})`:f!==void 0?" (unchanged)":" (first render)"}`);const d=t?.memoizedProps?.style;const m=a?.memoizedProps?.style;const $=m!==void 0?m:r?.memoizedProps?.style;const H=$!==void 0?d!==$:false;if(d){console.log("[Buoy]",` memoizedProps.style: ${JSON.stringify(safeStringify(d,2))}${H?" (REFERENCE CHANGED)":""}`);if(H&&$){const u=deepEqual(d,$);console.log("[Buoy]",` \u2514\u2500 Values actually changed: ${!u}`)}}console.log("[Buoy]",` All memoizedProps keys: [${Object.keys(t?.memoizedProps||{}).join(", ")}]`);const P=t?.memoizedProps?.testID;const T=t?.memoizedProps?.nativeID;const O=t?.memoizedProps?.accessibilityLabel;if(P)console.log("[Buoy]",` testID: "${P}"`);if(T)console.log("[Buoy]",` nativeID: "${T}"`);if(O)console.log("[Buoy]",` accessibilityLabel: "${O}"`);console.log("[Buoy]",` alternate: ${a?"YES":"NO"}`);if(a){console.log("[Buoy]",` alternate.memoizedProps.children: ${formatDisplayValue(y)}`)}console.log("[Buoy]",` Tree structure:`);console.log("[Buoy]",` return (parent): ${t?.return?getTagName(t.return.tag):"null"}`);console.log("[Buoy]",` child: ${t?.child?getTagName(t.child.tag):"null"}`);console.log("[Buoy]",` sibling: ${t?.sibling?getTagName(t.sibling.tag):"null"}`);console.log("[Buoy]","");console.log("[Buoy]",`COMPONENT FIBER (${c}):`);if(o){console.log("[Buoy]",` name: "${c}"`);console.log("[Buoy]",` type: ${typeof o.type} (${o.type?.name||o.type?.displayName||"anonymous"})`);console.log("[Buoy]",` tag: ${o.tag} (${getTagName(o.tag)})`);console.log("[Buoy]",` memoizedProps: ${JSON.stringify(safeStringify(o.memoizedProps,2))}`);console.log("[Buoy]",` alternate: ${o.alternate?"YES":"NO"}`);if(o.alternate){console.log("[Buoy]",` ALTERNATE memoizedProps: ${JSON.stringify(safeStringify(o.alternate.memoizedProps,2))}`);const B=!shallowEqual(o.alternate.memoizedProps,o.memoizedProps);console.log("[Buoy]",` Props changed (vs alternate): ${B?"YES":"NO"}`);console.log("[Buoy]",` ALTERNATE memoizedState: ${o.alternate.memoizedState===o.memoizedState?"SAME":"DIFFERENT"}`)}const u=getComponentFiberPrevState(o);if(u){console.log("[Buoy]",` WeakMap PREVIOUS memoizedProps: ${JSON.stringify(safeStringify(u.memoizedProps,2))}`);const B=!shallowEqual(u.memoizedProps,o.memoizedProps);console.log("[Buoy]",` Props changed (vs WeakMap): ${B?"YES":"NO"}`)}else{console.log("[Buoy]",` WeakMap PREVIOUS state: (not found - first render or WeakMap cleared)`)}if(o._debugOwner){const B=getComponentNameFromFiber(o._debugOwner);console.log("[Buoy]",` _debugOwner: "${B}"`);let C=o._debugOwner;let E=1;while(C&&E<5){const _=getComponentNameFromFiber(C);console.log("[Buoy]",` \u2514\u2500[${E}] ${_||"unknown"} (tag: ${C.tag})`);C=C._debugOwner;E++}}let p=0;let z=t._debugOwner||t.return;while(z&&z!==o&&p<30){z=z.return;p++}console.log("[Buoy]",` Depth from native fiber: ${p}`)}else{console.log("[Buoy]",` (No component fiber found - could not walk up tree)`)}console.log("[Buoy]","");console.log("[Buoy]",`HOOKS:`);if(o?.memoizedState){const u=extractHookStates(o);const p=o.alternate?extractHookStates(o.alternate):null;const z=getComponentFiberPrevState(o);const B=p||z?.extractedHooks;const C=p?"alternate":z?"WeakMap":"none";if(u&&u.length>0){console.log("[Buoy]",` Total hooks: ${u.length}`);console.log("[Buoy]",` Previous values source: ${C}`);u.forEach((E,_)=>{const N=B?.[_];const w=N?N.rawState!==E.rawState:false;const M=N?formatDisplayValue(N.value):"N/A";const I=w?" \u2190 CHANGED":"";console.log("[Buoy]",` [${_}] ${E.type}: ${formatDisplayValue(E.value)}${N?` (was: ${M})`:" (first render)"}${I}`)})}else{console.log("[Buoy]",` (Could not extract hooks - memoizedState structure not recognized)`);console.log("[Buoy]",` Raw memoizedState type: ${typeof o.memoizedState}`);console.log("[Buoy]",` Has 'next' property: ${"next"in(o.memoizedState||{})}`);console.log("[Buoy]",` Has 'queue' property: ${"queue"in(o.memoizedState||{})}`)}}else{console.log("[Buoy]",` (No memoizedState - class component, no hooks, or not a function component)`)}console.log("[Buoy]","");console.log("[Buoy]",`RAW HOOKS DATA:`);if(o?.memoizedState&&typeof o.memoizedState==="object"){let u=o.memoizedState;let p=0;while(u&&p<10){console.log("[Buoy]",` Hook[${p}]:`);console.log("[Buoy]",` memoizedState: ${safeStringify(u.memoizedState,2)}`);console.log("[Buoy]",` baseState: ${safeStringify(u.baseState,2)}`);console.log("[Buoy]",` queue: ${u.queue?"[Queue present]":"null"}`);console.log("[Buoy]",` next: ${u.next?"[Next hook]":"null"}`);u=u.next;p++}if(p===0){console.log("[Buoy]",` (memoizedState is not a hooks linked list)`)}}console.log("[Buoy]","");console.log("[Buoy]",`DETECTION RESULTS:`);console.log("[Buoy]",` Component Cause: ${n.cause.toUpperCase()}`);if(n.hookChanges&&n.hookChanges.length>0){console.log("[Buoy]",` Hook Changes Detected:`);n.hookChanges.forEach(u=>{console.log("[Buoy]",` [${u.index}] ${u.type}: ${u.previousValue} \u2192 ${u.currentValue}`);if(u.description){console.log("[Buoy]",` ${u.description}`)}})}const k=typeof t?.type==="string"?t.type:void 0;const A=getChangedKeys(r?.memoizedProps,t?.memoizedProps,k);if(A&&A.length>0){console.log("[Buoy]",` Native Props Changed: [${A.join(", ")}]`)}else if(r){console.log("[Buoy]",` Native Props Changed: (none detected)`)}console.log("[Buoy]","");console.log("[Buoy]",`BATCH CONTEXT:`);console.log("[Buoy]",` Batch size: ${s.size}`);console.log("[Buoy]",` All tags in batch: [${Array.from(s).slice(0,20).join(", ")}${s.size>20?"...":""}]`);const R=getParentNativeTag(t);const x=R!==null&&s.has(R);console.log("[Buoy]",` Parent nativeTag: ${R??"not found"}`);console.log("[Buoy]",` Parent in batch: ${x?"YES":"NO"}`);if(s.size>1){console.log("[Buoy]",` Components in same batch:`);let u=t?.return;let p=0;while(u&&p<10){const z=getNativeTagFromStateNode(u.stateNode);if(z!==null&&s.has(z)){const B=getComponentNameFromFiber(u)||u.type;console.log("[Buoy]",` [depth ${p}] ${B} (tag: ${z})`)}u=u.return;p++}}console.log("[Buoy]",`
4
4
  \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
5
- `)}function detectRenderCause(e,t,o,r="off"){const n=Date.now();if(!t){return{type:"unknown",timestamp:n}}let s=t;let l=t.alternate;const a=previousStates.get(e);if(a&&l){const k=a.memoizedProps?.children;const R=t.memoizedProps?.children;const N=l.memoizedProps?.children;const w=t.memoizedProps===a.memoizedProps||k!==void 0&&R===k;const c=l.memoizedProps===a.memoizedProps||k!==void 0&&N===k;if(w&&!c){s=l;l=t;if(r==="all"){console.log(`[RenderCause] Detected fiber swap - using alternate as current`)}}}let i=null;let u=null;if(l){i=l.memoizedProps;u=l.memoizedState}else{if(a){i=a.memoizedProps;u=a.memoizedState}}const h=i!==null?{memoizedProps:i,memoizedState:u,timestamp:n}:void 0;const g={memoizedProps:s.memoizedProps,memoizedState:s.memoizedState,timestamp:n};updateStoredState(e,g);const m=getOwningComponentFiber(s);const f=getComponentNameFromFiber(m)||void 0;const S=getParentComponentName(s,f)||void 0;const d=detectComponentCause(m);const p=d.cause;const $=d.hookChanges;if(!h){if(r!=="off"){if(r==="minimal"){console.log(`[${f||"Unknown"}] MOUNT`)}else if(r==="verbose"){const k=typeof s?.type==="string"?s.type:"Unknown";console.log(`[RENDER] ${f||"Unknown"} (${k}:${e}) | Cause: MOUNT`)}else if(r==="all"){const k=previousStates.has(e)?previousStates.size:1;logComprehensiveRenderData(e,s,m,h,d,o,k)}}return{type:"mount",timestamp:n,componentCause:"mount",componentName:f}}const _=typeof s.type==="string"?s.type:void 0;const C=getChangedKeys(h.memoizedProps,g.memoizedProps,_);if(r!=="off"){if(r==="minimal"){logMinimal(f,d)}else if(r==="verbose"){logVerbose(e,s,m,d,C)}else if(r==="all"){const k=previousStates.has(e)?previousStates.size:1;logComprehensiveRenderData(e,s,m,h,d,o,k)}}if(C&&C.length>0){return{type:"props",changedKeys:C.slice(0,MAX_CHANGED_KEYS),timestamp:n,componentCause:p,componentName:f,parentComponentName:S,hookChanges:$||void 0}}const O=detectHookChanges(h.memoizedState,g.memoizedState);if(O&&O.length>0){return{type:"hooks",hookIndices:O,timestamp:n,componentCause:p,componentName:f,parentComponentName:S,hookChanges:$||void 0}}const A=getParentNativeTag(s);if(A&&o.has(A)){return{type:"parent",timestamp:n,componentCause:p,componentName:f,parentComponentName:S,hookChanges:$||void 0}}if(p==="state"){return{type:"state",timestamp:n,componentCause:p,componentName:f,parentComponentName:S,hookChanges:$||void 0}}if(p==="props"){return{type:"props",timestamp:n,componentCause:p,componentName:f,parentComponentName:S}}if(p==="parent"){return{type:"parent",timestamp:n,componentCause:p,componentName:f,parentComponentName:S}}return{type:"unknown",timestamp:n,componentCause:p,componentName:f,parentComponentName:S}}function getChangedKeys(e,t,o){if(e===t)return null;if(!e||!t)return null;if(typeof e!=="object"||typeof t!=="object")return null;if(Array.isArray(e)||Array.isArray(t))return null;const r=getComponentPropConfig(o);const n=new Set([...Object.keys(e),...Object.keys(t)]);const s=[];for(const l of n){if(l.startsWith("__"))continue;if(r.skip.includes(l))continue;if(l==="children"){if(!r.alwaysTrack.includes("children")){continue}const a=e[l];const i=t[l];if(a!==i){if(isPrimitive(a)&&isPrimitive(i)){s.push(`children: ${formatValue(a)} \u2192 ${formatValue(i)}`)}else{s.push("children (content)")}}continue}if(e[l]!==t[l]){const a=e[l];const i=t[l];if(l==="style"){if(deepEqual(a,i)){s.push(`${l} (ref only)`)}else{s.push(l)}}else if(typeof a==="function"&&typeof i==="function"){s.push(`${l} (fn ref)`)}else{s.push(l)}}}return s.length>0?s:null}function isPlainObject(e){if(e===null||typeof e!=="object")return false;if(Array.isArray(e))return false;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function deepEqual(e,t,o=0){if(o>5)return false;if(e===t)return true;if(typeof e!==typeof t)return false;if(typeof e!=="object"||e===null||t===null){return e===t}if(Array.isArray(e)!==Array.isArray(t))return false;if(Array.isArray(e)){if(e.length!==t.length)return false;for(let s=0;s<e.length;s++){if(!deepEqual(e[s],t[s],o+1))return false}return true}const r=Object.keys(e);const n=Object.keys(t);if(r.length!==n.length)return false;for(const s of r){if(!n.includes(s))return false;if(!deepEqual(e[s],t[s],o+1))return false}return true}function isPrimitive(e){return e===null||e===void 0||typeof e==="string"||typeof e==="number"||typeof e==="boolean"}function formatValue(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e==="string"){return e.length>20?`"${e.slice(0,20)}..."`:`"${e}"`}if(typeof e==="number")return String(e);if(typeof e==="boolean")return String(e);return"[object]"}function detectHookChanges(e,t){if(e===t)return null;if(e==null||t==null)return null;if(typeof e!=="object"||typeof t!=="object"){return null}const o=[];let r=e;let n=t;let s=0;while(n!==null&&s<MAX_HOOK_DEPTH){if(r===null){o.push(s)}else if(didHookChange(r,n)){o.push(s)}n=n?.next??null;r=r?.next??null;s++}return o.length>0?o:null}function didHookChange(e,t){if(e===t)return false;if(e.memoizedState!==t.memoizedState){return true}if(e.baseState!==void 0&&e.baseState!==t.baseState){return true}return false}function getParentNativeTag(e){let t=e?.return;let o=0;while(t&&o<MAX_PARENT_DEPTH){if(t.stateNode){const r=getNativeTagFromStateNode(t.stateNode);if(r!=null)return r}t=t.return;o++}return null}function getParentComponentName(e,t){if(!e)return null;const o=getOwningComponentFiber(e);if(!o)return null;let r=o.return;let n=0;while(r&&n<MAX_PARENT_DEPTH){const s=r.tag;if(s===0||s===1||s===11||s===15){const l=getComponentNameFromFiber(r);if(l&&!isInternalComponentName(l)&&l!==t){return l}}r=r.return;n++}return null}function getNativeTagFromStateNode(e){if(!e)return null;if(typeof e.__nativeTag==="number"){return e.__nativeTag}if(typeof e._nativeTag==="number"){return e._nativeTag}if(typeof e.canonical?.__nativeTag==="number"){return e.canonical.__nativeTag}if(typeof e.canonical?.publicInstance?.__nativeTag==="number"){return e.canonical.publicInstance.__nativeTag}return null}function updateStoredState(e,t){if(previousStates.size>=MAX_STORED_STATES){const o=Array.from(previousStates.entries());o.sort((n,s)=>n[1].timestamp-s[1].timestamp);const r=Math.floor(MAX_STORED_STATES/4);for(let n=0;n<r;n++){previousStates.delete(o[n][0])}}previousStates.set(e,t)}function clearRenderCauseState(){previousStates.clear()}function removeRenderCauseState(e){previousStates.delete(e)}function getRenderCauseStats(){return{storedStates:previousStates.size,maxStates:MAX_STORED_STATES}}const MAX_CLONE_DEPTH=5;const MAX_STRING_LENGTH=200;const MAX_ARRAY_ITEMS=20;const MAX_OBJECT_KEYS=30;function safeCloneForHistory(e,t=0,o=new WeakSet){if(e===null||e===void 0)return e;if(typeof e==="boolean"||typeof e==="number")return e;if(typeof e==="string"){return e.length>MAX_STRING_LENGTH?e.slice(0,MAX_STRING_LENGTH)+"...":e}if(typeof e==="function"){return`[Function: ${e.name||"anonymous"}]`}if(typeof e==="symbol"){return`[Symbol: ${e.description||""}]`}if(t>=MAX_CLONE_DEPTH){if(Array.isArray(e))return`[Array: ${e.length} items]`;if(typeof e==="object"){const r=Object.keys(e);return`[Object: ${r.length} keys]`}return"[...]"}if(typeof e==="object"){if(o.has(e)){return"[Circular]"}o.add(e)}if(Array.isArray(e)){const r=e.slice(0,MAX_ARRAY_ITEMS).map(n=>safeCloneForHistory(n,t+1,o));if(e.length>MAX_ARRAY_ITEMS){r.push(`[...${e.length-MAX_ARRAY_ITEMS} more]`)}return r}if(e instanceof Date){return e.toISOString()}if(e instanceof Error){return`[Error: ${e.message}]`}if(e instanceof RegExp){return e.toString()}if(e instanceof Map){const r={__type:"Map",__size:e.size};let n=0;for(const[s,l]of e){if(n>=MAX_OBJECT_KEYS){r[`...${e.size-n} more`]=true;break}const a=typeof s==="string"?s:String(s);r[a]=safeCloneForHistory(l,t+1,o);n++}return r}if(e instanceof Set){return{__type:"Set",__size:e.size,values:Array.from(e).slice(0,MAX_ARRAY_ITEMS).map(r=>safeCloneForHistory(r,t+1,o))}}if(typeof e==="object"){const r={};const n=Object.keys(e);const s=n.slice(0,MAX_OBJECT_KEYS);for(const l of s){if(l.startsWith("__")||l==="children")continue;try{r[l]=safeCloneForHistory(e[l],t+1,o)}catch{r[l]="[Error accessing property]"}}if(n.length>MAX_OBJECT_KEYS){r[`...${n.length-MAX_OBJECT_KEYS} more keys`]=true}return r}return"[Unknown type]"}function capturePropsSnapshot(e){if(!e?.memoizedProps)return void 0;return safeCloneForHistory(e.memoizedProps)}function captureStateSnapshot(e){if(!e?.memoizedState)return void 0;const t=e.memoizedState;if(typeof t==="object"&&t!==null&&"next"in t){const o=[];let r=t;let n=0;while(r&&n<MAX_HOOK_DEPTH){o.push({index:n,memoizedState:safeCloneForHistory(r.memoizedState)});r=r.next;n++}return{__type:"Hooks",hooks:o}}return safeCloneForHistory(t)}
5
+ `)}function detectRenderCause(e,t,o,r="off"){const n=Date.now();if(!t){return{type:"unknown",timestamp:n}}let s=t;let l=t.alternate;const c=previousStates.get(e);if(c&&l){const k=c.memoizedProps?.children;const A=t.memoizedProps?.children;const R=l.memoizedProps?.children;const x=t.memoizedProps===c.memoizedProps||k!==void 0&&A===k;const u=l.memoizedProps===c.memoizedProps||k!==void 0&&R===k;if(x&&!u){s=l;l=t;if(r==="all"){console.log("[Buoy]",`[RenderCause] Detected fiber swap - using alternate as current`)}}}let i=null;let a=null;if(l){i=l.memoizedProps;a=l.memoizedState}else{if(c){i=c.memoizedProps;a=c.memoizedState}}const h=i!==null?{memoizedProps:i,memoizedState:a,timestamp:n}:void 0;const g={memoizedProps:s.memoizedProps,memoizedState:s.memoizedState,timestamp:n};updateStoredState(e,g);const y=getOwningComponentFiber(s);const f=getComponentNameFromFiber(y)||void 0;const S=getParentComponentName(s,f)||void 0;const d=detectComponentCause(y);const m=d.cause;const $=d.hookChanges;if(!h){if(r!=="off"){if(r==="minimal"){console.log("[Buoy]",`[${f||"Unknown"}] MOUNT`)}else if(r==="verbose"){const k=typeof s?.type==="string"?s.type:"Unknown";console.log("[Buoy]",`[RENDER] ${f||"Unknown"} (${k}:${e}) | Cause: MOUNT`)}else if(r==="all"){const k=previousStates.has(e)?previousStates.size:1;logComprehensiveRenderData(e,s,y,h,d,o,k)}}return{type:"mount",timestamp:n,componentCause:"mount",componentName:f}}const H=typeof s.type==="string"?s.type:void 0;const P=getChangedKeys(h.memoizedProps,g.memoizedProps,H);if(r!=="off"){if(r==="minimal"){logMinimal(f,d)}else if(r==="verbose"){logVerbose(e,s,y,d,P)}else if(r==="all"){const k=previousStates.has(e)?previousStates.size:1;logComprehensiveRenderData(e,s,y,h,d,o,k)}}if(P&&P.length>0){return{type:"props",changedKeys:P.slice(0,MAX_CHANGED_KEYS),timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:$||void 0}}const T=detectHookChanges(h.memoizedState,g.memoizedState);if(T&&T.length>0){return{type:"hooks",hookIndices:T,timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:$||void 0}}const O=getParentNativeTag(s);if(O&&o.has(O)){return{type:"parent",timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:$||void 0}}if(m==="state"){return{type:"state",timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:$||void 0}}if(m==="props"){return{type:"props",timestamp:n,componentCause:m,componentName:f,parentComponentName:S}}if(m==="parent"){return{type:"parent",timestamp:n,componentCause:m,componentName:f,parentComponentName:S}}return{type:"unknown",timestamp:n,componentCause:m,componentName:f,parentComponentName:S}}function getChangedKeys(e,t,o){if(e===t)return null;if(!e||!t)return null;if(typeof e!=="object"||typeof t!=="object")return null;if(Array.isArray(e)||Array.isArray(t))return null;const r=getComponentPropConfig(o);const n=new Set([...Object.keys(e),...Object.keys(t)]);const s=[];for(const l of n){if(l.startsWith("__"))continue;if(r.skip.includes(l))continue;if(l==="children"){if(!r.alwaysTrack.includes("children")){continue}const c=e[l];const i=t[l];if(c!==i){if(isPrimitive(c)&&isPrimitive(i)){s.push(`children: ${formatValue(c)} \u2192 ${formatValue(i)}`)}else{s.push("children (content)")}}continue}if(e[l]!==t[l]){const c=e[l];const i=t[l];if(l==="style"){if(deepEqual(c,i)){s.push(`${l} (ref only)`)}else{s.push(l)}}else if(typeof c==="function"&&typeof i==="function"){s.push(`${l} (fn ref)`)}else{s.push(l)}}}return s.length>0?s:null}function isPlainObject(e){if(e===null||typeof e!=="object")return false;if(Array.isArray(e))return false;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function deepEqual(e,t,o=0){if(o>5)return false;if(e===t)return true;if(typeof e!==typeof t)return false;if(typeof e!=="object"||e===null||t===null){return e===t}if(Array.isArray(e)!==Array.isArray(t))return false;if(Array.isArray(e)){if(e.length!==t.length)return false;for(let s=0;s<e.length;s++){if(!deepEqual(e[s],t[s],o+1))return false}return true}const r=Object.keys(e);const n=Object.keys(t);if(r.length!==n.length)return false;for(const s of r){if(!n.includes(s))return false;if(!deepEqual(e[s],t[s],o+1))return false}return true}function isPrimitive(e){return e===null||e===void 0||typeof e==="string"||typeof e==="number"||typeof e==="boolean"}function formatValue(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e==="string"){return e.length>20?`"${e.slice(0,20)}..."`:`"${e}"`}if(typeof e==="number")return String(e);if(typeof e==="boolean")return String(e);return"[object]"}function detectHookChanges(e,t){if(e===t)return null;if(e==null||t==null)return null;if(typeof e!=="object"||typeof t!=="object"){return null}const o=[];let r=e;let n=t;let s=0;while(n!==null&&s<MAX_HOOK_DEPTH){if(r===null){o.push(s)}else if(didHookChange(r,n)){o.push(s)}n=n?.next??null;r=r?.next??null;s++}return o.length>0?o:null}function didHookChange(e,t){if(e===t)return false;if(e.memoizedState!==t.memoizedState){return true}if(e.baseState!==void 0&&e.baseState!==t.baseState){return true}return false}function getParentNativeTag(e){let t=e?.return;let o=0;while(t&&o<MAX_PARENT_DEPTH){if(t.stateNode){const r=getNativeTagFromStateNode(t.stateNode);if(r!=null)return r}t=t.return;o++}return null}function getParentComponentName(e,t){if(!e)return null;const o=getOwningComponentFiber(e);if(!o)return null;let r=o.return;let n=0;while(r&&n<MAX_PARENT_DEPTH){const s=r.tag;if(s===0||s===1||s===11||s===15){const l=getComponentNameFromFiber(r);if(l&&!isInternalComponentName(l)&&l!==t){return l}}r=r.return;n++}return null}function getNativeTagFromStateNode(e){if(!e)return null;if(typeof e.__nativeTag==="number"){return e.__nativeTag}if(typeof e._nativeTag==="number"){return e._nativeTag}if(typeof e.canonical?.__nativeTag==="number"){return e.canonical.__nativeTag}if(typeof e.canonical?.publicInstance?.__nativeTag==="number"){return e.canonical.publicInstance.__nativeTag}return null}function updateStoredState(e,t){if(previousStates.size>=MAX_STORED_STATES){const o=Array.from(previousStates.entries());o.sort((n,s)=>n[1].timestamp-s[1].timestamp);const r=Math.floor(MAX_STORED_STATES/4);for(let n=0;n<r;n++){previousStates.delete(o[n][0])}}previousStates.set(e,t)}function clearRenderCauseState(){previousStates.clear()}function removeRenderCauseState(e){previousStates.delete(e)}function getRenderCauseStats(){return{storedStates:previousStates.size,maxStates:MAX_STORED_STATES}}const MAX_CLONE_DEPTH=5;const MAX_STRING_LENGTH=200;const MAX_ARRAY_ITEMS=20;const MAX_OBJECT_KEYS=30;function safeCloneForHistory(e,t=0,o=new WeakSet){if(e===null||e===void 0)return e;if(typeof e==="boolean"||typeof e==="number")return e;if(typeof e==="string"){return e.length>MAX_STRING_LENGTH?e.slice(0,MAX_STRING_LENGTH)+"...":e}if(typeof e==="function"){return`[Function: ${e.name||"anonymous"}]`}if(typeof e==="symbol"){return`[Symbol: ${e.description||""}]`}if(t>=MAX_CLONE_DEPTH){if(Array.isArray(e))return`[Array: ${e.length} items]`;if(typeof e==="object"){const r=Object.keys(e);return`[Object: ${r.length} keys]`}return"[...]"}if(typeof e==="object"){if(o.has(e)){return"[Circular]"}o.add(e)}if(Array.isArray(e)){const r=e.slice(0,MAX_ARRAY_ITEMS).map(n=>safeCloneForHistory(n,t+1,o));if(e.length>MAX_ARRAY_ITEMS){r.push(`[...${e.length-MAX_ARRAY_ITEMS} more]`)}return r}if(e instanceof Date){return e.toISOString()}if(e instanceof Error){return`[Error: ${e.message}]`}if(e instanceof RegExp){return e.toString()}if(e instanceof Map){const r={__type:"Map",__size:e.size};let n=0;for(const[s,l]of e){if(n>=MAX_OBJECT_KEYS){r[`...${e.size-n} more`]=true;break}const c=typeof s==="string"?s:String(s);r[c]=safeCloneForHistory(l,t+1,o);n++}return r}if(e instanceof Set){return{__type:"Set",__size:e.size,values:Array.from(e).slice(0,MAX_ARRAY_ITEMS).map(r=>safeCloneForHistory(r,t+1,o))}}if(typeof e==="object"){const r={};const n=Object.keys(e);const s=n.slice(0,MAX_OBJECT_KEYS);for(const l of s){if(l.startsWith("__")||l==="children")continue;try{r[l]=safeCloneForHistory(e[l],t+1,o)}catch{r[l]="[Error accessing property]"}}if(n.length>MAX_OBJECT_KEYS){r[`...${n.length-MAX_OBJECT_KEYS} more keys`]=true}return r}return"[Unknown type]"}function capturePropsSnapshot(e){if(!e?.memoizedProps)return void 0;return safeCloneForHistory(e.memoizedProps)}function captureStateSnapshot(e){if(!e?.memoizedState)return void 0;const t=e.memoizedState;if(typeof t==="object"&&t!==null&&"next"in t){const o=[];let r=t;let n=0;while(r&&n<MAX_HOOK_DEPTH){o.push({index:n,memoizedState:safeCloneForHistory(r.memoizedState)});r=r.next;n++}return{__type:"Hooks",hooks:o}}return safeCloneForHistory(t)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.RenderTracker=void 0;var _ViewTypeMapper=require("./ViewTypeMapper");var _PerformanceLogger=require("./PerformanceLogger");var _namedComposite=require("./namedComposite");const MAX_TRACKED_COMPONENTS=200;const DEFAULT_BATCH_SIZE=150;class RenderTrackerSingleton{renders=new Map;listeners=new Set;stateListeners=new Set;settingsListeners=new Set;filterListeners=new Set;renderEventCallbacks=new Set;isTracking=false;isPaused=false;settings={batchSize:DEFAULT_BATCH_SIZE,showRenderCount:true,performanceLogging:false,trackRenderCauses:false,enableRenderHistory:false,maxRenderHistoryPerComponent:20,capturePropsOnRender:false,captureStateOnRender:false,debugLogLevel:"off",excludeDevTools:true,showHostViews:false};isBatchMode=false;batchDirty=false;filters={includeTestID:new Set,includeNativeID:new Set,includeViewType:new Set,includeComponent:new Set,excludeTestID:new Set,excludeNativeID:new Set,excludeViewType:new Set,excludeComponent:new Set,includePatterns:[],excludePatterns:[]};trackRender(e){if(this.isPaused)return;const t=String(e.nativeTag);const s=Date.now();const i=this.renders.get(t);if(i){i.renderCount=e.count;i.lastRenderTime=s;i.color=e.color;if(e.measurements){i.measurements=e.measurements}if(e.testID&&!i.testID)i.testID=e.testID;if(e.nativeID&&!i.nativeID)i.nativeID=e.nativeID;if(e.accessibilityLabel&&!i.accessibilityLabel){i.accessibilityLabel=e.accessibilityLabel}if(e.componentName&&!i.componentName){i.componentName=e.componentName}if(e.renderCause){i.lastRenderCause=e.renderCause}if(this.settings.enableRenderHistory){const r=e.renderCause||{type:"unknown",timestamp:s};this.addRenderEvent(i,r,e.capturedProps,e.capturedState)}}else{const r={id:t,nativeTag:e.nativeTag,viewType:e.viewType,displayName:(0,_ViewTypeMapper.getComponentDisplayName)(e.viewType),testID:e.testID,nativeID:e.nativeID,accessibilityLabel:e.accessibilityLabel,componentName:e.componentName,renderCount:e.count,firstRenderTime:s,lastRenderTime:s,measurements:e.measurements,color:e.color,lastRenderCause:e.renderCause};if(this.settings.enableRenderHistory){r.renderHistory=[];const n=e.renderCause||{type:e.count===1?"mount":"unknown",timestamp:s};this.addRenderEvent(r,n,e.capturedProps,e.capturedState)}this.renders.set(t,r);if(this.renders.size>MAX_TRACKED_COMPONENTS){const n=Array.from(this.renders.values()).sort((a,l)=>a.lastRenderTime-l.lastRenderTime);const o=n.slice(0,this.renders.size-MAX_TRACKED_COMPONENTS);for(const a of o){this.renders.delete(a.id)}}}if(this.isBatchMode){this.batchDirty=true}else{this.notifyListeners()}}addRenderEvent(e,t,s,i){if(!e.renderHistory){e.renderHistory=[]}const r={id:`${e.nativeTag}-${t.timestamp}`,timestamp:t.timestamp,cause:t,renderNumber:e.renderCount,capturedProps:this.settings.capturePropsOnRender?s:void 0,capturedState:this.settings.captureStateOnRender?i:void 0};e.renderHistory.push(r);const n=Math.max(5,Math.min(50,this.settings.maxRenderHistoryPerComponent));if(e.renderHistory.length>n){e.renderHistory=e.renderHistory.slice(-n)}this.notifyRenderEventCallbacks(r,e)}notifyRenderEventCallbacks(e,t){this.renderEventCallbacks.forEach(s=>{try{s(e,t)}catch{}})}emitRenderEvent(e){if(this.renderEventCallbacks.size===0)return;const t=Date.now();const s=e.renderCause||{type:"unknown",timestamp:t};const i={id:String(e.nativeTag),nativeTag:e.nativeTag,viewType:e.viewType,displayName:(0,_ViewTypeMapper.getComponentDisplayName)(e.viewType),testID:e.testID,nativeID:e.nativeID,accessibilityLabel:e.accessibilityLabel,componentName:e.componentName,renderCount:e.count,firstRenderTime:t,lastRenderTime:t,measurements:e.measurements,color:e.color,lastRenderCause:s,renderHistory:[]};const r={id:`${e.nativeTag}-${t}-${e.count}`,timestamp:t,renderNumber:e.count,cause:s,capturedProps:void 0,capturedState:void 0};this.notifyRenderEventCallbacks(r,i)}startBatch(){this.isBatchMode=true;this.batchDirty=false}endBatch(){this.isBatchMode=false;if(this.batchDirty){this.batchDirty=false;this.notifyListeners()}}getRenders(){return Array.from(this.renders.values()).map(e=>({...e}))}passesFilters(e){if(this.filters.includePatterns.length>0){const t=this.matchesAnyPatternForInfo(e,this.filters.includePatterns);if(!t)return false}if(this.filters.excludePatterns.length>0){const t=this.matchesAnyPatternForInfo(e,this.filters.excludePatterns);if(t)return false}if(this.filters.includeViewType.size>0){const t=e.viewType||"";const s=e.displayName||"";if(!this.matchesPattern(t,this.filters.includeViewType)&&!this.matchesPattern(s,this.filters.includeViewType)){return false}}if(this.filters.includeTestID.size>0){if(!e.testID||!this.matchesPattern(e.testID,this.filters.includeTestID)){return false}}if(this.filters.includeNativeID.size>0){if(!e.nativeID||!this.matchesPattern(e.nativeID,this.filters.includeNativeID)){return false}}if(this.filters.includeComponent.size>0){if(!e.componentName||!this.matchesPattern(e.componentName,this.filters.includeComponent)){return false}}if(this.filters.excludeViewType.size>0){const t=e.viewType||"";const s=e.displayName||"";if(this.matchesPattern(t,this.filters.excludeViewType)||this.matchesPattern(s,this.filters.excludeViewType)){return false}}if(this.filters.excludeTestID.size>0){if(e.testID&&this.matchesPattern(e.testID,this.filters.excludeTestID)){return false}}if(this.filters.excludeNativeID.size>0){if(e.nativeID&&this.matchesPattern(e.nativeID,this.filters.excludeNativeID)){return false}}if(this.filters.excludeComponent.size>0){if(e.componentName&&this.matchesPattern(e.componentName,this.filters.excludeComponent)){return false}}return true}matchesAnyPatternForInfo(e,t){for(const s of t){const i=s.value.toLowerCase();switch(s.type){case"any":if(e.viewType.toLowerCase().includes(i)||e.displayName?.toLowerCase().includes(i)||e.testID?.toLowerCase().includes(i)||e.nativeID?.toLowerCase().includes(i)||e.componentName?.toLowerCase().includes(i)||e.accessibilityLabel?.toLowerCase().includes(i)){return true}break;case"viewType":if(e.viewType.toLowerCase().includes(i)||e.displayName?.toLowerCase().includes(i)){return true}break;case"testID":if(e.testID?.toLowerCase().includes(i)){return true}break;case"nativeID":if(e.nativeID?.toLowerCase().includes(i)){return true}break;case"component":if(e.componentName?.toLowerCase().includes(i)){return true}break;case"accessibilityLabel":if(e.accessibilityLabel?.toLowerCase().includes(i)){return true}break}}return false}hasActiveFilters(){return this.filters.includePatterns.length>0||this.filters.excludePatterns.length>0||this.filters.includeViewType.size>0||this.filters.includeTestID.size>0||this.filters.includeNativeID.size>0||this.filters.includeComponent.size>0||this.filters.excludeViewType.size>0||this.filters.excludeTestID.size>0||this.filters.excludeNativeID.size>0||this.filters.excludeComponent.size>0||this.filters.minRenderCount!==void 0||this.filters.maxRenderCount!==void 0}getFilteredRenders(e=""){let t=this.getRenders();if(!this.settings.showHostViews){t=t.filter(_namedComposite.isNamedComposite)}if(e.trim()){const s=e.toLowerCase();t=t.filter(i=>{return i.viewType.toLowerCase().includes(s)||i.displayName.toLowerCase().includes(s)||i.testID?.toLowerCase().includes(s)||i.nativeID?.toLowerCase().includes(s)||i.accessibilityLabel?.toLowerCase().includes(s)||i.componentName?.toLowerCase().includes(s)||String(i.nativeTag).includes(s)})}t=t.filter(s=>this.passesFilters(s));if(this.filters.minRenderCount!==void 0){t=t.filter(s=>s.renderCount>=this.filters.minRenderCount)}if(this.filters.maxRenderCount!==void 0){t=t.filter(s=>s.renderCount<=this.filters.maxRenderCount)}return t.sort((s,i)=>i.lastRenderTime-s.lastRenderTime)}matchesPattern(e,t){const s=e.toLowerCase();for(const i of t){const r=i.toLowerCase();if(s.includes(r)){return true}}return false}getRender(e){return this.renders.get(e)}clear(){this.renders.clear();this.notifyListeners()}resetRenderCount(e){const t=this.renders.get(e);if(t){t.renderCount=0;this.notifyListeners()}}start(){this.isTracking=true;this.isPaused=false;this.notifyStateListeners()}stop(){this.isTracking=false;this.isPaused=false;this.notifyStateListeners()}pause(){this.isPaused=true;this.notifyStateListeners()}resume(){this.isPaused=false;this.notifyStateListeners()}togglePause(){this.isPaused=!this.isPaused;this.notifyStateListeners()}getState(){return{isTracking:this.isTracking,isPaused:this.isPaused}}replaceRenders(e,t){const s=new Map;for(const[i,r]of this.renders){if(r.renderHistory&&r.renderHistory.length>0){s.set(i,r.renderHistory)}}this.renders=new Map(e.map(i=>{const r=s.get(i.id);const n=r&&!(i.renderHistory&&i.renderHistory.length>0)?{...i,renderHistory:r}:i;return[n.id,n]}));if(t&&(this.isTracking!==t.isTracking||this.isPaused!==t.isPaused)){this.isTracking=t.isTracking;this.isPaused=t.isPaused;this.notifyStateListeners()}this.notifyListeners()}hydrateRender(e){const t=this.renders.get(e.id);this.renders.set(e.id,t?{...t,...e}:e);this.notifyListeners()}getFilters(){return this.filters}setFilters(e){this.filters={...this.filters,...e};this.notifyListeners();this.notifyFilterListeners()}addIncludePattern(e,t){const s=`include${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].add(t);this.notifyListeners()}removeIncludePattern(e,t){const s=`include${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].delete(t);this.notifyListeners()}addExcludePattern(e,t){const s=`exclude${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].add(t);this.notifyListeners()}removeExcludePattern(e,t){const s=`exclude${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].delete(t);this.notifyListeners()}clearFilters(){this.filters={includeTestID:new Set,includeNativeID:new Set,includeViewType:new Set,includeComponent:new Set,excludeTestID:new Set,excludeNativeID:new Set,excludeViewType:new Set,excludeComponent:new Set,includePatterns:[],excludePatterns:[],minRenderCount:void 0,maxRenderCount:void 0};this.notifyListeners()}getAvailableProps(){const e=new Set;const t=new Set;const s=new Set;const i=new Set;const r=new Set;for(const n of this.renders.values()){if(n.viewType)e.add(n.viewType);if(n.testID)t.add(n.testID);if(n.nativeID)s.add(n.nativeID);if(n.componentName)i.add(n.componentName);if(n.accessibilityLabel)r.add(n.accessibilityLabel)}return{viewTypes:Array.from(e).sort(),testIDs:Array.from(t).sort(),nativeIDs:Array.from(s).sort(),componentNames:Array.from(i).sort(),accessibilityLabels:Array.from(r).sort()}}getStats(){let e=0;for(const t of this.renders.values()){e+=t.renderCount}return{totalComponents:this.renders.size,totalRenders:e}}subscribe(e){this.listeners.add(e);e(this.getRenders());return()=>{this.listeners.delete(e)}}subscribeToState(e){this.stateListeners.add(e);e(this.getState());return()=>{this.stateListeners.delete(e)}}subscribeToSettings(e){this.settingsListeners.add(e);e(this.settings);return()=>{this.settingsListeners.delete(e)}}subscribeToFilters(e){this.filterListeners.add(e);e(this.filters);return()=>{this.filterListeners.delete(e)}}onRenderEvent(e){this.renderEventCallbacks.add(e);return()=>{this.renderEventCallbacks.delete(e)}}getRenderEventCallbackCount(){return this.renderEventCallbacks.size}shouldShowRender(e){const t=this.filters;if(t.includePatterns.length>0){if(!this.matchesAnyPatternForInfo(e,t.includePatterns)){return false}}if(t.excludePatterns.length>0){if(this.matchesAnyPatternForInfo(e,t.excludePatterns)){return false}}const s=t.includeViewType.size>0||t.includeTestID.size>0||t.includeNativeID.size>0||t.includeComponent.size>0;if(s){const i=t.includeViewType.size>0&&t.includeViewType.has(e.viewType)||t.includeTestID.size>0&&e.testID&&t.includeTestID.has(e.testID)||t.includeNativeID.size>0&&e.nativeID&&t.includeNativeID.has(e.nativeID)||t.includeComponent.size>0&&e.componentName&&t.includeComponent.has(e.componentName);if(!i){return false}}if(t.excludeViewType.has(e.viewType))return false;if(e.testID&&t.excludeTestID.has(e.testID))return false;if(e.nativeID&&t.excludeNativeID.has(e.nativeID))return false;if(e.componentName&&t.excludeComponent.has(e.componentName))return false;return true}getSettings(){return{...this.settings}}setSettings(e){if(e.batchSize!==void 0){e.batchSize=Math.max(10,Math.min(500,e.batchSize))}if(e.maxRenderHistoryPerComponent!==void 0){e.maxRenderHistoryPerComponent=Math.max(5,Math.min(50,e.maxRenderHistoryPerComponent))}if(e.enableRenderHistory&&!this.settings.trackRenderCauses){e.trackRenderCauses=true}if(e.trackRenderCauses===false&&this.settings.enableRenderHistory){e.enableRenderHistory=false}this.settings={...this.settings,...e};if(e.performanceLogging!==void 0){_PerformanceLogger.PerformanceLogger.setEnabled(e.performanceLogging)}this.notifySettingsListeners()}clearAllRenderHistory(){for(const e of this.renders.values()){e.renderHistory=[]}this.notifyListeners()}clearRenderHistory(e){const t=this.renders.get(e);if(t){t.renderHistory=[];this.notifyListeners()}}getRenderHistoryStats(){let e=0;let t=0;for(const s of this.renders.values()){if(s.renderHistory&&s.renderHistory.length>0){e+=s.renderHistory.length;t++}}return{totalEvents:e,componentsWithHistory:t,averageEventsPerComponent:t>0?e/t:0}}getBatchSize(){return this.settings.batchSize}setBatchSize(e){this.setSettings({batchSize:e})}notifyListeners(){const e=this.getRenders();for(const t of this.listeners){try{t(e)}catch(s){console.error("[RenderTracker] Error in listener:",s)}}}notifyStateListeners(){const e=this.getState();for(const t of this.stateListeners){try{t(e)}catch(s){console.error("[RenderTracker] Error in state listener:",s)}}}notifySettingsListeners(){const e=this.getSettings();for(const t of this.settingsListeners){try{t(e)}catch(s){console.error("[RenderTracker] Error in settings listener:",s)}}}notifyFilterListeners(){const e=this.getFilters();for(const t of this.filterListeners){try{t(e)}catch(s){console.error("[RenderTracker] Error in filter listener:",s)}}}}const RenderTracker=exports.RenderTracker=new RenderTrackerSingleton;var _default=exports.default=RenderTracker;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.RenderTracker=void 0;var _ViewTypeMapper=require("./ViewTypeMapper");var _PerformanceLogger=require("./PerformanceLogger");var _namedComposite=require("./namedComposite");const MAX_TRACKED_COMPONENTS=200;const DEFAULT_BATCH_SIZE=150;class RenderTrackerSingleton{renders=new Map;listeners=new Set;stateListeners=new Set;settingsListeners=new Set;filterListeners=new Set;renderEventCallbacks=new Set;isTracking=false;isPaused=false;settings={batchSize:DEFAULT_BATCH_SIZE,showRenderCount:true,performanceLogging:false,trackRenderCauses:false,enableRenderHistory:false,maxRenderHistoryPerComponent:20,capturePropsOnRender:false,captureStateOnRender:false,debugLogLevel:"off",excludeDevTools:true,showHostViews:false};isBatchMode=false;batchDirty=false;filters={includeTestID:new Set,includeNativeID:new Set,includeViewType:new Set,includeComponent:new Set,excludeTestID:new Set,excludeNativeID:new Set,excludeViewType:new Set,excludeComponent:new Set,includePatterns:[],excludePatterns:[]};trackRender(e){if(this.isPaused)return;const t=String(e.nativeTag);const s=Date.now();const i=this.renders.get(t);if(i){i.renderCount=e.count;i.lastRenderTime=s;i.color=e.color;if(e.measurements){i.measurements=e.measurements}if(e.testID&&!i.testID)i.testID=e.testID;if(e.nativeID&&!i.nativeID)i.nativeID=e.nativeID;if(e.accessibilityLabel&&!i.accessibilityLabel){i.accessibilityLabel=e.accessibilityLabel}if(e.componentName&&!i.componentName){i.componentName=e.componentName}if(e.renderCause){i.lastRenderCause=e.renderCause}if(this.settings.enableRenderHistory){const r=e.renderCause||{type:"unknown",timestamp:s};this.addRenderEvent(i,r,e.capturedProps,e.capturedState)}}else{const r={id:t,nativeTag:e.nativeTag,viewType:e.viewType,displayName:(0,_ViewTypeMapper.getComponentDisplayName)(e.viewType),testID:e.testID,nativeID:e.nativeID,accessibilityLabel:e.accessibilityLabel,componentName:e.componentName,...e.isComponent===void 0?{}:{isComponent:e.isComponent},renderCount:e.count,firstRenderTime:s,lastRenderTime:s,measurements:e.measurements,color:e.color,lastRenderCause:e.renderCause};if(this.settings.enableRenderHistory){r.renderHistory=[];const n=e.renderCause||{type:e.count===1?"mount":"unknown",timestamp:s};this.addRenderEvent(r,n,e.capturedProps,e.capturedState)}this.renders.set(t,r);if(this.renders.size>MAX_TRACKED_COMPONENTS){const n=Array.from(this.renders.values()).sort((a,l)=>a.lastRenderTime-l.lastRenderTime);const o=n.slice(0,this.renders.size-MAX_TRACKED_COMPONENTS);for(const a of o){this.renders.delete(a.id)}}}if(this.isBatchMode){this.batchDirty=true}else{this.notifyListeners()}}addRenderEvent(e,t,s,i){if(!e.renderHistory){e.renderHistory=[]}const r={id:`${e.nativeTag}-${t.timestamp}`,timestamp:t.timestamp,cause:t,renderNumber:e.renderCount,capturedProps:this.settings.capturePropsOnRender?s:void 0,capturedState:this.settings.captureStateOnRender?i:void 0};e.renderHistory.push(r);const n=Math.max(5,Math.min(50,this.settings.maxRenderHistoryPerComponent));if(e.renderHistory.length>n){e.renderHistory=e.renderHistory.slice(-n)}this.notifyRenderEventCallbacks(r,e)}notifyRenderEventCallbacks(e,t){this.renderEventCallbacks.forEach(s=>{try{s(e,t)}catch{}})}emitRenderEvent(e){if(this.renderEventCallbacks.size===0)return;const t=Date.now();const s=e.renderCause||{type:"unknown",timestamp:t};const i={id:String(e.nativeTag),nativeTag:e.nativeTag,viewType:e.viewType,displayName:(0,_ViewTypeMapper.getComponentDisplayName)(e.viewType),testID:e.testID,nativeID:e.nativeID,accessibilityLabel:e.accessibilityLabel,componentName:e.componentName,renderCount:e.count,firstRenderTime:t,lastRenderTime:t,measurements:e.measurements,color:e.color,lastRenderCause:s,renderHistory:[]};const r={id:`${e.nativeTag}-${t}-${e.count}`,timestamp:t,renderNumber:e.count,cause:s,capturedProps:void 0,capturedState:void 0};this.notifyRenderEventCallbacks(r,i)}startBatch(){this.isBatchMode=true;this.batchDirty=false}endBatch(){this.isBatchMode=false;if(this.batchDirty){this.batchDirty=false;this.notifyListeners()}}getRenders(){return Array.from(this.renders.values()).map(e=>({...e}))}passesFilters(e){if(this.filters.includePatterns.length>0){const t=this.matchesAnyPatternForInfo(e,this.filters.includePatterns);if(!t)return false}if(this.filters.excludePatterns.length>0){const t=this.matchesAnyPatternForInfo(e,this.filters.excludePatterns);if(t)return false}if(this.filters.includeViewType.size>0){const t=e.viewType||"";const s=e.displayName||"";if(!this.matchesPattern(t,this.filters.includeViewType)&&!this.matchesPattern(s,this.filters.includeViewType)){return false}}if(this.filters.includeTestID.size>0){if(!e.testID||!this.matchesPattern(e.testID,this.filters.includeTestID)){return false}}if(this.filters.includeNativeID.size>0){if(!e.nativeID||!this.matchesPattern(e.nativeID,this.filters.includeNativeID)){return false}}if(this.filters.includeComponent.size>0){if(!e.componentName||!this.matchesPattern(e.componentName,this.filters.includeComponent)){return false}}if(this.filters.excludeViewType.size>0){const t=e.viewType||"";const s=e.displayName||"";if(this.matchesPattern(t,this.filters.excludeViewType)||this.matchesPattern(s,this.filters.excludeViewType)){return false}}if(this.filters.excludeTestID.size>0){if(e.testID&&this.matchesPattern(e.testID,this.filters.excludeTestID)){return false}}if(this.filters.excludeNativeID.size>0){if(e.nativeID&&this.matchesPattern(e.nativeID,this.filters.excludeNativeID)){return false}}if(this.filters.excludeComponent.size>0){if(e.componentName&&this.matchesPattern(e.componentName,this.filters.excludeComponent)){return false}}return true}matchesAnyPatternForInfo(e,t){for(const s of t){const i=s.value.toLowerCase();switch(s.type){case"any":if(e.viewType.toLowerCase().includes(i)||e.displayName?.toLowerCase().includes(i)||e.testID?.toLowerCase().includes(i)||e.nativeID?.toLowerCase().includes(i)||e.componentName?.toLowerCase().includes(i)||e.accessibilityLabel?.toLowerCase().includes(i)){return true}break;case"viewType":if(e.viewType.toLowerCase().includes(i)||e.displayName?.toLowerCase().includes(i)){return true}break;case"testID":if(e.testID?.toLowerCase().includes(i)){return true}break;case"nativeID":if(e.nativeID?.toLowerCase().includes(i)){return true}break;case"component":if(e.componentName?.toLowerCase().includes(i)){return true}break;case"accessibilityLabel":if(e.accessibilityLabel?.toLowerCase().includes(i)){return true}break}}return false}hasActiveFilters(){return this.filters.includePatterns.length>0||this.filters.excludePatterns.length>0||this.filters.includeViewType.size>0||this.filters.includeTestID.size>0||this.filters.includeNativeID.size>0||this.filters.includeComponent.size>0||this.filters.excludeViewType.size>0||this.filters.excludeTestID.size>0||this.filters.excludeNativeID.size>0||this.filters.excludeComponent.size>0||this.filters.minRenderCount!==void 0||this.filters.maxRenderCount!==void 0}getFilteredRenders(e=""){let t=this.getRenders();if(!this.settings.showHostViews){t=t.filter(_namedComposite.isNamedComposite)}if(e.trim()){const s=e.toLowerCase();t=t.filter(i=>{return i.viewType.toLowerCase().includes(s)||i.displayName.toLowerCase().includes(s)||i.testID?.toLowerCase().includes(s)||i.nativeID?.toLowerCase().includes(s)||i.accessibilityLabel?.toLowerCase().includes(s)||i.componentName?.toLowerCase().includes(s)||String(i.nativeTag).includes(s)})}t=t.filter(s=>this.passesFilters(s));if(this.filters.minRenderCount!==void 0){t=t.filter(s=>s.renderCount>=this.filters.minRenderCount)}if(this.filters.maxRenderCount!==void 0){t=t.filter(s=>s.renderCount<=this.filters.maxRenderCount)}return t.sort((s,i)=>i.lastRenderTime-s.lastRenderTime)}matchesPattern(e,t){const s=e.toLowerCase();for(const i of t){const r=i.toLowerCase();if(s.includes(r)){return true}}return false}getRender(e){return this.renders.get(e)}clear(){this.renders.clear();this.notifyListeners()}resetRenderCount(e){const t=this.renders.get(e);if(t){t.renderCount=0;this.notifyListeners()}}start(){this.isTracking=true;this.isPaused=false;this.notifyStateListeners()}stop(){this.isTracking=false;this.isPaused=false;this.notifyStateListeners()}pause(){this.isPaused=true;this.notifyStateListeners()}resume(){this.isPaused=false;this.notifyStateListeners()}togglePause(){this.isPaused=!this.isPaused;this.notifyStateListeners()}getState(){return{isTracking:this.isTracking,isPaused:this.isPaused}}replaceRenders(e,t){const s=new Map;for(const[i,r]of this.renders){if(r.renderHistory&&r.renderHistory.length>0){s.set(i,r.renderHistory)}}this.renders=new Map(e.map(i=>{const r=s.get(i.id);const n=r&&!(i.renderHistory&&i.renderHistory.length>0)?{...i,renderHistory:r}:i;return[n.id,n]}));if(t&&(this.isTracking!==t.isTracking||this.isPaused!==t.isPaused)){this.isTracking=t.isTracking;this.isPaused=t.isPaused;this.notifyStateListeners()}this.notifyListeners()}hydrateRender(e){const t=this.renders.get(e.id);this.renders.set(e.id,t?{...t,...e}:e);this.notifyListeners()}getFilters(){return this.filters}setFilters(e){this.filters={...this.filters,...e};this.notifyListeners();this.notifyFilterListeners()}addIncludePattern(e,t){const s=`include${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].add(t);this.notifyListeners()}removeIncludePattern(e,t){const s=`include${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].delete(t);this.notifyListeners()}addExcludePattern(e,t){const s=`exclude${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].add(t);this.notifyListeners()}removeExcludePattern(e,t){const s=`exclude${e.charAt(0).toUpperCase()+e.slice(1)}`;this.filters[s].delete(t);this.notifyListeners()}clearFilters(){this.filters={includeTestID:new Set,includeNativeID:new Set,includeViewType:new Set,includeComponent:new Set,excludeTestID:new Set,excludeNativeID:new Set,excludeViewType:new Set,excludeComponent:new Set,includePatterns:[],excludePatterns:[],minRenderCount:void 0,maxRenderCount:void 0};this.notifyListeners()}getAvailableProps(){const e=new Set;const t=new Set;const s=new Set;const i=new Set;const r=new Set;for(const n of this.renders.values()){if(n.viewType)e.add(n.viewType);if(n.testID)t.add(n.testID);if(n.nativeID)s.add(n.nativeID);if(n.componentName)i.add(n.componentName);if(n.accessibilityLabel)r.add(n.accessibilityLabel)}return{viewTypes:Array.from(e).sort(),testIDs:Array.from(t).sort(),nativeIDs:Array.from(s).sort(),componentNames:Array.from(i).sort(),accessibilityLabels:Array.from(r).sort()}}getStats(){let e=0;for(const t of this.renders.values()){e+=t.renderCount}return{totalComponents:this.renders.size,totalRenders:e}}subscribe(e){this.listeners.add(e);e(this.getRenders());return()=>{this.listeners.delete(e)}}subscribeToState(e){this.stateListeners.add(e);e(this.getState());return()=>{this.stateListeners.delete(e)}}subscribeToSettings(e){this.settingsListeners.add(e);e(this.settings);return()=>{this.settingsListeners.delete(e)}}subscribeToFilters(e){this.filterListeners.add(e);e(this.filters);return()=>{this.filterListeners.delete(e)}}onRenderEvent(e){this.renderEventCallbacks.add(e);return()=>{this.renderEventCallbacks.delete(e)}}getRenderEventCallbackCount(){return this.renderEventCallbacks.size}shouldShowRender(e){const t=this.filters;if(t.includePatterns.length>0){if(!this.matchesAnyPatternForInfo(e,t.includePatterns)){return false}}if(t.excludePatterns.length>0){if(this.matchesAnyPatternForInfo(e,t.excludePatterns)){return false}}const s=t.includeViewType.size>0||t.includeTestID.size>0||t.includeNativeID.size>0||t.includeComponent.size>0;if(s){const i=t.includeViewType.size>0&&t.includeViewType.has(e.viewType)||t.includeTestID.size>0&&e.testID&&t.includeTestID.has(e.testID)||t.includeNativeID.size>0&&e.nativeID&&t.includeNativeID.has(e.nativeID)||t.includeComponent.size>0&&e.componentName&&t.includeComponent.has(e.componentName);if(!i){return false}}if(t.excludeViewType.has(e.viewType))return false;if(e.testID&&t.excludeTestID.has(e.testID))return false;if(e.nativeID&&t.excludeNativeID.has(e.nativeID))return false;if(e.componentName&&t.excludeComponent.has(e.componentName))return false;return true}getSettings(){return{...this.settings}}setSettings(e){if(e.batchSize!==void 0){e.batchSize=Math.max(10,Math.min(500,e.batchSize))}if(e.maxRenderHistoryPerComponent!==void 0){e.maxRenderHistoryPerComponent=Math.max(5,Math.min(50,e.maxRenderHistoryPerComponent))}if(e.enableRenderHistory&&!this.settings.trackRenderCauses){e.trackRenderCauses=true}if(e.trackRenderCauses===false&&this.settings.enableRenderHistory){e.enableRenderHistory=false}this.settings={...this.settings,...e};if(e.performanceLogging!==void 0){_PerformanceLogger.PerformanceLogger.setEnabled(e.performanceLogging)}this.notifySettingsListeners()}clearAllRenderHistory(){for(const e of this.renders.values()){e.renderHistory=[]}this.notifyListeners()}clearRenderHistory(e){const t=this.renders.get(e);if(t){t.renderHistory=[];this.notifyListeners()}}getRenderHistoryStats(){let e=0;let t=0;for(const s of this.renders.values()){if(s.renderHistory&&s.renderHistory.length>0){e+=s.renderHistory.length;t++}}return{totalEvents:e,componentsWithHistory:t,averageEventsPerComponent:t>0?e/t:0}}getBatchSize(){return this.settings.batchSize}setBatchSize(e){this.setSettings({batchSize:e})}notifyListeners(){const e=this.getRenders();for(const t of this.listeners){try{t(e)}catch(s){console.error("[Buoy]","[RenderTracker] Error in listener:",s)}}}notifyStateListeners(){const e=this.getState();for(const t of this.stateListeners){try{t(e)}catch(s){console.error("[Buoy]","[RenderTracker] Error in state listener:",s)}}}notifySettingsListeners(){const e=this.getSettings();for(const t of this.settingsListeners){try{t(e)}catch(s){console.error("[Buoy]","[RenderTracker] Error in settings listener:",s)}}}notifyFilterListeners(){const e=this.getFilters();for(const t of this.filterListeners){try{t(e)}catch(s){console.error("[Buoy]","[RenderTracker] Error in filter listener:",s)}}}}const RenderTracker=exports.RenderTracker=new RenderTrackerSingleton;var _default=exports.default=RenderTracker;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isHostViewName=isHostViewName;exports.isNamedComposite=isNamedComposite;const HOST_NAMES=new Set(["View","RCTView","Text","RCTText","RawText","RCTRawText","VirtualText","RCTVirtualText","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","Pressable","TouchableOpacity","Image","RCTImageView"]);const PLACEHOLDER_NAMES=new Set(["Unknown","Anonymous","CellRenderer","NativeComponent"]);function isNamedComposite(e){if(e.testID&&e.testID.trim())return true;const t=(e.componentName??"").trim();if(!t)return false;if(HOST_NAMES.has(t))return false;if(PLACEHOLDER_NAMES.has(t))return false;const i=(e.viewType??"").trim();if(i&&HOST_NAMES.has(i)&&t===i)return false;if(/^comp(\s|$)/i.test(t))return false;if(t.startsWith("_"))return false;return true}function isHostViewName(e){return!!e&&HOST_NAMES.has(e)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isHostViewName=isHostViewName;exports.isNamedComposite=isNamedComposite;const HOST_NAMES=new Set(["View","RCTView","Text","RCTText","RawText","RCTRawText","VirtualText","RCTVirtualText","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","Pressable","TouchableOpacity","Image","RCTImageView"]);const PLACEHOLDER_NAMES=new Set(["Unknown","Anonymous","CellRenderer","NativeComponent"]);function isNamedComposite(e){if(e.isComponent===true)return true;if(e.testID&&e.testID.trim())return true;const t=(e.componentName??"").trim();if(!t)return false;if(HOST_NAMES.has(t))return false;if(PLACEHOLDER_NAMES.has(t))return false;const r=(e.viewType??"").trim();if(r&&HOST_NAMES.has(r)&&t===r)return false;if(/^comp(\s|$)/i.test(t))return false;if(t.startsWith("_"))return false;return true}function isHostViewName(e){return!!e&&HOST_NAMES.has(e)}