@kubb/core 5.0.0-alpha.1 → 5.0.0-alpha.2

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/hooks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { N as PluginManager, _ as PluginFactoryOptions, h as Plugin } from "./types-D30QAz2y.js";
2
+ import { M as PluginManager, _ as PluginFactoryOptions, h as Plugin } from "./types-B7eZvqwD.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/hooks/useMode.d.ts
package/dist/index.cjs CHANGED
@@ -1026,19 +1026,19 @@ var PluginManager = class {
1026
1026
  get plugins() {
1027
1027
  return this.#getSortedPlugins();
1028
1028
  }
1029
- getFile({ name, mode, extname, pluginKey, options }) {
1029
+ getFile({ name, mode, extname, pluginName, options }) {
1030
1030
  const baseName = `${name}${extname}`;
1031
1031
  const path = this.resolvePath({
1032
1032
  baseName,
1033
1033
  mode,
1034
- pluginKey,
1034
+ pluginName,
1035
1035
  options
1036
1036
  });
1037
- if (!path) throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
1037
+ if (!path) throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginName "${pluginName}"`);
1038
1038
  return {
1039
1039
  path,
1040
1040
  baseName,
1041
- meta: { pluginKey },
1041
+ meta: { pluginName },
1042
1042
  sources: [],
1043
1043
  imports: [],
1044
1044
  exports: []
@@ -1047,8 +1047,8 @@ var PluginManager = class {
1047
1047
  resolvePath = (params) => {
1048
1048
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
1049
1049
  const defaultPath = node_path.default.resolve(root, params.baseName);
1050
- if (params.pluginKey) return this.hookForPluginSync({
1051
- pluginKey: params.pluginKey,
1050
+ if (params.pluginName) return this.hookForPluginSync({
1051
+ pluginName: params.pluginName,
1052
1052
  hookName: "resolvePath",
1053
1053
  parameters: [
1054
1054
  params.baseName,
@@ -1066,9 +1066,9 @@ var PluginManager = class {
1066
1066
  })?.result || defaultPath;
1067
1067
  };
1068
1068
  resolveName = (params) => {
1069
- if (params.pluginKey) {
1069
+ if (params.pluginName) {
1070
1070
  const names = this.hookForPluginSync({
1071
- pluginKey: params.pluginKey,
1071
+ pluginName: params.pluginName,
1072
1072
  hookName: "resolveName",
1073
1073
  parameters: [params.name.trim(), params.type]
1074
1074
  });
@@ -1083,8 +1083,8 @@ var PluginManager = class {
1083
1083
  /**
1084
1084
  * Run a specific hookName for plugin x.
1085
1085
  */
1086
- async hookForPlugin({ pluginKey, hookName, parameters }) {
1087
- const plugins = this.getPluginsByKey(hookName, pluginKey);
1086
+ async hookForPlugin({ pluginName, hookName, parameters }) {
1087
+ const plugins = this.getPluginsByName(hookName, pluginName);
1088
1088
  this.events.emit("plugins:hook:progress:start", {
1089
1089
  hookName,
1090
1090
  plugins
@@ -1105,8 +1105,8 @@ var PluginManager = class {
1105
1105
  /**
1106
1106
  * Run a specific hookName for plugin x.
1107
1107
  */
1108
- hookForPluginSync({ pluginKey, hookName, parameters }) {
1109
- return this.getPluginsByKey(hookName, pluginKey).map((plugin) => {
1108
+ hookForPluginSync({ pluginName, hookName, parameters }) {
1109
+ return this.getPluginsByName(hookName, pluginName).map((plugin) => {
1110
1110
  return this.#executeSync({
1111
1111
  strategy: "hookFirst",
1112
1112
  hookName,
@@ -1244,24 +1244,12 @@ var PluginManager = class {
1244
1244
  return 0;
1245
1245
  });
1246
1246
  }
1247
- getPluginByKey(pluginKey) {
1248
- const plugins = [...this.#plugins];
1249
- const [searchPluginName] = pluginKey;
1250
- return plugins.find((item) => {
1251
- const [name] = item.key;
1252
- return name === searchPluginName;
1253
- });
1247
+ getPluginByName(pluginName) {
1248
+ return [...this.#plugins].find((item) => item.name === pluginName);
1254
1249
  }
1255
- getPluginsByKey(hookName, pluginKey) {
1250
+ getPluginsByName(hookName, pluginName) {
1256
1251
  const plugins = [...this.plugins];
1257
- const [searchPluginName, searchIdentifier] = pluginKey;
1258
- const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => {
1259
- const [name, identifier] = item.key;
1260
- const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
1261
- const nameCheck = name === searchPluginName;
1262
- if (searchIdentifier) return identifierCheck && nameCheck;
1263
- return nameCheck;
1264
- });
1252
+ const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => item.name === pluginName);
1265
1253
  if (!pluginByPluginName?.length) {
1266
1254
  const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
1267
1255
  return corePlugin ? [corePlugin] : [];
@@ -1358,11 +1346,10 @@ var PluginManager = class {
1358
1346
  const usedPluginNames = this.#usedPluginNames;
1359
1347
  setUniqueName(plugin.name, usedPluginNames);
1360
1348
  const usageCount = usedPluginNames[plugin.name];
1361
- if (usageCount && usageCount > 1) this.events.emit("warn", `Multiple instances of plugin "${plugin.name}" detected. This behavior is deprecated and will be removed in v5.`, `Plugin key: [${plugin.name}, ${usageCount}]`);
1349
+ 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.`);
1362
1350
  return {
1363
1351
  install() {},
1364
- ...plugin,
1365
- key: [plugin.name, usedPluginNames[plugin.name]].filter(Boolean)
1352
+ ...plugin
1366
1353
  };
1367
1354
  }
1368
1355
  };
@@ -1469,7 +1456,7 @@ const fsStorage = defineStorage(() => ({
1469
1456
  }));
1470
1457
  //#endregion
1471
1458
  //#region package.json
1472
- var version = "5.0.0-alpha.1";
1459
+ var version = "5.0.0-alpha.2";
1473
1460
  //#endregion
1474
1461
  //#region src/utils/diagnostics.ts
1475
1462
  /**
@@ -1643,7 +1630,7 @@ async function safeBuild(options, overrides) {
1643
1630
  await events.emit("plugin:start", plugin);
1644
1631
  await events.emit("debug", {
1645
1632
  date: timestamp,
1646
- logs: ["Installing plugin...", ` • Plugin Key: [${plugin.key.join(", ")}]`]
1633
+ logs: ["Installing plugin...", ` • Plugin Name: ${plugin.name}`]
1647
1634
  });
1648
1635
  await installer(context);
1649
1636
  const duration = getElapsedMs(hrStart);
@@ -1669,7 +1656,7 @@ async function safeBuild(options, overrides) {
1669
1656
  date: errorTimestamp,
1670
1657
  logs: [
1671
1658
  "✗ Plugin installation failed",
1672
- ` • Plugin Key: ${JSON.stringify(plugin.key)}`,
1659
+ ` • Plugin Name: ${plugin.name}`,
1673
1660
  ` • Error: ${error.constructor.name} - ${error.message}`,
1674
1661
  " • Stack Trace:",
1675
1662
  error.stack || "No stack trace available"
@@ -1743,14 +1730,14 @@ async function safeBuild(options, overrides) {
1743
1730
  }
1744
1731
  }
1745
1732
  function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, pluginManager }) {
1746
- const pluginKeyMap = /* @__PURE__ */ new Map();
1747
- for (const plugin of pluginManager.plugins) pluginKeyMap.set(JSON.stringify(plugin.key), plugin);
1733
+ const pluginNameMap = /* @__PURE__ */ new Map();
1734
+ for (const plugin of pluginManager.plugins) pluginNameMap.set(plugin.name, plugin);
1748
1735
  return barrelFiles.flatMap((file) => {
1749
1736
  const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
1750
1737
  return (file.sources ?? []).flatMap((source) => {
1751
1738
  if (!file.path || !source.isIndexable) return [];
1752
1739
  const meta = file.meta;
1753
- const pluginOptions = (meta?.pluginKey ? pluginKeyMap.get(JSON.stringify(meta.pluginKey)) : void 0)?.options;
1740
+ const pluginOptions = (meta?.pluginName ? pluginNameMap.get(meta.pluginName) : void 0)?.options;
1754
1741
  if (!pluginOptions || pluginOptions.output?.barrelType === false) return [];
1755
1742
  const exportName = config.output.barrelType === "all" ? void 0 : source.name ? [source.name] : void 0;
1756
1743
  if (exportName?.some((n) => existingExports.has(n))) return [];