@kubb/core 5.3.4 → 5.3.6
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 +6 -0
- package/dist/index.cjs +33 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -12
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{types-DIHOpbmO.d.ts → types-Cw20YGzh.d.ts} +30 -8
- package/dist/{usingCtx-BfeNtY1B.js → usingCtx-BoFplz1D.js} +5 -2
- package/dist/{usingCtx-BfeNtY1B.js.map → usingCtx-BoFplz1D.js.map} +1 -1
- package/dist/{usingCtx-CBWq26N5.cjs → usingCtx-DOy3BJPz.cjs} +5 -2
- package/dist/{usingCtx-CBWq26N5.cjs.map → usingCtx-DOy3BJPz.cjs.map} +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,6 +38,12 @@ pnpm add @kubb/core
|
|
|
38
38
|
npm install @kubb/core
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
## Cancellation
|
|
42
|
+
|
|
43
|
+
`createKubb` accepts an `AbortSignal`. The engine checks it before setup, while it parses input and
|
|
44
|
+
normalizes plugins, and before each generated-file write. Plugin authors receive the same signal in
|
|
45
|
+
their generator context when they need to stop their own asynchronous work.
|
|
46
|
+
|
|
41
47
|
## Supporting Kubb
|
|
42
48
|
|
|
43
49
|
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_usingCtx = require("./usingCtx-
|
|
2
|
+
const require_usingCtx = require("./usingCtx-DOy3BJPz.cjs");
|
|
3
3
|
let node_async_hooks = require("node:async_hooks");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_process = require("node:process");
|
|
@@ -127,7 +127,7 @@ function formatMs(ms) {
|
|
|
127
127
|
/**
|
|
128
128
|
* Docs major version, derived from the package version so the link tracks the published major.
|
|
129
129
|
*/
|
|
130
|
-
const docsMajor = "5.3.
|
|
130
|
+
const docsMajor = "5.3.6".split(".")[0] ?? "5";
|
|
131
131
|
/**
|
|
132
132
|
* Builds a type guard that narrows a {@link Diagnostic} to the variant for `kind`. A diagnostic
|
|
133
133
|
* with no `kind` is treated as a `problem`.
|
|
@@ -459,9 +459,15 @@ var Diagnostics = class Diagnostics {
|
|
|
459
459
|
let infos = 0;
|
|
460
460
|
for (const diagnostic of diagnostics) {
|
|
461
461
|
if (!isProblem(diagnostic)) continue;
|
|
462
|
-
if (diagnostic.severity === "error")
|
|
463
|
-
|
|
464
|
-
|
|
462
|
+
if (diagnostic.severity === "error") {
|
|
463
|
+
errors += 1;
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (diagnostic.severity === "warning") {
|
|
467
|
+
warnings += 1;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
infos += 1;
|
|
465
471
|
}
|
|
466
472
|
return {
|
|
467
473
|
errors,
|
|
@@ -1025,9 +1031,7 @@ var Resolver = class Resolver {
|
|
|
1025
1031
|
];
|
|
1026
1032
|
if (config.output.defaultBanner !== "simple") {
|
|
1027
1033
|
const input = config.input;
|
|
1028
|
-
|
|
1029
|
-
if (typeof input === "string") source = getInputKind(input) === "inline" ? "text content" : node_path.default.basename(input);
|
|
1030
|
-
else if (input) source = "text content";
|
|
1034
|
+
const source = typeof input === "string" ? getInputKind(input) === "inline" ? "text content" : node_path.default.basename(input) : input ? "text content" : "";
|
|
1031
1035
|
if (source) lines.push(`* Source: ${source}`);
|
|
1032
1036
|
if (title) lines.push(`* Title: ${title}`);
|
|
1033
1037
|
if (version) lines.push(`* OpenAPI spec version: ${version}`);
|
|
@@ -1258,6 +1262,7 @@ var KubbDriver = class {
|
|
|
1258
1262
|
* so `run` can parse it later.
|
|
1259
1263
|
*/
|
|
1260
1264
|
async setup() {
|
|
1265
|
+
this.options.signal?.throwIfAborted();
|
|
1261
1266
|
const normalized = this.#sortPlugins(this.config.plugins.map((rawPlugin) => {
|
|
1262
1267
|
return {
|
|
1263
1268
|
name: rawPlugin.name,
|
|
@@ -1312,7 +1317,8 @@ var KubbDriver = class {
|
|
|
1312
1317
|
*/
|
|
1313
1318
|
async #parseInput() {
|
|
1314
1319
|
if (this.inputNode || !this.adapter || !this.#adapterSource) return;
|
|
1315
|
-
this.
|
|
1320
|
+
this.options.signal?.throwIfAborted();
|
|
1321
|
+
this.inputNode = await this.adapter.parse(this.#adapterSource, { signal: this.options.signal });
|
|
1316
1322
|
}
|
|
1317
1323
|
/**
|
|
1318
1324
|
* Registers a plugin's lifecycle hooks on the shared `Hookable` as pass-through listeners that
|
|
@@ -1433,10 +1439,14 @@ var KubbDriver = class {
|
|
|
1433
1439
|
});
|
|
1434
1440
|
return Diagnostics.scope((diagnostic) => diagnostics.push(diagnostic), async () => {
|
|
1435
1441
|
try {
|
|
1442
|
+
this.options.signal?.throwIfAborted();
|
|
1436
1443
|
const outputRoot = (0, node_path.resolve)(config.root, config.output.path);
|
|
1437
1444
|
await this.#parseInput();
|
|
1438
1445
|
await this.setupHooks();
|
|
1439
|
-
for (const plugin of this.plugins.values())
|
|
1446
|
+
for (const plugin of this.plugins.values()) {
|
|
1447
|
+
this.options.signal?.throwIfAborted();
|
|
1448
|
+
plugin.options = normalizePluginOptions(plugin.options, plugin.name);
|
|
1449
|
+
}
|
|
1440
1450
|
if (this.adapter && this.inputNode) {
|
|
1441
1451
|
const buildStartContext = this.#withFiles({
|
|
1442
1452
|
config,
|
|
@@ -1494,7 +1504,8 @@ var KubbDriver = class {
|
|
|
1494
1504
|
await fileManager.write(fileManager.files, {
|
|
1495
1505
|
storage: config.storage,
|
|
1496
1506
|
parsers: parsersMap,
|
|
1497
|
-
manifest: this.options.manifest
|
|
1507
|
+
manifest: this.options.manifest,
|
|
1508
|
+
signal: this.options.signal
|
|
1498
1509
|
});
|
|
1499
1510
|
await hooks.callHook("kubb:build:end", {
|
|
1500
1511
|
files: this.fileManager.files,
|
|
@@ -1784,6 +1795,7 @@ var KubbDriver = class {
|
|
|
1784
1795
|
};
|
|
1785
1796
|
return {
|
|
1786
1797
|
config: driver.config,
|
|
1798
|
+
signal: driver.options.signal,
|
|
1787
1799
|
get root() {
|
|
1788
1800
|
return (0, node_path.resolve)(driver.config.root, driver.config.output.path);
|
|
1789
1801
|
},
|
|
@@ -2160,9 +2172,11 @@ var Kubb = class {
|
|
|
2160
2172
|
#driver = null;
|
|
2161
2173
|
#storage = null;
|
|
2162
2174
|
#manifest = null;
|
|
2175
|
+
#signal;
|
|
2163
2176
|
constructor(userConfig, options = {}) {
|
|
2164
2177
|
this.config = resolveConfig(userConfig);
|
|
2165
2178
|
this.hooks = options.hooks ?? new require_usingCtx.Hookable();
|
|
2179
|
+
this.#signal = options.signal;
|
|
2166
2180
|
}
|
|
2167
2181
|
get storage() {
|
|
2168
2182
|
if (!this.#storage) throw new Error("[kubb] setup() must be called before accessing storage");
|
|
@@ -2176,6 +2190,8 @@ var Kubb = class {
|
|
|
2176
2190
|
* Initializes the driver and storage. `build()` calls this automatically.
|
|
2177
2191
|
*/
|
|
2178
2192
|
async setup() {
|
|
2193
|
+
const signal = this.#signal;
|
|
2194
|
+
signal?.throwIfAborted();
|
|
2179
2195
|
const config = this.config;
|
|
2180
2196
|
const manifest = hasOutputPasses(config.output) ? await createOutputManifest({
|
|
2181
2197
|
storage: config.storage,
|
|
@@ -2183,7 +2199,8 @@ var Kubb = class {
|
|
|
2183
2199
|
}) : void 0;
|
|
2184
2200
|
const driver = new KubbDriver(config, {
|
|
2185
2201
|
hooks: this.hooks,
|
|
2186
|
-
manifest
|
|
2202
|
+
manifest,
|
|
2203
|
+
signal
|
|
2187
2204
|
});
|
|
2188
2205
|
this.hooks.setMaxListeners(Math.max(10, config.plugins.length * 4));
|
|
2189
2206
|
if (config.output.clean) {
|
|
@@ -2222,6 +2239,7 @@ var Kubb = class {
|
|
|
2222
2239
|
async safeBuild() {
|
|
2223
2240
|
try {
|
|
2224
2241
|
var _usingCtx$1 = require_usingCtx._usingCtx();
|
|
2242
|
+
this.#signal?.throwIfAborted();
|
|
2225
2243
|
if (!this.#driver) await this.setup();
|
|
2226
2244
|
const self = _usingCtx$1.u(this);
|
|
2227
2245
|
const driver = self.driver;
|
|
@@ -2252,6 +2270,8 @@ var Kubb = class {
|
|
|
2252
2270
|
* ```
|
|
2253
2271
|
*/
|
|
2254
2272
|
async generate(options = {}) {
|
|
2273
|
+
const signal = this.#signal;
|
|
2274
|
+
signal?.throwIfAborted();
|
|
2255
2275
|
const { hooks, config } = this;
|
|
2256
2276
|
const hrStart = process.hrtime();
|
|
2257
2277
|
await hooks.callHook("kubb:generation:start", { config });
|
|
@@ -2259,6 +2279,7 @@ var Kubb = class {
|
|
|
2259
2279
|
await this.setup();
|
|
2260
2280
|
await hooks.callHook("kubb:setup:end");
|
|
2261
2281
|
const { files, diagnostics, storage } = await this.safeBuild();
|
|
2282
|
+
signal?.throwIfAborted();
|
|
2262
2283
|
for (const diagnostic of diagnostics) {
|
|
2263
2284
|
if (!Diagnostics.isProblem(diagnostic)) continue;
|
|
2264
2285
|
if (diagnostic.code === Diagnostics.code.unknown) {
|