@kubb/core 5.0.0-beta.40 → 5.0.0-beta.41

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.
@@ -661,7 +661,7 @@ var URLPath = class {
661
661
  };
662
662
  //#endregion
663
663
  //#region package.json
664
- var version = "5.0.0-beta.40";
664
+ var version = "5.0.0-beta.41";
665
665
  //#endregion
666
666
  //#region src/constants.ts
667
667
  /**
@@ -2463,6 +2463,11 @@ var KubbDriver = class KubbDriver {
2463
2463
  * A failing plugin contributes an error diagnostic so the rest of the build continues.
2464
2464
  * Every plugin also contributes a `timing` diagnostic.
2465
2465
  *
2466
+ * Plugins run sequentially so `kubb:plugin:end` fires as each plugin completes, instead
2467
+ * of all at once after every plugin has marched through the parallel batches together.
2468
+ * That ordering is what drives the CLI's `Plugins N/M` counter; without it the bar would
2469
+ * sit at the initial value until the very end of the run.
2470
+ *
2466
2471
  * When `entries` is empty or `this.inputNode` is `null`, every entry still gets a
2467
2472
  * `kubb:plugin:end` so middleware listeners (the barrel writer and friends) complete.
2468
2473
  */
@@ -2507,15 +2512,18 @@ var KubbDriver = class KubbDriver {
2507
2512
  });
2508
2513
  const emitsSchemaHook = this.hooks.listenerCount("kubb:generate:schema") > 0;
2509
2514
  const emitsOperationHook = this.hooks.listenerCount("kubb:generate:operation") > 0;
2515
+ const emitsOperationsHook = this.hooks.listenerCount("kubb:generate:operations") > 0;
2516
+ const schemasBuffer = [];
2517
+ for await (const schema of schemas) schemasBuffer.push(schema);
2518
+ const operationsBuffer = [];
2519
+ for await (const operation of operations) operationsBuffer.push(operation);
2510
2520
  const pruningStates = states.filter(({ plugin }) => {
2511
2521
  const { include } = plugin.options;
2512
2522
  return (include?.some(({ type }) => OPERATION_FILTER_TYPES.has(type)) ?? false) && !(include?.some(({ type }) => type === "schemaName") ?? false);
2513
2523
  });
2514
2524
  if (pruningStates.length > 0) {
2515
- const allSchemas = [];
2516
- for await (const schema of schemas) allSchemas.push(schema);
2517
2525
  const includedOpsByState = new Map(pruningStates.map((state) => [state, []]));
2518
- for await (const operation of operations) for (const state of pruningStates) {
2526
+ for (const operation of operationsBuffer) for (const state of pruningStates) {
2519
2527
  const { exclude, include, override } = state.plugin.options;
2520
2528
  if (state.generatorContext.resolver.resolveOptions(operation, {
2521
2529
  options: state.plugin.options,
@@ -2525,7 +2533,7 @@ var KubbDriver = class KubbDriver {
2525
2533
  }) !== null) includedOpsByState.get(state)?.push(operation);
2526
2534
  }
2527
2535
  for (const state of pruningStates) {
2528
- state.allowedSchemaNames = (0, _kubb_ast.collectUsedSchemaNames)(includedOpsByState.get(state) ?? [], allSchemas);
2536
+ state.allowedSchemaNames = (0, _kubb_ast.collectUsedSchemaNames)(includedOpsByState.get(state) ?? [], schemasBuffer);
2529
2537
  includedOpsByState.delete(state);
2530
2538
  }
2531
2539
  }
@@ -2587,20 +2595,20 @@ var KubbDriver = class KubbDriver {
2587
2595
  checkAllowedNames: false,
2588
2596
  emit: emitsOperationHook ? (node, ctx) => this.hooks.emit("kubb:generate:operation", node, ctx) : null
2589
2597
  };
2590
- const needsCollectedOperations = this.hooks.listenerCount("kubb:generate:operations") > 0 || states.some((state) => state.generators.some((gen) => !!gen.operations));
2591
- const collectedOperations = needsCollectedOperations ? [] : void 0;
2592
- await forBatches(schemas, (nodes) => Promise.all(nodes.flatMap((node) => states.map((state) => dispatchNode(state, node, schemaDispatch)))), {
2593
- concurrency: 8,
2594
- flush: flushPending
2595
- });
2596
- await forBatches(operations, (nodes) => {
2597
- if (needsCollectedOperations) collectedOperations?.push(...nodes);
2598
- return Promise.all(nodes.flatMap((node) => states.map((state) => dispatchNode(state, node, operationDispatch))));
2599
- }, {
2600
- concurrency: 8,
2601
- flush: flushPending
2602
- });
2603
2598
  for (const state of states) {
2599
+ const needsCollectedOperations = emitsOperationsHook || state.generators.some((gen) => !!gen.operations);
2600
+ const collectedOperations = needsCollectedOperations ? [] : void 0;
2601
+ await forBatches(schemasBuffer, (nodes) => Promise.all(nodes.map((node) => dispatchNode(state, node, schemaDispatch))), {
2602
+ concurrency: 8,
2603
+ flush: flushPending
2604
+ });
2605
+ await forBatches(operationsBuffer, (nodes) => {
2606
+ if (needsCollectedOperations) collectedOperations?.push(...nodes);
2607
+ return Promise.all(nodes.map((node) => dispatchNode(state, node, operationDispatch)));
2608
+ }, {
2609
+ concurrency: 8,
2610
+ flush: flushPending
2611
+ });
2604
2612
  if (!state.failed && needsCollectedOperations) try {
2605
2613
  const { plugin, generatorContext, generators } = state;
2606
2614
  const ctx = {
@@ -2982,4 +2990,4 @@ Object.defineProperty(exports, "memoryStorage", {
2982
2990
  }
2983
2991
  });
2984
2992
 
2985
- //# sourceMappingURL=memoryStorage-Dkxnid2K.cjs.map
2993
+ //# sourceMappingURL=memoryStorage-DZqlEW7H.cjs.map