@bemoje/composition 2.1.0 → 2.1.3
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/package.json +83 -149
- package/lib/IView.cjs +0 -2
- package/lib/IView.d.cts +0 -12
- package/lib/IView.d.ts +0 -12
- package/lib/IView.js +0 -1
- package/lib/OptionsConfigurator.cjs +0 -166
- package/lib/OptionsConfigurator.d.cts +0 -2229
- package/lib/OptionsConfigurator.d.ts +0 -2229
- package/lib/OptionsConfigurator.js +0 -163
- package/lib/View.cjs +0 -22
- package/lib/View.d.cts +0 -14
- package/lib/View.d.ts +0 -14
- package/lib/View.js +0 -20
- package/lib/inheritProxifiedPrototype.cjs +0 -19
- package/lib/inheritProxifiedPrototype.d.cts +0 -11
- package/lib/inheritProxifiedPrototype.d.ts +0 -11
- package/lib/inheritProxifiedPrototype.js +0 -16
- package/lib/inheritProxifiedPrototypeProperty.cjs +0 -45
- package/lib/inheritProxifiedPrototypeProperty.d.cts +0 -9
- package/lib/inheritProxifiedPrototypeProperty.d.ts +0 -9
- package/lib/inheritProxifiedPrototypeProperty.js +0 -43
- package/lib/inspector/Inspector.cjs +0 -227
- package/lib/inspector/Inspector.d.cts +0 -4
- package/lib/inspector/Inspector.d.ts +0 -4
- package/lib/inspector/Inspector.js +0 -220
- package/lib/inspector/defaults/ignoreValuesDefaults.cjs +0 -11
- package/lib/inspector/defaults/ignoreValuesDefaults.d.cts +0 -11
- package/lib/inspector/defaults/ignoreValuesDefaults.d.ts +0 -11
- package/lib/inspector/defaults/ignoreValuesDefaults.js +0 -11
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.cjs +0 -23
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.cts +0 -11
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.ts +0 -11
- package/lib/inspector/defaults/ignoreValuesFilterDefaults.js +0 -21
- package/lib/inspector/defaults/inspectDefaults.cjs +0 -17
- package/lib/inspector/defaults/inspectDefaults.d.cts +0 -8
- package/lib/inspector/defaults/inspectDefaults.d.ts +0 -8
- package/lib/inspector/defaults/inspectDefaults.js +0 -16
- package/lib/inspector/defaults/inspectorDefaults.cjs +0 -15
- package/lib/inspector/defaults/inspectorDefaults.d.cts +0 -11
- package/lib/inspector/defaults/inspectorDefaults.d.ts +0 -11
- package/lib/inspector/defaults/inspectorDefaults.js +0 -14
- package/lib/inspector/types.cjs +0 -2
- package/lib/inspector/types.d.cts +0 -4
- package/lib/inspector/types.d.ts +0 -4
- package/lib/inspector/types.js +0 -1
- package/lib/parenting/ParentRelationTypes.cjs +0 -130
- package/lib/parenting/ParentRelationTypes.d.cts +0 -4
- package/lib/parenting/ParentRelationTypes.d.ts +0 -4
- package/lib/parenting/ParentRelationTypes.js +0 -123
- package/lib/parenting/Parenting.cjs +0 -88
- package/lib/parenting/Parenting.d.cts +0 -4
- package/lib/parenting/Parenting.d.ts +0 -4
- package/lib/parenting/Parenting.js +0 -85
- package/lib/parenting/types.cjs +0 -2
- package/lib/parenting/types.d.cts +0 -4
- package/lib/parenting/types.d.ts +0 -4
- package/lib/parenting/types.js +0 -1
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
-
import { View } from '../View';
|
|
3
|
-
import { cloneDeep } from 'es-toolkit/object';
|
|
4
|
-
import colors from 'ansi-colors';
|
|
5
|
-
import { hasProperty, defineMethod, defineLazyProperty, getClassChain, hasOwnProperty, defineValue } from '@mono/object';
|
|
6
|
-
import { ignoreValuesFilterDefaults } from './defaults/ignoreValuesFilterDefaults';
|
|
7
|
-
import { inspect } from 'util';
|
|
8
|
-
import { inspectorDefaults } from './defaults/inspectorDefaults';
|
|
9
|
-
import { isObjectLike, omit } from 'es-toolkit/compat';
|
|
10
|
-
import { mapValues } from 'es-toolkit';
|
|
11
|
-
|
|
12
|
-
class Inspector extends View {
|
|
13
|
-
static {
|
|
14
|
-
__name(this, "Inspector");
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Composes a class with Inspector capabilities by adding inspection methods to its prototype.
|
|
18
|
-
* This follows the Composition pattern to extend classes without inheritance.
|
|
19
|
-
*/
|
|
20
|
-
static compose(cls, options = {}) {
|
|
21
|
-
if (!hasProperty(cls.prototype, inspect.custom)) {
|
|
22
|
-
defineMethod(cls.prototype, inspect.custom, function(depth, options2) {
|
|
23
|
-
return this.inspector.inspect(depth, options2);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (!hasProperty(cls.prototype, "inspector")) {
|
|
27
|
-
defineLazyProperty(cls.prototype, "inspector", /* @__PURE__ */ __name(function get() {
|
|
28
|
-
return new Inspector(this);
|
|
29
|
-
}, "get"));
|
|
30
|
-
}
|
|
31
|
-
if (!hasProperty(cls.prototype, "toJSON")) {
|
|
32
|
-
defineMethod(cls.prototype, "toJSON", function() {
|
|
33
|
-
return this.inspector.toObject();
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return options;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Compile the target object and return the output as an object.
|
|
40
|
-
*/
|
|
41
|
-
toObject(depth = 0) {
|
|
42
|
-
const result = mapValues(this.compile(depth).output, (value) => {
|
|
43
|
-
if (!value) {
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
if (typeof value !== "object") {
|
|
47
|
-
return value;
|
|
48
|
-
}
|
|
49
|
-
if (Array.isArray(value)) {
|
|
50
|
-
return value.map((v) => {
|
|
51
|
-
if (v.inspector && v.inspector instanceof Inspector) {
|
|
52
|
-
return v.inspector.toObject(depth + 1);
|
|
53
|
-
}
|
|
54
|
-
return v;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if (value.inspector && value.inspector instanceof Inspector) {
|
|
58
|
-
return value.inspector.toObject(depth + 1);
|
|
59
|
-
}
|
|
60
|
-
return value;
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
T: this.target.constructor.name,
|
|
64
|
-
...result
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Inspect the target object.
|
|
69
|
-
*/
|
|
70
|
-
inspect(depth = 0, options = {}) {
|
|
71
|
-
const { output, inspectOptions } = this.compile(depth);
|
|
72
|
-
Object.assign(inspectOptions, options);
|
|
73
|
-
const result = inspect(output, options);
|
|
74
|
-
return result.replaceAll(/Object \[\w+] {/gm, (match) => {
|
|
75
|
-
match = match.substring(8, match.length - 3);
|
|
76
|
-
return `[${inspectOptions.colors ? colors.magenta(match) : match}] {`;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Compiles the output object and inspect options.
|
|
81
|
-
* Merges prototype chain options and applies filters to determine which properties to include.
|
|
82
|
-
*/
|
|
83
|
-
compile(depth = 0) {
|
|
84
|
-
const output = Object.defineProperty({}, Symbol.toStringTag, {
|
|
85
|
-
value: this.target.constructor.name,
|
|
86
|
-
configurable: true
|
|
87
|
-
});
|
|
88
|
-
const options = this.mergePrototypeOptions();
|
|
89
|
-
const keys = new Set(options.keys);
|
|
90
|
-
if (options.autoAddBooleanKeys) {
|
|
91
|
-
const insBooleanValueKeys = Object.entries(this.target).filter(([_key, value]) => {
|
|
92
|
-
return typeof value === "boolean";
|
|
93
|
-
}).map(([key]) => {
|
|
94
|
-
return key;
|
|
95
|
-
});
|
|
96
|
-
const protoGetterKeys = getClassChain(this.target, {
|
|
97
|
-
includeSelf: false
|
|
98
|
-
}).map((cls) => {
|
|
99
|
-
return Object.getOwnPropertyNames(cls.prototype).filter((key) => {
|
|
100
|
-
return hasOwnProperty(Reflect.getOwnPropertyDescriptor(cls.prototype, key), "get");
|
|
101
|
-
});
|
|
102
|
-
}).flat(2);
|
|
103
|
-
const booleanKeys = insBooleanValueKeys.concat(protoGetterKeys).filter((key) => {
|
|
104
|
-
return /^(is|was|has|should)[A-Z]/.test(key);
|
|
105
|
-
});
|
|
106
|
-
booleanKeys.forEach((key) => {
|
|
107
|
-
return keys.add(key);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const ignoreFilters = Object.entries(options.ignoreValues).filter(([_name, enabled]) => {
|
|
111
|
-
return enabled;
|
|
112
|
-
}).map(([name]) => {
|
|
113
|
-
return ignoreValuesFilterDefaults[name];
|
|
114
|
-
});
|
|
115
|
-
const objectValues = [];
|
|
116
|
-
const arrayValues = [];
|
|
117
|
-
for (const key of keys) {
|
|
118
|
-
const value = this.target[key];
|
|
119
|
-
if (!ignoreFilters.every((filter) => {
|
|
120
|
-
return filter(value);
|
|
121
|
-
})) {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (!options.filters.every((filter) => {
|
|
125
|
-
return filter.call(this.target, value, key, depth, output);
|
|
126
|
-
})) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
if (Array.isArray(value)) {
|
|
130
|
-
arrayValues.push(() => {
|
|
131
|
-
return defineValue(output, key, value);
|
|
132
|
-
});
|
|
133
|
-
} else if (isObjectLike(value)) {
|
|
134
|
-
objectValues.push(() => {
|
|
135
|
-
return defineValue(output, key, value);
|
|
136
|
-
});
|
|
137
|
-
} else {
|
|
138
|
-
defineValue(output, key, value);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
objectValues.forEach((fn) => {
|
|
142
|
-
return fn();
|
|
143
|
-
});
|
|
144
|
-
arrayValues.forEach((fn) => {
|
|
145
|
-
return fn();
|
|
146
|
-
});
|
|
147
|
-
return {
|
|
148
|
-
output,
|
|
149
|
-
inspectOptions: options.inspect
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Walks the prototype chain and merges Inspector options from all classes.
|
|
154
|
-
* Subclass options override superclass options following inheritance semantics.
|
|
155
|
-
*/
|
|
156
|
-
mergePrototypeOptions() {
|
|
157
|
-
const defaults = this.getDefaults();
|
|
158
|
-
let inspectOptions = defaults.inspect;
|
|
159
|
-
const keys = new Set(defaults.keys);
|
|
160
|
-
let autoAddBooleanKeys = defaults.autoAddBooleanKeys;
|
|
161
|
-
const ignoreKeys = new Set(defaults.ignoreKeys);
|
|
162
|
-
const ignoreValues = defaults.ignoreValues;
|
|
163
|
-
const customFilters = defaults.filters;
|
|
164
|
-
const prototypeChainOptions = getClassChain(this.target.constructor, {
|
|
165
|
-
includeSelf: true
|
|
166
|
-
}).reverse().map((cls) => {
|
|
167
|
-
return cls.inspector ?? {};
|
|
168
|
-
});
|
|
169
|
-
for (const options of prototypeChainOptions) {
|
|
170
|
-
if (options.inspect) {
|
|
171
|
-
inspectOptions = {
|
|
172
|
-
...inspectOptions,
|
|
173
|
-
...options.inspect
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
options.keys?.forEach((elem) => {
|
|
177
|
-
return keys.add(elem);
|
|
178
|
-
});
|
|
179
|
-
if (options.autoAddBooleanKeys != null) {
|
|
180
|
-
autoAddBooleanKeys = options.autoAddBooleanKeys;
|
|
181
|
-
}
|
|
182
|
-
keys.forEach((elem) => {
|
|
183
|
-
return ignoreKeys.delete(elem);
|
|
184
|
-
});
|
|
185
|
-
options.ignoreKeys?.forEach((elem) => {
|
|
186
|
-
return ignoreKeys.add(elem);
|
|
187
|
-
});
|
|
188
|
-
ignoreKeys.forEach((elem) => {
|
|
189
|
-
return keys.delete(elem);
|
|
190
|
-
});
|
|
191
|
-
if (options.ignoreValues) {
|
|
192
|
-
Object.assign(ignoreValues, options.ignoreValues);
|
|
193
|
-
}
|
|
194
|
-
options.filters?.forEach((filter) => {
|
|
195
|
-
return customFilters.push(filter);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
inspect: inspectOptions,
|
|
200
|
-
ignoreValues,
|
|
201
|
-
autoAddBooleanKeys,
|
|
202
|
-
keys: Array.from(keys),
|
|
203
|
-
ignoreKeys: Array.from(ignoreKeys),
|
|
204
|
-
filters: customFilters
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Returns a deep clone of the default Inspector options.
|
|
209
|
-
*/
|
|
210
|
-
getDefaults() {
|
|
211
|
-
const filters = inspectorDefaults.filters.slice();
|
|
212
|
-
const rest = cloneDeep(omit(inspectorDefaults, "filters"));
|
|
213
|
-
return {
|
|
214
|
-
...rest,
|
|
215
|
-
filters
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export { Inspector };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { a as IgnoreValuesOptions } from '../../Inspector-CrOT_QD4.cjs';
|
|
2
|
-
import 'util';
|
|
3
|
-
import '../../View.cjs';
|
|
4
|
-
import '../../IView.cjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Default options for ignoring specific values during object inspection.
|
|
8
|
-
*/
|
|
9
|
-
declare const ignoreValuesDefaults: IgnoreValuesOptions;
|
|
10
|
-
|
|
11
|
-
export { ignoreValuesDefaults };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { a as IgnoreValuesOptions } from '../../Inspector-DAN0uRqw.js';
|
|
2
|
-
import 'util';
|
|
3
|
-
import '../../View.js';
|
|
4
|
-
import '../../IView.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Default options for ignoring specific values during object inspection.
|
|
8
|
-
*/
|
|
9
|
-
declare const ignoreValuesDefaults: IgnoreValuesOptions;
|
|
10
|
-
|
|
11
|
-
export { ignoreValuesDefaults };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
const ignoreValuesFilterDefaults = {
|
|
6
|
-
noFalse: /* @__PURE__ */ __name((value) => {
|
|
7
|
-
return value !== false;
|
|
8
|
-
}, "noFalse"),
|
|
9
|
-
noNull: /* @__PURE__ */ __name((value) => {
|
|
10
|
-
return value !== null;
|
|
11
|
-
}, "noNull"),
|
|
12
|
-
noUndefined: /* @__PURE__ */ __name((value) => {
|
|
13
|
-
return value !== void 0;
|
|
14
|
-
}, "noUndefined"),
|
|
15
|
-
noEmptyArray: /* @__PURE__ */ __name((value) => {
|
|
16
|
-
return !Array.isArray(value) || !!value.length;
|
|
17
|
-
}, "noEmptyArray"),
|
|
18
|
-
noEmptyObject: /* @__PURE__ */ __name((value) => {
|
|
19
|
-
return !value || typeof value !== "object" || Array.isArray(value) || !!Object.keys(value).length;
|
|
20
|
-
}, "noEmptyObject")
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.ignoreValuesFilterDefaults = ignoreValuesFilterDefaults;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { a as IgnoreValuesOptions } from '../../Inspector-CrOT_QD4.cjs';
|
|
2
|
-
import 'util';
|
|
3
|
-
import '../../View.cjs';
|
|
4
|
-
import '../../IView.cjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Default filter functions for ignoring values during object inspection.
|
|
8
|
-
*/
|
|
9
|
-
declare const ignoreValuesFilterDefaults: Record<keyof IgnoreValuesOptions, (value: unknown) => boolean>;
|
|
10
|
-
|
|
11
|
-
export { ignoreValuesFilterDefaults };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { a as IgnoreValuesOptions } from '../../Inspector-DAN0uRqw.js';
|
|
2
|
-
import 'util';
|
|
3
|
-
import '../../View.js';
|
|
4
|
-
import '../../IView.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Default filter functions for ignoring values during object inspection.
|
|
8
|
-
*/
|
|
9
|
-
declare const ignoreValuesFilterDefaults: Record<keyof IgnoreValuesOptions, (value: unknown) => boolean>;
|
|
10
|
-
|
|
11
|
-
export { ignoreValuesFilterDefaults };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { __name } from '../../chunk-SHUYVCID.js';
|
|
2
|
-
|
|
3
|
-
const ignoreValuesFilterDefaults = {
|
|
4
|
-
noFalse: /* @__PURE__ */ __name((value) => {
|
|
5
|
-
return value !== false;
|
|
6
|
-
}, "noFalse"),
|
|
7
|
-
noNull: /* @__PURE__ */ __name((value) => {
|
|
8
|
-
return value !== null;
|
|
9
|
-
}, "noNull"),
|
|
10
|
-
noUndefined: /* @__PURE__ */ __name((value) => {
|
|
11
|
-
return value !== void 0;
|
|
12
|
-
}, "noUndefined"),
|
|
13
|
-
noEmptyArray: /* @__PURE__ */ __name((value) => {
|
|
14
|
-
return !Array.isArray(value) || !!value.length;
|
|
15
|
-
}, "noEmptyArray"),
|
|
16
|
-
noEmptyObject: /* @__PURE__ */ __name((value) => {
|
|
17
|
-
return !value || typeof value !== "object" || Array.isArray(value) || !!Object.keys(value).length;
|
|
18
|
-
}, "noEmptyObject")
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { ignoreValuesFilterDefaults };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var util = require('util');
|
|
4
|
-
|
|
5
|
-
const inspectDefaults = {
|
|
6
|
-
...util.inspect.defaultOptions,
|
|
7
|
-
customInspect: true,
|
|
8
|
-
maxStringLength: 500,
|
|
9
|
-
maxArrayLength: 200,
|
|
10
|
-
breakLength: 100,
|
|
11
|
-
colors: true,
|
|
12
|
-
depth: 100,
|
|
13
|
-
compact: false,
|
|
14
|
-
numericSeparator: true
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.inspectDefaults = inspectDefaults;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import '../../chunk-SHUYVCID.js';
|
|
2
|
-
import { inspect } from 'util';
|
|
3
|
-
|
|
4
|
-
const inspectDefaults = {
|
|
5
|
-
...inspect.defaultOptions,
|
|
6
|
-
customInspect: true,
|
|
7
|
-
maxStringLength: 500,
|
|
8
|
-
maxArrayLength: 200,
|
|
9
|
-
breakLength: 100,
|
|
10
|
-
colors: true,
|
|
11
|
-
depth: 100,
|
|
12
|
-
compact: false,
|
|
13
|
-
numericSeparator: true
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { inspectDefaults };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var ignoreValuesDefaults = require('./ignoreValuesDefaults');
|
|
4
|
-
var inspectDefaults = require('./inspectDefaults');
|
|
5
|
-
|
|
6
|
-
const inspectorDefaults = {
|
|
7
|
-
inspect: inspectDefaults.inspectDefaults,
|
|
8
|
-
ignoreValues: ignoreValuesDefaults.ignoreValuesDefaults,
|
|
9
|
-
keys: [],
|
|
10
|
-
autoAddBooleanKeys: false,
|
|
11
|
-
ignoreKeys: [],
|
|
12
|
-
filters: []
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
exports.inspectorDefaults = inspectorDefaults;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { d as InspectorOptions } from '../../Inspector-CrOT_QD4.cjs';
|
|
2
|
-
import 'util';
|
|
3
|
-
import '../../View.cjs';
|
|
4
|
-
import '../../IView.cjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The default inspector configuration options.
|
|
8
|
-
*/
|
|
9
|
-
declare const inspectorDefaults: Required<InspectorOptions>;
|
|
10
|
-
|
|
11
|
-
export { inspectorDefaults };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { d as InspectorOptions } from '../../Inspector-DAN0uRqw.js';
|
|
2
|
-
import 'util';
|
|
3
|
-
import '../../View.js';
|
|
4
|
-
import '../../IView.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The default inspector configuration options.
|
|
8
|
-
*/
|
|
9
|
-
declare const inspectorDefaults: Required<InspectorOptions>;
|
|
10
|
-
|
|
11
|
-
export { inspectorDefaults };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import '../../chunk-SHUYVCID.js';
|
|
2
|
-
import { ignoreValuesDefaults } from './ignoreValuesDefaults';
|
|
3
|
-
import { inspectDefaults } from './inspectDefaults';
|
|
4
|
-
|
|
5
|
-
const inspectorDefaults = {
|
|
6
|
-
inspect: inspectDefaults,
|
|
7
|
-
ignoreValues: ignoreValuesDefaults,
|
|
8
|
-
keys: [],
|
|
9
|
-
autoAddBooleanKeys: false,
|
|
10
|
-
ignoreKeys: [],
|
|
11
|
-
filters: []
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { inspectorDefaults };
|
package/lib/inspector/types.cjs
DELETED
package/lib/inspector/types.d.ts
DELETED
package/lib/inspector/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var mnemonist = require('mnemonist');
|
|
4
|
-
var View = require('../View');
|
|
5
|
-
var colors = require('ansi-colors');
|
|
6
|
-
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
|
|
9
|
-
var colors__default = /*#__PURE__*/_interopDefault(colors);
|
|
10
|
-
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
-
class ParentRelationTypes extends View.View {
|
|
14
|
-
static {
|
|
15
|
-
__name(this, "ParentRelationTypes");
|
|
16
|
-
}
|
|
17
|
-
registerParent(parentType) {
|
|
18
|
-
ParentRelationTypes.parentTypesStats.get(this.target).add(parentType);
|
|
19
|
-
ParentRelationTypes.childTypesStats.get(parentType).add(this.target);
|
|
20
|
-
}
|
|
21
|
-
get hasParent() {
|
|
22
|
-
return ParentRelationTypes.parentTypesStats.has(this.target);
|
|
23
|
-
}
|
|
24
|
-
get getParentTypes() {
|
|
25
|
-
return ParentRelationTypes.parentTypesStats.get(this.target);
|
|
26
|
-
}
|
|
27
|
-
get hasChildren() {
|
|
28
|
-
return ParentRelationTypes.childTypesStats.has(this.target);
|
|
29
|
-
}
|
|
30
|
-
get getChildTypes() {
|
|
31
|
-
return ParentRelationTypes.childTypesStats.get(this.target);
|
|
32
|
-
}
|
|
33
|
-
get isRoot() {
|
|
34
|
-
return !this.hasParent && this.hasChildren;
|
|
35
|
-
}
|
|
36
|
-
get isLeaf() {
|
|
37
|
-
return this.hasParent && !this.hasChildren;
|
|
38
|
-
}
|
|
39
|
-
get isIsolated() {
|
|
40
|
-
return !this.hasParent && !this.hasChildren;
|
|
41
|
-
}
|
|
42
|
-
static getAllChildTypesStats() {
|
|
43
|
-
const res = {};
|
|
44
|
-
Array.from(this.childTypesStats.entries()).map(([cls, multimap]) => {
|
|
45
|
-
multimap.forEachMultiplicity((count, key) => {
|
|
46
|
-
if (!res[cls.name]) {
|
|
47
|
-
res[cls.name] = {};
|
|
48
|
-
}
|
|
49
|
-
if (!res[cls.name][key.name]) {
|
|
50
|
-
res[cls.name][key.name] = count;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
return res;
|
|
55
|
-
}
|
|
56
|
-
static getAllParentTypesStats() {
|
|
57
|
-
const res = {};
|
|
58
|
-
Array.from(this.parentTypesStats.entries()).map(([cls, multimap]) => {
|
|
59
|
-
multimap.forEachMultiplicity((count, key) => {
|
|
60
|
-
if (!res[cls.name]) {
|
|
61
|
-
res[cls.name] = {};
|
|
62
|
-
}
|
|
63
|
-
if (!res[cls.name][key.name]) {
|
|
64
|
-
res[cls.name][key.name] = count;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
return res;
|
|
69
|
-
}
|
|
70
|
-
static getAllStats() {
|
|
71
|
-
const classes = /* @__PURE__ */ new Set([
|
|
72
|
-
...Array.from(this.childTypesStats.keys()),
|
|
73
|
-
...Array.from(this.parentTypesStats.keys())
|
|
74
|
-
]);
|
|
75
|
-
return Array.from(classes).map((cls) => {
|
|
76
|
-
const parents = Array.from(this.parentTypesStats.get(cls).multiplicities()).map(([cls2, count]) => {
|
|
77
|
-
return [
|
|
78
|
-
cls2.name,
|
|
79
|
-
count
|
|
80
|
-
];
|
|
81
|
-
});
|
|
82
|
-
const children = Array.from(this.childTypesStats.get(cls).multiplicities()).map(([cls2, count]) => {
|
|
83
|
-
return [
|
|
84
|
-
cls2.name,
|
|
85
|
-
count
|
|
86
|
-
];
|
|
87
|
-
});
|
|
88
|
-
const result = {
|
|
89
|
-
class: cls.name
|
|
90
|
-
};
|
|
91
|
-
if (parents.length) {
|
|
92
|
-
result.parents = Object.fromEntries(parents);
|
|
93
|
-
}
|
|
94
|
-
if (children.length) {
|
|
95
|
-
result.children = Object.fromEntries(children);
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
static printAllStats() {
|
|
101
|
-
console.log();
|
|
102
|
-
console.log(colors__default.default.bold.yellow("Parent-Child Relation Stats"));
|
|
103
|
-
for (const stats of this.getAllStats()) {
|
|
104
|
-
console.log(stats.class);
|
|
105
|
-
if (stats.parents) {
|
|
106
|
-
let prefix = ` ${colors__default.default.dim("parents : ")}`;
|
|
107
|
-
for (const [parent, count] of Object.entries(stats.parents)) {
|
|
108
|
-
console.log(`${prefix}${colors__default.default.blue(parent)}: ${colors__default.default.yellow(String(count))}`);
|
|
109
|
-
prefix = " ".repeat(12);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (stats.children) {
|
|
113
|
-
let prefix = ` ${colors__default.default.dim("children : ")}`;
|
|
114
|
-
for (const [child, count] of Object.entries(stats.children)) {
|
|
115
|
-
console.log(`${prefix}${colors__default.default.green(child)}: ${colors__default.default.yellow(String(count))}`);
|
|
116
|
-
prefix = " ".repeat(12);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
console.log();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
static childTypesStats = new mnemonist.DefaultMap(() => {
|
|
123
|
-
return new mnemonist.MultiSet();
|
|
124
|
-
});
|
|
125
|
-
static parentTypesStats = new mnemonist.DefaultMap(() => {
|
|
126
|
-
return new mnemonist.MultiSet();
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
exports.ParentRelationTypes = ParentRelationTypes;
|