@kubb/core 1.9.0-canary.20230910T193001 → 1.9.0-canary.20230911T090848

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.cjs CHANGED
@@ -954,6 +954,9 @@ var definePlugin = createPlugin((options) => {
954
954
  get config() {
955
955
  return options.config;
956
956
  },
957
+ get plugins() {
958
+ return options.getPlugins();
959
+ },
957
960
  logger,
958
961
  fileManager,
959
962
  async addFile(...files) {
@@ -1068,14 +1071,15 @@ var PluginManager = class {
1068
1071
  eventEmitter = new EventEmitter();
1069
1072
  constructor(config, options) {
1070
1073
  this.logger = options.logger;
1071
- this.queue = new Queue(50, options.debug);
1074
+ this.queue = new Queue(100, options.debug);
1072
1075
  this.fileManager = new FileManager({ task: options.task, queue: this.queue });
1073
1076
  const core = definePlugin({
1074
1077
  config,
1075
1078
  logger: this.logger,
1076
1079
  fileManager: this.fileManager,
1077
- resolvePath: this.resolvePath,
1078
- resolveName: this.resolveName
1080
+ resolvePath: this.resolvePath.bind(this),
1081
+ resolveName: this.resolveName.bind(this),
1082
+ getPlugins: this.getSortedPlugins.bind(this)
1079
1083
  });
1080
1084
  this.core = pluginParser(core, core.api.call(null));
1081
1085
  this.plugins = [this.core, ...config.plugins || []].reduce((prev, plugin) => {
@@ -1155,7 +1159,7 @@ var PluginManager = class {
1155
1159
  skipped
1156
1160
  }) {
1157
1161
  let promise = Promise.resolve(null);
1158
- for (const plugin of this.getSortedPlugins(hookName)) {
1162
+ for (const plugin of this.getSortedPlugins()) {
1159
1163
  if (skipped && skipped.has(plugin)) {
1160
1164
  continue;
1161
1165
  }
@@ -1187,7 +1191,7 @@ var PluginManager = class {
1187
1191
  skipped
1188
1192
  }) {
1189
1193
  let parseResult = null;
1190
- for (const plugin of this.getSortedPlugins(hookName)) {
1194
+ for (const plugin of this.getSortedPlugins()) {
1191
1195
  if (skipped && skipped.has(plugin)) {
1192
1196
  continue;
1193
1197
  }
@@ -1215,7 +1219,7 @@ var PluginManager = class {
1215
1219
  parameters
1216
1220
  }) {
1217
1221
  const parallelPromises = [];
1218
- for (const plugin of this.getSortedPlugins(hookName)) {
1222
+ for (const plugin of this.getSortedPlugins()) {
1219
1223
  const promise = this.execute({ strategy: "hookParallel", hookName, parameters, plugin });
1220
1224
  if (promise) {
1221
1225
  parallelPromises.push(promise);
@@ -1244,7 +1248,7 @@ var PluginManager = class {
1244
1248
  }) {
1245
1249
  const [argument0, ...rest] = parameters;
1246
1250
  let promise = Promise.resolve(argument0);
1247
- for (const plugin of this.getSortedPlugins(hookName)) {
1251
+ for (const plugin of this.getSortedPlugins()) {
1248
1252
  promise = promise.then((arg0) => {
1249
1253
  const value = this.execute({
1250
1254
  strategy: "hookReduceArg0",
@@ -1262,7 +1266,7 @@ var PluginManager = class {
1262
1266
  */
1263
1267
  hookSeq({ hookName, parameters }) {
1264
1268
  let promise = Promise.resolve();
1265
- for (const plugin of this.getSortedPlugins(hookName)) {
1269
+ for (const plugin of this.getSortedPlugins()) {
1266
1270
  promise = promise.then(
1267
1271
  () => this.execute({
1268
1272
  strategy: "hookSeq",
@@ -1274,8 +1278,11 @@ var PluginManager = class {
1274
1278
  }
1275
1279
  return promise.then(noReturn);
1276
1280
  }
1277
- getSortedPlugins(_hookName) {
1281
+ getSortedPlugins(hookName) {
1278
1282
  const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1283
+ if (hookName) {
1284
+ return plugins.filter((item) => item[hookName]);
1285
+ }
1279
1286
  return plugins;
1280
1287
  }
1281
1288
  getPlugin(hookName, pluginName2) {
@@ -1391,20 +1398,20 @@ function noReturn() {
1391
1398
  // src/managers/pluginManager/validate.ts
1392
1399
  var ValidationPluginError = class extends Error {
1393
1400
  };
1394
- function validatePlugins(plugins, dependedPluginNames) {
1401
+ function getDependedPlugins(plugins, dependedPluginNames) {
1395
1402
  let pluginNames = [];
1396
1403
  if (typeof dependedPluginNames === "string") {
1397
1404
  pluginNames = [dependedPluginNames];
1398
1405
  } else {
1399
1406
  pluginNames = dependedPluginNames;
1400
1407
  }
1401
- pluginNames.forEach((pluginName2) => {
1402
- const exists = plugins.some((plugin) => plugin.name === pluginName2);
1403
- if (!exists) {
1408
+ return pluginNames.map((pluginName2) => {
1409
+ const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
1410
+ if (!plugin) {
1404
1411
  throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
1405
1412
  }
1413
+ return plugin;
1406
1414
  });
1407
- return true;
1408
1415
  }
1409
1416
 
1410
1417
  // src/types.ts
@@ -1552,6 +1559,7 @@ exports.default = src_default;
1552
1559
  exports.defaultColours = defaultColours;
1553
1560
  exports.defineConfig = defineConfig;
1554
1561
  exports.extensions = extensions;
1562
+ exports.getDependedPlugins = getDependedPlugins;
1555
1563
  exports.getEncodedText = getEncodedText;
1556
1564
  exports.getFileSource = getFileSource;
1557
1565
  exports.getIndexes = getIndexes;
@@ -1578,7 +1586,6 @@ exports.throttle = throttle;
1578
1586
  exports.timeout = timeout;
1579
1587
  exports.transformReservedWord = transformReservedWord;
1580
1588
  exports.uniqueIdFactory = uniqueIdFactory;
1581
- exports.validatePlugins = validatePlugins;
1582
1589
  exports.write = write;
1583
1590
  //# sourceMappingURL=out.js.map
1584
1591
  //# sourceMappingURL=index.cjs.map