@buoy-gg/highlight-updates 7.0.62 → 7.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/lib/commonjs/highlight-updates/components/HighlightUpdatesModal.js +1 -1
- package/lib/commonjs/highlight-updates/utils/CommitProfiler.js +1 -1
- package/lib/commonjs/highlight-updates/utils/HighlightUpdatesController.js +1 -1
- package/lib/commonjs/highlight-updates/utils/PerformanceLogger.js +2 -2
- package/lib/commonjs/highlight-updates/utils/ProfilerInterceptor.js +1 -1
- package/lib/commonjs/highlight-updates/utils/RenderCauseDetector.js +4 -4
- package/lib/commonjs/highlight-updates/utils/RenderTracker.js +1 -1
- package/lib/commonjs/highlight-updates/utils/namedComposite.js +1 -1
- package/lib/commonjs/highlight-updates/utils/screenElements.js +1 -1
- package/lib/commonjs/sync/highlightUpdatesSyncAdapter.js +1 -1
- package/lib/module/highlight-updates/components/HighlightUpdatesModal.js +1 -1
- package/lib/module/highlight-updates/utils/CommitProfiler.js +1 -1
- package/lib/module/highlight-updates/utils/HighlightUpdatesController.js +1 -1
- package/lib/module/highlight-updates/utils/PerformanceLogger.js +2 -2
- package/lib/module/highlight-updates/utils/ProfilerInterceptor.js +1 -1
- package/lib/module/highlight-updates/utils/RenderCauseDetector.js +4 -4
- package/lib/module/highlight-updates/utils/RenderTracker.js +1 -1
- package/lib/module/highlight-updates/utils/namedComposite.js +1 -1
- package/lib/module/highlight-updates/utils/screenElements.js +1 -1
- package/lib/module/sync/highlightUpdatesSyncAdapter.js +1 -1
- package/lib/typescript/highlight-updates/utils/HighlightUpdatesController.d.ts +12 -0
- package/lib/typescript/highlight-updates/utils/RenderTracker.d.ts +3 -0
- package/lib/typescript/highlight-updates/utils/namedComposite.d.ts +1 -0
- package/lib/typescript/highlight-updates/utils/screenElements.d.ts +64 -0
- package/lib/typescript/sync/highlightUpdatesSyncAdapter.d.ts +4 -0
- package/lib/web/index.mjs +28 -28
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.describeScreen=describeScreen;exports.resolveTouchTarget=resolveTouchTarget;exports.tapElement=tapElement;exports.waitFor=waitFor;var _utils=require("@buoy-gg/shared-ui/utils");var _reactNative=require("react-native");var _tapMatch=require("./tapMatch");const HostComponent=5;const OffscreenComponent=22;const INTERNAL_NAMES=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]);function getReactDevToolsHook(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}let commitCount=0;let commitCounterInstalled=false;function ensureCommitCounter(){if(commitCounterInstalled)return;const e=getReactDevToolsHook();if(!e)return;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(...n){commitCount++;return typeof t==="function"?t.apply(e,n):void 0};commitCounterInstalled=true}const TAP_SETTLE_MS=250;function makeChromeCheck(){const e=new Map;return t=>{const n=[];let r=t;let a=0;let s=false;while(r&&a<400){const c=e.get(r);if(c!==void 0){s=c;break}if(getProps(r)?.__buoyDevToolsRoot){s=true;e.set(r,true);break}n.push(r);r=r.return;a++}for(const c of n)e.set(c,s);return s}}function getAllFiberRoots(){const e=getReactDevToolsHook();if(!e)return[];const t=[];try{if(e.renderers&&typeof e.renderers.forEach==="function"){e.renderers.forEach((n,r)=>{try{const a=e.getFiberRoots?.(r);if(a)a.forEach(s=>t.push(s))}catch{}})}if(t.length===0&&e.getFiberRoots){const n=e.getFiberRoots(1);if(n)n.forEach(r=>t.push(r))}}catch{}return t}function isHiddenOffscreen(e){return e.tag===OffscreenComponent&&e.memoizedState!==null}let includeHiddenScreens=false;let prunedHiddenScreens=0;let fullVisibleText=false;function withHiddenScreens(e,t){const n=includeHiddenScreens;includeHiddenScreens=e;try{return t()}finally{includeHiddenScreens=n}}function isNotShowingScreen(e){const t=e.memoizedProps;if(!t)return false;if(t["aria-hidden"]===true&&(t.activityState!==void 0||"shouldFreeze"in t))return true;if(t.isFocused===false&&(t.routeKey!==void 0||"freezeContents"in t))return true;return false}function isInactiveScreen(e){const t=e.memoizedProps?.activityState;if(t===0||t===1)return true;if(e.memoizedProps?.isPageFocused===false)return true;if(!includeHiddenScreens&&isNotShowingScreen(e)){prunedHiddenScreens++;return true}return false}function traverseFiberTree(e,t,n=0,r=new Set){if(!e||r.has(e)||n>500)return;r.add(e);if(isHiddenOffscreen(e)||isInactiveScreen(e)){if(e.sibling)traverseFiberTree(e.sibling,t,n,r);return}t(e);if(e.child)traverseFiberTree(e.child,t,n+1,r);if(e.sibling)traverseFiberTree(e.sibling,t,n,r)}function getPublicInstance(e){const t=(0,_utils.getDOMPublicInstance)(e);if(t)return t;if(!e)return null;const n=e;if(n.canonical?.publicInstance)return n.canonical.publicInstance;if(n.canonical&&typeof n.canonical.measure==="function"){return n.canonical}if(typeof n.measure==="function"||typeof n.measureInWindow==="function"){return n}return null}function getNativeTag(e){const t=(0,_utils.getDOMNodeHandle)(e);if(t!==null)return t;if(e==null)return null;const n=e;if(typeof n.__nativeTag==="number")return n.__nativeTag;if(typeof n._nativeTag==="number")return n._nativeTag;if(typeof n.nativeTag==="number")return n.nativeTag;if(n.canonical){if(typeof n.canonical.__nativeTag==="number")return n.canonical.__nativeTag;if(typeof n.canonical._nativeTag==="number")return n.canonical._nativeTag;if(typeof n.canonical.nativeTag==="number")return n.canonical.nativeTag}return null}function findHostInstance(e){const t=getPublicInstance(e.stateNode);if(t){return{instance:t,nativeTag:getNativeTag(e.stateNode),stateNode:e.stateNode}}const n=[];if(e.child)n.push(e.child);let r=0;while(n.length>0&&r<4e3){r++;const a=n.pop();if(!a)continue;const s=getPublicInstance(a.stateNode);if(s)return{instance:s,nativeTag:getNativeTag(a.stateNode),stateNode:a.stateNode};if(a.child)n.push(a.child);if(a.sibling)n.push(a.sibling)}return null}function findScrollAncestor(e){let t=e;let n=0;while(t&&n++<200){const r=t.stateNode;if(r&&typeof r.scrollTo==="function"){const a=typeof r.getNativeScrollRef==="function"&&r.getNativeScrollRef()||null;const s=typeof r.getInnerViewNode==="function"&&r.getInnerViewNode()||typeof r.getScrollableNode==="function"&&r.getScrollableNode()||r;return{instance:r,nativeRef:a,innerNode:s}}t=t.return}return null}async function scrollIntoView(e,t,n,r){try{if((0,_utils.isDOMElement)(n)){n.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});await new Promise(f=>setTimeout(f,16));return true}const a=findScrollAncestor(e);if(!a)return false;const s=t;let c=null;const o=f=>new Promise(i=>{let u=false;const d=g=>{if(u)return;u=true;i(g)};const m=setTimeout(()=>d(null),600);try{f(g=>{clearTimeout(m);d(g)})}catch{clearTimeout(m);d(null)}});if(a.nativeRef&&typeof s.measureLayout==="function"){c=await o(f=>s.measureLayout(a.nativeRef,(i,u)=>f(u),()=>f(null)))}if(c==null){const f=(0,_reactNative.findNodeHandle)(t);const i=typeof a.innerNode==="number"?a.innerNode:(0,_reactNative.findNodeHandle)(a.innerNode);if(f!=null&&i!=null){c=await o(u=>_reactNative.UIManager.measureLayout(f,i,()=>u(null),(d,m)=>u(m)))}}if(c==null)return false;a.instance.scrollTo({y:Math.max(0,c-r),animated:false});await new Promise(f=>setTimeout(f,120));return true}catch{return false}}function getComponentName(e){const t=e?.type;if(!t)return null;if(typeof t==="string")return t;return t.displayName||t.name||null}function getOwningComponentName(e){let t=e?._debugOwner||e?.return;let n=0;while(t&&n<30){n++;const r=getComponentName(t);if(r&&!INTERNAL_NAMES.has(r)&&typeof t.type!=="string"){return r}t=t.return}return null}function getProps(e){return(0,_utils.getDOMControlProps)(e?.stateNode,e?.memoizedProps??e?.pendingProps??null)}function flattenText(e,t=0){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e)&&t<4){const n=[];for(const r of e){const a=flattenText(r,t+1);if(a)n.push(a)}return n.length>0?n.join(""):void 0}return void 0}function normalizeVisibleText(e){return e.replace(/\s+/g," ").trim()}function getVisibleText(e){if(!e)return void 0;const t=n=>{const r=flattenText(n);if(r===void 0)return void 0;const a=normalizeVisibleText(r);return a?fullVisibleText?a:a.slice(0,80):void 0};return t(e.children)??t(e.title)??t(e.label)??t(e.placeholder)??void 0}function collectDescendantText(e,t){const n=[];const r=(s,c)=>{if(!s||c>t||n.length>=4)return;if(s!==e){const f=getProps(s);if(f&&(typeof f.onPress==="function"||typeof f.onLongPress==="function"))return}const o=getVisibleText(getProps(s));if(o&&!n.includes(o))n.push(o);if(s.child)r(s.child,c+1);if(s!==e&&s.sibling)r(s.sibling,c)};if(e.child)r(e.child,1);const a=n.join(" ").trim();return a?a.slice(0,80):void 0}function findPressHandler(e){let t=e;let n=0;let r=null;let a=null;while(t&&n<25&&!(r&&a)){const s=getProps(t);if(s){if(!r&&typeof s.onPress==="function")r=s.onPress;if(!a&&typeof s.onLongPress==="function")a=s.onLongPress}t=t.return;n++}if(r)return{handler:r,kind:"onPress",longPress:a??void 0};return a?{handler:a,kind:"onLongPress"}:null}function measureInstance(e){return new Promise(t=>{let n=false;const r=a=>{if(n)return;n=true;t(a)};setTimeout(()=>r(null),1e3);try{if(typeof e.measureInWindow==="function"){e.measureInWindow((a,s,c,o)=>{if(c>0&&o>0)r({x:a,y:s,width:c,height:o});else r(null)})}else if(typeof e.measure==="function"){e.measure((a,s,c,o,f,i)=>{if(c>0&&o>0&&f!=null&&i!=null){r({x:f,y:i,width:c,height:o})}else{r(null)}})}else{r(null)}}catch{r(null)}})}const SPINNER_HOSTS=new Set(["RCTActivityIndicatorView","AndroidProgressBar"]);function collectCandidates(){const e=getAllFiberRoots();if(e.length===0)return[];const t=[];const n=new Map;const r=new Map;const a=makeChromeCheck();for(const s of e){traverseFiberTree(s.current,c=>{const o=getProps(c);if(!o)return;const f=typeof o.onPress==="function"||typeof o.onLongPress==="function";const i=typeof o.onValueChange==="function";const u=typeof o.onChangeText==="function";const d=o.testID||void 0;const m=o.accessibilityLabel||void 0;const g=o.accessibilityRole||o.role||void 0;let y=getVisibleText(o);const x=g==="button"||g==="link"||g==="menuitem"||g==="tab"||g==="switch"||g==="checkbox";const w=typeof c.type==="string"&&SPINNER_HOSTS.has(c.type)&&o.animating!==false;if(!f&&!i&&!u&&!d&&!m&&!y&&!x&&!w){return}let C=null;let P=null;let I=null;if(i){const D=o.value;const _=typeof D==="number"||typeof o.minimumValue==="number";P={handler:o.onValueChange,kind:_?"slider":"toggle",current:D,min:typeof o.minimumValue==="number"?o.minimumValue:void 0,max:typeof o.maximumValue==="number"?o.maximumValue:void 0}}else if(u){I={handler:o.onChangeText,current:typeof o.value==="string"?o.value:void 0}}else{C=findPressHandler(c)}const l=getComponentName(c);let h=l??"Unknown";if(!l||INTERNAL_NAMES.has(l)||typeof c.type==="string"){h=getOwningComponentName(c)??l??"Unknown"}const v=findHostInstance(c);if(!v&&!d)return;if(!y&&!m&&f){y=collectDescendantText(c,6)}const T=v?.instance??null;const b=v?.nativeTag??null;const p=(T?n.get(T):void 0)??(b!=null?r.get(b):void 0);if(p){if(!p.press&&C)p.press=C;else if(p.press&&C?.longPress&&!p.press.longPress){p.press.longPress=C.longPress}if(!p.valueControl&&P)p.valueControl=P;if(!p.textControl&&I)p.textControl=I;if(!p.testID&&d)p.testID=d;if(!p.label&&m)p.label=m;if(!p.text&&y)p.text=y;if(T&&!n.has(T))n.set(T,p);if(b!=null&&!r.has(b))r.set(b,p);return}const S={nativeTag:b,name:h,role:g??(w?"progressbar":void 0),testID:d,label:m,text:y,instance:T,stateNode:v?.stateNode??null,fiber:c,press:C,valueControl:P,textControl:I,rect:null,buoy:a(c)};t.push(S);if(T)n.set(T,S);if(b!=null)r.set(b,S)})}return t}function explicitlyTargets(e,t){if(t.nativeTag!=null)return e.nativeTag===t.nativeTag;if(t.testID&&e.testID)return e.testID.toLowerCase()===t.testID.toLowerCase();return false}function appCandidates(e){const t=collectCandidates();if(e.includeBuoy)return t;return t.filter(n=>!n.buoy||explicitlyTargets(n,e))}async function measureCandidates(e){await Promise.all(e.map(async t=>{if(t.instance)t.rect=await measureInstance(t.instance)}))}const LIST_WRAPPERS=/^(FlatList|SectionList|VirtualizedSectionList|VirtualizedList|Animated\(.*\)|AnimatedComponent.*)$/;async function collectLists(e,t){const n=[];const r=makeChromeCheck();for(const s of getAllFiberRoots()){traverseFiberTree(s.current,c=>{if(getComponentName(c)!=="VirtualizedList")return;const o=c.memoizedProps;if(!o||typeof o.getItemCount!=="function")return;if(!e&&r(c))return;let f;try{f=Number(o.getItemCount(o.data))}catch{return}if(!Number.isFinite(f)||f<=0)return;const i=[];const u=(g,y)=>{for(let x=g?.child;x;x=x.sibling){const w=getComponentName(x);if(w==="VirtualizedList")continue;if(w==="CellRenderer"){i.push(x);continue}if(y<40)u(x,y+1)}};u(c,0);let d=c;let m=getOwningComponentName(d);for(let g=0;g<6&&m&&LIST_WRAPPERS.test(m);g++){d=d._debugOwner||d.return;m=getOwningComponentName(d)}n.push({owner:m,items:f,cells:i})})}const a=[];for(const s of n){const c=await Promise.all(s.cells.map(async f=>{const i=findHostInstance(f);return i?measureInstance(i.instance):null}));const o=c.filter(t).length;if(o>0&&s.items>o)a.push({owner:s.owner,items:s.items,listed:o})}return a}async function describeScreen(e={}){const t=includeHiddenScreens;const n=fullVisibleText;includeHiddenScreens=!!e.includeHidden;fullVisibleText=!!e.fullText;try{return await describeScreenInner(e)}finally{includeHiddenScreens=t;fullVisibleText=n}}async function describeScreenInner(e){prunedHiddenScreens=0;const t=collectCandidates();const n=prunedHiddenScreens;const r=e.includeBuoy?t:t.filter(u=>!u.buoy);const a=t.length-r.length;await measureCandidates(r);const s=_reactNative.Dimensions.get("window");const c=Math.round(s.width)||1;const o=Math.round(s.height)||1;const f=[];for(const u of r){const d=u.rect;if(!d&&!u.testID)continue;let m;let g;if(d){const w=d.x+d.width/2;const C=d.y+d.height/2;if(C<-o*.1||C>o*1.1||w<-c*.1||w>c*1.1){continue}m={x:round2(w/c),y:round2(C/o)};g={x:round2(d.x/c),y:round2(d.y/o),width:round2(d.width/c),height:round2(d.height/o)}}const y=u.valueControl?u.valueControl.kind:u.textControl?"text":void 0;const x=u.valueControl?u.valueControl.current:u.textControl?.current;f.push({nativeTag:u.nativeTag,name:u.name,role:u.role,testID:u.testID,label:u.label,text:u.text,interactive:!!(u.press||u.valueControl||u.textControl),longPressable:u.press&&(u.press.kind==="onLongPress"||u.press.longPress)?true:void 0,control:y,value:x,tap:m,frame:g})}f.sort((u,d)=>{const m=u.tap?.y??2;const g=d.tap?.y??2;if(Math.abs(m-g)>.02)return m-g;return(u.tap?.x??2)-(d.tap?.x??2)});const i=await collectLists(!!e.includeBuoy,u=>{if(!u)return false;const d=u.x+u.width/2;return u.y<=o*1.1&&u.y+u.height>=-o*.1&&d>=-c*.1&&d<=c*1.1});return{screen:{width:c,height:o},count:f.length,elements:f,...a>0?{hiddenBuoy:a}:{},...n>0?{hiddenScreens:n}:{},...i.length?{lists:i}:{}}}function round2(e){return Math.round(e*100)/100}function fieldsOf(e){return{nativeTag:e.nativeTag,testID:e.testID,label:e.label,text:e.text,name:e.name}}function matchScore(e,t){return(0,_tapMatch.scoreTapMatch)(fieldsOf(e),t)}function tapPoint(e,t,n){if(!e||!t||!n)return void 0;return{x:(e.x+e.width/2)/t,y:(e.y+e.height/2)/n}}function makeSyntheticPressEvent(e){const t=e?e.x+e.width/2:0;const n=e?e.y+e.height/2:0;const r={locationX:e?e.width/2:0,locationY:e?e.height/2:0,pageX:t,pageY:n,timestamp:0,target:null,identifier:1,touches:[],changedTouches:[]};return{nativeEvent:r,persist:()=>{},preventDefault:()=>{},stopPropagation:()=>{},isDefaultPrevented:()=>false,isPropagationStopped:()=>false,target:null,currentTarget:null,type:"press",timeStamp:0}}async function tapElement(e){const t=withHiddenScreens(!!e.includeHidden,()=>appCandidates(e));if(t.length===0){return{tapped:false,reason:"No React fiber roots / elements found on screen."}}const n=t.map(l=>({c:l,score:matchScore(l,e)})).filter(l=>l.score>0).sort((l,h)=>h.score-l.score);const r=l=>!!(l.press||l.valueControl||l.textControl);if(n.length===0&&!e.includeHidden){const l=withHiddenScreens(true,()=>appCandidates(e)).map(h=>({c:h,score:matchScore(h,e)})).filter(h=>h.score>0);if(l.length>0){return{tapped:false,reason:"That element is only on a screen that isn't showing (another tab, or a screen under the current one). Navigate to it first, or pass includeHidden:true if you really mean the hidden one."}}}if(n.length===0){return{tapped:false,reason:"No element matched. Call describe_screen to see available elements (match by testID, text, or name).",candidates:t.filter(r).slice(0,12).map(l=>({nativeTag:l.nativeTag,name:l.name,testID:l.testID,text:l.text}))}}const a=_reactNative.Dimensions.get("window");const s=a.width||1;const c=a.height||1;const o=n.slice(0,15);await Promise.all(o.map(async l=>{if(l.c.instance&&!l.c.rect)l.c.rect=await measureInstance(l.c.instance)}));for(const l of o){l.score=(0,_tapMatch.scoreTapMatch)({...fieldsOf(l.c),tap:tapPoint(l.c.rect,s,c)},e)}o.sort((l,h)=>h.score-l.score);const f=o.find(l=>r(l.c))??n.find(l=>r(l.c))??o[0];const i=f.c;const u=(l,h)=>l.press&&l.press.handler===h.press?.handler||l.valueControl&&l.valueControl.handler===h.valueControl?.handler||l.textControl&&l.textControl.handler===h.textControl?.handler;const d=o.filter(l=>l!==f&&r(l.c)&&l.score===f.score).filter(l=>!u(l.c,i)).filter((l,h,v)=>v.findIndex(T=>u(T.c,l.c))===h).slice(0,3).map(l=>({nativeTag:l.c.nativeTag,name:l.c.name,testID:l.c.testID,text:l.c.text,tap:tapPoint(l.c.rect,s,c)}));const m=e.nativeTag==null&&!(e.testID&&!e.query);if(m&&d.length>0){const l=[i,...d.map(h=>o.find(v=>v.c.nativeTag===h.nativeTag)?.c).filter(Boolean)];return{tapped:false,reason:`"${e.query}" matches ${l.length} different controls equally well, so nothing was tapped. Tap one by its nativeTag.`,candidates:l.map(h=>({nativeTag:h.nativeTag,name:h.name,testID:h.testID,text:h.text}))}}const g=o[0];if(m&&g&&g!==f&&!r(g.c)&&g.score>=90&&f.score<g.score-40){return{tapped:false,reason:`The best match for "${e.query}" is "${g.c.text??g.c.label??g.c.name}", which has no JS press handler (it may be native, like a tab bar button). The closest pressable match, "${i.text??i.label??i.name}", is a much weaker match, so nothing was tapped. Use navigate, or tap a specific element by nativeTag.`,candidates:[{nativeTag:i.nativeTag,name:i.name,testID:i.testID,text:i.text}]}}if(!r(i)){return{tapped:false,reason:`Matched "${i.name}"${i.text?` ("${i.text}")`:""} but it has no onPress / onValueChange / onChangeText handler (e.g. a react-native-gesture-handler GestureDetector). This element can't be driven in JS.`,matched:{nativeTag:i.nativeTag,name:i.name,testID:i.testID,label:i.label,text:i.text,via:"onPress"}}}if(i.instance&&!i.rect)i.rect=await measureInstance(i.instance);let y=false;const x=i.rect==null||!(0,_tapMatch.isRectCenterOnScreen)(i.rect,s,c);if(x&&e.scrollIntoView!==false&&i.instance){y=await scrollIntoView(i.fiber,i.instance,i.stateNode,80);if(y)i.rect=await measureInstance(i.instance)}const w={nativeTag:i.nativeTag,name:i.name,testID:i.testID,label:i.label,text:i.text};ensureCommitCounter();const C=commitCount;const P=Date.now();const I=async l=>{await new Promise(h=>setTimeout(h,TAP_SETTLE_MS));return{tapped:true,scrolled:y,matched:l,effect:{commits:commitCount-C,observedMs:Date.now()-P},...d.length?{alsoMatched:d}:{}}};try{if(i.press){if(e.longPress){const h=i.press.kind==="onLongPress"?i.press.handler:i.press.longPress;if(!h){return{tapped:false,scrolled:y,reason:`Matched "${i.name}"${i.text?` ("${i.text}")`:""} but it has no onLongPress handler \u2014 call tap_element without longPress to tap it normally.`,matched:{...w,via:"onPress"}}}h(makeSyntheticPressEvent(i.rect));return await I({...w,via:"onLongPress"})}i.press.handler(makeSyntheticPressEvent(i.rect));return await I({...w,via:i.press.kind})}if(i.valueControl){const h=i.valueControl;let v;if(h.kind==="toggle"){v=typeof e.value==="boolean"?e.value:!h.current}else{const T=h.min??0;const b=h.max??1;if(typeof e.value==="number"){v=Math.min(b,Math.max(T,e.value))}else{v=h.current===b?T:b}}h.handler(v);return await I({...w,via:"onValueChange",value:v})}const l=e.text??(typeof e.value==="string"?e.value:"");i.textControl.handler(l);return await I({...w,via:"onChangeText",value:l})}catch(l){return{tapped:false,scrolled:y,reason:`handler threw: ${l instanceof Error?l.message:String(l)}`,matched:{...w,via:i.press?i.press.kind:i.valueControl?"onValueChange":"onChangeText"}}}}const WAIT_DEFAULT_MS=5e3;const WAIT_MAX_MS=3e4;const WAIT_MIN_POLL_MS=50;const WAIT_DEFAULT_POLL_MS=150;async function waitFor(e){const t=e.nativeTag!=null||!!String(e.testID??"").trim()||!!String(e.query??"").trim();if(!t){return{ok:false,waitedMs:0,polls:0,reason:"Nothing to wait for \u2014 pass nativeTag, testID or query."}}const n=Math.min(Math.max(e.timeoutMs??WAIT_DEFAULT_MS,0),WAIT_MAX_MS);const r=Math.max(e.pollMs??WAIT_DEFAULT_POLL_MS,WAIT_MIN_POLL_MS);const a=e.gone===true;const s=Date.now();let c=0;for(;;){c+=1;const{hit:o,closest:f}=await findOnScreen(e);if(a?!o:!!o){return{ok:true,waitedMs:Date.now()-s,polls:c,matched:o??void 0}}if(Date.now()-s>=n){const i=f?.length?f:void 0;const u=a?`Still on screen after ${n}ms.`:i?`Not on screen after ${n}ms \u2014 ${i.length===1?"one element":`${i.length} elements`} matched but ${i.some(d=>d.onScreen)?"not well enough":"none is visible"}. See \`closest\`; do not retry with different words, call describeScreen.`:`Not on screen after ${n}ms, and nothing matched those words at all. Call describeScreen to see what is there.`;return{ok:false,waitedMs:Date.now()-s,polls:c,reason:u,matched:o??void 0,closest:i}}await new Promise(i=>setTimeout(i,r))}}async function findOnScreen(e){const t=appCandidates(e).map(o=>({c:o,score:matchScore(o,e)})).filter(o=>o.score>0).sort((o,f)=>f.score-o.score).slice(0,8);if(t.length===0)return{hit:null,closest:void 0};await measureCandidates(t.map(o=>o.c));const n=_reactNative.Dimensions.get("window");const r=Math.round(n.width)||1;const a=Math.round(n.height)||1;let s=null;for(const{c:o}of t){if(!(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,a))continue;s={nativeTag:o.nativeTag,name:o.name,testID:o.testID,label:o.label,text:o.text,interactive:!!(o.press||o.valueControl||o.textControl)};break}const c=t.slice(0,3).map(({c:o})=>({name:o.name,testID:o.testID,text:o.text,onScreen:(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,a)}));return{hit:s,closest:c}}function isBuoyChrome(e){let t=e;let n=0;while(t&&n<400){if(getProps(t)?.__buoyDevToolsRoot)return true;t=t.return;n++}return false}function preferHandlerOwner(e,t){const n=getProps(e.fiber);if(typeof n?.onPress==="function"||typeof n?.onValueChange==="function"||typeof n?.onChangeText==="function"){return e}let r=null;let a=e.fiber?.return;let s=0;while(a&&s<25){if(typeof getProps(a)?.onPress==="function"){r=a;break}a=a.return;s++}if(!r)return e;let c=r;for(let o=0;o<6&&c;o++){const f=t.get(c);if(f)return f;c=c.return}return e}function resolveTouchTarget(e){const t=collectCandidates();if(t.length===0)return null;const n=new Map;for(const o of t)n.set(o.fiber,o);const r=t.find(o=>o.nativeTag===e);let a=null;if(!r){for(const o of getAllFiberRoots()){traverseFiberTree(o.current,f=>{if(a)return;if(f.stateNode&&getNativeTag(f.stateNode)===e){a=f}});if(a)break}}let s=r??null;if(!s&&a){let o=a;let f=0;let i=null;while(o&&f<25){const u=n.get(o);if(u){if(u.press||u.valueControl||u.textControl){s=u;break}if(!i)i=u}o=o.return;f++}if(!s)s=i}if(!s)return null;s=preferHandlerOwner(s,n);if(!s.press&&!s.valueControl&&!s.textControl)return null;if(isBuoyChrome(s.fiber))return null;const c=s.valueControl?s.valueControl.kind:s.textControl?"text":"press";return{nativeTag:s.nativeTag,name:s.name,role:s.role,testID:s.testID,label:s.label,text:s.text,control:c,value:s.valueControl?s.valueControl.current:s.textControl?s.textControl.current:void 0}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.describeScreen=describeScreen;exports.hitTest=hitTest;exports.readMaps=readMaps;exports.resolveTouchTarget=resolveTouchTarget;exports.tapElement=tapElement;exports.waitFor=waitFor;var _utils=require("@buoy-gg/shared-ui/utils");var _reactNative=require("react-native");var _tapMatch=require("./tapMatch");const HostComponent=5;const OffscreenComponent=22;const INTERNAL_NAMES=new Set(["View","RCTView","ScrollView","RCTScrollView","RCTScrollContentView","SafeAreaView","RCTSafeAreaView","AndroidHorizontalScrollContentView","KeyboardAvoidingView","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","AnimatedComponent","Wrapper"]);function getReactDevToolsHook(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}let commitCount=0;let commitCounterInstalled=false;function ensureCommitCounter(){if(commitCounterInstalled)return;const e=getReactDevToolsHook();if(!e)return;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(...n){commitCount++;return typeof t==="function"?t.apply(e,n):void 0};commitCounterInstalled=true}const TAP_SETTLE_MS=250;function makeChromeCheck(){const e=new Map;return t=>{const n=[];let r=t;let s=0;let i=false;while(r&&s<400){const l=e.get(r);if(l!==void 0){i=l;break}if(getProps(r)?.__buoyDevToolsRoot){i=true;e.set(r,true);break}n.push(r);r=r.return;s++}for(const l of n)e.set(l,i);return i}}function getAllFiberRoots(){const e=getReactDevToolsHook();if(!e)return[];const t=[];try{if(e.renderers&&typeof e.renderers.forEach==="function"){e.renderers.forEach((n,r)=>{try{const s=e.getFiberRoots?.(r);if(s)s.forEach(i=>t.push(i))}catch{}})}if(t.length===0&&e.getFiberRoots){const n=e.getFiberRoots(1);if(n)n.forEach(r=>t.push(r))}}catch{}return t}function isHiddenOffscreen(e){return e.tag===OffscreenComponent&&e.memoizedState!==null}let includeHiddenScreens=false;let prunedHiddenScreens=0;let fullVisibleText=false;function withHiddenScreens(e,t){const n=includeHiddenScreens;includeHiddenScreens=e;try{return t()}finally{includeHiddenScreens=n}}function isNotShowingScreen(e){const t=e.memoizedProps;if(!t)return false;if(t["aria-hidden"]===true&&(t.activityState!==void 0||"shouldFreeze"in t))return true;if(t.isFocused===false&&(t.routeKey!==void 0||"freezeContents"in t))return true;return false}function isInactiveScreen(e){const t=e.memoizedProps?.activityState;if(t===0||t===1)return true;if(e.memoizedProps?.isPageFocused===false)return true;if(!includeHiddenScreens&&isNotShowingScreen(e)){prunedHiddenScreens++;return true}return false}function traverseFiberTree(e,t,n=0,r=new Set){if(!e||r.has(e)||n>500)return;r.add(e);if(isHiddenOffscreen(e)||isInactiveScreen(e)){if(e.sibling)traverseFiberTree(e.sibling,t,n,r);return}t(e);if(e.child)traverseFiberTree(e.child,t,n+1,r);if(e.sibling)traverseFiberTree(e.sibling,t,n,r)}function getPublicInstance(e){const t=(0,_utils.getDOMPublicInstance)(e);if(t)return t;if(!e)return null;const n=e;if(n.canonical?.publicInstance)return n.canonical.publicInstance;if(n.canonical&&typeof n.canonical.measure==="function"){return n.canonical}if(typeof n.measure==="function"||typeof n.measureInWindow==="function"){return n}return null}function getNativeTag(e){const t=(0,_utils.getDOMNodeHandle)(e);if(t!==null)return t;if(e==null)return null;const n=e;if(typeof n.__nativeTag==="number")return n.__nativeTag;if(typeof n._nativeTag==="number")return n._nativeTag;if(typeof n.nativeTag==="number")return n.nativeTag;if(n.canonical){if(typeof n.canonical.__nativeTag==="number")return n.canonical.__nativeTag;if(typeof n.canonical._nativeTag==="number")return n.canonical._nativeTag;if(typeof n.canonical.nativeTag==="number")return n.canonical.nativeTag}return null}function findHostInstance(e){const t=getPublicInstance(e.stateNode);if(t){return{instance:t,nativeTag:getNativeTag(e.stateNode),stateNode:e.stateNode}}const n=[];if(e.child)n.push(e.child);let r=0;while(n.length>0&&r<4e3){r++;const s=n.pop();if(!s)continue;const i=getPublicInstance(s.stateNode);if(i)return{instance:i,nativeTag:getNativeTag(s.stateNode),stateNode:s.stateNode};if(s.child)n.push(s.child);if(s.sibling)n.push(s.sibling)}return null}function findScrollAncestor(e){let t=e;let n=0;while(t&&n++<200){const r=t.stateNode;if(r&&typeof r.scrollTo==="function"){const s=typeof r.getNativeScrollRef==="function"&&r.getNativeScrollRef()||null;const i=typeof r.getInnerViewNode==="function"&&r.getInnerViewNode()||typeof r.getScrollableNode==="function"&&r.getScrollableNode()||r;return{instance:r,nativeRef:s,innerNode:i}}t=t.return}return null}async function scrollIntoView(e,t,n,r){try{if((0,_utils.isDOMElement)(n)){n.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});await new Promise(c=>setTimeout(c,16));return true}const s=findScrollAncestor(e);if(!s)return false;const i=t;let l=null;const o=c=>new Promise(a=>{let f=false;const d=m=>{if(f)return;f=true;a(m)};const g=setTimeout(()=>d(null),600);try{c(m=>{clearTimeout(g);d(m)})}catch{clearTimeout(g);d(null)}});if(s.nativeRef&&typeof i.measureLayout==="function"){l=await o(c=>i.measureLayout(s.nativeRef,(a,f)=>c(f),()=>c(null)))}if(l==null){const c=(0,_reactNative.findNodeHandle)(t);const a=typeof s.innerNode==="number"?s.innerNode:(0,_reactNative.findNodeHandle)(s.innerNode);if(c!=null&&a!=null){l=await o(f=>_reactNative.UIManager.measureLayout(c,a,()=>f(null),(d,g)=>f(g)))}}if(l==null)return false;s.instance.scrollTo({y:Math.max(0,l-r),animated:false});await new Promise(c=>setTimeout(c,120));return true}catch{return false}}function getComponentName(e){const t=e?.type;if(!t)return null;if(typeof t==="string")return t;return t.displayName||t.name||null}function getOwningComponentName(e){let t=e?._debugOwner||e?.return;let n=0;while(t&&n<30){n++;const r=getComponentName(t);if(r&&!INTERNAL_NAMES.has(r)&&typeof t.type!=="string"){return r}t=t.return}return null}function getProps(e){return(0,_utils.getDOMControlProps)(e?.stateNode,e?.memoizedProps??e?.pendingProps??null)}function flattenText(e,t=0){if(typeof e==="string")return e;if(typeof e==="number"&&Number.isFinite(e))return String(e);if(Array.isArray(e)&&t<4){const n=[];for(const r of e){const s=flattenText(r,t+1);if(s)n.push(s)}return n.length>0?n.join(""):void 0}return void 0}function normalizeVisibleText(e){return e.replace(/\s+/g," ").trim()}function getVisibleText(e){if(!e)return void 0;const t=n=>{const r=flattenText(n);if(r===void 0)return void 0;const s=normalizeVisibleText(r);return s?fullVisibleText?s:s.slice(0,80):void 0};return t(e.children)??t(e.title)??t(e.label)??t(e.placeholder)??void 0}function collectDescendantText(e,t){const n=[];const r=(i,l)=>{if(!i||l>t||n.length>=4)return;if(i!==e){const c=getProps(i);if(c&&(typeof c.onPress==="function"||typeof c.onLongPress==="function"))return}const o=getVisibleText(getProps(i));if(o&&!n.includes(o))n.push(o);if(i.child)r(i.child,l+1);if(i!==e&&i.sibling)r(i.sibling,l)};if(e.child)r(e.child,1);const s=n.join(" ").trim();return s?s.slice(0,80):void 0}function findPressHandler(e){let t=e;let n=0;let r=null;let s=null;while(t&&n<25&&!(r&&s)){const i=getProps(t);if(i){if(!r&&typeof i.onPress==="function")r=i.onPress;if(!s&&typeof i.onLongPress==="function")s=i.onLongPress}t=t.return;n++}if(r)return{handler:r,kind:"onPress",longPress:s??void 0};return s?{handler:s,kind:"onLongPress"}:null}function measureInstance(e){return new Promise(t=>{let n=false;const r=s=>{if(n)return;n=true;t(s)};setTimeout(()=>r(null),1e3);try{if(typeof e.measureInWindow==="function"){e.measureInWindow((s,i,l,o)=>{if(l>0&&o>0)r({x:s,y:i,width:l,height:o});else r(null)})}else if(typeof e.measure==="function"){e.measure((s,i,l,o,c,a)=>{if(l>0&&o>0&&c!=null&&a!=null){r({x:c,y:a,width:l,height:o})}else{r(null)}})}else{r(null)}}catch{r(null)}})}const SPINNER_HOSTS=new Set(["RCTActivityIndicatorView","AndroidProgressBar"]);function collectCandidates(){const e=getAllFiberRoots();if(e.length===0)return[];const t=[];const n=new Map;const r=new Map;const s=makeChromeCheck();for(const i of e){traverseFiberTree(i.current,l=>{const o=getProps(l);if(!o)return;const c=typeof o.onPress==="function"||typeof o.onLongPress==="function";const a=typeof o.onValueChange==="function";const f=typeof o.onChangeText==="function";const d=o.testID||void 0;const g=o.accessibilityLabel||void 0;const m=o.accessibilityRole||o.role||void 0;let p=getVisibleText(o);const v=m==="button"||m==="link"||m==="menuitem"||m==="tab"||m==="switch"||m==="checkbox";const y=typeof l.type==="string"&&SPINNER_HOSTS.has(l.type)&&o.animating!==false;if(!c&&!a&&!f&&!d&&!g&&!p&&!v&&!y){return}let x=null;let I=null;let P=null;if(a){const N=o.value;const D=typeof N==="number"||typeof o.minimumValue==="number";I={handler:o.onValueChange,kind:D?"slider":"toggle",current:N,min:typeof o.minimumValue==="number"?o.minimumValue:void 0,max:typeof o.maximumValue==="number"?o.maximumValue:void 0}}else if(f){P={handler:o.onChangeText,current:typeof o.value==="string"?o.value:void 0}}else{x=findPressHandler(l)}const u=getComponentName(l);let h=u??"Unknown";if(!u||INTERNAL_NAMES.has(u)||typeof l.type==="string"){h=getOwningComponentName(l)??u??"Unknown"}const T=findHostInstance(l);if(!T&&!d)return;if(!p&&!g&&c){p=collectDescendantText(l,6)}const b=T?.instance??null;const C=T?.nativeTag??null;const w=(b?n.get(b):void 0)??(C!=null?r.get(C):void 0);if(w){if(!w.press&&x)w.press=x;else if(w.press&&x?.longPress&&!w.press.longPress){w.press.longPress=x.longPress}if(!w.valueControl&&I)w.valueControl=I;if(!w.textControl&&P)w.textControl=P;if(!w.testID&&d)w.testID=d;if(!w.label&&g)w.label=g;if(!w.text&&p)w.text=p;if(b&&!n.has(b))n.set(b,w);if(C!=null&&!r.has(C))r.set(C,w);return}const S={nativeTag:C,name:h,role:m??(y?"progressbar":void 0),testID:d,label:g,text:p,instance:b,stateNode:T?.stateNode??null,fiber:l,press:x,valueControl:I,textControl:P,rect:null,buoy:s(l)};t.push(S);if(b)n.set(b,S);if(C!=null)r.set(C,S)})}return t}function explicitlyTargets(e,t){if(t.nativeTag!=null)return e.nativeTag===t.nativeTag;if(t.testID&&e.testID)return e.testID.toLowerCase()===t.testID.toLowerCase();return false}function appCandidates(e){const t=collectCandidates();if(e.includeBuoy)return t;return t.filter(n=>!n.buoy||explicitlyTargets(n,e))}async function measureCandidates(e){await Promise.all(e.map(async t=>{if(t.instance)t.rect=await measureInstance(t.instance)}))}const LIST_WRAPPERS=/^(FlatList|SectionList|VirtualizedSectionList|VirtualizedList|Animated\(.*\)|AnimatedComponent.*)$/;async function collectLists(e,t){const n=[];const r=makeChromeCheck();for(const i of getAllFiberRoots()){traverseFiberTree(i.current,l=>{if(getComponentName(l)!=="VirtualizedList")return;const o=l.memoizedProps;if(!o||typeof o.getItemCount!=="function")return;if(!e&&r(l))return;let c;try{c=Number(o.getItemCount(o.data))}catch{return}if(!Number.isFinite(c)||c<=0)return;const a=[];const f=(m,p)=>{for(let v=m?.child;v;v=v.sibling){const y=getComponentName(v);if(y==="VirtualizedList")continue;if(y==="CellRenderer"){a.push(v);continue}if(p<40)f(v,p+1)}};f(l,0);let d=l;let g=getOwningComponentName(d);for(let m=0;m<6&&g&&LIST_WRAPPERS.test(g);m++){d=d._debugOwner||d.return;g=getOwningComponentName(d)}n.push({owner:g,items:c,cells:a})})}const s=[];for(const i of n){const l=await Promise.all(i.cells.map(async c=>{const a=findHostInstance(c);return a?measureInstance(a.instance):null}));const o=l.filter(t).length;if(o>0&&i.items>o)s.push({owner:i.owner,items:i.items,listed:o})}return s}async function describeScreen(e={}){const t=includeHiddenScreens;const n=fullVisibleText;includeHiddenScreens=!!e.includeHidden;fullVisibleText=!!e.fullText;try{return await describeScreenInner(e)}finally{includeHiddenScreens=t;fullVisibleText=n}}async function describeScreenInner(e){prunedHiddenScreens=0;const t=collectCandidates();const n=prunedHiddenScreens;const r=e.includeBuoy?t:t.filter(f=>!f.buoy);const s=t.length-r.length;await measureCandidates(r);const i=_reactNative.Dimensions.get("window");const l=Math.round(i.width)||1;const o=Math.round(i.height)||1;const c=[];for(const f of r){const d=f.rect;if(!d&&!f.testID)continue;let g;let m;if(d){const y=d.x+d.width/2;const x=d.y+d.height/2;if(x<-o*.1||x>o*1.1||y<-l*.1||y>l*1.1){continue}g={x:round2(y/l),y:round2(x/o)};m={x:round2(d.x/l),y:round2(d.y/o),width:round2(d.width/l),height:round2(d.height/o)}}const p=f.valueControl?f.valueControl.kind:f.textControl?"text":void 0;const v=f.valueControl?f.valueControl.current:f.textControl?.current;c.push({nativeTag:f.nativeTag,name:f.name,role:f.role,testID:f.testID,label:f.label,text:f.text,interactive:!!(f.press||f.valueControl||f.textControl),longPressable:f.press&&(f.press.kind==="onLongPress"||f.press.longPress)?true:void 0,control:p,value:v,tap:g,frame:m})}c.sort((f,d)=>{const g=f.tap?.y??2;const m=d.tap?.y??2;if(Math.abs(g-m)>.02)return g-m;return(f.tap?.x??2)-(d.tap?.x??2)});const a=await collectLists(!!e.includeBuoy,f=>{if(!f)return false;const d=f.x+f.width/2;return f.y<=o*1.1&&f.y+f.height>=-o*.1&&d>=-l*.1&&d<=l*1.1});return{screen:{width:l,height:o},count:c.length,elements:c,...s>0?{hiddenBuoy:s}:{},...n>0?{hiddenScreens:n}:{},...a.length?{lists:a}:{}}}function round2(e){return Math.round(e*100)/100}function fieldsOf(e){return{nativeTag:e.nativeTag,testID:e.testID,label:e.label,text:e.text,name:e.name}}function matchScore(e,t){return(0,_tapMatch.scoreTapMatch)(fieldsOf(e),t)}function tapPoint(e,t,n){if(!e||!t||!n)return void 0;return{x:(e.x+e.width/2)/t,y:(e.y+e.height/2)/n}}function makeSyntheticPressEvent(e){const t=e?e.x+e.width/2:0;const n=e?e.y+e.height/2:0;const r={locationX:e?e.width/2:0,locationY:e?e.height/2:0,pageX:t,pageY:n,timestamp:0,target:null,identifier:1,touches:[],changedTouches:[]};return{nativeEvent:r,persist:()=>{},preventDefault:()=>{},stopPropagation:()=>{},isDefaultPrevented:()=>false,isPropagationStopped:()=>false,target:null,currentTarget:null,type:"press",timeStamp:0}}async function tapElement(e){const t=withHiddenScreens(!!e.includeHidden,()=>appCandidates(e));if(t.length===0){return{tapped:false,reason:"No React fiber roots / elements found on screen."}}const n=t.map(u=>({c:u,score:matchScore(u,e)})).filter(u=>u.score>0).sort((u,h)=>h.score-u.score);const r=u=>!!(u.press||u.valueControl||u.textControl);if(n.length===0&&!e.includeHidden){const u=withHiddenScreens(true,()=>appCandidates(e)).map(h=>({c:h,score:matchScore(h,e)})).filter(h=>h.score>0);if(u.length>0){return{tapped:false,reason:"That element is only on a screen that isn't showing (another tab, or a screen under the current one). Navigate to it first, or pass includeHidden:true if you really mean the hidden one."}}}if(n.length===0){return{tapped:false,reason:"No element matched. Call describe_screen to see available elements (match by testID, text, or name).",candidates:t.filter(r).slice(0,12).map(u=>({nativeTag:u.nativeTag,name:u.name,testID:u.testID,text:u.text}))}}const s=_reactNative.Dimensions.get("window");const i=s.width||1;const l=s.height||1;const o=n.slice(0,15);await Promise.all(o.map(async u=>{if(u.c.instance&&!u.c.rect)u.c.rect=await measureInstance(u.c.instance)}));for(const u of o){u.score=(0,_tapMatch.scoreTapMatch)({...fieldsOf(u.c),tap:tapPoint(u.c.rect,i,l)},e)}o.sort((u,h)=>h.score-u.score);const c=o.find(u=>r(u.c))??n.find(u=>r(u.c))??o[0];const a=c.c;const f=(u,h)=>u.press&&u.press.handler===h.press?.handler||u.valueControl&&u.valueControl.handler===h.valueControl?.handler||u.textControl&&u.textControl.handler===h.textControl?.handler;const d=o.filter(u=>u!==c&&r(u.c)&&u.score===c.score).filter(u=>!f(u.c,a)).filter((u,h,T)=>T.findIndex(b=>f(b.c,u.c))===h).slice(0,3).map(u=>({nativeTag:u.c.nativeTag,name:u.c.name,testID:u.c.testID,text:u.c.text,tap:tapPoint(u.c.rect,i,l)}));const g=e.nativeTag==null&&!(e.testID&&!e.query);if(g&&d.length>0){const u=[a,...d.map(h=>o.find(T=>T.c.nativeTag===h.nativeTag)?.c).filter(Boolean)];return{tapped:false,reason:`"${e.query}" matches ${u.length} different controls equally well, so nothing was tapped. Tap one by its nativeTag.`,candidates:u.map(h=>({nativeTag:h.nativeTag,name:h.name,testID:h.testID,text:h.text}))}}const m=o[0];if(g&&m&&m!==c&&!r(m.c)&&m.score>=90&&c.score<m.score-40){return{tapped:false,reason:`The best match for "${e.query}" is "${m.c.text??m.c.label??m.c.name}", which has no JS press handler (it may be native, like a tab bar button). The closest pressable match, "${a.text??a.label??a.name}", is a much weaker match, so nothing was tapped. Use navigate, or tap a specific element by nativeTag.`,candidates:[{nativeTag:a.nativeTag,name:a.name,testID:a.testID,text:a.text}]}}if(!r(a)){return{tapped:false,reason:`Matched "${a.name}"${a.text?` ("${a.text}")`:""} but it has no onPress / onValueChange / onChangeText handler (e.g. a react-native-gesture-handler GestureDetector). This element can't be driven in JS.`,matched:{nativeTag:a.nativeTag,name:a.name,testID:a.testID,label:a.label,text:a.text,via:"onPress"}}}if(a.instance&&!a.rect)a.rect=await measureInstance(a.instance);let p=false;const v=a.rect==null||!(0,_tapMatch.isRectCenterOnScreen)(a.rect,i,l);if(v&&e.scrollIntoView!==false&&a.instance){p=await scrollIntoView(a.fiber,a.instance,a.stateNode,80);if(p)a.rect=await measureInstance(a.instance)}const y={nativeTag:a.nativeTag,name:a.name,testID:a.testID,label:a.label,text:a.text};ensureCommitCounter();const x=commitCount;const I=Date.now();const P=async u=>{await new Promise(h=>setTimeout(h,TAP_SETTLE_MS));return{tapped:true,scrolled:p,matched:u,effect:{commits:commitCount-x,observedMs:Date.now()-I},...d.length?{alsoMatched:d}:{}}};try{if(a.press){if(e.longPress){const h=a.press.kind==="onLongPress"?a.press.handler:a.press.longPress;if(!h){return{tapped:false,scrolled:p,reason:`Matched "${a.name}"${a.text?` ("${a.text}")`:""} but it has no onLongPress handler \u2014 call tap_element without longPress to tap it normally.`,matched:{...y,via:"onPress"}}}h(makeSyntheticPressEvent(a.rect));return await P({...y,via:"onLongPress"})}a.press.handler(makeSyntheticPressEvent(a.rect));return await P({...y,via:a.press.kind})}if(a.valueControl){const h=a.valueControl;let T;if(h.kind==="toggle"){T=typeof e.value==="boolean"?e.value:!h.current}else{const b=h.min??0;const C=h.max??1;if(typeof e.value==="number"){T=Math.min(C,Math.max(b,e.value))}else{T=h.current===C?b:C}}h.handler(T);return await P({...y,via:"onValueChange",value:T})}const u=e.text??(typeof e.value==="string"?e.value:"");a.textControl.handler(u);return await P({...y,via:"onChangeText",value:u})}catch(u){return{tapped:false,scrolled:p,reason:`handler threw: ${u instanceof Error?u.message:String(u)}`,matched:{...y,via:a.press?a.press.kind:a.valueControl?"onValueChange":"onChangeText"}}}}const WAIT_DEFAULT_MS=5e3;const WAIT_MAX_MS=3e4;const WAIT_MIN_POLL_MS=50;const WAIT_DEFAULT_POLL_MS=150;async function waitFor(e){const t=e.nativeTag!=null||!!String(e.testID??"").trim()||!!String(e.query??"").trim();if(!t){return{ok:false,waitedMs:0,polls:0,reason:"Nothing to wait for \u2014 pass nativeTag, testID or query."}}const n=Math.min(Math.max(e.timeoutMs??WAIT_DEFAULT_MS,0),WAIT_MAX_MS);const r=Math.max(e.pollMs??WAIT_DEFAULT_POLL_MS,WAIT_MIN_POLL_MS);const s=e.gone===true;const i=Date.now();let l=0;for(;;){l+=1;const{hit:o,closest:c}=await findOnScreen(e);if(s?!o:!!o){return{ok:true,waitedMs:Date.now()-i,polls:l,matched:o??void 0}}if(Date.now()-i>=n){const a=c?.length?c:void 0;const f=s?`Still on screen after ${n}ms.`:a?`Not on screen after ${n}ms \u2014 ${a.length===1?"one element":`${a.length} elements`} matched but ${a.some(d=>d.onScreen)?"not well enough":"none is visible"}. See \`closest\`; do not retry with different words, call describeScreen.`:`Not on screen after ${n}ms, and nothing matched those words at all. Call describeScreen to see what is there.`;return{ok:false,waitedMs:Date.now()-i,polls:l,reason:f,matched:o??void 0,closest:a}}await new Promise(a=>setTimeout(a,r))}}async function findOnScreen(e){const t=appCandidates(e).map(o=>({c:o,score:matchScore(o,e)})).filter(o=>o.score>0).sort((o,c)=>c.score-o.score).slice(0,8);if(t.length===0)return{hit:null,closest:void 0};await measureCandidates(t.map(o=>o.c));const n=_reactNative.Dimensions.get("window");const r=Math.round(n.width)||1;const s=Math.round(n.height)||1;let i=null;for(const{c:o}of t){if(!(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,s))continue;i={nativeTag:o.nativeTag,name:o.name,testID:o.testID,label:o.label,text:o.text,interactive:!!(o.press||o.valueControl||o.textControl)};break}const l=t.slice(0,3).map(({c:o})=>({name:o.name,testID:o.testID,text:o.text,onScreen:(0,_tapMatch.isRectCenterOnScreen)(o.rect,r,s)}));return{hit:i,closest:l}}function isBuoyChrome(e){let t=e;let n=0;while(t&&n<400){if(getProps(t)?.__buoyDevToolsRoot)return true;t=t.return;n++}return false}function preferHandlerOwner(e,t){const n=getProps(e.fiber);if(typeof n?.onPress==="function"||typeof n?.onValueChange==="function"||typeof n?.onChangeText==="function"){return e}let r=null;let s=e.fiber?.return;let i=0;while(s&&i<25){if(typeof getProps(s)?.onPress==="function"){r=s;break}s=s.return;i++}if(!r)return e;let l=r;for(let o=0;o<6&&l;o++){const c=t.get(l);if(c)return c;l=l.return}return e}function resolveTouchTarget(e){const t=collectCandidates();if(t.length===0)return null;const n=new Map;for(const o of t)n.set(o.fiber,o);const r=t.find(o=>o.nativeTag===e);let s=null;if(!r){for(const o of getAllFiberRoots()){traverseFiberTree(o.current,c=>{if(s)return;if(c.stateNode&&getNativeTag(c.stateNode)===e){s=c}});if(s)break}}let i=r??null;if(!i&&s){let o=s;let c=0;let a=null;while(o&&c<25){const f=n.get(o);if(f){if(f.press||f.valueControl||f.textControl){i=f;break}if(!a)a=f}o=o.return;c++}if(!i)i=a}if(!i)return null;i=preferHandlerOwner(i,n);if(!i.press&&!i.valueControl&&!i.textControl)return null;if(isBuoyChrome(i.fiber))return null;const l=i.valueControl?i.valueControl.kind:i.textControl?"text":"press";return{nativeTag:i.nativeTag,name:i.name,role:i.role,testID:i.testID,label:i.label,text:i.text,control:l,value:i.valueControl?i.valueControl.current:i.textControl?i.textControl.current:void 0}}function fiberForTag(e){let t=null;for(const n of getAllFiberRoots()){traverseFiberTree(n.current,r=>{if(!t&&r.stateNode&&getNativeTag(r.stateNode)===e)t=r});if(t)break}return t}function rootHostFibers(){const e=[];for(const t of getAllFiberRoots()){let n=t.current?.child;let r=0;while(n&&r++<200){if(n.tag===HostComponent&&n.stateNode){e.push(n);break}n=n.child}}return e}function fabricFiberAt(e,t){const n=global.nativeFabricUIManager;if(!n||typeof n.findNodeAtPoint!=="function")return null;const r=rootHostFibers().filter(s=>s.stateNode?.node);if(!r.length)return null;return new Promise(s=>{const i=setTimeout(()=>s(null),1e3);let l=r.length;let o=null;r.forEach((c,a)=>{try{n.findNodeAtPoint(c.stateNode.node,e,t,f=>{if(f&&(!o||a>=o.i))o={i:a,fiber:f};if(--l===0){clearTimeout(i);s(o?.fiber??null)}})}catch{if(--l===0){clearTimeout(i);s(o?.fiber??null)}}})})}function paperFiberAt(e,t){const n=_reactNative.UIManager?.findSubviewIn;if(typeof n!=="function")return null;const r=rootHostFibers()[0];const s=r?getNativeTag(r.stateNode)??(0,_reactNative.findNodeHandle)(r.stateNode):null;if(s==null)return null;return new Promise(i=>{const l=setTimeout(()=>i(null),1e3);try{n.call(_reactNative.UIManager,s,[e,t],o=>{clearTimeout(l);i(typeof o==="number"?fiberForTag(o):null)})}catch{clearTimeout(l);i(null)}})}function visibleHostFibers(){const e=[];const t=new Set;const n=s=>{const i=[];const l=(o,c)=>{for(let a=o;a&&i.length<5e3;a=a.sibling){if(t.has(a)||c>500)continue;if(isHiddenOffscreen(a)||isInactiveScreen(a))continue;if(a.tag===HostComponent&&a.stateNode)i.push(a);else if(a.child)l(a.child,c+1)}};if(s.child)l(s.child,0);return i};const r=(s,i)=>{if(t.has(s)||i>500)return;t.add(s);e.push(s);sortByZ(n(s)).forEach(l=>r(l,i+1))};for(const s of getAllFiberRoots())sortByZ(n(s.current)).forEach(i=>r(i,0));return e}function sortByZ(e){const t=e.map(n=>{const r=Number(flatStyle(getProps(n)?.style).zIndex);return Number.isFinite(r)?r:0});return e.map((n,r)=>({h:n,i:r})).sort((n,r)=>t[n.i]-t[r.i]||n.i-r.i).map(({h:n})=>n)}function flatStyle(e,t=0){if(!e||typeof e!=="object"||t>10)return{};if(Array.isArray(e))return Object.assign({},...e.map(n=>flatStyle(n,t+1)));return e}const SCROLL_HOSTS=new Set(["RCTScrollView","AndroidHorizontalScrollView","RCTScrollContentView"]);function clipsChildren(e){if(typeof e.type==="string"&&SCROLL_HOSTS.has(e.type)&&e.type!=="RCTScrollContentView")return true;const t=flatStyle(getProps(e)?.style).overflow;return t==="hidden"||t==="scroll"}function passesTouchesThrough(e){let t=getProps(e)?.pointerEvents??getProps(e)?.style?.pointerEvents;if(t==="none")return"all";let n=e.return;let r=0;while(n&&r++<200){const s=getProps(n)?.pointerEvents??getProps(n)?.style?.pointerEvents;if(s==="none")return"all";if(s==="box-only"&&n.tag===HostComponent)return"all";n=n.return}return t==="box-none"?"self":null}async function measuredFiberAt(e,t,n){const r=await Promise.all(n.map(o=>{const c=getPublicInstance(o.stateNode);return c?measureInstance(c):Promise.resolve(null)}));const s=new Map;n.forEach((o,c)=>s.set(o,r[c]));const i=o=>!!o&&e>=o.x&&e<=o.x+o.width&&t>=o.y&&t<=o.y+o.height;const l=o=>{for(let c=o.return,a=0;c&&a<300;c=c.return,a++){if(c.tag===HostComponent&&s.has(c)&&clipsChildren(c)&&!i(s.get(c)))return true}return false};for(let o=n.length-1;o>=0;o--){if(!i(r[o])||passesTouchesThrough(n[o])||l(n[o]))continue;return n[o]}return null}function domFiberAt(e,t){const n=global.document;const r=global.window;if(!n?.elementFromPoint||!r)return null;let s=n.elementFromPoint(e*r.innerWidth,t*r.innerHeight);while(s){const i=Object.keys(s).find(l=>l.startsWith("__reactFiber$"));if(i)return s[i];s=s.parentElement}return null}async function hitTest(e){const t=Math.min(1,Math.max(0,Number(e?.x)));const n=Math.min(1,Math.max(0,Number(e?.y)));if(!Number.isFinite(t)||!Number.isFinite(n))return{found:false,method:"none",reason:"x and y must be numbers from 0 to 1."};const r=_reactNative.Dimensions.get("window");const s=t*r.width;const i=n*r.height;let l="none";let o=null;const c=domFiberAt(t,n);if(c){l="dom";o=c}else{const p=fabricFiberAt(s,i);if(p){l="fabric";o=await p}else{const y=paperFiberAt(s,i);if(y){l="paper";o=await y}}const v=visibleHostFibers();if(!o||!new Set(v).has(o)){o=await measuredFiberAt(s,i,v);l="measured"}}if(!o)return{found:false,method:l};const a=getProps(o)??{};const f=getNativeTag(o.stateNode);const d=[];let g=o;let m=0;while(g&&m++<80&&d.length<6){const p=getComponentName(g);if(p&&typeof g.type!=="string"&&!INTERNAL_NAMES.has(p)&&d[d.length-1]!==p)d.push(p);g=g.return}return{found:true,method:l,buoy:isBuoyChrome(o),view:{name:getComponentName(o)??"Unknown",nativeTag:f,testID:a.testID||void 0,label:a.accessibilityLabel||a["aria-label"]||void 0,text:getVisibleText(a)},path:d,target:f!=null?resolveTouchTarget(f):null}}async function readMaps(){const e=[];for(const s of getAllFiberRoots()){traverseFiberTree(s.current,i=>{const l=i.stateNode;if(i.tag===1&&l&&typeof l.getCamera==="function"&&!isBuoyChrome(i))e.push(i)})}const t=_reactNative.Dimensions.get("window");const n=s=>Promise.race([s,new Promise(i=>setTimeout(()=>i(null),1e3))]);const r=await Promise.all(e.slice(0,5).map(async s=>{try{const i=await n(Promise.resolve(s.stateNode.getCamera()));if(!i)return null;const l=findHostInstance(s);const o=l?await measureInstance(l.instance):null;const c=getProps(s)??{};return{name:getComponentName(s)??"Map",testID:typeof c.testID==="string"?c.testID:void 0,frame:o&&t.width&&t.height?{x:round2(o.x/t.width),y:round2(o.y/t.height),width:round2(o.width/t.width),height:round2(o.height/t.height)}:void 0,camera:{heading:typeof i.heading==="number"?i.heading:void 0,pitch:typeof i.pitch==="number"?i.pitch:void 0,altitude:typeof i.altitude==="number"?i.altitude:void 0,zoom:typeof i.zoom==="number"?i.zoom:void 0,center:i.center}}}catch{return null}}));return{maps:r.filter(s=>!!s)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.highlightUpdatesSyncAdapter=void 0;var _HighlightUpdatesController=_interopRequireDefault(require("../highlight-updates/utils/HighlightUpdatesController"));var _componentSource=require("../highlight-updates/utils/componentSource");var _RenderTracker=require("../highlight-updates/utils/RenderTracker");var _screenElements=require("../highlight-updates/utils/screenElements");var _touchCapture=require("../highlight-updates/utils/touchCapture");var _CommitProfiler=require("../highlight-updates/utils/CommitProfiler");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ensureInitialized(){if(!_HighlightUpdatesController.default.isInitialized()){_HighlightUpdatesController.default.initialize()}}function toWireCause(e){if(!e)return void 0;const{hookChanges:t,...r}=e;return r}function toWireRender(e){const{renderHistory:t,lastRenderCause:r,...n}=e;return{...n,lastRenderCause:toWireCause(r),historyCount:t?.length??0}}function jsonSafeRender(e){try{JSON.stringify(e);return e}catch{return{...e,lastRenderCause:toWireCause(e.lastRenderCause),renderHistory:e.renderHistory?.map(t=>({...t,capturedProps:void 0,capturedState:void 0,cause:toWireCause(t.cause)??t.cause}))}}}function beginMeasurement(){if(!_CommitProfiler.CommitProfiler.isSupported()){return{ok:false,reason:"render capture needs a dev build with the React DevTools hook available"}}_CommitProfiler.CommitProfiler.startCapture({detail:true});return{ok:true}}function endMeasurement(){return{summary:_CommitProfiler.CommitProfiler.stopCapture()}}const highlightUpdatesSyncAdapter=exports.highlightUpdatesSyncAdapter={version:3,getSnapshot:()=>({enabled:_HighlightUpdatesController.default.isEnabled(),frozen:_HighlightUpdatesController.default.getFrozen(),highlightsSuppressed:_HighlightUpdatesController.default.getHighlightsSuppressed(),renders:_RenderTracker.RenderTracker.getRenders().map(toWireRender),trackerState:_RenderTracker.RenderTracker.getState()}),subscribe:e=>{const t=_HighlightUpdatesController.default.subscribe(e);const r=_HighlightUpdatesController.default.subscribeToFreeze(e);const n=_RenderTracker.RenderTracker.subscribe(e);const a=_RenderTracker.RenderTracker.subscribeToState(e);return()=>{t();r();n();a()}},actions:{getComponentSource:async e=>{try{return await(0,_componentSource.getComponentSource)(e)}catch(t){return{found:false,reason:`Could not read the component's source: ${t instanceof Error?t.message:String(t)}`}}},beginMeasurement:()=>beginMeasurement(),endMeasurement:()=>endMeasurement(),getRenderDetail:e=>{const{nativeTag:t}=e??{};if(t==null){return{found:false,reason:"missing nativeTag"}}const r=_RenderTracker.RenderTracker.getRender(String(t));if(!r)return{found:false,reason:"unknown nativeTag"};return{found:true,nativeTag:t,render:jsonSafeRender(r)}},toggle:()=>{ensureInitialized();_HighlightUpdatesController.default.toggle()},setEnabled:e=>{ensureInitialized();_HighlightUpdatesController.default.setEnabled(e.enabled)},toggleFreeze:()=>{_HighlightUpdatesController.default.toggleFreeze()},clearRenderCounts:()=>{_HighlightUpdatesController.default.clearRenderCounts()},setSpotlight:e=>{_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},locateComponent:e=>{ensureInitialized();return _HighlightUpdatesController.default.locateComponent(e??{})},setSilentTracking:e=>{ensureInitialized();_HighlightUpdatesController.default.setSilentTracking(e.enabled??false)},describeScreen:e=>(0,_screenElements.describeScreen)(e??{}),tapElement:e=>(0,_screenElements.tapElement)(e??{}),waitFor:e=>(0,_screenElements.waitFor)(e??{}),startTouchCapture:()=>(0,_touchCapture.startTouchCapture)(),stopTouchCapture:()=>{(0,_touchCapture.stopTouchCapture)();return(0,_touchCapture.getTouchCaptureStatus)()},clearTouchCapture:()=>{(0,_touchCapture.clearTouchCapture)();return{ok:true}},readTouchCapture:e=>(0,_touchCapture.readTouchCapture)(e?.sinceSeq??0)}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.highlightUpdatesSyncAdapter=void 0;var _HighlightUpdatesController=_interopRequireDefault(require("../highlight-updates/utils/HighlightUpdatesController"));var _componentSource=require("../highlight-updates/utils/componentSource");var _RenderTracker=require("../highlight-updates/utils/RenderTracker");var _screenElements=require("../highlight-updates/utils/screenElements");var _touchCapture=require("../highlight-updates/utils/touchCapture");var _CommitProfiler=require("../highlight-updates/utils/CommitProfiler");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ensureInitialized(){if(!_HighlightUpdatesController.default.isInitialized()){_HighlightUpdatesController.default.initialize()}}function toWireCause(e){if(!e)return void 0;const{hookChanges:t,...r}=e;return r}function toWireRender(e){const{renderHistory:t,lastRenderCause:r,...n}=e;return{...n,lastRenderCause:toWireCause(r),historyCount:t?.length??0}}function jsonSafeRender(e){try{JSON.stringify(e);return e}catch{return{...e,lastRenderCause:toWireCause(e.lastRenderCause),renderHistory:e.renderHistory?.map(t=>({...t,capturedProps:void 0,capturedState:void 0,cause:toWireCause(t.cause)??t.cause}))}}}function beginMeasurement(){if(!_CommitProfiler.CommitProfiler.isSupported()){return{ok:false,reason:"render capture needs a dev build with the React DevTools hook available"}}_CommitProfiler.CommitProfiler.startCapture({detail:true});return{ok:true}}function endMeasurement(){return{summary:_CommitProfiler.CommitProfiler.stopCapture()}}const highlightUpdatesSyncAdapter=exports.highlightUpdatesSyncAdapter={version:3,getSnapshot:()=>({enabled:_HighlightUpdatesController.default.isEnabled(),frozen:_HighlightUpdatesController.default.getFrozen(),highlightsSuppressed:_HighlightUpdatesController.default.getHighlightsSuppressed(),renders:_RenderTracker.RenderTracker.getRenders().map(toWireRender),trackerState:_RenderTracker.RenderTracker.getState()}),subscribe:e=>{const t=_HighlightUpdatesController.default.subscribe(e);const r=_HighlightUpdatesController.default.subscribeToFreeze(e);const n=_RenderTracker.RenderTracker.subscribe(e);const a=_RenderTracker.RenderTracker.subscribeToState(e);return()=>{t();r();n();a()}},actions:{getComponentSource:async e=>{try{return await(0,_componentSource.getComponentSource)(e)}catch(t){return{found:false,reason:`Could not read the component's source: ${t instanceof Error?t.message:String(t)}`}}},beginMeasurement:()=>beginMeasurement(),endMeasurement:()=>endMeasurement(),getRenderDetail:e=>{const{nativeTag:t}=e??{};if(t==null){return{found:false,reason:"missing nativeTag"}}const r=_RenderTracker.RenderTracker.getRender(String(t));if(!r)return{found:false,reason:"unknown nativeTag"};return{found:true,nativeTag:t,render:jsonSafeRender(r)}},toggle:()=>{ensureInitialized();_HighlightUpdatesController.default.toggle()},setEnabled:e=>{ensureInitialized();_HighlightUpdatesController.default.setEnabled(e.enabled)},toggleFreeze:()=>{_HighlightUpdatesController.default.toggleFreeze()},clearRenderCounts:()=>{_HighlightUpdatesController.default.clearRenderCounts()},setSpotlight:e=>{_HighlightUpdatesController.default.setSpotlight(e.nativeTag)},locateComponent:e=>{ensureInitialized();return _HighlightUpdatesController.default.locateComponent(e??{})},setSilentTracking:e=>{ensureInitialized();_HighlightUpdatesController.default.setSilentTracking(e.enabled??false)},describeScreen:e=>(0,_screenElements.describeScreen)(e??{}),tapElement:e=>(0,_screenElements.tapElement)(e??{}),waitFor:e=>(0,_screenElements.waitFor)(e??{}),hitTest:e=>(0,_screenElements.hitTest)(e??{x:.5,y:.5}),readMaps:()=>(0,_screenElements.readMaps)(),startTouchCapture:()=>(0,_touchCapture.startTouchCapture)(),stopTouchCapture:()=>{(0,_touchCapture.stopTouchCapture)();return(0,_touchCapture.getTouchCaptureStatus)()},clearTouchCapture:()=>{(0,_touchCapture.clearTouchCapture)();return{ok:true}},readTouchCapture:e=>(0,_touchCapture.readTouchCapture)(e?.sinceSeq??0)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import
|
|
1
|
+
"use strict";import Oe,{useState as l,useEffect as g,useRef as y,useCallback as o}from"react";import{View as D,Text as Te,StyleSheet as Ue,Platform as je}from"react-native";import{Power as Je,JsModal as Me,devToolsStorageKeys as x,persistentStorage as V,night as w,TickProvider as xe,windowDragProps as Ke}from"@buoy-gg/shared-ui";import{useIsPro as We}from"@buoy-gg/license";import c from"../utils/HighlightUpdatesController";import{RenderTracker as i}from"../utils/RenderTracker";import{RenderDetailView as qe}from"./RenderDetailView";import{EventStepperFooter as Ge}from"@buoy-gg/shared-ui";import{HighlightFilterView as Qe}from"./HighlightFilterView";import{IsolatedRenderList as Xe}from"./IsolatedRenderList";import{MainListHeader as Ye,FilterViewHeader as Ze,DetailViewHeader as $e,CopySettingsViewHeader as et}from"./ModalHeaderContent";import{RenderHistoryViewer as tt,RenderHistoryFooter as nt}from"./RenderHistoryViewer";import{RendersCopySettingsView as rt}from"./RendersCopySettingsView";import{jsx as s,jsxs as J,Fragment as st}from"react/jsx-runtime";const ot=Oe.memo(function a(){return J(D,{testID:"buoy-highlight-disabled-banner",style:b.disabledBanner,children:[s(Je,{size:14,color:w.color.warning}),s(Te,{testID:"buoy-highlight-disabled-text",style:b.disabledText,children:"Render tracking is disabled"})]})});export function HighlightUpdatesModal({visible:a,onClose:we,onBack:M,onMinimize:Ce,enableSharedModalDimensions:Fe=false,initialNativeTag:k,onInitialNativeTagHandled:K,onRenderSelect:H,inline:be=false}){const I=We();const[v,Ie]=l(false);const[W,ve]=l(()=>c.getFrozen());const[q,G]=l(()=>i.getStats().totalComponents>0);const[r,f]=l(null);const[p,T]=l(0);const[A,z]=l(false);const[N,Q]=l(false);const[Re,Pe]=l([]);const[B,De]=l("filters");const[C,X]=l("details");const[Y,_]=l(0);const[m,Ve]=l("");const[R,E]=l(false);const Z=y(null);const F=y([]);const $=y(i.getFilters());const[L,ee]=l(()=>{const e=i.getFilters();return e.includePatterns.length+e.excludePatterns.length});const[d,te]=l(()=>i.getFilters());const[O,ne]=l(()=>i.getSettings());const re=y(false);const U=y(false);const P=y(false);g(()=>{if(!a||re.current)return;re.current=true},[a]);g(()=>{if(!a||U.current)return;const e=async()=>{try{const t=await V.getItem(x.highlightUpdates.filters());if(t){const n=JSON.parse(t);const u={includeTestID:new Set(n.includeTestID||[]),includeNativeID:new Set(n.includeNativeID||[]),includeViewType:new Set(n.includeViewType||[]),includeComponent:new Set(n.includeComponent||[]),excludeTestID:new Set(n.excludeTestID||[]),excludeNativeID:new Set(n.excludeNativeID||[]),excludeViewType:new Set(n.excludeViewType||[]),excludeComponent:new Set(n.excludeComponent||[]),includePatterns:n.includePatterns||[],excludePatterns:n.excludePatterns||[]};i.setFilters(u);const h=i.getFilters();$.current=h;te(h);ee(h.includePatterns.length+h.excludePatterns.length)}U.current=true}catch(t){}};e()},[a]);g(()=>{if(!U.current)return;const e=async()=>{try{const t={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 V.setItem(x.highlightUpdates.filters(),JSON.stringify(t))}catch(t){}};e()},[d]);g(()=>{if(!a||P.current)return;const e=async()=>{try{const t=await V.getItem(x.highlightUpdates.settings());if(t){const n=JSON.parse(t);const{performanceLogging:u,excludeDevTools:h,...S}=n;i.setSettings(S);ne(i.getSettings())}P.current=true}catch(t){P.current=true}};e()},[a]);g(()=>{if(!P.current)return;const e=async()=>{try{const{performanceLogging:t,excludeDevTools:n,...u}=O;await V.setItem(x.highlightUpdates.settings(),JSON.stringify(u))}catch(t){}};e()},[O]);g(()=>{const e=i.subscribeToState(t=>{Ie(t.isTracking)});return()=>{e()}},[]);g(()=>{const e=c.subscribeToFreeze(t=>{ve(t)});return()=>{e()}},[]);g(()=>{if(R){requestAnimationFrame(()=>{Z.current?.focus()})}},[R]);g(()=>{if(!a){c.setSpotlight(null)}},[a]);g(()=>{if(a&&k!=null){const e=i.getRender(String(k));if(e){f(e);T(0);z(false);c.setSpotlight(e.nativeTag)}K?.()}},[a,k,K]);const se=o(()=>{if(!c.isInitialized()){c.initialize()}c.toggle()},[]);const oe=o(()=>{c.toggleFreeze()},[]);const ie=o(()=>{c.clearRenderCounts();G(false)},[]);const le=o(()=>{Pe(i.getFilteredRenders(m));Q(true)},[m]);const ae=o(()=>{Q(false)},[]);const ce=o(e=>{Ve(e)},[]);const ke=o((e,t,n)=>{f(e);T(t);X("details");_(0);F.current=n;c.setSpotlight(e.nativeTag)},[]);g(()=>{if(!r)return;const e=String(r.nativeTag);return i.subscribe(()=>{const t=i.getRender(e);if(t)f({...t})})},[r?.nativeTag]);const de=y(null);g(()=>{if(!H||!r)return;if(de.current===r.nativeTag)return;de.current=r.nativeTag;H(r)},[r,H]);const He=o(e=>{F.current=e},[]);const ge=o(()=>{f(null);T(0);if(m)E(true);c.setSpotlight(null)},[m]);const Ae=o(()=>{const e=F.current;if(p>0){const t=p-1;const n=e[t];if(n){f(n);T(t);c.setSpotlight(n.nativeTag)}}},[p]);const ze=o(()=>{const e=F.current;if(p<e.length-1){const t=p+1;const n=e[t];if(n){f(n);T(t);c.setSpotlight(n.nativeTag)}}},[p]);const ue=o(()=>{z(false)},[]);const he=o(()=>{z(true)},[]);const fe=o(()=>{E(true)},[]);const pe=o(()=>{E(false)},[]);const j=o(e=>{i.setFilters(e);const t=i.getFilters();$.current=t;te(t);ee(t.includePatterns.length+t.excludePatterns.length)},[]);const Ne=o((e,t)=>{const n=i.getFilters();const u={};if(t==="include"){const h=n.includePatterns.some(S=>S.type===e.type&&S.value===e.value);if(!h){u.includePatterns=[...n.includePatterns,e]}}else{const h=n.excludePatterns.some(S=>S.type===e.type&&S.value===e.value);if(!h){u.excludePatterns=[...n.excludePatterns,e]}}if(Object.keys(u).length>0){j(u);f(null);T(0);c.setSpotlight(null)}},[j]);const Be=o(e=>{i.setSettings(e);ne(i.getSettings())},[]);const _e=o(e=>{G(e.totalComponents>0)},[]);const me=o(()=>{if(N){return s(et,{onBack:ae})}if(A){return s(Ze,{onBack:ue,activeTab:B,onTabChange:De,activeFilterCount:L})}if(r){return s($e,{onBack:ge,activeTab:C,onTabChange:X,hasHistory:(r.renderHistory?.length??0)>0})}return s(Ye,{onBack:M,isSearchActive:R,searchText:m,onSearchChange:ce,onSearchToggle:fe,onSearchClose:pe,onFilterToggle:he,onToggleTracking:se,onToggleFreeze:oe,onClear:ie,onOpenCopySettings:le,isTracking:v,isFrozen:W,activeFilterCount:L,hasRenders:q,searchInputRef:Z})},[N,A,r,M,R,m,v,W,L,q,B,C,ue,ge,ae,ce,fe,pe,he,se,oe,ie,le]);const Ee=Fe?x.modal.root():x.highlightUpdates.modal();if(!a)return null;const Le=F.current.length;const Se=r?C==="details"?s(Ge,{currentIndex:p,totalItems:Le,onPrevious:Ae,onNext:ze,itemLabel:"Component",subtitle:r.componentName||r.displayName||r.viewType}):s(nt,{render:r,selectedEventIndex:Y,onEventIndexChange:_,isPro:I}):null;const ye=s(D,{nativeID:"__rn_buoy__highlight-modal",testID:"buoy-highlight-body",style:b.container,children:N?s(rt,{renders:Re}):r?C==="details"?s(qe,{render:r,disableInternalFooter:true,onAddFilter:Ne,isPro:I}):s(tt,{render:r,disableInternalFooter:true,selectedEventIndex:Y,onEventIndexChange:_,isPro:I}):A?s(Qe,{filters:d,onFilterChange:j,settings:O,onSettingsChange:Be,availableProps:i.getAvailableProps(),activeTab:B}):J(st,{children:[c.getRenderSourceStatus()==="unavailable"?s(Te,{style:{color:w.color.warning,padding:16},children:"Not in this app"}):!v&&s(ot,{}),s(Xe,{searchText:m,filters:d,onSelectRender:ke,onStatsChange:_e,onRendersChange:He,isTracking:v,isPro:I})]})});if(be){return s(xe,{children:J(D,{style:b.inlineRoot,children:[s(D,{style:b.inlineHeader,...Ke,children:me()}),ye,Se]})})}return s(xe,{children:s(Me,{visible:a,onClose:we,onMinimize:Ce,persistenceKey:Ee,header:{showToggleButton:true,customContent:me()},enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:je.OS==="web",styles:{},footer:Se,footerHeight:r?C==="details"?68:(r.renderHistory?.length??0)>1?68:0:0,children:ye})})}export function HighlightToolView(a={}){return s(HighlightUpdatesModal,{...a,inline:true,visible:true,onClose:()=>{}})}const b=Ue.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:w.color.border,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:w.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:w.color.warning+"20"},disabledText:{color:w.color.warning,fontSize:11,flex:1}});export default HighlightUpdatesModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{isDevToolsComponentName as I,isRenderLoopUnsafeName as x}from"./devtoolsComponentNames";import{ownStateChanged as B}from"./ownStateChanged";const k=0;const O=1;const b=11;const w=14;const N=15;const
|
|
1
|
+
"use strict";import{isDevToolsComponentName as I,isRenderLoopUnsafeName as x}from"./devtoolsComponentNames";import{ownStateChanged as B}from"./ownStateChanged";const k=0;const O=1;const b=11;const w=14;const N=15;const d=1;const K=1e4;const L=300;const H=20;let E=false;let p=false;let A=false;let m=false;let h=0;let u=0;let g=0;let c={};let f=new Map;function F(){if(typeof global==="undefined")return null;return global.__REACT_DEVTOOLS_GLOBAL_HOOK__??null}function C(e){const t=e.flags??e.effectTag;return typeof t==="number"?t:0}function T(e){return e===k||e===O||e===b||e===w||e===N}function _(e){const t=e.type;try{switch(e.tag){case k:case O:return t?.displayName||t?.name||"Anonymous";case b:return t?.displayName||t?.render?.displayName||t?.render?.name||"ForwardRef";case w:case N:{const s=t?.type??e.elementType?.type;return t?.displayName||s?.displayName||s?.name||"Memo"}default:return"Anonymous"}}catch{return"Anonymous"}}function X(e){const t=e.actualDuration;if(typeof t!=="number")return null;let s=t;for(let r=e.child;r!=null;r=r.sibling){if(typeof r.actualDuration==="number")s-=r.actualDuration}return s>0?s:0}const U=new Set(["View","Text","Image","ImageBackground","ScrollView","FlatList","SectionList","SafeAreaView","KeyboardAvoidingView","StatusBar","ActivityIndicator","RefreshControl","Modal","Switch","Pressable","PlatformPressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","PressabilityDebugView","AnimatedComponent","Wrapper"]);const D=["Animated(","Pressability","Virtualized","CellRenderer"];function v(e){if(U.has(e))return true;for(let t=0;t<D.length;t++){if(e.startsWith(D[t]))return true}return false}const z=40;const V=5;function G(e,t){if(Object.is(e,t))return true;const s=typeof e;if(s!==typeof t)return false;if(s==="function")return true;if(e===null||t===null||s!=="object")return false;const r=Array.isArray(e);if(r!==Array.isArray(t))return false;if(r){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!Object.is(e[a],t[a]))return false;return true}const n=Object.keys(e);const i=Object.keys(t);if(n.length!==i.length)return false;for(let a=0;a<n.length;a++){const o=n[a];if(!Object.prototype.hasOwnProperty.call(t,o))return false;if(!Object.is(e[o],t[o]))return false}return true}function q(e,t){const s=e.alternate;if(!s)return{cause:"mount"};const r=e.memoizedProps;const n=s.memoizedProps;if(r!==n&&r&&n){let i=false;let a=false;let o;const l=Object.keys(r);const W=l.length<z?l.length:z;for(let M=0;M<W;M++){const P=l[M];const S=n[P];const R=r[P];if(Object.is(S,R))continue;i=true;if(t){if(!o)o=[];if(o.length<V)o.push(P)}if(!G(S,R)){a=true;if(!t)break}}if(!a&&Object.keys(n).length!==l.length){i=true;a=true}if(i){return{cause:a?"props":"propsUnstable",changedKeys:o}}}if(B(s,e))return{cause:"hooks"};return{cause:"parent"}}function Y(e){for(let t=e.return;t!=null;t=t.return){if(!T(t.tag))continue;if((C(t)&d)===0)continue;const s=_(t);if(v(s))continue;return s}return void 0}function J(e,t){const s=_(e);const r=X(e);if(r!==null)A=true;const n=r??0;u+=1;g+=n;const{cause:i,changedKeys:a}=q(e,m);c[i]=(c[i]??0)+1;if(v(s))return;let o=f.get(s);if(!o){if(f.size>=L)return;o={renders:0,totalSelfMs:0,maxSelfMs:0,causes:{}};f.set(s,o)}o.renders+=1;o.totalSelfMs+=n;if(n>o.maxSelfMs)o.maxSelfMs=n;o.causes[i]=(o.causes[i]??0)+1;if(m){if(a){if(!o.changedProps)o.changedProps=new Set;for(let l=0;l<a.length;l++){if(o.changedProps.size>=V)break;o.changedProps.add(a[l])}}if(t&&!o.parentName)o.parentName=t}}function Q(e){const t=e?.current;if(!t)return;const s=u;let r=0;let n=t;while(n!=null){r+=1;if(r>K)break;let i=false;const a=T(n.tag);if(n.memoizedProps?.__buoyDevToolsRoot||n.memoizedProps?.["data-buoy-root"]!==void 0){i=true}else if(a){const o=_(n);if(x(o)){i=true}else if(I(o)){}else if((C(n)&d)!==0){J(n,m?Y(n):void 0)}}if(!i){const o=n.subtreeFlags;const l=typeof o==="number"&&(o&d)===0&&(C(n)&d)===0;if(!l&&n.child!=null){n=n.child;continue}}while(n!=null){if(n===t)return j(s);if(n.sibling!=null){n=n.sibling;break}n=n.return}}j(s)}function j(e){if(u>e)h+=1}function Z(){if(E)return true;const e=F();if(!e)return false;const t=e.onCommitFiberRoot;e.onCommitFiberRoot=function(s,r,...n){if(p){try{Q(r)}catch{}}return typeof t==="function"?t.call(e,s,r,...n):void 0};E=true;return true}function $(){if(typeof __DEV__!=="undefined"&&!__DEV__)return false;const e=F();return Boolean(e&&e.renderers&&e.renderers.size>0)}function ee(){return p}function te(e){if(!Z())return;f=new Map;A=false;m=e?.detail===true;h=0;u=0;g=0;c={};p=true}function ne(){if(!p&&u===0&&f.size===0)return null;p=false;const e=Array.from(f.entries()).sort((s,r)=>{const n=r[1].totalSelfMs-s[1].totalSelfMs;return n!==0?n:r[1].renders-s[1].renders}).slice(0,H).map(([s,r])=>({name:s,renders:r.renders,totalMs:y(r.totalSelfMs),maxMs:y(r.maxSelfMs),avgMs:r.renders>0?y(r.totalSelfMs/r.renders):0,causes:r.causes,...r.changedProps&&r.changedProps.size>0?{changedProps:Array.from(r.changedProps)}:null,...r.parentName?{parentName:r.parentName}:null}));const t={totalCommits:h,totalRenders:u,capturedDurations:A,totalRenderMs:y(g),wastedRenders:(c.parent??0)+(c.propsUnstable??0),causes:c,topComponents:e};f=new Map;h=0;u=0;g=0;c={};return t}function y(e){return Math.round(e*100)/100}export const CommitProfiler={isSupported:$,isCapturing:ee,startCapture:te,stopCapture:ne};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{getDOMFiber as W,getDOMNodeHandle as Ne,getDOMPublicInstance as Oe,isDOMElement as ae}from"@buoy-gg/shared-ui/utils";"use strict";import{installProfilerInterceptor as Le,uninstallProfilerInterceptor as Re,setComparisonCallback as He}from"./ProfilerInterceptor";import{findNodeHandle as oe,UIManager as Ve,Dimensions as ze,PixelRatio as se}from"react-native";import{RenderTracker as v}from"./RenderTracker";import{describeScreen as xe}from"./screenElements";import{scoreTapMatch as Ue}from"./tapMatch";import{PerformanceLogger as le,markEventReceived as Ae}from"./PerformanceLogger";import{detectRenderCause as ce,clearRenderCauseState as Fe}from"./RenderCauseDetector";import{notifySubscriberCountChange as ue}from"@buoy-gg/shared-ui";import{HIGHLIGHT_OVERLAY_COMPONENTS as Me,HIGHLIGHT_OVERLAY_PREFIXES as Ge,OTHER_DEV_TOOLS_COMPONENTS as Be,OTHER_DEV_TOOLS_EXACT as $e,OTHER_DEV_TOOLS_PREFIXES as je,isCapturingBuoyToolRenders as We,isPerfMonitorComponentName as Ke}from"./devtoolsComponentNames";let w=false;let V=false;let L=false;let N=false;let y=null;let O=null;let A=null;let z=null;let fe=false;let k=false;const F=new Set;const K=new Set;const q=new Map;const X=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"];const qe=false;function f(e,n){if(!qe)return;if(n!==void 0){console.log(`[HighlightUpdates] ${e}`,n)}else{console.log(`[HighlightUpdates] ${e}`)}}function M(e){const n=Oe(e);if(n)return n;if(!e)return null;const i=e;if(i.canonical?.publicInstance){return i.canonical.publicInstance}if(i.canonical&&typeof i.canonical.measure==="function"){return i.canonical}if(typeof i.measure==="function"){return i}return null}function R(e){const n=Ne(e);if(n!==null)return n;if(e==null)return null;const i=e;if(i.__nativeTag!=null)return i.__nativeTag;if(i._nativeTag!=null)return i._nativeTag;if(i.nativeTag!=null)return i.nativeTag;if(i.canonical){if(i.canonical.__nativeTag!=null)return i.canonical.__nativeTag;if(i.canonical._nativeTag!=null)return i.canonical._nativeTag;if(i.canonical.nativeTag!=null)return i.canonical.nativeTag}return null}function Y(e){const n=e;const i={viewType:"Unknown"};if(n?.canonical?.viewConfig?.uiViewClassName){i.viewType=n.canonical.viewConfig.uiViewClassName}else if(n?.viewConfig?.uiViewClassName){i.viewType=n.viewConfig.uiViewClassName}else if(ae(n)){i.viewType=n.tagName.toLowerCase()}const o=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||W(n);const r=n?.canonical?.currentProps;const a=n?.canonical?.pendingProps;const t=o?.pendingProps;const c=o?.memoizedProps;i.testID=r?.testID||a?.testID||t?.testID||c?.testID||t?.["data-testid"]||c?.["data-testid"]||void 0;i.nativeID=r?.nativeID||a?.nativeID||t?.nativeID||c?.nativeID||t?.id||c?.id||void 0;i.accessibilityLabel=r?.accessibilityLabel||a?.accessibilityLabel||t?.accessibilityLabel||c?.accessibilityLabel||t?.["aria-label"]||c?.["aria-label"]||void 0;i.componentName=nn(o)||void 0;return i}function Gn(e){const n=e;const i=M(e);const o=R(e)||R(i);const r={nativeTag:o??"unknown",type:n?.canonical?"Fabric":"Legacy",hasMeasure:typeof i?.measure==="function"};if(n){r.stateNodeKeys=Object.keys(n).slice(0,20);if(n.node){r.nodeKeys=Object.keys(n.node).slice(0,20)}if(n.viewConfig){r.viewConfig={uiViewClassName:n.viewConfig.uiViewClassName,validAttributes:n.viewConfig.validAttributes?Object.keys(n.viewConfig.validAttributes).slice(0,10):void 0}}if(n.canonical){const a=n.canonical;r.canonicalKeys=Object.keys(a).slice(0,20);if(a.viewConfig){r.canonicalViewConfig={uiViewClassName:a.viewConfig.uiViewClassName}}if(a.nativeTag!=null){r.canonicalNativeTag=a.nativeTag}if(a.internalInstanceHandle){const t=a.internalInstanceHandle;r.fiberKeys=Object.keys(t).slice(0,30);if(t.type){r.fiberType=typeof t.type==="function"?t.type.name||t.type.displayName||"function":t.type}if(t.elementType){r.fiberElementType=typeof t.elementType==="function"?t.elementType.name||t.elementType.displayName||"function":t.elementType}if(t._debugOwner){const c=t._debugOwner;r.fiberDebugOwner=c.type?.name||c.type?.displayName||c.elementType?.name||"unknown"}if(t._debugSource){r.fiberDebugSource=t._debugSource}if(t.tag!=null){r.fiberTag=t.tag}if(t.pendingProps){if(t.pendingProps.nativeID)r.fiberPendingNativeID=t.pendingProps.nativeID;if(t.pendingProps.testID)r.fiberPendingTestID=t.pendingProps.testID}if(t.memoizedProps){if(t.memoizedProps.nativeID)r.fiberMemoizedNativeID=t.memoizedProps.nativeID;if(t.memoizedProps.testID)r.fiberMemoizedTestID=t.memoizedProps.testID}}if(a.publicInstance){const t=a.publicInstance;r.publicInstanceKeys=Object.keys(t).slice(0,20);if(t.nativeID!=null)r.nativeID=t.nativeID;if(t._nativeID!=null)r._nativeID=t._nativeID;if(t.props){r.publicInstanceProps=Object.keys(t.props).slice(0,15);if(t.props.nativeID)r.propsNativeID=t.props.nativeID;if(t.props.testID)r.propsTestID=t.props.testID;if(t.props.accessibilityLabel)r.accessibilityLabel=t.props.accessibilityLabel}}if(a.currentProps){r.currentPropsKeys=Object.keys(a.currentProps).slice(0,15);if(a.currentProps.nativeID!=null)r.currentPropsNativeID=a.currentProps.nativeID;if(a.currentProps.testID!=null)r.currentPropsTestID=a.currentProps.testID;if(a.currentProps.accessibilityLabel!=null)r.currentPropsAccessLabel=a.currentProps.accessibilityLabel}if(a.pendingProps){r.pendingPropsKeys=Object.keys(a.pendingProps).slice(0,15);if(a.pendingProps.nativeID!=null)r.pendingPropsNativeID=a.pendingProps.nativeID;if(a.pendingProps.testID!=null)r.pendingPropsTestID=a.pendingProps.testID}}if(n._debugOwner){const a=n._debugOwner;r.debugOwnerType=a.type?.name||a.type?.displayName||typeof a.type}if(n._debugSource){r.debugSource=n._debugSource}}return r}const de=false;let Xe=false;let Z=null;const Bn=350;const ge=new Set;function $n(e){if(e==null)return false;return ge.has(e)}const Ye=new Set(["highlight-updates-overlay","__rn_buoy__highlight-modal"]);const Ze=new Set(["jsmodal-root","image-overlay-standalone","logbox_inspector","logbox"]);const H=new Map;const pe=500;function Je(){H.clear()}function me(e){if(!e)return false;if(Ye.has(e))return true;if(e.startsWith("__highlight_"))return true;return false}function be(e){if(!e)return false;if(Ze.has(e))return true;const n=e.charCodeAt(0);if(n===95){if(e.startsWith("__rn_buoy__"))return true}if(n===108&&e.startsWith("logbox")){return true}return false}function he(e){if(!e)return null;const n=e.type;if(n){if(typeof n==="string")return n;if(n.name)return n.name;if(n.displayName)return n.displayName}const i=e.elementType;if(i){if(i.name)return i.name;if(i.displayName)return i.displayName}return null}const Qe=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 en(e){if(!e)return true;if(Qe.has(e))return true;if(e==="Unknown"||e==="Component")return true;if(e.startsWith("Animated"))return true;return false}function nn(e){if(!e)return null;let n=e._debugOwner||e.return;let i=0;let o=null;while(n&&i<30){const r=he(n);if(r&&typeof n.type!=="string"){if(!o){o=r}if(!en(r)){return r}}n=n.return;i++}return o}function tn(e){const n=e;const i=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||W(n);const o=R(e)||R(n?.canonical?.publicInstance);const r=We();const a=!r&&v.getSettings().excludeDevTools;if(a&&ae(e)&&e.closest("[data-buoy-root]"))return true;if(o!=null&&a){const p=H.get(o);if(p!==void 0){return p}}let t=false;const c=i?.pendingProps?.nativeID||i?.memoizedProps?.nativeID||n?.canonical?.currentProps?.nativeID||null;if(me(c)){t=true}else if(a&&be(c)){t=true}if(!t&&i){let p=i;let h=0;while(p&&h<30){const s=he(p);if(s){if(Me.has(s)){t=true;break}for(const g of Ge){if(s.startsWith(g)){t=true;break}}if(t)break;if(r&&Ke(s)){t=true;break}if(a){if(Be.has(s)||$e.has(s)){t=true;break}for(const g of je){if(s.startsWith(g)){t=true;break}}if(t)break}}const d=p.pendingProps?.nativeID||p.memoizedProps?.nativeID;if(me(d)){t=true;break}if(a&&be(d)){t=true;break}p=p.return;h++}}if(t&&o!=null&&a){if(H.size>=pe){const p=Array.from(H.keys());for(let h=0;h<pe/2;h++){H.delete(p[h])}}H.set(o,t)}return t}function rn(e){const n=Math.min(e-1,X.length-1);return X[Math.max(0,n)]}function an(e){if(e.size===0){return}if(!w&&!L){return}const n=v.getState();if(n.isPaused){return}if(le.isEnabled()){Ae()}const i=v.getBatchSize();const o=le.startBatch(e.size,i);const r=[];let a=0;let t=0;const c=v.hasActiveFilters();for(const s of e){if(s&&typeof s==="object"){try{if(tn(s)){a++;continue}const d=M(s);const g=R(s)||R(d);if(g==null){continue}const T=Y(s);if(c&&!v.passesFilters(T)){t++;continue}const P=v.getSettings().showRenderCount;let m;let u;if(P){const l=q.get(g)||0;m=l+1;q.set(g,m);u=rn(m)}else{m=0;u=X[0]}r.push({node:s,color:u,count:m})}catch{}}}o.markFilteringComplete(a+t,r.length);if(r.length===0){o.finish();return}if(de){console.log(`[HighlightUpdates] ${r.length} component(s) re-rendered`)}const p=v.getRenderEventCallbackCount()>0;if(!O&&!p){if(de){console.log(`[HighlightUpdates] No highlightCallback and no event callbacks - skipping render`)}fe=false;return}o.markMeasurementStart();const h=r.slice(0,i*4).map(({node:s,color:d,count:g})=>new Promise(T=>{let P=false;const m=b=>{if(P)return;P=true;clearTimeout(u);T(b)};const u=setTimeout(()=>m({rect:null,stateNode:s,color:d,count:g}),500);const l=M(s);const E=R(s)||R(l);if(E==null){m({rect:null,stateNode:s,color:d,count:g});return}const I=(b,D,_,S,ie,re)=>{if(ie==null||re==null||_==null||S==null){m({rect:null,stateNode:s,color:d,count:g});return}m({rect:{id:E,x:ie,y:re,width:_,height:S,color:d,count:g},stateNode:s,color:d,count:g})};if(!l){const b=s.node;const D=globalThis.nativeFabricUIManager;if(b&&D?.measure){try{D.measure(b,I)}catch(_){m({rect:null,stateNode:s,color:d,count:g})}return}m({rect:null,stateNode:s,color:d,count:g});return}try{l.measure(I)}catch(b){m({rect:null,stateNode:s,color:d,count:g})}}));Promise.all(h).then(s=>{const d=s.filter(T=>T.rect!==null);const g=d.map(T=>T.rect);o.markMeasurementComplete(d.length,s.length-d.length);if(g.length>0&&O&&w&&!V){O(g)}setTimeout(()=>{try{for(const u of d){if(u.rect)on(u.rect.id,u.stateNode)}}catch(u){f("registerTrackedNode batch failed",u)}const T=v.getSettings();const P=T.trackRenderCauses&&T.showRenderCount;let m=null;if(P){m=new Set;for(const{rect:u}of d){if(u){m.add(u.id)}}}if(w){v.startBatch();for(const{rect:u,stateNode:l,color:E,count:I}of d){if(u){const b=Y(l);let D;if(P&&m){const _=l;const S=J(_);D=ce(u.id,S,m,T.debugLogLevel)}v.trackRender({nativeTag:u.id,viewType:b.viewType,testID:b.testID,nativeID:b.nativeID,accessibilityLabel:b.accessibilityLabel,componentName:b.componentName,measurements:{x:u.x,y:u.y,width:u.width,height:u.height},color:E,count:I,renderCause:D})}}v.endBatch()}else{for(const{rect:u,stateNode:l,color:E,count:I}of d){if(u){const b=Y(l);let D;if(P&&m){const _=l;const S=J(_);D=ce(u.id,S,m,T.debugLogLevel)}v.emitRenderEvent({nativeTag:u.id,viewType:b.viewType,testID:b.testID,nativeID:b.nativeID,accessibilityLabel:b.accessibilityLabel,componentName:b.componentName,measurements:{x:u.x,y:u.y,width:u.width,height:u.height},color:E,count:I,renderCause:D})}}}o.markTrackingComplete();o.markCallbackComplete();o.finish()},0)}).catch(s=>{console.error("[HighlightUpdates] Error in measurement pipeline:",s);o.finish()})}const ye=globalThis.WeakRef;const G=new Map;function on(e,n){if(e==null||n==null||typeof n!=="object"){return}try{G.set(e,ye?new ye(n):{deref:()=>n})}catch{G.set(e,{deref:()=>n})}}function sn(e){const n=G.get(e);const i=n?.deref();if(!i)G.delete(e);return i??null}function ln(e){return new Promise(n=>{try{e.measure((i,o,r,a,t,c)=>{if(t==null||c==null||r==null||a==null){n(null)}else{n({x:t,y:c,width:r,height:a})}})}catch{n(null)}})}function J(e){const n=e;return n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||W(n)||null}function cn(e){let n=J(e);let i=0;while(n&&i++<200){const o=n.stateNode;if(o&&typeof o.scrollTo==="function"){const r=typeof o.getNativeScrollRef==="function"&&o.getNativeScrollRef()||null;const a=typeof o.getInnerViewNode==="function"&&o.getInnerViewNode()||typeof o.getScrollableNode==="function"&&o.getScrollableNode()||o;return{instance:o,nativeRef:r,innerNode:a}}n=n.return}return null}async function un(e,n,i){try{const o=cn(e);if(!o)return false;const r=n;let a=null;const t=c=>new Promise(p=>{let h=false;const s=g=>{if(h)return;h=true;p(g)};const d=setTimeout(()=>s(null),600);try{c(g=>{clearTimeout(d);s(g)})}catch{clearTimeout(d);s(null)}});if(o.nativeRef&&typeof r.measureLayout==="function"){a=await t(c=>r.measureLayout(o.nativeRef,(p,h)=>c(h),()=>c(null)))}if(a==null){const c=oe(n);const p=typeof o.innerNode==="number"?o.innerNode:oe(o.innerNode);if(c!=null&&p!=null){a=await t(h=>Ve.measureLayout(c,p,()=>h(null),(s,d)=>h(d)))}}if(a==null)return false;o.instance.scrollTo({y:Math.max(0,a-i),animated:false});await new Promise(c=>setTimeout(c,80));return true}catch{return false}}function fn(e,n){const i=[e.testID,e.nativeID,e.accessibilityLabel,e.componentName,e.viewType,String(e.nativeTag)];let o=0;for(const r of i){if(!r)continue;const a=r.toLowerCase();if(a===n)return 3;if(a.startsWith(n))o=Math.max(o,2);else if(a.includes(n))o=Math.max(o,1)}return o}async function dn(e){const n=e.scrollIntoView!==false;const i=typeof e.margin==="number"?e.margin:12;const o=v.getRenders();const r=async()=>{const l=await xe();const E=(e.query??"").trim().toLowerCase();let I;for(const _ of l.elements){if(e.nativeTag!=null&&_.nativeTag===e.nativeTag){I={el:_,score:1e3};break}const S=Ue({nativeTag:_.nativeTag,testID:_.testID,label:_.label,text:_.text,name:_.name,tap:_.tap},{query:E||void 0,nativeTag:e.nativeTag});if(S<=0)continue;if(!I||S>I.score)I={el:_,score:S}}if(!I?.el.frame){return{matched:false,reason:"no-match",candidates:[]}}const b=l.screen;const D=I.el.frame;return{matched:true,live:true,rect:{x:D.x*b.width,y:D.y*b.height,width:D.width*b.width,height:D.height*b.height},scale:se.get(),screen:{width:b.width,height:b.height},nativeTag:I.el.nativeTag??void 0,componentName:I.el.name,testID:I.el.testID}};if(o.length===0)return r();const a=(e.query??"").trim().toLowerCase();const t=a?o.map(l=>({r:l,score:fn(l,a)})).filter(l=>l.score>0).sort((l,E)=>E.score-l.score||E.r.lastRenderTime-l.r.lastRenderTime):[];const c=t.slice(0,8).map(({r:l})=>({nativeTag:l.nativeTag,componentName:l.componentName,testID:l.testID,nativeID:l.nativeID,viewType:l.viewType,renderCount:l.renderCount}));const p=e.nativeTag??(t.length>0?t[0].r.nativeTag:void 0);if(p==null){const l=await r();return l.matched?l:{matched:false,reason:"no-match",candidates:c}}const h=o.find(l=>l.nativeTag===p);let s=null;let d=false;let g=false;const T=sn(p);if(T){const l=M(T);if(l){if(n){g=await un(T,l,i)}s=await ln(l);d=!!s}}if(!s&&h?.measurements){s={...h.measurements}}if(!s){return{matched:false,reason:"no-measurement",nativeTag:p,candidates:c}}const P=se.get();const m=ze.get("window");const u=s.x>=-1&&s.y>=-1&&s.x+s.width<=m.width+1&&s.y+s.height<=m.height+1;return{matched:true,live:d,scrolled:g,inView:u,rect:s,scale:P,screen:{width:m.width,height:m.height},nativeTag:p,componentName:h?.componentName,testID:h?.testID,candidates:c}}function _e(e){if(!y?.rendererInterfaces){f("No rendererInterfaces available");return}let n=0;y.rendererInterfaces.forEach((i,o)=>{if(typeof i.setTraceUpdatesEnabled==="function"){try{i.setTraceUpdatesEnabled(e);n++;f(`Renderer ${o}: setTraceUpdatesEnabled(${e})`)}catch(r){f(`Renderer ${o}: error setting trace updates`,r)}}else{f(`Renderer ${o}: no setTraceUpdatesEnabled method`)}});f(`Set trace updates ${e?"enabled":"disabled"} on ${n} renderer(s)`);if(y.reactDevtoolsAgent?.setTraceUpdatesEnabled){try{y.reactDevtoolsAgent.setTraceUpdatesEnabled(e);f("Also set trace updates on agent")}catch(i){f("Error setting trace updates on agent",i)}}}function Te(){if(!y)return;if(z)return;f("Subscribing to traceUpdates event");if(typeof y.sub==="function"){z=y.sub("traceUpdates",an);f("Subscribed using hook.sub()")}else{f("hook.sub not available, traceUpdates may not work")}_e(true)}function Q(){_e(false);if(z){z();z=null;f("Unsubscribed from traceUpdates event")}}function Ie(e){O=e;f(`Highlight callback ${e?"set":"cleared"}`)}function gn(e){A=e;f(`Badge press callback ${e?"set":"cleared"}`)}function pn(){return A}function mn(e){if(A){A(e)}}let ee=null;let B=null;function bn(e){ee=e;if(e&&B!==null){e(B)}}function hn(e){if(C){C("setSpotlight",{nativeTag:e});return}B=e;if(ee){ee(e)}}let C=null;function yn(e){C=e}function _n(e){if(w!==e.enabled){w=e.enabled;ne()}if(k!==e.frozen){k=e.frozen;j()}}function Tn(){return B}function ne(){K.forEach(e=>{try{e(w)}catch(n){console.error("[HighlightUpdates] Error in state listener:",n)}})}function ve(e){K.add(e);e(w);return()=>{K.delete(e)}}function $(){if(typeof __DEV__!=="undefined"&&!__DEV__){f("Only available in development builds");return false}if(C){return true}if(N){return true}y=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null;if(!y){f("React DevTools hook not found");return false}f("Hook found");f(`Hook has sub: ${typeof y.sub==="function"}`);f(`Hook has on: ${typeof y.on==="function"}`);f(`Hook has emit: ${typeof y.emit==="function"}`);Le();if(y.rendererInterfaces&&y.rendererInterfaces.size>0){N=true;f(`Initialized with ${y.rendererInterfaces.size} renderer(s)`);we();return true}const e=setInterval(()=>{if(y?.rendererInterfaces&&y.rendererInterfaces.size>0){clearInterval(e);N=true;f(`Initialized with ${y.rendererInterfaces.size} renderer(s) (delayed)`);we()}},100);setTimeout(()=>clearInterval(e),1e4);return false}function we(){if(typeof window!=="undefined"){window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable:x,disable:U,toggle:De,isEnabled:Ce,setEnabled:ke,subscribe:ve,initialize:$,destroy:Se,isInitialized:()=>N,setHighlightCallback:Ie}}}function x(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!N){$()}if(V){V=false}if(w){return}f("Enabling highlights");if(!L){Te()}v.start();w=true;ne();ue("render")}function U(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!w){return}f("Disabling highlights");Xe=false;fe=false;if(Z){clearTimeout(Z);Z=null}ge.clear();H.clear();Fe();if(k){k=false;j()}if(!L){Q()}v.stop();w=false;ne();ue("render")}function In(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(L){return}if(!N){$()}f("Enabling background tracking");if(!w){Te()}L=true}function vn(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!L){return}f("Disabling background tracking");L=false;if(!w){Q()}}function wn(){return L}function De(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(C){C("toggle");return}if(w){U()}else{x()}}function Dn(){if(C){C("clearRenderCounts");return}q.clear();v.clear();f("Cleared render counts")}function Ce(){return w}function ke(e){if(C){C("setEnabled",{enabled:e});return}if(e)x();else U()}function te(e){if(V===e)return;V=e;if(e&&O){O([])}}function Cn(){return V}function kn(e){if(C){C("setSilentTracking",{enabled:e});return}if(e){x();te(true)}else{te(false);U()}}function En(){return N}function j(){F.forEach(e=>{try{e(k)}catch(n){console.error("[HighlightUpdates] Error in freeze listener:",n)}})}function Pn(e){F.add(e);e(k);return()=>{F.delete(e)}}function Ee(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(k)return;k=true;f("Freeze mode enabled");j()}function Pe(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!k)return;k=false;f("Freeze mode disabled");if(O){O([])}j()}function Sn(){if(C){C("toggleFreeze");return}if(k){Pe()}else{Ee()}}function Nn(){return k}function Se(){if(!N)return;Q();Re();He(null);k=false;F.clear();w=false;y=null;O=null;N=false;if(typeof window!=="undefined"){delete window.__HIGHLIGHT_UPDATES_CONTROLLER__}f("Destroyed")}const On={subscribe:ve,enable:x,disable:U,toggle:De,isEnabled:Ce,setEnabled:ke,initialize:$,destroy:Se,isInitialized:En,setHighlightCallback:Ie,clearRenderCounts:Dn,freeze:Ee,unfreeze:Pe,toggleFreeze:Sn,getFrozen:Nn,subscribeToFreeze:Pn,setBadgePressCallback:gn,getBadgePressCallback:pn,handleBadgePress:mn,setSpotlightCallback:bn,setSpotlight:hn,getSpotlight:Tn,clearDevToolsCache:Je,enableBackgroundTracking:In,disableBackgroundTracking:vn,isBackgroundTrackingEnabled:wn,setRemoteHandler:yn,replaceRemoteState:_n,locateComponent:dn,setHighlightsSuppressed:te,getHighlightsSuppressed:Cn,setSilentTracking:kn};export default On;
|
|
1
|
+
"use strict";import{getDOMFiber as K,getDOMNodeHandle as se,getDOMPublicInstance as Ve,isDOMElement as le}from"@buoy-gg/shared-ui/utils";"use strict";import{installProfilerInterceptor as ze,uninstallProfilerInterceptor as xe,setComparisonCallback as Ae}from"./ProfilerInterceptor";import{findNodeHandle as ce,UIManager as Ue,Dimensions as Fe,PixelRatio as ue}from"react-native";import{RenderTracker as y}from"./RenderTracker";import{describeScreen as Me}from"./screenElements";import{scoreTapMatch as Be}from"./tapMatch";import{PerformanceLogger as fe,markEventReceived as Ge}from"./PerformanceLogger";import{detectRenderCause as de,clearRenderCauseState as $e}from"./RenderCauseDetector";import{notifySubscriberCountChange as ge}from"@buoy-gg/shared-ui";import{HIGHLIGHT_OVERLAY_COMPONENTS as je,HIGHLIGHT_OVERLAY_PREFIXES as We,OTHER_DEV_TOOLS_COMPONENTS as Ke,OTHER_DEV_TOOLS_EXACT as qe,OTHER_DEV_TOOLS_PREFIXES as Xe,isCapturingBuoyToolRenders as Ye,isPerfMonitorComponentName as Ze}from"./devtoolsComponentNames";let v=false;let V=false;let O=false;let k=false;let T=null;let R=null;let B=null;let U=null;let pe=false;let E=false;const G=new Set;const q=new Set;const X=new Map;const Y=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"];const Je=false;function g(e,n){if(!Je)return;if(n!==void 0){console.log("[Buoy]",`[HighlightUpdates] ${e}`,n)}else{console.log("[Buoy]",`[HighlightUpdates] ${e}`)}}function $(e){const n=Ve(e);if(n)return n;if(!e)return null;const i=e;if(i.canonical?.publicInstance){return i.canonical.publicInstance}if(i.canonical&&typeof i.canonical.measure==="function"){return i.canonical}if(typeof i.measure==="function"){return i}return null}function L(e){const n=se(e);if(n!==null)return n;if(e==null)return null;const i=e;if(i.__nativeTag!=null)return i.__nativeTag;if(i._nativeTag!=null)return i._nativeTag;if(i.nativeTag!=null)return i.nativeTag;if(i.canonical){if(i.canonical.__nativeTag!=null)return i.canonical.__nativeTag;if(i.canonical._nativeTag!=null)return i.canonical._nativeTag;if(i.canonical.nativeTag!=null)return i.canonical.nativeTag}return null}function Z(e){const n=e;const i={viewType:"Unknown"};if(n?.canonical?.viewConfig?.uiViewClassName){i.viewType=n.canonical.viewConfig.uiViewClassName}else if(n?.viewConfig?.uiViewClassName){i.viewType=n.viewConfig.uiViewClassName}else if(le(n)){i.viewType=n.tagName.toLowerCase()}const o=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||K(n);const r=n?.canonical?.currentProps;const a=n?.canonical?.pendingProps;const t=o?.pendingProps;const c=o?.memoizedProps;i.testID=r?.testID||a?.testID||t?.testID||c?.testID||t?.["data-testid"]||c?.["data-testid"]||void 0;i.nativeID=r?.nativeID||a?.nativeID||t?.nativeID||c?.nativeID||t?.id||c?.id||void 0;i.accessibilityLabel=r?.accessibilityLabel||a?.accessibilityLabel||t?.accessibilityLabel||c?.accessibilityLabel||t?.["aria-label"]||c?.["aria-label"]||void 0;i.componentName=on(o)||void 0;return i}function jn(e){const n=e;const i=$(e);const o=L(e)||L(i);const r={nativeTag:o??"unknown",type:n?.canonical?"Fabric":"Legacy",hasMeasure:typeof i?.measure==="function"};if(n){r.stateNodeKeys=Object.keys(n).slice(0,20);if(n.node){r.nodeKeys=Object.keys(n.node).slice(0,20)}if(n.viewConfig){r.viewConfig={uiViewClassName:n.viewConfig.uiViewClassName,validAttributes:n.viewConfig.validAttributes?Object.keys(n.viewConfig.validAttributes).slice(0,10):void 0}}if(n.canonical){const a=n.canonical;r.canonicalKeys=Object.keys(a).slice(0,20);if(a.viewConfig){r.canonicalViewConfig={uiViewClassName:a.viewConfig.uiViewClassName}}if(a.nativeTag!=null){r.canonicalNativeTag=a.nativeTag}if(a.internalInstanceHandle){const t=a.internalInstanceHandle;r.fiberKeys=Object.keys(t).slice(0,30);if(t.type){r.fiberType=typeof t.type==="function"?t.type.name||t.type.displayName||"function":t.type}if(t.elementType){r.fiberElementType=typeof t.elementType==="function"?t.elementType.name||t.elementType.displayName||"function":t.elementType}if(t._debugOwner){const c=t._debugOwner;r.fiberDebugOwner=c.type?.name||c.type?.displayName||c.elementType?.name||"unknown"}if(t._debugSource){r.fiberDebugSource=t._debugSource}if(t.tag!=null){r.fiberTag=t.tag}if(t.pendingProps){if(t.pendingProps.nativeID)r.fiberPendingNativeID=t.pendingProps.nativeID;if(t.pendingProps.testID)r.fiberPendingTestID=t.pendingProps.testID}if(t.memoizedProps){if(t.memoizedProps.nativeID)r.fiberMemoizedNativeID=t.memoizedProps.nativeID;if(t.memoizedProps.testID)r.fiberMemoizedTestID=t.memoizedProps.testID}}if(a.publicInstance){const t=a.publicInstance;r.publicInstanceKeys=Object.keys(t).slice(0,20);if(t.nativeID!=null)r.nativeID=t.nativeID;if(t._nativeID!=null)r._nativeID=t._nativeID;if(t.props){r.publicInstanceProps=Object.keys(t.props).slice(0,15);if(t.props.nativeID)r.propsNativeID=t.props.nativeID;if(t.props.testID)r.propsTestID=t.props.testID;if(t.props.accessibilityLabel)r.accessibilityLabel=t.props.accessibilityLabel}}if(a.currentProps){r.currentPropsKeys=Object.keys(a.currentProps).slice(0,15);if(a.currentProps.nativeID!=null)r.currentPropsNativeID=a.currentProps.nativeID;if(a.currentProps.testID!=null)r.currentPropsTestID=a.currentProps.testID;if(a.currentProps.accessibilityLabel!=null)r.currentPropsAccessLabel=a.currentProps.accessibilityLabel}if(a.pendingProps){r.pendingPropsKeys=Object.keys(a.pendingProps).slice(0,15);if(a.pendingProps.nativeID!=null)r.pendingPropsNativeID=a.pendingProps.nativeID;if(a.pendingProps.testID!=null)r.pendingPropsTestID=a.pendingProps.testID}}if(n._debugOwner){const a=n._debugOwner;r.debugOwnerType=a.type?.name||a.type?.displayName||typeof a.type}if(n._debugSource){r.debugSource=n._debugSource}}return r}const me=false;let Qe=false;let J=null;const Wn=350;const be=new Set;function Kn(e){if(e==null)return false;return be.has(e)}const en=new Set(["highlight-updates-overlay","__rn_buoy__highlight-modal"]);const nn=new Set(["jsmodal-root","image-overlay-standalone","logbox_inspector","logbox"]);const z=new Map;const he=500;function tn(){z.clear()}function ye(e){if(!e)return false;if(en.has(e))return true;if(e.startsWith("__highlight_"))return true;return false}function _e(e){if(!e)return false;if(nn.has(e))return true;const n=e.charCodeAt(0);if(n===95){if(e.startsWith("__rn_buoy__"))return true}if(n===108&&e.startsWith("logbox")){return true}return false}function Te(e){if(!e)return null;const n=e.type;if(n){if(typeof n==="string")return n;if(n.displayName)return n.displayName;if(n.name)return n.name}const i=e.elementType;if(i){if(i.displayName)return i.displayName;if(i.name)return i.name}return null}const rn=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 an(e){if(!e)return true;if(rn.has(e))return true;if(e==="Unknown"||e==="Component")return true;if(e.startsWith("Animated"))return true;return false}function on(e){if(!e)return null;let n=e._debugOwner||e.return;let i=0;let o=null;while(n&&i<30){const r=Te(n);if(r&&typeof n.type!=="string"){if(!o){o=r}if(!an(r)){return r}}n=n.return;i++}return o}function sn(e){const n=e;const i=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||K(n);const o=L(e)||L(n?.canonical?.publicInstance);const r=Ye();const a=!r&&y.getSettings().excludeDevTools;if(a&&le(e)&&e.closest("[data-buoy-root]"))return true;if(o!=null&&a){const u=z.get(o);if(u!==void 0){return u}}let t=false;const c=i?.pendingProps?.nativeID||i?.memoizedProps?.nativeID||n?.canonical?.currentProps?.nativeID||null;if(ye(c)){t=true}else if(a&&_e(c)){t=true}if(!t&&i){let u=i;let b=0;while(u&&b<30){const s=Te(u);if(s){if(je.has(s)){t=true;break}for(const p of We){if(s.startsWith(p)){t=true;break}}if(t)break;if(r&&Ze(s)){t=true;break}if(a){if(Ke.has(s)||qe.has(s)){t=true;break}for(const p of Xe){if(s.startsWith(p)){t=true;break}}if(t)break}}const d=u.pendingProps?.nativeID||u.memoizedProps?.nativeID;if(ye(d)){t=true;break}if(a&&_e(d)){t=true;break}u=u.return;b++}}if(t&&o!=null&&a){if(z.size>=he){const u=Array.from(z.keys());for(let b=0;b<he/2;b++){z.delete(u[b])}}z.set(o,t)}return t}function Ie(e){const n=Math.min(e-1,Y.length-1);return Y[Math.max(0,n)]}function ln(e){if(e.size===0){return}if(!v&&!O){return}const n=y.getState();if(n.isPaused){return}if(fe.isEnabled()){Ge()}const i=y.getBatchSize();const o=fe.startBatch(e.size,i);const r=[];let a=0;let t=0;const c=y.hasActiveFilters();for(const s of e){if(s&&typeof s==="object"){try{if(sn(s)){a++;continue}const d=$(s);const p=L(s)||L(d);if(p==null){continue}const _=Z(s);if(c&&!y.passesFilters(_)){t++;continue}const S=y.getSettings().showRenderCount;let m;let f;if(S){const l=X.get(p)||0;m=l+1;X.set(p,m);f=Ie(m)}else{m=0;f=Y[0]}r.push({node:s,color:f,count:m})}catch{}}}o.markFilteringComplete(a+t,r.length);if(r.length===0){o.finish();return}if(me){console.log("[Buoy]",`[HighlightUpdates] ${r.length} component(s) re-rendered`)}const u=y.getRenderEventCallbackCount()>0;if(!R&&!u){if(me){console.log("[Buoy]",`[HighlightUpdates] No highlightCallback and no event callbacks - skipping render`)}pe=false;return}o.markMeasurementStart();const b=r.slice(0,i*4).map(({node:s,color:d,count:p})=>new Promise(_=>{let S=false;const m=h=>{if(S)return;S=true;clearTimeout(f);_(h)};const f=setTimeout(()=>m({rect:null,stateNode:s,color:d,count:p}),500);const l=$(s);const P=L(s)||L(l);if(P==null){m({rect:null,stateNode:s,color:d,count:p});return}const w=(h,D,I,N,ae,oe)=>{if(ae==null||oe==null||I==null||N==null){m({rect:null,stateNode:s,color:d,count:p});return}m({rect:{id:P,x:ae,y:oe,width:I,height:N,color:d,count:p},stateNode:s,color:d,count:p})};if(!l){const h=s.node;const D=globalThis.nativeFabricUIManager;if(h&&D?.measure){try{D.measure(h,w)}catch(I){m({rect:null,stateNode:s,color:d,count:p})}return}m({rect:null,stateNode:s,color:d,count:p});return}try{l.measure(w)}catch(h){m({rect:null,stateNode:s,color:d,count:p})}}));Promise.all(b).then(s=>{const d=s.filter(_=>_.rect!==null);const p=d.map(_=>_.rect);o.markMeasurementComplete(d.length,s.length-d.length);if(p.length>0&&R&&v&&!V){R(p)}setTimeout(()=>{try{for(const f of d){if(f.rect)we(f.rect.id,f.stateNode)}}catch(f){g("registerTrackedNode batch failed",f)}const _=y.getSettings();const S=_.trackRenderCauses&&_.showRenderCount;let m=null;if(S){m=new Set;for(const{rect:f}of d){if(f){m.add(f.id)}}}if(v){y.startBatch();for(const{rect:f,stateNode:l,color:P,count:w}of d){if(f){const h=Z(l);let D;if(S&&m){const I=l;const N=Q(I);D=de(f.id,N,m,_.debugLogLevel)}y.trackRender({nativeTag:f.id,viewType:h.viewType,testID:h.testID,nativeID:h.nativeID,accessibilityLabel:h.accessibilityLabel,componentName:h.componentName,measurements:{x:f.x,y:f.y,width:f.width,height:f.height},color:P,count:w,renderCause:D})}}y.endBatch()}else{for(const{rect:f,stateNode:l,color:P,count:w}of d){if(f){const h=Z(l);let D;if(S&&m){const I=l;const N=Q(I);D=de(f.id,N,m,_.debugLogLevel)}y.emitRenderEvent({nativeTag:f.id,viewType:h.viewType,testID:h.testID,nativeID:h.nativeID,accessibilityLabel:h.accessibilityLabel,componentName:h.componentName,measurements:{x:f.x,y:f.y,width:f.width,height:f.height},color:P,count:w,renderCause:D})}}}o.markTrackingComplete();o.markCallbackComplete();o.finish()},0)}).catch(s=>{console.error("[Buoy]","[HighlightUpdates] Error in measurement pipeline:",s);o.finish()})}const ve=globalThis.WeakRef;const x=new Map;function we(e,n){if(e==null||n==null||typeof n!=="object"){return}try{x.set(e,ve?new ve(n):{deref:()=>n})}catch{x.set(e,{deref:()=>n})}}function cn(e){const n=x.get(e);const i=n?.deref();if(!i)x.delete(e);return i??null}function un(e){return new Promise(n=>{try{e.measure((i,o,r,a,t,c)=>{if(t==null||c==null||r==null||a==null){n(null)}else{n({x:t,y:c,width:r,height:a})}})}catch{n(null)}})}function Q(e){const n=e;return n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV||K(n)||null}function fn(e){let n=Q(e);let i=0;while(n&&i++<200){const o=n.stateNode;if(o&&typeof o.scrollTo==="function"){const r=typeof o.getNativeScrollRef==="function"&&o.getNativeScrollRef()||null;const a=typeof o.getInnerViewNode==="function"&&o.getInnerViewNode()||typeof o.getScrollableNode==="function"&&o.getScrollableNode()||o;return{instance:o,nativeRef:r,innerNode:a}}n=n.return}return null}async function dn(e,n,i){try{const o=fn(e);if(!o)return false;const r=n;let a=null;const t=c=>new Promise(u=>{let b=false;const s=p=>{if(b)return;b=true;u(p)};const d=setTimeout(()=>s(null),600);try{c(p=>{clearTimeout(d);s(p)})}catch{clearTimeout(d);s(null)}});if(o.nativeRef&&typeof r.measureLayout==="function"){a=await t(c=>r.measureLayout(o.nativeRef,(u,b)=>c(b),()=>c(null)))}if(a==null){const c=ce(n);const u=typeof o.innerNode==="number"?o.innerNode:ce(o.innerNode);if(c!=null&&u!=null){a=await t(b=>Ue.measureLayout(c,u,()=>b(null),(s,d)=>b(d)))}}if(a==null)return false;o.instance.scrollTo({y:Math.max(0,a-i),animated:false});await new Promise(c=>setTimeout(c,80));return true}catch{return false}}function gn(e,n){const i=[e.testID,e.nativeID,e.accessibilityLabel,e.componentName,e.viewType,String(e.nativeTag)];let o=0;for(const r of i){if(!r)continue;const a=r.toLowerCase();if(a===n)return 3;if(a.startsWith(n))o=Math.max(o,2);else if(a.includes(n))o=Math.max(o,1)}return o}async function pn(e){const n=e.scrollIntoView!==false;const i=typeof e.margin==="number"?e.margin:12;const o=y.getRenders();const r=async()=>{const l=await Me();const P=(e.query??"").trim().toLowerCase();let w;for(const I of l.elements){if(e.nativeTag!=null&&I.nativeTag===e.nativeTag){w={el:I,score:1e3};break}const N=Be({nativeTag:I.nativeTag,testID:I.testID,label:I.label,text:I.text,name:I.name,tap:I.tap},{query:P||void 0,nativeTag:e.nativeTag});if(N<=0)continue;if(!w||N>w.score)w={el:I,score:N}}if(!w?.el.frame){return{matched:false,reason:"no-match",candidates:[]}}const h=l.screen;const D=w.el.frame;return{matched:true,live:true,rect:{x:D.x*h.width,y:D.y*h.height,width:D.width*h.width,height:D.height*h.height},scale:ue.get(),screen:{width:h.width,height:h.height},nativeTag:w.el.nativeTag??void 0,componentName:w.el.name,testID:w.el.testID}};if(o.length===0)return r();const a=(e.query??"").trim().toLowerCase();const t=a?o.map(l=>({r:l,score:gn(l,a)})).filter(l=>l.score>0).sort((l,P)=>P.score-l.score||P.r.lastRenderTime-l.r.lastRenderTime):[];const c=t.slice(0,8).map(({r:l})=>({nativeTag:l.nativeTag,componentName:l.componentName,testID:l.testID,nativeID:l.nativeID,viewType:l.viewType,renderCount:l.renderCount}));const u=e.nativeTag??(t.length>0?t[0].r.nativeTag:void 0);if(u==null){const l=await r();return l.matched?l:{matched:false,reason:"no-match",candidates:c}}const b=o.find(l=>l.nativeTag===u);let s=null;let d=false;let p=false;const _=cn(u);if(_){const l=$(_);if(l){if(n){p=await dn(_,l,i)}s=await un(l);d=!!s}}if(!s&&b?.measurements){s={...b.measurements}}if(!s){return{matched:false,reason:"no-measurement",nativeTag:u,candidates:c}}const S=ue.get();const m=Fe.get("window");const f=s.x>=-1&&s.y>=-1&&s.x+s.width<=m.width+1&&s.y+s.height<=m.height+1;return{matched:true,live:d,scrolled:p,inView:f,rect:s,scale:S,screen:{width:m.width,height:m.height},nativeTag:u,componentName:b?.componentName,testID:b?.testID,candidates:c}}function De(e){if(!T?.rendererInterfaces){g("No rendererInterfaces available");return}let n=0;T.rendererInterfaces.forEach((i,o)=>{if(typeof i.setTraceUpdatesEnabled==="function"){try{i.setTraceUpdatesEnabled(e);n++;g(`Renderer ${o}: setTraceUpdatesEnabled(${e})`)}catch(r){g(`Renderer ${o}: error setting trace updates`,r)}}else{g(`Renderer ${o}: no setTraceUpdatesEnabled method`)}});g(`Set trace updates ${e?"enabled":"disabled"} on ${n} renderer(s)`);if(T.reactDevtoolsAgent?.setTraceUpdatesEnabled){try{T.reactDevtoolsAgent.setTraceUpdatesEnabled(e);g("Also set trace updates on agent")}catch(i){g("Error setting trace updates on agent",i)}}}function Ce(){if(!T)return;if(U)return;g("Subscribing to traceUpdates event");if(typeof T.sub==="function"){U=T.sub("traceUpdates",ln);g("Subscribed using hook.sub()")}else{g("hook.sub not available, traceUpdates may not work")}De(true)}function ee(){De(false);if(U){U();U=null;g("Unsubscribed from traceUpdates event")}}function Se(e){R=e;g(`Highlight callback ${e?"set":"cleared"}`)}function mn(e){B=e;g(`Badge press callback ${e?"set":"cleared"}`)}function bn(){return B}function hn(e){if(B){B(e)}}let ne=null;let j=null;function yn(e){ne=e;if(e&&j!==null){e(j)}}function _n(e){if(C){C("setSpotlight",{nativeTag:e});return}j=e;if(ne){ne(e)}}let C=null;function Tn(e){C=e}function In(e){if(v!==e.enabled){v=e.enabled;te()}if(E!==e.frozen){E=e.frozen;W()}}function vn(){return j}function te(){q.forEach(e=>{try{e(v)}catch(n){console.error("[Buoy]","[HighlightUpdates] Error in state listener:",n)}})}function ke(e){q.add(e);e(v);return()=>{q.delete(e)}}function wn(e){if(typeof __DEV__!=="undefined"&&!__DEV__){return{recordRenders:()=>{},disconnect:()=>{}}}if(H!==void 0||k)throw new Error("Connect the render source before Highlight starts.");H=e;let n=true;const i=new Set;F();return{recordRenders(o){if(!n||!e||!v||y.getState().isPaused)return;const r=[];y.startBatch();try{for(const{host:a,name:t,count:c}of o){if(!a.isConnected)continue;const u=se(a);if(u===null)continue;const b=(y.getRender(String(u))?.renderCount??0)+c;const s=Ie(b);const{x:d,y:p,width:_,height:S}=a.getBoundingClientRect();const m={x:d,y:p,width:_,height:S};y.trackRender({nativeTag:u,viewType:t,componentName:t,isComponent:true,testID:a.getAttribute("data-testid")??void 0,measurements:m,color:s,count:b});we(u,a);i.add(u);if(_>0&&S>0)r.push({id:u,...m,color:s,count:y.getSettings().showRenderCount?b:0})}}finally{y.endBatch()}for(const a of i){if(!y.getRender(String(a))){i.delete(a);x.delete(a)}}if(!V&&r.length)R?.(r)},disconnect(){if(!n)return;n=false;A();R?.([]);Pe();for(const o of i)x.delete(o);i.clear();H=void 0;k=false}}}let H;function Dn(){return H===void 0?void 0:H?"ready":"unavailable"}function F(){if(typeof __DEV__!=="undefined"&&!__DEV__){g("Only available in development builds");return false}if(C){return true}if(k){return true}if(H!==void 0){k=H;ie();return k}T=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null;if(!T){g("React DevTools hook not found");return false}g("Hook found");g(`Hook has sub: ${typeof T.sub==="function"}`);g(`Hook has on: ${typeof T.on==="function"}`);g(`Hook has emit: ${typeof T.emit==="function"}`);ze();if(T.rendererInterfaces&&T.rendererInterfaces.size>0){k=true;g(`Initialized with ${T.rendererInterfaces.size} renderer(s)`);ie();return true}const e=setInterval(()=>{if(T?.rendererInterfaces&&T.rendererInterfaces.size>0){clearInterval(e);k=true;g(`Initialized with ${T.rendererInterfaces.size} renderer(s) (delayed)`);ie()}},100);setTimeout(()=>clearInterval(e),1e4);return false}function ie(){if(typeof window!=="undefined"){window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable:M,disable:A,toggle:Ee,isEnabled:Re,setEnabled:Ne,subscribe:ke,initialize:F,destroy:He,isInitialized:()=>k,setHighlightCallback:Se}}}function M(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(H===false)return;if(!k){F()}if(V){V=false}if(v){return}g("Enabling highlights");if(!O){Ce()}y.start();v=true;te();ge("render")}function A(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!v){return}g("Disabling highlights");Qe=false;pe=false;if(J){clearTimeout(J);J=null}be.clear();z.clear();$e();if(E){E=false;W()}if(!O){ee()}y.stop();v=false;te();ge("render")}function Cn(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(O){return}if(!k){F()}g("Enabling background tracking");if(!v){Ce()}O=true}function Sn(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!O){return}g("Disabling background tracking");O=false;if(!v){ee()}}function kn(){return O}function Ee(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(C){C("toggle");return}if(v){A()}else{M()}}function Pe(){if(C){C("clearRenderCounts");return}X.clear();y.clear();g("Cleared render counts")}function Re(){return v}function Ne(e){if(C){C("setEnabled",{enabled:e});return}if(e)M();else A()}function re(e){if(V===e)return;V=e;if(e&&R){R([])}}function En(){return V}function Pn(e){if(C){C("setSilentTracking",{enabled:e});return}if(e){M();re(true)}else{re(false);A()}}function Rn(){return k}function W(){G.forEach(e=>{try{e(E)}catch(n){console.error("[Buoy]","[HighlightUpdates] Error in freeze listener:",n)}})}function Nn(e){G.add(e);e(E);return()=>{G.delete(e)}}function Oe(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(E)return;E=true;g("Freeze mode enabled");W()}function Le(){if(typeof __DEV__!=="undefined"&&!__DEV__)return;if(!E)return;E=false;g("Freeze mode disabled");if(R){R([])}W()}function On(){if(C){C("toggleFreeze");return}if(E){Le()}else{Oe()}}function Ln(){return E}function He(){if(!k)return;ee();xe();Ae(null);E=false;G.clear();v=false;T=null;R=null;k=false;if(typeof window!=="undefined"){delete window.__HIGHLIGHT_UPDATES_CONTROLLER__}g("Destroyed")}const Hn={connectRenderSource:wn,getRenderSourceStatus:Dn,subscribe:ke,enable:M,disable:A,toggle:Ee,isEnabled:Re,setEnabled:Ne,initialize:F,destroy:He,isInitialized:Rn,setHighlightCallback:Se,clearRenderCounts:Pe,freeze:Oe,unfreeze:Le,toggleFreeze:On,getFrozen:Ln,subscribeToFreeze:Nn,setBadgePressCallback:mn,getBadgePressCallback:bn,handleBadgePress:hn,setSpotlightCallback:yn,setSpotlight:_n,getSpotlight:vn,clearDevToolsCache:tn,enableBackgroundTracking:Cn,disableBackgroundTracking:Sn,isBackgroundTrackingEnabled:kn,setRemoteHandler:Tn,replaceRemoteState:In,locateComponent:pn,setHighlightsSuppressed:re,getHighlightsSuppressed:En,setSilentTracking:Pn};export default Hn;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";let S=0;let p=null;export function markEventReceived(){S=performance.now();return S}export function markOverlayRendered(f,t){if(S>0&&f>0){S=0}}class b{enabled=false;batchCounter=0;listeners=new Set;rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0};recentBatches=[];MAX_HISTORY=100;summaryInterval=null;SUMMARY_INTERVAL_MS=1e4;setEnabled(t){const a=this.enabled;this.enabled=t;if(t&&!a){this.resetStats()}else if(!t&&a){this.stopSummaryInterval()}}isEnabled(){return this.enabled}startBatch(t,a){const i=`batch_${++this.batchCounter}`;const h=performance.now();let o=null;let l=null;let r=null;let s=null;let e=null;let n=0;let m=0;let
|
|
1
|
+
"use strict";let S=0;let p=null;export function markEventReceived(){S=performance.now();return S}export function markOverlayRendered(f,t){if(S>0&&f>0){S=0}}class b{enabled=false;batchCounter=0;listeners=new Set;rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0};recentBatches=[];MAX_HISTORY=100;summaryInterval=null;SUMMARY_INTERVAL_MS=1e4;setEnabled(t){const a=this.enabled;this.enabled=t;if(t&&!a){this.resetStats()}else if(!t&&a){this.stopSummaryInterval()}}isEnabled(){return this.enabled}startBatch(t,a){const i=`batch_${++this.batchCounter}`;const h=performance.now();let o=null;let l=null;let r=null;let s=null;let e=null;let n=0;let m=0;let g=0;let T=0;let u;const F={markFilteringComplete:(c,d)=>{o=performance.now();n=c;m=d},markMeasurementStart:()=>{l=performance.now()},markMeasurementComplete:(c,d)=>{r=performance.now();g=c;T=d},markTrackingComplete:()=>{s=performance.now()},markCallbackComplete:()=>{e=performance.now()},setOverlayRenderTime:c=>{u=c},getBatchId:()=>i,finish:()=>{const c=performance.now();const d={batchId:i,timestamp:Date.now(),nodesReceived:t,nodesFiltered:n,nodesToProcess:m,batchSize:a,nodesInBatch:Math.min(m,a),filteringTime:o?o-h:0,measurementTime:l&&r?r-l:0,trackingTime:r&&s?s-r:0,callbackTime:s&&e?e-s:0,totalTime:c-h,measurementSuccessCount:g,measurementFailCount:T,overlayRenderTime:u};if(this.enabled){this.recordMetrics(d)}return d}};return F}recordMetrics(t){this.rollingStats.batchCount++;this.rollingStats.totalNodes+=t.nodesReceived;this.rollingStats.totalFiltered+=t.nodesFiltered;this.rollingStats.totalProcessed+=t.nodesInBatch;this.rollingStats.totalTime+=t.totalTime;this.rollingStats.maxTime=Math.max(this.rollingStats.maxTime,t.totalTime);this.rollingStats.minTime=Math.min(this.rollingStats.minTime,t.totalTime);const a=this.rollingStats.avgMeasurementTime;const i=this.rollingStats.batchCount;this.rollingStats.avgMeasurementTime=a+(t.measurementTime-a)/i;this.recentBatches.push(t);if(this.recentBatches.length>this.MAX_HISTORY){this.recentBatches.shift()}this.notifyListeners(t)}logBatch(t){const{batchId:a,nodesReceived:i,nodesFiltered:h,nodesInBatch:o,batchSize:l,filteringTime:r,measurementTime:s,trackingTime:e,callbackTime:n,totalTime:m,measurementSuccessCount:g,measurementFailCount:T,overlayRenderTime:u}=t;console.log("[Buoy]",`[HighlightPerf] ${a} | In:${i} Filt:${h} Proc:${o}/${l} | Filter:${r.toFixed(1)}ms Measure:${s.toFixed(1)}ms Track:${e.toFixed(1)}ms Callback:${n.toFixed(1)}ms | Total:${m.toFixed(1)}ms`+(u?` Render:${u.toFixed(1)}ms`:"")+` | Success:${g} Fail:${T}`);if(m>100){console.warn("[Buoy]",`[HighlightPerf] \u26A0\uFE0F SLOW BATCH: ${m.toFixed(1)}ms - Measurement phase: ${s.toFixed(1)}ms (${(s/m*100).toFixed(0)}%)`)}}logSummary(){if(this.rollingStats.batchCount===0)return;const t=this.rollingStats;const a=t.totalTime/t.batchCount;const i=t.totalNodes/t.batchCount;console.log("[Buoy]",`
|
|
2
2
|
[HighlightPerf] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 SUMMARY (last ${this.SUMMARY_INTERVAL_MS/1e3}s) \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
3
3
|
Batches: ${t.batchCount}
|
|
4
4
|
Avg nodes/batch: ${i.toFixed(1)} (filtered: ${(t.totalFiltered/t.batchCount).toFixed(1)})
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
Avg measurement time: ${t.avgMeasurementTime.toFixed(1)}ms
|
|
7
7
|
Min/Max time: ${t.minTime.toFixed(1)}ms / ${t.maxTime.toFixed(1)}ms
|
|
8
8
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
9
|
-
`);this.resetStats()}resetStats(){this.rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0}}startSummaryInterval(){this.stopSummaryInterval();this.summaryInterval=setInterval(()=>{this.logSummary()},this.SUMMARY_INTERVAL_MS)}stopSummaryInterval(){if(this.summaryInterval){clearInterval(this.summaryInterval);this.summaryInterval=null}}subscribe(t){this.listeners.add(t);return()=>{this.listeners.delete(t)}}notifyListeners(t){for(const a of this.listeners){try{a(t)}catch(i){console.error("[HighlightPerf] Error in metrics listener:",i)}}}getRecentBatches(){return[...this.recentBatches]}getRollingStats(){return{...this.rollingStats}}clear(){this.recentBatches=[];this.resetStats();this.batchCounter=0}generateReport(){const t=this.recentBatches;if(t.length===0){return"No performance data collected yet."}const a=t.reduce((e,n)=>e+n.totalTime,0);const i=a/t.length;const h=t.reduce((e,n)=>e+n.measurementTime,0);const o=h/t.length;const l=t.filter(e=>e.totalTime>100);const r=t.filter(e=>e.totalTime<20);const s=`
|
|
9
|
+
`);this.resetStats()}resetStats(){this.rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0}}startSummaryInterval(){this.stopSummaryInterval();this.summaryInterval=setInterval(()=>{this.logSummary()},this.SUMMARY_INTERVAL_MS)}stopSummaryInterval(){if(this.summaryInterval){clearInterval(this.summaryInterval);this.summaryInterval=null}}subscribe(t){this.listeners.add(t);return()=>{this.listeners.delete(t)}}notifyListeners(t){for(const a of this.listeners){try{a(t)}catch(i){console.error("[Buoy]","[HighlightPerf] Error in metrics listener:",i)}}}getRecentBatches(){return[...this.recentBatches]}getRollingStats(){return{...this.rollingStats}}clear(){this.recentBatches=[];this.resetStats();this.batchCounter=0}generateReport(){const t=this.recentBatches;if(t.length===0){return"No performance data collected yet."}const a=t.reduce((e,n)=>e+n.totalTime,0);const i=a/t.length;const h=t.reduce((e,n)=>e+n.measurementTime,0);const o=h/t.length;const l=t.filter(e=>e.totalTime>100);const r=t.filter(e=>e.totalTime<20);const s=`
|
|
10
10
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
11
11
|
\u2551 HIGHLIGHT UPDATES PERFORMANCE REPORT \u2551
|
|
12
12
|
\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let a=null;let c=null;let l=false;let s=false;let f=null;function u(n){if(!n)return{type:"null"};const e=n;const t={};if(e.canonical){t.type="Fabric";const o=e.canonical;if(o.publicInstance){const r=o.publicInstance;t.hasMeasure=typeof r.measure==="function";t.nativeTag=r.__nativeTag??r._nativeTag??"unknown"}}else if(typeof e.measure==="function"){t.type="Legacy";t.hasMeasure=true;t.nativeTag=e.__nativeTag??e._nativeTag??e.nativeTag??"unknown"}else{t.type="Unknown";t.keys=Object.keys(e).slice(0,10)}return t}function p(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n||typeof n.emit!=="function"){return}if(a){return}a=n.emit.bind(n);n.emit=function(e,...t){if(e==="traceUpdates"&&s){const o=t[0];if(o.size>0){console.log(
|
|
1
|
+
"use strict";let a=null;let c=null;let l=false;let s=false;let f=null;function u(n){if(!n)return{type:"null"};const e=n;const t={};if(e.canonical){t.type="Fabric";const o=e.canonical;if(o.publicInstance){const r=o.publicInstance;t.hasMeasure=typeof r.measure==="function";t.nativeTag=r.__nativeTag??r._nativeTag??"unknown"}}else if(typeof e.measure==="function"){t.type="Legacy";t.hasMeasure=true;t.nativeTag=e.__nativeTag??e._nativeTag??e.nativeTag??"unknown"}else{t.type="Unknown";t.keys=Object.keys(e).slice(0,10)}return t}function p(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n||typeof n.emit!=="function"){return}if(a){return}a=n.emit.bind(n);n.emit=function(e,...t){if(e==="traceUpdates"&&s){const o=t[0];if(o.size>0){console.log("[Buoy]",`[PROFILER] traceUpdates: ${o.size} nodes`,Array.from(o).map((r,i)=>({index:i,...u(r)})))}if(f){f(o)}}return a(e,...t)}}function g(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;const e=n?.reactDevtoolsAgent;if(!e||typeof e.emit!=="function"){return}if(c){return}c=e.emit.bind(e);e.emit=function(t,...o){if(s&&t==="drawTraceUpdates"){const r=o[0];if(r.length>0){console.log("[Buoy]",`[PROFILER] drawTraceUpdates: ${r.length} nodes`,r.map((i,d)=>({index:d,color:i.color,...u(i.node)})))}}return c(t,...o)}}export function logRendererInterfaces(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces){console.log("[Buoy]","[ProfilerInterceptor] No rendererInterfaces available");return}const e=[];n.rendererInterfaces.forEach((t,o)=>{const r=Object.keys(t).filter(i=>typeof t[i]==="function");e.push({id:o,hasSetTraceUpdatesEnabled:typeof t.setTraceUpdatesEnabled==="function",methods:r.slice(0,20)})});console.log("[Buoy]",`[ProfilerInterceptor] Found ${n.rendererInterfaces.size} renderer interface(s)`,e)}export function logHookStructure(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n){console.log("[Buoy]","[ProfilerInterceptor] No hook available");return}const e={};for(const t in n){const o=n[t];if(typeof o==="function"){e[t]="function"}else if(o instanceof Map){e[t]=`Map(${o.size})`}else if(o instanceof Set){e[t]=`Set(${o.size})`}else if(typeof o==="object"&&o!==null){e[t]="object"}else{e[t]=typeof o}}console.log("[Buoy]","[ProfilerInterceptor] Hook structure:",e)}function O(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces){return}n.rendererInterfaces.forEach(e=>{if(typeof e.setTraceUpdatesEnabled==="function"){try{e.setTraceUpdatesEnabled(true)}catch{}}})}function _(){const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!n?.rendererInterfaces)return;n.rendererInterfaces.forEach(e=>{if(typeof e.setTraceUpdatesEnabled==="function"){try{e.setTraceUpdatesEnabled(false)}catch{}}})}export function setComparisonCallback(n){f=n}export function installProfilerInterceptor(){if(typeof __DEV__!=="undefined"&&!__DEV__){return}if(l){return}p();g();l=true}export function uninstallProfilerInterceptor(){if(!l)return;const n=window.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(a&&n){n.emit=a;a=null}if(c&&n?.reactDevtoolsAgent){n.reactDevtoolsAgent.emit=c;c=null}_();f=null;l=false}export function isInterceptorInstalled(){return l}export function enableProfilerLogging(){s=true}export function disableProfilerLogging(){s=false}export function isLoggingEnabled(){return s}export default{install:installProfilerInterceptor,uninstall:uninstallProfilerInterceptor,isInstalled:isInterceptorInstalled,setComparisonCallback,enableTracing:O,disableTracing:_,enableLogging:enableProfilerLogging,disableLogging:disableProfilerLogging,isLoggingEnabled};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";import{hookStateChanged as
|
|
2
|
-
[RN-BUOY RENDER DEBUG] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);console.log(
|
|
3
|
-
`);console.log(
|
|
1
|
+
"use strict";import{hookStateChanged as ue}from"./ownStateChanged";const Y={RCTText:{alwaysTrack:["children"],skip:[],description:"Text component - children is the displayed content"},RCTVirtualText:{alwaysTrack:["children"],skip:[],description:"Virtual Text (nested) - children is the displayed content"},RCTView:{alwaysTrack:[],skip:["children"],description:"View container - children are React elements"},RCTImageView:{alwaysTrack:["source"],skip:["children"],description:"Image - source contains the image URL/require"},RCTTextInput:{alwaysTrack:["value","defaultValue"],skip:["children"],description:"TextInput - value is the input content"},RCTSwitch:{alwaysTrack:["value"],skip:["children"],description:"Switch - value is the toggle state"},default:{alwaysTrack:[],skip:["children"],description:"Unknown component type"}};function ae(e){if(!e)return Y.default;return Y[e]||Y.default}const U=new WeakMap;function G(e){if(!e)return void 0;let t=U.get(e);if(t)return t;if(e.alternate){t=U.get(e.alternate);if(t)return t}return void 0}function fe(e,t){if(!e)return;U.set(e,t);if(e.alternate){U.set(e.alternate,t)}}const $=new Map;const J=500;const de=10;const Q=50;const F=50;const ye=new Set(["View","Text","TextImpl","Image","ScrollView","FlatList","SectionList","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","Pressable","TextInput","Switch","ActivityIndicator","Modal","StatusBar","KeyboardAvoidingView","AnimatedComponent","AnimatedComponentWrapper","Fragment","Suspense","Provider","Consumer","Context","ForwardRef","Unknown","Component"]);function L(e){if(!e)return true;if(ye.has(e))return true;if(e.startsWith("Animated"))return true;return false}function b(e){if(!e)return null;let t=e._debugOwner||e.return;let o=0;let r=null;while(t&&o<30){const n=t.tag;if(n===0||n===1||n===11||n===15){const s=C(t);if(!r){r=t}if(!L(s)){return t}}t=t.return;o++}return r}function C(e){if(!e)return null;const t=e.type;if(t){if(typeof t==="string")return t;if(t.displayName)return t.displayName;if(t.name)return t.name}return null}function me(e){if(!e||typeof e!=="object"){return"unknown"}if(e.queue!==null&&e.queue!==void 0){return"useState"}const t=e.memoizedState;if(t!==null&&typeof t==="object"&&!Array.isArray(t)&&"current"in t&&Object.keys(t).length===1){return"useRef"}if(Array.isArray(t)&&t.length===2){const[,o]=t;if(Array.isArray(o)||o===null){if(typeof t[0]==="function"){return"useCallback"}return"useMemo"}}if(t!==null&&typeof t==="object"&&!Array.isArray(t)&&("tag"in t||"create"in t||"destroy"in t)){return"useEffect"}return"unknown"}function pe(e,t){const o=e?.memoizedState;switch(t){case"useState":case"useReducer":return o;case"useRef":return o?.current;case"useMemo":case"useCallback":return Array.isArray(o)?o[0]:o;case"useEffect":return"[effect]";default:return o}}function R(e){if(!e?.memoizedState)return null;const t=e.memoizedState;if(typeof t!=="object"||t===null){return null}if(!("next"in t)&&!("queue"in t)&&!("memoizedState"in t)){return null}const o=[];let r=t;let n=0;while(r!==null&&n<Q){const s=me(r);const i=pe(r,s);o.push({index:n,type:s,value:i,rawState:r.memoizedState});r=r.next;n++}return o.length>0?o:null}function ge(e,t){if(!e||!t)return null;const o=[];const r=Math.max(e.length,t.length);for(let n=0;n<r;n++){const s=e[n];const i=t[n];if(!s&&i){o.push({index:n,type:i.type,currentValue:j(i.value,i.type),description:`Hook[${n}] added`});continue}if(s&&!i){o.push({index:n,type:s.type,previousValue:j(s.value,s.type),description:`Hook[${n}] removed`});continue}if(s&&i){if(s.rawState===i.rawState){continue}if(i.type==="useEffect"){continue}if(i.type==="useMemo"||i.type==="useCallback"){continue}if(i.type==="useState"||i.type==="useReducer"||i.type==="useRef"){const u=j(s.value,s.type);const l=j(i.value,i.type);o.push({index:n,type:i.type,previousValue:u,currentValue:l,description:`${u} \u2192 ${l}`})}}}return o.length>0?o:null}function j(e,t){if(t==="useRef"){return T(e)}return T(e)}function T(e){if(e===null)return null;if(e===void 0)return void 0;if(typeof e==="boolean")return e;if(typeof e==="number")return e;if(typeof e==="string"){return e.length>30?e.slice(0,30)+"...":e}if(typeof e==="function"){return`[Function: ${e.name||"anonymous"}]`}if(Array.isArray(e)){return`[Array: ${e.length} items]`}if(typeof e==="object"){const t=Object.keys(e);return`{Object: ${t.length} keys}`}return String(e)}function he(e){if(!e)return{cause:"unknown",hookChanges:null};let t=e;let o=e.alternate;const r=G(e);if(r&&o){const a=R(e);const k=R(o);const g=r.extractedHooks;if(a&&k&&g&&g.length>0){const y=g.find(f=>f.type==="useState");if(y){const f=a.find(d=>d.index===y.index);const S=k.find(d=>d.index===y.index);if(f&&S){const d=f.value===y.value;const m=S.value===y.value;if(d&&!m){t=o;o=e}}}}}const n=R(t);let s=null;let i=null;let u=null;if(o){s=o.memoizedProps;i=o.memoizedState;u=R(o)}else{if(r){s=r.memoizedProps;i=r.memoizedState;u=r.extractedHooks}}fe(t,{memoizedProps:t.memoizedProps,memoizedState:t.memoizedState,extractedHooks:n});if(s===null){return{cause:"mount",hookChanges:null}}const l=!Z(s,t.memoizedProps);if(l){return{cause:"props",hookChanges:null}}if(ue(i,t.memoizedState,{isClassComponent:t.tag===1})){const a=ge(u,n);return{cause:"state",hookChanges:a}}return{cause:"parent",hookChanges:null}}function Z(e,t){if(e===t)return true;if(!e||!t)return false;if(typeof e!=="object"||typeof t!=="object")return false;const o=Object.keys(e);const r=Object.keys(t);if(o.length!==r.length)return false;for(const n of o){if(e[n]!==t[n])return false}return true}function h(e,t=3){const o=new WeakSet;function r(n,s){if(s>t)return"[MAX_DEPTH]";if(n===null)return null;if(n===void 0)return void 0;if(typeof n==="function")return`[Function: ${n.name||"anonymous"}]`;if(typeof n==="symbol")return`[Symbol: ${n.toString()}]`;if(typeof n!=="object")return n;if(o.has(n))return"[Circular]";o.add(n);if(Array.isArray(n)){return n.slice(0,10).map(l=>r(l,s+1))}const i={};const u=Object.keys(n).slice(0,20);for(const l of u){try{i[l]=r(n[l],s+1)}catch{i[l]="[Error accessing]"}}return i}return r(e,0)}function Te(e,t,o,r,n,s){const i=C(o)||"Unknown";console.log("[Buoy]","\n========================================");console.log("[Buoy]","[RN-BUOY DEBUG] RENDER EVENT");console.log("[Buoy]","========================================");console.log("[Buoy]",`Native Tag: ${e}`);console.log("[Buoy]",`Component Name: ${i}`);console.log("[Buoy]",`Is First Render: ${!r}`);console.log("[Buoy]",`Component Cause Detected: ${s}`);console.log("[Buoy]","----------------------------------------");console.log("[Buoy]","\n--- NATIVE FIBER (Host Component) ---");console.log("[Buoy]","fiber.type:",t?.type);console.log("[Buoy]","fiber.tag:",t?.tag);console.log("[Buoy]","fiber.memoizedProps (CURRENT):",h(t?.memoizedProps));console.log("[Buoy]","fiber.memoizedState:",h(t?.memoizedState));if(r){console.log("[Buoy]","PREVIOUS memoizedProps:",h(r.memoizedProps));console.log("[Buoy]","PREVIOUS memoizedState:",h(r.memoizedState))}console.log("[Buoy]","\n--- COMPONENT FIBER (React Component) ---");if(o){console.log("[Buoy]","componentFiber.type:",o?.type?.name||o?.type);console.log("[Buoy]","componentFiber.tag:",o?.tag);console.log("[Buoy]","componentFiber.memoizedProps:",h(o?.memoizedProps));console.log("[Buoy]","componentFiber.memoizedState:",h(o?.memoizedState));console.log("[Buoy]","\n--- HOOKS STATE (linked list walk) ---");let l=o?.memoizedState;let a=0;while(l&&a<10){console.log("[Buoy]",`Hook[${a}]:`,h({memoizedState:l.memoizedState,baseState:l.baseState,queue:l.queue?"[Queue object]":null}));l=l.next;a++}console.log("[Buoy]","\n--- EXTRACTED HOOKS (Phase 3) ---");const k=R(o);if(k){for(const g of k){console.log("[Buoy]",`Hook[${g.index}] (${g.type}):`,T(g.value))}}else{console.log("[Buoy]","(No hooks extracted)")}}else{console.log("[Buoy]","(No component fiber found)")}console.log("[Buoy]","\n--- CHILDREN/TEXT CONTENT ---");const u=t?.memoizedProps?.children;console.log("[Buoy]","children type:",typeof u);console.log("[Buoy]","children value:",h(u));console.log("[Buoy]","\n========================================\n")}function I(e){if(e===void 0)return"undefined";const t={0:"FunctionComponent",1:"ClassComponent",2:"IndeterminateComponent",3:"HostRoot",4:"HostPortal",5:"HostComponent",6:"HostText",7:"Fragment",8:"Mode",9:"ContextConsumer",10:"ContextProvider",11:"ForwardRef",12:"Profiler",13:"SuspenseComponent",14:"MemoComponent",15:"SimpleMemoComponent"};return t[e]||`Unknown(${e})`}function ke(e,t){if(!t.hookChanges||t.hookChanges.length===0){return}for(const o of t.hookChanges){console.log("[Buoy]",`[${e||"Unknown"}] ${o.type}[${o.index}]: ${o.previousValue} \u2192 ${o.currentValue}`)}}function Se(e,t,o,r,n){const s=C(o)||"Unknown";const i=typeof t?.type==="string"?t.type:"Unknown";const{cause:u,hookChanges:l}=r;console.log("[Buoy]",`[RENDER] ${s} (${i}:${e}) | Cause: ${u.toUpperCase()}`+(n&&n.length>0?` | Props: [${n.join(", ")}]`:""));if(l&&l.length>0){for(const a of l){console.log("[Buoy]",` \u2514\u2500 ${a.type}[${a.index}]: ${a.previousValue} \u2192 ${a.currentValue}`)}}}function v(e,t,o,r,n,s,i){const u=C(o)||"Unknown";const l=typeof t?.type==="string"?t.type:"Unknown";console.log("[Buoy]",`
|
|
2
|
+
[RN-BUOY RENDER DEBUG] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);console.log("[Buoy]",`Render #${i} for ${l} (nativeTag: ${e})`);console.log("[Buoy]",`Timestamp: ${new Date().toISOString()}`);console.log("[Buoy]",`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
3
|
+
`);console.log("[Buoy]",`NATIVE FIBER (${l}):`);console.log("[Buoy]",` type: "${t?.type}"`);console.log("[Buoy]",` tag: ${t?.tag} (${I(t?.tag)})`);const a=t?.alternate;const k=a?"alternate":r?"storage":"none";console.log("[Buoy]",` Previous values source: ${k}`);const g=t?.memoizedProps?.children;const y=a?.memoizedProps?.children;const f=y!==void 0?y:r?.memoizedProps?.children;const S=f!==void 0?g!==f:false;console.log("[Buoy]",` memoizedProps.children: ${T(g)}${S?` (was: ${T(f)})`:f!==void 0?" (unchanged)":" (first render)"}`);const d=t?.memoizedProps?.style;const m=a?.memoizedProps?.style;const P=m!==void 0?m:r?.memoizedProps?.style;const D=P!==void 0?d!==P:false;if(d){console.log("[Buoy]",` memoizedProps.style: ${JSON.stringify(h(d,2))}${D?" (REFERENCE CHANGED)":""}`);if(D&&P){const c=W(d,P);console.log("[Buoy]",` \u2514\u2500 Values actually changed: ${!c}`)}}console.log("[Buoy]",` All memoizedProps keys: [${Object.keys(t?.memoizedProps||{}).join(", ")}]`);const O=t?.memoizedProps?.testID;const H=t?.memoizedProps?.nativeID;const _=t?.memoizedProps?.accessibilityLabel;if(O)console.log("[Buoy]",` testID: "${O}"`);if(H)console.log("[Buoy]",` nativeID: "${H}"`);if(_)console.log("[Buoy]",` accessibilityLabel: "${_}"`);console.log("[Buoy]",` alternate: ${a?"YES":"NO"}`);if(a){console.log("[Buoy]",` alternate.memoizedProps.children: ${T(y)}`)}console.log("[Buoy]",` Tree structure:`);console.log("[Buoy]",` return (parent): ${t?.return?I(t.return.tag):"null"}`);console.log("[Buoy]",` child: ${t?.child?I(t.child.tag):"null"}`);console.log("[Buoy]",` sibling: ${t?.sibling?I(t.sibling.tag):"null"}`);console.log("[Buoy]","");console.log("[Buoy]",`COMPONENT FIBER (${u}):`);if(o){console.log("[Buoy]",` name: "${u}"`);console.log("[Buoy]",` type: ${typeof o.type} (${o.type?.name||o.type?.displayName||"anonymous"})`);console.log("[Buoy]",` tag: ${o.tag} (${I(o.tag)})`);console.log("[Buoy]",` memoizedProps: ${JSON.stringify(h(o.memoizedProps,2))}`);console.log("[Buoy]",` alternate: ${o.alternate?"YES":"NO"}`);if(o.alternate){console.log("[Buoy]",` ALTERNATE memoizedProps: ${JSON.stringify(h(o.alternate.memoizedProps,2))}`);const E=!Z(o.alternate.memoizedProps,o.memoizedProps);console.log("[Buoy]",` Props changed (vs alternate): ${E?"YES":"NO"}`);console.log("[Buoy]",` ALTERNATE memoizedState: ${o.alternate.memoizedState===o.memoizedState?"SAME":"DIFFERENT"}`)}const c=G(o);if(c){console.log("[Buoy]",` WeakMap PREVIOUS memoizedProps: ${JSON.stringify(h(c.memoizedProps,2))}`);const E=!Z(c.memoizedProps,o.memoizedProps);console.log("[Buoy]",` Props changed (vs WeakMap): ${E?"YES":"NO"}`)}else{console.log("[Buoy]",` WeakMap PREVIOUS state: (not found - first render or WeakMap cleared)`)}if(o._debugOwner){const E=C(o._debugOwner);console.log("[Buoy]",` _debugOwner: "${E}"`);let A=o._debugOwner;let N=1;while(A&&N<5){const V=C(A);console.log("[Buoy]",` \u2514\u2500[${N}] ${V||"unknown"} (tag: ${A.tag})`);A=A._debugOwner;N++}}let p=0;let B=t._debugOwner||t.return;while(B&&B!==o&&p<30){B=B.return;p++}console.log("[Buoy]",` Depth from native fiber: ${p}`)}else{console.log("[Buoy]",` (No component fiber found - could not walk up tree)`)}console.log("[Buoy]","");console.log("[Buoy]",`HOOKS:`);if(o?.memoizedState){const c=R(o);const p=o.alternate?R(o.alternate):null;const B=G(o);const E=p||B?.extractedHooks;const A=p?"alternate":B?"WeakMap":"none";if(c&&c.length>0){console.log("[Buoy]",` Total hooks: ${c.length}`);console.log("[Buoy]",` Previous values source: ${A}`);c.forEach((N,V)=>{const M=E?.[V];const ie=M?M.rawState!==N.rawState:false;const le=M?T(M.value):"N/A";const ce=ie?" \u2190 CHANGED":"";console.log("[Buoy]",` [${V}] ${N.type}: ${T(N.value)}${M?` (was: ${le})`:" (first render)"}${ce}`)})}else{console.log("[Buoy]",` (Could not extract hooks - memoizedState structure not recognized)`);console.log("[Buoy]",` Raw memoizedState type: ${typeof o.memoizedState}`);console.log("[Buoy]",` Has 'next' property: ${"next"in(o.memoizedState||{})}`);console.log("[Buoy]",` Has 'queue' property: ${"queue"in(o.memoizedState||{})}`)}}else{console.log("[Buoy]",` (No memoizedState - class component, no hooks, or not a function component)`)}console.log("[Buoy]","");console.log("[Buoy]",`RAW HOOKS DATA:`);if(o?.memoizedState&&typeof o.memoizedState==="object"){let c=o.memoizedState;let p=0;while(c&&p<10){console.log("[Buoy]",` Hook[${p}]:`);console.log("[Buoy]",` memoizedState: ${h(c.memoizedState,2)}`);console.log("[Buoy]",` baseState: ${h(c.baseState,2)}`);console.log("[Buoy]",` queue: ${c.queue?"[Queue present]":"null"}`);console.log("[Buoy]",` next: ${c.next?"[Next hook]":"null"}`);c=c.next;p++}if(p===0){console.log("[Buoy]",` (memoizedState is not a hooks linked list)`)}}console.log("[Buoy]","");console.log("[Buoy]",`DETECTION RESULTS:`);console.log("[Buoy]",` Component Cause: ${n.cause.toUpperCase()}`);if(n.hookChanges&&n.hookChanges.length>0){console.log("[Buoy]",` Hook Changes Detected:`);n.hookChanges.forEach(c=>{console.log("[Buoy]",` [${c.index}] ${c.type}: ${c.previousValue} \u2192 ${c.currentValue}`);if(c.description){console.log("[Buoy]",` ${c.description}`)}})}const z=typeof t?.type==="string"?t.type:void 0;const x=ee(r?.memoizedProps,t?.memoizedProps,z);if(x&&x.length>0){console.log("[Buoy]",` Native Props Changed: [${x.join(", ")}]`)}else if(r){console.log("[Buoy]",` Native Props Changed: (none detected)`)}console.log("[Buoy]","");console.log("[Buoy]",`BATCH CONTEXT:`);console.log("[Buoy]",` Batch size: ${s.size}`);console.log("[Buoy]",` All tags in batch: [${Array.from(s).slice(0,20).join(", ")}${s.size>20?"...":""}]`);const w=ne(t);const K=w!==null&&s.has(w);console.log("[Buoy]",` Parent nativeTag: ${w??"not found"}`);console.log("[Buoy]",` Parent in batch: ${K?"YES":"NO"}`);if(s.size>1){console.log("[Buoy]",` Components in same batch:`);let c=t?.return;let p=0;while(c&&p<10){const B=re(c.stateNode);if(B!==null&&s.has(B)){const E=C(c)||c.type;console.log("[Buoy]",` [depth ${p}] ${E} (tag: ${B})`)}c=c.return;p++}}console.log("[Buoy]",`
|
|
4
4
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
5
|
-
`)}export function detectRenderCause(e,t,o,r="off"){const n=Date.now();if(!t){return{type:"unknown",timestamp:n}}let s=t;let i=t.alternate;const
|
|
5
|
+
`)}export function detectRenderCause(e,t,o,r="off"){const n=Date.now();if(!t){return{type:"unknown",timestamp:n}}let s=t;let i=t.alternate;const u=$.get(e);if(u&&i){const z=u.memoizedProps?.children;const x=t.memoizedProps?.children;const w=i.memoizedProps?.children;const K=t.memoizedProps===u.memoizedProps||z!==void 0&&x===z;const c=i.memoizedProps===u.memoizedProps||z!==void 0&&w===z;if(K&&!c){s=i;i=t;if(r==="all"){console.log("[Buoy]",`[RenderCause] Detected fiber swap - using alternate as current`)}}}let l=null;let a=null;if(i){l=i.memoizedProps;a=i.memoizedState}else{if(u){l=u.memoizedProps;a=u.memoizedState}}const k=l!==null?{memoizedProps:l,memoizedState:a,timestamp:n}:void 0;const g={memoizedProps:s.memoizedProps,memoizedState:s.memoizedState,timestamp:n};Pe(e,g);const y=b(s);const f=C(y)||void 0;const S=Be(s,f)||void 0;const d=he(y);const m=d.cause;const P=d.hookChanges;if(!k){if(r!=="off"){if(r==="minimal"){console.log("[Buoy]",`[${f||"Unknown"}] MOUNT`)}else if(r==="verbose"){const z=typeof s?.type==="string"?s.type:"Unknown";console.log("[Buoy]",`[RENDER] ${f||"Unknown"} (${z}:${e}) | Cause: MOUNT`)}else if(r==="all"){const z=$.has(e)?$.size:1;v(e,s,y,k,d,o,z)}}return{type:"mount",timestamp:n,componentCause:"mount",componentName:f}}const D=typeof s.type==="string"?s.type:void 0;const O=ee(k.memoizedProps,g.memoizedProps,D);if(r!=="off"){if(r==="minimal"){ke(f,d)}else if(r==="verbose"){Se(e,s,y,d,O)}else if(r==="all"){const z=$.has(e)?$.size:1;v(e,s,y,k,d,o,z)}}if(O&&O.length>0){return{type:"props",changedKeys:O.slice(0,de),timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:P||void 0}}const H=ze(k.memoizedState,g.memoizedState);if(H&&H.length>0){return{type:"hooks",hookIndices:H,timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:P||void 0}}const _=ne(s);if(_&&o.has(_)){return{type:"parent",timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:P||void 0}}if(m==="state"){return{type:"state",timestamp:n,componentCause:m,componentName:f,parentComponentName:S,hookChanges:P||void 0}}if(m==="props"){return{type:"props",timestamp:n,componentCause:m,componentName:f,parentComponentName:S}}if(m==="parent"){return{type:"parent",timestamp:n,componentCause:m,componentName:f,parentComponentName:S}}return{type:"unknown",timestamp:n,componentCause:m,componentName:f,parentComponentName:S}}function ee(e,t,o){if(e===t)return null;if(!e||!t)return null;if(typeof e!=="object"||typeof t!=="object")return null;if(Array.isArray(e)||Array.isArray(t))return null;const r=ae(o);const n=new Set([...Object.keys(e),...Object.keys(t)]);const s=[];for(const i of n){if(i.startsWith("__"))continue;if(r.skip.includes(i))continue;if(i==="children"){if(!r.alwaysTrack.includes("children")){continue}const u=e[i];const l=t[i];if(u!==l){if(te(u)&&te(l)){s.push(`children: ${oe(u)} \u2192 ${oe(l)}`)}else{s.push("children (content)")}}continue}if(e[i]!==t[i]){const u=e[i];const l=t[i];if(i==="style"){if(W(u,l)){s.push(`${i} (ref only)`)}else{s.push(i)}}else if(typeof u==="function"&&typeof l==="function"){s.push(`${i} (fn ref)`)}else{s.push(i)}}}return s.length>0?s:null}function Oe(e){if(e===null||typeof e!=="object")return false;if(Array.isArray(e))return false;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function W(e,t,o=0){if(o>5)return false;if(e===t)return true;if(typeof e!==typeof t)return false;if(typeof e!=="object"||e===null||t===null){return e===t}if(Array.isArray(e)!==Array.isArray(t))return false;if(Array.isArray(e)){if(e.length!==t.length)return false;for(let s=0;s<e.length;s++){if(!W(e[s],t[s],o+1))return false}return true}const r=Object.keys(e);const n=Object.keys(t);if(r.length!==n.length)return false;for(const s of r){if(!n.includes(s))return false;if(!W(e[s],t[s],o+1))return false}return true}function te(e){return e===null||e===void 0||typeof e==="string"||typeof e==="number"||typeof e==="boolean"}function oe(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e==="string"){return e.length>20?`"${e.slice(0,20)}..."`:`"${e}"`}if(typeof e==="number")return String(e);if(typeof e==="boolean")return String(e);return"[object]"}function ze(e,t){if(e===t)return null;if(e==null||t==null)return null;if(typeof e!=="object"||typeof t!=="object"){return null}const o=[];let r=e;let n=t;let s=0;while(n!==null&&s<Q){if(r===null){o.push(s)}else if($e(r,n)){o.push(s)}n=n?.next??null;r=r?.next??null;s++}return o.length>0?o:null}function $e(e,t){if(e===t)return false;if(e.memoizedState!==t.memoizedState){return true}if(e.baseState!==void 0&&e.baseState!==t.baseState){return true}return false}function ne(e){let t=e?.return;let o=0;while(t&&o<F){if(t.stateNode){const r=re(t.stateNode);if(r!=null)return r}t=t.return;o++}return null}function Be(e,t){if(!e)return null;const o=b(e);if(!o)return null;let r=o.return;let n=0;while(r&&n<F){const s=r.tag;if(s===0||s===1||s===11||s===15){const i=C(r);if(i&&!L(i)&&i!==t){return i}}r=r.return;n++}return null}function re(e){if(!e)return null;if(typeof e.__nativeTag==="number"){return e.__nativeTag}if(typeof e._nativeTag==="number"){return e._nativeTag}if(typeof e.canonical?.__nativeTag==="number"){return e.canonical.__nativeTag}if(typeof e.canonical?.publicInstance?.__nativeTag==="number"){return e.canonical.publicInstance.__nativeTag}return null}function Pe(e,t){if($.size>=J){const o=Array.from($.entries());o.sort((n,s)=>n[1].timestamp-s[1].timestamp);const r=Math.floor(J/4);for(let n=0;n<r;n++){$.delete(o[n][0])}}$.set(e,t)}export function clearRenderCauseState(){$.clear()}export function removeRenderCauseState(e){$.delete(e)}export function getRenderCauseStats(){return{storedStates:$.size,maxStates:J}}const Ee=5;const se=200;const q=20;const X=30;export function safeCloneForHistory(e,t=0,o=new WeakSet){if(e===null||e===void 0)return e;if(typeof e==="boolean"||typeof e==="number")return e;if(typeof e==="string"){return e.length>se?e.slice(0,se)+"...":e}if(typeof e==="function"){return`[Function: ${e.name||"anonymous"}]`}if(typeof e==="symbol"){return`[Symbol: ${e.description||""}]`}if(t>=Ee){if(Array.isArray(e))return`[Array: ${e.length} items]`;if(typeof e==="object"){const r=Object.keys(e);return`[Object: ${r.length} keys]`}return"[...]"}if(typeof e==="object"){if(o.has(e)){return"[Circular]"}o.add(e)}if(Array.isArray(e)){const r=e.slice(0,q).map(n=>safeCloneForHistory(n,t+1,o));if(e.length>q){r.push(`[...${e.length-q} more]`)}return r}if(e instanceof Date){return e.toISOString()}if(e instanceof Error){return`[Error: ${e.message}]`}if(e instanceof RegExp){return e.toString()}if(e instanceof Map){const r={__type:"Map",__size:e.size};let n=0;for(const[s,i]of e){if(n>=X){r[`...${e.size-n} more`]=true;break}const u=typeof s==="string"?s:String(s);r[u]=safeCloneForHistory(i,t+1,o);n++}return r}if(e instanceof Set){return{__type:"Set",__size:e.size,values:Array.from(e).slice(0,q).map(r=>safeCloneForHistory(r,t+1,o))}}if(typeof e==="object"){const r={};const n=Object.keys(e);const s=n.slice(0,X);for(const i of s){if(i.startsWith("__")||i==="children")continue;try{r[i]=safeCloneForHistory(e[i],t+1,o)}catch{r[i]="[Error accessing property]"}}if(n.length>X){r[`...${n.length-X} more keys`]=true}return r}return"[Unknown type]"}export function capturePropsSnapshot(e){if(!e?.memoizedProps)return void 0;return safeCloneForHistory(e.memoizedProps)}export function captureStateSnapshot(e){if(!e?.memoizedState)return void 0;const t=e.memoizedState;if(typeof t==="object"&&t!==null&&"next"in t){const o=[];let r=t;let n=0;while(r&&n<Q){o.push({index:n,memoizedState:safeCloneForHistory(r.memoizedState)});r=r.next;n++}return{__type:"Hooks",hooks:o}}return safeCloneForHistory(t)}
|