@kubb/core 5.0.0-alpha.1 → 5.0.0-alpha.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/hooks.cjs CHANGED
@@ -1,24 +1,48 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("./chunk-ByKO4r7w.cjs");
3
3
  let _kubb_react_fabric = require("@kubb/react-fabric");
4
+ //#region src/hooks/useKubb.ts
5
+ function useKubb() {
6
+ const { meta } = (0, _kubb_react_fabric.useApp)();
7
+ return {
8
+ plugin: meta.plugin,
9
+ mode: meta.mode,
10
+ config: meta.pluginManager.config,
11
+ getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),
12
+ getFile: meta.pluginManager.getFile.bind(meta.pluginManager),
13
+ resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),
14
+ resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager)
15
+ };
16
+ }
17
+ //#endregion
4
18
  //#region src/hooks/useMode.ts
19
+ /**
20
+ * @deprecated use `useKubb` instead
21
+ */
5
22
  function useMode() {
6
23
  const { meta } = (0, _kubb_react_fabric.useApp)();
7
24
  return meta.mode;
8
25
  }
9
26
  //#endregion
10
27
  //#region src/hooks/usePlugin.ts
28
+ /**
29
+ * @deprecated use useApp instead
30
+ */
11
31
  function usePlugin() {
12
32
  const { meta } = (0, _kubb_react_fabric.useApp)();
13
33
  return meta.plugin;
14
34
  }
15
35
  //#endregion
16
36
  //#region src/hooks/usePluginManager.ts
37
+ /**
38
+ * @deprecated use `useKubb` instead
39
+ */
17
40
  function usePluginManager() {
18
41
  const { meta } = (0, _kubb_react_fabric.useApp)();
19
42
  return meta.pluginManager;
20
43
  }
21
44
  //#endregion
45
+ exports.useKubb = useKubb;
22
46
  exports.useMode = useMode;
23
47
  exports.usePlugin = usePlugin;
24
48
  exports.usePluginManager = usePluginManager;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;;AAGA,SAAgB,UAAyB;CACvC,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA0C;AAElD,QAAO,KAAK;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA+C;AAEvD,QAAO,KAAK;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,UAAA,GAAA,mBAAA,SAAmD;AAE3D,QAAO,KAAK"}
1
+ {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp as useAppBase } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>() {\n const { meta } = useAppBase<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n pluginManager: PluginManager\n }>()\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config: meta.pluginManager.config,\n getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),\n getFile: meta.pluginManager.getFile.bind(meta.pluginManager),\n resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),\n resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager),\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useApp instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;;AAKA,SAAgB,UAAwE;CACtF,MAAM,EAAE,UAAA,GAAA,mBAAA,SAIJ;AAEJ,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,KAAK,cAAc;EAC3B,iBAAiB,KAAK,cAAc,gBAAgB,KAAK,KAAK,cAAc;EAC5E,SAAS,KAAK,cAAc,QAAQ,KAAK,KAAK,cAAc;EAC5D,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACpE,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACrE;;;;;;;ACdH,SAAgB,UAAyB;CACvC,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA0C;AAElD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA+C;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,UAAA,GAAA,mBAAA,SAAmD;AAE3D,QAAO,KAAK"}
package/dist/hooks.d.ts CHANGED
@@ -1,15 +1,49 @@
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, T as ResolvePathParams, _ as PluginFactoryOptions, a as Config, h as Plugin, w as ResolveNameParams } from "./types-CiPWLv-5.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
+ //#region src/hooks/useKubb.d.ts
6
+ declare function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): {
7
+ plugin: Plugin<TOptions>;
8
+ mode: KubbFile.Mode;
9
+ config: Config;
10
+ getPluginByName: (pluginName: string) => Plugin | undefined;
11
+ getFile: <TOptions_1 = object>({
12
+ name,
13
+ mode,
14
+ extname,
15
+ pluginName,
16
+ options
17
+ }: {
18
+ name: string;
19
+ mode?: KubbFile.Mode;
20
+ extname: KubbFile.Extname;
21
+ pluginName: string;
22
+ options?: TOptions_1 | undefined;
23
+ }) => KubbFile.File<{
24
+ pluginName: string;
25
+ }>;
26
+ resolveName: (params: ResolveNameParams) => string;
27
+ resolvePath: <TOptions_1 = object>(params: ResolvePathParams<TOptions_1>) => KubbFile.Path;
28
+ };
29
+ //#endregion
5
30
  //#region src/hooks/useMode.d.ts
31
+ /**
32
+ * @deprecated use `useKubb` instead
33
+ */
6
34
  declare function useMode(): KubbFile.Mode;
7
35
  //#endregion
8
36
  //#region src/hooks/usePlugin.d.ts
37
+ /**
38
+ * @deprecated use useApp instead
39
+ */
9
40
  declare function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions>;
10
41
  //#endregion
11
42
  //#region src/hooks/usePluginManager.d.ts
43
+ /**
44
+ * @deprecated use `useKubb` instead
45
+ */
12
46
  declare function usePluginManager(): PluginManager;
13
47
  //#endregion
14
- export { useMode, usePlugin, usePluginManager };
48
+ export { useKubb, useMode, usePlugin, usePluginManager };
15
49
  //# sourceMappingURL=hooks.d.ts.map
package/dist/hooks.js CHANGED
@@ -1,23 +1,46 @@
1
1
  import "./chunk--u3MIqq1.js";
2
2
  import { useApp } from "@kubb/react-fabric";
3
+ //#region src/hooks/useKubb.ts
4
+ function useKubb() {
5
+ const { meta } = useApp();
6
+ return {
7
+ plugin: meta.plugin,
8
+ mode: meta.mode,
9
+ config: meta.pluginManager.config,
10
+ getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),
11
+ getFile: meta.pluginManager.getFile.bind(meta.pluginManager),
12
+ resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),
13
+ resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager)
14
+ };
15
+ }
16
+ //#endregion
3
17
  //#region src/hooks/useMode.ts
18
+ /**
19
+ * @deprecated use `useKubb` instead
20
+ */
4
21
  function useMode() {
5
22
  const { meta } = useApp();
6
23
  return meta.mode;
7
24
  }
8
25
  //#endregion
9
26
  //#region src/hooks/usePlugin.ts
27
+ /**
28
+ * @deprecated use useApp instead
29
+ */
10
30
  function usePlugin() {
11
31
  const { meta } = useApp();
12
32
  return meta.plugin;
13
33
  }
14
34
  //#endregion
15
35
  //#region src/hooks/usePluginManager.ts
36
+ /**
37
+ * @deprecated use `useKubb` instead
38
+ */
16
39
  function usePluginManager() {
17
40
  const { meta } = useApp();
18
41
  return meta.pluginManager;
19
42
  }
20
43
  //#endregion
21
- export { useMode, usePlugin, usePluginManager };
44
+ export { useKubb, useMode, usePlugin, usePluginManager };
22
45
 
23
46
  //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;AAGA,SAAgB,UAAyB;CACvC,MAAM,EAAE,SAAS,QAAiC;AAElD,QAAO,KAAK;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,QAAsC;AAEvD,QAAO,KAAK;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,SAAS,QAA0C;AAE3D,QAAO,KAAK"}
1
+ {"version":3,"file":"hooks.js","names":["useAppBase"],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp as useAppBase } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>() {\n const { meta } = useAppBase<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n pluginManager: PluginManager\n }>()\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config: meta.pluginManager.config,\n getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),\n getFile: meta.pluginManager.getFile.bind(meta.pluginManager),\n resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),\n resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager),\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useApp instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;AAKA,SAAgB,UAAwE;CACtF,MAAM,EAAE,SAASA,QAIb;AAEJ,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,KAAK,cAAc;EAC3B,iBAAiB,KAAK,cAAc,gBAAgB,KAAK,KAAK,cAAc;EAC5E,SAAS,KAAK,cAAc,QAAQ,KAAK,KAAK,cAAc;EAC5D,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACpE,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACrE;;;;;;;ACdH,SAAgB,UAAyB;CACvC,MAAM,EAAE,SAAS,QAAiC;AAElD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,QAAsC;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,SAAS,QAA0C;AAE3D,QAAO,KAAK"}
package/dist/index.cjs CHANGED
@@ -959,7 +959,7 @@ function isPromiseRejectedResult(result) {
959
959
  //#region src/PluginManager.ts
960
960
  function getMode(fileOrFolder) {
961
961
  if (!fileOrFolder) return "split";
962
- return node_path.default.extname(fileOrFolder) ? "single" : "split";
962
+ return (0, node_path.extname)(fileOrFolder) ? "single" : "split";
963
963
  }
964
964
  var PluginManager = class {
965
965
  config;
@@ -969,6 +969,7 @@ var PluginManager = class {
969
969
  * the build pipeline after the adapter's `parse()` resolves.
970
970
  */
971
971
  rootNode = void 0;
972
+ adapter = void 0;
972
973
  #studioIsOpen = false;
973
974
  #plugins = /* @__PURE__ */ new Set();
974
975
  #usedPluginNames = {};
@@ -994,7 +995,7 @@ var PluginManager = class {
994
995
  plugin,
995
996
  events: this.options.events,
996
997
  pluginManager: this,
997
- mode: getMode(node_path.default.resolve(this.config.root, this.config.output.path)),
998
+ mode: getMode((0, node_path.resolve)(this.config.root, this.config.output.path)),
998
999
  addFile: async (...files) => {
999
1000
  await this.options.fabric.addFile(...files);
1000
1001
  },
@@ -1004,10 +1005,13 @@ var PluginManager = class {
1004
1005
  get rootNode() {
1005
1006
  return pluginManager.rootNode;
1006
1007
  },
1008
+ get adapter() {
1009
+ return pluginManager.adapter;
1010
+ },
1007
1011
  openInStudio(options) {
1012
+ if (!pluginManager.config.devtools || pluginManager.#studioIsOpen) return;
1008
1013
  if (typeof pluginManager.config.devtools !== "object") throw new Error("Devtools must be an object");
1009
- if (!pluginManager.rootNode) throw new Error("RootNode is not defined, make sure you have set the parser in kubb.config.ts");
1010
- if (pluginManager.#studioIsOpen) return;
1014
+ if (!pluginManager.rootNode || !pluginManager.adapter) throw new Error("adapter is not defined, make sure you have set the parser in kubb.config.ts");
1011
1015
  pluginManager.#studioIsOpen = true;
1012
1016
  const studioUrl = pluginManager.config.devtools?.studioUrl ?? "https://studio.kubb.dev";
1013
1017
  return openInStudio(pluginManager.rootNode, studioUrl, options);
@@ -1026,29 +1030,32 @@ var PluginManager = class {
1026
1030
  get plugins() {
1027
1031
  return this.#getSortedPlugins();
1028
1032
  }
1029
- getFile({ name, mode, extname, pluginKey, options }) {
1030
- const baseName = `${name}${extname}`;
1033
+ getFile({ name, mode, extname, pluginName, options }) {
1034
+ const resolvedName = mode ? mode === "single" ? "" : this.resolveName({
1035
+ name,
1036
+ pluginName,
1037
+ type: "file"
1038
+ }) : name;
1031
1039
  const path = this.resolvePath({
1032
- baseName,
1040
+ baseName: `${resolvedName}${extname}`,
1033
1041
  mode,
1034
- pluginKey,
1042
+ pluginName,
1035
1043
  options
1036
1044
  });
1037
- if (!path) throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
1045
+ if (!path) throw new Error(`Filepath should be defined for resolvedName "${resolvedName}" and pluginName "${pluginName}"`);
1038
1046
  return {
1039
1047
  path,
1040
- baseName,
1041
- meta: { pluginKey },
1048
+ baseName: (0, node_path.basename)(path),
1049
+ meta: { pluginName },
1042
1050
  sources: [],
1043
1051
  imports: [],
1044
1052
  exports: []
1045
1053
  };
1046
1054
  }
1047
1055
  resolvePath = (params) => {
1048
- const root = node_path.default.resolve(this.config.root, this.config.output.path);
1049
- const defaultPath = node_path.default.resolve(root, params.baseName);
1050
- if (params.pluginKey) return this.hookForPluginSync({
1051
- pluginKey: params.pluginKey,
1056
+ const defaultPath = (0, node_path.resolve)((0, node_path.resolve)(this.config.root, this.config.output.path), params.baseName);
1057
+ if (params.pluginName) return this.hookForPluginSync({
1058
+ pluginName: params.pluginName,
1052
1059
  hookName: "resolvePath",
1053
1060
  parameters: [
1054
1061
  params.baseName,
@@ -1066,9 +1073,9 @@ var PluginManager = class {
1066
1073
  })?.result || defaultPath;
1067
1074
  };
1068
1075
  resolveName = (params) => {
1069
- if (params.pluginKey) {
1076
+ if (params.pluginName) {
1070
1077
  const names = this.hookForPluginSync({
1071
- pluginKey: params.pluginKey,
1078
+ pluginName: params.pluginName,
1072
1079
  hookName: "resolveName",
1073
1080
  parameters: [params.name.trim(), params.type]
1074
1081
  });
@@ -1083,8 +1090,8 @@ var PluginManager = class {
1083
1090
  /**
1084
1091
  * Run a specific hookName for plugin x.
1085
1092
  */
1086
- async hookForPlugin({ pluginKey, hookName, parameters }) {
1087
- const plugins = this.getPluginsByKey(hookName, pluginKey);
1093
+ async hookForPlugin({ pluginName, hookName, parameters }) {
1094
+ const plugins = this.getPluginsByName(hookName, pluginName);
1088
1095
  this.events.emit("plugins:hook:progress:start", {
1089
1096
  hookName,
1090
1097
  plugins
@@ -1105,8 +1112,8 @@ var PluginManager = class {
1105
1112
  /**
1106
1113
  * Run a specific hookName for plugin x.
1107
1114
  */
1108
- hookForPluginSync({ pluginKey, hookName, parameters }) {
1109
- return this.getPluginsByKey(hookName, pluginKey).map((plugin) => {
1115
+ hookForPluginSync({ pluginName, hookName, parameters }) {
1116
+ return this.getPluginsByName(hookName, pluginName).map((plugin) => {
1110
1117
  return this.#executeSync({
1111
1118
  strategy: "hookFirst",
1112
1119
  hookName,
@@ -1234,7 +1241,8 @@ var PluginManager = class {
1234
1241
  if (hookName) return plugins.filter((plugin) => hookName in plugin);
1235
1242
  return plugins.map((plugin) => {
1236
1243
  if (plugin.pre) {
1237
- const missingPlugins = plugin.pre.filter((pluginName) => !plugins.find((pluginToFind) => pluginToFind.name === pluginName));
1244
+ let missingPlugins = plugin.pre.filter((pluginName) => !plugins.find((pluginToFind) => pluginToFind.name === pluginName));
1245
+ if (missingPlugins.includes("plugin-oas") && this.adapter) missingPlugins = missingPlugins.filter((pluginName) => pluginName !== "plugin-oas");
1238
1246
  if (missingPlugins.length > 0) throw new ValidationPluginError(`The plugin '${plugin.name}' has a pre set that references missing plugins for '${missingPlugins.join(", ")}'`);
1239
1247
  }
1240
1248
  return plugin;
@@ -1244,24 +1252,12 @@ var PluginManager = class {
1244
1252
  return 0;
1245
1253
  });
1246
1254
  }
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
- });
1255
+ getPluginByName(pluginName) {
1256
+ return [...this.#plugins].find((item) => item.name === pluginName);
1254
1257
  }
1255
- getPluginsByKey(hookName, pluginKey) {
1258
+ getPluginsByName(hookName, pluginName) {
1256
1259
  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
- });
1260
+ const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => item.name === pluginName);
1265
1261
  if (!pluginByPluginName?.length) {
1266
1262
  const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
1267
1263
  return corePlugin ? [corePlugin] : [];
@@ -1358,11 +1354,10 @@ var PluginManager = class {
1358
1354
  const usedPluginNames = this.#usedPluginNames;
1359
1355
  setUniqueName(plugin.name, usedPluginNames);
1360
1356
  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}]`);
1357
+ 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
1358
  return {
1363
1359
  install() {},
1364
- ...plugin,
1365
- key: [plugin.name, usedPluginNames[plugin.name]].filter(Boolean)
1360
+ ...plugin
1366
1361
  };
1367
1362
  }
1368
1363
  };
@@ -1469,7 +1464,7 @@ const fsStorage = defineStorage(() => ({
1469
1464
  }));
1470
1465
  //#endregion
1471
1466
  //#region package.json
1472
- var version = "5.0.0-alpha.1";
1467
+ var version = "5.0.0-alpha.3";
1473
1468
  //#endregion
1474
1469
  //#region src/utils/diagnostics.ts
1475
1470
  /**
@@ -1594,6 +1589,7 @@ async function setup(options) {
1594
1589
  date: /* @__PURE__ */ new Date(),
1595
1590
  logs: [`Running adapter: ${definedConfig.adapter.name}`]
1596
1591
  });
1592
+ pluginManager.adapter = definedConfig.adapter;
1597
1593
  pluginManager.rootNode = await definedConfig.adapter.parse(source);
1598
1594
  await events.emit("debug", {
1599
1595
  date: /* @__PURE__ */ new Date(),
@@ -1643,7 +1639,7 @@ async function safeBuild(options, overrides) {
1643
1639
  await events.emit("plugin:start", plugin);
1644
1640
  await events.emit("debug", {
1645
1641
  date: timestamp,
1646
- logs: ["Installing plugin...", ` • Plugin Key: [${plugin.key.join(", ")}]`]
1642
+ logs: ["Installing plugin...", ` • Plugin Name: ${plugin.name}`]
1647
1643
  });
1648
1644
  await installer(context);
1649
1645
  const duration = getElapsedMs(hrStart);
@@ -1669,7 +1665,7 @@ async function safeBuild(options, overrides) {
1669
1665
  date: errorTimestamp,
1670
1666
  logs: [
1671
1667
  "✗ Plugin installation failed",
1672
- ` • Plugin Key: ${JSON.stringify(plugin.key)}`,
1668
+ ` • Plugin Name: ${plugin.name}`,
1673
1669
  ` • Error: ${error.constructor.name} - ${error.message}`,
1674
1670
  " • Stack Trace:",
1675
1671
  error.stack || "No stack trace available"
@@ -1743,14 +1739,14 @@ async function safeBuild(options, overrides) {
1743
1739
  }
1744
1740
  }
1745
1741
  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);
1742
+ const pluginNameMap = /* @__PURE__ */ new Map();
1743
+ for (const plugin of pluginManager.plugins) pluginNameMap.set(plugin.name, plugin);
1748
1744
  return barrelFiles.flatMap((file) => {
1749
1745
  const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
1750
1746
  return (file.sources ?? []).flatMap((source) => {
1751
1747
  if (!file.path || !source.isIndexable) return [];
1752
1748
  const meta = file.meta;
1753
- const pluginOptions = (meta?.pluginKey ? pluginKeyMap.get(JSON.stringify(meta.pluginKey)) : void 0)?.options;
1749
+ const pluginOptions = (meta?.pluginName ? pluginNameMap.get(meta.pluginName) : void 0)?.options;
1754
1750
  if (!pluginOptions || pluginOptions.output?.barrelType === false) return [];
1755
1751
  const exportName = config.output.barrelType === "all" ? void 0 : source.name ? [source.name] : void 0;
1756
1752
  if (exportName?.some((n) => existingExports.has(n))) return [];