@kubb/core 3.0.0-alpha.1 → 3.0.0-alpha.11

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