@buoy-gg/js-top 7.0.74 → 7.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/js-top/components/TaskTable.js +1 -1
- package/lib/commonjs/js-top/engine/JsTopController.js +1 -1
- package/lib/commonjs/js-top/engine/originRegistry.js +1 -1
- package/lib/module/js-top/components/TaskTable.js +1 -1
- package/lib/module/js-top/engine/JsTopController.js +1 -1
- package/lib/module/js-top/engine/originRegistry.js +1 -1
- package/lib/typescript/js-top/components/TaskTable.d.ts +1 -0
- package/lib/typescript/js-top/engine/JsTopController.d.ts +2 -0
- package/lib/web/index.mjs +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.API_BADGE=void 0;exports.TaskTable=TaskTable;exports.badgeFor=badgeFor;exports.displayName=displayName;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _jsxRuntime=require("react/jsx-runtime");const SORT_OPTIONS=[{key:"windowMs",title:"RECENT"},{key:"calls",title:"CALLS"},{key:"avgMs",title:"AVG"},{key:"maxMs",title:"MAX"},{key:"totalMs",title:"TOTAL"}];const API_BADGE=exports.API_BADGE={timeout:{text:"TIMEOUT",color:"#38BDF8",prefix:"setTimeout"},interval:{text:"INTERVAL",color:"#22D3EE",prefix:"setInterval"},immediate:{text:"IMMED",color:"#60A5FA",prefix:"setImmediate"},raf:{text:"RAF",color:"#34D399",prefix:"requestAnimationFrame"},microtask:{text:"MICRO",color:"#A78BFA",prefix:"queueMicrotask"},then:{text:"PROMISE",color:"#BF5AF2",prefix:"Promise.then"},bridge:{text:"BRIDGE",color:"#FBBF24",prefix:"bridge"},unattributed:{text:"SYSTEM",color:"#8E8E93"},other:{text:"OTHER",color:"#8E8E93",prefix:"other"}};function badgeFor(t){return API_BADGE[t]??API_BADGE.other}function displayName(t){if(t.api==="unattributed")return"events \xB7 React \xB7 native call-ins";if(t.api==="other")return"evicted cold origins";const e=badgeFor(t.api).prefix;let r=t.label;if(e&&r.startsWith(e))r=r.slice(e.length);r=r.replace(/^[\s←@]+/,"").trim();return r.length>0?r:"anonymous"}function fmt(t){if(t>=1e4)return`${Math.round(t/1e3)}k`;if(t>=1e3)return`${(t/1e3).toFixed(1)}k`;if(t>=100)return`${Math.round(t)}`;return`${Math.round(t*10)/10}`}function statsLine(t){if(t.calls<=0)return"measured by probe \xB7 not reachable from JS";return`${fmt(t.calls)} calls \xB7 avg ${fmt(t.avgMs)} \xB7 max ${fmt(t.maxMs)} \xB7 total ${fmt(t.totalMs)} ms`}const TaskRow=(0,_react.memo)(function t({row:e,rank:r,onPress:a}){const i=badgeFor(e.api);const o=a?_reactNative.TouchableOpacity:_reactNative.View;return(0,_jsxRuntime.jsxs)(o,{style:rowStyles.row,testID:"buoy-jstop-row",...a?{onPress:()=>a(e),activeOpacity:.6}:{},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:rowStyles.topLine,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.rank,children:r}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[rowStyles.badge,{borderColor:i.color,backgroundColor:`${i.color}1A`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[rowStyles.badgeText,{color:i.color}],children:i.text})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.name,numberOfLines:1,testID:"buoy-jstop-row-name",children:displayName(e)}),e.freezes>0&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[rowStyles.freezeBadge,e.worstFreezeMs>=100&&rowStyles.freezeBadgeSevere],children:["\u26A0 \xD7",e.freezes]}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[rowStyles.windowMs,e.api!=="unattributed"&&e.pctOfBusy>=25&&{color:e.pctOfBusy>=50?_sharedUi.macOSColors.semantic.error:_sharedUi.macOSColors.semantic.warning}],children:[fmt(e.windowMs),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.unit,children:" ms"})]}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[rowStyles.pct,e.api==="unattributed"&&rowStyles.pctMuted],children:[Math.round(e.pctOfBusy),"%"]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:rowStyles.subLine,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:rowStyles.barTrack,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[rowStyles.barFill,{width:`${Math.min(100,e.pctOfBusy)}%`,backgroundColor:i.color}]})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.stats,numberOfLines:1,testID:"buoy-jstop-row-stats",children:statsLine(e)})]})]})},(t,e)=>t.rank===e.rank&&t.onPress===e.onPress&&t.row.key===e.row.key&&t.row.windowMs===e.row.windowMs&&t.row.calls===e.row.calls&&t.row.maxMs===e.row.maxMs&&t.row.totalMs===e.row.totalMs&&t.row.pctOfBusy===e.row.pctOfBusy&&t.row.freezes===e.row.freezes&&t.row.worstFreezeMs===e.row.worstFreezeMs);function TaskTable({rows:t,onSelectRow:e}){const[r,a]=(0,_react.useState)("windowMs");const i=r==="windowMs"?t:[...t].sort((o,n)=>n[r]-o[r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.root,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sortRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sortLabel,children:"SORT"}),SORT_OPTIONS.map(o=>(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>a(o.key),style:[styles.sortChip,r===o.key&&styles.sortChipOn],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.sortChipText,r===o.key&&styles.sortChipTextOn],children:o.title})},o.key))]}),(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.body,children:[i.map((o,n)=>(0,_jsxRuntime.jsx)(TaskRow,{row:o,rank:n+1,onPress:e},o.key)),i.length===0&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.empty,testID:"buoy-jstop-empty",children:"No tasks observed yet \u2014 interact with the app."})]})]})}const styles=_reactNative.StyleSheet.create({root:{flex:1,minHeight:0},sortRow:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:6,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface},sortLabel:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginRight:2},sortChip:{borderWidth:1,borderColor:_sharedUi.night.color.border,borderRadius:4,paddingHorizontal:7,paddingVertical:3},sortChipOn:{borderColor:_sharedUi.night.color.accentBorderStrong,backgroundColor:_sharedUi.night.color.accentSoft},sortChipText:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"600",fontVariant:["tabular-nums"]},sortChipTextOn:{color:_sharedUi.night.color.accent},body:{flex:1},empty:{color:_sharedUi.night.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:24}});const rowStyles=_reactNative.StyleSheet.create({row:{paddingHorizontal:10,paddingVertical:8,borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:_sharedUi.night.color.border,gap:5},topLine:{flexDirection:"row",alignItems:"center",gap:6},rank:{width:16,color:_sharedUi.night.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},badge:{borderWidth:1,borderRadius:3,paddingHorizontal:4,paddingVertical:1},badgeText:{fontSize:8,fontWeight:"700",letterSpacing:.4},name:{flex:1,color:_sharedUi.night.color.text,fontSize:13,fontWeight:"500"},freezeBadge:{color:_sharedUi.macOSColors.semantic.warning,fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},freezeBadgeSevere:{color:_sharedUi.macOSColors.semantic.error},windowMs:{color:_sharedUi.night.color.text,fontSize:13,fontWeight:"700",fontVariant:["tabular-nums"]},unit:{color:_sharedUi.night.color.textTertiary,fontSize:10,fontWeight:"400"},pct:{width:38,textAlign:"right",color:_sharedUi.night.color.textSecondary,fontSize:12,fontWeight:"600",fontVariant:["tabular-nums"]},pctMuted:{color:_sharedUi.night.color.textTertiary},subLine:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:22},barTrack:{width:72,height:4,borderRadius:2,backgroundColor:_sharedUi.night.color.fillSecondary,overflow:"hidden"},barFill:{height:4,borderRadius:2,opacity:.85},stats:{flex:1,color:_sharedUi.night.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.API_BADGE=void 0;exports.TaskTable=TaskTable;exports.badgeFor=badgeFor;exports.displayName=displayName;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _jsxRuntime=require("react/jsx-runtime");const SORT_OPTIONS=[{key:"windowMs",title:"RECENT"},{key:"calls",title:"CALLS"},{key:"avgMs",title:"AVG"},{key:"maxMs",title:"MAX"},{key:"totalMs",title:"TOTAL"}];const API_BADGE=exports.API_BADGE={timeout:{text:"TIMEOUT",color:"#38BDF8",prefix:"setTimeout"},interval:{text:"INTERVAL",color:"#22D3EE",prefix:"setInterval"},immediate:{text:"IMMED",color:"#60A5FA",prefix:"setImmediate"},raf:{text:"RAF",color:"#34D399",prefix:"requestAnimationFrame"},microtask:{text:"MICRO",color:"#A78BFA",prefix:"queueMicrotask"},then:{text:"PROMISE",color:"#BF5AF2",prefix:"Promise.then"},bridge:{text:"BRIDGE",color:"#FBBF24",prefix:"bridge"},unattributed:{text:"SYSTEM",color:"#8E8E93"},other:{text:"OTHER",color:"#8E8E93",prefix:"other"}};function badgeFor(t){return API_BADGE[t]??API_BADGE.other}function displayName(t){if(t.api==="unattributed")return"events \xB7 React \xB7 native call-ins";if(t.api==="other")return t.key==="minor"?t.label:"evicted cold origins";const e=badgeFor(t.api).prefix;let r=t.label;if(e&&r.startsWith(e))r=r.slice(e.length);r=r.replace(/^[\s←@]+/,"").trim();return r.length>0?r:"anonymous"}function fmt(t){if(t>=1e4)return`${Math.round(t/1e3)}k`;if(t>=1e3)return`${(t/1e3).toFixed(1)}k`;if(t>=100)return`${Math.round(t)}`;return`${Math.round(t*10)/10}`}function statsLine(t){if(t.calls<=0)return"measured by probe \xB7 not reachable from JS";return`${fmt(t.calls)} calls \xB7 avg ${fmt(t.avgMs)} \xB7 max ${fmt(t.maxMs)} \xB7 total ${fmt(t.totalMs)} ms`}const TaskRow=(0,_react.memo)(function t({row:e,rank:r,onPress:a}){const i=badgeFor(e.api);const o=a?_reactNative.TouchableOpacity:_reactNative.View;return(0,_jsxRuntime.jsxs)(o,{style:rowStyles.row,testID:"buoy-jstop-row",...a?{onPress:()=>a(e),activeOpacity:.6}:{},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:rowStyles.topLine,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.rank,children:r}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[rowStyles.badge,{borderColor:i.color,backgroundColor:`${i.color}1A`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[rowStyles.badgeText,{color:i.color}],children:i.text})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.name,numberOfLines:1,testID:"buoy-jstop-row-name",children:displayName(e)}),e.freezes>0&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[rowStyles.freezeBadge,e.worstFreezeMs>=100&&rowStyles.freezeBadgeSevere],children:["\u26A0 \xD7",e.freezes]}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[rowStyles.windowMs,e.api!=="unattributed"&&e.pctOfBusy>=25&&{color:e.pctOfBusy>=50?_sharedUi.macOSColors.semantic.error:_sharedUi.macOSColors.semantic.warning}],children:[fmt(e.windowMs),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.unit,children:" ms"})]}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[rowStyles.pct,e.api==="unattributed"&&rowStyles.pctMuted],children:[Math.round(e.pctOfBusy),"%"]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:rowStyles.subLine,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:rowStyles.barTrack,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[rowStyles.barFill,{width:`${Math.min(100,e.pctOfBusy)}%`,backgroundColor:i.color}]})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:rowStyles.stats,numberOfLines:1,testID:"buoy-jstop-row-stats",children:statsLine(e)})]})]})},(t,e)=>t.rank===e.rank&&t.onPress===e.onPress&&t.row.key===e.row.key&&t.row.windowMs===e.row.windowMs&&t.row.calls===e.row.calls&&t.row.maxMs===e.row.maxMs&&t.row.totalMs===e.row.totalMs&&t.row.pctOfBusy===e.row.pctOfBusy&&t.row.freezes===e.row.freezes&&t.row.worstFreezeMs===e.row.worstFreezeMs);function TaskTable({rows:t,onSelectRow:e}){const[r,a]=(0,_react.useState)("windowMs");const i=r==="windowMs"?t:[...t].sort((o,n)=>n[r]-o[r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.root,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sortRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sortLabel,children:"SORT"}),SORT_OPTIONS.map(o=>(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>a(o.key),style:[styles.sortChip,r===o.key&&styles.sortChipOn],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.sortChipText,r===o.key&&styles.sortChipTextOn],children:o.title})},o.key))]}),(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.body,children:[i.map((o,n)=>(0,_jsxRuntime.jsx)(TaskRow,{row:o,rank:n+1,onPress:e},o.key)),i.length===0&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.empty,testID:"buoy-jstop-empty",children:"No tasks observed yet \u2014 interact with the app."})]})]})}const styles=_reactNative.StyleSheet.create({root:{flex:1,minHeight:0},sortRow:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:6,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface},sortLabel:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginRight:2},sortChip:{borderWidth:1,borderColor:_sharedUi.night.color.border,borderRadius:4,paddingHorizontal:7,paddingVertical:3},sortChipOn:{borderColor:_sharedUi.night.color.accentBorderStrong,backgroundColor:_sharedUi.night.color.accentSoft},sortChipText:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"600",fontVariant:["tabular-nums"]},sortChipTextOn:{color:_sharedUi.night.color.accent},body:{flex:1},empty:{color:_sharedUi.night.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:24}});const rowStyles=_reactNative.StyleSheet.create({row:{paddingHorizontal:10,paddingVertical:8,borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:_sharedUi.night.color.border,gap:5},topLine:{flexDirection:"row",alignItems:"center",gap:6},rank:{width:16,color:_sharedUi.night.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},badge:{borderWidth:1,borderRadius:3,paddingHorizontal:4,paddingVertical:1},badgeText:{fontSize:8,fontWeight:"700",letterSpacing:.4},name:{flex:1,color:_sharedUi.night.color.text,fontSize:13,fontWeight:"500"},freezeBadge:{color:_sharedUi.macOSColors.semantic.warning,fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},freezeBadgeSevere:{color:_sharedUi.macOSColors.semantic.error},windowMs:{color:_sharedUi.night.color.text,fontSize:13,fontWeight:"700",fontVariant:["tabular-nums"]},unit:{color:_sharedUi.night.color.textTertiary,fontSize:10,fontWeight:"400"},pct:{width:38,textAlign:"right",color:_sharedUi.night.color.textSecondary,fontSize:12,fontWeight:"600",fontVariant:["tabular-nums"]},pctMuted:{color:_sharedUi.night.color.textTertiary},subLine:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:22},barTrack:{width:72,height:4,borderRadius:2,backgroundColor:_sharedUi.night.color.fillSecondary,overflow:"hidden"},barFill:{height:4,borderRadius:2,opacity:.85},stats:{flex:1,color:_sharedUi.night.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JsTopController=void 0;var _types=require("../types");var _now=require("./now");var _state=require("./state");var _timers=require("./patches/timers");var _microtasks=require("./patches/microtasks");var _aggregator=require("./aggregator");var _originRegistry=require("./originRegistry");var _busyProbe=require("./busyProbe");var _preferences=require("../utils/preferences");var _sharedUi=require("@buoy-gg/shared-ui");const NOTIFY_INTERVAL_MS=_types.BUCKET_MS;class JsTopControllerImpl{enabled=false;enabledLoaded=false;paused=false;remoteSampling=false;engineRunning=false;tiers={timers:false,promises:false,bridge:false,longtask:false};notifyHandle=null;appStateSub=null;snapshot=this.buildSnapshot();subscribers=new Set;enabledSubscribers=new Set;tierInstallers=[];longtaskProvider=null;freezeStatsProvider=null;clearHooks=[];constructor(){void(0,_preferences.loadJsTopPrefs)().then(e=>{this.enabledLoaded=true;if(e.enabled&&!this.enabled)this.setEnabled(true)})}subscribe(e){this.subscribers.add(e);this.syncEngineState();e(this.snapshot);return()=>{this.subscribers.delete(e);this.syncEngineState()}}subscribeEnabled(e){this.enabledSubscribers.add(e);e(this.enabled);return()=>{this.enabledSubscribers.delete(e)}}setEnabled(e){if(this.enabled===e)return;this.enabled=e;if(this.enabledLoaded)void(0,_preferences.saveJsTopPrefs)({enabled:e});this.enabledSubscribers.forEach(t=>{try{t(e)}catch(i){if(__DEV__){console.error("[Buoy]","[js-top] enabled subscriber threw",i)}}});this.syncEngineState()}isEnabled(){return this.enabled}setRemoteSampling(e){if(this.remoteSampling===e)return;this.remoteSampling=e;this.syncEngineState()}isRemoteSampling(){return this.remoteSampling}getStatus(){if(!this.engineRunning)return"disabled";return this.paused?"paused":"running"}pause(){if(this.paused)return;this.paused=true;(0,_state.setActive)(false);(0,_busyProbe.stopBusyProbe)();this.emitSnapshot()}resume(){if(!this.paused)return;this.paused=false;if(this.engineRunning){(0,_state.setActive)(true);(0,_busyProbe.startBusyProbe)()}this.emitSnapshot()}clear(){(0,_originRegistry.resetOrigins)();(0,_aggregator.resetAggregator)();for(const e of this.clearHooks){try{e()}catch{}}this.emitSnapshot()}registerClearHook(e){this.clearHooks.push(e)}getSnapshot(){return this.snapshot}getOriginDetail(e){const t=(0,_now.now)();const i=(0,_aggregator.windowBusyMs)(t);const a=this.freezeStatsProvider?.(Date.now());const s=a?.byOrigin[e];if(e==="unattributed"){const u=(0,_aggregator.windowResidualBuckets)(t);const r=Math.round(u.reduce((n,l)=>n+l,0)*10)/10;return{key:e,label:"unattributed (events / React / native call-ins)",api:"unattributed",promoted:false,scheduleCount:0,calls:0,totalMs:0,avgMs:0,maxMs:0,windowMs:r,pctOfBusy:i>0?Math.min(100,Math.round(r/i*1e3)/10):0,lastSeenAgoMs:0,buckets:u,freezes:s?.count??0,worstFreezeMs:Math.round(s?.maxMs??0)}}const o=(0,_originRegistry.getOriginDetailBase)(e,t,i);if(!o)return null;return{...o,freezes:s?.count??0,worstFreezeMs:Math.round(s?.maxMs??0)}}registerTierInstaller(e){this.tierInstallers.push(e);if(this.engineRunning){Object.assign(this.tiers,this.runInstaller(e))}}registerLongtaskProvider(e){this.longtaskProvider=e}registerFreezeStatsProvider(e){this.freezeStatsProvider=e}shouldRun(){return this.subscribers.size>0||this.remoteSampling}syncEngineState(){const e=this.shouldRun();if(e&&!this.engineRunning)this.startEngine();else if(!e&&this.engineRunning)this.stopEngine()}runInstaller(e){try{return e()}catch(t){if(__DEV__){console.error("[Buoy]","[js-top] tier installer threw",t)}return{}}}startEngine(){this.engineRunning=true;(0,_timers.installTimerPatches)();(0,_microtasks.installMicrotaskPatches)();this.tiers={timers:true,promises:false,bridge:false,longtask:false};for(const e of this.tierInstallers){Object.assign(this.tiers,this.runInstaller(e))}(0,_state.setActive)(!this.paused);if(!this.paused)(0,_busyProbe.startBusyProbe)();try{this.appStateSub=(0,_sharedUi.subscribeRealAppState)(()=>{(0,_busyProbe.suppressNextGap)()})}catch{this.appStateSub=null}this.notifyHandle=(0,_state.getOriginals)().setInterval(()=>this.emitSnapshot(),NOTIFY_INTERVAL_MS);this.emitSnapshot()}stopEngine(){this.engineRunning=false;(0,_state.setActive)(false);(0,_busyProbe.stopBusyProbe)();if(this.notifyHandle!=null){(0,_state.getOriginals)().clearInterval(this.notifyHandle);this.notifyHandle=null}if(this.appStateSub){try{this.appStateSub.remove()}catch{}this.appStateSub=null}}buildSnapshot(){const e=(0,_now.now)();const t=(0,_aggregator.windowBusyMs)(e);const i=(0,_aggregator.windowAttributedMs)(e);const a=Math.max(0,t-i);const s=(0,_originRegistry.buildRows)(e,t,_types.SNAPSHOT_ROWS);if(a>=1){s.push({key:"unattributed",label:"unattributed (events / React / native call-ins)",api:"unattributed",windowMs:Math.round(a*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(a/t*1e3)/10):0,totalMs:0,calls:0,avgMs:0,maxMs:0,lastSeenAgoMs:0,freezes:0,worstFreezeMs:0});s.sort((r,n)=>n.windowMs-r.windowMs||n.totalMs-r.totalMs)}const o=this.freezeStatsProvider?.(Date.now())??{count:0,worstMs:0,byOrigin:{}};for(const r of s){const n=o.byOrigin[r.key];if(n){r.freezes=n.count;r.worstFreezeMs=Math.round(n.maxMs)}}const u=_types.WINDOW_BUCKETS*_types.BUCKET_MS;return{ts:Date.now(),paused:this.paused,busyPct:Math.min(100,Math.round(t/u*1e3)/10),busyHistory:(0,_aggregator.busyHistory)(e),tiers:{...this.tiers},rows:s,totals:{attributedWindowMs:Math.round(i*10)/10,unattributedWindowMs:Math.round(a*10)/10,windowMs:u},freezeSummary:{count:o.count,worstMs:Math.round(o.worstMs)},longtasks:this.longtaskProvider?this.longtaskProvider():[]}}emitSnapshot(){this.snapshot=this.buildSnapshot();this.subscribers.forEach(e=>{try{e(this.snapshot)}catch(t){if(__DEV__){console.error("[Buoy]","[js-top] snapshot subscriber threw",t)}}})}isEngineActive(){return(0,_state.isActive)()}}const JsTopController=exports.JsTopController=new JsTopControllerImpl;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JsTopController=void 0;var _types=require("../types");var _now=require("./now");var _state=require("./state");var _timers=require("./patches/timers");var _microtasks=require("./patches/microtasks");var _aggregator=require("./aggregator");var _originRegistry=require("./originRegistry");var _busyProbe=require("./busyProbe");var _preferences=require("../utils/preferences");var _sharedUi=require("@buoy-gg/shared-ui");const NOTIFY_INTERVAL_MS=_types.BUCKET_MS;class JsTopControllerImpl{enabled=false;enabledLoaded=false;paused=false;pausedAt=0;remoteSampling=false;engineRunning=false;tiers={timers:false,promises:false,bridge:false,longtask:false};notifyHandle=null;appStateSub=null;snapshot=this.buildSnapshot();subscribers=new Set;enabledSubscribers=new Set;tierInstallers=[];longtaskProvider=null;freezeStatsProvider=null;clearHooks=[];constructor(){void(0,_preferences.loadJsTopPrefs)().then(e=>{this.enabledLoaded=true;if(e.enabled&&!this.enabled)this.setEnabled(true)})}subscribe(e){this.subscribers.add(e);this.syncEngineState();e(this.snapshot);return()=>{this.subscribers.delete(e);this.syncEngineState()}}subscribeEnabled(e){this.enabledSubscribers.add(e);e(this.enabled);return()=>{this.enabledSubscribers.delete(e)}}setEnabled(e){if(this.enabled===e)return;this.enabled=e;if(this.enabledLoaded)void(0,_preferences.saveJsTopPrefs)({enabled:e});this.enabledSubscribers.forEach(t=>{try{t(e)}catch(i){if(__DEV__){console.error("[Buoy]","[js-top] enabled subscriber threw",i)}}});this.syncEngineState()}isEnabled(){return this.enabled}setRemoteSampling(e){if(this.remoteSampling===e)return;this.remoteSampling=e;this.syncEngineState()}isRemoteSampling(){return this.remoteSampling}getStatus(){if(!this.engineRunning)return"disabled";return this.paused?"paused":"running"}pause(){if(this.paused)return;this.paused=true;this.pausedAt=(0,_now.now)();(0,_state.setActive)(false);(0,_busyProbe.stopBusyProbe)();this.emitSnapshot()}resume(){if(!this.paused)return;this.paused=false;if(this.engineRunning){(0,_state.setActive)(true);(0,_busyProbe.startBusyProbe)()}this.emitSnapshot()}clear(){(0,_originRegistry.resetOrigins)();(0,_aggregator.resetAggregator)();for(const e of this.clearHooks){try{e()}catch{}}this.emitSnapshot()}registerClearHook(e){this.clearHooks.push(e)}getSnapshot(){return this.snapshot}getOriginDetail(e){const t=(0,_now.now)();const i=(0,_aggregator.windowBusyMs)(t);const a=this.freezeStatsProvider?.(Date.now());const s=a?.byOrigin[e];if(e==="unattributed"){const u=(0,_aggregator.windowResidualBuckets)(t);const r=Math.round(u.reduce((n,l)=>n+l,0)*10)/10;return{key:e,label:"unattributed (events / React / native call-ins)",api:"unattributed",promoted:false,scheduleCount:0,calls:0,totalMs:0,avgMs:0,maxMs:0,windowMs:r,pctOfBusy:i>0?Math.min(100,Math.round(r/i*1e3)/10):0,lastSeenAgoMs:0,buckets:u,freezes:s?.count??0,worstFreezeMs:Math.round(s?.maxMs??0)}}const o=(0,_originRegistry.getOriginDetailBase)(e,t,i);if(!o)return null;return{...o,freezes:s?.count??0,worstFreezeMs:Math.round(s?.maxMs??0)}}registerTierInstaller(e){this.tierInstallers.push(e);if(this.engineRunning){Object.assign(this.tiers,this.runInstaller(e))}}registerLongtaskProvider(e){this.longtaskProvider=e}registerFreezeStatsProvider(e){this.freezeStatsProvider=e}shouldRun(){return this.subscribers.size>0||this.remoteSampling}syncEngineState(){const e=this.shouldRun();if(e&&!this.engineRunning)this.startEngine();else if(!e&&this.engineRunning)this.stopEngine()}runInstaller(e){try{return e()}catch(t){if(__DEV__){console.error("[Buoy]","[js-top] tier installer threw",t)}return{}}}startEngine(){this.engineRunning=true;(0,_timers.installTimerPatches)();(0,_microtasks.installMicrotaskPatches)();this.tiers={timers:true,promises:false,bridge:false,longtask:false};for(const e of this.tierInstallers){Object.assign(this.tiers,this.runInstaller(e))}(0,_state.setActive)(!this.paused);if(!this.paused)(0,_busyProbe.startBusyProbe)();try{this.appStateSub=(0,_sharedUi.subscribeRealAppState)(()=>{(0,_busyProbe.suppressNextGap)()})}catch{this.appStateSub=null}this.notifyHandle=(0,_state.getOriginals)().setInterval(()=>this.emitSnapshot(),NOTIFY_INTERVAL_MS);this.emitSnapshot()}stopEngine(){this.engineRunning=false;(0,_state.setActive)(false);(0,_busyProbe.stopBusyProbe)();if(this.notifyHandle!=null){(0,_state.getOriginals)().clearInterval(this.notifyHandle);this.notifyHandle=null}if(this.appStateSub){try{this.appStateSub.remove()}catch{}this.appStateSub=null}}buildSnapshot(){const e=this.paused?this.pausedAt:(0,_now.now)();const t=(0,_aggregator.windowBusyMs)(e);const i=(0,_aggregator.windowAttributedMs)(e);const a=Math.max(0,t-i);const s=(0,_originRegistry.buildRows)(e,t,_types.SNAPSHOT_ROWS);if(a>=1){s.push({key:"unattributed",label:"unattributed (events / React / native call-ins)",api:"unattributed",windowMs:Math.round(a*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(a/t*1e3)/10):0,totalMs:0,calls:0,avgMs:0,maxMs:0,lastSeenAgoMs:0,freezes:0,worstFreezeMs:0});s.sort((r,n)=>n.windowMs-r.windowMs||n.totalMs-r.totalMs)}const o=this.freezeStatsProvider?.(Date.now())??{count:0,worstMs:0,byOrigin:{}};for(const r of s){const n=o.byOrigin[r.key];if(n){r.freezes=n.count;r.worstFreezeMs=Math.round(n.maxMs)}}const u=_types.WINDOW_BUCKETS*_types.BUCKET_MS;return{ts:Date.now(),paused:this.paused,busyPct:Math.min(100,Math.round(t/u*1e3)/10),busyHistory:(0,_aggregator.busyHistory)(e),tiers:{...this.tiers},rows:s,totals:{attributedWindowMs:Math.round(i*10)/10,unattributedWindowMs:Math.round(a*10)/10,windowMs:u},freezeSummary:{count:o.count,worstMs:Math.round(o.worstMs)},longtasks:this.longtaskProvider?this.longtaskProvider():[]}}emitSnapshot(){this.snapshot=this.buildSnapshot();this.subscribers.forEach(e=>{try{e(this.snapshot)}catch(t){if(__DEV__){console.error("[Buoy]","[js-top] snapshot subscriber threw",t)}}})}isEngineActive(){return(0,_state.isActive)()}}const JsTopController=exports.JsTopController=new JsTopControllerImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.OTHER_KEY=void 0;exports.buildRows=buildRows;exports.buoyJsTopBookExclusive=buoyJsTopBookExclusive;exports.buoyJsTopOriginExists=buoyJsTopOriginExists;exports.buoyJsTopScheduleOrigin=buoyJsTopScheduleOrigin;exports.debugGetOrigin=debugGetOrigin;exports.getOriginDetailBase=getOriginDetailBase;exports.labelForOrigin=labelForOrigin;exports.originCount=originCount;exports.parseStack=parseStack;exports.resetOrigins=resetOrigins;var _types=require("../types");var _aggregator=require("./aggregator");var _symbolicate=require("./symbolicate");const STACK_CAPTURE_MIN_INTERVAL_PER_KEY_MS=500;const STACK_CAPTURES_PER_SEC_GLOBAL=20;const origins=new Map;const OTHER_KEY=exports.OTHER_KEY="other";let globalCaptureWindowStart=0;let globalCapturesInWindow=0;function makeOrigin(n,r,i){return{key:n,api:r,label:i,calls:0,totalMs:0,maxMs:0,scheduleCount:0,lastSeenAt:0,promoted:false,lastCaptureAt:0,ring:new Float64Array(_types.WINDOW_BUCKETS),ringStamps:new Float64Array(_types.WINDOW_BUCKETS).fill(-1)}}function windowMsOf(n,r){const i=(0,_aggregator.epochOf)(r);let
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.OTHER_KEY=void 0;exports.buildRows=buildRows;exports.buoyJsTopBookExclusive=buoyJsTopBookExclusive;exports.buoyJsTopOriginExists=buoyJsTopOriginExists;exports.buoyJsTopScheduleOrigin=buoyJsTopScheduleOrigin;exports.debugGetOrigin=debugGetOrigin;exports.getOriginDetailBase=getOriginDetailBase;exports.labelForOrigin=labelForOrigin;exports.originCount=originCount;exports.parseStack=parseStack;exports.resetOrigins=resetOrigins;var _types=require("../types");var _aggregator=require("./aggregator");var _symbolicate=require("./symbolicate");const STACK_CAPTURE_MIN_INTERVAL_PER_KEY_MS=500;const STACK_CAPTURES_PER_SEC_GLOBAL=20;const origins=new Map;const OTHER_KEY=exports.OTHER_KEY="other";let globalCaptureWindowStart=0;let globalCapturesInWindow=0;function makeOrigin(n,r,i){return{key:n,api:r,label:i,calls:0,totalMs:0,maxMs:0,scheduleCount:0,lastSeenAt:0,promoted:false,lastCaptureAt:0,ring:new Float64Array(_types.WINDOW_BUCKETS),ringStamps:new Float64Array(_types.WINDOW_BUCKETS).fill(-1)}}function windowMsOf(n,r){const i=(0,_aggregator.epochOf)(r);let t=0;for(let o=i-_types.WINDOW_BUCKETS+1;o<=i;o++){const a=o%_types.WINDOW_BUCKETS;if(a>=0&&n.ringStamps[a]===o)t+=n.ring[a]}return t}function evictColdest(n){let r=null;let i=Infinity;for(const o of origins.values()){if(o.key===OTHER_KEY)continue;const a=windowMsOf(o,n)*1e6+o.lastSeenAt;if(a<i){i=a;r=o}}if(!r)return false;const t=getOrCreate(OTHER_KEY,"other","other (evicted origins)");t.calls+=r.calls;t.totalMs+=r.totalMs;t.maxMs=Math.max(t.maxMs,r.maxMs);t.lastSeenAt=Math.max(t.lastSeenAt,r.lastSeenAt);origins.delete(r.key);return true}function getOrCreate(n,r,i){let t=origins.get(n);if(!t){t=makeOrigin(n,r,i);origins.set(n,t)}return t}function parseStack(n){const r=[];let i;const t=n.split("\n");for(const o of t){const a=/at\s+(.*?)\s+\((?:address at\s+)?(.*?):(\d+):(\d+)\)/.exec(o)??/at\s+()(.*?):(\d+):(\d+)$/.exec(o.trim())??/^([^@\s]*)@(.+?):(\d+):(\d+)$/.exec(o.trim());if(!a)continue;const e=a[1]??"";if(e.includes("buoyJsTop")||e==="Error"||a[2]?.includes("/js-top/")){continue}r.push({file:a[2]??"",line:Number(a[3]),col:Number(a[4])});const s=/^(react_stack_bottom_frame|runWithFiberInDEV|commitHookEffectList|flushPassive|performWork|renderWithHooks|safelyCall)/.test(e)||/^(then|catch|finally|resolve|reject|fulfilled|rejected|step|tryCallOne|tryCallTwo|tryCatch|invokeCallback|notify)$/.test(e);if(!i&&e&&e!=="anonymous"&&!s){i=e}if(r.length>=3)break}return{caller:i,frames:r}}function allowCapture(n,r){if(r-n.lastCaptureAt<STACK_CAPTURE_MIN_INTERVAL_PER_KEY_MS){return false}if(r-globalCaptureWindowStart>1e3){globalCaptureWindowStart=r;globalCapturesInWindow=0}if(globalCapturesInWindow>=STACK_CAPTURES_PER_SEC_GLOBAL)return false;globalCapturesInWindow++;n.lastCaptureAt=r;return true}function shortFile(n){if(!n)return void 0;const r=(n.split("?")[0]??n).replace(/\/\/&.*$/,"");const i=/^[a-z]+:\/\/[^/]+\/(.*)$/.exec(r);const t=i?i[1]:r;const o=t.split("/");return o.slice(-2).join("/")}function buoyJsTopOriginExists(n){return origins.has(n)}function buoyJsTopScheduleOrigin(n,r,i,t=true){const o=r;const a=typeof o.displayName==="string"&&o.displayName||typeof o.name==="string"&&o.name||"anonymous";const e=`${n}|${a}`;let s=origins.get(e);if(s?.activeRefinedKey&&!origins.has(s.activeRefinedKey)){s.activeRefinedKey=void 0}if(!s){while(origins.size>=_types.MAX_ORIGINS&&evictColdest(i));s=makeOrigin(e,n,a==="anonymous"?apiLabel(n):`${apiLabel(n)} ${a}`);origins.set(e,s)}s.scheduleCount++;if(!s.promoted&&(s.scheduleCount>=_types.PROMOTE_MIN_CALLS||s.totalMs>=_types.PROMOTE_MIN_TOTAL_MS)){s.promoted=true}if((s.promoted||n==="interval")&&t&&allowCapture(s,i)){const{caller:c,frames:m}=parseStack(new Error().stack??"");const u=m[0];if(u||c){const d=u?`${shortFile(u.file)??"?"}:${u.line}`:"?";const M=`${e}@${c??"?"}:${d}`;let l=origins.get(M);if(!l){while(origins.size>=_types.MAX_ORIGINS&&evictColdest(i));const f=a==="anonymous"?apiLabel(n):`${apiLabel(n)} ${a}`;l=makeOrigin(M,n,c?`${f} \u2190 ${c}`:a==="anonymous"?`${f} @ ${shortFile(u?.file??"")??"?"}`:f);l.caller=c;l.file=u?shortFile(u.file):void 0;l.line=u?.line;l.frames=m;l.promoted=true;l.calls=s.calls;l.totalMs=s.totalMs;l.maxMs=s.maxMs;l.scheduleCount=s.scheduleCount;l.lastSeenAt=s.lastSeenAt;l.ring.set(s.ring);l.ringStamps.set(s.ringStamps);s.calls=0;s.totalMs=0;s.maxMs=0;s.ring.fill(0);s.ringStamps.fill(-1);origins.set(M,l);(0,_symbolicate.buoyJsTopSymbolicateOrigin)(l,apiLabel(n))}s.activeRefinedKey=M}}return s.activeRefinedKey??e}function apiLabel(n){switch(n){case"timeout":return"setTimeout";case"interval":return"setInterval";case"immediate":return"setImmediate";case"raf":return"requestAnimationFrame";case"microtask":return"queueMicrotask";case"then":return"Promise.then";case"bridge":return"bridge";default:return n}}function buoyJsTopBookExclusive(n,r,i,t){const o=origins.get(n);if(!o)return;o.calls++;o.totalMs+=r;if(r>o.maxMs)o.maxMs=r;o.lastSeenAt=t;if(!o.promoted&&o.totalMs>=_types.PROMOTE_MIN_TOTAL_MS)o.promoted=true;const a=t-i;const e=a>0?Math.min(1,r/a):1;const s=Math.max(i,t-_types.WINDOW_BUCKETS*_types.BUCKET_MS);let c=(0,_aggregator.epochOf)(s);const m=(0,_aggregator.epochOf)(t);let u=s;while(c<=m){const d=(c+1)*_types.BUCKET_MS;const M=Math.min(t,d);const l=M-u;if(l>0){const f=c%_types.WINDOW_BUCKETS;if(f>=0){if(o.ringStamps[f]!==c){o.ringStamps[f]=c;o.ring[f]=0}o.ring[f]+=a>0?l*e:r}}u=M;c++}(0,_aggregator.bookAttributedRange)(i,t,r)}function labelForOrigin(n){return origins.get(n)?.label??null}function buildRows(n,r,i){const t=[];for(const e of origins.values()){const s=windowMsOf(e,n);if(s<=0&&e.totalMs<1)continue;t.push({key:e.key,label:e.label,api:e.api,file:e.file,line:e.line,windowMs:Math.round(s*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(s/r*1e3)/10):0,totalMs:Math.round(e.totalMs*10)/10,calls:e.calls,avgMs:e.calls>0?Math.round(e.totalMs/e.calls*100)/100:0,maxMs:Math.round(e.maxMs*100)/100,lastSeenAgoMs:e.lastSeenAt>0?Math.max(0,n-e.lastSeenAt):0,freezes:0,worstFreezeMs:0})}t.sort((e,s)=>s.windowMs-e.windowMs||s.totalMs-e.totalMs);const o=[];const a=[];for(const e of t){(e.windowMs>=1||e.pctOfBusy>=.5||e.freezes>0?o:a).push(e)}if(a.length>=2){o.push({key:"minor",label:`${a.length} minor origins (\u22641ms each)`,api:"other",windowMs:Math.round(a.reduce((e,s)=>e+s.windowMs,0)*10)/10,pctOfBusy:Math.round(a.reduce((e,s)=>e+s.pctOfBusy,0)*10)/10,totalMs:Math.round(a.reduce((e,s)=>e+s.totalMs,0)*10)/10,calls:a.reduce((e,s)=>e+s.calls,0),avgMs:0,maxMs:Math.max(0,...a.map(e=>e.maxMs)),lastSeenAgoMs:Math.min(...a.map(e=>e.lastSeenAgoMs)),freezes:0,worstFreezeMs:0});return o.slice(0,i)}return t.slice(0,i)}function getOriginDetailBase(n,r,i){const t=origins.get(n);if(!t)return null;const o=(0,_aggregator.epochOf)(r);const a=[];let e=0;for(let s=o-_types.WINDOW_BUCKETS+1;s<=o;s++){const c=s%_types.WINDOW_BUCKETS;const m=c>=0&&t.ringStamps[c]===s?Math.round(t.ring[c]*10)/10:0;a.push(m);e+=m}return{key:t.key,label:t.label,api:t.api,caller:t.caller,file:t.file,line:t.line,frames:t.frames,promoted:t.promoted,scheduleCount:t.scheduleCount,calls:t.calls,totalMs:Math.round(t.totalMs*10)/10,avgMs:t.calls>0?Math.round(t.totalMs/t.calls*100)/100:0,maxMs:Math.round(t.maxMs*100)/100,windowMs:Math.round(e*10)/10,pctOfBusy:i>0?Math.min(100,Math.round(e/i*1e3)/10):0,lastSeenAgoMs:t.lastSeenAt>0?Math.max(0,r-t.lastSeenAt):0,buckets:a}}function resetOrigins(){origins.clear()}function debugGetOrigin(n){return origins.get(n)}function originCount(){return origins.size}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{memo as
|
|
1
|
+
"use strict";import{memo as g,useState as x}from"react";import{ScrollView as M,StyleSheet as m,Text as l,TouchableOpacity as b,View as f}from"react-native";import{macOSColors as p,night as r}from"@buoy-gg/shared-ui";import{jsx as a,jsxs as s}from"react/jsx-runtime";const w=[{key:"windowMs",title:"RECENT"},{key:"calls",title:"CALLS"},{key:"avgMs",title:"AVG"},{key:"maxMs",title:"MAX"},{key:"totalMs",title:"TOTAL"}];export const API_BADGE={timeout:{text:"TIMEOUT",color:"#38BDF8",prefix:"setTimeout"},interval:{text:"INTERVAL",color:"#22D3EE",prefix:"setInterval"},immediate:{text:"IMMED",color:"#60A5FA",prefix:"setImmediate"},raf:{text:"RAF",color:"#34D399",prefix:"requestAnimationFrame"},microtask:{text:"MICRO",color:"#A78BFA",prefix:"queueMicrotask"},then:{text:"PROMISE",color:"#BF5AF2",prefix:"Promise.then"},bridge:{text:"BRIDGE",color:"#FBBF24",prefix:"bridge"},unattributed:{text:"SYSTEM",color:"#8E8E93"},other:{text:"OTHER",color:"#8E8E93",prefix:"other"}};export function badgeFor(t){return API_BADGE[t]??API_BADGE.other}export function displayName(t){if(t.api==="unattributed")return"events \xB7 React \xB7 native call-ins";if(t.api==="other")return t.key==="minor"?t.label:"evicted cold origins";const e=badgeFor(t.api).prefix;let i=t.label;if(e&&i.startsWith(e))i=i.slice(e.length);i=i.replace(/^[\s←@]+/,"").trim();return i.length>0?i:"anonymous"}function h(t){if(t>=1e4)return`${Math.round(t/1e3)}k`;if(t>=1e3)return`${(t/1e3).toFixed(1)}k`;if(t>=100)return`${Math.round(t)}`;return`${Math.round(t*10)/10}`}function S(t){if(t.calls<=0)return"measured by probe \xB7 not reachable from JS";return`${h(t.calls)} calls \xB7 avg ${h(t.avgMs)} \xB7 max ${h(t.maxMs)} \xB7 total ${h(t.totalMs)} ms`}const k=g(function t({row:e,rank:i,onPress:u}){const d=badgeFor(e.api);const n=u?b:f;return s(n,{style:o.row,testID:"buoy-jstop-row",...u?{onPress:()=>u(e),activeOpacity:.6}:{},children:[s(f,{style:o.topLine,children:[a(l,{style:o.rank,children:i}),a(f,{style:[o.badge,{borderColor:d.color,backgroundColor:`${d.color}1A`}],children:a(l,{style:[o.badgeText,{color:d.color}],children:d.text})}),a(l,{style:o.name,numberOfLines:1,testID:"buoy-jstop-row-name",children:displayName(e)}),e.freezes>0&&s(l,{style:[o.freezeBadge,e.worstFreezeMs>=100&&o.freezeBadgeSevere],children:["\u26A0 \xD7",e.freezes]}),s(l,{style:[o.windowMs,e.api!=="unattributed"&&e.pctOfBusy>=25&&{color:e.pctOfBusy>=50?p.semantic.error:p.semantic.warning}],children:[h(e.windowMs),a(l,{style:o.unit,children:" ms"})]}),s(l,{style:[o.pct,e.api==="unattributed"&&o.pctMuted],children:[Math.round(e.pctOfBusy),"%"]})]}),s(f,{style:o.subLine,children:[a(f,{style:o.barTrack,children:a(f,{style:[o.barFill,{width:`${Math.min(100,e.pctOfBusy)}%`,backgroundColor:d.color}]})}),a(l,{style:o.stats,numberOfLines:1,testID:"buoy-jstop-row-stats",children:S(e)})]})]})},(t,e)=>t.rank===e.rank&&t.onPress===e.onPress&&t.row.key===e.row.key&&t.row.windowMs===e.row.windowMs&&t.row.calls===e.row.calls&&t.row.maxMs===e.row.maxMs&&t.row.totalMs===e.row.totalMs&&t.row.pctOfBusy===e.row.pctOfBusy&&t.row.freezes===e.row.freezes&&t.row.worstFreezeMs===e.row.worstFreezeMs);export function TaskTable({rows:t,onSelectRow:e}){const[i,u]=x("windowMs");const d=i==="windowMs"?t:[...t].sort((n,y)=>y[i]-n[i]);return s(f,{style:c.root,children:[s(f,{style:c.sortRow,children:[a(l,{style:c.sortLabel,children:"SORT"}),w.map(n=>a(b,{onPress:()=>u(n.key),style:[c.sortChip,i===n.key&&c.sortChipOn],children:a(l,{style:[c.sortChipText,i===n.key&&c.sortChipTextOn],children:n.title})},n.key))]}),s(M,{style:c.body,children:[d.map((n,y)=>a(k,{row:n,rank:y+1,onPress:e},n.key)),d.length===0&&a(l,{style:c.empty,testID:"buoy-jstop-empty",children:"No tasks observed yet \u2014 interact with the app."})]})]})}const c=m.create({root:{flex:1,minHeight:0},sortRow:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:6,borderBottomWidth:1,borderBottomColor:r.color.border,backgroundColor:r.color.surface},sortLabel:{color:r.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginRight:2},sortChip:{borderWidth:1,borderColor:r.color.border,borderRadius:4,paddingHorizontal:7,paddingVertical:3},sortChipOn:{borderColor:r.color.accentBorderStrong,backgroundColor:r.color.accentSoft},sortChipText:{color:r.color.textTertiary,fontSize:9,fontWeight:"600",fontVariant:["tabular-nums"]},sortChipTextOn:{color:r.color.accent},body:{flex:1},empty:{color:r.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:24}});const o=m.create({row:{paddingHorizontal:10,paddingVertical:8,borderBottomWidth:m.hairlineWidth,borderBottomColor:r.color.border,gap:5},topLine:{flexDirection:"row",alignItems:"center",gap:6},rank:{width:16,color:r.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},badge:{borderWidth:1,borderRadius:3,paddingHorizontal:4,paddingVertical:1},badgeText:{fontSize:8,fontWeight:"700",letterSpacing:.4},name:{flex:1,color:r.color.text,fontSize:13,fontWeight:"500"},freezeBadge:{color:p.semantic.warning,fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},freezeBadgeSevere:{color:p.semantic.error},windowMs:{color:r.color.text,fontSize:13,fontWeight:"700",fontVariant:["tabular-nums"]},unit:{color:r.color.textTertiary,fontSize:10,fontWeight:"400"},pct:{width:38,textAlign:"right",color:r.color.textSecondary,fontSize:12,fontWeight:"600",fontVariant:["tabular-nums"]},pctMuted:{color:r.color.textTertiary},subLine:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:22},barTrack:{width:72,height:4,borderRadius:2,backgroundColor:r.color.fillSecondary,overflow:"hidden"},barFill:{height:4,borderRadius:2,opacity:.85},stats:{flex:1,color:r.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{BUCKET_MS as
|
|
1
|
+
"use strict";import{BUCKET_MS as d,WINDOW_BUCKETS as m,SNAPSHOT_ROWS as S}from"../types";import{now as h}from"./now";import{setActive as l,isActive as M}from"./state";import{installTimerPatches as w}from"./patches/timers";import{installMicrotaskPatches as y}from"./patches/microtasks";import{busyHistory as v,resetAggregator as E,windowAttributedMs as R,windowBusyMs as c,windowResidualBuckets as z}from"./aggregator";import{buildRows as P,getOriginDetailBase as _,resetOrigins as k}from"./originRegistry";import{startBusyProbe as p,stopBusyProbe as b,suppressNextGap as O}from"./busyProbe";import{getOriginals as f}from"./state";import{loadJsTopPrefs as A,saveJsTopPrefs as I}from"../utils/preferences";import{subscribeRealAppState as B}from"@buoy-gg/shared-ui";const H=d;class T{enabled=false;enabledLoaded=false;paused=false;pausedAt=0;remoteSampling=false;engineRunning=false;tiers={timers:false,promises:false,bridge:false,longtask:false};notifyHandle=null;appStateSub=null;snapshot=this.buildSnapshot();subscribers=new Set;enabledSubscribers=new Set;tierInstallers=[];longtaskProvider=null;freezeStatsProvider=null;clearHooks=[];constructor(){void A().then(t=>{this.enabledLoaded=true;if(t.enabled&&!this.enabled)this.setEnabled(true)})}subscribe(t){this.subscribers.add(t);this.syncEngineState();t(this.snapshot);return()=>{this.subscribers.delete(t);this.syncEngineState()}}subscribeEnabled(t){this.enabledSubscribers.add(t);t(this.enabled);return()=>{this.enabledSubscribers.delete(t)}}setEnabled(t){if(this.enabled===t)return;this.enabled=t;if(this.enabledLoaded)void I({enabled:t});this.enabledSubscribers.forEach(e=>{try{e(t)}catch(r){if(__DEV__){console.error("[Buoy]","[js-top] enabled subscriber threw",r)}}});this.syncEngineState()}isEnabled(){return this.enabled}setRemoteSampling(t){if(this.remoteSampling===t)return;this.remoteSampling=t;this.syncEngineState()}isRemoteSampling(){return this.remoteSampling}getStatus(){if(!this.engineRunning)return"disabled";return this.paused?"paused":"running"}pause(){if(this.paused)return;this.paused=true;this.pausedAt=h();l(false);b();this.emitSnapshot()}resume(){if(!this.paused)return;this.paused=false;if(this.engineRunning){l(true);p()}this.emitSnapshot()}clear(){k();E();for(const t of this.clearHooks){try{t()}catch{}}this.emitSnapshot()}registerClearHook(t){this.clearHooks.push(t)}getSnapshot(){return this.snapshot}getOriginDetail(t){const e=h();const r=c(e);const a=this.freezeStatsProvider?.(Date.now());const s=a?.byOrigin[t];if(t==="unattributed"){const u=z(e);const i=Math.round(u.reduce((n,g)=>n+g,0)*10)/10;return{key:t,label:"unattributed (events / React / native call-ins)",api:"unattributed",promoted:false,scheduleCount:0,calls:0,totalMs:0,avgMs:0,maxMs:0,windowMs:i,pctOfBusy:r>0?Math.min(100,Math.round(i/r*1e3)/10):0,lastSeenAgoMs:0,buckets:u,freezes:s?.count??0,worstFreezeMs:Math.round(s?.maxMs??0)}}const o=_(t,e,r);if(!o)return null;return{...o,freezes:s?.count??0,worstFreezeMs:Math.round(s?.maxMs??0)}}registerTierInstaller(t){this.tierInstallers.push(t);if(this.engineRunning){Object.assign(this.tiers,this.runInstaller(t))}}registerLongtaskProvider(t){this.longtaskProvider=t}registerFreezeStatsProvider(t){this.freezeStatsProvider=t}shouldRun(){return this.subscribers.size>0||this.remoteSampling}syncEngineState(){const t=this.shouldRun();if(t&&!this.engineRunning)this.startEngine();else if(!t&&this.engineRunning)this.stopEngine()}runInstaller(t){try{return t()}catch(e){if(__DEV__){console.error("[Buoy]","[js-top] tier installer threw",e)}return{}}}startEngine(){this.engineRunning=true;w();y();this.tiers={timers:true,promises:false,bridge:false,longtask:false};for(const t of this.tierInstallers){Object.assign(this.tiers,this.runInstaller(t))}l(!this.paused);if(!this.paused)p();try{this.appStateSub=B(()=>{O()})}catch{this.appStateSub=null}this.notifyHandle=f().setInterval(()=>this.emitSnapshot(),H);this.emitSnapshot()}stopEngine(){this.engineRunning=false;l(false);b();if(this.notifyHandle!=null){f().clearInterval(this.notifyHandle);this.notifyHandle=null}if(this.appStateSub){try{this.appStateSub.remove()}catch{}this.appStateSub=null}}buildSnapshot(){const t=this.paused?this.pausedAt:h();const e=c(t);const r=R(t);const a=Math.max(0,e-r);const s=P(t,e,S);if(a>=1){s.push({key:"unattributed",label:"unattributed (events / React / native call-ins)",api:"unattributed",windowMs:Math.round(a*10)/10,pctOfBusy:e>0?Math.min(100,Math.round(a/e*1e3)/10):0,totalMs:0,calls:0,avgMs:0,maxMs:0,lastSeenAgoMs:0,freezes:0,worstFreezeMs:0});s.sort((i,n)=>n.windowMs-i.windowMs||n.totalMs-i.totalMs)}const o=this.freezeStatsProvider?.(Date.now())??{count:0,worstMs:0,byOrigin:{}};for(const i of s){const n=o.byOrigin[i.key];if(n){i.freezes=n.count;i.worstFreezeMs=Math.round(n.maxMs)}}const u=m*d;return{ts:Date.now(),paused:this.paused,busyPct:Math.min(100,Math.round(e/u*1e3)/10),busyHistory:v(t),tiers:{...this.tiers},rows:s,totals:{attributedWindowMs:Math.round(r*10)/10,unattributedWindowMs:Math.round(a*10)/10,windowMs:u},freezeSummary:{count:o.count,worstMs:Math.round(o.worstMs)},longtasks:this.longtaskProvider?this.longtaskProvider():[]}}emitSnapshot(){this.snapshot=this.buildSnapshot();this.subscribers.forEach(t=>{try{t(this.snapshot)}catch(e){if(__DEV__){console.error("[Buoy]","[js-top] snapshot subscriber threw",e)}}})}isEngineActive(){return M()}}export const JsTopController=new T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{MAX_ORIGINS as b,PROMOTE_MIN_CALLS as _,PROMOTE_MIN_TOTAL_MS as C,WINDOW_BUCKETS as M,BUCKET_MS as O}from"../types";import{bookAttributedRange as $,epochOf as g}from"./aggregator";import{buoyJsTopSymbolicateOrigin as R}from"./symbolicate";const
|
|
1
|
+
"use strict";import{MAX_ORIGINS as b,PROMOTE_MIN_CALLS as _,PROMOTE_MIN_TOTAL_MS as C,WINDOW_BUCKETS as M,BUCKET_MS as O}from"../types";import{bookAttributedRange as $,epochOf as g}from"./aggregator";import{buoyJsTopSymbolicateOrigin as R}from"./symbolicate";const v=500;const I=20;const c=new Map;export const OTHER_KEY="other";let w=0;let S=0;function x(s,r,l){return{key:s,api:r,label:l,calls:0,totalMs:0,maxMs:0,scheduleCount:0,lastSeenAt:0,promoted:false,lastCaptureAt:0,ring:new Float64Array(M),ringStamps:new Float64Array(M).fill(-1)}}function k(s,r){const l=g(r);let e=0;for(let o=l-M+1;o<=l;o++){const a=o%M;if(a>=0&&s.ringStamps[a]===o)e+=s.ring[a]}return e}function E(s){let r=null;let l=Infinity;for(const o of c.values()){if(o.key===OTHER_KEY)continue;const a=k(o,s)*1e6+o.lastSeenAt;if(a<l){l=a;r=o}}if(!r)return false;const e=K(OTHER_KEY,"other","other (evicted origins)");e.calls+=r.calls;e.totalMs+=r.totalMs;e.maxMs=Math.max(e.maxMs,r.maxMs);e.lastSeenAt=Math.max(e.lastSeenAt,r.lastSeenAt);c.delete(r.key);return true}function K(s,r,l){let e=c.get(s);if(!e){e=x(s,r,l);c.set(s,e)}return e}export function parseStack(s){const r=[];let l;const e=s.split("\n");for(const o of e){const a=/at\s+(.*?)\s+\((?:address at\s+)?(.*?):(\d+):(\d+)\)/.exec(o)??/at\s+()(.*?):(\d+):(\d+)$/.exec(o.trim())??/^([^@\s]*)@(.+?):(\d+):(\d+)$/.exec(o.trim());if(!a)continue;const t=a[1]??"";if(t.includes("buoyJsTop")||t==="Error"||a[2]?.includes("/js-top/")){continue}r.push({file:a[2]??"",line:Number(a[3]),col:Number(a[4])});const n=/^(react_stack_bottom_frame|runWithFiberInDEV|commitHookEffectList|flushPassive|performWork|renderWithHooks|safelyCall)/.test(t)||/^(then|catch|finally|resolve|reject|fulfilled|rejected|step|tryCallOne|tryCallTwo|tryCatch|invokeCallback|notify)$/.test(t);if(!l&&t&&t!=="anonymous"&&!n){l=t}if(r.length>=3)break}return{caller:l,frames:r}}function T(s,r){if(r-s.lastCaptureAt<v){return false}if(r-w>1e3){w=r;S=0}if(S>=I)return false;S++;s.lastCaptureAt=r;return true}function A(s){if(!s)return void 0;const r=(s.split("?")[0]??s).replace(/\/\/&.*$/,"");const l=/^[a-z]+:\/\/[^/]+\/(.*)$/.exec(r);const e=l?l[1]:r;const o=e.split("/");return o.slice(-2).join("/")}export function buoyJsTopOriginExists(s){return c.has(s)}export function buoyJsTopScheduleOrigin(s,r,l,e=true){const o=r;const a=typeof o.displayName==="string"&&o.displayName||typeof o.name==="string"&&o.name||"anonymous";const t=`${s}|${a}`;let n=c.get(t);if(n?.activeRefinedKey&&!c.has(n.activeRefinedKey)){n.activeRefinedKey=void 0}if(!n){while(c.size>=b&&E(l));n=x(t,s,a==="anonymous"?h(s):`${h(s)} ${a}`);c.set(t,n)}n.scheduleCount++;if(!n.promoted&&(n.scheduleCount>=_||n.totalMs>=C)){n.promoted=true}if((n.promoted||s==="interval")&&e&&T(n,l)){const{caller:u,frames:d}=parseStack(new Error().stack??"");const f=d[0];if(f||u){const y=f?`${A(f.file)??"?"}:${f.line}`:"?";const p=`${t}@${u??"?"}:${y}`;let i=c.get(p);if(!i){while(c.size>=b&&E(l));const m=a==="anonymous"?h(s):`${h(s)} ${a}`;i=x(p,s,u?`${m} \u2190 ${u}`:a==="anonymous"?`${m} @ ${A(f?.file??"")??"?"}`:m);i.caller=u;i.file=f?A(f.file):void 0;i.line=f?.line;i.frames=d;i.promoted=true;i.calls=n.calls;i.totalMs=n.totalMs;i.maxMs=n.maxMs;i.scheduleCount=n.scheduleCount;i.lastSeenAt=n.lastSeenAt;i.ring.set(n.ring);i.ringStamps.set(n.ringStamps);n.calls=0;n.totalMs=0;n.maxMs=0;n.ring.fill(0);n.ringStamps.fill(-1);c.set(p,i);R(i,h(s))}n.activeRefinedKey=p}}return n.activeRefinedKey??t}function h(s){switch(s){case"timeout":return"setTimeout";case"interval":return"setInterval";case"immediate":return"setImmediate";case"raf":return"requestAnimationFrame";case"microtask":return"queueMicrotask";case"then":return"Promise.then";case"bridge":return"bridge";default:return s}}export function buoyJsTopBookExclusive(s,r,l,e){const o=c.get(s);if(!o)return;o.calls++;o.totalMs+=r;if(r>o.maxMs)o.maxMs=r;o.lastSeenAt=e;if(!o.promoted&&o.totalMs>=C)o.promoted=true;const a=e-l;const t=a>0?Math.min(1,r/a):1;const n=Math.max(l,e-M*O);let u=g(n);const d=g(e);let f=n;while(u<=d){const y=(u+1)*O;const p=Math.min(e,y);const i=p-f;if(i>0){const m=u%M;if(m>=0){if(o.ringStamps[m]!==u){o.ringStamps[m]=u;o.ring[m]=0}o.ring[m]+=a>0?i*t:r}}f=p;u++}$(l,e,r)}export function labelForOrigin(s){return c.get(s)?.label??null}export function buildRows(s,r,l){const e=[];for(const t of c.values()){const n=k(t,s);if(n<=0&&t.totalMs<1)continue;e.push({key:t.key,label:t.label,api:t.api,file:t.file,line:t.line,windowMs:Math.round(n*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(n/r*1e3)/10):0,totalMs:Math.round(t.totalMs*10)/10,calls:t.calls,avgMs:t.calls>0?Math.round(t.totalMs/t.calls*100)/100:0,maxMs:Math.round(t.maxMs*100)/100,lastSeenAgoMs:t.lastSeenAt>0?Math.max(0,s-t.lastSeenAt):0,freezes:0,worstFreezeMs:0})}e.sort((t,n)=>n.windowMs-t.windowMs||n.totalMs-t.totalMs);const o=[];const a=[];for(const t of e){(t.windowMs>=1||t.pctOfBusy>=.5||t.freezes>0?o:a).push(t)}if(a.length>=2){o.push({key:"minor",label:`${a.length} minor origins (\u22641ms each)`,api:"other",windowMs:Math.round(a.reduce((t,n)=>t+n.windowMs,0)*10)/10,pctOfBusy:Math.round(a.reduce((t,n)=>t+n.pctOfBusy,0)*10)/10,totalMs:Math.round(a.reduce((t,n)=>t+n.totalMs,0)*10)/10,calls:a.reduce((t,n)=>t+n.calls,0),avgMs:0,maxMs:Math.max(0,...a.map(t=>t.maxMs)),lastSeenAgoMs:Math.min(...a.map(t=>t.lastSeenAgoMs)),freezes:0,worstFreezeMs:0});return o.slice(0,l)}return e.slice(0,l)}export function getOriginDetailBase(s,r,l){const e=c.get(s);if(!e)return null;const o=g(r);const a=[];let t=0;for(let n=o-M+1;n<=o;n++){const u=n%M;const d=u>=0&&e.ringStamps[u]===n?Math.round(e.ring[u]*10)/10:0;a.push(d);t+=d}return{key:e.key,label:e.label,api:e.api,caller:e.caller,file:e.file,line:e.line,frames:e.frames,promoted:e.promoted,scheduleCount:e.scheduleCount,calls:e.calls,totalMs:Math.round(e.totalMs*10)/10,avgMs:e.calls>0?Math.round(e.totalMs/e.calls*100)/100:0,maxMs:Math.round(e.maxMs*100)/100,windowMs:Math.round(t*10)/10,pctOfBusy:l>0?Math.min(100,Math.round(t/l*1e3)/10):0,lastSeenAgoMs:e.lastSeenAt>0?Math.max(0,r-e.lastSeenAt):0,buckets:a}}export function resetOrigins(){c.clear()}export function debugGetOrigin(s){return c.get(s)}export function originCount(){return c.size}
|
|
@@ -22,6 +22,8 @@ declare class JsTopControllerImpl {
|
|
|
22
22
|
private enabled;
|
|
23
23
|
private enabledLoaded;
|
|
24
24
|
private paused;
|
|
25
|
+
/** Engine time the pause began; snapshots read the window at this moment. */
|
|
26
|
+
private pausedAt;
|
|
25
27
|
private remoteSampling;
|
|
26
28
|
private engineRunning;
|
|
27
29
|
private tiers;
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";var
|
|
2
|
-
`);for(let o of n){let a=/at\s+(.*?)\s+\((?:address at\s+)?(.*?):(\d+):(\d+)\)/.exec(o)??/at\s+()(.*?):(\d+):(\d+)$/.exec(o.trim())??/^([^@\s]*)@(.+?):(\d+):(\d+)$/.exec(o.trim());if(!a)continue;let i=a[1]??"";if(i.includes("buoyJsTop")||i==="Error"||a[2]?.includes("/js-top/"))continue;t.push({file:a[2]??"",line:Number(a[3]),col:Number(a[4])});let l=/^(react_stack_bottom_frame|runWithFiberInDEV|commitHookEffectList|flushPassive|performWork|renderWithHooks|safelyCall)/.test(i)||/^(then|catch|finally|resolve|reject|fulfilled|rejected|step|tryCallOne|tryCallTwo|tryCatch|invokeCallback|notify)$/.test(i);if(!r&&i&&i!=="anonymous"&&!l&&(r=i),t.length>=3)break}return{caller:r,frames:t}}s(Et,"parseStack");function zt(e,t){return t-e.lastCaptureAt<Dr||(t-Ct>1e3&&(Ct=t,Re=0),Re>=$r)?false:(Re++,e.lastCaptureAt=t,true)}s(zt,"allowCapture");function fe(e){if(!e)return;let t=(e.split("?")[0]??e).replace(/\/\/&.*$/,""),r=/^[a-z]+:\/\/[^/]+\/(.*)$/.exec(t);return(r?r[1]:t).split("/").slice(-2).join("/")}s(fe,"shortFile");function Bt(e){return A.has(e)}s(Bt,"buoyJsTopOriginExists");function pe(e,t,r,n=true){let o=t,a=typeof o.displayName=="string"&&o.displayName||typeof o.name=="string"&&o.name||"anonymous",i=`${e}|${a}`,l=A.get(i);if(l||(A.size>=500&&Oe(r),l=me(i,e,a==="anonymous"?_(e):`${_(e)} ${a}`),A.set(i,l)),l.scheduleCount++,!l.promoted&&(l.scheduleCount>=25||l.totalMs>=50)&&(l.promoted=true),(l.promoted||e==="interval")&&n&&zt(l,r)){let{caller:c,frames:d}=Et(new Error().stack??""),u=d[0];if(u||c){let C=u?`${fe(u.file)??"?"}:${u.line}`:"?",p=`${i}@${c??"?"}:${C}`,y=A.get(p);if(!y){A.size>=500&&Oe(r);let S=a==="anonymous"?_(e):`${_(e)} ${a}`;y=me(p,e,c?`${S} \u2190 ${c}`:a==="anonymous"?`${S} @ ${fe(u?.file??"")??"?"}`:S),y.caller=c,y.file=u?fe(u.file):void 0,y.line=u?.line,y.frames=d,y.promoted=true,y.calls=l.calls,y.totalMs=l.totalMs,y.maxMs=l.maxMs,y.scheduleCount=l.scheduleCount,y.lastSeenAt=l.lastSeenAt,y.ring.set(l.ring),y.ringStamps.set(l.ringStamps),l.calls=0,l.totalMs=0,l.maxMs=0,l.ring.fill(0),l.ringStamps.fill(-1),A.set(p,y),kt(y,_(e))}l.activeRefinedKey=p}}return l.activeRefinedKey??i}s(pe,"buoyJsTopScheduleOrigin");function _(e){switch(e){case"timeout":return"setTimeout";case"interval":return"setInterval";case"immediate":return"setImmediate";case"raf":return"requestAnimationFrame";case"microtask":return"queueMicrotask";case"then":return"Promise.then";case"bridge":return"bridge";default:return e}}s(_,"apiLabel");function Rt(e,t,r,n){let o=A.get(e);if(!o)return;o.calls++,o.totalMs+=t,t>o.maxMs&&(o.maxMs=t),o.lastSeenAt=n,!o.promoted&&o.totalMs>=50&&(o.promoted=true);let a=n-r,i=a>0?Math.min(1,t/a):1,l=Math.max(r,n-5e3),c=L(l),d=L(n),u=l;for(;c<=d;){let C=(c+1)*250,p=Math.min(n,C),y=p-u;if(y>0){let S=c%20;S>=0&&(o.ringStamps[S]!==c&&(o.ringStamps[S]=c,o.ring[S]=0),o.ring[S]+=a>0?y*i:t)}u=p,c++}ct(r,n,t)}s(Rt,"buoyJsTopBookExclusive");function It(e){return A.get(e)?.label??null}s(It,"labelForOrigin");function Ot(e,t,r){let n=[];for(let i of A.values()){let l=Ie(i,e);l<=0&&i.totalMs<1||n.push({key:i.key,label:i.label,api:i.api,file:i.file,line:i.line,windowMs:Math.round(l*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(l/t*1e3)/10):0,totalMs:Math.round(i.totalMs*10)/10,calls:i.calls,avgMs:i.calls>0?Math.round(i.totalMs/i.calls*100)/100:0,maxMs:Math.round(i.maxMs*100)/100,lastSeenAgoMs:i.lastSeenAt>0?Math.max(0,e-i.lastSeenAt):0,freezes:0,worstFreezeMs:0})}n.sort((i,l)=>l.windowMs-i.windowMs||l.totalMs-i.totalMs);let o=[],a=[];for(let i of n)(i.windowMs>=1||i.pctOfBusy>=.5||i.freezes>0?o:a).push(i);return a.length>=2?(o.push({key:"minor",label:`${a.length} minor origins (\u22641ms each)`,api:"other",windowMs:Math.round(a.reduce((i,l)=>i+l.windowMs,0)*10)/10,pctOfBusy:Math.round(a.reduce((i,l)=>i+l.pctOfBusy,0)*10)/10,totalMs:Math.round(a.reduce((i,l)=>i+l.totalMs,0)*10)/10,calls:a.reduce((i,l)=>i+l.calls,0),avgMs:0,maxMs:Math.max(0,...a.map(i=>i.maxMs)),lastSeenAgoMs:Math.min(...a.map(i=>i.lastSeenAgoMs)),freezes:0,worstFreezeMs:0}),o.slice(0,r)):n.slice(0,r)}s(Ot,"buildRows");function Pt(e,t,r){let n=A.get(e);if(!n)return null;let o=L(t),a=[],i=0;for(let l=o-20+1;l<=o;l++){let c=l%20,d=c>=0&&n.ringStamps[c]===l?Math.round(n.ring[c]*10)/10:0;a.push(d),i+=d}return{key:n.key,label:n.label,api:n.api,caller:n.caller,file:n.file,line:n.line,frames:n.frames,promoted:n.promoted,scheduleCount:n.scheduleCount,calls:n.calls,totalMs:Math.round(n.totalMs*10)/10,avgMs:n.calls>0?Math.round(n.totalMs/n.calls*100)/100:0,maxMs:Math.round(n.maxMs*100)/100,windowMs:Math.round(i*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(i/r*1e3)/10):0,lastSeenAgoMs:n.lastSeenAt>0?Math.max(0,t-n.lastSeenAt):0,buckets:a}}s(Pt,"getOriginDetailBase");function Ft(){A.clear()}s(Ft,"resetOrigins");var jr=32,Q=[],Wr=20,Lt=64,Dt=new Array(Lt).fill(null),Pe=0;function $t(){return Dt}s($t,"recentIntervals");function Fe(e,t){let r=F(),n=Q.length>0?Q[Q.length-1]:null,o=null;Q.length<jr&&(o={originKey:e,start:r,childrenMs:0},Q.push(o));try{return t()}finally{try{if(o){Q.pop();let a=F(),i=a-r,l=Math.max(0,i-o.childrenMs);n&&(n.childrenMs+=i),Rt(e,l,r,a),!n&&i>=Wr&&(Dt[Pe]={originKey:e,start:r,end:a},Pe=(Pe+1)%Lt)}}catch{}}}s(Fe,"buoyJsTopRunFrame");function J(e,t){if(typeof e!="function"||e[st])return e;let r=H()?pe(t,e,F()):null,n=s(function(...o){return H()?((r===null||!Bt(r))&&(r=pe(t,e,F(),false)),Fe(r,()=>e.apply(this,o))):e.apply(this,o)},"buoyJsTopTaskWrapper");return n[st]=true,n}s(J,"buoyJsTopWrapTask");function Le(e,t,r){if(!H())return r();let n=pe(e,{name:t},F());return Fe(n,r)}s(Le,"buoyJsTopRunAs");function De(){let e=de();if(typeof f.setTimeout=="function"&&!f.setTimeout[k]){let t=s(function(r,n,...o){let a=J(r,"timeout");return e.setTimeout(a,n,...o)},"buoyJsTopSetTimeout");t[k]=true,f.setTimeout=t}if(typeof f.setInterval=="function"&&!f.setInterval[k]){let t=s(function(r,n,...o){let a=J(r,"interval");return e.setInterval(a,n,...o)},"buoyJsTopSetInterval");t[k]=true,f.setInterval=t}if(typeof f.setImmediate=="function"&&!f.setImmediate[k]&&e.setImmediate){let t=s(function(r,...n){let o=J(r,"immediate");return e.setImmediate(o,...n)},"buoyJsTopSetImmediate");t[k]=true,f.setImmediate=t}if(typeof f.requestAnimationFrame=="function"&&!f.requestAnimationFrame[k]&&e.requestAnimationFrame){let t=s(function(r){let n=J(r,"raf");return e.requestAnimationFrame(n)},"buoyJsTopRequestAnimationFrame");t[k]=true,f.requestAnimationFrame=t}}s(De,"installTimerPatches");function $e(){let e=de();if(typeof f.queueMicrotask=="function"&&!f.queueMicrotask[k]&&e.queueMicrotask){let t=s(function(r){let n=J(r,"microtask");return e.queueMicrotask(n)},"buoyJsTopQueueMicrotask");t[k]=true,f.queueMicrotask=t}}s($e,"installMicrotaskPatches");var je=16,Hr=100,Vr=3,Nr=8,oe=null,ae=0,be=false,ie=[],G=1/0,Y=0,We=je;function jt(){let e=F(),t=ae>0?e-ae:0;if(ae=e,be){be=false,G=1/0,Y=e;return}if(t<=0)return;t<Hr&&(t<G&&(G=t),Y===0&&(Y=e),e-Y>=1e3&&(ie.push(G),ie.length>Vr&&ie.shift(),We=Math.max(Nr,Math.min(...ie)),G=1/0,Y=e));let r=t-We;r>1&&ut(e-r,e)}s(jt,"buoyJsTopProbeTick");function He(){if(oe!=null)return;let e=re();ae=F(),be=false,ie=[],G=1/0,Y=0,We=je,oe=e.setInterval(jt,je)}s(He,"startBusyProbe");function Ve(){oe!=null&&(re().clearInterval(oe),oe=null),ae=0}s(Ve,"stopBusyProbe");function Wt(){be=true}s(Wt,"suppressNextGap");import{definePersistedSetting as Jr}from"@buoy-gg/shared-ui/web";var Kr="@react_buoy/js-top/prefs",qr={enabled:false},Ht=Jr(Kr,qr,{sanitize:s(e=>({enabled:e.enabled===true}),"sanitize")});async function Vt(){return Ht.load()}s(Vt,"loadJsTopPrefs");async function Nt(e){await Ht.save(e)}s(Nt,"saveJsTopPrefs");import{subscribeRealAppState as Ur}from"@buoy-gg/shared-ui/web";var _r=250,Jt=class Lo{constructor(){this.enabled=false;this.enabledLoaded=false;this.paused=false;this.remoteSampling=false;this.engineRunning=false;this.tiers={timers:false,promises:false,bridge:false,longtask:false};this.notifyHandle=null;this.appStateSub=null;this.snapshot=this.buildSnapshot();this.subscribers=new Set;this.enabledSubscribers=new Set;this.tierInstallers=[];this.longtaskProvider=null;this.freezeStatsProvider=null;this.clearHooks=[];Vt().then(t=>{this.enabledLoaded=true,t.enabled&&!this.enabled&&this.setEnabled(true)})}subscribe(t){return this.subscribers.add(t),this.syncEngineState(),t(this.snapshot),()=>{this.subscribers.delete(t),this.syncEngineState()}}subscribeEnabled(t){return this.enabledSubscribers.add(t),t(this.enabled),()=>{this.enabledSubscribers.delete(t)}}setEnabled(t){this.enabled!==t&&(this.enabled=t,this.enabledLoaded&&Nt({enabled:t}),this.enabledSubscribers.forEach(r=>{try{r(t)}catch(n){ee&&console.error("[Buoy]","[js-top] enabled subscriber threw",n)}}),this.syncEngineState())}isEnabled(){return this.enabled}setRemoteSampling(t){this.remoteSampling!==t&&(this.remoteSampling=t,this.syncEngineState())}isRemoteSampling(){return this.remoteSampling}getStatus(){return this.engineRunning?this.paused?"paused":"running":"disabled"}pause(){this.paused||(this.paused=true,te(false),Ve(),this.emitSnapshot())}resume(){this.paused&&(this.paused=false,this.engineRunning&&(te(true),He()),this.emitSnapshot())}clear(){Ft(),pt();for(let t of this.clearHooks)try{t()}catch{}this.emitSnapshot()}registerClearHook(t){this.clearHooks.push(t)}getSnapshot(){return this.snapshot}getOriginDetail(t){let r=F(),n=ze(r),o=this.freezeStatsProvider?.(Date.now())?.byOrigin[t];if(t==="unattributed"){let i=mt(r),l=Math.round(i.reduce((c,d)=>c+d,0)*10)/10;return{key:t,label:"unattributed (events / React / native call-ins)",api:"unattributed",promoted:false,scheduleCount:0,calls:0,totalMs:0,avgMs:0,maxMs:0,windowMs:l,pctOfBusy:n>0?Math.min(100,Math.round(l/n*1e3)/10):0,lastSeenAgoMs:0,buckets:i,freezes:o?.count??0,worstFreezeMs:Math.round(o?.maxMs??0)}}let a=Pt(t,r,n);return a?{...a,freezes:o?.count??0,worstFreezeMs:Math.round(o?.maxMs??0)}:null}registerTierInstaller(t){this.tierInstallers.push(t),this.engineRunning&&Object.assign(this.tiers,this.runInstaller(t))}registerLongtaskProvider(t){this.longtaskProvider=t}registerFreezeStatsProvider(t){this.freezeStatsProvider=t}shouldRun(){return this.subscribers.size>0||this.remoteSampling}syncEngineState(){let t=this.shouldRun();t&&!this.engineRunning?this.startEngine():!t&&this.engineRunning&&this.stopEngine()}runInstaller(t){try{return t()}catch(r){return ee&&console.error("[Buoy]","[js-top] tier installer threw",r),{}}}startEngine(){this.engineRunning=true,De(),$e(),this.tiers={timers:true,promises:false,bridge:false,longtask:false};for(let t of this.tierInstallers)Object.assign(this.tiers,this.runInstaller(t));te(!this.paused),this.paused||He();try{this.appStateSub=Ur(()=>{Wt()})}catch{this.appStateSub=null}this.notifyHandle=re().setInterval(()=>this.emitSnapshot(),_r),this.emitSnapshot()}stopEngine(){if(this.engineRunning=false,te(false),Ve(),this.notifyHandle!=null&&(re().clearInterval(this.notifyHandle),this.notifyHandle=null),this.appStateSub){try{this.appStateSub.remove()}catch{}this.appStateSub=null}}buildSnapshot(){let t=F(),r=ze(t),n=ht(t),o=Math.max(0,r-n),a=Ot(t,r,30);o>=1&&(a.push({key:"unattributed",label:"unattributed (events / React / native call-ins)",api:"unattributed",windowMs:Math.round(o*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(o/r*1e3)/10):0,totalMs:0,calls:0,avgMs:0,maxMs:0,lastSeenAgoMs:0,freezes:0,worstFreezeMs:0}),a.sort((c,d)=>d.windowMs-c.windowMs||d.totalMs-c.totalMs));let i=this.freezeStatsProvider?.(Date.now())??{count:0,worstMs:0,byOrigin:{}};for(let c of a){let d=i.byOrigin[c.key];d&&(c.freezes=d.count,c.worstFreezeMs=Math.round(d.maxMs))}let l=5e3;return{ts:Date.now(),paused:this.paused,busyPct:Math.min(100,Math.round(r/l*1e3)/10),busyHistory:ft(t),tiers:{...this.tiers},rows:a,totals:{attributedWindowMs:Math.round(n*10)/10,unattributedWindowMs:Math.round(o*10)/10,windowMs:l},freezeSummary:{count:i.count,worstMs:Math.round(i.worstMs)},longtasks:this.longtaskProvider?this.longtaskProvider():[]}}emitSnapshot(){this.snapshot=this.buildSnapshot(),this.subscribers.forEach(t=>{try{t(this.snapshot)}catch(r){ee&&console.error("[Buoy]","[js-top] snapshot subscriber threw",r)}})}isEngineActive(){return H()}};s(Jt,"JsTopControllerImpl");var Qr=Jt,m=new Qr;function ge(e,t){let r=e[t];if(typeof r!="function")return false;if(r[k])return true;let n=s(function(...o){for(let a=0;a<o.length;a++)typeof o[a]=="function"&&(o[a]=J(o[a],"then"));return r.apply(this,o)},"patched");return n[k]=true,Object.defineProperty(n,"name",{value:t,configurable:true}),e[t]=n,true}s(ge,"patchMethod");function Kt(){let e=f.Promise?.prototype;if(!e)return{promises:false};let t=ge(e,"then");return ge(e,"catch"),ge(e,"finally"),{promises:t}}s(Kt,"installPromisePatches");function qt(){let e=f.__fbBatchedBridge;if(!e)return{bridge:false};let t=false;if(typeof e.callFunctionReturnFlushedQueue=="function"&&!e.callFunctionReturnFlushedQueue[k]){let n=e.callFunctionReturnFlushedQueue.bind(e),o=s(function(a,i,l){return H()?Le("bridge",`${a}.${i}`,()=>n(a,i,l)):n(a,i,l)},"buoyJsTopCallFunction");o[k]=true,e.callFunctionReturnFlushedQueue=o,t=true}if(typeof e.invokeCallbackAndReturnFlushedQueue=="function"&&!e.invokeCallbackAndReturnFlushedQueue[k]){let n=e.invokeCallbackAndReturnFlushedQueue.bind(e),o=s(function(a,i){return H()?Le("bridge","nativeModuleCallback",()=>n(a,i)):n(a,i)},"buoyJsTopInvokeCallback");o[k]=true,e.invokeCallbackAndReturnFlushedQueue=o,t=true}let r=e.callFunctionReturnFlushedQueue?.[k]===true;return{bridge:t||r}}s(qt,"installBridgePatch");var Gr=40,Yr=6e4,Zr="unattributed",Ut=false,ye=false,Z=[];function _t(e,t){let r=e+t,n=null,o=0;for(let a of $t()){if(!a)continue;let i=Math.min(r,a.end)-Math.max(e,a.start);i>o&&(o=i,n=a.originKey)}return n}s(_t,"correlate");function Qt(){if(Ut)return{longtask:ye};Ut=true;let e=f.PerformanceObserver;if(typeof e!="function")return{longtask:false};try{new e(t=>{if(H())try{for(let r of t.getEntries()){if(r.entryType!=="longtask")continue;let n=r.startTime,o=r.duration;dt(n,n+o),Z.push({start:n,duration:o,at:Date.now(),originKey:_t(n,o)}),Z.length>Gr&&Z.shift()}}catch{}}).observe({entryTypes:["longtask"]}),ye=true}catch{ye=false}return{longtask:ye}}s(Qt,"installLongtaskObserver");function Gt(){return Z.map(e=>({start:e.start,duration:e.duration,at:e.at,originLabel:e.originKey?It(e.originKey):null}))}s(Gt,"getLongtasks");function Yt(e){let t={},r=0,n=0;for(let o of Z){if(o.at>0&&e-o.at>Yr)continue;r++,o.duration>n&&(n=o.duration);let a=o.originKey??Zr,i=t[a];i?(i.count++,o.duration>i.maxMs&&(i.maxMs=o.duration)):t[a]={count:1,maxMs:o.duration}}return{count:r,worstMs:n,byOrigin:t}}s(Yt,"getFreezeStats");function Zt(){Z.length=0}s(Zt,"clearLongtasks");var Xr={version:1,getSnapshot:s(()=>({live:m.getSnapshot(),enabled:m.isEnabled()||m.isRemoteSampling()}),"getSnapshot"),subscribe:s(e=>{let t=m.subscribe(()=>e()),r=m.subscribeEnabled(()=>e());return()=>{t(),r()}},"subscribe"),actions:{setEnabled:s(e=>{let t=e.enabled;m.setRemoteSampling(t)},"setEnabled"),pause:s(()=>m.pause(),"pause"),resume:s(()=>m.resume(),"resume"),clear:s(()=>m.clear(),"clear"),getOriginDetail:s(e=>m.getOriginDetail(e.key),"getOriginDetail"),sample:s(async e=>{let t=e,r=Math.min(Math.max(t?.durationMs??3e3,250),3e4),n=m.isRemoteSampling()||m.isEnabled();n||m.setRemoteSampling(true),t?.clearFirst&&m.clear();try{return await new Promise(o=>setTimeout(o,r)),m.getSnapshot()}finally{n||m.setRemoteSampling(false)}},"sample")}};import{useCallback as en,useEffect as tn,useMemo as rn,useState as Xt}from"react";var er={};Br(er,{AccessibilityInfo:()=>sn,ActivityIndicator:()=>so,Alert:()=>co,Animated:()=>ln,AppRegistry:()=>cn,AppState:()=>dn,Appearance:()=>un,BackHandler:()=>hn,Button:()=>lo,CheckBox:()=>En,Clipboard:()=>mn,DeviceEventEmitter:()=>Jn,Dimensions:()=>fn,Easing:()=>pn,FlatList:()=>zn,I18nManager:()=>bn,Image:()=>Bn,ImageBackground:()=>Rn,InteractionManager:()=>yn,Keyboard:()=>gn,KeyboardAvoidingView:()=>In,LayoutAnimation:()=>wn,Linking:()=>Mn,LogBox:()=>Nn,Modal:()=>ao,NativeEventEmitter:()=>xn,NativeModules:()=>an,PanResponder:()=>Sn,Picker:()=>On,PixelRatio:()=>vn,Platform:()=>kn,Pressable:()=>oo,ProgressBar:()=>Pn,RefreshControl:()=>Fn,SafeAreaView:()=>Ln,ScrollView:()=>Ke,SectionList:()=>Dn,Share:()=>Tn,StatusBar:()=>$n,StyleSheet:()=>V,Switch:()=>io,Text:()=>h,TextInput:()=>to,Touchable:()=>jn,TouchableHighlight:()=>ro,TouchableNativeFeedback:()=>Wn,TouchableOpacity:()=>le,TouchableWithoutFeedback:()=>no,UIManager:()=>Cn,Vibration:()=>An,View:()=>b,VirtualizedList:()=>Hn,YellowBox:()=>Vn,findNodeHandle:()=>uo,unstable_createElement:()=>on,useColorScheme:()=>Kn,useLocaleContext:()=>qn,useWindowDimensions:()=>Un});Rr(er,nn);import*as nn from"react-native-web";import{unstable_createElement as on,NativeModules as an,AccessibilityInfo as sn,Animated as ln,Appearance as un,AppRegistry as cn,AppState as dn,BackHandler as hn,Clipboard as mn,Dimensions as fn,Easing as pn,I18nManager as bn,Keyboard as gn,InteractionManager as yn,LayoutAnimation as wn,Linking as Mn,NativeEventEmitter as xn,PanResponder as Sn,PixelRatio as vn,Platform as kn,Share as Tn,StyleSheet as V,UIManager as Cn,Vibration as An,CheckBox as En,FlatList as zn,Image as Bn,ImageBackground as Rn,KeyboardAvoidingView as In,Picker as On,ProgressBar as Pn,RefreshControl as Fn,SafeAreaView as Ln,SectionList as Dn,StatusBar as $n,Touchable as jn,TouchableNativeFeedback as Wn,VirtualizedList as Hn,YellowBox as Vn,LogBox as Nn,DeviceEventEmitter as Jn,useColorScheme as Kn,useLocaleContext as qn,useWindowDimensions as Un}from"react-native-web";import*as B from"react-native-web";import{createElement as Ne,forwardRef as tr,useCallback as _n,useRef as Qn}from"react";import{useEffect as Gn,useState as Yn}from"react";import{createPortal as Zn}from"react-dom";var Xn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as eo}from"react/jsx-runtime";var se=Symbol.for("@buoy-gg/portal-host"),rr=s(e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"},"isTextField");function Je(){let e=document;if(e[se])return e[se].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Xn});let r=s(()=>{let u=document.fullscreenElement,C=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==C&&C.appendChild(t)},"move"),n=new Map,o=s(u=>{(!t.contains(u.target)||!rr(u.target))&&n.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},"down"),a=s(u=>{n.delete(u.code||u.key)},"up"),i=s(()=>n.clear(),"clear"),l=s(()=>{let u=[...n.values()];n.clear();for(let C of u)document.dispatchEvent(new KeyboardEvent("keyup",{...C,bubbles:true}))},"focus"),c=s(u=>{rr(u.target)&&u.stopPropagation()},"key"),d=s(u=>u.stopPropagation(),"wheel");return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",a,true),window.addEventListener("blur",i),t.addEventListener("focusin",l),t.addEventListener("keydown",c),t.addEventListener("keyup",c),t.addEventListener("keypress",c),t.addEventListener("wheel",d,{passive:true}),e[se]={host:t,users:0,dispose:s(()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",a,true),window.removeEventListener("blur",i),t.remove(),delete e[se]},"dispose")},t}s(Je,"getBuoyPortalHost");function nr({children:e}){let[t,r]=Yn(null);return Gn(()=>{let n=Je(),o=document[se];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?Zn(eo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}s(nr,"BuoyPortal");function R(e){let t=tr((n,o)=>{let{accessibilityState:a,accessibilityValue:i,...l}=n;for(let c of["busy","checked","disabled","expanded","selected"])a?.[c]!==void 0&&l[`aria-${c}`]===void 0&&(l[`aria-${c}`]=a[c]);for(let[c,d]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[c]!==void 0&&l[`aria-${d}`]===void 0&&(l[`aria-${d}`]=i[c]);return Ne(e,{...l,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}s(R,"withAccessibility");var b=R(B.View),h=R(B.Text),to=R(B.TextInput),le=R(B.TouchableOpacity),ro=R(B.TouchableHighlight),no=R(B.TouchableWithoutFeedback),oo=R(B.Pressable),Ke=R(B.ScrollView),or=tr((e,t)=>{let r=Qn(null),n=_n(o=>{if(o){let a=o;for(;a.parentElement&&a.parentElement!==document.body;)a=a.parentElement;a.parentElement===document.body&&(r.current=a,Object.assign(a.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Je().appendChild(a))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return Ne(nr,null,Ne(B.Modal,{...e,ref:n}))});or.displayName="Modal";var ao=R(or),io=R(B.Switch),so=R(B.ActivityIndicator),lo=R(B.Button),uo=B.findNodeHandle,co={alert(e,t,r,n){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(a),t){let d=document.createElement("p");d.textContent=t,d.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(d)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],c=s(()=>{o.close?.(),o.remove()},"close");for(let d of l){let u=document.createElement("button");u.type="button",u.textContent=d.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{c(),d.onPress?.()},i.appendChild(u)}o.addEventListener("cancel",d=>{d.preventDefault(),n?.cancelable!==false&&(c(),n?.onDismiss?.())}),o.appendChild(i),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{Activity as ho,JsModal as mo,macOSColors as P,night as z,ModalHeader as ue,Pause as fo,Play as po,Trash2 as bo}from"@buoy-gg/shared-ui/web";import{memo as go}from"react";import{macOSColors as qe}from"@buoy-gg/shared-ui/web";import{jsx as ar}from"react/jsx-runtime";var yo=60;function ir(e){return e>=80?qe.semantic.error:e>=40?qe.semantic.warning:qe.semantic.success}s(ir,"barColor");var wo=go(s(function({history:e}){let t=e.slice(-yo);return ar(b,{style:sr.row,pointerEvents:"none",children:t.map((r,n)=>ar(b,{style:[sr.bar,{height:Math.max(2,r/100*28),backgroundColor:ir(r)}]},`b${n}`))})},"BusySparkline")),sr=V.create({row:{flexDirection:"row",alignItems:"flex-end",gap:1,height:28,alignSelf:"stretch"},bar:{flex:1,maxWidth:6,borderRadius:1,opacity:.9}});import{memo as Mo,useState as xo}from"react";import{macOSColors as we,night as v}from"@buoy-gg/shared-ui/web";import{jsx as I,jsxs as D}from"react/jsx-runtime";var So=[{key:"windowMs",title:"RECENT"},{key:"calls",title:"CALLS"},{key:"avgMs",title:"AVG"},{key:"maxMs",title:"MAX"},{key:"totalMs",title:"TOTAL"}],lr={timeout:{text:"TIMEOUT",color:"#38BDF8",prefix:"setTimeout"},interval:{text:"INTERVAL",color:"#22D3EE",prefix:"setInterval"},immediate:{text:"IMMED",color:"#60A5FA",prefix:"setImmediate"},raf:{text:"RAF",color:"#34D399",prefix:"requestAnimationFrame"},microtask:{text:"MICRO",color:"#A78BFA",prefix:"queueMicrotask"},then:{text:"PROMISE",color:"#BF5AF2",prefix:"Promise.then"},bridge:{text:"BRIDGE",color:"#FBBF24",prefix:"bridge"},unattributed:{text:"SYSTEM",color:"#8E8E93"},other:{text:"OTHER",color:"#8E8E93",prefix:"other"}};function Me(e){return lr[e]??lr.other}s(Me,"badgeFor");function Ue(e){if(e.api==="unattributed")return"events \xB7 React \xB7 native call-ins";if(e.api==="other")return"evicted cold origins";let t=Me(e.api).prefix,r=e.label;return t&&r.startsWith(t)&&(r=r.slice(t.length)),r=r.replace(/^[\s←@]+/,"").trim(),r.length>0?r:"anonymous"}s(Ue,"displayName");function X(e){return e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e>=100?`${Math.round(e)}`:`${Math.round(e*10)/10}`}s(X,"fmt");function ur(e){return e.calls<=0?"measured by probe \xB7 not reachable from JS":`${X(e.calls)} calls \xB7 avg ${X(e.avgMs)} \xB7 max ${X(e.maxMs)} \xB7 total ${X(e.totalMs)} ms`}s(ur,"statsLine");var vo=Mo(s(function({row:e,rank:t,onPress:r}){let n=Me(e.api);return D(r?le:b,{style:E.row,testID:"buoy-jstop-row",...r?{onPress:s(()=>r(e),"onPress"),activeOpacity:.6}:{},children:[D(b,{style:E.topLine,children:[I(h,{style:E.rank,children:t}),I(b,{style:[E.badge,{borderColor:n.color,backgroundColor:`${n.color}1A`}],children:I(h,{style:[E.badgeText,{color:n.color}],children:n.text})}),I(h,{style:E.name,numberOfLines:1,testID:"buoy-jstop-row-name",children:Ue(e)}),e.freezes>0&&D(h,{style:[E.freezeBadge,e.worstFreezeMs>=100&&E.freezeBadgeSevere],children:["\u26A0 \xD7",e.freezes]}),D(h,{style:[E.windowMs,e.api!=="unattributed"&&e.pctOfBusy>=25&&{color:e.pctOfBusy>=50?we.semantic.error:we.semantic.warning}],children:[X(e.windowMs),I(h,{style:E.unit,children:" ms"})]}),D(h,{style:[E.pct,e.api==="unattributed"&&E.pctMuted],children:[Math.round(e.pctOfBusy),"%"]})]}),D(b,{style:E.subLine,children:[I(b,{style:E.barTrack,children:I(b,{style:[E.barFill,{width:`${Math.min(100,e.pctOfBusy)}%`,backgroundColor:n.color}]})}),I(h,{style:E.stats,numberOfLines:1,testID:"buoy-jstop-row-stats",children:ur(e)})]})]})},"TaskRow"),(e,t)=>e.rank===t.rank&&e.onPress===t.onPress&&e.row.key===t.row.key&&e.row.windowMs===t.row.windowMs&&e.row.calls===t.row.calls&&e.row.maxMs===t.row.maxMs&&e.row.totalMs===t.row.totalMs&&e.row.pctOfBusy===t.row.pctOfBusy&&e.row.freezes===t.row.freezes&&e.row.worstFreezeMs===t.row.worstFreezeMs);function cr({rows:e,onSelectRow:t}){let[r,n]=xo("windowMs"),o=r==="windowMs"?e:[...e].sort((a,i)=>i[r]-a[r]);return D(b,{style:$.root,children:[D(b,{style:$.sortRow,children:[I(h,{style:$.sortLabel,children:"SORT"}),So.map(a=>I(le,{onPress:()=>n(a.key),style:[$.sortChip,r===a.key&&$.sortChipOn],children:I(h,{style:[$.sortChipText,r===a.key&&$.sortChipTextOn],children:a.title})},a.key))]}),D(Ke,{style:$.body,children:[o.map((a,i)=>I(vo,{row:a,rank:i+1,onPress:t},a.key)),o.length===0&&I(h,{style:$.empty,testID:"buoy-jstop-empty",children:"No tasks observed yet \u2014 interact with the app."})]})]})}s(cr,"TaskTable");var $=V.create({root:{flex:1,minHeight:0},sortRow:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:6,borderBottomWidth:1,borderBottomColor:v.color.border,backgroundColor:v.color.surface},sortLabel:{color:v.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginRight:2},sortChip:{borderWidth:1,borderColor:v.color.border,borderRadius:4,paddingHorizontal:7,paddingVertical:3},sortChipOn:{borderColor:v.color.accentBorderStrong,backgroundColor:v.color.accentSoft},sortChipText:{color:v.color.textTertiary,fontSize:9,fontWeight:"600",fontVariant:["tabular-nums"]},sortChipTextOn:{color:v.color.accent},body:{flex:1},empty:{color:v.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:24}}),E=V.create({row:{paddingHorizontal:10,paddingVertical:8,borderBottomWidth:V.hairlineWidth,borderBottomColor:v.color.border,gap:5},topLine:{flexDirection:"row",alignItems:"center",gap:6},rank:{width:16,color:v.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},badge:{borderWidth:1,borderRadius:3,paddingHorizontal:4,paddingVertical:1},badgeText:{fontSize:8,fontWeight:"700",letterSpacing:.4},name:{flex:1,color:v.color.text,fontSize:13,fontWeight:"500"},freezeBadge:{color:we.semantic.warning,fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},freezeBadgeSevere:{color:we.semantic.error},windowMs:{color:v.color.text,fontSize:13,fontWeight:"700",fontVariant:["tabular-nums"]},unit:{color:v.color.textTertiary,fontSize:10,fontWeight:"400"},pct:{width:38,textAlign:"right",color:v.color.textSecondary,fontSize:12,fontWeight:"600",fontVariant:["tabular-nums"]},pctMuted:{color:v.color.textTertiary},subLine:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:22},barTrack:{width:72,height:4,borderRadius:2,backgroundColor:v.color.fillSecondary,overflow:"hidden"},barFill:{height:4,borderRadius:2,opacity:.85},stats:{flex:1,color:v.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]}});import{memo as ko}from"react";import{macOSColors as xe,night as T,useSafeAreaInsets as To}from"@buoy-gg/shared-ui/web";import{Fragment as dr,jsx as M,jsxs as O}from"react/jsx-runtime";var hr={timeout:"Work scheduled with setTimeout. Time shown is the callback's exclusive run time on the JS thread.",interval:"A repeating setInterval. One scheduling site, many runs \u2014 a hot interval is the classic silent JS-FPS killer.",immediate:"Work scheduled with setImmediate \u2014 runs at the end of the current event-loop turn.",raf:"requestAnimationFrame work \u2014 runs once per frame while scheduled. Cost here directly trades against 60fps.",microtask:"queueMicrotask work \u2014 runs after the current task, before the thread yields.",then:"Promise reaction (.then/.catch/.finally). Named by the function that attached the reaction. Note: async/await bodies bypass .then and land in the System row instead.",bridge:"A native\u2192JS call-in over the legacy bridge (events, module callbacks), measured as its un-nested remainder.",unattributed:"Thread time the probe measured but no JS wrapper could claim: touch handlers, React commits, native call-ins, and async/await bodies. High here on New Architecture is normal \u2014 it's where UI work lives.",other:"Origins evicted from the table when the registry hit its cap \u2014 their totals are preserved here."};function mr(e){return hr[e]??hr.other}s(mr,"explainerFor");function N(e){return e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e>=100?`${Math.round(e)}`:`${Math.round(e*100)/100}`}s(N,"fmt");function fr(e){if(e<=0)return"\u2014";let t=e/1e3;return t<1?"just now":t<60?`${Math.round(t)}s ago`:`${Math.floor(t/60)}m ago`}s(fr,"agoFmt");function j({label:e,value:t,accent:r}){return O(b,{style:g.stat,children:[M(h,{style:g.statLabel,children:e}),M(h,{style:[g.statValue,r?{color:r}:null],children:t})]})}s(j,"Stat");var Co=ko(s(function({detail:e}){let t=Me(e.api),r=To({minBottom:12}),n=Math.max(1,...e.buckets);return O(Ke,{style:g.root,testID:"buoy-jstop-detail",contentContainerStyle:{paddingBottom:r.bottom},children:[O(b,{style:g.identityRow,children:[M(b,{style:[g.badge,{borderColor:t.color,backgroundColor:`${t.color}1A`}],children:M(h,{style:[g.badgeText,{color:t.color}],children:t.text})}),M(h,{style:g.name,numberOfLines:2,testID:"buoy-jstop-detail-name",children:Ue(e)})]}),M(h,{style:g.explainer,children:mr(e.api)}),M(h,{style:g.sectionTitle,children:"ACTIVITY \xB7 LAST 5S"}),M(b,{style:g.chartRow,children:e.buckets.map((o,a)=>M(b,{style:g.chartBarSlot,children:M(b,{style:[g.chartBar,{height:Math.max(2,o/n*44),backgroundColor:t.color}]})},`bk${a}`))}),O(b,{style:g.chartLegend,children:[O(h,{style:g.chartLegendText,children:[N(e.windowMs)," ms in window \xB7 ",e.pctOfBusy.toFixed(1),"% of busy time"]}),O(h,{style:g.chartLegendText,children:["peak ",N(n)," ms/250ms"]})]}),M(h,{style:g.sectionTitle,children:"STATS \xB7 SINCE START"}),O(b,{style:g.statGrid,children:[M(j,{label:"RUNS",value:e.calls>0?N(e.calls):"\u2014"}),M(j,{label:"SCHEDULED",value:e.scheduleCount>0?N(e.scheduleCount):"\u2014"}),M(j,{label:"AVG / RUN",value:e.calls>0?`${N(e.avgMs)} ms`:"\u2014"}),M(j,{label:"MAX / RUN",value:e.maxMs>0?`${N(e.maxMs)} ms`:"\u2014",accent:e.maxMs>=50?xe.semantic.warning:void 0}),M(j,{label:"TOTAL",value:e.totalMs>0?`${N(e.totalMs)} ms`:"\u2014"}),M(j,{label:"LAST RUN",value:fr(e.lastSeenAgoMs)}),M(j,{label:"FREEZES \xB7 60S",value:e.freezes>0?`${e.freezes}`:"0",accent:e.freezes>0?xe.semantic.error:void 0}),M(j,{label:"WORST FREEZE",value:e.worstFreezeMs>0?`${e.worstFreezeMs} ms`:"\u2014",accent:e.worstFreezeMs>=100?xe.semantic.error:e.worstFreezeMs>0?xe.semantic.warning:void 0})]}),(e.caller||(e.frames?.length??0)>0)&&O(dr,{children:[M(h,{style:g.sectionTitle,children:"SCHEDULED FROM"}),O(b,{style:g.siteCard,children:[e.caller&&O(h,{style:g.siteCaller,children:[e.caller,"()"]}),e.file&&O(h,{style:g.siteFile,children:[e.file,e.line!=null?`:${e.line}`:""]}),e.frames?.map((o,a)=>O(h,{style:g.siteFrame,numberOfLines:1,children:[o.file,":",o.line,":",o.col]},`fr${a}`)),M(h,{style:g.siteNote,children:"Frames are bundle offsets (Hermes) \u2014 the caller name above is the readable part. Captured once when this origin got hot."})]})]}),!e.caller&&(e.frames?.length??0)===0&&e.api!=="unattributed"&&e.api!=="other"&&O(dr,{children:[M(h,{style:g.sectionTitle,children:"SCHEDULED FROM"}),M(h,{style:g.sitePending,children:e.promoted?"Stack capture pending \u2014 next schedule from this site will record it.":"Not hot enough yet \u2014 the scheduling stack is captured once an origin passes 25 schedules or 50ms total."})]})]})},"TaskDetailView")),g=V.create({root:{flex:1,backgroundColor:"transparent",paddingHorizontal:12},identityRow:{flexDirection:"row",alignItems:"center",gap:8,paddingTop:12},badge:{borderWidth:1,borderRadius:3,paddingHorizontal:5,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.4},name:{flex:1,color:T.color.text,fontSize:15,fontWeight:"600"},explainer:{color:T.color.textTertiary,fontSize:11,lineHeight:15,marginTop:6,marginBottom:4},sectionTitle:{color:T.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginTop:14,marginBottom:6},chartRow:{flexDirection:"row",alignItems:"flex-end",height:48,gap:2,backgroundColor:T.color.surface,borderRadius:6,borderWidth:1,borderColor:T.color.border,paddingHorizontal:6,paddingTop:2},chartBarSlot:{flex:1,alignItems:"center",justifyContent:"flex-end"},chartBar:{width:"70%",borderTopLeftRadius:2,borderTopRightRadius:2,opacity:.9},chartLegend:{flexDirection:"row",justifyContent:"space-between",marginTop:4},chartLegendText:{color:T.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},statGrid:{flexDirection:"row",flexWrap:"wrap",gap:8},stat:{width:"23%",minWidth:76,flexGrow:1,backgroundColor:T.color.surface,borderWidth:1,borderColor:T.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:6},statLabel:{color:T.color.textTertiary,fontSize:8,fontWeight:"700",letterSpacing:.4,marginBottom:3},statValue:{color:T.color.text,fontSize:13,fontWeight:"600",fontVariant:["tabular-nums"]},siteCard:{backgroundColor:T.color.surface,borderWidth:1,borderColor:T.color.border,borderRadius:6,padding:10,gap:3},siteCaller:{color:T.color.text,fontSize:13,fontWeight:"600"},siteFile:{color:T.color.info,fontSize:11},siteFrame:{color:T.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},siteNote:{color:T.color.textTertiary,fontSize:9,opacity:.8,marginTop:4},sitePending:{color:T.color.textTertiary,fontSize:11}});import{Fragment as Ao,jsx as w,jsxs as W}from"react/jsx-runtime";function _e(e){return e>=80?P.semantic.error:e>=40?P.semantic.warning:P.semantic.success}s(_e,"busyColor");function Se(e){return e>=100?P.semantic.error:P.semantic.warning}s(Se,"freezeColor");function pr(e){let t=e.rows.find(r=>r.api!=="unattributed"&&r.api!=="other");return t&&t.pctOfBusy>=25&&e.busyPct>=15?{color:t.pctOfBusy>=50?P.semantic.error:P.semantic.warning,icon:"\u25B2",text:`${t.label} is eating ${Math.round(t.pctOfBusy)}% of thread time \u2014 start there.`}:e.freezeSummary.count>0?{color:Se(e.freezeSummary.worstMs),icon:"\u25B2",text:`${e.freezeSummary.count} freeze${e.freezeSummary.count===1?"":"s"} in the last 60s (worst ${e.freezeSummary.worstMs}ms) \u2014 check rows marked \u26A0.`}:e.busyPct>=80?{color:P.semantic.warning,icon:"\u25B2",text:"Thread saturated by UI/React work \u2014 open Highlight Updates to find re-renders."}:{color:P.semantic.success,icon:"\u25CF",text:`Thread healthy at ${Math.round(e.busyPct)}% load \u2014 nothing worth chasing.`}}s(pr,"diagnose");function Qe({visible:e,onClose:t,onBack:r,onMinimize:n,initialModalState:o,minimizeTargetPosition:a,remoteSnapshot:i,remoteActions:l,embedded:c=false}){let d=i!==void 0,[u,C]=Xt(null);tn(()=>{if(!(d||!e))return m.subscribe(C)},[d,e]);let p=d?i:u,y=rn(()=>l??{pause:s(()=>m.pause(),"pause"),resume:s(()=>m.resume(),"resume"),clear:s(()=>m.clear(),"clear")},[l]),S=p?.paused??false,ve=(p?.rows.length??0)>0,[ke,et]=Xt(null),Cr=en(K=>et(K.key),[]),tt=!d&&ke?m.getOriginDetail(ke):null,rt=ke!==null,nt=W(ue,{children:[rt?w(ue.Navigation,{onBack:()=>et(null)}):r?w(ue.Navigation,{onBack:r}):null,w(ue.Content,{title:"",noMargin:true,children:W(b,{style:x.titleRow,children:[w(ho,{size:14,color:"#34D399"}),w(h,{style:x.title,testID:"buoy-jstop-title",children:"JS Top"}),p&&w(b,{style:[x.busyPill,{borderColor:_e(p.busyPct)}],children:W(h,{testID:"buoy-jstop-busy",style:[x.busyText,{color:_e(p.busyPct)}],children:[p.busyPct.toFixed(0),"% BUSY"]})}),p&&p.freezeSummary.count>0&&w(b,{style:[x.busyPill,{borderColor:Se(p.freezeSummary.worstMs)}],children:W(h,{testID:"buoy-jstop-freezes",style:[x.busyText,{color:Se(p.freezeSummary.worstMs)}],children:["\u26A0 ",p.freezeSummary.count," \xB7"," ",p.freezeSummary.worstMs,"ms"]})})]})}),W(ue.Actions,{children:[w(le,{onPress:S?y.resume:y.pause,style:[x.actionBtn,S&&x.actionBtnActive],testID:"buoy-jstop-pause",accessibilityLabel:S?"Resume sampling":"Pause sampling",children:S?w(po,{size:14,color:z.color.accent}):w(fo,{size:14,color:z.color.textSecondary})}),w(le,{onPress:y.clear,disabled:!ve,style:[x.actionBtn,!ve&&x.actionBtnDisabled],testID:"buoy-jstop-clear",accessibilityLabel:"Clear stats",children:w(bo,{size:14,color:ve?z.color.textTertiary:z.color.textTertiary})})]})]}),ot=w(b,{style:x.body,children:rt?tt?w(Co,{detail:tt}):w(h,{style:x.waiting,children:"This origin is no longer tracked (cleared or evicted)."}):p?W(Ao,{children:[(()=>{let K=pr(p);return W(b,{style:[x.diagnosis,{borderLeftColor:K.color}],children:[w(h,{style:[x.diagnosisIcon,{color:K.color}],children:K.icon}),w(h,{style:x.diagnosisText,children:K.text})]})})(),W(b,{style:x.sparklineRow,children:[w(h,{style:x.sparklineCaption,children:"JS THREAD LOAD \xB7 LAST 30s"}),w(wo,{history:p.busyHistory})]}),!p.tiers.bridge&&w(h,{style:x.tierBanner,children:"\u201CSystem\u201D rows are UI/React/native work pure JS can\u2019t name \u2014 timers, rAF and Promise chains are fully attributed."}),w(cr,{rows:p.rows,onSelectRow:d?void 0:Cr})]}):w(h,{style:x.waiting,children:d?"Waiting for device\u2026":"Starting engine\u2026"})});return c?W(b,{style:x.embeddedRoot,children:[w(b,{style:x.embeddedHeader,children:nt}),ot]}):w(mo,{visible:e,onClose:t,onMinimize:n,minimizeTargetPosition:a,initialModalState:o,header:{showToggleButton:true,customContent:nt},persistenceKey:"buoy-js-top-modal",enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:ot})}s(Qe,"JsTopModal");var x=V.create({titleRow:{flexDirection:"row",alignItems:"center",gap:8},title:{color:z.color.text,fontSize:14,fontWeight:"500"},busyPill:{borderWidth:1,borderRadius:4,paddingHorizontal:6,paddingVertical:2},busyText:{fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:z.color.buttonSurface,borderWidth:1,borderColor:z.color.border,alignItems:"center",justifyContent:"center"},actionBtnActive:{backgroundColor:z.color.accentSoft,borderColor:z.color.accentBorderStrong},actionBtnDisabled:{opacity:.55},body:{flex:1,minHeight:0,backgroundColor:"transparent"},diagnosis:{flexDirection:"row",alignItems:"center",gap:8,marginHorizontal:10,marginTop:8,paddingHorizontal:10,paddingVertical:8,backgroundColor:z.color.surface,borderRadius:6,borderLeftWidth:3},diagnosisIcon:{fontSize:11,fontWeight:"700"},diagnosisText:{flex:1,color:z.color.text,fontSize:12,lineHeight:16},sparklineRow:{paddingHorizontal:10,paddingVertical:8,gap:4},sparklineCaption:{color:z.color.textTertiary,fontSize:8,fontWeight:"700",letterSpacing:.5},tierBanner:{color:z.color.textTertiary,fontSize:10,paddingHorizontal:10,paddingBottom:6},waiting:{color:z.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:32},embeddedRoot:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:P.background.base},embeddedHeader:{borderBottomWidth:1,borderBottomColor:P.border.default}});import{useEffect as br,useState as gr}from"react";import{macOSColors as Ge,night as Ye}from"@buoy-gg/shared-ui/web";import{jsx as Eo,jsxs as yr}from"react/jsx-runtime";function wr(e){return e>=80?Ge.semantic.error:e>=40?Ge.semantic.warning:Ge.semantic.success}s(wr,"busyColor");function Mr(){let[e,t]=gr(()=>m.isEnabled()),[r,n]=gr(null);if(br(()=>m.subscribeEnabled(t),[]),br(()=>{if(!e){n(null);return}return m.subscribe(n)},[e]),!e||!r)return null;let o=r.rows.find(a=>a.api!=="unattributed");return yr(b,{style:Ze.pill,pointerEvents:"none",children:[yr(h,{style:[Ze.busy,{color:wr(r.busyPct)}],children:[r.busyPct.toFixed(0),"%"]}),o&&Eo(h,{style:Ze.label,numberOfLines:1,children:o.label})]})}s(Mr,"JsTopHudOverlay");var Ze=V.create({pill:{position:"absolute",top:60,left:8,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:Ye.color.buttonSurface,borderWidth:1,borderColor:Ye.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:4,maxWidth:220},busy:{fontSize:11,fontWeight:"700",fontVariant:["tabular-nums"]},label:{color:Ye.color.textSecondary,fontSize:10,flexShrink:1}});import{useEffect as zo,useState as Bo}from"react";import{Activity as xr}from"@buoy-gg/shared-ui/web";import{jsx as Sr}from"react/jsx-runtime";var Xe="#34D399",vr="#6B7280";function kr({size:e}){let[t,r]=Bo(()=>m.isEnabled());return zo(()=>m.subscribeEnabled(r),[]),Sr(xr,{size:e,color:t?Xe:vr})}s(kr,"JsTopToggleIcon");function Tr(){return null}s(Tr,"EmptyComponent");var Ro={id:"js-top",name:"JS TOP",description:"Toggle the floating JS-thread busy pill",slot:"row",icon:kr,component:Tr,props:{},launchMode:"toggle-only",onPress:s(()=>{m.setEnabled(!m.isEnabled())},"onPress")},Io={id:"js-top-modal",name:"TASKS",description:"Live Task Manager for the JS thread",slot:"both",icon:s(({size:e})=>Sr(xr,{size:e,color:Xe}),"icon"),component:Qe,props:{enableSharedModalDimensions:false}};m.registerTierInstaller(Kt);m.registerTierInstaller(qt);m.registerTierInstaller(Qt);m.registerLongtaskProvider(Gt);m.registerFreezeStatsProvider(Yt);m.registerClearHook(Zt);try{typeof window<"u"&&(De(),$e())}catch{}export{vr as JS_TOP_DISABLED_COLOR,Xe as JS_TOP_ENABLED_COLOR,m as JsTopController,Mr as JsTopHudOverlay,Qe as JsTopModal,Io as jsTopModalPreset,Ro as jsTopPreset,Xr as jsTopSyncAdapter};
|
|
1
|
+
"use client";var Ee=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Or=Object.getOwnPropertyNames;var Ir=Object.prototype.hasOwnProperty;var s=(e,t)=>Ee(e,"name",{value:t,configurable:true});var Pr=(e,t)=>{for(var r in t)Ee(e,r,{get:t[r],enumerable:true})},ut=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Or(t))!Ir.call(e,n)&&n!==r&&Ee(e,n,{get:()=>t[n],enumerable:!(o=Br(t,n))||o.enumerable});return e},Fr=(e,t,r)=>(ut(e,t,"default"),r&&ut(r,t,"default"));var re=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);var he=typeof globalThis<"u"?globalThis:void 0,Lr=(()=>{if(typeof he?.nativePerformanceNow=="function"){let e=he.nativePerformanceNow;return()=>e()}if(typeof he?.performance?.now=="function"){let e=he.performance;return()=>e.now()}return()=>Date.now()})(),$r=Lr;function P(){return $r()}s(P,"now");var p=typeof globalThis<"u"?globalThis:{},ct=false;function H(){return ct}s(H,"isActive");function oe(e){ct=e}s(oe,"setActive");var ze=null;function fe(){return ze||(ze={setTimeout:p.setTimeout?.bind(p),setInterval:p.setInterval?.bind(p),clearInterval:p.clearInterval?.bind(p),clearTimeout:p.clearTimeout?.bind(p),setImmediate:p.setImmediate?.bind(p),requestAnimationFrame:p.requestAnimationFrame?.bind(p),queueMicrotask:p.queueMicrotask?.bind(p)}),ze}s(fe,"captureOriginals");function ne(){return fe()}s(ne,"getOriginals");var T=Symbol.for("buoy.jsTop.patched"),dt=Symbol.for("buoy.jsTop.wrapped");var U=new Float64Array(120),ae=new Float64Array(120),Re=new Float64Array(120),q=new Float64Array(120).fill(-1);function L(e){return Math.floor(e/250)}s(L,"epochOf");function ht(e){let t=e%120;return q[t]!==e&&(q[t]=e,U[t]=0,ae[t]=0,Re[t]=0),t}s(ht,"slotFor");function me(e,t,r){if(!(t>e))return;let o=Math.max(e,t-3e4),n=L(o),a=L(t),i=o;for(;n<=a;){let l=(n+1)*250,c=Math.min(t,l),d=c-i;d>0&&r(ht(n),d),i=c,n++}}s(me,"distribute");function ft(e,t){me(e,t,(r,o)=>{U[r]=Math.min(250,U[r]+o)})}s(ft,"bookBusyRange");function mt(e,t,r){let o=t-e;if(!(o>0)||!(r>0))return;let n=Math.min(1,r/o);me(e,t,(a,i)=>{ae[a]=Math.min(250,ae[a]+i*n)})}s(mt,"bookAttributedRange");function pt(e,t){me(e,t,(r,o)=>{Re[r]=Math.min(250,Re[r]+o)})}s(pt,"bookLongtaskRange");function Be(e,t,r){let o=L(t),n=0;for(let a=o-r+1;a<=o;a++){let i=a%120;i>=0&&q[i]===a&&(n+=e[i])}return n}s(Be,"sumWindow");function Oe(e){return Be(U,e,20)}s(Oe,"windowBusyMs");function bt(e){return Be(ae,e,20)}s(bt,"windowAttributedMs");function gt(e){let t=L(e),r=[];for(let o=t-20+1;o<=t;o++){let n=o%120;n>=0&&q[n]===o?r.push(Math.max(0,Math.round((U[n]-ae[n])*10)/10)):r.push(0)}return r}s(gt,"windowResidualBuckets");function yt(e){let t=L(e),r=[];for(let n=t-120+1;n<=t;n++){let a=n%120;a>=0&&q[a]===n?r.push(Math.round(U[a]/250*100)):r.push(0)}let o=0;for(;o<r.length&&r[o]===0;)o++;return r.slice(Math.max(0,Math.min(o,r.length-1)))}s(yt,"busyHistory");function wt(){q.fill(-1)}s(wt,"resetAggregator");import{buoyFetch as xt}from"@buoy-gg/shared-ui/web";var Dr=3,Ie=0;function St(){return typeof re<"u"&&re}s(St,"isDev");var jr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wr=new Map([...jr].map((e,t)=>[e,t]));function Mt(e){let t=[],r=0,o=0,n=0,a=0;for(let i of e.split(";")){let l=[],c=0;for(let d of i.split(",")){if(!d)continue;let u=[],b=0,m=0;for(let g of d){let v=Wr.get(g);if(v===void 0)break;b+=(v&31)<<m,v&32?m+=5:(u.push(b&1?-(b>>1):b>>1),b=0,m=0)}u.length&&(c+=u[0],u.length===1?l.push([c]):u.length>=4&&(r+=u[1],o+=u[2],n+=u[3],u.length>=5?(a+=u[4],l.push([c,r,o,n,a])):l.push([c,r,o,n])))}t.push(l)}return t}s(Mt,"decodeMappings");function vt(e,t,r){let o=e.lines[t-1];if(!o?.length)return null;let n;for(let i of o)if(i[0]<=r-1)n=i;else break;if(!n||n.length<4)return null;let a=e.sources[n[1]];return a?{file:a,line:n[2]+1,name:n.length>=5?e.names[n[4]]:void 0}:null}s(vt,"lookup");var kt=new Map;function Tt(e){let t=kt.get(e);return t||(t=(async()=>{let r=await(await xt(e)).text(),o=Math.max(r.lastIndexOf("//# sourceMappingURL="),r.lastIndexOf("//@ sourceMappingURL="));if(o<0)return null;let n=/^\/\/[#@]\s*sourceMappingURL=(\S+)/.exec(r.slice(o));if(!n)return null;let a=new URL(n[1],e).href,i=await(await xt(a)).json();return!i.mappings||!i.sources?null:{sources:i.sources,names:i.names??[],lines:Mt(i.mappings)}})().catch(()=>null),kt.set(e,t)),t}s(Tt,"loadMap");function Ct(e){return(e.split("?")[0]??e).split("/").filter(Boolean).slice(-2).join("/")}s(Ct,"tailPath");function At(e){return/^[A-Z][A-Za-z0-9]*$/.test(e)}s(At,"looksLikeComponent");function Et(e,t){if(!St()||e.symbolicated||!e.frames||e.frames.length===0||Ie>=Dr)return;e.symbolicated=true;let r=e.frames.filter(o=>/^(https?|capacitor|file):\/\//.test(o.file));r.length&&(Ie++,(async()=>{for(let o of r){let n=await Tt(o.file.split("?")[0]??o.file);if(!n)continue;let a=vt(n,o.line,o.col);if(!a||a.file.includes("node_modules"))continue;let i=Ct(a.file);e.file=i,e.line=a.line;let l=`${i.split("/").pop()}:${a.line}`;a.name&&At(a.name)&&!e.caller?(e.caller=a.name,e.label=`${e.label} \u2190 <${a.name}> \xB7 ${l}`):e.label=`${e.label} \xB7 ${l}`;return}})().catch(()=>{}).finally(()=>{Ie--}))}s(Et,"buoyJsTopSymbolicateOrigin");var Hr=500,Vr=20,C=new Map,zt="other",Rt=0,Pe=0;function pe(e,t,r){return{key:e,api:t,label:r,calls:0,totalMs:0,maxMs:0,scheduleCount:0,lastSeenAt:0,promoted:false,lastCaptureAt:0,ring:new Float64Array(20),ringStamps:new Float64Array(20).fill(-1)}}s(pe,"makeOrigin");function Fe(e,t){let r=L(t),o=0;for(let n=r-20+1;n<=r;n++){let a=n%20;a>=0&&e.ringStamps[a]===n&&(o+=e.ring[a])}return o}s(Fe,"windowMsOf");function Le(e){let t=null,r=1/0;for(let n of C.values()){if(n.key===zt)continue;let a=Fe(n,e)*1e6+n.lastSeenAt;a<r&&(r=a,t=n)}if(!t)return false;let o=Bt(zt,"other","other (evicted origins)");return o.calls+=t.calls,o.totalMs+=t.totalMs,o.maxMs=Math.max(o.maxMs,t.maxMs),o.lastSeenAt=Math.max(o.lastSeenAt,t.lastSeenAt),C.delete(t.key),true}s(Le,"evictColdest");function Bt(e,t,r){let o=C.get(e);return o||(o=pe(e,t,r),C.set(e,o)),o}s(Bt,"getOrCreate");function Ot(e){let t=[],r,o=e.split(`
|
|
2
|
+
`);for(let n of o){let a=/at\s+(.*?)\s+\((?:address at\s+)?(.*?):(\d+):(\d+)\)/.exec(n)??/at\s+()(.*?):(\d+):(\d+)$/.exec(n.trim())??/^([^@\s]*)@(.+?):(\d+):(\d+)$/.exec(n.trim());if(!a)continue;let i=a[1]??"";if(i.includes("buoyJsTop")||i==="Error"||a[2]?.includes("/js-top/"))continue;t.push({file:a[2]??"",line:Number(a[3]),col:Number(a[4])});let l=/^(react_stack_bottom_frame|runWithFiberInDEV|commitHookEffectList|flushPassive|performWork|renderWithHooks|safelyCall)/.test(i)||/^(then|catch|finally|resolve|reject|fulfilled|rejected|step|tryCallOne|tryCallTwo|tryCatch|invokeCallback|notify)$/.test(i);if(!r&&i&&i!=="anonymous"&&!l&&(r=i),t.length>=3)break}return{caller:r,frames:t}}s(Ot,"parseStack");function It(e,t){return t-e.lastCaptureAt<Hr||(t-Rt>1e3&&(Rt=t,Pe=0),Pe>=Vr)?false:(Pe++,e.lastCaptureAt=t,true)}s(It,"allowCapture");function be(e){if(!e)return;let t=(e.split("?")[0]??e).replace(/\/\/&.*$/,""),r=/^[a-z]+:\/\/[^/]+\/(.*)$/.exec(t);return(r?r[1]:t).split("/").slice(-2).join("/")}s(be,"shortFile");function Pt(e){return C.has(e)}s(Pt,"buoyJsTopOriginExists");function ge(e,t,r,o=true){let n=t,a=typeof n.displayName=="string"&&n.displayName||typeof n.name=="string"&&n.name||"anonymous",i=`${e}|${a}`,l=C.get(i);if(l?.activeRefinedKey&&!C.has(l.activeRefinedKey)&&(l.activeRefinedKey=void 0),!l){for(;C.size>=500&&Le(r););l=pe(i,e,a==="anonymous"?_(e):`${_(e)} ${a}`),C.set(i,l)}if(l.scheduleCount++,!l.promoted&&(l.scheduleCount>=25||l.totalMs>=50)&&(l.promoted=true),(l.promoted||e==="interval")&&o&&It(l,r)){let{caller:c,frames:d}=Ot(new Error().stack??""),u=d[0];if(u||c){let b=u?`${be(u.file)??"?"}:${u.line}`:"?",m=`${i}@${c??"?"}:${b}`,g=C.get(m);if(!g){for(;C.size>=500&&Le(r););let v=a==="anonymous"?_(e):`${_(e)} ${a}`;g=pe(m,e,c?`${v} \u2190 ${c}`:a==="anonymous"?`${v} @ ${be(u?.file??"")??"?"}`:v),g.caller=c,g.file=u?be(u.file):void 0,g.line=u?.line,g.frames=d,g.promoted=true,g.calls=l.calls,g.totalMs=l.totalMs,g.maxMs=l.maxMs,g.scheduleCount=l.scheduleCount,g.lastSeenAt=l.lastSeenAt,g.ring.set(l.ring),g.ringStamps.set(l.ringStamps),l.calls=0,l.totalMs=0,l.maxMs=0,l.ring.fill(0),l.ringStamps.fill(-1),C.set(m,g),Et(g,_(e))}l.activeRefinedKey=m}}return l.activeRefinedKey??i}s(ge,"buoyJsTopScheduleOrigin");function _(e){switch(e){case"timeout":return"setTimeout";case"interval":return"setInterval";case"immediate":return"setImmediate";case"raf":return"requestAnimationFrame";case"microtask":return"queueMicrotask";case"then":return"Promise.then";case"bridge":return"bridge";default:return e}}s(_,"apiLabel");function Ft(e,t,r,o){let n=C.get(e);if(!n)return;n.calls++,n.totalMs+=t,t>n.maxMs&&(n.maxMs=t),n.lastSeenAt=o,!n.promoted&&n.totalMs>=50&&(n.promoted=true);let a=o-r,i=a>0?Math.min(1,t/a):1,l=Math.max(r,o-5e3),c=L(l),d=L(o),u=l;for(;c<=d;){let b=(c+1)*250,m=Math.min(o,b),g=m-u;if(g>0){let v=c%20;v>=0&&(n.ringStamps[v]!==c&&(n.ringStamps[v]=c,n.ring[v]=0),n.ring[v]+=a>0?g*i:t)}u=m,c++}mt(r,o,t)}s(Ft,"buoyJsTopBookExclusive");function Lt(e){return C.get(e)?.label??null}s(Lt,"labelForOrigin");function $t(e,t,r){let o=[];for(let i of C.values()){let l=Fe(i,e);l<=0&&i.totalMs<1||o.push({key:i.key,label:i.label,api:i.api,file:i.file,line:i.line,windowMs:Math.round(l*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(l/t*1e3)/10):0,totalMs:Math.round(i.totalMs*10)/10,calls:i.calls,avgMs:i.calls>0?Math.round(i.totalMs/i.calls*100)/100:0,maxMs:Math.round(i.maxMs*100)/100,lastSeenAgoMs:i.lastSeenAt>0?Math.max(0,e-i.lastSeenAt):0,freezes:0,worstFreezeMs:0})}o.sort((i,l)=>l.windowMs-i.windowMs||l.totalMs-i.totalMs);let n=[],a=[];for(let i of o)(i.windowMs>=1||i.pctOfBusy>=.5||i.freezes>0?n:a).push(i);return a.length>=2?(n.push({key:"minor",label:`${a.length} minor origins (\u22641ms each)`,api:"other",windowMs:Math.round(a.reduce((i,l)=>i+l.windowMs,0)*10)/10,pctOfBusy:Math.round(a.reduce((i,l)=>i+l.pctOfBusy,0)*10)/10,totalMs:Math.round(a.reduce((i,l)=>i+l.totalMs,0)*10)/10,calls:a.reduce((i,l)=>i+l.calls,0),avgMs:0,maxMs:Math.max(0,...a.map(i=>i.maxMs)),lastSeenAgoMs:Math.min(...a.map(i=>i.lastSeenAgoMs)),freezes:0,worstFreezeMs:0}),n.slice(0,r)):o.slice(0,r)}s($t,"buildRows");function Dt(e,t,r){let o=C.get(e);if(!o)return null;let n=L(t),a=[],i=0;for(let l=n-20+1;l<=n;l++){let c=l%20,d=c>=0&&o.ringStamps[c]===l?Math.round(o.ring[c]*10)/10:0;a.push(d),i+=d}return{key:o.key,label:o.label,api:o.api,caller:o.caller,file:o.file,line:o.line,frames:o.frames,promoted:o.promoted,scheduleCount:o.scheduleCount,calls:o.calls,totalMs:Math.round(o.totalMs*10)/10,avgMs:o.calls>0?Math.round(o.totalMs/o.calls*100)/100:0,maxMs:Math.round(o.maxMs*100)/100,windowMs:Math.round(i*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(i/r*1e3)/10):0,lastSeenAgoMs:o.lastSeenAt>0?Math.max(0,t-o.lastSeenAt):0,buckets:a}}s(Dt,"getOriginDetailBase");function jt(){C.clear()}s(jt,"resetOrigins");var Nr=32,Q=[],Jr=20,Wt=64,Ht=new Array(Wt).fill(null),$e=0;function Vt(){return Ht}s(Vt,"recentIntervals");function De(e,t){let r=P(),o=Q.length>0?Q[Q.length-1]:null,n=null;Q.length<Nr&&(n={originKey:e,start:r,childrenMs:0},Q.push(n));try{return t()}finally{try{if(n){Q.pop();let a=P(),i=a-r,l=Math.max(0,i-n.childrenMs);o&&(o.childrenMs+=i),Ft(e,l,r,a),!o&&i>=Jr&&(Ht[$e]={originKey:e,start:r,end:a},$e=($e+1)%Wt)}}catch{}}}s(De,"buoyJsTopRunFrame");function J(e,t){if(typeof e!="function"||e[dt])return e;let r=H()?ge(t,e,P()):null,o=s(function(...n){return H()?((r===null||!Pt(r))&&(r=ge(t,e,P(),false)),De(r,()=>e.apply(this,n))):e.apply(this,n)},"buoyJsTopTaskWrapper");return o[dt]=true,o}s(J,"buoyJsTopWrapTask");function je(e,t,r){if(!H())return r();let o=ge(e,{name:t},P());return De(o,r)}s(je,"buoyJsTopRunAs");function We(){let e=fe();if(typeof p.setTimeout=="function"&&!p.setTimeout[T]){let t=s(function(r,o,...n){let a=J(r,"timeout");return e.setTimeout(a,o,...n)},"buoyJsTopSetTimeout");t[T]=true,p.setTimeout=t}if(typeof p.setInterval=="function"&&!p.setInterval[T]){let t=s(function(r,o,...n){let a=J(r,"interval");return e.setInterval(a,o,...n)},"buoyJsTopSetInterval");t[T]=true,p.setInterval=t}if(typeof p.setImmediate=="function"&&!p.setImmediate[T]&&e.setImmediate){let t=s(function(r,...o){let n=J(r,"immediate");return e.setImmediate(n,...o)},"buoyJsTopSetImmediate");t[T]=true,p.setImmediate=t}if(typeof p.requestAnimationFrame=="function"&&!p.requestAnimationFrame[T]&&e.requestAnimationFrame){let t=s(function(r){let o=J(r,"raf");return e.requestAnimationFrame(o)},"buoyJsTopRequestAnimationFrame");t[T]=true,p.requestAnimationFrame=t}}s(We,"installTimerPatches");function He(){let e=fe();if(typeof p.queueMicrotask=="function"&&!p.queueMicrotask[T]&&e.queueMicrotask){let t=s(function(r){let o=J(r,"microtask");return e.queueMicrotask(o)},"buoyJsTopQueueMicrotask");t[T]=true,p.queueMicrotask=t}}s(He,"installMicrotaskPatches");var Ve=16,Kr=100,Ur=3,qr=8,ie=null,se=0,ye=false,le=[],G=1/0,Y=0,Ne=Ve;function Nt(){let e=P(),t=se>0?e-se:0;if(se=e,ye){ye=false,G=1/0,Y=e;return}if(t<=0)return;t<Kr&&(t<G&&(G=t),Y===0&&(Y=e),e-Y>=1e3&&(le.push(G),le.length>Ur&&le.shift(),Ne=Math.max(qr,Math.min(...le)),G=1/0,Y=e));let r=t-Ne;r>1&&ft(e-r,e)}s(Nt,"buoyJsTopProbeTick");function Je(){if(ie!=null)return;let e=ne();se=P(),ye=false,le=[],G=1/0,Y=0,Ne=Ve,ie=e.setInterval(Nt,Ve)}s(Je,"startBusyProbe");function Ke(){ie!=null&&(ne().clearInterval(ie),ie=null),se=0}s(Ke,"stopBusyProbe");function Jt(){ye=true}s(Jt,"suppressNextGap");import{definePersistedSetting as _r}from"@buoy-gg/shared-ui/web";var Qr="@react_buoy/js-top/prefs",Gr={enabled:false},Kt=_r(Qr,Gr,{sanitize:s(e=>({enabled:e.enabled===true}),"sanitize")});async function Ut(){return Kt.load()}s(Ut,"loadJsTopPrefs");async function qt(e){await Kt.save(e)}s(qt,"saveJsTopPrefs");import{subscribeRealAppState as Yr}from"@buoy-gg/shared-ui/web";var Zr=250,_t=class Vn{constructor(){this.enabled=false;this.enabledLoaded=false;this.paused=false;this.pausedAt=0;this.remoteSampling=false;this.engineRunning=false;this.tiers={timers:false,promises:false,bridge:false,longtask:false};this.notifyHandle=null;this.appStateSub=null;this.snapshot=this.buildSnapshot();this.subscribers=new Set;this.enabledSubscribers=new Set;this.tierInstallers=[];this.longtaskProvider=null;this.freezeStatsProvider=null;this.clearHooks=[];Ut().then(t=>{this.enabledLoaded=true,t.enabled&&!this.enabled&&this.setEnabled(true)})}subscribe(t){return this.subscribers.add(t),this.syncEngineState(),t(this.snapshot),()=>{this.subscribers.delete(t),this.syncEngineState()}}subscribeEnabled(t){return this.enabledSubscribers.add(t),t(this.enabled),()=>{this.enabledSubscribers.delete(t)}}setEnabled(t){this.enabled!==t&&(this.enabled=t,this.enabledLoaded&&qt({enabled:t}),this.enabledSubscribers.forEach(r=>{try{r(t)}catch(o){re&&console.error("[Buoy]","[js-top] enabled subscriber threw",o)}}),this.syncEngineState())}isEnabled(){return this.enabled}setRemoteSampling(t){this.remoteSampling!==t&&(this.remoteSampling=t,this.syncEngineState())}isRemoteSampling(){return this.remoteSampling}getStatus(){return this.engineRunning?this.paused?"paused":"running":"disabled"}pause(){this.paused||(this.paused=true,this.pausedAt=P(),oe(false),Ke(),this.emitSnapshot())}resume(){this.paused&&(this.paused=false,this.engineRunning&&(oe(true),Je()),this.emitSnapshot())}clear(){jt(),wt();for(let t of this.clearHooks)try{t()}catch{}this.emitSnapshot()}registerClearHook(t){this.clearHooks.push(t)}getSnapshot(){return this.snapshot}getOriginDetail(t){let r=P(),o=Oe(r),n=this.freezeStatsProvider?.(Date.now())?.byOrigin[t];if(t==="unattributed"){let i=gt(r),l=Math.round(i.reduce((c,d)=>c+d,0)*10)/10;return{key:t,label:"unattributed (events / React / native call-ins)",api:"unattributed",promoted:false,scheduleCount:0,calls:0,totalMs:0,avgMs:0,maxMs:0,windowMs:l,pctOfBusy:o>0?Math.min(100,Math.round(l/o*1e3)/10):0,lastSeenAgoMs:0,buckets:i,freezes:n?.count??0,worstFreezeMs:Math.round(n?.maxMs??0)}}let a=Dt(t,r,o);return a?{...a,freezes:n?.count??0,worstFreezeMs:Math.round(n?.maxMs??0)}:null}registerTierInstaller(t){this.tierInstallers.push(t),this.engineRunning&&Object.assign(this.tiers,this.runInstaller(t))}registerLongtaskProvider(t){this.longtaskProvider=t}registerFreezeStatsProvider(t){this.freezeStatsProvider=t}shouldRun(){return this.subscribers.size>0||this.remoteSampling}syncEngineState(){let t=this.shouldRun();t&&!this.engineRunning?this.startEngine():!t&&this.engineRunning&&this.stopEngine()}runInstaller(t){try{return t()}catch(r){return re&&console.error("[Buoy]","[js-top] tier installer threw",r),{}}}startEngine(){this.engineRunning=true,We(),He(),this.tiers={timers:true,promises:false,bridge:false,longtask:false};for(let t of this.tierInstallers)Object.assign(this.tiers,this.runInstaller(t));oe(!this.paused),this.paused||Je();try{this.appStateSub=Yr(()=>{Jt()})}catch{this.appStateSub=null}this.notifyHandle=ne().setInterval(()=>this.emitSnapshot(),Zr),this.emitSnapshot()}stopEngine(){if(this.engineRunning=false,oe(false),Ke(),this.notifyHandle!=null&&(ne().clearInterval(this.notifyHandle),this.notifyHandle=null),this.appStateSub){try{this.appStateSub.remove()}catch{}this.appStateSub=null}}buildSnapshot(){let t=this.paused?this.pausedAt:P(),r=Oe(t),o=bt(t),n=Math.max(0,r-o),a=$t(t,r,30);n>=1&&(a.push({key:"unattributed",label:"unattributed (events / React / native call-ins)",api:"unattributed",windowMs:Math.round(n*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(n/r*1e3)/10):0,totalMs:0,calls:0,avgMs:0,maxMs:0,lastSeenAgoMs:0,freezes:0,worstFreezeMs:0}),a.sort((c,d)=>d.windowMs-c.windowMs||d.totalMs-c.totalMs));let i=this.freezeStatsProvider?.(Date.now())??{count:0,worstMs:0,byOrigin:{}};for(let c of a){let d=i.byOrigin[c.key];d&&(c.freezes=d.count,c.worstFreezeMs=Math.round(d.maxMs))}let l=5e3;return{ts:Date.now(),paused:this.paused,busyPct:Math.min(100,Math.round(r/l*1e3)/10),busyHistory:yt(t),tiers:{...this.tiers},rows:a,totals:{attributedWindowMs:Math.round(o*10)/10,unattributedWindowMs:Math.round(n*10)/10,windowMs:l},freezeSummary:{count:i.count,worstMs:Math.round(i.worstMs)},longtasks:this.longtaskProvider?this.longtaskProvider():[]}}emitSnapshot(){this.snapshot=this.buildSnapshot(),this.subscribers.forEach(t=>{try{t(this.snapshot)}catch(r){re&&console.error("[Buoy]","[js-top] snapshot subscriber threw",r)}})}isEngineActive(){return H()}};s(_t,"JsTopControllerImpl");var Xr=_t,f=new Xr;function we(e,t){let r=e[t];if(typeof r!="function")return false;if(r[T])return true;let o=s(function(...n){for(let a=0;a<n.length;a++)typeof n[a]=="function"&&(n[a]=J(n[a],"then"));return r.apply(this,n)},"patched");return o[T]=true,Object.defineProperty(o,"name",{value:t,configurable:true}),e[t]=o,true}s(we,"patchMethod");function Qt(){let e=p.Promise?.prototype;if(!e)return{promises:false};let t=we(e,"then");return we(e,"catch"),we(e,"finally"),{promises:t}}s(Qt,"installPromisePatches");function Gt(){let e=p.__fbBatchedBridge;if(!e)return{bridge:false};let t=false;if(typeof e.callFunctionReturnFlushedQueue=="function"&&!e.callFunctionReturnFlushedQueue[T]){let o=e.callFunctionReturnFlushedQueue.bind(e),n=s(function(a,i,l){return H()?je("bridge",`${a}.${i}`,()=>o(a,i,l)):o(a,i,l)},"buoyJsTopCallFunction");n[T]=true,e.callFunctionReturnFlushedQueue=n,t=true}if(typeof e.invokeCallbackAndReturnFlushedQueue=="function"&&!e.invokeCallbackAndReturnFlushedQueue[T]){let o=e.invokeCallbackAndReturnFlushedQueue.bind(e),n=s(function(a,i){return H()?je("bridge","nativeModuleCallback",()=>o(a,i)):o(a,i)},"buoyJsTopInvokeCallback");n[T]=true,e.invokeCallbackAndReturnFlushedQueue=n,t=true}let r=e.callFunctionReturnFlushedQueue?.[T]===true;return{bridge:t||r}}s(Gt,"installBridgePatch");var eo=40,to=6e4,ro="unattributed",Yt=false,xe=false,Z=[];function Zt(e,t){let r=e+t,o=null,n=0;for(let a of Vt()){if(!a)continue;let i=Math.min(r,a.end)-Math.max(e,a.start);i>n&&(n=i,o=a.originKey)}return o}s(Zt,"correlate");function Xt(){if(Yt)return{longtask:xe};Yt=true;let e=p.PerformanceObserver;if(typeof e!="function")return{longtask:false};try{new e(t=>{if(H())try{for(let r of t.getEntries()){if(r.entryType!=="longtask")continue;let o=r.startTime,n=r.duration;pt(o,o+n),Z.push({start:o,duration:n,at:Date.now(),originKey:Zt(o,n)}),Z.length>eo&&Z.shift()}}catch{}}).observe({entryTypes:["longtask"]}),xe=true}catch{xe=false}return{longtask:xe}}s(Xt,"installLongtaskObserver");function er(){return Z.map(e=>({start:e.start,duration:e.duration,at:e.at,originLabel:e.originKey?Lt(e.originKey):null}))}s(er,"getLongtasks");function tr(e){let t={},r=0,o=0;for(let n of Z){if(n.at>0&&e-n.at>to)continue;r++,n.duration>o&&(o=n.duration);let a=n.originKey??ro,i=t[a];i?(i.count++,n.duration>i.maxMs&&(i.maxMs=n.duration)):t[a]={count:1,maxMs:n.duration}}return{count:r,worstMs:o,byOrigin:t}}s(tr,"getFreezeStats");function rr(){Z.length=0}s(rr,"clearLongtasks");var oo={version:1,getSnapshot:s(()=>({live:f.getSnapshot(),enabled:f.isEnabled()||f.isRemoteSampling()}),"getSnapshot"),subscribe:s(e=>{let t=f.subscribe(()=>e()),r=f.subscribeEnabled(()=>e());return()=>{t(),r()}},"subscribe"),actions:{setEnabled:s(e=>{let t=e.enabled;f.setRemoteSampling(t)},"setEnabled"),pause:s(()=>f.pause(),"pause"),resume:s(()=>f.resume(),"resume"),clear:s(()=>f.clear(),"clear"),getOriginDetail:s(e=>f.getOriginDetail(e.key),"getOriginDetail"),sample:s(async e=>{let t=e,r=Math.min(Math.max(t?.durationMs??3e3,250),3e4),o=f.isRemoteSampling()||f.isEnabled();o||f.setRemoteSampling(true),t?.clearFirst&&f.clear();try{return await new Promise(n=>setTimeout(n,r)),f.getSnapshot()}finally{o||f.setRemoteSampling(false)}},"sample")}};import{useCallback as no,useEffect as ao,useMemo as io,useState as or}from"react";var nr={};Pr(nr,{AccessibilityInfo:()=>co,ActivityIndicator:()=>mn,Alert:()=>gn,Animated:()=>sn,AppRegistry:()=>fo,AppState:()=>mo,Appearance:()=>ho,BackHandler:()=>po,Button:()=>pn,CheckBox:()=>Bo,Clipboard:()=>bo,DeviceEventEmitter:()=>qo,Dimensions:()=>go,Easing:()=>yo,FlatList:()=>Oo,I18nManager:()=>wo,Image:()=>Io,ImageBackground:()=>Po,InteractionManager:()=>So,Keyboard:()=>xo,KeyboardAvoidingView:()=>Fo,LayoutAnimation:()=>Mo,Linking:()=>vo,LogBox:()=>Uo,Modal:()=>hn,NativeEventEmitter:()=>ko,NativeModules:()=>uo,PanResponder:()=>To,Picker:()=>Lo,PixelRatio:()=>Co,Platform:()=>Ao,Pressable:()=>dn,ProgressBar:()=>$o,RefreshControl:()=>Do,SafeAreaView:()=>jo,ScrollView:()=>Qe,SectionList:()=>Wo,Share:()=>Eo,StatusBar:()=>Ho,StyleSheet:()=>V,Switch:()=>fn,Text:()=>h,TextInput:()=>ln,Touchable:()=>Vo,TouchableHighlight:()=>un,TouchableNativeFeedback:()=>No,TouchableOpacity:()=>ce,TouchableWithoutFeedback:()=>cn,UIManager:()=>zo,Vibration:()=>Ro,View:()=>y,VirtualizedList:()=>Jo,YellowBox:()=>Ko,findNodeHandle:()=>bn,unstable_createElement:()=>lo,useColorScheme:()=>_o,useLocaleContext:()=>Qo,useWindowDimensions:()=>Go});Fr(nr,so);import*as so from"react-native-web";import{unstable_createElement as lo,NativeModules as uo,AccessibilityInfo as co,Appearance as ho,AppRegistry as fo,AppState as mo,BackHandler as po,Clipboard as bo,Dimensions as go,Easing as yo,I18nManager as wo,Keyboard as xo,InteractionManager as So,LayoutAnimation as Mo,Linking as vo,NativeEventEmitter as ko,PanResponder as To,PixelRatio as Co,Platform as Ao,Share as Eo,UIManager as zo,Vibration as Ro,CheckBox as Bo,FlatList as Oo,Image as Io,ImageBackground as Po,KeyboardAvoidingView as Fo,Picker as Lo,ProgressBar as $o,RefreshControl as Do,SafeAreaView as jo,SectionList as Wo,StatusBar as Ho,Touchable as Vo,TouchableNativeFeedback as No,VirtualizedList as Jo,YellowBox as Ko,LogBox as Uo,DeviceEventEmitter as qo,useColorScheme as _o,useLocaleContext as Qo,useWindowDimensions as Go}from"react-native-web";import*as z from"react-native-web";import{createElement as Ue,forwardRef as ar,useCallback as Yo,useRef as Zo}from"react";import{useEffect as Xo,useState as en}from"react";import{createPortal as tn}from"react-dom";var rn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as on}from"react/jsx-runtime";var ue=Symbol.for("@buoy-gg/portal-host"),ir=s(e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"},"isTextField");function qe(){let e=document;if(e[ue])return e[ue].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:rn});let r=s(()=>{let u=document.fullscreenElement,b=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==b&&b.appendChild(t)},"move"),o=new Map,n=s(u=>{(!t.contains(u.target)||!ir(u.target))&&o.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},"down"),a=s(u=>{o.delete(u.code||u.key)},"up"),i=s(()=>o.clear(),"clear"),l=s(()=>{let u=[...o.values()];o.clear();for(let b of u)document.dispatchEvent(new KeyboardEvent("keyup",{...b,bubbles:true}))},"focus"),c=s(u=>{ir(u.target)&&u.stopPropagation()},"key"),d=s(u=>u.stopPropagation(),"wheel");return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",a,true),window.addEventListener("blur",i),t.addEventListener("focusin",l),t.addEventListener("keydown",c),t.addEventListener("keyup",c),t.addEventListener("keypress",c),t.addEventListener("wheel",d,{passive:true}),e[ue]={host:t,users:0,dispose:s(()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",a,true),window.removeEventListener("blur",i),t.remove(),delete e[ue]},"dispose")},t}s(qe,"getBuoyPortalHost");function sr({children:e}){let[t,r]=en(null);return Xo(()=>{let o=qe(),n=document[ue];return n.users++,r(o),()=>{--n.users===0&&n.dispose()}},[]),t?tn(on("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}s(sr,"BuoyPortal");var X=z,nn=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ee=s(e=>typeof e=="number"?`${e}px`:e,"px");function Se(e){if(Array.isArray(e)){let b=e.map(Se);return b.some((m,g)=>m!==e[g])?b:e}if(!e||typeof e!="object"||!nn.some(b=>e[b]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:o,shadowRadius:n,textShadowColor:a,textShadowOffset:i,textShadowRadius:l,...c}=e;if(t!=null||r!=null||o!=null||n!=null){let b=t??"black",m=o==null?b:`color-mix(in srgb, ${b} ${Math.min(o,1)*100}%, transparent)`,g=`${ee(r?.width??0)} ${ee(r?.height??0)} ${ee(n??0)} ${m}`;c.boxShadow=typeof c.boxShadow=="string"?`${c.boxShadow}, ${g}`:c.boxShadow??g}let{width:d=0,height:u=0}=i??{};if(a&&(d||u||l)){let b=`${ee(d)} ${ee(u)} ${ee(l??0)} ${a}`;c.textShadow=c.textShadow?`${c.textShadow}, ${b}`:b}return c}s(Se,"webShadows");var an=X.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function _e(e,t){if(typeof e=="function")return o=>_e(e(o),t);let r=Se(e);return t?[r,an[t]]:r}s(_e,"webStyle");var V={...X.StyleSheet,create:s(e=>X.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Se(r)]))),"create")};function B(e){let t=ar((o,n)=>{let{accessibilityState:a,accessibilityValue:i,pointerEvents:l,...c}=o;for(let u of["busy","checked","disabled","expanded","selected"])a?.[u]!==void 0&&c[`aria-${u}`]===void 0&&(c[`aria-${u}`]=a[u]);for(let[u,b]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[u]!==void 0&&c[`aria-${b}`]===void 0&&(c[`aria-${b}`]=i[u]);let d=_e(c.style,l);return d!==c.style&&(c.style=d),Ue(e,{...c,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}s(B,"withAccessibility");var y=B(z.View),h=B(z.Text),sn={...X.Animated,View:X.Animated.createAnimatedComponent(y),Text:X.Animated.createAnimatedComponent(h)},ln=B(z.TextInput),ce=B(z.TouchableOpacity),un=B(z.TouchableHighlight),cn=B(z.TouchableWithoutFeedback),dn=B(z.Pressable),Qe=B(z.ScrollView),lr=ar((e,t)=>{let r=Zo(null),o=Yo(n=>{if(n){let a=n;for(;a.parentElement&&a.parentElement!==document.body;)a=a.parentElement;a.parentElement===document.body&&(r.current=a,Object.assign(a.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),qe().appendChild(a))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return Ue(sr,null,Ue(z.Modal,{...e,ref:o}))});lr.displayName="Modal";var hn=B(lr),fn=B(z.Switch),mn=B(z.ActivityIndicator),pn=B(z.Button),bn=z.findNodeHandle,gn={alert(e,t,r,o){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(a),t){let d=document.createElement("p");d.textContent=t,d.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(d)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],c=s(()=>{n.close?.(),n.remove()},"close");for(let d of l){let u=document.createElement("button");u.type="button",u.textContent=d.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{c(),d.onPress?.()},i.appendChild(u)}n.addEventListener("cancel",d=>{d.preventDefault(),o?.cancelable!==false&&(c(),o?.onDismiss?.())}),n.appendChild(i),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{Activity as yn,JsModal as wn,macOSColors as F,night as R,ModalHeader as de,Pause as xn,Play as Sn,Trash2 as Mn}from"@buoy-gg/shared-ui/web";import{memo as vn}from"react";import{macOSColors as Ge}from"@buoy-gg/shared-ui/web";import{jsx as ur}from"react/jsx-runtime";var kn=60;function cr(e){return e>=80?Ge.semantic.error:e>=40?Ge.semantic.warning:Ge.semantic.success}s(cr,"barColor");var Tn=vn(s(function({history:e}){let t=e.slice(-kn);return ur(y,{style:dr.row,pointerEvents:"none",children:t.map((r,o)=>ur(y,{style:[dr.bar,{height:Math.max(2,r/100*28),backgroundColor:cr(r)}]},`b${o}`))})},"BusySparkline")),dr=V.create({row:{flexDirection:"row",alignItems:"flex-end",gap:1,height:28,alignSelf:"stretch"},bar:{flex:1,maxWidth:6,borderRadius:1,opacity:.9}});import{memo as Cn,useState as An}from"react";import{macOSColors as Me,night as k}from"@buoy-gg/shared-ui/web";import{jsx as O,jsxs as $}from"react/jsx-runtime";var En=[{key:"windowMs",title:"RECENT"},{key:"calls",title:"CALLS"},{key:"avgMs",title:"AVG"},{key:"maxMs",title:"MAX"},{key:"totalMs",title:"TOTAL"}],hr={timeout:{text:"TIMEOUT",color:"#38BDF8",prefix:"setTimeout"},interval:{text:"INTERVAL",color:"#22D3EE",prefix:"setInterval"},immediate:{text:"IMMED",color:"#60A5FA",prefix:"setImmediate"},raf:{text:"RAF",color:"#34D399",prefix:"requestAnimationFrame"},microtask:{text:"MICRO",color:"#A78BFA",prefix:"queueMicrotask"},then:{text:"PROMISE",color:"#BF5AF2",prefix:"Promise.then"},bridge:{text:"BRIDGE",color:"#FBBF24",prefix:"bridge"},unattributed:{text:"SYSTEM",color:"#8E8E93"},other:{text:"OTHER",color:"#8E8E93",prefix:"other"}};function ve(e){return hr[e]??hr.other}s(ve,"badgeFor");function Ye(e){if(e.api==="unattributed")return"events \xB7 React \xB7 native call-ins";if(e.api==="other")return e.key==="minor"?e.label:"evicted cold origins";let t=ve(e.api).prefix,r=e.label;return t&&r.startsWith(t)&&(r=r.slice(t.length)),r=r.replace(/^[\s←@]+/,"").trim(),r.length>0?r:"anonymous"}s(Ye,"displayName");function te(e){return e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e>=100?`${Math.round(e)}`:`${Math.round(e*10)/10}`}s(te,"fmt");function fr(e){return e.calls<=0?"measured by probe \xB7 not reachable from JS":`${te(e.calls)} calls \xB7 avg ${te(e.avgMs)} \xB7 max ${te(e.maxMs)} \xB7 total ${te(e.totalMs)} ms`}s(fr,"statsLine");var zn=Cn(s(function({row:e,rank:t,onPress:r}){let o=ve(e.api);return $(r?ce:y,{style:E.row,testID:"buoy-jstop-row",...r?{onPress:s(()=>r(e),"onPress"),activeOpacity:.6}:{},children:[$(y,{style:E.topLine,children:[O(h,{style:E.rank,children:t}),O(y,{style:[E.badge,{borderColor:o.color,backgroundColor:`${o.color}1A`}],children:O(h,{style:[E.badgeText,{color:o.color}],children:o.text})}),O(h,{style:E.name,numberOfLines:1,testID:"buoy-jstop-row-name",children:Ye(e)}),e.freezes>0&&$(h,{style:[E.freezeBadge,e.worstFreezeMs>=100&&E.freezeBadgeSevere],children:["\u26A0 \xD7",e.freezes]}),$(h,{style:[E.windowMs,e.api!=="unattributed"&&e.pctOfBusy>=25&&{color:e.pctOfBusy>=50?Me.semantic.error:Me.semantic.warning}],children:[te(e.windowMs),O(h,{style:E.unit,children:" ms"})]}),$(h,{style:[E.pct,e.api==="unattributed"&&E.pctMuted],children:[Math.round(e.pctOfBusy),"%"]})]}),$(y,{style:E.subLine,children:[O(y,{style:E.barTrack,children:O(y,{style:[E.barFill,{width:`${Math.min(100,e.pctOfBusy)}%`,backgroundColor:o.color}]})}),O(h,{style:E.stats,numberOfLines:1,testID:"buoy-jstop-row-stats",children:fr(e)})]})]})},"TaskRow"),(e,t)=>e.rank===t.rank&&e.onPress===t.onPress&&e.row.key===t.row.key&&e.row.windowMs===t.row.windowMs&&e.row.calls===t.row.calls&&e.row.maxMs===t.row.maxMs&&e.row.totalMs===t.row.totalMs&&e.row.pctOfBusy===t.row.pctOfBusy&&e.row.freezes===t.row.freezes&&e.row.worstFreezeMs===t.row.worstFreezeMs);function mr({rows:e,onSelectRow:t}){let[r,o]=An("windowMs"),n=r==="windowMs"?e:[...e].sort((a,i)=>i[r]-a[r]);return $(y,{style:D.root,children:[$(y,{style:D.sortRow,children:[O(h,{style:D.sortLabel,children:"SORT"}),En.map(a=>O(ce,{onPress:()=>o(a.key),style:[D.sortChip,r===a.key&&D.sortChipOn],children:O(h,{style:[D.sortChipText,r===a.key&&D.sortChipTextOn],children:a.title})},a.key))]}),$(Qe,{style:D.body,children:[n.map((a,i)=>O(zn,{row:a,rank:i+1,onPress:t},a.key)),n.length===0&&O(h,{style:D.empty,testID:"buoy-jstop-empty",children:"No tasks observed yet \u2014 interact with the app."})]})]})}s(mr,"TaskTable");var D=V.create({root:{flex:1,minHeight:0},sortRow:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:6,borderBottomWidth:1,borderBottomColor:k.color.border,backgroundColor:k.color.surface},sortLabel:{color:k.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginRight:2},sortChip:{borderWidth:1,borderColor:k.color.border,borderRadius:4,paddingHorizontal:7,paddingVertical:3},sortChipOn:{borderColor:k.color.accentBorderStrong,backgroundColor:k.color.accentSoft},sortChipText:{color:k.color.textTertiary,fontSize:9,fontWeight:"600",fontVariant:["tabular-nums"]},sortChipTextOn:{color:k.color.accent},body:{flex:1},empty:{color:k.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:24}}),E=V.create({row:{paddingHorizontal:10,paddingVertical:8,borderBottomWidth:V.hairlineWidth,borderBottomColor:k.color.border,gap:5},topLine:{flexDirection:"row",alignItems:"center",gap:6},rank:{width:16,color:k.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},badge:{borderWidth:1,borderRadius:3,paddingHorizontal:4,paddingVertical:1},badgeText:{fontSize:8,fontWeight:"700",letterSpacing:.4},name:{flex:1,color:k.color.text,fontSize:13,fontWeight:"500"},freezeBadge:{color:Me.semantic.warning,fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},freezeBadgeSevere:{color:Me.semantic.error},windowMs:{color:k.color.text,fontSize:13,fontWeight:"700",fontVariant:["tabular-nums"]},unit:{color:k.color.textTertiary,fontSize:10,fontWeight:"400"},pct:{width:38,textAlign:"right",color:k.color.textSecondary,fontSize:12,fontWeight:"600",fontVariant:["tabular-nums"]},pctMuted:{color:k.color.textTertiary},subLine:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:22},barTrack:{width:72,height:4,borderRadius:2,backgroundColor:k.color.fillSecondary,overflow:"hidden"},barFill:{height:4,borderRadius:2,opacity:.85},stats:{flex:1,color:k.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]}});import{memo as Rn}from"react";import{macOSColors as ke,night as A,useSafeAreaInsets as Bn}from"@buoy-gg/shared-ui/web";import{Fragment as pr,jsx as S,jsxs as I}from"react/jsx-runtime";var br={timeout:"Work scheduled with setTimeout. Time shown is the callback's exclusive run time on the JS thread.",interval:"A repeating setInterval. One scheduling site, many runs \u2014 a hot interval is the classic silent JS-FPS killer.",immediate:"Work scheduled with setImmediate \u2014 runs at the end of the current event-loop turn.",raf:"requestAnimationFrame work \u2014 runs once per frame while scheduled. Cost here directly trades against 60fps.",microtask:"queueMicrotask work \u2014 runs after the current task, before the thread yields.",then:"Promise reaction (.then/.catch/.finally). Named by the function that attached the reaction. Note: async/await bodies bypass .then and land in the System row instead.",bridge:"A native\u2192JS call-in over the legacy bridge (events, module callbacks), measured as its un-nested remainder.",unattributed:"Thread time the probe measured but no JS wrapper could claim: touch handlers, React commits, native call-ins, and async/await bodies. High here on New Architecture is normal \u2014 it's where UI work lives.",other:"Origins evicted from the table when the registry hit its cap \u2014 their totals are preserved here."};function gr(e){return br[e]??br.other}s(gr,"explainerFor");function N(e){return e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e>=100?`${Math.round(e)}`:`${Math.round(e*100)/100}`}s(N,"fmt");function yr(e){if(e<=0)return"\u2014";let t=e/1e3;return t<1?"just now":t<60?`${Math.round(t)}s ago`:`${Math.floor(t/60)}m ago`}s(yr,"agoFmt");function j({label:e,value:t,accent:r}){return I(y,{style:w.stat,children:[S(h,{style:w.statLabel,children:e}),S(h,{style:[w.statValue,r?{color:r}:null],children:t})]})}s(j,"Stat");var On=Rn(s(function({detail:e}){let t=ve(e.api),r=Bn({minBottom:12}),o=Math.max(1,...e.buckets);return I(Qe,{style:w.root,testID:"buoy-jstop-detail",contentContainerStyle:{paddingBottom:r.bottom},children:[I(y,{style:w.identityRow,children:[S(y,{style:[w.badge,{borderColor:t.color,backgroundColor:`${t.color}1A`}],children:S(h,{style:[w.badgeText,{color:t.color}],children:t.text})}),S(h,{style:w.name,numberOfLines:2,testID:"buoy-jstop-detail-name",children:Ye(e)})]}),S(h,{style:w.explainer,children:gr(e.api)}),S(h,{style:w.sectionTitle,children:"ACTIVITY \xB7 LAST 5S"}),S(y,{style:w.chartRow,children:e.buckets.map((n,a)=>S(y,{style:w.chartBarSlot,children:S(y,{style:[w.chartBar,{height:Math.max(2,n/o*44),backgroundColor:t.color}]})},`bk${a}`))}),I(y,{style:w.chartLegend,children:[I(h,{style:w.chartLegendText,children:[N(e.windowMs)," ms in window \xB7 ",e.pctOfBusy.toFixed(1),"% of busy time"]}),I(h,{style:w.chartLegendText,children:["peak ",N(o)," ms/250ms"]})]}),S(h,{style:w.sectionTitle,children:"STATS \xB7 SINCE START"}),I(y,{style:w.statGrid,children:[S(j,{label:"RUNS",value:e.calls>0?N(e.calls):"\u2014"}),S(j,{label:"SCHEDULED",value:e.scheduleCount>0?N(e.scheduleCount):"\u2014"}),S(j,{label:"AVG / RUN",value:e.calls>0?`${N(e.avgMs)} ms`:"\u2014"}),S(j,{label:"MAX / RUN",value:e.maxMs>0?`${N(e.maxMs)} ms`:"\u2014",accent:e.maxMs>=50?ke.semantic.warning:void 0}),S(j,{label:"TOTAL",value:e.totalMs>0?`${N(e.totalMs)} ms`:"\u2014"}),S(j,{label:"LAST RUN",value:yr(e.lastSeenAgoMs)}),S(j,{label:"FREEZES \xB7 60S",value:e.freezes>0?`${e.freezes}`:"0",accent:e.freezes>0?ke.semantic.error:void 0}),S(j,{label:"WORST FREEZE",value:e.worstFreezeMs>0?`${e.worstFreezeMs} ms`:"\u2014",accent:e.worstFreezeMs>=100?ke.semantic.error:e.worstFreezeMs>0?ke.semantic.warning:void 0})]}),(e.caller||(e.frames?.length??0)>0)&&I(pr,{children:[S(h,{style:w.sectionTitle,children:"SCHEDULED FROM"}),I(y,{style:w.siteCard,children:[e.caller&&I(h,{style:w.siteCaller,children:[e.caller,"()"]}),e.file&&I(h,{style:w.siteFile,children:[e.file,e.line!=null?`:${e.line}`:""]}),e.frames?.map((n,a)=>I(h,{style:w.siteFrame,numberOfLines:1,children:[n.file,":",n.line,":",n.col]},`fr${a}`)),S(h,{style:w.siteNote,children:"Frames are bundle offsets (Hermes) \u2014 the caller name above is the readable part. Captured once when this origin got hot."})]})]}),!e.caller&&(e.frames?.length??0)===0&&e.api!=="unattributed"&&e.api!=="other"&&I(pr,{children:[S(h,{style:w.sectionTitle,children:"SCHEDULED FROM"}),S(h,{style:w.sitePending,children:e.promoted?"Stack capture pending \u2014 next schedule from this site will record it.":"Not hot enough yet \u2014 the scheduling stack is captured once an origin passes 25 schedules or 50ms total."})]})]})},"TaskDetailView")),w=V.create({root:{flex:1,backgroundColor:"transparent",paddingHorizontal:12},identityRow:{flexDirection:"row",alignItems:"center",gap:8,paddingTop:12},badge:{borderWidth:1,borderRadius:3,paddingHorizontal:5,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.4},name:{flex:1,color:A.color.text,fontSize:15,fontWeight:"600"},explainer:{color:A.color.textTertiary,fontSize:11,lineHeight:15,marginTop:6,marginBottom:4},sectionTitle:{color:A.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginTop:14,marginBottom:6},chartRow:{flexDirection:"row",alignItems:"flex-end",height:48,gap:2,backgroundColor:A.color.surface,borderRadius:6,borderWidth:1,borderColor:A.color.border,paddingHorizontal:6,paddingTop:2},chartBarSlot:{flex:1,alignItems:"center",justifyContent:"flex-end"},chartBar:{width:"70%",borderTopLeftRadius:2,borderTopRightRadius:2,opacity:.9},chartLegend:{flexDirection:"row",justifyContent:"space-between",marginTop:4},chartLegendText:{color:A.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},statGrid:{flexDirection:"row",flexWrap:"wrap",gap:8},stat:{width:"23%",minWidth:76,flexGrow:1,backgroundColor:A.color.surface,borderWidth:1,borderColor:A.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:6},statLabel:{color:A.color.textTertiary,fontSize:8,fontWeight:"700",letterSpacing:.4,marginBottom:3},statValue:{color:A.color.text,fontSize:13,fontWeight:"600",fontVariant:["tabular-nums"]},siteCard:{backgroundColor:A.color.surface,borderWidth:1,borderColor:A.color.border,borderRadius:6,padding:10,gap:3},siteCaller:{color:A.color.text,fontSize:13,fontWeight:"600"},siteFile:{color:A.color.info,fontSize:11},siteFrame:{color:A.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},siteNote:{color:A.color.textTertiary,fontSize:9,opacity:.8,marginTop:4},sitePending:{color:A.color.textTertiary,fontSize:11}});import{Fragment as In,jsx as x,jsxs as W}from"react/jsx-runtime";function Ze(e){return e>=80?F.semantic.error:e>=40?F.semantic.warning:F.semantic.success}s(Ze,"busyColor");function Te(e){return e>=100?F.semantic.error:F.semantic.warning}s(Te,"freezeColor");function wr(e){let t=e.rows.find(r=>r.api!=="unattributed"&&r.api!=="other");return t&&t.pctOfBusy>=25&&e.busyPct>=15?{color:t.pctOfBusy>=50?F.semantic.error:F.semantic.warning,icon:"\u25B2",text:`${t.label} is eating ${Math.round(t.pctOfBusy)}% of thread time \u2014 start there.`}:e.freezeSummary.count>0?{color:Te(e.freezeSummary.worstMs),icon:"\u25B2",text:`${e.freezeSummary.count} freeze${e.freezeSummary.count===1?"":"s"} in the last 60s (worst ${e.freezeSummary.worstMs}ms) \u2014 check rows marked \u26A0.`}:e.busyPct>=80?{color:F.semantic.warning,icon:"\u25B2",text:"Thread saturated by UI/React work \u2014 open Highlight Updates to find re-renders."}:{color:F.semantic.success,icon:"\u25CF",text:`Thread healthy at ${Math.round(e.busyPct)}% load \u2014 nothing worth chasing.`}}s(wr,"diagnose");function Xe({visible:e,onClose:t,onBack:r,onMinimize:o,initialModalState:n,minimizeTargetPosition:a,remoteSnapshot:i,remoteActions:l,embedded:c=false}){let d=i!==void 0,[u,b]=or(null);ao(()=>{if(!(d||!e))return f.subscribe(b)},[d,e]);let m=d?i:u,g=io(()=>l??{pause:s(()=>f.pause(),"pause"),resume:s(()=>f.resume(),"resume"),clear:s(()=>f.clear(),"clear")},[l]),v=m?.paused??false,Ce=(m?.rows.length??0)>0,[Ae,nt]=or(null),Rr=no(K=>nt(K.key),[]),at=!d&&Ae?f.getOriginDetail(Ae):null,it=Ae!==null,st=W(de,{children:[it?x(de.Navigation,{onBack:()=>nt(null)}):r?x(de.Navigation,{onBack:r}):null,x(de.Content,{title:"",noMargin:true,children:W(y,{style:M.titleRow,children:[x(yn,{size:14,color:"#34D399"}),x(h,{style:M.title,testID:"buoy-jstop-title",children:"JS Top"}),m&&x(y,{style:[M.busyPill,{borderColor:Ze(m.busyPct)}],children:W(h,{testID:"buoy-jstop-busy",style:[M.busyText,{color:Ze(m.busyPct)}],children:[m.busyPct.toFixed(0),"% BUSY"]})}),m&&m.freezeSummary.count>0&&x(y,{style:[M.busyPill,{borderColor:Te(m.freezeSummary.worstMs)}],children:W(h,{testID:"buoy-jstop-freezes",style:[M.busyText,{color:Te(m.freezeSummary.worstMs)}],children:["\u26A0 ",m.freezeSummary.count," \xB7"," ",m.freezeSummary.worstMs,"ms"]})})]})}),W(de.Actions,{children:[x(ce,{onPress:v?g.resume:g.pause,style:[M.actionBtn,v&&M.actionBtnActive],testID:"buoy-jstop-pause",accessibilityLabel:v?"Resume sampling":"Pause sampling",children:v?x(Sn,{size:14,color:R.color.accent}):x(xn,{size:14,color:R.color.textSecondary})}),x(ce,{onPress:g.clear,disabled:!Ce,style:[M.actionBtn,!Ce&&M.actionBtnDisabled],testID:"buoy-jstop-clear",accessibilityLabel:"Clear stats",children:x(Mn,{size:14,color:Ce?R.color.textTertiary:R.color.textTertiary})})]})]}),lt=x(y,{style:M.body,children:it?at?x(On,{detail:at}):x(h,{style:M.waiting,children:"This origin is no longer tracked (cleared or evicted)."}):m?W(In,{children:[(()=>{let K=wr(m);return W(y,{style:[M.diagnosis,{borderLeftColor:K.color}],children:[x(h,{style:[M.diagnosisIcon,{color:K.color}],children:K.icon}),x(h,{style:M.diagnosisText,children:K.text})]})})(),W(y,{style:M.sparklineRow,children:[x(h,{style:M.sparklineCaption,children:"JS THREAD LOAD \xB7 LAST 30s"}),x(Tn,{history:m.busyHistory})]}),!m.tiers.bridge&&x(h,{style:M.tierBanner,children:"\u201CSystem\u201D rows are UI/React/native work pure JS can\u2019t name \u2014 timers, rAF and Promise chains are fully attributed."}),x(mr,{rows:m.rows,onSelectRow:d?void 0:Rr})]}):x(h,{style:M.waiting,children:d?"Waiting for device\u2026":"Starting engine\u2026"})});return c?W(y,{style:M.embeddedRoot,children:[x(y,{style:M.embeddedHeader,children:st}),lt]}):x(wn,{visible:e,onClose:t,onMinimize:o,minimizeTargetPosition:a,initialModalState:n,header:{showToggleButton:true,customContent:st},persistenceKey:"buoy-js-top-modal",enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:lt})}s(Xe,"JsTopModal");var M=V.create({titleRow:{flexDirection:"row",alignItems:"center",gap:8},title:{color:R.color.text,fontSize:14,fontWeight:"500"},busyPill:{borderWidth:1,borderRadius:4,paddingHorizontal:6,paddingVertical:2},busyText:{fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:R.color.buttonSurface,borderWidth:1,borderColor:R.color.border,alignItems:"center",justifyContent:"center"},actionBtnActive:{backgroundColor:R.color.accentSoft,borderColor:R.color.accentBorderStrong},actionBtnDisabled:{opacity:.55},body:{flex:1,minHeight:0,backgroundColor:"transparent"},diagnosis:{flexDirection:"row",alignItems:"center",gap:8,marginHorizontal:10,marginTop:8,paddingHorizontal:10,paddingVertical:8,backgroundColor:R.color.surface,borderRadius:6,borderLeftWidth:3},diagnosisIcon:{fontSize:11,fontWeight:"700"},diagnosisText:{flex:1,color:R.color.text,fontSize:12,lineHeight:16},sparklineRow:{paddingHorizontal:10,paddingVertical:8,gap:4},sparklineCaption:{color:R.color.textTertiary,fontSize:8,fontWeight:"700",letterSpacing:.5},tierBanner:{color:R.color.textTertiary,fontSize:10,paddingHorizontal:10,paddingBottom:6},waiting:{color:R.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:32},embeddedRoot:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:F.background.base},embeddedHeader:{borderBottomWidth:1,borderBottomColor:F.border.default}});import{useEffect as xr,useState as Sr}from"react";import{macOSColors as et,night as tt}from"@buoy-gg/shared-ui/web";import{jsx as Pn,jsxs as Mr}from"react/jsx-runtime";function vr(e){return e>=80?et.semantic.error:e>=40?et.semantic.warning:et.semantic.success}s(vr,"busyColor");function kr(){let[e,t]=Sr(()=>f.isEnabled()),[r,o]=Sr(null);if(xr(()=>f.subscribeEnabled(t),[]),xr(()=>{if(!e){o(null);return}return f.subscribe(o)},[e]),!e||!r)return null;let n=r.rows.find(a=>a.api!=="unattributed");return Mr(y,{style:rt.pill,pointerEvents:"none",children:[Mr(h,{style:[rt.busy,{color:vr(r.busyPct)}],children:[r.busyPct.toFixed(0),"%"]}),n&&Pn(h,{style:rt.label,numberOfLines:1,children:n.label})]})}s(kr,"JsTopHudOverlay");var rt=V.create({pill:{position:"absolute",top:60,left:8,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:tt.color.buttonSurface,borderWidth:1,borderColor:tt.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:4,maxWidth:220},busy:{fontSize:11,fontWeight:"700",fontVariant:["tabular-nums"]},label:{color:tt.color.textSecondary,fontSize:10,flexShrink:1}});import{useEffect as Fn,useState as Ln}from"react";import{Activity as Tr}from"@buoy-gg/shared-ui/web";import{jsx as Cr}from"react/jsx-runtime";var ot="#34D399",Ar="#6B7280";function Er({size:e}){let[t,r]=Ln(()=>f.isEnabled());return Fn(()=>f.subscribeEnabled(r),[]),Cr(Tr,{size:e,color:t?ot:Ar})}s(Er,"JsTopToggleIcon");function zr(){return null}s(zr,"EmptyComponent");var $n={id:"js-top",name:"JS TOP",description:"Toggle the floating JS-thread busy pill",slot:"row",icon:Er,component:zr,props:{},launchMode:"toggle-only",onPress:s(()=>{f.setEnabled(!f.isEnabled())},"onPress")},Dn={id:"js-top-modal",name:"TASKS",description:"Live Task Manager for the JS thread",slot:"both",icon:s(({size:e})=>Cr(Tr,{size:e,color:ot}),"icon"),component:Xe,props:{enableSharedModalDimensions:false}};f.registerTierInstaller(Qt);f.registerTierInstaller(Gt);f.registerTierInstaller(Xt);f.registerLongtaskProvider(er);f.registerFreezeStatsProvider(tr);f.registerClearHook(rr);try{typeof window<"u"&&(We(),He())}catch{}export{Ar as JS_TOP_DISABLED_COLOR,ot as JS_TOP_ENABLED_COLOR,f as JsTopController,kr as JsTopHudOverlay,Xe as JsTopModal,Dn as jsTopModalPreset,$n as jsTopPreset,oo as jsTopSyncAdapter};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/js-top",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.76",
|
|
4
4
|
"description": "Inspect instrumented JavaScript timers, promises and callbacks to investigate work on the React Native JS thread.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
15
|
+
"@buoy-gg/shared-ui": "^7.0.76"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "*"
|