@kubb/core 1.1.6 → 1.1.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/README.md CHANGED
@@ -5,38 +5,45 @@
5
5
 
6
6
  <p>
7
7
  Core utils for other packages.
8
- </p>
8
+ </p>
9
+ <img src="https://raw.githubusercontent.com/kubb-project/kubb/main/assets/banner.png" alt="logo" height="auto" />
9
10
 
10
- <!-- Badges -->
11
- <p>
12
- <a href="https://www.npmjs.com/package/@kubb/core">
11
+ <!-- Badges -->
12
+ <p>
13
+ <a href="https://www.npmjs.com/package/@kubb/core" target="_blank">
13
14
  <img alt="npm version" src="https://img.shields.io/npm/v/@kubb/core?style=for-the-badge"/>
14
15
  </a>
15
- <a href="https://www.npmjs.com/package/@kubb/core">
16
- <img alt="npm downloads" src="https://img.shields.io/bundlephobia/min/@kubb/core?style=for-the-badge"/>
17
- </a>
18
- <a href="https://www.npmjs.com/package/@kubb/core">
16
+
17
+ <a href="https://www.npmjs.com/package/@kubb/core" target="_blank">
19
18
  <img alt="npm downloads" src="https://img.shields.io/npm/dm/@kubb/core?style=for-the-badge"/>
20
19
  </a>
21
- </p>
20
+ </p>
21
+
22
+ <p>
23
+ <a href="https://www.npmjs.com/package/@kubb/core" target="_blank">
24
+ <img alt="Minified size" src="https://img.shields.io/bundlephobia/min/@kubb/core?style=for-the-badge"/>
25
+ </a>
26
+
27
+ <a href="https://www.npmjs.com/package/@kubb/core" target="_blank">
28
+ <img alt="Coverage" src="https://img.shields.io/codecov/c/github/kubb-project/kubb?style=for-the-badge"/>
29
+ </a>
30
+
31
+ <a href="https://www.npmjs.com/package/@kubb/core" target="_blank">
32
+ <img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/kubb-project/kubb/ci.yaml?style=for-the-badge"/>
33
+ </a>
34
+
35
+
36
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
37
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
38
+ </p>
22
39
 
23
- <h4>
24
- <a href="https://codesandbox.io/s/github/kubb-project/kubb/tree/main/examples/simple">View Demo</a>
25
- <span> · </span>
26
- <a href="https://kubb.dev/" target="_blank">Documentation</a>
27
- <span> · </span>
28
- <a href="https://github.com/kubb-project/kubb/issues/">Report Bug</a>
29
- <span> · </span>
30
- <a href="https://github.com/kubb-project/kubb/issues/">Request Feature</a>
40
+ <h4>
41
+ <a href="https://codesandbox.io/s/github/kubb-project/kubb/tree/main/examples/simple" target="_blank">View Demo</a>
42
+ <span> · </span>
43
+ <a href="https://kubb.dev/" target="_blank">Documentation</a>
44
+ <span> · </span>
45
+ <a href="https://github.com/kubb-project/kubb/issues/" target="_blank">Report Bug</a>
46
+ <span> · </span>
47
+ <a href="https://github.com/kubb-project/kubb/issues/" target="_blank">Request Feature</a>
31
48
  </h4>
32
49
  </div>
33
-
34
- <br />
35
-
36
- <!-- About the Project
37
- ## :star2: About the Project
38
-
39
- <div align="center">
40
- <img src="assets/screenshot.jpg" alt="screenshot" />
41
- </div>
42
- -->
package/dist/index.cjs CHANGED
@@ -3,42 +3,22 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var module$1 = require('module');
6
- var pathParser2 = require('path');
6
+ var crypto = require('crypto');
7
7
  var fs = require('fs');
8
+ var pathParser2 = require('path');
8
9
  var changeCase = require('change-case');
9
10
  var rimraf = require('rimraf');
10
11
  var dirTree = require('directory-tree');
11
- var crypto = require('crypto');
12
12
  var tsCodegen = require('@kubb/ts-codegen');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
15
 
16
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
16
17
  var pathParser2__default = /*#__PURE__*/_interopDefault(pathParser2);
17
18
  var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
18
- var crypto__default = /*#__PURE__*/_interopDefault(crypto);
19
19
 
20
20
  module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('out.js', document.baseURI).href)));
21
21
 
22
- // src/managers/pluginManager/PluginError.ts
23
- var PluginError = class extends Error {
24
- pluginManager;
25
- constructor(message, options) {
26
- super(message, { cause: options.cause });
27
- this.pluginManager = options.pluginManager;
28
- }
29
- };
30
-
31
- // src/managers/pluginManager/ParallelPluginError.ts
32
- var ParallelPluginError = class extends Error {
33
- errors;
34
- pluginManager;
35
- constructor(message, options) {
36
- super(message, { cause: options.cause });
37
- this.errors = options.errors;
38
- this.pluginManager = options.pluginManager;
39
- }
40
- };
41
-
42
22
  // src/utils/isPromise.ts
43
23
  function isPromise(result) {
44
24
  return typeof result?.then === "function";
@@ -86,19 +66,19 @@ function createPluginCache(cache) {
86
66
  }
87
67
  };
88
68
  }
89
- function slash(path) {
69
+ function slash(path, platform = "linux") {
90
70
  const isExtendedLengthPath = /^\\\\\?\\/.test(path);
91
- if (isExtendedLengthPath) {
92
- return path;
71
+ if (isExtendedLengthPath || platform === "linux" || platform === "mac") {
72
+ return path.replace("../", "").trimEnd();
93
73
  }
94
- return path.replace(/\\/g, "/");
74
+ return path.replace(/\\/g, "/").replace("../", "").trimEnd();
95
75
  }
96
- function getRelativePath(rootDir, filePath) {
76
+ function getRelativePath(rootDir, filePath, platform = "linux") {
97
77
  if (!rootDir || !filePath) {
98
78
  throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir} ${filePath}`);
99
79
  }
100
80
  const relativePath = pathParser2__default.default.relative(rootDir, filePath);
101
- const path = slash(relativePath).replace("../", "").trimEnd();
81
+ const path = slash(relativePath, platform);
102
82
  if (path.startsWith("../")) {
103
83
  return path.replace(pathParser2__default.default.basename(path), pathParser2__default.default.basename(path, pathParser2__default.default.extname(filePath)));
104
84
  }
@@ -111,12 +91,7 @@ function getPathMode(path) {
111
91
  return pathParser2__default.default.extname(path) ? "file" : "directory";
112
92
  }
113
93
  async function read(path) {
114
- try {
115
- return fs.promises.readFile(path, { encoding: "utf8" });
116
- } catch (err) {
117
- console.error(err);
118
- throw err;
119
- }
94
+ return fs.promises.readFile(path, { encoding: "utf8" });
120
95
  }
121
96
 
122
97
  // src/utils/isURL.ts
@@ -253,10 +228,13 @@ var TreeNode = class {
253
228
  return child;
254
229
  }
255
230
  find(data) {
231
+ if (!data) {
232
+ return null;
233
+ }
256
234
  if (data === this.data) {
257
235
  return this;
258
236
  }
259
- if (this.children) {
237
+ if (this.children?.length) {
260
238
  for (let i = 0, { length } = this.children, target = null; i < length; i++) {
261
239
  target = this.children[i].find(data);
262
240
  if (target) {
@@ -266,23 +244,23 @@ var TreeNode = class {
266
244
  }
267
245
  return null;
268
246
  }
269
- leaves() {
247
+ get leaves() {
270
248
  if (!this.children || this.children.length === 0) {
271
249
  return [this];
272
250
  }
273
251
  const leaves = [];
274
252
  if (this.children) {
275
253
  for (let i = 0, { length } = this.children; i < length; i++) {
276
- leaves.push.apply(leaves, this.children[i].leaves());
254
+ leaves.push.apply(leaves, this.children[i].leaves);
277
255
  }
278
256
  }
279
257
  return leaves;
280
258
  }
281
- root() {
259
+ get root() {
282
260
  if (!this.parent) {
283
261
  return this;
284
262
  }
285
- return this.parent.root();
263
+ return this.parent.root;
286
264
  }
287
265
  forEach(callback) {
288
266
  if (typeof callback !== "function") {
@@ -297,21 +275,26 @@ var TreeNode = class {
297
275
  return this;
298
276
  }
299
277
  static build(path, options = {}) {
300
- const filteredTree = dirTree__default.default(path, { extensions: options?.extensions, exclude: options.exclude });
301
- if (!filteredTree) {
302
- return null;
303
- }
304
- const treeNode = new TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type });
305
- const recurse = (node, item) => {
306
- const subNode = node.addChild({ name: item.name, path: item.path, type: item.type });
307
- if (item.children?.length) {
308
- item.children?.forEach((child) => {
309
- recurse(subNode, child);
310
- });
278
+ try {
279
+ const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
280
+ const filteredTree = dirTree__default.default(path, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
281
+ if (!filteredTree) {
282
+ return null;
311
283
  }
312
- };
313
- filteredTree.children?.forEach((child) => recurse(treeNode, child));
314
- return treeNode;
284
+ const treeNode = new TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || getPathMode(filteredTree.path) });
285
+ const recurse = (node, item) => {
286
+ const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || getPathMode(item.path) });
287
+ if (item.children?.length) {
288
+ item.children?.forEach((child) => {
289
+ recurse(subNode, child);
290
+ });
291
+ }
292
+ };
293
+ filteredTree.children?.forEach((child) => recurse(treeNode, child));
294
+ return treeNode;
295
+ } catch (e) {
296
+ throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
297
+ }
315
298
  }
316
299
  };
317
300
 
@@ -424,76 +407,10 @@ function getStackTrace(belowFn) {
424
407
  return v8StackTrace;
425
408
  }
426
409
 
427
- // src/plugin.ts
428
- function createPlugin(factory) {
429
- return (options) => {
430
- const plugin = factory(options);
431
- if (Array.isArray(plugin)) {
432
- throw new Error("Not implemented");
433
- }
434
- if (!plugin.transform) {
435
- plugin.transform = function transform(code) {
436
- return code;
437
- };
438
- }
439
- return plugin;
440
- };
441
- }
442
- var name = "core";
443
- var definePlugin = createPlugin((options) => {
444
- const { fileManager, resolvePath, resolveName, load } = options;
445
- const api = {
446
- get config() {
447
- return options.config;
448
- },
449
- fileManager,
450
- async addFile(...files) {
451
- const trace = getStackTrace();
452
- const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
453
- if (a.name.length < b.name.length)
454
- return 1;
455
- if (a.name.length > b.name.length)
456
- return -1;
457
- return 0;
458
- });
459
- const pluginName = plugins?.[0].name;
460
- return Promise.all(
461
- files.map((file) => {
462
- const fileWithMeta = {
463
- ...file,
464
- meta: {
465
- ...file.meta || {},
466
- pluginName
467
- }
468
- };
469
- if (file.override) {
470
- return fileManager.add(fileWithMeta);
471
- }
472
- return fileManager.addOrAppend(fileWithMeta);
473
- })
474
- );
475
- },
476
- resolvePath,
477
- resolveName: (params) => {
478
- const name2 = resolveName(params);
479
- return transformReservedWord(name2);
480
- },
481
- load,
482
- cache: createPluginCache(/* @__PURE__ */ Object.create(null))
483
- };
484
- return {
485
- name,
486
- options,
487
- api,
488
- resolvePath(fileName) {
489
- const root = pathParser2__default.default.resolve(this.config.root, this.config.output.path);
490
- return pathParser2__default.default.resolve(root, fileName);
491
- },
492
- resolveName(name2) {
493
- return name2;
494
- }
495
- };
496
- });
410
+ // src/utils/uniqueId.ts
411
+ var uniqueId = ((counter) => (str = "") => `${str}${++counter}`)(0);
412
+
413
+ // src/managers/fileManager/FileManager.ts
497
414
  var FileManager = class {
498
415
  cache = /* @__PURE__ */ new Map();
499
416
  task;
@@ -585,6 +502,219 @@ ${file.source}`,
585
502
  return read(...params);
586
503
  }
587
504
  };
505
+ function writeIndexes(root, options = {}) {
506
+ const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
507
+ if (!tree) {
508
+ return null;
509
+ }
510
+ const fileReducer = (files2, currentTree) => {
511
+ if (!currentTree.children) {
512
+ return [];
513
+ }
514
+ if (currentTree.children?.length > 1) {
515
+ const path = pathParser2__default.default.resolve(currentTree.data.path, "index.ts");
516
+ const exports = currentTree.children.map((file) => {
517
+ if (!file) {
518
+ return void 0;
519
+ }
520
+ const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
521
+ if (importPath.includes("index") && path.includes("index")) {
522
+ return void 0;
523
+ }
524
+ return { path: importPath };
525
+ }).filter(Boolean);
526
+ files2.push({
527
+ path,
528
+ fileName: "index.ts",
529
+ source: "",
530
+ exports
531
+ });
532
+ } else {
533
+ currentTree.children?.forEach((child) => {
534
+ const path = pathParser2__default.default.resolve(currentTree.data.path, "index.ts");
535
+ const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
536
+ files2.push({
537
+ path,
538
+ fileName: "index.ts",
539
+ source: "",
540
+ exports: [{ path: importPath }]
541
+ });
542
+ });
543
+ }
544
+ currentTree.children.forEach((childItem) => {
545
+ fileReducer(files2, childItem);
546
+ });
547
+ return files2;
548
+ };
549
+ const files = fileReducer([], tree);
550
+ return files;
551
+ }
552
+ function combineFiles(files) {
553
+ return files.filter(Boolean).reduce((acc, curr) => {
554
+ const prevIndex = acc.findIndex((item) => item.path === curr.path);
555
+ if (prevIndex !== -1) {
556
+ const prev = acc[prevIndex];
557
+ acc[prevIndex] = {
558
+ ...curr,
559
+ source: `${prev.source}
560
+ ${curr.source}`,
561
+ imports: [...prev.imports || [], ...curr.imports || []],
562
+ exports: [...prev.exports || [], ...curr.exports || []]
563
+ };
564
+ } else {
565
+ acc.push(curr);
566
+ }
567
+ return acc;
568
+ }, []);
569
+ }
570
+ function getFileSource(file) {
571
+ let { source } = file;
572
+ if (!file.fileName.endsWith(".ts")) {
573
+ return file.source;
574
+ }
575
+ const imports = [];
576
+ const exports = [];
577
+ file.imports?.forEach((curr) => {
578
+ const existingImport = imports.find((imp) => imp.path === curr.path);
579
+ if (!existingImport) {
580
+ imports.push({
581
+ ...curr,
582
+ name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
583
+ });
584
+ }
585
+ if (existingImport && !Array.isArray(existingImport.name) && existingImport.name !== curr.name) {
586
+ imports.push(curr);
587
+ }
588
+ if (existingImport && Array.isArray(existingImport.name)) {
589
+ if (Array.isArray(curr.name)) {
590
+ existingImport.name = [.../* @__PURE__ */ new Set([...existingImport.name, ...curr.name])];
591
+ }
592
+ }
593
+ });
594
+ file.exports?.forEach((curr) => {
595
+ const exists = exports.find((imp) => imp.path === curr.path);
596
+ if (!exists) {
597
+ exports.push({
598
+ ...curr,
599
+ name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
600
+ });
601
+ }
602
+ if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
603
+ exports.push(curr);
604
+ }
605
+ if (exists && Array.isArray(exists.name)) {
606
+ if (Array.isArray(curr.name)) {
607
+ exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
608
+ }
609
+ }
610
+ });
611
+ const importNodes = imports.reduce((prev, curr) => {
612
+ return [...prev, tsCodegen.createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
613
+ }, []);
614
+ const importSource = tsCodegen.print(importNodes);
615
+ const exportNodes = exports.reduce((prev, curr) => {
616
+ return [...prev, tsCodegen.createExportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly, asAlias: curr.asAlias })];
617
+ }, []);
618
+ const exportSource = tsCodegen.print(exportNodes);
619
+ if (importSource) {
620
+ source = `${importSource}
621
+ ${source}`;
622
+ }
623
+ if (exportSource) {
624
+ source = `${exportSource}
625
+ ${source}`;
626
+ }
627
+ return source;
628
+ }
629
+ function createPlugin(factory) {
630
+ return (options) => {
631
+ const plugin = factory(options);
632
+ if (Array.isArray(plugin)) {
633
+ throw new Error("Not implemented");
634
+ }
635
+ if (!plugin.transform) {
636
+ plugin.transform = function transform(code) {
637
+ return code;
638
+ };
639
+ }
640
+ return plugin;
641
+ };
642
+ }
643
+ var name = "core";
644
+ var definePlugin = createPlugin((options) => {
645
+ const { fileManager, resolvePath, resolveName, load } = options;
646
+ const api = {
647
+ get config() {
648
+ return options.config;
649
+ },
650
+ fileManager,
651
+ async addFile(...files) {
652
+ const trace = getStackTrace();
653
+ const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
654
+ if (a.name.length < b.name.length)
655
+ return 1;
656
+ if (a.name.length > b.name.length)
657
+ return -1;
658
+ return 0;
659
+ });
660
+ const pluginName = plugins?.[0].name;
661
+ return Promise.all(
662
+ files.map((file) => {
663
+ const fileWithMeta = {
664
+ ...file,
665
+ meta: {
666
+ ...file.meta || {},
667
+ pluginName
668
+ }
669
+ };
670
+ if (file.override) {
671
+ return fileManager.add(fileWithMeta);
672
+ }
673
+ return fileManager.addOrAppend(fileWithMeta);
674
+ })
675
+ );
676
+ },
677
+ resolvePath,
678
+ resolveName: (params) => {
679
+ const name2 = resolveName(params);
680
+ return transformReservedWord(name2);
681
+ },
682
+ load,
683
+ cache: createPluginCache(/* @__PURE__ */ Object.create(null))
684
+ };
685
+ return {
686
+ name,
687
+ options,
688
+ api,
689
+ resolvePath(fileName) {
690
+ const root = pathParser2__default.default.resolve(this.config.root, this.config.output.path);
691
+ return pathParser2__default.default.resolve(root, fileName);
692
+ },
693
+ resolveName(name2) {
694
+ return name2;
695
+ }
696
+ };
697
+ });
698
+
699
+ // src/managers/pluginManager/ParallelPluginError.ts
700
+ var ParallelPluginError = class extends Error {
701
+ errors;
702
+ pluginManager;
703
+ constructor(message, options) {
704
+ super(message, { cause: options.cause });
705
+ this.errors = options.errors;
706
+ this.pluginManager = options.pluginManager;
707
+ }
708
+ };
709
+
710
+ // src/managers/pluginManager/PluginError.ts
711
+ var PluginError = class extends Error {
712
+ pluginManager;
713
+ constructor(message, options) {
714
+ super(message, { cause: options.cause });
715
+ this.pluginManager = options.pluginManager;
716
+ }
717
+ };
588
718
 
589
719
  // src/managers/pluginManager/PluginManager.ts
590
720
  var hookNames = {
@@ -942,133 +1072,6 @@ function validatePlugins(plugins, dependedPluginNames) {
942
1072
  });
943
1073
  return true;
944
1074
  }
945
- function writeIndexes(root, options) {
946
- const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
947
- if (!tree) {
948
- return void 0;
949
- }
950
- const fileReducer = (files2, item) => {
951
- if (!item.children) {
952
- return [];
953
- }
954
- if (item.children?.length > 1) {
955
- const path = pathParser2__default.default.resolve(item.data.path, "index.ts");
956
- const exports = item.children.map((file) => {
957
- if (!file) {
958
- return void 0;
959
- }
960
- const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
961
- if (importPath.includes("index") && path.includes("index")) {
962
- return void 0;
963
- }
964
- return { path: importPath };
965
- }).filter(Boolean);
966
- files2.push({
967
- path,
968
- fileName: "index.ts",
969
- source: "",
970
- exports
971
- });
972
- } else {
973
- item.children?.forEach((child) => {
974
- const path = pathParser2__default.default.resolve(item.data.path, "index.ts");
975
- const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
976
- files2.push({
977
- path,
978
- fileName: "index.ts",
979
- source: "",
980
- exports: [{ path: importPath }]
981
- });
982
- });
983
- }
984
- item.children.forEach((childItem) => {
985
- fileReducer(files2, childItem);
986
- });
987
- return files2;
988
- };
989
- const files = fileReducer([], tree);
990
- return files;
991
- }
992
- function combineFiles(files) {
993
- return files.filter(Boolean).reduce((acc, curr) => {
994
- if (!curr) {
995
- return acc;
996
- }
997
- const prevIndex = acc.findIndex((item) => item.path === curr.path);
998
- if (prevIndex !== -1) {
999
- const prev = acc[prevIndex];
1000
- acc[prevIndex] = {
1001
- ...curr,
1002
- source: `${prev.source}
1003
- ${curr.source}`,
1004
- imports: [...prev.imports || [], ...curr.imports || []],
1005
- exports: [...prev.exports || [], ...curr.exports || []]
1006
- };
1007
- } else {
1008
- acc.push(curr);
1009
- }
1010
- return acc;
1011
- }, []);
1012
- }
1013
- function getFileSource(file) {
1014
- let { source } = file;
1015
- if (!file.fileName.endsWith(".ts")) {
1016
- return file.source;
1017
- }
1018
- const imports = [];
1019
- const exports = [];
1020
- file.imports?.forEach((curr) => {
1021
- const exists = imports.find((imp) => imp.path === curr.path);
1022
- if (!exists) {
1023
- imports.push({
1024
- ...curr,
1025
- name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
1026
- });
1027
- }
1028
- if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
1029
- imports.push(curr);
1030
- }
1031
- if (exists && Array.isArray(exists.name)) {
1032
- if (Array.isArray(curr.name)) {
1033
- exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
1034
- }
1035
- }
1036
- });
1037
- file.exports?.forEach((curr) => {
1038
- const exists = exports.find((imp) => imp.path === curr.path);
1039
- if (!exists) {
1040
- exports.push({
1041
- ...curr,
1042
- name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
1043
- });
1044
- }
1045
- if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
1046
- exports.push(curr);
1047
- }
1048
- if (exists && Array.isArray(exists.name)) {
1049
- if (Array.isArray(curr.name)) {
1050
- exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
1051
- }
1052
- }
1053
- });
1054
- const importNodes = imports.reduce((prev, curr) => {
1055
- return [...prev, tsCodegen.createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
1056
- }, []);
1057
- const importSource = tsCodegen.print(importNodes);
1058
- const exportNodes = exports.reduce((prev, curr) => {
1059
- return [...prev, tsCodegen.createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
1060
- }, []);
1061
- const exportSource = tsCodegen.print(exportNodes);
1062
- if (importSource) {
1063
- source = `${importSource}
1064
- ${source}`;
1065
- }
1066
- if (exportSource) {
1067
- source = `${exportSource}
1068
- ${source}`;
1069
- }
1070
- return source;
1071
- }
1072
1075
 
1073
1076
  // src/build.ts
1074
1077
  async function transformReducer(_previousCode, result, _plugin) {
@@ -1081,7 +1084,7 @@ async function build(options) {
1081
1084
  await read(config.input.path);
1082
1085
  }
1083
1086
  } catch (e) {
1084
- throw new Error("Cannot read file defined in `input.path` or set with --input in the CLI of your Kubb config", { cause: e });
1087
+ throw new Error("Cannot read file/URL defined in `input.path` or set with --input in the CLI of your Kubb config", { cause: e });
1085
1088
  }
1086
1089
  if (config.output.clean) {
1087
1090
  await clean(config.output.path);
@@ -1197,6 +1200,7 @@ exports.read = read;
1197
1200
  exports.renderTemplate = renderTemplate;
1198
1201
  exports.timeout = timeout;
1199
1202
  exports.transformReservedWord = transformReservedWord;
1203
+ exports.uniqueId = uniqueId;
1200
1204
  exports.validatePlugins = validatePlugins;
1201
1205
  exports.write = write;
1202
1206
  exports.writeIndexes = writeIndexes;