@kubb/core 2.0.0-beta.1 → 2.0.0-beta.11
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/Queue-2-6pMcCx.d.cts +32 -0
- package/dist/Queue-2-6pMcCx.d.ts +32 -0
- package/dist/fs.cjs +2383 -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 +2380 -0
- package/dist/fs.js.map +1 -0
- package/dist/index.cjs +3448 -394
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -127
- package/dist/index.d.ts +77 -127
- package/dist/index.js +3761 -423
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +90 -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 +78 -0
- package/dist/logger.js.map +1 -0
- package/dist/transformers.cjs +222 -0
- package/dist/transformers.cjs.map +1 -0
- package/dist/transformers.d.cts +55 -0
- package/dist/transformers.d.ts +55 -0
- package/dist/transformers.js +207 -0
- package/dist/transformers.js.map +1 -0
- package/dist/utils.cjs +174 -899
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -146
- package/dist/utils.d.ts +2 -146
- package/dist/utils.js +175 -859
- package/dist/utils.js.map +1 -1
- package/dist/write-46ytbnu9.d.cts +7 -0
- package/dist/write-46ytbnu9.d.ts +7 -0
- package/package.json +27 -12
- package/src/BarrelManager.ts +55 -65
- package/src/FileManager.ts +109 -68
- package/src/PluginManager.ts +55 -32
- package/src/build.ts +5 -16
- package/src/fs/index.ts +3 -0
- package/src/index.ts +4 -5
- package/src/{utils/logger.ts → logger.ts} +37 -0
- package/src/plugin.ts +4 -4
- package/src/transformers/casing.ts +9 -0
- package/src/transformers/createJSDocBlockText.ts +9 -0
- package/src/transformers/index.ts +36 -0
- package/src/transformers/trim.ts +7 -0
- package/src/types.ts +23 -42
- package/src/utils/FunctionParams.ts +3 -2
- package/src/utils/TreeNode.ts +6 -3
- package/src/utils/URLPath.ts +5 -5
- package/src/utils/index.ts +10 -19
- package/src/SchemaGenerator.ts +0 -8
- package/src/utils/randomColour.ts +0 -39
- package/src/utils/throttle.ts +0 -30
- package/src/utils/transformers/createJSDocBlockText.ts +0 -15
- package/src/utils/transformers/index.ts +0 -22
- package/src/utils/transformers/trim.ts +0 -3
- /package/src/{utils → fs}/clean.ts +0 -0
- /package/src/{utils → fs}/read.ts +0 -0
- /package/src/{utils → fs}/write.ts +0 -0
- /package/src/{utils/transformers → transformers}/combineCodes.ts +0 -0
- /package/src/{utils/transformers → transformers}/escape.ts +0 -0
- /package/src/{utils/transformers → transformers}/indent.ts +0 -0
- /package/src/{utils/transformers → transformers}/nameSorter.ts +0 -0
- /package/src/{utils/transformers → transformers}/searchAndReplace.ts +0 -0
- /package/src/{utils/transformers → transformers}/transformReservedWord.ts +0 -0
package/dist/utils.cjs
CHANGED
|
@@ -1,48 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fs2 = require('fs-extra');
|
|
4
|
-
var changeCase = require('change-case');
|
|
5
3
|
var naturalOrderby = require('natural-orderby');
|
|
6
|
-
var
|
|
4
|
+
var changeCase = require('change-case');
|
|
7
5
|
var crypto = require('crypto');
|
|
8
6
|
var perf_hooks = require('perf_hooks');
|
|
9
7
|
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
8
|
|
|
18
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
10
|
|
|
20
|
-
function _interopNamespace(e) {
|
|
21
|
-
if (e && e.__esModule) return e;
|
|
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
11
|
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
12
|
|
|
47
13
|
var __accessCheck = (obj, member, msg) => {
|
|
48
14
|
if (!member.has(obj))
|
|
@@ -74,376 +40,30 @@ var __privateMethod = (obj, member, method) => {
|
|
|
74
40
|
__accessCheck(obj, member, "access private method");
|
|
75
41
|
return method;
|
|
76
42
|
};
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
};
|
|
43
|
+
function camelCase(text) {
|
|
44
|
+
return changeCase.camelCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.camelCaseTransformMerge });
|
|
104
45
|
}
|
|
105
|
-
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
var FunctionParams = class {
|
|
109
|
-
constructor(type) {
|
|
110
|
-
this.items = [];
|
|
111
|
-
this.type = type;
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
add(item) {
|
|
115
|
-
if (!item) {
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
if (Array.isArray(item)) {
|
|
119
|
-
item.filter(Boolean).forEach((it) => this.items.push(it));
|
|
120
|
-
return this;
|
|
121
|
-
}
|
|
122
|
-
this.items.push(item);
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
toString() {
|
|
126
|
-
const sortedData = naturalOrderby.orderBy(this.items.filter(Boolean), [(v) => !v.default, (v) => v.required ?? true], ["desc", "desc"]);
|
|
127
|
-
return sortedData.filter(({ enabled = true }) => enabled).reduce((acc, { name, type, required = true, ...rest }) => {
|
|
128
|
-
if (!name) {
|
|
129
|
-
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
130
|
-
return acc;
|
|
131
|
-
}
|
|
132
|
-
const parameterName = name.startsWith("{") ? name : changeCase.camelCase(name, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
133
|
-
if (type) {
|
|
134
|
-
if (required) {
|
|
135
|
-
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
136
|
-
} else {
|
|
137
|
-
acc.push(`${parameterName}?: ${type}`);
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
acc.push(`${parameterName}`);
|
|
141
|
-
}
|
|
142
|
-
return acc;
|
|
143
|
-
}, []).join(", ");
|
|
144
|
-
}
|
|
145
|
-
};
|
|
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 && logLevel !== LogLevel.silent) {
|
|
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;
|
|
46
|
+
function pascalCase(text) {
|
|
47
|
+
return changeCase.pascalCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.pascalCaseTransformMerge });
|
|
187
48
|
}
|
|
188
49
|
|
|
189
|
-
// src/
|
|
190
|
-
function isPromise(result) {
|
|
191
|
-
return !!result && typeof result?.then === "function";
|
|
192
|
-
}
|
|
193
|
-
function isPromiseFulfilledResult(result) {
|
|
194
|
-
return result.status === "fulfilled";
|
|
195
|
-
}
|
|
196
|
-
function isPromiseRejectedResult(result) {
|
|
197
|
-
return result.status === "rejected";
|
|
198
|
-
}
|
|
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
|
-
|
|
365
|
-
// src/utils/renderTemplate.ts
|
|
366
|
-
function renderTemplate(template, data = void 0) {
|
|
367
|
-
if (!data || !Object.keys(data).length) {
|
|
368
|
-
return template.replace(/{{(.*?)}}/g, "");
|
|
369
|
-
}
|
|
370
|
-
const matches = template.match(/{{(.*?)}}/g);
|
|
371
|
-
return matches?.reduce((prev, curr) => {
|
|
372
|
-
const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
|
|
373
|
-
if (index === void 0) {
|
|
374
|
-
return prev;
|
|
375
|
-
}
|
|
376
|
-
const value = data[index];
|
|
377
|
-
if (value === void 0) {
|
|
378
|
-
return prev;
|
|
379
|
-
}
|
|
380
|
-
return prev.replace(curr, () => {
|
|
381
|
-
if (typeof value === "boolean") {
|
|
382
|
-
return `${value.toString()}` || "false";
|
|
383
|
-
}
|
|
384
|
-
return value || "";
|
|
385
|
-
}).trim();
|
|
386
|
-
}, template) || "";
|
|
387
|
-
}
|
|
388
|
-
|
|
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
|
-
// src/utils/timeout.ts
|
|
417
|
-
async function timeout(ms) {
|
|
418
|
-
return new Promise((resolve2) => {
|
|
419
|
-
setTimeout(() => {
|
|
420
|
-
resolve2(true);
|
|
421
|
-
}, ms);
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// src/utils/transformers/combineCodes.ts
|
|
50
|
+
// src/transformers/combineCodes.ts
|
|
426
51
|
function combineCodes(codes) {
|
|
427
52
|
return codes.join("\n");
|
|
428
53
|
}
|
|
429
54
|
|
|
430
|
-
// src/
|
|
431
|
-
function createJSDocBlockText({ comments
|
|
55
|
+
// src/transformers/createJSDocBlockText.ts
|
|
56
|
+
function createJSDocBlockText({ comments }) {
|
|
432
57
|
const filteredComments = comments.filter(Boolean);
|
|
433
58
|
if (!filteredComments.length) {
|
|
434
59
|
return "";
|
|
435
60
|
}
|
|
436
|
-
|
|
61
|
+
return `/**
|
|
437
62
|
* ${filteredComments.join("\n * ")}
|
|
438
63
|
*/`;
|
|
439
|
-
if (newLine) {
|
|
440
|
-
return `${source}
|
|
441
|
-
`;
|
|
442
|
-
}
|
|
443
|
-
return source;
|
|
444
64
|
}
|
|
445
65
|
|
|
446
|
-
// src/
|
|
66
|
+
// src/transformers/escape.ts
|
|
447
67
|
function escape(text) {
|
|
448
68
|
return text ? text.replaceAll("`", "\\`") : "";
|
|
449
69
|
}
|
|
@@ -468,12 +88,12 @@ function jsStringEscape(input) {
|
|
|
468
88
|
});
|
|
469
89
|
}
|
|
470
90
|
|
|
471
|
-
// src/
|
|
91
|
+
// src/transformers/indent.ts
|
|
472
92
|
function createIndent(size) {
|
|
473
93
|
return Array.from({ length: size + 1 }).join(" ");
|
|
474
94
|
}
|
|
475
95
|
|
|
476
|
-
// src/
|
|
96
|
+
// src/transformers/nameSorter.ts
|
|
477
97
|
function nameSorter(a, b) {
|
|
478
98
|
if (a.name < b.name) {
|
|
479
99
|
return -1;
|
|
@@ -484,7 +104,7 @@ function nameSorter(a, b) {
|
|
|
484
104
|
return 0;
|
|
485
105
|
}
|
|
486
106
|
|
|
487
|
-
// src/
|
|
107
|
+
// src/transformers/searchAndReplace.ts
|
|
488
108
|
function searchAndReplace(options) {
|
|
489
109
|
const { text, replaceBy, prefix = "", key } = options;
|
|
490
110
|
const searchValues = options.searchValues?.(prefix, key) || [
|
|
@@ -501,7 +121,7 @@ function searchAndReplace(options) {
|
|
|
501
121
|
}, text);
|
|
502
122
|
}
|
|
503
123
|
|
|
504
|
-
// src/
|
|
124
|
+
// src/transformers/transformReservedWord.ts
|
|
505
125
|
var reservedWords = [
|
|
506
126
|
"abstract",
|
|
507
127
|
"arguments",
|
|
@@ -594,13 +214,16 @@ function transformReservedWord(word) {
|
|
|
594
214
|
return word;
|
|
595
215
|
}
|
|
596
216
|
|
|
597
|
-
// src/
|
|
217
|
+
// src/transformers/trim.ts
|
|
598
218
|
function trim(text) {
|
|
599
219
|
return text.replaceAll(/\n/g, "").trim();
|
|
600
220
|
}
|
|
221
|
+
function trimExtName(text) {
|
|
222
|
+
return text.replace(/\.[^/.]+$/, "");
|
|
223
|
+
}
|
|
601
224
|
|
|
602
|
-
// src/
|
|
603
|
-
var
|
|
225
|
+
// src/transformers/index.ts
|
|
226
|
+
var transformers_default = {
|
|
604
227
|
combineCodes,
|
|
605
228
|
escape,
|
|
606
229
|
jsStringEscape,
|
|
@@ -609,522 +232,189 @@ var transformers = {
|
|
|
609
232
|
nameSorter,
|
|
610
233
|
searchAndReplace,
|
|
611
234
|
trim,
|
|
235
|
+
trimExtName,
|
|
612
236
|
JSDoc: {
|
|
613
237
|
createJSDocBlockText
|
|
614
|
-
}
|
|
238
|
+
},
|
|
239
|
+
camelCase,
|
|
240
|
+
pascalCase
|
|
615
241
|
};
|
|
616
|
-
async function saveCreateDirectory(path2) {
|
|
617
|
-
const passedPath = path.dirname(path.resolve(path2));
|
|
618
|
-
await fs2__default.default.mkdir(passedPath, { recursive: true });
|
|
619
|
-
}
|
|
620
|
-
var writer = jsRuntime.switcher(
|
|
621
|
-
{
|
|
622
|
-
node: async (path2, data) => {
|
|
623
|
-
try {
|
|
624
|
-
await fs2__default.default.stat(path.resolve(path2));
|
|
625
|
-
const oldContent = await fs2__default.default.readFile(path.resolve(path2), { encoding: "utf-8" });
|
|
626
|
-
if (oldContent?.toString() === data?.toString()) {
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
} catch (_err) {
|
|
630
|
-
}
|
|
631
|
-
await saveCreateDirectory(path2);
|
|
632
|
-
await fs2__default.default.writeFile(path.resolve(path2), data, { encoding: "utf-8" });
|
|
633
|
-
const savedData = await fs2__default.default.readFile(path.resolve(path2), { encoding: "utf-8" });
|
|
634
|
-
if (savedData?.toString() !== data?.toString()) {
|
|
635
|
-
throw new Error(`Sanity check failed for ${path2}
|
|
636
|
-
|
|
637
|
-
Data[${data.length}]:
|
|
638
|
-
${data}
|
|
639
|
-
|
|
640
|
-
Saved[${savedData.length}]:
|
|
641
|
-
${savedData}
|
|
642
|
-
`);
|
|
643
|
-
}
|
|
644
|
-
return savedData;
|
|
645
|
-
},
|
|
646
|
-
bun: async (path2, data) => {
|
|
647
|
-
try {
|
|
648
|
-
await saveCreateDirectory(path2);
|
|
649
|
-
await Bun.write(path.resolve(path2), data);
|
|
650
|
-
const file = Bun.file(path.resolve(path2));
|
|
651
|
-
const savedData = await file.text();
|
|
652
|
-
if (savedData?.toString() !== data?.toString()) {
|
|
653
|
-
throw new Error(`Sanity check failed for ${path2}
|
|
654
242
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
`);
|
|
661
|
-
}
|
|
662
|
-
return savedData;
|
|
663
|
-
} catch (e) {
|
|
664
|
-
console.log(e, path.resolve(path2));
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
},
|
|
668
|
-
"node"
|
|
669
|
-
);
|
|
670
|
-
async function write(data, path2) {
|
|
671
|
-
if (data.trim() === "") {
|
|
672
|
-
return void 0;
|
|
673
|
-
}
|
|
674
|
-
return writer(path2, data.trim());
|
|
675
|
-
}
|
|
676
|
-
var _options;
|
|
677
|
-
var BarrelManager = class {
|
|
678
|
-
constructor(options = {}) {
|
|
679
|
-
__privateAdd(this, _options, {});
|
|
680
|
-
__privateSet(this, _options, options);
|
|
243
|
+
// src/utils/FunctionParams.ts
|
|
244
|
+
var FunctionParams = class {
|
|
245
|
+
constructor(type) {
|
|
246
|
+
this.items = [];
|
|
247
|
+
this.type = type;
|
|
681
248
|
return this;
|
|
682
249
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
".ts": {
|
|
687
|
-
extensions: /\.ts/,
|
|
688
|
-
exclude: [/schemas/, /json/]
|
|
689
|
-
},
|
|
690
|
-
".json": {
|
|
691
|
-
extensions: /\.json/,
|
|
692
|
-
exclude: []
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...treeNode });
|
|
696
|
-
if (!tree) {
|
|
697
|
-
return null;
|
|
250
|
+
add(item) {
|
|
251
|
+
if (!item) {
|
|
252
|
+
return this;
|
|
698
253
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
if (currentTree.children?.length > 1) {
|
|
704
|
-
const indexPath = path__default.default.resolve(currentTree.data.path, "index.ts");
|
|
705
|
-
const exports = currentTree.children.filter(Boolean).map((file) => {
|
|
706
|
-
const importPath = file.data.type === "directory" ? `./${file.data.name}/index` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
707
|
-
if (importPath.includes("index") && file.data.type === "file") {
|
|
708
|
-
return void 0;
|
|
709
|
-
}
|
|
710
|
-
return {
|
|
711
|
-
path: includeExt ? `${importPath}${extName}` : importPath,
|
|
712
|
-
isTypeOnly
|
|
713
|
-
};
|
|
714
|
-
}).filter(Boolean);
|
|
715
|
-
files2.push({
|
|
716
|
-
path: indexPath,
|
|
717
|
-
baseName: "index.ts",
|
|
718
|
-
source: "",
|
|
719
|
-
exports: output ? exports?.filter((item) => {
|
|
720
|
-
return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
|
|
721
|
-
}) : exports
|
|
722
|
-
});
|
|
723
|
-
} else {
|
|
724
|
-
currentTree.children?.forEach((child) => {
|
|
725
|
-
const indexPath = path__default.default.resolve(currentTree.data.path, "index.ts");
|
|
726
|
-
const importPath = child.data.type === "directory" ? `./${child.data.name}/index` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
727
|
-
const exports = [
|
|
728
|
-
{
|
|
729
|
-
path: includeExt ? `${importPath}${extName}` : importPath,
|
|
730
|
-
isTypeOnly
|
|
731
|
-
}
|
|
732
|
-
];
|
|
733
|
-
files2.push({
|
|
734
|
-
path: indexPath,
|
|
735
|
-
baseName: "index.ts",
|
|
736
|
-
source: "",
|
|
737
|
-
exports: output ? exports?.filter((item) => {
|
|
738
|
-
return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
|
|
739
|
-
}) : exports
|
|
740
|
-
});
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
currentTree.children.forEach((childItem) => {
|
|
744
|
-
fileReducer(files2, childItem);
|
|
745
|
-
});
|
|
746
|
-
return files2;
|
|
747
|
-
};
|
|
748
|
-
const files = fileReducer([], tree).reverse();
|
|
749
|
-
const filteredFiles = filter ? files.filter(filter) : files;
|
|
750
|
-
return map ? filteredFiles.map(map) : filteredFiles;
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
_options = new WeakMap();
|
|
754
|
-
var _cache, _task, _isWriting, _timeout, _queue2, _validate, validate_fn, _add, add_fn, _addOrAppend, addOrAppend_fn;
|
|
755
|
-
var _FileManager = class _FileManager {
|
|
756
|
-
constructor(options) {
|
|
757
|
-
__privateAdd(this, _validate);
|
|
758
|
-
__privateAdd(this, _add);
|
|
759
|
-
__privateAdd(this, _addOrAppend);
|
|
760
|
-
__privateAdd(this, _cache, /* @__PURE__ */ new Map());
|
|
761
|
-
__privateAdd(this, _task, void 0);
|
|
762
|
-
__privateAdd(this, _isWriting, false);
|
|
763
|
-
/**
|
|
764
|
-
* Timeout between writes
|
|
765
|
-
*/
|
|
766
|
-
__privateAdd(this, _timeout, 0);
|
|
767
|
-
__privateAdd(this, _queue2, void 0);
|
|
768
|
-
if (options) {
|
|
769
|
-
__privateSet(this, _task, options.task);
|
|
770
|
-
__privateSet(this, _queue2, options.queue);
|
|
771
|
-
__privateSet(this, _timeout, options.timeout || 0);
|
|
254
|
+
if (Array.isArray(item)) {
|
|
255
|
+
item.filter(Boolean).forEach((it) => this.items.push(it));
|
|
256
|
+
return this;
|
|
772
257
|
}
|
|
258
|
+
this.items.push(item);
|
|
773
259
|
return this;
|
|
774
260
|
}
|
|
775
|
-
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
return files;
|
|
781
|
-
}
|
|
782
|
-
get isExecuting() {
|
|
783
|
-
return __privateGet(this, _queue2)?.hasJobs ?? __privateGet(this, _isWriting) ?? false;
|
|
784
|
-
}
|
|
785
|
-
async add(...files) {
|
|
786
|
-
const promises = files.map((file) => {
|
|
787
|
-
__privateMethod(this, _validate, validate_fn).call(this, file);
|
|
788
|
-
if (file.override) {
|
|
789
|
-
return __privateMethod(this, _add, add_fn).call(this, file);
|
|
790
|
-
}
|
|
791
|
-
return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, file);
|
|
792
|
-
});
|
|
793
|
-
const resolvedFiles = await Promise.all(promises);
|
|
794
|
-
if (files.length > 1) {
|
|
795
|
-
return resolvedFiles;
|
|
796
|
-
}
|
|
797
|
-
return resolvedFiles[0];
|
|
798
|
-
}
|
|
799
|
-
async addIndexes({ root, extName = ".ts", meta, options = {} }) {
|
|
800
|
-
const barrelManager = new BarrelManager(options);
|
|
801
|
-
const files = barrelManager.getIndexes(root, extName);
|
|
802
|
-
if (!files) {
|
|
803
|
-
return void 0;
|
|
804
|
-
}
|
|
805
|
-
return await Promise.all(
|
|
806
|
-
files.map((file) => {
|
|
807
|
-
return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
|
|
808
|
-
...file,
|
|
809
|
-
meta: meta ? meta : file.meta
|
|
810
|
-
});
|
|
811
|
-
})
|
|
812
|
-
);
|
|
813
|
-
}
|
|
814
|
-
getCacheByUUID(UUID) {
|
|
815
|
-
let cache;
|
|
816
|
-
__privateGet(this, _cache).forEach((files) => {
|
|
817
|
-
cache = files.find((item) => item.id === UUID);
|
|
818
|
-
});
|
|
819
|
-
return cache;
|
|
820
|
-
}
|
|
821
|
-
get(path2) {
|
|
822
|
-
return __privateGet(this, _cache).get(path2);
|
|
823
|
-
}
|
|
824
|
-
remove(path2) {
|
|
825
|
-
const cacheItem = this.get(path2);
|
|
826
|
-
if (!cacheItem) {
|
|
827
|
-
return;
|
|
828
|
-
}
|
|
829
|
-
__privateGet(this, _cache).delete(path2);
|
|
830
|
-
}
|
|
831
|
-
async write(...params) {
|
|
832
|
-
if (!__privateGet(this, _isWriting)) {
|
|
833
|
-
__privateSet(this, _isWriting, true);
|
|
834
|
-
const text = await write(...params);
|
|
835
|
-
__privateSet(this, _isWriting, false);
|
|
836
|
-
return text;
|
|
837
|
-
}
|
|
838
|
-
await timeout(__privateGet(this, _timeout));
|
|
839
|
-
return this.write(...params);
|
|
840
|
-
}
|
|
841
|
-
async read(...params) {
|
|
842
|
-
return read(...params);
|
|
843
|
-
}
|
|
844
|
-
// statics
|
|
845
|
-
static getSource(file) {
|
|
846
|
-
if (!_FileManager.isExtensionAllowed(file.baseName)) {
|
|
847
|
-
return file.source;
|
|
848
|
-
}
|
|
849
|
-
const exports = file.exports ? combineExports(file.exports) : [];
|
|
850
|
-
const imports = file.imports ? combineImports(file.imports, exports, file.source) : [];
|
|
851
|
-
const importNodes = imports.map((item) => factory__namespace.createImportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly }));
|
|
852
|
-
const exportNodes = exports.map(
|
|
853
|
-
(item) => factory__namespace.createExportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly, asAlias: item.asAlias })
|
|
854
|
-
);
|
|
855
|
-
return [parser.print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
|
|
856
|
-
}
|
|
857
|
-
static combineFiles(files) {
|
|
858
|
-
return files.filter(Boolean).reduce((acc, file) => {
|
|
859
|
-
const prevIndex = acc.findIndex((item) => item.path === file.path);
|
|
860
|
-
if (prevIndex === -1) {
|
|
861
|
-
return [...acc, file];
|
|
862
|
-
}
|
|
863
|
-
const prev = acc[prevIndex];
|
|
864
|
-
if (prev && file.override) {
|
|
865
|
-
acc[prevIndex] = {
|
|
866
|
-
imports: [],
|
|
867
|
-
exports: [],
|
|
868
|
-
...file
|
|
869
|
-
};
|
|
261
|
+
toString() {
|
|
262
|
+
const sortedData = naturalOrderby.orderBy(this.items.filter(Boolean), [(v) => !v.default, (v) => v.required ?? true], ["desc", "desc"]);
|
|
263
|
+
return sortedData.filter(({ enabled = true }) => enabled).reduce((acc, { name, type, required = true, ...rest }) => {
|
|
264
|
+
if (!name) {
|
|
265
|
+
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
870
266
|
return acc;
|
|
871
267
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
};
|
|
268
|
+
const parameterName = name.startsWith("{") ? name : transformers_default.camelCase(name);
|
|
269
|
+
if (type) {
|
|
270
|
+
if (required) {
|
|
271
|
+
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
272
|
+
} else {
|
|
273
|
+
acc.push(`${parameterName}?: ${type}`);
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
acc.push(`${parameterName}`);
|
|
881
277
|
}
|
|
882
278
|
return acc;
|
|
883
|
-
}, []);
|
|
279
|
+
}, []).join(", ");
|
|
884
280
|
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/utils/promise.ts
|
|
284
|
+
function isPromise(result) {
|
|
285
|
+
return !!result && typeof result?.then === "function";
|
|
286
|
+
}
|
|
287
|
+
function isPromiseFulfilledResult(result) {
|
|
288
|
+
return result.status === "fulfilled";
|
|
289
|
+
}
|
|
290
|
+
function isPromiseRejectedResult(result) {
|
|
291
|
+
return result.status === "rejected";
|
|
292
|
+
}
|
|
293
|
+
var _emitter;
|
|
294
|
+
var EventEmitter = class {
|
|
295
|
+
constructor() {
|
|
296
|
+
__privateAdd(this, _emitter, new events.EventEmitter());
|
|
297
|
+
__privateGet(this, _emitter).setMaxListeners(100);
|
|
890
298
|
}
|
|
891
|
-
|
|
892
|
-
|
|
299
|
+
emit(eventName, ...eventArg) {
|
|
300
|
+
__privateGet(this, _emitter).emit(eventName, ...eventArg);
|
|
893
301
|
}
|
|
894
|
-
|
|
895
|
-
|
|
302
|
+
on(eventName, handler) {
|
|
303
|
+
__privateGet(this, _emitter).on(eventName, handler);
|
|
896
304
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
_task = new WeakMap();
|
|
900
|
-
_isWriting = new WeakMap();
|
|
901
|
-
_timeout = new WeakMap();
|
|
902
|
-
_queue2 = new WeakMap();
|
|
903
|
-
_validate = new WeakSet();
|
|
904
|
-
validate_fn = function(file) {
|
|
905
|
-
if (!file.validate) {
|
|
906
|
-
return;
|
|
305
|
+
off(eventName, handler) {
|
|
306
|
+
__privateGet(this, _emitter).off(eventName, handler);
|
|
907
307
|
}
|
|
908
|
-
|
|
909
|
-
|
|
308
|
+
removeAll() {
|
|
309
|
+
__privateGet(this, _emitter).removeAllListeners();
|
|
910
310
|
}
|
|
911
311
|
};
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
);
|
|
312
|
+
_emitter = new WeakMap();
|
|
313
|
+
|
|
314
|
+
// src/utils/Queue.ts
|
|
315
|
+
var _queue, _workerCount, _maxParallel, _debug, _work, work_fn;
|
|
316
|
+
var Queue = class {
|
|
317
|
+
constructor(maxParallel, debug = false) {
|
|
318
|
+
__privateAdd(this, _work);
|
|
319
|
+
__privateAdd(this, _queue, []);
|
|
320
|
+
this.eventEmitter = new EventEmitter();
|
|
321
|
+
__privateAdd(this, _workerCount, 0);
|
|
322
|
+
__privateAdd(this, _maxParallel, void 0);
|
|
323
|
+
__privateAdd(this, _debug, false);
|
|
324
|
+
__privateSet(this, _maxParallel, maxParallel);
|
|
325
|
+
__privateSet(this, _debug, debug);
|
|
925
326
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
...file,
|
|
936
|
-
source: previousCache.source && file.source ? `${previousCache.source}
|
|
937
|
-
${file.source}` : "",
|
|
938
|
-
imports: [...previousCache.imports || [], ...file.imports || []],
|
|
939
|
-
exports: [...previousCache.exports || [], ...file.exports || []],
|
|
940
|
-
env: { ...previousCache.env || {}, ...file.env || {} }
|
|
327
|
+
run(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
328
|
+
return new Promise((resolve, reject) => {
|
|
329
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
330
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
331
|
+
__privateSet(this, _queue, __privateGet(this, _queue).filter((queueItem) => queueItem.name === item.name));
|
|
332
|
+
reject("Aborted");
|
|
333
|
+
});
|
|
334
|
+
__privateGet(this, _queue).push(item);
|
|
335
|
+
__privateMethod(this, _work, work_fn).call(this);
|
|
941
336
|
});
|
|
942
337
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
return prev;
|
|
953
|
-
}
|
|
954
|
-
const uniquePrev = prev.findLast(
|
|
955
|
-
(imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
|
|
956
|
-
);
|
|
957
|
-
if (uniquePrev || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) {
|
|
958
|
-
return prev;
|
|
959
|
-
}
|
|
960
|
-
if (!prevByPath) {
|
|
961
|
-
return [
|
|
962
|
-
...prev,
|
|
963
|
-
{
|
|
964
|
-
...curr,
|
|
965
|
-
name: Array.isArray(name) ? [...new Set(name)] : name
|
|
966
|
-
}
|
|
967
|
-
];
|
|
968
|
-
}
|
|
969
|
-
if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
|
|
970
|
-
prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...curr.name])];
|
|
971
|
-
return prev;
|
|
972
|
-
}
|
|
973
|
-
return [...prev, curr];
|
|
974
|
-
}, []);
|
|
975
|
-
return naturalOrderby.orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
|
|
976
|
-
}
|
|
977
|
-
function combineImports(imports, exports, source) {
|
|
978
|
-
const combinedImports = naturalOrderby.orderBy(imports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
|
|
979
|
-
let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
|
|
980
|
-
const hasImportInSource = (importName) => {
|
|
981
|
-
if (!source) {
|
|
982
|
-
return true;
|
|
983
|
-
}
|
|
984
|
-
const checker = (name2) => name2 && !!source.includes(name2);
|
|
985
|
-
return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
|
|
986
|
-
};
|
|
987
|
-
if (Array.isArray(name)) {
|
|
988
|
-
name = name.filter((item) => hasImportInSource(item));
|
|
989
|
-
}
|
|
990
|
-
const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
|
|
991
|
-
const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
|
|
992
|
-
const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly);
|
|
993
|
-
if (prevByPathNameAndIsTypeOnly) {
|
|
994
|
-
return prev;
|
|
995
|
-
}
|
|
996
|
-
if (uniquePrev || Array.isArray(name) && !name.length) {
|
|
997
|
-
return prev;
|
|
998
|
-
}
|
|
999
|
-
if (!prevByPath) {
|
|
1000
|
-
return [
|
|
1001
|
-
...prev,
|
|
1002
|
-
{
|
|
1003
|
-
...curr,
|
|
1004
|
-
name
|
|
1005
|
-
}
|
|
1006
|
-
];
|
|
1007
|
-
}
|
|
1008
|
-
if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
|
|
1009
|
-
prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...name])];
|
|
1010
|
-
return prev;
|
|
1011
|
-
}
|
|
1012
|
-
if (!Array.isArray(name) && name && !hasImportInSource(name)) {
|
|
1013
|
-
return prev;
|
|
1014
|
-
}
|
|
1015
|
-
return [...prev, curr];
|
|
1016
|
-
}, []);
|
|
1017
|
-
return naturalOrderby.orderBy(combinedImports, [(v) => !v.isTypeOnly], ["desc"]);
|
|
1018
|
-
}
|
|
1019
|
-
function getEnvSource(source, env) {
|
|
1020
|
-
if (!env) {
|
|
1021
|
-
return source;
|
|
1022
|
-
}
|
|
1023
|
-
const keys = Object.keys(env);
|
|
1024
|
-
if (!keys.length) {
|
|
1025
|
-
return source;
|
|
338
|
+
runSync(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
339
|
+
new Promise((resolve, reject) => {
|
|
340
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
341
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
342
|
+
__privateSet(this, _queue, __privateGet(this, _queue).filter((queueItem) => queueItem.name === item.name));
|
|
343
|
+
});
|
|
344
|
+
__privateGet(this, _queue).push(item);
|
|
345
|
+
__privateMethod(this, _work, work_fn).call(this);
|
|
346
|
+
});
|
|
1026
347
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
const replaceBy = environmentValue ? `'${environmentValue.replaceAll('"', "")?.replaceAll("'", "")}'` : "undefined";
|
|
1030
|
-
if (key.toUpperCase() !== key) {
|
|
1031
|
-
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
1032
|
-
}
|
|
1033
|
-
if (typeof replaceBy === "string") {
|
|
1034
|
-
prev = transformers.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
|
|
1035
|
-
prev = transformers.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
|
|
1036
|
-
`, "ig"), ""), replaceBy, key });
|
|
1037
|
-
}
|
|
1038
|
-
return prev;
|
|
1039
|
-
}, source);
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// src/utils/TreeNode.ts
|
|
1043
|
-
var TreeNode = class _TreeNode {
|
|
1044
|
-
constructor(data, parent) {
|
|
1045
|
-
this.children = [];
|
|
1046
|
-
this.data = data;
|
|
1047
|
-
this.parent = parent;
|
|
1048
|
-
return this;
|
|
348
|
+
get hasJobs() {
|
|
349
|
+
return __privateGet(this, _workerCount) > 0 || __privateGet(this, _queue).length > 0;
|
|
1049
350
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
if (!this.children) {
|
|
1053
|
-
this.children = [];
|
|
1054
|
-
}
|
|
1055
|
-
this.children.push(child);
|
|
1056
|
-
return child;
|
|
351
|
+
get count() {
|
|
352
|
+
return __privateGet(this, _workerCount);
|
|
1057
353
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
target = this.children[i].find(data);
|
|
1068
|
-
if (target) {
|
|
1069
|
-
return target;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
return null;
|
|
354
|
+
};
|
|
355
|
+
_queue = new WeakMap();
|
|
356
|
+
_workerCount = new WeakMap();
|
|
357
|
+
_maxParallel = new WeakMap();
|
|
358
|
+
_debug = new WeakMap();
|
|
359
|
+
_work = new WeakSet();
|
|
360
|
+
work_fn = function() {
|
|
361
|
+
if (__privateGet(this, _workerCount) >= __privateGet(this, _maxParallel)) {
|
|
362
|
+
return;
|
|
1074
363
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
364
|
+
__privateWrapper(this, _workerCount)._++;
|
|
365
|
+
let entry;
|
|
366
|
+
while (entry = __privateGet(this, _queue).shift()) {
|
|
367
|
+
const { reject, resolve, job, name, description } = entry;
|
|
368
|
+
if (__privateGet(this, _debug)) {
|
|
369
|
+
perf_hooks.performance.mark(name + "_start");
|
|
1078
370
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
371
|
+
job().then((result) => {
|
|
372
|
+
this.eventEmitter.emit("jobDone", result);
|
|
373
|
+
resolve(result);
|
|
374
|
+
if (__privateGet(this, _debug)) {
|
|
375
|
+
perf_hooks.performance.mark(name + "_stop");
|
|
376
|
+
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
1083
377
|
}
|
|
1084
|
-
}
|
|
1085
|
-
|
|
378
|
+
}).catch((err) => {
|
|
379
|
+
this.eventEmitter.emit("jobFailed", err);
|
|
380
|
+
reject(err);
|
|
381
|
+
});
|
|
1086
382
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
383
|
+
__privateWrapper(this, _workerCount)._--;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// src/utils/renderTemplate.ts
|
|
387
|
+
function renderTemplate(template, data = void 0) {
|
|
388
|
+
if (!data || !Object.keys(data).length) {
|
|
389
|
+
return template.replace(/{{(.*?)}}/g, "");
|
|
1092
390
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
391
|
+
const matches = template.match(/{{(.*?)}}/g);
|
|
392
|
+
return matches?.reduce((prev, curr) => {
|
|
393
|
+
const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
|
|
394
|
+
if (index === void 0) {
|
|
395
|
+
return prev;
|
|
1096
396
|
}
|
|
1097
|
-
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1100
|
-
this.children[i].forEach(callback);
|
|
1101
|
-
}
|
|
397
|
+
const value = data[index];
|
|
398
|
+
if (value === void 0) {
|
|
399
|
+
return prev;
|
|
1102
400
|
}
|
|
1103
|
-
return
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
try {
|
|
1107
|
-
const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
|
|
1108
|
-
const filteredTree = dirTree__default.default(path2, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
|
|
1109
|
-
if (!filteredTree) {
|
|
1110
|
-
return null;
|
|
401
|
+
return prev.replace(curr, () => {
|
|
402
|
+
if (typeof value === "boolean") {
|
|
403
|
+
return `${value.toString()}` || "false";
|
|
1111
404
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
};
|
|
405
|
+
return value || "";
|
|
406
|
+
}).trim();
|
|
407
|
+
}, template) || "";
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// src/utils/timeout.ts
|
|
411
|
+
async function timeout(ms) {
|
|
412
|
+
return new Promise((resolve) => {
|
|
413
|
+
setTimeout(() => {
|
|
414
|
+
resolve(true);
|
|
415
|
+
}, ms);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
1128
418
|
|
|
1129
419
|
// src/utils/uniqueName.ts
|
|
1130
420
|
function getUniqueName(originalName, data) {
|
|
@@ -1145,9 +435,11 @@ function setUniqueName(originalName, data) {
|
|
|
1145
435
|
data[originalName] = 1;
|
|
1146
436
|
return originalName;
|
|
1147
437
|
}
|
|
438
|
+
|
|
439
|
+
// src/utils/URLPath.ts
|
|
1148
440
|
var URLPath = class {
|
|
1149
|
-
constructor(
|
|
1150
|
-
this.path =
|
|
441
|
+
constructor(path) {
|
|
442
|
+
this.path = path;
|
|
1151
443
|
return this;
|
|
1152
444
|
}
|
|
1153
445
|
/**
|
|
@@ -1211,7 +503,7 @@ var URLPath = class {
|
|
|
1211
503
|
let newPath = this.path.replaceAll("{", "${");
|
|
1212
504
|
if (found) {
|
|
1213
505
|
newPath = found.reduce((prev, curr) => {
|
|
1214
|
-
const pathParam = replacer ? replacer(
|
|
506
|
+
const pathParam = replacer ? replacer(transformers_default.camelCase(curr)) : transformers_default.camelCase(curr);
|
|
1215
507
|
const replacement = `\${${pathParam}}`;
|
|
1216
508
|
return prev.replace(curr, replacement);
|
|
1217
509
|
}, this.path);
|
|
@@ -1227,7 +519,7 @@ var URLPath = class {
|
|
|
1227
519
|
const params = {};
|
|
1228
520
|
found.forEach((item) => {
|
|
1229
521
|
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
1230
|
-
const pathParam = replacer ? replacer(
|
|
522
|
+
const pathParam = replacer ? replacer(transformers_default.camelCase(item)) : transformers_default.camelCase(item);
|
|
1231
523
|
params[pathParam] = pathParam;
|
|
1232
524
|
}, this.path);
|
|
1233
525
|
return params;
|
|
@@ -1241,32 +533,15 @@ var URLPath = class {
|
|
|
1241
533
|
}
|
|
1242
534
|
};
|
|
1243
535
|
|
|
1244
|
-
Object.defineProperty(exports, 'pc', {
|
|
1245
|
-
enumerable: true,
|
|
1246
|
-
get: function () { return pc2__default.default; }
|
|
1247
|
-
});
|
|
1248
536
|
exports.FunctionParams = FunctionParams;
|
|
1249
|
-
exports.LogLevel = LogLevel;
|
|
1250
537
|
exports.Queue = Queue;
|
|
1251
|
-
exports.TreeNode = TreeNode;
|
|
1252
538
|
exports.URLPath = URLPath;
|
|
1253
|
-
exports.clean = clean;
|
|
1254
|
-
exports.createLogger = createLogger;
|
|
1255
|
-
exports.createPluginCache = createPluginCache;
|
|
1256
|
-
exports.getRelativePath = getRelativePath;
|
|
1257
539
|
exports.getUniqueName = getUniqueName;
|
|
1258
540
|
exports.isPromise = isPromise;
|
|
1259
541
|
exports.isPromiseFulfilledResult = isPromiseFulfilledResult;
|
|
1260
542
|
exports.isPromiseRejectedResult = isPromiseRejectedResult;
|
|
1261
|
-
exports.randomColour = randomColour;
|
|
1262
|
-
exports.randomPicoColour = randomPicoColour;
|
|
1263
|
-
exports.read = read;
|
|
1264
|
-
exports.readSync = readSync;
|
|
1265
543
|
exports.renderTemplate = renderTemplate;
|
|
1266
544
|
exports.setUniqueName = setUniqueName;
|
|
1267
|
-
exports.throttle = throttle;
|
|
1268
545
|
exports.timeout = timeout;
|
|
1269
|
-
exports.transformers = transformers;
|
|
1270
|
-
exports.write = write;
|
|
1271
546
|
//# sourceMappingURL=out.js.map
|
|
1272
547
|
//# sourceMappingURL=utils.cjs.map
|