@buoy-gg/highlight-updates 2.0.9 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/highlight-updates/components/HighlightUpdatesModal.js +1 -1
- package/lib/commonjs/highlight-updates/components/ModalHeaderContent.js +1 -1
- package/lib/commonjs/highlight-updates/utils/HighlightUpdatesController.js +1 -1
- package/lib/commonjs/highlight-updates/utils/RenderTracker.js +1 -1
- package/lib/module/highlight-updates/components/HighlightUpdatesModal.js +1 -1
- package/lib/module/highlight-updates/components/ModalHeaderContent.js +1 -1
- package/lib/module/highlight-updates/utils/HighlightUpdatesController.js +1 -1
- package/lib/module/highlight-updates/utils/RenderTracker.js +1 -1
- package/lib/typescript/highlight-updates/utils/RenderTracker.d.ts +0 -5
- package/package.json +20 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HighlightUpdatesModal=HighlightUpdatesModal,exports.default=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_license=require("@buoy-gg/license"),_HighlightUpdatesController=_interopRequireDefault(require("../utils/HighlightUpdatesController")),_RenderTracker=require("../utils/RenderTracker"),_RenderCauseBadge=require("./RenderCauseBadge"),_RenderDetailView=require("./RenderDetailView"),_HighlightFilterView=require("./HighlightFilterView"),_IsolatedRenderList=require("./IsolatedRenderList"),_ModalHeaderContent=require("./ModalHeaderContent"),_RenderHistoryViewer=require("./RenderHistoryViewer"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var n,s,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(n=t?a:r){if(n.has(e))return n.get(e);n.set(e,i)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((s=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(s.get||s.set)?n(i,t,s):i[t]=e[t]);return i})(e,t)}const DisabledBanner=_react.default.memo(function(){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.disabledBanner,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.buoyColors.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.disabledText,children:"Render tracking is disabled"})]})});function formatRenderDataForClipboard(){const e=_RenderTracker.RenderTracker.getRenders(),t=_RenderTracker.RenderTracker.getStats(),r=_RenderTracker.RenderTracker.getSettings(),a=(new Date).toISOString(),n=[];n.push("=".repeat(60)),n.push("RENDER TRACKING DATA EXPORT"),n.push("=".repeat(60)),n.push(`Timestamp: ${a}`),n.push(`Total Components: ${t.totalComponents}`),n.push(`Total Renders: ${t.totalRenders}`),n.push(""),n.push("Settings:"),n.push(` - Show Render Count: ${r.showRenderCount}`),n.push(` - Track Render Causes: ${r.trackRenderCauses}`),n.push(` - Batch Size: ${r.batchSize}`),n.push("");const s=[...e].sort((e,t)=>t.renderCount-e.renderCount);n.push("-".repeat(60)),n.push("COMPONENTS BY RENDER COUNT (descending)"),n.push("-".repeat(60)),n.push(""),s.forEach((e,t)=>{const r=e.lastRenderCause?.type,a=e.lastRenderCause?.componentCause,s=e.lastRenderCause&&r?`${_RenderCauseBadge.CAUSE_CONFIG[r].label}${e.lastRenderCause.changedKeys?` [${e.lastRenderCause.changedKeys.join(", ")}]`:""}${e.lastRenderCause.hookIndices?` [Hook ${e.lastRenderCause.hookIndices.join(", ")}]`:""}`:"N/A",i=a?_RenderCauseBadge.COMPONENT_CAUSE_CONFIG[a].label.toUpperCase():"N/A",o=e.lastRenderCause?.componentName||e.componentName;n.push(`${t+1}. ${e.displayName} (${e.viewType}) - ${e.renderCount} renders`),a&&r?n.push(` Why: ${o||"Component"} (${i}) → Native (${s})`):n.push(` Last Cause: ${s}`),e.testID&&n.push(` testID: ${e.testID}`),e.nativeID&&n.push(` nativeID: ${e.nativeID}`),o&&n.push(` component: ${o}`),e.accessibilityLabel&&n.push(` accessibilityLabel: ${e.accessibilityLabel}`),n.push(` nativeTag: ${e.nativeTag}`);const l=e.lastRenderTime-e.firstRenderTime,c=l>0?(e.renderCount/(l/1e3)).toFixed(2):e.renderCount;n.push(` Renders/sec: ${c}`),n.push("")}),n.push("-".repeat(60)),n.push("BY VIEW TYPE"),n.push("-".repeat(60));const i=new Map;e.forEach(e=>{const t=i.get(e.viewType)||{count:0,renders:0};t.count++,t.renders+=e.renderCount,i.set(e.viewType,t)}),[...i.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{n.push(`${e}: ${t.count} components, ${t.renders} total renders`)}),n.push(""),n.push("-".repeat(60)),n.push("BY COMPONENT NAME"),n.push("-".repeat(60));const o=new Map;if(e.forEach(e=>{const t=e.componentName||"(unknown)",r=o.get(t)||{count:0,renders:0};r.count++,r.renders+=e.renderCount,o.set(t,r)}),[...o.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{n.push(`${e}: ${t.count} instances, ${t.renders} total renders`)}),n.push(""),r.trackRenderCauses){n.push("-".repeat(60)),n.push("BY NATIVE CAUSE (what changed on the native view)"),n.push("-".repeat(60));const t=new Map;e.forEach(e=>{const r=e.lastRenderCause?.type||"unknown";t.set(r,(t.get(r)||0)+1)}),[...t.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=_RenderCauseBadge.CAUSE_CONFIG[e];n.push(`${r?.label||e}: ${t} components`)}),n.push(""),n.push("-".repeat(60)),n.push("BY COMPONENT CAUSE (why the React component re-rendered)"),n.push("-".repeat(60));const r=new Map;e.forEach(e=>{const t=e.lastRenderCause?.componentCause||"unknown";r.set(t,(r.get(t)||0)+1)}),[...r.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=_RenderCauseBadge.COMPONENT_CAUSE_CONFIG[e];n.push(`${r?.label?.toUpperCase()||e}: ${t} components`)}),n.push("");const a=e.filter(e=>"parent"===e.lastRenderCause?.componentCause);a.length>0&&(n.push("-".repeat(60)),n.push("💡 OPTIMIZATION OPPORTUNITIES"),n.push("-".repeat(60)),n.push(`${a.length} component(s) re-rendered due to parent:`),a.forEach(e=>{const t=e.lastRenderCause?.componentName||e.componentName||e.displayName;n.push(` - ${t}: Consider wrapping with React.memo()`)}),n.push(""))}return n.push("=".repeat(60)),n.push("END OF EXPORT"),n.push("=".repeat(60)),n.join("\n")}function HighlightUpdatesModal({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:n=!1,initialNativeTag:s,onInitialNativeTagHandled:i}){const o=(0,_license.useIsPro)(),[l,c]=(0,_react.useState)(!1),[d,u]=(0,_react.useState)(()=>_HighlightUpdatesController.default.getFrozen()),[h,g]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getStats().totalComponents>0),[p,_]=(0,_react.useState)(null),[C,R]=(0,_react.useState)(0),[f,T]=(0,_react.useState)(!1),[m,y]=(0,_react.useState)("filters"),[k,S]=(0,_react.useState)("details"),[b,x]=(0,_react.useState)(0),[w,v]=(0,_react.useState)(""),[U,I]=(0,_react.useState)(!1),N=(0,_react.useRef)(null),E=(0,_react.useRef)([]),H=(0,_react.useRef)(_RenderTracker.RenderTracker.getFilters()),[P,j]=(0,_react.useState)(()=>{const e=_RenderTracker.RenderTracker.getFilters();return e.includePatterns.length+e.excludePatterns.length}),[D,F]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getFilters()),[$,M]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getSettings()),O=(0,_react.useRef)(!1),V=(0,_react.useRef)(!1),A=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{e&&!O.current&&(async()=>{try{const e=await(0,_sharedUi.safeGetItem)(_sharedUi.devToolsStorageKeys.highlightUpdates.isTracking());null!==e&&"true"===e&&!_HighlightUpdatesController.default.isEnabled()&&(_HighlightUpdatesController.default.isInitialized()||_HighlightUpdatesController.default.initialize(),_HighlightUpdatesController.default.enable()),O.current=!0}catch(e){}})()},[e]),(0,_react.useEffect)(()=>{O.current&&(async()=>{try{await(0,_sharedUi.safeSetItem)(_sharedUi.devToolsStorageKeys.highlightUpdates.isTracking(),l.toString())}catch(e){}})()},[l]),(0,_react.useEffect)(()=>{e&&!V.current&&(async()=>{try{const e=await(0,_sharedUi.safeGetItem)(_sharedUi.devToolsStorageKeys.highlightUpdates.filters());if(e){const t=JSON.parse(e),r={includeTestID:new Set(t.includeTestID||[]),includeNativeID:new Set(t.includeNativeID||[]),includeViewType:new Set(t.includeViewType||[]),includeComponent:new Set(t.includeComponent||[]),excludeTestID:new Set(t.excludeTestID||[]),excludeNativeID:new Set(t.excludeNativeID||[]),excludeViewType:new Set(t.excludeViewType||[]),excludeComponent:new Set(t.excludeComponent||[]),includePatterns:t.includePatterns||[],excludePatterns:t.excludePatterns||[]};_RenderTracker.RenderTracker.setFilters(r);const a=_RenderTracker.RenderTracker.getFilters();H.current=a,F(a),j(a.includePatterns.length+a.excludePatterns.length)}V.current=!0}catch(e){}})()},[e]),(0,_react.useEffect)(()=>{V.current&&(async()=>{try{const e={includeTestID:Array.from(D.includeTestID),includeNativeID:Array.from(D.includeNativeID),includeViewType:Array.from(D.includeViewType),includeComponent:Array.from(D.includeComponent),excludeTestID:Array.from(D.excludeTestID),excludeNativeID:Array.from(D.excludeNativeID),excludeViewType:Array.from(D.excludeViewType),excludeComponent:Array.from(D.excludeComponent),includePatterns:D.includePatterns,excludePatterns:D.excludePatterns};await(0,_sharedUi.safeSetItem)(_sharedUi.devToolsStorageKeys.highlightUpdates.filters(),JSON.stringify(e))}catch(e){}})()},[D]),(0,_react.useEffect)(()=>{e&&!A.current&&(async()=>{try{const e=await(0,_sharedUi.safeGetItem)(_sharedUi.devToolsStorageKeys.highlightUpdates.settings());if(e){const t=JSON.parse(e),{performanceLogging:r,...a}=t;_RenderTracker.RenderTracker.setSettings(a),M(_RenderTracker.RenderTracker.getSettings())}A.current=!0}catch(e){A.current=!0}})()},[e]),(0,_react.useEffect)(()=>{A.current&&(async()=>{try{const{performanceLogging:e,...t}=$;await(0,_sharedUi.safeSetItem)(_sharedUi.devToolsStorageKeys.highlightUpdates.settings(),JSON.stringify(t))}catch(e){}})()},[$]),(0,_react.useEffect)(()=>{const e=_RenderTracker.RenderTracker.subscribeToState(e=>{c(e.isTracking)});return()=>{e()}},[]),(0,_react.useEffect)(()=>{const e=_HighlightUpdatesController.default.subscribeToFreeze(e=>{u(e)});return()=>{e()}},[]),(0,_react.useEffect)(()=>{U&&requestAnimationFrame(()=>{N.current?.focus()})},[U]),(0,_react.useEffect)(()=>{e||_HighlightUpdatesController.default.setSpotlight(null)},[e]),(0,_react.useEffect)(()=>{if(e&&null!=s){const e=_RenderTracker.RenderTracker.getRender(String(s));e&&(_(e),R(0),T(!1),_HighlightUpdatesController.default.setSpotlight(e.nativeTag)),i?.()}},[e,s,i]);const B=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.isInitialized()||_HighlightUpdatesController.default.initialize(),_HighlightUpdatesController.default.toggle()},[]),q=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.toggleFreeze()},[]),z=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.clearRenderCounts(),g(!1)},[]),K=(0,_react.useMemo)(()=>h?formatRenderDataForClipboard():"",[h]),L=(0,_react.useCallback)(e=>{v(e)},[]),G=(0,_react.useCallback)((e,t,r)=>{_(e),R(t),S("details"),x(0),E.current=r,_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},[]),W=(0,_react.useCallback)(e=>{E.current=e},[]),Y=(0,_react.useCallback)(()=>{_(null),R(0),_HighlightUpdatesController.default.setSpotlight(null)},[]),J=(0,_react.useCallback)(()=>{const e=E.current;if(C>0){const t=C-1,r=e[t];r&&(_(r),R(t),_HighlightUpdatesController.default.setSpotlight(r.nativeTag))}},[C]),X=(0,_react.useCallback)(()=>{const e=E.current;if(C<e.length-1){const t=C+1,r=e[t];r&&(_(r),R(t),_HighlightUpdatesController.default.setSpotlight(r.nativeTag))}},[C]),Z=(0,_react.useCallback)(()=>{T(!1)},[]),Q=(0,_react.useCallback)(()=>{T(!0)},[]),ee=(0,_react.useCallback)(()=>{I(!0)},[]),te=(0,_react.useCallback)(()=>{I(!1)},[]),re=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setFilters(e);const t=_RenderTracker.RenderTracker.getFilters();H.current=t,F(t),j(t.includePatterns.length+t.excludePatterns.length)},[]),ae=(0,_react.useCallback)((e,t)=>{const r=_RenderTracker.RenderTracker.getFilters(),a={};"include"===t?r.includePatterns.some(t=>t.type===e.type&&t.value===e.value)||(a.includePatterns=[...r.includePatterns,e]):r.excludePatterns.some(t=>t.type===e.type&&t.value===e.value)||(a.excludePatterns=[...r.excludePatterns,e]),Object.keys(a).length>0&&(re(a),_(null),R(0),_HighlightUpdatesController.default.setSpotlight(null))},[re]),ne=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setSettings(e),M(_RenderTracker.RenderTracker.getSettings())},[]),se=(0,_react.useCallback)(e=>{g(e.totalComponents>0)},[]),ie=(0,_react.useCallback)(()=>f?(0,_jsxRuntime.jsx)(_ModalHeaderContent.FilterViewHeader,{onBack:Z,activeTab:m,onTabChange:y,activeFilterCount:P}):p?(0,_jsxRuntime.jsx)(_ModalHeaderContent.DetailViewHeader,{onBack:Y,activeTab:k,onTabChange:S,hasHistory:(p.renderHistory?.length??0)>0}):(0,_jsxRuntime.jsx)(_ModalHeaderContent.MainListHeader,{onBack:r,isSearchActive:U,searchText:w,onSearchChange:L,onSearchToggle:ee,onSearchClose:te,onFilterToggle:Q,onToggleTracking:B,onToggleFreeze:q,onClear:z,copyData:K,isTracking:l,isFrozen:d,activeFilterCount:P,hasRenders:h,searchInputRef:N}),[f,p,r,U,w,l,d,P,h,m,k,Z,Y,L,ee,te,Q,B,q,z,K]),oe=n?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.highlightUpdates.modal();if(!e)return null;const le=E.current.length,ce=p?"details"===k?(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:C,totalItems:le,onPrevious:J,onNext:X,itemLabel:"Component",subtitle:p.componentName||p.displayName||p.viewType}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryFooter,{render:p,selectedEventIndex:b,onEventIndexChange:x,isPro:o}):null;return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:e,onClose:t,onMinimize:a,persistenceKey:oe,header:{showToggleButton:!0,customContent:ie()},enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,styles:{},footer:ce,footerHeight:p&&("details"===k||(p.renderHistory?.length??0)>1)?68:0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{nativeID:"__rn_buoy__highlight-modal",style:styles.container,children:p?"details"===k?(0,_jsxRuntime.jsx)(_RenderDetailView.RenderDetailView,{render:p,disableInternalFooter:!0,onAddFilter:ae,isPro:o}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryViewer,{render:p,disableInternalFooter:!0,selectedEventIndex:b,onEventIndexChange:x,isPro:o}):f?(0,_jsxRuntime.jsx)(_HighlightFilterView.HighlightFilterView,{filters:D,onFilterChange:re,settings:$,onSettingsChange:ne,availableProps:_RenderTracker.RenderTracker.getAvailableProps(),activeTab:m}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[!l&&(0,_jsxRuntime.jsx)(DisabledBanner,{}),(0,_jsxRuntime.jsx)(_IsolatedRenderList.IsolatedRenderList,{searchText:w,filters:D,onSelectRender:G,onStatsChange:se,onRendersChange:W,isTracking:l,isPro:o})]})})})}const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:_sharedUi.buoyColors.base},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.buoyColors.warning+"15",borderRadius:8,borderWidth:1,borderColor:_sharedUi.buoyColors.warning+"20"},disabledText:{color:_sharedUi.buoyColors.warning,fontSize:11,flex:1}});var _default=exports.default=HighlightUpdatesModal;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HighlightUpdatesModal=HighlightUpdatesModal,exports.default=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_license=require("@buoy-gg/license"),_HighlightUpdatesController=_interopRequireDefault(require("../utils/HighlightUpdatesController")),_RenderTracker=require("../utils/RenderTracker"),_RenderCauseBadge=require("./RenderCauseBadge"),_RenderDetailView=require("./RenderDetailView"),_HighlightFilterView=require("./HighlightFilterView"),_IsolatedRenderList=require("./IsolatedRenderList"),_ModalHeaderContent=require("./ModalHeaderContent"),_RenderHistoryViewer=require("./RenderHistoryViewer"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var n,s,i={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return i;if(n=t?a:r){if(n.has(e))return n.get(e);n.set(e,i)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((s=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(s.get||s.set)?n(i,t,s):i[t]=e[t]);return i})(e,t)}const DisabledBanner=_react.default.memo(function(){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.disabledBanner,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.buoyColors.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.disabledText,children:"Render tracking is disabled"})]})});function formatRenderDataForClipboard(){const e=_RenderTracker.RenderTracker.getRenders(),t=_RenderTracker.RenderTracker.getStats(),r=_RenderTracker.RenderTracker.getSettings(),a=(new Date).toISOString(),n=[];n.push("=".repeat(60)),n.push("RENDER TRACKING DATA EXPORT"),n.push("=".repeat(60)),n.push(`Timestamp: ${a}`),n.push(`Total Components: ${t.totalComponents}`),n.push(`Total Renders: ${t.totalRenders}`),n.push(""),n.push("Settings:"),n.push(` - Show Render Count: ${r.showRenderCount}`),n.push(` - Track Render Causes: ${r.trackRenderCauses}`),n.push(` - Batch Size: ${r.batchSize}`),n.push("");const s=[...e].sort((e,t)=>t.renderCount-e.renderCount);n.push("-".repeat(60)),n.push("COMPONENTS BY RENDER COUNT (descending)"),n.push("-".repeat(60)),n.push(""),s.forEach((e,t)=>{const r=e.lastRenderCause?.type,a=e.lastRenderCause?.componentCause,s=e.lastRenderCause&&r?`${_RenderCauseBadge.CAUSE_CONFIG[r].label}${e.lastRenderCause.changedKeys?` [${e.lastRenderCause.changedKeys.join(", ")}]`:""}${e.lastRenderCause.hookIndices?` [Hook ${e.lastRenderCause.hookIndices.join(", ")}]`:""}`:"N/A",i=a?_RenderCauseBadge.COMPONENT_CAUSE_CONFIG[a].label.toUpperCase():"N/A",o=e.lastRenderCause?.componentName||e.componentName;n.push(`${t+1}. ${e.displayName} (${e.viewType}) - ${e.renderCount} renders`),a&&r?n.push(` Why: ${o||"Component"} (${i}) → Native (${s})`):n.push(` Last Cause: ${s}`),e.testID&&n.push(` testID: ${e.testID}`),e.nativeID&&n.push(` nativeID: ${e.nativeID}`),o&&n.push(` component: ${o}`),e.accessibilityLabel&&n.push(` accessibilityLabel: ${e.accessibilityLabel}`),n.push(` nativeTag: ${e.nativeTag}`);const l=e.lastRenderTime-e.firstRenderTime,c=l>0?(e.renderCount/(l/1e3)).toFixed(2):e.renderCount;n.push(` Renders/sec: ${c}`),n.push("")}),n.push("-".repeat(60)),n.push("BY VIEW TYPE"),n.push("-".repeat(60));const i=new Map;e.forEach(e=>{const t=i.get(e.viewType)||{count:0,renders:0};t.count++,t.renders+=e.renderCount,i.set(e.viewType,t)}),[...i.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{n.push(`${e}: ${t.count} components, ${t.renders} total renders`)}),n.push(""),n.push("-".repeat(60)),n.push("BY COMPONENT NAME"),n.push("-".repeat(60));const o=new Map;if(e.forEach(e=>{const t=e.componentName||"(unknown)",r=o.get(t)||{count:0,renders:0};r.count++,r.renders+=e.renderCount,o.set(t,r)}),[...o.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{n.push(`${e}: ${t.count} instances, ${t.renders} total renders`)}),n.push(""),r.trackRenderCauses){n.push("-".repeat(60)),n.push("BY NATIVE CAUSE (what changed on the native view)"),n.push("-".repeat(60));const t=new Map;e.forEach(e=>{const r=e.lastRenderCause?.type||"unknown";t.set(r,(t.get(r)||0)+1)}),[...t.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=_RenderCauseBadge.CAUSE_CONFIG[e];n.push(`${r?.label||e}: ${t} components`)}),n.push(""),n.push("-".repeat(60)),n.push("BY COMPONENT CAUSE (why the React component re-rendered)"),n.push("-".repeat(60));const r=new Map;e.forEach(e=>{const t=e.lastRenderCause?.componentCause||"unknown";r.set(t,(r.get(t)||0)+1)}),[...r.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=_RenderCauseBadge.COMPONENT_CAUSE_CONFIG[e];n.push(`${r?.label?.toUpperCase()||e}: ${t} components`)}),n.push("");const a=e.filter(e=>"parent"===e.lastRenderCause?.componentCause);a.length>0&&(n.push("-".repeat(60)),n.push("💡 OPTIMIZATION OPPORTUNITIES"),n.push("-".repeat(60)),n.push(`${a.length} component(s) re-rendered due to parent:`),a.forEach(e=>{const t=e.lastRenderCause?.componentName||e.componentName||e.displayName;n.push(` - ${t}: Consider wrapping with React.memo()`)}),n.push(""))}return n.push("=".repeat(60)),n.push("END OF EXPORT"),n.push("=".repeat(60)),n.join("\n")}function HighlightUpdatesModal({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:n=!1,initialNativeTag:s,onInitialNativeTagHandled:i}){const o=(0,_license.useIsPro)(),[l,c]=(0,_react.useState)(!1),[d,u]=(0,_react.useState)(()=>_HighlightUpdatesController.default.getFrozen()),[h,g]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getStats().totalComponents>0),[p,_]=(0,_react.useState)(null),[C,R]=(0,_react.useState)(0),[T,f]=(0,_react.useState)(!1),[m,y]=(0,_react.useState)("filters"),[k,S]=(0,_react.useState)("details"),[b,x]=(0,_react.useState)(0),[w,v]=(0,_react.useState)(""),[U,I]=(0,_react.useState)(!1),N=(0,_react.useRef)(null),E=(0,_react.useRef)([]),H=(0,_react.useRef)(_RenderTracker.RenderTracker.getFilters()),[P,j]=(0,_react.useState)(()=>{const e=_RenderTracker.RenderTracker.getFilters();return e.includePatterns.length+e.excludePatterns.length}),[D,F]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getFilters()),[$,M]=(0,_react.useState)(()=>_RenderTracker.RenderTracker.getSettings()),O=(0,_react.useRef)(!1),V=(0,_react.useRef)(!1),A=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{e&&!O.current&&(async()=>{try{const e=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.highlightUpdates.isTracking());null!==e&&"true"===e&&!_HighlightUpdatesController.default.isEnabled()&&(_HighlightUpdatesController.default.isInitialized()||_HighlightUpdatesController.default.initialize(),_HighlightUpdatesController.default.enable()),O.current=!0}catch(e){}})()},[e]),(0,_react.useEffect)(()=>{O.current&&(async()=>{try{await _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.highlightUpdates.isTracking(),l.toString())}catch(e){}})()},[l]),(0,_react.useEffect)(()=>{e&&!V.current&&(async()=>{try{const e=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.highlightUpdates.filters());if(e){const t=JSON.parse(e),r={includeTestID:new Set(t.includeTestID||[]),includeNativeID:new Set(t.includeNativeID||[]),includeViewType:new Set(t.includeViewType||[]),includeComponent:new Set(t.includeComponent||[]),excludeTestID:new Set(t.excludeTestID||[]),excludeNativeID:new Set(t.excludeNativeID||[]),excludeViewType:new Set(t.excludeViewType||[]),excludeComponent:new Set(t.excludeComponent||[]),includePatterns:t.includePatterns||[],excludePatterns:t.excludePatterns||[]};_RenderTracker.RenderTracker.setFilters(r);const a=_RenderTracker.RenderTracker.getFilters();H.current=a,F(a),j(a.includePatterns.length+a.excludePatterns.length)}V.current=!0}catch(e){}})()},[e]),(0,_react.useEffect)(()=>{V.current&&(async()=>{try{const e={includeTestID:Array.from(D.includeTestID),includeNativeID:Array.from(D.includeNativeID),includeViewType:Array.from(D.includeViewType),includeComponent:Array.from(D.includeComponent),excludeTestID:Array.from(D.excludeTestID),excludeNativeID:Array.from(D.excludeNativeID),excludeViewType:Array.from(D.excludeViewType),excludeComponent:Array.from(D.excludeComponent),includePatterns:D.includePatterns,excludePatterns:D.excludePatterns};await _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.highlightUpdates.filters(),JSON.stringify(e))}catch(e){}})()},[D]),(0,_react.useEffect)(()=>{e&&!A.current&&(async()=>{try{const e=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.highlightUpdates.settings());if(e){const t=JSON.parse(e),{performanceLogging:r,...a}=t;_RenderTracker.RenderTracker.setSettings(a),M(_RenderTracker.RenderTracker.getSettings())}A.current=!0}catch(e){A.current=!0}})()},[e]),(0,_react.useEffect)(()=>{A.current&&(async()=>{try{const{performanceLogging:e,...t}=$;await _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.highlightUpdates.settings(),JSON.stringify(t))}catch(e){}})()},[$]),(0,_react.useEffect)(()=>{const e=_RenderTracker.RenderTracker.subscribeToState(e=>{c(e.isTracking)});return()=>{e()}},[]),(0,_react.useEffect)(()=>{const e=_HighlightUpdatesController.default.subscribeToFreeze(e=>{u(e)});return()=>{e()}},[]),(0,_react.useEffect)(()=>{U&&requestAnimationFrame(()=>{N.current?.focus()})},[U]),(0,_react.useEffect)(()=>{e||_HighlightUpdatesController.default.setSpotlight(null)},[e]),(0,_react.useEffect)(()=>{if(e&&null!=s){const e=_RenderTracker.RenderTracker.getRender(String(s));e&&(_(e),R(0),f(!1),_HighlightUpdatesController.default.setSpotlight(e.nativeTag)),i?.()}},[e,s,i]);const B=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.isInitialized()||_HighlightUpdatesController.default.initialize(),_HighlightUpdatesController.default.toggle()},[]),q=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.toggleFreeze()},[]),z=(0,_react.useCallback)(()=>{_HighlightUpdatesController.default.clearRenderCounts(),g(!1)},[]),K=(0,_react.useMemo)(()=>h?formatRenderDataForClipboard():"",[h]),L=(0,_react.useCallback)(e=>{v(e)},[]),W=(0,_react.useCallback)((e,t,r)=>{_(e),R(t),S("details"),x(0),E.current=r,_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},[]),G=(0,_react.useCallback)(e=>{E.current=e},[]),Y=(0,_react.useCallback)(()=>{_(null),R(0),_HighlightUpdatesController.default.setSpotlight(null)},[]),J=(0,_react.useCallback)(()=>{const e=E.current;if(C>0){const t=C-1,r=e[t];r&&(_(r),R(t),_HighlightUpdatesController.default.setSpotlight(r.nativeTag))}},[C]),X=(0,_react.useCallback)(()=>{const e=E.current;if(C<e.length-1){const t=C+1,r=e[t];r&&(_(r),R(t),_HighlightUpdatesController.default.setSpotlight(r.nativeTag))}},[C]),Z=(0,_react.useCallback)(()=>{f(!1)},[]),Q=(0,_react.useCallback)(()=>{f(!0)},[]),ee=(0,_react.useCallback)(()=>{I(!0)},[]),te=(0,_react.useCallback)(()=>{I(!1)},[]),re=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setFilters(e);const t=_RenderTracker.RenderTracker.getFilters();H.current=t,F(t),j(t.includePatterns.length+t.excludePatterns.length)},[]),ae=(0,_react.useCallback)((e,t)=>{const r=_RenderTracker.RenderTracker.getFilters(),a={};"include"===t?r.includePatterns.some(t=>t.type===e.type&&t.value===e.value)||(a.includePatterns=[...r.includePatterns,e]):r.excludePatterns.some(t=>t.type===e.type&&t.value===e.value)||(a.excludePatterns=[...r.excludePatterns,e]),Object.keys(a).length>0&&(re(a),_(null),R(0),_HighlightUpdatesController.default.setSpotlight(null))},[re]),ne=(0,_react.useCallback)(e=>{_RenderTracker.RenderTracker.setSettings(e),M(_RenderTracker.RenderTracker.getSettings())},[]),se=(0,_react.useCallback)(e=>{g(e.totalComponents>0)},[]),ie=(0,_react.useCallback)(()=>T?(0,_jsxRuntime.jsx)(_ModalHeaderContent.FilterViewHeader,{onBack:Z,activeTab:m,onTabChange:y,activeFilterCount:P}):p?(0,_jsxRuntime.jsx)(_ModalHeaderContent.DetailViewHeader,{onBack:Y,activeTab:k,onTabChange:S,hasHistory:(p.renderHistory?.length??0)>0}):(0,_jsxRuntime.jsx)(_ModalHeaderContent.MainListHeader,{onBack:r,isSearchActive:U,searchText:w,onSearchChange:L,onSearchToggle:ee,onSearchClose:te,onFilterToggle:Q,onToggleTracking:B,onToggleFreeze:q,onClear:z,copyData:K,isTracking:l,isFrozen:d,activeFilterCount:P,hasRenders:h,searchInputRef:N}),[T,p,r,U,w,l,d,P,h,m,k,Z,Y,L,ee,te,Q,B,q,z,K]),oe=n?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.highlightUpdates.modal();if(!e)return null;const le=E.current.length,ce=p?"details"===k?(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:C,totalItems:le,onPrevious:J,onNext:X,itemLabel:"Component",subtitle:p.componentName||p.displayName||p.viewType}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryFooter,{render:p,selectedEventIndex:b,onEventIndexChange:x,isPro:o}):null;return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:e,onClose:t,onMinimize:a,persistenceKey:oe,header:{showToggleButton:!0,customContent:ie()},enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,styles:{},footer:ce,footerHeight:p&&("details"===k||(p.renderHistory?.length??0)>1)?68:0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{nativeID:"__rn_buoy__highlight-modal",style:styles.container,children:p?"details"===k?(0,_jsxRuntime.jsx)(_RenderDetailView.RenderDetailView,{render:p,disableInternalFooter:!0,onAddFilter:ae,isPro:o}):(0,_jsxRuntime.jsx)(_RenderHistoryViewer.RenderHistoryViewer,{render:p,disableInternalFooter:!0,selectedEventIndex:b,onEventIndexChange:x,isPro:o}):T?(0,_jsxRuntime.jsx)(_HighlightFilterView.HighlightFilterView,{filters:D,onFilterChange:re,settings:$,onSettingsChange:ne,availableProps:_RenderTracker.RenderTracker.getAvailableProps(),activeTab:m}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[!l&&(0,_jsxRuntime.jsx)(DisabledBanner,{}),(0,_jsxRuntime.jsx)(_IsolatedRenderList.IsolatedRenderList,{searchText:w,filters:D,onSelectRender:W,onStatsChange:se,onRendersChange:G,isTracking:l,isPro:o})]})})})}const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:_sharedUi.buoyColors.base},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.buoyColors.warning+"15",borderRadius:8,borderWidth:1,borderColor:_sharedUi.buoyColors.warning+"20"},disabledText:{color:_sharedUi.buoyColors.warning,fontSize:11,flex:1}});var _default=exports.default=HighlightUpdatesModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchSection=exports.MainListHeader=exports.HeaderActions=exports.FilterViewHeader=exports.DetailViewHeader=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_StatsDisplay=require("./StatsDisplay"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var a,s
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchSection=exports.MainListHeader=exports.HeaderActions=exports.FilterViewHeader=exports.DetailViewHeader=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_StatsDisplay=require("./StatsDisplay"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var a,i,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(a=r?o:t){if(a.has(e))return a.get(e);a.set(e,s)}for(const r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(s,r,i):s[r]=e[r]);return s})(e,r)}const SearchSectionInner=(0,_react.memo)(function({isActive:e,searchText:r,onSearchChange:t,onSearchClose:o}){return e?(0,_jsxRuntime.jsxs)(_reactNative.View,{nativeID:"__rn_buoy__search-container",style:styles.headerSearchContainer,children:[(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.buoyColors.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.headerSearchInput,placeholder:"Search testID, nativeID, component...",placeholderTextColor:_sharedUi.buoyColors.textMuted,value:r,onChangeText:t,onSubmitEditing:o,onBlur:o,accessibilityLabel:"Search renders",autoCapitalize:"none",autoCorrect:!1,returnKeyType:"search",autoFocus:!0}),r.length>0?(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>{t(""),o()},style:styles.headerSearchClear,children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:14,color:_sharedUi.buoyColors.textSecondary})}):null]}):null}),SearchSection=exports.SearchSection=SearchSectionInner,HeaderActionsInner=(0,_react.memo)(function({onSearchToggle:e,onFilterToggle:r,onToggleTracking:t,onToggleFreeze:o,onClear:a,copyData:i,isTracking:s,isFrozen:n,activeFilterCount:l,hasRenders:d}){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:e,style:styles.headerActionButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.buoyColors.textSecondary})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:r,style:[styles.headerActionButton,l>0&&styles.activeFilterButton],children:(0,_jsxRuntime.jsx)(_sharedUi.Filter,{size:14,color:l>0?_sharedUi.buoyColors.primary:_sharedUi.buoyColors.textMuted})}),(0,_jsxRuntime.jsx)(_sharedUi.CopyButton,{value:i,size:14,buttonStyle:d?styles.headerActionButton:styles.headerActionButtonCopyDisabled,disabled:!d,colors:{idle:d?_sharedUi.buoyColors.textSecondary:_sharedUi.buoyColors.textMuted}}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:o,style:[styles.headerActionButton,n&&styles.freezeButton,!s&&styles.headerActionButtonDisabled],disabled:!s,children:(0,_jsxRuntime.jsx)(_sharedUi.Pause,{size:14,color:s&&n?_sharedUi.buoyColors.primary:_sharedUi.buoyColors.textMuted})}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:s,onToggle:t,accessibilityLabel:"Toggle render tracking"}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:a,style:[styles.headerActionButton,!d&&styles.headerActionButtonDisabled],disabled:!d,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:14,color:_sharedUi.buoyColors.textMuted})})]})}),HeaderActions=exports.HeaderActions=HeaderActionsInner,MainListHeader=exports.MainListHeader=(0,_react.memo)(function({onBack:e,isSearchActive:r,searchText:t,onSearchChange:o,onSearchToggle:a,onSearchClose:i,onFilterToggle:s,onToggleTracking:n,onToggleFreeze:l,onClear:d,copyData:c,isTracking:u,isFrozen:h,activeFilterCount:_,hasRenders:x,searchInputRef:y}){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[e&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:e}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:r?(0,_jsxRuntime.jsx)(SearchSection,{isActive:r,searchText:t,onSearchChange:o,onSearchClose:i,searchInputRef:y}):(0,_jsxRuntime.jsx)(_StatsDisplay.StatsDisplay,{})}),(0,_jsxRuntime.jsx)(HeaderActions,{onSearchToggle:a,onFilterToggle:s,onToggleTracking:n,onToggleFreeze:l,onClear:d,copyData:c,isTracking:u,isFrozen:h,activeFilterCount:_,hasRenders:x})]})}),FilterViewHeader=exports.FilterViewHeader=(0,_react.memo)(function({onBack:e,activeTab:r,onTabChange:t,activeFilterCount:o=0}){const a=[{key:"filters",label:"Filters"+(o>0?` (${o})`:"")},{key:"settings",label:"Settings"}];return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:e}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",noMargin:!0,children:(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:a,activeTab:r,onTabChange:e=>t(e)})}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Actions,{})]})}),DetailViewHeader=exports.DetailViewHeader=(0,_react.memo)(function({onBack:e,activeTab:r,onTabChange:t,hasHistory:o=!0}){const a=[{key:"details",label:"Details"},{key:"history",label:"History",disabled:!o}];return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:e}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",noMargin:!0,children:(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:a,activeTab:r,onTabChange:e=>t(e)})}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Actions,{})]})}),styles=_reactNative.StyleSheet.create({headerSearchContainer:{flexDirection:"row",alignItems:"center",backgroundColor:_sharedUi.buoyColors.input,borderRadius:10,borderWidth:1,borderColor:_sharedUi.buoyColors.border,paddingHorizontal:12,paddingVertical:5},headerSearchInput:{flex:1,color:_sharedUi.buoyColors.text,fontSize:13,marginLeft:6,paddingVertical:2},headerSearchClear:{marginLeft:6,padding:4},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.buoyColors.hover,borderWidth:1,borderColor:_sharedUi.buoyColors.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonCopyDisabled:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.buoyColors.hover,borderWidth:1,borderColor:_sharedUi.buoyColors.border,alignItems:"center",justifyContent:"center",opacity:.55},activeFilterButton:{backgroundColor:_sharedUi.buoyColors.primary+"15",borderColor:_sharedUi.buoyColors.primary+"40"},freezeButton:{backgroundColor:_sharedUi.buoyColors.primary+"15",borderColor:_sharedUi.buoyColors.primary+"40"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _ProfilerInterceptor=require("./ProfilerInterceptor"),_RenderTracker=require("./RenderTracker"),_PerformanceLogger=require("./PerformanceLogger"),_RenderCauseDetector=require("./RenderCauseDetector");let globalEnabled=!1,initialized=!1,hook=null,highlightCallback=null,badgePressCallback=null,traceUpdatesUnsubscribe=null,isProcessing=!1,isFrozen=!1;const freezeListeners=new Set,stateListeners=new Set,nodeRenderCounts=new Map,COLORS=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"],DEBUG=!1;function debugLog(e,t){}function getPublicInstance(e){if(!e)return null;const t=e;return t.canonical?.publicInstance?t.canonical.publicInstance:t.canonical&&"function"==typeof t.canonical.measure?t.canonical:"function"==typeof t.measure?t:null}function getNativeTag(e){const t=e;if(null!=t.__nativeTag)return t.__nativeTag;if(null!=t._nativeTag)return t._nativeTag;if(null!=t.nativeTag)return t.nativeTag;if(t.canonical){if(null!=t.canonical.__nativeTag)return t.canonical.__nativeTag;if(null!=t.canonical._nativeTag)return t.canonical._nativeTag}return null}function extractComponentInfo(e){const t=e,n={viewType:"Unknown"};t?.canonical?.viewConfig?.uiViewClassName?n.viewType=t.canonical.viewConfig.uiViewClassName:t?.viewConfig?.uiViewClassName&&(n.viewType=t.viewConfig.uiViewClassName);const r=t?.canonical?.internalInstanceHandle,i=t?.canonical?.currentProps,a=t?.canonical?.pendingProps,o=r?.pendingProps,s=r?.memoizedProps;return n.testID=i?.testID||a?.testID||o?.testID||s?.testID||void 0,n.nativeID=i?.nativeID||a?.nativeID||o?.nativeID||s?.nativeID||void 0,n.accessibilityLabel=i?.accessibilityLabel||a?.accessibilityLabel||o?.accessibilityLabel||s?.accessibilityLabel||void 0,n.componentName=getOwningComponentName(r)||void 0,n}function describeNodeForLog(e){const t=e,n=getPublicInstance(e),r={nativeTag:(getNativeTag(e)||getNativeTag(n))??"unknown",type:t?.canonical?"Fabric":"Legacy",hasMeasure:"function"==typeof n?.measure};if(t){if(r.stateNodeKeys=Object.keys(t).slice(0,20),t.node&&(r.nodeKeys=Object.keys(t.node).slice(0,20)),t.viewConfig&&(r.viewConfig={uiViewClassName:t.viewConfig.uiViewClassName,validAttributes:t.viewConfig.validAttributes?Object.keys(t.viewConfig.validAttributes).slice(0,10):void 0}),t.canonical){const e=t.canonical;if(r.canonicalKeys=Object.keys(e).slice(0,20),e.viewConfig&&(r.canonicalViewConfig={uiViewClassName:e.viewConfig.uiViewClassName}),null!=e.nativeTag&&(r.canonicalNativeTag=e.nativeTag),e.internalInstanceHandle){const t=e.internalInstanceHandle;if(r.fiberKeys=Object.keys(t).slice(0,30),t.type&&(r.fiberType="function"==typeof t.type?t.type.name||t.type.displayName||"function":t.type),t.elementType&&(r.fiberElementType="function"==typeof t.elementType?t.elementType.name||t.elementType.displayName||"function":t.elementType),t._debugOwner){const e=t._debugOwner;r.fiberDebugOwner=e.type?.name||e.type?.displayName||e.elementType?.name||"unknown"}t._debugSource&&(r.fiberDebugSource=t._debugSource),null!=t.tag&&(r.fiberTag=t.tag),t.pendingProps&&(t.pendingProps.nativeID&&(r.fiberPendingNativeID=t.pendingProps.nativeID),t.pendingProps.testID&&(r.fiberPendingTestID=t.pendingProps.testID)),t.memoizedProps&&(t.memoizedProps.nativeID&&(r.fiberMemoizedNativeID=t.memoizedProps.nativeID),t.memoizedProps.testID&&(r.fiberMemoizedTestID=t.memoizedProps.testID))}if(e.publicInstance){const t=e.publicInstance;r.publicInstanceKeys=Object.keys(t).slice(0,20),null!=t.nativeID&&(r.nativeID=t.nativeID),null!=t._nativeID&&(r._nativeID=t._nativeID),t.props&&(r.publicInstanceProps=Object.keys(t.props).slice(0,15),t.props.nativeID&&(r.propsNativeID=t.props.nativeID),t.props.testID&&(r.propsTestID=t.props.testID),t.props.accessibilityLabel&&(r.accessibilityLabel=t.props.accessibilityLabel))}e.currentProps&&(r.currentPropsKeys=Object.keys(e.currentProps).slice(0,15),null!=e.currentProps.nativeID&&(r.currentPropsNativeID=e.currentProps.nativeID),null!=e.currentProps.testID&&(r.currentPropsTestID=e.currentProps.testID),null!=e.currentProps.accessibilityLabel&&(r.currentPropsAccessLabel=e.currentProps.accessibilityLabel)),e.pendingProps&&(r.pendingPropsKeys=Object.keys(e.pendingProps).slice(0,15),null!=e.pendingProps.nativeID&&(r.pendingPropsNativeID=e.pendingProps.nativeID),null!=e.pendingProps.testID&&(r.pendingPropsTestID=e.pendingProps.testID))}if(t._debugOwner){const e=t._debugOwner;r.debugOwnerType=e.type?.name||e.type?.displayName||typeof e.type}t._debugSource&&(r.debugSource=t._debugSource)}return r}const DEBUG_LOGGING=!1;let renderingLock=!1,renderingLockTimeout=null;const RENDER_LOCK_DURATION=350,renderedOverlayTags=new Set;function isOurOverlayTag(e){return null!=e&&renderedOverlayTags.has(e)}const DEV_TOOLS_COMPONENT_NAMES=new Set(["JsModalComponent","JsModal","HighlightUpdatesModal","HighlightFilterView","RenderDetailView","RenderListItem","RenderListItemInner","TypePicker","PatternInput","PatternChip","DetectedItemsSection","DetectedCategoryBadge","IdentifierBadge","CategoryBadge","AppRenderer","AppOverlay","FloatingTools","DialDevTools","HighlightUpdatesOverlay","DevToolsVisibilityProvider","AppHostProvider","MinimizedToolsProvider","ModalHeader","TabSelector","SectionHeader","DraggableHeader","WindowControls","LogBox","LogBoxLog","LogBoxLogNotification","LogBoxNotificationContainer","_LogBoxNotificationContainer","LogBoxInspector","LogBoxInspectorContainer","LogBoxInspectorHeader","LogBoxInspectorBody","LogBoxInspectorFooter","LogBoxInspectorMessageHeader","LogBoxInspectorStackFrame","LogBoxInspectorSection","LogBoxButton","LogBoxMessage"]),DEV_TOOLS_COMPONENT_PREFIXES=["JsModal","HighlightUpdates","RenderList","RenderDetail"],DEV_TOOLS_NATIVE_IDS=new Set(["highlight-updates-overlay","jsmodal-root","__rn_buoy__highlight-modal","logbox_inspector","logbox"]),devToolsNodeCache=new Map,CACHE_MAX_SIZE=500;function isDevToolsNativeID(e){if(!e)return!1;if(DEV_TOOLS_NATIVE_IDS.has(e))return!0;const t=e.charCodeAt(0);return!(95!==t||!e.startsWith("__highlight_")&&!e.startsWith("__rn_buoy__"))||!(108!==t||!e.startsWith("logbox"))}function getComponentName(e){if(!e)return null;const t=e.type;if(t){if("string"==typeof t)return t;if(t.name)return t.name;if(t.displayName)return t.displayName}const n=e.elementType;if(n){if(n.name)return n.name;if(n.displayName)return n.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){return!e||!!INTERNAL_COMPONENT_NAMES.has(e)||"Unknown"===e||"Component"===e||!!e.startsWith("Animated")}function getOwningComponentName(e){if(!e)return null;let t=e._debugOwner||e.return,n=0,r=null;for(;t&&n<30;){const e=getComponentName(t);if(e&&"string"!=typeof t.type&&(r||(r=e),!isInternalComponent(e)))return e;t=t.return,n++}return r}function isOurOverlayNode(e){const t=e,n=t?.canonical?.internalInstanceHandle,r=getNativeTag(e)||getNativeTag(t?.canonical?.publicInstance);if(null!=r){const e=devToolsNodeCache.get(r);if(void 0!==e)return e}let i=!1;if(isDevToolsNativeID(n?.pendingProps?.nativeID||n?.memoizedProps?.nativeID||t?.canonical?.currentProps?.nativeID||null))i=!0;else if(n){let e=n,t=0;for(;e&&t<30;){const n=getComponentName(e);if(n){if(DEV_TOOLS_COMPONENT_NAMES.has(n)){i=!0;break}for(const e of DEV_TOOLS_COMPONENT_PREFIXES)if(n.startsWith(e)){i=!0;break}if(i)break}if(isDevToolsNativeID(e.pendingProps?.nativeID||e.memoizedProps?.nativeID)){i=!0;break}e=e.return,t++}}if(i&&null!=r){if(devToolsNodeCache.size>=500){const e=Array.from(devToolsNodeCache.keys());for(let t=0;t<250;t++)devToolsNodeCache.delete(e[t])}devToolsNodeCache.set(r,i)}return i}function getColorForRenderCount(e){const t=Math.min(e-1,COLORS.length-1);return COLORS[Math.max(0,t)]}function handleTraceUpdates(e){if(0===e.size)return;if(!globalEnabled)return;if(_RenderTracker.RenderTracker.getState().isPaused)return;_PerformanceLogger.PerformanceLogger.isEnabled()&&(0,_PerformanceLogger.markEventReceived)();const t=_RenderTracker.RenderTracker.getBatchSize(),n=_PerformanceLogger.PerformanceLogger.startBatch(e.size,t),r=[];let i=0,a=0;const o=_RenderTracker.RenderTracker.hasActiveFilters();for(const t of e)if(t&&"object"==typeof t){if(isOurOverlayNode(t)){i++;continue}const e=getPublicInstance(t),n=getNativeTag(t)||getNativeTag(e);if(null==n)continue;const s=extractComponentInfo(t);if(o&&!_RenderTracker.RenderTracker.passesFilters(s)){a++;continue}let l,c;_RenderTracker.RenderTracker.getSettings().showRenderCount?(l=(nodeRenderCounts.get(n)||0)+1,nodeRenderCounts.set(n,l),c=getColorForRenderCount(l)):(l=0,c=COLORS[0]),r.push({node:t,color:c,count:l})}if(n.markFilteringComplete(i+a,r.length),0===r.length)return void n.finish();if(!highlightCallback)return void(isProcessing=!1);n.markMeasurementStart();const s=r.slice(0,t).map(({node:e,color:t,count:n})=>new Promise(r=>{const i=getPublicInstance(e);if(!i)return void r({rect:null,stateNode:e,color:t,count:n});const a=getNativeTag(e)||getNativeTag(i);if(null!=a)try{i.measure((i,o,s,l,c,d)=>{r(null!=c&&null!=d&&null!=s&&null!=l?{rect:{id:a,x:c,y:d,width:s,height:l,color:t,count:n},stateNode:e,color:t,count:n}:{rect:null,stateNode:e,color:t,count:n})})}catch(i){r({rect:null,stateNode:e,color:t,count:n})}else r({rect:null,stateNode:e,color:t,count:n})}));Promise.all(s).then(e=>{const t=e.filter(e=>null!==e.rect),r=t.map(e=>e.rect);n.markMeasurementComplete(t.length,e.length-t.length),_RenderTracker.RenderTracker.startBatch();const i=_RenderTracker.RenderTracker.getSettings(),a=i.trackRenderCauses&&i.showRenderCount;let o=null;if(a){o=new Set;for(const{rect:e}of t)e&&o.add(e.id)}for(const{rect:e,stateNode:n,color:r,count:s}of t)if(e){const t=extractComponentInfo(n);let l;if(a&&o){const t=n,r=t?.canonical?.internalInstanceHandle,a="off"!==i.debugLogLevel?i.debugLogLevel:i.debugRawFiberLogging?"all":"off";l=(0,_RenderCauseDetector.detectRenderCause)(e.id,r,o,a)}_RenderTracker.RenderTracker.trackRender({nativeTag:e.id,viewType:t.viewType,testID:t.testID,nativeID:t.nativeID,accessibilityLabel:t.accessibilityLabel,componentName:t.componentName,measurements:{x:e.x,y:e.y,width:e.width,height:e.height},color:r,count:s,renderCause:l})}_RenderTracker.RenderTracker.endBatch(),n.markTrackingComplete(),r.length>0&&highlightCallback&&highlightCallback(r),n.markCallbackComplete(),n.finish()}).catch(e=>{console.error("[HighlightUpdates] Error in measurement pipeline:",e),n.finish()})}function setTraceUpdatesOnRenderers(e){if(!hook?.rendererInterfaces)return void debugLog("No rendererInterfaces available");let t=0;if(hook.rendererInterfaces.forEach((n,r)=>{if("function"==typeof n.setTraceUpdatesEnabled)try{n.setTraceUpdatesEnabled(e),t++,debugLog(`Renderer ${r}: setTraceUpdatesEnabled(${e})`)}catch(e){debugLog(`Renderer ${r}: error setting trace updates`,e)}else debugLog(`Renderer ${r}: no setTraceUpdatesEnabled method`)}),debugLog(`Set trace updates ${e?"enabled":"disabled"} on ${t} renderer(s)`),hook.reactDevtoolsAgent?.setTraceUpdatesEnabled)try{hook.reactDevtoolsAgent.setTraceUpdatesEnabled(e),debugLog("Also set trace updates on agent")}catch(e){debugLog("Error setting trace updates on agent",e)}}function subscribeToTraceUpdates(){hook&&(traceUpdatesUnsubscribe||(debugLog("Subscribing to traceUpdates event"),"function"==typeof hook.sub?(traceUpdatesUnsubscribe=hook.sub("traceUpdates",handleTraceUpdates),debugLog("Subscribed using hook.sub()")):debugLog("hook.sub not available, traceUpdates may not work"),setTraceUpdatesOnRenderers(!0)))}function unsubscribeFromTraceUpdates(){setTraceUpdatesOnRenderers(!1),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){badgePressCallback&&badgePressCallback(e)}let spotlightCallback=null,currentSpotlightTag=null;function setSpotlightCallback(e){spotlightCallback=e,e&&null!==currentSpotlightTag&&e(currentSpotlightTag)}function setSpotlight(e){currentSpotlightTag=e,spotlightCallback&&spotlightCallback(e)}function getSpotlight(){return currentSpotlightTag}function notifyStateListeners(){stateListeners.forEach(e=>{try{e(globalEnabled)}catch(e){console.error("[HighlightUpdates] Error in state listener:",e)}})}function subscribe(e){return stateListeners.add(e),e(globalEnabled),()=>{stateListeners.delete(e)}}function initialize(){if("undefined"!=typeof __DEV__&&!__DEV__)return debugLog("Only available in development builds"),!1;if(initialized)return!0;if(hook=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null,!hook)return debugLog("React DevTools hook not found"),!1;if(debugLog("Hook found"),debugLog(`Hook has sub: ${"function"==typeof hook.sub}`),debugLog(`Hook has on: ${"function"==typeof hook.on}`),debugLog(`Hook has emit: ${"function"==typeof hook.emit}`),(0,_ProfilerInterceptor.installProfilerInterceptor)(),hook.rendererInterfaces&&hook.rendererInterfaces.size>0)return initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`),exposeGlobally(),!0;const e=setInterval(()=>{hook?.rendererInterfaces&&hook.rendererInterfaces.size>0&&(clearInterval(e),initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`),exposeGlobally())},100);return setTimeout(()=>clearInterval(e),1e4),!1}function exposeGlobally(){"undefined"!=typeof window&&(window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,subscribe:subscribe,initialize:initialize,destroy:destroy,isInitialized:()=>initialized,setHighlightCallback:setHighlightCallback})}function enable(){("undefined"==typeof __DEV__||__DEV__)&&(initialized||initialize(),globalEnabled||(debugLog("Enabling highlights"),subscribeToTraceUpdates(),_RenderTracker.RenderTracker.start(),globalEnabled=!0,notifyStateListeners()))}function disable(){("undefined"==typeof __DEV__||__DEV__)&&globalEnabled&&(debugLog("Disabling highlights"),renderingLock=!1,isProcessing=!1,renderingLockTimeout&&(clearTimeout(renderingLockTimeout),renderingLockTimeout=null),renderedOverlayTags.clear(),devToolsNodeCache.clear(),(0,_RenderCauseDetector.clearRenderCauseState)(),unsubscribeFromTraceUpdates(),_RenderTracker.RenderTracker.stop(),globalEnabled=!1,notifyStateListeners())}function toggle(){("undefined"==typeof __DEV__||__DEV__)&&(globalEnabled?disable():enable())}function clearRenderCounts(){nodeRenderCounts.clear(),_RenderTracker.RenderTracker.clear(),debugLog("Cleared render counts")}function isEnabled(){return globalEnabled}function setEnabled(e){e?enable():disable()}function isInitialized(){return initialized}function notifyFreezeListeners(){freezeListeners.forEach(e=>{try{e(isFrozen)}catch(e){console.error("[HighlightUpdates] Error in freeze listener:",e)}})}function subscribeToFreeze(e){return freezeListeners.add(e),e(isFrozen),()=>{freezeListeners.delete(e)}}function freeze(){("undefined"==typeof __DEV__||__DEV__)&&(isFrozen||(isFrozen=!0,debugLog("Freeze mode enabled"),notifyFreezeListeners()))}function unfreeze(){("undefined"==typeof __DEV__||__DEV__)&&isFrozen&&(isFrozen=!1,debugLog("Freeze mode disabled"),highlightCallback&&highlightCallback([]),notifyFreezeListeners())}function toggleFreeze(){isFrozen?unfreeze():freeze()}function getFrozen(){return isFrozen}function destroy(){initialized&&(unsubscribeFromTraceUpdates(),(0,_ProfilerInterceptor.uninstallProfilerInterceptor)(),(0,_ProfilerInterceptor.setComparisonCallback)(null),isFrozen=!1,freezeListeners.clear(),globalEnabled=!1,hook=null,highlightCallback=null,initialized=!1,"undefined"!=typeof window&&delete window.__HIGHLIGHT_UPDATES_CONTROLLER__,debugLog("Destroyed"))}const HighlightUpdatesController={subscribe:subscribe,enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,initialize:initialize,destroy:destroy,isInitialized:isInitialized,setHighlightCallback:setHighlightCallback,clearRenderCounts:clearRenderCounts,freeze:freeze,unfreeze:unfreeze,toggleFreeze:toggleFreeze,getFrozen:getFrozen,subscribeToFreeze:subscribeToFreeze,setBadgePressCallback:setBadgePressCallback,getBadgePressCallback:getBadgePressCallback,handleBadgePress:handleBadgePress,setSpotlightCallback:setSpotlightCallback,setSpotlight:setSpotlight,getSpotlight:getSpotlight};var _default=exports.default=HighlightUpdatesController;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _ProfilerInterceptor=require("./ProfilerInterceptor"),_RenderTracker=require("./RenderTracker"),_PerformanceLogger=require("./PerformanceLogger"),_RenderCauseDetector=require("./RenderCauseDetector");let globalEnabled=!1,initialized=!1,hook=null,highlightCallback=null,badgePressCallback=null,traceUpdatesUnsubscribe=null,isProcessing=!1,isFrozen=!1;const freezeListeners=new Set,stateListeners=new Set,nodeRenderCounts=new Map,COLORS=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"],DEBUG=!1;function debugLog(e,t){}function getPublicInstance(e){if(!e)return null;const t=e;return t.canonical?.publicInstance?t.canonical.publicInstance:t.canonical&&"function"==typeof t.canonical.measure?t.canonical:"function"==typeof t.measure?t:null}function getNativeTag(e){const t=e;if(null!=t.__nativeTag)return t.__nativeTag;if(null!=t._nativeTag)return t._nativeTag;if(null!=t.nativeTag)return t.nativeTag;if(t.canonical){if(null!=t.canonical.__nativeTag)return t.canonical.__nativeTag;if(null!=t.canonical._nativeTag)return t.canonical._nativeTag}return null}function extractComponentInfo(e){const t=e,n={viewType:"Unknown"};t?.canonical?.viewConfig?.uiViewClassName?n.viewType=t.canonical.viewConfig.uiViewClassName:t?.viewConfig?.uiViewClassName&&(n.viewType=t.viewConfig.uiViewClassName);const r=t?.canonical?.internalInstanceHandle,i=t?.canonical?.currentProps,o=t?.canonical?.pendingProps,a=r?.pendingProps,s=r?.memoizedProps;return n.testID=i?.testID||o?.testID||a?.testID||s?.testID||void 0,n.nativeID=i?.nativeID||o?.nativeID||a?.nativeID||s?.nativeID||void 0,n.accessibilityLabel=i?.accessibilityLabel||o?.accessibilityLabel||a?.accessibilityLabel||s?.accessibilityLabel||void 0,n.componentName=getOwningComponentName(r)||void 0,n}function describeNodeForLog(e){const t=e,n=getPublicInstance(e),r={nativeTag:(getNativeTag(e)||getNativeTag(n))??"unknown",type:t?.canonical?"Fabric":"Legacy",hasMeasure:"function"==typeof n?.measure};if(t){if(r.stateNodeKeys=Object.keys(t).slice(0,20),t.node&&(r.nodeKeys=Object.keys(t.node).slice(0,20)),t.viewConfig&&(r.viewConfig={uiViewClassName:t.viewConfig.uiViewClassName,validAttributes:t.viewConfig.validAttributes?Object.keys(t.viewConfig.validAttributes).slice(0,10):void 0}),t.canonical){const e=t.canonical;if(r.canonicalKeys=Object.keys(e).slice(0,20),e.viewConfig&&(r.canonicalViewConfig={uiViewClassName:e.viewConfig.uiViewClassName}),null!=e.nativeTag&&(r.canonicalNativeTag=e.nativeTag),e.internalInstanceHandle){const t=e.internalInstanceHandle;if(r.fiberKeys=Object.keys(t).slice(0,30),t.type&&(r.fiberType="function"==typeof t.type?t.type.name||t.type.displayName||"function":t.type),t.elementType&&(r.fiberElementType="function"==typeof t.elementType?t.elementType.name||t.elementType.displayName||"function":t.elementType),t._debugOwner){const e=t._debugOwner;r.fiberDebugOwner=e.type?.name||e.type?.displayName||e.elementType?.name||"unknown"}t._debugSource&&(r.fiberDebugSource=t._debugSource),null!=t.tag&&(r.fiberTag=t.tag),t.pendingProps&&(t.pendingProps.nativeID&&(r.fiberPendingNativeID=t.pendingProps.nativeID),t.pendingProps.testID&&(r.fiberPendingTestID=t.pendingProps.testID)),t.memoizedProps&&(t.memoizedProps.nativeID&&(r.fiberMemoizedNativeID=t.memoizedProps.nativeID),t.memoizedProps.testID&&(r.fiberMemoizedTestID=t.memoizedProps.testID))}if(e.publicInstance){const t=e.publicInstance;r.publicInstanceKeys=Object.keys(t).slice(0,20),null!=t.nativeID&&(r.nativeID=t.nativeID),null!=t._nativeID&&(r._nativeID=t._nativeID),t.props&&(r.publicInstanceProps=Object.keys(t.props).slice(0,15),t.props.nativeID&&(r.propsNativeID=t.props.nativeID),t.props.testID&&(r.propsTestID=t.props.testID),t.props.accessibilityLabel&&(r.accessibilityLabel=t.props.accessibilityLabel))}e.currentProps&&(r.currentPropsKeys=Object.keys(e.currentProps).slice(0,15),null!=e.currentProps.nativeID&&(r.currentPropsNativeID=e.currentProps.nativeID),null!=e.currentProps.testID&&(r.currentPropsTestID=e.currentProps.testID),null!=e.currentProps.accessibilityLabel&&(r.currentPropsAccessLabel=e.currentProps.accessibilityLabel)),e.pendingProps&&(r.pendingPropsKeys=Object.keys(e.pendingProps).slice(0,15),null!=e.pendingProps.nativeID&&(r.pendingPropsNativeID=e.pendingProps.nativeID),null!=e.pendingProps.testID&&(r.pendingPropsTestID=e.pendingProps.testID))}if(t._debugOwner){const e=t._debugOwner;r.debugOwnerType=e.type?.name||e.type?.displayName||typeof e.type}t._debugSource&&(r.debugSource=t._debugSource)}return r}const DEBUG_LOGGING=!1;let renderingLock=!1,renderingLockTimeout=null;const RENDER_LOCK_DURATION=350,renderedOverlayTags=new Set;function isOurOverlayTag(e){return null!=e&&renderedOverlayTags.has(e)}const DEV_TOOLS_COMPONENT_NAMES=new Set(["JsModalComponent","JsModal","HighlightUpdatesModal","HighlightFilterView","RenderDetailView","RenderListItem","RenderListItemInner","TypePicker","PatternInput","PatternChip","DetectedItemsSection","DetectedCategoryBadge","IdentifierBadge","CategoryBadge","AppRenderer","AppOverlay","FloatingTools","DialDevTools","HighlightUpdatesOverlay","DevToolsVisibilityProvider","AppHostProvider","MinimizedToolsProvider","ModalHeader","TabSelector","SectionHeader","DraggableHeader","WindowControls","TreeDiffViewer","DataViewer","SplitDiffViewer","VirtualizedDataExplorer","DiffSummary","TypeLegend","IndentGuides","IndentGuidesOverlay","CyberpunkInput","EventStepperFooter","RenderHistoryViewer","RenderHistoryFooter","CurrentStateView","DiffView","AnswerCard","DetailsSection","DetailRow","QuickActionsSection","FilterOptionCard","RenderCauseBadge","TwoLevelCauseBadge","EnhancedCauseDisplay","IsolatedRenderList","IsolatedRenderListInner","StatsDisplay","StatsDisplayInner","SearchSection","SearchSectionInner","HeaderActions","HeaderActionsInner","MainListHeader","FilterViewHeader","DetailViewHeader","FloatingMenu","FloatingDevTools","MinimizedToolsStack","MinimizedToolsContext","GlitchToolButton","ExpandablePopover","CollapsedPeek","ExpandedWrapper","DialIcon","DialMenu","DialIconItem","OnboardingTooltip","MenuLauncherIcon","DevToolsSettingsModal","SettingsModal","ToolCard","ToolIcon","GripVerticalIcon","UserStatus","Divider","ChevronDown","ChevronUp","ChevronLeft","ChevronRight","ChevronDownIcon","ChevronUpIcon","ChevronLeftIcon","ChevronRightIcon","LogBox","LogBoxLog","LogBoxLogNotification","LogBoxNotificationContainer","_LogBoxNotificationContainer","LogBoxInspector","LogBoxInspectorContainer","LogBoxInspectorHeader","LogBoxInspectorBody","LogBoxInspectorFooter","LogBoxInspectorMessageHeader","LogBoxInspectorStackFrame","LogBoxInspectorSection","LogBoxButton","LogBoxMessage"]),DEV_TOOLS_COMPONENT_PREFIXES=["JsModal","HighlightUpdates","RenderList","RenderDetail","RenderHistory","RenderCause","TreeDiff","DataViewer","DiffView","DiffSummary","EventStepper","Virtualized","Floating","Minimized","Dial","Expandable","Chevron","Glitch","Settings","Onboarding","DevTools"],DEV_TOOLS_NATIVE_IDS=new Set(["highlight-updates-overlay","jsmodal-root","__rn_buoy__highlight-modal","logbox_inspector","logbox"]),devToolsNodeCache=new Map,CACHE_MAX_SIZE=500;function isDevToolsNativeID(e){if(!e)return!1;if(DEV_TOOLS_NATIVE_IDS.has(e))return!0;const t=e.charCodeAt(0);return!(95!==t||!e.startsWith("__highlight_")&&!e.startsWith("__rn_buoy__"))||!(108!==t||!e.startsWith("logbox"))}function getComponentName(e){if(!e)return null;const t=e.type;if(t){if("string"==typeof t)return t;if(t.name)return t.name;if(t.displayName)return t.displayName}const n=e.elementType;if(n){if(n.name)return n.name;if(n.displayName)return n.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){return!e||!!INTERNAL_COMPONENT_NAMES.has(e)||"Unknown"===e||"Component"===e||!!e.startsWith("Animated")}function getOwningComponentName(e){if(!e)return null;let t=e._debugOwner||e.return,n=0,r=null;for(;t&&n<30;){const e=getComponentName(t);if(e&&"string"!=typeof t.type&&(r||(r=e),!isInternalComponent(e)))return e;t=t.return,n++}return r}function isOurOverlayNode(e){const t=e,n=t?.canonical?.internalInstanceHandle,r=getNativeTag(e)||getNativeTag(t?.canonical?.publicInstance);if(null!=r){const e=devToolsNodeCache.get(r);if(void 0!==e)return e}let i=!1;if(isDevToolsNativeID(n?.pendingProps?.nativeID||n?.memoizedProps?.nativeID||t?.canonical?.currentProps?.nativeID||null))i=!0;else if(n){let e=n,t=0;for(;e&&t<30;){const n=getComponentName(e);if(n){if(DEV_TOOLS_COMPONENT_NAMES.has(n)){i=!0;break}for(const e of DEV_TOOLS_COMPONENT_PREFIXES)if(n.startsWith(e)){i=!0;break}if(i)break}if(isDevToolsNativeID(e.pendingProps?.nativeID||e.memoizedProps?.nativeID)){i=!0;break}e=e.return,t++}}if(i&&null!=r){if(devToolsNodeCache.size>=500){const e=Array.from(devToolsNodeCache.keys());for(let t=0;t<250;t++)devToolsNodeCache.delete(e[t])}devToolsNodeCache.set(r,i)}return i}function getColorForRenderCount(e){const t=Math.min(e-1,COLORS.length-1);return COLORS[Math.max(0,t)]}function handleTraceUpdates(e){if(0===e.size)return;if(!globalEnabled)return;if(_RenderTracker.RenderTracker.getState().isPaused)return;_PerformanceLogger.PerformanceLogger.isEnabled()&&(0,_PerformanceLogger.markEventReceived)();const t=_RenderTracker.RenderTracker.getBatchSize(),n=_PerformanceLogger.PerformanceLogger.startBatch(e.size,t),r=[];let i=0,o=0;const a=_RenderTracker.RenderTracker.hasActiveFilters();for(const t of e)if(t&&"object"==typeof t){if(isOurOverlayNode(t)){i++;continue}const e=getPublicInstance(t),n=getNativeTag(t)||getNativeTag(e);if(null==n)continue;const s=extractComponentInfo(t);if(a&&!_RenderTracker.RenderTracker.passesFilters(s)){o++;continue}let l,c;_RenderTracker.RenderTracker.getSettings().showRenderCount?(l=(nodeRenderCounts.get(n)||0)+1,nodeRenderCounts.set(n,l),c=getColorForRenderCount(l)):(l=0,c=COLORS[0]),r.push({node:t,color:c,count:l})}if(n.markFilteringComplete(i+o,r.length),0===r.length)return void n.finish();if(!highlightCallback)return void(isProcessing=!1);n.markMeasurementStart();const s=r.slice(0,t).map(({node:e,color:t,count:n})=>new Promise(r=>{const i=getPublicInstance(e);if(!i)return void r({rect:null,stateNode:e,color:t,count:n});const o=getNativeTag(e)||getNativeTag(i);if(null!=o)try{i.measure((i,a,s,l,c,d)=>{r(null!=c&&null!=d&&null!=s&&null!=l?{rect:{id:o,x:c,y:d,width:s,height:l,color:t,count:n},stateNode:e,color:t,count:n}:{rect:null,stateNode:e,color:t,count:n})})}catch(i){r({rect:null,stateNode:e,color:t,count:n})}else r({rect:null,stateNode:e,color:t,count:n})}));Promise.all(s).then(e=>{const t=e.filter(e=>null!==e.rect),r=t.map(e=>e.rect);n.markMeasurementComplete(t.length,e.length-t.length),_RenderTracker.RenderTracker.startBatch();const i=_RenderTracker.RenderTracker.getSettings(),o=i.trackRenderCauses&&i.showRenderCount;let a=null;if(o){a=new Set;for(const{rect:e}of t)e&&a.add(e.id)}for(const{rect:e,stateNode:n,color:r,count:s}of t)if(e){const t=extractComponentInfo(n);let l;if(o&&a){const t=n,r=t?.canonical?.internalInstanceHandle;l=(0,_RenderCauseDetector.detectRenderCause)(e.id,r,a,i.debugLogLevel)}_RenderTracker.RenderTracker.trackRender({nativeTag:e.id,viewType:t.viewType,testID:t.testID,nativeID:t.nativeID,accessibilityLabel:t.accessibilityLabel,componentName:t.componentName,measurements:{x:e.x,y:e.y,width:e.width,height:e.height},color:r,count:s,renderCause:l})}_RenderTracker.RenderTracker.endBatch(),n.markTrackingComplete(),r.length>0&&highlightCallback&&highlightCallback(r),n.markCallbackComplete(),n.finish()}).catch(e=>{console.error("[HighlightUpdates] Error in measurement pipeline:",e),n.finish()})}function setTraceUpdatesOnRenderers(e){if(!hook?.rendererInterfaces)return void debugLog("No rendererInterfaces available");let t=0;if(hook.rendererInterfaces.forEach((n,r)=>{if("function"==typeof n.setTraceUpdatesEnabled)try{n.setTraceUpdatesEnabled(e),t++,debugLog(`Renderer ${r}: setTraceUpdatesEnabled(${e})`)}catch(e){debugLog(`Renderer ${r}: error setting trace updates`,e)}else debugLog(`Renderer ${r}: no setTraceUpdatesEnabled method`)}),debugLog(`Set trace updates ${e?"enabled":"disabled"} on ${t} renderer(s)`),hook.reactDevtoolsAgent?.setTraceUpdatesEnabled)try{hook.reactDevtoolsAgent.setTraceUpdatesEnabled(e),debugLog("Also set trace updates on agent")}catch(e){debugLog("Error setting trace updates on agent",e)}}function subscribeToTraceUpdates(){hook&&(traceUpdatesUnsubscribe||(debugLog("Subscribing to traceUpdates event"),"function"==typeof hook.sub?(traceUpdatesUnsubscribe=hook.sub("traceUpdates",handleTraceUpdates),debugLog("Subscribed using hook.sub()")):debugLog("hook.sub not available, traceUpdates may not work"),setTraceUpdatesOnRenderers(!0)))}function unsubscribeFromTraceUpdates(){setTraceUpdatesOnRenderers(!1),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){badgePressCallback&&badgePressCallback(e)}let spotlightCallback=null,currentSpotlightTag=null;function setSpotlightCallback(e){spotlightCallback=e,e&&null!==currentSpotlightTag&&e(currentSpotlightTag)}function setSpotlight(e){currentSpotlightTag=e,spotlightCallback&&spotlightCallback(e)}function getSpotlight(){return currentSpotlightTag}function notifyStateListeners(){stateListeners.forEach(e=>{try{e(globalEnabled)}catch(e){console.error("[HighlightUpdates] Error in state listener:",e)}})}function subscribe(e){return stateListeners.add(e),e(globalEnabled),()=>{stateListeners.delete(e)}}function initialize(){if("undefined"!=typeof __DEV__&&!__DEV__)return debugLog("Only available in development builds"),!1;if(initialized)return!0;if(hook=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null,!hook)return debugLog("React DevTools hook not found"),!1;if(debugLog("Hook found"),debugLog(`Hook has sub: ${"function"==typeof hook.sub}`),debugLog(`Hook has on: ${"function"==typeof hook.on}`),debugLog(`Hook has emit: ${"function"==typeof hook.emit}`),(0,_ProfilerInterceptor.installProfilerInterceptor)(),hook.rendererInterfaces&&hook.rendererInterfaces.size>0)return initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`),exposeGlobally(),!0;const e=setInterval(()=>{hook?.rendererInterfaces&&hook.rendererInterfaces.size>0&&(clearInterval(e),initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`),exposeGlobally())},100);return setTimeout(()=>clearInterval(e),1e4),!1}function exposeGlobally(){"undefined"!=typeof window&&(window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,subscribe:subscribe,initialize:initialize,destroy:destroy,isInitialized:()=>initialized,setHighlightCallback:setHighlightCallback})}function enable(){("undefined"==typeof __DEV__||__DEV__)&&(initialized||initialize(),globalEnabled||(debugLog("Enabling highlights"),subscribeToTraceUpdates(),_RenderTracker.RenderTracker.start(),globalEnabled=!0,notifyStateListeners()))}function disable(){("undefined"==typeof __DEV__||__DEV__)&&globalEnabled&&(debugLog("Disabling highlights"),renderingLock=!1,isProcessing=!1,renderingLockTimeout&&(clearTimeout(renderingLockTimeout),renderingLockTimeout=null),renderedOverlayTags.clear(),devToolsNodeCache.clear(),(0,_RenderCauseDetector.clearRenderCauseState)(),unsubscribeFromTraceUpdates(),_RenderTracker.RenderTracker.stop(),globalEnabled=!1,notifyStateListeners())}function toggle(){("undefined"==typeof __DEV__||__DEV__)&&(globalEnabled?disable():enable())}function clearRenderCounts(){nodeRenderCounts.clear(),_RenderTracker.RenderTracker.clear(),debugLog("Cleared render counts")}function isEnabled(){return globalEnabled}function setEnabled(e){e?enable():disable()}function isInitialized(){return initialized}function notifyFreezeListeners(){freezeListeners.forEach(e=>{try{e(isFrozen)}catch(e){console.error("[HighlightUpdates] Error in freeze listener:",e)}})}function subscribeToFreeze(e){return freezeListeners.add(e),e(isFrozen),()=>{freezeListeners.delete(e)}}function freeze(){("undefined"==typeof __DEV__||__DEV__)&&(isFrozen||(isFrozen=!0,debugLog("Freeze mode enabled"),notifyFreezeListeners()))}function unfreeze(){("undefined"==typeof __DEV__||__DEV__)&&isFrozen&&(isFrozen=!1,debugLog("Freeze mode disabled"),highlightCallback&&highlightCallback([]),notifyFreezeListeners())}function toggleFreeze(){isFrozen?unfreeze():freeze()}function getFrozen(){return isFrozen}function destroy(){initialized&&(unsubscribeFromTraceUpdates(),(0,_ProfilerInterceptor.uninstallProfilerInterceptor)(),(0,_ProfilerInterceptor.setComparisonCallback)(null),isFrozen=!1,freezeListeners.clear(),globalEnabled=!1,hook=null,highlightCallback=null,initialized=!1,"undefined"!=typeof window&&delete window.__HIGHLIGHT_UPDATES_CONTROLLER__,debugLog("Destroyed"))}const HighlightUpdatesController={subscribe:subscribe,enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,initialize:initialize,destroy:destroy,isInitialized:isInitialized,setHighlightCallback:setHighlightCallback,clearRenderCounts:clearRenderCounts,freeze:freeze,unfreeze:unfreeze,toggleFreeze:toggleFreeze,getFrozen:getFrozen,subscribeToFreeze:subscribeToFreeze,setBadgePressCallback:setBadgePressCallback,getBadgePressCallback:getBadgePressCallback,handleBadgePress:handleBadgePress,setSpotlightCallback:setSpotlightCallback,setSpotlight:setSpotlight,getSpotlight:getSpotlight};var _default=exports.default=HighlightUpdatesController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RenderTracker=void 0;var _ViewTypeMapper=require("./ViewTypeMapper"),_PerformanceLogger=require("./PerformanceLogger");const MAX_TRACKED_COMPONENTS=200,DEFAULT_BATCH_SIZE=150;class RenderTrackerSingleton{renders=new Map;listeners=new Set;stateListeners=new Set;settingsListeners=new Set;filterListeners=new Set;isTracking=!1;isPaused=!1;settings={batchSize:150,showRenderCount:!0,performanceLogging:!1,trackRenderCauses:!1,enableRenderHistory:!0,maxRenderHistoryPerComponent:20,capturePropsOnRender:!1,captureStateOnRender:!1,debugLogLevel:"off",debugRawFiberLogging:!1};isBatchMode=!1;batchDirty=!1;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),s=Date.now(),i=this.renders.get(t);if(i)i.renderCount=e.count,i.lastRenderTime=s,i.color=e.color,e.measurements&&(i.measurements=e.measurements),e.testID&&!i.testID&&(i.testID=e.testID),e.nativeID&&!i.nativeID&&(i.nativeID=e.nativeID),e.accessibilityLabel&&!i.accessibilityLabel&&(i.accessibilityLabel=e.accessibilityLabel),e.componentName&&!i.componentName&&(i.componentName=e.componentName),e.renderCause&&(i.lastRenderCause=e.renderCause),this.settings.enableRenderHistory&&e.renderCause&&this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState);else{const i={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&&e.renderCause&&(i.renderHistory=[],this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState)),this.renders.set(t,i),this.renders.size>200){const e=Array.from(this.renders.values()).sort((e,t)=>e.lastRenderTime-t.lastRenderTime).slice(0,this.renders.size-200);for(const t of e)this.renders.delete(t.id)}}this.isBatchMode?this.batchDirty=!0:this.notifyListeners()}addRenderEvent(e,t,s,i){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));e.renderHistory.length>n&&(e.renderHistory=e.renderHistory.slice(-n))}startBatch(){this.isBatchMode=!0,this.batchDirty=!1}endBatch(){this.isBatchMode=!1,this.batchDirty&&(this.batchDirty=!1,this.notifyListeners())}getRenders(){return Array.from(this.renders.values()).map(e=>({...e}))}passesFilters(e){if(this.filters.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,this.filters.includePatterns))return!1;if(this.filters.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,this.filters.excludePatterns))return!1;if(this.filters.includeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(!this.matchesPattern(t,this.filters.includeViewType)&&!this.matchesPattern(s,this.filters.includeViewType))return!1}if(this.filters.includeTestID.size>0&&(!e.testID||!this.matchesPattern(e.testID,this.filters.includeTestID)))return!1;if(this.filters.includeNativeID.size>0&&(!e.nativeID||!this.matchesPattern(e.nativeID,this.filters.includeNativeID)))return!1;if(this.filters.includeComponent.size>0&&(!e.componentName||!this.matchesPattern(e.componentName,this.filters.includeComponent)))return!1;if(this.filters.excludeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(this.matchesPattern(t,this.filters.excludeViewType)||this.matchesPattern(s,this.filters.excludeViewType))return!1}return!(this.filters.excludeTestID.size>0&&e.testID&&this.matchesPattern(e.testID,this.filters.excludeTestID)||this.filters.excludeNativeID.size>0&&e.nativeID&&this.matchesPattern(e.nativeID,this.filters.excludeNativeID)||this.filters.excludeComponent.size>0&&e.componentName&&this.matchesPattern(e.componentName,this.filters.excludeComponent))}matchesAnyPatternForInfo(e,t){for(const s of t){const t=s.value.toLowerCase();switch(s.type){case"any":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t)||e.testID?.toLowerCase().includes(t)||e.nativeID?.toLowerCase().includes(t)||e.componentName?.toLowerCase().includes(t)||e.accessibilityLabel?.toLowerCase().includes(t))return!0;break;case"viewType":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t))return!0;break;case"testID":if(e.testID?.toLowerCase().includes(t))return!0;break;case"nativeID":if(e.nativeID?.toLowerCase().includes(t))return!0;break;case"component":if(e.componentName?.toLowerCase().includes(t))return!0;break;case"accessibilityLabel":if(e.accessibilityLabel?.toLowerCase().includes(t))return!0}}return!1}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||void 0!==this.filters.minRenderCount||void 0!==this.filters.maxRenderCount}getFilteredRenders(e=""){let t=this.getRenders();if(e.trim()){const s=e.toLowerCase();t=t.filter(e=>e.viewType.toLowerCase().includes(s)||e.displayName.toLowerCase().includes(s)||e.testID?.toLowerCase().includes(s)||e.nativeID?.toLowerCase().includes(s)||e.accessibilityLabel?.toLowerCase().includes(s)||e.componentName?.toLowerCase().includes(s)||String(e.nativeTag).includes(s))}return t=t.filter(e=>this.passesFilters(e)),void 0!==this.filters.minRenderCount&&(t=t.filter(e=>e.renderCount>=this.filters.minRenderCount)),void 0!==this.filters.maxRenderCount&&(t=t.filter(e=>e.renderCount<=this.filters.maxRenderCount)),t.sort((e,t)=>t.lastRenderTime-e.lastRenderTime)}matchesPattern(e,t){const s=e.toLowerCase();for(const e of t){const t=e.toLowerCase();if(s.includes(t))return!0}return!1}getRender(e){return this.renders.get(e)}clear(){this.renders.clear(),this.notifyListeners()}resetRenderCount(e){const t=this.renders.get(e);t&&(t.renderCount=0,this.notifyListeners())}start(){this.isTracking=!0,this.isPaused=!1,this.notifyStateListeners()}stop(){this.isTracking=!1,this.isPaused=!1,this.notifyStateListeners()}pause(){this.isPaused=!0,this.notifyStateListeners()}resume(){this.isPaused=!1,this.notifyStateListeners()}togglePause(){this.isPaused=!this.isPaused,this.notifyStateListeners()}getState(){return{isTracking:this.isTracking,isPaused:this.isPaused}}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,t=new Set,s=new Set,i=new Set,r=new Set;for(const n of this.renders.values())n.viewType&&e.add(n.viewType),n.testID&&t.add(n.testID),n.nativeID&&s.add(n.nativeID),n.componentName&&i.add(n.componentName),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){return this.listeners.add(e),e(this.getRenders()),()=>{this.listeners.delete(e)}}subscribeToState(e){return this.stateListeners.add(e),e(this.getState()),()=>{this.stateListeners.delete(e)}}subscribeToSettings(e){return this.settingsListeners.add(e),e(this.settings),()=>{this.settingsListeners.delete(e)}}subscribeToFilters(e){return this.filterListeners.add(e),e(this.filters),()=>{this.filterListeners.delete(e)}}shouldShowRender(e){const t=this.filters;return!(t.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,t.includePatterns))&&(!(t.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,t.excludePatterns))&&(!((t.includeViewType.size>0||t.includeTestID.size>0||t.includeNativeID.size>0||t.includeComponent.size>0)&&!(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)))&&!(t.excludeViewType.has(e.viewType)||e.testID&&t.excludeTestID.has(e.testID)||e.nativeID&&t.excludeNativeID.has(e.nativeID)||e.componentName&&t.excludeComponent.has(e.componentName))))}getSettings(){return{...this.settings}}setSettings(e){void 0!==e.batchSize&&(e.batchSize=Math.max(10,Math.min(500,e.batchSize))),void 0!==e.maxRenderHistoryPerComponent&&(e.maxRenderHistoryPerComponent=Math.max(5,Math.min(50,e.maxRenderHistoryPerComponent))),e.enableRenderHistory&&!this.settings.trackRenderCauses&&(e.trackRenderCauses=!0),!1===e.trackRenderCauses&&this.settings.enableRenderHistory&&(e.enableRenderHistory=!1),this.settings={...this.settings,...e},void 0!==e.performanceLogging&&_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);t&&(t.renderHistory=[],this.notifyListeners())}getRenderHistoryStats(){let e=0,t=0;for(const s of this.renders.values())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(e){console.error("[RenderTracker] Error in listener:",e)}}notifyStateListeners(){const e=this.getState();for(const t of this.stateListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in state listener:",e)}}notifySettingsListeners(){const e=this.getSettings();for(const t of this.settingsListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in settings listener:",e)}}notifyFilterListeners(){const e=this.getFilters();for(const t of this.filterListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in filter listener:",e)}}}const RenderTracker=exports.RenderTracker=new RenderTrackerSingleton;var _default=exports.default=RenderTracker;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RenderTracker=void 0;var _ViewTypeMapper=require("./ViewTypeMapper"),_PerformanceLogger=require("./PerformanceLogger");const MAX_TRACKED_COMPONENTS=200,DEFAULT_BATCH_SIZE=150;class RenderTrackerSingleton{renders=new Map;listeners=new Set;stateListeners=new Set;settingsListeners=new Set;filterListeners=new Set;isTracking=!1;isPaused=!1;settings={batchSize:150,showRenderCount:!0,performanceLogging:!1,trackRenderCauses:!1,enableRenderHistory:!0,maxRenderHistoryPerComponent:20,capturePropsOnRender:!1,captureStateOnRender:!1,debugLogLevel:"off"};isBatchMode=!1;batchDirty=!1;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),s=Date.now(),i=this.renders.get(t);if(i)i.renderCount=e.count,i.lastRenderTime=s,i.color=e.color,e.measurements&&(i.measurements=e.measurements),e.testID&&!i.testID&&(i.testID=e.testID),e.nativeID&&!i.nativeID&&(i.nativeID=e.nativeID),e.accessibilityLabel&&!i.accessibilityLabel&&(i.accessibilityLabel=e.accessibilityLabel),e.componentName&&!i.componentName&&(i.componentName=e.componentName),e.renderCause&&(i.lastRenderCause=e.renderCause),this.settings.enableRenderHistory&&e.renderCause&&this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState);else{const i={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&&e.renderCause&&(i.renderHistory=[],this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState)),this.renders.set(t,i),this.renders.size>200){const e=Array.from(this.renders.values()).sort((e,t)=>e.lastRenderTime-t.lastRenderTime).slice(0,this.renders.size-200);for(const t of e)this.renders.delete(t.id)}}this.isBatchMode?this.batchDirty=!0:this.notifyListeners()}addRenderEvent(e,t,s,i){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));e.renderHistory.length>n&&(e.renderHistory=e.renderHistory.slice(-n))}startBatch(){this.isBatchMode=!0,this.batchDirty=!1}endBatch(){this.isBatchMode=!1,this.batchDirty&&(this.batchDirty=!1,this.notifyListeners())}getRenders(){return Array.from(this.renders.values()).map(e=>({...e}))}passesFilters(e){if(this.filters.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,this.filters.includePatterns))return!1;if(this.filters.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,this.filters.excludePatterns))return!1;if(this.filters.includeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(!this.matchesPattern(t,this.filters.includeViewType)&&!this.matchesPattern(s,this.filters.includeViewType))return!1}if(this.filters.includeTestID.size>0&&(!e.testID||!this.matchesPattern(e.testID,this.filters.includeTestID)))return!1;if(this.filters.includeNativeID.size>0&&(!e.nativeID||!this.matchesPattern(e.nativeID,this.filters.includeNativeID)))return!1;if(this.filters.includeComponent.size>0&&(!e.componentName||!this.matchesPattern(e.componentName,this.filters.includeComponent)))return!1;if(this.filters.excludeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(this.matchesPattern(t,this.filters.excludeViewType)||this.matchesPattern(s,this.filters.excludeViewType))return!1}return!(this.filters.excludeTestID.size>0&&e.testID&&this.matchesPattern(e.testID,this.filters.excludeTestID)||this.filters.excludeNativeID.size>0&&e.nativeID&&this.matchesPattern(e.nativeID,this.filters.excludeNativeID)||this.filters.excludeComponent.size>0&&e.componentName&&this.matchesPattern(e.componentName,this.filters.excludeComponent))}matchesAnyPatternForInfo(e,t){for(const s of t){const t=s.value.toLowerCase();switch(s.type){case"any":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t)||e.testID?.toLowerCase().includes(t)||e.nativeID?.toLowerCase().includes(t)||e.componentName?.toLowerCase().includes(t)||e.accessibilityLabel?.toLowerCase().includes(t))return!0;break;case"viewType":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t))return!0;break;case"testID":if(e.testID?.toLowerCase().includes(t))return!0;break;case"nativeID":if(e.nativeID?.toLowerCase().includes(t))return!0;break;case"component":if(e.componentName?.toLowerCase().includes(t))return!0;break;case"accessibilityLabel":if(e.accessibilityLabel?.toLowerCase().includes(t))return!0}}return!1}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||void 0!==this.filters.minRenderCount||void 0!==this.filters.maxRenderCount}getFilteredRenders(e=""){let t=this.getRenders();if(e.trim()){const s=e.toLowerCase();t=t.filter(e=>e.viewType.toLowerCase().includes(s)||e.displayName.toLowerCase().includes(s)||e.testID?.toLowerCase().includes(s)||e.nativeID?.toLowerCase().includes(s)||e.accessibilityLabel?.toLowerCase().includes(s)||e.componentName?.toLowerCase().includes(s)||String(e.nativeTag).includes(s))}return t=t.filter(e=>this.passesFilters(e)),void 0!==this.filters.minRenderCount&&(t=t.filter(e=>e.renderCount>=this.filters.minRenderCount)),void 0!==this.filters.maxRenderCount&&(t=t.filter(e=>e.renderCount<=this.filters.maxRenderCount)),t.sort((e,t)=>t.lastRenderTime-e.lastRenderTime)}matchesPattern(e,t){const s=e.toLowerCase();for(const e of t){const t=e.toLowerCase();if(s.includes(t))return!0}return!1}getRender(e){return this.renders.get(e)}clear(){this.renders.clear(),this.notifyListeners()}resetRenderCount(e){const t=this.renders.get(e);t&&(t.renderCount=0,this.notifyListeners())}start(){this.isTracking=!0,this.isPaused=!1,this.notifyStateListeners()}stop(){this.isTracking=!1,this.isPaused=!1,this.notifyStateListeners()}pause(){this.isPaused=!0,this.notifyStateListeners()}resume(){this.isPaused=!1,this.notifyStateListeners()}togglePause(){this.isPaused=!this.isPaused,this.notifyStateListeners()}getState(){return{isTracking:this.isTracking,isPaused:this.isPaused}}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,t=new Set,s=new Set,i=new Set,r=new Set;for(const n of this.renders.values())n.viewType&&e.add(n.viewType),n.testID&&t.add(n.testID),n.nativeID&&s.add(n.nativeID),n.componentName&&i.add(n.componentName),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){return this.listeners.add(e),e(this.getRenders()),()=>{this.listeners.delete(e)}}subscribeToState(e){return this.stateListeners.add(e),e(this.getState()),()=>{this.stateListeners.delete(e)}}subscribeToSettings(e){return this.settingsListeners.add(e),e(this.settings),()=>{this.settingsListeners.delete(e)}}subscribeToFilters(e){return this.filterListeners.add(e),e(this.filters),()=>{this.filterListeners.delete(e)}}shouldShowRender(e){const t=this.filters;return!(t.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,t.includePatterns))&&(!(t.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,t.excludePatterns))&&(!((t.includeViewType.size>0||t.includeTestID.size>0||t.includeNativeID.size>0||t.includeComponent.size>0)&&!(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)))&&!(t.excludeViewType.has(e.viewType)||e.testID&&t.excludeTestID.has(e.testID)||e.nativeID&&t.excludeNativeID.has(e.nativeID)||e.componentName&&t.excludeComponent.has(e.componentName))))}getSettings(){return{...this.settings}}setSettings(e){void 0!==e.batchSize&&(e.batchSize=Math.max(10,Math.min(500,e.batchSize))),void 0!==e.maxRenderHistoryPerComponent&&(e.maxRenderHistoryPerComponent=Math.max(5,Math.min(50,e.maxRenderHistoryPerComponent))),e.enableRenderHistory&&!this.settings.trackRenderCauses&&(e.trackRenderCauses=!0),!1===e.trackRenderCauses&&this.settings.enableRenderHistory&&(e.enableRenderHistory=!1),this.settings={...this.settings,...e},void 0!==e.performanceLogging&&_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);t&&(t.renderHistory=[],this.notifyListeners())}getRenderHistoryStats(){let e=0,t=0;for(const s of this.renders.values())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(e){console.error("[RenderTracker] Error in listener:",e)}}notifyStateListeners(){const e=this.getState();for(const t of this.stateListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in state listener:",e)}}notifySettingsListeners(){const e=this.getSettings();for(const t of this.settingsListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in settings listener:",e)}}notifyFilterListeners(){const e=this.getFilters();for(const t of this.filterListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in filter listener:",e)}}}const RenderTracker=exports.RenderTracker=new RenderTrackerSingleton;var _default=exports.default=RenderTracker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{useState,useEffect,useRef,useCallback,useMemo}from"react";import{View,Text,StyleSheet}from"react-native";import{Power,JsModal,devToolsStorageKeys,safeGetItem,safeSetItem,buoyColors}from"@buoy-gg/shared-ui";import{useIsPro}from"@buoy-gg/license";import HighlightUpdatesController from"../utils/HighlightUpdatesController";import{RenderTracker}from"../utils/RenderTracker";import{CAUSE_CONFIG,COMPONENT_CAUSE_CONFIG}from"./RenderCauseBadge";import{RenderDetailView}from"./RenderDetailView";import{EventStepperFooter}from"@buoy-gg/shared-ui";import{HighlightFilterView}from"./HighlightFilterView";import{IsolatedRenderList}from"./IsolatedRenderList";import{MainListHeader,FilterViewHeader,DetailViewHeader}from"./ModalHeaderContent";import{RenderHistoryViewer,RenderHistoryFooter}from"./RenderHistoryViewer";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const DisabledBanner=React.memo(function(){return _jsxs(View,{style:styles.disabledBanner,children:[_jsx(Power,{size:14,color:buoyColors.warning}),_jsx(Text,{style:styles.disabledText,children:"Render tracking is disabled"})]})});function formatRenderDataForClipboard(){const e=RenderTracker.getRenders(),t=RenderTracker.getStats(),r=RenderTracker.getSettings(),n=(new Date).toISOString(),s=[];s.push("=".repeat(60)),s.push("RENDER TRACKING DATA EXPORT"),s.push("=".repeat(60)),s.push(`Timestamp: ${n}`),s.push(`Total Components: ${t.totalComponents}`),s.push(`Total Renders: ${t.totalRenders}`),s.push(""),s.push("Settings:"),s.push(` - Show Render Count: ${r.showRenderCount}`),s.push(` - Track Render Causes: ${r.trackRenderCauses}`),s.push(` - Batch Size: ${r.batchSize}`),s.push("");const a=[...e].sort((e,t)=>t.renderCount-e.renderCount);s.push("-".repeat(60)),s.push("COMPONENTS BY RENDER COUNT (descending)"),s.push("-".repeat(60)),s.push(""),a.forEach((e,t)=>{const r=e.lastRenderCause?.type,n=e.lastRenderCause?.componentCause,a=e.lastRenderCause&&r?`${CAUSE_CONFIG[r].label}${e.lastRenderCause.changedKeys?` [${e.lastRenderCause.changedKeys.join(", ")}]`:""}${e.lastRenderCause.hookIndices?` [Hook ${e.lastRenderCause.hookIndices.join(", ")}]`:""}`:"N/A",o=n?COMPONENT_CAUSE_CONFIG[n].label.toUpperCase():"N/A",i=e.lastRenderCause?.componentName||e.componentName;s.push(`${t+1}. ${e.displayName} (${e.viewType}) - ${e.renderCount} renders`),n&&r?s.push(` Why: ${i||"Component"} (${o}) → Native (${a})`):s.push(` Last Cause: ${a}`),e.testID&&s.push(` testID: ${e.testID}`),e.nativeID&&s.push(` nativeID: ${e.nativeID}`),i&&s.push(` component: ${i}`),e.accessibilityLabel&&s.push(` accessibilityLabel: ${e.accessibilityLabel}`),s.push(` nativeTag: ${e.nativeTag}`);const l=e.lastRenderTime-e.firstRenderTime,c=l>0?(e.renderCount/(l/1e3)).toFixed(2):e.renderCount;s.push(` Renders/sec: ${c}`),s.push("")}),s.push("-".repeat(60)),s.push("BY VIEW TYPE"),s.push("-".repeat(60));const o=new Map;e.forEach(e=>{const t=o.get(e.viewType)||{count:0,renders:0};t.count++,t.renders+=e.renderCount,o.set(e.viewType,t)}),[...o.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{s.push(`${e}: ${t.count} components, ${t.renders} total renders`)}),s.push(""),s.push("-".repeat(60)),s.push("BY COMPONENT NAME"),s.push("-".repeat(60));const i=new Map;if(e.forEach(e=>{const t=e.componentName||"(unknown)",r=i.get(t)||{count:0,renders:0};r.count++,r.renders+=e.renderCount,i.set(t,r)}),[...i.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{s.push(`${e}: ${t.count} instances, ${t.renders} total renders`)}),s.push(""),r.trackRenderCauses){s.push("-".repeat(60)),s.push("BY NATIVE CAUSE (what changed on the native view)"),s.push("-".repeat(60));const t=new Map;e.forEach(e=>{const r=e.lastRenderCause?.type||"unknown";t.set(r,(t.get(r)||0)+1)}),[...t.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=CAUSE_CONFIG[e];s.push(`${r?.label||e}: ${t} components`)}),s.push(""),s.push("-".repeat(60)),s.push("BY COMPONENT CAUSE (why the React component re-rendered)"),s.push("-".repeat(60));const r=new Map;e.forEach(e=>{const t=e.lastRenderCause?.componentCause||"unknown";r.set(t,(r.get(t)||0)+1)}),[...r.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=COMPONENT_CAUSE_CONFIG[e];s.push(`${r?.label?.toUpperCase()||e}: ${t} components`)}),s.push("");const n=e.filter(e=>"parent"===e.lastRenderCause?.componentCause);n.length>0&&(s.push("-".repeat(60)),s.push("💡 OPTIMIZATION OPPORTUNITIES"),s.push("-".repeat(60)),s.push(`${n.length} component(s) re-rendered due to parent:`),n.forEach(e=>{const t=e.lastRenderCause?.componentName||e.componentName||e.displayName;s.push(` - ${t}: Consider wrapping with React.memo()`)}),s.push(""))}return s.push("=".repeat(60)),s.push("END OF EXPORT"),s.push("=".repeat(60)),s.join("\n")}export function HighlightUpdatesModal({visible:e,onClose:t,onBack:r,onMinimize:n,enableSharedModalDimensions:s=!1,initialNativeTag:a,onInitialNativeTagHandled:o}){const i=useIsPro(),[l,c]=useState(!1),[u,d]=useState(()=>HighlightUpdatesController.getFrozen()),[h,p]=useState(()=>RenderTracker.getStats().totalComponents>0),[g,C]=useState(null),[m,T]=useState(0),[f,y]=useState(!1),[S,R]=useState("filters"),[b,I]=useState("details"),[w,x]=useState(0),[k,v]=useState(""),[E,N]=useState(!1),H=useRef(null),P=useRef([]),F=useRef(RenderTracker.getFilters()),[U,D]=useState(()=>{const e=RenderTracker.getFilters();return e.includePatterns.length+e.excludePatterns.length}),[$,_]=useState(()=>RenderTracker.getFilters()),[O,A]=useState(()=>RenderTracker.getSettings()),V=useRef(!1),j=useRef(!1),M=useRef(!1);useEffect(()=>{e&&!V.current&&(async()=>{try{const e=await safeGetItem(devToolsStorageKeys.highlightUpdates.isTracking());null!==e&&"true"===e&&!HighlightUpdatesController.isEnabled()&&(HighlightUpdatesController.isInitialized()||HighlightUpdatesController.initialize(),HighlightUpdatesController.enable()),V.current=!0}catch(e){}})()},[e]),useEffect(()=>{V.current&&(async()=>{try{await safeSetItem(devToolsStorageKeys.highlightUpdates.isTracking(),l.toString())}catch(e){}})()},[l]),useEffect(()=>{e&&!j.current&&(async()=>{try{const e=await safeGetItem(devToolsStorageKeys.highlightUpdates.filters());if(e){const t=JSON.parse(e),r={includeTestID:new Set(t.includeTestID||[]),includeNativeID:new Set(t.includeNativeID||[]),includeViewType:new Set(t.includeViewType||[]),includeComponent:new Set(t.includeComponent||[]),excludeTestID:new Set(t.excludeTestID||[]),excludeNativeID:new Set(t.excludeNativeID||[]),excludeViewType:new Set(t.excludeViewType||[]),excludeComponent:new Set(t.excludeComponent||[]),includePatterns:t.includePatterns||[],excludePatterns:t.excludePatterns||[]};RenderTracker.setFilters(r);const n=RenderTracker.getFilters();F.current=n,_(n),D(n.includePatterns.length+n.excludePatterns.length)}j.current=!0}catch(e){}})()},[e]),useEffect(()=>{j.current&&(async()=>{try{const e={includeTestID:Array.from($.includeTestID),includeNativeID:Array.from($.includeNativeID),includeViewType:Array.from($.includeViewType),includeComponent:Array.from($.includeComponent),excludeTestID:Array.from($.excludeTestID),excludeNativeID:Array.from($.excludeNativeID),excludeViewType:Array.from($.excludeViewType),excludeComponent:Array.from($.excludeComponent),includePatterns:$.includePatterns,excludePatterns:$.excludePatterns};await safeSetItem(devToolsStorageKeys.highlightUpdates.filters(),JSON.stringify(e))}catch(e){}})()},[$]),useEffect(()=>{e&&!M.current&&(async()=>{try{const e=await safeGetItem(devToolsStorageKeys.highlightUpdates.settings());if(e){const t=JSON.parse(e),{performanceLogging:r,...n}=t;RenderTracker.setSettings(n),A(RenderTracker.getSettings())}M.current=!0}catch(e){M.current=!0}})()},[e]),useEffect(()=>{M.current&&(async()=>{try{const{performanceLogging:e,...t}=O;await safeSetItem(devToolsStorageKeys.highlightUpdates.settings(),JSON.stringify(t))}catch(e){}})()},[O]),useEffect(()=>{const e=RenderTracker.subscribeToState(e=>{c(e.isTracking)});return()=>{e()}},[]),useEffect(()=>{const e=HighlightUpdatesController.subscribeToFreeze(e=>{d(e)});return()=>{e()}},[]),useEffect(()=>{E&&requestAnimationFrame(()=>{H.current?.focus()})},[E]),useEffect(()=>{e||HighlightUpdatesController.setSpotlight(null)},[e]),useEffect(()=>{if(e&&null!=a){const e=RenderTracker.getRender(String(a));e&&(C(e),T(0),y(!1),HighlightUpdatesController.setSpotlight(e.nativeTag)),o?.()}},[e,a,o]);const z=useCallback(()=>{HighlightUpdatesController.isInitialized()||HighlightUpdatesController.initialize(),HighlightUpdatesController.toggle()},[]),B=useCallback(()=>{HighlightUpdatesController.toggleFreeze()},[]),K=useCallback(()=>{HighlightUpdatesController.clearRenderCounts(),p(!1)},[]),G=useMemo(()=>h?formatRenderDataForClipboard():"",[h]),L=useCallback(e=>{v(e)},[]),J=useCallback((e,t,r)=>{C(e),T(t),I("details"),x(0),P.current=r,HighlightUpdatesController.setSpotlight(e.nativeTag)},[]),Y=useCallback(e=>{P.current=e},[]),W=useCallback(()=>{C(null),T(0),HighlightUpdatesController.setSpotlight(null)},[]),X=useCallback(()=>{const e=P.current;if(m>0){const t=m-1,r=e[t];r&&(C(r),T(t),HighlightUpdatesController.setSpotlight(r.nativeTag))}},[m]),q=useCallback(()=>{const e=P.current;if(m<e.length-1){const t=m+1,r=e[t];r&&(C(r),T(t),HighlightUpdatesController.setSpotlight(r.nativeTag))}},[m]),Z=useCallback(()=>{y(!1)},[]),Q=useCallback(()=>{y(!0)},[]),ee=useCallback(()=>{N(!0)},[]),te=useCallback(()=>{N(!1)},[]),re=useCallback(e=>{RenderTracker.setFilters(e);const t=RenderTracker.getFilters();F.current=t,_(t),D(t.includePatterns.length+t.excludePatterns.length)},[]),ne=useCallback((e,t)=>{const r=RenderTracker.getFilters(),n={};"include"===t?r.includePatterns.some(t=>t.type===e.type&&t.value===e.value)||(n.includePatterns=[...r.includePatterns,e]):r.excludePatterns.some(t=>t.type===e.type&&t.value===e.value)||(n.excludePatterns=[...r.excludePatterns,e]),Object.keys(n).length>0&&(re(n),C(null),T(0),HighlightUpdatesController.setSpotlight(null))},[re]),se=useCallback(e=>{RenderTracker.setSettings(e),A(RenderTracker.getSettings())},[]),ae=useCallback(e=>{p(e.totalComponents>0)},[]),oe=useCallback(()=>f?_jsx(FilterViewHeader,{onBack:Z,activeTab:S,onTabChange:R,activeFilterCount:U}):g?_jsx(DetailViewHeader,{onBack:W,activeTab:b,onTabChange:I,hasHistory:(g.renderHistory?.length??0)>0}):_jsx(MainListHeader,{onBack:r,isSearchActive:E,searchText:k,onSearchChange:L,onSearchToggle:ee,onSearchClose:te,onFilterToggle:Q,onToggleTracking:z,onToggleFreeze:B,onClear:K,copyData:G,isTracking:l,isFrozen:u,activeFilterCount:U,hasRenders:h,searchInputRef:H}),[f,g,r,E,k,l,u,U,h,S,b,Z,W,L,ee,te,Q,z,B,K,G]),ie=s?devToolsStorageKeys.modal.root():devToolsStorageKeys.highlightUpdates.modal();if(!e)return null;const le=P.current.length,ce=g?"details"===b?_jsx(EventStepperFooter,{currentIndex:m,totalItems:le,onPrevious:X,onNext:q,itemLabel:"Component",subtitle:g.componentName||g.displayName||g.viewType}):_jsx(RenderHistoryFooter,{render:g,selectedEventIndex:w,onEventIndexChange:x,isPro:i}):null;return _jsx(JsModal,{visible:e,onClose:t,onMinimize:n,persistenceKey:ie,header:{showToggleButton:!0,customContent:oe()},enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,styles:{},footer:ce,footerHeight:g&&("details"===b||(g.renderHistory?.length??0)>1)?68:0,children:_jsx(View,{nativeID:"__rn_buoy__highlight-modal",style:styles.container,children:g?"details"===b?_jsx(RenderDetailView,{render:g,disableInternalFooter:!0,onAddFilter:ne,isPro:i}):_jsx(RenderHistoryViewer,{render:g,disableInternalFooter:!0,selectedEventIndex:w,onEventIndexChange:x,isPro:i}):f?_jsx(HighlightFilterView,{filters:$,onFilterChange:re,settings:O,onSettingsChange:se,availableProps:RenderTracker.getAvailableProps(),activeTab:S}):_jsxs(_Fragment,{children:[!l&&_jsx(DisabledBanner,{}),_jsx(IsolatedRenderList,{searchText:k,filters:$,onSelectRender:J,onStatsChange:ae,onRendersChange:Y,isTracking:l,isPro:i})]})})})}const styles=StyleSheet.create({container:{flex:1,backgroundColor:buoyColors.base},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:buoyColors.warning+"15",borderRadius:8,borderWidth:1,borderColor:buoyColors.warning+"20"},disabledText:{color:buoyColors.warning,fontSize:11,flex:1}});export default HighlightUpdatesModal;
|
|
1
|
+
"use strict";import React,{useState,useEffect,useRef,useCallback,useMemo}from"react";import{View,Text,StyleSheet}from"react-native";import{Power,JsModal,devToolsStorageKeys,persistentStorage,buoyColors}from"@buoy-gg/shared-ui";import{useIsPro}from"@buoy-gg/license";import HighlightUpdatesController from"../utils/HighlightUpdatesController";import{RenderTracker}from"../utils/RenderTracker";import{CAUSE_CONFIG,COMPONENT_CAUSE_CONFIG}from"./RenderCauseBadge";import{RenderDetailView}from"./RenderDetailView";import{EventStepperFooter}from"@buoy-gg/shared-ui";import{HighlightFilterView}from"./HighlightFilterView";import{IsolatedRenderList}from"./IsolatedRenderList";import{MainListHeader,FilterViewHeader,DetailViewHeader}from"./ModalHeaderContent";import{RenderHistoryViewer,RenderHistoryFooter}from"./RenderHistoryViewer";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const DisabledBanner=React.memo(function(){return _jsxs(View,{style:styles.disabledBanner,children:[_jsx(Power,{size:14,color:buoyColors.warning}),_jsx(Text,{style:styles.disabledText,children:"Render tracking is disabled"})]})});function formatRenderDataForClipboard(){const e=RenderTracker.getRenders(),t=RenderTracker.getStats(),r=RenderTracker.getSettings(),n=(new Date).toISOString(),s=[];s.push("=".repeat(60)),s.push("RENDER TRACKING DATA EXPORT"),s.push("=".repeat(60)),s.push(`Timestamp: ${n}`),s.push(`Total Components: ${t.totalComponents}`),s.push(`Total Renders: ${t.totalRenders}`),s.push(""),s.push("Settings:"),s.push(` - Show Render Count: ${r.showRenderCount}`),s.push(` - Track Render Causes: ${r.trackRenderCauses}`),s.push(` - Batch Size: ${r.batchSize}`),s.push("");const a=[...e].sort((e,t)=>t.renderCount-e.renderCount);s.push("-".repeat(60)),s.push("COMPONENTS BY RENDER COUNT (descending)"),s.push("-".repeat(60)),s.push(""),a.forEach((e,t)=>{const r=e.lastRenderCause?.type,n=e.lastRenderCause?.componentCause,a=e.lastRenderCause&&r?`${CAUSE_CONFIG[r].label}${e.lastRenderCause.changedKeys?` [${e.lastRenderCause.changedKeys.join(", ")}]`:""}${e.lastRenderCause.hookIndices?` [Hook ${e.lastRenderCause.hookIndices.join(", ")}]`:""}`:"N/A",o=n?COMPONENT_CAUSE_CONFIG[n].label.toUpperCase():"N/A",i=e.lastRenderCause?.componentName||e.componentName;s.push(`${t+1}. ${e.displayName} (${e.viewType}) - ${e.renderCount} renders`),n&&r?s.push(` Why: ${i||"Component"} (${o}) → Native (${a})`):s.push(` Last Cause: ${a}`),e.testID&&s.push(` testID: ${e.testID}`),e.nativeID&&s.push(` nativeID: ${e.nativeID}`),i&&s.push(` component: ${i}`),e.accessibilityLabel&&s.push(` accessibilityLabel: ${e.accessibilityLabel}`),s.push(` nativeTag: ${e.nativeTag}`);const l=e.lastRenderTime-e.firstRenderTime,c=l>0?(e.renderCount/(l/1e3)).toFixed(2):e.renderCount;s.push(` Renders/sec: ${c}`),s.push("")}),s.push("-".repeat(60)),s.push("BY VIEW TYPE"),s.push("-".repeat(60));const o=new Map;e.forEach(e=>{const t=o.get(e.viewType)||{count:0,renders:0};t.count++,t.renders+=e.renderCount,o.set(e.viewType,t)}),[...o.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{s.push(`${e}: ${t.count} components, ${t.renders} total renders`)}),s.push(""),s.push("-".repeat(60)),s.push("BY COMPONENT NAME"),s.push("-".repeat(60));const i=new Map;if(e.forEach(e=>{const t=e.componentName||"(unknown)",r=i.get(t)||{count:0,renders:0};r.count++,r.renders+=e.renderCount,i.set(t,r)}),[...i.entries()].sort((e,t)=>t[1].renders-e[1].renders).forEach(([e,t])=>{s.push(`${e}: ${t.count} instances, ${t.renders} total renders`)}),s.push(""),r.trackRenderCauses){s.push("-".repeat(60)),s.push("BY NATIVE CAUSE (what changed on the native view)"),s.push("-".repeat(60));const t=new Map;e.forEach(e=>{const r=e.lastRenderCause?.type||"unknown";t.set(r,(t.get(r)||0)+1)}),[...t.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=CAUSE_CONFIG[e];s.push(`${r?.label||e}: ${t} components`)}),s.push(""),s.push("-".repeat(60)),s.push("BY COMPONENT CAUSE (why the React component re-rendered)"),s.push("-".repeat(60));const r=new Map;e.forEach(e=>{const t=e.lastRenderCause?.componentCause||"unknown";r.set(t,(r.get(t)||0)+1)}),[...r.entries()].sort((e,t)=>t[1]-e[1]).forEach(([e,t])=>{const r=COMPONENT_CAUSE_CONFIG[e];s.push(`${r?.label?.toUpperCase()||e}: ${t} components`)}),s.push("");const n=e.filter(e=>"parent"===e.lastRenderCause?.componentCause);n.length>0&&(s.push("-".repeat(60)),s.push("💡 OPTIMIZATION OPPORTUNITIES"),s.push("-".repeat(60)),s.push(`${n.length} component(s) re-rendered due to parent:`),n.forEach(e=>{const t=e.lastRenderCause?.componentName||e.componentName||e.displayName;s.push(` - ${t}: Consider wrapping with React.memo()`)}),s.push(""))}return s.push("=".repeat(60)),s.push("END OF EXPORT"),s.push("=".repeat(60)),s.join("\n")}export function HighlightUpdatesModal({visible:e,onClose:t,onBack:r,onMinimize:n,enableSharedModalDimensions:s=!1,initialNativeTag:a,onInitialNativeTagHandled:o}){const i=useIsPro(),[l,c]=useState(!1),[u,d]=useState(()=>HighlightUpdatesController.getFrozen()),[h,g]=useState(()=>RenderTracker.getStats().totalComponents>0),[p,C]=useState(null),[m,T]=useState(0),[f,S]=useState(!1),[y,R]=useState("filters"),[b,w]=useState("details"),[x,k]=useState(0),[I,v]=useState(""),[E,N]=useState(!1),H=useRef(null),P=useRef([]),F=useRef(RenderTracker.getFilters()),[U,D]=useState(()=>{const e=RenderTracker.getFilters();return e.includePatterns.length+e.excludePatterns.length}),[$,_]=useState(()=>RenderTracker.getFilters()),[O,A]=useState(()=>RenderTracker.getSettings()),V=useRef(!1),j=useRef(!1),M=useRef(!1);useEffect(()=>{e&&!V.current&&(async()=>{try{const e=await persistentStorage.getItem(devToolsStorageKeys.highlightUpdates.isTracking());null!==e&&"true"===e&&!HighlightUpdatesController.isEnabled()&&(HighlightUpdatesController.isInitialized()||HighlightUpdatesController.initialize(),HighlightUpdatesController.enable()),V.current=!0}catch(e){}})()},[e]),useEffect(()=>{V.current&&(async()=>{try{await persistentStorage.setItem(devToolsStorageKeys.highlightUpdates.isTracking(),l.toString())}catch(e){}})()},[l]),useEffect(()=>{e&&!j.current&&(async()=>{try{const e=await persistentStorage.getItem(devToolsStorageKeys.highlightUpdates.filters());if(e){const t=JSON.parse(e),r={includeTestID:new Set(t.includeTestID||[]),includeNativeID:new Set(t.includeNativeID||[]),includeViewType:new Set(t.includeViewType||[]),includeComponent:new Set(t.includeComponent||[]),excludeTestID:new Set(t.excludeTestID||[]),excludeNativeID:new Set(t.excludeNativeID||[]),excludeViewType:new Set(t.excludeViewType||[]),excludeComponent:new Set(t.excludeComponent||[]),includePatterns:t.includePatterns||[],excludePatterns:t.excludePatterns||[]};RenderTracker.setFilters(r);const n=RenderTracker.getFilters();F.current=n,_(n),D(n.includePatterns.length+n.excludePatterns.length)}j.current=!0}catch(e){}})()},[e]),useEffect(()=>{j.current&&(async()=>{try{const e={includeTestID:Array.from($.includeTestID),includeNativeID:Array.from($.includeNativeID),includeViewType:Array.from($.includeViewType),includeComponent:Array.from($.includeComponent),excludeTestID:Array.from($.excludeTestID),excludeNativeID:Array.from($.excludeNativeID),excludeViewType:Array.from($.excludeViewType),excludeComponent:Array.from($.excludeComponent),includePatterns:$.includePatterns,excludePatterns:$.excludePatterns};await persistentStorage.setItem(devToolsStorageKeys.highlightUpdates.filters(),JSON.stringify(e))}catch(e){}})()},[$]),useEffect(()=>{e&&!M.current&&(async()=>{try{const e=await persistentStorage.getItem(devToolsStorageKeys.highlightUpdates.settings());if(e){const t=JSON.parse(e),{performanceLogging:r,...n}=t;RenderTracker.setSettings(n),A(RenderTracker.getSettings())}M.current=!0}catch(e){M.current=!0}})()},[e]),useEffect(()=>{M.current&&(async()=>{try{const{performanceLogging:e,...t}=O;await persistentStorage.setItem(devToolsStorageKeys.highlightUpdates.settings(),JSON.stringify(t))}catch(e){}})()},[O]),useEffect(()=>{const e=RenderTracker.subscribeToState(e=>{c(e.isTracking)});return()=>{e()}},[]),useEffect(()=>{const e=HighlightUpdatesController.subscribeToFreeze(e=>{d(e)});return()=>{e()}},[]),useEffect(()=>{E&&requestAnimationFrame(()=>{H.current?.focus()})},[E]),useEffect(()=>{e||HighlightUpdatesController.setSpotlight(null)},[e]),useEffect(()=>{if(e&&null!=a){const e=RenderTracker.getRender(String(a));e&&(C(e),T(0),S(!1),HighlightUpdatesController.setSpotlight(e.nativeTag)),o?.()}},[e,a,o]);const z=useCallback(()=>{HighlightUpdatesController.isInitialized()||HighlightUpdatesController.initialize(),HighlightUpdatesController.toggle()},[]),B=useCallback(()=>{HighlightUpdatesController.toggleFreeze()},[]),K=useCallback(()=>{HighlightUpdatesController.clearRenderCounts(),g(!1)},[]),L=useMemo(()=>h?formatRenderDataForClipboard():"",[h]),G=useCallback(e=>{v(e)},[]),J=useCallback((e,t,r)=>{C(e),T(t),w("details"),k(0),P.current=r,HighlightUpdatesController.setSpotlight(e.nativeTag)},[]),Y=useCallback(e=>{P.current=e},[]),W=useCallback(()=>{C(null),T(0),HighlightUpdatesController.setSpotlight(null)},[]),X=useCallback(()=>{const e=P.current;if(m>0){const t=m-1,r=e[t];r&&(C(r),T(t),HighlightUpdatesController.setSpotlight(r.nativeTag))}},[m]),q=useCallback(()=>{const e=P.current;if(m<e.length-1){const t=m+1,r=e[t];r&&(C(r),T(t),HighlightUpdatesController.setSpotlight(r.nativeTag))}},[m]),Z=useCallback(()=>{S(!1)},[]),Q=useCallback(()=>{S(!0)},[]),ee=useCallback(()=>{N(!0)},[]),te=useCallback(()=>{N(!1)},[]),re=useCallback(e=>{RenderTracker.setFilters(e);const t=RenderTracker.getFilters();F.current=t,_(t),D(t.includePatterns.length+t.excludePatterns.length)},[]),ne=useCallback((e,t)=>{const r=RenderTracker.getFilters(),n={};"include"===t?r.includePatterns.some(t=>t.type===e.type&&t.value===e.value)||(n.includePatterns=[...r.includePatterns,e]):r.excludePatterns.some(t=>t.type===e.type&&t.value===e.value)||(n.excludePatterns=[...r.excludePatterns,e]),Object.keys(n).length>0&&(re(n),C(null),T(0),HighlightUpdatesController.setSpotlight(null))},[re]),se=useCallback(e=>{RenderTracker.setSettings(e),A(RenderTracker.getSettings())},[]),ae=useCallback(e=>{g(e.totalComponents>0)},[]),oe=useCallback(()=>f?_jsx(FilterViewHeader,{onBack:Z,activeTab:y,onTabChange:R,activeFilterCount:U}):p?_jsx(DetailViewHeader,{onBack:W,activeTab:b,onTabChange:w,hasHistory:(p.renderHistory?.length??0)>0}):_jsx(MainListHeader,{onBack:r,isSearchActive:E,searchText:I,onSearchChange:G,onSearchToggle:ee,onSearchClose:te,onFilterToggle:Q,onToggleTracking:z,onToggleFreeze:B,onClear:K,copyData:L,isTracking:l,isFrozen:u,activeFilterCount:U,hasRenders:h,searchInputRef:H}),[f,p,r,E,I,l,u,U,h,y,b,Z,W,G,ee,te,Q,z,B,K,L]),ie=s?devToolsStorageKeys.modal.root():devToolsStorageKeys.highlightUpdates.modal();if(!e)return null;const le=P.current.length,ce=p?"details"===b?_jsx(EventStepperFooter,{currentIndex:m,totalItems:le,onPrevious:X,onNext:q,itemLabel:"Component",subtitle:p.componentName||p.displayName||p.viewType}):_jsx(RenderHistoryFooter,{render:p,selectedEventIndex:x,onEventIndexChange:k,isPro:i}):null;return _jsx(JsModal,{visible:e,onClose:t,onMinimize:n,persistenceKey:ie,header:{showToggleButton:!0,customContent:oe()},enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,styles:{},footer:ce,footerHeight:p&&("details"===b||(p.renderHistory?.length??0)>1)?68:0,children:_jsx(View,{nativeID:"__rn_buoy__highlight-modal",style:styles.container,children:p?"details"===b?_jsx(RenderDetailView,{render:p,disableInternalFooter:!0,onAddFilter:ne,isPro:i}):_jsx(RenderHistoryViewer,{render:p,disableInternalFooter:!0,selectedEventIndex:x,onEventIndexChange:k,isPro:i}):f?_jsx(HighlightFilterView,{filters:$,onFilterChange:re,settings:O,onSettingsChange:se,availableProps:RenderTracker.getAvailableProps(),activeTab:y}):_jsxs(_Fragment,{children:[!l&&_jsx(DisabledBanner,{}),_jsx(IsolatedRenderList,{searchText:I,filters:$,onSelectRender:J,onStatsChange:ae,onRendersChange:Y,isTracking:l,isPro:i})]})})})}const styles=StyleSheet.create({container:{flex:1,backgroundColor:buoyColors.base},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:buoyColors.warning+"15",borderRadius:8,borderWidth:1,borderColor:buoyColors.warning+"20"},disabledText:{color:buoyColors.warning,fontSize:11,flex:1}});export default HighlightUpdatesModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{memo}from"react";import{View,TouchableOpacity,TextInput,StyleSheet}from"react-native";import{Trash2,
|
|
1
|
+
"use strict";import React,{memo}from"react";import{View,TouchableOpacity,TextInput,StyleSheet}from"react-native";import{Trash2,Search,Filter,X,Pause,ModalHeader,TabSelector,CopyButton,buoyColors,PowerToggleButton}from"@buoy-gg/shared-ui";import{StatsDisplay}from"./StatsDisplay";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SearchSectionInner=memo(function({isActive:e,searchText:o,onSearchChange:t,onSearchClose:r}){return e?_jsxs(View,{nativeID:"__rn_buoy__search-container",style:styles.headerSearchContainer,children:[_jsx(Search,{size:14,color:buoyColors.textSecondary}),_jsx(TextInput,{style:styles.headerSearchInput,placeholder:"Search testID, nativeID, component...",placeholderTextColor:buoyColors.textMuted,value:o,onChangeText:t,onSubmitEditing:r,onBlur:r,accessibilityLabel:"Search renders",autoCapitalize:"none",autoCorrect:!1,returnKeyType:"search",autoFocus:!0}),o.length>0?_jsx(TouchableOpacity,{onPress:()=>{t(""),r()},style:styles.headerSearchClear,children:_jsx(X,{size:14,color:buoyColors.textSecondary})}):null]}):null});export const SearchSection=SearchSectionInner;const HeaderActionsInner=memo(function({onSearchToggle:e,onFilterToggle:o,onToggleTracking:t,onToggleFreeze:r,onClear:a,copyData:n,isTracking:s,isFrozen:i,activeFilterCount:l,hasRenders:c}){return _jsxs(ModalHeader.Actions,{children:[_jsx(TouchableOpacity,{onPress:e,style:styles.headerActionButton,children:_jsx(Search,{size:14,color:buoyColors.textSecondary})}),_jsx(TouchableOpacity,{onPress:o,style:[styles.headerActionButton,l>0&&styles.activeFilterButton],children:_jsx(Filter,{size:14,color:l>0?buoyColors.primary:buoyColors.textMuted})}),_jsx(CopyButton,{value:n,size:14,buttonStyle:c?styles.headerActionButton:styles.headerActionButtonCopyDisabled,disabled:!c,colors:{idle:c?buoyColors.textSecondary:buoyColors.textMuted}}),_jsx(TouchableOpacity,{onPress:r,style:[styles.headerActionButton,i&&styles.freezeButton,!s&&styles.headerActionButtonDisabled],disabled:!s,children:_jsx(Pause,{size:14,color:s&&i?buoyColors.primary:buoyColors.textMuted})}),_jsx(PowerToggleButton,{isEnabled:s,onToggle:t,accessibilityLabel:"Toggle render tracking"}),_jsx(TouchableOpacity,{onPress:a,style:[styles.headerActionButton,!c&&styles.headerActionButtonDisabled],disabled:!c,children:_jsx(Trash2,{size:14,color:buoyColors.textMuted})})]})});export const HeaderActions=HeaderActionsInner;export const MainListHeader=memo(function({onBack:e,isSearchActive:o,searchText:t,onSearchChange:r,onSearchToggle:a,onSearchClose:n,onFilterToggle:s,onToggleTracking:i,onToggleFreeze:l,onClear:c,copyData:d,isTracking:u,isFrozen:h,activeFilterCount:y,hasRenders:b,searchInputRef:g}){return _jsxs(ModalHeader,{children:[e&&_jsx(ModalHeader.Navigation,{onBack:e}),_jsx(ModalHeader.Content,{title:"",children:o?_jsx(SearchSection,{isActive:o,searchText:t,onSearchChange:r,onSearchClose:n,searchInputRef:g}):_jsx(StatsDisplay,{})}),_jsx(HeaderActions,{onSearchToggle:a,onFilterToggle:s,onToggleTracking:i,onToggleFreeze:l,onClear:c,copyData:d,isTracking:u,isFrozen:h,activeFilterCount:y,hasRenders:b})]})});export const FilterViewHeader=memo(function({onBack:e,activeTab:o,onTabChange:t,activeFilterCount:r=0}){const a=[{key:"filters",label:"Filters"+(r>0?` (${r})`:"")},{key:"settings",label:"Settings"}];return _jsxs(ModalHeader,{children:[_jsx(ModalHeader.Navigation,{onBack:e}),_jsx(ModalHeader.Content,{title:"",noMargin:!0,children:_jsx(TabSelector,{tabs:a,activeTab:o,onTabChange:e=>t(e)})}),_jsx(ModalHeader.Actions,{})]})});export const DetailViewHeader=memo(function({onBack:e,activeTab:o,onTabChange:t,hasHistory:r=!0}){const a=[{key:"details",label:"Details"},{key:"history",label:"History",disabled:!r}];return _jsxs(ModalHeader,{children:[_jsx(ModalHeader.Navigation,{onBack:e}),_jsx(ModalHeader.Content,{title:"",noMargin:!0,children:_jsx(TabSelector,{tabs:a,activeTab:o,onTabChange:e=>t(e)})}),_jsx(ModalHeader.Actions,{})]})});const styles=StyleSheet.create({headerSearchContainer:{flexDirection:"row",alignItems:"center",backgroundColor:buoyColors.input,borderRadius:10,borderWidth:1,borderColor:buoyColors.border,paddingHorizontal:12,paddingVertical:5},headerSearchInput:{flex:1,color:buoyColors.text,fontSize:13,marginLeft:6,paddingVertical:2},headerSearchClear:{marginLeft:6,padding:4},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:buoyColors.hover,borderWidth:1,borderColor:buoyColors.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonCopyDisabled:{width:32,height:32,borderRadius:8,backgroundColor:buoyColors.hover,borderWidth:1,borderColor:buoyColors.border,alignItems:"center",justifyContent:"center",opacity:.55},activeFilterButton:{backgroundColor:buoyColors.primary+"15",borderColor:buoyColors.primary+"40"},freezeButton:{backgroundColor:buoyColors.primary+"15",borderColor:buoyColors.primary+"40"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{installProfilerInterceptor,uninstallProfilerInterceptor,setComparisonCallback}from"./ProfilerInterceptor";import{RenderTracker}from"./RenderTracker";import{PerformanceLogger,markEventReceived}from"./PerformanceLogger";import{detectRenderCause,clearRenderCauseState}from"./RenderCauseDetector";let globalEnabled=!1,initialized=!1,hook=null,highlightCallback=null,badgePressCallback=null,traceUpdatesUnsubscribe=null,isProcessing=!1,isFrozen=!1;const freezeListeners=new Set,stateListeners=new Set,nodeRenderCounts=new Map,COLORS=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"],DEBUG=!1;function debugLog(e,t){}function getPublicInstance(e){if(!e)return null;const t=e;return t.canonical?.publicInstance?t.canonical.publicInstance:t.canonical&&"function"==typeof t.canonical.measure?t.canonical:"function"==typeof t.measure?t:null}function getNativeTag(e){const t=e;if(null!=t.__nativeTag)return t.__nativeTag;if(null!=t._nativeTag)return t._nativeTag;if(null!=t.nativeTag)return t.nativeTag;if(t.canonical){if(null!=t.canonical.__nativeTag)return t.canonical.__nativeTag;if(null!=t.canonical._nativeTag)return t.canonical._nativeTag}return null}function extractComponentInfo(e){const t=e,n={viewType:"Unknown"};t?.canonical?.viewConfig?.uiViewClassName?n.viewType=t.canonical.viewConfig.uiViewClassName:t?.viewConfig?.uiViewClassName&&(n.viewType=t.viewConfig.uiViewClassName);const i=t?.canonical?.internalInstanceHandle,o=t?.canonical?.currentProps,a=t?.canonical?.pendingProps,r=i?.pendingProps,s=i?.memoizedProps;return n.testID=o?.testID||a?.testID||r?.testID||s?.testID||void 0,n.nativeID=o?.nativeID||a?.nativeID||r?.nativeID||s?.nativeID||void 0,n.accessibilityLabel=o?.accessibilityLabel||a?.accessibilityLabel||r?.accessibilityLabel||s?.accessibilityLabel||void 0,n.componentName=getOwningComponentName(i)||void 0,n}function describeNodeForLog(e){const t=e,n=getPublicInstance(e),i={nativeTag:(getNativeTag(e)||getNativeTag(n))??"unknown",type:t?.canonical?"Fabric":"Legacy",hasMeasure:"function"==typeof n?.measure};if(t){if(i.stateNodeKeys=Object.keys(t).slice(0,20),t.node&&(i.nodeKeys=Object.keys(t.node).slice(0,20)),t.viewConfig&&(i.viewConfig={uiViewClassName:t.viewConfig.uiViewClassName,validAttributes:t.viewConfig.validAttributes?Object.keys(t.viewConfig.validAttributes).slice(0,10):void 0}),t.canonical){const e=t.canonical;if(i.canonicalKeys=Object.keys(e).slice(0,20),e.viewConfig&&(i.canonicalViewConfig={uiViewClassName:e.viewConfig.uiViewClassName}),null!=e.nativeTag&&(i.canonicalNativeTag=e.nativeTag),e.internalInstanceHandle){const t=e.internalInstanceHandle;if(i.fiberKeys=Object.keys(t).slice(0,30),t.type&&(i.fiberType="function"==typeof t.type?t.type.name||t.type.displayName||"function":t.type),t.elementType&&(i.fiberElementType="function"==typeof t.elementType?t.elementType.name||t.elementType.displayName||"function":t.elementType),t._debugOwner){const e=t._debugOwner;i.fiberDebugOwner=e.type?.name||e.type?.displayName||e.elementType?.name||"unknown"}t._debugSource&&(i.fiberDebugSource=t._debugSource),null!=t.tag&&(i.fiberTag=t.tag),t.pendingProps&&(t.pendingProps.nativeID&&(i.fiberPendingNativeID=t.pendingProps.nativeID),t.pendingProps.testID&&(i.fiberPendingTestID=t.pendingProps.testID)),t.memoizedProps&&(t.memoizedProps.nativeID&&(i.fiberMemoizedNativeID=t.memoizedProps.nativeID),t.memoizedProps.testID&&(i.fiberMemoizedTestID=t.memoizedProps.testID))}if(e.publicInstance){const t=e.publicInstance;i.publicInstanceKeys=Object.keys(t).slice(0,20),null!=t.nativeID&&(i.nativeID=t.nativeID),null!=t._nativeID&&(i._nativeID=t._nativeID),t.props&&(i.publicInstanceProps=Object.keys(t.props).slice(0,15),t.props.nativeID&&(i.propsNativeID=t.props.nativeID),t.props.testID&&(i.propsTestID=t.props.testID),t.props.accessibilityLabel&&(i.accessibilityLabel=t.props.accessibilityLabel))}e.currentProps&&(i.currentPropsKeys=Object.keys(e.currentProps).slice(0,15),null!=e.currentProps.nativeID&&(i.currentPropsNativeID=e.currentProps.nativeID),null!=e.currentProps.testID&&(i.currentPropsTestID=e.currentProps.testID),null!=e.currentProps.accessibilityLabel&&(i.currentPropsAccessLabel=e.currentProps.accessibilityLabel)),e.pendingProps&&(i.pendingPropsKeys=Object.keys(e.pendingProps).slice(0,15),null!=e.pendingProps.nativeID&&(i.pendingPropsNativeID=e.pendingProps.nativeID),null!=e.pendingProps.testID&&(i.pendingPropsTestID=e.pendingProps.testID))}if(t._debugOwner){const e=t._debugOwner;i.debugOwnerType=e.type?.name||e.type?.displayName||typeof e.type}t._debugSource&&(i.debugSource=t._debugSource)}return i}const DEBUG_LOGGING=!1;let renderingLock=!1,renderingLockTimeout=null;const RENDER_LOCK_DURATION=350,renderedOverlayTags=new Set;function isOurOverlayTag(e){return null!=e&&renderedOverlayTags.has(e)}const DEV_TOOLS_COMPONENT_NAMES=new Set(["JsModalComponent","JsModal","HighlightUpdatesModal","HighlightFilterView","RenderDetailView","RenderListItem","RenderListItemInner","TypePicker","PatternInput","PatternChip","DetectedItemsSection","DetectedCategoryBadge","IdentifierBadge","CategoryBadge","AppRenderer","AppOverlay","FloatingTools","DialDevTools","HighlightUpdatesOverlay","DevToolsVisibilityProvider","AppHostProvider","MinimizedToolsProvider","ModalHeader","TabSelector","SectionHeader","DraggableHeader","WindowControls","LogBox","LogBoxLog","LogBoxLogNotification","LogBoxNotificationContainer","_LogBoxNotificationContainer","LogBoxInspector","LogBoxInspectorContainer","LogBoxInspectorHeader","LogBoxInspectorBody","LogBoxInspectorFooter","LogBoxInspectorMessageHeader","LogBoxInspectorStackFrame","LogBoxInspectorSection","LogBoxButton","LogBoxMessage"]),DEV_TOOLS_COMPONENT_PREFIXES=["JsModal","HighlightUpdates","RenderList","RenderDetail"],DEV_TOOLS_NATIVE_IDS=new Set(["highlight-updates-overlay","jsmodal-root","__rn_buoy__highlight-modal","logbox_inspector","logbox"]),devToolsNodeCache=new Map,CACHE_MAX_SIZE=500;function isDevToolsNativeID(e){if(!e)return!1;if(DEV_TOOLS_NATIVE_IDS.has(e))return!0;const t=e.charCodeAt(0);return!(95!==t||!e.startsWith("__highlight_")&&!e.startsWith("__rn_buoy__"))||!(108!==t||!e.startsWith("logbox"))}function getComponentName(e){if(!e)return null;const t=e.type;if(t){if("string"==typeof t)return t;if(t.name)return t.name;if(t.displayName)return t.displayName}const n=e.elementType;if(n){if(n.name)return n.name;if(n.displayName)return n.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){return!e||!!INTERNAL_COMPONENT_NAMES.has(e)||"Unknown"===e||"Component"===e||!!e.startsWith("Animated")}function getOwningComponentName(e){if(!e)return null;let t=e._debugOwner||e.return,n=0,i=null;for(;t&&n<30;){const e=getComponentName(t);if(e&&"string"!=typeof t.type&&(i||(i=e),!isInternalComponent(e)))return e;t=t.return,n++}return i}function isOurOverlayNode(e){const t=e,n=t?.canonical?.internalInstanceHandle,i=getNativeTag(e)||getNativeTag(t?.canonical?.publicInstance);if(null!=i){const e=devToolsNodeCache.get(i);if(void 0!==e)return e}let o=!1;if(isDevToolsNativeID(n?.pendingProps?.nativeID||n?.memoizedProps?.nativeID||t?.canonical?.currentProps?.nativeID||null))o=!0;else if(n){let e=n,t=0;for(;e&&t<30;){const n=getComponentName(e);if(n){if(DEV_TOOLS_COMPONENT_NAMES.has(n)){o=!0;break}for(const e of DEV_TOOLS_COMPONENT_PREFIXES)if(n.startsWith(e)){o=!0;break}if(o)break}if(isDevToolsNativeID(e.pendingProps?.nativeID||e.memoizedProps?.nativeID)){o=!0;break}e=e.return,t++}}if(o&&null!=i){if(devToolsNodeCache.size>=500){const e=Array.from(devToolsNodeCache.keys());for(let t=0;t<250;t++)devToolsNodeCache.delete(e[t])}devToolsNodeCache.set(i,o)}return o}function getColorForRenderCount(e){const t=Math.min(e-1,COLORS.length-1);return COLORS[Math.max(0,t)]}function handleTraceUpdates(e){if(0===e.size)return;if(!globalEnabled)return;if(RenderTracker.getState().isPaused)return;PerformanceLogger.isEnabled()&&markEventReceived();const t=RenderTracker.getBatchSize(),n=PerformanceLogger.startBatch(e.size,t),i=[];let o=0,a=0;const r=RenderTracker.hasActiveFilters();for(const t of e)if(t&&"object"==typeof t){if(isOurOverlayNode(t)){o++;continue}const e=getPublicInstance(t),n=getNativeTag(t)||getNativeTag(e);if(null==n)continue;const s=extractComponentInfo(t);if(r&&!RenderTracker.passesFilters(s)){a++;continue}let l,c;RenderTracker.getSettings().showRenderCount?(l=(nodeRenderCounts.get(n)||0)+1,nodeRenderCounts.set(n,l),c=getColorForRenderCount(l)):(l=0,c=COLORS[0]),i.push({node:t,color:c,count:l})}if(n.markFilteringComplete(o+a,i.length),0===i.length)return void n.finish();if(!highlightCallback)return void(isProcessing=!1);n.markMeasurementStart();const s=i.slice(0,t).map(({node:e,color:t,count:n})=>new Promise(i=>{const o=getPublicInstance(e);if(!o)return void i({rect:null,stateNode:e,color:t,count:n});const a=getNativeTag(e)||getNativeTag(o);if(null!=a)try{o.measure((o,r,s,l,c,d)=>{i(null!=c&&null!=d&&null!=s&&null!=l?{rect:{id:a,x:c,y:d,width:s,height:l,color:t,count:n},stateNode:e,color:t,count:n}:{rect:null,stateNode:e,color:t,count:n})})}catch(o){i({rect:null,stateNode:e,color:t,count:n})}else i({rect:null,stateNode:e,color:t,count:n})}));Promise.all(s).then(e=>{const t=e.filter(e=>null!==e.rect),i=t.map(e=>e.rect);n.markMeasurementComplete(t.length,e.length-t.length),RenderTracker.startBatch();const o=RenderTracker.getSettings(),a=o.trackRenderCauses&&o.showRenderCount;let r=null;if(a){r=new Set;for(const{rect:e}of t)e&&r.add(e.id)}for(const{rect:e,stateNode:n,color:i,count:s}of t)if(e){const t=extractComponentInfo(n);let l;if(a&&r){const t=n,i=t?.canonical?.internalInstanceHandle,a="off"!==o.debugLogLevel?o.debugLogLevel:o.debugRawFiberLogging?"all":"off";l=detectRenderCause(e.id,i,r,a)}RenderTracker.trackRender({nativeTag:e.id,viewType:t.viewType,testID:t.testID,nativeID:t.nativeID,accessibilityLabel:t.accessibilityLabel,componentName:t.componentName,measurements:{x:e.x,y:e.y,width:e.width,height:e.height},color:i,count:s,renderCause:l})}RenderTracker.endBatch(),n.markTrackingComplete(),i.length>0&&highlightCallback&&highlightCallback(i),n.markCallbackComplete(),n.finish()}).catch(e=>{console.error("[HighlightUpdates] Error in measurement pipeline:",e),n.finish()})}function setTraceUpdatesOnRenderers(e){if(!hook?.rendererInterfaces)return void debugLog("No rendererInterfaces available");let t=0;if(hook.rendererInterfaces.forEach((n,i)=>{if("function"==typeof n.setTraceUpdatesEnabled)try{n.setTraceUpdatesEnabled(e),t++,debugLog(`Renderer ${i}: setTraceUpdatesEnabled(${e})`)}catch(e){debugLog(`Renderer ${i}: error setting trace updates`,e)}else debugLog(`Renderer ${i}: no setTraceUpdatesEnabled method`)}),debugLog(`Set trace updates ${e?"enabled":"disabled"} on ${t} renderer(s)`),hook.reactDevtoolsAgent?.setTraceUpdatesEnabled)try{hook.reactDevtoolsAgent.setTraceUpdatesEnabled(e),debugLog("Also set trace updates on agent")}catch(e){debugLog("Error setting trace updates on agent",e)}}function subscribeToTraceUpdates(){hook&&(traceUpdatesUnsubscribe||(debugLog("Subscribing to traceUpdates event"),"function"==typeof hook.sub?(traceUpdatesUnsubscribe=hook.sub("traceUpdates",handleTraceUpdates),debugLog("Subscribed using hook.sub()")):debugLog("hook.sub not available, traceUpdates may not work"),setTraceUpdatesOnRenderers(!0)))}function unsubscribeFromTraceUpdates(){setTraceUpdatesOnRenderers(!1),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){badgePressCallback&&badgePressCallback(e)}let spotlightCallback=null,currentSpotlightTag=null;function setSpotlightCallback(e){spotlightCallback=e,e&&null!==currentSpotlightTag&&e(currentSpotlightTag)}function setSpotlight(e){currentSpotlightTag=e,spotlightCallback&&spotlightCallback(e)}function getSpotlight(){return currentSpotlightTag}function notifyStateListeners(){stateListeners.forEach(e=>{try{e(globalEnabled)}catch(e){console.error("[HighlightUpdates] Error in state listener:",e)}})}function subscribe(e){return stateListeners.add(e),e(globalEnabled),()=>{stateListeners.delete(e)}}function initialize(){if("undefined"!=typeof __DEV__&&!__DEV__)return debugLog("Only available in development builds"),!1;if(initialized)return!0;if(hook=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null,!hook)return debugLog("React DevTools hook not found"),!1;if(debugLog("Hook found"),debugLog(`Hook has sub: ${"function"==typeof hook.sub}`),debugLog(`Hook has on: ${"function"==typeof hook.on}`),debugLog(`Hook has emit: ${"function"==typeof hook.emit}`),installProfilerInterceptor(),hook.rendererInterfaces&&hook.rendererInterfaces.size>0)return initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`),exposeGlobally(),!0;const e=setInterval(()=>{hook?.rendererInterfaces&&hook.rendererInterfaces.size>0&&(clearInterval(e),initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`),exposeGlobally())},100);return setTimeout(()=>clearInterval(e),1e4),!1}function exposeGlobally(){"undefined"!=typeof window&&(window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,subscribe:subscribe,initialize:initialize,destroy:destroy,isInitialized:()=>initialized,setHighlightCallback:setHighlightCallback})}function enable(){("undefined"==typeof __DEV__||__DEV__)&&(initialized||initialize(),globalEnabled||(debugLog("Enabling highlights"),subscribeToTraceUpdates(),RenderTracker.start(),globalEnabled=!0,notifyStateListeners()))}function disable(){("undefined"==typeof __DEV__||__DEV__)&&globalEnabled&&(debugLog("Disabling highlights"),renderingLock=!1,isProcessing=!1,renderingLockTimeout&&(clearTimeout(renderingLockTimeout),renderingLockTimeout=null),renderedOverlayTags.clear(),devToolsNodeCache.clear(),clearRenderCauseState(),unsubscribeFromTraceUpdates(),RenderTracker.stop(),globalEnabled=!1,notifyStateListeners())}function toggle(){("undefined"==typeof __DEV__||__DEV__)&&(globalEnabled?disable():enable())}function clearRenderCounts(){nodeRenderCounts.clear(),RenderTracker.clear(),debugLog("Cleared render counts")}function isEnabled(){return globalEnabled}function setEnabled(e){e?enable():disable()}function isInitialized(){return initialized}function notifyFreezeListeners(){freezeListeners.forEach(e=>{try{e(isFrozen)}catch(e){console.error("[HighlightUpdates] Error in freeze listener:",e)}})}function subscribeToFreeze(e){return freezeListeners.add(e),e(isFrozen),()=>{freezeListeners.delete(e)}}function freeze(){("undefined"==typeof __DEV__||__DEV__)&&(isFrozen||(isFrozen=!0,debugLog("Freeze mode enabled"),notifyFreezeListeners()))}function unfreeze(){("undefined"==typeof __DEV__||__DEV__)&&isFrozen&&(isFrozen=!1,debugLog("Freeze mode disabled"),highlightCallback&&highlightCallback([]),notifyFreezeListeners())}function toggleFreeze(){isFrozen?unfreeze():freeze()}function getFrozen(){return isFrozen}function destroy(){initialized&&(unsubscribeFromTraceUpdates(),uninstallProfilerInterceptor(),setComparisonCallback(null),isFrozen=!1,freezeListeners.clear(),globalEnabled=!1,hook=null,highlightCallback=null,initialized=!1,"undefined"!=typeof window&&delete window.__HIGHLIGHT_UPDATES_CONTROLLER__,debugLog("Destroyed"))}const HighlightUpdatesController={subscribe:subscribe,enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,initialize:initialize,destroy:destroy,isInitialized:isInitialized,setHighlightCallback:setHighlightCallback,clearRenderCounts:clearRenderCounts,freeze:freeze,unfreeze:unfreeze,toggleFreeze:toggleFreeze,getFrozen:getFrozen,subscribeToFreeze:subscribeToFreeze,setBadgePressCallback:setBadgePressCallback,getBadgePressCallback:getBadgePressCallback,handleBadgePress:handleBadgePress,setSpotlightCallback:setSpotlightCallback,setSpotlight:setSpotlight,getSpotlight:getSpotlight};export default HighlightUpdatesController;
|
|
1
|
+
"use strict";import{installProfilerInterceptor,uninstallProfilerInterceptor,setComparisonCallback}from"./ProfilerInterceptor";import{RenderTracker}from"./RenderTracker";import{PerformanceLogger,markEventReceived}from"./PerformanceLogger";import{detectRenderCause,clearRenderCauseState}from"./RenderCauseDetector";let globalEnabled=!1,initialized=!1,hook=null,highlightCallback=null,badgePressCallback=null,traceUpdatesUnsubscribe=null,isProcessing=!1,isFrozen=!1;const freezeListeners=new Set,stateListeners=new Set,nodeRenderCounts=new Map,COLORS=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"],DEBUG=!1;function debugLog(e,t){}function getPublicInstance(e){if(!e)return null;const t=e;return t.canonical?.publicInstance?t.canonical.publicInstance:t.canonical&&"function"==typeof t.canonical.measure?t.canonical:"function"==typeof t.measure?t:null}function getNativeTag(e){const t=e;if(null!=t.__nativeTag)return t.__nativeTag;if(null!=t._nativeTag)return t._nativeTag;if(null!=t.nativeTag)return t.nativeTag;if(t.canonical){if(null!=t.canonical.__nativeTag)return t.canonical.__nativeTag;if(null!=t.canonical._nativeTag)return t.canonical._nativeTag}return null}function extractComponentInfo(e){const t=e,n={viewType:"Unknown"};t?.canonical?.viewConfig?.uiViewClassName?n.viewType=t.canonical.viewConfig.uiViewClassName:t?.viewConfig?.uiViewClassName&&(n.viewType=t.viewConfig.uiViewClassName);const i=t?.canonical?.internalInstanceHandle,o=t?.canonical?.currentProps,r=t?.canonical?.pendingProps,a=i?.pendingProps,s=i?.memoizedProps;return n.testID=o?.testID||r?.testID||a?.testID||s?.testID||void 0,n.nativeID=o?.nativeID||r?.nativeID||a?.nativeID||s?.nativeID||void 0,n.accessibilityLabel=o?.accessibilityLabel||r?.accessibilityLabel||a?.accessibilityLabel||s?.accessibilityLabel||void 0,n.componentName=getOwningComponentName(i)||void 0,n}function describeNodeForLog(e){const t=e,n=getPublicInstance(e),i={nativeTag:(getNativeTag(e)||getNativeTag(n))??"unknown",type:t?.canonical?"Fabric":"Legacy",hasMeasure:"function"==typeof n?.measure};if(t){if(i.stateNodeKeys=Object.keys(t).slice(0,20),t.node&&(i.nodeKeys=Object.keys(t.node).slice(0,20)),t.viewConfig&&(i.viewConfig={uiViewClassName:t.viewConfig.uiViewClassName,validAttributes:t.viewConfig.validAttributes?Object.keys(t.viewConfig.validAttributes).slice(0,10):void 0}),t.canonical){const e=t.canonical;if(i.canonicalKeys=Object.keys(e).slice(0,20),e.viewConfig&&(i.canonicalViewConfig={uiViewClassName:e.viewConfig.uiViewClassName}),null!=e.nativeTag&&(i.canonicalNativeTag=e.nativeTag),e.internalInstanceHandle){const t=e.internalInstanceHandle;if(i.fiberKeys=Object.keys(t).slice(0,30),t.type&&(i.fiberType="function"==typeof t.type?t.type.name||t.type.displayName||"function":t.type),t.elementType&&(i.fiberElementType="function"==typeof t.elementType?t.elementType.name||t.elementType.displayName||"function":t.elementType),t._debugOwner){const e=t._debugOwner;i.fiberDebugOwner=e.type?.name||e.type?.displayName||e.elementType?.name||"unknown"}t._debugSource&&(i.fiberDebugSource=t._debugSource),null!=t.tag&&(i.fiberTag=t.tag),t.pendingProps&&(t.pendingProps.nativeID&&(i.fiberPendingNativeID=t.pendingProps.nativeID),t.pendingProps.testID&&(i.fiberPendingTestID=t.pendingProps.testID)),t.memoizedProps&&(t.memoizedProps.nativeID&&(i.fiberMemoizedNativeID=t.memoizedProps.nativeID),t.memoizedProps.testID&&(i.fiberMemoizedTestID=t.memoizedProps.testID))}if(e.publicInstance){const t=e.publicInstance;i.publicInstanceKeys=Object.keys(t).slice(0,20),null!=t.nativeID&&(i.nativeID=t.nativeID),null!=t._nativeID&&(i._nativeID=t._nativeID),t.props&&(i.publicInstanceProps=Object.keys(t.props).slice(0,15),t.props.nativeID&&(i.propsNativeID=t.props.nativeID),t.props.testID&&(i.propsTestID=t.props.testID),t.props.accessibilityLabel&&(i.accessibilityLabel=t.props.accessibilityLabel))}e.currentProps&&(i.currentPropsKeys=Object.keys(e.currentProps).slice(0,15),null!=e.currentProps.nativeID&&(i.currentPropsNativeID=e.currentProps.nativeID),null!=e.currentProps.testID&&(i.currentPropsTestID=e.currentProps.testID),null!=e.currentProps.accessibilityLabel&&(i.currentPropsAccessLabel=e.currentProps.accessibilityLabel)),e.pendingProps&&(i.pendingPropsKeys=Object.keys(e.pendingProps).slice(0,15),null!=e.pendingProps.nativeID&&(i.pendingPropsNativeID=e.pendingProps.nativeID),null!=e.pendingProps.testID&&(i.pendingPropsTestID=e.pendingProps.testID))}if(t._debugOwner){const e=t._debugOwner;i.debugOwnerType=e.type?.name||e.type?.displayName||typeof e.type}t._debugSource&&(i.debugSource=t._debugSource)}return i}const DEBUG_LOGGING=!1;let renderingLock=!1,renderingLockTimeout=null;const RENDER_LOCK_DURATION=350,renderedOverlayTags=new Set;function isOurOverlayTag(e){return null!=e&&renderedOverlayTags.has(e)}const DEV_TOOLS_COMPONENT_NAMES=new Set(["JsModalComponent","JsModal","HighlightUpdatesModal","HighlightFilterView","RenderDetailView","RenderListItem","RenderListItemInner","TypePicker","PatternInput","PatternChip","DetectedItemsSection","DetectedCategoryBadge","IdentifierBadge","CategoryBadge","AppRenderer","AppOverlay","FloatingTools","DialDevTools","HighlightUpdatesOverlay","DevToolsVisibilityProvider","AppHostProvider","MinimizedToolsProvider","ModalHeader","TabSelector","SectionHeader","DraggableHeader","WindowControls","TreeDiffViewer","DataViewer","SplitDiffViewer","VirtualizedDataExplorer","DiffSummary","TypeLegend","IndentGuides","IndentGuidesOverlay","CyberpunkInput","EventStepperFooter","RenderHistoryViewer","RenderHistoryFooter","CurrentStateView","DiffView","AnswerCard","DetailsSection","DetailRow","QuickActionsSection","FilterOptionCard","RenderCauseBadge","TwoLevelCauseBadge","EnhancedCauseDisplay","IsolatedRenderList","IsolatedRenderListInner","StatsDisplay","StatsDisplayInner","SearchSection","SearchSectionInner","HeaderActions","HeaderActionsInner","MainListHeader","FilterViewHeader","DetailViewHeader","FloatingMenu","FloatingDevTools","MinimizedToolsStack","MinimizedToolsContext","GlitchToolButton","ExpandablePopover","CollapsedPeek","ExpandedWrapper","DialIcon","DialMenu","DialIconItem","OnboardingTooltip","MenuLauncherIcon","DevToolsSettingsModal","SettingsModal","ToolCard","ToolIcon","GripVerticalIcon","UserStatus","Divider","ChevronDown","ChevronUp","ChevronLeft","ChevronRight","ChevronDownIcon","ChevronUpIcon","ChevronLeftIcon","ChevronRightIcon","LogBox","LogBoxLog","LogBoxLogNotification","LogBoxNotificationContainer","_LogBoxNotificationContainer","LogBoxInspector","LogBoxInspectorContainer","LogBoxInspectorHeader","LogBoxInspectorBody","LogBoxInspectorFooter","LogBoxInspectorMessageHeader","LogBoxInspectorStackFrame","LogBoxInspectorSection","LogBoxButton","LogBoxMessage"]),DEV_TOOLS_COMPONENT_PREFIXES=["JsModal","HighlightUpdates","RenderList","RenderDetail","RenderHistory","RenderCause","TreeDiff","DataViewer","DiffView","DiffSummary","EventStepper","Virtualized","Floating","Minimized","Dial","Expandable","Chevron","Glitch","Settings","Onboarding","DevTools"],DEV_TOOLS_NATIVE_IDS=new Set(["highlight-updates-overlay","jsmodal-root","__rn_buoy__highlight-modal","logbox_inspector","logbox"]),devToolsNodeCache=new Map,CACHE_MAX_SIZE=500;function isDevToolsNativeID(e){if(!e)return!1;if(DEV_TOOLS_NATIVE_IDS.has(e))return!0;const t=e.charCodeAt(0);return!(95!==t||!e.startsWith("__highlight_")&&!e.startsWith("__rn_buoy__"))||!(108!==t||!e.startsWith("logbox"))}function getComponentName(e){if(!e)return null;const t=e.type;if(t){if("string"==typeof t)return t;if(t.name)return t.name;if(t.displayName)return t.displayName}const n=e.elementType;if(n){if(n.name)return n.name;if(n.displayName)return n.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){return!e||!!INTERNAL_COMPONENT_NAMES.has(e)||"Unknown"===e||"Component"===e||!!e.startsWith("Animated")}function getOwningComponentName(e){if(!e)return null;let t=e._debugOwner||e.return,n=0,i=null;for(;t&&n<30;){const e=getComponentName(t);if(e&&"string"!=typeof t.type&&(i||(i=e),!isInternalComponent(e)))return e;t=t.return,n++}return i}function isOurOverlayNode(e){const t=e,n=t?.canonical?.internalInstanceHandle,i=getNativeTag(e)||getNativeTag(t?.canonical?.publicInstance);if(null!=i){const e=devToolsNodeCache.get(i);if(void 0!==e)return e}let o=!1;if(isDevToolsNativeID(n?.pendingProps?.nativeID||n?.memoizedProps?.nativeID||t?.canonical?.currentProps?.nativeID||null))o=!0;else if(n){let e=n,t=0;for(;e&&t<30;){const n=getComponentName(e);if(n){if(DEV_TOOLS_COMPONENT_NAMES.has(n)){o=!0;break}for(const e of DEV_TOOLS_COMPONENT_PREFIXES)if(n.startsWith(e)){o=!0;break}if(o)break}if(isDevToolsNativeID(e.pendingProps?.nativeID||e.memoizedProps?.nativeID)){o=!0;break}e=e.return,t++}}if(o&&null!=i){if(devToolsNodeCache.size>=500){const e=Array.from(devToolsNodeCache.keys());for(let t=0;t<250;t++)devToolsNodeCache.delete(e[t])}devToolsNodeCache.set(i,o)}return o}function getColorForRenderCount(e){const t=Math.min(e-1,COLORS.length-1);return COLORS[Math.max(0,t)]}function handleTraceUpdates(e){if(0===e.size)return;if(!globalEnabled)return;if(RenderTracker.getState().isPaused)return;PerformanceLogger.isEnabled()&&markEventReceived();const t=RenderTracker.getBatchSize(),n=PerformanceLogger.startBatch(e.size,t),i=[];let o=0,r=0;const a=RenderTracker.hasActiveFilters();for(const t of e)if(t&&"object"==typeof t){if(isOurOverlayNode(t)){o++;continue}const e=getPublicInstance(t),n=getNativeTag(t)||getNativeTag(e);if(null==n)continue;const s=extractComponentInfo(t);if(a&&!RenderTracker.passesFilters(s)){r++;continue}let l,c;RenderTracker.getSettings().showRenderCount?(l=(nodeRenderCounts.get(n)||0)+1,nodeRenderCounts.set(n,l),c=getColorForRenderCount(l)):(l=0,c=COLORS[0]),i.push({node:t,color:c,count:l})}if(n.markFilteringComplete(o+r,i.length),0===i.length)return void n.finish();if(!highlightCallback)return void(isProcessing=!1);n.markMeasurementStart();const s=i.slice(0,t).map(({node:e,color:t,count:n})=>new Promise(i=>{const o=getPublicInstance(e);if(!o)return void i({rect:null,stateNode:e,color:t,count:n});const r=getNativeTag(e)||getNativeTag(o);if(null!=r)try{o.measure((o,a,s,l,c,d)=>{i(null!=c&&null!=d&&null!=s&&null!=l?{rect:{id:r,x:c,y:d,width:s,height:l,color:t,count:n},stateNode:e,color:t,count:n}:{rect:null,stateNode:e,color:t,count:n})})}catch(o){i({rect:null,stateNode:e,color:t,count:n})}else i({rect:null,stateNode:e,color:t,count:n})}));Promise.all(s).then(e=>{const t=e.filter(e=>null!==e.rect),i=t.map(e=>e.rect);n.markMeasurementComplete(t.length,e.length-t.length),RenderTracker.startBatch();const o=RenderTracker.getSettings(),r=o.trackRenderCauses&&o.showRenderCount;let a=null;if(r){a=new Set;for(const{rect:e}of t)e&&a.add(e.id)}for(const{rect:e,stateNode:n,color:i,count:s}of t)if(e){const t=extractComponentInfo(n);let l;if(r&&a){const t=n,i=t?.canonical?.internalInstanceHandle;l=detectRenderCause(e.id,i,a,o.debugLogLevel)}RenderTracker.trackRender({nativeTag:e.id,viewType:t.viewType,testID:t.testID,nativeID:t.nativeID,accessibilityLabel:t.accessibilityLabel,componentName:t.componentName,measurements:{x:e.x,y:e.y,width:e.width,height:e.height},color:i,count:s,renderCause:l})}RenderTracker.endBatch(),n.markTrackingComplete(),i.length>0&&highlightCallback&&highlightCallback(i),n.markCallbackComplete(),n.finish()}).catch(e=>{console.error("[HighlightUpdates] Error in measurement pipeline:",e),n.finish()})}function setTraceUpdatesOnRenderers(e){if(!hook?.rendererInterfaces)return void debugLog("No rendererInterfaces available");let t=0;if(hook.rendererInterfaces.forEach((n,i)=>{if("function"==typeof n.setTraceUpdatesEnabled)try{n.setTraceUpdatesEnabled(e),t++,debugLog(`Renderer ${i}: setTraceUpdatesEnabled(${e})`)}catch(e){debugLog(`Renderer ${i}: error setting trace updates`,e)}else debugLog(`Renderer ${i}: no setTraceUpdatesEnabled method`)}),debugLog(`Set trace updates ${e?"enabled":"disabled"} on ${t} renderer(s)`),hook.reactDevtoolsAgent?.setTraceUpdatesEnabled)try{hook.reactDevtoolsAgent.setTraceUpdatesEnabled(e),debugLog("Also set trace updates on agent")}catch(e){debugLog("Error setting trace updates on agent",e)}}function subscribeToTraceUpdates(){hook&&(traceUpdatesUnsubscribe||(debugLog("Subscribing to traceUpdates event"),"function"==typeof hook.sub?(traceUpdatesUnsubscribe=hook.sub("traceUpdates",handleTraceUpdates),debugLog("Subscribed using hook.sub()")):debugLog("hook.sub not available, traceUpdates may not work"),setTraceUpdatesOnRenderers(!0)))}function unsubscribeFromTraceUpdates(){setTraceUpdatesOnRenderers(!1),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){badgePressCallback&&badgePressCallback(e)}let spotlightCallback=null,currentSpotlightTag=null;function setSpotlightCallback(e){spotlightCallback=e,e&&null!==currentSpotlightTag&&e(currentSpotlightTag)}function setSpotlight(e){currentSpotlightTag=e,spotlightCallback&&spotlightCallback(e)}function getSpotlight(){return currentSpotlightTag}function notifyStateListeners(){stateListeners.forEach(e=>{try{e(globalEnabled)}catch(e){console.error("[HighlightUpdates] Error in state listener:",e)}})}function subscribe(e){return stateListeners.add(e),e(globalEnabled),()=>{stateListeners.delete(e)}}function initialize(){if("undefined"!=typeof __DEV__&&!__DEV__)return debugLog("Only available in development builds"),!1;if(initialized)return!0;if(hook=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null,!hook)return debugLog("React DevTools hook not found"),!1;if(debugLog("Hook found"),debugLog(`Hook has sub: ${"function"==typeof hook.sub}`),debugLog(`Hook has on: ${"function"==typeof hook.on}`),debugLog(`Hook has emit: ${"function"==typeof hook.emit}`),installProfilerInterceptor(),hook.rendererInterfaces&&hook.rendererInterfaces.size>0)return initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`),exposeGlobally(),!0;const e=setInterval(()=>{hook?.rendererInterfaces&&hook.rendererInterfaces.size>0&&(clearInterval(e),initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`),exposeGlobally())},100);return setTimeout(()=>clearInterval(e),1e4),!1}function exposeGlobally(){"undefined"!=typeof window&&(window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,subscribe:subscribe,initialize:initialize,destroy:destroy,isInitialized:()=>initialized,setHighlightCallback:setHighlightCallback})}function enable(){("undefined"==typeof __DEV__||__DEV__)&&(initialized||initialize(),globalEnabled||(debugLog("Enabling highlights"),subscribeToTraceUpdates(),RenderTracker.start(),globalEnabled=!0,notifyStateListeners()))}function disable(){("undefined"==typeof __DEV__||__DEV__)&&globalEnabled&&(debugLog("Disabling highlights"),renderingLock=!1,isProcessing=!1,renderingLockTimeout&&(clearTimeout(renderingLockTimeout),renderingLockTimeout=null),renderedOverlayTags.clear(),devToolsNodeCache.clear(),clearRenderCauseState(),unsubscribeFromTraceUpdates(),RenderTracker.stop(),globalEnabled=!1,notifyStateListeners())}function toggle(){("undefined"==typeof __DEV__||__DEV__)&&(globalEnabled?disable():enable())}function clearRenderCounts(){nodeRenderCounts.clear(),RenderTracker.clear(),debugLog("Cleared render counts")}function isEnabled(){return globalEnabled}function setEnabled(e){e?enable():disable()}function isInitialized(){return initialized}function notifyFreezeListeners(){freezeListeners.forEach(e=>{try{e(isFrozen)}catch(e){console.error("[HighlightUpdates] Error in freeze listener:",e)}})}function subscribeToFreeze(e){return freezeListeners.add(e),e(isFrozen),()=>{freezeListeners.delete(e)}}function freeze(){("undefined"==typeof __DEV__||__DEV__)&&(isFrozen||(isFrozen=!0,debugLog("Freeze mode enabled"),notifyFreezeListeners()))}function unfreeze(){("undefined"==typeof __DEV__||__DEV__)&&isFrozen&&(isFrozen=!1,debugLog("Freeze mode disabled"),highlightCallback&&highlightCallback([]),notifyFreezeListeners())}function toggleFreeze(){isFrozen?unfreeze():freeze()}function getFrozen(){return isFrozen}function destroy(){initialized&&(unsubscribeFromTraceUpdates(),uninstallProfilerInterceptor(),setComparisonCallback(null),isFrozen=!1,freezeListeners.clear(),globalEnabled=!1,hook=null,highlightCallback=null,initialized=!1,"undefined"!=typeof window&&delete window.__HIGHLIGHT_UPDATES_CONTROLLER__,debugLog("Destroyed"))}const HighlightUpdatesController={subscribe:subscribe,enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,initialize:initialize,destroy:destroy,isInitialized:isInitialized,setHighlightCallback:setHighlightCallback,clearRenderCounts:clearRenderCounts,freeze:freeze,unfreeze:unfreeze,toggleFreeze:toggleFreeze,getFrozen:getFrozen,subscribeToFreeze:subscribeToFreeze,setBadgePressCallback:setBadgePressCallback,getBadgePressCallback:getBadgePressCallback,handleBadgePress:handleBadgePress,setSpotlightCallback:setSpotlightCallback,setSpotlight:setSpotlight,getSpotlight:getSpotlight};export default HighlightUpdatesController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{getComponentDisplayName}from"./ViewTypeMapper";import{PerformanceLogger}from"./PerformanceLogger";const MAX_TRACKED_COMPONENTS=200,DEFAULT_BATCH_SIZE=150;class RenderTrackerSingleton{renders=new Map;listeners=new Set;stateListeners=new Set;settingsListeners=new Set;filterListeners=new Set;isTracking=!1;isPaused=!1;settings={batchSize:150,showRenderCount:!0,performanceLogging:!1,trackRenderCauses:!1,enableRenderHistory:!0,maxRenderHistoryPerComponent:20,capturePropsOnRender:!1,captureStateOnRender:!1,debugLogLevel:"off",debugRawFiberLogging:!1};isBatchMode=!1;batchDirty=!1;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),s=Date.now(),i=this.renders.get(t);if(i)i.renderCount=e.count,i.lastRenderTime=s,i.color=e.color,e.measurements&&(i.measurements=e.measurements),e.testID&&!i.testID&&(i.testID=e.testID),e.nativeID&&!i.nativeID&&(i.nativeID=e.nativeID),e.accessibilityLabel&&!i.accessibilityLabel&&(i.accessibilityLabel=e.accessibilityLabel),e.componentName&&!i.componentName&&(i.componentName=e.componentName),e.renderCause&&(i.lastRenderCause=e.renderCause),this.settings.enableRenderHistory&&e.renderCause&&this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState);else{const i={id:t,nativeTag:e.nativeTag,viewType:e.viewType,displayName: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&&e.renderCause&&(i.renderHistory=[],this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState)),this.renders.set(t,i),this.renders.size>200){const e=Array.from(this.renders.values()).sort((e,t)=>e.lastRenderTime-t.lastRenderTime).slice(0,this.renders.size-200);for(const t of e)this.renders.delete(t.id)}}this.isBatchMode?this.batchDirty=!0:this.notifyListeners()}addRenderEvent(e,t,s,i){e.renderHistory||(e.renderHistory=[]);const n={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(n);const r=Math.max(5,Math.min(50,this.settings.maxRenderHistoryPerComponent));e.renderHistory.length>r&&(e.renderHistory=e.renderHistory.slice(-r))}startBatch(){this.isBatchMode=!0,this.batchDirty=!1}endBatch(){this.isBatchMode=!1,this.batchDirty&&(this.batchDirty=!1,this.notifyListeners())}getRenders(){return Array.from(this.renders.values()).map(e=>({...e}))}passesFilters(e){if(this.filters.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,this.filters.includePatterns))return!1;if(this.filters.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,this.filters.excludePatterns))return!1;if(this.filters.includeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(!this.matchesPattern(t,this.filters.includeViewType)&&!this.matchesPattern(s,this.filters.includeViewType))return!1}if(this.filters.includeTestID.size>0&&(!e.testID||!this.matchesPattern(e.testID,this.filters.includeTestID)))return!1;if(this.filters.includeNativeID.size>0&&(!e.nativeID||!this.matchesPattern(e.nativeID,this.filters.includeNativeID)))return!1;if(this.filters.includeComponent.size>0&&(!e.componentName||!this.matchesPattern(e.componentName,this.filters.includeComponent)))return!1;if(this.filters.excludeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(this.matchesPattern(t,this.filters.excludeViewType)||this.matchesPattern(s,this.filters.excludeViewType))return!1}return!(this.filters.excludeTestID.size>0&&e.testID&&this.matchesPattern(e.testID,this.filters.excludeTestID)||this.filters.excludeNativeID.size>0&&e.nativeID&&this.matchesPattern(e.nativeID,this.filters.excludeNativeID)||this.filters.excludeComponent.size>0&&e.componentName&&this.matchesPattern(e.componentName,this.filters.excludeComponent))}matchesAnyPatternForInfo(e,t){for(const s of t){const t=s.value.toLowerCase();switch(s.type){case"any":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t)||e.testID?.toLowerCase().includes(t)||e.nativeID?.toLowerCase().includes(t)||e.componentName?.toLowerCase().includes(t)||e.accessibilityLabel?.toLowerCase().includes(t))return!0;break;case"viewType":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t))return!0;break;case"testID":if(e.testID?.toLowerCase().includes(t))return!0;break;case"nativeID":if(e.nativeID?.toLowerCase().includes(t))return!0;break;case"component":if(e.componentName?.toLowerCase().includes(t))return!0;break;case"accessibilityLabel":if(e.accessibilityLabel?.toLowerCase().includes(t))return!0}}return!1}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||void 0!==this.filters.minRenderCount||void 0!==this.filters.maxRenderCount}getFilteredRenders(e=""){let t=this.getRenders();if(e.trim()){const s=e.toLowerCase();t=t.filter(e=>e.viewType.toLowerCase().includes(s)||e.displayName.toLowerCase().includes(s)||e.testID?.toLowerCase().includes(s)||e.nativeID?.toLowerCase().includes(s)||e.accessibilityLabel?.toLowerCase().includes(s)||e.componentName?.toLowerCase().includes(s)||String(e.nativeTag).includes(s))}return t=t.filter(e=>this.passesFilters(e)),void 0!==this.filters.minRenderCount&&(t=t.filter(e=>e.renderCount>=this.filters.minRenderCount)),void 0!==this.filters.maxRenderCount&&(t=t.filter(e=>e.renderCount<=this.filters.maxRenderCount)),t.sort((e,t)=>t.lastRenderTime-e.lastRenderTime)}matchesPattern(e,t){const s=e.toLowerCase();for(const e of t){const t=e.toLowerCase();if(s.includes(t))return!0}return!1}getRender(e){return this.renders.get(e)}clear(){this.renders.clear(),this.notifyListeners()}resetRenderCount(e){const t=this.renders.get(e);t&&(t.renderCount=0,this.notifyListeners())}start(){this.isTracking=!0,this.isPaused=!1,this.notifyStateListeners()}stop(){this.isTracking=!1,this.isPaused=!1,this.notifyStateListeners()}pause(){this.isPaused=!0,this.notifyStateListeners()}resume(){this.isPaused=!1,this.notifyStateListeners()}togglePause(){this.isPaused=!this.isPaused,this.notifyStateListeners()}getState(){return{isTracking:this.isTracking,isPaused:this.isPaused}}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,t=new Set,s=new Set,i=new Set,n=new Set;for(const r of this.renders.values())r.viewType&&e.add(r.viewType),r.testID&&t.add(r.testID),r.nativeID&&s.add(r.nativeID),r.componentName&&i.add(r.componentName),r.accessibilityLabel&&n.add(r.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(n).sort()}}getStats(){let e=0;for(const t of this.renders.values())e+=t.renderCount;return{totalComponents:this.renders.size,totalRenders:e}}subscribe(e){return this.listeners.add(e),e(this.getRenders()),()=>{this.listeners.delete(e)}}subscribeToState(e){return this.stateListeners.add(e),e(this.getState()),()=>{this.stateListeners.delete(e)}}subscribeToSettings(e){return this.settingsListeners.add(e),e(this.settings),()=>{this.settingsListeners.delete(e)}}subscribeToFilters(e){return this.filterListeners.add(e),e(this.filters),()=>{this.filterListeners.delete(e)}}shouldShowRender(e){const t=this.filters;return!(t.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,t.includePatterns))&&(!(t.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,t.excludePatterns))&&(!((t.includeViewType.size>0||t.includeTestID.size>0||t.includeNativeID.size>0||t.includeComponent.size>0)&&!(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)))&&!(t.excludeViewType.has(e.viewType)||e.testID&&t.excludeTestID.has(e.testID)||e.nativeID&&t.excludeNativeID.has(e.nativeID)||e.componentName&&t.excludeComponent.has(e.componentName))))}getSettings(){return{...this.settings}}setSettings(e){void 0!==e.batchSize&&(e.batchSize=Math.max(10,Math.min(500,e.batchSize))),void 0!==e.maxRenderHistoryPerComponent&&(e.maxRenderHistoryPerComponent=Math.max(5,Math.min(50,e.maxRenderHistoryPerComponent))),e.enableRenderHistory&&!this.settings.trackRenderCauses&&(e.trackRenderCauses=!0),!1===e.trackRenderCauses&&this.settings.enableRenderHistory&&(e.enableRenderHistory=!1),this.settings={...this.settings,...e},void 0!==e.performanceLogging&&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);t&&(t.renderHistory=[],this.notifyListeners())}getRenderHistoryStats(){let e=0,t=0;for(const s of this.renders.values())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(e){console.error("[RenderTracker] Error in listener:",e)}}notifyStateListeners(){const e=this.getState();for(const t of this.stateListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in state listener:",e)}}notifySettingsListeners(){const e=this.getSettings();for(const t of this.settingsListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in settings listener:",e)}}notifyFilterListeners(){const e=this.getFilters();for(const t of this.filterListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in filter listener:",e)}}}export const RenderTracker=new RenderTrackerSingleton;export default RenderTracker;
|
|
1
|
+
"use strict";import{getComponentDisplayName}from"./ViewTypeMapper";import{PerformanceLogger}from"./PerformanceLogger";const MAX_TRACKED_COMPONENTS=200,DEFAULT_BATCH_SIZE=150;class RenderTrackerSingleton{renders=new Map;listeners=new Set;stateListeners=new Set;settingsListeners=new Set;filterListeners=new Set;isTracking=!1;isPaused=!1;settings={batchSize:150,showRenderCount:!0,performanceLogging:!1,trackRenderCauses:!1,enableRenderHistory:!0,maxRenderHistoryPerComponent:20,capturePropsOnRender:!1,captureStateOnRender:!1,debugLogLevel:"off"};isBatchMode=!1;batchDirty=!1;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),s=Date.now(),i=this.renders.get(t);if(i)i.renderCount=e.count,i.lastRenderTime=s,i.color=e.color,e.measurements&&(i.measurements=e.measurements),e.testID&&!i.testID&&(i.testID=e.testID),e.nativeID&&!i.nativeID&&(i.nativeID=e.nativeID),e.accessibilityLabel&&!i.accessibilityLabel&&(i.accessibilityLabel=e.accessibilityLabel),e.componentName&&!i.componentName&&(i.componentName=e.componentName),e.renderCause&&(i.lastRenderCause=e.renderCause),this.settings.enableRenderHistory&&e.renderCause&&this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState);else{const i={id:t,nativeTag:e.nativeTag,viewType:e.viewType,displayName: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&&e.renderCause&&(i.renderHistory=[],this.addRenderEvent(i,e.renderCause,e.capturedProps,e.capturedState)),this.renders.set(t,i),this.renders.size>200){const e=Array.from(this.renders.values()).sort((e,t)=>e.lastRenderTime-t.lastRenderTime).slice(0,this.renders.size-200);for(const t of e)this.renders.delete(t.id)}}this.isBatchMode?this.batchDirty=!0:this.notifyListeners()}addRenderEvent(e,t,s,i){e.renderHistory||(e.renderHistory=[]);const n={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(n);const r=Math.max(5,Math.min(50,this.settings.maxRenderHistoryPerComponent));e.renderHistory.length>r&&(e.renderHistory=e.renderHistory.slice(-r))}startBatch(){this.isBatchMode=!0,this.batchDirty=!1}endBatch(){this.isBatchMode=!1,this.batchDirty&&(this.batchDirty=!1,this.notifyListeners())}getRenders(){return Array.from(this.renders.values()).map(e=>({...e}))}passesFilters(e){if(this.filters.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,this.filters.includePatterns))return!1;if(this.filters.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,this.filters.excludePatterns))return!1;if(this.filters.includeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(!this.matchesPattern(t,this.filters.includeViewType)&&!this.matchesPattern(s,this.filters.includeViewType))return!1}if(this.filters.includeTestID.size>0&&(!e.testID||!this.matchesPattern(e.testID,this.filters.includeTestID)))return!1;if(this.filters.includeNativeID.size>0&&(!e.nativeID||!this.matchesPattern(e.nativeID,this.filters.includeNativeID)))return!1;if(this.filters.includeComponent.size>0&&(!e.componentName||!this.matchesPattern(e.componentName,this.filters.includeComponent)))return!1;if(this.filters.excludeViewType.size>0){const t=e.viewType||"",s=e.displayName||"";if(this.matchesPattern(t,this.filters.excludeViewType)||this.matchesPattern(s,this.filters.excludeViewType))return!1}return!(this.filters.excludeTestID.size>0&&e.testID&&this.matchesPattern(e.testID,this.filters.excludeTestID)||this.filters.excludeNativeID.size>0&&e.nativeID&&this.matchesPattern(e.nativeID,this.filters.excludeNativeID)||this.filters.excludeComponent.size>0&&e.componentName&&this.matchesPattern(e.componentName,this.filters.excludeComponent))}matchesAnyPatternForInfo(e,t){for(const s of t){const t=s.value.toLowerCase();switch(s.type){case"any":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t)||e.testID?.toLowerCase().includes(t)||e.nativeID?.toLowerCase().includes(t)||e.componentName?.toLowerCase().includes(t)||e.accessibilityLabel?.toLowerCase().includes(t))return!0;break;case"viewType":if(e.viewType.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t))return!0;break;case"testID":if(e.testID?.toLowerCase().includes(t))return!0;break;case"nativeID":if(e.nativeID?.toLowerCase().includes(t))return!0;break;case"component":if(e.componentName?.toLowerCase().includes(t))return!0;break;case"accessibilityLabel":if(e.accessibilityLabel?.toLowerCase().includes(t))return!0}}return!1}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||void 0!==this.filters.minRenderCount||void 0!==this.filters.maxRenderCount}getFilteredRenders(e=""){let t=this.getRenders();if(e.trim()){const s=e.toLowerCase();t=t.filter(e=>e.viewType.toLowerCase().includes(s)||e.displayName.toLowerCase().includes(s)||e.testID?.toLowerCase().includes(s)||e.nativeID?.toLowerCase().includes(s)||e.accessibilityLabel?.toLowerCase().includes(s)||e.componentName?.toLowerCase().includes(s)||String(e.nativeTag).includes(s))}return t=t.filter(e=>this.passesFilters(e)),void 0!==this.filters.minRenderCount&&(t=t.filter(e=>e.renderCount>=this.filters.minRenderCount)),void 0!==this.filters.maxRenderCount&&(t=t.filter(e=>e.renderCount<=this.filters.maxRenderCount)),t.sort((e,t)=>t.lastRenderTime-e.lastRenderTime)}matchesPattern(e,t){const s=e.toLowerCase();for(const e of t){const t=e.toLowerCase();if(s.includes(t))return!0}return!1}getRender(e){return this.renders.get(e)}clear(){this.renders.clear(),this.notifyListeners()}resetRenderCount(e){const t=this.renders.get(e);t&&(t.renderCount=0,this.notifyListeners())}start(){this.isTracking=!0,this.isPaused=!1,this.notifyStateListeners()}stop(){this.isTracking=!1,this.isPaused=!1,this.notifyStateListeners()}pause(){this.isPaused=!0,this.notifyStateListeners()}resume(){this.isPaused=!1,this.notifyStateListeners()}togglePause(){this.isPaused=!this.isPaused,this.notifyStateListeners()}getState(){return{isTracking:this.isTracking,isPaused:this.isPaused}}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,t=new Set,s=new Set,i=new Set,n=new Set;for(const r of this.renders.values())r.viewType&&e.add(r.viewType),r.testID&&t.add(r.testID),r.nativeID&&s.add(r.nativeID),r.componentName&&i.add(r.componentName),r.accessibilityLabel&&n.add(r.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(n).sort()}}getStats(){let e=0;for(const t of this.renders.values())e+=t.renderCount;return{totalComponents:this.renders.size,totalRenders:e}}subscribe(e){return this.listeners.add(e),e(this.getRenders()),()=>{this.listeners.delete(e)}}subscribeToState(e){return this.stateListeners.add(e),e(this.getState()),()=>{this.stateListeners.delete(e)}}subscribeToSettings(e){return this.settingsListeners.add(e),e(this.settings),()=>{this.settingsListeners.delete(e)}}subscribeToFilters(e){return this.filterListeners.add(e),e(this.filters),()=>{this.filterListeners.delete(e)}}shouldShowRender(e){const t=this.filters;return!(t.includePatterns.length>0&&!this.matchesAnyPatternForInfo(e,t.includePatterns))&&(!(t.excludePatterns.length>0&&this.matchesAnyPatternForInfo(e,t.excludePatterns))&&(!((t.includeViewType.size>0||t.includeTestID.size>0||t.includeNativeID.size>0||t.includeComponent.size>0)&&!(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)))&&!(t.excludeViewType.has(e.viewType)||e.testID&&t.excludeTestID.has(e.testID)||e.nativeID&&t.excludeNativeID.has(e.nativeID)||e.componentName&&t.excludeComponent.has(e.componentName))))}getSettings(){return{...this.settings}}setSettings(e){void 0!==e.batchSize&&(e.batchSize=Math.max(10,Math.min(500,e.batchSize))),void 0!==e.maxRenderHistoryPerComponent&&(e.maxRenderHistoryPerComponent=Math.max(5,Math.min(50,e.maxRenderHistoryPerComponent))),e.enableRenderHistory&&!this.settings.trackRenderCauses&&(e.trackRenderCauses=!0),!1===e.trackRenderCauses&&this.settings.enableRenderHistory&&(e.enableRenderHistory=!1),this.settings={...this.settings,...e},void 0!==e.performanceLogging&&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);t&&(t.renderHistory=[],this.notifyListeners())}getRenderHistoryStats(){let e=0,t=0;for(const s of this.renders.values())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(e){console.error("[RenderTracker] Error in listener:",e)}}notifyStateListeners(){const e=this.getState();for(const t of this.stateListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in state listener:",e)}}notifySettingsListeners(){const e=this.getSettings();for(const t of this.settingsListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in settings listener:",e)}}notifyFilterListeners(){const e=this.getFilters();for(const t of this.filterListeners)try{t(e)}catch(e){console.error("[RenderTracker] Error in filter listener:",e)}}}export const RenderTracker=new RenderTrackerSingleton;export default RenderTracker;
|
|
@@ -171,11 +171,6 @@ export interface RenderTrackerSettings {
|
|
|
171
171
|
* Default: "off"
|
|
172
172
|
*/
|
|
173
173
|
debugLogLevel: DebugLogLevel;
|
|
174
|
-
/**
|
|
175
|
-
* @deprecated Use debugLogLevel instead. Kept for backward compatibility.
|
|
176
|
-
* When true, equivalent to debugLogLevel: "all"
|
|
177
|
-
*/
|
|
178
|
-
debugRawFiberLogging: boolean;
|
|
179
174
|
}
|
|
180
175
|
declare class RenderTrackerSingleton {
|
|
181
176
|
private renders;
|
package/package.json
CHANGED
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/highlight-updates",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Control React DevTools highlight updates feature from your app",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|
|
8
8
|
"react-native": "lib/module/index.js",
|
|
9
9
|
"source": "src/index.tsx",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"react-native": "./lib/module/index.js",
|
|
13
|
+
"import": {
|
|
14
|
+
"default": "./lib/module/index.js",
|
|
15
|
+
"types": "./lib/typescript/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"default": "./lib/commonjs/index.js",
|
|
19
|
+
"types": "./lib/typescript/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
10
24
|
"files": [
|
|
11
25
|
"lib"
|
|
12
26
|
],
|
|
13
27
|
"sideEffects": false,
|
|
14
28
|
"dependencies": {
|
|
15
|
-
"@buoy-gg/shared-ui": "1.
|
|
16
|
-
"@buoy-gg/floating-tools-core": "1.
|
|
29
|
+
"@buoy-gg/shared-ui": "2.1.2",
|
|
30
|
+
"@buoy-gg/floating-tools-core": "2.1.2"
|
|
17
31
|
},
|
|
18
32
|
"peerDependencies": {
|
|
19
33
|
"@buoy-gg/license": "*",
|
|
20
34
|
"react": "*",
|
|
21
35
|
"react-native": "*",
|
|
22
|
-
"@buoy-gg/core": "1.
|
|
36
|
+
"@buoy-gg/core": "2.1.2"
|
|
23
37
|
},
|
|
24
38
|
"peerDependenciesMeta": {
|
|
25
39
|
"@buoy-gg/core": {
|
|
@@ -30,8 +44,8 @@
|
|
|
30
44
|
"@types/react": "^19.1.0",
|
|
31
45
|
"@types/react-native": "^0.73.0",
|
|
32
46
|
"typescript": "~5.8.3",
|
|
33
|
-
"@buoy-gg/core": "1.
|
|
34
|
-
"@buoy-gg/license": "1.
|
|
47
|
+
"@buoy-gg/core": "2.1.2",
|
|
48
|
+
"@buoy-gg/license": "2.1.2"
|
|
35
49
|
},
|
|
36
50
|
"react-native-builder-bob": {
|
|
37
51
|
"source": "src",
|