@kubb/core 3.0.0-alpha.2 → 3.0.0-alpha.21

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.
Files changed (107) hide show
  1. package/README.md +13 -4
  2. package/dist/{FileManager-Bw-FNS3q.d.cts → FileManager-4lbobkix.d.cts} +124 -84
  3. package/dist/{FileManager-BW--rO8q.d.ts → FileManager-CdXrquQt.d.ts} +124 -84
  4. package/dist/chunk-2EU7DMPM.js +96 -0
  5. package/dist/chunk-2EU7DMPM.js.map +1 -0
  6. package/dist/{chunk-LM2YQC3T.cjs → chunk-3MDDPVXB.cjs} +81 -51
  7. package/dist/chunk-3MDDPVXB.cjs.map +1 -0
  8. package/dist/chunk-4X5FFJPJ.js +8 -13
  9. package/dist/chunk-4X5FFJPJ.js.map +1 -1
  10. package/dist/{chunk-67C6RBGQ.cjs → chunk-6NKPFDXC.cjs} +28 -29
  11. package/dist/chunk-6NKPFDXC.cjs.map +1 -0
  12. package/dist/chunk-CLTNHSMO.js +895 -0
  13. package/dist/chunk-CLTNHSMO.js.map +1 -0
  14. package/dist/{chunk-3OXCZ5DJ.js → chunk-E6CN2CZC.js} +63 -54
  15. package/dist/chunk-E6CN2CZC.js.map +1 -0
  16. package/dist/chunk-HBQM723K.js +1049 -0
  17. package/dist/chunk-HBQM723K.js.map +1 -0
  18. package/dist/chunk-MHOAMP5V.cjs +1537 -0
  19. package/dist/chunk-MHOAMP5V.cjs.map +1 -0
  20. package/dist/chunk-PWFXUBH6.cjs +101 -0
  21. package/dist/chunk-PWFXUBH6.cjs.map +1 -0
  22. package/dist/chunk-RSTRL2FG.cjs +42 -0
  23. package/dist/chunk-RSTRL2FG.cjs.map +1 -0
  24. package/dist/chunk-SWGRKRKB.cjs +1088 -0
  25. package/dist/chunk-SWGRKRKB.cjs.map +1 -0
  26. package/dist/index.cjs +551 -599
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +7 -22
  29. package/dist/index.d.ts +7 -22
  30. package/dist/index.js +442 -512
  31. package/dist/index.js.map +1 -1
  32. package/dist/{logger-DChjnJMn.d.cts → logger-DvbHXjIO.d.cts} +29 -19
  33. package/dist/{logger-DChjnJMn.d.ts → logger-DvbHXjIO.d.ts} +29 -19
  34. package/dist/logger.cjs +25 -15
  35. package/dist/logger.cjs.map +1 -1
  36. package/dist/logger.d.cts +1 -2
  37. package/dist/logger.d.ts +1 -2
  38. package/dist/logger.js +3 -15
  39. package/dist/logger.js.map +1 -1
  40. package/dist/mocks.cjs +42 -31
  41. package/dist/mocks.cjs.map +1 -1
  42. package/dist/mocks.d.cts +7 -9
  43. package/dist/mocks.d.ts +7 -9
  44. package/dist/mocks.js +35 -33
  45. package/dist/mocks.js.map +1 -1
  46. package/dist/prompt-7BUJOOIL.cjs +760 -0
  47. package/dist/prompt-7BUJOOIL.cjs.map +1 -0
  48. package/dist/prompt-WQQUN22Z.js +749 -0
  49. package/dist/prompt-WQQUN22Z.js.map +1 -0
  50. package/dist/transformers.cjs +216 -49
  51. package/dist/transformers.cjs.map +1 -1
  52. package/dist/transformers.d.cts +1 -3
  53. package/dist/transformers.d.ts +1 -3
  54. package/dist/transformers.js +149 -35
  55. package/dist/transformers.js.map +1 -1
  56. package/dist/utils.cjs +65 -26
  57. package/dist/utils.cjs.map +1 -1
  58. package/dist/utils.d.cts +32 -3
  59. package/dist/utils.d.ts +32 -3
  60. package/dist/utils.js +3 -26
  61. package/dist/utils.js.map +1 -1
  62. package/package.json +11 -14
  63. package/src/BarrelManager.ts +95 -109
  64. package/src/{Generator.ts → BaseGenerator.ts} +1 -1
  65. package/src/FileManager.ts +190 -298
  66. package/src/PackageManager.ts +1 -1
  67. package/src/PluginManager.ts +149 -90
  68. package/src/PromiseManager.ts +1 -1
  69. package/src/__snapshots__/barrel.json +93 -0
  70. package/src/__snapshots__/grouped.json +120 -0
  71. package/src/__snapshots__/ordered.json +68 -0
  72. package/src/build.ts +87 -122
  73. package/src/config.ts +2 -4
  74. package/src/errors.ts +0 -11
  75. package/src/index.ts +2 -3
  76. package/src/logger.ts +76 -34
  77. package/src/plugin.ts +2 -5
  78. package/src/transformers/escape.ts +0 -10
  79. package/src/transformers/index.ts +2 -3
  80. package/src/transformers/trim.ts +0 -4
  81. package/src/types.ts +48 -17
  82. package/src/utils/TreeNode.ts +132 -50
  83. package/src/utils/executeStrategies.ts +3 -3
  84. package/src/utils/index.ts +2 -1
  85. package/src/utils/parser.ts +166 -0
  86. package/dist/chunk-3OXCZ5DJ.js.map +0 -1
  87. package/dist/chunk-5JZNFPUP.js +0 -309
  88. package/dist/chunk-5JZNFPUP.js.map +0 -1
  89. package/dist/chunk-67C6RBGQ.cjs.map +0 -1
  90. package/dist/chunk-ADC5UNZ5.cjs +0 -1227
  91. package/dist/chunk-ADC5UNZ5.cjs.map +0 -1
  92. package/dist/chunk-HMLY7DHA.js +0 -16
  93. package/dist/chunk-HMLY7DHA.js.map +0 -1
  94. package/dist/chunk-JKZG2IJR.js +0 -283
  95. package/dist/chunk-JKZG2IJR.js.map +0 -1
  96. package/dist/chunk-LM2YQC3T.cjs.map +0 -1
  97. package/dist/chunk-PZT4CTBV.cjs +0 -299
  98. package/dist/chunk-PZT4CTBV.cjs.map +0 -1
  99. package/dist/chunk-SA2GZKXS.js +0 -596
  100. package/dist/chunk-SA2GZKXS.js.map +0 -1
  101. package/dist/chunk-XCPFG6DO.cjs +0 -66
  102. package/dist/chunk-XCPFG6DO.cjs.map +0 -1
  103. package/dist/chunk-YTSNYMHW.cjs +0 -320
  104. package/dist/chunk-YTSNYMHW.cjs.map +0 -1
  105. package/schema.json +0 -86
  106. package/src/utils/cache.ts +0 -35
  107. package/src/utils/getParser.ts +0 -17
package/dist/index.cjs CHANGED
@@ -1,48 +1,44 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
-
6
-
7
- var _chunkLM2YQC3Tcjs = require('./chunk-LM2YQC3T.cjs');
8
-
9
-
10
-
11
- var _chunkADC5UNZ5cjs = require('./chunk-ADC5UNZ5.cjs');
12
-
13
-
14
- var _chunkPZT4CTBVcjs = require('./chunk-PZT4CTBV.cjs');
15
-
16
-
17
-
18
- var _chunkYTSNYMHWcjs = require('./chunk-YTSNYMHW.cjs');
19
- require('./chunk-67C6RBGQ.cjs');
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
- var _chunkXCPFG6DOcjs = require('./chunk-XCPFG6DO.cjs');
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var chunkPWFXUBH6_cjs = require('./chunk-PWFXUBH6.cjs');
6
+ var chunk3MDDPVXB_cjs = require('./chunk-3MDDPVXB.cjs');
7
+ var chunkMHOAMP5V_cjs = require('./chunk-MHOAMP5V.cjs');
8
+ require('./chunk-6NKPFDXC.cjs');
9
+ require('./chunk-SWGRKRKB.cjs');
10
+ var chunkRSTRL2FG_cjs = require('./chunk-RSTRL2FG.cjs');
11
+ var fs = require('@kubb/fs');
12
+ var path3 = require('path');
13
+ var mod = require('module');
14
+ var os = require('os');
15
+ var url = require('url');
16
+ var process = require('process');
17
+ var fs$1 = require('fs');
18
+ var semver = require('semver');
19
+
20
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
+
22
+ var path3__default = /*#__PURE__*/_interopDefault(path3);
23
+ var mod__default = /*#__PURE__*/_interopDefault(mod);
24
+ var os__default = /*#__PURE__*/_interopDefault(os);
25
+ var process__default = /*#__PURE__*/_interopDefault(process);
26
+ var fs__default = /*#__PURE__*/_interopDefault(fs$1);
29
27
 
30
28
  // src/index.ts
31
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
29
+ chunkRSTRL2FG_cjs.init_cjs_shims();
32
30
 
33
31
  // src/build.ts
34
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
35
- var _fs = require('@kubb/fs');
32
+ chunkRSTRL2FG_cjs.init_cjs_shims();
36
33
 
37
34
  // src/PluginManager.ts
38
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
39
-
35
+ chunkRSTRL2FG_cjs.init_cjs_shims();
40
36
 
41
37
  // src/PromiseManager.ts
42
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
38
+ chunkRSTRL2FG_cjs.init_cjs_shims();
43
39
 
44
40
  // src/utils/executeStrategies.ts
45
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
41
+ chunkRSTRL2FG_cjs.init_cjs_shims();
46
42
  function hookSeq(promises) {
47
43
  return promises.filter(Boolean).reduce(
48
44
  (promise, func) => {
@@ -77,11 +73,10 @@ function hookParallel(promises) {
77
73
  }
78
74
 
79
75
  // src/PromiseManager.ts
80
- var _options;
81
76
  var PromiseManager = class {
77
+ #options = {};
82
78
  constructor(options = {}) {
83
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _options, {});
84
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options, options);
79
+ this.#options = options;
85
80
  return this;
86
81
  }
87
82
  run(strategy, promises) {
@@ -89,7 +84,7 @@ var PromiseManager = class {
89
84
  return hookSeq(promises);
90
85
  }
91
86
  if (strategy === "first") {
92
- return hookFirst(promises, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options).nullCheck);
87
+ return hookFirst(promises, this.#options.nullCheck);
93
88
  }
94
89
  if (strategy === "parallel") {
95
90
  return hookParallel(promises);
@@ -97,59 +92,20 @@ var PromiseManager = class {
97
92
  throw new Error(`${strategy} not implemented`);
98
93
  }
99
94
  };
100
- _options = new WeakMap();
101
95
  function isPromise(result) {
102
- return !!result && typeof _optionalChain([result, 'optionalAccess', _2 => _2.then]) === "function";
96
+ return !!result && typeof result?.then === "function";
103
97
  }
104
98
  function isPromiseRejectedResult(result) {
105
99
  return result.status === "rejected";
106
100
  }
107
101
 
108
102
  // src/errors.ts
109
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
110
- var Warning = class extends Error {
111
- constructor(message, options) {
112
- super(message, { cause: _optionalChain([options, 'optionalAccess', _3 => _3.cause]) });
113
- this.name = "Warning";
114
- }
115
- };
103
+ chunkRSTRL2FG_cjs.init_cjs_shims();
116
104
  var ValidationPluginError = class extends Error {
117
105
  };
118
106
 
119
107
  // src/plugin.ts
120
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
121
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
122
-
123
- // src/utils/cache.ts
124
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
125
- function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
126
- return {
127
- set(id, value) {
128
- Store[id] = [0, value];
129
- },
130
- get(id) {
131
- const item = Store[id];
132
- if (!item) {
133
- return null;
134
- }
135
- item[0] = 0;
136
- return item[1];
137
- },
138
- has(id) {
139
- const item = Store[id];
140
- if (!item) {
141
- return false;
142
- }
143
- item[0] = 0;
144
- return true;
145
- },
146
- delete(id) {
147
- return delete Store[id];
148
- }
149
- };
150
- }
151
-
152
- // src/plugin.ts
108
+ chunkRSTRL2FG_cjs.init_cjs_shims();
153
109
  function createPlugin(factory) {
154
110
  return (options = {}) => {
155
111
  return factory(options);
@@ -183,13 +139,12 @@ var pluginCore = createPlugin((options) => {
183
139
  return resolvedFiles;
184
140
  },
185
141
  resolvePath,
186
- resolveName,
187
- cache: createPluginCache()
142
+ resolveName
188
143
  };
189
144
  },
190
145
  resolvePath(baseName) {
191
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
192
- return _path2.default.resolve(root, baseName);
146
+ const root = path3__default.default.resolve(options.config.root, options.config.output.path);
147
+ return path3__default.default.resolve(root, baseName);
193
148
  },
194
149
  resolveName(name) {
195
150
  return name;
@@ -198,75 +153,25 @@ var pluginCore = createPlugin((options) => {
198
153
  });
199
154
 
200
155
  // src/PluginManager.ts
201
- var _core, _usedPluginNames, _promiseManager, _PluginManager_instances, getSortedPlugins_fn, addExecutedToCallStack_fn, execute_fn, executeSync_fn, catcher_fn, parse_fn;
202
156
  var PluginManager = class {
157
+ plugins = /* @__PURE__ */ new Set();
158
+ fileManager;
159
+ events = new chunk3MDDPVXB_cjs.EventEmitter();
160
+ config;
161
+ executed = [];
162
+ logger;
163
+ options;
164
+ #core;
165
+ #usedPluginNames = {};
166
+ #promiseManager;
203
167
  constructor(config, options) {
204
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _PluginManager_instances);
205
- this.events = new (0, _chunkLM2YQC3Tcjs.EventEmitter)();
206
- this.executed = [];
207
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _core);
208
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _usedPluginNames, {});
209
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _promiseManager);
210
- this.resolvePath = (params) => {
211
- if (params.pluginKey) {
212
- const paths = this.hookForPluginSync({
213
- pluginKey: params.pluginKey,
214
- hookName: "resolvePath",
215
- parameters: [params.baseName, params.mode, params.options]
216
- });
217
- if (paths && _optionalChain([paths, 'optionalAccess', _4 => _4.length]) > 1) {
218
- this.logger.emit("debug", [
219
- `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
220
-
221
- Paths: ${JSON.stringify(paths, void 0, 2)}
222
-
223
- Falling back on the first item.
224
- `
225
- ]);
226
- }
227
- return _optionalChain([paths, 'optionalAccess', _5 => _5.at, 'call', _6 => _6(0)]);
228
- }
229
- return this.hookFirstSync({
230
- hookName: "resolvePath",
231
- parameters: [params.baseName, params.mode, params.options]
232
- }).result;
233
- };
234
- this.resolveName = (params) => {
235
- if (params.pluginKey) {
236
- const names = this.hookForPluginSync({
237
- pluginKey: params.pluginKey,
238
- hookName: "resolveName",
239
- parameters: [params.name, params.type]
240
- });
241
- if (names && _optionalChain([names, 'optionalAccess', _7 => _7.length]) > 1) {
242
- this.logger.emit("debug", [
243
- `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
244
-
245
- Names: ${JSON.stringify(names, void 0, 2)}
246
-
247
- Falling back on the first item.
248
- `
249
- ]);
250
- }
251
- return _chunkPZT4CTBVcjs.transformReservedWord.call(void 0, _optionalChain([names, 'optionalAccess', _8 => _8.at, 'call', _9 => _9(0)]) || params.name);
252
- }
253
- const name = this.hookFirstSync({
254
- hookName: "resolveName",
255
- parameters: [params.name, params.type]
256
- }).result;
257
- return _chunkPZT4CTBVcjs.transformReservedWord.call(void 0, name);
258
- };
259
168
  this.config = config;
169
+ this.options = options;
260
170
  this.logger = options.logger;
261
- this.queue = new (0, _chunkADC5UNZ5cjs.PQueue)({ concurrency: 1 });
262
- this.fileManager = new (0, _chunkADC5UNZ5cjs.FileManager)({
263
- task: options.task,
264
- queue: this.queue
171
+ this.fileManager = new chunkMHOAMP5V_cjs.FileManager();
172
+ this.#promiseManager = new PromiseManager({
173
+ nullCheck: (state) => !!state?.result
265
174
  });
266
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _promiseManager, new PromiseManager({
267
- nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _10 => _10.result])
268
- }));
269
- const plugins = config.plugins || [];
270
175
  const core = pluginCore({
271
176
  config,
272
177
  logger: this.logger,
@@ -274,34 +179,90 @@ Falling back on the first item.
274
179
  fileManager: this.fileManager,
275
180
  resolvePath: this.resolvePath.bind(this),
276
181
  resolveName: this.resolveName.bind(this),
277
- getPlugins: _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).bind(this)
182
+ getPlugins: this.#getSortedPlugins.bind(this)
278
183
  });
279
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _core, _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, parse_fn).call(this, core, this, core.context.call(null)));
280
- this.plugins = [_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core), ...plugins].map((plugin) => {
281
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, parse_fn).call(this, plugin, this, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context);
184
+ this.#core = this.#parse(core, this, core.context.call(null));
185
+ [this.#core, ...config.plugins || []].forEach((plugin) => {
186
+ const parsedPlugin = this.#parse(plugin, this, this.#core.context);
187
+ this.plugins.add(parsedPlugin);
282
188
  });
283
189
  return this;
284
190
  }
285
191
  getFile({ name, mode, extName, pluginKey, options }) {
286
- let source = "";
287
192
  const baseName = `${name}${extName}`;
288
193
  const path4 = this.resolvePath({ baseName, mode, pluginKey, options });
289
194
  if (!path4) {
290
195
  throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
291
196
  }
292
- try {
293
- source = _fs.readSync.call(void 0, path4);
294
- } catch (_e) {
295
- }
296
197
  return {
297
198
  path: path4,
298
199
  baseName,
299
200
  meta: {
300
201
  pluginKey
301
202
  },
302
- source
203
+ sources: []
303
204
  };
304
205
  }
206
+ resolvePath = (params) => {
207
+ if (params.pluginKey) {
208
+ const paths = this.hookForPluginSync({
209
+ pluginKey: params.pluginKey,
210
+ hookName: "resolvePath",
211
+ parameters: [params.baseName, params.mode, params.options],
212
+ message: `Resolving path '${params.baseName}'`
213
+ });
214
+ if (paths && paths?.length > 1) {
215
+ this.logger.emit("debug", {
216
+ date: /* @__PURE__ */ new Date(),
217
+ logs: [
218
+ `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
219
+
220
+ Paths: ${JSON.stringify(paths, void 0, 2)}
221
+
222
+ Falling back on the first item.
223
+ `
224
+ ]
225
+ });
226
+ }
227
+ return paths?.at(0);
228
+ }
229
+ return this.hookFirstSync({
230
+ hookName: "resolvePath",
231
+ parameters: [params.baseName, params.mode, params.options],
232
+ message: `Resolving path '${params.baseName}'`
233
+ }).result;
234
+ };
235
+ //TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path
236
+ resolveName = (params) => {
237
+ if (params.pluginKey) {
238
+ const names = this.hookForPluginSync({
239
+ pluginKey: params.pluginKey,
240
+ hookName: "resolveName",
241
+ parameters: [params.name, params.type],
242
+ message: `Resolving name '${params.name}' and type '${params.type}'`
243
+ });
244
+ if (names && names?.length > 1) {
245
+ this.logger.emit("debug", {
246
+ date: /* @__PURE__ */ new Date(),
247
+ logs: [
248
+ `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
249
+
250
+ Names: ${JSON.stringify(names, void 0, 2)}
251
+
252
+ Falling back on the first item.
253
+ `
254
+ ]
255
+ });
256
+ }
257
+ return chunkPWFXUBH6_cjs.transformReservedWord(names?.at(0) || params.name);
258
+ }
259
+ const name = this.hookFirstSync({
260
+ hookName: "resolveName",
261
+ parameters: [params.name, params.type],
262
+ message: `Resolving name '${params.name}' and type '${params.type}'`
263
+ }).result;
264
+ return chunkPWFXUBH6_cjs.transformReservedWord(name);
265
+ };
305
266
  /**
306
267
  * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
307
268
  */
@@ -311,21 +272,26 @@ Falling back on the first item.
311
272
  /**
312
273
  * Run a specific hookName for plugin x.
313
274
  */
314
- hookForPlugin({
275
+ async hookForPlugin({
315
276
  pluginKey,
316
277
  hookName,
317
- parameters
278
+ parameters,
279
+ message
318
280
  }) {
319
281
  const plugins = this.getPluginsByKey(hookName, pluginKey);
282
+ this.logger.emit("progress_start", { id: hookName, size: plugins.length, message: "Running plugins..." });
320
283
  const promises = plugins.map((plugin) => {
321
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, execute_fn).call(this, {
284
+ return this.#execute({
322
285
  strategy: "hookFirst",
323
286
  hookName,
324
287
  parameters,
325
- plugin
288
+ plugin,
289
+ message
326
290
  });
327
291
  }).filter(Boolean);
328
- return Promise.all(promises);
292
+ const items = await Promise.all(promises);
293
+ this.logger.emit("progress_stop", { id: hookName });
294
+ return items;
329
295
  }
330
296
  /**
331
297
  * Run a specific hookName for plugin x.
@@ -333,17 +299,20 @@ Falling back on the first item.
333
299
  hookForPluginSync({
334
300
  pluginKey,
335
301
  hookName,
336
- parameters
302
+ parameters,
303
+ message
337
304
  }) {
338
305
  const plugins = this.getPluginsByKey(hookName, pluginKey);
339
- return plugins.map((plugin) => {
340
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, executeSync_fn).call(this, {
306
+ const result = plugins.map((plugin) => {
307
+ return this.#executeSync({
341
308
  strategy: "hookFirst",
342
309
  hookName,
343
310
  parameters,
344
- plugin
311
+ plugin,
312
+ message
345
313
  });
346
314
  }).filter(Boolean);
315
+ return result;
347
316
  }
348
317
  /**
349
318
  * First non-null result stops and will return it's value.
@@ -351,17 +320,21 @@ Falling back on the first item.
351
320
  async hookFirst({
352
321
  hookName,
353
322
  parameters,
354
- skipped
323
+ skipped,
324
+ message
355
325
  }) {
356
- const promises = _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).call(this).filter((plugin) => {
326
+ const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
357
327
  return skipped ? skipped.has(plugin) : true;
358
- }).map((plugin) => {
328
+ });
329
+ this.logger.emit("progress_start", { id: hookName, size: plugins.length });
330
+ const promises = plugins.map((plugin) => {
359
331
  return async () => {
360
- const value = await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, execute_fn).call(this, {
332
+ const value = await this.#execute({
361
333
  strategy: "hookFirst",
362
334
  hookName,
363
335
  parameters,
364
- plugin
336
+ plugin,
337
+ message
365
338
  });
366
339
  return Promise.resolve({
367
340
  plugin,
@@ -369,7 +342,9 @@ Falling back on the first item.
369
342
  });
370
343
  };
371
344
  });
372
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _promiseManager).run("first", promises);
345
+ const result = await this.#promiseManager.run("first", promises);
346
+ this.logger.emit("progress_stop", { id: hookName });
347
+ return result;
373
348
  }
374
349
  /**
375
350
  * First non-null result stops and will return it's value.
@@ -377,23 +352,25 @@ Falling back on the first item.
377
352
  hookFirstSync({
378
353
  hookName,
379
354
  parameters,
380
- skipped
355
+ skipped,
356
+ message
381
357
  }) {
382
358
  let parseResult = null;
383
- for (const plugin of _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).call(this)) {
384
- if (_optionalChain([skipped, 'optionalAccess', _11 => _11.has, 'call', _12 => _12(plugin)])) {
385
- continue;
386
- }
359
+ const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
360
+ return skipped ? skipped.has(plugin) : true;
361
+ });
362
+ for (const plugin of plugins) {
387
363
  parseResult = {
388
- result: _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, executeSync_fn).call(this, {
364
+ result: this.#executeSync({
389
365
  strategy: "hookFirst",
390
366
  hookName,
391
367
  parameters,
392
- plugin
368
+ plugin,
369
+ message
393
370
  }),
394
371
  plugin
395
372
  };
396
- if (_optionalChain([parseResult, 'optionalAccess', _13 => _13.result]) != null) {
373
+ if (parseResult?.result != null) {
397
374
  break;
398
375
  }
399
376
  }
@@ -404,23 +381,28 @@ Falling back on the first item.
404
381
  */
405
382
  async hookParallel({
406
383
  hookName,
407
- parameters
384
+ parameters,
385
+ message
408
386
  }) {
409
- const promises = _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).call(this).map((plugin) => {
410
- return () => _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, execute_fn).call(this, {
387
+ const plugins = this.#getSortedPlugins(hookName);
388
+ this.logger.emit("progress_start", { id: hookName, size: plugins.length });
389
+ const promises = plugins.map((plugin) => {
390
+ return () => this.#execute({
411
391
  strategy: "hookParallel",
412
392
  hookName,
413
393
  parameters,
414
- plugin
394
+ plugin,
395
+ message
415
396
  });
416
397
  });
417
- const results = await _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _promiseManager).run("parallel", promises);
398
+ const results = await this.#promiseManager.run("parallel", promises);
418
399
  results.forEach((result, index) => {
419
400
  if (isPromiseRejectedResult(result)) {
420
- const plugin = _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).call(this)[index];
421
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, catcher_fn).call(this, result.reason, plugin, hookName);
401
+ const plugin = this.#getSortedPlugins(hookName)[index];
402
+ this.#catcher(result.reason, plugin, hookName);
422
403
  }
423
404
  });
405
+ this.logger.emit("progress_stop", { id: hookName });
424
406
  return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
425
407
  }
426
408
  /**
@@ -429,60 +411,226 @@ Falling back on the first item.
429
411
  hookReduceArg0({
430
412
  hookName,
431
413
  parameters,
432
- reduce
414
+ reduce,
415
+ message
433
416
  }) {
434
417
  const [argument0, ...rest] = parameters;
418
+ const plugins = this.#getSortedPlugins(hookName);
435
419
  let promise = Promise.resolve(argument0);
436
- for (const plugin of _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).call(this)) {
420
+ for (const plugin of plugins) {
437
421
  promise = promise.then((arg0) => {
438
- const value = _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, execute_fn).call(this, {
422
+ const value = this.#execute({
439
423
  strategy: "hookReduceArg0",
440
424
  hookName,
441
425
  parameters: [arg0, ...rest],
442
- plugin
426
+ plugin,
427
+ message
443
428
  });
444
429
  return value;
445
- }).then((result) => reduce.call(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context, argument0, result, plugin));
430
+ }).then((result) => reduce.call(this.#core.context, argument0, result, plugin));
446
431
  }
447
432
  return promise;
448
433
  }
449
434
  /**
450
435
  * Chains plugins
451
436
  */
452
- async hookSeq({ hookName, parameters }) {
453
- const promises = _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).call(this).map((plugin) => {
454
- return () => _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, execute_fn).call(this, {
437
+ async hookSeq({
438
+ hookName,
439
+ parameters,
440
+ message
441
+ }) {
442
+ const plugins = this.#getSortedPlugins(hookName);
443
+ this.logger.emit("progress_start", { id: hookName, size: plugins.length });
444
+ const promises = plugins.map((plugin) => {
445
+ return () => this.#execute({
455
446
  strategy: "hookSeq",
456
447
  hookName,
457
448
  parameters,
458
- plugin
449
+ plugin,
450
+ message
459
451
  });
460
452
  });
461
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _promiseManager).run("seq", promises);
453
+ await this.#promiseManager.run("seq", promises);
454
+ this.logger.emit("progress_stop", { id: hookName });
455
+ }
456
+ #getSortedPlugins(hookName) {
457
+ const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
458
+ if (hookName) {
459
+ return plugins.filter((plugin) => hookName in plugin);
460
+ }
461
+ return plugins.map((plugin) => {
462
+ if (plugin.pre) {
463
+ const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName));
464
+ if (!isValid) {
465
+ throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
466
+ }
467
+ }
468
+ return plugin;
469
+ }).sort((a, b) => {
470
+ if (b.pre?.includes(a.name)) {
471
+ return 1;
472
+ }
473
+ if (b.post?.includes(a.name)) {
474
+ return -1;
475
+ }
476
+ return 0;
477
+ });
462
478
  }
463
479
  getPluginsByKey(hookName, pluginKey) {
464
480
  const plugins = [...this.plugins];
465
481
  const [searchPluginName, searchIdentifier] = pluginKey;
466
- const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
482
+ const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => {
467
483
  const [name, identifier] = item.key;
468
- const identifierCheck = _optionalChain([identifier, 'optionalAccess', _14 => _14.toString, 'call', _15 => _15()]) === _optionalChain([searchIdentifier, 'optionalAccess', _16 => _16.toString, 'call', _17 => _17()]);
484
+ const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
469
485
  const nameCheck = name === searchPluginName;
470
486
  if (searchIdentifier) {
471
487
  return identifierCheck && nameCheck;
472
488
  }
473
489
  return nameCheck;
474
490
  });
475
- if (!_optionalChain([pluginByPluginName, 'optionalAccess', _18 => _18.length])) {
476
- const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
491
+ if (!pluginByPluginName?.length) {
492
+ const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
477
493
  if (corePlugin) {
478
- this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]);
494
+ this.logger.emit("debug", {
495
+ date: /* @__PURE__ */ new Date(),
496
+ logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]
497
+ });
479
498
  } else {
480
- this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]);
499
+ this.logger.emit("debug", {
500
+ date: /* @__PURE__ */ new Date(),
501
+ logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]
502
+ });
481
503
  }
482
504
  return corePlugin ? [corePlugin] : [];
483
505
  }
484
506
  return pluginByPluginName;
485
507
  }
508
+ #addExecutedToCallStack(executer) {
509
+ if (executer) {
510
+ this.events.emit("executed", executer);
511
+ this.executed.push(executer);
512
+ this.logger.emit("progressed", { id: executer.hookName, message: `${executer.plugin.name}: ${executer.message}` });
513
+ }
514
+ }
515
+ /**
516
+ * Run an async plugin hook and return the result.
517
+ * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
518
+ * @param args Arguments passed to the plugin hook.
519
+ * @param plugin The actual pluginObject to run.
520
+ */
521
+ // Implementation signature
522
+ #execute({
523
+ strategy,
524
+ hookName,
525
+ parameters,
526
+ plugin,
527
+ message
528
+ }) {
529
+ const hook = plugin[hookName];
530
+ let output;
531
+ if (!hook) {
532
+ return null;
533
+ }
534
+ this.events.emit("executing", { strategy, hookName, parameters, plugin, message });
535
+ const promise = new Promise((resolve2) => {
536
+ resolve2(void 0);
537
+ });
538
+ const task = promise.then(() => {
539
+ if (typeof hook === "function") {
540
+ const possiblePromiseResult = hook.apply({ ...this.#core.context, plugin }, parameters);
541
+ if (isPromise(possiblePromiseResult)) {
542
+ return Promise.resolve(possiblePromiseResult);
543
+ }
544
+ return possiblePromiseResult;
545
+ }
546
+ return hook;
547
+ }).then((result) => {
548
+ output = result;
549
+ this.#addExecutedToCallStack({
550
+ parameters,
551
+ output,
552
+ strategy,
553
+ hookName,
554
+ plugin,
555
+ message
556
+ });
557
+ return result;
558
+ }).catch((e) => {
559
+ this.#catcher(e, plugin, hookName);
560
+ return null;
561
+ });
562
+ return task;
563
+ }
564
+ /**
565
+ * Run a sync plugin hook and return the result.
566
+ * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
567
+ * @param args Arguments passed to the plugin hook.
568
+ * @param plugin The acutal plugin
569
+ * @param replaceContext When passed, the plugin context can be overridden.
570
+ */
571
+ #executeSync({
572
+ strategy,
573
+ hookName,
574
+ parameters,
575
+ plugin,
576
+ message
577
+ }) {
578
+ const hook = plugin[hookName];
579
+ let output;
580
+ if (!hook) {
581
+ return null;
582
+ }
583
+ this.events.emit("executing", { strategy, hookName, parameters, plugin, message });
584
+ try {
585
+ if (typeof hook === "function") {
586
+ const fn = hook.apply({ ...this.#core.context, plugin }, parameters);
587
+ output = fn;
588
+ this.#addExecutedToCallStack({
589
+ parameters,
590
+ output,
591
+ strategy,
592
+ hookName,
593
+ plugin,
594
+ message
595
+ });
596
+ return fn;
597
+ }
598
+ output = hook;
599
+ this.#addExecutedToCallStack({
600
+ parameters,
601
+ output,
602
+ strategy,
603
+ hookName,
604
+ plugin,
605
+ message
606
+ });
607
+ return hook;
608
+ } catch (e) {
609
+ this.#catcher(e, plugin, hookName);
610
+ return null;
611
+ }
612
+ }
613
+ #catcher(cause, plugin, hookName) {
614
+ const text = `${cause.message} (plugin: ${plugin?.name || "unknown"}, hook: ${hookName || "unknown"})`;
615
+ this.logger.emit("error", text, cause);
616
+ this.events.emit("error", cause);
617
+ }
618
+ #parse(plugin, pluginManager, context) {
619
+ const usedPluginNames = pluginManager.#usedPluginNames;
620
+ chunkMHOAMP5V_cjs.setUniqueName(plugin.name, usedPluginNames);
621
+ const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
622
+ if (plugin.context && typeof plugin.context === "function") {
623
+ return {
624
+ ...plugin,
625
+ key,
626
+ context: plugin.context.call(context)
627
+ };
628
+ }
629
+ return {
630
+ ...plugin,
631
+ key
632
+ };
633
+ }
486
634
  static getDependedPlugins(plugins, dependedPluginNames) {
487
635
  let pluginNames = [];
488
636
  if (typeof dependedPluginNames === "string") {
@@ -502,400 +650,211 @@ Falling back on the first item.
502
650
  return ["buildStart", "resolvePath", "resolveName", "buildEnd"];
503
651
  }
504
652
  };
505
- _core = new WeakMap();
506
- _usedPluginNames = new WeakMap();
507
- _promiseManager = new WeakMap();
508
- _PluginManager_instances = new WeakSet();
509
- getSortedPlugins_fn = function(hookName) {
510
- const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
511
- if (hookName) {
512
- if (this.logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
513
- const containsHookName = plugins.some((item) => item[hookName]);
514
- if (!containsHookName) {
515
- this.logger.emit("warning", `No hook ${hookName} found`);
516
- }
517
- }
518
- return plugins.filter((item) => item[hookName]);
519
- }
520
- return plugins.map((plugin) => {
521
- if (plugin.pre) {
522
- const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName));
523
- if (!isValid) {
524
- throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
525
- }
526
- }
527
- return plugin;
528
- }).sort((a, b) => {
529
- if (_optionalChain([b, 'access', _19 => _19.pre, 'optionalAccess', _20 => _20.includes, 'call', _21 => _21(a.name)])) {
530
- return 1;
531
- }
532
- if (_optionalChain([b, 'access', _22 => _22.post, 'optionalAccess', _23 => _23.includes, 'call', _24 => _24(a.name)])) {
533
- return -1;
534
- }
535
- return 0;
536
- });
537
- };
538
- addExecutedToCallStack_fn = function(executer) {
539
- if (executer) {
540
- this.events.emit("executed", executer);
541
- this.executed.push(executer);
542
- }
543
- };
544
- /**
545
- * Run an async plugin hook and return the result.
546
- * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
547
- * @param args Arguments passed to the plugin hook.
548
- * @param plugin The actual pluginObject to run.
549
- */
550
- // Implementation signature
551
- execute_fn = function({
552
- strategy,
553
- hookName,
554
- parameters,
555
- plugin
556
- }) {
557
- const hook = plugin[hookName];
558
- let output;
559
- if (!hook) {
560
- return null;
561
- }
562
- this.events.emit("execute", { strategy, hookName, parameters, plugin });
563
- const task = Promise.resolve().then(() => {
564
- if (typeof hook === "function") {
565
- const possiblePromiseResult = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context, plugin }, parameters);
566
- if (isPromise(possiblePromiseResult)) {
567
- return Promise.resolve(possiblePromiseResult);
568
- }
569
- return possiblePromiseResult;
570
- }
571
- return hook;
572
- }).then((result) => {
573
- output = result;
574
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, addExecutedToCallStack_fn).call(this, {
575
- parameters,
576
- output,
577
- strategy,
578
- hookName,
579
- plugin
580
- });
581
- return result;
582
- }).catch((e) => {
583
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, catcher_fn).call(this, e, plugin, hookName);
584
- return null;
585
- });
586
- return task;
587
- };
588
- /**
589
- * Run a sync plugin hook and return the result.
590
- * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
591
- * @param args Arguments passed to the plugin hook.
592
- * @param plugin The acutal plugin
593
- * @param replaceContext When passed, the plugin context can be overridden.
594
- */
595
- executeSync_fn = function({
596
- strategy,
597
- hookName,
598
- parameters,
599
- plugin
600
- }) {
601
- const hook = plugin[hookName];
602
- let output;
603
- if (!hook) {
604
- return null;
605
- }
606
- this.events.emit("execute", { strategy, hookName, parameters, plugin });
607
- try {
608
- if (typeof hook === "function") {
609
- const fn = hook.apply({ ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _core).context, plugin }, parameters);
610
- output = fn;
611
- return fn;
612
- }
613
- output = hook;
614
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, addExecutedToCallStack_fn).call(this, {
615
- parameters,
616
- output,
617
- strategy,
618
- hookName,
619
- plugin
620
- });
621
- return hook;
622
- } catch (e) {
623
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, catcher_fn).call(this, e, plugin, hookName);
624
- return null;
625
- }
626
- };
627
- catcher_fn = function(cause, plugin, hookName) {
628
- const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _25 => _25.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
629
- this.logger.emit("error", text, cause);
630
- this.events.emit("error", cause);
631
- };
632
- parse_fn = function(plugin, pluginManager, context) {
633
- const usedPluginNames = _chunkXCPFG6DOcjs.__privateGet.call(void 0, pluginManager, _usedPluginNames);
634
- _chunkYTSNYMHWcjs.setUniqueName.call(void 0, plugin.name, usedPluginNames);
635
- const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
636
- if (plugin.context && typeof plugin.context === "function") {
637
- return {
638
- ...plugin,
639
- key,
640
- context: plugin.context.call(context)
641
- };
642
- }
643
- return {
644
- ...plugin,
645
- key
646
- };
647
- };
648
653
 
649
654
  // src/config.ts
650
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
655
+ chunkRSTRL2FG_cjs.init_cjs_shims();
651
656
  function defineConfig(options) {
652
657
  return options;
653
658
  }
654
659
  function isInputPath(result) {
655
- return !!result && "path" in result;
660
+ return !!result && "path" in result?.input;
656
661
  }
657
-
658
- // src/build.ts
659
662
  async function setup(options) {
660
- const { config, logger = _chunkLM2YQC3Tcjs.createLogger.call(void 0, { logLevel: _chunkLM2YQC3Tcjs.LogLevel.silent }) } = options;
661
- let count = 0;
663
+ const { config, logger = chunk3MDDPVXB_cjs.createLogger() } = options;
662
664
  try {
663
- if (isInputPath(config) && !new (0, _chunkYTSNYMHWcjs.URLPath)(config.input.path).isURL) {
664
- await _fs.read.call(void 0, config.input.path);
665
+ if (isInputPath(config) && !new chunkMHOAMP5V_cjs.URLPath(config.input.path).isURL) {
666
+ await fs.read(config.input.path);
665
667
  }
666
668
  } catch (e) {
667
669
  if (isInputPath(config)) {
668
- throw new Error(
669
- `Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${_chunkLM2YQC3Tcjs.p.dim(config.input.path)}`,
670
- {
671
- cause: e
672
- }
673
- );
670
+ throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${config.input.path}`, {
671
+ cause: e
672
+ });
674
673
  }
675
674
  }
676
675
  if (config.output.clean) {
677
- await _fs.clean.call(void 0, config.output.path);
676
+ await fs.clean(config.output.path);
677
+ await fs.clean(path3.join(config.root, ".kubb"));
678
678
  }
679
- const task = async (file) => {
680
- const { path: path4 } = file;
681
- const source = await _chunkADC5UNZ5cjs.FileManager.getSource(file);
682
- if (source) {
683
- if (config.output.write || config.output.write === void 0) {
684
- await pluginManager.fileManager.write(path4, source, { sanity: false });
685
- }
686
- }
687
- return {
688
- ...file,
689
- source: source || ""
690
- };
691
- };
692
- const pluginManager = new PluginManager(config, { logger, task });
693
- pluginManager.queue.on("add", () => {
694
- if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
695
- return;
696
- }
697
- if (count === 0) {
698
- logger.emit("start", "\u{1F4BE} Writing");
699
- }
700
- });
701
- pluginManager.queue.on("active", () => {
702
- if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
703
- return;
704
- }
705
- if (logger.spinner && pluginManager.queue.size > 0) {
706
- const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
707
- logger.spinner.suffixText = _chunkLM2YQC3Tcjs.p.dim(text);
708
- }
709
- ++count;
710
- });
711
- pluginManager.queue.on("completed", () => {
712
- if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
713
- return;
714
- }
715
- if (logger.spinner) {
716
- const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
717
- logger.spinner.suffixText = _chunkLM2YQC3Tcjs.p.dim(text);
718
- }
719
- });
720
- pluginManager.on("executed", (executer) => {
721
- const { hookName, plugin, output, parameters } = executer;
722
- const logs = [
723
- `${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} Executing ${hookName}`,
724
- parameters && `${_chunkLM2YQC3Tcjs.p.bgWhite("Parameters")} ${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
725
- JSON.stringify(parameters, void 0, 2),
726
- output && `${_chunkLM2YQC3Tcjs.p.bgWhite("Output")} ${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
727
- output
728
- ].filter(Boolean);
729
- logger.emit("debug", logs);
730
- });
731
- return pluginManager;
679
+ return new PluginManager(config, { logger });
732
680
  }
733
681
  async function build(options) {
734
- const pluginManager = await setup(options);
735
- const { fileManager, logger } = pluginManager;
736
- await pluginManager.hookParallel({
737
- hookName: "buildStart",
738
- parameters: [options.config]
739
- });
740
- await pluginManager.hookParallel({ hookName: "buildEnd" });
741
- if (logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
742
- logger.emit("end", "\u{1F4BE} Writing completed");
743
- }
744
- const files = await Promise.all(
745
- fileManager.files.map(async (file) => ({
746
- ...file,
747
- source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
748
- }))
749
- );
682
+ const { files, pluginManager, error } = await safeBuild(options);
683
+ if (error) throw error;
750
684
  return {
751
685
  files,
752
- pluginManager
686
+ pluginManager,
687
+ error
753
688
  };
754
689
  }
755
690
  async function safeBuild(options) {
691
+ let files = [];
756
692
  const pluginManager = await setup(options);
757
- const { fileManager, logger } = pluginManager;
758
693
  try {
694
+ pluginManager.events.on("executing", ({ plugin, message }) => {
695
+ pluginManager.logger.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Executing pluginKey ${plugin.key?.join(".")} | ${message}`] });
696
+ });
697
+ pluginManager.events.on("executed", ({ plugin, message, output }) => {
698
+ pluginManager.logger.emit("debug", {
699
+ date: /* @__PURE__ */ new Date(),
700
+ logs: [`Executed pluginKey ${plugin.key?.join(".")} | ${message} | ${JSON.stringify(output, void 0, 2)}`]
701
+ });
702
+ });
759
703
  await pluginManager.hookParallel({
760
704
  hookName: "buildStart",
761
- parameters: [options.config]
705
+ parameters: [options.config],
706
+ message: "buildStart"
707
+ });
708
+ const root = path3.resolve(options.config.root);
709
+ const rootPath = path3.resolve(root, options.config.output.path, "index.ts");
710
+ const barrelFiles = pluginManager.fileManager.files.filter((file) => {
711
+ return file.sources.some((source) => source.isIndexable);
762
712
  });
763
- await pluginManager.hookParallel({ hookName: "buildEnd" });
764
- if (logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
765
- logger.emit("end", "\u{1F4BE} Writing completed");
713
+ const rootFile = {
714
+ path: rootPath,
715
+ baseName: "index.ts",
716
+ exports: barrelFiles.flatMap((file) => {
717
+ return file.sources?.map((source) => {
718
+ if (!file.path || !source.isIndexable) {
719
+ return void 0;
720
+ }
721
+ const plugin = [...pluginManager.plugins].find((item) => {
722
+ const meta = file.meta;
723
+ return item.key === meta?.pluginKey;
724
+ });
725
+ const options2 = plugin?.options ?? {};
726
+ if (options2.output?.exportType === false) {
727
+ return void 0;
728
+ }
729
+ if (chunkMHOAMP5V_cjs.FileManager.getMode(options2.output?.path) === "single") {
730
+ return void 0;
731
+ }
732
+ return {
733
+ name: options2.output?.exportType === "barrel" ? void 0 : [source.name],
734
+ path: fs.getRelativePath(rootPath, file.path),
735
+ isTypeOnly: source.isTypeOnly
736
+ };
737
+ }).filter(Boolean);
738
+ }).filter(Boolean),
739
+ sources: [],
740
+ meta: {}
741
+ };
742
+ if (options.config.output.exportType) {
743
+ await pluginManager.fileManager.add(rootFile);
766
744
  }
745
+ files = await chunkMHOAMP5V_cjs.processFiles({
746
+ config: options.config,
747
+ dryRun: !options.config.output.write,
748
+ files: pluginManager.fileManager.files,
749
+ logger: pluginManager.logger
750
+ });
751
+ await pluginManager.hookParallel({ hookName: "buildEnd", message: `Build stopped for ${options.config.name}` });
752
+ pluginManager.fileManager.clear();
767
753
  } catch (e) {
768
- const files2 = await Promise.all(
769
- fileManager.files.map(async (file) => ({
770
- ...file,
771
- source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
772
- }))
773
- );
774
754
  return {
775
- files: files2,
755
+ files: [],
776
756
  pluginManager,
777
757
  error: e
778
758
  };
779
759
  }
780
- const files = await Promise.all(
781
- fileManager.files.map(async (file) => ({
782
- ...file,
783
- source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
784
- }))
785
- );
786
760
  return {
787
761
  files,
788
762
  pluginManager
789
763
  };
790
764
  }
791
765
 
792
- // src/Generator.ts
793
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
794
- var _options2, _context;
795
- var Generator = class {
766
+ // src/BaseGenerator.ts
767
+ chunkRSTRL2FG_cjs.init_cjs_shims();
768
+ var BaseGenerator = class {
769
+ #options = {};
770
+ #context = {};
796
771
  constructor(options, context) {
797
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _options2, {});
798
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _context, {});
799
772
  if (context) {
800
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _context, context);
773
+ this.#context = context;
801
774
  }
802
775
  if (options) {
803
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options2, options);
776
+ this.#options = options;
804
777
  }
805
778
  return this;
806
779
  }
807
780
  get options() {
808
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options2);
781
+ return this.#options;
809
782
  }
810
783
  get context() {
811
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _context);
784
+ return this.#context;
812
785
  }
813
786
  set options(options) {
814
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options2, { ..._chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options2), ...options });
787
+ this.#options = { ...this.#options, ...options };
815
788
  }
816
789
  };
817
- _options2 = new WeakMap();
818
- _context = new WeakMap();
819
790
 
820
791
  // src/PackageManager.ts
821
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
822
- var _module = require('module'); var _module2 = _interopRequireDefault(_module);
823
- var _os = require('os'); var _os2 = _interopRequireDefault(_os);
824
- var _url = require('url');
792
+ chunkRSTRL2FG_cjs.init_cjs_shims();
825
793
 
826
794
  // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
827
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
828
-
795
+ chunkRSTRL2FG_cjs.init_cjs_shims();
829
796
 
830
797
  // ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
831
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
832
- var _process = require('process'); var _process2 = _interopRequireDefault(_process);
833
-
834
- var _fs3 = require('fs'); var _fs4 = _interopRequireDefault(_fs3);
835
-
798
+ chunkRSTRL2FG_cjs.init_cjs_shims();
836
799
 
837
800
  // ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
838
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
801
+ chunkRSTRL2FG_cjs.init_cjs_shims();
839
802
 
840
803
  // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
841
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
804
+ chunkRSTRL2FG_cjs.init_cjs_shims();
842
805
 
843
806
  // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
844
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
807
+ chunkRSTRL2FG_cjs.init_cjs_shims();
845
808
  var Node = class {
809
+ value;
810
+ next;
846
811
  constructor(value) {
847
- _chunkXCPFG6DOcjs.__publicField.call(void 0, this, "value");
848
- _chunkXCPFG6DOcjs.__publicField.call(void 0, this, "next");
849
812
  this.value = value;
850
813
  }
851
814
  };
852
- var _head, _tail, _size;
853
815
  var Queue = class {
816
+ #head;
817
+ #tail;
818
+ #size;
854
819
  constructor() {
855
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _head);
856
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _tail);
857
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _size);
858
820
  this.clear();
859
821
  }
860
822
  enqueue(value) {
861
823
  const node = new Node(value);
862
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _head)) {
863
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _tail).next = node;
864
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _tail, node);
824
+ if (this.#head) {
825
+ this.#tail.next = node;
826
+ this.#tail = node;
865
827
  } else {
866
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _head, node);
867
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _tail, node);
828
+ this.#head = node;
829
+ this.#tail = node;
868
830
  }
869
- _chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _size)._++;
831
+ this.#size++;
870
832
  }
871
833
  dequeue() {
872
- const current = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _head);
834
+ const current = this.#head;
873
835
  if (!current) {
874
836
  return;
875
837
  }
876
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _head, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _head).next);
877
- _chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _size)._--;
838
+ this.#head = this.#head.next;
839
+ this.#size--;
878
840
  return current.value;
879
841
  }
880
842
  clear() {
881
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _head, void 0);
882
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _tail, void 0);
883
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _size, 0);
843
+ this.#head = void 0;
844
+ this.#tail = void 0;
845
+ this.#size = 0;
884
846
  }
885
847
  get size() {
886
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _size);
848
+ return this.#size;
887
849
  }
888
850
  *[Symbol.iterator]() {
889
- let current = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _head);
851
+ let current = this.#head;
890
852
  while (current) {
891
853
  yield current.value;
892
854
  current = current.next;
893
855
  }
894
856
  }
895
857
  };
896
- _head = new WeakMap();
897
- _tail = new WeakMap();
898
- _size = new WeakMap();
899
858
 
900
859
  // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
901
860
  function pLimit(concurrency) {
@@ -910,18 +869,18 @@ function pLimit(concurrency) {
910
869
  queue.dequeue()();
911
870
  }
912
871
  };
913
- const run = async (fn, resolve, args) => {
872
+ const run = async (fn, resolve2, args) => {
914
873
  activeCount++;
915
874
  const result = (async () => fn(...args))();
916
- resolve(result);
875
+ resolve2(result);
917
876
  try {
918
877
  await result;
919
- } catch (e2) {
878
+ } catch {
920
879
  }
921
880
  next();
922
881
  };
923
- const enqueue = (fn, resolve, args) => {
924
- queue.enqueue(run.bind(void 0, fn, resolve, args));
882
+ const enqueue = (fn, resolve2, args) => {
883
+ queue.enqueue(run.bind(void 0, fn, resolve2, args));
925
884
  (async () => {
926
885
  await Promise.resolve();
927
886
  if (activeCount < concurrency && queue.size > 0) {
@@ -929,8 +888,8 @@ function pLimit(concurrency) {
929
888
  }
930
889
  })();
931
890
  };
932
- const generator = (fn, ...args) => new Promise((resolve) => {
933
- enqueue(fn, resolve, args);
891
+ const generator = (fn, ...args) => new Promise((resolve2) => {
892
+ enqueue(fn, resolve2, args);
934
893
  });
935
894
  Object.defineProperties(generator, {
936
895
  activeCount: {
@@ -992,9 +951,9 @@ function checkType(type) {
992
951
  throw new Error(`Invalid type specified: ${type}`);
993
952
  }
994
953
  var matchType = (type, stat) => stat[typeMappings[type]]();
995
- var toPath = (urlOrPath) => urlOrPath instanceof URL ? _url.fileURLToPath.call(void 0, urlOrPath) : urlOrPath;
954
+ var toPath = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
996
955
  async function locatePath(paths, {
997
- cwd = _process2.default.cwd(),
956
+ cwd = process__default.default.cwd(),
998
957
  type = "file",
999
958
  allowSymlinks = true,
1000
959
  concurrency,
@@ -1002,27 +961,27 @@ async function locatePath(paths, {
1002
961
  } = {}) {
1003
962
  checkType(type);
1004
963
  cwd = toPath(cwd);
1005
- const statFunction = allowSymlinks ? _fs3.promises.stat : _fs3.promises.lstat;
964
+ const statFunction = allowSymlinks ? fs$1.promises.stat : fs$1.promises.lstat;
1006
965
  return pLocate(paths, async (path_) => {
1007
966
  try {
1008
- const stat = await statFunction(_path2.default.resolve(cwd, path_));
967
+ const stat = await statFunction(path3__default.default.resolve(cwd, path_));
1009
968
  return matchType(type, stat);
1010
- } catch (e3) {
969
+ } catch {
1011
970
  return false;
1012
971
  }
1013
972
  }, { concurrency, preserveOrder });
1014
973
  }
1015
974
  function locatePathSync(paths, {
1016
- cwd = _process2.default.cwd(),
975
+ cwd = process__default.default.cwd(),
1017
976
  type = "file",
1018
977
  allowSymlinks = true
1019
978
  } = {}) {
1020
979
  checkType(type);
1021
980
  cwd = toPath(cwd);
1022
- const statFunction = allowSymlinks ? _fs4.default.statSync : _fs4.default.lstatSync;
981
+ const statFunction = allowSymlinks ? fs__default.default.statSync : fs__default.default.lstatSync;
1023
982
  for (const path_ of paths) {
1024
983
  try {
1025
- const stat = statFunction(_path2.default.resolve(cwd, path_), {
984
+ const stat = statFunction(path3__default.default.resolve(cwd, path_), {
1026
985
  throwIfNoEntry: false
1027
986
  });
1028
987
  if (!stat) {
@@ -1031,29 +990,27 @@ function locatePathSync(paths, {
1031
990
  if (matchType(type, stat)) {
1032
991
  return path_;
1033
992
  }
1034
- } catch (e4) {
993
+ } catch {
1035
994
  }
1036
995
  }
1037
996
  }
1038
997
 
1039
998
  // ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
1040
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
1041
-
999
+ chunkRSTRL2FG_cjs.init_cjs_shims();
1042
1000
  function toPath2(urlOrPath) {
1043
- return urlOrPath instanceof URL ? _url.fileURLToPath.call(void 0, urlOrPath) : urlOrPath;
1001
+ return urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
1044
1002
  }
1045
1003
 
1046
1004
  // ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
1047
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
1048
-
1005
+ chunkRSTRL2FG_cjs.init_cjs_shims();
1049
1006
 
1050
1007
  // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
1051
1008
  var findUpStop = Symbol("findUpStop");
1052
1009
  async function findUpMultiple(name, options = {}) {
1053
- let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
1054
- const { root } = _path2.default.parse(directory);
1055
- const stopAt = _path2.default.resolve(directory, toPath2(_nullishCoalesce(options.stopAt, () => ( root))));
1056
- const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
1010
+ let directory = path3__default.default.resolve(toPath2(options.cwd) ?? "");
1011
+ const { root } = path3__default.default.parse(directory);
1012
+ const stopAt = path3__default.default.resolve(directory, toPath2(options.stopAt ?? root));
1013
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
1057
1014
  const paths = [name].flat();
1058
1015
  const runMatcher = async (locateOptions) => {
1059
1016
  if (typeof name !== "function") {
@@ -1072,20 +1029,20 @@ async function findUpMultiple(name, options = {}) {
1072
1029
  break;
1073
1030
  }
1074
1031
  if (foundPath) {
1075
- matches.push(_path2.default.resolve(directory, foundPath));
1032
+ matches.push(path3__default.default.resolve(directory, foundPath));
1076
1033
  }
1077
1034
  if (directory === stopAt || matches.length >= limit) {
1078
1035
  break;
1079
1036
  }
1080
- directory = _path2.default.dirname(directory);
1037
+ directory = path3__default.default.dirname(directory);
1081
1038
  }
1082
1039
  return matches;
1083
1040
  }
1084
1041
  function findUpMultipleSync(name, options = {}) {
1085
- let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
1086
- const { root } = _path2.default.parse(directory);
1087
- const stopAt = _path2.default.resolve(directory, _nullishCoalesce(toPath2(options.stopAt), () => ( root)));
1088
- const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
1042
+ let directory = path3__default.default.resolve(toPath2(options.cwd) ?? "");
1043
+ const { root } = path3__default.default.parse(directory);
1044
+ const stopAt = path3__default.default.resolve(directory, toPath2(options.stopAt) ?? root);
1045
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
1089
1046
  const paths = [name].flat();
1090
1047
  const runMatcher = (locateOptions) => {
1091
1048
  if (typeof name !== "function") {
@@ -1104,12 +1061,12 @@ function findUpMultipleSync(name, options = {}) {
1104
1061
  break;
1105
1062
  }
1106
1063
  if (foundPath) {
1107
- matches.push(_path2.default.resolve(directory, foundPath));
1064
+ matches.push(path3__default.default.resolve(directory, foundPath));
1108
1065
  }
1109
1066
  if (directory === stopAt || matches.length >= limit) {
1110
1067
  break;
1111
1068
  }
1112
- directory = _path2.default.dirname(directory);
1069
+ directory = path3__default.default.dirname(directory);
1113
1070
  }
1114
1071
  return matches;
1115
1072
  }
@@ -1121,37 +1078,32 @@ function findUpSync(name, options = {}) {
1121
1078
  const matches = findUpMultipleSync(name, { ...options, limit: 1 });
1122
1079
  return matches[0];
1123
1080
  }
1124
-
1125
- // src/PackageManager.ts
1126
- var _semver = require('semver');
1127
-
1128
- var _cache, _cwd, _SLASHES, _PackageManager_instances, match_fn;
1129
- var _PackageManager = class _PackageManager {
1081
+ var PackageManager = class _PackageManager {
1082
+ static #cache = {};
1083
+ #cwd;
1084
+ #SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
1130
1085
  constructor(workspace) {
1131
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _PackageManager_instances);
1132
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _cwd);
1133
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _SLASHES, /* @__PURE__ */ new Set(["/", "\\"]));
1134
1086
  if (workspace) {
1135
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _cwd, workspace);
1087
+ this.#cwd = workspace;
1136
1088
  }
1137
1089
  return this;
1138
1090
  }
1139
1091
  set workspace(workspace) {
1140
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _cwd, workspace);
1092
+ this.#cwd = workspace;
1141
1093
  }
1142
1094
  get workspace() {
1143
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cwd);
1095
+ return this.#cwd;
1144
1096
  }
1145
1097
  normalizeDirectory(directory) {
1146
- if (!_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _SLASHES).has(directory[directory.length - 1])) {
1098
+ if (!this.#SLASHES.has(directory[directory.length - 1])) {
1147
1099
  return `${directory}/`;
1148
1100
  }
1149
1101
  return directory;
1150
1102
  }
1151
1103
  getLocation(path4) {
1152
1104
  let location = path4;
1153
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cwd)) {
1154
- const require2 = _module2.default.createRequire(this.normalizeDirectory(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cwd)));
1105
+ if (this.#cwd) {
1106
+ const require2 = mod__default.default.createRequire(this.normalizeDirectory(this.#cwd));
1155
1107
  location = require2.resolve(path4);
1156
1108
  }
1157
1109
  return location;
@@ -1159,58 +1111,69 @@ var _PackageManager = class _PackageManager {
1159
1111
  async import(path4) {
1160
1112
  try {
1161
1113
  let location = this.getLocation(path4);
1162
- if (_os2.default.platform() === "win32") {
1163
- location = _url.pathToFileURL.call(void 0, location).href;
1114
+ if (os__default.default.platform() === "win32") {
1115
+ location = url.pathToFileURL(location).href;
1164
1116
  }
1165
- const module = await Promise.resolve().then(() => _interopRequireWildcard(require(location)));
1166
- return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _26 => _26.default]), () => ( module));
1117
+ const module = await import(location);
1118
+ return module?.default ?? module;
1167
1119
  } catch (e) {
1168
- console.log(e);
1120
+ console.error(e);
1169
1121
  return void 0;
1170
1122
  }
1171
1123
  }
1172
1124
  async getPackageJSON() {
1173
1125
  const pkgPath = await findUp(["package.json"], {
1174
- cwd: _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cwd)
1126
+ cwd: this.#cwd
1175
1127
  });
1176
1128
  if (!pkgPath) {
1177
1129
  return void 0;
1178
1130
  }
1179
- const json = await _fs.read.call(void 0, pkgPath);
1131
+ const json = await fs.read(pkgPath);
1180
1132
  return JSON.parse(json);
1181
1133
  }
1182
1134
  getPackageJSONSync() {
1183
1135
  const pkgPath = findUpSync(["package.json"], {
1184
- cwd: _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cwd)
1136
+ cwd: this.#cwd
1185
1137
  });
1186
1138
  if (!pkgPath) {
1187
1139
  return void 0;
1188
1140
  }
1189
- const json = _fs.readSync.call(void 0, pkgPath);
1141
+ const json = fs.readSync(pkgPath);
1190
1142
  return JSON.parse(json);
1191
1143
  }
1192
1144
  static setVersion(dependency, version) {
1193
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, _PackageManager, _cache)[dependency] = version;
1145
+ _PackageManager.#cache[dependency] = version;
1146
+ }
1147
+ #match(packageJSON, dependency) {
1148
+ const dependencies = {
1149
+ ...packageJSON["dependencies"] || {},
1150
+ ...packageJSON["devDependencies"] || {}
1151
+ };
1152
+ if (typeof dependency === "string" && dependencies[dependency]) {
1153
+ return dependencies[dependency];
1154
+ }
1155
+ const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency));
1156
+ return matchedDependency ? dependencies[matchedDependency] : void 0;
1194
1157
  }
1195
1158
  async getVersion(dependency) {
1196
- if (typeof dependency === "string" && _chunkXCPFG6DOcjs.__privateGet.call(void 0, _PackageManager, _cache)[dependency]) {
1197
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, _PackageManager, _cache)[dependency];
1159
+ if (typeof dependency === "string" && _PackageManager.#cache[dependency]) {
1160
+ return _PackageManager.#cache[dependency];
1198
1161
  }
1199
1162
  const packageJSON = await this.getPackageJSON();
1200
1163
  if (!packageJSON) {
1201
1164
  return void 0;
1202
1165
  }
1203
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PackageManager_instances, match_fn).call(this, packageJSON, dependency);
1166
+ return this.#match(packageJSON, dependency);
1204
1167
  }
1205
1168
  getVersionSync(dependency) {
1206
- if (typeof dependency === "string" && _chunkXCPFG6DOcjs.__privateGet.call(void 0, _PackageManager, _cache)[dependency]) {
1207
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, _PackageManager, _cache)[dependency];
1169
+ if (typeof dependency === "string" && _PackageManager.#cache[dependency]) {
1170
+ return _PackageManager.#cache[dependency];
1208
1171
  }
1209
1172
  const packageJSON = this.getPackageJSONSync();
1210
1173
  if (!packageJSON) {
1211
1174
  return void 0;
1212
1175
  }
1213
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PackageManager_instances, match_fn).call(this, packageJSON, dependency);
1176
+ return this.#match(packageJSON, dependency);
1214
1177
  }
1215
1178
  async isValid(dependency, version) {
1216
1179
  const packageVersion = await this.getVersion(dependency);
@@ -1220,53 +1183,42 @@ var _PackageManager = class _PackageManager {
1220
1183
  if (packageVersion === version) {
1221
1184
  return true;
1222
1185
  }
1223
- const semVer = _semver.coerce.call(void 0, packageVersion);
1186
+ const semVer = semver.coerce(packageVersion);
1224
1187
  if (!semVer) {
1225
1188
  throw new Error(`${packageVersion} is not valid`);
1226
1189
  }
1227
- return _semver.satisfies.call(void 0, semVer, version);
1190
+ return semver.satisfies(semVer, version);
1228
1191
  }
1229
1192
  isValidSync(dependency, version) {
1230
1193
  const packageVersion = this.getVersionSync(dependency);
1231
1194
  if (!packageVersion) {
1232
1195
  return false;
1233
1196
  }
1234
- const semVer = _semver.coerce.call(void 0, packageVersion);
1197
+ const semVer = semver.coerce(packageVersion);
1235
1198
  if (!semVer) {
1236
1199
  throw new Error(`${packageVersion} is not valid`);
1237
1200
  }
1238
- return _semver.satisfies.call(void 0, semVer, version);
1239
- }
1240
- };
1241
- _cache = new WeakMap();
1242
- _cwd = new WeakMap();
1243
- _SLASHES = new WeakMap();
1244
- _PackageManager_instances = new WeakSet();
1245
- match_fn = function(packageJSON, dependency) {
1246
- const dependencies = {
1247
- ...packageJSON["dependencies"] || {},
1248
- ...packageJSON["devDependencies"] || {}
1249
- };
1250
- if (typeof dependency === "string" && dependencies[dependency]) {
1251
- return dependencies[dependency];
1201
+ return semver.satisfies(semVer, version);
1252
1202
  }
1253
- const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency));
1254
- return matchedDependency ? dependencies[matchedDependency] : void 0;
1255
1203
  };
1256
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, _PackageManager, _cache, {});
1257
- var PackageManager = _PackageManager;
1258
-
1259
-
1260
-
1261
-
1262
-
1263
-
1264
1204
 
1265
-
1266
-
1267
-
1268
-
1269
-
1270
-
1271
- exports.FileManager = _chunkADC5UNZ5cjs.FileManager; exports.Generator = Generator; exports.PackageManager = PackageManager; exports.PluginManager = PluginManager; exports.PromiseManager = PromiseManager; exports.Warning = Warning; exports.build = build; exports.createPlugin = createPlugin; exports.default = build; exports.defineConfig = defineConfig; exports.isInputPath = isInputPath; exports.safeBuild = safeBuild;
1205
+ Object.defineProperty(exports, "FileManager", {
1206
+ enumerable: true,
1207
+ get: function () { return chunkMHOAMP5V_cjs.FileManager; }
1208
+ });
1209
+ Object.defineProperty(exports, "getSource", {
1210
+ enumerable: true,
1211
+ get: function () { return chunkMHOAMP5V_cjs.getSource; }
1212
+ });
1213
+ exports.BaseGenerator = BaseGenerator;
1214
+ exports.PackageManager = PackageManager;
1215
+ exports.PluginManager = PluginManager;
1216
+ exports.PromiseManager = PromiseManager;
1217
+ exports.build = build;
1218
+ exports.createPlugin = createPlugin;
1219
+ exports.default = build;
1220
+ exports.defineConfig = defineConfig;
1221
+ exports.isInputPath = isInputPath;
1222
+ exports.safeBuild = safeBuild;
1223
+ //# sourceMappingURL=index.cjs.map
1272
1224
  //# sourceMappingURL=index.cjs.map