@alithanar/react-automation-profiler
Version:
Automated React profiling and data visualization using React's Profiler API, Puppeteer, and D3.
44 lines • 1.86 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutomationAPI = void 0;
const automation_1 = __importDefault(require("../automation/automation"));
const path_1 = __importDefault(require("path"));
const AutomationResultsStorage_1 = require("../automation/AutomationResultsStorage");
const interfaces_1 = require("../interfaces");
const path_2 = require("path");
class AutomationAPI {
static async run({ averageOf = 1, includeMount = false, page, preloadFilePath, cookies, scenarios, headless = true, browserArgs = [], }) {
let results = {};
const scriptPath = (0, path_2.resolve)('./lib/api/index.js');
const packagePath = `${scriptPath.slice(0, scriptPath.lastIndexOf('/'))}`;
const resultsStorage = new AutomationResultsStorage_1.AutomationResultsStorage();
for (let automationCount = 1; automationCount <= averageOf; automationCount++) {
const props = {
automationCount,
preloadFilePath,
averageOf,
cwd: path_1.default.resolve(),
includeMount,
isServerReady: false,
packagePath,
serverPort: 0,
url: page,
headless,
browserArgs,
cookies,
output: interfaces_1.OutputType.JSON,
scenarios,
};
const automationResult = await (0, automation_1.default)(props, resultsStorage);
if (automationResult) {
results = automationResult;
}
}
return results;
}
}
exports.AutomationAPI = AutomationAPI;
//# sourceMappingURL=index.js.map