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
46 changes: 34 additions & 12 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class CssPlugin 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 @@ -46,6 +47,12 @@ export default class CssPlugin extends SitespeedioPlugin {
break;
}
case 'sitespeedio.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', {
id: pluginname,
Expand All @@ -62,6 +69,11 @@ export default class CssPlugin extends SitespeedioPlugin {
type: 'run'
})
);

break;
}
case 'plugin-webperf-core.setup': {
this.isWebperfCorePluginPresent = true;
break;
}
case 'browsertime.har': {
Expand All @@ -70,18 +82,28 @@ export default class CssPlugin extends SitespeedioPlugin {
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(
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