@kubb/core
Advanced tools
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
+4
-19
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
| const require_memoryStorage = require("./memoryStorage-Dkxnid2K.cjs"); | ||
| const require_memoryStorage = require("./memoryStorage-DZqlEW7H.cjs"); | ||
| let node_util = require("node:util"); | ||
@@ -534,7 +534,6 @@ let node_crypto = require("node:crypto"); | ||
| /** | ||
| * Defines a typed logger. Use the second type parameter to declare a return | ||
| * value from `install`, which is handy when the logger exposes a sink factory | ||
| * or cleanup callback to the caller. | ||
| * Defines a typed logger. The `install` method subscribes to lifecycle events | ||
| * on the shared emitter and forwards them to the logger's destination. | ||
| * | ||
| * @example Basic logger | ||
| * @example | ||
| * ```ts | ||
@@ -551,16 +550,2 @@ * import { defineLogger } from '@kubb/core' | ||
| * ``` | ||
| * | ||
| * @example Logger that returns a hook sink factory | ||
| * ```ts | ||
| * import { defineLogger, type LoggerOptions } from '@kubb/core' | ||
| * import type { HookSinkFactory } from './sinks' | ||
| * | ||
| * export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({ | ||
| * name: 'my-logger', | ||
| * install(context) { | ||
| * // … register event handlers … | ||
| * return () => ({ onStdout: console.log }) | ||
| * }, | ||
| * }) | ||
| * ``` | ||
| */ | ||
@@ -567,0 +552,0 @@ function defineLogger(logger) { |
+2
-2
| import { t as __name } from "./chunk-C0LytTxp.js"; | ||
| import { $ as Override, A as KubbHookEndContext, At as logLevel, B as createKubb, Bt as AsyncEventEmitter, C as KubbErrorContext, Ct as createReporter, D as KubbFilesProcessingUpdateContext, Dt as LoggerOptions, E as KubbFilesProcessingStartContext, Et as LoggerContext, F as KubbPluginsEndContext, Ft as createStorage, G as Exclude, H as GeneratorContext, I as KubbSuccessContext, It as Adapter, J as KubbPluginEndContext, K as Group, L as KubbWarnContext, Lt as AdapterFactoryOptions, M as KubbHooks, Mt as RendererFactory, N as KubbInfoContext, Nt as createRenderer, O as KubbGenerationEndContext, Ot as UserLogger, P as KubbLifecycleStartContext, Pt as Storage, Q as Output, R as PossibleConfig, Rt as AdapterSource, S as KubbDiagnosticContext, St as UserReporter, T as KubbFilesProcessingEndContext, Tt as Logger, U as defineGenerator, V as Generator, W as KubbDriver, X as KubbPluginStartContext, Y as KubbPluginSetupContext, Z as NormalizedPlugin, _ as InputPath, _t as defineParser, a as DiagnosticLocation, at as ResolveBannerFile, b as KubbBuildStartContext, bt as ReporterContext, c as PerformanceDiagnostic, ct as ResolverContext, d as SerializedDiagnostic, dt as defineResolver, et as Plugin, f as UpdateDiagnostic, ft as Middleware, g as InputData, gt as Parser, h as Config, ht as ParsedFile, i as DiagnosticKind, it as ResolveBannerContext, j as KubbHookStartContext, jt as Renderer, k as KubbGenerationStartContext, kt as defineLogger, l as ProblemCode, lt as ResolverFileParams, m as CLIOptions, mt as FileProcessorHooks, n as DiagnosticByCode, nt as definePlugin, o as DiagnosticSeverity, ot as ResolveOptionsContext, p as BuildOutput, pt as defineMiddleware, q as Include, r as DiagnosticDoc, rt as BannerMeta, s as Diagnostics, st as Resolver, t as Diagnostic, tt as PluginFactoryOptions, u as ProblemDiagnostic, ut as ResolverPathParams, v as Kubb, vt as GenerationResult, w as KubbFileProcessingUpdate, wt as selectReporters, x as KubbConfigEndContext, xt as ReporterName, y as KubbBuildEndContext, yt as Reporter, z as UserConfig, zt as createAdapter } from "./diagnostics-DhfW8YpT.js"; | ||
| import { $ as Output, A as KubbHookEndContext, At as defineLogger, B as UserConfig, Bt as createAdapter, C as KubbErrorContext, Ct as UserReporter, D as KubbFilesProcessingUpdateContext, Dt as LoggerContext, E as KubbFilesProcessingStartContext, Et as Logger, F as KubbLifecycleStartContext, Ft as Storage, G as KubbDriver, H as Generator, I as KubbPluginsEndContext, It as createStorage, J as Include, K as Exclude, L as KubbSuccessContext, Lt as Adapter, M as KubbHookStartContext, Mt as Renderer, N as KubbHooks, Nt as RendererFactory, O as KubbGenerationEndContext, Ot as LoggerOptions, P as KubbInfoContext, Pt as createRenderer, Q as NormalizedPlugin, R as KubbWarnContext, Rt as AdapterFactoryOptions, S as KubbDiagnosticContext, St as ReporterName, T as KubbFilesProcessingEndContext, Tt as selectReporters, U as GeneratorContext, V as createKubb, Vt as AsyncEventEmitter, W as defineGenerator, X as KubbPluginSetupContext, Y as KubbPluginEndContext, Z as KubbPluginStartContext, _ as InputPath, _t as Parser, a as DiagnosticLocation, at as ResolveBannerContext, b as KubbBuildStartContext, bt as Reporter, c as PerformanceDiagnostic, ct as Resolver, d as SerializedDiagnostic, dt as ResolverPathParams, et as Override, f as UpdateDiagnostic, ft as defineResolver, g as InputData, gt as ParsedFile, h as Config, ht as FileProcessorHooks, i as DiagnosticKind, it as BannerMeta, j as KubbHookLineContext, jt as logLevel, k as KubbGenerationStartContext, kt as UserLogger, l as ProblemCode, lt as ResolverContext, m as CLIOptions, mt as defineMiddleware, n as DiagnosticByCode, nt as PluginFactoryOptions, o as DiagnosticSeverity, ot as ResolveBannerFile, p as BuildOutput, pt as Middleware, q as Group, r as DiagnosticDoc, rt as definePlugin, s as Diagnostics, st as ResolveOptionsContext, t as Diagnostic, tt as Plugin, u as ProblemDiagnostic, ut as ResolverFileParams, v as Kubb, vt as defineParser, w as KubbFileProcessingUpdate, wt as createReporter, x as KubbConfigEndContext, xt as ReporterContext, y as KubbBuildEndContext, yt as GenerationResult, z as PossibleConfig, zt as AdapterSource } from "./diagnostics-Ba-FcsPo.js"; | ||
| import * as ast from "@kubb/ast"; | ||
@@ -372,3 +372,3 @@ | ||
| //#endregion | ||
| export { type Adapter, type AdapterFactoryOptions, type AdapterSource, AsyncEventEmitter, type BannerMeta, type BuildOutput, type CLIOptions, type Config, type Diagnostic, type DiagnosticByCode, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileProcessorHooks, type GenerationResult, type Generator, type GeneratorContext, type Group, type Include, type InputData, type InputPath, type Kubb, type KubbBuildEndContext, type KubbBuildStartContext, type KubbConfigEndContext, type KubbDiagnosticContext, KubbDriver, type KubbErrorContext, type KubbFileProcessingUpdate, type KubbFilesProcessingEndContext, type KubbFilesProcessingStartContext, type KubbFilesProcessingUpdateContext, type KubbGenerationEndContext, type KubbGenerationStartContext, type KubbHookEndContext, type KubbHookStartContext, type KubbHooks, type KubbInfoContext, type KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type KubbPluginsEndContext, type KubbSuccessContext, type KubbWarnContext, type Logger, type LoggerContext, type LoggerOptions, type Middleware, type NormalizedPlugin, type Output, type Override, type ParsedFile, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PossibleConfig, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type SerializedDiagnostic, type Storage, Telemetry, URLPath, type UpdateDiagnostic, type UserConfig, type UserLogger, type UserReporter, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineLogger, defineMiddleware, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage, selectReporters }; | ||
| export { type Adapter, type AdapterFactoryOptions, type AdapterSource, AsyncEventEmitter, type BannerMeta, type BuildOutput, type CLIOptions, type Config, type Diagnostic, type DiagnosticByCode, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileProcessorHooks, type GenerationResult, type Generator, type GeneratorContext, type Group, type Include, type InputData, type InputPath, type Kubb, type KubbBuildEndContext, type KubbBuildStartContext, type KubbConfigEndContext, type KubbDiagnosticContext, KubbDriver, type KubbErrorContext, type KubbFileProcessingUpdate, type KubbFilesProcessingEndContext, type KubbFilesProcessingStartContext, type KubbFilesProcessingUpdateContext, type KubbGenerationEndContext, type KubbGenerationStartContext, type KubbHookEndContext, type KubbHookLineContext, type KubbHookStartContext, type KubbHooks, type KubbInfoContext, type KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type KubbPluginsEndContext, type KubbSuccessContext, type KubbWarnContext, type Logger, type LoggerContext, type LoggerOptions, type Middleware, type NormalizedPlugin, type Output, type Override, type ParsedFile, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PossibleConfig, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type SerializedDiagnostic, type Storage, Telemetry, URLPath, type UpdateDiagnostic, type UserConfig, type UserLogger, type UserReporter, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineLogger, defineMiddleware, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage, selectReporters }; | ||
| //# sourceMappingURL=index.d.ts.map |
+4
-19
| import "./chunk-C0LytTxp.js"; | ||
| import { c as createStorage, d as URLPath, f as formatMs, g as BuildError, h as AsyncEventEmitter, l as Diagnostics, n as KubbDriver, o as defineResolver, p as getElapsedMs, r as _usingCtx, s as definePlugin, t as memoryStorage, u as OTLP_ENDPOINT } from "./memoryStorage-DTv1Kub1.js"; | ||
| import { c as createStorage, d as URLPath, f as formatMs, g as BuildError, h as AsyncEventEmitter, l as Diagnostics, n as KubbDriver, o as defineResolver, p as getElapsedMs, r as _usingCtx, s as definePlugin, t as memoryStorage, u as OTLP_ENDPOINT } from "./memoryStorage-DA1bnMte.js"; | ||
| import { stripVTControlCharacters, styleText } from "node:util"; | ||
@@ -531,7 +531,6 @@ import { createHash, randomBytes } from "node:crypto"; | ||
| /** | ||
| * Defines a typed logger. Use the second type parameter to declare a return | ||
| * value from `install`, which is handy when the logger exposes a sink factory | ||
| * or cleanup callback to the caller. | ||
| * Defines a typed logger. The `install` method subscribes to lifecycle events | ||
| * on the shared emitter and forwards them to the logger's destination. | ||
| * | ||
| * @example Basic logger | ||
| * @example | ||
| * ```ts | ||
@@ -548,16 +547,2 @@ * import { defineLogger } from '@kubb/core' | ||
| * ``` | ||
| * | ||
| * @example Logger that returns a hook sink factory | ||
| * ```ts | ||
| * import { defineLogger, type LoggerOptions } from '@kubb/core' | ||
| * import type { HookSinkFactory } from './sinks' | ||
| * | ||
| * export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({ | ||
| * name: 'my-logger', | ||
| * install(context) { | ||
| * // … register event handlers … | ||
| * return () => ({ onStdout: console.log }) | ||
| * }, | ||
| * }) | ||
| * ``` | ||
| */ | ||
@@ -564,0 +549,0 @@ function defineLogger(logger) { |
+1
-1
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
| const require_memoryStorage = require("./memoryStorage-Dkxnid2K.cjs"); | ||
| const require_memoryStorage = require("./memoryStorage-DZqlEW7H.cjs"); | ||
| let node_path = require("node:path"); | ||
@@ -4,0 +4,0 @@ node_path = require_memoryStorage.__toESM(node_path, 1); |
+1
-1
| import { t as __name } from "./chunk-C0LytTxp.js"; | ||
| import { It as Adapter, Lt as AdapterFactoryOptions, V as Generator, W as KubbDriver, Z as NormalizedPlugin, gt as Parser, h as Config, tt as PluginFactoryOptions } from "./diagnostics-DhfW8YpT.js"; | ||
| import { G as KubbDriver, H as Generator, Lt as Adapter, Q as NormalizedPlugin, Rt as AdapterFactoryOptions, _t as Parser, h as Config, nt as PluginFactoryOptions } from "./diagnostics-Ba-FcsPo.js"; | ||
| import { FileNode, InputMeta, OperationNode, SchemaNode, Visitor } from "@kubb/ast"; | ||
@@ -4,0 +4,0 @@ |
+1
-1
| import "./chunk-C0LytTxp.js"; | ||
| import { a as FileManager, i as FileProcessor, m as camelCase, n as KubbDriver, r as _usingCtx, t as memoryStorage } from "./memoryStorage-DTv1Kub1.js"; | ||
| import { a as FileManager, i as FileProcessor, m as camelCase, n as KubbDriver, r as _usingCtx, t as memoryStorage } from "./memoryStorage-DA1bnMte.js"; | ||
| import path, { resolve } from "node:path"; | ||
@@ -4,0 +4,0 @@ import { transform } from "@kubb/ast"; |
+4
-4
| { | ||
| "name": "@kubb/core", | ||
| "version": "5.0.0-beta.40", | ||
| "version": "5.0.0-beta.41", | ||
| "description": "Core engine for Kubb's plugin-based code generation system. Provides the plugin driver, file manager, defineConfig, and build orchestration used by every Kubb plugin.", | ||
@@ -61,10 +61,10 @@ "keywords": [ | ||
| "tinyexec": "~1.1.2", | ||
| "@kubb/ast": "5.0.0-beta.40" | ||
| "@kubb/ast": "5.0.0-beta.41" | ||
| }, | ||
| "devDependencies": { | ||
| "@internals/utils": "0.0.0", | ||
| "@kubb/renderer-jsx": "5.0.0-beta.40" | ||
| "@kubb/renderer-jsx": "5.0.0-beta.41" | ||
| }, | ||
| "peerDependencies": { | ||
| "@kubb/renderer-jsx": "5.0.0-beta.40" | ||
| "@kubb/renderer-jsx": "5.0.0-beta.41" | ||
| }, | ||
@@ -71,0 +71,0 @@ "size-limit": [ |
+13
-13
@@ -8,5 +8,5 @@ <div align="center"> | ||
| [![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
| [![Coverage][coverage-src]][coverage-href] | ||
| [![Stars][stars-src]][stars-href] | ||
| [![License][license-src]][license-href] | ||
| [![Sponsors][sponsors-src]][sponsors-href] | ||
| [![Node][node-src]][node-href] | ||
@@ -30,3 +30,3 @@ <h4> | ||
| > **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. | ||
| > **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. | ||
@@ -62,11 +62,11 @@ ## Installation | ||
| [npm-version-src]: https://img.shields.io/npm/v/@kubb/core?flat&colorA=18181B&colorB=f58517 | ||
| [npm-version-href]: https://npmjs.com/package/@kubb/core | ||
| [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/core?flat&colorA=18181B&colorB=f58517 | ||
| [npm-downloads-href]: https://npmjs.com/package/@kubb/core | ||
| [license-src]: https://img.shields.io/npm/l/%40kubb%2Fcore?flat&colorA=18181B&colorB=f58517 | ||
| [license-href]: https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT | ||
| [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517 | ||
| [coverage-href]: https://www.npmjs.com/package/@kubb/core | ||
| [sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517 | ||
| [sponsors-href]: https://github.com/sponsors/stijnvanhulle/ | ||
| [npm-version-src]: https://shieldcn.dev/npm/v/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark | ||
| [npm-version-href]: https://npmx.dev/package/@kubb/core | ||
| [npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark | ||
| [npm-downloads-href]: https://npmx.dev/package/@kubb/core | ||
| [stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark | ||
| [stars-href]: https://github.com/kubb-labs/kubb | ||
| [license-src]: https://shieldcn.dev/npm/license/@kubb/core.svg?variant=secondary&size=xs&theme=zinc | ||
| [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE | ||
| [node-src]: https://shieldcn.dev/npm/node/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark | ||
| [node-href]: https://npmx.dev/package/@kubb/core |
+24
-0
@@ -467,2 +467,3 @@ import { resolve } from 'node:path' | ||
| 'kubb:hook:start': [ctx: KubbHookStartContext] | ||
| 'kubb:hook:line': [ctx: KubbHookLineContext] | ||
| 'kubb:hook:end': [ctx: KubbHookEndContext] | ||
@@ -722,2 +723,17 @@ 'kubb:info': [ctx: KubbInfoContext] | ||
| /** | ||
| * Emitted for each line streamed from a hook's stdout while it runs. | ||
| * A logger correlates the line to its active UI element via `id`. | ||
| */ | ||
| export type KubbHookLineContext = { | ||
| /** | ||
| * Identifier matching the corresponding `kubb:hook:start` event. | ||
| */ | ||
| id: string | ||
| /** | ||
| * A single streamed stdout line, without its trailing newline. | ||
| */ | ||
| line: string | ||
| } | ||
| export type KubbHookEndContext = { | ||
@@ -744,2 +760,10 @@ /** | ||
| error: Error | null | ||
| /** | ||
| * Captured stdout from the process, populated when it exits non-zero. | ||
| */ | ||
| stdout?: string | ||
| /** | ||
| * Captured stderr from the process, populated when it exits non-zero. | ||
| */ | ||
| stderr?: string | ||
| } | ||
@@ -746,0 +770,0 @@ |
+10
-28
@@ -37,5 +37,5 @@ import type { AsyncEventEmitter } from '@internals/utils' | ||
| * to whichever lifecycle events it wants to forward to its destination | ||
| * (console, file, remote sink). | ||
| * (console, file, remote service). | ||
| */ | ||
| export type Logger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = { | ||
| export type Logger<TOptions extends LoggerOptions = LoggerOptions> = { | ||
| /** | ||
@@ -46,17 +46,15 @@ * Display name used in diagnostics. | ||
| /** | ||
| * Called once per build with the shared event emitter. Subscribe to events | ||
| * here. The return value (if any) is forwarded to whoever installed the | ||
| * logger, which is handy for sink factories. | ||
| * Called once per build with the shared event emitter. Subscribe to the | ||
| * lifecycle events the logger wants to forward to its destination. | ||
| */ | ||
| install: (context: LoggerContext, options?: TOptions) => TInstallReturn | Promise<TInstallReturn> | ||
| install: (context: LoggerContext, options?: TOptions) => void | Promise<void> | ||
| } | ||
| export type UserLogger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = Logger<TOptions, TInstallReturn> | ||
| export type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<TOptions> | ||
| /** | ||
| * Defines a typed logger. Use the second type parameter to declare a return | ||
| * value from `install`, which is handy when the logger exposes a sink factory | ||
| * or cleanup callback to the caller. | ||
| * Defines a typed logger. The `install` method subscribes to lifecycle events | ||
| * on the shared emitter and forwards them to the logger's destination. | ||
| * | ||
| * @example Basic logger | ||
| * @example | ||
| * ```ts | ||
@@ -73,21 +71,5 @@ * import { defineLogger } from '@kubb/core' | ||
| * ``` | ||
| * | ||
| * @example Logger that returns a hook sink factory | ||
| * ```ts | ||
| * import { defineLogger, type LoggerOptions } from '@kubb/core' | ||
| * import type { HookSinkFactory } from './sinks' | ||
| * | ||
| * export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({ | ||
| * name: 'my-logger', | ||
| * install(context) { | ||
| * // … register event handlers … | ||
| * return () => ({ onStdout: console.log }) | ||
| * }, | ||
| * }) | ||
| * ``` | ||
| */ | ||
| export function defineLogger<Options extends LoggerOptions = LoggerOptions, TInstallReturn = void>( | ||
| logger: UserLogger<Options, TInstallReturn>, | ||
| ): Logger<Options, TInstallReturn> { | ||
| export function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options> { | ||
| return logger | ||
| } |
+37
-28
@@ -476,2 +476,7 @@ import { resolve } from 'node:path' | ||
| * | ||
| * Plugins run sequentially so `kubb:plugin:end` fires as each plugin completes, instead | ||
| * of all at once after every plugin has marched through the parallel batches together. | ||
| * That ordering is what drives the CLI's `Plugins N/M` counter; without it the bar would | ||
| * sit at the initial value until the very end of the run. | ||
| * | ||
| * When `entries` is empty or `this.inputNode` is `null`, every entry still gets a | ||
@@ -530,7 +535,15 @@ * `kubb:plugin:end` so middleware listeners (the barrel writer and friends) complete. | ||
| const emitsOperationHook = this.hooks.listenerCount('kubb:generate:operation') > 0 | ||
| const emitsOperationsHook = this.hooks.listenerCount('kubb:generate:operations') > 0 | ||
| // Buffer the streaming adapter's nodes once. Each plugin reads the same buffer | ||
| // instead of re-parsing the document per pass, and the pruning pre-scan below | ||
| // shares it too (previously it iterated its own copies). | ||
| const schemasBuffer: Array<SchemaNode> = [] | ||
| for await (const schema of schemas) schemasBuffer.push(schema) | ||
| const operationsBuffer: Array<OperationNode> = [] | ||
| for await (const operation of operations) operationsBuffer.push(operation) | ||
| // Pre-scan: plugins with operation-based includes (but no schemaName include) need | ||
| // the reachable schema set. This requires the full schema graph in memory at once, | ||
| // since transitive reachability can't be derived from a single node. `allSchemas` is | ||
| // released as soon as the pre-scan returns, so the main passes get fresh iterators. | ||
| // since transitive reachability can't be derived from a single node. | ||
| const pruningStates = states.filter(({ plugin }) => { | ||
@@ -542,7 +555,4 @@ const { include } = plugin.options | ||
| if (pruningStates.length > 0) { | ||
| const allSchemas: Array<SchemaNode> = [] | ||
| for await (const schema of schemas) allSchemas.push(schema) | ||
| const includedOpsByState = new Map<PluginState, Array<OperationNode>>(pruningStates.map((state) => [state, []])) | ||
| for await (const operation of operations) { | ||
| for (const operation of operationsBuffer) { | ||
| for (const state of pruningStates) { | ||
@@ -556,3 +566,3 @@ const { exclude, include, override } = state.plugin.options | ||
| for (const state of pruningStates) { | ||
| state.allowedSchemaNames = collectUsedSchemaNames(includedOpsByState.get(state) ?? [], allSchemas) | ||
| state.allowedSchemaNames = collectUsedSchemaNames(includedOpsByState.get(state) ?? [], schemasBuffer) | ||
| includedOpsByState.delete(state) | ||
@@ -635,26 +645,25 @@ } | ||
| // Skip building the aggregated operations array when nothing consumes it. Saves an | ||
| // N-sized allocation on the common path where plugins only define per-node `gen.operation`. | ||
| const needsCollectedOperations = | ||
| this.hooks.listenerCount('kubb:generate:operations') > 0 || states.some((state) => state.generators.some((gen) => !!gen.operations)) | ||
| const collectedOperations: Array<OperationNode> | undefined = needsCollectedOperations ? [] : undefined | ||
| for (const state of states) { | ||
| // Skip building the aggregated operations array when this plugin doesn't consume it. | ||
| // Saves an N-sized allocation when the plugin only defines per-node `gen.operation`. | ||
| const needsCollectedOperations = emitsOperationsHook || state.generators.some((gen) => !!gen.operations) | ||
| const collectedOperations: Array<OperationNode> | undefined = needsCollectedOperations ? [] : undefined | ||
| // Run schemas before operations: the two passes share `flushPending` and the | ||
| // FileProcessor's event emitter, so running them concurrently would interleave | ||
| // `kubb:files:processing:start|end` events and race on the shared dirty list. | ||
| await forBatches(schemas, (nodes) => Promise.all(nodes.flatMap((node) => states.map((state) => dispatchNode(state, node, schemaDispatch)))), { | ||
| concurrency: SCHEMA_PARALLEL, | ||
| flush: flushPending, | ||
| }) | ||
| // Run schemas before operations: the two passes share `flushPending` and the | ||
| // FileProcessor's event emitter, so running them concurrently would interleave | ||
| // `kubb:files:processing:start|end` events and race on the shared dirty list. | ||
| await forBatches(schemasBuffer, (nodes) => Promise.all(nodes.map((node) => dispatchNode(state, node, schemaDispatch))), { | ||
| concurrency: SCHEMA_PARALLEL, | ||
| flush: flushPending, | ||
| }) | ||
| await forBatches( | ||
| operations, | ||
| (nodes) => { | ||
| if (needsCollectedOperations) collectedOperations?.push(...nodes) | ||
| return Promise.all(nodes.flatMap((node) => states.map((state) => dispatchNode(state, node, operationDispatch)))) | ||
| }, | ||
| { concurrency: SCHEMA_PARALLEL, flush: flushPending }, | ||
| ) | ||
| await forBatches( | ||
| operationsBuffer, | ||
| (nodes) => { | ||
| if (needsCollectedOperations) collectedOperations?.push(...nodes) | ||
| return Promise.all(nodes.map((node) => dispatchNode(state, node, operationDispatch))) | ||
| }, | ||
| { concurrency: SCHEMA_PARALLEL, flush: flushPending }, | ||
| ) | ||
| for (const state of states) { | ||
| if (!state.failed && needsCollectedOperations) { | ||
@@ -661,0 +670,0 @@ try { |
+1
-0
@@ -34,2 +34,3 @@ export type { Adapter, AdapterFactoryOptions, AdapterSource } from './createAdapter.ts' | ||
| KubbHookEndContext, | ||
| KubbHookLineContext, | ||
| KubbHookStartContext, | ||
@@ -36,0 +37,0 @@ KubbHooks, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
1216757
0.1%17509
0.05%25
-3.85%4
33.33%+ Added
+ Added
- Removed
- Removed
Updated