@kubb/fabric-core 0.12.11 → 0.13.1
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/{Fabric-CrRJykMN.d.ts → Fabric-CE-4sqCG.d.ts} +1 -4
- package/dist/{Fabric-DMmgrLto.d.cts → Fabric-efyCO1t7.d.ts} +2 -2
- package/dist/{RootContext-Cf7WJM7r.d.cts → RootContext-BgiMS39h.d.ts} +3 -3
- package/dist/{RootContext-CvaGJ-4g.d.ts → RootContext-CA-zkTEp.d.ts} +3 -4
- package/dist/{chunk-BVHe6Par.js → chunk-BYypO7fO.js} +1 -5
- package/dist/{chunk-DVipidnM.cjs → chunk-uaV2rQ02.cjs} +0 -10
- package/dist/{defaultParser-BK-zOanQ.cjs → defaultParser-BAgmtMo_.cjs} +2 -3
- package/dist/{defaultParser-BK-zOanQ.cjs.map → defaultParser-BAgmtMo_.cjs.map} +1 -1
- package/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
- package/dist/{defaultParser-BD_N68Bo.js.map → defaultParser-C1atU7yU.js.map} +1 -1
- package/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
- package/dist/{getRelativePath-C4Au07ON.js.map → getRelativePath-BcieQL5M.js.map} +1 -1
- package/dist/{getRelativePath-DpbA6qm5.cjs → getRelativePath-DVG8dIzW.cjs} +2 -2
- package/dist/{getRelativePath-DpbA6qm5.cjs.map → getRelativePath-DVG8dIzW.cjs.map} +1 -1
- package/dist/index.cjs +62 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/{Root-CKos-Ahf.cjs → onProcessExit-B7_bTfyR.cjs} +115 -213
- package/dist/onProcessExit-B7_bTfyR.cjs.map +1 -0
- package/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
- package/dist/onProcessExit-CF200hsz.js.map +1 -0
- package/dist/parsers/typescript.cjs +4 -4
- package/dist/parsers/typescript.cjs.map +1 -1
- package/dist/parsers/typescript.d.ts +1 -2
- package/dist/parsers/typescript.js +3 -4
- package/dist/parsers/typescript.js.map +1 -1
- package/dist/parsers.cjs +2 -3
- package/dist/parsers.cjs.map +1 -1
- package/dist/parsers.d.ts +1 -2
- package/dist/parsers.js +2 -3
- package/dist/parsers.js.map +1 -1
- package/dist/plugins.cjs +61 -305
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.ts +9 -40
- package/dist/plugins.js +58 -298
- package/dist/plugins.js.map +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.ts +3 -4
- package/dist/types.js +1 -1
- package/dist/{useNodeTree-CgEKFUV-.d.cts → useNodeTree-BpHR6gQx.d.ts} +2 -2
- package/dist/{useNodeTree-CamNuFQP.d.ts → useNodeTree-DuQ5Df0t.d.ts} +2 -3
- package/package.json +8 -18
- package/src/FileManager.ts +6 -2
- package/src/createFile.ts +12 -9
- package/src/index.ts +3 -2
- package/src/plugins/fsPlugin.ts +8 -6
- package/src/plugins/fsxPlugin/Runtime.ts +4 -7
- package/src/plugins/index.ts +0 -1
- package/src/plugins/loggerPlugin.ts +15 -192
- package/src/utils/onProcessExit.ts +35 -0
- package/dist/Root-BQX3eHqb.js.map +0 -1
- package/dist/Root-CKos-Ahf.cjs.map +0 -1
- package/dist/index.d.cts +0 -595
- package/dist/parsers/typescript.d.cts +0 -45
- package/dist/parsers.d.cts +0 -37
- package/dist/plugins.d.cts +0 -149
- package/dist/types.d.cts +0 -11
- package/src/plugins/graphPlugin.ts +0 -136
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-
|
|
2
|
-
const require_getRelativePath = require('./getRelativePath-
|
|
3
|
-
const require_defaultParser = require('./defaultParser-
|
|
4
|
-
let
|
|
1
|
+
const require_chunk = require('./chunk-uaV2rQ02.cjs');
|
|
2
|
+
const require_getRelativePath = require('./getRelativePath-DVG8dIzW.cjs');
|
|
3
|
+
const require_defaultParser = require('./defaultParser-BAgmtMo_.cjs');
|
|
4
|
+
let remeda = require("remeda");
|
|
5
5
|
let node_crypto = require("node:crypto");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
7
|
node_path = require_chunk.__toESM(node_path);
|
|
8
|
-
let remeda = require("remeda");
|
|
9
8
|
let p_limit = require("p-limit");
|
|
10
9
|
p_limit = require_chunk.__toESM(p_limit);
|
|
11
10
|
let node_events = require("node:events");
|
|
@@ -86,21 +85,11 @@ const NodeTreeContext = createContext(null);
|
|
|
86
85
|
//#region src/createFile.ts
|
|
87
86
|
function combineSources(sources) {
|
|
88
87
|
return (0, remeda.uniqueBy)(sources, (obj) => {
|
|
89
|
-
|
|
90
|
-
var _obj$name;
|
|
91
|
-
var _obj$isExportable;
|
|
92
|
-
var _obj$isTypeOnly;
|
|
93
|
-
return `${(_ref = (_obj$name = obj.name) !== null && _obj$name !== void 0 ? _obj$name : obj.value) !== null && _ref !== void 0 ? _ref : ""}:${(_obj$isExportable = obj.isExportable) !== null && _obj$isExportable !== void 0 ? _obj$isExportable : false}:${(_obj$isTypeOnly = obj.isTypeOnly) !== null && _obj$isTypeOnly !== void 0 ? _obj$isTypeOnly : false}`;
|
|
88
|
+
return `${obj.name ?? obj.value ?? ""}:${obj.isExportable ?? false}:${obj.isTypeOnly ?? false}`;
|
|
94
89
|
});
|
|
95
90
|
}
|
|
96
91
|
function combineExports(exports) {
|
|
97
|
-
const sorted = (0,
|
|
98
|
-
(v) => !!Array.isArray(v.name),
|
|
99
|
-
(v) => !v.isTypeOnly,
|
|
100
|
-
(v) => v.path,
|
|
101
|
-
(v) => !!v.name,
|
|
102
|
-
(v) => Array.isArray(v.name) ? (0, natural_orderby.orderBy)(v.name) : v.name
|
|
103
|
-
]);
|
|
92
|
+
const sorted = (0, remeda.sortBy)(exports, (v) => !!Array.isArray(v.name), (v) => !v.isTypeOnly, (v) => v.path, (v) => !!v.name, (v) => Array.isArray(v.name) ? [...v.name].sort().join("\0") : v.name ?? "");
|
|
104
93
|
const prev = [];
|
|
105
94
|
const pathMap = /* @__PURE__ */ new Map();
|
|
106
95
|
const uniqueMap = /* @__PURE__ */ new Map();
|
|
@@ -109,7 +98,7 @@ function combineExports(exports) {
|
|
|
109
98
|
const pathKey = curr.path;
|
|
110
99
|
const prevByPath = pathMap.get(pathKey);
|
|
111
100
|
const uniqueKey = `${`${pathKey}:${Array.isArray(name) ? JSON.stringify(name) : name || ""}:${curr.isTypeOnly}`}:${curr.asAlias || ""}`;
|
|
112
|
-
if (uniqueMap.get(uniqueKey) || Array.isArray(name) && !name.length ||
|
|
101
|
+
if (uniqueMap.get(uniqueKey) || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) continue;
|
|
113
102
|
if (!prevByPath) {
|
|
114
103
|
const newItem = {
|
|
115
104
|
...curr,
|
|
@@ -149,13 +138,7 @@ function combineImports(imports, exports, source) {
|
|
|
149
138
|
usageCache.set(importName, isUsed);
|
|
150
139
|
return isUsed;
|
|
151
140
|
};
|
|
152
|
-
const sorted = (0,
|
|
153
|
-
(v) => !!Array.isArray(v.name),
|
|
154
|
-
(v) => !v.isTypeOnly,
|
|
155
|
-
(v) => v.path,
|
|
156
|
-
(v) => !!v.name,
|
|
157
|
-
(v) => Array.isArray(v.name) ? (0, natural_orderby.orderBy)(v.name) : v.name
|
|
158
|
-
]);
|
|
141
|
+
const sorted = (0, remeda.sortBy)(imports, (v) => Array.isArray(v.name), (v) => !v.isTypeOnly, (v) => v.path, (v) => !!v.name, (v) => Array.isArray(v.name) ? [...v.name].sort().join("\0") : v.name ?? "");
|
|
159
142
|
const prev = [];
|
|
160
143
|
const pathTypeMap = /* @__PURE__ */ new Map();
|
|
161
144
|
const uniqueMap = /* @__PURE__ */ new Map();
|
|
@@ -192,15 +175,12 @@ function combineImports(imports, exports, source) {
|
|
|
192
175
|
* Helper to create a file with name and id set
|
|
193
176
|
*/
|
|
194
177
|
function createFile(file) {
|
|
195
|
-
var _file$exports;
|
|
196
|
-
var _file$imports;
|
|
197
|
-
var _file$sources;
|
|
198
178
|
const extname = node_path.default.extname(file.baseName);
|
|
199
179
|
if (!extname) throw new Error(`No extname found for ${file.baseName}`);
|
|
200
180
|
const source = file.sources.map((item) => item.value).join("\n\n");
|
|
201
|
-
const exports =
|
|
202
|
-
const imports =
|
|
203
|
-
const sources =
|
|
181
|
+
const exports = file.exports?.length ? combineExports(file.exports) : [];
|
|
182
|
+
const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : [];
|
|
183
|
+
const sources = file.sources?.length ? combineSources(file.sources) : [];
|
|
204
184
|
return {
|
|
205
185
|
...file,
|
|
206
186
|
id: (0, node_crypto.createHash)("sha256").update(file.path).digest("hex"),
|
|
@@ -213,53 +193,20 @@ function createFile(file) {
|
|
|
213
193
|
};
|
|
214
194
|
}
|
|
215
195
|
|
|
216
|
-
//#endregion
|
|
217
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/checkPrivateRedeclaration.js
|
|
218
|
-
function _checkPrivateRedeclaration(e, t) {
|
|
219
|
-
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldInitSpec.js
|
|
224
|
-
function _classPrivateFieldInitSpec(e, t, a) {
|
|
225
|
-
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/assertClassBrand.js
|
|
230
|
-
function _assertClassBrand(e, t, n) {
|
|
231
|
-
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
232
|
-
throw new TypeError("Private element is not present on this object");
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldGet2.js
|
|
237
|
-
function _classPrivateFieldGet2(s, a) {
|
|
238
|
-
return s.get(_assertClassBrand(s, a));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateFieldSet2.js
|
|
243
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
244
|
-
return s.set(_assertClassBrand(s, a), r), r;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
196
|
//#endregion
|
|
248
197
|
//#region src/utils/AsyncEventEmitter.ts
|
|
249
|
-
var _emitter = /* @__PURE__ */ new WeakMap();
|
|
250
|
-
var _mode = /* @__PURE__ */ new WeakMap();
|
|
251
198
|
var AsyncEventEmitter = class {
|
|
252
199
|
constructor({ maxListener = 100, mode = "sequential" } = {}) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
_classPrivateFieldGet2(_emitter, this).setMaxListeners(maxListener);
|
|
256
|
-
_classPrivateFieldSet2(_mode, this, mode);
|
|
200
|
+
this.#emitter.setMaxListeners(maxListener);
|
|
201
|
+
this.#mode = mode;
|
|
257
202
|
}
|
|
203
|
+
#emitter = new node_events.EventEmitter();
|
|
204
|
+
#mode;
|
|
258
205
|
async emit(eventName, ...eventArgs) {
|
|
259
|
-
const listeners =
|
|
206
|
+
const listeners = this.#emitter.listeners(eventName);
|
|
260
207
|
if (listeners.length === 0) return;
|
|
261
208
|
const errors = [];
|
|
262
|
-
if (
|
|
209
|
+
if (this.#mode === "sequential") for (const listener of listeners) try {
|
|
263
210
|
await listener(...eventArgs);
|
|
264
211
|
} catch (err) {
|
|
265
212
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
@@ -280,7 +227,7 @@ var AsyncEventEmitter = class {
|
|
|
280
227
|
if (errors.length > 1) throw new AggregateError(errors, `Errors in async listeners for "${eventName}"`);
|
|
281
228
|
}
|
|
282
229
|
on(eventName, handler) {
|
|
283
|
-
|
|
230
|
+
this.#emitter.on(eventName, handler);
|
|
284
231
|
}
|
|
285
232
|
onOnce(eventName, handler) {
|
|
286
233
|
const wrapper = (...args) => {
|
|
@@ -290,67 +237,24 @@ var AsyncEventEmitter = class {
|
|
|
290
237
|
this.on(eventName, wrapper);
|
|
291
238
|
}
|
|
292
239
|
off(eventName, handler) {
|
|
293
|
-
|
|
240
|
+
this.#emitter.off(eventName, handler);
|
|
294
241
|
}
|
|
295
242
|
removeAll() {
|
|
296
|
-
|
|
243
|
+
this.#emitter.removeAllListeners();
|
|
297
244
|
}
|
|
298
245
|
};
|
|
299
246
|
|
|
300
|
-
//#endregion
|
|
301
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/typeof.js
|
|
302
|
-
function _typeof(o) {
|
|
303
|
-
"@babel/helpers - typeof";
|
|
304
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
305
|
-
return typeof o;
|
|
306
|
-
} : function(o) {
|
|
307
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
308
|
-
}, _typeof(o);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/toPrimitive.js
|
|
313
|
-
function toPrimitive(t, r) {
|
|
314
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
315
|
-
var e = t[Symbol.toPrimitive];
|
|
316
|
-
if (void 0 !== e) {
|
|
317
|
-
var i = e.call(t, r || "default");
|
|
318
|
-
if ("object" != _typeof(i)) return i;
|
|
319
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
320
|
-
}
|
|
321
|
-
return ("string" === r ? String : Number)(t);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
//#endregion
|
|
325
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/toPropertyKey.js
|
|
326
|
-
function toPropertyKey(t) {
|
|
327
|
-
var i = toPrimitive(t, "string");
|
|
328
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/defineProperty.js
|
|
333
|
-
function _defineProperty(e, r, t) {
|
|
334
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
335
|
-
value: t,
|
|
336
|
-
enumerable: !0,
|
|
337
|
-
configurable: !0,
|
|
338
|
-
writable: !0
|
|
339
|
-
}) : e[r] = t, e;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
247
|
//#endregion
|
|
343
248
|
//#region src/FileProcessor.ts
|
|
344
|
-
var _limit = /* @__PURE__ */ new WeakMap();
|
|
345
249
|
var FileProcessor = class {
|
|
250
|
+
#limit = (0, p_limit.default)(100);
|
|
251
|
+
events;
|
|
346
252
|
constructor({ events = new AsyncEventEmitter() } = {}) {
|
|
347
|
-
_classPrivateFieldInitSpec(this, _limit, (0, p_limit.default)(100));
|
|
348
|
-
_defineProperty(this, "events", void 0);
|
|
349
253
|
this.events = events;
|
|
350
254
|
return this;
|
|
351
255
|
}
|
|
352
256
|
async parse(file, { parsers, extension } = {}) {
|
|
353
|
-
const parseExtName =
|
|
257
|
+
const parseExtName = extension?.[file.extname] || void 0;
|
|
354
258
|
if (!parsers) {
|
|
355
259
|
console.warn("No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.");
|
|
356
260
|
return require_defaultParser.defaultParser.parse(file, { extname: parseExtName });
|
|
@@ -387,7 +291,7 @@ var FileProcessor = class {
|
|
|
387
291
|
}
|
|
388
292
|
for await (const [file, index] of asyncFiles()) if (file) await processOne(file, index);
|
|
389
293
|
} else {
|
|
390
|
-
const promises = files.map((resolvedFile, index) =>
|
|
294
|
+
const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)));
|
|
391
295
|
await Promise.all(promises);
|
|
392
296
|
}
|
|
393
297
|
await this.events.emit("files:processing:end", files);
|
|
@@ -397,39 +301,29 @@ var FileProcessor = class {
|
|
|
397
301
|
|
|
398
302
|
//#endregion
|
|
399
303
|
//#region src/utils/Cache.ts
|
|
400
|
-
var _buffer = /* @__PURE__ */ new WeakMap();
|
|
401
304
|
var Cache = class {
|
|
402
|
-
|
|
403
|
-
_classPrivateFieldInitSpec(this, _buffer, /* @__PURE__ */ new Map());
|
|
404
|
-
}
|
|
305
|
+
#buffer = /* @__PURE__ */ new Map();
|
|
405
306
|
get(key) {
|
|
406
|
-
|
|
407
|
-
return (_this$buffer$get = _classPrivateFieldGet2(_buffer, this).get(key)) !== null && _this$buffer$get !== void 0 ? _this$buffer$get : null;
|
|
307
|
+
return this.#buffer.get(key) ?? null;
|
|
408
308
|
}
|
|
409
309
|
set(key, value) {
|
|
410
|
-
|
|
310
|
+
this.#buffer.set(key, value);
|
|
411
311
|
}
|
|
412
312
|
delete(key) {
|
|
413
|
-
|
|
313
|
+
this.#buffer.delete(key);
|
|
414
314
|
}
|
|
415
315
|
clear() {
|
|
416
|
-
|
|
316
|
+
this.#buffer.clear();
|
|
417
317
|
}
|
|
418
318
|
keys() {
|
|
419
|
-
return [...
|
|
319
|
+
return [...this.#buffer.keys()];
|
|
420
320
|
}
|
|
421
321
|
values() {
|
|
422
|
-
return [...
|
|
322
|
+
return [...this.#buffer.values()];
|
|
423
323
|
}
|
|
424
324
|
flush() {}
|
|
425
325
|
};
|
|
426
326
|
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region \0@oxc-project+runtime@0.112.0/helpers/classPrivateMethodInitSpec.js
|
|
429
|
-
function _classPrivateMethodInitSpec(e, a) {
|
|
430
|
-
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
327
|
//#endregion
|
|
434
328
|
//#region src/FileManager.ts
|
|
435
329
|
function mergeFile(a, b) {
|
|
@@ -440,20 +334,24 @@ function mergeFile(a, b) {
|
|
|
440
334
|
exports: [...a.exports || [], ...b.exports || []]
|
|
441
335
|
};
|
|
442
336
|
}
|
|
443
|
-
var _cache = /* @__PURE__ */ new WeakMap();
|
|
444
|
-
var _filesCache = /* @__PURE__ */ new WeakMap();
|
|
445
|
-
var _FileManager_brand = /* @__PURE__ */ new WeakSet();
|
|
446
337
|
var FileManager = class {
|
|
338
|
+
#cache = new Cache();
|
|
339
|
+
#filesCache = null;
|
|
340
|
+
events;
|
|
341
|
+
processor;
|
|
447
342
|
constructor({ events = new AsyncEventEmitter() } = {}) {
|
|
448
|
-
_classPrivateMethodInitSpec(this, _FileManager_brand);
|
|
449
|
-
_classPrivateFieldInitSpec(this, _cache, new Cache());
|
|
450
|
-
_classPrivateFieldInitSpec(this, _filesCache, null);
|
|
451
|
-
_defineProperty(this, "events", void 0);
|
|
452
|
-
_defineProperty(this, "processor", void 0);
|
|
453
343
|
this.processor = new FileProcessor({ events });
|
|
454
344
|
this.events = events;
|
|
455
345
|
return this;
|
|
456
346
|
}
|
|
347
|
+
#resolvePath(file) {
|
|
348
|
+
this.events.emit("file:resolve:path", file);
|
|
349
|
+
return file;
|
|
350
|
+
}
|
|
351
|
+
#resolveName(file) {
|
|
352
|
+
this.events.emit("file:resolve:name", file);
|
|
353
|
+
return file;
|
|
354
|
+
}
|
|
457
355
|
add(...files) {
|
|
458
356
|
const resolvedFiles = [];
|
|
459
357
|
const mergedFiles = /* @__PURE__ */ new Map();
|
|
@@ -463,10 +361,10 @@ var FileManager = class {
|
|
|
463
361
|
else mergedFiles.set(file.path, file);
|
|
464
362
|
});
|
|
465
363
|
for (let file of mergedFiles.values()) {
|
|
466
|
-
file =
|
|
467
|
-
file =
|
|
364
|
+
file = this.#resolveName(file);
|
|
365
|
+
file = this.#resolvePath(file);
|
|
468
366
|
const resolvedFile = createFile(file);
|
|
469
|
-
|
|
367
|
+
this.#cache.set(resolvedFile.path, resolvedFile);
|
|
470
368
|
this.flush();
|
|
471
369
|
resolvedFiles.push(resolvedFile);
|
|
472
370
|
}
|
|
@@ -482,11 +380,11 @@ var FileManager = class {
|
|
|
482
380
|
else mergedFiles.set(file.path, file);
|
|
483
381
|
});
|
|
484
382
|
for (let file of mergedFiles.values()) {
|
|
485
|
-
const existing =
|
|
486
|
-
file =
|
|
487
|
-
file =
|
|
383
|
+
const existing = this.#cache.get(file.path);
|
|
384
|
+
file = this.#resolveName(file);
|
|
385
|
+
file = this.#resolvePath(file);
|
|
488
386
|
const resolvedFile = createFile(existing ? mergeFile(existing, file) : file);
|
|
489
|
-
|
|
387
|
+
this.#cache.set(resolvedFile.path, resolvedFile);
|
|
490
388
|
this.flush();
|
|
491
389
|
resolvedFiles.push(resolvedFile);
|
|
492
390
|
}
|
|
@@ -494,29 +392,29 @@ var FileManager = class {
|
|
|
494
392
|
return resolvedFiles;
|
|
495
393
|
}
|
|
496
394
|
flush() {
|
|
497
|
-
|
|
498
|
-
|
|
395
|
+
this.#filesCache = null;
|
|
396
|
+
this.#cache.flush();
|
|
499
397
|
}
|
|
500
398
|
getByPath(path) {
|
|
501
|
-
return
|
|
399
|
+
return this.#cache.get(path);
|
|
502
400
|
}
|
|
503
401
|
deleteByPath(path) {
|
|
504
|
-
|
|
505
|
-
|
|
402
|
+
this.#cache.delete(path);
|
|
403
|
+
this.#filesCache = null;
|
|
506
404
|
}
|
|
507
405
|
clear() {
|
|
508
|
-
|
|
509
|
-
|
|
406
|
+
this.#cache.clear();
|
|
407
|
+
this.#filesCache = null;
|
|
510
408
|
}
|
|
511
409
|
get files() {
|
|
512
|
-
if (
|
|
513
|
-
const keys = (0,
|
|
410
|
+
if (this.#filesCache) return this.#filesCache;
|
|
411
|
+
const keys = (0, remeda.sortBy)(this.#cache.keys(), (v) => v.length, (v) => require_getRelativePath.trimExtName(v).endsWith("index"));
|
|
514
412
|
const files = [];
|
|
515
413
|
for (const key of keys) {
|
|
516
|
-
const file =
|
|
414
|
+
const file = this.#cache.get(key);
|
|
517
415
|
if (file) files.push(file);
|
|
518
416
|
}
|
|
519
|
-
|
|
417
|
+
this.#filesCache = files;
|
|
520
418
|
return files;
|
|
521
419
|
}
|
|
522
420
|
async write(options) {
|
|
@@ -527,41 +425,31 @@ var FileManager = class {
|
|
|
527
425
|
return resolvedFiles;
|
|
528
426
|
}
|
|
529
427
|
};
|
|
530
|
-
function _resolvePath(file) {
|
|
531
|
-
this.events.emit("file:resolve:path", file);
|
|
532
|
-
return file;
|
|
533
|
-
}
|
|
534
|
-
function _resolveName(file) {
|
|
535
|
-
this.events.emit("file:resolve:name", file);
|
|
536
|
-
return file;
|
|
537
|
-
}
|
|
538
428
|
|
|
539
429
|
//#endregion
|
|
540
430
|
//#region src/utils/TreeNode.ts
|
|
541
|
-
var _childrenMap = /* @__PURE__ */ new WeakMap();
|
|
542
|
-
var _cachedLeaves = /* @__PURE__ */ new WeakMap();
|
|
543
431
|
var TreeNode = class TreeNode {
|
|
432
|
+
data;
|
|
433
|
+
parent;
|
|
434
|
+
children = [];
|
|
435
|
+
#childrenMap = /* @__PURE__ */ new Map();
|
|
436
|
+
#cachedLeaves;
|
|
544
437
|
constructor(data, parent) {
|
|
545
|
-
_defineProperty(this, "data", void 0);
|
|
546
|
-
_defineProperty(this, "parent", void 0);
|
|
547
|
-
_defineProperty(this, "children", []);
|
|
548
|
-
_classPrivateFieldInitSpec(this, _childrenMap, /* @__PURE__ */ new Map());
|
|
549
|
-
_classPrivateFieldInitSpec(this, _cachedLeaves, void 0);
|
|
550
438
|
this.data = data;
|
|
551
439
|
this.parent = parent;
|
|
552
440
|
}
|
|
553
441
|
addChild(data) {
|
|
554
442
|
const child = new TreeNode(data, this);
|
|
555
443
|
this.children.push(child);
|
|
556
|
-
if (typeof data === "object" && data !== null && "name" in data)
|
|
557
|
-
|
|
444
|
+
if (typeof data === "object" && data !== null && "name" in data) this.#childrenMap.set(data.name, child);
|
|
445
|
+
this.#cachedLeaves = void 0;
|
|
558
446
|
return child;
|
|
559
447
|
}
|
|
560
448
|
getChildByName(name) {
|
|
561
|
-
return
|
|
449
|
+
return this.#childrenMap.get(name);
|
|
562
450
|
}
|
|
563
451
|
get leaves() {
|
|
564
|
-
if (
|
|
452
|
+
if (this.#cachedLeaves) return this.#cachedLeaves;
|
|
565
453
|
if (this.children.length === 0) return [this];
|
|
566
454
|
const result = [];
|
|
567
455
|
const stack = [...this.children];
|
|
@@ -573,7 +461,7 @@ var TreeNode = class TreeNode {
|
|
|
573
461
|
if (node.children.length > 0) stack.push(...node.children);
|
|
574
462
|
else result.push(node);
|
|
575
463
|
}
|
|
576
|
-
|
|
464
|
+
this.#cachedLeaves = result;
|
|
577
465
|
return result;
|
|
578
466
|
}
|
|
579
467
|
forEach(callback) {
|
|
@@ -620,8 +508,7 @@ var TreeNode = class TreeNode {
|
|
|
620
508
|
const normalizedPaths = /* @__PURE__ */ new Map();
|
|
621
509
|
const filteredFiles = [];
|
|
622
510
|
for (const file of files) {
|
|
623
|
-
|
|
624
|
-
const filePath = (_normalizedPaths$get = normalizedPaths.get(file)) !== null && _normalizedPaths$get !== void 0 ? _normalizedPaths$get : normalizePath(file.path);
|
|
511
|
+
const filePath = normalizedPaths.get(file) ?? normalizePath(file.path);
|
|
625
512
|
normalizedPaths.set(file, filePath);
|
|
626
513
|
if (!filePath.endsWith(".json") && (!rootFolder || filePath.startsWith(rootPrefix))) filteredFiles.push(file);
|
|
627
514
|
}
|
|
@@ -771,9 +658,8 @@ function createComponent(type, Component) {
|
|
|
771
658
|
fn.props = args[0];
|
|
772
659
|
fn.type = type;
|
|
773
660
|
fn.children = (...children) => {
|
|
774
|
-
var _args$;
|
|
775
661
|
const propsWithChildren = {
|
|
776
|
-
...
|
|
662
|
+
...args[0] ?? {},
|
|
777
663
|
children() {
|
|
778
664
|
return renderIntrinsic(children);
|
|
779
665
|
}
|
|
@@ -821,12 +707,46 @@ const Root = createComponent("Root", ({ onError, onExit, treeNode, fileManager,
|
|
|
821
707
|
try {
|
|
822
708
|
return children;
|
|
823
709
|
} catch (e) {
|
|
824
|
-
if (e instanceof Error) onError
|
|
710
|
+
if (e instanceof Error) onError?.(e);
|
|
825
711
|
return "";
|
|
826
712
|
}
|
|
827
713
|
});
|
|
828
714
|
Root.displayName = "Root";
|
|
829
715
|
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region src/utils/onProcessExit.ts
|
|
718
|
+
const SIGNALS = [
|
|
719
|
+
"SIGINT",
|
|
720
|
+
"SIGTERM",
|
|
721
|
+
"SIGHUP"
|
|
722
|
+
];
|
|
723
|
+
/**
|
|
724
|
+
* Register a callback to run when the process exits (via exit event or common signals).
|
|
725
|
+
* Returns an unsubscribe function.
|
|
726
|
+
*/
|
|
727
|
+
function onProcessExit(callback) {
|
|
728
|
+
const exitHandler = (code) => callback(code);
|
|
729
|
+
const signalHandlers = /* @__PURE__ */ new Map();
|
|
730
|
+
for (const signal of SIGNALS) {
|
|
731
|
+
const handler = () => {
|
|
732
|
+
unsubscribe();
|
|
733
|
+
try {
|
|
734
|
+
callback(null);
|
|
735
|
+
} finally {
|
|
736
|
+
process.kill(process.pid, signal);
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
signalHandlers.set(signal, handler);
|
|
740
|
+
process.on(signal, handler);
|
|
741
|
+
}
|
|
742
|
+
process.on("exit", exitHandler);
|
|
743
|
+
function unsubscribe() {
|
|
744
|
+
process.removeListener("exit", exitHandler);
|
|
745
|
+
for (const [signal, handler] of signalHandlers) process.removeListener(signal, handler);
|
|
746
|
+
}
|
|
747
|
+
return unsubscribe;
|
|
748
|
+
}
|
|
749
|
+
|
|
830
750
|
//#endregion
|
|
831
751
|
Object.defineProperty(exports, 'AsyncEventEmitter', {
|
|
832
752
|
enumerable: true,
|
|
@@ -876,30 +796,6 @@ Object.defineProperty(exports, 'TreeNode', {
|
|
|
876
796
|
return TreeNode;
|
|
877
797
|
}
|
|
878
798
|
});
|
|
879
|
-
Object.defineProperty(exports, '_classPrivateFieldGet2', {
|
|
880
|
-
enumerable: true,
|
|
881
|
-
get: function () {
|
|
882
|
-
return _classPrivateFieldGet2;
|
|
883
|
-
}
|
|
884
|
-
});
|
|
885
|
-
Object.defineProperty(exports, '_classPrivateFieldInitSpec', {
|
|
886
|
-
enumerable: true,
|
|
887
|
-
get: function () {
|
|
888
|
-
return _classPrivateFieldInitSpec;
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
Object.defineProperty(exports, '_classPrivateFieldSet2', {
|
|
892
|
-
enumerable: true,
|
|
893
|
-
get: function () {
|
|
894
|
-
return _classPrivateFieldSet2;
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
Object.defineProperty(exports, '_defineProperty', {
|
|
898
|
-
enumerable: true,
|
|
899
|
-
get: function () {
|
|
900
|
-
return _defineProperty;
|
|
901
|
-
}
|
|
902
|
-
});
|
|
903
799
|
Object.defineProperty(exports, 'createComponent', {
|
|
904
800
|
enumerable: true,
|
|
905
801
|
get: function () {
|
|
@@ -930,6 +826,12 @@ Object.defineProperty(exports, 'inject', {
|
|
|
930
826
|
return inject;
|
|
931
827
|
}
|
|
932
828
|
});
|
|
829
|
+
Object.defineProperty(exports, 'onProcessExit', {
|
|
830
|
+
enumerable: true,
|
|
831
|
+
get: function () {
|
|
832
|
+
return onProcessExit;
|
|
833
|
+
}
|
|
834
|
+
});
|
|
933
835
|
Object.defineProperty(exports, 'provide', {
|
|
934
836
|
enumerable: true,
|
|
935
837
|
get: function () {
|
|
@@ -954,4 +856,4 @@ Object.defineProperty(exports, 'unprovide', {
|
|
|
954
856
|
return unprovide;
|
|
955
857
|
}
|
|
956
858
|
});
|
|
957
|
-
//# sourceMappingURL=
|
|
859
|
+
//# sourceMappingURL=onProcessExit-B7_bTfyR.cjs.map
|