@kubb/core 3.0.0-alpha.5 → 3.0.0-alpha.6
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-tzl0YsYE.d.ts → FileManager-Ceski1W9.d.ts} +46 -33
- package/dist/{FileManager-jZpqETKU.d.cts → FileManager-wyXRkgIk.d.cts} +46 -33
- package/dist/chunk-2EU7DMPM.js +97 -0
- package/dist/chunk-2EU7DMPM.js.map +1 -0
- package/dist/chunk-5HN4LW3R.cjs +102 -0
- package/dist/chunk-5HN4LW3R.cjs.map +1 -0
- package/dist/{chunk-Z5CHJQJB.js → chunk-76UEJFFE.js} +1 -4
- package/dist/chunk-76UEJFFE.js.map +1 -0
- package/dist/{chunk-5JZNFPUP.js → chunk-AWAZR3D5.js} +61 -10
- package/dist/chunk-AWAZR3D5.js.map +1 -0
- package/dist/{chunk-FWU62YO5.cjs → chunk-DCZQYCCO.cjs} +216 -326
- package/dist/chunk-DCZQYCCO.cjs.map +1 -0
- package/dist/{chunk-YTSNYMHW.cjs → chunk-L3JJLZ5Q.cjs} +62 -11
- package/dist/chunk-L3JJLZ5Q.cjs.map +1 -0
- package/dist/{chunk-RBP2ASUX.cjs → chunk-LOLEBOMW.cjs} +1 -4
- package/dist/chunk-LOLEBOMW.cjs.map +1 -0
- package/dist/chunk-RIEGCND2.js +525 -0
- package/dist/chunk-RIEGCND2.js.map +1 -0
- package/dist/index.cjs +80 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +67 -58
- package/dist/index.js.map +1 -1
- package/dist/{logger-BnWJh6Yq.d.cts → logger-BWFeedRk.d.cts} +15 -5
- package/dist/{logger-BnWJh6Yq.d.ts → logger-BWFeedRk.d.ts} +15 -5
- package/dist/logger.cjs +2 -2
- package/dist/logger.d.cts +1 -2
- package/dist/logger.d.ts +1 -2
- package/dist/logger.js +1 -1
- package/dist/mocks.cjs +4 -6
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +3 -5
- package/dist/mocks.d.ts +3 -5
- package/dist/mocks.js +3 -5
- package/dist/mocks.js.map +1 -1
- package/dist/transformers.cjs +189 -33
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.d.cts +1 -3
- package/dist/transformers.d.ts +1 -3
- package/dist/transformers.js +156 -14
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +6 -2
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +30 -3
- package/dist/utils.d.ts +30 -3
- package/dist/utils.js +7 -3
- package/package.json +9 -8
- package/src/BarrelManager.ts +24 -99
- package/src/FileManager.ts +156 -281
- package/src/PackageManager.ts +1 -1
- package/src/PluginManager.ts +89 -57
- package/src/build.ts +6 -19
- package/src/logger.ts +6 -8
- package/src/transformers/index.ts +2 -3
- package/src/transformers/trim.ts +0 -4
- package/src/types.ts +1 -1
- package/src/utils/TreeNode.ts +91 -26
- package/src/utils/executeStrategies.ts +1 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/parser.ts +96 -0
- package/dist/chunk-5JZNFPUP.js.map +0 -1
- package/dist/chunk-CEWT73XF.js +0 -637
- package/dist/chunk-CEWT73XF.js.map +0 -1
- package/dist/chunk-FWU62YO5.cjs.map +0 -1
- package/dist/chunk-JKZG2IJR.js +0 -283
- package/dist/chunk-JKZG2IJR.js.map +0 -1
- package/dist/chunk-PZT4CTBV.cjs +0 -299
- package/dist/chunk-PZT4CTBV.cjs.map +0 -1
- package/dist/chunk-RBP2ASUX.cjs.map +0 -1
- package/dist/chunk-YTSNYMHW.cjs.map +0 -1
- package/dist/chunk-Z5CHJQJB.js.map +0 -1
- package/src/utils/getParser.ts +0 -17
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
var _chunkPZT4CTBVcjs = require('./chunk-PZT4CTBV.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkYTSNYMHWcjs = require('./chunk-YTSNYMHW.cjs');
|
|
4
|
+
var _chunkL3JJLZ5Qcjs = require('./chunk-L3JJLZ5Q.cjs');
|
|
9
5
|
|
|
10
6
|
|
|
11
7
|
var _chunk67C6RBGQcjs = require('./chunk-67C6RBGQ.cjs');
|
|
@@ -186,19 +182,16 @@ var require_eventemitter3 = _chunkXCPFG6DOcjs.__commonJS.call(void 0, {
|
|
|
186
182
|
|
|
187
183
|
// src/FileManager.ts
|
|
188
184
|
_chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
189
|
-
var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
|
|
190
185
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
191
186
|
var _remeda = require('remeda');
|
|
192
187
|
var _fs = require('@kubb/fs');
|
|
193
188
|
|
|
194
189
|
// src/BarrelManager.ts
|
|
195
190
|
_chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
196
|
-
var _parserts = require('@kubb/parser-ts');
|
|
197
191
|
|
|
198
192
|
|
|
199
193
|
// src/utils/TreeNode.ts
|
|
200
194
|
_chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
201
|
-
var _directorytree = require('directory-tree'); var _directorytree2 = _interopRequireDefault(_directorytree);
|
|
202
195
|
var TreeNode = class _TreeNode {
|
|
203
196
|
constructor(data, parent) {
|
|
204
197
|
this.children = [];
|
|
@@ -261,25 +254,23 @@ var TreeNode = class _TreeNode {
|
|
|
261
254
|
}
|
|
262
255
|
return this;
|
|
263
256
|
}
|
|
264
|
-
static build(
|
|
257
|
+
static build(files, root) {
|
|
265
258
|
try {
|
|
266
|
-
const
|
|
267
|
-
const filteredTree = _directorytree2.default.call(void 0, path3, {
|
|
268
|
-
extensions: options.extensions,
|
|
269
|
-
exclude: [/node_modules/, ...exclude]
|
|
270
|
-
});
|
|
259
|
+
const filteredTree = buildDirectoryTree(files, root);
|
|
271
260
|
if (!filteredTree) {
|
|
272
261
|
return null;
|
|
273
262
|
}
|
|
274
263
|
const treeNode = new _TreeNode({
|
|
275
264
|
name: filteredTree.name,
|
|
276
265
|
path: filteredTree.path,
|
|
266
|
+
file: filteredTree.file,
|
|
277
267
|
type: FileManager.getMode(filteredTree.path)
|
|
278
268
|
});
|
|
279
269
|
const recurse = (node, item) => {
|
|
280
270
|
const subNode = node.addChild({
|
|
281
271
|
name: item.name,
|
|
282
272
|
path: item.path,
|
|
273
|
+
file: item.file,
|
|
283
274
|
type: FileManager.getMode(item.path)
|
|
284
275
|
});
|
|
285
276
|
if (_optionalChain([item, 'access', _8 => _8.children, 'optionalAccess', _9 => _9.length])) {
|
|
@@ -295,8 +286,55 @@ var TreeNode = class _TreeNode {
|
|
|
295
286
|
}
|
|
296
287
|
}
|
|
297
288
|
};
|
|
289
|
+
function buildDirectoryTree(files, rootFolder = "") {
|
|
290
|
+
const rootPrefix = rootFolder.endsWith("/") ? rootFolder : `${rootFolder}/`;
|
|
291
|
+
const filteredFiles = files.filter((file) => rootFolder ? file.path.startsWith(rootPrefix) && !file.path.endsWith(".json") : !file.path.endsWith(".json"));
|
|
292
|
+
if (filteredFiles.length === 0) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
const root = {
|
|
296
|
+
name: rootFolder || "",
|
|
297
|
+
path: rootFolder || "",
|
|
298
|
+
children: []
|
|
299
|
+
};
|
|
300
|
+
filteredFiles.forEach((file) => {
|
|
301
|
+
const path2 = file.path.slice(rootFolder.length);
|
|
302
|
+
const parts = path2.split("/");
|
|
303
|
+
let currentLevel = root.children;
|
|
304
|
+
let currentPath = rootFolder;
|
|
305
|
+
parts.forEach((part, index) => {
|
|
306
|
+
if (index !== 0) {
|
|
307
|
+
currentPath += `/${part}`;
|
|
308
|
+
} else {
|
|
309
|
+
currentPath += `${part}`;
|
|
310
|
+
}
|
|
311
|
+
let existingNode = currentLevel.find((node) => node.name === part);
|
|
312
|
+
if (!existingNode) {
|
|
313
|
+
if (index === parts.length - 1) {
|
|
314
|
+
existingNode = {
|
|
315
|
+
name: part,
|
|
316
|
+
file,
|
|
317
|
+
path: currentPath
|
|
318
|
+
};
|
|
319
|
+
} else {
|
|
320
|
+
existingNode = {
|
|
321
|
+
name: part,
|
|
322
|
+
path: currentPath,
|
|
323
|
+
children: []
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
currentLevel.push(existingNode);
|
|
327
|
+
}
|
|
328
|
+
if (!existingNode.file) {
|
|
329
|
+
currentLevel = existingNode.children;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
return root;
|
|
334
|
+
}
|
|
298
335
|
|
|
299
336
|
// src/BarrelManager.ts
|
|
337
|
+
|
|
300
338
|
var _options;
|
|
301
339
|
var BarrelManager = class {
|
|
302
340
|
constructor(options = {}) {
|
|
@@ -304,95 +342,34 @@ var BarrelManager = class {
|
|
|
304
342
|
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options, options);
|
|
305
343
|
return this;
|
|
306
344
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
*/
|
|
311
|
-
getNamedExport(root, item) {
|
|
312
|
-
const exportedNames = _parserts.getExports.call(void 0, _path2.default.resolve(root, item.path));
|
|
313
|
-
if (!exportedNames) {
|
|
314
|
-
return [item];
|
|
315
|
-
}
|
|
316
|
-
const exports = exportedNames.reduce(
|
|
317
|
-
(prev, curr) => {
|
|
318
|
-
if (!_optionalChain([prev, 'access', _16 => _16[0], 'optionalAccess', _17 => _17.name]) || !_optionalChain([prev, 'access', _18 => _18[1], 'optionalAccess', _19 => _19.name])) {
|
|
319
|
-
return prev;
|
|
320
|
-
}
|
|
321
|
-
if (curr.isTypeOnly) {
|
|
322
|
-
prev[1] = { ...prev[1], name: [...prev[1].name, curr.name] };
|
|
323
|
-
} else {
|
|
324
|
-
prev[0] = { ...prev[0], name: [...prev[0].name, curr.name] };
|
|
325
|
-
}
|
|
326
|
-
return prev;
|
|
327
|
-
},
|
|
328
|
-
[
|
|
329
|
-
{
|
|
330
|
-
...item,
|
|
331
|
-
name: [],
|
|
332
|
-
isTypeOnly: false
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
...item,
|
|
336
|
-
name: [],
|
|
337
|
-
isTypeOnly: true
|
|
338
|
-
}
|
|
339
|
-
]
|
|
340
|
-
);
|
|
341
|
-
return exports;
|
|
342
|
-
}
|
|
343
|
-
getNamedExports(root, exports) {
|
|
344
|
-
return _optionalChain([exports, 'optionalAccess', _20 => _20.flatMap, 'call', _21 => _21((item) => {
|
|
345
|
-
return this.getNamedExport(root, item);
|
|
346
|
-
})]);
|
|
347
|
-
}
|
|
348
|
-
getIndexes(root) {
|
|
349
|
-
const { treeNode = {}, isTypeOnly, extName } = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options);
|
|
350
|
-
const tree = TreeNode.build(root, treeNode);
|
|
345
|
+
getIndexes(generatedFiles, root) {
|
|
346
|
+
const { isTypeOnly, extName } = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options);
|
|
347
|
+
const tree = TreeNode.build(generatedFiles, root);
|
|
351
348
|
if (!tree) {
|
|
352
349
|
return null;
|
|
353
350
|
}
|
|
354
|
-
const fileReducer = (files,
|
|
355
|
-
if (!
|
|
351
|
+
const fileReducer = (files, treeNode) => {
|
|
352
|
+
if (!treeNode.children) {
|
|
356
353
|
return [];
|
|
357
354
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
});
|
|
377
|
-
} else if (treeNode2.children.length === 1) {
|
|
378
|
-
const [treeNodeChild] = treeNode2.children;
|
|
379
|
-
const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
|
|
380
|
-
const importPath = treeNodeChild.data.type === "split" ? `./${treeNodeChild.data.name}/index` : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, treeNodeChild.data.name)}`;
|
|
381
|
-
const exports = [
|
|
382
|
-
{
|
|
383
|
-
path: extName ? `${importPath}${extName}` : importPath,
|
|
384
|
-
isTypeOnly
|
|
385
|
-
}
|
|
386
|
-
];
|
|
387
|
-
files.push({
|
|
388
|
-
path: indexPath,
|
|
389
|
-
baseName: "index.ts",
|
|
390
|
-
source: "",
|
|
391
|
-
exports,
|
|
392
|
-
exportable: true
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
treeNode2.children.forEach((childItem) => {
|
|
355
|
+
const indexPath = _path2.default.resolve(treeNode.data.path, "index.ts");
|
|
356
|
+
const exports = treeNode.children.filter((item) => !!item.data.name).map((treeNode2) => {
|
|
357
|
+
const importPath = treeNode2.data.file ? `./${_fs.trimExtName.call(void 0, treeNode2.data.name)}` : `./${treeNode2.data.name}/index`;
|
|
358
|
+
if (importPath.endsWith("index") && treeNode2.data.file) {
|
|
359
|
+
return void 0;
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
path: extName ? `${importPath}${extName}` : importPath,
|
|
363
|
+
isTypeOnly
|
|
364
|
+
};
|
|
365
|
+
}).filter(Boolean);
|
|
366
|
+
files.push({
|
|
367
|
+
path: indexPath,
|
|
368
|
+
baseName: "index.ts",
|
|
369
|
+
exports,
|
|
370
|
+
sources: []
|
|
371
|
+
});
|
|
372
|
+
treeNode.children.forEach((childItem) => {
|
|
396
373
|
fileReducer(files, childItem);
|
|
397
374
|
});
|
|
398
375
|
return files;
|
|
@@ -402,6 +379,9 @@ var BarrelManager = class {
|
|
|
402
379
|
};
|
|
403
380
|
_options = new WeakMap();
|
|
404
381
|
|
|
382
|
+
// src/FileManager.ts
|
|
383
|
+
|
|
384
|
+
|
|
405
385
|
// ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
|
|
406
386
|
_chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
407
387
|
|
|
@@ -539,7 +519,7 @@ var PriorityQueue = class {
|
|
|
539
519
|
}
|
|
540
520
|
dequeue() {
|
|
541
521
|
const item = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).shift();
|
|
542
|
-
return _optionalChain([item, 'optionalAccess',
|
|
522
|
+
return _optionalChain([item, 'optionalAccess', _16 => _16.run]);
|
|
543
523
|
}
|
|
544
524
|
filter(options) {
|
|
545
525
|
return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).filter((element) => element.priority === options.priority).map((element) => element.run);
|
|
@@ -588,10 +568,10 @@ var PQueue = class extends import_index.default {
|
|
|
588
568
|
...options
|
|
589
569
|
};
|
|
590
570
|
if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
|
|
591
|
-
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${_nullishCoalesce(_optionalChain([options, 'access',
|
|
571
|
+
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${_nullishCoalesce(_optionalChain([options, 'access', _17 => _17.intervalCap, 'optionalAccess', _18 => _18.toString, 'call', _19 => _19()]), () => ( ""))}\` (${typeof options.intervalCap})`);
|
|
592
572
|
}
|
|
593
573
|
if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
|
|
594
|
-
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${_nullishCoalesce(_optionalChain([options, 'access',
|
|
574
|
+
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${_nullishCoalesce(_optionalChain([options, 'access', _20 => _20.interval, 'optionalAccess', _21 => _21.toString, 'call', _22 => _22()]), () => ( ""))}\` (${typeof options.interval})`);
|
|
595
575
|
}
|
|
596
576
|
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _carryoverConcurrencyCount, options.carryoverConcurrencyCount);
|
|
597
577
|
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0);
|
|
@@ -625,7 +605,7 @@ var PQueue = class extends import_index.default {
|
|
|
625
605
|
_chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _pending)._++;
|
|
626
606
|
_chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _intervalCount)._++;
|
|
627
607
|
try {
|
|
628
|
-
_optionalChain([options, 'access',
|
|
608
|
+
_optionalChain([options, 'access', _23 => _23.signal, 'optionalAccess', _24 => _24.throwIfAborted, 'call', _25 => _25()]);
|
|
629
609
|
let operation = function_({ signal: options.signal });
|
|
630
610
|
if (options.timeout) {
|
|
631
611
|
operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
|
|
@@ -861,22 +841,33 @@ onEvent_fn = async function(event, filter) {
|
|
|
861
841
|
};
|
|
862
842
|
|
|
863
843
|
// src/FileManager.ts
|
|
864
|
-
var
|
|
844
|
+
var _filesByPath, _files, _FileManager_instances, add_fn, addOrAppend_fn;
|
|
865
845
|
var _FileManager = class _FileManager {
|
|
866
846
|
constructor() {
|
|
867
847
|
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _FileManager_instances);
|
|
868
|
-
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this,
|
|
848
|
+
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _filesByPath, /* @__PURE__ */ new Map());
|
|
849
|
+
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _files, /* @__PURE__ */ new Set());
|
|
869
850
|
return this;
|
|
870
851
|
}
|
|
871
852
|
get files() {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
853
|
+
return Array.from(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files));
|
|
854
|
+
}
|
|
855
|
+
get orderedFiles() {
|
|
856
|
+
return _chunk67C6RBGQcjs.orderBy.call(void 0, Array.from(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files)), [
|
|
857
|
+
(v) => v.path.length,
|
|
858
|
+
(v) => _fs.trimExtName.call(void 0, v.path).endsWith("index"),
|
|
859
|
+
(v) => _fs.trimExtName.call(void 0, v.baseName),
|
|
860
|
+
(v) => v.path.split(".").pop()
|
|
861
|
+
]);
|
|
862
|
+
}
|
|
863
|
+
get groupedFiles() {
|
|
864
|
+
return buildDirectoryTree(Array.from(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files)));
|
|
865
|
+
}
|
|
866
|
+
get treeNode() {
|
|
867
|
+
return TreeNode.build(Array.from(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files)));
|
|
877
868
|
}
|
|
878
869
|
async add(...files) {
|
|
879
|
-
const promises =
|
|
870
|
+
const promises = files.map((file) => {
|
|
880
871
|
if (file.override) {
|
|
881
872
|
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, file);
|
|
882
873
|
}
|
|
@@ -888,31 +879,47 @@ var _FileManager = class _FileManager {
|
|
|
888
879
|
}
|
|
889
880
|
return resolvedFiles[0];
|
|
890
881
|
}
|
|
891
|
-
|
|
882
|
+
getCacheById(id) {
|
|
883
|
+
let cache;
|
|
884
|
+
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files).forEach((file) => {
|
|
885
|
+
if (file.id === id) {
|
|
886
|
+
cache = file;
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
return cache;
|
|
890
|
+
}
|
|
891
|
+
getByPath(path2) {
|
|
892
|
+
return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _filesByPath).get(path2);
|
|
893
|
+
}
|
|
894
|
+
deleteByPath(path2) {
|
|
895
|
+
const cacheItem = this.getByPath(path2);
|
|
896
|
+
if (!cacheItem) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _filesByPath).delete(path2);
|
|
900
|
+
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files).delete(cacheItem);
|
|
901
|
+
}
|
|
902
|
+
async getIndexFiles({ files, plugin, root, output, logger, options = {} }) {
|
|
892
903
|
const { exportType = "barrel" } = output;
|
|
893
904
|
if (exportType === false) {
|
|
894
905
|
return [];
|
|
895
906
|
}
|
|
896
907
|
const pathToBuildFrom = _path.resolve.call(void 0, root, output.path);
|
|
897
|
-
if (
|
|
908
|
+
if (_fs.trimExtName.call(void 0, pathToBuildFrom).endsWith("index")) {
|
|
898
909
|
logger.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
|
|
899
910
|
return [];
|
|
900
911
|
}
|
|
901
|
-
const exportPath = output.path.startsWith("./") ?
|
|
912
|
+
const exportPath = output.path.startsWith("./") ? output.path : `./${output.path}`;
|
|
902
913
|
const mode = _FileManager.getMode(output.path);
|
|
903
|
-
const barrelManager = new BarrelManager({
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
});
|
|
907
|
-
let files = barrelManager.getIndexes(pathToBuildFrom);
|
|
908
|
-
if (!files) {
|
|
914
|
+
const barrelManager = new BarrelManager({ ...options, extName: output.extName });
|
|
915
|
+
let indexFiles = barrelManager.getIndexes(files, pathToBuildFrom);
|
|
916
|
+
if (!indexFiles) {
|
|
909
917
|
return [];
|
|
910
918
|
}
|
|
911
919
|
const rootPath = mode === "split" ? `${exportPath}/index${output.extName || ""}` : `${exportPath}${output.extName || ""}`;
|
|
912
920
|
const rootFile = {
|
|
913
921
|
path: _path.resolve.call(void 0, root, "index.ts"),
|
|
914
922
|
baseName: "index.ts",
|
|
915
|
-
source: "",
|
|
916
923
|
exports: [
|
|
917
924
|
output.exportAs ? {
|
|
918
925
|
name: output.exportAs,
|
|
@@ -924,193 +931,111 @@ var _FileManager = class _FileManager {
|
|
|
924
931
|
isTypeOnly: options.isTypeOnly
|
|
925
932
|
}
|
|
926
933
|
],
|
|
927
|
-
|
|
934
|
+
sources: [],
|
|
935
|
+
meta: {
|
|
936
|
+
pluginKey: plugin.key
|
|
937
|
+
}
|
|
928
938
|
};
|
|
929
|
-
if (exportType === "
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
exports: barrelManager.getNamedExports(pathToBuildFrom, file.exports)
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
return file;
|
|
938
|
-
});
|
|
939
|
-
const barrelExportRoot = _optionalChain([rootFile, 'access', _32 => _32.exports, 'optionalAccess', _33 => _33[0]]);
|
|
940
|
-
if (!output.exportAs && barrelExportRoot) {
|
|
941
|
-
const exportFile = files.find((file) => {
|
|
942
|
-
return _chunkPZT4CTBVcjs.trimExtName.call(void 0, file.path) === _path2.default.resolve(root, barrelExportRoot.path);
|
|
943
|
-
});
|
|
944
|
-
if (_optionalChain([exportFile, 'optionalAccess', _34 => _34.exports])) {
|
|
945
|
-
rootFile.exports = exportFile.exports.map((exportItem) => {
|
|
939
|
+
if (exportType === "barrel") {
|
|
940
|
+
indexFiles = indexFiles.map((file) => {
|
|
941
|
+
return {
|
|
942
|
+
...file,
|
|
943
|
+
exports: _optionalChain([file, 'access', _26 => _26.exports, 'optionalAccess', _27 => _27.map, 'call', _28 => _28((exportItem) => {
|
|
946
944
|
return {
|
|
947
945
|
...exportItem,
|
|
948
|
-
|
|
946
|
+
name: void 0
|
|
949
947
|
};
|
|
950
|
-
})
|
|
951
|
-
}
|
|
952
|
-
}
|
|
948
|
+
})])
|
|
949
|
+
};
|
|
950
|
+
});
|
|
951
|
+
rootFile.exports = _optionalChain([rootFile, 'access', _29 => _29.exports, 'optionalAccess', _30 => _30.map, 'call', _31 => _31((item) => {
|
|
952
|
+
return {
|
|
953
|
+
...item,
|
|
954
|
+
name: void 0
|
|
955
|
+
};
|
|
956
|
+
})]);
|
|
953
957
|
}
|
|
954
958
|
return [
|
|
955
|
-
...
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
),
|
|
965
|
-
await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, addOrAppend_fn).call(this, {
|
|
966
|
-
...rootFile,
|
|
967
|
-
meta: {
|
|
968
|
-
pluginKey: plugin.key
|
|
969
|
-
}
|
|
970
|
-
})
|
|
959
|
+
...indexFiles.map((indexFile) => {
|
|
960
|
+
return {
|
|
961
|
+
...indexFile,
|
|
962
|
+
meta: {
|
|
963
|
+
pluginKey: plugin.key
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
}),
|
|
967
|
+
rootFile
|
|
971
968
|
];
|
|
972
969
|
}
|
|
973
|
-
getCacheByUUID(UUID) {
|
|
974
|
-
let cache;
|
|
975
|
-
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).forEach((files) => {
|
|
976
|
-
cache = files.find((item) => item.id === UUID);
|
|
977
|
-
});
|
|
978
|
-
return cache;
|
|
979
|
-
}
|
|
980
|
-
get(path3) {
|
|
981
|
-
return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).get(path3);
|
|
982
|
-
}
|
|
983
|
-
remove(path3) {
|
|
984
|
-
const cacheItem = this.get(path3);
|
|
985
|
-
if (!cacheItem) {
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).delete(path3);
|
|
989
|
-
}
|
|
990
970
|
async write(...params) {
|
|
991
971
|
return _fs.write.call(void 0, ...params);
|
|
992
972
|
}
|
|
993
973
|
async read(...params) {
|
|
994
974
|
return _fs.read.call(void 0, ...params);
|
|
995
975
|
}
|
|
996
|
-
async processFiles(...params) {
|
|
997
|
-
return processFiles(...params);
|
|
998
|
-
}
|
|
999
976
|
// statics
|
|
1000
|
-
static
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
static getMode(path3) {
|
|
1004
|
-
if (!path3) {
|
|
977
|
+
static getMode(path2) {
|
|
978
|
+
if (!path2) {
|
|
1005
979
|
return "split";
|
|
1006
980
|
}
|
|
1007
|
-
return _path.extname.call(void 0,
|
|
1008
|
-
}
|
|
1009
|
-
static get extensions() {
|
|
1010
|
-
return [".js", ".ts", ".tsx"];
|
|
1011
|
-
}
|
|
1012
|
-
static isJavascript(baseName) {
|
|
1013
|
-
return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
|
|
981
|
+
return _path.extname.call(void 0, path2) ? "single" : "split";
|
|
1014
982
|
}
|
|
1015
983
|
};
|
|
1016
|
-
|
|
984
|
+
_filesByPath = new WeakMap();
|
|
985
|
+
_files = new WeakMap();
|
|
1017
986
|
_FileManager_instances = new WeakSet();
|
|
1018
987
|
add_fn = async function(file) {
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
name: _chunkPZT4CTBVcjs.trimExtName.call(void 0, file.baseName),
|
|
1023
|
-
...file
|
|
1024
|
-
};
|
|
1025
|
-
if (_optionalChain([resolvedFile, 'access', _35 => _35.exports, 'optionalAccess', _36 => _36.length])) {
|
|
1026
|
-
const folder = resolvedFile.path.replace(resolvedFile.baseName, "");
|
|
1027
|
-
resolvedFile.exports = resolvedFile.exports.filter((exportItem) => {
|
|
1028
|
-
const exportedFile = this.files.find((file2) => file2.path.includes(_path.resolve.call(void 0, folder, exportItem.path)));
|
|
1029
|
-
if (exportedFile) {
|
|
1030
|
-
return exportedFile.exportable;
|
|
1031
|
-
}
|
|
1032
|
-
return true;
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
988
|
+
const resolvedFile = _chunkL3JJLZ5Qcjs.createFile.call(void 0, file);
|
|
989
|
+
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _filesByPath).set(resolvedFile.path, resolvedFile);
|
|
990
|
+
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files).add(resolvedFile);
|
|
1036
991
|
return resolvedFile;
|
|
1037
992
|
};
|
|
1038
993
|
addOrAppend_fn = async function(file) {
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this,
|
|
994
|
+
const previousFile = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _filesByPath).get(file.path);
|
|
995
|
+
if (previousFile) {
|
|
996
|
+
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _filesByPath).delete(previousFile.path);
|
|
997
|
+
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _files).delete(previousFile);
|
|
1043
998
|
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, {
|
|
1044
999
|
...file,
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
exports: [...previousCache.exports || [], ...file.exports || []],
|
|
1049
|
-
env: { ...previousCache.env || {}, ...file.env || {} }
|
|
1000
|
+
sources: [...previousFile.sources || [], ...file.sources || []],
|
|
1001
|
+
imports: [...previousFile.imports || [], ...file.imports || []],
|
|
1002
|
+
exports: [...previousFile.exports || [], ...file.exports || []]
|
|
1050
1003
|
});
|
|
1051
1004
|
}
|
|
1052
1005
|
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, file);
|
|
1053
1006
|
};
|
|
1054
1007
|
var FileManager = _FileManager;
|
|
1055
|
-
function combineFiles(files) {
|
|
1056
|
-
return files.filter(Boolean).reduce(
|
|
1057
|
-
(acc, file) => {
|
|
1058
|
-
const prevIndex = acc.findIndex((item) => item.path === file.path);
|
|
1059
|
-
if (prevIndex === -1) {
|
|
1060
|
-
return [...acc, file];
|
|
1061
|
-
}
|
|
1062
|
-
const prev = acc[prevIndex];
|
|
1063
|
-
if (prev && file.override) {
|
|
1064
|
-
acc[prevIndex] = {
|
|
1065
|
-
imports: [],
|
|
1066
|
-
exports: [],
|
|
1067
|
-
...file
|
|
1068
|
-
};
|
|
1069
|
-
return acc;
|
|
1070
|
-
}
|
|
1071
|
-
if (prev) {
|
|
1072
|
-
acc[prevIndex] = {
|
|
1073
|
-
...file,
|
|
1074
|
-
source: prev.source && file.source ? `${prev.source}
|
|
1075
|
-
${file.source}` : "",
|
|
1076
|
-
imports: [...prev.imports || [], ...file.imports || []],
|
|
1077
|
-
exports: [...prev.exports || [], ...file.exports || []],
|
|
1078
|
-
env: { ...prev.env || {}, ...file.env || {} }
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
|
-
return acc;
|
|
1082
|
-
},
|
|
1083
|
-
[]
|
|
1084
|
-
);
|
|
1085
|
-
}
|
|
1086
1008
|
async function getSource(file) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
const parser = await _chunkYTSNYMHWcjs.getParser.call(void 0, file.language);
|
|
1009
|
+
const parser = await _chunkL3JJLZ5Qcjs.getFileParser.call(void 0, file.extName);
|
|
1010
|
+
const source = file.sources.map((item) => item.value).join("\n\n");
|
|
1091
1011
|
const exports = file.exports ? combineExports(file.exports) : [];
|
|
1092
|
-
const imports = file.imports &&
|
|
1012
|
+
const imports = file.imports && source ? combineImports(file.imports, exports, source) : [];
|
|
1093
1013
|
const importNodes = imports.filter((item) => {
|
|
1094
|
-
const
|
|
1095
|
-
return
|
|
1014
|
+
const path2 = item.root ? _fs.getRelativePath.call(void 0, item.root, item.path) : item.path;
|
|
1015
|
+
return path2 !== _fs.trimExtName.call(void 0, file.path);
|
|
1096
1016
|
}).map((item) => {
|
|
1097
|
-
const
|
|
1098
|
-
return parser.
|
|
1017
|
+
const path2 = item.root ? _fs.getRelativePath.call(void 0, item.root, item.path) : item.path;
|
|
1018
|
+
return parser.createImport({
|
|
1099
1019
|
name: item.name,
|
|
1100
|
-
path: item.extName ? `${
|
|
1020
|
+
path: item.extName ? `${path2}${item.extName}` : path2,
|
|
1101
1021
|
isTypeOnly: item.isTypeOnly
|
|
1102
1022
|
});
|
|
1103
1023
|
});
|
|
1104
|
-
const exportNodes = exports.map(
|
|
1105
|
-
(item)
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1024
|
+
const exportNodes = exports.map((item) => {
|
|
1025
|
+
if (item.path) {
|
|
1026
|
+
return parser.createExport({
|
|
1027
|
+
name: item.name,
|
|
1028
|
+
path: item.extName ? `${item.path}${item.extName}` : item.path,
|
|
1029
|
+
isTypeOnly: item.isTypeOnly,
|
|
1030
|
+
asAlias: item.asAlias
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
}).filter(Boolean);
|
|
1034
|
+
return parser.print({
|
|
1035
|
+
imports: importNodes,
|
|
1036
|
+
exports: exportNodes,
|
|
1037
|
+
source
|
|
1038
|
+
});
|
|
1114
1039
|
}
|
|
1115
1040
|
function combineExports(exports) {
|
|
1116
1041
|
const combinedExports = _chunk67C6RBGQcjs.orderBy.call(void 0, exports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
|
|
@@ -1124,7 +1049,7 @@ function combineExports(exports) {
|
|
|
1124
1049
|
const uniquePrev = prev.findLast(
|
|
1125
1050
|
(imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
|
|
1126
1051
|
);
|
|
1127
|
-
if (uniquePrev || Array.isArray(name) && !name.length || _optionalChain([prevByPath, 'optionalAccess',
|
|
1052
|
+
if (uniquePrev || Array.isArray(name) && !name.length || _optionalChain([prevByPath, 'optionalAccess', _32 => _32.asAlias]) && !curr.asAlias) {
|
|
1128
1053
|
return prev;
|
|
1129
1054
|
}
|
|
1130
1055
|
if (!prevByPath) {
|
|
@@ -1144,7 +1069,7 @@ function combineExports(exports) {
|
|
|
1144
1069
|
},
|
|
1145
1070
|
[]
|
|
1146
1071
|
);
|
|
1147
|
-
return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias]
|
|
1072
|
+
return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias]);
|
|
1148
1073
|
}
|
|
1149
1074
|
function combineImports(imports, exports, source) {
|
|
1150
1075
|
const combinedImports = _chunk67C6RBGQcjs.orderBy.call(void 0, imports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
|
|
@@ -1192,69 +1117,34 @@ function combineImports(imports, exports, source) {
|
|
|
1192
1117
|
},
|
|
1193
1118
|
[]
|
|
1194
1119
|
);
|
|
1195
|
-
return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedImports, [(v) => !v.isTypeOnly]
|
|
1120
|
+
return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedImports, [(v) => !v.isTypeOnly]);
|
|
1196
1121
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
1210
|
-
}
|
|
1211
|
-
if (typeof replaceBy === "string") {
|
|
1212
|
-
prev = _chunkPZT4CTBVcjs.searchAndReplace.call(void 0, {
|
|
1213
|
-
text: prev.replaceAll(`process.env.${key}`, replaceBy),
|
|
1214
|
-
replaceBy,
|
|
1215
|
-
prefix: "process.env",
|
|
1216
|
-
key
|
|
1217
|
-
});
|
|
1218
|
-
prev = _chunkPZT4CTBVcjs.searchAndReplace.call(void 0, {
|
|
1219
|
-
text: prev.replaceAll(/(declare const).*\n/gi, ""),
|
|
1220
|
-
replaceBy,
|
|
1221
|
-
key
|
|
1222
|
-
});
|
|
1223
|
-
}
|
|
1224
|
-
return prev;
|
|
1225
|
-
}, source);
|
|
1226
|
-
}
|
|
1227
|
-
var queue = new PQueue({ concurrency: 10 });
|
|
1228
|
-
async function processFiles({ dryRun, logger, files }) {
|
|
1229
|
-
const mergedFiles = await Promise.all(
|
|
1230
|
-
files.map(async (file) => ({
|
|
1231
|
-
...file,
|
|
1232
|
-
source: await getSource(file)
|
|
1233
|
-
}))
|
|
1234
|
-
);
|
|
1235
|
-
const orderedFiles = _chunk67C6RBGQcjs.orderBy.call(void 0, mergedFiles, [(v) => !_optionalChain([v, 'access', _42 => _42.meta, 'optionalAccess', _43 => _43.pluginKey]), (v) => v.path.length, (v) => _chunkPZT4CTBVcjs.trimExtName.call(void 0, v.path).endsWith("index")], ["desc", "desc"]);
|
|
1236
|
-
logger.emit(
|
|
1237
|
-
"debug",
|
|
1238
|
-
orderedFiles.map((item) => `[${_optionalChain([item, 'access', _44 => _44.meta, 'optionalAccess', _45 => _45.pluginKey]) || "unknown"}]${item.path}:
|
|
1239
|
-
${item.source}`)
|
|
1240
|
-
);
|
|
1122
|
+
var queue = new PQueue({ concurrency: 100 });
|
|
1123
|
+
async function processFiles({ dryRun, config, logger, files }) {
|
|
1124
|
+
const orderedFiles = _chunk67C6RBGQcjs.orderBy.call(void 0, files, [
|
|
1125
|
+
(v) => _optionalChain([v, 'optionalAccess', _33 => _33.meta]) && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
1126
|
+
(v) => v.path.length,
|
|
1127
|
+
(v) => _fs.trimExtName.call(void 0, v.path).endsWith("index")
|
|
1128
|
+
]);
|
|
1129
|
+
logger.emit("debug", {
|
|
1130
|
+
logs: [JSON.stringify({ files: orderedFiles }, null, 2)],
|
|
1131
|
+
fileName: "kubb-files.json",
|
|
1132
|
+
override: true
|
|
1133
|
+
});
|
|
1241
1134
|
if (!dryRun) {
|
|
1242
|
-
_optionalChain([logger, 'access', _46 => _46.consola, 'optionalAccess', _47 => _47.pauseLogs, 'call', _48 => _48()]);
|
|
1243
1135
|
const size = orderedFiles.length;
|
|
1244
|
-
|
|
1136
|
+
logger.emit("progress_start", { id: "files", size });
|
|
1137
|
+
const promises = orderedFiles.map(async (file) => {
|
|
1245
1138
|
await queue.add(async () => {
|
|
1246
|
-
|
|
1247
|
-
await _fs.write.call(void 0, file.path,
|
|
1248
|
-
|
|
1249
|
-
setTimeout(resolve2, 0);
|
|
1250
|
-
});
|
|
1251
|
-
logger.emit("progress", { count: index + 1, size, file });
|
|
1139
|
+
const source = await getSource(file);
|
|
1140
|
+
await _fs.write.call(void 0, file.path, source, { sanity: false });
|
|
1141
|
+
logger.emit("progress", { id: "files", data: file ? _path.relative.call(void 0, config.root, file.path) : "" });
|
|
1252
1142
|
});
|
|
1253
1143
|
});
|
|
1254
1144
|
await Promise.all(promises);
|
|
1255
|
-
|
|
1145
|
+
logger.emit("progress_stop", { id: "files" });
|
|
1256
1146
|
}
|
|
1257
|
-
return
|
|
1147
|
+
return files;
|
|
1258
1148
|
}
|
|
1259
1149
|
|
|
1260
1150
|
|
|
@@ -1262,4 +1152,4 @@ ${item.source}`)
|
|
|
1262
1152
|
|
|
1263
1153
|
|
|
1264
1154
|
exports.FileManager = FileManager; exports.getSource = getSource; exports.processFiles = processFiles;
|
|
1265
|
-
//# sourceMappingURL=chunk-
|
|
1155
|
+
//# sourceMappingURL=chunk-DCZQYCCO.cjs.map
|