@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.
package/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
 
6
6
  [![npm version][npm-version-src]][npm-version-href]
7
7
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
8
- [![Coverage][coverage-src]][coverage-href]
8
+ [![Stars][stars-src]][stars-href]
9
9
  [![License][license-src]][license-href]
10
- [![Sponsors][sponsors-src]][sponsors-href]
10
+ [![Node][node-src]][node-href]
11
11
 
12
12
  <h4>
13
13
  <a href="https://kubb.dev" target="_blank">Documentation</a>
@@ -26,7 +26,7 @@
26
26
 
27
27
  Core engine for Kubb's plugin-based code generation system. Provides the plugin driver, file manager, `defineConfig`, `definePlugin`, `defineMiddleware`, and the build orchestration layer used by every Kubb plugin.
28
28
 
29
- > **Note:** Most users should install the [`kubb`](https://npmjs.com/package/kubb) meta-package instead of `@kubb/core` directly. Install `@kubb/core` only when building custom plugins or extending the Kubb internals.
29
+ > **Note:** Most users should install the [`kubb`](https://npmx.dev/package/kubb) meta-package instead of `@kubb/core` directly. Install `@kubb/core` only when building custom plugins or extending the Kubb internals.
30
30
 
31
31
  ## Installation
32
32
 
@@ -57,13 +57,13 @@ Kubb is an open source project, and its development is funded entirely by sponso
57
57
 
58
58
  <!-- Badges -->
59
59
 
60
- [npm-version-src]: https://img.shields.io/npm/v/@kubb/core?flat&colorA=18181B&colorB=f58517
61
- [npm-version-href]: https://npmjs.com/package/@kubb/core
62
- [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/core?flat&colorA=18181B&colorB=f58517
63
- [npm-downloads-href]: https://npmjs.com/package/@kubb/core
64
- [license-src]: https://img.shields.io/npm/l/%40kubb%2Fcore?flat&colorA=18181B&colorB=f58517
65
- [license-href]: https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT
66
- [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
67
- [coverage-href]: https://www.npmjs.com/package/@kubb/core
68
- [sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
69
- [sponsors-href]: https://github.com/sponsors/stijnvanhulle/
60
+ [npm-version-src]: https://shieldcn.dev/npm/v/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
61
+ [npm-version-href]: https://npmx.dev/package/@kubb/core
62
+ [npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
63
+ [npm-downloads-href]: https://npmx.dev/package/@kubb/core
64
+ [stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
65
+ [stars-href]: https://github.com/kubb-labs/kubb
66
+ [license-src]: https://shieldcn.dev/npm/license/@kubb/core.svg?variant=secondary&size=xs&theme=zinc
67
+ [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
68
+ [node-src]: https://shieldcn.dev/npm/node/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
69
+ [node-href]: https://npmx.dev/package/@kubb/core
@@ -524,27 +524,25 @@ type LoggerContext = AsyncEventEmitter<KubbHooks>;
524
524
  /**
525
525
  * Logger contract. A logger receives the build's event emitter and subscribes
526
526
  * to whichever lifecycle events it wants to forward to its destination
527
- * (console, file, remote sink).
527
+ * (console, file, remote service).
528
528
  */
529
- type Logger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = {
529
+ type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
530
530
  /**
531
531
  * Display name used in diagnostics.
532
532
  */
533
533
  name: string;
534
534
  /**
535
- * Called once per build with the shared event emitter. Subscribe to events
536
- * here. The return value (if any) is forwarded to whoever installed the
537
- * logger, which is handy for sink factories.
535
+ * Called once per build with the shared event emitter. Subscribe to the
536
+ * lifecycle events the logger wants to forward to its destination.
538
537
  */
539
- install: (context: LoggerContext, options?: TOptions) => TInstallReturn | Promise<TInstallReturn>;
538
+ install: (context: LoggerContext, options?: TOptions) => void | Promise<void>;
540
539
  };
541
- type UserLogger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = Logger<TOptions, TInstallReturn>;
540
+ type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<TOptions>;
542
541
  /**
543
- * Defines a typed logger. Use the second type parameter to declare a return
544
- * value from `install`, which is handy when the logger exposes a sink factory
545
- * or cleanup callback to the caller.
542
+ * Defines a typed logger. The `install` method subscribes to lifecycle events
543
+ * on the shared emitter and forwards them to the logger's destination.
546
544
  *
547
- * @example Basic logger
545
+ * @example
548
546
  * ```ts
549
547
  * import { defineLogger } from '@kubb/core'
550
548
  *
@@ -556,22 +554,8 @@ type UserLogger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn =
556
554
  * },
557
555
  * })
558
556
  * ```
559
- *
560
- * @example Logger that returns a hook sink factory
561
- * ```ts
562
- * import { defineLogger, type LoggerOptions } from '@kubb/core'
563
- * import type { HookSinkFactory } from './sinks'
564
- *
565
- * export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({
566
- * name: 'my-logger',
567
- * install(context) {
568
- * // … register event handlers …
569
- * return () => ({ onStdout: console.log })
570
- * },
571
- * })
572
- * ```
573
557
  */
574
- declare function defineLogger<Options extends LoggerOptions = LoggerOptions, TInstallReturn = void>(logger: UserLogger<Options, TInstallReturn>): Logger<Options, TInstallReturn>;
558
+ declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
575
559
  //#endregion
576
560
  //#region src/createReporter.d.ts
577
561
  /**
@@ -2218,6 +2202,7 @@ interface KubbHooks {
2218
2202
  'kubb:hooks:start': [];
2219
2203
  'kubb:hooks:end': [];
2220
2204
  'kubb:hook:start': [ctx: KubbHookStartContext];
2205
+ 'kubb:hook:line': [ctx: KubbHookLineContext];
2221
2206
  'kubb:hook:end': [ctx: KubbHookEndContext];
2222
2207
  'kubb:info': [ctx: KubbInfoContext];
2223
2208
  'kubb:error': [ctx: KubbErrorContext];
@@ -2454,6 +2439,20 @@ type KubbHookStartContext = {
2454
2439
  */
2455
2440
  args?: ReadonlyArray<string>;
2456
2441
  };
2442
+ /**
2443
+ * Emitted for each line streamed from a hook's stdout while it runs.
2444
+ * A logger correlates the line to its active UI element via `id`.
2445
+ */
2446
+ type KubbHookLineContext = {
2447
+ /**
2448
+ * Identifier matching the corresponding `kubb:hook:start` event.
2449
+ */
2450
+ id: string;
2451
+ /**
2452
+ * A single streamed stdout line, without its trailing newline.
2453
+ */
2454
+ line: string;
2455
+ };
2457
2456
  type KubbHookEndContext = {
2458
2457
  /**
2459
2458
  * Optional identifier matching the corresponding `kubb:hook:start` event.
@@ -2475,6 +2474,14 @@ type KubbHookEndContext = {
2475
2474
  * Error thrown by the command, or `null` on success.
2476
2475
  */
2477
2476
  error: Error | null;
2477
+ /**
2478
+ * Captured stdout from the process, populated when it exits non-zero.
2479
+ */
2480
+ stdout?: string;
2481
+ /**
2482
+ * Captured stderr from the process, populated when it exits non-zero.
2483
+ */
2484
+ stderr?: string;
2478
2485
  };
2479
2486
  /**
2480
2487
  * CLI options derived from command-line flags.
@@ -2959,5 +2966,5 @@ declare class Diagnostics {
2959
2966
  static formatLines(diagnostic: Diagnostic): Array<string>;
2960
2967
  }
2961
2968
  //#endregion
2962
- export { Override as $, KubbHookEndContext as A, logLevel as At, createKubb as B, AsyncEventEmitter as Bt, KubbErrorContext as C, createReporter as Ct, KubbFilesProcessingUpdateContext as D, LoggerOptions as Dt, KubbFilesProcessingStartContext as E, LoggerContext as Et, KubbPluginsEndContext as F, createStorage as Ft, Exclude$1 as G, GeneratorContext as H, KubbSuccessContext as I, Adapter as It, KubbPluginEndContext as J, Group as K, KubbWarnContext as L, AdapterFactoryOptions as Lt, KubbHooks as M, RendererFactory as Mt, KubbInfoContext as N, createRenderer as Nt, KubbGenerationEndContext as O, UserLogger as Ot, KubbLifecycleStartContext as P, Storage as Pt, Output as Q, PossibleConfig as R, AdapterSource as Rt, KubbDiagnosticContext as S, UserReporter as St, KubbFilesProcessingEndContext as T, Logger as Tt, defineGenerator as U, Generator$1 as V, KubbDriver as W, KubbPluginStartContext as X, KubbPluginSetupContext as Y, NormalizedPlugin as Z, InputPath as _, defineParser as _t, DiagnosticLocation as a, ResolveBannerFile as at, KubbBuildStartContext as b, ReporterContext as bt, PerformanceDiagnostic as c, ResolverContext as ct, SerializedDiagnostic as d, defineResolver as dt, Plugin as et, UpdateDiagnostic as f, Middleware as ft, InputData as g, Parser as gt, Config as h, ParsedFile as ht, DiagnosticKind as i, ResolveBannerContext as it, KubbHookStartContext as j, Renderer as jt, KubbGenerationStartContext as k, defineLogger as kt, ProblemCode as l, ResolverFileParams as lt, CLIOptions as m, FileProcessorHooks as mt, DiagnosticByCode as n, definePlugin as nt, DiagnosticSeverity as o, ResolveOptionsContext as ot, BuildOutput as p, defineMiddleware as pt, Include as q, DiagnosticDoc as r, BannerMeta as rt, Diagnostics as s, Resolver as st, Diagnostic as t, PluginFactoryOptions as tt, ProblemDiagnostic as u, ResolverPathParams as ut, Kubb$1 as v, GenerationResult as vt, KubbFileProcessingUpdate as w, selectReporters as wt, KubbConfigEndContext as x, ReporterName as xt, KubbBuildEndContext as y, Reporter as yt, UserConfig as z, createAdapter as zt };
2963
- //# sourceMappingURL=diagnostics-DhfW8YpT.d.ts.map
2969
+ export { Output as $, KubbHookEndContext as A, defineLogger as At, UserConfig as B, createAdapter as Bt, KubbErrorContext as C, UserReporter as Ct, KubbFilesProcessingUpdateContext as D, LoggerContext as Dt, KubbFilesProcessingStartContext as E, Logger as Et, KubbLifecycleStartContext as F, Storage as Ft, KubbDriver as G, Generator$1 as H, KubbPluginsEndContext as I, createStorage as It, Include as J, Exclude$1 as K, KubbSuccessContext as L, Adapter as Lt, KubbHookStartContext as M, Renderer as Mt, KubbHooks as N, RendererFactory as Nt, KubbGenerationEndContext as O, LoggerOptions as Ot, KubbInfoContext as P, createRenderer as Pt, NormalizedPlugin as Q, KubbWarnContext as R, AdapterFactoryOptions as Rt, KubbDiagnosticContext as S, ReporterName as St, KubbFilesProcessingEndContext as T, selectReporters as Tt, GeneratorContext as U, createKubb as V, AsyncEventEmitter as Vt, defineGenerator as W, KubbPluginSetupContext as X, KubbPluginEndContext as Y, KubbPluginStartContext as Z, InputPath as _, Parser as _t, DiagnosticLocation as a, ResolveBannerContext as at, KubbBuildStartContext as b, Reporter as bt, PerformanceDiagnostic as c, Resolver as ct, SerializedDiagnostic as d, ResolverPathParams as dt, Override as et, UpdateDiagnostic as f, defineResolver as ft, InputData as g, ParsedFile as gt, Config as h, FileProcessorHooks as ht, DiagnosticKind as i, BannerMeta as it, KubbHookLineContext as j, logLevel as jt, KubbGenerationStartContext as k, UserLogger as kt, ProblemCode as l, ResolverContext as lt, CLIOptions as m, defineMiddleware as mt, DiagnosticByCode as n, PluginFactoryOptions as nt, DiagnosticSeverity as o, ResolveBannerFile as ot, BuildOutput as p, Middleware as pt, Group as q, DiagnosticDoc as r, definePlugin as rt, Diagnostics as s, ResolveOptionsContext as st, Diagnostic as t, Plugin as tt, ProblemDiagnostic as u, ResolverFileParams as ut, Kubb$1 as v, defineParser as vt, KubbFileProcessingUpdate as w, createReporter as wt, KubbConfigEndContext as x, ReporterContext as xt, KubbBuildEndContext as y, GenerationResult as yt, PossibleConfig as z, AdapterSource as zt };
2970
+ //# sourceMappingURL=diagnostics-Ba-FcsPo.d.ts.map
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_memoryStorage = require("./memoryStorage-Dkxnid2K.cjs");
2
+ const require_memoryStorage = require("./memoryStorage-DZqlEW7H.cjs");
3
3
  let node_util = require("node:util");
4
4
  let node_crypto = require("node:crypto");
5
5
  let node_fs_promises = require("node:fs/promises");
@@ -531,11 +531,10 @@ const logLevel = {
531
531
  verbose: 4
532
532
  };
533
533
  /**
534
- * Defines a typed logger. Use the second type parameter to declare a return
535
- * value from `install`, which is handy when the logger exposes a sink factory
536
- * or cleanup callback to the caller.
534
+ * Defines a typed logger. The `install` method subscribes to lifecycle events
535
+ * on the shared emitter and forwards them to the logger's destination.
537
536
  *
538
- * @example Basic logger
537
+ * @example
539
538
  * ```ts
540
539
  * import { defineLogger } from '@kubb/core'
541
540
  *
@@ -547,20 +546,6 @@ const logLevel = {
547
546
  * },
548
547
  * })
549
548
  * ```
550
- *
551
- * @example Logger that returns a hook sink factory
552
- * ```ts
553
- * import { defineLogger, type LoggerOptions } from '@kubb/core'
554
- * import type { HookSinkFactory } from './sinks'
555
- *
556
- * export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({
557
- * name: 'my-logger',
558
- * install(context) {
559
- * // … register event handlers …
560
- * return () => ({ onStdout: console.log })
561
- * },
562
- * })
563
- * ```
564
549
  */
565
550
  function defineLogger(logger) {
566
551
  return logger;