@kubb/core 2.0.0-canary.20231030T124950 → 2.0.0
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/chunk-4A7WG6IA.js +128 -0
- package/dist/chunk-4A7WG6IA.js.map +1 -0
- package/dist/chunk-54P4AWHI.js +71 -0
- package/dist/chunk-54P4AWHI.js.map +1 -0
- package/dist/chunk-5TK7TMV6.cjs +131 -0
- package/dist/chunk-5TK7TMV6.cjs.map +1 -0
- package/dist/chunk-7S67BJXQ.js +85 -0
- package/dist/chunk-7S67BJXQ.js.map +1 -0
- package/dist/chunk-E3ANGQ5N.cjs +2290 -0
- package/dist/chunk-E3ANGQ5N.cjs.map +1 -0
- package/dist/chunk-H47IKRXJ.cjs +129 -0
- package/dist/chunk-H47IKRXJ.cjs.map +1 -0
- package/dist/chunk-HIE46T3F.js +129 -0
- package/dist/chunk-HIE46T3F.js.map +1 -0
- package/dist/chunk-K2H7BYQB.js +155 -0
- package/dist/chunk-K2H7BYQB.js.map +1 -0
- package/dist/chunk-NAWI7UXW.js +67 -0
- package/dist/chunk-NAWI7UXW.js.map +1 -0
- package/dist/chunk-PLVKILIY.cjs +162 -0
- package/dist/chunk-PLVKILIY.cjs.map +1 -0
- package/dist/chunk-W2FP7ZWW.cjs +71 -0
- package/dist/chunk-W2FP7ZWW.cjs.map +1 -0
- package/dist/chunk-WZQO3EPM.cjs +91 -0
- package/dist/chunk-WZQO3EPM.cjs.map +1 -0
- package/dist/chunk-XDHI63G7.cjs +104 -0
- package/dist/chunk-XDHI63G7.cjs.map +1 -0
- package/dist/chunk-XPOF4D5N.js +18 -0
- package/dist/chunk-XPOF4D5N.js.map +1 -0
- package/dist/fs.cjs +31 -0
- package/dist/fs.cjs.map +1 -0
- package/dist/fs.d.cts +5 -0
- package/dist/fs.d.ts +5 -0
- package/dist/fs.js +11 -0
- package/dist/fs.js.map +1 -0
- package/dist/index.cjs +1866 -977
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +302 -319
- package/dist/index.d.ts +302 -319
- package/dist/index.js +1071 -846
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +26 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +32 -0
- package/dist/logger.d.ts +32 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +1 -0
- package/dist/transformers.cjs +124 -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 +95 -0
- package/dist/transformers.js.map +1 -0
- package/dist/utils.cjs +23 -1163
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -143
- package/dist/utils.d.ts +2 -143
- package/dist/utils.js +15 -1118
- package/dist/utils.js.map +1 -1
- package/dist/write-A6VgHkYA.d.cts +10 -0
- package/dist/write-A6VgHkYA.d.ts +10 -0
- package/package.json +40 -23
- package/src/BarrelManager.ts +113 -0
- package/src/FileManager.ts +581 -0
- package/src/Generator.ts +34 -0
- package/src/PackageManager.ts +178 -0
- package/src/PluginManager.ts +645 -0
- package/src/PromiseManager.ts +51 -0
- package/src/build.ts +221 -0
- package/src/config.ts +22 -0
- package/src/errors.ts +12 -0
- package/src/fs/clean.ts +5 -0
- package/src/fs/index.ts +3 -0
- package/src/fs/read.ts +68 -0
- package/src/fs/write.ts +79 -0
- package/src/index.ts +27 -0
- package/src/logger.ts +121 -0
- package/src/plugin.ts +80 -0
- package/src/transformers/casing.ts +9 -0
- package/src/transformers/combineCodes.ts +3 -0
- package/src/transformers/createJSDocBlockText.ts +9 -0
- package/src/transformers/escape.ts +31 -0
- package/src/transformers/indent.ts +3 -0
- package/src/transformers/index.ts +36 -0
- package/src/transformers/nameSorter.ts +9 -0
- package/src/transformers/searchAndReplace.ts +25 -0
- package/src/transformers/transformReservedWord.ts +97 -0
- package/src/transformers/trim.ts +7 -0
- package/src/types.ts +334 -0
- package/src/utils/EventEmitter.ts +24 -0
- package/src/utils/FunctionParams.ts +86 -0
- package/src/utils/TreeNode.ts +125 -0
- package/src/utils/URLPath.ts +133 -0
- package/src/utils/cache.ts +35 -0
- package/src/utils/executeStrategies.ts +83 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/promise.ts +13 -0
- package/src/utils/renderTemplate.ts +31 -0
- package/src/utils/timeout.ts +7 -0
- package/src/utils/uniqueName.ts +20 -0
package/dist/utils.cjs
CHANGED
|
@@ -1,110 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkH47IKRXJ_cjs = require('./chunk-H47IKRXJ.cjs');
|
|
4
|
+
var chunkXDHI63G7_cjs = require('./chunk-XDHI63G7.cjs');
|
|
5
|
+
var chunkWZQO3EPM_cjs = require('./chunk-WZQO3EPM.cjs');
|
|
5
6
|
var naturalOrderby = require('natural-orderby');
|
|
6
|
-
var pc2 = require('picocolors');
|
|
7
|
-
var crypto = require('crypto');
|
|
8
|
-
var perf_hooks = require('perf_hooks');
|
|
9
|
-
var events = require('events');
|
|
10
|
-
var seedrandom = require('seedrandom');
|
|
11
|
-
var path = require('path');
|
|
12
|
-
var jsRuntime = require('js-runtime');
|
|
13
|
-
var dirTree = require('directory-tree');
|
|
14
|
-
var parser = require('@kubb/parser');
|
|
15
|
-
var factory = require('@kubb/parser/factory');
|
|
16
|
-
var isEqual = require('lodash.isequal');
|
|
17
7
|
|
|
18
|
-
|
|
8
|
+
// src/utils/index.ts
|
|
9
|
+
chunkWZQO3EPM_cjs.init_cjs_shims();
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var n = Object.create(null);
|
|
23
|
-
if (e) {
|
|
24
|
-
Object.keys(e).forEach(function (k) {
|
|
25
|
-
if (k !== 'default') {
|
|
26
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return e[k]; }
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
n.default = e;
|
|
35
|
-
return Object.freeze(n);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
39
|
-
var pc2__default = /*#__PURE__*/_interopDefault(pc2);
|
|
40
|
-
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
41
|
-
var seedrandom__default = /*#__PURE__*/_interopDefault(seedrandom);
|
|
42
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
43
|
-
var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
|
|
44
|
-
var factory__namespace = /*#__PURE__*/_interopNamespace(factory);
|
|
45
|
-
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
46
|
-
|
|
47
|
-
var __accessCheck = (obj, member, msg) => {
|
|
48
|
-
if (!member.has(obj))
|
|
49
|
-
throw TypeError("Cannot " + msg);
|
|
50
|
-
};
|
|
51
|
-
var __privateGet = (obj, member, getter) => {
|
|
52
|
-
__accessCheck(obj, member, "read from private field");
|
|
53
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
54
|
-
};
|
|
55
|
-
var __privateAdd = (obj, member, value) => {
|
|
56
|
-
if (member.has(obj))
|
|
57
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
58
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
59
|
-
};
|
|
60
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
61
|
-
__accessCheck(obj, member, "write to private field");
|
|
62
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
63
|
-
return value;
|
|
64
|
-
};
|
|
65
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
66
|
-
set _(value) {
|
|
67
|
-
__privateSet(obj, member, value, setter);
|
|
68
|
-
},
|
|
69
|
-
get _() {
|
|
70
|
-
return __privateGet(obj, member, getter);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
var __privateMethod = (obj, member, method) => {
|
|
74
|
-
__accessCheck(obj, member, "access private method");
|
|
75
|
-
return method;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// src/utils/cache.ts
|
|
79
|
-
function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
80
|
-
return {
|
|
81
|
-
set(id, value) {
|
|
82
|
-
Store[id] = [0, value];
|
|
83
|
-
},
|
|
84
|
-
get(id) {
|
|
85
|
-
const item = Store[id];
|
|
86
|
-
if (!item) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
item[0] = 0;
|
|
90
|
-
return item[1];
|
|
91
|
-
},
|
|
92
|
-
has(id) {
|
|
93
|
-
const item = Store[id];
|
|
94
|
-
if (!item) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
item[0] = 0;
|
|
98
|
-
return true;
|
|
99
|
-
},
|
|
100
|
-
delete(id) {
|
|
101
|
-
return delete Store[id];
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
async function clean(path2) {
|
|
106
|
-
return fs2.remove(path2);
|
|
107
|
-
}
|
|
11
|
+
// src/utils/FunctionParams.ts
|
|
12
|
+
chunkWZQO3EPM_cjs.init_cjs_shims();
|
|
108
13
|
var FunctionParams = class {
|
|
109
14
|
constructor(type) {
|
|
110
15
|
this.items = [];
|
|
@@ -129,7 +34,7 @@ var FunctionParams = class {
|
|
|
129
34
|
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
130
35
|
return acc;
|
|
131
36
|
}
|
|
132
|
-
const parameterName = name.startsWith("{") ? name :
|
|
37
|
+
const parameterName = name.startsWith("{") ? name : chunkXDHI63G7_cjs.camelCase(name);
|
|
133
38
|
if (type) {
|
|
134
39
|
if (required) {
|
|
135
40
|
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
@@ -143,50 +48,9 @@ var FunctionParams = class {
|
|
|
143
48
|
}, []).join(", ");
|
|
144
49
|
}
|
|
145
50
|
};
|
|
146
|
-
var LogLevel = {
|
|
147
|
-
silent: "silent",
|
|
148
|
-
info: "info",
|
|
149
|
-
debug: "debug"
|
|
150
|
-
};
|
|
151
|
-
function createLogger({ logLevel, name, spinner }) {
|
|
152
|
-
const logs = [];
|
|
153
|
-
const log = (message) => {
|
|
154
|
-
if (message && spinner) {
|
|
155
|
-
spinner.text = message;
|
|
156
|
-
logs.push(message);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const error = (message) => {
|
|
160
|
-
if (message) {
|
|
161
|
-
throw new Error(message || "Something went wrong");
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
const warn = (message) => {
|
|
165
|
-
if (message && spinner) {
|
|
166
|
-
spinner.warn(pc2__default.default.yellow(message));
|
|
167
|
-
logs.push(message);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const info = (message) => {
|
|
171
|
-
if (message && spinner) {
|
|
172
|
-
spinner.info(message);
|
|
173
|
-
logs.push(message);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
const logger = {
|
|
177
|
-
name,
|
|
178
|
-
logLevel,
|
|
179
|
-
log,
|
|
180
|
-
error,
|
|
181
|
-
warn,
|
|
182
|
-
info,
|
|
183
|
-
spinner,
|
|
184
|
-
logs
|
|
185
|
-
};
|
|
186
|
-
return logger;
|
|
187
|
-
}
|
|
188
51
|
|
|
189
52
|
// src/utils/promise.ts
|
|
53
|
+
chunkWZQO3EPM_cjs.init_cjs_shims();
|
|
190
54
|
function isPromise(result) {
|
|
191
55
|
return !!result && typeof result?.then === "function";
|
|
192
56
|
}
|
|
@@ -196,173 +60,9 @@ function isPromiseFulfilledResult(result) {
|
|
|
196
60
|
function isPromiseRejectedResult(result) {
|
|
197
61
|
return result.status === "rejected";
|
|
198
62
|
}
|
|
199
|
-
var _emitter;
|
|
200
|
-
var EventEmitter = class {
|
|
201
|
-
constructor() {
|
|
202
|
-
__privateAdd(this, _emitter, new events.EventEmitter());
|
|
203
|
-
__privateGet(this, _emitter).setMaxListeners(100);
|
|
204
|
-
}
|
|
205
|
-
emit(eventName, ...eventArg) {
|
|
206
|
-
__privateGet(this, _emitter).emit(eventName, ...eventArg);
|
|
207
|
-
}
|
|
208
|
-
on(eventName, handler) {
|
|
209
|
-
__privateGet(this, _emitter).on(eventName, handler);
|
|
210
|
-
}
|
|
211
|
-
off(eventName, handler) {
|
|
212
|
-
__privateGet(this, _emitter).off(eventName, handler);
|
|
213
|
-
}
|
|
214
|
-
removeAll() {
|
|
215
|
-
__privateGet(this, _emitter).removeAllListeners();
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
_emitter = new WeakMap();
|
|
219
|
-
|
|
220
|
-
// src/utils/Queue.ts
|
|
221
|
-
var _queue, _workerCount, _maxParallel, _debug, _work, work_fn;
|
|
222
|
-
var Queue = class {
|
|
223
|
-
constructor(maxParallel, debug = false) {
|
|
224
|
-
__privateAdd(this, _work);
|
|
225
|
-
__privateAdd(this, _queue, []);
|
|
226
|
-
this.eventEmitter = new EventEmitter();
|
|
227
|
-
__privateAdd(this, _workerCount, 0);
|
|
228
|
-
__privateAdd(this, _maxParallel, void 0);
|
|
229
|
-
__privateAdd(this, _debug, false);
|
|
230
|
-
__privateSet(this, _maxParallel, maxParallel);
|
|
231
|
-
__privateSet(this, _debug, debug);
|
|
232
|
-
}
|
|
233
|
-
run(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
234
|
-
return new Promise((resolve2, reject) => {
|
|
235
|
-
const item = { reject, resolve: resolve2, job, name: options.name, description: options.description || options.name };
|
|
236
|
-
options.controller?.signal.addEventListener("abort", () => {
|
|
237
|
-
__privateSet(this, _queue, __privateGet(this, _queue).filter((queueItem) => queueItem.name === item.name));
|
|
238
|
-
reject("Aborted");
|
|
239
|
-
});
|
|
240
|
-
__privateGet(this, _queue).push(item);
|
|
241
|
-
__privateMethod(this, _work, work_fn).call(this);
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
runSync(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
245
|
-
new Promise((resolve2, reject) => {
|
|
246
|
-
const item = { reject, resolve: resolve2, job, name: options.name, description: options.description || options.name };
|
|
247
|
-
options.controller?.signal.addEventListener("abort", () => {
|
|
248
|
-
__privateSet(this, _queue, __privateGet(this, _queue).filter((queueItem) => queueItem.name === item.name));
|
|
249
|
-
});
|
|
250
|
-
__privateGet(this, _queue).push(item);
|
|
251
|
-
__privateMethod(this, _work, work_fn).call(this);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
get hasJobs() {
|
|
255
|
-
return __privateGet(this, _workerCount) > 0 || __privateGet(this, _queue).length > 0;
|
|
256
|
-
}
|
|
257
|
-
get count() {
|
|
258
|
-
return __privateGet(this, _workerCount);
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
_queue = new WeakMap();
|
|
262
|
-
_workerCount = new WeakMap();
|
|
263
|
-
_maxParallel = new WeakMap();
|
|
264
|
-
_debug = new WeakMap();
|
|
265
|
-
_work = new WeakSet();
|
|
266
|
-
work_fn = function() {
|
|
267
|
-
if (__privateGet(this, _workerCount) >= __privateGet(this, _maxParallel)) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
__privateWrapper(this, _workerCount)._++;
|
|
271
|
-
let entry;
|
|
272
|
-
while (entry = __privateGet(this, _queue).shift()) {
|
|
273
|
-
const { reject, resolve: resolve2, job, name, description } = entry;
|
|
274
|
-
if (__privateGet(this, _debug)) {
|
|
275
|
-
perf_hooks.performance.mark(name + "_start");
|
|
276
|
-
}
|
|
277
|
-
job().then((result) => {
|
|
278
|
-
this.eventEmitter.emit("jobDone", result);
|
|
279
|
-
resolve2(result);
|
|
280
|
-
if (__privateGet(this, _debug)) {
|
|
281
|
-
perf_hooks.performance.mark(name + "_stop");
|
|
282
|
-
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
283
|
-
}
|
|
284
|
-
}).catch((err) => {
|
|
285
|
-
this.eventEmitter.emit("jobFailed", err);
|
|
286
|
-
reject(err);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
__privateWrapper(this, _workerCount)._--;
|
|
290
|
-
};
|
|
291
|
-
var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
292
|
-
function randomColour(text, colours = defaultColours) {
|
|
293
|
-
if (!text) {
|
|
294
|
-
return "white";
|
|
295
|
-
}
|
|
296
|
-
const random = seedrandom__default.default(text);
|
|
297
|
-
const colour = colours.at(Math.floor(random() * colours.length)) || "white";
|
|
298
|
-
return colour;
|
|
299
|
-
}
|
|
300
|
-
function randomPicoColour(text, colors = defaultColours) {
|
|
301
|
-
const colours = pc2__default.default.createColors(true);
|
|
302
|
-
if (!text) {
|
|
303
|
-
return colours.white(text);
|
|
304
|
-
}
|
|
305
|
-
const colour = randomColour(text, colors);
|
|
306
|
-
const isDark = colour.includes("dark");
|
|
307
|
-
const key = colour.replace("dark", "").toLowerCase();
|
|
308
|
-
const formatter = colours[key];
|
|
309
|
-
if (isDark) {
|
|
310
|
-
return pc2__default.default.bold(formatter(text));
|
|
311
|
-
}
|
|
312
|
-
if (typeof formatter !== "function") {
|
|
313
|
-
throw new Error("Formatter for picoColor is not of type function/Formatter");
|
|
314
|
-
}
|
|
315
|
-
return formatter(text);
|
|
316
|
-
}
|
|
317
|
-
function slash(path2, platform = "linux") {
|
|
318
|
-
const isWindowsPath = /^\\\\\?\\/.test(path2);
|
|
319
|
-
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
320
|
-
return path2.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
321
|
-
}
|
|
322
|
-
return path2.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
323
|
-
}
|
|
324
|
-
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
325
|
-
if (!rootDir || !filePath) {
|
|
326
|
-
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
327
|
-
}
|
|
328
|
-
const relativePath = path.relative(rootDir, filePath);
|
|
329
|
-
const slashedPath = slash(relativePath, platform);
|
|
330
|
-
if (slashedPath.startsWith("../")) {
|
|
331
|
-
return slashedPath.replace(path.basename(slashedPath), path.basename(slashedPath, path.extname(filePath)));
|
|
332
|
-
}
|
|
333
|
-
return `./${slashedPath.replace(path.basename(slashedPath), path.basename(slashedPath, path.extname(filePath)))}`;
|
|
334
|
-
}
|
|
335
|
-
var reader = jsRuntime.switcher(
|
|
336
|
-
{
|
|
337
|
-
node: async (path2) => {
|
|
338
|
-
return fs2__default.default.readFile(path2, { encoding: "utf8" });
|
|
339
|
-
},
|
|
340
|
-
bun: async (path2) => {
|
|
341
|
-
const file = Bun.file(path2);
|
|
342
|
-
return file.text();
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
"node"
|
|
346
|
-
);
|
|
347
|
-
var syncReader = jsRuntime.switcher(
|
|
348
|
-
{
|
|
349
|
-
node: (path2) => {
|
|
350
|
-
return fs2__default.default.readFileSync(path2, { encoding: "utf8" });
|
|
351
|
-
},
|
|
352
|
-
bun: () => {
|
|
353
|
-
throw new Error("Bun cannot read sync");
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
"node"
|
|
357
|
-
);
|
|
358
|
-
async function read(path2) {
|
|
359
|
-
return reader(path2);
|
|
360
|
-
}
|
|
361
|
-
function readSync(path2) {
|
|
362
|
-
return syncReader(path2);
|
|
363
|
-
}
|
|
364
63
|
|
|
365
64
|
// src/utils/renderTemplate.ts
|
|
65
|
+
chunkWZQO3EPM_cjs.init_cjs_shims();
|
|
366
66
|
function renderTemplate(template, data = void 0) {
|
|
367
67
|
if (!data || !Object.keys(data).length) {
|
|
368
68
|
return template.replace(/{{(.*?)}}/g, "");
|
|
@@ -386,873 +86,33 @@ function renderTemplate(template, data = void 0) {
|
|
|
386
86
|
}, template) || "";
|
|
387
87
|
}
|
|
388
88
|
|
|
389
|
-
// src/utils/throttle.ts
|
|
390
|
-
var throttle = (fn, delay) => {
|
|
391
|
-
let wait = false;
|
|
392
|
-
let timeout2;
|
|
393
|
-
let cancelled = false;
|
|
394
|
-
return [
|
|
395
|
-
(...args) => {
|
|
396
|
-
if (cancelled) {
|
|
397
|
-
return void 0;
|
|
398
|
-
}
|
|
399
|
-
if (wait) {
|
|
400
|
-
return void 0;
|
|
401
|
-
}
|
|
402
|
-
const val = fn(...args);
|
|
403
|
-
wait = true;
|
|
404
|
-
timeout2 = setTimeout(() => {
|
|
405
|
-
wait = false;
|
|
406
|
-
}, delay);
|
|
407
|
-
return val;
|
|
408
|
-
},
|
|
409
|
-
() => {
|
|
410
|
-
cancelled = true;
|
|
411
|
-
clearTimeout(timeout2);
|
|
412
|
-
}
|
|
413
|
-
];
|
|
414
|
-
};
|
|
415
|
-
|
|
416
89
|
// src/utils/timeout.ts
|
|
90
|
+
chunkWZQO3EPM_cjs.init_cjs_shims();
|
|
417
91
|
async function timeout(ms) {
|
|
418
|
-
return new Promise((
|
|
92
|
+
return new Promise((resolve) => {
|
|
419
93
|
setTimeout(() => {
|
|
420
|
-
|
|
94
|
+
resolve(true);
|
|
421
95
|
}, ms);
|
|
422
96
|
});
|
|
423
97
|
}
|
|
424
98
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
function
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
return "";
|
|
435
|
-
}
|
|
436
|
-
return `/**
|
|
437
|
-
* ${filteredComments.join("\n * ")}
|
|
438
|
-
*/`;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
// src/utils/transformers/escape.ts
|
|
442
|
-
function escape(text) {
|
|
443
|
-
return text ? text.replaceAll("`", "\\`") : "";
|
|
444
|
-
}
|
|
445
|
-
function jsStringEscape(input) {
|
|
446
|
-
return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
|
|
447
|
-
switch (character) {
|
|
448
|
-
case '"':
|
|
449
|
-
case "'":
|
|
450
|
-
case "\\":
|
|
451
|
-
return "\\" + character;
|
|
452
|
-
case "\n":
|
|
453
|
-
return "\\n";
|
|
454
|
-
case "\r":
|
|
455
|
-
return "\\r";
|
|
456
|
-
case "\u2028":
|
|
457
|
-
return "\\u2028";
|
|
458
|
-
case "\u2029":
|
|
459
|
-
return "\\u2029";
|
|
460
|
-
default:
|
|
461
|
-
return "";
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
// src/utils/transformers/indent.ts
|
|
467
|
-
function createIndent(size) {
|
|
468
|
-
return Array.from({ length: size + 1 }).join(" ");
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// src/utils/transformers/nameSorter.ts
|
|
472
|
-
function nameSorter(a, b) {
|
|
473
|
-
if (a.name < b.name) {
|
|
474
|
-
return -1;
|
|
475
|
-
}
|
|
476
|
-
if (a.name > b.name) {
|
|
477
|
-
return 1;
|
|
478
|
-
}
|
|
479
|
-
return 0;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// src/utils/transformers/searchAndReplace.ts
|
|
483
|
-
function searchAndReplace(options) {
|
|
484
|
-
const { text, replaceBy, prefix = "", key } = options;
|
|
485
|
-
const searchValues = options.searchValues?.(prefix, key) || [
|
|
486
|
-
`${prefix}["${key}"]`,
|
|
487
|
-
`${prefix}['${key}']`,
|
|
488
|
-
`${prefix}[\`${key}\`]`,
|
|
489
|
-
`${prefix}"${key}"`,
|
|
490
|
-
`${prefix}'${key}'`,
|
|
491
|
-
`${prefix}\`${key}\``,
|
|
492
|
-
new RegExp(`${prefix}${key}`, "g")
|
|
493
|
-
];
|
|
494
|
-
return searchValues.reduce((prev, searchValue) => {
|
|
495
|
-
return prev.toString().replaceAll(searchValue, replaceBy);
|
|
496
|
-
}, text);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// src/utils/transformers/transformReservedWord.ts
|
|
500
|
-
var reservedWords = [
|
|
501
|
-
"abstract",
|
|
502
|
-
"arguments",
|
|
503
|
-
"boolean",
|
|
504
|
-
"break",
|
|
505
|
-
"byte",
|
|
506
|
-
"case",
|
|
507
|
-
"catch",
|
|
508
|
-
"char",
|
|
509
|
-
"class",
|
|
510
|
-
"const",
|
|
511
|
-
"continue",
|
|
512
|
-
"debugger",
|
|
513
|
-
"default",
|
|
514
|
-
"delete",
|
|
515
|
-
"do",
|
|
516
|
-
"double",
|
|
517
|
-
"else",
|
|
518
|
-
"enum",
|
|
519
|
-
"eval",
|
|
520
|
-
"export",
|
|
521
|
-
"extends",
|
|
522
|
-
"false",
|
|
523
|
-
"final",
|
|
524
|
-
"finally",
|
|
525
|
-
"float",
|
|
526
|
-
"for",
|
|
527
|
-
"function",
|
|
528
|
-
"goto",
|
|
529
|
-
"if",
|
|
530
|
-
"implements",
|
|
531
|
-
"import",
|
|
532
|
-
"in",
|
|
533
|
-
"instanceof",
|
|
534
|
-
"int",
|
|
535
|
-
"interface",
|
|
536
|
-
"let",
|
|
537
|
-
"long",
|
|
538
|
-
"native",
|
|
539
|
-
"new",
|
|
540
|
-
"null",
|
|
541
|
-
"package",
|
|
542
|
-
"private",
|
|
543
|
-
"protected",
|
|
544
|
-
"public",
|
|
545
|
-
"return",
|
|
546
|
-
"short",
|
|
547
|
-
"static",
|
|
548
|
-
"super",
|
|
549
|
-
"switch",
|
|
550
|
-
"synchronized",
|
|
551
|
-
"this",
|
|
552
|
-
"throw",
|
|
553
|
-
"throws",
|
|
554
|
-
"transient",
|
|
555
|
-
"true",
|
|
556
|
-
"try",
|
|
557
|
-
"typeof",
|
|
558
|
-
"var",
|
|
559
|
-
"void",
|
|
560
|
-
"volatile",
|
|
561
|
-
"while",
|
|
562
|
-
"with",
|
|
563
|
-
"yield",
|
|
564
|
-
"Array",
|
|
565
|
-
"Date",
|
|
566
|
-
"eval",
|
|
567
|
-
"function",
|
|
568
|
-
"hasOwnProperty",
|
|
569
|
-
"Infinity",
|
|
570
|
-
"isFinite",
|
|
571
|
-
"isNaN",
|
|
572
|
-
"isPrototypeOf",
|
|
573
|
-
"length",
|
|
574
|
-
"Math",
|
|
575
|
-
"name",
|
|
576
|
-
"NaN",
|
|
577
|
-
"Number",
|
|
578
|
-
"Object",
|
|
579
|
-
"prototype",
|
|
580
|
-
"String",
|
|
581
|
-
"toString",
|
|
582
|
-
"undefined",
|
|
583
|
-
"valueOf"
|
|
584
|
-
];
|
|
585
|
-
function transformReservedWord(word) {
|
|
586
|
-
if (word && reservedWords.includes(word) || word?.match(/^\d/)) {
|
|
587
|
-
return `_${word}`;
|
|
588
|
-
}
|
|
589
|
-
return word;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// src/utils/transformers/index.ts
|
|
593
|
-
var transformers = {
|
|
594
|
-
combineCodes,
|
|
595
|
-
escape,
|
|
596
|
-
jsStringEscape,
|
|
597
|
-
createIndent,
|
|
598
|
-
transformReservedWord,
|
|
599
|
-
nameSorter,
|
|
600
|
-
searchAndReplace,
|
|
601
|
-
JSDoc: {
|
|
602
|
-
createJSDocBlockText
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
async function saveCreateDirectory(path2) {
|
|
606
|
-
const passedPath = path.dirname(path.resolve(path2));
|
|
607
|
-
await fs2__default.default.mkdir(passedPath, { recursive: true });
|
|
608
|
-
}
|
|
609
|
-
var writer = jsRuntime.switcher(
|
|
610
|
-
{
|
|
611
|
-
node: async (path2, data) => {
|
|
612
|
-
try {
|
|
613
|
-
await fs2__default.default.stat(path.resolve(path2));
|
|
614
|
-
const oldContent = await fs2__default.default.readFile(path.resolve(path2), { encoding: "utf-8" });
|
|
615
|
-
if (oldContent?.toString() === data?.toString()) {
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
} catch (_err) {
|
|
619
|
-
}
|
|
620
|
-
await saveCreateDirectory(path2);
|
|
621
|
-
await fs2__default.default.writeFile(path.resolve(path2), data, { encoding: "utf-8" });
|
|
622
|
-
const savedData = await fs2__default.default.readFile(path.resolve(path2), { encoding: "utf-8" });
|
|
623
|
-
if (savedData?.toString() !== data?.toString()) {
|
|
624
|
-
throw new Error(`Sanity check failed for ${path2}
|
|
625
|
-
|
|
626
|
-
Data[${data.length}]:
|
|
627
|
-
${data}
|
|
628
|
-
|
|
629
|
-
Saved[${savedData.length}]:
|
|
630
|
-
${savedData}
|
|
631
|
-
`);
|
|
632
|
-
}
|
|
633
|
-
return savedData;
|
|
634
|
-
},
|
|
635
|
-
bun: async (path2, data) => {
|
|
636
|
-
try {
|
|
637
|
-
await saveCreateDirectory(path2);
|
|
638
|
-
await Bun.write(path.resolve(path2), data);
|
|
639
|
-
const file = Bun.file(path.resolve(path2));
|
|
640
|
-
const savedData = await file.text();
|
|
641
|
-
if (savedData?.toString() !== data?.toString()) {
|
|
642
|
-
throw new Error(`Sanity check failed for ${path2}
|
|
643
|
-
|
|
644
|
-
Data[${data.length}]:
|
|
645
|
-
${data}
|
|
646
|
-
|
|
647
|
-
Saved[${savedData.length}]:
|
|
648
|
-
${savedData}
|
|
649
|
-
`);
|
|
650
|
-
}
|
|
651
|
-
return savedData;
|
|
652
|
-
} catch (e) {
|
|
653
|
-
console.log(e, path.resolve(path2));
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
"node"
|
|
658
|
-
);
|
|
659
|
-
async function write(data, path2) {
|
|
660
|
-
if (data.trim() === "") {
|
|
661
|
-
return void 0;
|
|
662
|
-
}
|
|
663
|
-
return writer(path2, data.trim());
|
|
664
|
-
}
|
|
665
|
-
var _options;
|
|
666
|
-
var BarrelManager = class {
|
|
667
|
-
constructor(options = {}) {
|
|
668
|
-
__privateAdd(this, _options, {});
|
|
669
|
-
__privateSet(this, _options, options);
|
|
670
|
-
return this;
|
|
671
|
-
}
|
|
672
|
-
getIndexes(root, extName) {
|
|
673
|
-
const { treeNode = {}, isTypeOnly, filter, map, output, includeExt } = __privateGet(this, _options);
|
|
674
|
-
const extMapper = {
|
|
675
|
-
".ts": {
|
|
676
|
-
extensions: /\.ts/,
|
|
677
|
-
exclude: [/schemas/, /json/]
|
|
678
|
-
},
|
|
679
|
-
".json": {
|
|
680
|
-
extensions: /\.json/,
|
|
681
|
-
exclude: []
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...treeNode });
|
|
685
|
-
if (!tree) {
|
|
686
|
-
return null;
|
|
687
|
-
}
|
|
688
|
-
const fileReducer = (files2, currentTree) => {
|
|
689
|
-
if (!currentTree.children) {
|
|
690
|
-
return [];
|
|
691
|
-
}
|
|
692
|
-
if (currentTree.children?.length > 1) {
|
|
693
|
-
const indexPath = path__default.default.resolve(currentTree.data.path, "index.ts");
|
|
694
|
-
const exports = currentTree.children.filter(Boolean).map((file) => {
|
|
695
|
-
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
696
|
-
if (importPath.includes("index") && indexPath.includes("index")) {
|
|
697
|
-
return void 0;
|
|
698
|
-
}
|
|
699
|
-
return {
|
|
700
|
-
path: includeExt ? file.data.type === "directory" ? `${importPath}/index${extName}` : `${importPath}${extName}` : importPath,
|
|
701
|
-
isTypeOnly
|
|
702
|
-
};
|
|
703
|
-
}).filter(Boolean);
|
|
704
|
-
files2.push({
|
|
705
|
-
path: indexPath,
|
|
706
|
-
baseName: "index.ts",
|
|
707
|
-
source: "",
|
|
708
|
-
exports: output ? exports?.filter((item) => {
|
|
709
|
-
return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
|
|
710
|
-
}) : exports
|
|
711
|
-
});
|
|
712
|
-
} else {
|
|
713
|
-
currentTree.children?.forEach((child) => {
|
|
714
|
-
const indexPath = path__default.default.resolve(currentTree.data.path, "index.ts");
|
|
715
|
-
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
716
|
-
const exports = [
|
|
717
|
-
{
|
|
718
|
-
path: includeExt ? child.data.type === "directory" ? `${importPath}/index${extName}` : `${importPath}${extName}` : importPath,
|
|
719
|
-
isTypeOnly
|
|
720
|
-
}
|
|
721
|
-
];
|
|
722
|
-
files2.push({
|
|
723
|
-
path: indexPath,
|
|
724
|
-
baseName: "index.ts",
|
|
725
|
-
source: "",
|
|
726
|
-
exports: output ? exports?.filter((item) => {
|
|
727
|
-
return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
|
|
728
|
-
}) : exports
|
|
729
|
-
});
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
currentTree.children.forEach((childItem) => {
|
|
733
|
-
fileReducer(files2, childItem);
|
|
734
|
-
});
|
|
735
|
-
return files2;
|
|
736
|
-
};
|
|
737
|
-
const files = fileReducer([], tree).reverse();
|
|
738
|
-
const filteredFiles = filter ? files.filter(filter) : files;
|
|
739
|
-
return map ? filteredFiles.map(map) : filteredFiles;
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
_options = new WeakMap();
|
|
743
|
-
var _cache, _task, _isWriting, _timeout, _queue2, _validate, validate_fn, _add, add_fn, _addOrAppend, addOrAppend_fn;
|
|
744
|
-
var _FileManager = class _FileManager {
|
|
745
|
-
constructor(options) {
|
|
746
|
-
__privateAdd(this, _validate);
|
|
747
|
-
__privateAdd(this, _add);
|
|
748
|
-
__privateAdd(this, _addOrAppend);
|
|
749
|
-
__privateAdd(this, _cache, /* @__PURE__ */ new Map());
|
|
750
|
-
__privateAdd(this, _task, void 0);
|
|
751
|
-
__privateAdd(this, _isWriting, false);
|
|
752
|
-
/**
|
|
753
|
-
* Timeout between writes
|
|
754
|
-
*/
|
|
755
|
-
__privateAdd(this, _timeout, 0);
|
|
756
|
-
__privateAdd(this, _queue2, void 0);
|
|
757
|
-
if (options) {
|
|
758
|
-
__privateSet(this, _task, options.task);
|
|
759
|
-
__privateSet(this, _queue2, options.queue);
|
|
760
|
-
__privateSet(this, _timeout, options.timeout || 0);
|
|
761
|
-
}
|
|
762
|
-
return this;
|
|
763
|
-
}
|
|
764
|
-
get files() {
|
|
765
|
-
const files = [];
|
|
766
|
-
__privateGet(this, _cache).forEach((item) => {
|
|
767
|
-
files.push(...item.flat(1));
|
|
768
|
-
});
|
|
769
|
-
return files;
|
|
770
|
-
}
|
|
771
|
-
get isExecuting() {
|
|
772
|
-
return __privateGet(this, _queue2)?.hasJobs ?? __privateGet(this, _isWriting) ?? false;
|
|
773
|
-
}
|
|
774
|
-
async add(...files) {
|
|
775
|
-
const promises = files.map((file) => {
|
|
776
|
-
__privateMethod(this, _validate, validate_fn).call(this, file);
|
|
777
|
-
if (file.override) {
|
|
778
|
-
return __privateMethod(this, _add, add_fn).call(this, file);
|
|
779
|
-
}
|
|
780
|
-
return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, file);
|
|
781
|
-
});
|
|
782
|
-
const resolvedFiles = await Promise.all(promises);
|
|
783
|
-
if (files.length > 1) {
|
|
784
|
-
return resolvedFiles;
|
|
785
|
-
}
|
|
786
|
-
return resolvedFiles[0];
|
|
787
|
-
}
|
|
788
|
-
async addIndexes({ root, extName = ".ts", meta, options = {} }) {
|
|
789
|
-
const barrelManager = new BarrelManager(options);
|
|
790
|
-
const files = barrelManager.getIndexes(root, extName);
|
|
791
|
-
if (!files) {
|
|
792
|
-
return void 0;
|
|
793
|
-
}
|
|
794
|
-
return await Promise.all(
|
|
795
|
-
files.map((file) => {
|
|
796
|
-
return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
|
|
797
|
-
...file,
|
|
798
|
-
meta: meta ? meta : file.meta
|
|
799
|
-
});
|
|
800
|
-
})
|
|
801
|
-
);
|
|
802
|
-
}
|
|
803
|
-
getCacheByUUID(UUID) {
|
|
804
|
-
let cache;
|
|
805
|
-
__privateGet(this, _cache).forEach((files) => {
|
|
806
|
-
cache = files.find((item) => item.id === UUID);
|
|
807
|
-
});
|
|
808
|
-
return cache;
|
|
809
|
-
}
|
|
810
|
-
get(path2) {
|
|
811
|
-
return __privateGet(this, _cache).get(path2);
|
|
812
|
-
}
|
|
813
|
-
remove(path2) {
|
|
814
|
-
const cacheItem = this.get(path2);
|
|
815
|
-
if (!cacheItem) {
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
__privateGet(this, _cache).delete(path2);
|
|
819
|
-
}
|
|
820
|
-
async write(...params) {
|
|
821
|
-
if (!__privateGet(this, _isWriting)) {
|
|
822
|
-
__privateSet(this, _isWriting, true);
|
|
823
|
-
const text = await write(...params);
|
|
824
|
-
__privateSet(this, _isWriting, false);
|
|
825
|
-
return text;
|
|
826
|
-
}
|
|
827
|
-
await timeout(__privateGet(this, _timeout));
|
|
828
|
-
return this.write(...params);
|
|
829
|
-
}
|
|
830
|
-
async read(...params) {
|
|
831
|
-
return read(...params);
|
|
832
|
-
}
|
|
833
|
-
// statics
|
|
834
|
-
static getSource(file) {
|
|
835
|
-
if (!_FileManager.isExtensionAllowed(file.baseName)) {
|
|
836
|
-
return file.source;
|
|
837
|
-
}
|
|
838
|
-
const exports = file.exports ? combineExports(file.exports) : [];
|
|
839
|
-
const imports = file.imports ? combineImports(file.imports, exports, file.source) : [];
|
|
840
|
-
const importNodes = imports.map((item) => factory__namespace.createImportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly }));
|
|
841
|
-
const exportNodes = exports.map(
|
|
842
|
-
(item) => factory__namespace.createExportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly, asAlias: item.asAlias })
|
|
843
|
-
);
|
|
844
|
-
return [parser.print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
|
|
845
|
-
}
|
|
846
|
-
static combineFiles(files) {
|
|
847
|
-
return files.filter(Boolean).reduce((acc, file) => {
|
|
848
|
-
const prevIndex = acc.findIndex((item) => item.path === file.path);
|
|
849
|
-
if (prevIndex === -1) {
|
|
850
|
-
return [...acc, file];
|
|
851
|
-
}
|
|
852
|
-
const prev = acc[prevIndex];
|
|
853
|
-
if (prev && file.override) {
|
|
854
|
-
acc[prevIndex] = {
|
|
855
|
-
imports: [],
|
|
856
|
-
exports: [],
|
|
857
|
-
...file
|
|
858
|
-
};
|
|
859
|
-
return acc;
|
|
860
|
-
}
|
|
861
|
-
if (prev) {
|
|
862
|
-
acc[prevIndex] = {
|
|
863
|
-
...file,
|
|
864
|
-
source: prev.source && file.source ? `${prev.source}
|
|
865
|
-
${file.source}` : "",
|
|
866
|
-
imports: [...prev.imports || [], ...file.imports || []],
|
|
867
|
-
exports: [...prev.exports || [], ...file.exports || []],
|
|
868
|
-
env: { ...prev.env || {}, ...file.env || {} }
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
return acc;
|
|
872
|
-
}, []);
|
|
873
|
-
}
|
|
874
|
-
static getMode(path2) {
|
|
875
|
-
if (!path2) {
|
|
876
|
-
return "directory";
|
|
877
|
-
}
|
|
878
|
-
return path.extname(path2) ? "file" : "directory";
|
|
879
|
-
}
|
|
880
|
-
static get extensions() {
|
|
881
|
-
return [".js", ".ts", ".tsx"];
|
|
882
|
-
}
|
|
883
|
-
static isExtensionAllowed(baseName) {
|
|
884
|
-
return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
_cache = new WeakMap();
|
|
888
|
-
_task = new WeakMap();
|
|
889
|
-
_isWriting = new WeakMap();
|
|
890
|
-
_timeout = new WeakMap();
|
|
891
|
-
_queue2 = new WeakMap();
|
|
892
|
-
_validate = new WeakSet();
|
|
893
|
-
validate_fn = function(file) {
|
|
894
|
-
if (!file.validate) {
|
|
895
|
-
return;
|
|
896
|
-
}
|
|
897
|
-
if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {
|
|
898
|
-
throw new Error(`${file.path} should end with the baseName ${file.baseName}`);
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
_add = new WeakSet();
|
|
902
|
-
add_fn = async function(file) {
|
|
903
|
-
const controller = new AbortController();
|
|
904
|
-
const resolvedFile = { id: crypto__default.default.randomUUID(), ...file };
|
|
905
|
-
__privateGet(this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
906
|
-
if (__privateGet(this, _queue2)) {
|
|
907
|
-
await __privateGet(this, _queue2).run(
|
|
908
|
-
async () => {
|
|
909
|
-
var _a;
|
|
910
|
-
return (_a = __privateGet(this, _task)) == null ? void 0 : _a.call(this, resolvedFile);
|
|
911
|
-
},
|
|
912
|
-
{ controller }
|
|
913
|
-
);
|
|
914
|
-
}
|
|
915
|
-
return resolvedFile;
|
|
916
|
-
};
|
|
917
|
-
_addOrAppend = new WeakSet();
|
|
918
|
-
addOrAppend_fn = async function(file) {
|
|
919
|
-
const previousCaches = __privateGet(this, _cache).get(file.path);
|
|
920
|
-
const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
|
|
921
|
-
if (previousCache) {
|
|
922
|
-
__privateGet(this, _cache).delete(previousCache.path);
|
|
923
|
-
return __privateMethod(this, _add, add_fn).call(this, {
|
|
924
|
-
...file,
|
|
925
|
-
source: previousCache.source && file.source ? `${previousCache.source}
|
|
926
|
-
${file.source}` : "",
|
|
927
|
-
imports: [...previousCache.imports || [], ...file.imports || []],
|
|
928
|
-
exports: [...previousCache.exports || [], ...file.exports || []],
|
|
929
|
-
env: { ...previousCache.env || {}, ...file.env || {} }
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
return __privateMethod(this, _add, add_fn).call(this, file);
|
|
933
|
-
};
|
|
934
|
-
var FileManager = _FileManager;
|
|
935
|
-
function combineExports(exports) {
|
|
936
|
-
const combinedExports = naturalOrderby.orderBy(exports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
|
|
937
|
-
const name = curr.name;
|
|
938
|
-
const prevByPath = prev.findLast((imp) => imp.path === curr.path);
|
|
939
|
-
const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly);
|
|
940
|
-
if (prevByPathAndIsTypeOnly) {
|
|
941
|
-
return prev;
|
|
942
|
-
}
|
|
943
|
-
const uniquePrev = prev.findLast(
|
|
944
|
-
(imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
|
|
945
|
-
);
|
|
946
|
-
if (uniquePrev || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) {
|
|
947
|
-
return prev;
|
|
948
|
-
}
|
|
949
|
-
if (!prevByPath) {
|
|
950
|
-
return [
|
|
951
|
-
...prev,
|
|
952
|
-
{
|
|
953
|
-
...curr,
|
|
954
|
-
name: Array.isArray(name) ? [...new Set(name)] : name
|
|
955
|
-
}
|
|
956
|
-
];
|
|
957
|
-
}
|
|
958
|
-
if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
|
|
959
|
-
prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...curr.name])];
|
|
960
|
-
return prev;
|
|
961
|
-
}
|
|
962
|
-
return [...prev, curr];
|
|
963
|
-
}, []);
|
|
964
|
-
return naturalOrderby.orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
|
|
965
|
-
}
|
|
966
|
-
function combineImports(imports, exports, source) {
|
|
967
|
-
const combinedImports = naturalOrderby.orderBy(imports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
|
|
968
|
-
let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
|
|
969
|
-
const hasImportInSource = (importName) => {
|
|
970
|
-
if (!source) {
|
|
971
|
-
return true;
|
|
972
|
-
}
|
|
973
|
-
const checker = (name2) => name2 && !!source.includes(name2);
|
|
974
|
-
return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
|
|
975
|
-
};
|
|
976
|
-
if (Array.isArray(name)) {
|
|
977
|
-
name = name.filter((item) => hasImportInSource(item));
|
|
978
|
-
}
|
|
979
|
-
const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
|
|
980
|
-
const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
|
|
981
|
-
const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly);
|
|
982
|
-
if (prevByPathNameAndIsTypeOnly) {
|
|
983
|
-
return prev;
|
|
984
|
-
}
|
|
985
|
-
if (uniquePrev || Array.isArray(name) && !name.length) {
|
|
986
|
-
return prev;
|
|
987
|
-
}
|
|
988
|
-
if (!prevByPath) {
|
|
989
|
-
return [
|
|
990
|
-
...prev,
|
|
991
|
-
{
|
|
992
|
-
...curr,
|
|
993
|
-
name
|
|
994
|
-
}
|
|
995
|
-
];
|
|
996
|
-
}
|
|
997
|
-
if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
|
|
998
|
-
prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...name])];
|
|
999
|
-
return prev;
|
|
1000
|
-
}
|
|
1001
|
-
if (!Array.isArray(name) && name && !hasImportInSource(name)) {
|
|
1002
|
-
return prev;
|
|
1003
|
-
}
|
|
1004
|
-
return [...prev, curr];
|
|
1005
|
-
}, []);
|
|
1006
|
-
return naturalOrderby.orderBy(combinedImports, [(v) => !v.isTypeOnly], ["desc"]);
|
|
1007
|
-
}
|
|
1008
|
-
function getEnvSource(source, env) {
|
|
1009
|
-
if (!env) {
|
|
1010
|
-
return source;
|
|
1011
|
-
}
|
|
1012
|
-
const keys = Object.keys(env);
|
|
1013
|
-
if (!keys.length) {
|
|
1014
|
-
return source;
|
|
1015
|
-
}
|
|
1016
|
-
return keys.reduce((prev, key) => {
|
|
1017
|
-
const environmentValue = env[key];
|
|
1018
|
-
const replaceBy = environmentValue ? `'${environmentValue.replaceAll('"', "")?.replaceAll("'", "")}'` : "undefined";
|
|
1019
|
-
if (key.toUpperCase() !== key) {
|
|
1020
|
-
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
1021
|
-
}
|
|
1022
|
-
if (typeof replaceBy === "string") {
|
|
1023
|
-
prev = transformers.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
|
|
1024
|
-
prev = transformers.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
|
|
1025
|
-
`, "ig"), ""), replaceBy, key });
|
|
1026
|
-
}
|
|
1027
|
-
return prev;
|
|
1028
|
-
}, source);
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
// src/utils/TreeNode.ts
|
|
1032
|
-
var TreeNode = class _TreeNode {
|
|
1033
|
-
constructor(data, parent) {
|
|
1034
|
-
this.children = [];
|
|
1035
|
-
this.data = data;
|
|
1036
|
-
this.parent = parent;
|
|
1037
|
-
return this;
|
|
1038
|
-
}
|
|
1039
|
-
addChild(data) {
|
|
1040
|
-
const child = new _TreeNode(data, this);
|
|
1041
|
-
if (!this.children) {
|
|
1042
|
-
this.children = [];
|
|
1043
|
-
}
|
|
1044
|
-
this.children.push(child);
|
|
1045
|
-
return child;
|
|
1046
|
-
}
|
|
1047
|
-
find(data) {
|
|
1048
|
-
if (!data) {
|
|
1049
|
-
return null;
|
|
1050
|
-
}
|
|
1051
|
-
if (data === this.data) {
|
|
1052
|
-
return this;
|
|
1053
|
-
}
|
|
1054
|
-
if (this.children?.length) {
|
|
1055
|
-
for (let i = 0, { length } = this.children, target = null; i < length; i++) {
|
|
1056
|
-
target = this.children[i].find(data);
|
|
1057
|
-
if (target) {
|
|
1058
|
-
return target;
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
return null;
|
|
1063
|
-
}
|
|
1064
|
-
get leaves() {
|
|
1065
|
-
if (!this.children || this.children.length === 0) {
|
|
1066
|
-
return [this];
|
|
1067
|
-
}
|
|
1068
|
-
const leaves = [];
|
|
1069
|
-
if (this.children) {
|
|
1070
|
-
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
1071
|
-
leaves.push.apply(leaves, this.children[i].leaves);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
return leaves;
|
|
1075
|
-
}
|
|
1076
|
-
get root() {
|
|
1077
|
-
if (!this.parent) {
|
|
1078
|
-
return this;
|
|
1079
|
-
}
|
|
1080
|
-
return this.parent.root;
|
|
1081
|
-
}
|
|
1082
|
-
forEach(callback) {
|
|
1083
|
-
if (typeof callback !== "function") {
|
|
1084
|
-
throw new TypeError("forEach() callback must be a function");
|
|
1085
|
-
}
|
|
1086
|
-
callback(this);
|
|
1087
|
-
if (this.children) {
|
|
1088
|
-
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
1089
|
-
this.children[i].forEach(callback);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
return this;
|
|
1093
|
-
}
|
|
1094
|
-
static build(path2, options = {}) {
|
|
1095
|
-
try {
|
|
1096
|
-
const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
|
|
1097
|
-
const filteredTree = dirTree__default.default(path2, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
|
|
1098
|
-
if (!filteredTree) {
|
|
1099
|
-
return null;
|
|
1100
|
-
}
|
|
1101
|
-
const treeNode = new _TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || FileManager.getMode(filteredTree.path) });
|
|
1102
|
-
const recurse = (node, item) => {
|
|
1103
|
-
const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || FileManager.getMode(item.path) });
|
|
1104
|
-
if (item.children?.length) {
|
|
1105
|
-
item.children?.forEach((child) => {
|
|
1106
|
-
recurse(subNode, child);
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
filteredTree.children?.forEach((child) => recurse(treeNode, child));
|
|
1111
|
-
return treeNode;
|
|
1112
|
-
} catch (e) {
|
|
1113
|
-
throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
};
|
|
1117
|
-
|
|
1118
|
-
// src/utils/uniqueName.ts
|
|
1119
|
-
function getUniqueName(originalName, data) {
|
|
1120
|
-
let used = data[originalName] || 0;
|
|
1121
|
-
if (used) {
|
|
1122
|
-
data[originalName] = ++used;
|
|
1123
|
-
originalName += used;
|
|
1124
|
-
}
|
|
1125
|
-
data[originalName] = 1;
|
|
1126
|
-
return originalName;
|
|
1127
|
-
}
|
|
1128
|
-
function setUniqueName(originalName, data) {
|
|
1129
|
-
let used = data[originalName] || 0;
|
|
1130
|
-
if (used) {
|
|
1131
|
-
data[originalName] = ++used;
|
|
1132
|
-
return originalName;
|
|
1133
|
-
}
|
|
1134
|
-
data[originalName] = 1;
|
|
1135
|
-
return originalName;
|
|
1136
|
-
}
|
|
1137
|
-
var URLPath = class {
|
|
1138
|
-
constructor(path2) {
|
|
1139
|
-
this.path = path2;
|
|
1140
|
-
return this;
|
|
1141
|
-
}
|
|
1142
|
-
/**
|
|
1143
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
1144
|
-
* @example /pet/{petId} => /pet/:petId
|
|
1145
|
-
*/
|
|
1146
|
-
get URL() {
|
|
1147
|
-
return this.toURLPath();
|
|
1148
|
-
}
|
|
1149
|
-
get isURL() {
|
|
1150
|
-
try {
|
|
1151
|
-
const url = new URL(this.path);
|
|
1152
|
-
if (url?.href) {
|
|
1153
|
-
return true;
|
|
1154
|
-
}
|
|
1155
|
-
} catch (error) {
|
|
1156
|
-
return false;
|
|
1157
|
-
}
|
|
1158
|
-
return false;
|
|
1159
|
-
}
|
|
1160
|
-
/**
|
|
1161
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
1162
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
1163
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
1164
|
-
* @example /account/userID => `/account/${userId}`
|
|
1165
|
-
*/
|
|
1166
|
-
get template() {
|
|
1167
|
-
return this.toTemplateString();
|
|
1168
|
-
}
|
|
1169
|
-
get object() {
|
|
1170
|
-
return this.toObject();
|
|
1171
|
-
}
|
|
1172
|
-
get params() {
|
|
1173
|
-
return this.getParams();
|
|
1174
|
-
}
|
|
1175
|
-
toObject({ type = "path", replacer, stringify } = {}) {
|
|
1176
|
-
const object = {
|
|
1177
|
-
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
1178
|
-
params: this.getParams()
|
|
1179
|
-
};
|
|
1180
|
-
if (stringify) {
|
|
1181
|
-
if (type !== "template") {
|
|
1182
|
-
throw new Error("Type should be `template` when using stringiyf");
|
|
1183
|
-
}
|
|
1184
|
-
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
1185
|
-
}
|
|
1186
|
-
return object;
|
|
1187
|
-
}
|
|
1188
|
-
/**
|
|
1189
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
1190
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
1191
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
1192
|
-
* @example /account/userID => `/account/${userId}`
|
|
1193
|
-
*/
|
|
1194
|
-
toTemplateString(replacer) {
|
|
1195
|
-
const regex = /{(\w|-)*}/g;
|
|
1196
|
-
const found = this.path.match(regex);
|
|
1197
|
-
let newPath = this.path.replaceAll("{", "${");
|
|
1198
|
-
if (found) {
|
|
1199
|
-
newPath = found.reduce((prev, curr) => {
|
|
1200
|
-
const pathParam = replacer ? replacer(changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
1201
|
-
const replacement = `\${${pathParam}}`;
|
|
1202
|
-
return prev.replace(curr, replacement);
|
|
1203
|
-
}, this.path);
|
|
1204
|
-
}
|
|
1205
|
-
return `\`${newPath}\``;
|
|
1206
|
-
}
|
|
1207
|
-
getParams(replacer) {
|
|
1208
|
-
const regex = /{(\w|-)*}/g;
|
|
1209
|
-
const found = this.path.match(regex);
|
|
1210
|
-
if (!found) {
|
|
1211
|
-
return void 0;
|
|
1212
|
-
}
|
|
1213
|
-
const params = {};
|
|
1214
|
-
found.forEach((item) => {
|
|
1215
|
-
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
1216
|
-
const pathParam = replacer ? replacer(changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
1217
|
-
params[pathParam] = pathParam;
|
|
1218
|
-
}, this.path);
|
|
1219
|
-
return params;
|
|
1220
|
-
}
|
|
1221
|
-
/**
|
|
1222
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
1223
|
-
* @example /pet/{petId} => /pet/:petId
|
|
1224
|
-
*/
|
|
1225
|
-
toURLPath() {
|
|
1226
|
-
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
|
|
1230
|
-
Object.defineProperty(exports, 'pc', {
|
|
99
|
+
Object.defineProperty(exports, 'URLPath', {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () { return chunkH47IKRXJ_cjs.URLPath; }
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, 'getUniqueName', {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () { return chunkH47IKRXJ_cjs.getUniqueName; }
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, 'setUniqueName', {
|
|
1231
108
|
enumerable: true,
|
|
1232
|
-
get: function () { return
|
|
109
|
+
get: function () { return chunkH47IKRXJ_cjs.setUniqueName; }
|
|
1233
110
|
});
|
|
1234
111
|
exports.FunctionParams = FunctionParams;
|
|
1235
|
-
exports.LogLevel = LogLevel;
|
|
1236
|
-
exports.Queue = Queue;
|
|
1237
|
-
exports.TreeNode = TreeNode;
|
|
1238
|
-
exports.URLPath = URLPath;
|
|
1239
|
-
exports.clean = clean;
|
|
1240
|
-
exports.createLogger = createLogger;
|
|
1241
|
-
exports.createPluginCache = createPluginCache;
|
|
1242
|
-
exports.getRelativePath = getRelativePath;
|
|
1243
|
-
exports.getUniqueName = getUniqueName;
|
|
1244
112
|
exports.isPromise = isPromise;
|
|
1245
113
|
exports.isPromiseFulfilledResult = isPromiseFulfilledResult;
|
|
1246
114
|
exports.isPromiseRejectedResult = isPromiseRejectedResult;
|
|
1247
|
-
exports.randomColour = randomColour;
|
|
1248
|
-
exports.randomPicoColour = randomPicoColour;
|
|
1249
|
-
exports.read = read;
|
|
1250
|
-
exports.readSync = readSync;
|
|
1251
115
|
exports.renderTemplate = renderTemplate;
|
|
1252
|
-
exports.setUniqueName = setUniqueName;
|
|
1253
|
-
exports.throttle = throttle;
|
|
1254
116
|
exports.timeout = timeout;
|
|
1255
|
-
exports.transformers = transformers;
|
|
1256
|
-
exports.write = write;
|
|
1257
117
|
//# sourceMappingURL=out.js.map
|
|
1258
118
|
//# sourceMappingURL=utils.cjs.map
|