@kubb/core 5.0.0-alpha.22 → 5.0.0-alpha.23
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/{PluginDriver-DZdEyCoa.d.ts → PluginDriver-P920mak9.d.ts} +50 -23
- package/dist/hooks.cjs +1 -3
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +2 -4
- package/dist/hooks.js +1 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +99 -224
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -58
- package/dist/index.js +100 -223
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/PluginDriver.ts +81 -145
- package/src/build.ts +2 -2
- package/src/constants.ts +0 -10
- package/src/defineGenerator.ts +7 -0
- package/src/defineResolver.ts +1 -10
- package/src/hooks/useDriver.ts +1 -3
- package/src/index.ts +0 -2
- package/src/renderNode.tsx +9 -6
- package/src/types.ts +29 -18
- package/src/utils/getConfigs.ts +1 -1
- package/src/utils/getPreset.ts +3 -3
- package/src/defineBuilder.ts +0 -26
- package/src/definePreset.ts +0 -27
package/dist/index.cjs
CHANGED
|
@@ -22,14 +22,6 @@ let empathic_package = require("empathic/package");
|
|
|
22
22
|
empathic_package = require_chunk.__toESM(empathic_package);
|
|
23
23
|
let semver = require("semver");
|
|
24
24
|
//#region ../../internals/utils/src/errors.ts
|
|
25
|
-
/** Thrown when a plugin's configuration or input fails validation.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* throw new ValidationPluginError('Invalid config: "output.path" is required')
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
var ValidationPluginError = class extends Error {};
|
|
33
25
|
/**
|
|
34
26
|
* Thrown when one or more errors occur during a Kubb build.
|
|
35
27
|
* Carries the full list of underlying errors on `errors`.
|
|
@@ -350,28 +342,6 @@ async function clean(path) {
|
|
|
350
342
|
});
|
|
351
343
|
}
|
|
352
344
|
//#endregion
|
|
353
|
-
//#region ../../internals/utils/src/names.ts
|
|
354
|
-
/**
|
|
355
|
-
* Registers `originalName` in `data` without altering the returned name.
|
|
356
|
-
* Use when you need to track usage frequency but always emit the original identifier.
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
* ```ts
|
|
360
|
-
* const seen: Record<string, number> = {}
|
|
361
|
-
* setUniqueName('Foo', seen) // 'Foo' (seen = { Foo: 1 })
|
|
362
|
-
* setUniqueName('Foo', seen) // 'Foo' (seen = { Foo: 2 })
|
|
363
|
-
* ```
|
|
364
|
-
*/
|
|
365
|
-
function setUniqueName(originalName, data) {
|
|
366
|
-
let used = data[originalName] || 0;
|
|
367
|
-
if (used) {
|
|
368
|
-
data[originalName] = ++used;
|
|
369
|
-
return originalName;
|
|
370
|
-
}
|
|
371
|
-
data[originalName] = 1;
|
|
372
|
-
return originalName;
|
|
373
|
-
}
|
|
374
|
-
//#endregion
|
|
375
345
|
//#region ../../internals/utils/src/promise.ts
|
|
376
346
|
/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.
|
|
377
347
|
*
|
|
@@ -995,29 +965,30 @@ var PluginDriver = class {
|
|
|
995
965
|
rootNode = void 0;
|
|
996
966
|
adapter = void 0;
|
|
997
967
|
#studioIsOpen = false;
|
|
998
|
-
|
|
999
|
-
#usedPluginNames = {};
|
|
968
|
+
plugins = /* @__PURE__ */ new Map();
|
|
1000
969
|
constructor(config, options) {
|
|
1001
970
|
this.config = config;
|
|
1002
971
|
this.options = options;
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
972
|
+
config.plugins.map((plugin) => Object.assign({ install() {} }, plugin)).sort((a, b) => {
|
|
973
|
+
if (b.pre?.includes(a.name)) return 1;
|
|
974
|
+
if (b.post?.includes(a.name)) return -1;
|
|
975
|
+
return 0;
|
|
976
|
+
}).forEach((plugin) => {
|
|
977
|
+
this.plugins.set(plugin.name, plugin);
|
|
1006
978
|
});
|
|
1007
979
|
}
|
|
1008
980
|
get events() {
|
|
1009
981
|
return this.options.events;
|
|
1010
982
|
}
|
|
1011
983
|
getContext(plugin) {
|
|
1012
|
-
const plugins = [...this.#plugins];
|
|
1013
984
|
const driver = this;
|
|
1014
985
|
const baseContext = {
|
|
1015
|
-
fabric:
|
|
1016
|
-
config:
|
|
986
|
+
fabric: driver.options.fabric,
|
|
987
|
+
config: driver.config,
|
|
1017
988
|
plugin,
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
989
|
+
getPlugin: driver.getPlugin.bind(driver),
|
|
990
|
+
events: driver.options.events,
|
|
991
|
+
driver,
|
|
1021
992
|
addFile: async (...files) => {
|
|
1022
993
|
await this.options.fabric.addFile(...files);
|
|
1023
994
|
},
|
|
@@ -1030,6 +1001,9 @@ var PluginDriver = class {
|
|
|
1030
1001
|
get adapter() {
|
|
1031
1002
|
return driver.adapter;
|
|
1032
1003
|
},
|
|
1004
|
+
get resolver() {
|
|
1005
|
+
return plugin.resolver;
|
|
1006
|
+
},
|
|
1033
1007
|
openInStudio(options) {
|
|
1034
1008
|
if (!driver.config.devtools || driver.#studioIsOpen) return;
|
|
1035
1009
|
if (typeof driver.config.devtools !== "object") throw new Error("Devtools must be an object");
|
|
@@ -1040,8 +1014,8 @@ var PluginDriver = class {
|
|
|
1040
1014
|
}
|
|
1041
1015
|
};
|
|
1042
1016
|
const mergedExtras = {};
|
|
1043
|
-
for (const
|
|
1044
|
-
const result =
|
|
1017
|
+
for (const plugin of this.plugins.values()) if (typeof plugin.inject === "function") {
|
|
1018
|
+
const result = plugin.inject.call(baseContext, baseContext);
|
|
1045
1019
|
if (result !== null && typeof result === "object") Object.assign(mergedExtras, result);
|
|
1046
1020
|
}
|
|
1047
1021
|
return {
|
|
@@ -1049,9 +1023,9 @@ var PluginDriver = class {
|
|
|
1049
1023
|
...mergedExtras
|
|
1050
1024
|
};
|
|
1051
1025
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1026
|
+
/**
|
|
1027
|
+
* @deprecated use resolvers context instead
|
|
1028
|
+
*/
|
|
1055
1029
|
getFile({ name, mode, extname, pluginName, options }) {
|
|
1056
1030
|
const resolvedName = mode ? mode === "single" ? "" : this.resolveName({
|
|
1057
1031
|
name,
|
|
@@ -1074,6 +1048,9 @@ var PluginDriver = class {
|
|
|
1074
1048
|
exports: []
|
|
1075
1049
|
};
|
|
1076
1050
|
}
|
|
1051
|
+
/**
|
|
1052
|
+
* @deprecated use resolvers context instead
|
|
1053
|
+
*/
|
|
1077
1054
|
resolvePath = (params) => {
|
|
1078
1055
|
const defaultPath = (0, node_path.resolve)((0, node_path.resolve)(this.config.root, this.config.output.path), params.baseName);
|
|
1079
1056
|
if (params.pluginName) return this.hookForPluginSync({
|
|
@@ -1094,15 +1071,15 @@ var PluginDriver = class {
|
|
|
1094
1071
|
]
|
|
1095
1072
|
})?.result || defaultPath;
|
|
1096
1073
|
};
|
|
1074
|
+
/**
|
|
1075
|
+
* @deprecated use resolvers context instead
|
|
1076
|
+
*/
|
|
1097
1077
|
resolveName = (params) => {
|
|
1098
|
-
if (params.pluginName) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
});
|
|
1104
|
-
return transformReservedWord([...new Set(names)].at(0) || params.name);
|
|
1105
|
-
}
|
|
1078
|
+
if (params.pluginName) return transformReservedWord(this.hookForPluginSync({
|
|
1079
|
+
pluginName: params.pluginName,
|
|
1080
|
+
hookName: "resolveName",
|
|
1081
|
+
parameters: [params.name.trim(), params.type]
|
|
1082
|
+
})?.at(0) ?? params.name);
|
|
1106
1083
|
const name = this.hookFirstSync({
|
|
1107
1084
|
hookName: "resolveName",
|
|
1108
1085
|
parameters: [params.name.trim(), params.type]
|
|
@@ -1113,44 +1090,41 @@ var PluginDriver = class {
|
|
|
1113
1090
|
* Run a specific hookName for plugin x.
|
|
1114
1091
|
*/
|
|
1115
1092
|
async hookForPlugin({ pluginName, hookName, parameters }) {
|
|
1116
|
-
const
|
|
1093
|
+
const plugin = this.plugins.get(pluginName);
|
|
1094
|
+
if (!plugin) return [null];
|
|
1117
1095
|
this.events.emit("plugins:hook:progress:start", {
|
|
1118
1096
|
hookName,
|
|
1119
|
-
plugins
|
|
1097
|
+
plugins: [plugin]
|
|
1098
|
+
});
|
|
1099
|
+
const result = await this.#execute({
|
|
1100
|
+
strategy: "hookFirst",
|
|
1101
|
+
hookName,
|
|
1102
|
+
parameters,
|
|
1103
|
+
plugin
|
|
1120
1104
|
});
|
|
1121
|
-
const items = [];
|
|
1122
|
-
for (const plugin of plugins) {
|
|
1123
|
-
const result = await this.#execute({
|
|
1124
|
-
strategy: "hookFirst",
|
|
1125
|
-
hookName,
|
|
1126
|
-
parameters,
|
|
1127
|
-
plugin
|
|
1128
|
-
});
|
|
1129
|
-
if (result !== void 0 && result !== null) items.push(result);
|
|
1130
|
-
}
|
|
1131
1105
|
this.events.emit("plugins:hook:progress:end", { hookName });
|
|
1132
|
-
return
|
|
1106
|
+
return [result];
|
|
1133
1107
|
}
|
|
1134
1108
|
/**
|
|
1135
1109
|
* Run a specific hookName for plugin x.
|
|
1136
1110
|
*/
|
|
1137
1111
|
hookForPluginSync({ pluginName, hookName, parameters }) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
})
|
|
1112
|
+
const plugin = this.plugins.get(pluginName);
|
|
1113
|
+
if (!plugin) return null;
|
|
1114
|
+
const result = this.#executeSync({
|
|
1115
|
+
strategy: "hookFirst",
|
|
1116
|
+
hookName,
|
|
1117
|
+
parameters,
|
|
1118
|
+
plugin
|
|
1119
|
+
});
|
|
1120
|
+
return result !== null ? [result] : [];
|
|
1146
1121
|
}
|
|
1147
1122
|
/**
|
|
1148
1123
|
* Returns the first non-null result.
|
|
1149
1124
|
*/
|
|
1150
1125
|
async hookFirst({ hookName, parameters, skipped }) {
|
|
1151
|
-
const plugins =
|
|
1152
|
-
|
|
1153
|
-
});
|
|
1126
|
+
const plugins = [];
|
|
1127
|
+
for (const plugin of this.plugins.values()) if (hookName in plugin && (skipped ? !skipped.has(plugin) : true)) plugins.push(plugin);
|
|
1154
1128
|
this.events.emit("plugins:hook:progress:start", {
|
|
1155
1129
|
hookName,
|
|
1156
1130
|
plugins
|
|
@@ -1177,10 +1151,9 @@ var PluginDriver = class {
|
|
|
1177
1151
|
*/
|
|
1178
1152
|
hookFirstSync({ hookName, parameters, skipped }) {
|
|
1179
1153
|
let parseResult = null;
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
for (const plugin of plugins) {
|
|
1154
|
+
for (const plugin of this.plugins.values()) {
|
|
1155
|
+
if (!(hookName in plugin)) continue;
|
|
1156
|
+
if (skipped?.has(plugin)) continue;
|
|
1184
1157
|
parseResult = {
|
|
1185
1158
|
result: this.#executeSync({
|
|
1186
1159
|
strategy: "hookFirst",
|
|
@@ -1190,7 +1163,7 @@ var PluginDriver = class {
|
|
|
1190
1163
|
}),
|
|
1191
1164
|
plugin
|
|
1192
1165
|
};
|
|
1193
|
-
if (parseResult
|
|
1166
|
+
if (parseResult.result != null) break;
|
|
1194
1167
|
}
|
|
1195
1168
|
return parseResult;
|
|
1196
1169
|
}
|
|
@@ -1198,7 +1171,8 @@ var PluginDriver = class {
|
|
|
1198
1171
|
* Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
|
|
1199
1172
|
*/
|
|
1200
1173
|
async hookParallel({ hookName, parameters }) {
|
|
1201
|
-
const plugins =
|
|
1174
|
+
const plugins = [];
|
|
1175
|
+
for (const plugin of this.plugins.values()) if (hookName in plugin) plugins.push(plugin);
|
|
1202
1176
|
this.events.emit("plugins:hook:progress:start", {
|
|
1203
1177
|
hookName,
|
|
1204
1178
|
plugins
|
|
@@ -1217,7 +1191,7 @@ var PluginDriver = class {
|
|
|
1217
1191
|
}), this.options.concurrency);
|
|
1218
1192
|
results.forEach((result, index) => {
|
|
1219
1193
|
if (isPromiseRejectedResult(result)) {
|
|
1220
|
-
const plugin =
|
|
1194
|
+
const plugin = plugins[index];
|
|
1221
1195
|
if (plugin) {
|
|
1222
1196
|
const startTime = pluginStartTimes.get(plugin) ?? node_perf_hooks.performance.now();
|
|
1223
1197
|
this.events.emit("error", result.reason, {
|
|
@@ -1240,7 +1214,8 @@ var PluginDriver = class {
|
|
|
1240
1214
|
* Chains plugins
|
|
1241
1215
|
*/
|
|
1242
1216
|
async hookSeq({ hookName, parameters }) {
|
|
1243
|
-
const plugins =
|
|
1217
|
+
const plugins = [];
|
|
1218
|
+
for (const plugin of this.plugins.values()) if (hookName in plugin) plugins.push(plugin);
|
|
1244
1219
|
this.events.emit("plugins:hook:progress:start", {
|
|
1245
1220
|
hookName,
|
|
1246
1221
|
plugins
|
|
@@ -1255,33 +1230,8 @@ var PluginDriver = class {
|
|
|
1255
1230
|
}));
|
|
1256
1231
|
this.events.emit("plugins:hook:progress:end", { hookName });
|
|
1257
1232
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
if (hookName) return plugins.filter((plugin) => hookName in plugin);
|
|
1261
|
-
return plugins.map((plugin) => {
|
|
1262
|
-
if (plugin.pre) {
|
|
1263
|
-
let missingPlugins = plugin.pre.filter((pluginName) => !plugins.find((pluginToFind) => pluginToFind.name === pluginName));
|
|
1264
|
-
if (missingPlugins.includes("plugin-oas") && this.adapter) missingPlugins = missingPlugins.filter((pluginName) => pluginName !== "plugin-oas");
|
|
1265
|
-
if (missingPlugins.length > 0) throw new ValidationPluginError(`The plugin '${plugin.name}' has a pre set that references missing plugins for '${missingPlugins.join(", ")}'`);
|
|
1266
|
-
}
|
|
1267
|
-
return plugin;
|
|
1268
|
-
}).sort((a, b) => {
|
|
1269
|
-
if (b.pre?.includes(a.name)) return 1;
|
|
1270
|
-
if (b.post?.includes(a.name)) return -1;
|
|
1271
|
-
return 0;
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
getPluginByName(pluginName) {
|
|
1275
|
-
return [...this.#plugins].find((item) => item.name === pluginName);
|
|
1276
|
-
}
|
|
1277
|
-
getPluginsByName(hookName, pluginName) {
|
|
1278
|
-
const plugins = [...this.plugins];
|
|
1279
|
-
const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => item.name === pluginName);
|
|
1280
|
-
if (!pluginByPluginName?.length) {
|
|
1281
|
-
const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
|
|
1282
|
-
return corePlugin ? [corePlugin] : [];
|
|
1283
|
-
}
|
|
1284
|
-
return pluginByPluginName;
|
|
1233
|
+
getPlugin(pluginName) {
|
|
1234
|
+
return this.plugins.get(pluginName);
|
|
1285
1235
|
}
|
|
1286
1236
|
/**
|
|
1287
1237
|
* Run an async plugin hook and return the result.
|
|
@@ -1369,16 +1319,6 @@ var PluginDriver = class {
|
|
|
1369
1319
|
return null;
|
|
1370
1320
|
}
|
|
1371
1321
|
}
|
|
1372
|
-
#parse(plugin) {
|
|
1373
|
-
const usedPluginNames = this.#usedPluginNames;
|
|
1374
|
-
setUniqueName(plugin.name, usedPluginNames);
|
|
1375
|
-
const usageCount = usedPluginNames[plugin.name];
|
|
1376
|
-
if (usageCount && usageCount > 1) throw new ValidationPluginError(`Duplicate plugin "${plugin.name}" detected. Each plugin can only be used once. Use a different configuration instead of adding multiple instances of the same plugin.`);
|
|
1377
|
-
return {
|
|
1378
|
-
install() {},
|
|
1379
|
-
...plugin
|
|
1380
|
-
};
|
|
1381
|
-
}
|
|
1382
1322
|
};
|
|
1383
1323
|
//#endregion
|
|
1384
1324
|
//#region src/createStorage.ts
|
|
@@ -1478,7 +1418,7 @@ const fsStorage = createStorage(() => ({
|
|
|
1478
1418
|
}));
|
|
1479
1419
|
//#endregion
|
|
1480
1420
|
//#region package.json
|
|
1481
|
-
var version = "5.0.0-alpha.
|
|
1421
|
+
var version = "5.0.0-alpha.23";
|
|
1482
1422
|
//#endregion
|
|
1483
1423
|
//#region src/utils/diagnostics.ts
|
|
1484
1424
|
/**
|
|
@@ -1674,7 +1614,7 @@ async function safeBuild(options, overrides) {
|
|
|
1674
1614
|
const pluginTimings = /* @__PURE__ */ new Map();
|
|
1675
1615
|
const config = driver.config;
|
|
1676
1616
|
try {
|
|
1677
|
-
for (const plugin of driver.plugins) {
|
|
1617
|
+
for (const plugin of driver.plugins.values()) {
|
|
1678
1618
|
const context = driver.getContext(plugin);
|
|
1679
1619
|
const hrStart = process.hrtime();
|
|
1680
1620
|
const installer = plugin.install.bind(context);
|
|
@@ -1784,7 +1724,7 @@ async function safeBuild(options, overrides) {
|
|
|
1784
1724
|
}
|
|
1785
1725
|
function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, driver }) {
|
|
1786
1726
|
const pluginNameMap = /* @__PURE__ */ new Map();
|
|
1787
|
-
for (const plugin of driver.plugins) pluginNameMap.set(plugin.name, plugin);
|
|
1727
|
+
for (const plugin of driver.plugins.values()) pluginNameMap.set(plugin.name, plugin);
|
|
1788
1728
|
return barrelFiles.flatMap((file) => {
|
|
1789
1729
|
const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
|
|
1790
1730
|
return (file.sources ?? []).flatMap((source) => {
|
|
@@ -1866,26 +1806,6 @@ function createPlugin(build) {
|
|
|
1866
1806
|
return (options) => build(options ?? {});
|
|
1867
1807
|
}
|
|
1868
1808
|
//#endregion
|
|
1869
|
-
//#region src/defineBuilder.ts
|
|
1870
|
-
/**
|
|
1871
|
-
* Defines a builder for a plugin — a named collection of schema-building helpers that
|
|
1872
|
-
* can be exported alongside the plugin and imported by other plugins or generators.
|
|
1873
|
-
*
|
|
1874
|
-
* @example
|
|
1875
|
-
* export const builder = defineBuilder<PluginTs>(() => ({
|
|
1876
|
-
* name: 'default',
|
|
1877
|
-
* buildParamsSchema({ params, node, resolver }) {
|
|
1878
|
-
* return createSchema({ type: 'object', properties: [] })
|
|
1879
|
-
* },
|
|
1880
|
-
* buildDataSchemaNode({ node, resolver }) {
|
|
1881
|
-
* return createSchema({ type: 'object', properties: [] })
|
|
1882
|
-
* },
|
|
1883
|
-
* }))
|
|
1884
|
-
*/
|
|
1885
|
-
function defineBuilder(build) {
|
|
1886
|
-
return build();
|
|
1887
|
-
}
|
|
1888
|
-
//#endregion
|
|
1889
1809
|
//#region src/defineGenerator.ts
|
|
1890
1810
|
function defineGenerator(generator) {
|
|
1891
1811
|
if (generator.type === "react") return {
|
|
@@ -1933,34 +1853,6 @@ function defineLogger(logger) {
|
|
|
1933
1853
|
return logger;
|
|
1934
1854
|
}
|
|
1935
1855
|
//#endregion
|
|
1936
|
-
//#region src/definePreset.ts
|
|
1937
|
-
/**
|
|
1938
|
-
* Creates a typed preset object that bundles a name, resolvers, optional
|
|
1939
|
-
* transformers, and optional generators — the building block for composable plugin presets.
|
|
1940
|
-
*
|
|
1941
|
-
* @example
|
|
1942
|
-
* import { definePreset } from '@kubb/core'
|
|
1943
|
-
* import { resolverTsLegacy } from '@kubb/plugin-ts'
|
|
1944
|
-
*
|
|
1945
|
-
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy] })
|
|
1946
|
-
*
|
|
1947
|
-
* @example
|
|
1948
|
-
* // With custom transformers
|
|
1949
|
-
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy], transformers: [myTransformer] })
|
|
1950
|
-
*
|
|
1951
|
-
* @example
|
|
1952
|
-
* // With generators
|
|
1953
|
-
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy], generators: [typeGeneratorLegacy] })
|
|
1954
|
-
*/
|
|
1955
|
-
function definePreset(name, { resolvers, transformers, generators }) {
|
|
1956
|
-
return {
|
|
1957
|
-
name,
|
|
1958
|
-
resolvers,
|
|
1959
|
-
transformers,
|
|
1960
|
-
generators
|
|
1961
|
-
};
|
|
1962
|
-
}
|
|
1963
|
-
//#endregion
|
|
1964
1856
|
//#region src/definePresets.ts
|
|
1965
1857
|
/**
|
|
1966
1858
|
* Creates a typed presets registry object — a named collection of {@link Preset} entries.
|
|
@@ -2107,13 +1999,7 @@ function defaultResolveOptions(node, { options, exclude = [], include, override
|
|
|
2107
1999
|
*/
|
|
2108
2000
|
function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root, output, group }) {
|
|
2109
2001
|
if ((pathMode ?? getMode(node_path.default.resolve(root, output.path))) === "single") return node_path.default.resolve(root, output.path);
|
|
2110
|
-
if (group && (groupPath || tag)) {
|
|
2111
|
-
const groupName = group.name ? group.name : (ctx) => {
|
|
2112
|
-
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
2113
|
-
return `${camelCase(ctx.group)}Controller`;
|
|
2114
|
-
};
|
|
2115
|
-
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? groupPath : tag }), baseName);
|
|
2116
|
-
}
|
|
2002
|
+
if (group && (groupPath || tag)) return node_path.default.resolve(root, output.path, group.name({ group: group.type === "path" ? groupPath : tag }), baseName);
|
|
2117
2003
|
return node_path.default.resolve(root, output.path, baseName);
|
|
2118
2004
|
}
|
|
2119
2005
|
/**
|
|
@@ -2313,19 +2199,15 @@ async function renderOperations(nodes, options) {
|
|
|
2313
2199
|
const { config, fabric, plugin, Component, driver, adapter } = options;
|
|
2314
2200
|
if (!Component) return;
|
|
2315
2201
|
const fabricChild = (0, _kubb_react_fabric.createReactFabric)();
|
|
2316
|
-
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Fabric, {
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
nodes,
|
|
2326
|
-
options: options.options
|
|
2327
|
-
})
|
|
2328
|
-
}));
|
|
2202
|
+
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Fabric, { children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Component, {
|
|
2203
|
+
config,
|
|
2204
|
+
plugin,
|
|
2205
|
+
driver,
|
|
2206
|
+
adapter,
|
|
2207
|
+
nodes,
|
|
2208
|
+
options: options.options,
|
|
2209
|
+
resolver: options.resolver
|
|
2210
|
+
}) }));
|
|
2329
2211
|
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
2330
2212
|
fabricChild.unmount();
|
|
2331
2213
|
}
|
|
@@ -2336,19 +2218,15 @@ async function renderOperation(node, options) {
|
|
|
2336
2218
|
const { config, fabric, plugin, Component, adapter, driver } = options;
|
|
2337
2219
|
if (!Component) return;
|
|
2338
2220
|
const fabricChild = (0, _kubb_react_fabric.createReactFabric)();
|
|
2339
|
-
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Fabric, {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
node,
|
|
2349
|
-
options: options.options
|
|
2350
|
-
})
|
|
2351
|
-
}));
|
|
2221
|
+
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Fabric, { children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Component, {
|
|
2222
|
+
config,
|
|
2223
|
+
plugin,
|
|
2224
|
+
driver,
|
|
2225
|
+
adapter,
|
|
2226
|
+
node,
|
|
2227
|
+
options: options.options,
|
|
2228
|
+
resolver: options.resolver
|
|
2229
|
+
}) }));
|
|
2352
2230
|
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
2353
2231
|
fabricChild.unmount();
|
|
2354
2232
|
}
|
|
@@ -2359,19 +2237,15 @@ async function renderSchema(node, options) {
|
|
|
2359
2237
|
const { config, fabric, plugin, Component, adapter, driver } = options;
|
|
2360
2238
|
if (!Component) return;
|
|
2361
2239
|
const fabricChild = (0, _kubb_react_fabric.createReactFabric)();
|
|
2362
|
-
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Fabric, {
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
node,
|
|
2372
|
-
options: options.options
|
|
2373
|
-
})
|
|
2374
|
-
}));
|
|
2240
|
+
await fabricChild.render(/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Fabric, { children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Component, {
|
|
2241
|
+
config,
|
|
2242
|
+
plugin,
|
|
2243
|
+
driver,
|
|
2244
|
+
adapter,
|
|
2245
|
+
node,
|
|
2246
|
+
options: options.options,
|
|
2247
|
+
resolver: options.resolver
|
|
2248
|
+
}) }));
|
|
2375
2249
|
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
2376
2250
|
fabricChild.unmount();
|
|
2377
2251
|
}
|
|
@@ -2784,7 +2658,10 @@ async function getBarrelFiles(files, { type, meta = {}, root, output }) {
|
|
|
2784
2658
|
*/
|
|
2785
2659
|
async function getConfigs(config, args) {
|
|
2786
2660
|
const resolved = await (typeof config === "function" ? config(args) : config);
|
|
2787
|
-
return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({
|
|
2661
|
+
return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({
|
|
2662
|
+
plugins: [],
|
|
2663
|
+
...item
|
|
2664
|
+
}));
|
|
2788
2665
|
}
|
|
2789
2666
|
//#endregion
|
|
2790
2667
|
//#region src/utils/mergeResolvers.ts
|
|
@@ -2816,7 +2693,7 @@ function mergeResolvers(...resolvers) {
|
|
|
2816
2693
|
* - Combines preset generators with user-supplied generators; falls back to the `default` preset's generators when neither provides any.
|
|
2817
2694
|
*/
|
|
2818
2695
|
function getPreset(params) {
|
|
2819
|
-
const { preset: presetName, presets, resolvers, transformers: userTransformers, generators: userGenerators } = params;
|
|
2696
|
+
const { preset: presetName, presets, resolvers = [], transformers: userTransformers = [], generators: userGenerators = [] } = params;
|
|
2820
2697
|
const [defaultResolver, ...userResolvers] = resolvers;
|
|
2821
2698
|
const preset = presets[presetName];
|
|
2822
2699
|
const resolver = mergeResolvers(mergeResolvers(defaultResolver, ...preset?.resolvers ?? []), ...userResolvers ?? []);
|
|
@@ -2928,11 +2805,9 @@ exports.defaultResolveFile = defaultResolveFile;
|
|
|
2928
2805
|
exports.defaultResolveFooter = defaultResolveFooter;
|
|
2929
2806
|
exports.defaultResolveOptions = defaultResolveOptions;
|
|
2930
2807
|
exports.defaultResolvePath = defaultResolvePath;
|
|
2931
|
-
exports.defineBuilder = defineBuilder;
|
|
2932
2808
|
exports.defineConfig = defineConfig;
|
|
2933
2809
|
exports.defineGenerator = defineGenerator;
|
|
2934
2810
|
exports.defineLogger = defineLogger;
|
|
2935
|
-
exports.definePreset = definePreset;
|
|
2936
2811
|
exports.definePresets = definePresets;
|
|
2937
2812
|
Object.defineProperty(exports, "definePrinter", {
|
|
2938
2813
|
enumerable: true,
|