@xbrowser/cli 0.14.1 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -6586,8 +6586,21 @@ async function executeChain(input, options) {
6586
6586
  };
6587
6587
  const start2 = Date.now();
6588
6588
  try {
6589
+ const hooks = await loadHooks();
6590
+ if (hooks.length > 0) {
6591
+ await Promise.all(hooks.map((h) => h.onBeforeCommand?.({ page: session.page, command: `${cmdName} ${subCommand}`, params: pluginParams })));
6592
+ }
6589
6593
  const raw = await cmdEntry.handler(pluginParams, pluginCtx);
6590
6594
  const duration2 = Date.now() - start2;
6595
+ let hookOutputs;
6596
+ if (hooks.length > 0) {
6597
+ const outputs = [];
6598
+ for (const h of hooks) {
6599
+ const output = await h.onAfterCommand?.({ page: session.page, command: `${cmdName} ${subCommand}`, params: pluginParams, result: raw, duration: duration2 });
6600
+ if (output) outputs.push(output);
6601
+ }
6602
+ if (outputs.length > 0) hookOutputs = outputs;
6603
+ }
6591
6604
  const data = raw?.data ?? raw;
6592
6605
  recordArchive(session.id, sessionName, {
6593
6606
  step: results.length,
@@ -6602,7 +6615,8 @@ async function executeChain(input, options) {
6602
6615
  command: `${cmdName} ${subCommand}`,
6603
6616
  raw: cmdStr,
6604
6617
  ...ok25(data),
6605
- duration: duration2
6618
+ duration: duration2,
6619
+ ...hookOutputs ? { hookOutputs } : {}
6606
6620
  });
6607
6621
  if (type === "or") {
6608
6622
  return {
@@ -6666,7 +6680,8 @@ async function executeChain(input, options) {
6666
6680
  data: result.data,
6667
6681
  message: result.message,
6668
6682
  duration,
6669
- tips: result.tips
6683
+ tips: result.tips,
6684
+ ...result.hookOutputs ? { hookOutputs: result.hookOutputs } : {}
6670
6685
  };
6671
6686
  results.push(stepResult);
6672
6687
  if (type === "and" && !result.success) {
@@ -6567,8 +6567,21 @@ async function executeChain(input, options) {
6567
6567
  };
6568
6568
  const start2 = Date.now();
6569
6569
  try {
6570
+ const hooks = await loadHooks();
6571
+ if (hooks.length > 0) {
6572
+ await Promise.all(hooks.map((h) => h.onBeforeCommand?.({ page: session.page, command: `${cmdName} ${subCommand}`, params: pluginParams })));
6573
+ }
6570
6574
  const raw = await cmdEntry.handler(pluginParams, pluginCtx);
6571
6575
  const duration2 = Date.now() - start2;
6576
+ let hookOutputs;
6577
+ if (hooks.length > 0) {
6578
+ const outputs = [];
6579
+ for (const h of hooks) {
6580
+ const output = await h.onAfterCommand?.({ page: session.page, command: `${cmdName} ${subCommand}`, params: pluginParams, result: raw, duration: duration2 });
6581
+ if (output) outputs.push(output);
6582
+ }
6583
+ if (outputs.length > 0) hookOutputs = outputs;
6584
+ }
6572
6585
  const data = raw?.data ?? raw;
6573
6586
  recordArchive(session.id, sessionName, {
6574
6587
  step: results.length,
@@ -6583,7 +6596,8 @@ async function executeChain(input, options) {
6583
6596
  command: `${cmdName} ${subCommand}`,
6584
6597
  raw: cmdStr,
6585
6598
  ...ok25(data),
6586
- duration: duration2
6599
+ duration: duration2,
6600
+ ...hookOutputs ? { hookOutputs } : {}
6587
6601
  });
6588
6602
  if (type === "or") {
6589
6603
  return {
@@ -6647,7 +6661,8 @@ async function executeChain(input, options) {
6647
6661
  data: result.data,
6648
6662
  message: result.message,
6649
6663
  duration,
6650
- tips: result.tips
6664
+ tips: result.tips,
6665
+ ...result.hookOutputs ? { hookOutputs: result.hookOutputs } : {}
6651
6666
  };
6652
6667
  results.push(stepResult);
6653
6668
  if (type === "and" && !result.success) {