@kubb/core 5.7.0 → 5.8.1
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/{KubbDriver-BcoHguLM.cjs → KubbDriver-DQ7pt93q.cjs} +100 -89
- package/dist/KubbDriver-DQ7pt93q.cjs.map +1 -0
- package/dist/{KubbDriver-DRobnIcp.js → KubbDriver-Dz36Klt9.js} +96 -91
- package/dist/KubbDriver-Dz36Klt9.js.map +1 -0
- package/dist/{types-Cd91JYuu.d.ts → createAdapter-BO_AxI05.d.ts} +1708 -1661
- package/dist/html/ui.iife.js +18 -4
- package/dist/index.cjs +168 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +145 -3
- package/dist/index.js +164 -61
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +3 -2
- package/dist/mocks.js +2 -2
- package/dist/{rolldown-runtime-C0LytTxp.js → rolldown-runtime-CRm0XQPb.js} +1 -0
- package/package.json +3 -2
- package/schemas/kubb-extension.json +168 -0
- package/dist/KubbDriver-BcoHguLM.cjs.map +0 -1
- package/dist/KubbDriver-DRobnIcp.js.map +0 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import "./rolldown-runtime-
|
|
1
|
+
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
+
import { satisfies } from "verkit";
|
|
2
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
4
|
import { styleText } from "node:util";
|
|
4
5
|
import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
5
6
|
import path, { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
6
7
|
import { ast, collectImportedRefNames, collectUsedSchemaNames, composeMacros, extractStringsFromNodes, operationDef, schemaDef, transform } from "@kubb/ast";
|
|
7
|
-
import { satisfies } from "verkit";
|
|
8
8
|
import { EventEmitter } from "node:events";
|
|
9
|
+
//#region package.json
|
|
10
|
+
var version = "5.8.1";
|
|
11
|
+
//#endregion
|
|
9
12
|
//#region ../../internals/utils/src/casing.ts
|
|
10
13
|
/**
|
|
11
14
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -329,9 +332,6 @@ function formatMs(ms) {
|
|
|
329
332
|
return `${Math.round(ms)}ms`;
|
|
330
333
|
}
|
|
331
334
|
//#endregion
|
|
332
|
-
//#region package.json
|
|
333
|
-
var version = "5.7.0";
|
|
334
|
-
//#endregion
|
|
335
335
|
//#region src/constants.ts
|
|
336
336
|
/**
|
|
337
337
|
* Stable codes Kubb attaches to a `Diagnostic`. Each maps to a known failure mode
|
|
@@ -923,11 +923,96 @@ var Diagnostics = class Diagnostics {
|
|
|
923
923
|
}
|
|
924
924
|
};
|
|
925
925
|
//#endregion
|
|
926
|
+
//#region src/defineExtension.ts
|
|
927
|
+
/**
|
|
928
|
+
* Returns `meta`, or `{ name }` for an extension that only sets the deprecated `name`. Throws `KUBB_INVALID_PLUGIN_OPTIONS` when it has neither.
|
|
929
|
+
*/
|
|
930
|
+
function resolveMeta({ name, meta }) {
|
|
931
|
+
if (meta) return meta;
|
|
932
|
+
if (name) return { name };
|
|
933
|
+
throw new Diagnostics.Error({
|
|
934
|
+
code: Diagnostics.code.invalidPluginOptions,
|
|
935
|
+
severity: "error",
|
|
936
|
+
message: "An extension has neither `meta.name` nor `name`.",
|
|
937
|
+
help: "Set `meta: { name }` on the plugin or parser.",
|
|
938
|
+
location: { kind: "config" }
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Throws `KUBB_INCOMPATIBLE_EXTENSION` when the running Kubb or Node.js version is outside `meta.compatibility`.
|
|
943
|
+
*/
|
|
944
|
+
function checkCompatibility(meta) {
|
|
945
|
+
const checks = [{
|
|
946
|
+
target: "Kubb",
|
|
947
|
+
range: meta.compatibility?.kubb,
|
|
948
|
+
version
|
|
949
|
+
}, {
|
|
950
|
+
target: "Node.js",
|
|
951
|
+
range: meta.compatibility?.node,
|
|
952
|
+
version: process.versions.node
|
|
953
|
+
}];
|
|
954
|
+
for (const { target, range, version } of checks) {
|
|
955
|
+
if (!range || satisfies(version, range, { includePrerelease: true })) continue;
|
|
956
|
+
throw new Diagnostics.Error({
|
|
957
|
+
code: Diagnostics.code.incompatibleExtension,
|
|
958
|
+
severity: "error",
|
|
959
|
+
message: `"${meta.name}" requires ${target} ${range}, but ${version} is running.`,
|
|
960
|
+
help: `Use a ${target} version that satisfies ${range}, or a version of "${meta.name}" that supports ${target} ${version}.`,
|
|
961
|
+
location: { kind: "config" },
|
|
962
|
+
plugin: meta.name
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Throws `KUBB_MISSING_DEPENDENCY` for a missing required entry in a `dependencies` record, and
|
|
968
|
+
* `KUBB_INCOMPATIBLE_DEPENDENCY` when an entry's `meta.version` is out of range. Arrays are not checked.
|
|
969
|
+
*/
|
|
970
|
+
function checkDependencies({ name, dependencies, plugins }) {
|
|
971
|
+
if (!dependencies || Array.isArray(dependencies)) return;
|
|
972
|
+
for (const [dependencyName, dependency] of Object.entries(dependencies)) {
|
|
973
|
+
const target = plugins.get(dependencyName);
|
|
974
|
+
if (!target) {
|
|
975
|
+
if (dependency?.optional) continue;
|
|
976
|
+
throw new Diagnostics.Error({
|
|
977
|
+
code: Diagnostics.code.missingDependency,
|
|
978
|
+
severity: "error",
|
|
979
|
+
message: `Plugin "${dependencyName}" is required by "${name}" but not found.`,
|
|
980
|
+
help: `Add "${dependencyName}" to the \`plugins\` array in kubb.config.ts.`,
|
|
981
|
+
location: { kind: "config" },
|
|
982
|
+
plugin: name
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
const range = dependency?.version;
|
|
986
|
+
const version = target.meta?.version;
|
|
987
|
+
if (!range || !version || satisfies(version, range, { includePrerelease: true })) continue;
|
|
988
|
+
throw new Diagnostics.Error({
|
|
989
|
+
code: Diagnostics.code.incompatibleDependency,
|
|
990
|
+
severity: "error",
|
|
991
|
+
message: `"${name}" requires "${dependencyName}" ${range}, but ${version} is configured.`,
|
|
992
|
+
help: `Install a version of "${dependencyName}" that satisfies ${range}.`,
|
|
993
|
+
location: { kind: "config" },
|
|
994
|
+
plugin: name
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
function defineExtension({ kind, meta, build }) {
|
|
999
|
+
const factory = (options) => build(options ?? {});
|
|
1000
|
+
return Object.assign(factory, meta ? {
|
|
1001
|
+
kind,
|
|
1002
|
+
meta
|
|
1003
|
+
} : { kind });
|
|
1004
|
+
}
|
|
1005
|
+
//#endregion
|
|
926
1006
|
//#region src/composables.ts
|
|
1007
|
+
const kubbContextKey = Symbol.for("kubb.context");
|
|
1008
|
+
const host = globalThis;
|
|
927
1009
|
/**
|
|
928
1010
|
* Holds the setup context of the plugin whose `setup` or `kubb:plugin:setup` is running. `KubbDriver` sets it for each plugin.
|
|
1011
|
+
*
|
|
1012
|
+
* The store lives on `globalThis`, so the ESM and CommonJS builds of `@kubb/core` share one. A plugin that a
|
|
1013
|
+
* CommonJS config loads would otherwise read an empty store and fail with `KUBB_NO_CONTEXT`.
|
|
929
1014
|
*/
|
|
930
|
-
const kubbContext = new AsyncLocalStorage();
|
|
1015
|
+
const kubbContext = host[kubbContextKey] ??= new AsyncLocalStorage();
|
|
931
1016
|
function requireContext(caller) {
|
|
932
1017
|
const ctx = kubbContext.getStore();
|
|
933
1018
|
if (ctx) return ctx;
|
|
@@ -1009,86 +1094,6 @@ function requirePlugin(name) {
|
|
|
1009
1094
|
return requireContext("requirePlugin").requirePlugin(name);
|
|
1010
1095
|
}
|
|
1011
1096
|
//#endregion
|
|
1012
|
-
//#region src/defineExtension.ts
|
|
1013
|
-
/**
|
|
1014
|
-
* Returns `meta`, or `{ name }` for an extension that only sets the deprecated `name`. Throws `KUBB_INVALID_PLUGIN_OPTIONS` when it has neither.
|
|
1015
|
-
*/
|
|
1016
|
-
function resolveMeta({ name, meta }) {
|
|
1017
|
-
if (meta) return meta;
|
|
1018
|
-
if (name) return { name };
|
|
1019
|
-
throw new Diagnostics.Error({
|
|
1020
|
-
code: Diagnostics.code.invalidPluginOptions,
|
|
1021
|
-
severity: "error",
|
|
1022
|
-
message: "An extension has neither `meta.name` nor `name`.",
|
|
1023
|
-
help: "Set `meta: { name }` on the plugin or parser.",
|
|
1024
|
-
location: { kind: "config" }
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* Throws `KUBB_INCOMPATIBLE_EXTENSION` when the running Kubb or Node.js version is outside `meta.compatibility`.
|
|
1029
|
-
*/
|
|
1030
|
-
function checkCompatibility(meta) {
|
|
1031
|
-
const checks = [{
|
|
1032
|
-
target: "Kubb",
|
|
1033
|
-
range: meta.compatibility?.kubb,
|
|
1034
|
-
version
|
|
1035
|
-
}, {
|
|
1036
|
-
target: "Node.js",
|
|
1037
|
-
range: meta.compatibility?.node,
|
|
1038
|
-
version: process.versions.node
|
|
1039
|
-
}];
|
|
1040
|
-
for (const { target, range, version } of checks) {
|
|
1041
|
-
if (!range || satisfies(version, range, { includePrerelease: true })) continue;
|
|
1042
|
-
throw new Diagnostics.Error({
|
|
1043
|
-
code: Diagnostics.code.incompatibleExtension,
|
|
1044
|
-
severity: "error",
|
|
1045
|
-
message: `"${meta.name}" requires ${target} ${range}, but ${version} is running.`,
|
|
1046
|
-
help: `Use a ${target} version that satisfies ${range}, or a version of "${meta.name}" that supports ${target} ${version}.`,
|
|
1047
|
-
location: { kind: "config" },
|
|
1048
|
-
plugin: meta.name
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
/**
|
|
1053
|
-
* Throws `KUBB_MISSING_DEPENDENCY` for a missing required entry in a `dependencies` record, and
|
|
1054
|
-
* `KUBB_INCOMPATIBLE_DEPENDENCY` when an entry's `meta.version` is out of range. Arrays are not checked.
|
|
1055
|
-
*/
|
|
1056
|
-
function checkDependencies({ name, dependencies, plugins }) {
|
|
1057
|
-
if (!dependencies || Array.isArray(dependencies)) return;
|
|
1058
|
-
for (const [dependencyName, dependency] of Object.entries(dependencies)) {
|
|
1059
|
-
const target = plugins.get(dependencyName);
|
|
1060
|
-
if (!target) {
|
|
1061
|
-
if (dependency?.optional) continue;
|
|
1062
|
-
throw new Diagnostics.Error({
|
|
1063
|
-
code: Diagnostics.code.missingDependency,
|
|
1064
|
-
severity: "error",
|
|
1065
|
-
message: `Plugin "${dependencyName}" is required by "${name}" but not found.`,
|
|
1066
|
-
help: `Add "${dependencyName}" to the \`plugins\` array in kubb.config.ts.`,
|
|
1067
|
-
location: { kind: "config" },
|
|
1068
|
-
plugin: name
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
const range = dependency?.version;
|
|
1072
|
-
const version = target.meta?.version;
|
|
1073
|
-
if (!range || !version || satisfies(version, range, { includePrerelease: true })) continue;
|
|
1074
|
-
throw new Diagnostics.Error({
|
|
1075
|
-
code: Diagnostics.code.incompatibleDependency,
|
|
1076
|
-
severity: "error",
|
|
1077
|
-
message: `"${name}" requires "${dependencyName}" ${range}, but ${version} is configured.`,
|
|
1078
|
-
help: `Install a version of "${dependencyName}" that satisfies ${range}.`,
|
|
1079
|
-
location: { kind: "config" },
|
|
1080
|
-
plugin: name
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
function defineExtension({ kind, meta, build }) {
|
|
1085
|
-
const factory = (options) => build(options ?? {});
|
|
1086
|
-
return Object.assign(factory, meta ? {
|
|
1087
|
-
kind,
|
|
1088
|
-
meta
|
|
1089
|
-
} : { kind });
|
|
1090
|
-
}
|
|
1091
|
-
//#endregion
|
|
1092
1097
|
//#region src/definePlugin.ts
|
|
1093
1098
|
/**
|
|
1094
1099
|
* Merges the `output.mode` default into the output config and validates the combination.
|
|
@@ -1765,7 +1770,7 @@ var Hookable = class {
|
|
|
1765
1770
|
}
|
|
1766
1771
|
};
|
|
1767
1772
|
//#endregion
|
|
1768
|
-
//#region \0@oxc-project+runtime@0.
|
|
1773
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/usingCtx.js
|
|
1769
1774
|
function _usingCtx() {
|
|
1770
1775
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
1771
1776
|
var n = Error();
|
|
@@ -2189,14 +2194,14 @@ var KubbDriver = class {
|
|
|
2189
2194
|
this.adapter = config.adapter ?? null;
|
|
2190
2195
|
}
|
|
2191
2196
|
/**
|
|
2192
|
-
*
|
|
2197
|
+
* Checks the adapter's and parsers' `meta.compatibility`, then normalizes and checks every configured plugin, orders them, and registers their lifecycle handlers.
|
|
2193
2198
|
* A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
|
|
2194
2199
|
* `'post'`. When the config has an adapter, the adapter source is resolved from the input
|
|
2195
2200
|
* so `run` can parse it later.
|
|
2196
2201
|
*/
|
|
2197
2202
|
async setup() {
|
|
2198
2203
|
this.options.signal?.throwIfAborted();
|
|
2199
|
-
for (const
|
|
2204
|
+
for (const extension of [this.config.adapter, ...this.config.parsers]) if (extension?.meta) checkCompatibility(extension.meta);
|
|
2200
2205
|
const normalized = this.#sortPlugins(this.config.plugins.map((rawPlugin) => {
|
|
2201
2206
|
if (rawPlugin.meta) checkCompatibility(rawPlugin.meta);
|
|
2202
2207
|
const meta = resolveMeta(rawPlugin);
|
|
@@ -2779,6 +2784,6 @@ function pluginNotFoundError({ pluginName, requiredBy }) {
|
|
|
2779
2784
|
});
|
|
2780
2785
|
}
|
|
2781
2786
|
//#endregion
|
|
2782
|
-
export {
|
|
2787
|
+
export { inParallel as A, useOptions as C, Diagnostics as D, resolveMeta as E, toPosixPath as F, write as I, toError as L, exists as M, isPathInside as N, formatMs as O, read as P, camelCase as R, useKubb as S, defineExtension as T, setMacros as _, _usingCtx as a, tryUseKubb as b, Resolver as c, definePlugin as d, addGenerator as f, requirePlugin as g, kubbContext as h, FileManager as i, clean as j, getElapsedMs as k, getInputKind as l, injectFile as m, pluginNotFoundError as n, Hookable as o, addMacro as p, createNodeCache as r, createResolver as s, KubbDriver as t, assertPluginOption as u, setOptions as v, checkCompatibility as w, useConfig as x, setResolver as y };
|
|
2783
2788
|
|
|
2784
|
-
//# sourceMappingURL=KubbDriver-
|
|
2789
|
+
//# sourceMappingURL=KubbDriver-Dz36Klt9.js.map
|