@buoy-gg/js-top 7.0.56 → 7.0.57
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/engine/originRegistry.js +1 -1
- package/lib/commonjs/js-top/engine/symbolicate.web.js +1 -0
- package/lib/module/js-top/engine/originRegistry.js +1 -1
- package/lib/module/js-top/engine/symbolicate.web.js +1 -0
- package/lib/typescript/js-top/engine/symbolicate.web.d.ts +29 -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.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,
|
|
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 e=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)e+=n.ring[a]}return e}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;const e=getOrCreate(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);origins.delete(r.key)}function getOrCreate(n,r,i){let e=origins.get(n);if(!e){e=makeOrigin(n,r,i);origins.set(n,e)}return e}function parseStack(n){const r=[];let i;const e=n.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 s=/^(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(!i&&t&&t!=="anonymous"&&!s){i=t}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 e=i?i[1]:r;const o=e.split("/");return o.slice(-2).join("/")}function buoyJsTopOriginExists(n){return origins.has(n)}function buoyJsTopScheduleOrigin(n,r,i,e=true){const o=r;const a=typeof o.displayName==="string"&&o.displayName||typeof o.name==="string"&&o.name||"anonymous";const t=`${n}|${a}`;let s=origins.get(t);if(!s){if(origins.size>=_types.MAX_ORIGINS)evictColdest(i);s=makeOrigin(t,n,a==="anonymous"?apiLabel(n):`${apiLabel(n)} ${a}`);origins.set(t,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")&&e&&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=`${t}@${c??"?"}:${d}`;let l=origins.get(M);if(!l){if(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??t}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,e){const o=origins.get(n);if(!o)return;o.calls++;o.totalMs+=r;if(r>o.maxMs)o.maxMs=r;o.lastSeenAt=e;if(!o.promoted&&o.totalMs>=_types.PROMOTE_MIN_TOTAL_MS)o.promoted=true;const a=e-i;const t=a>0?Math.min(1,r/a):1;const s=Math.max(i,e-_types.WINDOW_BUCKETS*_types.BUCKET_MS);let c=(0,_aggregator.epochOf)(s);const m=(0,_aggregator.epochOf)(e);let u=s;while(c<=m){const d=(c+1)*_types.BUCKET_MS;const M=Math.min(e,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*t:r}}u=M;c++}(0,_aggregator.bookAttributedRange)(i,e,r)}function labelForOrigin(n){return origins.get(n)?.label??null}function buildRows(n,r,i){const e=[];for(const t of origins.values()){const s=windowMsOf(t,n);if(s<=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(s*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(s/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,n-t.lastSeenAt):0,freezes:0,worstFreezeMs:0})}e.sort((t,s)=>s.windowMs-t.windowMs||s.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,s)=>t+s.windowMs,0)*10)/10,pctOfBusy:Math.round(a.reduce((t,s)=>t+s.pctOfBusy,0)*10)/10,totalMs:Math.round(a.reduce((t,s)=>t+s.totalMs,0)*10)/10,calls:a.reduce((t,s)=>t+s.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,i)}return e.slice(0,i)}function getOriginDetailBase(n,r,i){const e=origins.get(n);if(!e)return null;const o=(0,_aggregator.epochOf)(r);const a=[];let t=0;for(let s=o-_types.WINDOW_BUCKETS+1;s<=o;s++){const c=s%_types.WINDOW_BUCKETS;const m=c>=0&&e.ringStamps[c]===s?Math.round(e.ring[c]*10)/10:0;a.push(m);t+=m}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:i>0?Math.min(100,Math.round(t/i*1e3)/10):0,lastSeenAgoMs:e.lastSeenAt>0?Math.max(0,r-e.lastSeenAt):0,buckets:a}}function resetOrigins(){origins.clear()}function debugGetOrigin(n){return origins.get(n)}function originCount(){return origins.size}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buoyJsTopSymbolicateOrigin=buoyJsTopSymbolicateOrigin;exports.decodeMappings=decodeMappings;exports.lookup=lookup;const MAX_IN_FLIGHT=3;let inFlight=0;function isDev(){return typeof __DEV__!=="undefined"&&__DEV__}const B64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const B64_INDEX=new Map([...B64].map((e,l)=>[e,l]));function decodeMappings(e){const l=[];let o=0;let i=0;let n=0;let t=0;for(const s of e.split(";")){const a=[];let f=0;for(const g of s.split(",")){if(!g)continue;const r=[];let c=0;let u=0;for(const h of g){const p=B64_INDEX.get(h);if(p===void 0)break;c+=(p&31)<<u;if(p&32){u+=5}else{r.push(c&1?-(c>>1):c>>1);c=0;u=0}}if(!r.length)continue;f+=r[0];if(r.length===1)a.push([f]);else if(r.length>=4){o+=r[1];i+=r[2];n+=r[3];if(r.length>=5){t+=r[4];a.push([f,o,i,n,t])}else{a.push([f,o,i,n])}}}l.push(a)}return l}function lookup(e,l,o){const i=e.lines[l-1];if(!i?.length)return null;let n;for(const s of i){if(s[0]<=o-1)n=s;else break}if(!n||n.length<4)return null;const t=e.sources[n[1]];if(!t)return null;return{file:t,line:n[2]+1,name:n.length>=5?e.names[n[4]]:void 0}}const maps=new Map;function loadMap(e){let l=maps.get(e);if(!l){l=(async()=>{const o=await(await fetch(e)).text();const i=Math.max(o.lastIndexOf("//# sourceMappingURL="),o.lastIndexOf("//@ sourceMappingURL="));if(i<0)return null;const n=/^\/\/[#@]\s*sourceMappingURL=(\S+)/.exec(o.slice(i));if(!n)return null;const t=new URL(n[1],e).href;const s=await(await fetch(t)).json();if(!s.mappings||!s.sources)return null;return{sources:s.sources,names:s.names??[],lines:decodeMappings(s.mappings)}})().catch(()=>null);maps.set(e,l)}return l}function tailPath(e){const l=e.split("?")[0]??e;return l.split("/").filter(Boolean).slice(-2).join("/")}function looksLikeComponent(e){return/^[A-Z][A-Za-z0-9]*$/.test(e)}function buoyJsTopSymbolicateOrigin(e,l){if(!isDev())return;if(e.symbolicated||!e.frames||e.frames.length===0)return;if(inFlight>=MAX_IN_FLIGHT)return;e.symbolicated=true;const o=e.frames.filter(i=>/^(https?|capacitor|file):\/\//.test(i.file));if(!o.length)return;inFlight++;(async()=>{for(const i of o){const n=await loadMap(i.file.split("?")[0]??i.file);if(!n)continue;const t=lookup(n,i.line,i.col);if(!t||t.file.includes("node_modules"))continue;const s=tailPath(t.file);e.file=s;e.line=t.line;const a=`${s.split("/").pop()}:${t.line}`;if(t.name&&looksLikeComponent(t.name)&&!e.caller){e.caller=t.name;e.label=`${e.label} \u2190 <${t.name}> \xB7 ${a}`}else{e.label=`${e.label} \xB7 ${a}`}return}})().catch(()=>{}).finally(()=>{inFlight--})}
|
|
@@ -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 I=500;const T=20;const c=new Map;export const OTHER_KEY="other";let w=0;let y=0;function x(
|
|
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 I=500;const T=20;const c=new Map;export const OTHER_KEY="other";let w=0;let y=0;function x(n,r,l){return{key:n,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(n,r){const l=g(r);let e=0;for(let o=l-M+1;o<=l;o++){const a=o%M;if(a>=0&&n.ringStamps[a]===o)e+=n.ring[a]}return e}function E(n){let r=null;let l=Infinity;for(const o of c.values()){if(o.key===OTHER_KEY)continue;const a=k(o,n)*1e6+o.lastSeenAt;if(a<l){l=a;r=o}}if(!r)return;const e=v(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)}function v(n,r,l){let e=c.get(n);if(!e){e=x(n,r,l);c.set(n,e)}return e}export function parseStack(n){const r=[];let l;const e=n.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 s=/^(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"&&!s){l=t}if(r.length>=3)break}return{caller:l,frames:r}}function K(n,r){if(r-n.lastCaptureAt<I){return false}if(r-w>1e3){w=r;y=0}if(y>=T)return false;y++;n.lastCaptureAt=r;return true}function A(n){if(!n)return void 0;const r=(n.split("?")[0]??n).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(n){return c.has(n)}export function buoyJsTopScheduleOrigin(n,r,l,e=true){const o=r;const a=typeof o.displayName==="string"&&o.displayName||typeof o.name==="string"&&o.name||"anonymous";const t=`${n}|${a}`;let s=c.get(t);if(!s){if(c.size>=b)E(l);s=x(t,n,a==="anonymous"?h(n):`${h(n)} ${a}`);c.set(t,s)}s.scheduleCount++;if(!s.promoted&&(s.scheduleCount>=_||s.totalMs>=C)){s.promoted=true}if((s.promoted||n==="interval")&&e&&K(s,l)){const{caller:u,frames:d}=parseStack(new Error().stack??"");const f=d[0];if(f||u){const S=f?`${A(f.file)??"?"}:${f.line}`:"?";const p=`${t}@${u??"?"}:${S}`;let i=c.get(p);if(!i){if(c.size>=b)E(l);const m=a==="anonymous"?h(n):`${h(n)} ${a}`;i=x(p,n,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=s.calls;i.totalMs=s.totalMs;i.maxMs=s.maxMs;i.scheduleCount=s.scheduleCount;i.lastSeenAt=s.lastSeenAt;i.ring.set(s.ring);i.ringStamps.set(s.ringStamps);s.calls=0;s.totalMs=0;s.maxMs=0;s.ring.fill(0);s.ringStamps.fill(-1);c.set(p,i);R(i,h(n))}s.activeRefinedKey=p}}return s.activeRefinedKey??t}function h(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}}export function buoyJsTopBookExclusive(n,r,l,e){const o=c.get(n);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 s=Math.max(l,e-M*O);let u=g(s);const d=g(e);let f=s;while(u<=d){const S=(u+1)*O;const p=Math.min(e,S);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(n){return c.get(n)?.label??null}export function buildRows(n,r,l){const e=[];for(const t of c.values()){const s=k(t,n);if(s<=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(s*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(s/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,n-t.lastSeenAt):0,freezes:0,worstFreezeMs:0})}e.sort((t,s)=>s.windowMs-t.windowMs||s.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,s)=>t+s.windowMs,0)*10)/10,pctOfBusy:Math.round(a.reduce((t,s)=>t+s.pctOfBusy,0)*10)/10,totalMs:Math.round(a.reduce((t,s)=>t+s.totalMs,0)*10)/10,calls:a.reduce((t,s)=>t+s.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(n,r,l){const e=c.get(n);if(!e)return null;const o=g(r);const a=[];let t=0;for(let s=o-M+1;s<=o;s++){const u=s%M;const d=u>=0&&e.ringStamps[u]===s?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(n){return c.get(n)}export function originCount(){return c.size}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const b=3;let g=0;function _(){return typeof __DEV__!=="undefined"&&__DEV__}const x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";const w=new Map([...x].map((e,l)=>[e,l]));export function decodeMappings(e){const l=[];let o=0;let i=0;let n=0;let t=0;for(const s of e.split(";")){const r=[];let f=0;for(const h of s.split(",")){if(!h)continue;const a=[];let c=0;let u=0;for(const d of h){const p=w.get(d);if(p===void 0)break;c+=(p&31)<<u;if(p&32){u+=5}else{a.push(c&1?-(c>>1):c>>1);c=0;u=0}}if(!a.length)continue;f+=a[0];if(a.length===1)r.push([f]);else if(a.length>=4){o+=a[1];i+=a[2];n+=a[3];if(a.length>=5){t+=a[4];r.push([f,o,i,n,t])}else{r.push([f,o,i,n])}}}l.push(r)}return l}export function lookup(e,l,o){const i=e.lines[l-1];if(!i?.length)return null;let n;for(const s of i){if(s[0]<=o-1)n=s;else break}if(!n||n.length<4)return null;const t=e.sources[n[1]];if(!t)return null;return{file:t,line:n[2]+1,name:n.length>=5?e.names[n[4]]:void 0}}const m=new Map;function M(e){let l=m.get(e);if(!l){l=(async()=>{const o=await(await fetch(e)).text();const i=Math.max(o.lastIndexOf("//# sourceMappingURL="),o.lastIndexOf("//@ sourceMappingURL="));if(i<0)return null;const n=/^\/\/[#@]\s*sourceMappingURL=(\S+)/.exec(o.slice(i));if(!n)return null;const t=new URL(n[1],e).href;const s=await(await fetch(t)).json();if(!s.mappings||!s.sources)return null;return{sources:s.sources,names:s.names??[],lines:decodeMappings(s.mappings)}})().catch(()=>null);m.set(e,l)}return l}function y(e){const l=e.split("?")[0]??e;return l.split("/").filter(Boolean).slice(-2).join("/")}function L(e){return/^[A-Z][A-Za-z0-9]*$/.test(e)}export function buoyJsTopSymbolicateOrigin(e,l){if(!_())return;if(e.symbolicated||!e.frames||e.frames.length===0)return;if(g>=b)return;e.symbolicated=true;const o=e.frames.filter(i=>/^(https?|capacitor|file):\/\//.test(i.file));if(!o.length)return;g++;(async()=>{for(const i of o){const n=await M(i.file.split("?")[0]??i.file);if(!n)continue;const t=lookup(n,i.line,i.col);if(!t||t.file.includes("node_modules"))continue;const s=y(t.file);e.file=s;e.line=t.line;const r=`${s.split("/").pop()}:${t.line}`;if(t.name&&L(t.name)&&!e.caller){e.caller=t.name;e.label=`${e.label} \u2190 <${t.name}> \xB7 ${r}`}else{e.label=`${e.label} \xB7 ${r}`}return}})().catch(()=>{}).finally(()=>{g--})}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web twin of symbolicate.ts. There is no Metro to ask, so the bundle's own
|
|
3
|
+
* source map is read instead: the script names it in a `sourceMappingURL`
|
|
4
|
+
* comment (a file next to it, or inline as a data: URL, which Vite's dev
|
|
5
|
+
* server uses). Works for http(s) pages and Capacitor's capacitor:// pages.
|
|
6
|
+
*
|
|
7
|
+
* Same contract as native: dev only, one attempt per origin, a few in flight,
|
|
8
|
+
* silent on any failure (no map in a production build, a map that won't
|
|
9
|
+
* load). The origin's label/file/line are upgraded in place.
|
|
10
|
+
*/
|
|
11
|
+
import type { Origin } from "./originRegistry";
|
|
12
|
+
/** One decoded line: [generatedCol, sourceIndex, originalLine, originalCol, nameIndex?] segments. */
|
|
13
|
+
type Segment = number[];
|
|
14
|
+
interface DecodedMap {
|
|
15
|
+
sources: string[];
|
|
16
|
+
names: string[];
|
|
17
|
+
lines: Segment[][];
|
|
18
|
+
}
|
|
19
|
+
/** Decode a source map's VLQ `mappings` into absolute values per generated line. */
|
|
20
|
+
export declare function decodeMappings(mappings: string): Segment[][];
|
|
21
|
+
/** The original position for a generated 1-based line and 1-based column. */
|
|
22
|
+
export declare function lookup(map: DecodedMap, line: number, col: number): {
|
|
23
|
+
file: string;
|
|
24
|
+
line: number;
|
|
25
|
+
name?: string;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare function buoyJsTopSymbolicateOrigin(o: Origin, _apiLabelText: string): void;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=symbolicate.web.d.ts.map
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";var Ve=Object.defineProperty;var
|
|
2
|
-
`);for(let o of n){let i=/at\s+(.*?)\s+\((?:address at\s+)?(.*?):(\d+):(\d+)\)/.exec(o)??/at\s+()(.*?):(\d+):(\d+)$/.exec(o.trim());if(!i)continue;let a=i[1]??"";if(a.includes("buoyJsTop")||a==="Error"||i[2]?.includes("/js-top/"))continue;t.push({file:i[2]??"",line:Number(i[3]),col:Number(i[4])});let s=/^(react_stack_bottom_frame|runWithFiberInDEV|commitHookEffectList|flushPassive|performWork|renderWithHooks|safelyCall)/.test(a)||/^(then|catch|finally|resolve|reject|fulfilled|rejected|step|tryCallOne|tryCallTwo|tryCatch|invokeCallback|notify)$/.test(a);if(!r&&a&&a!=="anonymous"&&!s&&(r=a),t.length>=3)break}return{caller:r,frames:t}}function Ut(e,t){return t-e.lastCaptureAt<jt||(t-_e>1e3&&(_e=t,xe=0),xe>=qt)?false:(xe++,e.lastCaptureAt=t,true)}function Se(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("/")}function _t(e){return k.has(e)}function ve(e,t,r,n=true){let o=t,i=typeof o.displayName=="string"&&o.displayName||typeof o.name=="string"&&o.name||"anonymous",a=`${e}|${i}`,s=k.get(a);if(s||(k.size>=500&&Ge(r),s=we(a,e,i==="anonymous"?X(e):`${X(e)} ${i}`),k.set(a,s)),s.scheduleCount++,!s.promoted&&(s.scheduleCount>=25||s.totalMs>=50)&&(s.promoted=true),(s.promoted||e==="interval")&&n&&Ut(s,r)){let{caller:l,frames:u}=Kt(new Error().stack??""),M=u[0];if(M||l){let F=M?`${Se(M.file)??"?"}:${M.line}`:"?",p=`${a}@${l??"?"}:${F}`,g=k.get(p);if(!g){k.size>=500&&Ge(r);let C=i==="anonymous"?X(e):`${X(e)} ${i}`;g=we(p,e,l?`${C} \u2190 ${l}`:i==="anonymous"?`${C} @ ${Se(M?.file??"")??"?"}`:C),g.caller=l,g.file=M?Se(M.file):void 0,g.line=M?.line,g.frames=u,g.promoted=true,g.calls=s.calls,g.totalMs=s.totalMs,g.maxMs=s.maxMs,g.scheduleCount=s.scheduleCount,g.lastSeenAt=s.lastSeenAt,g.ring.set(s.ring),g.ringStamps.set(s.ringStamps),s.calls=0,s.totalMs=0,s.maxMs=0,s.ring.fill(0),s.ringStamps.fill(-1),k.set(p,g),Nt(g,X(e))}s.activeRefinedKey=p}}return s.activeRefinedKey??a}function X(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}}function Qt(e,t,r,n){let o=k.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 i=n-r,a=i>0?Math.min(1,t/i):1,s=Math.max(r,n-5e3),l=P(s),u=P(n),M=s;for(;l<=u;){let F=(l+1)*250,p=Math.min(n,F),g=p-M;if(g>0){let C=l%20;C>=0&&(o.ringStamps[C]!==l&&(o.ringStamps[C]=l,o.ring[C]=0),o.ring[C]+=i>0?g*a:t)}M=p,l++}Ot(r,n,t)}function Gt(e){return k.get(e)?.label??null}function Yt(e,t,r){let n=[];for(let a of k.values()){let s=Qe(a,e);s<=0&&a.totalMs<1||n.push({key:a.key,label:a.label,api:a.api,file:a.file,line:a.line,windowMs:Math.round(s*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(s/t*1e3)/10):0,totalMs:Math.round(a.totalMs*10)/10,calls:a.calls,avgMs:a.calls>0?Math.round(a.totalMs/a.calls*100)/100:0,maxMs:Math.round(a.maxMs*100)/100,lastSeenAgoMs:a.lastSeenAt>0?Math.max(0,e-a.lastSeenAt):0,freezes:0,worstFreezeMs:0})}n.sort((a,s)=>s.windowMs-a.windowMs||s.totalMs-a.totalMs);let o=[],i=[];for(let a of n)(a.windowMs>=1||a.pctOfBusy>=.5||a.freezes>0?o:i).push(a);return i.length>=2?(o.push({key:"minor",label:`${i.length} minor origins (\u22641ms each)`,api:"other",windowMs:Math.round(i.reduce((a,s)=>a+s.windowMs,0)*10)/10,pctOfBusy:Math.round(i.reduce((a,s)=>a+s.pctOfBusy,0)*10)/10,totalMs:Math.round(i.reduce((a,s)=>a+s.totalMs,0)*10)/10,calls:i.reduce((a,s)=>a+s.calls,0),avgMs:0,maxMs:Math.max(0,...i.map(a=>a.maxMs)),lastSeenAgoMs:Math.min(...i.map(a=>a.lastSeenAgoMs)),freezes:0,worstFreezeMs:0}),o.slice(0,r)):n.slice(0,r)}function Zt(e,t,r){let n=k.get(e);if(!n)return null;let o=P(t),i=[],a=0;for(let s=o-20+1;s<=o;s++){let l=s%20,u=l>=0&&n.ringStamps[l]===s?Math.round(n.ring[l]*10)/10:0;i.push(u),a+=u}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(a*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(a/r*1e3)/10):0,lastSeenAgoMs:n.lastSeenAt>0?Math.max(0,t-n.lastSeenAt):0,buckets:i}}function Xt(){k.clear()}var er=32,K=[],tr=20,Ye=64,Ze=new Array(Ye).fill(null),ke=0;function rr(){return Ze}function Xe(e,t){let r=I(),n=K.length>0?K[K.length-1]:null,o=null;K.length<er&&(o={originKey:e,start:r,childrenMs:0},K.push(o));try{return t()}finally{try{if(o){K.pop();let i=I(),a=i-r,s=Math.max(0,a-o.childrenMs);n&&(n.childrenMs+=a),Qt(e,s,r,i),!n&&a>=tr&&(Ze[ke]={originKey:e,start:r,end:i},ke=(ke+1)%Ye)}}catch{}}}function U(e,t){if(typeof e!="function"||e[qe])return e;let r=V()?ve(t,e,I()):null,n=function(...o){return V()?((r===null||!_t(r))&&(r=ve(t,e,I(),false)),Xe(r,()=>e.apply(this,o))):e.apply(this,o)};return n[qe]=true,n}function et(e,t,r){if(!V())return r();let n=ve(e,{name:t},I());return Xe(n,r)}function tt(){let e=be();if(typeof h.setTimeout=="function"&&!h.setTimeout[S]){let t=function(r,n,...o){let i=U(r,"timeout");return e.setTimeout(i,n,...o)};t[S]=true,h.setTimeout=t}if(typeof h.setInterval=="function"&&!h.setInterval[S]){let t=function(r,n,...o){let i=U(r,"interval");return e.setInterval(i,n,...o)};t[S]=true,h.setInterval=t}if(typeof h.setImmediate=="function"&&!h.setImmediate[S]&&e.setImmediate){let t=function(r,...n){let o=U(r,"immediate");return e.setImmediate(o,...n)};t[S]=true,h.setImmediate=t}if(typeof h.requestAnimationFrame=="function"&&!h.requestAnimationFrame[S]&&e.requestAnimationFrame){let t=function(r){let n=U(r,"raf");return e.requestAnimationFrame(n)};t[S]=true,h.requestAnimationFrame=t}}function rt(){let e=be();if(typeof h.queueMicrotask=="function"&&!h.queueMicrotask[S]&&e.queueMicrotask){let t=function(r){let n=U(r,"microtask");return e.queueMicrotask(n)};t[S]=true,h.queueMicrotask=t}}var Te=16,nr=100,or=3,ir=8,ee=null,te=0,ce=false,re=[],_=1/0,Q=0,Ce=Te;function ar(){let e=I(),t=te>0?e-te:0;if(te=e,ce){ce=false,_=1/0,Q=e;return}if(t<=0)return;t<nr&&(t<_&&(_=t),Q===0&&(Q=e),e-Q>=1e3&&(re.push(_),re.length>or&&re.shift(),Ce=Math.max(ir,Math.min(...re)),_=1/0,Q=e));let r=t-Ce;r>1&&Ft(e-r,e)}function nt(){if(ee!=null)return;let e=le();te=I(),ce=false,re=[],_=1/0,Q=0,Ce=Te,ee=e.setInterval(ar,Te)}function ot(){ee!=null&&(le().clearInterval(ee),ee=null),te=0}function sr(){ce=true}import{definePersistedSetting as lr}from"@buoy-gg/shared-ui/web";var cr="@react_buoy/js-top/prefs",ur={enabled:false},it=lr(cr,ur,{sanitize:e=>({enabled:e.enabled===true})});async function dr(){return it.load()}async function hr(e){await it.save(e)}import{subscribeRealAppState as fr}from"@buoy-gg/shared-ui/web";var mr=250,pr=class{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=[];dr().then(e=>{this.enabledLoaded=true,e.enabled&&!this.enabled&&this.setEnabled(true)})}subscribe(e){return this.subscribers.add(e),this.syncEngineState(),e(this.snapshot),()=>{this.subscribers.delete(e),this.syncEngineState()}}subscribeEnabled(e){return this.enabledSubscribers.add(e),e(this.enabled),()=>{this.enabledSubscribers.delete(e)}}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.enabledLoaded&&hr({enabled:e}),this.enabledSubscribers.forEach(t=>{try{t(e)}catch(r){Y&&console.error("[js-top] enabled subscriber threw",r)}}),this.syncEngineState())}isEnabled(){return this.enabled}setRemoteSampling(e){this.remoteSampling!==e&&(this.remoteSampling=e,this.syncEngineState())}isRemoteSampling(){return this.remoteSampling}getStatus(){return this.engineRunning?this.paused?"paused":"running":"disabled"}pause(){this.paused||(this.paused=true,se(false),ot(),this.emitSnapshot())}resume(){this.paused&&(this.paused=false,this.engineRunning&&(se(true),nt()),this.emitSnapshot())}clear(){Xt(),Wt();for(let e of this.clearHooks)try{e()}catch{}this.emitSnapshot()}registerClearHook(e){this.clearHooks.push(e)}getSnapshot(){return this.snapshot}getOriginDetail(e){let t=I(),r=Ke(t),n=this.freezeStatsProvider?.(Date.now())?.byOrigin[e];if(e==="unattributed"){let i=$t(t),a=Math.round(i.reduce((s,l)=>s+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:a,pctOfBusy:r>0?Math.min(100,Math.round(a/r*1e3)/10):0,lastSeenAgoMs:0,buckets:i,freezes:n?.count??0,worstFreezeMs:Math.round(n?.maxMs??0)}}let o=Zt(e,t,r);return o?{...o,freezes:n?.count??0,worstFreezeMs:Math.round(n?.maxMs??0)}:null}registerTierInstaller(e){this.tierInstallers.push(e),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(){let e=this.shouldRun();e&&!this.engineRunning?this.startEngine():!e&&this.engineRunning&&this.stopEngine()}runInstaller(e){try{return e()}catch(t){return Y&&console.error("[js-top] tier installer threw",t),{}}}startEngine(){this.engineRunning=true,tt(),rt(),this.tiers={timers:true,promises:false,bridge:false,longtask:false};for(let e of this.tierInstallers)Object.assign(this.tiers,this.runInstaller(e));se(!this.paused),this.paused||nt();try{this.appStateSub=fr(()=>{sr()})}catch{this.appStateSub=null}this.notifyHandle=le().setInterval(()=>this.emitSnapshot(),mr),this.emitSnapshot()}stopEngine(){if(this.engineRunning=false,se(false),ot(),this.notifyHandle!=null&&(le().clearInterval(this.notifyHandle),this.notifyHandle=null),this.appStateSub){try{this.appStateSub.remove()}catch{}this.appStateSub=null}}buildSnapshot(){let e=I(),t=Ke(e),r=Pt(e),n=Math.max(0,t-r),o=Yt(e,t,30);n>=1&&(o.push({key:"unattributed",label:"unattributed (events / React / native call-ins)",api:"unattributed",windowMs:Math.round(n*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(n/t*1e3)/10):0,totalMs:0,calls:0,avgMs:0,maxMs:0,lastSeenAgoMs:0,freezes:0,worstFreezeMs:0}),o.sort((s,l)=>l.windowMs-s.windowMs||l.totalMs-s.totalMs));let i=this.freezeStatsProvider?.(Date.now())??{count:0,worstMs:0,byOrigin:{}};for(let s of o){let l=i.byOrigin[s.key];l&&(s.freezes=l.count,s.worstFreezeMs=Math.round(l.maxMs))}let a=5e3;return{ts:Date.now(),paused:this.paused,busyPct:Math.min(100,Math.round(t/a*1e3)/10),busyHistory:Lt(e),tiers:{...this.tiers},rows:o,totals:{attributedWindowMs:Math.round(r*10)/10,unattributedWindowMs:Math.round(n*10)/10,windowMs:a},freezeSummary:{count:i.count,worstMs:Math.round(i.worstMs)},longtasks:this.longtaskProvider?this.longtaskProvider():[]}}emitSnapshot(){this.snapshot=this.buildSnapshot(),this.subscribers.forEach(e=>{try{e(this.snapshot)}catch(t){Y&&console.error("[js-top] snapshot subscriber threw",t)}})}isEngineActive(){return V()}},d=new pr;function ze(e,t){let r=e[t];if(typeof r!="function")return false;if(r[S])return true;let n=function(...o){for(let i=0;i<o.length;i++)typeof o[i]=="function"&&(o[i]=U(o[i],"then"));return r.apply(this,o)};return n[S]=true,Object.defineProperty(n,"name",{value:t,configurable:true}),e[t]=n,true}function br(){let e=h.Promise?.prototype;if(!e)return{promises:false};let t=ze(e,"then");return ze(e,"catch"),ze(e,"finally"),{promises:t}}function gr(){let e=h.__fbBatchedBridge;if(!e)return{bridge:false};let t=false;if(typeof e.callFunctionReturnFlushedQueue=="function"&&!e.callFunctionReturnFlushedQueue[S]){let n=e.callFunctionReturnFlushedQueue.bind(e),o=function(i,a,s){return V()?et("bridge",`${i}.${a}`,()=>n(i,a,s)):n(i,a,s)};o[S]=true,e.callFunctionReturnFlushedQueue=o,t=true}if(typeof e.invokeCallbackAndReturnFlushedQueue=="function"&&!e.invokeCallbackAndReturnFlushedQueue[S]){let n=e.invokeCallbackAndReturnFlushedQueue.bind(e),o=function(i,a){return V()?et("bridge","nativeModuleCallback",()=>n(i,a)):n(i,a)};o[S]=true,e.invokeCallbackAndReturnFlushedQueue=o,t=true}let r=e.callFunctionReturnFlushedQueue?.[S]===true;return{bridge:t||r}}var yr=40,Mr=6e4,xr="unattributed",at=false,ue=false,G=[];function wr(e,t){let r=e+t,n=null,o=0;for(let i of rr()){if(!i)continue;let a=Math.min(r,i.end)-Math.max(e,i.start);a>o&&(o=a,n=i.originKey)}return n}function Sr(){if(at)return{longtask:ue};at=true;let e=h.PerformanceObserver;if(typeof e!="function")return{longtask:false};try{new e(t=>{if(V())try{for(let r of t.getEntries()){if(r.entryType!=="longtask")continue;let n=r.startTime,o=r.duration;It(n,n+o),G.push({start:n,duration:o,at:Date.now(),originKey:wr(n,o)}),G.length>yr&&G.shift()}}catch{}}).observe({entryTypes:["longtask"]}),ue=true}catch{ue=false}return{longtask:ue}}function vr(){return G.map(e=>({start:e.start,duration:e.duration,at:e.at,originLabel:e.originKey?Gt(e.originKey):null}))}function kr(e){let t={},r=0,n=0;for(let o of G){if(o.at>0&&e-o.at>Mr)continue;r++,o.duration>n&&(n=o.duration);let i=o.originKey??xr,a=t[i];a?(a.count++,o.duration>a.maxMs&&(a.maxMs=o.duration)):t[i]={count:1,maxMs:o.duration}}return{count:r,worstMs:n,byOrigin:t}}function Tr(){G.length=0}var Cr={version:1,getSnapshot:()=>({live:d.getSnapshot(),enabled:d.isEnabled()||d.isRemoteSampling()}),subscribe:e=>{let t=d.subscribe(()=>e()),r=d.subscribeEnabled(()=>e());return()=>{t(),r()}},actions:{setEnabled:e=>{let t=e.enabled;d.setRemoteSampling(t)},pause:()=>d.pause(),resume:()=>d.resume(),clear:()=>d.clear(),getOriginDetail:e=>d.getOriginDetail(e.key),sample:async e=>{let t=e,r=Math.min(Math.max(t?.durationMs??3e3,250),3e4),n=d.isRemoteSampling()||d.isEnabled();n||d.setRemoteSampling(true),t?.clearFirst&&d.clear();try{return await new Promise(o=>setTimeout(o,r)),d.getSnapshot()}finally{n||d.setRemoteSampling(false)}}}};import{useCallback as zr,useEffect as Ar,useMemo as Rr,useState as st}from"react";var lt={};zt(lt,{AccessibilityInfo:()=>Or,ActivityIndicator:()=>Rn,Alert:()=>Fn,Animated:()=>Ir,AppRegistry:()=>$r,AppState:()=>Lr,Appearance:()=>Pr,BackHandler:()=>Wr,Button:()=>Bn,CheckBox:()=>en,Clipboard:()=>Dr,DeviceEventEmitter:()=>gn,Dimensions:()=>Hr,Easing:()=>Vr,FlatList:()=>tn,I18nManager:()=>Nr,Image:()=>rn,ImageBackground:()=>nn,InteractionManager:()=>qr,Keyboard:()=>jr,KeyboardAvoidingView:()=>on,LayoutAnimation:()=>Jr,Linking:()=>Kr,LogBox:()=>bn,Modal:()=>zn,NativeEventEmitter:()=>Ur,NativeModules:()=>Fr,PanResponder:()=>_r,Picker:()=>an,PixelRatio:()=>Qr,Platform:()=>Gr,Pressable:()=>Cn,ProgressBar:()=>sn,RefreshControl:()=>ln,SafeAreaView:()=>cn,ScrollView:()=>Ae,SectionList:()=>un,Share:()=>Yr,StatusBar:()=>dn,StyleSheet:()=>D,Switch:()=>An,Text:()=>c,TextInput:()=>vn,Touchable:()=>hn,TouchableHighlight:()=>kn,TouchableNativeFeedback:()=>fn,TouchableOpacity:()=>ne,TouchableWithoutFeedback:()=>Tn,UIManager:()=>Zr,Vibration:()=>Xr,View:()=>f,VirtualizedList:()=>mn,YellowBox:()=>pn,findNodeHandle:()=>En,unstable_createElement:()=>Er,useColorScheme:()=>yn,useLocaleContext:()=>Mn,useWindowDimensions:()=>xn});At(lt,Br);import*as Br from"react-native-web";import{unstable_createElement as Er,NativeModules as Fr,AccessibilityInfo as Or,Animated as Ir,Appearance as Pr,AppRegistry as $r,AppState as Lr,BackHandler as Wr,Clipboard as Dr,Dimensions as Hr,Easing as Vr,I18nManager as Nr,Keyboard as jr,InteractionManager as qr,LayoutAnimation as Jr,Linking as Kr,NativeEventEmitter as Ur,PanResponder as _r,PixelRatio as Qr,Platform as Gr,Share as Yr,StyleSheet as D,UIManager as Zr,Vibration as Xr,CheckBox as en,FlatList as tn,Image as rn,ImageBackground as nn,KeyboardAvoidingView as on,Picker as an,ProgressBar as sn,RefreshControl as ln,SafeAreaView as cn,SectionList as un,StatusBar as dn,Touchable as hn,TouchableNativeFeedback as fn,VirtualizedList as mn,YellowBox as pn,LogBox as bn,DeviceEventEmitter as gn,useColorScheme as yn,useLocaleContext as Mn,useWindowDimensions as xn}from"react-native-web";import*as A from"react-native-web";import{createElement as wn,forwardRef as Sn}from"react";function E(e){let t=Sn((n,o)=>{let{accessibilityState:i,accessibilityValue:a,...s}=n;for(let l of["busy","checked","disabled","expanded","selected"])i?.[l]!==void 0&&s[`aria-${l}`]===void 0&&(s[`aria-${l}`]=i[l]);for(let[l,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[l]!==void 0&&s[`aria-${u}`]===void 0&&(s[`aria-${u}`]=a[l]);return wn(e,{...s,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var f=E(A.View),c=E(A.Text),vn=E(A.TextInput),ne=E(A.TouchableOpacity),kn=E(A.TouchableHighlight),Tn=E(A.TouchableWithoutFeedback),Cn=E(A.Pressable),Ae=E(A.ScrollView),zn=E(A.Modal),An=E(A.Switch),Rn=E(A.ActivityIndicator),Bn=E(A.Button),En=A.findNodeHandle,Fn={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 i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(u)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let s=r?.length?r:[{text:"OK"}],l=()=>{o.close?.(),o.remove()};for(let u of s){let M=document.createElement("button");M.type="button",M.textContent=u.text??"OK",M.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,M.onclick=()=>{l(),u.onPress?.()},a.appendChild(M)}o.addEventListener("cancel",u=>{u.preventDefault(),n?.cancelable!==false&&(l(),n?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{Activity as On,JsModal as In,macOSColors as O,night as z,ModalHeader as oe,Pause as Pn,Play as $n,Trash2 as Ln}from"@buoy-gg/shared-ui/web";import{memo as Wn}from"react";import{macOSColors as Re}from"@buoy-gg/shared-ui/web";import{jsx as ct}from"react/jsx-runtime";var Dn=60;function Hn(e){return e>=80?Re.semantic.error:e>=40?Re.semantic.warning:Re.semantic.success}var Vn=Wn(function({history:e}){let t=e.slice(-Dn);return ct(f,{style:ut.row,pointerEvents:"none",children:t.map((r,n)=>ct(f,{style:[ut.bar,{height:Math.max(2,r/100*28),backgroundColor:Hn(r)}]},`b${n}`))})}),ut=D.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 Nn,useState as jn}from"react";import{macOSColors as de,night as w}from"@buoy-gg/shared-ui/web";import{jsx as R,jsxs as $}from"react/jsx-runtime";var qn=[{key:"windowMs",title:"RECENT"},{key:"calls",title:"CALLS"},{key:"avgMs",title:"AVG"},{key:"maxMs",title:"MAX"},{key:"totalMs",title:"TOTAL"}],dt={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 Be(e){return dt[e]??dt.other}function ht(e){if(e.api==="unattributed")return"events \xB7 React \xB7 native call-ins";if(e.api==="other")return"evicted cold origins";let t=Be(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"}function ie(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}`}function Jn(e){return e.calls<=0?"measured by probe \xB7 not reachable from JS":`${ie(e.calls)} calls \xB7 avg ${ie(e.avgMs)} \xB7 max ${ie(e.maxMs)} \xB7 total ${ie(e.totalMs)} ms`}var Kn=Nn(function({row:e,rank:t,onPress:r}){let n=Be(e.api);return $(r?ne:f,{style:T.row,...r?{onPress:()=>r(e),activeOpacity:.6}:{},children:[$(f,{style:T.topLine,children:[R(c,{style:T.rank,children:t}),R(f,{style:[T.badge,{borderColor:n.color,backgroundColor:`${n.color}1A`}],children:R(c,{style:[T.badgeText,{color:n.color}],children:n.text})}),R(c,{style:T.name,numberOfLines:1,children:ht(e)}),e.freezes>0&&$(c,{style:[T.freezeBadge,e.worstFreezeMs>=100&&T.freezeBadgeSevere],children:["\u26A0 \xD7",e.freezes]}),$(c,{style:[T.windowMs,e.api!=="unattributed"&&e.pctOfBusy>=25&&{color:e.pctOfBusy>=50?de.semantic.error:de.semantic.warning}],children:[ie(e.windowMs),R(c,{style:T.unit,children:" ms"})]}),$(c,{style:[T.pct,e.api==="unattributed"&&T.pctMuted],children:[Math.round(e.pctOfBusy),"%"]})]}),$(f,{style:T.subLine,children:[R(f,{style:T.barTrack,children:R(f,{style:[T.barFill,{width:`${Math.min(100,e.pctOfBusy)}%`,backgroundColor:n.color}]})}),R(c,{style:T.stats,numberOfLines:1,children:Jn(e)})]})]})},(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 Un({rows:e,onSelectRow:t}){let[r,n]=jn("windowMs"),o=r==="windowMs"?e:[...e].sort((i,a)=>a[r]-i[r]);return $(f,{style:L.root,children:[$(f,{style:L.sortRow,children:[R(c,{style:L.sortLabel,children:"SORT"}),qn.map(i=>R(ne,{onPress:()=>n(i.key),style:[L.sortChip,r===i.key&&L.sortChipOn],children:R(c,{style:[L.sortChipText,r===i.key&&L.sortChipTextOn],children:i.title})},i.key))]}),$(Ae,{style:L.body,children:[o.map((i,a)=>R(Kn,{row:i,rank:a+1,onPress:t},i.key)),o.length===0&&R(c,{style:L.empty,children:"No tasks observed yet \u2014 interact with the app."})]})]})}var L=D.create({root:{flex:1,minHeight:0},sortRow:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:6,borderBottomWidth:1,borderBottomColor:w.color.border,backgroundColor:w.color.surface},sortLabel:{color:w.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginRight:2},sortChip:{borderWidth:1,borderColor:w.color.border,borderRadius:4,paddingHorizontal:7,paddingVertical:3},sortChipOn:{borderColor:w.color.accentBorderStrong,backgroundColor:w.color.accentSoft},sortChipText:{color:w.color.textTertiary,fontSize:9,fontWeight:"600",fontVariant:["tabular-nums"]},sortChipTextOn:{color:w.color.accent},body:{flex:1},empty:{color:w.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:24}}),T=D.create({row:{paddingHorizontal:10,paddingVertical:8,borderBottomWidth:D.hairlineWidth,borderBottomColor:w.color.border,gap:5},topLine:{flexDirection:"row",alignItems:"center",gap:6},rank:{width:16,color:w.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:w.color.text,fontSize:13,fontWeight:"500"},freezeBadge:{color:de.semantic.warning,fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},freezeBadgeSevere:{color:de.semantic.error},windowMs:{color:w.color.text,fontSize:13,fontWeight:"700",fontVariant:["tabular-nums"]},unit:{color:w.color.textTertiary,fontSize:10,fontWeight:"400"},pct:{width:38,textAlign:"right",color:w.color.textSecondary,fontSize:12,fontWeight:"600",fontVariant:["tabular-nums"]},pctMuted:{color:w.color.textTertiary},subLine:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:22},barTrack:{width:72,height:4,borderRadius:2,backgroundColor:w.color.fillSecondary,overflow:"hidden"},barFill:{height:4,borderRadius:2,opacity:.85},stats:{flex:1,color:w.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]}});import{memo as _n}from"react";import{macOSColors as he,night as v,useSafeAreaInsets as Qn}from"@buoy-gg/shared-ui/web";import{Fragment as ft,jsx as y,jsxs as B}from"react/jsx-runtime";var mt={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 Gn(e){return mt[e]??mt.other}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}`}function Yn(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`}function H({label:e,value:t,accent:r}){return B(f,{style:m.stat,children:[y(c,{style:m.statLabel,children:e}),y(c,{style:[m.statValue,r?{color:r}:null],children:t})]})}var Zn=_n(function({detail:e}){let t=Be(e.api),r=Qn({minBottom:12}),n=Math.max(1,...e.buckets);return B(Ae,{style:m.root,contentContainerStyle:{paddingBottom:r.bottom},children:[B(f,{style:m.identityRow,children:[y(f,{style:[m.badge,{borderColor:t.color,backgroundColor:`${t.color}1A`}],children:y(c,{style:[m.badgeText,{color:t.color}],children:t.text})}),y(c,{style:m.name,numberOfLines:2,children:ht(e)})]}),y(c,{style:m.explainer,children:Gn(e.api)}),y(c,{style:m.sectionTitle,children:"ACTIVITY \xB7 LAST 5S"}),y(f,{style:m.chartRow,children:e.buckets.map((o,i)=>y(f,{style:m.chartBarSlot,children:y(f,{style:[m.chartBar,{height:Math.max(2,o/n*44),backgroundColor:t.color}]})},`bk${i}`))}),B(f,{style:m.chartLegend,children:[B(c,{style:m.chartLegendText,children:[N(e.windowMs)," ms in window \xB7 ",e.pctOfBusy.toFixed(1),"% of busy time"]}),B(c,{style:m.chartLegendText,children:["peak ",N(n)," ms/250ms"]})]}),y(c,{style:m.sectionTitle,children:"STATS \xB7 SINCE START"}),B(f,{style:m.statGrid,children:[y(H,{label:"RUNS",value:e.calls>0?N(e.calls):"\u2014"}),y(H,{label:"SCHEDULED",value:e.scheduleCount>0?N(e.scheduleCount):"\u2014"}),y(H,{label:"AVG / RUN",value:e.calls>0?`${N(e.avgMs)} ms`:"\u2014"}),y(H,{label:"MAX / RUN",value:e.maxMs>0?`${N(e.maxMs)} ms`:"\u2014",accent:e.maxMs>=50?he.semantic.warning:void 0}),y(H,{label:"TOTAL",value:e.totalMs>0?`${N(e.totalMs)} ms`:"\u2014"}),y(H,{label:"LAST RUN",value:Yn(e.lastSeenAgoMs)}),y(H,{label:"FREEZES \xB7 60S",value:e.freezes>0?`${e.freezes}`:"0",accent:e.freezes>0?he.semantic.error:void 0}),y(H,{label:"WORST FREEZE",value:e.worstFreezeMs>0?`${e.worstFreezeMs} ms`:"\u2014",accent:e.worstFreezeMs>=100?he.semantic.error:e.worstFreezeMs>0?he.semantic.warning:void 0})]}),(e.caller||(e.frames?.length??0)>0)&&B(ft,{children:[y(c,{style:m.sectionTitle,children:"SCHEDULED FROM"}),B(f,{style:m.siteCard,children:[e.caller&&B(c,{style:m.siteCaller,children:[e.caller,"()"]}),e.file&&B(c,{style:m.siteFile,children:[e.file,e.line!=null?`:${e.line}`:""]}),e.frames?.map((o,i)=>B(c,{style:m.siteFrame,numberOfLines:1,children:[o.file,":",o.line,":",o.col]},`fr${i}`)),y(c,{style:m.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"&&B(ft,{children:[y(c,{style:m.sectionTitle,children:"SCHEDULED FROM"}),y(c,{style:m.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."})]})]})}),m=D.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:v.color.text,fontSize:15,fontWeight:"600"},explainer:{color:v.color.textTertiary,fontSize:11,lineHeight:15,marginTop:6,marginBottom:4},sectionTitle:{color:v.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginTop:14,marginBottom:6},chartRow:{flexDirection:"row",alignItems:"flex-end",height:48,gap:2,backgroundColor:v.color.surface,borderRadius:6,borderWidth:1,borderColor:v.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:v.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},statGrid:{flexDirection:"row",flexWrap:"wrap",gap:8},stat:{width:"23%",minWidth:76,flexGrow:1,backgroundColor:v.color.surface,borderWidth:1,borderColor:v.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:6},statLabel:{color:v.color.textTertiary,fontSize:8,fontWeight:"700",letterSpacing:.4,marginBottom:3},statValue:{color:v.color.text,fontSize:13,fontWeight:"600",fontVariant:["tabular-nums"]},siteCard:{backgroundColor:v.color.surface,borderWidth:1,borderColor:v.color.border,borderRadius:6,padding:10,gap:3},siteCaller:{color:v.color.text,fontSize:13,fontWeight:"600"},siteFile:{color:v.color.info,fontSize:11},siteFrame:{color:v.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},siteNote:{color:v.color.textTertiary,fontSize:9,opacity:.8,marginTop:4},sitePending:{color:v.color.textTertiary,fontSize:11}});import{Fragment as Xn,jsx as b,jsxs as W}from"react/jsx-runtime";function pt(e){return e>=80?O.semantic.error:e>=40?O.semantic.warning:O.semantic.success}function Ee(e){return e>=100?O.semantic.error:O.semantic.warning}function eo(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?O.semantic.error:O.semantic.warning,icon:"\u25B2",text:`${t.label} is eating ${Math.round(t.pctOfBusy)}% of thread time \u2014 start there.`}:e.freezeSummary.count>0?{color:Ee(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:O.semantic.warning,icon:"\u25B2",text:"Thread saturated by UI/React work \u2014 open Highlight Updates to find re-renders."}:{color:O.semantic.success,icon:"\u25CF",text:`Thread healthy at ${Math.round(e.busyPct)}% load \u2014 nothing worth chasing.`}}function bt({visible:e,onClose:t,onBack:r,onMinimize:n,initialModalState:o,minimizeTargetPosition:i,remoteSnapshot:a,remoteActions:s,embedded:l=false}){let u=a!==void 0,[M,F]=st(null);Ar(()=>{if(!(u||!e))return d.subscribe(F)},[u,e]);let p=u?a:M,g=Rr(()=>s??{pause:()=>d.pause(),resume:()=>d.resume(),clear:()=>d.clear()},[s]),C=p?.paused??false,fe=(p?.rows.length??0)>0,[me,$e]=st(null),vt=zr(j=>$e(j.key),[]),Le=!u&&me?d.getOriginDetail(me):null,We=me!==null,De=W(oe,{children:[We?b(oe.Navigation,{onBack:()=>$e(null)}):r?b(oe.Navigation,{onBack:r}):null,b(oe.Content,{title:"",noMargin:true,children:W(f,{style:x.titleRow,children:[b(On,{size:14,color:"#34D399"}),b(c,{style:x.title,children:"JS Top"}),p&&b(f,{style:[x.busyPill,{borderColor:pt(p.busyPct)}],children:W(c,{style:[x.busyText,{color:pt(p.busyPct)}],children:[p.busyPct.toFixed(0),"% BUSY"]})}),p&&p.freezeSummary.count>0&&b(f,{style:[x.busyPill,{borderColor:Ee(p.freezeSummary.worstMs)}],children:W(c,{style:[x.busyText,{color:Ee(p.freezeSummary.worstMs)}],children:["\u26A0 ",p.freezeSummary.count," \xB7"," ",p.freezeSummary.worstMs,"ms"]})})]})}),W(oe.Actions,{children:[b(ne,{onPress:C?g.resume:g.pause,style:[x.actionBtn,C&&x.actionBtnActive],accessibilityLabel:C?"Resume sampling":"Pause sampling",children:C?b($n,{size:14,color:z.color.accent}):b(Pn,{size:14,color:z.color.textSecondary})}),b(ne,{onPress:g.clear,disabled:!fe,style:[x.actionBtn,!fe&&x.actionBtnDisabled],accessibilityLabel:"Clear stats",children:b(Ln,{size:14,color:fe?z.color.textTertiary:z.color.textTertiary})})]})]}),He=b(f,{style:x.body,children:We?Le?b(Zn,{detail:Le}):b(c,{style:x.waiting,children:"This origin is no longer tracked (cleared or evicted)."}):p?W(Xn,{children:[(()=>{let j=eo(p);return W(f,{style:[x.diagnosis,{borderLeftColor:j.color}],children:[b(c,{style:[x.diagnosisIcon,{color:j.color}],children:j.icon}),b(c,{style:x.diagnosisText,children:j.text})]})})(),W(f,{style:x.sparklineRow,children:[b(c,{style:x.sparklineCaption,children:"JS THREAD LOAD \xB7 LAST 30s"}),b(Vn,{history:p.busyHistory})]}),!p.tiers.bridge&&b(c,{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."}),b(Un,{rows:p.rows,onSelectRow:u?void 0:vt})]}):b(c,{style:x.waiting,children:u?"Waiting for device\u2026":"Starting engine\u2026"})});return l?W(f,{style:x.embeddedRoot,children:[b(f,{style:x.embeddedHeader,children:De}),He]}):b(In,{visible:e,onClose:t,onMinimize:n,minimizeTargetPosition:i,initialModalState:o,header:{showToggleButton:true,customContent:De},persistenceKey:"buoy-js-top-modal",enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:He})}var x=D.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:O.background.base},embeddedHeader:{borderBottomWidth:1,borderBottomColor:O.border.default}});import{useEffect as gt,useState as yt}from"react";import{macOSColors as Fe,night as Oe}from"@buoy-gg/shared-ui/web";import{jsx as to,jsxs as Mt}from"react/jsx-runtime";function ro(e){return e>=80?Fe.semantic.error:e>=40?Fe.semantic.warning:Fe.semantic.success}function no(){let[e,t]=yt(()=>d.isEnabled()),[r,n]=yt(null);if(gt(()=>d.subscribeEnabled(t),[]),gt(()=>{if(!e){n(null);return}return d.subscribe(n)},[e]),!e||!r)return null;let o=r.rows.find(i=>i.api!=="unattributed");return Mt(f,{style:Ie.pill,pointerEvents:"none",children:[Mt(c,{style:[Ie.busy,{color:ro(r.busyPct)}],children:[r.busyPct.toFixed(0),"%"]}),o&&to(c,{style:Ie.label,numberOfLines:1,children:o.label})]})}var Ie=D.create({pill:{position:"absolute",top:60,left:8,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:Oe.color.buttonSurface,borderWidth:1,borderColor:Oe.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:4,maxWidth:220},busy:{fontSize:11,fontWeight:"700",fontVariant:["tabular-nums"]},label:{color:Oe.color.textSecondary,fontSize:10,flexShrink:1}});import{useEffect as oo,useState as io}from"react";import{Activity as xt}from"@buoy-gg/shared-ui/web";import{jsx as wt}from"react/jsx-runtime";var Pe="#34D399",St="#6B7280";function ao({size:e}){let[t,r]=io(()=>d.isEnabled());return oo(()=>d.subscribeEnabled(r),[]),wt(xt,{size:e,color:t?Pe:St})}function so(){return null}var lo={id:"js-top",name:"JS TOP",description:"Toggle the floating JS-thread busy pill",slot:"row",icon:ao,component:so,props:{},launchMode:"toggle-only",onPress:()=>{d.setEnabled(!d.isEnabled())}},co={id:"js-top-modal",name:"TASKS",description:"Live Task Manager for the JS thread",slot:"both",icon:({size:e})=>wt(xt,{size:e,color:Pe}),component:bt,props:{enableSharedModalDimensions:false}};d.registerTierInstaller(br);d.registerTierInstaller(gr);d.registerTierInstaller(Sr);d.registerLongtaskProvider(vr);d.registerFreezeStatsProvider(kr);d.registerClearHook(Tr);try{typeof window<"u"&&(tt(),rt())}catch{}export{St as JS_TOP_DISABLED_COLOR,Pe as JS_TOP_ENABLED_COLOR,d as JsTopController,no as JsTopHudOverlay,bt as JsTopModal,co as jsTopModalPreset,lo as jsTopPreset,Cr as jsTopSyncAdapter};
|
|
1
|
+
"use client";var Ve=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var zt=Object.prototype.hasOwnProperty;var At=(e,t)=>{for(var r in t)Ve(e,r,{get:t[r],enumerable:true})},je=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ct(t))!zt.call(e,o)&&o!==r&&Ve(e,o,{get:()=>t[o],enumerable:!(n=Tt(t,o))||n.enumerable});return e},Rt=(e,t,r)=>(je(e,t,"default"),r&&je(r,t,"default"));var Y=(()=>{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 ae=typeof globalThis<"u"?globalThis:void 0,Bt=(()=>{if(typeof ae?.nativePerformanceNow=="function"){let e=ae.nativePerformanceNow;return()=>e()}if(typeof ae?.performance?.now=="function"){let e=ae.performance;return()=>e.now()}return()=>Date.now()})(),Et=Bt;function I(){return Et()}var h=typeof globalThis<"u"?globalThis:{},Ne=false;function V(){return Ne}function se(e){Ne=e}var pe=null;function ge(){return pe||(pe={setTimeout:h.setTimeout?.bind(h),setInterval:h.setInterval?.bind(h),clearInterval:h.clearInterval?.bind(h),clearTimeout:h.clearTimeout?.bind(h),setImmediate:h.setImmediate?.bind(h),requestAnimationFrame:h.requestAnimationFrame?.bind(h),queueMicrotask:h.queueMicrotask?.bind(h)}),pe}function le(){return ge()}var v=Symbol.for("buoy.jsTop.patched"),qe=Symbol.for("buoy.jsTop.wrapped");var q=new Float64Array(120),Z=new Float64Array(120),be=new Float64Array(120),U=new Float64Array(120).fill(-1);function P(e){return Math.floor(e/250)}function Ft(e){let t=e%120;return U[t]!==e&&(U[t]=e,q[t]=0,Z[t]=0,be[t]=0),t}function ye(e,t,r){if(!(t>e))return;let n=Math.max(e,t-3e4),o=P(n),i=P(t),a=n;for(;o<=i;){let s=(o+1)*250,l=Math.min(t,s),d=l-a;d>0&&r(Ft(o),d),a=l,o++}}function Ot(e,t){ye(e,t,(r,n)=>{q[r]=Math.min(250,q[r]+n)})}function It(e,t,r){let n=t-e;if(!(n>0)||!(r>0))return;let o=Math.min(1,r/n);ye(e,t,(i,a)=>{Z[i]=Math.min(250,Z[i]+a*o)})}function Pt(e,t){ye(e,t,(r,n)=>{be[r]=Math.min(250,be[r]+n)})}function Ue(e,t,r){let n=P(t),o=0;for(let i=n-r+1;i<=n;i++){let a=i%120;a>=0&&U[a]===i&&(o+=e[a])}return o}function Je(e){return Ue(q,e,20)}function Lt(e){return Ue(Z,e,20)}function $t(e){let t=P(e),r=[];for(let n=t-20+1;n<=t;n++){let o=n%120;o>=0&&U[o]===n?r.push(Math.max(0,Math.round((q[o]-Z[o])*10)/10)):r.push(0)}return r}function Dt(e){let t=P(e),r=[];for(let o=t-120+1;o<=t;o++){let i=o%120;i>=0&&U[i]===o?r.push(Math.round(q[i]/250*100)):r.push(0)}let n=0;for(;n<r.length&&r[n]===0;)n++;return r.slice(Math.max(0,Math.min(n,r.length-1)))}function Wt(){U.fill(-1)}var Me=0;function Ht(){return typeof Y<"u"&&Y}var Vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",jt=new Map([...Vt].map((e,t)=>[e,t]));function Nt(e){let t=[],r=0,n=0,o=0,i=0;for(let a of e.split(";")){let s=[],l=0;for(let d of a.split(",")){if(!d)continue;let f=[],F=0,m=0;for(let b of d){let x=jt.get(b);if(x===void 0)break;F+=(x&31)<<m,x&32?m+=5:(f.push(F&1?-(F>>1):F>>1),F=0,m=0)}f.length&&(l+=f[0],f.length===1?s.push([l]):f.length>=4&&(r+=f[1],n+=f[2],o+=f[3],f.length>=5?(i+=f[4],s.push([l,r,n,o,i])):s.push([l,r,n,o])))}t.push(s)}return t}function qt(e,t,r){let n=e.lines[t-1];if(!n?.length)return null;let o;for(let a of n)if(a[0]<=r-1)o=a;else break;if(!o||o.length<4)return null;let i=e.sources[o[1]];return i?{file:i,line:o[2]+1,name:o.length>=5?e.names[o[4]]:void 0}:null}var Ke=new Map;function Ut(e){let t=Ke.get(e);return t||(t=(async()=>{let r=await(await fetch(e)).text(),n=Math.max(r.lastIndexOf("//# sourceMappingURL="),r.lastIndexOf("//@ sourceMappingURL="));if(n<0)return null;let o=/^\/\/[#@]\s*sourceMappingURL=(\S+)/.exec(r.slice(n));if(!o)return null;let i=new URL(o[1],e).href,a=await(await fetch(i)).json();return!a.mappings||!a.sources?null:{sources:a.sources,names:a.names??[],lines:Nt(a.mappings)}})().catch(()=>null),Ke.set(e,t)),t}function Jt(e){return(e.split("?")[0]??e).split("/").filter(Boolean).slice(-2).join("/")}function Kt(e){return/^[A-Z][A-Za-z0-9]*$/.test(e)}function _t(e,t){if(!Ht()||e.symbolicated||!e.frames||e.frames.length===0||Me>=3)return;e.symbolicated=true;let r=e.frames.filter(n=>/^(https?|capacitor|file):\/\//.test(n.file));r.length&&(Me++,(async()=>{for(let n of r){let o=await Ut(n.file.split("?")[0]??n.file);if(!o)continue;let i=qt(o,n.line,n.col);if(!i||i.file.includes("node_modules"))continue;let a=Jt(i.file);e.file=a,e.line=i.line;let s=`${a.split("/").pop()}:${i.line}`;i.name&&Kt(i.name)&&!e.caller?(e.caller=i.name,e.label=`${e.label} \u2190 <${i.name}> \xB7 ${s}`):e.label=`${e.label} \xB7 ${s}`;return}})().catch(()=>{}).finally(()=>{Me--}))}var Qt=500,Gt=20,T=new Map,_e="other",Qe=0,we=0;function xe(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)}}function Ge(e,t){let r=P(t),n=0;for(let o=r-20+1;o<=r;o++){let i=o%20;i>=0&&e.ringStamps[i]===o&&(n+=e.ring[i])}return n}function Ye(e){let t=null,r=1/0;for(let o of T.values()){if(o.key===_e)continue;let i=Ge(o,e)*1e6+o.lastSeenAt;i<r&&(r=i,t=o)}if(!t)return;let n=Yt(_e,"other","other (evicted origins)");n.calls+=t.calls,n.totalMs+=t.totalMs,n.maxMs=Math.max(n.maxMs,t.maxMs),n.lastSeenAt=Math.max(n.lastSeenAt,t.lastSeenAt),T.delete(t.key)}function Yt(e,t,r){let n=T.get(e);return n||(n=xe(e,t,r),T.set(e,n)),n}function Zt(e){let t=[],r,n=e.split(`
|
|
2
|
+
`);for(let o of n){let i=/at\s+(.*?)\s+\((?:address at\s+)?(.*?):(\d+):(\d+)\)/.exec(o)??/at\s+()(.*?):(\d+):(\d+)$/.exec(o.trim())??/^([^@\s]*)@(.+?):(\d+):(\d+)$/.exec(o.trim());if(!i)continue;let a=i[1]??"";if(a.includes("buoyJsTop")||a==="Error"||i[2]?.includes("/js-top/"))continue;t.push({file:i[2]??"",line:Number(i[3]),col:Number(i[4])});let s=/^(react_stack_bottom_frame|runWithFiberInDEV|commitHookEffectList|flushPassive|performWork|renderWithHooks|safelyCall)/.test(a)||/^(then|catch|finally|resolve|reject|fulfilled|rejected|step|tryCallOne|tryCallTwo|tryCatch|invokeCallback|notify)$/.test(a);if(!r&&a&&a!=="anonymous"&&!s&&(r=a),t.length>=3)break}return{caller:r,frames:t}}function Xt(e,t){return t-e.lastCaptureAt<Qt||(t-Qe>1e3&&(Qe=t,we=0),we>=Gt)?false:(we++,e.lastCaptureAt=t,true)}function Se(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("/")}function er(e){return T.has(e)}function ve(e,t,r,n=true){let o=t,i=typeof o.displayName=="string"&&o.displayName||typeof o.name=="string"&&o.name||"anonymous",a=`${e}|${i}`,s=T.get(a);if(s||(T.size>=500&&Ye(r),s=xe(a,e,i==="anonymous"?X(e):`${X(e)} ${i}`),T.set(a,s)),s.scheduleCount++,!s.promoted&&(s.scheduleCount>=25||s.totalMs>=50)&&(s.promoted=true),(s.promoted||e==="interval")&&n&&Xt(s,r)){let{caller:l,frames:d}=Zt(new Error().stack??""),f=d[0];if(f||l){let F=f?`${Se(f.file)??"?"}:${f.line}`:"?",m=`${a}@${l??"?"}:${F}`,b=T.get(m);if(!b){T.size>=500&&Ye(r);let x=i==="anonymous"?X(e):`${X(e)} ${i}`;b=xe(m,e,l?`${x} \u2190 ${l}`:i==="anonymous"?`${x} @ ${Se(f?.file??"")??"?"}`:x),b.caller=l,b.file=f?Se(f.file):void 0,b.line=f?.line,b.frames=d,b.promoted=true,b.calls=s.calls,b.totalMs=s.totalMs,b.maxMs=s.maxMs,b.scheduleCount=s.scheduleCount,b.lastSeenAt=s.lastSeenAt,b.ring.set(s.ring),b.ringStamps.set(s.ringStamps),s.calls=0,s.totalMs=0,s.maxMs=0,s.ring.fill(0),s.ringStamps.fill(-1),T.set(m,b),_t(b,X(e))}s.activeRefinedKey=m}}return s.activeRefinedKey??a}function X(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}}function tr(e,t,r,n){let o=T.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 i=n-r,a=i>0?Math.min(1,t/i):1,s=Math.max(r,n-5e3),l=P(s),d=P(n),f=s;for(;l<=d;){let F=(l+1)*250,m=Math.min(n,F),b=m-f;if(b>0){let x=l%20;x>=0&&(o.ringStamps[x]!==l&&(o.ringStamps[x]=l,o.ring[x]=0),o.ring[x]+=i>0?b*a:t)}f=m,l++}It(r,n,t)}function rr(e){return T.get(e)?.label??null}function nr(e,t,r){let n=[];for(let a of T.values()){let s=Ge(a,e);s<=0&&a.totalMs<1||n.push({key:a.key,label:a.label,api:a.api,file:a.file,line:a.line,windowMs:Math.round(s*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(s/t*1e3)/10):0,totalMs:Math.round(a.totalMs*10)/10,calls:a.calls,avgMs:a.calls>0?Math.round(a.totalMs/a.calls*100)/100:0,maxMs:Math.round(a.maxMs*100)/100,lastSeenAgoMs:a.lastSeenAt>0?Math.max(0,e-a.lastSeenAt):0,freezes:0,worstFreezeMs:0})}n.sort((a,s)=>s.windowMs-a.windowMs||s.totalMs-a.totalMs);let o=[],i=[];for(let a of n)(a.windowMs>=1||a.pctOfBusy>=.5||a.freezes>0?o:i).push(a);return i.length>=2?(o.push({key:"minor",label:`${i.length} minor origins (\u22641ms each)`,api:"other",windowMs:Math.round(i.reduce((a,s)=>a+s.windowMs,0)*10)/10,pctOfBusy:Math.round(i.reduce((a,s)=>a+s.pctOfBusy,0)*10)/10,totalMs:Math.round(i.reduce((a,s)=>a+s.totalMs,0)*10)/10,calls:i.reduce((a,s)=>a+s.calls,0),avgMs:0,maxMs:Math.max(0,...i.map(a=>a.maxMs)),lastSeenAgoMs:Math.min(...i.map(a=>a.lastSeenAgoMs)),freezes:0,worstFreezeMs:0}),o.slice(0,r)):n.slice(0,r)}function or(e,t,r){let n=T.get(e);if(!n)return null;let o=P(t),i=[],a=0;for(let s=o-20+1;s<=o;s++){let l=s%20,d=l>=0&&n.ringStamps[l]===s?Math.round(n.ring[l]*10)/10:0;i.push(d),a+=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(a*10)/10,pctOfBusy:r>0?Math.min(100,Math.round(a/r*1e3)/10):0,lastSeenAgoMs:n.lastSeenAt>0?Math.max(0,t-n.lastSeenAt):0,buckets:i}}function ir(){T.clear()}var ar=32,J=[],sr=20,Ze=64,Xe=new Array(Ze).fill(null),ke=0;function lr(){return Xe}function et(e,t){let r=I(),n=J.length>0?J[J.length-1]:null,o=null;J.length<ar&&(o={originKey:e,start:r,childrenMs:0},J.push(o));try{return t()}finally{try{if(o){J.pop();let i=I(),a=i-r,s=Math.max(0,a-o.childrenMs);n&&(n.childrenMs+=a),tr(e,s,r,i),!n&&a>=sr&&(Xe[ke]={originKey:e,start:r,end:i},ke=(ke+1)%Ze)}}catch{}}}function K(e,t){if(typeof e!="function"||e[qe])return e;let r=V()?ve(t,e,I()):null,n=function(...o){return V()?((r===null||!er(r))&&(r=ve(t,e,I(),false)),et(r,()=>e.apply(this,o))):e.apply(this,o)};return n[qe]=true,n}function tt(e,t,r){if(!V())return r();let n=ve(e,{name:t},I());return et(n,r)}function rt(){let e=ge();if(typeof h.setTimeout=="function"&&!h.setTimeout[v]){let t=function(r,n,...o){let i=K(r,"timeout");return e.setTimeout(i,n,...o)};t[v]=true,h.setTimeout=t}if(typeof h.setInterval=="function"&&!h.setInterval[v]){let t=function(r,n,...o){let i=K(r,"interval");return e.setInterval(i,n,...o)};t[v]=true,h.setInterval=t}if(typeof h.setImmediate=="function"&&!h.setImmediate[v]&&e.setImmediate){let t=function(r,...n){let o=K(r,"immediate");return e.setImmediate(o,...n)};t[v]=true,h.setImmediate=t}if(typeof h.requestAnimationFrame=="function"&&!h.requestAnimationFrame[v]&&e.requestAnimationFrame){let t=function(r){let n=K(r,"raf");return e.requestAnimationFrame(n)};t[v]=true,h.requestAnimationFrame=t}}function nt(){let e=ge();if(typeof h.queueMicrotask=="function"&&!h.queueMicrotask[v]&&e.queueMicrotask){let t=function(r){let n=K(r,"microtask");return e.queueMicrotask(n)};t[v]=true,h.queueMicrotask=t}}var Te=16,cr=100,ur=3,dr=8,ee=null,te=0,ce=false,re=[],_=1/0,Q=0,Ce=Te;function hr(){let e=I(),t=te>0?e-te:0;if(te=e,ce){ce=false,_=1/0,Q=e;return}if(t<=0)return;t<cr&&(t<_&&(_=t),Q===0&&(Q=e),e-Q>=1e3&&(re.push(_),re.length>ur&&re.shift(),Ce=Math.max(dr,Math.min(...re)),_=1/0,Q=e));let r=t-Ce;r>1&&Ot(e-r,e)}function ot(){if(ee!=null)return;let e=le();te=I(),ce=false,re=[],_=1/0,Q=0,Ce=Te,ee=e.setInterval(hr,Te)}function it(){ee!=null&&(le().clearInterval(ee),ee=null),te=0}function fr(){ce=true}import{definePersistedSetting as mr}from"@buoy-gg/shared-ui/web";var pr="@react_buoy/js-top/prefs",gr={enabled:false},at=mr(pr,gr,{sanitize:e=>({enabled:e.enabled===true})});async function br(){return at.load()}async function yr(e){await at.save(e)}import{subscribeRealAppState as Mr}from"@buoy-gg/shared-ui/web";var wr=250,xr=class{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=[];br().then(e=>{this.enabledLoaded=true,e.enabled&&!this.enabled&&this.setEnabled(true)})}subscribe(e){return this.subscribers.add(e),this.syncEngineState(),e(this.snapshot),()=>{this.subscribers.delete(e),this.syncEngineState()}}subscribeEnabled(e){return this.enabledSubscribers.add(e),e(this.enabled),()=>{this.enabledSubscribers.delete(e)}}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.enabledLoaded&&yr({enabled:e}),this.enabledSubscribers.forEach(t=>{try{t(e)}catch(r){Y&&console.error("[js-top] enabled subscriber threw",r)}}),this.syncEngineState())}isEnabled(){return this.enabled}setRemoteSampling(e){this.remoteSampling!==e&&(this.remoteSampling=e,this.syncEngineState())}isRemoteSampling(){return this.remoteSampling}getStatus(){return this.engineRunning?this.paused?"paused":"running":"disabled"}pause(){this.paused||(this.paused=true,se(false),it(),this.emitSnapshot())}resume(){this.paused&&(this.paused=false,this.engineRunning&&(se(true),ot()),this.emitSnapshot())}clear(){ir(),Wt();for(let e of this.clearHooks)try{e()}catch{}this.emitSnapshot()}registerClearHook(e){this.clearHooks.push(e)}getSnapshot(){return this.snapshot}getOriginDetail(e){let t=I(),r=Je(t),n=this.freezeStatsProvider?.(Date.now())?.byOrigin[e];if(e==="unattributed"){let i=$t(t),a=Math.round(i.reduce((s,l)=>s+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:a,pctOfBusy:r>0?Math.min(100,Math.round(a/r*1e3)/10):0,lastSeenAgoMs:0,buckets:i,freezes:n?.count??0,worstFreezeMs:Math.round(n?.maxMs??0)}}let o=or(e,t,r);return o?{...o,freezes:n?.count??0,worstFreezeMs:Math.round(n?.maxMs??0)}:null}registerTierInstaller(e){this.tierInstallers.push(e),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(){let e=this.shouldRun();e&&!this.engineRunning?this.startEngine():!e&&this.engineRunning&&this.stopEngine()}runInstaller(e){try{return e()}catch(t){return Y&&console.error("[js-top] tier installer threw",t),{}}}startEngine(){this.engineRunning=true,rt(),nt(),this.tiers={timers:true,promises:false,bridge:false,longtask:false};for(let e of this.tierInstallers)Object.assign(this.tiers,this.runInstaller(e));se(!this.paused),this.paused||ot();try{this.appStateSub=Mr(()=>{fr()})}catch{this.appStateSub=null}this.notifyHandle=le().setInterval(()=>this.emitSnapshot(),wr),this.emitSnapshot()}stopEngine(){if(this.engineRunning=false,se(false),it(),this.notifyHandle!=null&&(le().clearInterval(this.notifyHandle),this.notifyHandle=null),this.appStateSub){try{this.appStateSub.remove()}catch{}this.appStateSub=null}}buildSnapshot(){let e=I(),t=Je(e),r=Lt(e),n=Math.max(0,t-r),o=nr(e,t,30);n>=1&&(o.push({key:"unattributed",label:"unattributed (events / React / native call-ins)",api:"unattributed",windowMs:Math.round(n*10)/10,pctOfBusy:t>0?Math.min(100,Math.round(n/t*1e3)/10):0,totalMs:0,calls:0,avgMs:0,maxMs:0,lastSeenAgoMs:0,freezes:0,worstFreezeMs:0}),o.sort((s,l)=>l.windowMs-s.windowMs||l.totalMs-s.totalMs));let i=this.freezeStatsProvider?.(Date.now())??{count:0,worstMs:0,byOrigin:{}};for(let s of o){let l=i.byOrigin[s.key];l&&(s.freezes=l.count,s.worstFreezeMs=Math.round(l.maxMs))}let a=5e3;return{ts:Date.now(),paused:this.paused,busyPct:Math.min(100,Math.round(t/a*1e3)/10),busyHistory:Dt(e),tiers:{...this.tiers},rows:o,totals:{attributedWindowMs:Math.round(r*10)/10,unattributedWindowMs:Math.round(n*10)/10,windowMs:a},freezeSummary:{count:i.count,worstMs:Math.round(i.worstMs)},longtasks:this.longtaskProvider?this.longtaskProvider():[]}}emitSnapshot(){this.snapshot=this.buildSnapshot(),this.subscribers.forEach(e=>{try{e(this.snapshot)}catch(t){Y&&console.error("[js-top] snapshot subscriber threw",t)}})}isEngineActive(){return V()}},u=new xr;function ze(e,t){let r=e[t];if(typeof r!="function")return false;if(r[v])return true;let n=function(...o){for(let i=0;i<o.length;i++)typeof o[i]=="function"&&(o[i]=K(o[i],"then"));return r.apply(this,o)};return n[v]=true,Object.defineProperty(n,"name",{value:t,configurable:true}),e[t]=n,true}function Sr(){let e=h.Promise?.prototype;if(!e)return{promises:false};let t=ze(e,"then");return ze(e,"catch"),ze(e,"finally"),{promises:t}}function vr(){let e=h.__fbBatchedBridge;if(!e)return{bridge:false};let t=false;if(typeof e.callFunctionReturnFlushedQueue=="function"&&!e.callFunctionReturnFlushedQueue[v]){let n=e.callFunctionReturnFlushedQueue.bind(e),o=function(i,a,s){return V()?tt("bridge",`${i}.${a}`,()=>n(i,a,s)):n(i,a,s)};o[v]=true,e.callFunctionReturnFlushedQueue=o,t=true}if(typeof e.invokeCallbackAndReturnFlushedQueue=="function"&&!e.invokeCallbackAndReturnFlushedQueue[v]){let n=e.invokeCallbackAndReturnFlushedQueue.bind(e),o=function(i,a){return V()?tt("bridge","nativeModuleCallback",()=>n(i,a)):n(i,a)};o[v]=true,e.invokeCallbackAndReturnFlushedQueue=o,t=true}let r=e.callFunctionReturnFlushedQueue?.[v]===true;return{bridge:t||r}}var kr=40,Tr=6e4,Cr="unattributed",st=false,ue=false,G=[];function zr(e,t){let r=e+t,n=null,o=0;for(let i of lr()){if(!i)continue;let a=Math.min(r,i.end)-Math.max(e,i.start);a>o&&(o=a,n=i.originKey)}return n}function Ar(){if(st)return{longtask:ue};st=true;let e=h.PerformanceObserver;if(typeof e!="function")return{longtask:false};try{new e(t=>{if(V())try{for(let r of t.getEntries()){if(r.entryType!=="longtask")continue;let n=r.startTime,o=r.duration;Pt(n,n+o),G.push({start:n,duration:o,at:Date.now(),originKey:zr(n,o)}),G.length>kr&&G.shift()}}catch{}}).observe({entryTypes:["longtask"]}),ue=true}catch{ue=false}return{longtask:ue}}function Rr(){return G.map(e=>({start:e.start,duration:e.duration,at:e.at,originLabel:e.originKey?rr(e.originKey):null}))}function Br(e){let t={},r=0,n=0;for(let o of G){if(o.at>0&&e-o.at>Tr)continue;r++,o.duration>n&&(n=o.duration);let i=o.originKey??Cr,a=t[i];a?(a.count++,o.duration>a.maxMs&&(a.maxMs=o.duration)):t[i]={count:1,maxMs:o.duration}}return{count:r,worstMs:n,byOrigin:t}}function Er(){G.length=0}var Fr={version:1,getSnapshot:()=>({live:u.getSnapshot(),enabled:u.isEnabled()||u.isRemoteSampling()}),subscribe:e=>{let t=u.subscribe(()=>e()),r=u.subscribeEnabled(()=>e());return()=>{t(),r()}},actions:{setEnabled:e=>{let t=e.enabled;u.setRemoteSampling(t)},pause:()=>u.pause(),resume:()=>u.resume(),clear:()=>u.clear(),getOriginDetail:e=>u.getOriginDetail(e.key),sample:async e=>{let t=e,r=Math.min(Math.max(t?.durationMs??3e3,250),3e4),n=u.isRemoteSampling()||u.isEnabled();n||u.setRemoteSampling(true),t?.clearFirst&&u.clear();try{return await new Promise(o=>setTimeout(o,r)),u.getSnapshot()}finally{n||u.setRemoteSampling(false)}}}};import{useCallback as Or,useEffect as Ir,useMemo as Pr,useState as lt}from"react";var ct={};At(ct,{AccessibilityInfo:()=>Wr,ActivityIndicator:()=>Pn,Alert:()=>Dn,Animated:()=>Hr,AppRegistry:()=>jr,AppState:()=>Nr,Appearance:()=>Vr,BackHandler:()=>qr,Button:()=>Ln,CheckBox:()=>sn,Clipboard:()=>Ur,DeviceEventEmitter:()=>vn,Dimensions:()=>Jr,Easing:()=>Kr,FlatList:()=>ln,I18nManager:()=>_r,Image:()=>cn,ImageBackground:()=>un,InteractionManager:()=>Gr,Keyboard:()=>Qr,KeyboardAvoidingView:()=>dn,LayoutAnimation:()=>Yr,Linking:()=>Zr,LogBox:()=>Sn,Modal:()=>On,NativeEventEmitter:()=>Xr,NativeModules:()=>Dr,PanResponder:()=>en,Picker:()=>hn,PixelRatio:()=>tn,Platform:()=>rn,Pressable:()=>Fn,ProgressBar:()=>fn,RefreshControl:()=>mn,SafeAreaView:()=>pn,ScrollView:()=>Ae,SectionList:()=>gn,Share:()=>nn,StatusBar:()=>bn,StyleSheet:()=>W,Switch:()=>In,Text:()=>c,TextInput:()=>Rn,Touchable:()=>yn,TouchableHighlight:()=>Bn,TouchableNativeFeedback:()=>Mn,TouchableOpacity:()=>ne,TouchableWithoutFeedback:()=>En,UIManager:()=>on,Vibration:()=>an,View:()=>p,VirtualizedList:()=>wn,YellowBox:()=>xn,findNodeHandle:()=>$n,unstable_createElement:()=>$r,useColorScheme:()=>kn,useLocaleContext:()=>Tn,useWindowDimensions:()=>Cn});Rt(ct,Lr);import*as Lr from"react-native-web";import{unstable_createElement as $r,NativeModules as Dr,AccessibilityInfo as Wr,Animated as Hr,Appearance as Vr,AppRegistry as jr,AppState as Nr,BackHandler as qr,Clipboard as Ur,Dimensions as Jr,Easing as Kr,I18nManager as _r,Keyboard as Qr,InteractionManager as Gr,LayoutAnimation as Yr,Linking as Zr,NativeEventEmitter as Xr,PanResponder as en,PixelRatio as tn,Platform as rn,Share as nn,StyleSheet as W,UIManager as on,Vibration as an,CheckBox as sn,FlatList as ln,Image as cn,ImageBackground as un,KeyboardAvoidingView as dn,Picker as hn,ProgressBar as fn,RefreshControl as mn,SafeAreaView as pn,SectionList as gn,StatusBar as bn,Touchable as yn,TouchableNativeFeedback as Mn,VirtualizedList as wn,YellowBox as xn,LogBox as Sn,DeviceEventEmitter as vn,useColorScheme as kn,useLocaleContext as Tn,useWindowDimensions as Cn}from"react-native-web";import*as A from"react-native-web";import{createElement as zn,forwardRef as An}from"react";function E(e){let t=An((n,o)=>{let{accessibilityState:i,accessibilityValue:a,...s}=n;for(let l of["busy","checked","disabled","expanded","selected"])i?.[l]!==void 0&&s[`aria-${l}`]===void 0&&(s[`aria-${l}`]=i[l]);for(let[l,d]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[l]!==void 0&&s[`aria-${d}`]===void 0&&(s[`aria-${d}`]=a[l]);return zn(e,{...s,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var p=E(A.View),c=E(A.Text),Rn=E(A.TextInput),ne=E(A.TouchableOpacity),Bn=E(A.TouchableHighlight),En=E(A.TouchableWithoutFeedback),Fn=E(A.Pressable),Ae=E(A.ScrollView),On=E(A.Modal),In=E(A.Switch),Pn=E(A.ActivityIndicator),Ln=E(A.Button),$n=A.findNodeHandle,Dn={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 i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),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 a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let s=r?.length?r:[{text:"OK"}],l=()=>{o.close?.(),o.remove()};for(let d of s){let f=document.createElement("button");f.type="button",f.textContent=d.text??"OK",f.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,f.onclick=()=>{l(),d.onPress?.()},a.appendChild(f)}o.addEventListener("cancel",d=>{d.preventDefault(),n?.cancelable!==false&&(l(),n?.onDismiss?.())}),o.appendChild(a),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{Activity as Wn,JsModal as Hn,macOSColors as O,night as z,ModalHeader as oe,Pause as Vn,Play as jn,Trash2 as Nn}from"@buoy-gg/shared-ui/web";import{memo as qn}from"react";import{macOSColors as Re}from"@buoy-gg/shared-ui/web";import{jsx as ut}from"react/jsx-runtime";var Un=60;function Jn(e){return e>=80?Re.semantic.error:e>=40?Re.semantic.warning:Re.semantic.success}var Kn=qn(function({history:e}){let t=e.slice(-Un);return ut(p,{style:dt.row,pointerEvents:"none",children:t.map((r,n)=>ut(p,{style:[dt.bar,{height:Math.max(2,r/100*28),backgroundColor:Jn(r)}]},`b${n}`))})}),dt=W.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 _n,useState as Qn}from"react";import{macOSColors as de,night as S}from"@buoy-gg/shared-ui/web";import{jsx as R,jsxs as L}from"react/jsx-runtime";var Gn=[{key:"windowMs",title:"RECENT"},{key:"calls",title:"CALLS"},{key:"avgMs",title:"AVG"},{key:"maxMs",title:"MAX"},{key:"totalMs",title:"TOTAL"}],ht={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 Be(e){return ht[e]??ht.other}function ft(e){if(e.api==="unattributed")return"events \xB7 React \xB7 native call-ins";if(e.api==="other")return"evicted cold origins";let t=Be(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"}function ie(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}`}function Yn(e){return e.calls<=0?"measured by probe \xB7 not reachable from JS":`${ie(e.calls)} calls \xB7 avg ${ie(e.avgMs)} \xB7 max ${ie(e.maxMs)} \xB7 total ${ie(e.totalMs)} ms`}var Zn=_n(function({row:e,rank:t,onPress:r}){let n=Be(e.api);return L(r?ne:p,{style:C.row,...r?{onPress:()=>r(e),activeOpacity:.6}:{},children:[L(p,{style:C.topLine,children:[R(c,{style:C.rank,children:t}),R(p,{style:[C.badge,{borderColor:n.color,backgroundColor:`${n.color}1A`}],children:R(c,{style:[C.badgeText,{color:n.color}],children:n.text})}),R(c,{style:C.name,numberOfLines:1,children:ft(e)}),e.freezes>0&&L(c,{style:[C.freezeBadge,e.worstFreezeMs>=100&&C.freezeBadgeSevere],children:["\u26A0 \xD7",e.freezes]}),L(c,{style:[C.windowMs,e.api!=="unattributed"&&e.pctOfBusy>=25&&{color:e.pctOfBusy>=50?de.semantic.error:de.semantic.warning}],children:[ie(e.windowMs),R(c,{style:C.unit,children:" ms"})]}),L(c,{style:[C.pct,e.api==="unattributed"&&C.pctMuted],children:[Math.round(e.pctOfBusy),"%"]})]}),L(p,{style:C.subLine,children:[R(p,{style:C.barTrack,children:R(p,{style:[C.barFill,{width:`${Math.min(100,e.pctOfBusy)}%`,backgroundColor:n.color}]})}),R(c,{style:C.stats,numberOfLines:1,children:Yn(e)})]})]})},(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 Xn({rows:e,onSelectRow:t}){let[r,n]=Qn("windowMs"),o=r==="windowMs"?e:[...e].sort((i,a)=>a[r]-i[r]);return L(p,{style:$.root,children:[L(p,{style:$.sortRow,children:[R(c,{style:$.sortLabel,children:"SORT"}),Gn.map(i=>R(ne,{onPress:()=>n(i.key),style:[$.sortChip,r===i.key&&$.sortChipOn],children:R(c,{style:[$.sortChipText,r===i.key&&$.sortChipTextOn],children:i.title})},i.key))]}),L(Ae,{style:$.body,children:[o.map((i,a)=>R(Zn,{row:i,rank:a+1,onPress:t},i.key)),o.length===0&&R(c,{style:$.empty,children:"No tasks observed yet \u2014 interact with the app."})]})]})}var $=W.create({root:{flex:1,minHeight:0},sortRow:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:6,borderBottomWidth:1,borderBottomColor:S.color.border,backgroundColor:S.color.surface},sortLabel:{color:S.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginRight:2},sortChip:{borderWidth:1,borderColor:S.color.border,borderRadius:4,paddingHorizontal:7,paddingVertical:3},sortChipOn:{borderColor:S.color.accentBorderStrong,backgroundColor:S.color.accentSoft},sortChipText:{color:S.color.textTertiary,fontSize:9,fontWeight:"600",fontVariant:["tabular-nums"]},sortChipTextOn:{color:S.color.accent},body:{flex:1},empty:{color:S.color.textTertiary,fontSize:12,textAlign:"center",paddingVertical:24}}),C=W.create({row:{paddingHorizontal:10,paddingVertical:8,borderBottomWidth:W.hairlineWidth,borderBottomColor:S.color.border,gap:5},topLine:{flexDirection:"row",alignItems:"center",gap:6},rank:{width:16,color:S.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:S.color.text,fontSize:13,fontWeight:"500"},freezeBadge:{color:de.semantic.warning,fontSize:10,fontWeight:"700",fontVariant:["tabular-nums"]},freezeBadgeSevere:{color:de.semantic.error},windowMs:{color:S.color.text,fontSize:13,fontWeight:"700",fontVariant:["tabular-nums"]},unit:{color:S.color.textTertiary,fontSize:10,fontWeight:"400"},pct:{width:38,textAlign:"right",color:S.color.textSecondary,fontSize:12,fontWeight:"600",fontVariant:["tabular-nums"]},pctMuted:{color:S.color.textTertiary},subLine:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:22},barTrack:{width:72,height:4,borderRadius:2,backgroundColor:S.color.fillSecondary,overflow:"hidden"},barFill:{height:4,borderRadius:2,opacity:.85},stats:{flex:1,color:S.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]}});import{memo as eo}from"react";import{macOSColors as he,night as k,useSafeAreaInsets as to}from"@buoy-gg/shared-ui/web";import{Fragment as mt,jsx as M,jsxs as B}from"react/jsx-runtime";var pt={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 ro(e){return pt[e]??pt.other}function j(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}`}function no(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`}function H({label:e,value:t,accent:r}){return B(p,{style:g.stat,children:[M(c,{style:g.statLabel,children:e}),M(c,{style:[g.statValue,r?{color:r}:null],children:t})]})}var oo=eo(function({detail:e}){let t=Be(e.api),r=to({minBottom:12}),n=Math.max(1,...e.buckets);return B(Ae,{style:g.root,contentContainerStyle:{paddingBottom:r.bottom},children:[B(p,{style:g.identityRow,children:[M(p,{style:[g.badge,{borderColor:t.color,backgroundColor:`${t.color}1A`}],children:M(c,{style:[g.badgeText,{color:t.color}],children:t.text})}),M(c,{style:g.name,numberOfLines:2,children:ft(e)})]}),M(c,{style:g.explainer,children:ro(e.api)}),M(c,{style:g.sectionTitle,children:"ACTIVITY \xB7 LAST 5S"}),M(p,{style:g.chartRow,children:e.buckets.map((o,i)=>M(p,{style:g.chartBarSlot,children:M(p,{style:[g.chartBar,{height:Math.max(2,o/n*44),backgroundColor:t.color}]})},`bk${i}`))}),B(p,{style:g.chartLegend,children:[B(c,{style:g.chartLegendText,children:[j(e.windowMs)," ms in window \xB7 ",e.pctOfBusy.toFixed(1),"% of busy time"]}),B(c,{style:g.chartLegendText,children:["peak ",j(n)," ms/250ms"]})]}),M(c,{style:g.sectionTitle,children:"STATS \xB7 SINCE START"}),B(p,{style:g.statGrid,children:[M(H,{label:"RUNS",value:e.calls>0?j(e.calls):"\u2014"}),M(H,{label:"SCHEDULED",value:e.scheduleCount>0?j(e.scheduleCount):"\u2014"}),M(H,{label:"AVG / RUN",value:e.calls>0?`${j(e.avgMs)} ms`:"\u2014"}),M(H,{label:"MAX / RUN",value:e.maxMs>0?`${j(e.maxMs)} ms`:"\u2014",accent:e.maxMs>=50?he.semantic.warning:void 0}),M(H,{label:"TOTAL",value:e.totalMs>0?`${j(e.totalMs)} ms`:"\u2014"}),M(H,{label:"LAST RUN",value:no(e.lastSeenAgoMs)}),M(H,{label:"FREEZES \xB7 60S",value:e.freezes>0?`${e.freezes}`:"0",accent:e.freezes>0?he.semantic.error:void 0}),M(H,{label:"WORST FREEZE",value:e.worstFreezeMs>0?`${e.worstFreezeMs} ms`:"\u2014",accent:e.worstFreezeMs>=100?he.semantic.error:e.worstFreezeMs>0?he.semantic.warning:void 0})]}),(e.caller||(e.frames?.length??0)>0)&&B(mt,{children:[M(c,{style:g.sectionTitle,children:"SCHEDULED FROM"}),B(p,{style:g.siteCard,children:[e.caller&&B(c,{style:g.siteCaller,children:[e.caller,"()"]}),e.file&&B(c,{style:g.siteFile,children:[e.file,e.line!=null?`:${e.line}`:""]}),e.frames?.map((o,i)=>B(c,{style:g.siteFrame,numberOfLines:1,children:[o.file,":",o.line,":",o.col]},`fr${i}`)),M(c,{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"&&B(mt,{children:[M(c,{style:g.sectionTitle,children:"SCHEDULED FROM"}),M(c,{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."})]})]})}),g=W.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:k.color.text,fontSize:15,fontWeight:"600"},explainer:{color:k.color.textTertiary,fontSize:11,lineHeight:15,marginTop:6,marginBottom:4},sectionTitle:{color:k.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,marginTop:14,marginBottom:6},chartRow:{flexDirection:"row",alignItems:"flex-end",height:48,gap:2,backgroundColor:k.color.surface,borderRadius:6,borderWidth:1,borderColor:k.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:k.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},statGrid:{flexDirection:"row",flexWrap:"wrap",gap:8},stat:{width:"23%",minWidth:76,flexGrow:1,backgroundColor:k.color.surface,borderWidth:1,borderColor:k.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:6},statLabel:{color:k.color.textTertiary,fontSize:8,fontWeight:"700",letterSpacing:.4,marginBottom:3},statValue:{color:k.color.text,fontSize:13,fontWeight:"600",fontVariant:["tabular-nums"]},siteCard:{backgroundColor:k.color.surface,borderWidth:1,borderColor:k.color.border,borderRadius:6,padding:10,gap:3},siteCaller:{color:k.color.text,fontSize:13,fontWeight:"600"},siteFile:{color:k.color.info,fontSize:11},siteFrame:{color:k.color.textTertiary,fontSize:10,fontVariant:["tabular-nums"]},siteNote:{color:k.color.textTertiary,fontSize:9,opacity:.8,marginTop:4},sitePending:{color:k.color.textTertiary,fontSize:11}});import{Fragment as io,jsx as y,jsxs as D}from"react/jsx-runtime";function gt(e){return e>=80?O.semantic.error:e>=40?O.semantic.warning:O.semantic.success}function Ee(e){return e>=100?O.semantic.error:O.semantic.warning}function ao(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?O.semantic.error:O.semantic.warning,icon:"\u25B2",text:`${t.label} is eating ${Math.round(t.pctOfBusy)}% of thread time \u2014 start there.`}:e.freezeSummary.count>0?{color:Ee(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:O.semantic.warning,icon:"\u25B2",text:"Thread saturated by UI/React work \u2014 open Highlight Updates to find re-renders."}:{color:O.semantic.success,icon:"\u25CF",text:`Thread healthy at ${Math.round(e.busyPct)}% load \u2014 nothing worth chasing.`}}function bt({visible:e,onClose:t,onBack:r,onMinimize:n,initialModalState:o,minimizeTargetPosition:i,remoteSnapshot:a,remoteActions:s,embedded:l=false}){let d=a!==void 0,[f,F]=lt(null);Ir(()=>{if(!(d||!e))return u.subscribe(F)},[d,e]);let m=d?a:f,b=Pr(()=>s??{pause:()=>u.pause(),resume:()=>u.resume(),clear:()=>u.clear()},[s]),x=m?.paused??false,fe=(m?.rows.length??0)>0,[me,Le]=lt(null),kt=Or(N=>Le(N.key),[]),$e=!d&&me?u.getOriginDetail(me):null,De=me!==null,We=D(oe,{children:[De?y(oe.Navigation,{onBack:()=>Le(null)}):r?y(oe.Navigation,{onBack:r}):null,y(oe.Content,{title:"",noMargin:true,children:D(p,{style:w.titleRow,children:[y(Wn,{size:14,color:"#34D399"}),y(c,{style:w.title,children:"JS Top"}),m&&y(p,{style:[w.busyPill,{borderColor:gt(m.busyPct)}],children:D(c,{style:[w.busyText,{color:gt(m.busyPct)}],children:[m.busyPct.toFixed(0),"% BUSY"]})}),m&&m.freezeSummary.count>0&&y(p,{style:[w.busyPill,{borderColor:Ee(m.freezeSummary.worstMs)}],children:D(c,{style:[w.busyText,{color:Ee(m.freezeSummary.worstMs)}],children:["\u26A0 ",m.freezeSummary.count," \xB7"," ",m.freezeSummary.worstMs,"ms"]})})]})}),D(oe.Actions,{children:[y(ne,{onPress:x?b.resume:b.pause,style:[w.actionBtn,x&&w.actionBtnActive],accessibilityLabel:x?"Resume sampling":"Pause sampling",children:x?y(jn,{size:14,color:z.color.accent}):y(Vn,{size:14,color:z.color.textSecondary})}),y(ne,{onPress:b.clear,disabled:!fe,style:[w.actionBtn,!fe&&w.actionBtnDisabled],accessibilityLabel:"Clear stats",children:y(Nn,{size:14,color:fe?z.color.textTertiary:z.color.textTertiary})})]})]}),He=y(p,{style:w.body,children:De?$e?y(oo,{detail:$e}):y(c,{style:w.waiting,children:"This origin is no longer tracked (cleared or evicted)."}):m?D(io,{children:[(()=>{let N=ao(m);return D(p,{style:[w.diagnosis,{borderLeftColor:N.color}],children:[y(c,{style:[w.diagnosisIcon,{color:N.color}],children:N.icon}),y(c,{style:w.diagnosisText,children:N.text})]})})(),D(p,{style:w.sparklineRow,children:[y(c,{style:w.sparklineCaption,children:"JS THREAD LOAD \xB7 LAST 30s"}),y(Kn,{history:m.busyHistory})]}),!m.tiers.bridge&&y(c,{style:w.tierBanner,children:"\u201CSystem\u201D rows are UI/React/native work pure JS can\u2019t name \u2014 timers, rAF and Promise chains are fully attributed."}),y(Xn,{rows:m.rows,onSelectRow:d?void 0:kt})]}):y(c,{style:w.waiting,children:d?"Waiting for device\u2026":"Starting engine\u2026"})});return l?D(p,{style:w.embeddedRoot,children:[y(p,{style:w.embeddedHeader,children:We}),He]}):y(Hn,{visible:e,onClose:t,onMinimize:n,minimizeTargetPosition:i,initialModalState:o,header:{showToggleButton:true,customContent:We},persistenceKey:"buoy-js-top-modal",enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:He})}var w=W.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:O.background.base},embeddedHeader:{borderBottomWidth:1,borderBottomColor:O.border.default}});import{useEffect as yt,useState as Mt}from"react";import{macOSColors as Fe,night as Oe}from"@buoy-gg/shared-ui/web";import{jsx as so,jsxs as wt}from"react/jsx-runtime";function lo(e){return e>=80?Fe.semantic.error:e>=40?Fe.semantic.warning:Fe.semantic.success}function co(){let[e,t]=Mt(()=>u.isEnabled()),[r,n]=Mt(null);if(yt(()=>u.subscribeEnabled(t),[]),yt(()=>{if(!e){n(null);return}return u.subscribe(n)},[e]),!e||!r)return null;let o=r.rows.find(i=>i.api!=="unattributed");return wt(p,{style:Ie.pill,pointerEvents:"none",children:[wt(c,{style:[Ie.busy,{color:lo(r.busyPct)}],children:[r.busyPct.toFixed(0),"%"]}),o&&so(c,{style:Ie.label,numberOfLines:1,children:o.label})]})}var Ie=W.create({pill:{position:"absolute",top:60,left:8,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:Oe.color.buttonSurface,borderWidth:1,borderColor:Oe.color.border,borderRadius:6,paddingHorizontal:8,paddingVertical:4,maxWidth:220},busy:{fontSize:11,fontWeight:"700",fontVariant:["tabular-nums"]},label:{color:Oe.color.textSecondary,fontSize:10,flexShrink:1}});import{useEffect as uo,useState as ho}from"react";import{Activity as xt}from"@buoy-gg/shared-ui/web";import{jsx as St}from"react/jsx-runtime";var Pe="#34D399",vt="#6B7280";function fo({size:e}){let[t,r]=ho(()=>u.isEnabled());return uo(()=>u.subscribeEnabled(r),[]),St(xt,{size:e,color:t?Pe:vt})}function mo(){return null}var po={id:"js-top",name:"JS TOP",description:"Toggle the floating JS-thread busy pill",slot:"row",icon:fo,component:mo,props:{},launchMode:"toggle-only",onPress:()=>{u.setEnabled(!u.isEnabled())}},go={id:"js-top-modal",name:"TASKS",description:"Live Task Manager for the JS thread",slot:"both",icon:({size:e})=>St(xt,{size:e,color:Pe}),component:bt,props:{enableSharedModalDimensions:false}};u.registerTierInstaller(Sr);u.registerTierInstaller(vr);u.registerTierInstaller(Ar);u.registerLongtaskProvider(Rr);u.registerFreezeStatsProvider(Br);u.registerClearHook(Er);try{typeof window<"u"&&(rt(),nt())}catch{}export{vt as JS_TOP_DISABLED_COLOR,Pe as JS_TOP_ENABLED_COLOR,u as JsTopController,co as JsTopHudOverlay,bt as JsTopModal,go as jsTopModalPreset,po as jsTopPreset,Fr 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.57",
|
|
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.57"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "*"
|