@kubb/core 3.10.12 → 3.10.14
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/{chunk-PQLA6PG5.cjs → chunk-4Y54TK73.cjs} +296 -313
- package/dist/chunk-4Y54TK73.cjs.map +1 -0
- package/dist/{chunk-SUT27VY3.cjs → chunk-DFVR26S3.cjs} +13 -13
- package/dist/{chunk-SUT27VY3.cjs.map → chunk-DFVR26S3.cjs.map} +1 -1
- package/dist/{chunk-FFYEJDCV.cjs → chunk-DYN65P3T.cjs} +8 -8
- package/dist/{chunk-FFYEJDCV.cjs.map → chunk-DYN65P3T.cjs.map} +1 -1
- package/dist/{chunk-CXD7TVLT.cjs → chunk-H7GP5BQJ.cjs} +4 -4
- package/dist/chunk-H7GP5BQJ.cjs.map +1 -0
- package/dist/{chunk-YYPJL6UD.js → chunk-PNGIYL5L.js} +6 -21
- package/dist/chunk-PNGIYL5L.js.map +1 -0
- package/dist/{chunk-67N7TJNL.cjs → chunk-ZZEKLURQ.cjs} +17 -17
- package/dist/{chunk-67N7TJNL.cjs.map → chunk-ZZEKLURQ.cjs.map} +1 -1
- package/dist/fs.cjs +9 -9
- package/dist/index.cjs +42 -42
- package/dist/index.js +2 -2
- package/dist/logger.cjs +7 -7
- package/dist/mocks.cjs +10 -10
- package/dist/mocks.js +1 -1
- package/dist/{prompt-QMWQEXIN.cjs → prompt-HR6NQYCR.cjs} +4 -4
- package/dist/{prompt-QMWQEXIN.cjs.map → prompt-HR6NQYCR.cjs.map} +1 -1
- package/dist/transformers.cjs +22 -22
- package/dist/utils.cjs +19 -19
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/src/FileManager.ts +6 -31
- package/dist/chunk-CXD7TVLT.cjs.map +0 -1
- package/dist/chunk-PQLA6PG5.cjs.map +0 -1
- package/dist/chunk-YYPJL6UD.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkZZEKLURQ_cjs = require('./chunk-ZZEKLURQ.cjs');
|
|
4
|
+
var chunkDYN65P3T_cjs = require('./chunk-DYN65P3T.cjs');
|
|
5
|
+
var chunkH7GP5BQJ_cjs = require('./chunk-H7GP5BQJ.cjs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var hash = require('object-hash');
|
|
8
8
|
var remeda = require('remeda');
|
|
@@ -13,9 +13,9 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
13
13
|
var hash__default = /*#__PURE__*/_interopDefault(hash);
|
|
14
14
|
|
|
15
15
|
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
|
|
16
|
-
var require_eventemitter3 =
|
|
16
|
+
var require_eventemitter3 = chunkH7GP5BQJ_cjs.__commonJS({
|
|
17
17
|
"../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
|
|
18
|
-
|
|
18
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
19
19
|
var has = Object.prototype.hasOwnProperty;
|
|
20
20
|
var prefix = "~";
|
|
21
21
|
function Events() {
|
|
@@ -175,10 +175,10 @@ var require_eventemitter3 = chunkCXD7TVLT_cjs.__commonJS({
|
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
// src/utils/index.ts
|
|
178
|
-
|
|
178
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
179
179
|
|
|
180
180
|
// src/utils/FunctionParams.ts
|
|
181
|
-
|
|
181
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
182
182
|
var FunctionParams = class _FunctionParams {
|
|
183
183
|
#items = [];
|
|
184
184
|
constructor() {
|
|
@@ -199,7 +199,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
199
199
|
return this;
|
|
200
200
|
}
|
|
201
201
|
static #orderItems(items) {
|
|
202
|
-
return
|
|
202
|
+
return chunkZZEKLURQ_cjs.orderBy(
|
|
203
203
|
items.filter(Boolean),
|
|
204
204
|
[
|
|
205
205
|
(v) => {
|
|
@@ -227,7 +227,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
227
227
|
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
228
228
|
return acc;
|
|
229
229
|
}
|
|
230
|
-
const parameterName = name.startsWith("{") ? name :
|
|
230
|
+
const parameterName = name.startsWith("{") ? name : chunkZZEKLURQ_cjs.camelCase(name);
|
|
231
231
|
if (type) {
|
|
232
232
|
if (required) {
|
|
233
233
|
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
@@ -282,7 +282,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
282
282
|
};
|
|
283
283
|
|
|
284
284
|
// src/utils/promise.ts
|
|
285
|
-
|
|
285
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
286
286
|
function isPromise(result) {
|
|
287
287
|
return !!result && typeof result?.then === "function";
|
|
288
288
|
}
|
|
@@ -294,7 +294,7 @@ function isPromiseRejectedResult(result) {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
// src/utils/renderTemplate.ts
|
|
297
|
-
|
|
297
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
298
298
|
function renderTemplate(template, data = void 0) {
|
|
299
299
|
if (!data || !Object.keys(data).length) {
|
|
300
300
|
return template.replace(/{{(.*?)}}/g, "");
|
|
@@ -319,7 +319,7 @@ function renderTemplate(template, data = void 0) {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
// src/utils/timeout.ts
|
|
322
|
-
|
|
322
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
323
323
|
async function timeout(ms) {
|
|
324
324
|
return new Promise((resolve) => {
|
|
325
325
|
setTimeout(() => {
|
|
@@ -329,7 +329,7 @@ async function timeout(ms) {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
// src/utils/uniqueName.ts
|
|
332
|
-
|
|
332
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
333
333
|
function getUniqueName(originalName, data) {
|
|
334
334
|
let used = data[originalName] || 0;
|
|
335
335
|
if (used) {
|
|
@@ -350,7 +350,7 @@ function setUniqueName(originalName, data) {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
// src/utils/URLPath.ts
|
|
353
|
-
|
|
353
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
354
354
|
var URLPath = class {
|
|
355
355
|
path;
|
|
356
356
|
#options;
|
|
@@ -421,9 +421,9 @@ var URLPath = class {
|
|
|
421
421
|
if (found) {
|
|
422
422
|
newPath = found.reduce((prev, path2) => {
|
|
423
423
|
const pathWithoutBrackets = path2.replaceAll("{", "").replaceAll("}", "");
|
|
424
|
-
let param =
|
|
424
|
+
let param = chunkZZEKLURQ_cjs.isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : chunkZZEKLURQ_cjs.camelCase(pathWithoutBrackets);
|
|
425
425
|
if (this.#options.casing === "camelcase") {
|
|
426
|
-
param =
|
|
426
|
+
param = chunkZZEKLURQ_cjs.camelCase(param);
|
|
427
427
|
}
|
|
428
428
|
return prev.replace(path2, `\${${replacer ? replacer(param) : param}}`);
|
|
429
429
|
}, this.path);
|
|
@@ -439,9 +439,9 @@ var URLPath = class {
|
|
|
439
439
|
const params = {};
|
|
440
440
|
found.forEach((item) => {
|
|
441
441
|
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
442
|
-
let param =
|
|
442
|
+
let param = chunkZZEKLURQ_cjs.isValidVarName(item) ? item : chunkZZEKLURQ_cjs.camelCase(item);
|
|
443
443
|
if (this.#options.casing === "camelcase") {
|
|
444
|
-
param =
|
|
444
|
+
param = chunkZZEKLURQ_cjs.camelCase(param);
|
|
445
445
|
}
|
|
446
446
|
const key = replacer ? replacer(param) : param;
|
|
447
447
|
params[key] = key;
|
|
@@ -458,273 +458,20 @@ var URLPath = class {
|
|
|
458
458
|
};
|
|
459
459
|
|
|
460
460
|
// src/utils/parser.ts
|
|
461
|
-
|
|
461
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
462
462
|
|
|
463
463
|
// src/FileManager.ts
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
// src/BarrelManager.ts
|
|
467
|
-
chunkCXD7TVLT_cjs.init_cjs_shims();
|
|
468
|
-
|
|
469
|
-
// src/utils/TreeNode.ts
|
|
470
|
-
chunkCXD7TVLT_cjs.init_cjs_shims();
|
|
471
|
-
var TreeNode = class _TreeNode {
|
|
472
|
-
data;
|
|
473
|
-
parent;
|
|
474
|
-
children = [];
|
|
475
|
-
#cachedLeaves = void 0;
|
|
476
|
-
constructor(data, parent) {
|
|
477
|
-
this.data = data;
|
|
478
|
-
this.parent = parent;
|
|
479
|
-
return this;
|
|
480
|
-
}
|
|
481
|
-
addChild(data) {
|
|
482
|
-
const child = new _TreeNode(data, this);
|
|
483
|
-
if (!this.children) {
|
|
484
|
-
this.children = [];
|
|
485
|
-
}
|
|
486
|
-
this.children.push(child);
|
|
487
|
-
return child;
|
|
488
|
-
}
|
|
489
|
-
get root() {
|
|
490
|
-
if (!this.parent) {
|
|
491
|
-
return this;
|
|
492
|
-
}
|
|
493
|
-
return this.parent.root;
|
|
494
|
-
}
|
|
495
|
-
get leaves() {
|
|
496
|
-
if (!this.children || this.children.length === 0) {
|
|
497
|
-
return [this];
|
|
498
|
-
}
|
|
499
|
-
if (this.#cachedLeaves) {
|
|
500
|
-
return this.#cachedLeaves;
|
|
501
|
-
}
|
|
502
|
-
const leaves = [];
|
|
503
|
-
if (this.children) {
|
|
504
|
-
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
505
|
-
leaves.push.apply(leaves, this.children[i].leaves);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
this.#cachedLeaves = leaves;
|
|
509
|
-
return leaves;
|
|
510
|
-
}
|
|
511
|
-
forEach(callback) {
|
|
512
|
-
if (typeof callback !== "function") {
|
|
513
|
-
throw new TypeError("forEach() callback must be a function");
|
|
514
|
-
}
|
|
515
|
-
callback(this);
|
|
516
|
-
if (this.children) {
|
|
517
|
-
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
518
|
-
this.children[i]?.forEach(callback);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return this;
|
|
522
|
-
}
|
|
523
|
-
findDeep(predicate) {
|
|
524
|
-
if (typeof predicate !== "function") {
|
|
525
|
-
throw new TypeError("find() predicate must be a function");
|
|
526
|
-
}
|
|
527
|
-
return this.leaves.find(predicate);
|
|
528
|
-
}
|
|
529
|
-
forEachDeep(callback) {
|
|
530
|
-
if (typeof callback !== "function") {
|
|
531
|
-
throw new TypeError("forEach() callback must be a function");
|
|
532
|
-
}
|
|
533
|
-
this.leaves.forEach(callback);
|
|
534
|
-
}
|
|
535
|
-
filterDeep(callback) {
|
|
536
|
-
if (typeof callback !== "function") {
|
|
537
|
-
throw new TypeError("filter() callback must be a function");
|
|
538
|
-
}
|
|
539
|
-
return this.leaves.filter(callback);
|
|
540
|
-
}
|
|
541
|
-
mapDeep(callback) {
|
|
542
|
-
if (typeof callback !== "function") {
|
|
543
|
-
throw new TypeError("map() callback must be a function");
|
|
544
|
-
}
|
|
545
|
-
return this.leaves.map(callback);
|
|
546
|
-
}
|
|
547
|
-
static build(files, root) {
|
|
548
|
-
try {
|
|
549
|
-
const filteredTree = buildDirectoryTree(files, root);
|
|
550
|
-
if (!filteredTree) {
|
|
551
|
-
return null;
|
|
552
|
-
}
|
|
553
|
-
const treeNode = new _TreeNode({
|
|
554
|
-
name: filteredTree.name,
|
|
555
|
-
path: filteredTree.path,
|
|
556
|
-
file: filteredTree.file,
|
|
557
|
-
type: FileManager.getMode(filteredTree.path)
|
|
558
|
-
});
|
|
559
|
-
const recurse = (node, item) => {
|
|
560
|
-
const subNode = node.addChild({
|
|
561
|
-
name: item.name,
|
|
562
|
-
path: item.path,
|
|
563
|
-
file: item.file,
|
|
564
|
-
type: FileManager.getMode(item.path)
|
|
565
|
-
});
|
|
566
|
-
if (item.children?.length) {
|
|
567
|
-
item.children?.forEach((child) => {
|
|
568
|
-
recurse(subNode, child);
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
filteredTree.children?.forEach((child) => recurse(treeNode, child));
|
|
573
|
-
return treeNode;
|
|
574
|
-
} catch (e) {
|
|
575
|
-
throw new Error("Something went wrong with creating barrel files with the TreeNode class", { cause: e });
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
function buildDirectoryTree(files, rootFolder = "") {
|
|
580
|
-
const rootPrefix = rootFolder.endsWith("/") ? rootFolder : `${rootFolder}/`;
|
|
581
|
-
const filteredFiles = files.filter((file) => rootFolder ? file.path.startsWith(rootPrefix) && !file.path.endsWith(".json") : !file.path.endsWith(".json"));
|
|
582
|
-
if (filteredFiles.length === 0) {
|
|
583
|
-
return null;
|
|
584
|
-
}
|
|
585
|
-
const root = {
|
|
586
|
-
name: rootFolder || "",
|
|
587
|
-
path: rootFolder || "",
|
|
588
|
-
children: []
|
|
589
|
-
};
|
|
590
|
-
filteredFiles.forEach((file) => {
|
|
591
|
-
const path2 = file.path.slice(rootFolder.length);
|
|
592
|
-
const parts = path2.split("/");
|
|
593
|
-
let currentLevel = root.children;
|
|
594
|
-
let currentPath = rootFolder;
|
|
595
|
-
parts.forEach((part, index) => {
|
|
596
|
-
if (index !== 0) {
|
|
597
|
-
currentPath += `/${part}`;
|
|
598
|
-
} else {
|
|
599
|
-
currentPath += `${part}`;
|
|
600
|
-
}
|
|
601
|
-
let existingNode = currentLevel.find((node) => node.name === part);
|
|
602
|
-
if (!existingNode) {
|
|
603
|
-
if (index === parts.length - 1) {
|
|
604
|
-
existingNode = {
|
|
605
|
-
name: part,
|
|
606
|
-
file,
|
|
607
|
-
path: currentPath
|
|
608
|
-
};
|
|
609
|
-
} else {
|
|
610
|
-
existingNode = {
|
|
611
|
-
name: part,
|
|
612
|
-
path: currentPath,
|
|
613
|
-
children: []
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
currentLevel.push(existingNode);
|
|
617
|
-
}
|
|
618
|
-
if (!existingNode.file) {
|
|
619
|
-
currentLevel = existingNode.children;
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
});
|
|
623
|
-
return root;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// src/BarrelManager.ts
|
|
627
|
-
var BarrelManager = class {
|
|
628
|
-
#options;
|
|
629
|
-
constructor(options = {}) {
|
|
630
|
-
this.#options = options;
|
|
631
|
-
return this;
|
|
632
|
-
}
|
|
633
|
-
getFiles({ files: generatedFiles, root, meta }) {
|
|
634
|
-
const { logger } = this.#options;
|
|
635
|
-
const cachedFiles = /* @__PURE__ */ new Map();
|
|
636
|
-
logger?.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Start barrel generation for pluginKey ${meta?.pluginKey?.join(".")} and root '${root}'`] });
|
|
637
|
-
TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {
|
|
638
|
-
if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {
|
|
639
|
-
return void 0;
|
|
640
|
-
}
|
|
641
|
-
const barrelFile = {
|
|
642
|
-
path: path.join(treeNode.parent?.data.path, "index.ts"),
|
|
643
|
-
baseName: "index.ts",
|
|
644
|
-
exports: [],
|
|
645
|
-
sources: []
|
|
646
|
-
};
|
|
647
|
-
const previousBarrelFile = cachedFiles.get(barrelFile.path);
|
|
648
|
-
const leaves = treeNode.leaves;
|
|
649
|
-
leaves.forEach((item) => {
|
|
650
|
-
if (!item.data.name) {
|
|
651
|
-
return void 0;
|
|
652
|
-
}
|
|
653
|
-
const sources = item.data.file?.sources || [];
|
|
654
|
-
if (!sources.some((source) => source.isIndexable)) {
|
|
655
|
-
logger?.emit(
|
|
656
|
-
"warning",
|
|
657
|
-
`No isIndexable source found(source should have a name and isIndexable):
|
|
658
|
-
File: ${JSON.stringify(item.data.file, void 0, 2)}`
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
sources.forEach((source) => {
|
|
662
|
-
if (!item.data.file?.path || !source.isIndexable || !source.name) {
|
|
663
|
-
return void 0;
|
|
664
|
-
}
|
|
665
|
-
const alreadyContainInPreviousBarrelFile = previousBarrelFile?.sources.some((item2) => item2.name === source.name);
|
|
666
|
-
if (alreadyContainInPreviousBarrelFile) {
|
|
667
|
-
return void 0;
|
|
668
|
-
}
|
|
669
|
-
if (!barrelFile.exports) {
|
|
670
|
-
barrelFile.exports = [];
|
|
671
|
-
}
|
|
672
|
-
const isSubExport = !!treeNode.parent?.data.path?.split?.("/")?.length;
|
|
673
|
-
if (isSubExport) {
|
|
674
|
-
barrelFile.exports.push({
|
|
675
|
-
name: [source.name],
|
|
676
|
-
path: chunkFFYEJDCV_cjs.getRelativePath(treeNode.parent?.data.path, item.data.path),
|
|
677
|
-
isTypeOnly: source.isTypeOnly
|
|
678
|
-
});
|
|
679
|
-
} else {
|
|
680
|
-
barrelFile.exports.push({
|
|
681
|
-
name: [source.name],
|
|
682
|
-
path: `./${item.data.file.baseName}`,
|
|
683
|
-
isTypeOnly: source.isTypeOnly
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
barrelFile.sources.push({
|
|
687
|
-
name: source.name,
|
|
688
|
-
isTypeOnly: source.isTypeOnly,
|
|
689
|
-
//TODO use parser to generate import
|
|
690
|
-
value: "",
|
|
691
|
-
isExportable: false,
|
|
692
|
-
isIndexable: false
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
|
-
});
|
|
696
|
-
logger?.emit("debug", {
|
|
697
|
-
date: /* @__PURE__ */ new Date(),
|
|
698
|
-
logs: [
|
|
699
|
-
`Generating barrelFile '${chunkFFYEJDCV_cjs.getRelativePath(root, barrelFile.path)}' for '${chunkFFYEJDCV_cjs.getRelativePath(root, treeNode.data?.path)}' with ${barrelFile.sources.length} indexable exports: '${barrelFile.sources?.map((source) => source.name).join(", ")}'`
|
|
700
|
-
]
|
|
701
|
-
});
|
|
702
|
-
logger?.emit("debug", {
|
|
703
|
-
date: /* @__PURE__ */ new Date(),
|
|
704
|
-
logs: [
|
|
705
|
-
`Generated barrelFile '${chunkFFYEJDCV_cjs.getRelativePath(root, barrelFile.path)}' for '${chunkFFYEJDCV_cjs.getRelativePath(root, treeNode.data?.path)}' with exports: '${cachedFiles.get(barrelFile.path)?.sources?.map((source) => source.name).join(", ")}'`
|
|
706
|
-
]
|
|
707
|
-
});
|
|
708
|
-
if (previousBarrelFile) {
|
|
709
|
-
previousBarrelFile.sources.push(...barrelFile.sources);
|
|
710
|
-
previousBarrelFile.exports?.push(...barrelFile.exports || []);
|
|
711
|
-
} else {
|
|
712
|
-
cachedFiles.set(barrelFile.path, barrelFile);
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
return [...cachedFiles.values()];
|
|
716
|
-
}
|
|
717
|
-
};
|
|
464
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
718
465
|
|
|
719
466
|
// ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/index.js
|
|
720
|
-
|
|
467
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
721
468
|
|
|
722
469
|
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
723
|
-
|
|
724
|
-
var import_index =
|
|
470
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
471
|
+
var import_index = chunkH7GP5BQJ_cjs.__toESM(require_eventemitter3(), 1);
|
|
725
472
|
|
|
726
473
|
// ../../node_modules/.pnpm/p-timeout@6.1.3/node_modules/p-timeout/index.js
|
|
727
|
-
|
|
474
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
728
475
|
var TimeoutError = class extends Error {
|
|
729
476
|
constructor(message) {
|
|
730
477
|
super(message);
|
|
@@ -813,10 +560,10 @@ function pTimeout(promise, options) {
|
|
|
813
560
|
}
|
|
814
561
|
|
|
815
562
|
// ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/priority-queue.js
|
|
816
|
-
|
|
563
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
817
564
|
|
|
818
565
|
// ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/lower-bound.js
|
|
819
|
-
|
|
566
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
820
567
|
function lowerBound(array, value, comparator) {
|
|
821
568
|
let first = 0;
|
|
822
569
|
let count = array.length;
|
|
@@ -1208,6 +955,259 @@ var PQueue = class extends import_index.default {
|
|
|
1208
955
|
}
|
|
1209
956
|
};
|
|
1210
957
|
|
|
958
|
+
// src/BarrelManager.ts
|
|
959
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
960
|
+
|
|
961
|
+
// src/utils/TreeNode.ts
|
|
962
|
+
chunkH7GP5BQJ_cjs.init_cjs_shims();
|
|
963
|
+
var TreeNode = class _TreeNode {
|
|
964
|
+
data;
|
|
965
|
+
parent;
|
|
966
|
+
children = [];
|
|
967
|
+
#cachedLeaves = void 0;
|
|
968
|
+
constructor(data, parent) {
|
|
969
|
+
this.data = data;
|
|
970
|
+
this.parent = parent;
|
|
971
|
+
return this;
|
|
972
|
+
}
|
|
973
|
+
addChild(data) {
|
|
974
|
+
const child = new _TreeNode(data, this);
|
|
975
|
+
if (!this.children) {
|
|
976
|
+
this.children = [];
|
|
977
|
+
}
|
|
978
|
+
this.children.push(child);
|
|
979
|
+
return child;
|
|
980
|
+
}
|
|
981
|
+
get root() {
|
|
982
|
+
if (!this.parent) {
|
|
983
|
+
return this;
|
|
984
|
+
}
|
|
985
|
+
return this.parent.root;
|
|
986
|
+
}
|
|
987
|
+
get leaves() {
|
|
988
|
+
if (!this.children || this.children.length === 0) {
|
|
989
|
+
return [this];
|
|
990
|
+
}
|
|
991
|
+
if (this.#cachedLeaves) {
|
|
992
|
+
return this.#cachedLeaves;
|
|
993
|
+
}
|
|
994
|
+
const leaves = [];
|
|
995
|
+
if (this.children) {
|
|
996
|
+
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
997
|
+
leaves.push.apply(leaves, this.children[i].leaves);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
this.#cachedLeaves = leaves;
|
|
1001
|
+
return leaves;
|
|
1002
|
+
}
|
|
1003
|
+
forEach(callback) {
|
|
1004
|
+
if (typeof callback !== "function") {
|
|
1005
|
+
throw new TypeError("forEach() callback must be a function");
|
|
1006
|
+
}
|
|
1007
|
+
callback(this);
|
|
1008
|
+
if (this.children) {
|
|
1009
|
+
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
1010
|
+
this.children[i]?.forEach(callback);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return this;
|
|
1014
|
+
}
|
|
1015
|
+
findDeep(predicate) {
|
|
1016
|
+
if (typeof predicate !== "function") {
|
|
1017
|
+
throw new TypeError("find() predicate must be a function");
|
|
1018
|
+
}
|
|
1019
|
+
return this.leaves.find(predicate);
|
|
1020
|
+
}
|
|
1021
|
+
forEachDeep(callback) {
|
|
1022
|
+
if (typeof callback !== "function") {
|
|
1023
|
+
throw new TypeError("forEach() callback must be a function");
|
|
1024
|
+
}
|
|
1025
|
+
this.leaves.forEach(callback);
|
|
1026
|
+
}
|
|
1027
|
+
filterDeep(callback) {
|
|
1028
|
+
if (typeof callback !== "function") {
|
|
1029
|
+
throw new TypeError("filter() callback must be a function");
|
|
1030
|
+
}
|
|
1031
|
+
return this.leaves.filter(callback);
|
|
1032
|
+
}
|
|
1033
|
+
mapDeep(callback) {
|
|
1034
|
+
if (typeof callback !== "function") {
|
|
1035
|
+
throw new TypeError("map() callback must be a function");
|
|
1036
|
+
}
|
|
1037
|
+
return this.leaves.map(callback);
|
|
1038
|
+
}
|
|
1039
|
+
static build(files, root) {
|
|
1040
|
+
try {
|
|
1041
|
+
const filteredTree = buildDirectoryTree(files, root);
|
|
1042
|
+
if (!filteredTree) {
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
const treeNode = new _TreeNode({
|
|
1046
|
+
name: filteredTree.name,
|
|
1047
|
+
path: filteredTree.path,
|
|
1048
|
+
file: filteredTree.file,
|
|
1049
|
+
type: FileManager.getMode(filteredTree.path)
|
|
1050
|
+
});
|
|
1051
|
+
const recurse = (node, item) => {
|
|
1052
|
+
const subNode = node.addChild({
|
|
1053
|
+
name: item.name,
|
|
1054
|
+
path: item.path,
|
|
1055
|
+
file: item.file,
|
|
1056
|
+
type: FileManager.getMode(item.path)
|
|
1057
|
+
});
|
|
1058
|
+
if (item.children?.length) {
|
|
1059
|
+
item.children?.forEach((child) => {
|
|
1060
|
+
recurse(subNode, child);
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
filteredTree.children?.forEach((child) => recurse(treeNode, child));
|
|
1065
|
+
return treeNode;
|
|
1066
|
+
} catch (e) {
|
|
1067
|
+
throw new Error("Something went wrong with creating barrel files with the TreeNode class", { cause: e });
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
function buildDirectoryTree(files, rootFolder = "") {
|
|
1072
|
+
const rootPrefix = rootFolder.endsWith("/") ? rootFolder : `${rootFolder}/`;
|
|
1073
|
+
const filteredFiles = files.filter((file) => rootFolder ? file.path.startsWith(rootPrefix) && !file.path.endsWith(".json") : !file.path.endsWith(".json"));
|
|
1074
|
+
if (filteredFiles.length === 0) {
|
|
1075
|
+
return null;
|
|
1076
|
+
}
|
|
1077
|
+
const root = {
|
|
1078
|
+
name: rootFolder || "",
|
|
1079
|
+
path: rootFolder || "",
|
|
1080
|
+
children: []
|
|
1081
|
+
};
|
|
1082
|
+
filteredFiles.forEach((file) => {
|
|
1083
|
+
const path2 = file.path.slice(rootFolder.length);
|
|
1084
|
+
const parts = path2.split("/");
|
|
1085
|
+
let currentLevel = root.children;
|
|
1086
|
+
let currentPath = rootFolder;
|
|
1087
|
+
parts.forEach((part, index) => {
|
|
1088
|
+
if (index !== 0) {
|
|
1089
|
+
currentPath += `/${part}`;
|
|
1090
|
+
} else {
|
|
1091
|
+
currentPath += `${part}`;
|
|
1092
|
+
}
|
|
1093
|
+
let existingNode = currentLevel.find((node) => node.name === part);
|
|
1094
|
+
if (!existingNode) {
|
|
1095
|
+
if (index === parts.length - 1) {
|
|
1096
|
+
existingNode = {
|
|
1097
|
+
name: part,
|
|
1098
|
+
file,
|
|
1099
|
+
path: currentPath
|
|
1100
|
+
};
|
|
1101
|
+
} else {
|
|
1102
|
+
existingNode = {
|
|
1103
|
+
name: part,
|
|
1104
|
+
path: currentPath,
|
|
1105
|
+
children: []
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
currentLevel.push(existingNode);
|
|
1109
|
+
}
|
|
1110
|
+
if (!existingNode.file) {
|
|
1111
|
+
currentLevel = existingNode.children;
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
});
|
|
1115
|
+
return root;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// src/BarrelManager.ts
|
|
1119
|
+
var BarrelManager = class {
|
|
1120
|
+
#options;
|
|
1121
|
+
constructor(options = {}) {
|
|
1122
|
+
this.#options = options;
|
|
1123
|
+
return this;
|
|
1124
|
+
}
|
|
1125
|
+
getFiles({ files: generatedFiles, root, meta }) {
|
|
1126
|
+
const { logger } = this.#options;
|
|
1127
|
+
const cachedFiles = /* @__PURE__ */ new Map();
|
|
1128
|
+
logger?.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Start barrel generation for pluginKey ${meta?.pluginKey?.join(".")} and root '${root}'`] });
|
|
1129
|
+
TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {
|
|
1130
|
+
if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {
|
|
1131
|
+
return void 0;
|
|
1132
|
+
}
|
|
1133
|
+
const barrelFile = {
|
|
1134
|
+
path: path.join(treeNode.parent?.data.path, "index.ts"),
|
|
1135
|
+
baseName: "index.ts",
|
|
1136
|
+
exports: [],
|
|
1137
|
+
sources: []
|
|
1138
|
+
};
|
|
1139
|
+
const previousBarrelFile = cachedFiles.get(barrelFile.path);
|
|
1140
|
+
const leaves = treeNode.leaves;
|
|
1141
|
+
leaves.forEach((item) => {
|
|
1142
|
+
if (!item.data.name) {
|
|
1143
|
+
return void 0;
|
|
1144
|
+
}
|
|
1145
|
+
const sources = item.data.file?.sources || [];
|
|
1146
|
+
if (!sources.some((source) => source.isIndexable)) {
|
|
1147
|
+
logger?.emit(
|
|
1148
|
+
"warning",
|
|
1149
|
+
`No isIndexable source found(source should have a name and isIndexable):
|
|
1150
|
+
File: ${JSON.stringify(item.data.file, void 0, 2)}`
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
sources.forEach((source) => {
|
|
1154
|
+
if (!item.data.file?.path || !source.isIndexable || !source.name) {
|
|
1155
|
+
return void 0;
|
|
1156
|
+
}
|
|
1157
|
+
const alreadyContainInPreviousBarrelFile = previousBarrelFile?.sources.some((item2) => item2.name === source.name);
|
|
1158
|
+
if (alreadyContainInPreviousBarrelFile) {
|
|
1159
|
+
return void 0;
|
|
1160
|
+
}
|
|
1161
|
+
if (!barrelFile.exports) {
|
|
1162
|
+
barrelFile.exports = [];
|
|
1163
|
+
}
|
|
1164
|
+
const isSubExport = !!treeNode.parent?.data.path?.split?.("/")?.length;
|
|
1165
|
+
if (isSubExport) {
|
|
1166
|
+
barrelFile.exports.push({
|
|
1167
|
+
name: [source.name],
|
|
1168
|
+
path: chunkDYN65P3T_cjs.getRelativePath(treeNode.parent?.data.path, item.data.path),
|
|
1169
|
+
isTypeOnly: source.isTypeOnly
|
|
1170
|
+
});
|
|
1171
|
+
} else {
|
|
1172
|
+
barrelFile.exports.push({
|
|
1173
|
+
name: [source.name],
|
|
1174
|
+
path: `./${item.data.file.baseName}`,
|
|
1175
|
+
isTypeOnly: source.isTypeOnly
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
barrelFile.sources.push({
|
|
1179
|
+
name: source.name,
|
|
1180
|
+
isTypeOnly: source.isTypeOnly,
|
|
1181
|
+
//TODO use parser to generate import
|
|
1182
|
+
value: "",
|
|
1183
|
+
isExportable: false,
|
|
1184
|
+
isIndexable: false
|
|
1185
|
+
});
|
|
1186
|
+
});
|
|
1187
|
+
});
|
|
1188
|
+
logger?.emit("debug", {
|
|
1189
|
+
date: /* @__PURE__ */ new Date(),
|
|
1190
|
+
logs: [
|
|
1191
|
+
`Generating barrelFile '${chunkDYN65P3T_cjs.getRelativePath(root, barrelFile.path)}' for '${chunkDYN65P3T_cjs.getRelativePath(root, treeNode.data?.path)}' with ${barrelFile.sources.length} indexable exports: '${barrelFile.sources?.map((source) => source.name).join(", ")}'`
|
|
1192
|
+
]
|
|
1193
|
+
});
|
|
1194
|
+
logger?.emit("debug", {
|
|
1195
|
+
date: /* @__PURE__ */ new Date(),
|
|
1196
|
+
logs: [
|
|
1197
|
+
`Generated barrelFile '${chunkDYN65P3T_cjs.getRelativePath(root, barrelFile.path)}' for '${chunkDYN65P3T_cjs.getRelativePath(root, treeNode.data?.path)}' with exports: '${cachedFiles.get(barrelFile.path)?.sources?.map((source) => source.name).join(", ")}'`
|
|
1198
|
+
]
|
|
1199
|
+
});
|
|
1200
|
+
if (previousBarrelFile) {
|
|
1201
|
+
previousBarrelFile.sources.push(...barrelFile.sources);
|
|
1202
|
+
previousBarrelFile.exports?.push(...barrelFile.exports || []);
|
|
1203
|
+
} else {
|
|
1204
|
+
cachedFiles.set(barrelFile.path, barrelFile);
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
return [...cachedFiles.values()];
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
1211
|
// src/FileManager.ts
|
|
1212
1212
|
var FileManager = class {
|
|
1213
1213
|
#filesByPath = /* @__PURE__ */ new Map();
|
|
@@ -1218,13 +1218,13 @@ var FileManager = class {
|
|
|
1218
1218
|
return [...this.#filesByPath.values()];
|
|
1219
1219
|
}
|
|
1220
1220
|
get orderedFiles() {
|
|
1221
|
-
return
|
|
1221
|
+
return chunkZZEKLURQ_cjs.orderBy(
|
|
1222
1222
|
[...this.#filesByPath.values()],
|
|
1223
1223
|
[
|
|
1224
1224
|
(v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
1225
1225
|
(v) => v.path.length,
|
|
1226
|
-
(v) =>
|
|
1227
|
-
(v) =>
|
|
1226
|
+
(v) => chunkDYN65P3T_cjs.trimExtName(v.path).endsWith("index"),
|
|
1227
|
+
(v) => chunkDYN65P3T_cjs.trimExtName(v.baseName),
|
|
1228
1228
|
(v) => v.path.split(".").pop()
|
|
1229
1229
|
]
|
|
1230
1230
|
);
|
|
@@ -1283,7 +1283,7 @@ var FileManager = class {
|
|
|
1283
1283
|
}
|
|
1284
1284
|
const barrelManager = new BarrelManager({ logger });
|
|
1285
1285
|
const pathToBuildFrom = path.join(root, output.path);
|
|
1286
|
-
if (
|
|
1286
|
+
if (chunkDYN65P3T_cjs.trimExtName(pathToBuildFrom).endsWith("index")) {
|
|
1287
1287
|
logger?.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
|
|
1288
1288
|
return [];
|
|
1289
1289
|
}
|
|
@@ -1309,10 +1309,10 @@ var FileManager = class {
|
|
|
1309
1309
|
});
|
|
1310
1310
|
}
|
|
1311
1311
|
async write(...params) {
|
|
1312
|
-
return
|
|
1312
|
+
return chunkDYN65P3T_cjs.write(...params);
|
|
1313
1313
|
}
|
|
1314
1314
|
async read(...params) {
|
|
1315
|
-
return
|
|
1315
|
+
return chunkDYN65P3T_cjs.read(...params);
|
|
1316
1316
|
}
|
|
1317
1317
|
// statics
|
|
1318
1318
|
static getMode(path2) {
|
|
@@ -1339,32 +1339,15 @@ function mergeFile(a, b) {
|
|
|
1339
1339
|
};
|
|
1340
1340
|
}
|
|
1341
1341
|
function combineSources(sources) {
|
|
1342
|
-
return sources.
|
|
1343
|
-
(prev, curr) => {
|
|
1344
|
-
const prevByName = prev.findLast((imp) => imp.name && imp.name === curr.name);
|
|
1345
|
-
const prevByPathAndIsExportable = prev.findLast((imp) => imp.name === curr.name && imp.isExportable);
|
|
1346
|
-
if (prevByPathAndIsExportable) {
|
|
1347
|
-
return [...prev, curr];
|
|
1348
|
-
}
|
|
1349
|
-
if (prevByName) {
|
|
1350
|
-
prevByName.value = curr.value;
|
|
1351
|
-
prevByName.isExportable = curr.isExportable;
|
|
1352
|
-
prevByName.isTypeOnly = curr.isTypeOnly;
|
|
1353
|
-
prevByName.isIndexable = curr.isIndexable;
|
|
1354
|
-
return prev;
|
|
1355
|
-
}
|
|
1356
|
-
return [...prev, curr];
|
|
1357
|
-
},
|
|
1358
|
-
[]
|
|
1359
|
-
);
|
|
1342
|
+
return remeda.uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly]);
|
|
1360
1343
|
}
|
|
1361
1344
|
function combineExports(exports) {
|
|
1362
|
-
return
|
|
1345
|
+
return chunkZZEKLURQ_cjs.orderBy(exports, [
|
|
1363
1346
|
(v) => !!Array.isArray(v.name),
|
|
1364
1347
|
(v) => !v.isTypeOnly,
|
|
1365
1348
|
(v) => v.path,
|
|
1366
1349
|
(v) => !!v.name,
|
|
1367
|
-
(v) => Array.isArray(v.name) ?
|
|
1350
|
+
(v) => Array.isArray(v.name) ? chunkZZEKLURQ_cjs.orderBy(v.name) : v.name
|
|
1368
1351
|
]).reduce(
|
|
1369
1352
|
(prev, curr) => {
|
|
1370
1353
|
const name = curr.name;
|
|
@@ -1398,12 +1381,12 @@ function combineExports(exports) {
|
|
|
1398
1381
|
);
|
|
1399
1382
|
}
|
|
1400
1383
|
function combineImports(imports, exports, source) {
|
|
1401
|
-
return
|
|
1384
|
+
return chunkZZEKLURQ_cjs.orderBy(imports, [
|
|
1402
1385
|
(v) => !!Array.isArray(v.name),
|
|
1403
1386
|
(v) => !v.isTypeOnly,
|
|
1404
1387
|
(v) => v.path,
|
|
1405
1388
|
(v) => !!v.name,
|
|
1406
|
-
(v) => Array.isArray(v.name) ?
|
|
1389
|
+
(v) => Array.isArray(v.name) ? chunkZZEKLURQ_cjs.orderBy(v.name) : v.name
|
|
1407
1390
|
]).reduce(
|
|
1408
1391
|
(prev, curr) => {
|
|
1409
1392
|
let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
|
|
@@ -1454,10 +1437,10 @@ function combineImports(imports, exports, source) {
|
|
|
1454
1437
|
}
|
|
1455
1438
|
var queue = new PQueue({ concurrency: 100 });
|
|
1456
1439
|
async function processFiles({ dryRun, root, extension, logger, files }) {
|
|
1457
|
-
const orderedFiles =
|
|
1440
|
+
const orderedFiles = chunkZZEKLURQ_cjs.orderBy(files, [
|
|
1458
1441
|
(v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
1459
1442
|
(v) => v.path.length,
|
|
1460
|
-
(v) =>
|
|
1443
|
+
(v) => chunkDYN65P3T_cjs.trimExtName(v.path).endsWith("index")
|
|
1461
1444
|
]);
|
|
1462
1445
|
logger?.emit("debug", {
|
|
1463
1446
|
date: /* @__PURE__ */ new Date(),
|
|
@@ -1472,7 +1455,7 @@ async function processFiles({ dryRun, root, extension, logger, files }) {
|
|
|
1472
1455
|
const message = file ? `Writing ${path.relative(root, file.path)}` : "";
|
|
1473
1456
|
const extname2 = extension?.[file.extname] || void 0;
|
|
1474
1457
|
const source = await getSource(file, { logger, extname: extname2 });
|
|
1475
|
-
await
|
|
1458
|
+
await chunkDYN65P3T_cjs.write(file.path, source, { sanity: false });
|
|
1476
1459
|
logger?.emit("progressed", { id: "files", message });
|
|
1477
1460
|
});
|
|
1478
1461
|
});
|
|
@@ -1564,7 +1547,7 @@ var typeScriptParser = createFileParser({
|
|
|
1564
1547
|
const module = await import('@kubb/parser-ts');
|
|
1565
1548
|
const source = file.sources.map((item) => item.value).join("\n\n");
|
|
1566
1549
|
const importNodes = file.imports.map((item) => {
|
|
1567
|
-
const importPath = item.root ?
|
|
1550
|
+
const importPath = item.root ? chunkDYN65P3T_cjs.getRelativePath(item.root, item.path) : item.path;
|
|
1568
1551
|
const hasExtname = !!path__default.default.extname(importPath);
|
|
1569
1552
|
return module.factory.createImportDeclaration({
|
|
1570
1553
|
name: item.name,
|
|
@@ -1642,5 +1625,5 @@ exports.processFiles = processFiles;
|
|
|
1642
1625
|
exports.renderTemplate = renderTemplate;
|
|
1643
1626
|
exports.setUniqueName = setUniqueName;
|
|
1644
1627
|
exports.timeout = timeout;
|
|
1645
|
-
//# sourceMappingURL=chunk-
|
|
1646
|
-
//# sourceMappingURL=chunk-
|
|
1628
|
+
//# sourceMappingURL=chunk-4Y54TK73.cjs.map
|
|
1629
|
+
//# sourceMappingURL=chunk-4Y54TK73.cjs.map
|