UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 1.4 kB
import*as Platform from"../../../core/platform/platform.js";import*as Helpers from"../helpers/helpers.js";import*as Types from"../types/types.js";const warningsPerEvent=new Map,eventsPerWarning=new Map,FORCED_LAYOUT_AND_STYLES_THRESHOLD=Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(10));export function reset(){warningsPerEvent.clear(),eventsPerWarning.clear()}function storeWarning(e,n){const r=Platform.MapUtilities.getWithDefault(warningsPerEvent,e,(()=>[]));r.push(n),warningsPerEvent.set(e,r);const s=Platform.MapUtilities.getWithDefault(eventsPerWarning,n,(()=>[]));s.push(e),eventsPerWarning.set(n,s)}export function handleEvent(e){if("RunTask"!==e.name)if(Types.TraceEvents.isTraceEventFireIdleCallback(e)){const{duration:n}=Helpers.Timing.eventTimingsMilliSeconds(e);n>e.args.data.allottedMilliseconds&&storeWarning(e,"IDLE_CALLBACK_OVER_TIME")}else"Layout"!==e.name?"RecalculateStyles"!==e.name&&"UpdateLayoutTree"!==e.name||e.dur&&e.dur>=FORCED_LAYOUT_AND_STYLES_THRESHOLD&&storeWarning(e,"FORCED_STYLE"):e.dur&&e.dur>=FORCED_LAYOUT_AND_STYLES_THRESHOLD&&storeWarning(e,"FORCED_LAYOUT");else{const n=Helpers.Timing.millisecondsToMicroseconds(Types.Timing.MilliSeconds(50)),{duration:r}=Helpers.Timing.eventTimingsMicroSeconds(e);r>n&&storeWarning(e,"LONG_TASK")}}export function data(){return{perEvent:new Map(warningsPerEvent),perWarning:new Map(eventsPerWarning)}}