@kubb/core 3.0.0-alpha.10 → 3.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{FileManager-CpuFz6eH.d.ts → FileManager-B-fP5y5O.d.ts} +5 -10
- package/dist/{FileManager-BbUCeEyv.d.cts → FileManager-CL52wQgR.d.cts} +5 -10
- package/dist/chunk-2EU7DMPM.js +2 -3
- package/dist/chunk-2EU7DMPM.js.map +1 -1
- package/dist/chunk-4X5FFJPJ.js +8 -13
- package/dist/chunk-4X5FFJPJ.js.map +1 -1
- package/dist/{chunk-SEH6NUCX.cjs → chunk-ADFKVVPE.cjs} +10 -10
- package/dist/chunk-ADFKVVPE.cjs.map +1 -0
- package/dist/{chunk-MU3CBCQT.js → chunk-E6CN2CZC.js} +12 -27
- package/dist/chunk-E6CN2CZC.js.map +1 -0
- package/dist/chunk-HBQM723K.js +12 -26
- package/dist/chunk-HBQM723K.js.map +1 -1
- package/dist/{chunk-A6PCLWEY.cjs → chunk-JRU2D5E6.cjs} +28 -29
- package/dist/chunk-JRU2D5E6.cjs.map +1 -0
- package/dist/{chunk-NB4JMN75.cjs → chunk-OJRKV365.cjs} +156 -173
- package/dist/chunk-OJRKV365.cjs.map +1 -0
- package/dist/{chunk-5E2I6KH4.cjs → chunk-PJLUPV3P.cjs} +54 -37
- package/dist/chunk-PJLUPV3P.cjs.map +1 -0
- package/dist/{chunk-DID47EQD.cjs → chunk-TTDCUWK7.cjs} +6 -7
- package/dist/chunk-TTDCUWK7.cjs.map +1 -0
- package/dist/{chunk-L6YLVCKM.js → chunk-WDYNXEYV.js} +45 -88
- package/dist/chunk-WDYNXEYV.js.map +1 -0
- package/dist/{chunk-M7NLNCSM.cjs → chunk-YEVCYV36.cjs} +33 -36
- package/dist/chunk-YEVCYV36.cjs.map +1 -0
- package/dist/index.cjs +157 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -87
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +25 -14
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.js +3 -13
- package/dist/logger.js.map +1 -1
- package/dist/mocks.cjs +13 -18
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +5 -12
- package/dist/mocks.js.map +1 -1
- package/dist/{prompt-DVQN7JTN.cjs → prompt-L5KFKY73.cjs} +89 -89
- package/dist/prompt-L5KFKY73.cjs.map +1 -0
- package/dist/prompt-WQQUN22Z.js +8 -13
- package/dist/prompt-WQQUN22Z.js.map +1 -1
- package/dist/transformers.cjs +62 -52
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.js +9 -37
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +65 -34
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +3 -33
- package/dist/utils.js.map +1 -1
- package/package.json +7 -7
- package/src/BarrelManager.ts +1 -1
- package/src/FileManager.ts +29 -39
- package/src/PluginManager.ts +7 -8
- package/src/build.ts +1 -1
- package/src/index.ts +1 -1
- package/src/logger.ts +3 -3
- package/src/plugin.ts +0 -3
- package/src/types.ts +0 -2
- package/src/utils/parser.ts +3 -3
- package/dist/chunk-5E2I6KH4.cjs.map +0 -1
- package/dist/chunk-A6PCLWEY.cjs.map +0 -1
- package/dist/chunk-DID47EQD.cjs.map +0 -1
- package/dist/chunk-L6YLVCKM.js.map +0 -1
- package/dist/chunk-M7NLNCSM.cjs.map +0 -1
- package/dist/chunk-MU3CBCQT.js.map +0 -1
- package/dist/chunk-NB4JMN75.cjs.map +0 -1
- package/dist/chunk-SEH6NUCX.cjs.map +0 -1
- package/dist/prompt-DVQN7JTN.cjs.map +0 -1
- package/src/utils/cache.ts +0 -35
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkJRU2D5E6_cjs = require('./chunk-JRU2D5E6.cjs');
|
|
4
|
+
var chunkADFKVVPE_cjs = require('./chunk-ADFKVVPE.cjs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var fs = require('@kubb/fs');
|
|
7
|
+
var hash = require('object-hash');
|
|
8
|
+
var remeda = require('remeda');
|
|
3
9
|
|
|
4
|
-
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
|
|
12
|
+
var hash__default = /*#__PURE__*/_interopDefault(hash);
|
|
10
13
|
|
|
11
14
|
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
|
|
12
|
-
var require_eventemitter3 =
|
|
15
|
+
var require_eventemitter3 = chunkADFKVVPE_cjs.__commonJS({
|
|
13
16
|
"../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
|
|
14
|
-
|
|
15
|
-
_chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
|
|
17
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
16
18
|
var has = Object.prototype.hasOwnProperty;
|
|
17
19
|
var prefix = "~";
|
|
18
20
|
function Events() {
|
|
@@ -172,10 +174,10 @@ var require_eventemitter3 = _chunkSEH6NUCXcjs.__commonJS.call(void 0, {
|
|
|
172
174
|
});
|
|
173
175
|
|
|
174
176
|
// src/utils/index.ts
|
|
175
|
-
|
|
177
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
176
178
|
|
|
177
179
|
// src/utils/FunctionParams.ts
|
|
178
|
-
|
|
180
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
179
181
|
var FunctionParams = class _FunctionParams {
|
|
180
182
|
#items = [];
|
|
181
183
|
constructor() {
|
|
@@ -196,7 +198,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
196
198
|
return this;
|
|
197
199
|
}
|
|
198
200
|
static #orderItems(items) {
|
|
199
|
-
return
|
|
201
|
+
return chunkJRU2D5E6_cjs.orderBy(
|
|
200
202
|
items.filter(Boolean),
|
|
201
203
|
[
|
|
202
204
|
(v) => {
|
|
@@ -209,7 +211,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
209
211
|
if (Array.isArray(v)) {
|
|
210
212
|
return void 0;
|
|
211
213
|
}
|
|
212
|
-
return
|
|
214
|
+
return v.required ?? true;
|
|
213
215
|
}
|
|
214
216
|
],
|
|
215
217
|
["desc", "desc"]
|
|
@@ -224,7 +226,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
224
226
|
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
225
227
|
return acc;
|
|
226
228
|
}
|
|
227
|
-
const parameterName = name.startsWith("{") ? name :
|
|
229
|
+
const parameterName = name.startsWith("{") ? name : chunkJRU2D5E6_cjs.camelCase(name);
|
|
228
230
|
if (type) {
|
|
229
231
|
if (required) {
|
|
230
232
|
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
@@ -239,8 +241,8 @@ var FunctionParams = class _FunctionParams {
|
|
|
239
241
|
static toObject(items) {
|
|
240
242
|
let type = [];
|
|
241
243
|
let name = [];
|
|
242
|
-
const enabled = items.every((item) => item.enabled) ?
|
|
243
|
-
const required =
|
|
244
|
+
const enabled = items.every((item) => item.enabled) ? items.at(0)?.enabled : true;
|
|
245
|
+
const required = items.every((item) => item.required) ?? true;
|
|
244
246
|
items.forEach((item) => {
|
|
245
247
|
name = _FunctionParams.#addParams(name, { ...item, type: void 0 });
|
|
246
248
|
if (items.some((item2) => item2.type)) {
|
|
@@ -279,9 +281,9 @@ var FunctionParams = class _FunctionParams {
|
|
|
279
281
|
};
|
|
280
282
|
|
|
281
283
|
// src/utils/promise.ts
|
|
282
|
-
|
|
284
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
283
285
|
function isPromise(result) {
|
|
284
|
-
return !!result && typeof
|
|
286
|
+
return !!result && typeof result?.then === "function";
|
|
285
287
|
}
|
|
286
288
|
function isPromiseFulfilledResult(result) {
|
|
287
289
|
return result.status === "fulfilled";
|
|
@@ -291,14 +293,14 @@ function isPromiseRejectedResult(result) {
|
|
|
291
293
|
}
|
|
292
294
|
|
|
293
295
|
// src/utils/renderTemplate.ts
|
|
294
|
-
|
|
296
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
295
297
|
function renderTemplate(template, data = void 0) {
|
|
296
298
|
if (!data || !Object.keys(data).length) {
|
|
297
299
|
return template.replace(/{{(.*?)}}/g, "");
|
|
298
300
|
}
|
|
299
301
|
const matches = template.match(/{{(.*?)}}/g);
|
|
300
|
-
return
|
|
301
|
-
const index =
|
|
302
|
+
return matches?.reduce((prev, curr) => {
|
|
303
|
+
const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
|
|
302
304
|
if (index === void 0) {
|
|
303
305
|
return prev;
|
|
304
306
|
}
|
|
@@ -312,11 +314,11 @@ function renderTemplate(template, data = void 0) {
|
|
|
312
314
|
}
|
|
313
315
|
return value || "";
|
|
314
316
|
}).trim();
|
|
315
|
-
}, template)
|
|
317
|
+
}, template) || "";
|
|
316
318
|
}
|
|
317
319
|
|
|
318
320
|
// src/utils/timeout.ts
|
|
319
|
-
|
|
321
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
320
322
|
async function timeout(ms) {
|
|
321
323
|
return new Promise((resolve) => {
|
|
322
324
|
setTimeout(() => {
|
|
@@ -326,7 +328,7 @@ async function timeout(ms) {
|
|
|
326
328
|
}
|
|
327
329
|
|
|
328
330
|
// src/utils/uniqueName.ts
|
|
329
|
-
|
|
331
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
330
332
|
function getUniqueName(originalName, data) {
|
|
331
333
|
let used = data[originalName] || 0;
|
|
332
334
|
if (used) {
|
|
@@ -347,9 +349,9 @@ function setUniqueName(originalName, data) {
|
|
|
347
349
|
}
|
|
348
350
|
|
|
349
351
|
// src/utils/URLPath.ts
|
|
350
|
-
|
|
352
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
351
353
|
var URLPath = class {
|
|
352
|
-
|
|
354
|
+
path;
|
|
353
355
|
constructor(path) {
|
|
354
356
|
this.path = path;
|
|
355
357
|
return this;
|
|
@@ -364,7 +366,7 @@ var URLPath = class {
|
|
|
364
366
|
get isURL() {
|
|
365
367
|
try {
|
|
366
368
|
const url = new URL(this.path);
|
|
367
|
-
if (
|
|
369
|
+
if (url?.href) {
|
|
368
370
|
return true;
|
|
369
371
|
}
|
|
370
372
|
} catch (error) {
|
|
@@ -415,7 +417,7 @@ var URLPath = class {
|
|
|
415
417
|
let newPath = this.path.replaceAll("{", "${");
|
|
416
418
|
if (found) {
|
|
417
419
|
newPath = found.reduce((prev, curr) => {
|
|
418
|
-
const pathParam = replacer ? replacer(
|
|
420
|
+
const pathParam = replacer ? replacer(chunkJRU2D5E6_cjs.camelCase(curr)) : chunkJRU2D5E6_cjs.camelCase(curr);
|
|
419
421
|
const replacement = `\${${pathParam}}`;
|
|
420
422
|
return prev.replace(curr, replacement);
|
|
421
423
|
}, this.path);
|
|
@@ -431,7 +433,7 @@ var URLPath = class {
|
|
|
431
433
|
const params = {};
|
|
432
434
|
found.forEach((item) => {
|
|
433
435
|
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
434
|
-
const pathParam = replacer ? replacer(
|
|
436
|
+
const pathParam = replacer ? replacer(chunkJRU2D5E6_cjs.camelCase(item)) : chunkJRU2D5E6_cjs.camelCase(item);
|
|
435
437
|
params[pathParam] = pathParam;
|
|
436
438
|
}, this.path);
|
|
437
439
|
return params;
|
|
@@ -446,29 +448,22 @@ var URLPath = class {
|
|
|
446
448
|
};
|
|
447
449
|
|
|
448
450
|
// src/utils/parser.ts
|
|
449
|
-
|
|
450
|
-
var _path = require('path');
|
|
451
|
-
var _fs = require('@kubb/fs');
|
|
452
|
-
var _objecthash = require('object-hash'); var _objecthash2 = _interopRequireDefault(_objecthash);
|
|
451
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
453
452
|
|
|
454
453
|
// src/FileManager.ts
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
var _remeda = require('remeda');
|
|
458
|
-
|
|
454
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
459
455
|
|
|
460
456
|
// src/BarrelManager.ts
|
|
461
|
-
|
|
462
|
-
|
|
457
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
463
458
|
|
|
464
459
|
// src/utils/TreeNode.ts
|
|
465
|
-
|
|
466
|
-
var TreeNode =
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
460
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
461
|
+
var TreeNode = class _TreeNode {
|
|
462
|
+
data;
|
|
463
|
+
parent;
|
|
464
|
+
children = [];
|
|
470
465
|
#cachedLeaves = void 0;
|
|
471
|
-
constructor(data, parent) {
|
|
466
|
+
constructor(data, parent) {
|
|
472
467
|
this.data = data;
|
|
473
468
|
this.parent = parent;
|
|
474
469
|
return this;
|
|
@@ -510,7 +505,7 @@ var TreeNode = (_class = class _TreeNode {
|
|
|
510
505
|
callback(this);
|
|
511
506
|
if (this.children) {
|
|
512
507
|
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
513
|
-
|
|
508
|
+
this.children[i]?.forEach(callback);
|
|
514
509
|
}
|
|
515
510
|
}
|
|
516
511
|
return this;
|
|
@@ -558,19 +553,19 @@ var TreeNode = (_class = class _TreeNode {
|
|
|
558
553
|
file: item.file,
|
|
559
554
|
type: FileManager.getMode(item.path)
|
|
560
555
|
});
|
|
561
|
-
if (
|
|
562
|
-
|
|
556
|
+
if (item.children?.length) {
|
|
557
|
+
item.children?.forEach((child) => {
|
|
563
558
|
recurse(subNode, child);
|
|
564
|
-
})
|
|
559
|
+
});
|
|
565
560
|
}
|
|
566
561
|
};
|
|
567
|
-
|
|
562
|
+
filteredTree.children?.forEach((child) => recurse(treeNode, child));
|
|
568
563
|
return treeNode;
|
|
569
564
|
} catch (e) {
|
|
570
565
|
throw new Error("Something went wrong with creating barrel files with the TreeNode class", { cause: e });
|
|
571
566
|
}
|
|
572
567
|
}
|
|
573
|
-
}
|
|
568
|
+
};
|
|
574
569
|
function buildDirectoryTree(files, rootFolder = "") {
|
|
575
570
|
const rootPrefix = rootFolder.endsWith("/") ? rootFolder : `${rootFolder}/`;
|
|
576
571
|
const filteredFiles = files.filter((file) => rootFolder ? file.path.startsWith(rootPrefix) && !file.path.endsWith(".json") : !file.path.endsWith(".json"));
|
|
@@ -617,9 +612,6 @@ function buildDirectoryTree(files, rootFolder = "") {
|
|
|
617
612
|
});
|
|
618
613
|
return root;
|
|
619
614
|
}
|
|
620
|
-
|
|
621
|
-
// src/BarrelManager.ts
|
|
622
|
-
|
|
623
615
|
var BarrelManager = class {
|
|
624
616
|
#options;
|
|
625
617
|
constructor(options = {}) {
|
|
@@ -629,13 +621,13 @@ var BarrelManager = class {
|
|
|
629
621
|
getFiles({ files: generatedFiles, root, meta }) {
|
|
630
622
|
const { logger } = this.#options;
|
|
631
623
|
const cachedFiles = /* @__PURE__ */ new Map();
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
if (!treeNode || !treeNode.children || !
|
|
624
|
+
logger?.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Start barrel generation for pluginKey ${meta?.pluginKey?.join(".")} and root '${root}'`] });
|
|
625
|
+
TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {
|
|
626
|
+
if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {
|
|
635
627
|
return void 0;
|
|
636
628
|
}
|
|
637
629
|
const barrelFile = {
|
|
638
|
-
path:
|
|
630
|
+
path: path.join(treeNode.parent?.data.path, "index.ts"),
|
|
639
631
|
baseName: "index.ts",
|
|
640
632
|
exports: [],
|
|
641
633
|
sources: []
|
|
@@ -646,30 +638,30 @@ var BarrelManager = class {
|
|
|
646
638
|
if (!item.data.name) {
|
|
647
639
|
return void 0;
|
|
648
640
|
}
|
|
649
|
-
const sources =
|
|
641
|
+
const sources = item.data.file?.sources || [];
|
|
650
642
|
if (!sources.some((source) => source.isIndexable)) {
|
|
651
|
-
|
|
643
|
+
logger?.emit(
|
|
652
644
|
"warning",
|
|
653
645
|
`No isIndexable source found(source should have a name and isIndexable):
|
|
654
646
|
File: ${JSON.stringify(item.data.file, void 0, 2)}`
|
|
655
|
-
)
|
|
647
|
+
);
|
|
656
648
|
}
|
|
657
649
|
sources.forEach((source) => {
|
|
658
|
-
if (!
|
|
650
|
+
if (!item.data.file?.path || !source.isIndexable || !source.name) {
|
|
659
651
|
return void 0;
|
|
660
652
|
}
|
|
661
|
-
const alreadyContainInPreviousBarrelFile =
|
|
653
|
+
const alreadyContainInPreviousBarrelFile = previousBarrelFile?.sources.some((item2) => item2.name === source.name);
|
|
662
654
|
if (alreadyContainInPreviousBarrelFile) {
|
|
663
655
|
return void 0;
|
|
664
656
|
}
|
|
665
657
|
if (!barrelFile.exports) {
|
|
666
658
|
barrelFile.exports = [];
|
|
667
659
|
}
|
|
668
|
-
const isSubExport = !!
|
|
660
|
+
const isSubExport = !!treeNode.parent?.data.path?.split?.("/")?.length;
|
|
669
661
|
if (isSubExport) {
|
|
670
662
|
barrelFile.exports.push({
|
|
671
663
|
name: [source.name],
|
|
672
|
-
path:
|
|
664
|
+
path: fs.getRelativePath(treeNode.parent?.data.path, item.data.path),
|
|
673
665
|
isTypeOnly: source.isTypeOnly
|
|
674
666
|
});
|
|
675
667
|
} else {
|
|
@@ -689,41 +681,38 @@ File: ${JSON.stringify(item.data.file, void 0, 2)}`
|
|
|
689
681
|
});
|
|
690
682
|
});
|
|
691
683
|
});
|
|
692
|
-
|
|
684
|
+
logger?.emit("debug", {
|
|
693
685
|
date: /* @__PURE__ */ new Date(),
|
|
694
686
|
logs: [
|
|
695
|
-
`Generating barrelFile '${
|
|
687
|
+
`Generating barrelFile '${fs.getRelativePath(root, barrelFile.path)}' for '${fs.getRelativePath(root, treeNode.data?.path)}' with ${barrelFile.sources.length} indexable exports: '${barrelFile.sources?.map((source) => source.name).join(", ")}'`
|
|
696
688
|
]
|
|
697
|
-
})
|
|
698
|
-
|
|
689
|
+
});
|
|
690
|
+
logger?.emit("debug", {
|
|
699
691
|
date: /* @__PURE__ */ new Date(),
|
|
700
692
|
logs: [
|
|
701
|
-
`Generated barrelFile '${
|
|
693
|
+
`Generated barrelFile '${fs.getRelativePath(root, barrelFile.path)}' for '${fs.getRelativePath(root, treeNode.data?.path)}' with exports: '${cachedFiles.get(barrelFile.path)?.sources?.map((source) => source.name).join(", ")}'`
|
|
702
694
|
]
|
|
703
|
-
})
|
|
695
|
+
});
|
|
704
696
|
if (previousBarrelFile) {
|
|
705
697
|
previousBarrelFile.sources.push(...barrelFile.sources);
|
|
706
|
-
|
|
698
|
+
previousBarrelFile.exports?.push(...barrelFile.exports || []);
|
|
707
699
|
} else {
|
|
708
700
|
cachedFiles.set(barrelFile.path, barrelFile);
|
|
709
701
|
}
|
|
710
|
-
})
|
|
702
|
+
});
|
|
711
703
|
return [...cachedFiles.values()];
|
|
712
704
|
}
|
|
713
705
|
};
|
|
714
706
|
|
|
715
|
-
// src/FileManager.ts
|
|
716
|
-
|
|
717
|
-
|
|
718
707
|
// ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
|
|
719
|
-
|
|
708
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
720
709
|
|
|
721
710
|
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
722
|
-
|
|
723
|
-
var import_index =
|
|
711
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
712
|
+
var import_index = chunkADFKVVPE_cjs.__toESM(require_eventemitter3(), 1);
|
|
724
713
|
|
|
725
714
|
// ../../node_modules/.pnpm/p-timeout@6.1.2/node_modules/p-timeout/index.js
|
|
726
|
-
|
|
715
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
727
716
|
var TimeoutError = class extends Error {
|
|
728
717
|
constructor(message) {
|
|
729
718
|
super(message);
|
|
@@ -785,7 +774,7 @@ function pTimeout(promise, options) {
|
|
|
785
774
|
} else if (message instanceof Error) {
|
|
786
775
|
reject(message);
|
|
787
776
|
} else {
|
|
788
|
-
timeoutError.message =
|
|
777
|
+
timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
|
|
789
778
|
reject(timeoutError);
|
|
790
779
|
}
|
|
791
780
|
}, milliseconds);
|
|
@@ -808,10 +797,10 @@ function pTimeout(promise, options) {
|
|
|
808
797
|
}
|
|
809
798
|
|
|
810
799
|
// ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/priority-queue.js
|
|
811
|
-
|
|
800
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
812
801
|
|
|
813
802
|
// ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/lower-bound.js
|
|
814
|
-
|
|
803
|
+
chunkADFKVVPE_cjs.init_cjs_shims();
|
|
815
804
|
function lowerBound(array, value, comparator) {
|
|
816
805
|
let first = 0;
|
|
817
806
|
let count = array.length;
|
|
@@ -849,7 +838,7 @@ var PriorityQueue = class {
|
|
|
849
838
|
}
|
|
850
839
|
dequeue() {
|
|
851
840
|
const item = this.#queue.shift();
|
|
852
|
-
return
|
|
841
|
+
return item?.run;
|
|
853
842
|
}
|
|
854
843
|
filter(options) {
|
|
855
844
|
return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);
|
|
@@ -881,7 +870,7 @@ var PQueue = class extends import_index.default {
|
|
|
881
870
|
|
|
882
871
|
Applies to each future operation.
|
|
883
872
|
*/
|
|
884
|
-
|
|
873
|
+
timeout;
|
|
885
874
|
// TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
|
|
886
875
|
constructor(options) {
|
|
887
876
|
super();
|
|
@@ -895,10 +884,10 @@ var PQueue = class extends import_index.default {
|
|
|
895
884
|
...options
|
|
896
885
|
};
|
|
897
886
|
if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
|
|
898
|
-
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${
|
|
887
|
+
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${options.intervalCap?.toString() ?? ""}\` (${typeof options.intervalCap})`);
|
|
899
888
|
}
|
|
900
889
|
if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
|
|
901
|
-
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${
|
|
890
|
+
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
|
|
902
891
|
}
|
|
903
892
|
this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;
|
|
904
893
|
this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
|
|
@@ -1025,7 +1014,7 @@ var PQueue = class extends import_index.default {
|
|
|
1025
1014
|
this.#pending++;
|
|
1026
1015
|
this.#intervalCount++;
|
|
1027
1016
|
try {
|
|
1028
|
-
|
|
1017
|
+
options.signal?.throwIfAborted();
|
|
1029
1018
|
let operation = function_({ signal: options.signal });
|
|
1030
1019
|
if (options.timeout) {
|
|
1031
1020
|
operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
|
|
@@ -1155,27 +1144,29 @@ var PQueue = class extends import_index.default {
|
|
|
1155
1144
|
// src/FileManager.ts
|
|
1156
1145
|
var FileManager = class {
|
|
1157
1146
|
#filesByPath = /* @__PURE__ */ new Map();
|
|
1158
|
-
#files = /* @__PURE__ */ new Set();
|
|
1159
1147
|
constructor() {
|
|
1160
1148
|
return this;
|
|
1161
1149
|
}
|
|
1162
1150
|
get files() {
|
|
1163
|
-
return
|
|
1151
|
+
return [...this.#filesByPath.values()];
|
|
1164
1152
|
}
|
|
1165
1153
|
get orderedFiles() {
|
|
1166
|
-
return
|
|
1167
|
-
(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1154
|
+
return chunkJRU2D5E6_cjs.orderBy(
|
|
1155
|
+
[...this.#filesByPath.values()],
|
|
1156
|
+
[
|
|
1157
|
+
(v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
1158
|
+
(v) => v.path.length,
|
|
1159
|
+
(v) => fs.trimExtName(v.path).endsWith("index"),
|
|
1160
|
+
(v) => fs.trimExtName(v.baseName),
|
|
1161
|
+
(v) => v.path.split(".").pop()
|
|
1162
|
+
]
|
|
1163
|
+
);
|
|
1173
1164
|
}
|
|
1174
1165
|
get groupedFiles() {
|
|
1175
|
-
return buildDirectoryTree(
|
|
1166
|
+
return buildDirectoryTree([...this.#filesByPath.values()]);
|
|
1176
1167
|
}
|
|
1177
1168
|
get treeNode() {
|
|
1178
|
-
return TreeNode.build(
|
|
1169
|
+
return TreeNode.build([...this.#filesByPath.values()]);
|
|
1179
1170
|
}
|
|
1180
1171
|
async add(...files) {
|
|
1181
1172
|
const promises = files.map((file) => {
|
|
@@ -1193,30 +1184,21 @@ var FileManager = class {
|
|
|
1193
1184
|
async #add(file) {
|
|
1194
1185
|
const resolvedFile = createFile(file);
|
|
1195
1186
|
this.#filesByPath.set(resolvedFile.path, resolvedFile);
|
|
1196
|
-
this.#files.add(resolvedFile);
|
|
1197
1187
|
return resolvedFile;
|
|
1198
1188
|
}
|
|
1199
1189
|
clear() {
|
|
1200
1190
|
this.#filesByPath.clear();
|
|
1201
|
-
this.#files.clear();
|
|
1202
1191
|
}
|
|
1203
1192
|
async #addOrAppend(file) {
|
|
1204
1193
|
const previousFile = this.#filesByPath.get(file.path);
|
|
1205
1194
|
if (previousFile) {
|
|
1206
1195
|
this.#filesByPath.delete(previousFile.path);
|
|
1207
|
-
this.#files.delete(previousFile);
|
|
1208
1196
|
return this.#add(mergeFile(previousFile, file));
|
|
1209
1197
|
}
|
|
1210
1198
|
return this.#add(file);
|
|
1211
1199
|
}
|
|
1212
1200
|
getCacheById(id) {
|
|
1213
|
-
|
|
1214
|
-
this.#files.forEach((file) => {
|
|
1215
|
-
if (file.id === id) {
|
|
1216
|
-
cache = file;
|
|
1217
|
-
}
|
|
1218
|
-
});
|
|
1219
|
-
return cache;
|
|
1201
|
+
return [...this.#filesByPath.values()].find((file) => file.id === id);
|
|
1220
1202
|
}
|
|
1221
1203
|
getByPath(path) {
|
|
1222
1204
|
return this.#filesByPath.get(path);
|
|
@@ -1227,7 +1209,6 @@ var FileManager = class {
|
|
|
1227
1209
|
return;
|
|
1228
1210
|
}
|
|
1229
1211
|
this.#filesByPath.delete(path);
|
|
1230
|
-
this.#files.delete(cacheItem);
|
|
1231
1212
|
}
|
|
1232
1213
|
async getBarrelFiles({ files, meta, root, output, logger }) {
|
|
1233
1214
|
const { exportType = "barrelNamed" } = output;
|
|
@@ -1235,9 +1216,9 @@ var FileManager = class {
|
|
|
1235
1216
|
if (exportType === false) {
|
|
1236
1217
|
return [];
|
|
1237
1218
|
}
|
|
1238
|
-
const pathToBuildFrom =
|
|
1239
|
-
if (
|
|
1240
|
-
|
|
1219
|
+
const pathToBuildFrom = path.join(root, output.path);
|
|
1220
|
+
if (fs.trimExtName(pathToBuildFrom).endsWith("index")) {
|
|
1221
|
+
logger?.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
|
|
1241
1222
|
return [];
|
|
1242
1223
|
}
|
|
1243
1224
|
const barrelFiles = barrelManager.getFiles({ files, root: pathToBuildFrom, meta });
|
|
@@ -1245,12 +1226,12 @@ var FileManager = class {
|
|
|
1245
1226
|
return barrelFiles.map((file) => {
|
|
1246
1227
|
return {
|
|
1247
1228
|
...file,
|
|
1248
|
-
exports:
|
|
1229
|
+
exports: file.exports?.map((exportItem) => {
|
|
1249
1230
|
return {
|
|
1250
1231
|
...exportItem,
|
|
1251
1232
|
name: void 0
|
|
1252
1233
|
};
|
|
1253
|
-
})
|
|
1234
|
+
})
|
|
1254
1235
|
};
|
|
1255
1236
|
});
|
|
1256
1237
|
}
|
|
@@ -1262,17 +1243,17 @@ var FileManager = class {
|
|
|
1262
1243
|
});
|
|
1263
1244
|
}
|
|
1264
1245
|
async write(...params) {
|
|
1265
|
-
return
|
|
1246
|
+
return fs.write(...params);
|
|
1266
1247
|
}
|
|
1267
1248
|
async read(...params) {
|
|
1268
|
-
return
|
|
1249
|
+
return fs.read(...params);
|
|
1269
1250
|
}
|
|
1270
1251
|
// statics
|
|
1271
|
-
static getMode(path) {
|
|
1272
|
-
if (!path) {
|
|
1252
|
+
static getMode(path$1) {
|
|
1253
|
+
if (!path$1) {
|
|
1273
1254
|
return "split";
|
|
1274
1255
|
}
|
|
1275
|
-
return
|
|
1256
|
+
return path.extname(path$1) ? "single" : "split";
|
|
1276
1257
|
}
|
|
1277
1258
|
};
|
|
1278
1259
|
async function getSource(file, { logger } = {}) {
|
|
@@ -1308,18 +1289,24 @@ function combineSources(sources) {
|
|
|
1308
1289
|
);
|
|
1309
1290
|
}
|
|
1310
1291
|
function combineExports(exports) {
|
|
1311
|
-
|
|
1292
|
+
return chunkJRU2D5E6_cjs.orderBy(exports, [
|
|
1293
|
+
(v) => !!Array.isArray(v.name),
|
|
1294
|
+
(v) => !v.isTypeOnly,
|
|
1295
|
+
(v) => v.path,
|
|
1296
|
+
(v) => !!v.name,
|
|
1297
|
+
(v) => Array.isArray(v.name) ? chunkJRU2D5E6_cjs.orderBy(v.name) : v.name
|
|
1298
|
+
]).reduce(
|
|
1312
1299
|
(prev, curr) => {
|
|
1313
1300
|
const name = curr.name;
|
|
1314
1301
|
const prevByPath = prev.findLast((imp) => imp.path === curr.path);
|
|
1315
|
-
const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path &&
|
|
1302
|
+
const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly);
|
|
1316
1303
|
if (prevByPathAndIsTypeOnly) {
|
|
1317
1304
|
return prev;
|
|
1318
1305
|
}
|
|
1319
1306
|
const uniquePrev = prev.findLast(
|
|
1320
|
-
(imp) => imp.path === curr.path &&
|
|
1307
|
+
(imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
|
|
1321
1308
|
);
|
|
1322
|
-
if (uniquePrev || Array.isArray(name) && !name.length ||
|
|
1309
|
+
if (uniquePrev || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) {
|
|
1323
1310
|
return prev;
|
|
1324
1311
|
}
|
|
1325
1312
|
if (!prevByPath) {
|
|
@@ -1339,23 +1326,24 @@ function combineExports(exports) {
|
|
|
1339
1326
|
},
|
|
1340
1327
|
[]
|
|
1341
1328
|
);
|
|
1342
|
-
|
|
1329
|
+
}
|
|
1330
|
+
function combineImports(imports, exports, source) {
|
|
1331
|
+
return chunkJRU2D5E6_cjs.orderBy(imports, [
|
|
1343
1332
|
(v) => !!Array.isArray(v.name),
|
|
1344
1333
|
(v) => !v.isTypeOnly,
|
|
1345
1334
|
(v) => v.path,
|
|
1346
1335
|
(v) => !!v.name,
|
|
1347
|
-
(v) => Array.isArray(v.name) ?
|
|
1348
|
-
])
|
|
1349
|
-
}
|
|
1350
|
-
function combineImports(imports, exports, source) {
|
|
1351
|
-
const combinedImports = imports.reduce(
|
|
1336
|
+
(v) => Array.isArray(v.name) ? chunkJRU2D5E6_cjs.orderBy(v.name) : v.name
|
|
1337
|
+
]).reduce(
|
|
1352
1338
|
(prev, curr) => {
|
|
1353
1339
|
let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
|
|
1354
1340
|
const hasImportInSource = (importName) => {
|
|
1355
1341
|
if (!source) {
|
|
1356
1342
|
return true;
|
|
1357
1343
|
}
|
|
1358
|
-
const checker = (name2) =>
|
|
1344
|
+
const checker = (name2) => {
|
|
1345
|
+
return name2 && !!source.includes(name2);
|
|
1346
|
+
};
|
|
1359
1347
|
return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
|
|
1360
1348
|
};
|
|
1361
1349
|
if (curr.path === curr.root) {
|
|
@@ -1365,8 +1353,8 @@ function combineImports(imports, exports, source) {
|
|
|
1365
1353
|
name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
|
|
1366
1354
|
}
|
|
1367
1355
|
const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
|
|
1368
|
-
const uniquePrev = prev.findLast((imp) => imp.path === curr.path &&
|
|
1369
|
-
const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path &&
|
|
1356
|
+
const uniquePrev = prev.findLast((imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
|
|
1357
|
+
const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly);
|
|
1370
1358
|
if (prevByPathNameAndIsTypeOnly) {
|
|
1371
1359
|
return prev;
|
|
1372
1360
|
}
|
|
@@ -1393,20 +1381,13 @@ function combineImports(imports, exports, source) {
|
|
|
1393
1381
|
},
|
|
1394
1382
|
[]
|
|
1395
1383
|
);
|
|
1396
|
-
return _chunkA6PCLWEYcjs.orderBy.call(void 0, combinedImports, [
|
|
1397
|
-
(v) => !!Array.isArray(v.name),
|
|
1398
|
-
(v) => !v.isTypeOnly,
|
|
1399
|
-
(v) => v.path,
|
|
1400
|
-
(v) => !!v.name,
|
|
1401
|
-
(v) => Array.isArray(v.name) ? _chunkA6PCLWEYcjs.orderBy.call(void 0, v.name) : v.name
|
|
1402
|
-
]);
|
|
1403
1384
|
}
|
|
1404
1385
|
var queue = new PQueue({ concurrency: 100 });
|
|
1405
1386
|
async function processFiles({ dryRun, config, logger, files }) {
|
|
1406
|
-
const orderedFiles =
|
|
1407
|
-
(v) =>
|
|
1387
|
+
const orderedFiles = chunkJRU2D5E6_cjs.orderBy(files, [
|
|
1388
|
+
(v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
1408
1389
|
(v) => v.path.length,
|
|
1409
|
-
(v) =>
|
|
1390
|
+
(v) => fs.trimExtName(v.path).endsWith("index")
|
|
1410
1391
|
]);
|
|
1411
1392
|
logger.emit("debug", {
|
|
1412
1393
|
date: /* @__PURE__ */ new Date(),
|
|
@@ -1418,9 +1399,9 @@ async function processFiles({ dryRun, config, logger, files }) {
|
|
|
1418
1399
|
logger.emit("progress_start", { id: "files", size, message: "Writing files ..." });
|
|
1419
1400
|
const promises = orderedFiles.map(async (file) => {
|
|
1420
1401
|
await queue.add(async () => {
|
|
1421
|
-
const message = file ? `Writing ${
|
|
1402
|
+
const message = file ? `Writing ${path.relative(config.root, file.path)}` : "";
|
|
1422
1403
|
const source = await getSource(file, { logger });
|
|
1423
|
-
await
|
|
1404
|
+
await fs.write(file.path, source, { sanity: false });
|
|
1424
1405
|
logger.emit("progressed", { id: "files", message });
|
|
1425
1406
|
});
|
|
1426
1407
|
});
|
|
@@ -1432,7 +1413,7 @@ async function processFiles({ dryRun, config, logger, files }) {
|
|
|
1432
1413
|
|
|
1433
1414
|
// src/utils/parser.ts
|
|
1434
1415
|
function createFile(file) {
|
|
1435
|
-
const extName =
|
|
1416
|
+
const extName = path.extname(file.baseName);
|
|
1436
1417
|
if (!extName) {
|
|
1437
1418
|
throw new Error(`No extName found for ${file.baseName}`);
|
|
1438
1419
|
}
|
|
@@ -1442,7 +1423,7 @@ function createFile(file) {
|
|
|
1442
1423
|
const sources = file.sources ? combineSources(file.sources) : [];
|
|
1443
1424
|
return {
|
|
1444
1425
|
...file,
|
|
1445
|
-
id:
|
|
1426
|
+
id: hash__default.default({ path: file.path }),
|
|
1446
1427
|
name: trimExtName2(file.baseName),
|
|
1447
1428
|
extName,
|
|
1448
1429
|
imports: imports.map((item) => createFileImport(item)),
|
|
@@ -1454,14 +1435,14 @@ function createFileSource(source) {
|
|
|
1454
1435
|
return source;
|
|
1455
1436
|
}
|
|
1456
1437
|
function createFileImport(imp) {
|
|
1457
|
-
const extName =
|
|
1438
|
+
const extName = path.extname(imp.path);
|
|
1458
1439
|
return {
|
|
1459
1440
|
...imp,
|
|
1460
1441
|
extName: imp.extName ? imp.extName : extName
|
|
1461
1442
|
};
|
|
1462
1443
|
}
|
|
1463
1444
|
function createFileExport(exp) {
|
|
1464
|
-
const extName =
|
|
1445
|
+
const extName = path.extname(exp.path);
|
|
1465
1446
|
return {
|
|
1466
1447
|
...exp,
|
|
1467
1448
|
extName: exp.extName ? exp.extName : extName
|
|
@@ -1475,9 +1456,10 @@ var typeScriptParser = createFileParser({
|
|
|
1475
1456
|
return void 0;
|
|
1476
1457
|
},
|
|
1477
1458
|
async print(file) {
|
|
1478
|
-
const module = await
|
|
1459
|
+
const module = await import('@kubb/parser-ts');
|
|
1460
|
+
const source = file.sources.map((item) => item.value).join("\n\n");
|
|
1479
1461
|
const importNodes = file.imports.map((item) => {
|
|
1480
|
-
const path = item.root ?
|
|
1462
|
+
const path = item.root ? fs.getRelativePath(item.root, item.path) : item.path;
|
|
1481
1463
|
return module.factory.createImportDeclaration({
|
|
1482
1464
|
name: item.name,
|
|
1483
1465
|
path,
|
|
@@ -1492,8 +1474,7 @@ var typeScriptParser = createFileParser({
|
|
|
1492
1474
|
asAlias: item.asAlias
|
|
1493
1475
|
});
|
|
1494
1476
|
}).filter(Boolean);
|
|
1495
|
-
|
|
1496
|
-
return module.print([], { source, noEmitHelpers: false });
|
|
1477
|
+
return module.print([], { source: [module.print([...importNodes, ...exportNodes]), source].join("\n"), noEmitHelpers: false });
|
|
1497
1478
|
}
|
|
1498
1479
|
});
|
|
1499
1480
|
var defaultParser = createFileParser({
|
|
@@ -1526,23 +1507,25 @@ function trimExtName2(text) {
|
|
|
1526
1507
|
return text.replace(`.${extName}`, "");
|
|
1527
1508
|
}
|
|
1528
1509
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
exports.
|
|
1548
|
-
|
|
1510
|
+
exports.FileManager = FileManager;
|
|
1511
|
+
exports.FunctionParams = FunctionParams;
|
|
1512
|
+
exports.URLPath = URLPath;
|
|
1513
|
+
exports.combineExports = combineExports;
|
|
1514
|
+
exports.combineImports = combineImports;
|
|
1515
|
+
exports.combineSources = combineSources;
|
|
1516
|
+
exports.createFile = createFile;
|
|
1517
|
+
exports.createFileExport = createFileExport;
|
|
1518
|
+
exports.createFileImport = createFileImport;
|
|
1519
|
+
exports.createFileParser = createFileParser;
|
|
1520
|
+
exports.getFileParser = getFileParser;
|
|
1521
|
+
exports.getSource = getSource;
|
|
1522
|
+
exports.getUniqueName = getUniqueName;
|
|
1523
|
+
exports.isPromise = isPromise;
|
|
1524
|
+
exports.isPromiseFulfilledResult = isPromiseFulfilledResult;
|
|
1525
|
+
exports.isPromiseRejectedResult = isPromiseRejectedResult;
|
|
1526
|
+
exports.processFiles = processFiles;
|
|
1527
|
+
exports.renderTemplate = renderTemplate;
|
|
1528
|
+
exports.setUniqueName = setUniqueName;
|
|
1529
|
+
exports.timeout = timeout;
|
|
1530
|
+
//# sourceMappingURL=chunk-OJRKV365.cjs.map
|
|
1531
|
+
//# sourceMappingURL=chunk-OJRKV365.cjs.map
|