@kubb/core 2.0.0-beta.6 → 2.0.0-beta.8
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/index.cjs +78 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.js +72 -62
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +72 -62
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +513 -18
- package/dist/utils.d.ts +513 -18
- package/dist/utils.js +72 -62
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/BarrelManager.ts +55 -65
- package/src/FileManager.ts +55 -9
- package/src/utils/TreeNode.ts +6 -3
package/dist/index.cjs
CHANGED
|
@@ -521,9 +521,9 @@ function isInputPath(result) {
|
|
|
521
521
|
|
|
522
522
|
// src/utils/timeout.ts
|
|
523
523
|
async function timeout(ms) {
|
|
524
|
-
return new Promise((
|
|
524
|
+
return new Promise((resolve3) => {
|
|
525
525
|
setTimeout(() => {
|
|
526
|
-
|
|
526
|
+
resolve3(true);
|
|
527
527
|
}, ms);
|
|
528
528
|
});
|
|
529
529
|
}
|
|
@@ -677,78 +677,67 @@ var TreeNode = class _TreeNode {
|
|
|
677
677
|
var _options;
|
|
678
678
|
var BarrelManager = class {
|
|
679
679
|
constructor(options = {}) {
|
|
680
|
-
__privateAdd(this, _options,
|
|
680
|
+
__privateAdd(this, _options, void 0);
|
|
681
681
|
__privateSet(this, _options, options);
|
|
682
682
|
return this;
|
|
683
683
|
}
|
|
684
|
-
getIndexes(
|
|
685
|
-
const { treeNode = {}, isTypeOnly,
|
|
686
|
-
const
|
|
687
|
-
".ts": {
|
|
688
|
-
extensions: /\.ts/,
|
|
689
|
-
exclude: [/schemas/, /json/]
|
|
690
|
-
},
|
|
691
|
-
".json": {
|
|
692
|
-
extensions: /\.json/,
|
|
693
|
-
exclude: []
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...treeNode });
|
|
684
|
+
getIndexes(pathToBuild) {
|
|
685
|
+
const { treeNode = {}, isTypeOnly, extName } = __privateGet(this, _options);
|
|
686
|
+
const tree = TreeNode.build(pathToBuild, treeNode);
|
|
697
687
|
if (!tree) {
|
|
698
688
|
return null;
|
|
699
689
|
}
|
|
700
|
-
const fileReducer = (
|
|
701
|
-
if (!
|
|
690
|
+
const fileReducer = (files, treeNode2) => {
|
|
691
|
+
if (!treeNode2.children) {
|
|
702
692
|
return [];
|
|
703
693
|
}
|
|
704
|
-
if (
|
|
705
|
-
const indexPath = path4__default.default.resolve(
|
|
706
|
-
const exports =
|
|
707
|
-
const importPath = file.data.type === "directory" ? `./${file.data.name}/index` : `./${file.data.name
|
|
708
|
-
if (importPath.
|
|
694
|
+
if (treeNode2.children.length > 1) {
|
|
695
|
+
const indexPath = path4__default.default.resolve(treeNode2.data.path, "index.ts");
|
|
696
|
+
const exports = treeNode2.children.filter(Boolean).map((file) => {
|
|
697
|
+
const importPath = file.data.type === "directory" ? `./${file.data.name}/index` : `./${transformers_default.trimExtName(file.data.name)}`;
|
|
698
|
+
if (importPath.endsWith("index") && file.data.type === "file") {
|
|
709
699
|
return void 0;
|
|
710
700
|
}
|
|
711
701
|
return {
|
|
712
|
-
path:
|
|
702
|
+
path: extName ? `${importPath}${extName}` : importPath,
|
|
713
703
|
isTypeOnly
|
|
714
704
|
};
|
|
715
705
|
}).filter(Boolean);
|
|
716
|
-
|
|
706
|
+
files.push({
|
|
717
707
|
path: indexPath,
|
|
718
708
|
baseName: "index.ts",
|
|
719
709
|
source: "",
|
|
720
|
-
exports
|
|
721
|
-
|
|
722
|
-
|
|
710
|
+
exports,
|
|
711
|
+
meta: {
|
|
712
|
+
treeNode: treeNode2
|
|
713
|
+
}
|
|
723
714
|
});
|
|
724
|
-
} else {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}
|
|
715
|
+
} else if (treeNode2.children.length === 1) {
|
|
716
|
+
const [treeNodeChild] = treeNode2.children;
|
|
717
|
+
const indexPath = path4__default.default.resolve(treeNode2.data.path, "index.ts");
|
|
718
|
+
const importPath = treeNodeChild.data.type === "directory" ? `./${treeNodeChild.data.name}/index` : `./${transformers_default.trimExtName(treeNodeChild.data.name)}`;
|
|
719
|
+
const exports = [
|
|
720
|
+
{
|
|
721
|
+
path: extName ? `${importPath}${extName}` : importPath,
|
|
722
|
+
isTypeOnly
|
|
723
|
+
}
|
|
724
|
+
];
|
|
725
|
+
files.push({
|
|
726
|
+
path: indexPath,
|
|
727
|
+
baseName: "index.ts",
|
|
728
|
+
source: "",
|
|
729
|
+
exports,
|
|
730
|
+
meta: {
|
|
731
|
+
treeNode: treeNode2
|
|
732
|
+
}
|
|
742
733
|
});
|
|
743
734
|
}
|
|
744
|
-
|
|
745
|
-
fileReducer(
|
|
735
|
+
treeNode2.children.forEach((childItem) => {
|
|
736
|
+
fileReducer(files, childItem);
|
|
746
737
|
});
|
|
747
|
-
return
|
|
738
|
+
return files;
|
|
748
739
|
};
|
|
749
|
-
|
|
750
|
-
const filteredFiles = filter ? files.filter(filter) : files;
|
|
751
|
-
return map ? filteredFiles.map(map) : filteredFiles;
|
|
740
|
+
return fileReducer([], tree).reverse();
|
|
752
741
|
}
|
|
753
742
|
};
|
|
754
743
|
_options = new WeakMap();
|
|
@@ -801,12 +790,33 @@ var _FileManager = class _FileManager {
|
|
|
801
790
|
}
|
|
802
791
|
return resolvedFiles[0];
|
|
803
792
|
}
|
|
804
|
-
async addIndexes({ root,
|
|
805
|
-
const
|
|
806
|
-
const
|
|
793
|
+
async addIndexes({ root, output, meta, options = {} }) {
|
|
794
|
+
const exportPath = output.path.startsWith("./") ? output.path : `./${output.path}`;
|
|
795
|
+
const barrelManager = new BarrelManager({ extName: output.extName, ...options });
|
|
796
|
+
const files = barrelManager.getIndexes(path4.resolve(root, output.path));
|
|
807
797
|
if (!files) {
|
|
808
798
|
return void 0;
|
|
809
799
|
}
|
|
800
|
+
const rootFile = {
|
|
801
|
+
path: path4.resolve(root, "index.ts"),
|
|
802
|
+
baseName: "index.ts",
|
|
803
|
+
source: "",
|
|
804
|
+
exports: [
|
|
805
|
+
output.exportAs ? {
|
|
806
|
+
name: output.exportAs,
|
|
807
|
+
asAlias: true,
|
|
808
|
+
path: exportPath,
|
|
809
|
+
isTypeOnly: options.isTypeOnly
|
|
810
|
+
} : {
|
|
811
|
+
path: exportPath,
|
|
812
|
+
isTypeOnly: options.isTypeOnly
|
|
813
|
+
}
|
|
814
|
+
]
|
|
815
|
+
};
|
|
816
|
+
await __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
|
|
817
|
+
...rootFile,
|
|
818
|
+
meta: meta ? meta : rootFile.meta
|
|
819
|
+
});
|
|
810
820
|
return await Promise.all(
|
|
811
821
|
files.map((file) => {
|
|
812
822
|
return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
|
|
@@ -922,7 +932,7 @@ _validate = new WeakSet();
|
|
|
922
932
|
_add = new WeakSet();
|
|
923
933
|
add_fn = async function(file) {
|
|
924
934
|
const controller = new AbortController();
|
|
925
|
-
const resolvedFile = { id: crypto2__default.default.randomUUID(), ...file };
|
|
935
|
+
const resolvedFile = { id: crypto2__default.default.randomUUID(), name: transformers_default.trimExtName(file.baseName), ...file };
|
|
926
936
|
__privateGet(this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
927
937
|
if (__privateGet(this, _queue)) {
|
|
928
938
|
await __privateGet(this, _queue).run(
|
|
@@ -1081,8 +1091,8 @@ var Queue = class {
|
|
|
1081
1091
|
__privateSet(this, _debug, debug);
|
|
1082
1092
|
}
|
|
1083
1093
|
run(job, options = { controller: new AbortController(), name: crypto2__default.default.randomUUID(), description: "" }) {
|
|
1084
|
-
return new Promise((
|
|
1085
|
-
const item = { reject, resolve:
|
|
1094
|
+
return new Promise((resolve3, reject) => {
|
|
1095
|
+
const item = { reject, resolve: resolve3, job, name: options.name, description: options.description || options.name };
|
|
1086
1096
|
options.controller?.signal.addEventListener("abort", () => {
|
|
1087
1097
|
__privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
|
|
1088
1098
|
reject("Aborted");
|
|
@@ -1092,8 +1102,8 @@ var Queue = class {
|
|
|
1092
1102
|
});
|
|
1093
1103
|
}
|
|
1094
1104
|
runSync(job, options = { controller: new AbortController(), name: crypto2__default.default.randomUUID(), description: "" }) {
|
|
1095
|
-
new Promise((
|
|
1096
|
-
const item = { reject, resolve:
|
|
1105
|
+
new Promise((resolve3, reject) => {
|
|
1106
|
+
const item = { reject, resolve: resolve3, job, name: options.name, description: options.description || options.name };
|
|
1097
1107
|
options.controller?.signal.addEventListener("abort", () => {
|
|
1098
1108
|
__privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
|
|
1099
1109
|
});
|
|
@@ -1120,13 +1130,13 @@ work_fn = function() {
|
|
|
1120
1130
|
__privateWrapper(this, _workerCount)._++;
|
|
1121
1131
|
let entry;
|
|
1122
1132
|
while (entry = __privateGet(this, _queue2).shift()) {
|
|
1123
|
-
const { reject, resolve:
|
|
1133
|
+
const { reject, resolve: resolve3, job, name, description } = entry;
|
|
1124
1134
|
if (__privateGet(this, _debug)) {
|
|
1125
1135
|
perf_hooks.performance.mark(name + "_start");
|
|
1126
1136
|
}
|
|
1127
1137
|
job().then((result) => {
|
|
1128
1138
|
this.eventEmitter.emit("jobDone", result);
|
|
1129
|
-
|
|
1139
|
+
resolve3(result);
|
|
1130
1140
|
if (__privateGet(this, _debug)) {
|
|
1131
1141
|
perf_hooks.performance.mark(name + "_stop");
|
|
1132
1142
|
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
@@ -1964,18 +1974,18 @@ function pLimit(concurrency) {
|
|
|
1964
1974
|
queue.dequeue()();
|
|
1965
1975
|
}
|
|
1966
1976
|
};
|
|
1967
|
-
const run = async (fn,
|
|
1977
|
+
const run = async (fn, resolve3, args) => {
|
|
1968
1978
|
activeCount++;
|
|
1969
1979
|
const result = (async () => fn(...args))();
|
|
1970
|
-
|
|
1980
|
+
resolve3(result);
|
|
1971
1981
|
try {
|
|
1972
1982
|
await result;
|
|
1973
1983
|
} catch {
|
|
1974
1984
|
}
|
|
1975
1985
|
next();
|
|
1976
1986
|
};
|
|
1977
|
-
const enqueue = (fn,
|
|
1978
|
-
queue.enqueue(run.bind(void 0, fn,
|
|
1987
|
+
const enqueue = (fn, resolve3, args) => {
|
|
1988
|
+
queue.enqueue(run.bind(void 0, fn, resolve3, args));
|
|
1979
1989
|
(async () => {
|
|
1980
1990
|
await Promise.resolve();
|
|
1981
1991
|
if (activeCount < concurrency && queue.size > 0) {
|
|
@@ -1983,8 +1993,8 @@ function pLimit(concurrency) {
|
|
|
1983
1993
|
}
|
|
1984
1994
|
})();
|
|
1985
1995
|
};
|
|
1986
|
-
const generator = (fn, ...args) => new Promise((
|
|
1987
|
-
enqueue(fn,
|
|
1996
|
+
const generator = (fn, ...args) => new Promise((resolve3) => {
|
|
1997
|
+
enqueue(fn, resolve3, args);
|
|
1988
1998
|
});
|
|
1989
1999
|
Object.defineProperties(generator, {
|
|
1990
2000
|
activeCount: {
|