@kubb/core 5.0.0-alpha.6 → 5.0.0-alpha.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/{PluginManager-vZodFEMe.d.ts → PluginDriver-DRfJIbG1.d.ts} +18 -18
- package/dist/hooks.cjs +53 -11
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +15 -4
- package/dist/hooks.js +51 -10
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +100 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -46
- package/dist/index.js +95 -121
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Kubb.ts +1 -1
- package/src/{PluginManager.ts → PluginDriver.ts} +18 -22
- package/src/build.ts +21 -21
- package/src/{defineAdapter.ts → createAdapter.ts} +2 -2
- package/src/{defineGenerator.ts → createGenerator.ts} +3 -3
- package/src/{defineLogger.ts → createLogger.ts} +1 -1
- package/src/{definePlugin.ts → createPlugin.ts} +1 -1
- package/src/{defineStorage.ts → createStorage.ts} +5 -5
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useKubb.ts +90 -7
- package/src/hooks/usePluginDriver.ts +11 -0
- package/src/index.ts +6 -7
- package/src/storages/fsStorage.ts +2 -2
- package/src/storages/memoryStorage.ts +2 -2
- package/src/types.ts +9 -9
- package/src/utils/TreeNode.ts +1 -1
- package/src/utils/getBarrelFiles.ts +71 -9
- package/src/BarrelManager.ts +0 -74
- package/src/PromiseManager.ts +0 -40
- package/src/hooks/usePluginManager.ts +0 -11
package/dist/index.cjs
CHANGED
|
@@ -453,6 +453,10 @@ function setUniqueName(originalName, data) {
|
|
|
453
453
|
data[originalName] = 1;
|
|
454
454
|
return originalName;
|
|
455
455
|
}
|
|
456
|
+
/** Type guard for a rejected `Promise.allSettled` result with a typed `reason`. */
|
|
457
|
+
function isPromiseRejectedResult(result) {
|
|
458
|
+
return result.status === "rejected";
|
|
459
|
+
}
|
|
456
460
|
/**
|
|
457
461
|
* JavaScript and Java reserved words.
|
|
458
462
|
* @link https://github.com/jonschlinkert/reserved/blob/master/index.js
|
|
@@ -939,29 +943,13 @@ function hookParallel(promises, concurrency = Number.POSITIVE_INFINITY) {
|
|
|
939
943
|
return Promise.allSettled(tasks);
|
|
940
944
|
}
|
|
941
945
|
//#endregion
|
|
942
|
-
//#region src/
|
|
943
|
-
var PromiseManager = class {
|
|
944
|
-
#options = {};
|
|
945
|
-
constructor(options = {}) {
|
|
946
|
-
this.#options = options;
|
|
947
|
-
}
|
|
948
|
-
run(strategy, promises, { concurrency = Number.POSITIVE_INFINITY } = {}) {
|
|
949
|
-
if (strategy === "seq") return hookSeq(promises);
|
|
950
|
-
if (strategy === "first") return hookFirst(promises, this.#options.nullCheck);
|
|
951
|
-
if (strategy === "parallel") return hookParallel(promises, concurrency);
|
|
952
|
-
throw new Error(`${strategy} not implemented`);
|
|
953
|
-
}
|
|
954
|
-
};
|
|
955
|
-
function isPromiseRejectedResult(result) {
|
|
956
|
-
return result.status === "rejected";
|
|
957
|
-
}
|
|
958
|
-
//#endregion
|
|
959
|
-
//#region src/PluginManager.ts
|
|
946
|
+
//#region src/PluginDriver.ts
|
|
960
947
|
function getMode(fileOrFolder) {
|
|
961
948
|
if (!fileOrFolder) return "split";
|
|
962
949
|
return (0, node_path.extname)(fileOrFolder) ? "single" : "split";
|
|
963
950
|
}
|
|
964
|
-
|
|
951
|
+
const hookFirstNullCheck = (state) => !!state?.result;
|
|
952
|
+
var PluginDriver = class {
|
|
965
953
|
config;
|
|
966
954
|
options;
|
|
967
955
|
/**
|
|
@@ -973,11 +961,9 @@ var PluginManager = class {
|
|
|
973
961
|
#studioIsOpen = false;
|
|
974
962
|
#plugins = /* @__PURE__ */ new Set();
|
|
975
963
|
#usedPluginNames = {};
|
|
976
|
-
#promiseManager;
|
|
977
964
|
constructor(config, options) {
|
|
978
965
|
this.config = config;
|
|
979
966
|
this.options = options;
|
|
980
|
-
this.#promiseManager = new PromiseManager({ nullCheck: (state) => !!state?.result });
|
|
981
967
|
[...config.plugins || []].forEach((plugin) => {
|
|
982
968
|
const parsedPlugin = this.#parse(plugin);
|
|
983
969
|
this.#plugins.add(parsedPlugin);
|
|
@@ -988,13 +974,13 @@ var PluginManager = class {
|
|
|
988
974
|
}
|
|
989
975
|
getContext(plugin) {
|
|
990
976
|
const plugins = [...this.#plugins];
|
|
991
|
-
const
|
|
977
|
+
const driver = this;
|
|
992
978
|
const baseContext = {
|
|
993
979
|
fabric: this.options.fabric,
|
|
994
980
|
config: this.config,
|
|
995
981
|
plugin,
|
|
996
982
|
events: this.options.events,
|
|
997
|
-
|
|
983
|
+
driver: this,
|
|
998
984
|
mode: getMode((0, node_path.resolve)(this.config.root, this.config.output.path)),
|
|
999
985
|
addFile: async (...files) => {
|
|
1000
986
|
await this.options.fabric.addFile(...files);
|
|
@@ -1003,18 +989,18 @@ var PluginManager = class {
|
|
|
1003
989
|
await this.options.fabric.upsertFile(...files);
|
|
1004
990
|
},
|
|
1005
991
|
get rootNode() {
|
|
1006
|
-
return
|
|
992
|
+
return driver.rootNode;
|
|
1007
993
|
},
|
|
1008
994
|
get adapter() {
|
|
1009
|
-
return
|
|
995
|
+
return driver.adapter;
|
|
1010
996
|
},
|
|
1011
997
|
openInStudio(options) {
|
|
1012
|
-
if (!
|
|
1013
|
-
if (typeof
|
|
1014
|
-
if (!
|
|
1015
|
-
|
|
1016
|
-
const studioUrl =
|
|
1017
|
-
return openInStudio(
|
|
998
|
+
if (!driver.config.devtools || driver.#studioIsOpen) return;
|
|
999
|
+
if (typeof driver.config.devtools !== "object") throw new Error("Devtools must be an object");
|
|
1000
|
+
if (!driver.rootNode || !driver.adapter) throw new Error("adapter is not defined, make sure you have set the parser in kubb.config.ts");
|
|
1001
|
+
driver.#studioIsOpen = true;
|
|
1002
|
+
const studioUrl = driver.config.devtools?.studioUrl ?? "https://studio.kubb.dev";
|
|
1003
|
+
return openInStudio(driver.rootNode, studioUrl, options);
|
|
1018
1004
|
}
|
|
1019
1005
|
};
|
|
1020
1006
|
const mergedExtras = {};
|
|
@@ -1133,7 +1119,7 @@ var PluginManager = class {
|
|
|
1133
1119
|
hookName,
|
|
1134
1120
|
plugins
|
|
1135
1121
|
});
|
|
1136
|
-
const
|
|
1122
|
+
const result = await hookFirst(plugins.map((plugin) => {
|
|
1137
1123
|
return async () => {
|
|
1138
1124
|
const value = await this.#execute({
|
|
1139
1125
|
strategy: "hookFirst",
|
|
@@ -1146,8 +1132,7 @@ var PluginManager = class {
|
|
|
1146
1132
|
result: value
|
|
1147
1133
|
});
|
|
1148
1134
|
};
|
|
1149
|
-
});
|
|
1150
|
-
const result = await this.#promiseManager.run("first", promises);
|
|
1135
|
+
}), hookFirstNullCheck);
|
|
1151
1136
|
this.events.emit("plugins:hook:progress:end", { hookName });
|
|
1152
1137
|
return result;
|
|
1153
1138
|
}
|
|
@@ -1183,7 +1168,7 @@ var PluginManager = class {
|
|
|
1183
1168
|
plugins
|
|
1184
1169
|
});
|
|
1185
1170
|
const pluginStartTimes = /* @__PURE__ */ new Map();
|
|
1186
|
-
const
|
|
1171
|
+
const results = await hookParallel(plugins.map((plugin) => {
|
|
1187
1172
|
return () => {
|
|
1188
1173
|
pluginStartTimes.set(plugin, node_perf_hooks.performance.now());
|
|
1189
1174
|
return this.#execute({
|
|
@@ -1193,8 +1178,7 @@ var PluginManager = class {
|
|
|
1193
1178
|
plugin
|
|
1194
1179
|
});
|
|
1195
1180
|
};
|
|
1196
|
-
});
|
|
1197
|
-
const results = await this.#promiseManager.run("parallel", promises, { concurrency: this.options.concurrency });
|
|
1181
|
+
}), this.options.concurrency);
|
|
1198
1182
|
results.forEach((result, index) => {
|
|
1199
1183
|
if (isPromiseRejectedResult(result)) {
|
|
1200
1184
|
const plugin = this.#getSortedPlugins(hookName)[index];
|
|
@@ -1225,15 +1209,14 @@ var PluginManager = class {
|
|
|
1225
1209
|
hookName,
|
|
1226
1210
|
plugins
|
|
1227
1211
|
});
|
|
1228
|
-
|
|
1212
|
+
await hookSeq(plugins.map((plugin) => {
|
|
1229
1213
|
return () => this.#execute({
|
|
1230
1214
|
strategy: "hookSeq",
|
|
1231
1215
|
hookName,
|
|
1232
1216
|
parameters,
|
|
1233
1217
|
plugin
|
|
1234
1218
|
});
|
|
1235
|
-
});
|
|
1236
|
-
await this.#promiseManager.run("seq", promises);
|
|
1219
|
+
}));
|
|
1237
1220
|
this.events.emit("plugins:hook:progress:end", { hookName });
|
|
1238
1221
|
}
|
|
1239
1222
|
#getSortedPlugins(hookName) {
|
|
@@ -1362,19 +1345,19 @@ var PluginManager = class {
|
|
|
1362
1345
|
}
|
|
1363
1346
|
};
|
|
1364
1347
|
//#endregion
|
|
1365
|
-
//#region src/
|
|
1348
|
+
//#region src/createStorage.ts
|
|
1366
1349
|
/**
|
|
1367
1350
|
* Wraps a storage builder so the `options` argument is optional, following the
|
|
1368
|
-
* same factory pattern as `
|
|
1351
|
+
* same factory pattern as `createPlugin`, `createLogger`, and `createAdapter`.
|
|
1369
1352
|
*
|
|
1370
1353
|
* The builder receives the resolved options object and must return a
|
|
1371
1354
|
* `DefineStorage`-compatible object that includes a `name` string.
|
|
1372
1355
|
*
|
|
1373
1356
|
* @example
|
|
1374
1357
|
* ```ts
|
|
1375
|
-
* import {
|
|
1358
|
+
* import { createStorage } from '@kubb/core'
|
|
1376
1359
|
*
|
|
1377
|
-
* export const memoryStorage =
|
|
1360
|
+
* export const memoryStorage = createStorage((_options) => {
|
|
1378
1361
|
* const store = new Map<string, string>()
|
|
1379
1362
|
* return {
|
|
1380
1363
|
* name: 'memory',
|
|
@@ -1388,7 +1371,7 @@ var PluginManager = class {
|
|
|
1388
1371
|
* })
|
|
1389
1372
|
* ```
|
|
1390
1373
|
*/
|
|
1391
|
-
function
|
|
1374
|
+
function createStorage(build) {
|
|
1392
1375
|
return (options) => build(options ?? {});
|
|
1393
1376
|
}
|
|
1394
1377
|
//#endregion
|
|
@@ -1416,7 +1399,7 @@ function defineStorage(build) {
|
|
|
1416
1399
|
* })
|
|
1417
1400
|
* ```
|
|
1418
1401
|
*/
|
|
1419
|
-
const fsStorage =
|
|
1402
|
+
const fsStorage = createStorage(() => ({
|
|
1420
1403
|
name: "fs",
|
|
1421
1404
|
async hasItem(key) {
|
|
1422
1405
|
try {
|
|
@@ -1464,7 +1447,7 @@ const fsStorage = defineStorage(() => ({
|
|
|
1464
1447
|
}));
|
|
1465
1448
|
//#endregion
|
|
1466
1449
|
//#region package.json
|
|
1467
|
-
var version = "5.0.0-alpha.
|
|
1450
|
+
var version = "5.0.0-alpha.8";
|
|
1468
1451
|
//#endregion
|
|
1469
1452
|
//#region src/utils/diagnostics.ts
|
|
1470
1453
|
/**
|
|
@@ -1578,7 +1561,7 @@ async function setup(options) {
|
|
|
1578
1561
|
` • Barrel type: ${definedConfig.output.barrelType || "none"}`
|
|
1579
1562
|
]
|
|
1580
1563
|
});
|
|
1581
|
-
const
|
|
1564
|
+
const pluginDriver = new PluginDriver(definedConfig, {
|
|
1582
1565
|
fabric,
|
|
1583
1566
|
events,
|
|
1584
1567
|
concurrency: 15
|
|
@@ -1589,26 +1572,26 @@ async function setup(options) {
|
|
|
1589
1572
|
date: /* @__PURE__ */ new Date(),
|
|
1590
1573
|
logs: [`Running adapter: ${definedConfig.adapter.name}`]
|
|
1591
1574
|
});
|
|
1592
|
-
|
|
1593
|
-
|
|
1575
|
+
pluginDriver.adapter = definedConfig.adapter;
|
|
1576
|
+
pluginDriver.rootNode = await definedConfig.adapter.parse(source);
|
|
1594
1577
|
await events.emit("debug", {
|
|
1595
1578
|
date: /* @__PURE__ */ new Date(),
|
|
1596
1579
|
logs: [
|
|
1597
1580
|
`✓ Adapter '${definedConfig.adapter.name}' resolved RootNode`,
|
|
1598
|
-
` • Schemas: ${
|
|
1599
|
-
` • Operations: ${
|
|
1581
|
+
` • Schemas: ${pluginDriver.rootNode.schemas.length}`,
|
|
1582
|
+
` • Operations: ${pluginDriver.rootNode.operations.length}`
|
|
1600
1583
|
]
|
|
1601
1584
|
});
|
|
1602
1585
|
}
|
|
1603
1586
|
return {
|
|
1604
1587
|
events,
|
|
1605
1588
|
fabric,
|
|
1606
|
-
|
|
1589
|
+
driver: pluginDriver,
|
|
1607
1590
|
sources
|
|
1608
1591
|
};
|
|
1609
1592
|
}
|
|
1610
1593
|
async function build(options, overrides) {
|
|
1611
|
-
const { fabric, files,
|
|
1594
|
+
const { fabric, files, driver, failedPlugins, pluginTimings, error, sources } = await safeBuild(options, overrides);
|
|
1612
1595
|
if (error) throw error;
|
|
1613
1596
|
if (failedPlugins.size > 0) {
|
|
1614
1597
|
const errors = [...failedPlugins].map(({ error }) => error);
|
|
@@ -1618,20 +1601,20 @@ async function build(options, overrides) {
|
|
|
1618
1601
|
failedPlugins,
|
|
1619
1602
|
fabric,
|
|
1620
1603
|
files,
|
|
1621
|
-
|
|
1604
|
+
driver,
|
|
1622
1605
|
pluginTimings,
|
|
1623
1606
|
error: void 0,
|
|
1624
1607
|
sources
|
|
1625
1608
|
};
|
|
1626
1609
|
}
|
|
1627
1610
|
async function safeBuild(options, overrides) {
|
|
1628
|
-
const { fabric,
|
|
1611
|
+
const { fabric, driver, events, sources } = overrides ? overrides : await setup(options);
|
|
1629
1612
|
const failedPlugins = /* @__PURE__ */ new Set();
|
|
1630
1613
|
const pluginTimings = /* @__PURE__ */ new Map();
|
|
1631
|
-
const config =
|
|
1614
|
+
const config = driver.config;
|
|
1632
1615
|
try {
|
|
1633
|
-
for (const plugin of
|
|
1634
|
-
const context =
|
|
1616
|
+
for (const plugin of driver.plugins) {
|
|
1617
|
+
const context = driver.getContext(plugin);
|
|
1635
1618
|
const hrStart = process.hrtime();
|
|
1636
1619
|
const installer = plugin.install.bind(context);
|
|
1637
1620
|
try {
|
|
@@ -1704,7 +1687,7 @@ async function safeBuild(options, overrides) {
|
|
|
1704
1687
|
rootDir,
|
|
1705
1688
|
existingExports: new Set(existingBarrel?.exports?.flatMap((e) => Array.isArray(e.name) ? e.name : [e.name]).filter((n) => Boolean(n)) ?? []),
|
|
1706
1689
|
config,
|
|
1707
|
-
|
|
1690
|
+
driver
|
|
1708
1691
|
}),
|
|
1709
1692
|
sources: [],
|
|
1710
1693
|
imports: [],
|
|
@@ -1722,7 +1705,7 @@ async function safeBuild(options, overrides) {
|
|
|
1722
1705
|
failedPlugins,
|
|
1723
1706
|
fabric,
|
|
1724
1707
|
files,
|
|
1725
|
-
|
|
1708
|
+
driver,
|
|
1726
1709
|
pluginTimings,
|
|
1727
1710
|
sources
|
|
1728
1711
|
};
|
|
@@ -1731,16 +1714,16 @@ async function safeBuild(options, overrides) {
|
|
|
1731
1714
|
failedPlugins,
|
|
1732
1715
|
fabric,
|
|
1733
1716
|
files: [],
|
|
1734
|
-
|
|
1717
|
+
driver,
|
|
1735
1718
|
pluginTimings,
|
|
1736
1719
|
error,
|
|
1737
1720
|
sources
|
|
1738
1721
|
};
|
|
1739
1722
|
}
|
|
1740
1723
|
}
|
|
1741
|
-
function buildBarrelExports({ barrelFiles, rootDir, existingExports, config,
|
|
1724
|
+
function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, driver }) {
|
|
1742
1725
|
const pluginNameMap = /* @__PURE__ */ new Map();
|
|
1743
|
-
for (const plugin of
|
|
1726
|
+
for (const plugin of driver.plugins) pluginNameMap.set(plugin.name, plugin);
|
|
1744
1727
|
return barrelFiles.flatMap((file) => {
|
|
1745
1728
|
const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
|
|
1746
1729
|
return (file.sources ?? []).flatMap((source) => {
|
|
@@ -1777,13 +1760,13 @@ function inputToAdapterSource(config) {
|
|
|
1777
1760
|
};
|
|
1778
1761
|
}
|
|
1779
1762
|
//#endregion
|
|
1780
|
-
//#region src/
|
|
1763
|
+
//#region src/createAdapter.ts
|
|
1781
1764
|
/**
|
|
1782
1765
|
* Wraps an adapter builder to make the options parameter optional.
|
|
1783
1766
|
*
|
|
1784
1767
|
* @example
|
|
1785
1768
|
* ```ts
|
|
1786
|
-
* export const adapterOas =
|
|
1769
|
+
* export const adapterOas = createAdapter<OasAdapter>((options) => {
|
|
1787
1770
|
* const { validate = true, dateType = 'string' } = options
|
|
1788
1771
|
* return {
|
|
1789
1772
|
* name: adapterOasName,
|
|
@@ -1793,12 +1776,12 @@ function inputToAdapterSource(config) {
|
|
|
1793
1776
|
* })
|
|
1794
1777
|
* ```
|
|
1795
1778
|
*/
|
|
1796
|
-
function
|
|
1779
|
+
function createAdapter(build) {
|
|
1797
1780
|
return (options) => build(options ?? {});
|
|
1798
1781
|
}
|
|
1799
1782
|
//#endregion
|
|
1800
|
-
//#region src/
|
|
1801
|
-
function
|
|
1783
|
+
//#region src/createGenerator.ts
|
|
1784
|
+
function createGenerator(generator) {
|
|
1802
1785
|
if (generator.type === "react") return {
|
|
1803
1786
|
version: "2",
|
|
1804
1787
|
Operations() {
|
|
@@ -1827,16 +1810,16 @@ function defineGenerator(generator) {
|
|
|
1827
1810
|
};
|
|
1828
1811
|
}
|
|
1829
1812
|
//#endregion
|
|
1830
|
-
//#region src/
|
|
1831
|
-
function
|
|
1813
|
+
//#region src/createLogger.ts
|
|
1814
|
+
function createLogger(logger) {
|
|
1832
1815
|
return { ...logger };
|
|
1833
1816
|
}
|
|
1834
1817
|
//#endregion
|
|
1835
|
-
//#region src/
|
|
1818
|
+
//#region src/createPlugin.ts
|
|
1836
1819
|
/**
|
|
1837
1820
|
* Wraps a plugin builder to make the options parameter optional.
|
|
1838
1821
|
*/
|
|
1839
|
-
function
|
|
1822
|
+
function createPlugin(build) {
|
|
1840
1823
|
return (options) => build(options ?? {});
|
|
1841
1824
|
}
|
|
1842
1825
|
//#endregion
|
|
@@ -1941,7 +1924,7 @@ var PackageManager = class PackageManager {
|
|
|
1941
1924
|
* })
|
|
1942
1925
|
* ```
|
|
1943
1926
|
*/
|
|
1944
|
-
const memoryStorage =
|
|
1927
|
+
const memoryStorage = createStorage(() => {
|
|
1945
1928
|
const store = /* @__PURE__ */ new Map();
|
|
1946
1929
|
return {
|
|
1947
1930
|
name: "memory",
|
|
@@ -2214,50 +2197,46 @@ function buildDirectoryTree(files, rootFolder = "") {
|
|
|
2214
2197
|
return root;
|
|
2215
2198
|
}
|
|
2216
2199
|
//#endregion
|
|
2217
|
-
//#region src/
|
|
2200
|
+
//#region src/utils/getBarrelFiles.ts
|
|
2218
2201
|
/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
(item.data.file?.
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
isIndexable: false
|
|
2248
|
-
});
|
|
2202
|
+
function getBarrelFilesByRoot(root, files) {
|
|
2203
|
+
const cachedFiles = /* @__PURE__ */ new Map();
|
|
2204
|
+
TreeNode.build(files, root)?.forEach((treeNode) => {
|
|
2205
|
+
if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) return;
|
|
2206
|
+
const barrelFile = {
|
|
2207
|
+
path: (0, node_path.join)(treeNode.parent?.data.path, "index.ts"),
|
|
2208
|
+
baseName: "index.ts",
|
|
2209
|
+
exports: [],
|
|
2210
|
+
imports: [],
|
|
2211
|
+
sources: []
|
|
2212
|
+
};
|
|
2213
|
+
const previousBarrelFile = cachedFiles.get(barrelFile.path);
|
|
2214
|
+
treeNode.leaves.forEach((item) => {
|
|
2215
|
+
if (!item.data.name) return;
|
|
2216
|
+
(item.data.file?.sources || []).forEach((source) => {
|
|
2217
|
+
if (!item.data.file?.path || !source.isIndexable || !source.name) return;
|
|
2218
|
+
if (previousBarrelFile?.sources.some((item) => item.name === source.name && item.isTypeOnly === source.isTypeOnly)) return;
|
|
2219
|
+
barrelFile.exports.push({
|
|
2220
|
+
name: [source.name],
|
|
2221
|
+
path: getRelativePath(treeNode.parent?.data.path, item.data.path),
|
|
2222
|
+
isTypeOnly: source.isTypeOnly
|
|
2223
|
+
});
|
|
2224
|
+
barrelFile.sources.push({
|
|
2225
|
+
name: source.name,
|
|
2226
|
+
isTypeOnly: source.isTypeOnly,
|
|
2227
|
+
value: "",
|
|
2228
|
+
isExportable: false,
|
|
2229
|
+
isIndexable: false
|
|
2249
2230
|
});
|
|
2250
2231
|
});
|
|
2251
|
-
if (previousBarrelFile) {
|
|
2252
|
-
previousBarrelFile.sources.push(...barrelFile.sources);
|
|
2253
|
-
previousBarrelFile.exports?.push(...barrelFile.exports || []);
|
|
2254
|
-
} else cachedFiles.set(barrelFile.path, barrelFile);
|
|
2255
2232
|
});
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2233
|
+
if (previousBarrelFile) {
|
|
2234
|
+
previousBarrelFile.sources.push(...barrelFile.sources);
|
|
2235
|
+
previousBarrelFile.exports?.push(...barrelFile.exports || []);
|
|
2236
|
+
} else cachedFiles.set(barrelFile.path, barrelFile);
|
|
2237
|
+
});
|
|
2238
|
+
return [...cachedFiles.values()];
|
|
2239
|
+
}
|
|
2261
2240
|
function trimExtName(text) {
|
|
2262
2241
|
const dotIndex = text.lastIndexOf(".");
|
|
2263
2242
|
if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
|
|
@@ -2265,14 +2244,9 @@ function trimExtName(text) {
|
|
|
2265
2244
|
}
|
|
2266
2245
|
async function getBarrelFiles(files, { type, meta = {}, root, output }) {
|
|
2267
2246
|
if (!type || type === "propagate") return [];
|
|
2268
|
-
const barrelManager = new BarrelManager();
|
|
2269
2247
|
const pathToBuildFrom = (0, node_path.join)(root, output.path);
|
|
2270
2248
|
if (trimExtName(pathToBuildFrom).endsWith("index")) return [];
|
|
2271
|
-
const barrelFiles =
|
|
2272
|
-
files,
|
|
2273
|
-
root: pathToBuildFrom,
|
|
2274
|
-
meta
|
|
2275
|
-
});
|
|
2249
|
+
const barrelFiles = getBarrelFilesByRoot(pathToBuildFrom, files);
|
|
2276
2250
|
if (type === "all") return barrelFiles.map((file) => {
|
|
2277
2251
|
return {
|
|
2278
2252
|
...file,
|
|
@@ -2398,23 +2372,22 @@ function resolveOptions(node, { options, exclude = [], include, override = [] })
|
|
|
2398
2372
|
exports.AsyncEventEmitter = AsyncEventEmitter;
|
|
2399
2373
|
exports.FunctionParams = FunctionParams;
|
|
2400
2374
|
exports.PackageManager = PackageManager;
|
|
2401
|
-
exports.
|
|
2402
|
-
exports.PromiseManager = PromiseManager;
|
|
2375
|
+
exports.PluginDriver = PluginDriver;
|
|
2403
2376
|
exports.URLPath = URLPath;
|
|
2404
2377
|
exports.build = build;
|
|
2378
|
+
exports.createAdapter = createAdapter;
|
|
2379
|
+
exports.createGenerator = createGenerator;
|
|
2380
|
+
exports.createLogger = createLogger;
|
|
2381
|
+
exports.createPlugin = createPlugin;
|
|
2382
|
+
exports.createStorage = createStorage;
|
|
2405
2383
|
exports.default = build;
|
|
2406
|
-
exports.defineAdapter = defineAdapter;
|
|
2407
2384
|
exports.defineConfig = defineConfig;
|
|
2408
|
-
exports.defineGenerator = defineGenerator;
|
|
2409
|
-
exports.defineLogger = defineLogger;
|
|
2410
|
-
exports.definePlugin = definePlugin;
|
|
2411
2385
|
Object.defineProperty(exports, "definePrinter", {
|
|
2412
2386
|
enumerable: true,
|
|
2413
2387
|
get: function() {
|
|
2414
2388
|
return _kubb_ast.definePrinter;
|
|
2415
2389
|
}
|
|
2416
2390
|
});
|
|
2417
|
-
exports.defineStorage = defineStorage;
|
|
2418
2391
|
exports.detectFormatter = detectFormatter;
|
|
2419
2392
|
exports.detectLinter = detectLinter;
|
|
2420
2393
|
exports.formatters = formatters;
|