import Vnmf from '../../index' declare module '../../index' { /** EntryList Object * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.html */ interface EntryList { /** This method returns all performance data in the current list * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntries.html */ getEntries(): PerformanceEntry[] /** Get all the names in the current list as [name] Type [entryType] Performance data * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByName.html */ getEntriesByName(name: string, entryType: string): PerformanceEntry[] /** All types in the current list are [entryType] Performance data * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByType.html */ getEntriesByType(entryType: string): PerformanceEntry[] } /** Performance Object ,Used to obtain performance data and create performance monitor * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.html */ interface Performance { /** Create a global performance event monitor * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.createObserver.html */ createObserver(callback: Function): PerformanceObserver /** This method returns all performance data in the current buffer * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntries.html */ getEntries(): PerformanceEntry[] /** All names in the current buffer are [name] Type [entryType] Performance data * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByName.html */ getEntriesByName(name: string, entryType: string): PerformanceEntry[] /** All types in the current buffer are [entryType] Performance data * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByType.html */ getEntriesByType(entryType: string): PerformanceEntry[] /** Set the buffer size ,Default buffer 30 Strip performance data * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.setBufferSize.html */ setBufferSize(size: number): void } /** Single performance data * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceEntry.html */ interface PerformanceEntry { /** Indicator type */ entryType: keyof PerformanceEntry.EntryType /** Indicator name */ name: keyof PerformanceEntry.EntryName /** Starting time ,There will be differences in the specific meaning of different indicators */ startTime: number /** time consuming ms。For the indicators that indicate the stage, the indicators are valid 。 */ duration: number /** Page path 。only render and navigation The type indicator is valid 。 */ path: string /** The start time of the route really responding 。only navigation The type indicator is valid 。 */ navigationStart: number /** Route detailed type ,Corresponding to the small program routing method 。only navigation The type indicator is valid 。 */ navigationType: string /** Subcontractor ,The main bag is expressed as APP。only evaluateScript Effective indicators 。 */ moduleName: string /** List of injection files 。only evaluateScript Effective indicators 。 */ fileList: string[] /** Rendering layer code injection time completion time 。only firstRender Effective indicators 。 */ viewLayerReadyTime: number /** The time of the first rendering parameter from the logic layer 。only firstRender Effective indicators 。 */ initDataSendTime: number /** The time of the first rendering parameter in the rendering layer 。only firstRender Effective indicators 。 */ initDataRecvTime: number /** Rendering layer execution time start time 。only firstRender Effective indicators 。 */ viewLayerRenderStartTime: number /** Rendering layer execution end time 。only firstRender Effective indicators 。 */ viewLayerRenderEndTime: number } /** PerformanceObserver Object ,Used to monitor performance -related events * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.html */ interface PerformanceObserver { /** Get all the performance indicators currently supported */ supportedEntryTypes: PerformanceEntry[] /** Stop monitoring * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.disconnect.html */ disconnect(): void /** Start supervision * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.observe.html */ observe(option: PerformanceObserver.observe.Option): void } namespace PerformanceEntry { /** entryType Legal value */ interface EntryType { /** routing */ navigation /** Rendering */ render /** Script */ script } /** name Legal value */ interface EntryName { /** Time to start at applets 。The starting point is to click the applet icon for the user ,Or the time when the applet is pulled up ;The end point is homepage onReady。(entryType: navigation) */ appLaunch /** Route processing time consuming 。(entryType: navigation) */ route /** The first rendering of the page consuming 。The starting point is to receive the routing event in the logic layer ,Including the initialization of the logic layer page and component 、VD Synchronize 、The rendering layer executes rendering time ;The end point is homepage onReady。(entryType: render) */ firstRender /** [Page first drawing ](https://developer.mozilla.org/en-US/docs/Glossary/First_paint)。The first pixel renders the time used on the screen 。(entryType: render) */ firstPaint /** [Page first content drawing ](https://developer.mozilla.org/en-US/docs/Glossary/First_contentful_paint)。The first content rendered to the time used on the screen 。(entryType: render) */ firstContentfulPaint /** Logic layer JS Code injection time consumption 。(entryType: script) */ evaluateScript } } namespace PerformanceObserver { namespace observe { interface Option { /** Indicator type 。Be in harmony entryTypes use simultaneously */ type: keyof EntryType /** List of indicator type 。Be in harmony type use simultaneously 。 */ entryTypes: (keyof EntryType)[] } interface EntryType { /** routing */ navigation /** Rendering */ render /** Script */ script } } } interface VnmfStatic { /** Small program speed report 。before use ,Need to be configured in the small program management background 。 See [Small program speed measurement ](https://developers.weixin.qq.com/miniprogram/dev/framework/performanceReport/index.html)guide 。 * @supported weapp * @example * ```tsx * Vnmf.reportPerformance(1101, 680) * Vnmf.reportPerformance(1101, 680, 'custom') * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.reportPerformance.html */ reportPerformance( /** index id */ id: number, /** The value to be reported */ value: number, /** Custom dimension */ dimensions?: string | string[], ): void /** Small program speed report 。before use ,Need to be configured in the small program management background 。 See [Small program speed measurement ](https://developers.weixin.qq.com/miniprogram/dev/framework/performanceReport/index.html)guide 。 * * **Notice ** * - Currently ,When the code is turned on [Inject ](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/lazyload.html) `Time ,evaluateScript` It will only include some public code ,The code injection time of the page and the component will be included `firstRender` middle (Because the code injection process of the page and the component has become part of the first rendering process )。Therefore ,Script time consumption is reduced ,Rendering time is normal ,The optimization effect can pay attention to the overall startup time consuming (`appLaunch`)To evaluate 。 * - `firstPaint` and `firstContentfulPaint` The indicator is opening `vconsole` in the case of ,Due to drawing `vconsoel` Panel ,It will cause data advance 。 * @supported weapp, tt * @example * ```tsx * const performance = Vnmf.getPerformance() * const observer = performance.createObserver((entryList) => { * console.log(entryList.getEntries()) * }) * observer.observe({ entryTypes: ['render', 'script', 'navigation'] }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.getPerformance.html */ getPerformance(): Performance } }