@kubb/core 1.8.1 → 1.8.3

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/index.js CHANGED
@@ -941,6 +941,9 @@ var definePlugin = createPlugin((options) => {
941
941
  get config() {
942
942
  return options.config;
943
943
  },
944
+ get plugins() {
945
+ return options.getPlugins();
946
+ },
944
947
  logger,
945
948
  fileManager,
946
949
  async addFile(...files) {
@@ -1055,14 +1058,15 @@ var PluginManager = class {
1055
1058
  eventEmitter = new EventEmitter();
1056
1059
  constructor(config, options) {
1057
1060
  this.logger = options.logger;
1058
- this.queue = new Queue(50, options.debug);
1061
+ this.queue = new Queue(100, options.debug);
1059
1062
  this.fileManager = new FileManager({ task: options.task, queue: this.queue });
1060
1063
  const core = definePlugin({
1061
1064
  config,
1062
1065
  logger: this.logger,
1063
1066
  fileManager: this.fileManager,
1064
- resolvePath: this.resolvePath,
1065
- resolveName: this.resolveName
1067
+ resolvePath: this.resolvePath.bind(this),
1068
+ resolveName: this.resolveName.bind(this),
1069
+ getPlugins: this.getSortedPlugins.bind(this)
1066
1070
  });
1067
1071
  this.core = pluginParser(core, core.api.call(null));
1068
1072
  this.plugins = [this.core, ...config.plugins || []].reduce((prev, plugin) => {
@@ -1142,7 +1146,7 @@ var PluginManager = class {
1142
1146
  skipped
1143
1147
  }) {
1144
1148
  let promise = Promise.resolve(null);
1145
- for (const plugin of this.getSortedPlugins(hookName)) {
1149
+ for (const plugin of this.getSortedPlugins()) {
1146
1150
  if (skipped && skipped.has(plugin)) {
1147
1151
  continue;
1148
1152
  }
@@ -1174,7 +1178,7 @@ var PluginManager = class {
1174
1178
  skipped
1175
1179
  }) {
1176
1180
  let parseResult = null;
1177
- for (const plugin of this.getSortedPlugins(hookName)) {
1181
+ for (const plugin of this.getSortedPlugins()) {
1178
1182
  if (skipped && skipped.has(plugin)) {
1179
1183
  continue;
1180
1184
  }
@@ -1202,7 +1206,7 @@ var PluginManager = class {
1202
1206
  parameters
1203
1207
  }) {
1204
1208
  const parallelPromises = [];
1205
- for (const plugin of this.getSortedPlugins(hookName)) {
1209
+ for (const plugin of this.getSortedPlugins()) {
1206
1210
  const promise = this.execute({ strategy: "hookParallel", hookName, parameters, plugin });
1207
1211
  if (promise) {
1208
1212
  parallelPromises.push(promise);
@@ -1231,7 +1235,7 @@ var PluginManager = class {
1231
1235
  }) {
1232
1236
  const [argument0, ...rest] = parameters;
1233
1237
  let promise = Promise.resolve(argument0);
1234
- for (const plugin of this.getSortedPlugins(hookName)) {
1238
+ for (const plugin of this.getSortedPlugins()) {
1235
1239
  promise = promise.then((arg0) => {
1236
1240
  const value = this.execute({
1237
1241
  strategy: "hookReduceArg0",
@@ -1249,7 +1253,7 @@ var PluginManager = class {
1249
1253
  */
1250
1254
  hookSeq({ hookName, parameters }) {
1251
1255
  let promise = Promise.resolve();
1252
- for (const plugin of this.getSortedPlugins(hookName)) {
1256
+ for (const plugin of this.getSortedPlugins()) {
1253
1257
  promise = promise.then(
1254
1258
  () => this.execute({
1255
1259
  strategy: "hookSeq",
@@ -1261,8 +1265,11 @@ var PluginManager = class {
1261
1265
  }
1262
1266
  return promise.then(noReturn);
1263
1267
  }
1264
- getSortedPlugins(_hookName) {
1268
+ getSortedPlugins(hookName) {
1265
1269
  const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1270
+ if (hookName) {
1271
+ return plugins.filter((item) => item[hookName]);
1272
+ }
1266
1273
  return plugins;
1267
1274
  }
1268
1275
  getPlugin(hookName, pluginName2) {
@@ -1378,20 +1385,20 @@ function noReturn() {
1378
1385
  // src/managers/pluginManager/validate.ts
1379
1386
  var ValidationPluginError = class extends Error {
1380
1387
  };
1381
- function validatePlugins(plugins, dependedPluginNames) {
1388
+ function getDependedPlugins(plugins, dependedPluginNames) {
1382
1389
  let pluginNames = [];
1383
1390
  if (typeof dependedPluginNames === "string") {
1384
1391
  pluginNames = [dependedPluginNames];
1385
1392
  } else {
1386
1393
  pluginNames = dependedPluginNames;
1387
1394
  }
1388
- pluginNames.forEach((pluginName2) => {
1389
- const exists = plugins.some((plugin) => plugin.name === pluginName2);
1390
- if (!exists) {
1395
+ return pluginNames.map((pluginName2) => {
1396
+ const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
1397
+ if (!plugin) {
1391
1398
  throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
1392
1399
  }
1400
+ return plugin;
1393
1401
  });
1394
- return true;
1395
1402
  }
1396
1403
 
1397
1404
  // src/types.ts
@@ -1511,6 +1518,6 @@ var SchemaGenerator = class extends Generator {
1511
1518
  // src/index.ts
1512
1519
  var src_default = build;
1513
1520
 
1514
- export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, validatePlugins, write };
1521
+ export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getDependedPlugins, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
1515
1522
  //# sourceMappingURL=out.js.map
1516
1523
  //# sourceMappingURL=index.js.map