@kubb/core 5.8.1 → 5.8.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.
@@ -33,7 +33,7 @@ node_path = __toESM(node_path, 1);
33
33
  let _kubb_ast = require("@kubb/ast");
34
34
  let node_events = require("node:events");
35
35
  //#region package.json
36
- var version = "5.8.1";
36
+ var version = "5.8.2";
37
37
  //#endregion
38
38
  //#region ../../internals/utils/src/casing.ts
39
39
  /**
@@ -1021,13 +1021,61 @@ function checkDependencies({ name, dependencies, plugins }) {
1021
1021
  });
1022
1022
  }
1023
1023
  }
1024
- function defineExtension({ kind, meta, build }) {
1024
+ function createExtensionFactory({ kind, meta, build }) {
1025
1025
  const factory = (options) => build(options ?? {});
1026
1026
  return Object.assign(factory, meta ? {
1027
1027
  kind,
1028
1028
  meta
1029
1029
  } : { kind });
1030
1030
  }
1031
+ function defineExtension(definition) {
1032
+ switch (definition.kind) {
1033
+ case "plugin": {
1034
+ const { meta, dependencies, enforce, hooks = {}, setup } = definition;
1035
+ return createExtensionFactory({
1036
+ kind: "plugin",
1037
+ meta,
1038
+ build: (options) => ({
1039
+ name: meta.name,
1040
+ meta,
1041
+ options,
1042
+ dependencies,
1043
+ enforce,
1044
+ hooks,
1045
+ setup
1046
+ })
1047
+ });
1048
+ }
1049
+ case "adapter": {
1050
+ const { meta, setup, build } = definition;
1051
+ return createExtensionFactory({
1052
+ kind: "adapter",
1053
+ meta,
1054
+ build: (raw) => {
1055
+ const options = setup ? setup(raw) : raw;
1056
+ return Object.assign(build(options), {
1057
+ name: meta.name,
1058
+ meta,
1059
+ options
1060
+ });
1061
+ }
1062
+ });
1063
+ }
1064
+ case "parser": {
1065
+ const { meta, build } = definition;
1066
+ return createExtensionFactory({
1067
+ kind: "parser",
1068
+ meta,
1069
+ build: (options) => ({
1070
+ ...build(options),
1071
+ name: meta.name,
1072
+ meta,
1073
+ options
1074
+ })
1075
+ });
1076
+ }
1077
+ }
1078
+ }
1031
1079
  //#endregion
1032
1080
  //#region src/composables.ts
1033
1081
  const kubbContextKey = Symbol.for("kubb.context");
@@ -1160,7 +1208,7 @@ function assertPluginOption({ plugin, option, value, allowed }) {
1160
1208
  });
1161
1209
  }
1162
1210
  function definePlugin(input) {
1163
- if (typeof input === "function") return defineExtension({
1211
+ if (typeof input === "function") return createExtensionFactory({
1164
1212
  kind: "plugin",
1165
1213
  build: (options) => {
1166
1214
  const plugin = input(options);
@@ -1170,19 +1218,9 @@ function definePlugin(input) {
1170
1218
  };
1171
1219
  }
1172
1220
  });
1173
- const { meta, dependencies, enforce, hooks = {}, setup } = input;
1174
1221
  return defineExtension({
1175
1222
  kind: "plugin",
1176
- meta,
1177
- build: (options) => ({
1178
- name: meta.name,
1179
- meta,
1180
- options,
1181
- dependencies,
1182
- enforce,
1183
- hooks,
1184
- setup
1185
- })
1223
+ ...input
1186
1224
  });
1187
1225
  }
1188
1226
  //#endregion
@@ -2894,6 +2932,12 @@ Object.defineProperty(exports, "clean", {
2894
2932
  return clean;
2895
2933
  }
2896
2934
  });
2935
+ Object.defineProperty(exports, "createExtensionFactory", {
2936
+ enumerable: true,
2937
+ get: function() {
2938
+ return createExtensionFactory;
2939
+ }
2940
+ });
2897
2941
  Object.defineProperty(exports, "createNodeCache", {
2898
2942
  enumerable: true,
2899
2943
  get: function() {
@@ -3051,4 +3095,4 @@ Object.defineProperty(exports, "write", {
3051
3095
  }
3052
3096
  });
3053
3097
 
3054
- //# sourceMappingURL=KubbDriver-DQ7pt93q.cjs.map
3098
+ //# sourceMappingURL=KubbDriver-DxWuvJWV.cjs.map