@kubb/core 2.18.3 → 2.18.5

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