@bemoje/monorepo 1.2.1 → 1.2.2

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.
Files changed (125) hide show
  1. package/lib/index.cjs +19 -5219
  2. package/lib/index.d.cts +2765 -26
  3. package/lib/index.d.ts +2765 -26
  4. package/lib/index.js +14 -5217
  5. package/package.json +178 -298
  6. package/lib/MonoRepo.cjs +0 -7370
  7. package/lib/MonoRepo.d.cts +0 -10
  8. package/lib/MonoRepo.d.ts +0 -10
  9. package/lib/MonoRepo.js +0 -7361
  10. package/lib/code/AbstractCode.cjs +0 -5568
  11. package/lib/code/AbstractCode.d.cts +0 -30
  12. package/lib/code/AbstractCode.d.ts +0 -30
  13. package/lib/code/AbstractCode.js +0 -5562
  14. package/lib/code/CodeBlock.cjs +0 -5614
  15. package/lib/code/CodeBlock.d.cts +0 -22
  16. package/lib/code/CodeBlock.d.ts +0 -22
  17. package/lib/code/CodeBlock.js +0 -5608
  18. package/lib/code/TsCode.cjs +0 -7370
  19. package/lib/code/TsCode.d.cts +0 -10
  20. package/lib/code/TsCode.d.ts +0 -10
  21. package/lib/code/TsCode.js +0 -7361
  22. package/lib/code/imports/ImportKeywords.cjs +0 -5652
  23. package/lib/code/imports/ImportKeywords.d.cts +0 -10
  24. package/lib/code/imports/ImportKeywords.d.ts +0 -10
  25. package/lib/code/imports/ImportKeywords.js +0 -5646
  26. package/lib/code/imports/ImportSpecifiers.cjs +0 -5708
  27. package/lib/code/imports/ImportSpecifiers.d.cts +0 -10
  28. package/lib/code/imports/ImportSpecifiers.d.ts +0 -10
  29. package/lib/code/imports/ImportSpecifiers.js +0 -5702
  30. package/lib/code/imports/ImportStatement.cjs +0 -7372
  31. package/lib/code/imports/ImportStatement.d.cts +0 -10
  32. package/lib/code/imports/ImportStatement.d.ts +0 -10
  33. package/lib/code/imports/ImportStatement.js +0 -7363
  34. package/lib/code/imports/ModuleSpecifier.cjs +0 -7372
  35. package/lib/code/imports/ModuleSpecifier.d.cts +0 -10
  36. package/lib/code/imports/ModuleSpecifier.d.ts +0 -10
  37. package/lib/code/imports/ModuleSpecifier.js +0 -7363
  38. package/lib/common/AbstractBase.cjs +0 -638
  39. package/lib/common/AbstractBase.d.cts +0 -3
  40. package/lib/common/AbstractBase.d.ts +0 -3
  41. package/lib/common/AbstractBase.js +0 -634
  42. package/lib/file/File.cjs +0 -5496
  43. package/lib/file/File.d.cts +0 -10
  44. package/lib/file/File.d.ts +0 -10
  45. package/lib/file/File.js +0 -5490
  46. package/lib/file/TestFile.cjs +0 -7368
  47. package/lib/file/TestFile.d.cts +0 -10
  48. package/lib/file/TestFile.d.ts +0 -10
  49. package/lib/file/TestFile.js +0 -7359
  50. package/lib/file/TsFile.cjs +0 -7368
  51. package/lib/file/TsFile.d.cts +0 -10
  52. package/lib/file/TsFile.d.ts +0 -10
  53. package/lib/file/TsFile.js +0 -7359
  54. package/lib/methods/findWorkspacePackageName.cjs +0 -86
  55. package/lib/methods/findWorkspacePackageName.d.cts +0 -6
  56. package/lib/methods/findWorkspacePackageName.d.ts +0 -6
  57. package/lib/methods/findWorkspacePackageName.js +0 -78
  58. package/lib/methods/getAllImports.cjs +0 -20
  59. package/lib/methods/getAllImports.d.cts +0 -17
  60. package/lib/methods/getAllImports.d.ts +0 -17
  61. package/lib/methods/getAllImports.js +0 -18
  62. package/lib/methods/getAllWorkspacePackageJsonPaths.cjs +0 -57
  63. package/lib/methods/getAllWorkspacePackageJsonPaths.d.cts +0 -6
  64. package/lib/methods/getAllWorkspacePackageJsonPaths.d.ts +0 -6
  65. package/lib/methods/getAllWorkspacePackageJsonPaths.js +0 -49
  66. package/lib/methods/getAllWorkspacePackageJsons.cjs +0 -66
  67. package/lib/methods/getAllWorkspacePackageJsons.d.cts +0 -6
  68. package/lib/methods/getAllWorkspacePackageJsons.d.ts +0 -6
  69. package/lib/methods/getAllWorkspacePackageJsons.js +0 -58
  70. package/lib/methods/getAllWorkspacePackageNames.cjs +0 -75
  71. package/lib/methods/getAllWorkspacePackageNames.d.cts +0 -6
  72. package/lib/methods/getAllWorkspacePackageNames.d.ts +0 -6
  73. package/lib/methods/getAllWorkspacePackageNames.js +0 -67
  74. package/lib/methods/getAllWorkspacePaths.cjs +0 -50
  75. package/lib/methods/getAllWorkspacePaths.d.cts +0 -6
  76. package/lib/methods/getAllWorkspacePaths.d.ts +0 -6
  77. package/lib/methods/getAllWorkspacePaths.js +0 -42
  78. package/lib/methods/getImportsRecursively.cjs +0 -7577
  79. package/lib/methods/getImportsRecursively.d.cts +0 -37
  80. package/lib/methods/getImportsRecursively.d.ts +0 -37
  81. package/lib/methods/getImportsRecursively.js +0 -7566
  82. package/lib/methods/getRepoPackageJson.cjs +0 -40
  83. package/lib/methods/getRepoPackageJson.d.cts +0 -6
  84. package/lib/methods/getRepoPackageJson.d.ts +0 -6
  85. package/lib/methods/getRepoPackageJson.js +0 -32
  86. package/lib/methods/getRepoPackageJsonPath.cjs +0 -34
  87. package/lib/methods/getRepoPackageJsonPath.d.cts +0 -6
  88. package/lib/methods/getRepoPackageJsonPath.d.ts +0 -6
  89. package/lib/methods/getRepoPackageJsonPath.js +0 -26
  90. package/lib/repo/Workspace.cjs +0 -7370
  91. package/lib/repo/Workspace.d.cts +0 -10
  92. package/lib/repo/Workspace.d.ts +0 -10
  93. package/lib/repo/Workspace.js +0 -7361
  94. package/lib/util/SemanticExtnamePrefix.cjs +0 -13
  95. package/lib/util/SemanticExtnamePrefix.d.cts +0 -14
  96. package/lib/util/SemanticExtnamePrefix.d.ts +0 -14
  97. package/lib/util/SemanticExtnamePrefix.js +0 -11
  98. package/lib/util/SemanticExtnamePrefixDescriptions.cjs +0 -13
  99. package/lib/util/SemanticExtnamePrefixDescriptions.d.cts +0 -15
  100. package/lib/util/SemanticExtnamePrefixDescriptions.d.ts +0 -15
  101. package/lib/util/SemanticExtnamePrefixDescriptions.js +0 -11
  102. package/lib/util/SemanticExtnamePrefixes.cjs +0 -18
  103. package/lib/util/SemanticExtnamePrefixes.d.cts +0 -97
  104. package/lib/util/SemanticExtnamePrefixes.d.ts +0 -97
  105. package/lib/util/SemanticExtnamePrefixes.js +0 -14
  106. package/lib/util/getRepoRootDirpath.cjs +0 -30
  107. package/lib/util/getRepoRootDirpath.d.cts +0 -6
  108. package/lib/util/getRepoRootDirpath.d.ts +0 -6
  109. package/lib/util/getRepoRootDirpath.js +0 -22
  110. package/lib/util/getWorkspaceDirpaths.cjs +0 -42
  111. package/lib/util/getWorkspaceDirpaths.d.cts +0 -6
  112. package/lib/util/getWorkspaceDirpaths.d.ts +0 -6
  113. package/lib/util/getWorkspaceDirpaths.js +0 -34
  114. package/lib/util/hasExtnamePrefix.cjs +0 -27
  115. package/lib/util/hasExtnamePrefix.d.cts +0 -38
  116. package/lib/util/hasExtnamePrefix.d.ts +0 -38
  117. package/lib/util/hasExtnamePrefix.js +0 -25
  118. package/lib/util/resolveModuleImportPath.cjs +0 -51
  119. package/lib/util/resolveModuleImportPath.d.cts +0 -8
  120. package/lib/util/resolveModuleImportPath.d.ts +0 -8
  121. package/lib/util/resolveModuleImportPath.js +0 -42
  122. package/lib/util/semverVersionBump.cjs +0 -30
  123. package/lib/util/semverVersionBump.d.cts +0 -22
  124. package/lib/util/semverVersionBump.d.ts +0 -22
  125. package/lib/util/semverVersionBump.js +0 -28
@@ -1,638 +0,0 @@
1
- 'use strict';
2
-
3
- var object = require('es-toolkit/object');
4
- var colors2 = require('ansi-colors');
5
- var util = require('util');
6
- var compat = require('es-toolkit/compat');
7
- var esToolkit = require('es-toolkit');
8
- var mnemonist = require('mnemonist');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var colors2__default = /*#__PURE__*/_interopDefault(colors2);
13
-
14
- var __defProp = Object.defineProperty;
15
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
16
-
17
- // ../object/src/defineGetter.ts
18
- function defineGetter(obj, key, get, des = {}) {
19
- return Object.defineProperty(obj, key, {
20
- configurable: true,
21
- enumerable: false,
22
- get,
23
- ...des
24
- });
25
- }
26
- __name(defineGetter, "defineGetter");
27
-
28
- // ../object/src/defineValue.ts
29
- function defineValue(obj, key, value, des = {}) {
30
- return Object.defineProperty(obj, key, {
31
- configurable: true,
32
- value,
33
- enumerable: true,
34
- ...des
35
- });
36
- }
37
- __name(defineValue, "defineValue");
38
-
39
- // ../object/src/defineLazyProperty.ts
40
- function defineLazyProperty(obj, key, get, des = {}) {
41
- function getter() {
42
- const value = get.call(this);
43
- defineValue(this, key, value);
44
- return value;
45
- }
46
- __name(getter, "getter");
47
- return defineGetter(obj, key, getter, des);
48
- }
49
- __name(defineLazyProperty, "defineLazyProperty");
50
-
51
- // ../object/src/defineMethod.ts
52
- function defineMethod(obj, key, value, des = {}) {
53
- return Object.defineProperty(obj, key, {
54
- value,
55
- configurable: true,
56
- writable: true,
57
- enumerable: false,
58
- ...des
59
- });
60
- }
61
- __name(defineMethod, "defineMethod");
62
-
63
- // ../object/src/getClassChain.ts
64
- function getClassChain(target, options) {
65
- const ctor = typeof target === "function" ? target : target.constructor;
66
- const result = [];
67
- if (options?.includeSelf) {
68
- result.push(ctor);
69
- }
70
- let current = ctor;
71
- while (current = Reflect.getPrototypeOf(current)) {
72
- if (current === Function.prototype || current === Object.prototype) {
73
- result.push(Object);
74
- break;
75
- }
76
- result.push(current);
77
- }
78
- return result;
79
- }
80
- __name(getClassChain, "getClassChain");
81
-
82
- // ../object/src/hasOwnProperty.ts
83
- function hasOwnProperty(object, key) {
84
- return Object.prototype.hasOwnProperty.call(object, key);
85
- }
86
- __name(hasOwnProperty, "hasOwnProperty");
87
-
88
- // ../object/src/hasPrototypeChainProperty.ts
89
- function hasPrototypeChainProperty(object, key) {
90
- return getClassChain(object).some((ctor) => {
91
- return hasOwnProperty(ctor.prototype, key);
92
- });
93
- }
94
- __name(hasPrototypeChainProperty, "hasPrototypeChainProperty");
95
-
96
- // ../object/src/hasProperty.ts
97
- function hasProperty(object, key) {
98
- return hasOwnProperty(object, key) || hasPrototypeChainProperty(object, key);
99
- }
100
- __name(hasProperty, "hasProperty");
101
-
102
- // ../composition/src/View.ts
103
- var TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
104
- var View = class {
105
- static {
106
- __name(this, "View");
107
- }
108
- [TARGET_SYMBOL];
109
- constructor(target) {
110
- this[TARGET_SYMBOL] = target;
111
- }
112
- get [Symbol.toStringTag]() {
113
- return this.constructor.name;
114
- }
115
- get target() {
116
- return this[TARGET_SYMBOL];
117
- }
118
- };
119
-
120
- // ../composition/src/inspector/defaults/ignoreValuesFilterDefaults.ts
121
- var ignoreValuesFilterDefaults = {
122
- noFalse: /* @__PURE__ */ __name((value) => {
123
- return value !== false;
124
- }, "noFalse"),
125
- noNull: /* @__PURE__ */ __name((value) => {
126
- return value !== null;
127
- }, "noNull"),
128
- noUndefined: /* @__PURE__ */ __name((value) => {
129
- return value !== void 0;
130
- }, "noUndefined"),
131
- noEmptyArray: /* @__PURE__ */ __name((value) => {
132
- return !Array.isArray(value) || !!value.length;
133
- }, "noEmptyArray"),
134
- noEmptyObject: /* @__PURE__ */ __name((value) => {
135
- return !value || typeof value !== "object" || Array.isArray(value) || !!Object.keys(value).length;
136
- }, "noEmptyObject")
137
- };
138
-
139
- // ../composition/src/inspector/defaults/ignoreValuesDefaults.ts
140
- var ignoreValuesDefaults = {
141
- noEmptyArray: true,
142
- noEmptyObject: true,
143
- noNull: true,
144
- noUndefined: true,
145
- noFalse: false
146
- };
147
- var inspectDefaults = {
148
- ...util.inspect.defaultOptions,
149
- customInspect: true,
150
- maxStringLength: 500,
151
- maxArrayLength: 200,
152
- breakLength: 100,
153
- colors: true,
154
- depth: 100,
155
- compact: false,
156
- numericSeparator: true
157
- };
158
-
159
- // ../composition/src/inspector/defaults/inspectorDefaults.ts
160
- var inspectorDefaults = {
161
- inspect: inspectDefaults,
162
- ignoreValues: ignoreValuesDefaults,
163
- keys: [],
164
- autoAddBooleanKeys: false,
165
- ignoreKeys: [],
166
- filters: []
167
- };
168
- var Inspector = class _Inspector extends View {
169
- static {
170
- __name(this, "Inspector");
171
- }
172
- /**
173
- * Composes a class with Inspector capabilities by adding inspection methods to its prototype.
174
- * This follows the Composition pattern to extend classes without inheritance.
175
- */
176
- static compose(cls, options = {}) {
177
- if (!hasProperty(cls.prototype, util.inspect.custom)) {
178
- defineMethod(cls.prototype, util.inspect.custom, function(depth, options2) {
179
- return this.inspector.inspect(depth, options2);
180
- });
181
- }
182
- if (!hasProperty(cls.prototype, "inspector")) {
183
- defineLazyProperty(cls.prototype, "inspector", /* @__PURE__ */ __name(function get() {
184
- return new _Inspector(this);
185
- }, "get"));
186
- }
187
- if (!hasProperty(cls.prototype, "toJSON")) {
188
- defineMethod(cls.prototype, "toJSON", function() {
189
- return this.inspector.toObject();
190
- });
191
- }
192
- return options;
193
- }
194
- /**
195
- * Compile the target object and return the output as an object.
196
- */
197
- toObject(depth = 0) {
198
- const result = esToolkit.mapValues(this.compile(depth).output, (value) => {
199
- if (!value) {
200
- return value;
201
- }
202
- if (typeof value !== "object") {
203
- return value;
204
- }
205
- if (Array.isArray(value)) {
206
- return value.map((v) => {
207
- if (v.inspector && v.inspector instanceof _Inspector) {
208
- return v.inspector.toObject(depth + 1);
209
- }
210
- return v;
211
- });
212
- }
213
- if (value.inspector && value.inspector instanceof _Inspector) {
214
- return value.inspector.toObject(depth + 1);
215
- }
216
- return value;
217
- });
218
- return {
219
- T: this.target.constructor.name,
220
- ...result
221
- };
222
- }
223
- /**
224
- * Inspect the target object.
225
- */
226
- inspect(depth = 0, options = {}) {
227
- const { output, inspectOptions } = this.compile(depth);
228
- Object.assign(inspectOptions, options);
229
- const result = util.inspect(output, options);
230
- return result.replaceAll(/Object \[\w+] {/gm, (match) => {
231
- match = match.substring(8, match.length - 3);
232
- return `[${inspectOptions.colors ? colors2__default.default.magenta(match) : match}] {`;
233
- });
234
- }
235
- /**
236
- * Compiles the output object and inspect options.
237
- * Merges prototype chain options and applies filters to determine which properties to include.
238
- */
239
- compile(depth = 0) {
240
- const output = Object.defineProperty({}, Symbol.toStringTag, {
241
- value: this.target.constructor.name,
242
- configurable: true
243
- });
244
- const options = this.mergePrototypeOptions();
245
- const keys = new Set(options.keys);
246
- if (options.autoAddBooleanKeys) {
247
- const insBooleanValueKeys = Object.entries(this.target).filter(([_key, value]) => {
248
- return typeof value === "boolean";
249
- }).map(([key]) => {
250
- return key;
251
- });
252
- const protoGetterKeys = getClassChain(this.target, {
253
- includeSelf: false
254
- }).map((cls) => {
255
- return Object.getOwnPropertyNames(cls.prototype).filter((key) => {
256
- return hasOwnProperty(Reflect.getOwnPropertyDescriptor(cls.prototype, key), "get");
257
- });
258
- }).flat(2);
259
- const booleanKeys = insBooleanValueKeys.concat(protoGetterKeys).filter((key) => {
260
- return /^(is|was|has|should)[A-Z]/.test(key);
261
- });
262
- booleanKeys.forEach((key) => {
263
- return keys.add(key);
264
- });
265
- }
266
- const ignoreFilters = Object.entries(options.ignoreValues).filter(([_name, enabled]) => {
267
- return enabled;
268
- }).map(([name]) => {
269
- return ignoreValuesFilterDefaults[name];
270
- });
271
- const objectValues = [];
272
- const arrayValues = [];
273
- for (const key of keys) {
274
- const value = this.target[key];
275
- if (!ignoreFilters.every((filter) => {
276
- return filter(value);
277
- })) {
278
- continue;
279
- }
280
- if (!options.filters.every((filter) => {
281
- return filter.call(this.target, value, key, depth, output);
282
- })) {
283
- continue;
284
- }
285
- if (Array.isArray(value)) {
286
- arrayValues.push(() => {
287
- return defineValue(output, key, value);
288
- });
289
- } else if (compat.isObjectLike(value)) {
290
- objectValues.push(() => {
291
- return defineValue(output, key, value);
292
- });
293
- } else {
294
- defineValue(output, key, value);
295
- }
296
- }
297
- objectValues.forEach((fn) => {
298
- return fn();
299
- });
300
- arrayValues.forEach((fn) => {
301
- return fn();
302
- });
303
- return {
304
- output,
305
- inspectOptions: options.inspect
306
- };
307
- }
308
- /**
309
- * Walks the prototype chain and merges Inspector options from all classes.
310
- * Subclass options override superclass options following inheritance semantics.
311
- */
312
- mergePrototypeOptions() {
313
- const defaults = this.getDefaults();
314
- let inspectOptions = defaults.inspect;
315
- const keys = new Set(defaults.keys);
316
- let autoAddBooleanKeys = defaults.autoAddBooleanKeys;
317
- const ignoreKeys = new Set(defaults.ignoreKeys);
318
- const ignoreValues = defaults.ignoreValues;
319
- const customFilters = defaults.filters;
320
- const prototypeChainOptions = getClassChain(this.target.constructor, {
321
- includeSelf: true
322
- }).reverse().map((cls) => {
323
- return cls.inspector ?? {};
324
- });
325
- for (const options of prototypeChainOptions) {
326
- if (options.inspect) {
327
- inspectOptions = {
328
- ...inspectOptions,
329
- ...options.inspect
330
- };
331
- }
332
- options.keys?.forEach((elem) => {
333
- return keys.add(elem);
334
- });
335
- if (options.autoAddBooleanKeys != null) {
336
- autoAddBooleanKeys = options.autoAddBooleanKeys;
337
- }
338
- keys.forEach((elem) => {
339
- return ignoreKeys.delete(elem);
340
- });
341
- options.ignoreKeys?.forEach((elem) => {
342
- return ignoreKeys.add(elem);
343
- });
344
- ignoreKeys.forEach((elem) => {
345
- return keys.delete(elem);
346
- });
347
- if (options.ignoreValues) {
348
- Object.assign(ignoreValues, options.ignoreValues);
349
- }
350
- options.filters?.forEach((filter) => {
351
- return customFilters.push(filter);
352
- });
353
- }
354
- return {
355
- inspect: inspectOptions,
356
- ignoreValues,
357
- autoAddBooleanKeys,
358
- keys: Array.from(keys),
359
- ignoreKeys: Array.from(ignoreKeys),
360
- filters: customFilters
361
- };
362
- }
363
- /**
364
- * Returns a deep clone of the default Inspector options.
365
- */
366
- getDefaults() {
367
- const filters = inspectorDefaults.filters.slice();
368
- const rest = object.cloneDeep(compat.omit(inspectorDefaults, "filters"));
369
- return {
370
- ...rest,
371
- filters
372
- };
373
- }
374
- };
375
- var ParentRelationTypes = class _ParentRelationTypes extends View {
376
- static {
377
- __name(this, "ParentRelationTypes");
378
- }
379
- registerParent(parentType) {
380
- _ParentRelationTypes.parentTypesStats.get(this.target).add(parentType);
381
- _ParentRelationTypes.childTypesStats.get(parentType).add(this.target);
382
- }
383
- get hasParent() {
384
- return _ParentRelationTypes.parentTypesStats.has(this.target);
385
- }
386
- get getParentTypes() {
387
- return _ParentRelationTypes.parentTypesStats.get(this.target);
388
- }
389
- get hasChildren() {
390
- return _ParentRelationTypes.childTypesStats.has(this.target);
391
- }
392
- get getChildTypes() {
393
- return _ParentRelationTypes.childTypesStats.get(this.target);
394
- }
395
- get isRoot() {
396
- return !this.hasParent && this.hasChildren;
397
- }
398
- get isLeaf() {
399
- return this.hasParent && !this.hasChildren;
400
- }
401
- get isIsolated() {
402
- return !this.hasParent && !this.hasChildren;
403
- }
404
- static getAllChildTypesStats() {
405
- const res = {};
406
- Array.from(this.childTypesStats.entries()).map(([cls, multimap]) => {
407
- multimap.forEachMultiplicity((count, key) => {
408
- if (!res[cls.name]) {
409
- res[cls.name] = {};
410
- }
411
- if (!res[cls.name][key.name]) {
412
- res[cls.name][key.name] = count;
413
- }
414
- });
415
- });
416
- return res;
417
- }
418
- static getAllParentTypesStats() {
419
- const res = {};
420
- Array.from(this.parentTypesStats.entries()).map(([cls, multimap]) => {
421
- multimap.forEachMultiplicity((count, key) => {
422
- if (!res[cls.name]) {
423
- res[cls.name] = {};
424
- }
425
- if (!res[cls.name][key.name]) {
426
- res[cls.name][key.name] = count;
427
- }
428
- });
429
- });
430
- return res;
431
- }
432
- static getAllStats() {
433
- const classes = /* @__PURE__ */ new Set([
434
- ...Array.from(this.childTypesStats.keys()),
435
- ...Array.from(this.parentTypesStats.keys())
436
- ]);
437
- return Array.from(classes).map((cls) => {
438
- const parents = Array.from(this.parentTypesStats.get(cls).multiplicities()).map(([cls2, count]) => {
439
- return [
440
- cls2.name,
441
- count
442
- ];
443
- });
444
- const children = Array.from(this.childTypesStats.get(cls).multiplicities()).map(([cls2, count]) => {
445
- return [
446
- cls2.name,
447
- count
448
- ];
449
- });
450
- const result = {
451
- class: cls.name
452
- };
453
- if (parents.length) {
454
- result.parents = Object.fromEntries(parents);
455
- }
456
- if (children.length) {
457
- result.children = Object.fromEntries(children);
458
- }
459
- return result;
460
- });
461
- }
462
- static printAllStats() {
463
- console.log();
464
- console.log(colors2__default.default.bold.yellow("Parent-Child Relation Stats"));
465
- for (const stats of this.getAllStats()) {
466
- console.log(stats.class);
467
- if (stats.parents) {
468
- let prefix = ` ${colors2__default.default.dim("parents : ")}`;
469
- for (const [parent, count] of Object.entries(stats.parents)) {
470
- console.log(`${prefix}${colors2__default.default.blue(parent)}: ${colors2__default.default.yellow(String(count))}`);
471
- prefix = " ".repeat(12);
472
- }
473
- }
474
- if (stats.children) {
475
- let prefix = ` ${colors2__default.default.dim("children : ")}`;
476
- for (const [child, count] of Object.entries(stats.children)) {
477
- console.log(`${prefix}${colors2__default.default.green(child)}: ${colors2__default.default.yellow(String(count))}`);
478
- prefix = " ".repeat(12);
479
- }
480
- }
481
- console.log();
482
- }
483
- }
484
- static childTypesStats = new mnemonist.DefaultMap(() => {
485
- return new mnemonist.MultiSet();
486
- });
487
- static parentTypesStats = new mnemonist.DefaultMap(() => {
488
- return new mnemonist.MultiSet();
489
- });
490
- };
491
- var Parenting = class _Parenting extends View {
492
- static {
493
- __name(this, "Parenting");
494
- }
495
- /**
496
- * Class decorator to register and correctly initialize a class as a 'parentingTarget'.
497
- */
498
- static compose(cls) {
499
- if (!hasProperty(cls, "parenting")) {
500
- defineLazyProperty(cls, "parenting", function() {
501
- return new ParentRelationTypes(this);
502
- });
503
- }
504
- if (!hasProperty(cls.prototype, "parenting")) {
505
- defineLazyProperty(cls.prototype, "parenting", function() {
506
- return new _Parenting(this);
507
- });
508
- }
509
- }
510
- /**
511
- * Store a weak refences to the target object's parent.
512
- */
513
- onInstance(parent) {
514
- if (!parent) {
515
- return;
516
- }
517
- const targetClass = this.parentingTargetConstructor;
518
- _Parenting.parentWeakRefMap.get(targetClass).set(this.target, parent);
519
- targetClass.parenting?.registerParent(parent.constructor);
520
- }
521
- /**
522
- * Retrieve the parent object of 'target' object.
523
- */
524
- getParent() {
525
- const map = _Parenting.parentWeakRefMap.get(this.parentingTargetConstructor);
526
- const parent = map.get(this.target);
527
- return parent;
528
- }
529
- /**
530
- * Recursively get parent until no parent is found or a circular reference is detected.
531
- */
532
- *iterateAncestors() {
533
- let node = this.target.parenting.getParent();
534
- if (!node) {
535
- return;
536
- }
537
- const seen = /* @__PURE__ */ new Set();
538
- while (node) {
539
- if (seen.has(node)) {
540
- return;
541
- }
542
- seen.add(node);
543
- yield node;
544
- node = node?.parenting?.getParent();
545
- }
546
- }
547
- /**
548
- * The depth of the object in the parent-child hierarchy.
549
- */
550
- get depth() {
551
- return [
552
- ...this.iterateAncestors()
553
- ].length;
554
- }
555
- /**
556
- * The class constructor of the target object.
557
- */
558
- get parentingTargetConstructor() {
559
- return this.target.constructor;
560
- }
561
- /**
562
- * A WeakMap for parent references.
563
- */
564
- static parentWeakRefMap = new mnemonist.DefaultMap(() => {
565
- return /* @__PURE__ */ new WeakMap();
566
- });
567
- };
568
-
569
- // src/common/AbstractBase.ts
570
- function _ts_decorate(decorators, target, key, desc) {
571
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
572
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
573
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
574
- return c > 3 && r && Object.defineProperty(target, key, r), r;
575
- }
576
- __name(_ts_decorate, "_ts_decorate");
577
- function _ts_metadata(k, v) {
578
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
579
- }
580
- __name(_ts_metadata, "_ts_metadata");
581
- exports.AbstractBase = class _AbstractBase {
582
- static {
583
- __name(this, "AbstractBase");
584
- }
585
- static inspector = Inspector.compose(_AbstractBase, {
586
- keys: [],
587
- autoAddBooleanKeys: true,
588
- ignoreKeys: [],
589
- ignoreValues: {
590
- noEmptyArray: true,
591
- noEmptyObject: true,
592
- noNull: true,
593
- noUndefined: true,
594
- noFalse: true
595
- },
596
- inspect: {
597
- customInspect: true,
598
- maxStringLength: 500,
599
- maxArrayLength: 5,
600
- breakLength: 80,
601
- colors: true,
602
- depth: null,
603
- compact: false,
604
- numericSeparator: true
605
- },
606
- filters: []
607
- });
608
- constructor(parent) {
609
- this.parenting.onInstance(parent);
610
- }
611
- findParentDeep(predicate) {
612
- for (const parent of this.parenting.iterateAncestors()) {
613
- if (predicate(parent)) {
614
- return parent;
615
- }
616
- }
617
- return void 0;
618
- }
619
- get parent() {
620
- return this.parenting.getParent();
621
- }
622
- getParentDeep(instanceOf) {
623
- const parent = this.findParentDeep((p) => {
624
- return p instanceof instanceOf;
625
- });
626
- if (!parent) {
627
- throw new Error(`Parent of type ${instanceOf.name} not found.`);
628
- }
629
- return parent;
630
- }
631
- };
632
- exports.AbstractBase = _ts_decorate([
633
- Parenting.compose,
634
- _ts_metadata("design:type", Function),
635
- _ts_metadata("design:paramtypes", [
636
- typeof P === "undefined" ? Object : P
637
- ])
638
- ], exports.AbstractBase);
@@ -1,3 +0,0 @@
1
- export { A as AbstractBase } from '../AbstractBase-J4h6nW8k.cjs';
2
- import 'util';
3
- import 'mnemonist';
@@ -1,3 +0,0 @@
1
- export { A as AbstractBase } from '../AbstractBase-J4h6nW8k.js';
2
- import 'util';
3
- import 'mnemonist';