@kubb/core 2.0.0-alpha.9 → 2.0.0-beta.10
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 +1 -1
- package/dist/index.cjs +302 -248
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -69
- package/dist/index.d.ts +72 -69
- package/dist/index.js +299 -244
- package/dist/index.js.map +1 -1
- package/dist/transformers.cjs +222 -0
- package/dist/transformers.cjs.map +1 -0
- package/dist/transformers.d.cts +55 -0
- package/dist/transformers.d.ts +55 -0
- package/dist/transformers.js +207 -0
- package/dist/transformers.js.map +1 -0
- package/dist/utils.cjs +302 -274
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +515 -67
- package/dist/utils.d.ts +515 -67
- package/dist/utils.js +303 -274
- package/dist/utils.js.map +1 -1
- package/package.json +19 -15
- package/src/BarrelManager.ts +55 -65
- package/src/FileManager.ts +100 -31
- package/src/PluginManager.ts +41 -39
- package/src/PromiseManager.ts +5 -1
- package/src/build.ts +1 -11
- package/src/index.ts +0 -1
- package/src/plugin.ts +4 -4
- package/src/transformers/casing.ts +9 -0
- package/src/transformers/createJSDocBlockText.ts +9 -0
- package/src/transformers/index.ts +36 -0
- package/src/transformers/trim.ts +7 -0
- package/src/types.ts +22 -39
- package/src/utils/FunctionParams.ts +3 -2
- package/src/utils/TreeNode.ts +6 -3
- package/src/utils/URLPath.ts +5 -5
- package/src/utils/executeStrategies.ts +14 -2
- package/src/utils/index.ts +0 -1
- package/src/SchemaGenerator.ts +0 -8
- package/src/utils/transformers/createJSDocBlockText.ts +0 -15
- package/src/utils/transformers/index.ts +0 -22
- package/src/utils/transformers/trim.ts +0 -3
- /package/src/{utils/transformers → transformers}/combineCodes.ts +0 -0
- /package/src/{utils/transformers → transformers}/escape.ts +0 -0
- /package/src/{utils/transformers → transformers}/indent.ts +0 -0
- /package/src/{utils/transformers → transformers}/nameSorter.ts +0 -0
- /package/src/{utils/transformers → transformers}/searchAndReplace.ts +0 -0
- /package/src/{utils/transformers → transformers}/transformReservedWord.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -170,6 +170,24 @@ function randomPicoColour(text, colors = defaultColours) {
|
|
|
170
170
|
}
|
|
171
171
|
return formatter(text);
|
|
172
172
|
}
|
|
173
|
+
function slash(path5, platform = "linux") {
|
|
174
|
+
const isWindowsPath = /^\\\\\?\\/.test(path5);
|
|
175
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
176
|
+
return path5.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
177
|
+
}
|
|
178
|
+
return path5.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
179
|
+
}
|
|
180
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
181
|
+
if (!rootDir || !filePath) {
|
|
182
|
+
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
183
|
+
}
|
|
184
|
+
const relativePath = path4.relative(rootDir, filePath);
|
|
185
|
+
const slashedPath = slash(relativePath, platform);
|
|
186
|
+
if (slashedPath.startsWith("../")) {
|
|
187
|
+
return slashedPath.replace(path4.basename(slashedPath), path4.basename(slashedPath, path4.extname(filePath)));
|
|
188
|
+
}
|
|
189
|
+
return `./${slashedPath.replace(path4.basename(slashedPath), path4.basename(slashedPath, path4.extname(filePath)))}`;
|
|
190
|
+
}
|
|
173
191
|
var reader = jsRuntime.switcher(
|
|
174
192
|
{
|
|
175
193
|
node: async (path5) => {
|
|
@@ -196,141 +214,30 @@ jsRuntime.switcher(
|
|
|
196
214
|
async function read(path5) {
|
|
197
215
|
return reader(path5);
|
|
198
216
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.path = path5;
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
206
|
-
* @example /pet/{petId} => /pet/:petId
|
|
207
|
-
*/
|
|
208
|
-
get URL() {
|
|
209
|
-
return this.toURLPath();
|
|
210
|
-
}
|
|
211
|
-
get isURL() {
|
|
212
|
-
try {
|
|
213
|
-
const url = new URL(this.path);
|
|
214
|
-
if (url?.href) {
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
} catch (error) {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
224
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
225
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
226
|
-
* @example /account/userID => `/account/${userId}`
|
|
227
|
-
*/
|
|
228
|
-
get template() {
|
|
229
|
-
return this.toTemplateString();
|
|
230
|
-
}
|
|
231
|
-
get object() {
|
|
232
|
-
return this.toObject();
|
|
233
|
-
}
|
|
234
|
-
get params() {
|
|
235
|
-
return this.getParams();
|
|
236
|
-
}
|
|
237
|
-
toObject({ type = "path", replacer, stringify } = {}) {
|
|
238
|
-
const object = {
|
|
239
|
-
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
240
|
-
params: this.getParams()
|
|
241
|
-
};
|
|
242
|
-
if (stringify) {
|
|
243
|
-
if (type === "template") {
|
|
244
|
-
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
245
|
-
}
|
|
246
|
-
if (object.params) {
|
|
247
|
-
return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
248
|
-
}
|
|
249
|
-
return `{ url: '${object.url}' }`;
|
|
250
|
-
}
|
|
251
|
-
return object;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
255
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
256
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
257
|
-
* @example /account/userID => `/account/${userId}`
|
|
258
|
-
*/
|
|
259
|
-
toTemplateString(replacer) {
|
|
260
|
-
const regex = /{(\w|-)*}/g;
|
|
261
|
-
const found = this.path.match(regex);
|
|
262
|
-
let newPath = this.path.replaceAll("{", "${");
|
|
263
|
-
if (found) {
|
|
264
|
-
newPath = found.reduce((prev, curr) => {
|
|
265
|
-
const pathParam = replacer ? replacer(changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
266
|
-
const replacement = `\${${pathParam}}`;
|
|
267
|
-
return prev.replace(curr, replacement);
|
|
268
|
-
}, this.path);
|
|
269
|
-
}
|
|
270
|
-
return `\`${newPath}\``;
|
|
271
|
-
}
|
|
272
|
-
getParams(replacer) {
|
|
273
|
-
const regex = /{(\w|-)*}/g;
|
|
274
|
-
const found = this.path.match(regex);
|
|
275
|
-
if (!found) {
|
|
276
|
-
return void 0;
|
|
277
|
-
}
|
|
278
|
-
const params = {};
|
|
279
|
-
found.forEach((item) => {
|
|
280
|
-
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
281
|
-
const pathParam = replacer ? replacer(changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
282
|
-
params[pathParam] = pathParam;
|
|
283
|
-
}, this.path);
|
|
284
|
-
return params;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
288
|
-
* @example /pet/{petId} => /pet/:petId
|
|
289
|
-
*/
|
|
290
|
-
toURLPath() {
|
|
291
|
-
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// src/config.ts
|
|
296
|
-
function defineConfig(options) {
|
|
297
|
-
return options;
|
|
298
|
-
}
|
|
299
|
-
function isInputPath(result) {
|
|
300
|
-
return !!result && "path" in result;
|
|
217
|
+
function camelCase(text) {
|
|
218
|
+
return changeCase.camelCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.camelCaseTransformMerge });
|
|
301
219
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
async function timeout(ms) {
|
|
305
|
-
return new Promise((resolve2) => {
|
|
306
|
-
setTimeout(() => {
|
|
307
|
-
resolve2(true);
|
|
308
|
-
}, ms);
|
|
309
|
-
});
|
|
220
|
+
function pascalCase(text) {
|
|
221
|
+
return changeCase.pascalCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.pascalCaseTransformMerge });
|
|
310
222
|
}
|
|
311
223
|
|
|
312
|
-
// src/
|
|
224
|
+
// src/transformers/combineCodes.ts
|
|
313
225
|
function combineCodes(codes) {
|
|
314
226
|
return codes.join("\n");
|
|
315
227
|
}
|
|
316
228
|
|
|
317
|
-
// src/
|
|
318
|
-
function createJSDocBlockText({ comments
|
|
229
|
+
// src/transformers/createJSDocBlockText.ts
|
|
230
|
+
function createJSDocBlockText({ comments }) {
|
|
319
231
|
const filteredComments = comments.filter(Boolean);
|
|
320
232
|
if (!filteredComments.length) {
|
|
321
233
|
return "";
|
|
322
234
|
}
|
|
323
|
-
|
|
235
|
+
return `/**
|
|
324
236
|
* ${filteredComments.join("\n * ")}
|
|
325
237
|
*/`;
|
|
326
|
-
if (newLine) {
|
|
327
|
-
return `${source}
|
|
328
|
-
`;
|
|
329
|
-
}
|
|
330
|
-
return source;
|
|
331
238
|
}
|
|
332
239
|
|
|
333
|
-
// src/
|
|
240
|
+
// src/transformers/escape.ts
|
|
334
241
|
function escape(text) {
|
|
335
242
|
return text ? text.replaceAll("`", "\\`") : "";
|
|
336
243
|
}
|
|
@@ -355,12 +262,12 @@ function jsStringEscape(input) {
|
|
|
355
262
|
});
|
|
356
263
|
}
|
|
357
264
|
|
|
358
|
-
// src/
|
|
265
|
+
// src/transformers/indent.ts
|
|
359
266
|
function createIndent(size) {
|
|
360
267
|
return Array.from({ length: size + 1 }).join(" ");
|
|
361
268
|
}
|
|
362
269
|
|
|
363
|
-
// src/
|
|
270
|
+
// src/transformers/nameSorter.ts
|
|
364
271
|
function nameSorter(a, b) {
|
|
365
272
|
if (a.name < b.name) {
|
|
366
273
|
return -1;
|
|
@@ -371,7 +278,7 @@ function nameSorter(a, b) {
|
|
|
371
278
|
return 0;
|
|
372
279
|
}
|
|
373
280
|
|
|
374
|
-
// src/
|
|
281
|
+
// src/transformers/searchAndReplace.ts
|
|
375
282
|
function searchAndReplace(options) {
|
|
376
283
|
const { text, replaceBy, prefix = "", key } = options;
|
|
377
284
|
const searchValues = options.searchValues?.(prefix, key) || [
|
|
@@ -388,7 +295,7 @@ function searchAndReplace(options) {
|
|
|
388
295
|
}, text);
|
|
389
296
|
}
|
|
390
297
|
|
|
391
|
-
// src/
|
|
298
|
+
// src/transformers/transformReservedWord.ts
|
|
392
299
|
var reservedWords = [
|
|
393
300
|
"abstract",
|
|
394
301
|
"arguments",
|
|
@@ -481,13 +388,16 @@ function transformReservedWord(word) {
|
|
|
481
388
|
return word;
|
|
482
389
|
}
|
|
483
390
|
|
|
484
|
-
// src/
|
|
391
|
+
// src/transformers/trim.ts
|
|
485
392
|
function trim(text) {
|
|
486
393
|
return text.replaceAll(/\n/g, "").trim();
|
|
487
394
|
}
|
|
395
|
+
function trimExtName(text) {
|
|
396
|
+
return text.replace(/\.[^/.]+$/, "");
|
|
397
|
+
}
|
|
488
398
|
|
|
489
|
-
// src/
|
|
490
|
-
var
|
|
399
|
+
// src/transformers/index.ts
|
|
400
|
+
var transformers_default = {
|
|
491
401
|
combineCodes,
|
|
492
402
|
escape,
|
|
493
403
|
jsStringEscape,
|
|
@@ -496,10 +406,127 @@ var transformers = {
|
|
|
496
406
|
nameSorter,
|
|
497
407
|
searchAndReplace,
|
|
498
408
|
trim,
|
|
409
|
+
trimExtName,
|
|
499
410
|
JSDoc: {
|
|
500
411
|
createJSDocBlockText
|
|
412
|
+
},
|
|
413
|
+
camelCase,
|
|
414
|
+
pascalCase
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
// src/utils/URLPath.ts
|
|
418
|
+
var URLPath = class {
|
|
419
|
+
constructor(path5) {
|
|
420
|
+
this.path = path5;
|
|
421
|
+
return this;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
425
|
+
* @example /pet/{petId} => /pet/:petId
|
|
426
|
+
*/
|
|
427
|
+
get URL() {
|
|
428
|
+
return this.toURLPath();
|
|
429
|
+
}
|
|
430
|
+
get isURL() {
|
|
431
|
+
try {
|
|
432
|
+
const url = new URL(this.path);
|
|
433
|
+
if (url?.href) {
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
} catch (error) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
443
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
444
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
445
|
+
* @example /account/userID => `/account/${userId}`
|
|
446
|
+
*/
|
|
447
|
+
get template() {
|
|
448
|
+
return this.toTemplateString();
|
|
449
|
+
}
|
|
450
|
+
get object() {
|
|
451
|
+
return this.toObject();
|
|
452
|
+
}
|
|
453
|
+
get params() {
|
|
454
|
+
return this.getParams();
|
|
455
|
+
}
|
|
456
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
457
|
+
const object = {
|
|
458
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
459
|
+
params: this.getParams()
|
|
460
|
+
};
|
|
461
|
+
if (stringify) {
|
|
462
|
+
if (type === "template") {
|
|
463
|
+
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
464
|
+
}
|
|
465
|
+
if (object.params) {
|
|
466
|
+
return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
467
|
+
}
|
|
468
|
+
return `{ url: '${object.url}' }`;
|
|
469
|
+
}
|
|
470
|
+
return object;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
474
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
475
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
476
|
+
* @example /account/userID => `/account/${userId}`
|
|
477
|
+
*/
|
|
478
|
+
toTemplateString(replacer) {
|
|
479
|
+
const regex = /{(\w|-)*}/g;
|
|
480
|
+
const found = this.path.match(regex);
|
|
481
|
+
let newPath = this.path.replaceAll("{", "${");
|
|
482
|
+
if (found) {
|
|
483
|
+
newPath = found.reduce((prev, curr) => {
|
|
484
|
+
const pathParam = replacer ? replacer(transformers_default.camelCase(curr)) : transformers_default.camelCase(curr);
|
|
485
|
+
const replacement = `\${${pathParam}}`;
|
|
486
|
+
return prev.replace(curr, replacement);
|
|
487
|
+
}, this.path);
|
|
488
|
+
}
|
|
489
|
+
return `\`${newPath}\``;
|
|
490
|
+
}
|
|
491
|
+
getParams(replacer) {
|
|
492
|
+
const regex = /{(\w|-)*}/g;
|
|
493
|
+
const found = this.path.match(regex);
|
|
494
|
+
if (!found) {
|
|
495
|
+
return void 0;
|
|
496
|
+
}
|
|
497
|
+
const params = {};
|
|
498
|
+
found.forEach((item) => {
|
|
499
|
+
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
500
|
+
const pathParam = replacer ? replacer(transformers_default.camelCase(item)) : transformers_default.camelCase(item);
|
|
501
|
+
params[pathParam] = pathParam;
|
|
502
|
+
}, this.path);
|
|
503
|
+
return params;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
507
|
+
* @example /pet/{petId} => /pet/:petId
|
|
508
|
+
*/
|
|
509
|
+
toURLPath() {
|
|
510
|
+
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
501
511
|
}
|
|
502
512
|
};
|
|
513
|
+
|
|
514
|
+
// src/config.ts
|
|
515
|
+
function defineConfig(options) {
|
|
516
|
+
return options;
|
|
517
|
+
}
|
|
518
|
+
function isInputPath(result) {
|
|
519
|
+
return !!result && "path" in result;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/utils/timeout.ts
|
|
523
|
+
async function timeout(ms) {
|
|
524
|
+
return new Promise((resolve3) => {
|
|
525
|
+
setTimeout(() => {
|
|
526
|
+
resolve3(true);
|
|
527
|
+
}, ms);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
503
530
|
async function saveCreateDirectory(path5) {
|
|
504
531
|
const passedPath = path4.dirname(path4.resolve(path5));
|
|
505
532
|
await fs2__default.default.mkdir(passedPath, { recursive: true });
|
|
@@ -650,78 +677,67 @@ var TreeNode = class _TreeNode {
|
|
|
650
677
|
var _options;
|
|
651
678
|
var BarrelManager = class {
|
|
652
679
|
constructor(options = {}) {
|
|
653
|
-
__privateAdd(this, _options,
|
|
680
|
+
__privateAdd(this, _options, void 0);
|
|
654
681
|
__privateSet(this, _options, options);
|
|
655
682
|
return this;
|
|
656
683
|
}
|
|
657
|
-
getIndexes(
|
|
658
|
-
const { treeNode = {}, isTypeOnly,
|
|
659
|
-
const
|
|
660
|
-
".ts": {
|
|
661
|
-
extensions: /\.ts/,
|
|
662
|
-
exclude: [/schemas/, /json/]
|
|
663
|
-
},
|
|
664
|
-
".json": {
|
|
665
|
-
extensions: /\.json/,
|
|
666
|
-
exclude: []
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...treeNode });
|
|
684
|
+
getIndexes(pathToBuild) {
|
|
685
|
+
const { treeNode = {}, isTypeOnly, extName } = __privateGet(this, _options);
|
|
686
|
+
const tree = TreeNode.build(pathToBuild, treeNode);
|
|
670
687
|
if (!tree) {
|
|
671
688
|
return null;
|
|
672
689
|
}
|
|
673
|
-
const fileReducer = (
|
|
674
|
-
if (!
|
|
690
|
+
const fileReducer = (files, treeNode2) => {
|
|
691
|
+
if (!treeNode2.children) {
|
|
675
692
|
return [];
|
|
676
693
|
}
|
|
677
|
-
if (
|
|
678
|
-
const indexPath = path4__default.default.resolve(
|
|
679
|
-
const exports =
|
|
680
|
-
const importPath = file.data.type === "directory" ? `./${file.data.name}/index` : `./${file.data.name
|
|
681
|
-
if (importPath.
|
|
694
|
+
if (treeNode2.children.length > 1) {
|
|
695
|
+
const indexPath = path4__default.default.resolve(treeNode2.data.path, "index.ts");
|
|
696
|
+
const exports = treeNode2.children.filter(Boolean).map((file) => {
|
|
697
|
+
const importPath = file.data.type === "directory" ? `./${file.data.name}/index` : `./${transformers_default.trimExtName(file.data.name)}`;
|
|
698
|
+
if (importPath.endsWith("index") && file.data.type === "file") {
|
|
682
699
|
return void 0;
|
|
683
700
|
}
|
|
684
701
|
return {
|
|
685
|
-
path:
|
|
702
|
+
path: extName ? `${importPath}${extName}` : importPath,
|
|
686
703
|
isTypeOnly
|
|
687
704
|
};
|
|
688
705
|
}).filter(Boolean);
|
|
689
|
-
|
|
706
|
+
files.push({
|
|
690
707
|
path: indexPath,
|
|
691
708
|
baseName: "index.ts",
|
|
692
709
|
source: "",
|
|
693
|
-
exports
|
|
694
|
-
|
|
695
|
-
|
|
710
|
+
exports,
|
|
711
|
+
meta: {
|
|
712
|
+
treeNode: treeNode2
|
|
713
|
+
}
|
|
696
714
|
});
|
|
697
|
-
} else {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
715
|
+
} else if (treeNode2.children.length === 1) {
|
|
716
|
+
const [treeNodeChild] = treeNode2.children;
|
|
717
|
+
const indexPath = path4__default.default.resolve(treeNode2.data.path, "index.ts");
|
|
718
|
+
const importPath = treeNodeChild.data.type === "directory" ? `./${treeNodeChild.data.name}/index` : `./${transformers_default.trimExtName(treeNodeChild.data.name)}`;
|
|
719
|
+
const exports = [
|
|
720
|
+
{
|
|
721
|
+
path: extName ? `${importPath}${extName}` : importPath,
|
|
722
|
+
isTypeOnly
|
|
723
|
+
}
|
|
724
|
+
];
|
|
725
|
+
files.push({
|
|
726
|
+
path: indexPath,
|
|
727
|
+
baseName: "index.ts",
|
|
728
|
+
source: "",
|
|
729
|
+
exports,
|
|
730
|
+
meta: {
|
|
731
|
+
treeNode: treeNode2
|
|
732
|
+
}
|
|
715
733
|
});
|
|
716
734
|
}
|
|
717
|
-
|
|
718
|
-
fileReducer(
|
|
735
|
+
treeNode2.children.forEach((childItem) => {
|
|
736
|
+
fileReducer(files, childItem);
|
|
719
737
|
});
|
|
720
|
-
return
|
|
738
|
+
return files;
|
|
721
739
|
};
|
|
722
|
-
|
|
723
|
-
const filteredFiles = filter ? files.filter(filter) : files;
|
|
724
|
-
return map ? filteredFiles.map(map) : filteredFiles;
|
|
740
|
+
return fileReducer([], tree).reverse();
|
|
725
741
|
}
|
|
726
742
|
};
|
|
727
743
|
_options = new WeakMap();
|
|
@@ -730,7 +746,7 @@ _options = new WeakMap();
|
|
|
730
746
|
exports.KubbFile = void 0;
|
|
731
747
|
((KubbFile2) => {
|
|
732
748
|
})(exports.KubbFile || (exports.KubbFile = {}));
|
|
733
|
-
var _cache, _task, _isWriting, _timeout, _queue, _validate,
|
|
749
|
+
var _cache, _task, _isWriting, _timeout, _queue, _validate, _add, add_fn, _addOrAppend, addOrAppend_fn;
|
|
734
750
|
var _FileManager = class _FileManager {
|
|
735
751
|
constructor(options) {
|
|
736
752
|
__privateAdd(this, _validate);
|
|
@@ -763,7 +779,6 @@ var _FileManager = class _FileManager {
|
|
|
763
779
|
}
|
|
764
780
|
async add(...files) {
|
|
765
781
|
const promises = files.map((file) => {
|
|
766
|
-
__privateMethod(this, _validate, validate_fn).call(this, file);
|
|
767
782
|
if (file.override) {
|
|
768
783
|
return __privateMethod(this, _add, add_fn).call(this, file);
|
|
769
784
|
}
|
|
@@ -775,12 +790,37 @@ var _FileManager = class _FileManager {
|
|
|
775
790
|
}
|
|
776
791
|
return resolvedFiles[0];
|
|
777
792
|
}
|
|
778
|
-
async addIndexes({ root,
|
|
779
|
-
const
|
|
780
|
-
|
|
793
|
+
async addIndexes({ root, output, meta, options = {} }) {
|
|
794
|
+
const { exportType = "barrel" } = output;
|
|
795
|
+
if (!exportType) {
|
|
796
|
+
return void 0;
|
|
797
|
+
}
|
|
798
|
+
const exportPath = output.path.startsWith("./") ? output.path : `./${output.path}`;
|
|
799
|
+
const barrelManager = new BarrelManager({ extName: output.extName, ...options });
|
|
800
|
+
const files = barrelManager.getIndexes(path4.resolve(root, output.path));
|
|
781
801
|
if (!files) {
|
|
782
802
|
return void 0;
|
|
783
803
|
}
|
|
804
|
+
const rootFile = {
|
|
805
|
+
path: path4.resolve(root, "index.ts"),
|
|
806
|
+
baseName: "index.ts",
|
|
807
|
+
source: "",
|
|
808
|
+
exports: [
|
|
809
|
+
output.exportAs ? {
|
|
810
|
+
name: output.exportAs,
|
|
811
|
+
asAlias: true,
|
|
812
|
+
path: exportPath,
|
|
813
|
+
isTypeOnly: options.isTypeOnly
|
|
814
|
+
} : {
|
|
815
|
+
path: exportPath,
|
|
816
|
+
isTypeOnly: options.isTypeOnly
|
|
817
|
+
}
|
|
818
|
+
]
|
|
819
|
+
};
|
|
820
|
+
await __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
|
|
821
|
+
...rootFile,
|
|
822
|
+
meta: meta ? meta : rootFile.meta
|
|
823
|
+
});
|
|
784
824
|
return await Promise.all(
|
|
785
825
|
files.map((file) => {
|
|
786
826
|
return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
|
|
@@ -827,9 +867,22 @@ var _FileManager = class _FileManager {
|
|
|
827
867
|
}
|
|
828
868
|
const exports = file.exports ? combineExports(file.exports) : [];
|
|
829
869
|
const imports = file.imports ? combineImports(file.imports, exports, file.source) : [];
|
|
830
|
-
const importNodes = imports.
|
|
870
|
+
const importNodes = imports.filter((item) => {
|
|
871
|
+
return item.path !== transformers_default.trimExtName(file.path);
|
|
872
|
+
}).map((item) => {
|
|
873
|
+
return factory__namespace.createImportDeclaration({
|
|
874
|
+
name: item.name,
|
|
875
|
+
path: item.root ? getRelativePath(item.root, item.path) : item.path,
|
|
876
|
+
isTypeOnly: item.isTypeOnly
|
|
877
|
+
});
|
|
878
|
+
});
|
|
831
879
|
const exportNodes = exports.map(
|
|
832
|
-
(item) => factory__namespace.createExportDeclaration({
|
|
880
|
+
(item) => factory__namespace.createExportDeclaration({
|
|
881
|
+
name: item.name,
|
|
882
|
+
path: item.path,
|
|
883
|
+
isTypeOnly: item.isTypeOnly,
|
|
884
|
+
asAlias: item.asAlias
|
|
885
|
+
})
|
|
833
886
|
);
|
|
834
887
|
return [parser.print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
|
|
835
888
|
}
|
|
@@ -880,18 +933,10 @@ _isWriting = new WeakMap();
|
|
|
880
933
|
_timeout = new WeakMap();
|
|
881
934
|
_queue = new WeakMap();
|
|
882
935
|
_validate = new WeakSet();
|
|
883
|
-
validate_fn = function(file) {
|
|
884
|
-
if (!file.validate) {
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {
|
|
888
|
-
throw new Error(`${file.path} should end with the baseName ${file.baseName}`);
|
|
889
|
-
}
|
|
890
|
-
};
|
|
891
936
|
_add = new WeakSet();
|
|
892
937
|
add_fn = async function(file) {
|
|
893
938
|
const controller = new AbortController();
|
|
894
|
-
const resolvedFile = { id: crypto2__default.default.randomUUID(), ...file };
|
|
939
|
+
const resolvedFile = { id: crypto2__default.default.randomUUID(), name: transformers_default.trimExtName(file.baseName), ...file };
|
|
895
940
|
__privateGet(this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
896
941
|
if (__privateGet(this, _queue)) {
|
|
897
942
|
await __privateGet(this, _queue).run(
|
|
@@ -964,7 +1009,7 @@ function combineImports(imports, exports, source) {
|
|
|
964
1009
|
return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
|
|
965
1010
|
};
|
|
966
1011
|
if (Array.isArray(name)) {
|
|
967
|
-
name = name.filter((item) => hasImportInSource(item));
|
|
1012
|
+
name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
|
|
968
1013
|
}
|
|
969
1014
|
const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
|
|
970
1015
|
const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
|
|
@@ -1010,8 +1055,8 @@ function getEnvSource(source, env) {
|
|
|
1010
1055
|
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
1011
1056
|
}
|
|
1012
1057
|
if (typeof replaceBy === "string") {
|
|
1013
|
-
prev =
|
|
1014
|
-
prev =
|
|
1058
|
+
prev = transformers_default.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
|
|
1059
|
+
prev = transformers_default.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
|
|
1015
1060
|
`, "ig"), ""), replaceBy, key });
|
|
1016
1061
|
}
|
|
1017
1062
|
return prev;
|
|
@@ -1050,8 +1095,8 @@ var Queue = class {
|
|
|
1050
1095
|
__privateSet(this, _debug, debug);
|
|
1051
1096
|
}
|
|
1052
1097
|
run(job, options = { controller: new AbortController(), name: crypto2__default.default.randomUUID(), description: "" }) {
|
|
1053
|
-
return new Promise((
|
|
1054
|
-
const item = { reject, resolve:
|
|
1098
|
+
return new Promise((resolve3, reject) => {
|
|
1099
|
+
const item = { reject, resolve: resolve3, job, name: options.name, description: options.description || options.name };
|
|
1055
1100
|
options.controller?.signal.addEventListener("abort", () => {
|
|
1056
1101
|
__privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
|
|
1057
1102
|
reject("Aborted");
|
|
@@ -1061,8 +1106,8 @@ var Queue = class {
|
|
|
1061
1106
|
});
|
|
1062
1107
|
}
|
|
1063
1108
|
runSync(job, options = { controller: new AbortController(), name: crypto2__default.default.randomUUID(), description: "" }) {
|
|
1064
|
-
new Promise((
|
|
1065
|
-
const item = { reject, resolve:
|
|
1109
|
+
new Promise((resolve3, reject) => {
|
|
1110
|
+
const item = { reject, resolve: resolve3, job, name: options.name, description: options.description || options.name };
|
|
1066
1111
|
options.controller?.signal.addEventListener("abort", () => {
|
|
1067
1112
|
__privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
|
|
1068
1113
|
});
|
|
@@ -1089,13 +1134,13 @@ work_fn = function() {
|
|
|
1089
1134
|
__privateWrapper(this, _workerCount)._++;
|
|
1090
1135
|
let entry;
|
|
1091
1136
|
while (entry = __privateGet(this, _queue2).shift()) {
|
|
1092
|
-
const { reject, resolve:
|
|
1137
|
+
const { reject, resolve: resolve3, job, name, description } = entry;
|
|
1093
1138
|
if (__privateGet(this, _debug)) {
|
|
1094
1139
|
perf_hooks.performance.mark(name + "_start");
|
|
1095
1140
|
}
|
|
1096
1141
|
job().then((result) => {
|
|
1097
1142
|
this.eventEmitter.emit("jobDone", result);
|
|
1098
|
-
|
|
1143
|
+
resolve3(result);
|
|
1099
1144
|
if (__privateGet(this, _debug)) {
|
|
1100
1145
|
perf_hooks.performance.mark(name + "_stop");
|
|
1101
1146
|
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
@@ -1169,8 +1214,7 @@ var definePlugin = createPlugin((options) => {
|
|
|
1169
1214
|
return {
|
|
1170
1215
|
name: pluginName,
|
|
1171
1216
|
options,
|
|
1172
|
-
key: ["
|
|
1173
|
-
kind: "controller",
|
|
1217
|
+
key: ["core"],
|
|
1174
1218
|
api() {
|
|
1175
1219
|
return {
|
|
1176
1220
|
get config() {
|
|
@@ -1237,6 +1281,9 @@ function hookFirst(promises, nullCheck = (state) => state !== null) {
|
|
|
1237
1281
|
}
|
|
1238
1282
|
return promise;
|
|
1239
1283
|
}
|
|
1284
|
+
function hookParallel(promises) {
|
|
1285
|
+
return Promise.allSettled(promises.filter(Boolean).map((promise) => promise()));
|
|
1286
|
+
}
|
|
1240
1287
|
|
|
1241
1288
|
// src/PromiseManager.ts
|
|
1242
1289
|
var _options2;
|
|
@@ -1253,6 +1300,9 @@ var PromiseManager = class {
|
|
|
1253
1300
|
if (strategy === "first") {
|
|
1254
1301
|
return hookFirst(promises, __privateGet(this, _options2).nullCheck);
|
|
1255
1302
|
}
|
|
1303
|
+
if (strategy === "parallel") {
|
|
1304
|
+
return hookParallel(promises);
|
|
1305
|
+
}
|
|
1256
1306
|
throw new Error(`${strategy} not implemented`);
|
|
1257
1307
|
}
|
|
1258
1308
|
};
|
|
@@ -1300,11 +1350,14 @@ var PluginManager = class {
|
|
|
1300
1350
|
hookName: "resolvePath",
|
|
1301
1351
|
parameters: [params.baseName, params.directory, params.options]
|
|
1302
1352
|
});
|
|
1303
|
-
if (paths && paths?.length > 1) {
|
|
1304
|
-
|
|
1353
|
+
if (paths && paths?.length > 1 && this.logger.logLevel === LogLevel.debug) {
|
|
1354
|
+
this.logger.warn(
|
|
1305
1355
|
`Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1306
1356
|
|
|
1307
|
-
Paths: ${JSON.stringify(paths, void 0, 2)}
|
|
1357
|
+
Paths: ${JSON.stringify(paths, void 0, 2)}
|
|
1358
|
+
|
|
1359
|
+
Falling back on the first item.
|
|
1360
|
+
`
|
|
1308
1361
|
);
|
|
1309
1362
|
}
|
|
1310
1363
|
return paths?.at(0);
|
|
@@ -1321,11 +1374,14 @@ Paths: ${JSON.stringify(paths, void 0, 2)}`
|
|
|
1321
1374
|
hookName: "resolveName",
|
|
1322
1375
|
parameters: [params.name, params.type]
|
|
1323
1376
|
});
|
|
1324
|
-
if (names && names?.length > 1) {
|
|
1325
|
-
|
|
1377
|
+
if (names && names?.length > 1 && this.logger.logLevel === LogLevel.debug) {
|
|
1378
|
+
this.logger.warn(
|
|
1326
1379
|
`Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1327
1380
|
|
|
1328
|
-
Names: ${JSON.stringify(names, void 0, 2)}
|
|
1381
|
+
Names: ${JSON.stringify(names, void 0, 2)}
|
|
1382
|
+
|
|
1383
|
+
Falling back on the first item.
|
|
1384
|
+
`
|
|
1329
1385
|
);
|
|
1330
1386
|
}
|
|
1331
1387
|
return transformReservedWord(names?.at(0) || params.name);
|
|
@@ -1457,14 +1513,10 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1457
1513
|
hookName,
|
|
1458
1514
|
parameters
|
|
1459
1515
|
}) {
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
parallelPromises.push(promise);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
const results = await Promise.allSettled(parallelPromises);
|
|
1516
|
+
const promises = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
|
|
1517
|
+
return () => __privateMethod(this, _execute, execute_fn).call(this, { strategy: "hookParallel", hookName, parameters, plugin });
|
|
1518
|
+
});
|
|
1519
|
+
const results = await __privateGet(this, _promiseManager).run("parallel", promises);
|
|
1468
1520
|
results.forEach((result, index) => {
|
|
1469
1521
|
if (isPromiseRejectedResult(result)) {
|
|
1470
1522
|
const plugin = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)[index];
|
|
@@ -1512,20 +1564,19 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1512
1564
|
}
|
|
1513
1565
|
getPluginsByKey(hookName, pluginKey) {
|
|
1514
1566
|
const plugins = [...this.plugins];
|
|
1515
|
-
const [
|
|
1567
|
+
const [searchPluginName, searchIdentifier] = pluginKey;
|
|
1516
1568
|
const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
|
|
1517
|
-
const [
|
|
1569
|
+
const [name, identifier] = item.key;
|
|
1518
1570
|
const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
|
|
1519
|
-
const kindCheck = kind === searchKind;
|
|
1520
1571
|
const nameCheck = name === searchPluginName;
|
|
1521
1572
|
if (searchIdentifier) {
|
|
1522
|
-
return identifierCheck &&
|
|
1573
|
+
return identifierCheck && nameCheck;
|
|
1523
1574
|
}
|
|
1524
|
-
return
|
|
1575
|
+
return nameCheck;
|
|
1525
1576
|
});
|
|
1526
1577
|
if (!pluginByPluginName?.length) {
|
|
1527
1578
|
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
|
|
1528
|
-
if (this.logger.logLevel ===
|
|
1579
|
+
if (this.logger.logLevel === LogLevel.debug) {
|
|
1529
1580
|
if (corePlugin) {
|
|
1530
1581
|
this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`);
|
|
1531
1582
|
} else {
|
|
@@ -1553,7 +1604,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1553
1604
|
}
|
|
1554
1605
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1555
1606
|
static get hooks() {
|
|
1556
|
-
return ["
|
|
1607
|
+
return ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
1557
1608
|
}
|
|
1558
1609
|
};
|
|
1559
1610
|
_core = new WeakMap();
|
|
@@ -1563,7 +1614,7 @@ _getSortedPlugins = new WeakSet();
|
|
|
1563
1614
|
getSortedPlugins_fn = function(hookName) {
|
|
1564
1615
|
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
1565
1616
|
if (hookName) {
|
|
1566
|
-
if (this.logger.logLevel ===
|
|
1617
|
+
if (this.logger.logLevel === LogLevel.info) {
|
|
1567
1618
|
const containsHookName = plugins.some((item) => item[hookName]);
|
|
1568
1619
|
if (!containsHookName) {
|
|
1569
1620
|
this.logger.warn(`No hook ${hookName} found`);
|
|
@@ -1571,7 +1622,23 @@ getSortedPlugins_fn = function(hookName) {
|
|
|
1571
1622
|
}
|
|
1572
1623
|
return plugins.filter((item) => item[hookName]);
|
|
1573
1624
|
}
|
|
1574
|
-
return plugins
|
|
1625
|
+
return plugins.map((plugin) => {
|
|
1626
|
+
if (plugin.pre) {
|
|
1627
|
+
const isValid = plugin.pre.every((pluginName2) => plugins.find((pluginToFind) => pluginToFind.name === pluginName2));
|
|
1628
|
+
if (!isValid) {
|
|
1629
|
+
throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
return plugin;
|
|
1633
|
+
}).sort((a, b) => {
|
|
1634
|
+
if (b.pre?.includes(a.name)) {
|
|
1635
|
+
return 1;
|
|
1636
|
+
}
|
|
1637
|
+
if (b.post?.includes(a.name)) {
|
|
1638
|
+
return -1;
|
|
1639
|
+
}
|
|
1640
|
+
return 0;
|
|
1641
|
+
});
|
|
1575
1642
|
};
|
|
1576
1643
|
_addExecutedToCallStack = new WeakSet();
|
|
1577
1644
|
addExecutedToCallStack_fn = function(executer) {
|
|
@@ -1662,7 +1729,7 @@ _parse = new WeakSet();
|
|
|
1662
1729
|
parse_fn = function(plugin, pluginManager, context) {
|
|
1663
1730
|
const usedPluginNames = __privateGet(pluginManager, _usedPluginNames);
|
|
1664
1731
|
setUniqueName(plugin.name, usedPluginNames);
|
|
1665
|
-
const key =
|
|
1732
|
+
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
1666
1733
|
if (plugin.name !== "core" && usedPluginNames[plugin.name] >= 2) {
|
|
1667
1734
|
pluginManager.logger.warn("Using multiple of the same plugin is an experimental feature");
|
|
1668
1735
|
}
|
|
@@ -1750,7 +1817,7 @@ async function setup(options) {
|
|
|
1750
1817
|
if (logger.logLevel === LogLevel.info) {
|
|
1751
1818
|
logger.spinner.start(`\u{1F4BE} Writing`);
|
|
1752
1819
|
}
|
|
1753
|
-
if (logger.logLevel ===
|
|
1820
|
+
if (logger.logLevel === LogLevel.debug) {
|
|
1754
1821
|
logger.info(`PluginKey ${pc3__default.default.dim(JSON.stringify(plugin.key))}
|
|
1755
1822
|
with source
|
|
1756
1823
|
|
|
@@ -1785,10 +1852,6 @@ ${code}`);
|
|
|
1785
1852
|
async function build(options) {
|
|
1786
1853
|
const pluginManager = await setup(options);
|
|
1787
1854
|
const { fileManager, logger } = pluginManager;
|
|
1788
|
-
await pluginManager.hookParallel({
|
|
1789
|
-
hookName: "validate",
|
|
1790
|
-
parameters: [pluginManager.plugins]
|
|
1791
|
-
});
|
|
1792
1855
|
await pluginManager.hookParallel({
|
|
1793
1856
|
hookName: "buildStart",
|
|
1794
1857
|
parameters: [options.config]
|
|
@@ -1804,10 +1867,6 @@ async function safeBuild(options) {
|
|
|
1804
1867
|
const pluginManager = await setup(options);
|
|
1805
1868
|
const { fileManager, logger } = pluginManager;
|
|
1806
1869
|
try {
|
|
1807
|
-
await pluginManager.hookParallel({
|
|
1808
|
-
hookName: "validate",
|
|
1809
|
-
parameters: [pluginManager.plugins]
|
|
1810
|
-
});
|
|
1811
1870
|
await pluginManager.hookParallel({
|
|
1812
1871
|
hookName: "buildStart",
|
|
1813
1872
|
parameters: [options.config]
|
|
@@ -1919,18 +1978,18 @@ function pLimit(concurrency) {
|
|
|
1919
1978
|
queue.dequeue()();
|
|
1920
1979
|
}
|
|
1921
1980
|
};
|
|
1922
|
-
const run = async (fn,
|
|
1981
|
+
const run = async (fn, resolve3, args) => {
|
|
1923
1982
|
activeCount++;
|
|
1924
1983
|
const result = (async () => fn(...args))();
|
|
1925
|
-
|
|
1984
|
+
resolve3(result);
|
|
1926
1985
|
try {
|
|
1927
1986
|
await result;
|
|
1928
1987
|
} catch {
|
|
1929
1988
|
}
|
|
1930
1989
|
next();
|
|
1931
1990
|
};
|
|
1932
|
-
const enqueue = (fn,
|
|
1933
|
-
queue.enqueue(run.bind(void 0, fn,
|
|
1991
|
+
const enqueue = (fn, resolve3, args) => {
|
|
1992
|
+
queue.enqueue(run.bind(void 0, fn, resolve3, args));
|
|
1934
1993
|
(async () => {
|
|
1935
1994
|
await Promise.resolve();
|
|
1936
1995
|
if (activeCount < concurrency && queue.size > 0) {
|
|
@@ -1938,8 +1997,8 @@ function pLimit(concurrency) {
|
|
|
1938
1997
|
}
|
|
1939
1998
|
})();
|
|
1940
1999
|
};
|
|
1941
|
-
const generator = (fn, ...args) => new Promise((
|
|
1942
|
-
enqueue(fn,
|
|
2000
|
+
const generator = (fn, ...args) => new Promise((resolve3) => {
|
|
2001
|
+
enqueue(fn, resolve3, args);
|
|
1943
2002
|
});
|
|
1944
2003
|
Object.defineProperties(generator, {
|
|
1945
2004
|
activeCount: {
|
|
@@ -2249,10 +2308,6 @@ match_fn = function(packageJSON, dependency) {
|
|
|
2249
2308
|
__privateAdd(_PackageManager, _cache2, {});
|
|
2250
2309
|
var PackageManager = _PackageManager;
|
|
2251
2310
|
|
|
2252
|
-
// src/SchemaGenerator.ts
|
|
2253
|
-
var SchemaGenerator = class extends Generator {
|
|
2254
|
-
};
|
|
2255
|
-
|
|
2256
2311
|
// src/index.ts
|
|
2257
2312
|
var src_default = build;
|
|
2258
2313
|
|
|
@@ -2261,7 +2316,6 @@ exports.Generator = Generator;
|
|
|
2261
2316
|
exports.PackageManager = PackageManager;
|
|
2262
2317
|
exports.PluginManager = PluginManager;
|
|
2263
2318
|
exports.PromiseManager = PromiseManager;
|
|
2264
|
-
exports.SchemaGenerator = SchemaGenerator;
|
|
2265
2319
|
exports.ValidationPluginError = ValidationPluginError;
|
|
2266
2320
|
exports.Warning = Warning;
|
|
2267
2321
|
exports.build = build;
|