Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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', {
Expand All @@ -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': {
Expand Down