@kubb/core 1.15.0-canary.20231027T174910 → 1.15.0-canary.20231027T185539

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/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import mod, { createRequire } from 'module';
2
2
  import pc3 from 'picocolors';
3
+ export { default as pc } from 'picocolors';
4
+ import crypto from 'crypto';
3
5
  import fs2, { remove } from 'fs-extra';
4
- import seedrandom from 'seedrandom';
5
- import { switcher } from 'js-runtime';
6
6
  import { camelCase, camelCaseTransformMerge } from 'change-case';
7
- import crypto2 from 'crypto';
8
- import path, { resolve, dirname, extname } from 'path';
9
- import { print } from '@kubb/parser';
10
- import * as factory from '@kubb/parser/factory';
11
- import isEqual from 'lodash.isequal';
12
7
  import { orderBy } from 'natural-orderby';
8
+ import { performance } from 'perf_hooks';
9
+ import seedrandom from 'seedrandom';
10
+ import pathParser from 'path';
11
+ import { switcher } from 'js-runtime';
13
12
  import dirTree from 'directory-tree';
13
+ import { createImportDeclaration, print, createExportDeclaration } from '@kubb/parser';
14
+ import isEqual from 'lodash.isequal';
14
15
  import { EventEmitter as EventEmitter$1 } from 'events';
15
- import { performance } from 'perf_hooks';
16
16
  import os from 'os';
17
17
  import { pathToFileURL } from 'url';
18
18
  import { findUp, findUpSync } from 'find-up';
@@ -27,45 +27,110 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
27
27
  return require.apply(this, arguments);
28
28
  throw Error('Dynamic require of "' + x + '" is not supported');
29
29
  });
30
- var __accessCheck = (obj, member, msg) => {
31
- if (!member.has(obj))
32
- throw TypeError("Cannot " + msg);
33
- };
34
- var __privateGet = (obj, member, getter) => {
35
- __accessCheck(obj, member, "read from private field");
36
- return getter ? getter.call(obj) : member.get(obj);
37
- };
38
- var __privateAdd = (obj, member, value) => {
39
- if (member.has(obj))
40
- throw TypeError("Cannot add the same private member more than once");
41
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
42
- };
43
- var __privateSet = (obj, member, value, setter) => {
44
- __accessCheck(obj, member, "write to private field");
45
- setter ? setter.call(obj, value) : member.set(obj, value);
46
- return value;
47
- };
48
- var __privateWrapper = (obj, member, setter, getter) => ({
49
- set _(value) {
50
- __privateSet(obj, member, value, setter);
51
- },
52
- get _() {
53
- return __privateGet(obj, member, getter);
30
+
31
+ // src/utils/cache.ts
32
+ function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
33
+ return {
34
+ set(id, value) {
35
+ Store[id] = [0, value];
36
+ },
37
+ get(id) {
38
+ const item = Store[id];
39
+ if (!item) {
40
+ return null;
41
+ }
42
+ item[0] = 0;
43
+ return item[1];
44
+ },
45
+ has(id) {
46
+ const item = Store[id];
47
+ if (!item) {
48
+ return false;
49
+ }
50
+ item[0] = 0;
51
+ return true;
52
+ },
53
+ delete(id) {
54
+ return delete Store[id];
55
+ }
56
+ };
57
+ }
58
+ async function clean(path) {
59
+ return remove(path);
60
+ }
61
+ var FunctionParams = class {
62
+ type;
63
+ items = [];
64
+ constructor(type) {
65
+ this.type = type;
66
+ return this;
67
+ }
68
+ add(item) {
69
+ if (!item) {
70
+ return this;
71
+ }
72
+ if (Array.isArray(item)) {
73
+ item.filter(Boolean).forEach((it) => this.items.push(it));
74
+ return this;
75
+ }
76
+ this.items.push(item);
77
+ return this;
78
+ }
79
+ toString() {
80
+ const sortedData = orderBy(this.items.filter(Boolean), [(v) => !v.default, (v) => v.required ?? true], ["desc", "desc"]);
81
+ return sortedData.filter(({ enabled = true }) => enabled).reduce((acc, { name, type, required = true, ...rest }) => {
82
+ if (!name) {
83
+ acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
84
+ return acc;
85
+ }
86
+ const parameterName = name.startsWith("{") ? name : camelCase(name, { delimiter: "", transform: camelCaseTransformMerge });
87
+ if (type) {
88
+ if (required) {
89
+ acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
90
+ } else {
91
+ acc.push(`${parameterName}?: ${type}`);
92
+ }
93
+ } else {
94
+ acc.push(`${parameterName}`);
95
+ }
96
+ return acc;
97
+ }, []).join(", ");
54
98
  }
55
- });
56
- var __privateMethod = (obj, member, method) => {
57
- __accessCheck(obj, member, "access private method");
58
- return method;
59
99
  };
60
- async function clean(path3) {
61
- return remove(path3);
100
+
101
+ // src/utils/getUniqueName.ts
102
+ function getUniqueName(originalName, data) {
103
+ let used = data[originalName] || 0;
104
+ if (used) {
105
+ data[originalName] = ++used;
106
+ originalName += used;
107
+ }
108
+ data[originalName] = 1;
109
+ return originalName;
62
110
  }
63
- var LogLevel = {
64
- silent: "silent",
65
- info: "info",
66
- debug: "debug"
67
- };
68
- function createLogger({ logLevel, name, spinner }) {
111
+
112
+ // src/utils/isPromise.ts
113
+ function isPromise(result) {
114
+ return typeof result?.then === "function";
115
+ }
116
+ function isPromiseFulfilledResult(result) {
117
+ return result.status === "fulfilled";
118
+ }
119
+ function isPromiseRejectedResult(result) {
120
+ return result.status === "rejected";
121
+ }
122
+
123
+ // src/utils/jsdoc.ts
124
+ function createJSDocBlockText({ comments }) {
125
+ const filteredComments = comments.filter(Boolean);
126
+ if (!filteredComments.length) {
127
+ return "";
128
+ }
129
+ return `/**
130
+ * ${filteredComments.join("\n * ")}
131
+ */`;
132
+ }
133
+ function createLogger(spinner) {
69
134
  const logs = [];
70
135
  const log = (message) => {
71
136
  if (message && spinner) {
@@ -91,8 +156,6 @@ function createLogger({ logLevel, name, spinner }) {
91
156
  }
92
157
  };
93
158
  const logger = {
94
- name,
95
- logLevel,
96
159
  log,
97
160
  error,
98
161
  warn,
@@ -102,6 +165,75 @@ function createLogger({ logLevel, name, spinner }) {
102
165
  };
103
166
  return logger;
104
167
  }
168
+
169
+ // src/utils/nameSorter.ts
170
+ function nameSorter(a, b) {
171
+ if (a.name < b.name) {
172
+ return -1;
173
+ }
174
+ if (a.name > b.name) {
175
+ return 1;
176
+ }
177
+ return 0;
178
+ }
179
+ var Queue = class {
180
+ #queue = [];
181
+ #workerCount = 0;
182
+ #maxParallel;
183
+ #debug = false;
184
+ constructor(maxParallel, debug = false) {
185
+ this.#maxParallel = maxParallel;
186
+ this.#debug = debug;
187
+ }
188
+ run(job, options = { controller: new AbortController(), name: crypto.randomUUID(), description: "" }) {
189
+ return new Promise((resolve, reject) => {
190
+ const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
191
+ options.controller?.signal.addEventListener("abort", () => {
192
+ this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
193
+ reject("Aborted");
194
+ });
195
+ this.#queue.push(item);
196
+ this.#work();
197
+ });
198
+ }
199
+ runSync(job, options = { controller: new AbortController(), name: crypto.randomUUID(), description: "" }) {
200
+ new Promise((resolve, reject) => {
201
+ const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
202
+ options.controller?.signal.addEventListener("abort", () => {
203
+ this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
204
+ });
205
+ this.#queue.push(item);
206
+ this.#work();
207
+ });
208
+ }
209
+ get hasJobs() {
210
+ return this.#workerCount > 0 || this.#queue.length > 0;
211
+ }
212
+ get count() {
213
+ return this.#workerCount;
214
+ }
215
+ #work() {
216
+ if (this.#workerCount >= this.#maxParallel) {
217
+ return;
218
+ }
219
+ this.#workerCount++;
220
+ let entry;
221
+ while (entry = this.#queue.shift()) {
222
+ const { reject, resolve, job, name, description } = entry;
223
+ if (this.#debug) {
224
+ performance.mark(name + "_start");
225
+ }
226
+ job().then((result) => {
227
+ resolve(result);
228
+ if (this.#debug) {
229
+ performance.mark(name + "_stop");
230
+ performance.measure(description, name + "_start", name + "_stop");
231
+ }
232
+ }).catch((err) => reject(err));
233
+ }
234
+ this.#workerCount--;
235
+ }
236
+ };
105
237
  var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
106
238
  function randomColour(text, colours = defaultColours) {
107
239
  if (!text) {
@@ -128,22 +260,46 @@ function randomPicoColour(text, colors = defaultColours) {
128
260
  }
129
261
  return formatter(text);
130
262
  }
263
+ function slash(path, platform = "linux") {
264
+ const isWindowsPath = /^\\\\\?\\/.test(path);
265
+ if (["linux", "mac"].includes(platform) && !isWindowsPath) {
266
+ return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
267
+ }
268
+ return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
269
+ }
270
+ function getRelativePath(rootDir, filePath, platform = "linux") {
271
+ if (!rootDir || !filePath) {
272
+ throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
273
+ }
274
+ const relativePath = pathParser.relative(rootDir, filePath);
275
+ const path = slash(relativePath, platform);
276
+ if (path.startsWith("../")) {
277
+ return path.replace(pathParser.basename(path), pathParser.basename(path, pathParser.extname(filePath)));
278
+ }
279
+ return `./${path.replace(pathParser.basename(path), pathParser.basename(path, pathParser.extname(filePath)))}`;
280
+ }
281
+ function getPathMode(path) {
282
+ if (!path) {
283
+ return "directory";
284
+ }
285
+ return pathParser.extname(path) ? "file" : "directory";
286
+ }
131
287
  var reader = switcher(
132
288
  {
133
- node: async (path3) => {
134
- return fs2.readFile(path3, { encoding: "utf8" });
289
+ node: async (path) => {
290
+ return fs2.readFile(path, { encoding: "utf8" });
135
291
  },
136
- bun: async (path3) => {
137
- const file = Bun.file(path3);
292
+ bun: async (path) => {
293
+ const file = Bun.file(path);
138
294
  return file.text();
139
295
  }
140
296
  },
141
297
  "node"
142
298
  );
143
- switcher(
299
+ var syncReader = switcher(
144
300
  {
145
- node: (path3) => {
146
- return fs2.readFileSync(path3, { encoding: "utf8" });
301
+ node: (path) => {
302
+ return fs2.readFileSync(path, { encoding: "utf8" });
147
303
  },
148
304
  bun: () => {
149
305
  throw new Error("Bun cannot read sync");
@@ -151,115 +307,79 @@ switcher(
151
307
  },
152
308
  "node"
153
309
  );
154
- async function read(path3) {
155
- return reader(path3);
310
+ async function read(path) {
311
+ return reader(path);
156
312
  }
157
- var URLPath = class {
158
- constructor(path3) {
159
- this.path = path3;
160
- return this;
161
- }
162
- /**
163
- * Convert Swagger path to URLPath(syntax of Express)
164
- * @example /pet/{petId} => /pet/:petId
165
- */
166
- get URL() {
167
- return this.toURLPath();
168
- }
169
- get isURL() {
170
- try {
171
- const url = new URL(this.path);
172
- if (url?.href) {
173
- return true;
174
- }
175
- } catch (error) {
176
- return false;
177
- }
178
- return false;
179
- }
180
- /**
181
- * Convert Swagger path to template literals/ template strings(camelcase)
182
- * @example /pet/{petId} => `/pet/${petId}`
183
- * @example /account/monetary-accountID => `/account/${monetaryAccountId}`
184
- * @example /account/userID => `/account/${userId}`
185
- */
186
- get template() {
187
- return this.toTemplateString();
188
- }
189
- get object() {
190
- return this.toObject();
191
- }
192
- get params() {
193
- return this.getParams();
194
- }
195
- toObject({ type = "path", replacer, stringify } = {}) {
196
- const object = {
197
- url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
198
- params: this.getParams()
199
- };
200
- if (stringify) {
201
- if (type !== "template") {
202
- throw new Error("Type should be `template` when using stringiyf");
203
- }
204
- return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
205
- }
206
- return object;
207
- }
208
- /**
209
- * Convert Swagger path to template literals/ template strings(camelcase)
210
- * @example /pet/{petId} => `/pet/${petId}`
211
- * @example /account/monetary-accountID => `/account/${monetaryAccountId}`
212
- * @example /account/userID => `/account/${userId}`
213
- */
214
- toTemplateString(replacer) {
215
- const regex = /{(\w|-)*}/g;
216
- const found = this.path.match(regex);
217
- let newPath = this.path.replaceAll("{", "${");
218
- if (found) {
219
- newPath = found.reduce((prev, curr) => {
220
- const pathParam = replacer ? replacer(camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge });
221
- const replacement = `\${${pathParam}}`;
222
- return prev.replace(curr, replacement);
223
- }, this.path);
313
+ function readSync(path) {
314
+ return syncReader(path);
315
+ }
316
+
317
+ // src/utils/renderTemplate.ts
318
+ function renderTemplate(template, data = void 0) {
319
+ if (!data || !Object.keys(data).length) {
320
+ return template.replace(/{{(.*?)}}/g, "");
321
+ }
322
+ const matches = template.match(/{{(.*?)}}/g);
323
+ return matches?.reduce((prev, curr) => {
324
+ const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
325
+ if (index === void 0) {
326
+ return prev;
224
327
  }
225
- return `\`${newPath}\``;
226
- }
227
- getParams(replacer) {
228
- const regex = /{(\w|-)*}/g;
229
- const found = this.path.match(regex);
230
- if (!found) {
231
- return void 0;
328
+ const value = data[index];
329
+ if (value === void 0) {
330
+ return prev;
232
331
  }
233
- const params = {};
234
- found.forEach((item) => {
235
- item = item.replaceAll("{", "").replaceAll("}", "");
236
- const pathParam = replacer ? replacer(camelCase(item, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(item, { delimiter: "", transform: camelCaseTransformMerge });
237
- params[pathParam] = pathParam;
238
- }, this.path);
239
- return params;
240
- }
241
- /**
242
- * Convert Swagger path to URLPath(syntax of Express)
243
- * @example /pet/{petId} => /pet/:petId
244
- */
245
- toURLPath() {
246
- return this.path.replaceAll("{", ":").replaceAll("}", "");
332
+ return prev.replace(curr, () => {
333
+ if (typeof value === "boolean") {
334
+ return `${value.toString()}` || "false";
335
+ }
336
+ return value || "";
337
+ }).trim();
338
+ }, template) || "";
339
+ }
340
+
341
+ // src/utils/SummaryError.ts
342
+ var SummaryError = class extends Error {
343
+ summary;
344
+ constructor(message, options) {
345
+ super(message, { cause: options.cause });
346
+ this.name = "SummaryError";
347
+ this.summary = options.summary || [];
247
348
  }
248
349
  };
249
350
 
250
- // src/config.ts
251
- function defineConfig(options) {
252
- return options;
253
- }
254
- function isInputPath(result) {
255
- return !!result && "path" in result;
256
- }
351
+ // src/utils/throttle.ts
352
+ var throttle = (fn, delay) => {
353
+ let wait = false;
354
+ let timeout2;
355
+ let cancelled = false;
356
+ return [
357
+ (...args) => {
358
+ if (cancelled) {
359
+ return void 0;
360
+ }
361
+ if (wait) {
362
+ return void 0;
363
+ }
364
+ const val = fn(...args);
365
+ wait = true;
366
+ timeout2 = setTimeout(() => {
367
+ wait = false;
368
+ }, delay);
369
+ return val;
370
+ },
371
+ () => {
372
+ cancelled = true;
373
+ clearTimeout(timeout2);
374
+ }
375
+ ];
376
+ };
257
377
 
258
378
  // src/utils/timeout.ts
259
379
  async function timeout(ms) {
260
- return new Promise((resolve2) => {
380
+ return new Promise((resolve) => {
261
381
  setTimeout(() => {
262
- resolve2(true);
382
+ resolve(true);
263
383
  }, ms);
264
384
  });
265
385
  }
@@ -269,17 +389,6 @@ function combineCodes(codes) {
269
389
  return codes.join("\n");
270
390
  }
271
391
 
272
- // src/utils/transformers/createJSDocBlockText.ts
273
- function createJSDocBlockText({ comments }) {
274
- const filteredComments = comments.filter(Boolean);
275
- if (!filteredComments.length) {
276
- return "";
277
- }
278
- return `/**
279
- * ${filteredComments.join("\n * ")}
280
- */`;
281
- }
282
-
283
392
  // src/utils/transformers/escape.ts
284
393
  function escape(text) {
285
394
  return text ? text.replaceAll("`", "\\`") : "";
@@ -305,39 +414,6 @@ function jsStringEscape(input) {
305
414
  });
306
415
  }
307
416
 
308
- // src/utils/transformers/indent.ts
309
- function createIndent(size) {
310
- return Array.from({ length: size + 1 }).join(" ");
311
- }
312
-
313
- // src/utils/transformers/nameSorter.ts
314
- function nameSorter(a, b) {
315
- if (a.name < b.name) {
316
- return -1;
317
- }
318
- if (a.name > b.name) {
319
- return 1;
320
- }
321
- return 0;
322
- }
323
-
324
- // src/utils/transformers/searchAndReplace.ts
325
- function searchAndReplace(options) {
326
- const { text, replaceBy, prefix = "", key } = options;
327
- const searchValues = options.searchValues?.(prefix, key) || [
328
- `${prefix}["${key}"]`,
329
- `${prefix}['${key}']`,
330
- `${prefix}[\`${key}\`]`,
331
- `${prefix}"${key}"`,
332
- `${prefix}'${key}'`,
333
- `${prefix}\`${key}\``,
334
- new RegExp(`${prefix}${key}`, "g")
335
- ];
336
- return searchValues.reduce((prev, searchValue) => {
337
- return prev.toString().replaceAll(searchValue, replaceBy);
338
- }, text);
339
- }
340
-
341
417
  // src/utils/transformers/transformReservedWord.ts
342
418
  var reservedWords = [
343
419
  "abstract",
@@ -430,83 +506,11 @@ function transformReservedWord(word) {
430
506
  }
431
507
  return word;
432
508
  }
433
-
434
- // src/utils/transformers/index.ts
435
- var transformers = {
436
- combineCodes,
437
- escape,
438
- jsStringEscape,
439
- createIndent,
440
- transformReservedWord,
441
- nameSorter,
442
- searchAndReplace,
443
- JSDoc: {
444
- createJSDocBlockText
445
- }
446
- };
447
- async function saveCreateDirectory(path3) {
448
- const passedPath = dirname(resolve(path3));
449
- await fs2.mkdir(passedPath, { recursive: true });
450
- }
451
- var writer = switcher(
452
- {
453
- node: async (path3, data) => {
454
- try {
455
- await fs2.stat(resolve(path3));
456
- const oldContent = await fs2.readFile(resolve(path3), { encoding: "utf-8" });
457
- if (oldContent?.toString() === data?.toString()) {
458
- return;
459
- }
460
- } catch (_err) {
461
- }
462
- await saveCreateDirectory(path3);
463
- await fs2.writeFile(resolve(path3), data, { encoding: "utf-8" });
464
- const savedData = await fs2.readFile(resolve(path3), { encoding: "utf-8" });
465
- if (savedData?.toString() !== data?.toString()) {
466
- throw new Error(`Sanity check failed for ${path3}
467
-
468
- Data[${data.length}]:
469
- ${data}
470
-
471
- Saved[${savedData.length}]:
472
- ${savedData}
473
- `);
474
- }
475
- return savedData;
476
- },
477
- bun: async (path3, data) => {
478
- try {
479
- await saveCreateDirectory(path3);
480
- await Bun.write(resolve(path3), data);
481
- const file = Bun.file(resolve(path3));
482
- const savedData = await file.text();
483
- if (savedData?.toString() !== data?.toString()) {
484
- throw new Error(`Sanity check failed for ${path3}
485
-
486
- Data[${data.length}]:
487
- ${data}
488
-
489
- Saved[${savedData.length}]:
490
- ${savedData}
491
- `);
492
- }
493
- return savedData;
494
- } catch (e) {
495
- console.log(e, resolve(path3));
496
- }
497
- }
498
- },
499
- "node"
500
- );
501
- async function write(data, path3) {
502
- if (data.trim() === "") {
503
- return void 0;
504
- }
505
- return writer(path3, data.trim());
506
- }
507
509
  var TreeNode = class _TreeNode {
510
+ data;
511
+ parent;
512
+ children = [];
508
513
  constructor(data, parent) {
509
- this.children = [];
510
514
  this.data = data;
511
515
  this.parent = parent;
512
516
  return this;
@@ -566,16 +570,16 @@ var TreeNode = class _TreeNode {
566
570
  }
567
571
  return this;
568
572
  }
569
- static build(path3, options = {}) {
573
+ static build(path, options = {}) {
570
574
  try {
571
575
  const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
572
- const filteredTree = dirTree(path3, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
576
+ const filteredTree = dirTree(path, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
573
577
  if (!filteredTree) {
574
578
  return null;
575
579
  }
576
- const treeNode = new _TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || FileManager.getMode(filteredTree.path) });
580
+ const treeNode = new _TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || getPathMode(filteredTree.path) });
577
581
  const recurse = (node, item) => {
578
- const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || FileManager.getMode(item.path) });
582
+ const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || getPathMode(item.path) });
579
583
  if (item.children?.length) {
580
584
  item.children?.forEach((child) => {
581
585
  recurse(subNode, child);
@@ -590,287 +594,227 @@ var TreeNode = class _TreeNode {
590
594
  }
591
595
  };
592
596
 
593
- // src/BarrelManager.ts
594
- var _options;
595
- var BarrelManager = class {
596
- constructor(options = {}) {
597
- __privateAdd(this, _options, {});
598
- __privateSet(this, _options, options);
597
+ // src/utils/uniqueIdFactory.ts
598
+ var uniqueIdFactory = (counter) => (str = "") => `${str}${++counter}`;
599
+ var URLPath = class {
600
+ path;
601
+ constructor(path) {
602
+ this.path = path;
599
603
  return this;
600
604
  }
601
- getIndexes(root, extName) {
602
- const { treeNode = {}, isTypeOnly, filter, map, output, includeExt } = __privateGet(this, _options);
603
- const extMapper = {
604
- ".ts": {
605
- extensions: /\.ts/,
606
- exclude: [/schemas/, /json/]
607
- },
608
- ".json": {
609
- extensions: /\.json/,
610
- exclude: []
605
+ /**
606
+ * Convert Swagger path to URLPath(syntax of Express)
607
+ * @example /pet/{petId} => /pet/:petId
608
+ */
609
+ get URL() {
610
+ return this.toURLPath();
611
+ }
612
+ get isURL() {
613
+ try {
614
+ const url = new URL(this.path);
615
+ if (url?.href) {
616
+ return true;
611
617
  }
612
- };
613
- const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...treeNode });
614
- if (!tree) {
615
- return null;
618
+ } catch (error) {
619
+ return false;
616
620
  }
617
- const fileReducer = (files2, currentTree) => {
618
- if (!currentTree.children) {
619
- return [];
620
- }
621
- if (currentTree.children?.length > 1) {
622
- const indexPath = path.resolve(currentTree.data.path, "index.ts");
623
- const exports = currentTree.children.filter(Boolean).map((file) => {
624
- const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
625
- if (importPath.includes("index") && indexPath.includes("index")) {
626
- return void 0;
627
- }
628
- return {
629
- path: includeExt ? file.data.type === "directory" ? `${importPath}/index${extName}` : `${importPath}${extName}` : importPath,
630
- isTypeOnly
631
- };
632
- }).filter(Boolean);
633
- files2.push({
634
- path: indexPath,
635
- baseName: "index.ts",
636
- source: "",
637
- exports: output ? exports?.filter((item) => {
638
- return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
639
- }) : exports
640
- });
641
- } else {
642
- currentTree.children?.forEach((child) => {
643
- const indexPath = path.resolve(currentTree.data.path, "index.ts");
644
- const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
645
- const exports = [
646
- {
647
- path: includeExt ? child.data.type === "directory" ? `${importPath}/index${extName}` : `${importPath}${extName}` : importPath,
648
- isTypeOnly
649
- }
650
- ];
651
- files2.push({
652
- path: indexPath,
653
- baseName: "index.ts",
654
- source: "",
655
- exports: output ? exports?.filter((item) => {
656
- return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
657
- }) : exports
658
- });
659
- });
660
- }
661
- currentTree.children.forEach((childItem) => {
662
- fileReducer(files2, childItem);
663
- });
664
- return files2;
665
- };
666
- const files = fileReducer([], tree).reverse();
667
- const filteredFiles = filter ? files.filter(filter) : files;
668
- return map ? filteredFiles.map(map) : filteredFiles;
621
+ return false;
669
622
  }
670
- };
671
- _options = new WeakMap();
672
-
673
- // src/FileManager.ts
674
- var _cache, _task, _isWriting, _timeout, _queue, _validate, validate_fn, _add, add_fn, _addOrAppend, addOrAppend_fn;
675
- var _FileManager = class _FileManager {
676
- constructor(options) {
677
- __privateAdd(this, _validate);
678
- __privateAdd(this, _add);
679
- __privateAdd(this, _addOrAppend);
680
- __privateAdd(this, _cache, /* @__PURE__ */ new Map());
681
- __privateAdd(this, _task, void 0);
682
- __privateAdd(this, _isWriting, false);
683
- /**
684
- * Timeout between writes
685
- */
686
- __privateAdd(this, _timeout, 0);
687
- __privateAdd(this, _queue, void 0);
688
- if (options) {
689
- __privateSet(this, _task, options.task);
690
- __privateSet(this, _queue, options.queue);
691
- __privateSet(this, _timeout, options.timeout || 0);
692
- }
693
- return this;
623
+ /**
624
+ * Convert Swagger path to template literals/ template strings(camelcase)
625
+ * @example /pet/{petId} => `/pet/${petId}`
626
+ * @example /account/monetary-accountID => `/account/${monetaryAccountId}`
627
+ * @example /account/userID => `/account/${userId}`
628
+ */
629
+ get template() {
630
+ return this.toTemplateString();
694
631
  }
695
- get files() {
696
- const files = [];
697
- __privateGet(this, _cache).forEach((item) => {
698
- files.push(...item.flat(1));
699
- });
700
- return files;
632
+ get object() {
633
+ return this.toObject();
701
634
  }
702
- get isExecuting() {
703
- return __privateGet(this, _queue)?.hasJobs ?? __privateGet(this, _isWriting) ?? false;
635
+ get params() {
636
+ return this.getParams();
704
637
  }
705
- async add(...files) {
706
- const promises = files.map((file) => {
707
- __privateMethod(this, _validate, validate_fn).call(this, file);
708
- if (file.override) {
709
- return __privateMethod(this, _add, add_fn).call(this, file);
638
+ toObject({ type = "path", replacer, stringify } = {}) {
639
+ const object = {
640
+ url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
641
+ params: this.getParams()
642
+ };
643
+ if (stringify) {
644
+ if (type !== "template") {
645
+ throw new Error("Type should be `template` when using stringiyf");
710
646
  }
711
- return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, file);
712
- });
713
- const resolvedFiles = await Promise.all(promises);
714
- if (files.length > 1) {
715
- return resolvedFiles;
647
+ return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
716
648
  }
717
- return resolvedFiles[0];
649
+ return object;
718
650
  }
719
- async addIndexes({ root, extName = ".ts", meta, options = {} }) {
720
- const barrelManager = new BarrelManager(options);
721
- const files = barrelManager.getIndexes(root, extName);
722
- if (!files) {
651
+ /**
652
+ * Convert Swagger path to template literals/ template strings(camelcase)
653
+ * @example /pet/{petId} => `/pet/${petId}`
654
+ * @example /account/monetary-accountID => `/account/${monetaryAccountId}`
655
+ * @example /account/userID => `/account/${userId}`
656
+ */
657
+ toTemplateString(replacer) {
658
+ const regex = /{(\w|-)*}/g;
659
+ const found = this.path.match(regex);
660
+ let newPath = this.path.replaceAll("{", "${");
661
+ if (found) {
662
+ newPath = found.reduce((prev, curr) => {
663
+ const pathParam = replacer ? replacer(camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge });
664
+ const replacement = `\${${pathParam}}`;
665
+ return prev.replace(curr, replacement);
666
+ }, this.path);
667
+ }
668
+ return `\`${newPath}\``;
669
+ }
670
+ getParams(replacer) {
671
+ const regex = /{(\w|-)*}/g;
672
+ const found = this.path.match(regex);
673
+ if (!found) {
723
674
  return void 0;
724
675
  }
725
- return await Promise.all(
726
- files.map((file) => {
727
- return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
728
- ...file,
729
- meta: meta ? meta : file.meta
730
- });
731
- })
732
- );
676
+ const params = {};
677
+ found.forEach((item) => {
678
+ item = item.replaceAll("{", "").replaceAll("}", "");
679
+ const pathParam = replacer ? replacer(camelCase(item, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(item, { delimiter: "", transform: camelCaseTransformMerge });
680
+ params[pathParam] = pathParam;
681
+ }, this.path);
682
+ return params;
733
683
  }
734
- getCacheByUUID(UUID) {
735
- let cache;
736
- __privateGet(this, _cache).forEach((files) => {
737
- cache = files.find((item) => item.id === UUID);
738
- });
739
- return cache;
684
+ /**
685
+ * Convert Swagger path to URLPath(syntax of Express)
686
+ * @example /pet/{petId} => /pet/:petId
687
+ */
688
+ toURLPath() {
689
+ return this.path.replaceAll("{", ":").replaceAll("}", "");
740
690
  }
741
- get(path3) {
742
- return __privateGet(this, _cache).get(path3);
691
+ };
692
+
693
+ // src/utils/Warning.ts
694
+ var Warning = class extends Error {
695
+ constructor(message, options) {
696
+ super(message, { cause: options?.cause });
697
+ this.name = "Warning";
743
698
  }
744
- remove(path3) {
745
- const cacheItem = this.get(path3);
746
- if (!cacheItem) {
747
- return;
699
+ };
700
+ async function saveCreateDirectory(path) {
701
+ const passedPath = pathParser.dirname(pathParser.resolve(path));
702
+ await fs2.mkdir(passedPath, { recursive: true });
703
+ }
704
+ var writer = switcher(
705
+ {
706
+ node: async (path, data) => {
707
+ try {
708
+ await fs2.stat(path);
709
+ const oldContent = await fs2.readFile(path, { encoding: "utf-8" });
710
+ if (oldContent?.toString() === data) {
711
+ return;
712
+ }
713
+ } catch (_err) {
714
+ }
715
+ await saveCreateDirectory(path);
716
+ return fs2.writeFile(pathParser.resolve(path), data, { encoding: "utf-8" });
717
+ },
718
+ bun: async (path, data) => {
719
+ try {
720
+ await saveCreateDirectory(path);
721
+ await Bun.write(pathParser.resolve(path), data);
722
+ } catch (e) {
723
+ console.log(e, pathParser.resolve(path));
724
+ }
748
725
  }
749
- __privateGet(this, _cache).delete(path3);
750
- }
751
- async write(...params) {
752
- if (!__privateGet(this, _isWriting)) {
753
- __privateSet(this, _isWriting, true);
754
- const text = await write(...params);
755
- __privateSet(this, _isWriting, false);
756
- return text;
726
+ },
727
+ "node"
728
+ );
729
+ async function write(data, path) {
730
+ return writer(path, data);
731
+ }
732
+ function getIndexes(root, extName, options = {}) {
733
+ const extMapper = {
734
+ ".ts": {
735
+ extensions: /\.ts/,
736
+ exclude: [/schemas/, /json/]
737
+ },
738
+ ".json": {
739
+ extensions: /\.json/,
740
+ exclude: []
757
741
  }
758
- await timeout(__privateGet(this, _timeout));
759
- return this.write(...params);
760
- }
761
- async read(...params) {
762
- return read(...params);
742
+ };
743
+ const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...options });
744
+ if (!tree) {
745
+ return null;
763
746
  }
764
- // statics
765
- static getSource(file) {
766
- if (!_FileManager.isExtensionAllowed(file.baseName)) {
767
- return file.source;
747
+ const fileReducer = (files2, currentTree) => {
748
+ if (!currentTree.children) {
749
+ return [];
768
750
  }
769
- const exports = file.exports ? combineExports(file.exports) : [];
770
- const imports = file.imports ? combineImports(file.imports, exports, file.source) : [];
771
- const importNodes = imports.map((item) => factory.createImportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly }));
772
- const exportNodes = exports.map(
773
- (item) => factory.createExportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly, asAlias: item.asAlias })
774
- );
775
- return [print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
776
- }
777
- static combineFiles(files) {
778
- return files.filter(Boolean).reduce((acc, file) => {
779
- const prevIndex = acc.findIndex((item) => item.path === file.path);
780
- if (prevIndex === -1) {
781
- return [...acc, file];
782
- }
751
+ if (currentTree.children?.length > 1) {
752
+ const path = pathParser.resolve(currentTree.data.path, "index.ts");
753
+ const exports = currentTree.children.map((file) => {
754
+ if (!file) {
755
+ return void 0;
756
+ }
757
+ const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
758
+ if (importPath.includes("index") && path.includes("index")) {
759
+ return void 0;
760
+ }
761
+ return { path: importPath };
762
+ }).filter(Boolean);
763
+ files2.push({
764
+ path,
765
+ baseName: "index.ts",
766
+ source: "",
767
+ exports
768
+ });
769
+ } else {
770
+ currentTree.children?.forEach((child) => {
771
+ const path = pathParser.resolve(currentTree.data.path, "index.ts");
772
+ const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
773
+ files2.push({
774
+ path,
775
+ baseName: "index.ts",
776
+ source: "",
777
+ exports: [{ path: importPath }]
778
+ });
779
+ });
780
+ }
781
+ currentTree.children.forEach((childItem) => {
782
+ fileReducer(files2, childItem);
783
+ });
784
+ return files2;
785
+ };
786
+ const files = fileReducer([], tree);
787
+ return files;
788
+ }
789
+ function combineFiles(files) {
790
+ return files.filter(Boolean).reduce((acc, curr) => {
791
+ const prevIndex = acc.findIndex((item) => item.path === curr.path);
792
+ if (prevIndex !== -1) {
783
793
  const prev = acc[prevIndex];
784
- if (prev && file.override) {
785
- acc[prevIndex] = {
786
- imports: [],
787
- exports: [],
788
- ...file
789
- };
790
- return acc;
791
- }
792
794
  if (prev) {
793
795
  acc[prevIndex] = {
794
- ...file,
795
- source: prev.source && file.source ? `${prev.source}
796
- ${file.source}` : "",
797
- imports: [...prev.imports || [], ...file.imports || []],
798
- exports: [...prev.exports || [], ...file.exports || []],
799
- env: { ...prev.env || {}, ...file.env || {} }
796
+ ...curr,
797
+ source: prev.source && curr.source ? `${prev.source}
798
+ ${curr.source}` : "",
799
+ imports: [...prev.imports || [], ...curr.imports || []],
800
+ exports: [...prev.exports || [], ...curr.exports || []],
801
+ env: { ...prev.env || {}, ...curr.env || {} }
800
802
  };
801
803
  }
802
- return acc;
803
- }, []);
804
- }
805
- static getMode(path3) {
806
- if (!path3) {
807
- return "directory";
804
+ } else {
805
+ acc.push(curr);
808
806
  }
809
- return extname(path3) ? "file" : "directory";
810
- }
811
- static get extensions() {
812
- return [".js", ".ts", ".tsx"];
813
- }
814
- static isExtensionAllowed(baseName) {
815
- return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
816
- }
817
- };
818
- _cache = new WeakMap();
819
- _task = new WeakMap();
820
- _isWriting = new WeakMap();
821
- _timeout = new WeakMap();
822
- _queue = new WeakMap();
823
- _validate = new WeakSet();
824
- validate_fn = function(file) {
825
- if (!file.validate) {
826
- return;
827
- }
828
- if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {
829
- throw new Error(`${file.path} should end with the baseName ${file.baseName}`);
830
- }
831
- };
832
- _add = new WeakSet();
833
- add_fn = async function(file) {
834
- const controller = new AbortController();
835
- const resolvedFile = { id: crypto2.randomUUID(), ...file };
836
- __privateGet(this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
837
- if (__privateGet(this, _queue)) {
838
- await __privateGet(this, _queue).run(
839
- async () => {
840
- var _a;
841
- return (_a = __privateGet(this, _task)) == null ? void 0 : _a.call(this, resolvedFile);
842
- },
843
- { controller }
844
- );
845
- }
846
- return resolvedFile;
847
- };
848
- _addOrAppend = new WeakSet();
849
- addOrAppend_fn = async function(file) {
850
- const previousCaches = __privateGet(this, _cache).get(file.path);
851
- const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
852
- if (previousCache) {
853
- __privateGet(this, _cache).delete(previousCache.path);
854
- return __privateMethod(this, _add, add_fn).call(this, {
855
- ...file,
856
- source: previousCache.source && file.source ? `${previousCache.source}
857
- ${file.source}` : "",
858
- imports: [...previousCache.imports || [], ...file.imports || []],
859
- exports: [...previousCache.exports || [], ...file.exports || []],
860
- env: { ...previousCache.env || {}, ...file.env || {} }
861
- });
862
- }
863
- return __privateMethod(this, _add, add_fn).call(this, file);
864
- };
865
- var FileManager = _FileManager;
807
+ return acc;
808
+ }, []);
809
+ }
810
+ var extensions = [".js", ".ts", ".tsx"];
811
+ function isExtensionAllowed(baseName) {
812
+ return extensions.some((extension) => baseName.endsWith(extension));
813
+ }
866
814
  function combineExports(exports) {
867
- const combinedExports = orderBy(exports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
815
+ return exports.reduce((prev, curr) => {
868
816
  const name = curr.name;
869
817
  const prevByPath = prev.findLast((imp) => imp.path === curr.path);
870
- const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly);
871
- if (prevByPathAndIsTypeOnly) {
872
- return prev;
873
- }
874
818
  const uniquePrev = prev.findLast(
875
819
  (imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
876
820
  );
@@ -892,16 +836,12 @@ function combineExports(exports) {
892
836
  }
893
837
  return [...prev, curr];
894
838
  }, []);
895
- return orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
896
839
  }
897
840
  function combineImports(imports, exports, source) {
898
- const combinedImports = orderBy(imports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
841
+ return imports.reduce((prev, curr) => {
899
842
  let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
900
843
  const hasImportInSource = (importName) => {
901
- if (!source) {
902
- return true;
903
- }
904
- const checker = (name2) => name2 && !!source.includes(name2);
844
+ const checker = (name2) => name2 && !!source.includes(`${name2}`);
905
845
  return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
906
846
  };
907
847
  if (Array.isArray(name)) {
@@ -909,10 +849,6 @@ function combineImports(imports, exports, source) {
909
849
  }
910
850
  const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
911
851
  const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
912
- const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly);
913
- if (prevByPathNameAndIsTypeOnly) {
914
- return prev;
915
- }
916
852
  if (uniquePrev || Array.isArray(name) && !name.length) {
917
853
  return prev;
918
854
  }
@@ -934,7 +870,43 @@ function combineImports(imports, exports, source) {
934
870
  }
935
871
  return [...prev, curr];
936
872
  }, []);
937
- return orderBy(combinedImports, [(v) => !v.isTypeOnly], ["desc"]);
873
+ }
874
+ function createFileSource(file) {
875
+ let { source } = file;
876
+ if (!isExtensionAllowed(file.baseName)) {
877
+ return file.source;
878
+ }
879
+ const exports = file.exports ? combineExports(file.exports) : [];
880
+ const imports = file.imports ? combineImports(file.imports, exports, source) : [];
881
+ const importNodes = imports.map((item) => createImportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly }));
882
+ const importSource = print(importNodes);
883
+ const exportNodes = exports.map((item) => createExportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly, asAlias: item.asAlias }));
884
+ const exportSource = print(exportNodes);
885
+ source = getEnvSource(file.source, file.env);
886
+ if (importSource) {
887
+ source = `${importSource}
888
+ ${source}`;
889
+ }
890
+ if (exportSource) {
891
+ source = `${exportSource}
892
+ ${source}`;
893
+ }
894
+ return source;
895
+ }
896
+ function searchAndReplace(options) {
897
+ const { text, replaceBy, prefix = "", key } = options;
898
+ const searchValues = options.searchValues?.(prefix, key) || [
899
+ `${prefix}["${key}"]`,
900
+ `${prefix}['${key}']`,
901
+ `${prefix}[\`${key}\`]`,
902
+ `${prefix}"${key}"`,
903
+ `${prefix}'${key}'`,
904
+ `${prefix}\`${key}\``,
905
+ new RegExp(`${prefix}${key}`, "g")
906
+ ];
907
+ return searchValues.reduce((prev, searchValue) => {
908
+ return prev.toString().replaceAll(searchValue, replaceBy);
909
+ }, text);
938
910
  }
939
911
  function getEnvSource(source, env) {
940
912
  if (!env) {
@@ -951,128 +923,132 @@ function getEnvSource(source, env) {
951
923
  throw new TypeError(`Environment should be in upperCase for ${key}`);
952
924
  }
953
925
  if (typeof replaceBy === "string") {
954
- prev = transformers.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
955
- prev = transformers.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
926
+ prev = searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
927
+ prev = searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
956
928
  `, "ig"), ""), replaceBy, key });
957
929
  }
958
930
  return prev;
959
931
  }, source);
960
932
  }
961
- var _emitter;
962
- var EventEmitter = class {
963
- constructor() {
964
- __privateAdd(this, _emitter, new EventEmitter$1());
965
- __privateGet(this, _emitter).setMaxListeners(100);
933
+
934
+ // src/managers/fileManager/FileManager.ts
935
+ var FileManager = class {
936
+ #cache = /* @__PURE__ */ new Map();
937
+ #task;
938
+ #queue;
939
+ constructor(options) {
940
+ if (options) {
941
+ this.#task = options.task;
942
+ this.#queue = options.queue;
943
+ }
944
+ return this;
966
945
  }
967
- emit(eventName, ...eventArg) {
968
- __privateGet(this, _emitter).emit(eventName, ...eventArg);
946
+ get extensions() {
947
+ return extensions;
969
948
  }
970
- on(eventName, handler) {
971
- __privateGet(this, _emitter).on(eventName, handler);
972
- }
973
- off(eventName, handler) {
974
- __privateGet(this, _emitter).off(eventName, handler);
949
+ get files() {
950
+ const files = [];
951
+ this.#cache.forEach((item) => {
952
+ files.push(...item.flat(1));
953
+ });
954
+ return files;
975
955
  }
976
- removeAll() {
977
- __privateGet(this, _emitter).removeAllListeners();
956
+ get isExecuting() {
957
+ return this.#queue?.hasJobs ?? false;
978
958
  }
979
- };
980
- _emitter = new WeakMap();
981
- var _queue2, _workerCount, _maxParallel, _debug, _work, work_fn;
982
- var Queue = class {
983
- constructor(maxParallel, debug = false) {
984
- __privateAdd(this, _work);
985
- __privateAdd(this, _queue2, []);
986
- this.eventEmitter = new EventEmitter();
987
- __privateAdd(this, _workerCount, 0);
988
- __privateAdd(this, _maxParallel, void 0);
989
- __privateAdd(this, _debug, false);
990
- __privateSet(this, _maxParallel, maxParallel);
991
- __privateSet(this, _debug, debug);
992
- }
993
- run(job, options = { controller: new AbortController(), name: crypto2.randomUUID(), description: "" }) {
994
- return new Promise((resolve2, reject) => {
995
- const item = { reject, resolve: resolve2, job, name: options.name, description: options.description || options.name };
996
- options.controller?.signal.addEventListener("abort", () => {
997
- __privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
998
- reject("Aborted");
999
- });
1000
- __privateGet(this, _queue2).push(item);
1001
- __privateMethod(this, _work, work_fn).call(this);
1002
- });
959
+ async add(file) {
960
+ const controller = new AbortController();
961
+ const resolvedFile = { id: crypto.randomUUID(), ...file };
962
+ this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
963
+ if (this.#queue) {
964
+ try {
965
+ await this.#queue.run(
966
+ async () => {
967
+ return this.#task?.(resolvedFile);
968
+ },
969
+ { controller }
970
+ );
971
+ } catch {
972
+ return resolvedFile;
973
+ }
974
+ }
975
+ return resolvedFile;
1003
976
  }
1004
- runSync(job, options = { controller: new AbortController(), name: crypto2.randomUUID(), description: "" }) {
1005
- new Promise((resolve2, reject) => {
1006
- const item = { reject, resolve: resolve2, job, name: options.name, description: options.description || options.name };
1007
- options.controller?.signal.addEventListener("abort", () => {
1008
- __privateSet(this, _queue2, __privateGet(this, _queue2).filter((queueItem) => queueItem.name === item.name));
977
+ async addOrAppend(file) {
978
+ const previousCaches = this.#cache.get(file.path);
979
+ const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
980
+ if (previousCache) {
981
+ this.#cache.delete(previousCache.path);
982
+ return this.add({
983
+ ...file,
984
+ source: previousCache.source && file.source ? `${previousCache.source}
985
+ ${file.source}` : "",
986
+ imports: [...previousCache.imports || [], ...file.imports || []],
987
+ exports: [...previousCache.exports || [], ...file.exports || []],
988
+ env: { ...previousCache.env || {}, ...file.env || {} }
1009
989
  });
1010
- __privateGet(this, _queue2).push(item);
1011
- __privateMethod(this, _work, work_fn).call(this);
1012
- });
990
+ }
991
+ return this.add(file);
1013
992
  }
1014
- get hasJobs() {
1015
- return __privateGet(this, _workerCount) > 0 || __privateGet(this, _queue2).length > 0;
993
+ async addIndexes(root, extName = ".ts", options = {}) {
994
+ const files = await getIndexes(root, extName, options);
995
+ if (!files) {
996
+ return void 0;
997
+ }
998
+ return Promise.all(
999
+ files.map((file) => {
1000
+ if (file.override) {
1001
+ return this.add(file);
1002
+ }
1003
+ return this.addOrAppend(file);
1004
+ })
1005
+ );
1016
1006
  }
1017
- get count() {
1018
- return __privateGet(this, _workerCount);
1007
+ #append(path, file) {
1008
+ const previousFiles = this.#cache.get(path) || [];
1009
+ this.#cache.set(path, [...previousFiles, file]);
1019
1010
  }
1020
- };
1021
- _queue2 = new WeakMap();
1022
- _workerCount = new WeakMap();
1023
- _maxParallel = new WeakMap();
1024
- _debug = new WeakMap();
1025
- _work = new WeakSet();
1026
- work_fn = function() {
1027
- if (__privateGet(this, _workerCount) >= __privateGet(this, _maxParallel)) {
1028
- return;
1029
- }
1030
- __privateWrapper(this, _workerCount)._++;
1031
- let entry;
1032
- while (entry = __privateGet(this, _queue2).shift()) {
1033
- const { reject, resolve: resolve2, job, name, description } = entry;
1034
- if (__privateGet(this, _debug)) {
1035
- performance.mark(name + "_start");
1036
- }
1037
- job().then((result) => {
1038
- this.eventEmitter.emit("jobDone", result);
1039
- resolve2(result);
1040
- if (__privateGet(this, _debug)) {
1041
- performance.mark(name + "_stop");
1042
- performance.measure(description, name + "_start", name + "_stop");
1043
- }
1044
- }).catch((err) => {
1045
- this.eventEmitter.emit("jobFailed", err);
1046
- reject(err);
1011
+ getCacheByUUID(UUID) {
1012
+ let cache;
1013
+ this.#cache.forEach((files) => {
1014
+ cache = files.find((item) => item.id === UUID);
1047
1015
  });
1016
+ return cache;
1048
1017
  }
1049
- __privateWrapper(this, _workerCount)._--;
1050
- };
1051
-
1052
- // src/utils/uniqueName.ts
1053
- function setUniqueName(originalName, data) {
1054
- let used = data[originalName] || 0;
1055
- if (used) {
1056
- data[originalName] = ++used;
1057
- return originalName;
1018
+ get(path) {
1019
+ return this.#cache.get(path);
1058
1020
  }
1059
- data[originalName] = 1;
1060
- return originalName;
1061
- }
1062
-
1063
- // src/errors.ts
1064
- var PluginError = class extends Error {
1065
- constructor(message, options) {
1066
- super(message, { cause: options.cause });
1067
- this.name = "PluginError";
1068
- this.cause = options.cause;
1069
- this.pluginManager = options.pluginManager;
1021
+ remove(path) {
1022
+ const cacheItem = this.get(path);
1023
+ if (!cacheItem) {
1024
+ return;
1025
+ }
1026
+ this.#cache.delete(path);
1027
+ }
1028
+ async write(...params) {
1029
+ if (this.#queue) {
1030
+ return this.#queue.run(async () => {
1031
+ return write(...params);
1032
+ });
1033
+ }
1034
+ return write(...params);
1035
+ }
1036
+ async read(...params) {
1037
+ if (this.#queue) {
1038
+ return this.#queue.run(async () => {
1039
+ return read(...params);
1040
+ });
1041
+ }
1042
+ return read(...params);
1070
1043
  }
1071
1044
  };
1045
+
1046
+ // src/managers/pluginManager/ParallelPluginError.ts
1072
1047
  var ParallelPluginError = class extends Error {
1048
+ errors = [];
1049
+ pluginManager;
1073
1050
  constructor(message, options) {
1074
1051
  super(message, { cause: options.cause });
1075
- this.errors = [];
1076
1052
  this.name = "ParallelPluginError";
1077
1053
  this.errors = options.errors;
1078
1054
  this.pluginManager = options.pluginManager;
@@ -1092,54 +1068,30 @@ var ParallelPluginError = class extends Error {
1092
1068
  })?.cause;
1093
1069
  }
1094
1070
  };
1095
- var SummaryError = class extends Error {
1071
+
1072
+ // src/managers/pluginManager/PluginError.ts
1073
+ var PluginError = class extends Error {
1074
+ pluginManager;
1075
+ cause;
1096
1076
  constructor(message, options) {
1097
1077
  super(message, { cause: options.cause });
1098
- this.name = "SummaryError";
1099
- this.summary = options.summary || [];
1100
- }
1101
- };
1102
- var Warning = class extends Error {
1103
- constructor(message, options) {
1104
- super(message, { cause: options?.cause });
1105
- this.name = "Warning";
1078
+ this.name = "PluginError";
1079
+ this.cause = options.cause;
1080
+ this.pluginManager = options.pluginManager;
1106
1081
  }
1107
1082
  };
1108
- var ValidationPluginError = class extends Error {
1109
- };
1110
-
1111
- // src/utils/cache.ts
1112
- function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
1113
- return {
1114
- set(id, value) {
1115
- Store[id] = [0, value];
1116
- },
1117
- get(id) {
1118
- const item = Store[id];
1119
- if (!item) {
1120
- return null;
1121
- }
1122
- item[0] = 0;
1123
- return item[1];
1124
- },
1125
- has(id) {
1126
- const item = Store[id];
1127
- if (!item) {
1128
- return false;
1129
- }
1130
- item[0] = 0;
1131
- return true;
1132
- },
1133
- delete(id) {
1134
- return delete Store[id];
1135
- }
1136
- };
1137
- }
1138
-
1139
- // src/plugin.ts
1140
- function createPlugin(factory2) {
1083
+ function createPlugin(factory) {
1141
1084
  return (options) => {
1142
- return factory2(options);
1085
+ const plugin = factory(options);
1086
+ if (Array.isArray(plugin)) {
1087
+ throw new Error("Not implemented");
1088
+ }
1089
+ if (!plugin.transform) {
1090
+ plugin.transform = function transform(code) {
1091
+ return code;
1092
+ };
1093
+ }
1094
+ return plugin;
1143
1095
  };
1144
1096
  }
1145
1097
  var pluginName = "core";
@@ -1148,8 +1100,6 @@ var definePlugin = createPlugin((options) => {
1148
1100
  return {
1149
1101
  name: pluginName,
1150
1102
  options,
1151
- key: ["controller", "core"],
1152
- kind: "controller",
1153
1103
  api() {
1154
1104
  return {
1155
1105
  get config() {
@@ -1158,18 +1108,18 @@ var definePlugin = createPlugin((options) => {
1158
1108
  get plugins() {
1159
1109
  return options.getPlugins();
1160
1110
  },
1161
- get plugin() {
1162
- return options.plugin;
1163
- },
1164
1111
  logger,
1165
1112
  fileManager,
1166
1113
  pluginManager,
1167
1114
  async addFile(...files) {
1168
- const resolvedFiles = await fileManager.add(...files);
1169
- if (!Array.isArray(resolvedFiles)) {
1170
- return [resolvedFiles];
1171
- }
1172
- return resolvedFiles;
1115
+ return Promise.all(
1116
+ files.map((file) => {
1117
+ if (file.override) {
1118
+ return fileManager.add(file);
1119
+ }
1120
+ return fileManager.addOrAppend(file);
1121
+ })
1122
+ );
1173
1123
  },
1174
1124
  resolvePath,
1175
1125
  resolveName,
@@ -1177,133 +1127,75 @@ var definePlugin = createPlugin((options) => {
1177
1127
  };
1178
1128
  },
1179
1129
  resolvePath(baseName) {
1180
- const root = path.resolve(this.config.root, this.config.output.path);
1181
- return path.resolve(root, baseName);
1130
+ const root = pathParser.resolve(this.config.root, this.config.output.path);
1131
+ return pathParser.resolve(root, baseName);
1182
1132
  },
1183
1133
  resolveName(name) {
1184
1134
  return name;
1185
1135
  }
1186
1136
  };
1187
1137
  });
1188
-
1189
- // src/utils/executeStrategies.ts
1190
- function hookSeq(promises) {
1191
- return promises.reduce(
1192
- (promise, func) => {
1193
- if (!func || typeof func !== "function") {
1194
- throw new Error("HookSeq needs a function that returns a promise `() => Promise<unknown>`");
1195
- }
1196
- return promise.then((result) => {
1197
- const calledFunc = func();
1198
- if (calledFunc) {
1199
- return calledFunc.then(Array.prototype.concat.bind(result));
1200
- }
1201
- });
1202
- },
1203
- Promise.resolve([])
1204
- );
1205
- }
1206
-
1207
- // src/PromiseManager.ts
1208
- var _options2;
1209
- var PromiseManager = class {
1210
- constructor(options = {}) {
1211
- __privateAdd(this, _options2, {});
1212
- __privateSet(this, _options2, options);
1213
- return this;
1138
+ var EventEmitter = class {
1139
+ constructor() {
1140
+ this.#emitter.setMaxListeners(100);
1214
1141
  }
1215
- run(strategy, promises) {
1216
- if (strategy === "seq") {
1217
- return hookSeq(promises);
1218
- }
1219
- throw new Error(`${strategy} not implemented`);
1142
+ #emitter = new EventEmitter$1();
1143
+ emit(eventName, ...eventArg) {
1144
+ this.#emitter.emit(eventName, ...eventArg);
1145
+ }
1146
+ on(eventName, handler) {
1147
+ this.#emitter.on(eventName, handler);
1148
+ }
1149
+ off(eventName, handler) {
1150
+ this.#emitter.off(eventName, handler);
1151
+ }
1152
+ removeAll() {
1153
+ this.#emitter.removeAllListeners();
1220
1154
  }
1221
1155
  };
1222
- _options2 = new WeakMap();
1223
- function isPromise(result) {
1224
- return !!result && typeof result?.then === "function";
1225
- }
1226
- function isPromiseRejectedResult(result) {
1227
- return result.status === "rejected";
1156
+
1157
+ // src/managers/pluginManager/pluginParser.ts
1158
+ var usedPluginNames = {};
1159
+ function pluginParser(plugin, context) {
1160
+ const key = [plugin.kind, plugin.name, getUniqueName(plugin.name, usedPluginNames).split(plugin.name).at(1)];
1161
+ if (plugin.api && typeof plugin.api === "function") {
1162
+ const api = plugin.api.call(context);
1163
+ return {
1164
+ ...plugin,
1165
+ key,
1166
+ api
1167
+ };
1168
+ }
1169
+ return {
1170
+ ...plugin,
1171
+ key
1172
+ };
1228
1173
  }
1229
1174
 
1230
- // src/PluginManager.ts
1231
- var _core, _usedPluginNames, _promiseManager, _getSortedPlugins, getSortedPlugins_fn, _addExecutedToCallStack, addExecutedToCallStack_fn, _execute, execute_fn, _executeSync, executeSync_fn, _catcher, catcher_fn, _parse, parse_fn;
1175
+ // src/managers/pluginManager/PluginManager.ts
1176
+ var hookNames = {
1177
+ validate: 1,
1178
+ buildStart: 1,
1179
+ resolvePath: 1,
1180
+ resolveName: 1,
1181
+ load: 1,
1182
+ transform: 1,
1183
+ writeFile: 1,
1184
+ buildEnd: 1
1185
+ };
1186
+ var hooks = Object.keys(hookNames);
1232
1187
  var PluginManager = class {
1188
+ plugins;
1189
+ fileManager;
1190
+ eventEmitter = new EventEmitter();
1191
+ queue;
1192
+ executed = [];
1193
+ logger;
1194
+ #core;
1233
1195
  constructor(config, options) {
1234
- __privateAdd(this, _getSortedPlugins);
1235
- __privateAdd(this, _addExecutedToCallStack);
1236
- /**
1237
- * Run an async plugin hook and return the result.
1238
- * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
1239
- * @param args Arguments passed to the plugin hook.
1240
- * @param plugin The actual pluginObject to run.
1241
- */
1242
- // Implementation signature
1243
- __privateAdd(this, _execute);
1244
- /**
1245
- * Run a sync plugin hook and return the result.
1246
- * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
1247
- * @param args Arguments passed to the plugin hook.
1248
- * @param plugin The acutal plugin
1249
- * @param replaceContext When passed, the plugin context can be overridden.
1250
- */
1251
- __privateAdd(this, _executeSync);
1252
- __privateAdd(this, _catcher);
1253
- __privateAdd(this, _parse);
1254
- this.eventEmitter = new EventEmitter();
1255
- this.executed = [];
1256
- __privateAdd(this, _core, void 0);
1257
- __privateAdd(this, _usedPluginNames, {});
1258
- __privateAdd(this, _promiseManager, void 0);
1259
- this.resolvePath = (params) => {
1260
- if (params.pluginKey) {
1261
- const paths = this.hookForPluginSync({
1262
- pluginKey: params.pluginKey,
1263
- hookName: "resolvePath",
1264
- parameters: [params.baseName, params.directory, params.options]
1265
- });
1266
- if (paths && paths?.length > 1) {
1267
- throw new Error(
1268
- `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1269
-
1270
- Paths: ${JSON.stringify(paths, void 0, 2)}`
1271
- );
1272
- }
1273
- return paths?.at(0);
1274
- }
1275
- return this.hookFirstSync({
1276
- hookName: "resolvePath",
1277
- parameters: [params.baseName, params.directory, params.options]
1278
- }).result;
1279
- };
1280
- this.resolveName = (params) => {
1281
- if (params.pluginKey) {
1282
- const names = this.hookForPluginSync({
1283
- pluginKey: params.pluginKey,
1284
- hookName: "resolveName",
1285
- parameters: [params.name, params.type]
1286
- });
1287
- if (names && names?.length > 1) {
1288
- throw new Error(
1289
- `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1290
-
1291
- Names: ${JSON.stringify(names, void 0, 2)}`
1292
- );
1293
- }
1294
- return transformReservedWord(names?.at(0) || params.name);
1295
- }
1296
- const name = this.hookFirstSync({
1297
- hookName: "resolveName",
1298
- parameters: [params.name, params.type]
1299
- }).result;
1300
- return transformReservedWord(name);
1301
- };
1302
1196
  this.logger = options.logger;
1303
- this.queue = new Queue(100, this.logger.logLevel === LogLevel.debug);
1304
- this.fileManager = new FileManager({ task: options.task, queue: this.queue, timeout: options.writeTimeout });
1305
- __privateSet(this, _promiseManager, new PromiseManager());
1306
- const plugins = config.plugins || [];
1197
+ this.queue = new Queue(100, options.debug);
1198
+ this.fileManager = new FileManager({ task: options.task, queue: this.queue });
1307
1199
  const core = definePlugin({
1308
1200
  config,
1309
1201
  logger: this.logger,
@@ -1311,14 +1203,44 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1311
1203
  fileManager: this.fileManager,
1312
1204
  resolvePath: this.resolvePath.bind(this),
1313
1205
  resolveName: this.resolveName.bind(this),
1314
- getPlugins: __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).bind(this)
1315
- });
1316
- __privateSet(this, _core, __privateMethod(this, _parse, parse_fn).call(this, core, this, core.api.call(null)));
1317
- this.plugins = [__privateGet(this, _core), ...plugins].map((plugin) => {
1318
- return __privateMethod(this, _parse, parse_fn).call(this, plugin, this, __privateGet(this, _core).api);
1206
+ getPlugins: this.#getSortedPlugins.bind(this),
1207
+ plugin: void 0
1319
1208
  });
1209
+ this.#core = pluginParser(core, core.api.call(null));
1210
+ this.plugins = [this.#core, ...config.plugins || []].reduce((prev, plugin) => {
1211
+ const convertedApi = pluginParser(plugin, this.#core?.api);
1212
+ return [...prev, convertedApi];
1213
+ }, []);
1320
1214
  return this;
1321
1215
  }
1216
+ resolvePath = (params) => {
1217
+ if (params.pluginName) {
1218
+ return this.hookForPluginSync({
1219
+ pluginName: params.pluginName,
1220
+ hookName: "resolvePath",
1221
+ parameters: [params.baseName, params.directory, params.options]
1222
+ });
1223
+ }
1224
+ return this.hookFirstSync({
1225
+ hookName: "resolvePath",
1226
+ parameters: [params.baseName, params.directory, params.options]
1227
+ }).result;
1228
+ };
1229
+ resolveName = (params) => {
1230
+ if (params.pluginName) {
1231
+ const name2 = this.hookForPluginSync({
1232
+ pluginName: params.pluginName,
1233
+ hookName: "resolveName",
1234
+ parameters: [params.name, params.type]
1235
+ });
1236
+ return transformReservedWord(name2 || params.name);
1237
+ }
1238
+ const name = this.hookFirstSync({
1239
+ hookName: "resolveName",
1240
+ parameters: [params.name, params.type]
1241
+ }).result;
1242
+ return transformReservedWord(name);
1243
+ };
1322
1244
  on(eventName, handler) {
1323
1245
  this.eventEmitter.on(eventName, handler);
1324
1246
  }
@@ -1326,35 +1248,30 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1326
1248
  * Run only hook for a specific plugin name
1327
1249
  */
1328
1250
  hookForPlugin({
1329
- pluginKey,
1251
+ pluginName: pluginName2,
1330
1252
  hookName,
1331
1253
  parameters
1332
1254
  }) {
1333
- const plugins = this.getPluginsByKey(hookName, pluginKey);
1334
- const promises = plugins.map((plugin) => {
1335
- return __privateMethod(this, _execute, execute_fn).call(this, {
1336
- strategy: "hookFirst",
1337
- hookName,
1338
- parameters,
1339
- plugin
1340
- });
1341
- }).filter(Boolean);
1342
- return Promise.all(promises);
1255
+ const plugin = this.getPlugin(hookName, pluginName2);
1256
+ return this.#execute({
1257
+ strategy: "hookFirst",
1258
+ hookName,
1259
+ parameters,
1260
+ plugin
1261
+ });
1343
1262
  }
1344
1263
  hookForPluginSync({
1345
- pluginKey,
1264
+ pluginName: pluginName2,
1346
1265
  hookName,
1347
1266
  parameters
1348
1267
  }) {
1349
- const plugins = this.getPluginsByKey(hookName, pluginKey);
1350
- return plugins.map((plugin) => {
1351
- return __privateMethod(this, _executeSync, executeSync_fn).call(this, {
1352
- strategy: "hookFirst",
1353
- hookName,
1354
- parameters,
1355
- plugin
1356
- });
1357
- }).filter(Boolean);
1268
+ const plugin = this.getPlugin(hookName, pluginName2);
1269
+ return this.#executeSync({
1270
+ strategy: "hookFirst",
1271
+ hookName,
1272
+ parameters,
1273
+ plugin
1274
+ });
1358
1275
  }
1359
1276
  /**
1360
1277
  * Chains, first non-null result stops and returns
@@ -1365,7 +1282,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1365
1282
  skipped
1366
1283
  }) {
1367
1284
  let promise = Promise.resolve(null);
1368
- for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1285
+ for (const plugin of this.#getSortedPlugins()) {
1369
1286
  if (skipped && skipped.has(plugin)) {
1370
1287
  continue;
1371
1288
  }
@@ -1373,7 +1290,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1373
1290
  if (parseResult?.result != null) {
1374
1291
  return parseResult;
1375
1292
  }
1376
- const value = await __privateMethod(this, _execute, execute_fn).call(this, {
1293
+ const value = await this.#execute({
1377
1294
  strategy: "hookFirst",
1378
1295
  hookName,
1379
1296
  parameters,
@@ -1398,12 +1315,12 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1398
1315
  skipped
1399
1316
  }) {
1400
1317
  let parseResult = null;
1401
- for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1318
+ for (const plugin of this.#getSortedPlugins()) {
1402
1319
  if (skipped && skipped.has(plugin)) {
1403
1320
  continue;
1404
1321
  }
1405
1322
  parseResult = {
1406
- result: __privateMethod(this, _executeSync, executeSync_fn).call(this, {
1323
+ result: this.#executeSync({
1407
1324
  strategy: "hookFirst",
1408
1325
  hookName,
1409
1326
  parameters,
@@ -1425,8 +1342,8 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1425
1342
  parameters
1426
1343
  }) {
1427
1344
  const parallelPromises = [];
1428
- for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1429
- const promise = __privateMethod(this, _execute, execute_fn).call(this, { strategy: "hookParallel", hookName, parameters, plugin });
1345
+ for (const plugin of this.#getSortedPlugins()) {
1346
+ const promise = this.#execute({ strategy: "hookParallel", hookName, parameters, plugin });
1430
1347
  if (promise) {
1431
1348
  parallelPromises.push(promise);
1432
1349
  }
@@ -1453,16 +1370,16 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1453
1370
  }) {
1454
1371
  const [argument0, ...rest] = parameters;
1455
1372
  let promise = Promise.resolve(argument0);
1456
- for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1373
+ for (const plugin of this.#getSortedPlugins()) {
1457
1374
  promise = promise.then((arg0) => {
1458
- const value = __privateMethod(this, _execute, execute_fn).call(this, {
1375
+ const value = this.#execute({
1459
1376
  strategy: "hookReduceArg0",
1460
1377
  hookName,
1461
1378
  parameters: [arg0, ...rest],
1462
1379
  plugin
1463
1380
  });
1464
1381
  return value;
1465
- }).then((result) => reduce.call(__privateGet(this, _core).api, argument0, result, plugin));
1382
+ }).then((result) => reduce.call(this.#core.api, argument0, result, plugin));
1466
1383
  }
1467
1384
  return promise;
1468
1385
  }
@@ -1470,192 +1387,160 @@ Names: ${JSON.stringify(names, void 0, 2)}`
1470
1387
  * Chains plugins
1471
1388
  */
1472
1389
  hookSeq({ hookName, parameters }) {
1473
- const promises = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
1474
- return () => __privateMethod(this, _execute, execute_fn).call(this, {
1475
- strategy: "hookSeq",
1476
- hookName,
1477
- parameters,
1478
- plugin
1390
+ let promise = Promise.resolve();
1391
+ for (const plugin of this.#getSortedPlugins()) {
1392
+ promise = promise.then(() => {
1393
+ this.#execute({
1394
+ strategy: "hookSeq",
1395
+ hookName,
1396
+ parameters,
1397
+ plugin
1398
+ });
1479
1399
  });
1480
- });
1481
- return __privateGet(this, _promiseManager).run("seq", promises);
1400
+ }
1401
+ return promise.then(noReturn);
1402
+ }
1403
+ #getSortedPlugins(hookName) {
1404
+ const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1405
+ if (hookName) {
1406
+ return plugins.filter((item) => item[hookName]);
1407
+ }
1408
+ return plugins;
1482
1409
  }
1483
- getPluginsByKey(hookName, pluginKey) {
1410
+ getPlugin(hookName, pluginName2) {
1484
1411
  const plugins = [...this.plugins];
1485
- const [searchKind, searchPluginName, searchIdentifier] = pluginKey;
1486
- const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
1487
- const [kind, name, identifier] = item.key;
1488
- const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
1489
- const kindCheck = kind === searchKind;
1490
- const nameCheck = name === searchPluginName;
1491
- if (searchIdentifier) {
1492
- return identifierCheck && kindCheck && nameCheck;
1493
- }
1494
- return kindCheck && nameCheck;
1495
- });
1496
- if (!pluginByPluginName?.length) {
1497
- const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
1498
- if (this.logger.logLevel === "info") {
1499
- if (corePlugin) {
1500
- this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`);
1501
- } else {
1502
- this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`);
1503
- }
1504
- }
1505
- return corePlugin ? [corePlugin] : [];
1412
+ const pluginByPluginName = plugins.find((item) => item.name === pluginName2 && item[hookName]);
1413
+ if (!pluginByPluginName) {
1414
+ return this.#core;
1506
1415
  }
1507
1416
  return pluginByPluginName;
1508
1417
  }
1509
- static getDependedPlugins(plugins, dependedPluginNames) {
1510
- let pluginNames = [];
1511
- if (typeof dependedPluginNames === "string") {
1512
- pluginNames = [dependedPluginNames];
1513
- } else {
1514
- pluginNames = dependedPluginNames;
1418
+ #addExecutedToCallStack(executer) {
1419
+ if (executer) {
1420
+ this.eventEmitter.emit("execute", executer);
1421
+ this.executed.push(executer);
1515
1422
  }
1516
- return pluginNames.map((pluginName2) => {
1517
- const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
1518
- if (!plugin) {
1519
- throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
1520
- }
1521
- return plugin;
1522
- });
1523
- }
1524
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1525
- static get hooks() {
1526
- return ["validate", "buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
1527
1423
  }
1528
- };
1529
- _core = new WeakMap();
1530
- _usedPluginNames = new WeakMap();
1531
- _promiseManager = new WeakMap();
1532
- _getSortedPlugins = new WeakSet();
1533
- getSortedPlugins_fn = function(hookName) {
1534
- const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1535
- if (hookName) {
1536
- if (this.logger.logLevel === "info") {
1537
- const containsHookName = plugins.some((item) => item[hookName]);
1538
- if (!containsHookName) {
1539
- this.logger.warn(`No hook ${hookName} found`);
1540
- }
1424
+ /**
1425
+ * Run an async plugin hook and return the result.
1426
+ * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
1427
+ * @param args Arguments passed to the plugin hook.
1428
+ * @param plugin The actual pluginObject to run.
1429
+ */
1430
+ // Implementation signature
1431
+ #execute({
1432
+ strategy,
1433
+ hookName,
1434
+ parameters,
1435
+ plugin
1436
+ }) {
1437
+ const hook = plugin[hookName];
1438
+ let output;
1439
+ if (!hook) {
1440
+ return null;
1541
1441
  }
1542
- return plugins.filter((item) => item[hookName]);
1543
- }
1544
- return plugins;
1545
- };
1546
- _addExecutedToCallStack = new WeakSet();
1547
- addExecutedToCallStack_fn = function(executer) {
1548
- if (executer) {
1549
- this.eventEmitter.emit("executed", executer);
1550
- this.executed.push(executer);
1551
- }
1552
- };
1553
- _execute = new WeakSet();
1554
- execute_fn = function({
1555
- strategy,
1556
- hookName,
1557
- parameters,
1558
- plugin
1559
- }) {
1560
- const hook = plugin[hookName];
1561
- let output;
1562
- if (!hook) {
1563
- return null;
1564
- }
1565
- this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1566
- const task = Promise.resolve().then(() => {
1567
- if (typeof hook === "function") {
1568
- const possiblePromiseResult = hook.apply({ ...__privateGet(this, _core).api, plugin }, parameters);
1569
- if (isPromise(possiblePromiseResult)) {
1570
- return Promise.resolve(possiblePromiseResult);
1442
+ this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1443
+ const task = Promise.resolve().then(() => {
1444
+ if (typeof hook === "function") {
1445
+ const possiblePromiseResult = hook.apply({ ...this.#core.api, plugin }, parameters);
1446
+ if (isPromise(possiblePromiseResult)) {
1447
+ return Promise.resolve(possiblePromiseResult);
1448
+ }
1449
+ return possiblePromiseResult;
1571
1450
  }
1572
- return possiblePromiseResult;
1573
- }
1574
- return hook;
1575
- }).then((result) => {
1576
- output = result;
1577
- return result;
1578
- }).catch((e) => {
1579
- __privateMethod(this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1580
- return null;
1581
- }).finally(() => {
1582
- __privateMethod(this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1583
- parameters,
1584
- output,
1585
- strategy,
1586
- hookName,
1587
- plugin
1451
+ return hook;
1452
+ }).then((result) => {
1453
+ output = result;
1454
+ return result;
1455
+ }).catch((e) => {
1456
+ this.#catcher(e, plugin, hookName);
1457
+ return null;
1458
+ }).finally(() => {
1459
+ this.#addExecutedToCallStack({
1460
+ parameters,
1461
+ output,
1462
+ strategy,
1463
+ hookName,
1464
+ plugin
1465
+ });
1588
1466
  });
1589
- });
1590
- return task;
1591
- };
1592
- _executeSync = new WeakSet();
1593
- executeSync_fn = function({
1594
- strategy,
1595
- hookName,
1596
- parameters,
1597
- plugin
1598
- }) {
1599
- const hook = plugin[hookName];
1600
- let output;
1601
- if (!hook) {
1602
- return null;
1467
+ return task;
1603
1468
  }
1604
- this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1605
- try {
1606
- if (typeof hook === "function") {
1607
- const fn = hook.apply({ ...__privateGet(this, _core).api, plugin }, parameters);
1608
- output = fn;
1609
- return fn;
1469
+ /**
1470
+ * Run a sync plugin hook and return the result.
1471
+ * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
1472
+ * @param args Arguments passed to the plugin hook.
1473
+ * @param plugin The acutal plugin
1474
+ * @param replaceContext When passed, the plugin context can be overridden.
1475
+ */
1476
+ #executeSync({
1477
+ strategy,
1478
+ hookName,
1479
+ parameters,
1480
+ plugin
1481
+ }) {
1482
+ const hook = plugin[hookName];
1483
+ let output;
1484
+ if (!hook) {
1485
+ return null;
1486
+ }
1487
+ this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1488
+ try {
1489
+ if (typeof hook === "function") {
1490
+ const fn = hook.apply(this.#core.api, parameters);
1491
+ output = fn;
1492
+ return fn;
1493
+ }
1494
+ output = hook;
1495
+ return hook;
1496
+ } catch (e) {
1497
+ this.#catcher(e, plugin, hookName);
1498
+ return null;
1499
+ } finally {
1500
+ this.#addExecutedToCallStack({
1501
+ parameters,
1502
+ output,
1503
+ strategy,
1504
+ hookName,
1505
+ plugin
1506
+ });
1610
1507
  }
1611
- output = hook;
1612
- return hook;
1613
- } catch (e) {
1614
- __privateMethod(this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1615
- return null;
1616
- } finally {
1617
- __privateMethod(this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1618
- parameters,
1619
- output,
1620
- strategy,
1621
- hookName,
1622
- plugin
1623
- });
1624
1508
  }
1625
- };
1626
- _catcher = new WeakSet();
1627
- catcher_fn = function(e, plugin, hookName) {
1628
- const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
1509
+ #catcher(e, plugin, hookName) {
1510
+ const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
1629
1511
  `;
1630
- const pluginError = new PluginError(text, { cause: e, pluginManager: this });
1631
- this.eventEmitter.emit("error", pluginError);
1632
- throw pluginError;
1633
- };
1634
- _parse = new WeakSet();
1635
- parse_fn = function(plugin, pluginManager, context) {
1636
- const usedPluginNames = __privateGet(pluginManager, _usedPluginNames);
1637
- setUniqueName(plugin.name, usedPluginNames);
1638
- const key = plugin.key || [plugin.kind, plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
1639
- if (plugin.name !== "core" && usedPluginNames[plugin.name] >= 2) {
1640
- pluginManager.logger.warn("Using multiple of the same plugin is an experimental feature");
1641
- }
1642
- if (!plugin.transform) {
1643
- plugin.transform = function transform(code) {
1644
- return code;
1645
- };
1646
- }
1647
- if (plugin.api && typeof plugin.api === "function") {
1648
- const api = plugin.api.call(context);
1649
- return {
1650
- ...plugin,
1651
- key,
1652
- api
1653
- };
1512
+ const pluginError = new PluginError(text, { cause: e, pluginManager: this });
1513
+ this.eventEmitter.emit("error", pluginError);
1514
+ throw pluginError;
1654
1515
  }
1655
- return {
1656
- ...plugin,
1657
- key
1658
- };
1516
+ };
1517
+ function noReturn() {
1518
+ }
1519
+
1520
+ // src/managers/pluginManager/validate.ts
1521
+ var ValidationPluginError = class extends Error {
1522
+ };
1523
+ function getDependedPlugins(plugins, dependedPluginNames) {
1524
+ let pluginNames = [];
1525
+ if (typeof dependedPluginNames === "string") {
1526
+ pluginNames = [dependedPluginNames];
1527
+ } else {
1528
+ pluginNames = dependedPluginNames;
1529
+ }
1530
+ return pluginNames.map((pluginName2) => {
1531
+ const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
1532
+ if (!plugin) {
1533
+ throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
1534
+ }
1535
+ return plugin;
1536
+ });
1537
+ }
1538
+
1539
+ // src/types.ts
1540
+ var LogLevel = {
1541
+ silent: "silent",
1542
+ info: "info",
1543
+ debug: "debug"
1659
1544
  };
1660
1545
 
1661
1546
  // src/build.ts
@@ -1663,13 +1548,13 @@ async function transformReducer(_previousCode, result, _plugin) {
1663
1548
  return result;
1664
1549
  }
1665
1550
  async function build(options) {
1666
- const { config, logger = createLogger({ logLevel: LogLevel.silent }) } = options;
1551
+ const { config, logLevel, logger = createLogger() } = options;
1667
1552
  try {
1668
- if (isInputPath(config) && !new URLPath(config.input.path).isURL) {
1553
+ if ("path" in config.input && !new URLPath(config.input.path).isURL) {
1669
1554
  await read(config.input.path);
1670
1555
  }
1671
1556
  } catch (e) {
1672
- if (isInputPath(config)) {
1557
+ if ("path" in config.input) {
1673
1558
  throw new Error(
1674
1559
  "Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config " + pc3.dim(config.input.path),
1675
1560
  {
@@ -1682,11 +1567,11 @@ async function build(options) {
1682
1567
  await clean(config.output.path);
1683
1568
  }
1684
1569
  const queueTask = async (file) => {
1685
- const { path: path3 } = file;
1686
- let code = FileManager.getSource(file);
1570
+ const { path } = file;
1571
+ let code = createFileSource(file);
1687
1572
  const { result: loadedResult } = await pluginManager.hookFirst({
1688
1573
  hookName: "load",
1689
- parameters: [path3]
1574
+ parameters: [path]
1690
1575
  });
1691
1576
  if (loadedResult && isPromise(loadedResult)) {
1692
1577
  code = await loadedResult;
@@ -1697,53 +1582,28 @@ async function build(options) {
1697
1582
  if (code) {
1698
1583
  const transformedCode = await pluginManager.hookReduceArg0({
1699
1584
  hookName: "transform",
1700
- parameters: [code, path3],
1585
+ parameters: [code, path],
1701
1586
  reduce: transformReducer
1702
1587
  });
1703
1588
  if (config.output.write || config.output.write === void 0) {
1704
- if (file.meta?.pluginKey) {
1705
- return pluginManager.hookForPlugin({
1706
- pluginKey: file.meta?.pluginKey,
1707
- hookName: "writeFile",
1708
- parameters: [transformedCode, path3]
1709
- });
1710
- }
1711
- return pluginManager.hookFirst({
1589
+ await pluginManager.hookParallel({
1712
1590
  hookName: "writeFile",
1713
- parameters: [transformedCode, path3]
1591
+ parameters: [transformedCode, path]
1714
1592
  });
1715
1593
  }
1716
1594
  }
1717
1595
  };
1718
- const pluginManager = new PluginManager(config, { logger, task: queueTask, writeTimeout: 0 });
1596
+ const pluginManager = new PluginManager(config, { debug: logLevel === LogLevel.debug, logger, task: queueTask });
1719
1597
  const { plugins, fileManager } = pluginManager;
1720
1598
  pluginManager.on("execute", (executer) => {
1721
- const { hookName, parameters, plugin } = executer;
1722
- if (hookName === "writeFile" && logger.spinner) {
1723
- const [code] = parameters;
1724
- if (logger.logLevel === LogLevel.info) {
1725
- logger.spinner.start(`\u{1F4BE} Writing`);
1726
- }
1727
- if (logger.logLevel === "debug") {
1728
- logger.info(`PluginKey ${pc3.dim(JSON.stringify(plugin.key))}
1729
- with source
1730
-
1731
- ${code}`);
1732
- }
1733
- }
1734
- });
1735
- pluginManager.on("executed", (executer) => {
1736
1599
  const { hookName, plugin, output, parameters } = executer;
1737
1600
  const messsage = `${randomPicoColour(plugin.name)} Executing ${hookName}`;
1738
- if (logger.logLevel === LogLevel.info && logger.spinner) {
1739
- if (hookName === "writeFile") {
1740
- const [_code, path3] = parameters;
1741
- logger.spinner.suffixText = pc3.dim(path3);
1742
- } else {
1601
+ if (logLevel === LogLevel.info) {
1602
+ if (logger.spinner) {
1743
1603
  logger.spinner.suffixText = messsage;
1744
1604
  }
1745
1605
  }
1746
- if (logger.logLevel === LogLevel.debug) {
1606
+ if (logLevel === LogLevel.debug) {
1747
1607
  logger.info(messsage);
1748
1608
  const logs = [
1749
1609
  parameters && `${pc3.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,
@@ -1763,72 +1623,74 @@ ${code}`);
1763
1623
  parameters: [config]
1764
1624
  });
1765
1625
  await pluginManager.hookParallel({ hookName: "buildEnd" });
1766
- if (!fileManager.isExecuting && logger.spinner) {
1767
- logger.spinner.suffixText = "";
1768
- logger.spinner.succeed(`\u{1F4BE} Writing completed`);
1769
- }
1770
- return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager };
1626
+ return { files: fileManager.files.map((file) => ({ ...file, source: createFileSource(file) })), pluginManager };
1627
+ }
1628
+
1629
+ // src/config.ts
1630
+ function defineConfig(options) {
1631
+ return options;
1771
1632
  }
1772
1633
 
1773
- // src/Generator.ts
1774
- var _options3, _context;
1634
+ // src/generators/Generator.ts
1775
1635
  var Generator = class {
1636
+ #options = {};
1637
+ #context = {};
1776
1638
  constructor(options, context) {
1777
- __privateAdd(this, _options3, {});
1778
- __privateAdd(this, _context, {});
1779
1639
  if (context) {
1780
- __privateSet(this, _context, context);
1640
+ this.#context = context;
1781
1641
  }
1782
1642
  if (options) {
1783
- __privateSet(this, _options3, options);
1643
+ this.#options = options;
1784
1644
  }
1785
1645
  return this;
1786
1646
  }
1787
1647
  get options() {
1788
- return __privateGet(this, _options3);
1648
+ return this.#options;
1789
1649
  }
1790
1650
  get context() {
1791
- return __privateGet(this, _context);
1651
+ return this.#context;
1792
1652
  }
1793
1653
  set options(options) {
1794
- __privateSet(this, _options3, { ...__privateGet(this, _options3), ...options });
1654
+ this.#options = { ...this.#options, ...options };
1795
1655
  }
1796
1656
  };
1797
- _options3 = new WeakMap();
1798
- _context = new WeakMap();
1799
- var _cache2, _cwd, _SLASHES;
1800
- var _PackageManager = class _PackageManager {
1657
+
1658
+ // src/generators/SchemaGenerator.ts
1659
+ var SchemaGenerator = class extends Generator {
1660
+ };
1661
+ var PackageManager = class _PackageManager {
1662
+ static #cache = {};
1663
+ #cwd;
1664
+ #SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
1801
1665
  constructor(workspace) {
1802
- __privateAdd(this, _cwd, void 0);
1803
- __privateAdd(this, _SLASHES, /* @__PURE__ */ new Set(["/", "\\"]));
1804
1666
  if (workspace) {
1805
- __privateSet(this, _cwd, workspace);
1667
+ this.#cwd = workspace;
1806
1668
  }
1807
1669
  return this;
1808
1670
  }
1809
1671
  set workspace(workspace) {
1810
- __privateSet(this, _cwd, workspace);
1672
+ this.#cwd = workspace;
1811
1673
  }
1812
1674
  get workspace() {
1813
- return __privateGet(this, _cwd);
1675
+ return this.#cwd;
1814
1676
  }
1815
1677
  normalizeDirectory(directory) {
1816
- if (!__privateGet(this, _SLASHES).has(directory[directory.length - 1])) {
1678
+ if (!this.#SLASHES.has(directory[directory.length - 1])) {
1817
1679
  return `${directory}/`;
1818
1680
  }
1819
1681
  return directory;
1820
1682
  }
1821
- getLocation(path3) {
1822
- let location = path3;
1823
- if (__privateGet(this, _cwd)) {
1824
- const require2 = mod.createRequire(this.normalizeDirectory(__privateGet(this, _cwd)));
1825
- location = require2.resolve(path3);
1683
+ getLocation(path) {
1684
+ let location = path;
1685
+ if (this.#cwd) {
1686
+ const require2 = mod.createRequire(this.normalizeDirectory(this.#cwd));
1687
+ location = require2.resolve(path);
1826
1688
  }
1827
1689
  return location;
1828
1690
  }
1829
- async import(path3) {
1691
+ async import(path) {
1830
1692
  try {
1831
- let location = this.getLocation(path3);
1693
+ let location = this.getLocation(path);
1832
1694
  if (os.platform() == "win32") {
1833
1695
  location = pathToFileURL(location).href;
1834
1696
  }
@@ -1841,7 +1703,7 @@ var _PackageManager = class _PackageManager {
1841
1703
  }
1842
1704
  async getPackageJSON() {
1843
1705
  const pkgPath = await findUp(["package.json"], {
1844
- cwd: __privateGet(this, _cwd)
1706
+ cwd: this.#cwd
1845
1707
  });
1846
1708
  if (!pkgPath) {
1847
1709
  return void 0;
@@ -1850,7 +1712,7 @@ var _PackageManager = class _PackageManager {
1850
1712
  }
1851
1713
  getPackageJSONSync() {
1852
1714
  const pkgPath = findUpSync(["package.json"], {
1853
- cwd: __privateGet(this, _cwd)
1715
+ cwd: this.#cwd
1854
1716
  });
1855
1717
  if (!pkgPath) {
1856
1718
  return void 0;
@@ -1858,11 +1720,11 @@ var _PackageManager = class _PackageManager {
1858
1720
  return __require(pkgPath);
1859
1721
  }
1860
1722
  static setVersion(dependency, version) {
1861
- __privateGet(_PackageManager, _cache2)[dependency] = version;
1723
+ _PackageManager.#cache[dependency] = version;
1862
1724
  }
1863
1725
  async getVersion(dependency) {
1864
- if (__privateGet(_PackageManager, _cache2)[dependency]) {
1865
- return __privateGet(_PackageManager, _cache2)[dependency];
1726
+ if (_PackageManager.#cache[dependency]) {
1727
+ return _PackageManager.#cache[dependency];
1866
1728
  }
1867
1729
  const packageJSON = await this.getPackageJSON();
1868
1730
  if (!packageJSON) {
@@ -1871,8 +1733,8 @@ var _PackageManager = class _PackageManager {
1871
1733
  return packageJSON["dependencies"]?.[dependency] || packageJSON["devDependencies"]?.[dependency];
1872
1734
  }
1873
1735
  getVersionSync(dependency) {
1874
- if (__privateGet(_PackageManager, _cache2)[dependency]) {
1875
- return __privateGet(_PackageManager, _cache2)[dependency];
1736
+ if (_PackageManager.#cache[dependency]) {
1737
+ return _PackageManager.#cache[dependency];
1876
1738
  }
1877
1739
  const packageJSON = this.getPackageJSONSync();
1878
1740
  if (!packageJSON) {
@@ -1903,19 +1765,10 @@ var _PackageManager = class _PackageManager {
1903
1765
  return satisfies(semVer, version);
1904
1766
  }
1905
1767
  };
1906
- _cache2 = new WeakMap();
1907
- _cwd = new WeakMap();
1908
- _SLASHES = new WeakMap();
1909
- __privateAdd(_PackageManager, _cache2, {});
1910
- var PackageManager = _PackageManager;
1911
-
1912
- // src/SchemaGenerator.ts
1913
- var SchemaGenerator = class extends Generator {
1914
- };
1915
1768
 
1916
1769
  // src/index.ts
1917
1770
  var src_default = build;
1918
1771
 
1919
- export { FileManager, Generator, PackageManager, ParallelPluginError, PluginError, PluginManager, PromiseManager, SchemaGenerator, SummaryError, ValidationPluginError, Warning, build, combineExports, combineImports, createPlugin, src_default as default, defineConfig, isInputPath, pluginName as name, pluginName };
1772
+ export { FileManager, FunctionParams, Generator, LogLevel, PackageManager, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, clean, combineCodes, combineExports, combineFiles, combineImports, createFileSource, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, escape, extensions, getDependedPlugins, getIndexes, getPathMode, getRelativePath, getUniqueName, hooks, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, jsStringEscape, pluginName as name, nameSorter, pluginName, randomColour, randomPicoColour, read, readSync, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
1920
1773
  //# sourceMappingURL=out.js.map
1921
1774
  //# sourceMappingURL=index.js.map