@kubb/core 3.0.0-alpha.4 → 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-CaejIVBd.d.ts → FileManager-Ceski1W9.d.ts} +47 -47
- package/dist/{FileManager--scIq4y4.d.cts → FileManager-wyXRkgIk.d.cts} +47 -47
- 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-EFQPHF4E.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-V5THHXXQ.cjs → chunk-DCZQYCCO.cjs} +218 -299
- 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-QRIDQ4RG.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 +81 -75
- 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 +68 -64
- package/dist/index.js.map +1 -1
- package/dist/{logger-dzAcLeAA.d.cts → logger-BWFeedRk.d.cts} +17 -2
- package/dist/{logger-dzAcLeAA.d.ts → logger-BWFeedRk.d.ts} +17 -2
- package/dist/logger.cjs +2 -2
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- 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 +5 -7
- 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 +27 -93
- package/src/FileManager.ts +165 -266
- package/src/PackageManager.ts +1 -1
- package/src/PluginManager.ts +89 -57
- package/src/build.ts +7 -26
- package/src/logger.ts +6 -7
- 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-EFQPHF4E.js.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-QRIDQ4RG.cjs.map +0 -1
- package/dist/chunk-UUBPTMRW.js +0 -608
- package/dist/chunk-UUBPTMRW.js.map +0 -1
- package/dist/chunk-V5THHXXQ.cjs.map +0 -1
- package/dist/chunk-YTSNYMHW.cjs.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, path2, {
|
|
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,90 +342,34 @@ var BarrelManager = class {
|
|
|
304
342
|
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options, options);
|
|
305
343
|
return this;
|
|
306
344
|
}
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
return [item];
|
|
311
|
-
}
|
|
312
|
-
return exportedNames.reduce(
|
|
313
|
-
(prev, curr) => {
|
|
314
|
-
if (!_optionalChain([prev, 'access', _16 => _16[0], 'optionalAccess', _17 => _17.name]) || !_optionalChain([prev, 'access', _18 => _18[1], 'optionalAccess', _19 => _19.name])) {
|
|
315
|
-
return prev;
|
|
316
|
-
}
|
|
317
|
-
if (curr.isTypeOnly) {
|
|
318
|
-
prev[1] = { ...prev[1], name: [...prev[1].name, curr.name] };
|
|
319
|
-
} else {
|
|
320
|
-
prev[0] = { ...prev[0], name: [...prev[0].name, curr.name] };
|
|
321
|
-
}
|
|
322
|
-
return prev;
|
|
323
|
-
},
|
|
324
|
-
[
|
|
325
|
-
{
|
|
326
|
-
...item,
|
|
327
|
-
name: [],
|
|
328
|
-
isTypeOnly: false
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
...item,
|
|
332
|
-
name: [],
|
|
333
|
-
isTypeOnly: true
|
|
334
|
-
}
|
|
335
|
-
]
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
getNamedExports(root, exports) {
|
|
339
|
-
return _optionalChain([exports, 'optionalAccess', _20 => _20.flatMap, 'call', _21 => _21((item) => {
|
|
340
|
-
return this.getNamedExport(root, item);
|
|
341
|
-
})]);
|
|
342
|
-
}
|
|
343
|
-
getIndexes(root) {
|
|
344
|
-
const { treeNode = {}, isTypeOnly, extName } = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options);
|
|
345
|
-
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);
|
|
346
348
|
if (!tree) {
|
|
347
349
|
return null;
|
|
348
350
|
}
|
|
349
|
-
const fileReducer = (files,
|
|
350
|
-
if (!
|
|
351
|
+
const fileReducer = (files, treeNode) => {
|
|
352
|
+
if (!treeNode.children) {
|
|
351
353
|
return [];
|
|
352
354
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
372
|
-
} else if (treeNode2.children.length === 1) {
|
|
373
|
-
const [treeNodeChild] = treeNode2.children;
|
|
374
|
-
const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
|
|
375
|
-
const importPath = treeNodeChild.data.type === "split" ? `./${treeNodeChild.data.name}/index` : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, treeNodeChild.data.name)}`;
|
|
376
|
-
const exports = [
|
|
377
|
-
{
|
|
378
|
-
path: extName ? `${importPath}${extName}` : importPath,
|
|
379
|
-
isTypeOnly
|
|
380
|
-
}
|
|
381
|
-
];
|
|
382
|
-
files.push({
|
|
383
|
-
path: indexPath,
|
|
384
|
-
baseName: "index.ts",
|
|
385
|
-
source: "",
|
|
386
|
-
exports,
|
|
387
|
-
exportable: true
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
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) => {
|
|
391
373
|
fileReducer(files, childItem);
|
|
392
374
|
});
|
|
393
375
|
return files;
|
|
@@ -397,6 +379,9 @@ var BarrelManager = class {
|
|
|
397
379
|
};
|
|
398
380
|
_options = new WeakMap();
|
|
399
381
|
|
|
382
|
+
// src/FileManager.ts
|
|
383
|
+
|
|
384
|
+
|
|
400
385
|
// ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
|
|
401
386
|
_chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
|
|
402
387
|
|
|
@@ -534,7 +519,7 @@ var PriorityQueue = class {
|
|
|
534
519
|
}
|
|
535
520
|
dequeue() {
|
|
536
521
|
const item = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).shift();
|
|
537
|
-
return _optionalChain([item, 'optionalAccess',
|
|
522
|
+
return _optionalChain([item, 'optionalAccess', _16 => _16.run]);
|
|
538
523
|
}
|
|
539
524
|
filter(options) {
|
|
540
525
|
return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).filter((element) => element.priority === options.priority).map((element) => element.run);
|
|
@@ -583,10 +568,10 @@ var PQueue = class extends import_index.default {
|
|
|
583
568
|
...options
|
|
584
569
|
};
|
|
585
570
|
if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
|
|
586
|
-
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})`);
|
|
587
572
|
}
|
|
588
573
|
if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
|
|
589
|
-
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})`);
|
|
590
575
|
}
|
|
591
576
|
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _carryoverConcurrencyCount, options.carryoverConcurrencyCount);
|
|
592
577
|
_chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0);
|
|
@@ -620,7 +605,7 @@ var PQueue = class extends import_index.default {
|
|
|
620
605
|
_chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _pending)._++;
|
|
621
606
|
_chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _intervalCount)._++;
|
|
622
607
|
try {
|
|
623
|
-
_optionalChain([options, 'access',
|
|
608
|
+
_optionalChain([options, 'access', _23 => _23.signal, 'optionalAccess', _24 => _24.throwIfAborted, 'call', _25 => _25()]);
|
|
624
609
|
let operation = function_({ signal: options.signal });
|
|
625
610
|
if (options.timeout) {
|
|
626
611
|
operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
|
|
@@ -856,22 +841,33 @@ onEvent_fn = async function(event, filter) {
|
|
|
856
841
|
};
|
|
857
842
|
|
|
858
843
|
// src/FileManager.ts
|
|
859
|
-
var
|
|
844
|
+
var _filesByPath, _files, _FileManager_instances, add_fn, addOrAppend_fn;
|
|
860
845
|
var _FileManager = class _FileManager {
|
|
861
846
|
constructor() {
|
|
862
847
|
_chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _FileManager_instances);
|
|
863
|
-
_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());
|
|
864
850
|
return this;
|
|
865
851
|
}
|
|
866
852
|
get files() {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
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)));
|
|
872
868
|
}
|
|
873
869
|
async add(...files) {
|
|
874
|
-
const promises =
|
|
870
|
+
const promises = files.map((file) => {
|
|
875
871
|
if (file.override) {
|
|
876
872
|
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, file);
|
|
877
873
|
}
|
|
@@ -883,42 +879,47 @@ var _FileManager = class _FileManager {
|
|
|
883
879
|
}
|
|
884
880
|
return resolvedFiles[0];
|
|
885
881
|
}
|
|
886
|
-
|
|
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 = {} }) {
|
|
887
903
|
const { exportType = "barrel" } = output;
|
|
888
904
|
if (exportType === false) {
|
|
889
905
|
return [];
|
|
890
906
|
}
|
|
891
907
|
const pathToBuildFrom = _path.resolve.call(void 0, root, output.path);
|
|
892
|
-
if (
|
|
908
|
+
if (_fs.trimExtName.call(void 0, pathToBuildFrom).endsWith("index")) {
|
|
893
909
|
logger.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
|
|
894
910
|
return [];
|
|
895
911
|
}
|
|
896
|
-
const exportPath = output.path.startsWith("./") ?
|
|
912
|
+
const exportPath = output.path.startsWith("./") ? output.path : `./${output.path}`;
|
|
897
913
|
const mode = _FileManager.getMode(output.path);
|
|
898
|
-
const barrelManager = new BarrelManager({
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
});
|
|
902
|
-
let files = barrelManager.getIndexes(pathToBuildFrom);
|
|
903
|
-
if (!files) {
|
|
914
|
+
const barrelManager = new BarrelManager({ ...options, extName: output.extName });
|
|
915
|
+
let indexFiles = barrelManager.getIndexes(files, pathToBuildFrom);
|
|
916
|
+
if (!indexFiles) {
|
|
904
917
|
return [];
|
|
905
918
|
}
|
|
906
|
-
if (exportType === "barrelNamed") {
|
|
907
|
-
files = files.map((file) => {
|
|
908
|
-
if (file.exports) {
|
|
909
|
-
return {
|
|
910
|
-
...file,
|
|
911
|
-
exports: barrelManager.getNamedExports(pathToBuildFrom, file.exports)
|
|
912
|
-
};
|
|
913
|
-
}
|
|
914
|
-
return file;
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
919
|
const rootPath = mode === "split" ? `${exportPath}/index${output.extName || ""}` : `${exportPath}${output.extName || ""}`;
|
|
918
920
|
const rootFile = {
|
|
919
921
|
path: _path.resolve.call(void 0, root, "index.ts"),
|
|
920
922
|
baseName: "index.ts",
|
|
921
|
-
source: "",
|
|
922
923
|
exports: [
|
|
923
924
|
output.exportAs ? {
|
|
924
925
|
name: output.exportAs,
|
|
@@ -930,170 +931,111 @@ var _FileManager = class _FileManager {
|
|
|
930
931
|
isTypeOnly: options.isTypeOnly
|
|
931
932
|
}
|
|
932
933
|
],
|
|
933
|
-
|
|
934
|
+
sources: [],
|
|
935
|
+
meta: {
|
|
936
|
+
pluginKey: plugin.key
|
|
937
|
+
}
|
|
934
938
|
};
|
|
935
|
-
if (exportType === "
|
|
936
|
-
|
|
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) => {
|
|
944
|
+
return {
|
|
945
|
+
...exportItem,
|
|
946
|
+
name: void 0
|
|
947
|
+
};
|
|
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
|
+
})]);
|
|
937
957
|
}
|
|
938
958
|
return [
|
|
939
|
-
...
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
),
|
|
947
|
-
|
|
948
|
-
...rootFile,
|
|
949
|
-
meta: meta ? meta : rootFile.meta
|
|
950
|
-
})
|
|
959
|
+
...indexFiles.map((indexFile) => {
|
|
960
|
+
return {
|
|
961
|
+
...indexFile,
|
|
962
|
+
meta: {
|
|
963
|
+
pluginKey: plugin.key
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
}),
|
|
967
|
+
rootFile
|
|
951
968
|
];
|
|
952
969
|
}
|
|
953
|
-
getCacheByUUID(UUID) {
|
|
954
|
-
let cache;
|
|
955
|
-
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).forEach((files) => {
|
|
956
|
-
cache = files.find((item) => item.id === UUID);
|
|
957
|
-
});
|
|
958
|
-
return cache;
|
|
959
|
-
}
|
|
960
|
-
get(path2) {
|
|
961
|
-
return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).get(path2);
|
|
962
|
-
}
|
|
963
|
-
remove(path2) {
|
|
964
|
-
const cacheItem = this.get(path2);
|
|
965
|
-
if (!cacheItem) {
|
|
966
|
-
return;
|
|
967
|
-
}
|
|
968
|
-
_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).delete(path2);
|
|
969
|
-
}
|
|
970
970
|
async write(...params) {
|
|
971
971
|
return _fs.write.call(void 0, ...params);
|
|
972
972
|
}
|
|
973
973
|
async read(...params) {
|
|
974
974
|
return _fs.read.call(void 0, ...params);
|
|
975
975
|
}
|
|
976
|
-
async processFiles(...params) {
|
|
977
|
-
return processFiles(...params);
|
|
978
|
-
}
|
|
979
976
|
// statics
|
|
980
|
-
static async getSource(file) {
|
|
981
|
-
return getSource(file);
|
|
982
|
-
}
|
|
983
|
-
static combineFiles(files) {
|
|
984
|
-
return combineFiles(files);
|
|
985
|
-
}
|
|
986
977
|
static getMode(path2) {
|
|
987
978
|
if (!path2) {
|
|
988
979
|
return "split";
|
|
989
980
|
}
|
|
990
981
|
return _path.extname.call(void 0, path2) ? "single" : "split";
|
|
991
982
|
}
|
|
992
|
-
static get extensions() {
|
|
993
|
-
return [".js", ".ts", ".tsx"];
|
|
994
|
-
}
|
|
995
|
-
static isJavascript(baseName) {
|
|
996
|
-
return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
|
|
997
|
-
}
|
|
998
983
|
};
|
|
999
|
-
|
|
984
|
+
_filesByPath = new WeakMap();
|
|
985
|
+
_files = new WeakMap();
|
|
1000
986
|
_FileManager_instances = new WeakSet();
|
|
1001
987
|
add_fn = async function(file) {
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
name: _chunkPZT4CTBVcjs.trimExtName.call(void 0, file.baseName),
|
|
1006
|
-
...file
|
|
1007
|
-
};
|
|
1008
|
-
if (_optionalChain([resolvedFile, 'access', _34 => _34.exports, 'optionalAccess', _35 => _35.length])) {
|
|
1009
|
-
const folder = resolvedFile.path.replace(resolvedFile.baseName, "");
|
|
1010
|
-
resolvedFile.exports = resolvedFile.exports.filter((exportItem) => {
|
|
1011
|
-
const exportedFile = this.files.find((file2) => file2.path.includes(_path.resolve.call(void 0, folder, exportItem.path)));
|
|
1012
|
-
if (exportedFile) {
|
|
1013
|
-
return exportedFile.exportable;
|
|
1014
|
-
}
|
|
1015
|
-
return true;
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
_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);
|
|
1019
991
|
return resolvedFile;
|
|
1020
992
|
};
|
|
1021
993
|
addOrAppend_fn = async function(file) {
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
_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);
|
|
1026
998
|
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, {
|
|
1027
999
|
...file,
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
exports: [...previousCache.exports || [], ...file.exports || []],
|
|
1032
|
-
env: { ...previousCache.env || {}, ...file.env || {} }
|
|
1000
|
+
sources: [...previousFile.sources || [], ...file.sources || []],
|
|
1001
|
+
imports: [...previousFile.imports || [], ...file.imports || []],
|
|
1002
|
+
exports: [...previousFile.exports || [], ...file.exports || []]
|
|
1033
1003
|
});
|
|
1034
1004
|
}
|
|
1035
1005
|
return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, file);
|
|
1036
1006
|
};
|
|
1037
1007
|
var FileManager = _FileManager;
|
|
1038
|
-
function combineFiles(files) {
|
|
1039
|
-
return files.filter(Boolean).reduce(
|
|
1040
|
-
(acc, file) => {
|
|
1041
|
-
const prevIndex = acc.findIndex((item) => item.path === file.path);
|
|
1042
|
-
if (prevIndex === -1) {
|
|
1043
|
-
return [...acc, file];
|
|
1044
|
-
}
|
|
1045
|
-
const prev = acc[prevIndex];
|
|
1046
|
-
if (prev && file.override) {
|
|
1047
|
-
acc[prevIndex] = {
|
|
1048
|
-
imports: [],
|
|
1049
|
-
exports: [],
|
|
1050
|
-
...file
|
|
1051
|
-
};
|
|
1052
|
-
return acc;
|
|
1053
|
-
}
|
|
1054
|
-
if (prev) {
|
|
1055
|
-
acc[prevIndex] = {
|
|
1056
|
-
...file,
|
|
1057
|
-
source: prev.source && file.source ? `${prev.source}
|
|
1058
|
-
${file.source}` : "",
|
|
1059
|
-
imports: [...prev.imports || [], ...file.imports || []],
|
|
1060
|
-
exports: [...prev.exports || [], ...file.exports || []],
|
|
1061
|
-
env: { ...prev.env || {}, ...file.env || {} }
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
return acc;
|
|
1065
|
-
},
|
|
1066
|
-
[]
|
|
1067
|
-
);
|
|
1068
|
-
}
|
|
1069
1008
|
async function getSource(file) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
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");
|
|
1074
1011
|
const exports = file.exports ? combineExports(file.exports) : [];
|
|
1075
|
-
const imports = file.imports &&
|
|
1012
|
+
const imports = file.imports && source ? combineImports(file.imports, exports, source) : [];
|
|
1076
1013
|
const importNodes = imports.filter((item) => {
|
|
1077
1014
|
const path2 = item.root ? _fs.getRelativePath.call(void 0, item.root, item.path) : item.path;
|
|
1078
|
-
return path2 !==
|
|
1015
|
+
return path2 !== _fs.trimExtName.call(void 0, file.path);
|
|
1079
1016
|
}).map((item) => {
|
|
1080
1017
|
const path2 = item.root ? _fs.getRelativePath.call(void 0, item.root, item.path) : item.path;
|
|
1081
|
-
return parser.
|
|
1018
|
+
return parser.createImport({
|
|
1082
1019
|
name: item.name,
|
|
1083
1020
|
path: item.extName ? `${path2}${item.extName}` : path2,
|
|
1084
1021
|
isTypeOnly: item.isTypeOnly
|
|
1085
1022
|
});
|
|
1086
1023
|
});
|
|
1087
|
-
const exportNodes = exports.map(
|
|
1088
|
-
(item)
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
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
|
+
});
|
|
1097
1039
|
}
|
|
1098
1040
|
function combineExports(exports) {
|
|
1099
1041
|
const combinedExports = _chunk67C6RBGQcjs.orderBy.call(void 0, exports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
|
|
@@ -1107,7 +1049,7 @@ function combineExports(exports) {
|
|
|
1107
1049
|
const uniquePrev = prev.findLast(
|
|
1108
1050
|
(imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
|
|
1109
1051
|
);
|
|
1110
|
-
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) {
|
|
1111
1053
|
return prev;
|
|
1112
1054
|
}
|
|
1113
1055
|
if (!prevByPath) {
|
|
@@ -1127,7 +1069,7 @@ function combineExports(exports) {
|
|
|
1127
1069
|
},
|
|
1128
1070
|
[]
|
|
1129
1071
|
);
|
|
1130
|
-
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]);
|
|
1131
1073
|
}
|
|
1132
1074
|
function combineImports(imports, exports, source) {
|
|
1133
1075
|
const combinedImports = _chunk67C6RBGQcjs.orderBy.call(void 0, imports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
|
|
@@ -1175,62 +1117,39 @@ function combineImports(imports, exports, source) {
|
|
|
1175
1117
|
},
|
|
1176
1118
|
[]
|
|
1177
1119
|
);
|
|
1178
|
-
return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedImports, [(v) => !v.isTypeOnly]
|
|
1179
|
-
}
|
|
1180
|
-
function getEnvSource(source, env) {
|
|
1181
|
-
if (!env) {
|
|
1182
|
-
return source;
|
|
1183
|
-
}
|
|
1184
|
-
const keys = Object.keys(env);
|
|
1185
|
-
if (!keys.length) {
|
|
1186
|
-
return source;
|
|
1187
|
-
}
|
|
1188
|
-
return keys.reduce((prev, key) => {
|
|
1189
|
-
const environmentValue = env[key];
|
|
1190
|
-
const replaceBy = environmentValue ? `'${_optionalChain([environmentValue, 'access', _37 => _37.replaceAll, 'call', _38 => _38('"', ""), 'optionalAccess', _39 => _39.replaceAll, 'call', _40 => _40("'", "")])}'` : "undefined";
|
|
1191
|
-
if (key.toUpperCase() !== key) {
|
|
1192
|
-
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
1193
|
-
}
|
|
1194
|
-
if (typeof replaceBy === "string") {
|
|
1195
|
-
prev = _chunkPZT4CTBVcjs.searchAndReplace.call(void 0, {
|
|
1196
|
-
text: prev.replaceAll(`process.env.${key}`, replaceBy),
|
|
1197
|
-
replaceBy,
|
|
1198
|
-
prefix: "process.env",
|
|
1199
|
-
key
|
|
1200
|
-
});
|
|
1201
|
-
prev = _chunkPZT4CTBVcjs.searchAndReplace.call(void 0, {
|
|
1202
|
-
text: prev.replaceAll(/(declare const).*\n/gi, ""),
|
|
1203
|
-
replaceBy,
|
|
1204
|
-
key
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
return prev;
|
|
1208
|
-
}, source);
|
|
1120
|
+
return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedImports, [(v) => !v.isTypeOnly]);
|
|
1209
1121
|
}
|
|
1210
|
-
var queue = new PQueue({ concurrency:
|
|
1211
|
-
async function processFiles({ dryRun, logger, files }) {
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
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
|
+
});
|
|
1218
1134
|
if (!dryRun) {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1135
|
+
const size = orderedFiles.length;
|
|
1136
|
+
logger.emit("progress_start", { id: "files", size });
|
|
1137
|
+
const promises = orderedFiles.map(async (file) => {
|
|
1138
|
+
await queue.add(async () => {
|
|
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) : "" });
|
|
1224
1142
|
});
|
|
1225
1143
|
});
|
|
1226
|
-
await Promise.all(
|
|
1227
|
-
|
|
1144
|
+
await Promise.all(promises);
|
|
1145
|
+
logger.emit("progress_stop", { id: "files" });
|
|
1228
1146
|
}
|
|
1229
|
-
return
|
|
1147
|
+
return files;
|
|
1230
1148
|
}
|
|
1231
1149
|
|
|
1232
1150
|
|
|
1233
1151
|
|
|
1234
1152
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1153
|
+
|
|
1154
|
+
exports.FileManager = FileManager; exports.getSource = getSource; exports.processFiles = processFiles;
|
|
1155
|
+
//# sourceMappingURL=chunk-DCZQYCCO.cjs.map
|