From accf665e339b115f6bf8ea4aaa86ef8b74fbe0c5 Mon Sep 17 00:00:00 2001 From: 7h3Rabbit <62792609+7h3Rabbit@users.noreply.github.com> Date: Sun, 20 Apr 2025 12:35:55 +0200 Subject: [PATCH] Hide our tab when plugin-webperf-core is used --- lib/index.js | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5aa0e52..dddf5f9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -18,6 +18,7 @@ export default class JavascriptPlugin extends SitespeedioPlugin { async open(context, options) { this.make = context.messageMaker(pluginname).make; this.harAnalyzer = new HarAnalyzer(); + this.isWebperfCorePluginPresent = false; const libFolder = fileURLToPath(new URL('..', import.meta.url)); this.pluginFolder = path.resolve(libFolder); this.options = options; @@ -32,8 +33,11 @@ export default class JavascriptPlugin extends SitespeedioPlugin { // const filterRegistry = this.filterRegistry; switch (message.type) { case 'sitespeedio.setup': { - // Let other plugins know that the pagenotfound plugin is alive - // queue.postMessage(this.make(pluginname + '.setup')); + // Let other plugins know that our plugin is alive + queue.postMessage(this.make(pluginname + '.setup', { + 'version': this.version, + 'dependencies': this.dependencies + })); // Add the HTML pugs queue.postMessage( this.make('html.pug', { @@ -53,24 +57,40 @@ export default class JavascriptPlugin extends SitespeedioPlugin { ); break; } + case 'plugin-webperf-core.setup': { + this.isWebperfCorePluginPresent = true; + break; + } case 'browsertime.har': { const url = message.url; const group = message.group; const harData = message.data; var data = await this.harAnalyzer.analyzeData(url, harData, group); - - super.sendMessage( - // The HTML plugin will pickup every message names *.pageSummary - // and publish the data under pageInfo.data.*.pageSummary - // in this case pageInfo.data.gpsi.pageSummary - pluginname + '.pageSummary', - data, - { - url, - group - } - ); + if (this.isWebperfCorePluginPresent) { + super.sendMessage( + // The WebPerf plugin will pickup every message names *.webPerfCoreSummary + // and publish the data under pageInfo.data.*.pageSummary + pluginname + '.webPerfCoreSummary', + data, + { + url, + group + } + ); + } else { + super.sendMessage( + // The HTML plugin will pickup every message names *.pageSummary + // and publish the data under pageInfo.data.*.pageSummary + // in this case pageInfo.data.gpsi.pageSummary + pluginname + '.pageSummary', + data, + { + url, + group + } + ); + } break; } case 'sitespeedio.summarize': {