/**
* @file plugins/analyze/stats.js
* @copyright @spmhome @_2025
* @author Scott Meesseman @spmeesseman
*//** */
const WpwAnalyzePlugin = require("./base");
/**
* @augments WpwAnalyzePlugin
*/
class WpwStatsAnalyzePlugin extends WpwAnalyzePlugin
{
/**
* @type {number}
*/
start;
/**
* @param {WpwPluginOptions} options Plugin options to be applied
*/
constructor(options)
{
super(options);
this.start = 0;
this.buildOptions = /** @type {WpwStatsAnalyzePluginOptions} */(this.buildOptions);
}
/**
* @override
* @static
*/
static create = WpwStatsAnalyzePlugin.wrap.bind(this);
/**
* @override
* @returns {WpwPluginTapOptions<any, any, boolean> | undefined}
*/
onApply()
{
return {
normalizeStats: {
async: false,
forceRun: true,
hook: "compilation",
hookCompilation: "statsNormalize",
callback: this.normalizeStats.bind(this)
},
examineStatsFactory: {
async: false,
forceRun: true,
hook: "compilation",
hookCompilation: "statsFactory",
callback: this.examineStatsFactory.bind(this)
},
printStats: {
async: false,
forceRun: true,
hook: "compilation",
hookCompilation: "statsPrinter",
callback: this.printStats.bind(this)
},
processErrors: {
async: false,
forceRun: true,
hook: "compilation",
hookCompilation: "processErrors",
callback: this.processErrors.bind(this)
},
processTimeElapsedDone: {
async: false,
forceRun: true,
hook: "done",
callback: this.processTimeElapsedDone.bind(this)
},
processTimeElapsedStart: {
async: false,
forceRun: true,
hook: "run",
callback: this.processTimeElapsedStart.bind(this)
}
};
}
/**
* @private
* @param {WebpackStats} _stats
*/
async examineStatsFactory(_stats)
{
const l = this.hookstart();
try {
l.write(" ...TODO...", 1);
}
catch (e)
{ this.addMessage(
{ exception: e,
code: this.MsgCode.ERROR_PLUGIN_HOOK_FAILED,
message: "to level error, see exception info for any detail"
}, true);
}
finally { this.hookdone(); }
}
/**
* @private
* @param {WebpackStats} _stats
*/
async normalizeStats(_stats)
{
const l = this.hookstart();
try {
l.write(" ...TODO...", 1);
}
catch (e)
{ this.addMessage({
exception: e,
code: this.MsgCode.ERROR_PLUGIN_HOOK_FAILED,
message: "to level error, see exception info for any detail"
}, true);
}
finally { this.hookdone(); }
}
/**
* @private
* @param {WebpackStats} _stats
*/
async printStats(_stats)
{
const l = this.hookstart();
try {
l.write(" ...TODO...", 1);
}
catch (e)
{ this.addMessage(
{ exception: e,
code: this.MsgCode.ERROR_PLUGIN_HOOK_FAILED,
message: "to level error, see exception info for any detail"
}, true);
}
finally { this.hookdone(); }
}
/**
* @private
* @param {WebpackStats} _stats
*/
async processErrors(_stats)
{
const l = this.hookstart();
try {
l.write(" ...TODO...", 1);
}
catch (e)
{ this.addMessage(
{ exception: e,
code: this.MsgCode.ERROR_PLUGIN_HOOK_FAILED,
message: "to level error, see exception info for any detail"
}, true);
}
finally { this.hookdone(); }
}
processTimeElapsedDone() { this.build.elapsed = Date.now() - this.start; }
processTimeElapsedStart() { this.start = Date.now(); }
}
module.exports = WpwStatsAnalyzePlugin.create;