UNPKG

@react-native/debugger-frontend

Version:
2 lines (1 loc) • 19.8 kB
import*as e from"../../../core/platform/platform.js";import*as t from"../../../core/common/common.js";import*as n from"../types/types.js";let r=null;class i{#e=[];#t=[];static activate(e){r=e}static createAndActivate(e){const t=new i(e);return i.activate(t),t}static getActiveManager(){if(!r)throw new Error("Attempted to get a SyntheticEventsManager without initializing");return r}static reset(){r=null}static registerSyntheticEvent(e){try{return i.getActiveManager().registerSyntheticEvent(e)}catch{return e}}constructor(e){this.#t=e}registerSyntheticEvent(e){const t=this.#t.indexOf(e.rawSourceEvent);if(t<0)throw new Error("Attempted to register a synthetic event paired to an unknown raw event.");const n=e;return this.#e[t]=n,n}syntheticEventForRawEventIndex(e){const t=this.#e.at(e);if(!t)throw new Error(`Attempted to get a synthetic event from an unknown raw event index: ${e}`);return t}getSyntheticTraces(){return this.#e}getRawTraceEvents(){return this.#t}}var a=Object.freeze({__proto__:null,SyntheticEventsManager:i});const o=e=>n.Timing.Micro(1e3*e),s=e=>n.Timing.Milli(1e3*e),c=e=>n.Timing.Milli(e/1e3);function l(e){return{startTime:e.ts,endTime:e.ts+(e.dur??0),duration:e.dur||0}}function u(e,t){const n=e.ts;return n<=t.max&&t.min<=n+(e.dur??0)}var d=Object.freeze({__proto__:null,boundsIncludeTimeRange:function(e){const{min:t,max:n}=e.bounds,{min:r,max:i}=e.timeRange;return t<=i&&n>=r},eventIsInBounds:u,eventTimingsMicroSeconds:l,eventTimingsMilliSeconds:function(e){return{startTime:e.ts/1e3,endTime:(e.ts+(e.dur??0))/1e3,duration:(e.dur||0)/1e3}},expandWindowByPercentOrToOneMillisecond:function(e,t,r){let i=e.min-e.range*(r/100)/2,a=e.max+e.range*(r/100)/2;if(a-i<1e3){const t=(e.min+e.max)/2;i=t-500,a=t+500}return i=Math.max(i,t.min),a=Math.min(a,t.max),{min:n.Timing.Micro(i),max:n.Timing.Micro(a),range:n.Timing.Micro(a-i)}},microToMilli:c,microToSeconds:e=>n.Timing.Seconds(e/1e3/1e3),milliToMicro:o,secondsToMicro:e=>o(s(e)),secondsToMilli:s,timeStampForEventAdjustedByClosestNavigation:function(e,t,r,i){let a=e.ts-t.min;if(e.args?.data?.navigationId){const t=r.get(e.args.data.navigationId);t&&(a=e.ts-t.ts)}else if(e.args?.data?.frame){const t=g(e,e.args.data.frame,i);t&&(a=e.ts-t.ts)}return n.Timing.Micro(a)},timestampIsInBounds:function(e,t){return t>=e.min&&t<=e.max},traceWindowFromEvent:function(e){return{min:e.ts,max:n.Timing.Micro(e.ts+(e.dur??0)),range:e.dur??n.Timing.Micro(0)}},traceWindowFromMicroSeconds:function(e,t){return{min:e,max:t,range:n.Timing.Micro(t-e)}},traceWindowFromMilliSeconds:function(e,t){return{min:o(e),max:o(t),range:n.Timing.Micro(o(t)-o(e))}},traceWindowMicroSecondsToMilliSeconds:function(e){return{min:c(e.min),max:c(e.max),range:c(e.range)}},traceWindowMilliSeconds:function(e){return{min:c(e.min),max:c(e.max),range:c(e.range)}},windowFitsInsideBounds:function(e){return e.window.min>=e.bounds.min&&e.window.max<=e.bounds.max},windowsEqual:function(e,t){return e.min===t.min&&e.max===t.max}});function m(e){if(e.args?.data?.stackTrace)return e.args.data.stackTrace;if(e.args?.stackTrace)return e.args.stackTrace;if(n.Events.isUpdateLayoutTree(e))return e.args.beginData?.stackTrace||null;if(n.Events.isLayout(e))return e.args.beginData.stackTrace??null;if(n.Events.isFunctionCall(e)){const t=e.args.data;if(!t)return null;const{columnNumber:n,lineNumber:r,url:i,scriptId:a,functionName:o}=t;return void 0===r||void 0===o||void 0===n||void 0===a||void 0===i?null:[{columnNumber:n,lineNumber:r,url:i,scriptId:a,functionName:o}]}if(n.Events.isProfileCall(e)){const t=e.callFrame;if(!t)return null;const{columnNumber:n,lineNumber:r,url:i,scriptId:a,functionName:o}=t;return void 0===r||void 0===o||void 0===n||void 0===a||void 0===i?null:[{columnNumber:n,lineNumber:r,url:i,scriptId:a,functionName:o}]}return null}function h(e,t){const r=e.ts,i=t.ts;if(r<i)return-1;if(r>i)return 1;const a=r+(e.dur??0),o=i+(t.dur??0);return a>o?-1:a<o?1:n.Events.isProfileCall(e)&&!n.Events.isProfileCall(t)?-1:n.Events.isProfileCall(t)&&!n.Events.isProfileCall(e)?1:0}function f(e){e.sort(h)}function p(e,t){const n=[];let r=0,i=0;for(;r<e.length&&i<t.length;){const a=e[r],o=t[i],s=h(a,o);s<=0&&(n.push(a),r++),1===s&&(n.push(o),i++)}for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function g(t,n,r){const i=r.get(n);if(!i||""===n)return null;const a=e.ArrayUtilities.nearestIndexFromEnd(i,(e=>e.ts<=t.ts));return null===a?null:i[a]}function v(e){return e.id??e.id2?.global??e.id2?.local}function S(e,t,r,i,a,o){return{cat:"",name:"ProfileCall",nodeId:e.id,args:{},ph:"X",pid:a,tid:o,ts:i,dur:n.Timing.Micro(0),callFrame:e.callFrame,sampleIndex:r,profileId:t}}function T(t){const n=new Map;for(const r of t){const t=k(r);if(void 0===t)continue;const i=e.MapUtilities.getWithDefault(n,t,(()=>({begin:null,end:null,instant:[]}))),a="b"===r.ph,o="e"===r.ph,s="n"===r.ph;a?i.begin=r:o?i.end=r:s&&(i.instant||(i.instant=[]),i.instant.push(r))}return n}function k(e){const t=v(e);return t&&`${e.cat}:${t}:${e.name}`}function E(e,t){const r=[];for(const[a,o]of e.entries()){const s=o.begin,c=o.end,l=o.instant;if(!s||!c&&!l)continue;const u={beginEvent:s,endEvent:c,instantEvents:l};function d(e){const t=!!e.instantEvents&&e.instantEvents.some((e=>a===k(e))),n=!!e.endEvent&&a===k(e.endEvent);return Boolean(a)&&(t||n)}if(!d(u))continue;const m=c||s,h=i.registerSyntheticEvent({rawSourceEvent:u.beginEvent,cat:m.cat,ph:m.ph,pid:m.pid,tid:m.tid,id:a,name:s.name,dur:n.Timing.Micro(m.ts-s.ts),ts:s.ts,args:{data:u}});h.dur<0||(t?.(h),r.push(h))}return r.sort(((e,t)=>e.ts-t.ts))}function y(e){const t={...e};return t.lineNumber=e.lineNumber&&e.lineNumber-1,t.columnNumber=e.columnNumber&&e.columnNumber-1,t}function b(e){return"JSRoot"===e.name&&"toplevel"===e.cat||e.cat.includes("disabled-by-default-devtools.timeline")&&"RunTask"===e.name}function I(t,n){let r=e.ArrayUtilities.upperBound(t,n,((e,t)=>e-t.ts))-1;for(;r>0&&!b(t[r]);)r--;return Math.max(r,0)}const M=new Map;function C(e){if(!e.args)return null;if("beginData"in e.args){return e.args.beginData.sampleTraceId??null}return e.args?.sampleTraceId??e.args?.data?.sampleTraceId??null}const w=new Set(["AbortPostTaskCallback","Animation","AsyncTask","v8.deserializeOnBackground","BeginFrame","BeginMainThreadFrame","v8.produceModuleCache","v8.produceCache","CancelAnimationFrame","CancelIdleCallback","v8.compile","V8.CompileCode","V8.CompileModule","Commit","CompositeLayers","ComputeIntersections","ConsoleTime","TimeStamp","CppGC.IncrementalSweep","DoDecrypt","DoDecryptReply","DoDigest","DoDigestReply","DoEncrypt","DoEncryptReply","DoSign","DoSignReply","DoVerify","DoVerifyReply","Decode Image","DrawFrame","EmbedderCallback","v8.evaluateModule","EvaluateScript","EventDispatch","EventTiming","V8.FinalizeDeserialization","FireAnimationFrame","FireIdleCallback","FrameStartedLoading","FunctionCall","GCEvent","BlinkGC.AtomicPhase","GPUTask","HandlePostMessage","HitTest","InvalidateLayout","JSSample","Layerize","Layout","LayoutShift","MajorGC","MarkDOMContent","firstPaint","firstContentfulPaint","largestContentfulPaint::Candidate","MarkLoad","MinorGC","V8.OptimizeCode","Paint","PaintImage","PaintSetup","ParseAuthorStyleSheet","ParseHTML","PrePaint","ProfileCall","Program","RasterTask","RequestAnimationFrame","RequestIdleCallback","RequestMainThreadFrame","ResourceFinish","ResourceReceivedData","ResourceReceiveResponse","ResourceSendRequest","ResourceWillSendRequest","RunMicrotasks","RunPostTaskCallback","RunTask","SchedulePostMessage","SchedulePostTaskCallback","ScheduleStyleRecalculation","ScrollLayer","CpuProfiler::StartProfiling","v8.parseOnBackground","v8.parseOnBackgroundParsing","v8.parseOnBackgroundWaiting","SyntheticLayoutShift","SyntheticLayoutShiftCluster","TimerFire","TimerInstall","TimerRemove","UpdateLayer","UpdateLayerTree","UpdateLayoutTree","UserTiming","V8Console::runTask","v8.wasm.cachedModule","v8.wasm.compiledModule","v8.wasm.moduleCacheHit","v8.wasm.moduleCacheInvalid","v8.wasm.streamFromResponseCallback","WebSocketCreate","WebSocketDestroy","WebSocketReceive","WebSocketReceiveHandshakeResponse","WebSocketSend","WebSocketSendHandshakeRequest","XHRLoad","XHRReadyStateChange"]);var N=Object.freeze({__proto__:null,VISIBLE_TRACE_EVENT_TYPES:w,activeURLForFrameAtTime:function(e,t,n){const r=n.get(e);if(!r)return null;for(const e of r.values())for(const n of e)if(!(n.window.min>t||n.window.max<t))return n.frame.url;return null},addEventToProcessThread:function(e,t){const{tid:n,pid:r}=e;let i=t.get(r);i||(i=new Map);let a=i.get(n);a||(a=[]),a.push(e),i.set(e.tid,a),t.set(e.pid,i)},createMatchedSortedSyntheticEvents:function(e,t){return E(T(e),t)},createSortedSyntheticEvents:E,eventContainsTimestamp:function(e,t){return e.ts<=t&&e.ts+(e.dur||0)>=t},eventHasCategory:function(e,t){let n=M.get(e.cat);return n||(n=new Set(e.cat.split(",")||[])),n.has(t)},eventTimeComparator:h,extractId:v,extractOriginFromTrace:function(e){const n=t.ParsedURL.ParsedURL.fromString(e);return n?n.host.startsWith("www.")?n.host.slice(4):n.host:null},extractSampleTraceId:C,findNextEventAfterTimestamp:function(t,n){const r=e.ArrayUtilities.nearestIndexFromBeginning(t,(e=>n<e.ts));return null===r?null:t[r]},findPreviousEventBeforeTimestamp:function(t,n){const r=e.ArrayUtilities.nearestIndexFromEnd(t,(e=>e.ts<n));return null===r?null:t[r]},findUpdateLayoutTreeEvents:function(e,t,r){const i=[];for(let a=I(e,t);a<e.length;a++){const t=e[a];n.Events.isUpdateLayoutTree(t)&&(t.ts>=(r||1/0)||i.push(t))}return i},forEachEvent:function(e,t){const r=t.startTime??n.Timing.Micro(0),i=t.endTime||n.Timing.Micro(1/0),a=!1!==t.ignoreAsyncEvents,o=[];for(let s=I(e,r);s<e.length;s++){const c=e[s],u=l(c);if(u.endTime<r)continue;if(u.startTime>i)break;if(a&&n.Events.isPhaseAsync(c.ph)||n.Events.isFlowPhase(c.ph))continue;let d=o.at(-1),m=d?l(d).endTime:null;for(;d&&m&&m<=u.startTime;)o.pop(),t.onEndEvent(d),d=o.at(-1),m=d?l(d).endTime:null;t.eventFilter&&!t.eventFilter(c)||(u.duration?(t.onStartEvent(c),o.push(c)):t.onInstantEvent&&t.onInstantEvent(c))}for(;o.length;){const e=o.pop();e&&t.onEndEvent(e)}},frameIDForEvent:function(e){return e.args&&"beginData"in e.args&&"object"==typeof e.args.beginData&&null!==e.args.beginData&&"frame"in e.args.beginData&&"string"==typeof e.args.beginData.frame?e.args.beginData.frame:e.args?.data?.frame?e.args.data.frame:null},getNavigationForTraceEvent:g,getZeroIndexedLineAndColumnForEvent:function(e){const t=function(e){if(!e.args?.data)return{lineNumber:void 0,columnNumber:void 0};let t,n;"lineNumber"in e.args.data&&"number"==typeof e.args.data.lineNumber&&(t=e.args.data.lineNumber);"columnNumber"in e.args.data&&"number"==typeof e.args.data.columnNumber&&(n=e.args.data.columnNumber);return{lineNumber:t,columnNumber:n}}(e),{lineNumber:n,columnNumber:r}=t;switch(e.name){case"FunctionCall":case"EvaluateScript":case"v8.compile":case"v8.produceCache":return{lineNumber:"number"==typeof n?n-1:void 0,columnNumber:"number"==typeof r?r-1:void 0};case"ProfileCall":{const t=e.callFrame;return{lineNumber:"number"==typeof n?t.lineNumber-1:void 0,columnNumber:"number"==typeof r?t.columnNumber-1:void 0}}default:return t}},getZeroIndexedStackTraceForEvent:function(e){const t=m(e);return t?t.map((t=>{switch(e.name){case"ScheduleStyleRecalculation":case"InvalidateLayout":case"FunctionCall":case"Layout":case"UpdateLayoutTree":return y(t);default:if(n.Events.isUserTiming(e)||n.Extensions.isSyntheticExtensionEntry(e))return y(t)}return t})):null},isMatchingCallFrame:function(e,t){return e.columnNumber===t.columnNumber&&e.lineNumber===t.lineNumber&&String(e.scriptId)===t.scriptId&&e.url===t.url&&e.functionName===t.functionName},isTopLevelEvent:b,makeProfileCall:S,makeZeroBasedCallFrame:y,matchEvents:T,mergeEventsInOrder:p,sortTraceEventsInPlace:f,stackTraceInEvent:m});let F=0;const P=()=>++F,x=()=>({roots:new Set,maxDepth:0}),R=(e,t)=>({entry:e,id:t,parent:null,children:[],depth:0});function D(e,t){const r=new Map,i=[];F=-1;const a=x();for(let o=0;o<e.length;o++){const s=e[o];if(t&&!t.filter.has(s.name))continue;const c=s.dur||0,l=P(),u=R(s,l);if(0===i.length){a.roots.add(u),u.selfTime=n.Timing.Micro(c),i.push(u),a.maxDepth=Math.max(a.maxDepth,i.length),r.set(s,u);continue}const d=i.at(-1);if(void 0===d)throw new Error("Impossible: no parent node found in the stack");const m=d.entry,h=s.ts,f=m.ts,p=h+c,g=f+(m.dur||0);if(h<f)throw new Error("Impossible: current event starts before the parent event");if(h>=g){i.pop(),o--,F--;continue}p>g||(u.depth=i.length,u.parent=d,d.children.push(u),u.selfTime=n.Timing.Micro(c),void 0!==d.selfTime&&(d.selfTime=n.Timing.Micro(d.selfTime-(s.dur||0))),i.push(u),a.maxDepth=Math.max(a.maxDepth,i.length),r.set(s,u))}return{tree:a,entryToNode:r}}function J(e,t,r,i,a,o){if(!a||(s=a,u(t.entry,s))){var s;if(void 0!==o){if(n.Timing.Micro(t.entry.ts+n.Timing.Micro(t.entry.dur??0))<o)return}r(t.entry);for(const n of t.children)J(e,n,r,i,a,o);i(t.entry)}}function _(e){const t=[];for(const n of e){const e=n.ts,r=n.ts+(n.dur??0);let i=t.at(-1);if(void 0===i){t.push(n);continue}let a=i.ts+(i.dur??0);for(;t.length&&e>=a&&(t.pop(),i=t.at(-1),void 0!==i);)a=i.ts+(i.dur??0);if(t.length&&r>a)return!1;t.push(n)}return!0}var A=Object.freeze({__proto__:null,canBuildTreesFromEvents:_,makeEmptyTraceEntryNode:R,makeEmptyTraceEntryTree:x,makeTraceEntryNodeId:P,treify:D,walkEntireTree:function(e,t,n,r,i,a){for(const o of t.roots)J(e,o,n,r,i,a)},walkTreeFromEntry:function(e,t,n,r){const i=e.get(t);i&&J(e,i,n,r)}});var B=Object.freeze({__proto__:null,buildTrackDataFromExtensionEntries:function(t,n,r){const i=new Map;for(const n of t){const t=n.args.trackGroup||`track-name-${n.args.track}`,r=e.MapUtilities.getWithDefault(i,t,(()=>({name:n.args.trackGroup||n.args.track,isTrackGroup:Boolean(n.args.trackGroup),entriesByTrack:{[n.args.track]:[]}})));r.entriesByTrack[n.args.track]||(r.entriesByTrack[n.args.track]=[]);r.entriesByTrack[n.args.track].push(n)}for(const e of i.values()){for(const t of Object.values(e.entriesByTrack))if(f(t),_(t))for(const[e,n]of D(t).entryToNode)r.set(e,n);n.push(e)}return{extensionTrackData:n,entryToNode:r}}});const L=new Set(["non_blocking","dynamically_injected_non_blocking","potentially_blocking"]);const O=new Set(["VeryHigh","High","Medium"]);const U=new Set([200,203,206]),W=new Set(["Font","Image","Media","Script","Stylesheet"]);const j=["localhost","127.0.0.1"];var G=Object.freeze({__proto__:null,CACHEABLE_STATUS_CODES:U,NON_NETWORK_SCHEMES:["blob","data","intent","file","filesystem","chrome-extension"],STATIC_RESOURCE_TYPES:W,isSyntheticNetworkRequestEventRenderBlocking:function(e){return!L.has(e.args.data.renderBlocking)},isSyntheticNetworkRequestHighPriority:function(e){return O.has(e.args.data.priority)},isSyntheticNetworkRequestLocalhost:function(e){try{const t=new URL(e.args.data.url).hostname;return j.includes(t)||t.endsWith(".localhost")}catch{return!1}},parseCacheControl:function(e){if(!e)return null;const t=e.split(",").map((e=>e.trim())),n={};for(const e of t){const[t,r]=e.split("=").map((e=>e.trim()));switch(t){case"max-age":{const e=parseInt(r,10);isNaN(e)||(n["max-age"]=e);break}case"no-cache":n["no-cache"]=!0;break;case"no-store":n["no-store"]=!0;break;case"must-revalidate":n["must-revalidate"]=!0;break;case"private":n.private=!0}}return n}});var H=Object.freeze({__proto__:null,SamplesIntegrator:class e{#n=[];#r=[];#i;#a;#o=[];#s=!1;#c;#l=new Map;#u;#d;jsSampleEvents=[];constructor(e,t,r,i,a){this.#c=e,this.#a=i,this.#i=r,this.#u=a||n.Configuration.defaults(),this.#d=t}buildProfileCalls(e){const t=p(e,this.callsFromProfileSamples()),r=[];for(let e=0;e<t.length;e++){const i=t[e];if("I"===i.ph&&!C(i))continue;if(0===r.length){if(n.Events.isProfileCall(i)){this.#m(i);continue}r.push(i),this.#h(i);continue}const a=r.at(-1);if(void 0===a)continue;i.ts>=a.ts+(a.dur||0)?(this.#f(a),r.pop(),e--):n.Events.isProfileCall(i)?this.#m(i,a):(this.#h(i),r.push(i))}for(;r.length;){const e=r.pop();e&&this.#f(e)}return f(this.jsSampleEvents),this.#n}#h(e){"RunMicrotasks"!==e.name&&"RunTask"!==e.name||(this.#o=[],this.#p(0,e.ts),this.#s=!1),this.#s&&(this.#p(this.#o.pop()||0,e.ts),this.#s=!1),this.#g(e),this.#o.push(this.#r.length)}#m(e,t){if(t&&n.Events.isJSInvocationEvent(t)||this.#s)this.#g(e);else if(n.Events.isProfileCall(e)&&0===this.#r.length){this.#s=!0;const t=this.#r.length;this.#g(e),this.#o.push(t)}}#f(e){const t=n.Timing.Micro(e.ts+(e.dur??0));this.#p(this.#o.pop()||0,t)}callsFromProfileSamples(){const e=this.#c.samples,t=this.#c.timestamps;if(!e)return[];const r=[];let i;for(let a=0;a<e.length;a++){const e=this.#c.nodeByIndex(a),s=o(n.Timing.Milli(t[a]));if(!e)continue;const c=S(e,this.#d,a,s,this.#i,this.#a);if(r.push(c),this.#u.debugMode){const e=this.#c.traceIds?.[a];this.jsSampleEvents.push(this.#v(c,s,e))}e.id===this.#c.gcNode?.id&&i?this.#l.set(c,i):i=e}return r}#S(e,t){let n=this.#c.nodeById(e.nodeId);const r=n?.id===this.#c.gcNode?.id;if(r&&(n=this.#l.get(e)||null),!n)return[];const i=new Array(n.depth+1+Number(r));let a=i.length-1;for(r&&(i[a--]=e);n;)i[a--]=S(n,e.profileId,e.sampleIndex,t??e.ts,this.#i,this.#a),n=n.parent;return i}#T(e,t){const n=this.#c.traceIds?.[e],r=n&&this.#c.nodeById(n),i=r&&S(r,this.#d,-1,t,this.#i,this.#a);return i?(this.#u.debugMode&&this.jsSampleEvents.push(this.#v(i,t,e)),this.#S(i)):null}#g(t){let r=this.#r;n.Events.isProfileCall(t)&&(r=this.#S(t));const i=C(t),a=i&&this.#T(i,t.ts);a&&(r=a),e.filterStackFrames(r,this.#u);const o=t.ts+(t.dur||0),s=Math.min(r.length,this.#r.length);let c;for(c=this.#o.at(-1)||0;c<s;++c){const t=r[c].callFrame,i=this.#r[c].callFrame;if(!e.framesAreEqual(t,i))break;this.#r[c].dur=n.Timing.Micro(Math.max(this.#r[c].dur||0,o-this.#r[c].ts))}for(this.#p(c,t.ts);c<r.length;++c){const e=r[c];e.nodeId!==this.#c.programNode?.id&&e.nodeId!==this.#c.root?.id&&e.nodeId!==this.#c.idleNode?.id&&e.nodeId!==this.#c.gcNode?.id&&(this.#r.push(e),this.#n.push(e))}}#p(e,t){if(this.#o.length){const n=this.#o.at(-1);n&&e<n&&(console.error(`Child stack is shallower (${e}) than the parent stack (${n}) at ${t}`),e=n)}this.#r.length<e&&(console.error(`Trying to truncate higher than the current stack size at ${t}`),e=this.#r.length);for(let e=0;e<this.#r.length;++e)this.#r[e].dur=n.Timing.Micro(Math.max(t-this.#r[e].ts,0));this.#r.length=e}#v(e,t,r){return{name:"JSSample",cat:"devtools.timeline",args:{data:{traceId:r,stackTrace:this.#S(e).map((e=>e.callFrame))}},ph:"I",ts:t,dur:n.Timing.Micro(0),pid:this.#i,tid:this.#a}}static framesAreEqual(e,t){return e.scriptId===t.scriptId&&e.functionName===t.functionName&&e.lineNumber===t.lineNumber}static showNativeName(t,n){return n&&Boolean(e.nativeGroup(t))}static nativeGroup(e){return e.startsWith("Parse")?"Parse":e.startsWith("Compile")||e.startsWith("Recompile")?"Compile":null}static isNativeRuntimeFrame(e){return"native V8Runtime"===e.url}static filterStackFrames(t,n){if(n.showAllEvents)return;let r=null,i=0;for(let a=0;a<t.length;++a){const o=t[a].callFrame,s=e.isNativeRuntimeFrame(o);if(s&&!e.showNativeName(o.functionName,n.includeRuntimeCallStats))continue;const c=s?e.nativeGroup(o.functionName):null;r&&r===c||(r=c,t[i++]=t[a])}t.length=i}static createFakeTraceFromCpuProfile(e,t){const r=[],i=`Thread ${t}`;return a("TracingStartedInPage",{data:{sessionId:"1"}},0,0,"M"),a("thread_name",{name:i},0,0,"M","__metadata"),e?(a("JSRoot",{},e.startTime,e.endTime-e.startTime,"X","toplevel"),a("CpuProfile",{data:{cpuProfile:e}},e.endTime,0,"X"),{traceEvents:r,metadata:{dataOrigin:"CPUProfile"}}):{traceEvents:r,metadata:{}};function a(e,i,a,o,s,c){const l={cat:c||"disabled-by-default-devtools.timeline",name:e,ph:s||"X",pid:n.Events.ProcessID(1),tid:t,ts:n.Timing.Micro(a),args:i};return o&&(l.dur=n.Timing.Micro(o)),r.push(l),l}}}});export{B as Extensions,G as Network,H as SamplesIntegrator,a as SyntheticEvents,d as Timing,N as Trace,A as TreeHelpers};