@bemoje/composition 2.1.2 → 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.
Files changed (57) hide show
  1. package/package.json +83 -149
  2. package/lib/IView.cjs +0 -2
  3. package/lib/IView.d.cts +0 -12
  4. package/lib/IView.d.ts +0 -12
  5. package/lib/IView.js +0 -1
  6. package/lib/OptionsConfigurator.cjs +0 -166
  7. package/lib/OptionsConfigurator.d.cts +0 -2229
  8. package/lib/OptionsConfigurator.d.ts +0 -2229
  9. package/lib/OptionsConfigurator.js +0 -163
  10. package/lib/View.cjs +0 -22
  11. package/lib/View.d.cts +0 -14
  12. package/lib/View.d.ts +0 -14
  13. package/lib/View.js +0 -20
  14. package/lib/inheritProxifiedPrototype.cjs +0 -19
  15. package/lib/inheritProxifiedPrototype.d.cts +0 -11
  16. package/lib/inheritProxifiedPrototype.d.ts +0 -11
  17. package/lib/inheritProxifiedPrototype.js +0 -16
  18. package/lib/inheritProxifiedPrototypeProperty.cjs +0 -45
  19. package/lib/inheritProxifiedPrototypeProperty.d.cts +0 -9
  20. package/lib/inheritProxifiedPrototypeProperty.d.ts +0 -9
  21. package/lib/inheritProxifiedPrototypeProperty.js +0 -43
  22. package/lib/inspector/Inspector.cjs +0 -227
  23. package/lib/inspector/Inspector.d.cts +0 -4
  24. package/lib/inspector/Inspector.d.ts +0 -4
  25. package/lib/inspector/Inspector.js +0 -220
  26. package/lib/inspector/defaults/ignoreValuesDefaults.cjs +0 -11
  27. package/lib/inspector/defaults/ignoreValuesDefaults.d.cts +0 -11
  28. package/lib/inspector/defaults/ignoreValuesDefaults.d.ts +0 -11
  29. package/lib/inspector/defaults/ignoreValuesDefaults.js +0 -11
  30. package/lib/inspector/defaults/ignoreValuesFilterDefaults.cjs +0 -23
  31. package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.cts +0 -11
  32. package/lib/inspector/defaults/ignoreValuesFilterDefaults.d.ts +0 -11
  33. package/lib/inspector/defaults/ignoreValuesFilterDefaults.js +0 -21
  34. package/lib/inspector/defaults/inspectDefaults.cjs +0 -17
  35. package/lib/inspector/defaults/inspectDefaults.d.cts +0 -8
  36. package/lib/inspector/defaults/inspectDefaults.d.ts +0 -8
  37. package/lib/inspector/defaults/inspectDefaults.js +0 -16
  38. package/lib/inspector/defaults/inspectorDefaults.cjs +0 -15
  39. package/lib/inspector/defaults/inspectorDefaults.d.cts +0 -11
  40. package/lib/inspector/defaults/inspectorDefaults.d.ts +0 -11
  41. package/lib/inspector/defaults/inspectorDefaults.js +0 -14
  42. package/lib/inspector/types.cjs +0 -2
  43. package/lib/inspector/types.d.cts +0 -4
  44. package/lib/inspector/types.d.ts +0 -4
  45. package/lib/inspector/types.js +0 -1
  46. package/lib/parenting/ParentRelationTypes.cjs +0 -130
  47. package/lib/parenting/ParentRelationTypes.d.cts +0 -4
  48. package/lib/parenting/ParentRelationTypes.d.ts +0 -4
  49. package/lib/parenting/ParentRelationTypes.js +0 -123
  50. package/lib/parenting/Parenting.cjs +0 -88
  51. package/lib/parenting/Parenting.d.cts +0 -4
  52. package/lib/parenting/Parenting.d.ts +0 -4
  53. package/lib/parenting/Parenting.js +0 -85
  54. package/lib/parenting/types.cjs +0 -2
  55. package/lib/parenting/types.d.cts +0 -4
  56. package/lib/parenting/types.d.ts +0 -4
  57. package/lib/parenting/types.js +0 -1
@@ -1,163 +0,0 @@
1
- import { __name } from './chunk-SHUYVCID.js';
2
- import { KindGuard, Type } from '@sinclair/typebox';
3
- import { Value } from '@sinclair/typebox/value';
4
- import { assertValidSchema } from '@mono/tschema';
5
- import { entriesOf, keysOf } from '@mono/object';
6
-
7
- function OptionsConfigurator(schemaOrProps, defaultKeys) {
8
- const props = KindGuard.IsObject(schemaOrProps) ? schemaOrProps.properties : schemaOrProps;
9
- const schema = KindGuard.IsObject(schemaOrProps) ? schemaOrProps : Type.Object(props);
10
- const defaults = entriesOf(props).reduce((acc, [key, prop]) => {
11
- if ("default" in prop) {
12
- Reflect.set(acc, key, typeof prop.default === "function" ? prop.default : () => {
13
- return prop.default;
14
- });
15
- }
16
- return acc;
17
- }, {});
18
- const requiredKeys = schema.required;
19
- const optionalKeys = keysOf(props).filter((k) => {
20
- return !requiredKeys.includes(k);
21
- });
22
- const create = createConfigurator({
23
- defaults,
24
- requiredKeys,
25
- optionalKeys
26
- });
27
- const build = /* @__PURE__ */ __name((callback) => {
28
- const builder = create();
29
- const options = callback(builder);
30
- return options;
31
- }, "build");
32
- build.getSchemaProps = () => {
33
- return props;
34
- };
35
- build.getSchema = () => {
36
- return schema;
37
- };
38
- build.getDefaults = () => {
39
- return defaults;
40
- };
41
- build.getDefaultKeys = () => {
42
- return defaultKeys;
43
- };
44
- build.cast = (v) => {
45
- return v;
46
- };
47
- build.getCreate = () => {
48
- return create;
49
- };
50
- build.getBuild = () => {
51
- return build;
52
- };
53
- build.createFunction = (func) => {
54
- function fn(arg0) {
55
- const options = typeof arg0 === "function" ? build(arg0) : Value.Default(schema, arg0);
56
- assertValidSchema(schema, options, "Invalid options");
57
- return func(options);
58
- }
59
- __name(fn, "fn");
60
- if (func.name) {
61
- Object.defineProperty(fn, "name", {
62
- value: func.name,
63
- configurable: true
64
- });
65
- }
66
- Object.defineProperty(fn, "OptionsConfigurator", {
67
- get() {
68
- return build;
69
- },
70
- enumerable: true
71
- });
72
- return fn;
73
- };
74
- build.createBaseClass = () => {
75
- return class Base {
76
- static {
77
- __name(this, "Base");
78
- }
79
- static get OptionsConfigurator() {
80
- return build;
81
- }
82
- options;
83
- constructor(arg0) {
84
- this.options = typeof arg0 === "function" ? build(arg0) : Value.Default(schema, arg0);
85
- this.initialize();
86
- }
87
- /**
88
- * Called by the constructor
89
- */
90
- initialize() {
91
- this.assertValidOptions();
92
- }
93
- isValidOptions() {
94
- return Value.Check(schema, this.options);
95
- }
96
- assertValidOptions() {
97
- assertValidSchema(schema, this.options, "Invalid options");
98
- }
99
- };
100
- };
101
- return build;
102
- }
103
- __name(OptionsConfigurator, "OptionsConfigurator");
104
- function createConfigurator(options) {
105
- let CFG = class CFG {
106
- static {
107
- __name(this, "CFG");
108
- }
109
- $data;
110
- constructor($data) {
111
- this.$data = $data;
112
- }
113
- /**
114
- * Applies defaults for missing values and then returns data.
115
- */
116
- done() {
117
- this.applyDefaults();
118
- return this.$data;
119
- }
120
- /**
121
- * Set default values for missing keys.
122
- */
123
- applyDefaults() {
124
- entriesOf(options.defaults).forEach(([key, dfValue]) => {
125
- if (this.$data[key] === void 0) {
126
- const df = dfValue?.();
127
- if (df !== void 0) {
128
- this.$data[key] = df;
129
- }
130
- }
131
- });
132
- return this;
133
- }
134
- };
135
- const keys = /* @__PURE__ */ new Set([
136
- ...options.requiredKeys,
137
- ...keysOf(options.defaults),
138
- ...options.optionalKeys
139
- ]);
140
- for (const key of keys) {
141
- Object.defineProperty(CFG.prototype, key, {
142
- value: /* @__PURE__ */ __name(function(value) {
143
- if (value === void 0) {
144
- if (key in options.defaults) {
145
- this.$data[key] = options.defaults[key]();
146
- } else {
147
- delete this.$data[key];
148
- }
149
- } else {
150
- this.$data[key] = value;
151
- }
152
- return new CFG(this.$data);
153
- }, "value")
154
- });
155
- }
156
- return /* @__PURE__ */ __name(function configurator() {
157
- const ins = new CFG({});
158
- return ins;
159
- }, "configurator");
160
- }
161
- __name(createConfigurator, "createConfigurator");
162
-
163
- export { OptionsConfigurator };
package/lib/View.cjs DELETED
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
6
- class View {
7
- static {
8
- __name(this, "View");
9
- }
10
- [TARGET_SYMBOL];
11
- constructor(target) {
12
- this[TARGET_SYMBOL] = target;
13
- }
14
- get [Symbol.toStringTag]() {
15
- return this.constructor.name;
16
- }
17
- get target() {
18
- return this[TARGET_SYMBOL];
19
- }
20
- }
21
-
22
- exports.View = View;
package/lib/View.d.cts DELETED
@@ -1,14 +0,0 @@
1
- import { IView } from './IView.cjs';
2
-
3
- declare const TARGET_SYMBOL: unique symbol;
4
- /**
5
- * Base class providing view functionality over a target object using the Composition pattern.
6
- */
7
- declare class View<Target extends object> implements IView<Target> {
8
- private [TARGET_SYMBOL];
9
- constructor(target: Target);
10
- get [Symbol.toStringTag](): string;
11
- get target(): Target;
12
- }
13
-
14
- export { View };
package/lib/View.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { IView } from './IView.js';
2
-
3
- declare const TARGET_SYMBOL: unique symbol;
4
- /**
5
- * Base class providing view functionality over a target object using the Composition pattern.
6
- */
7
- declare class View<Target extends object> implements IView<Target> {
8
- private [TARGET_SYMBOL];
9
- constructor(target: Target);
10
- get [Symbol.toStringTag](): string;
11
- get target(): Target;
12
- }
13
-
14
- export { View };
package/lib/View.js DELETED
@@ -1,20 +0,0 @@
1
- import { __name } from './chunk-SHUYVCID.js';
2
-
3
- const TARGET_SYMBOL = /* @__PURE__ */ Symbol("target");
4
- class View {
5
- static {
6
- __name(this, "View");
7
- }
8
- [TARGET_SYMBOL];
9
- constructor(target) {
10
- this[TARGET_SYMBOL] = target;
11
- }
12
- get [Symbol.toStringTag]() {
13
- return this.constructor.name;
14
- }
15
- get target() {
16
- return this[TARGET_SYMBOL];
17
- }
18
- }
19
-
20
- export { View };
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var inheritProxifiedPrototypeProperty = require('./inheritProxifiedPrototypeProperty');
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
8
- Reflect.ownKeys(TargetClass.prototype).filter((k) => {
9
- return k !== "constructor" && k !== Symbol.toStringTag;
10
- }).filter((k) => {
11
- return omitKeys ? !omitKeys.includes(k) : true;
12
- }).forEach((k) => {
13
- return inheritProxifiedPrototypeProperty.inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
14
- });
15
- return ViewerClass;
16
- }
17
- __name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
18
-
19
- exports.inheritProxifiedPrototype = inheritProxifiedPrototype;
@@ -1,11 +0,0 @@
1
- import { C as Class } from './basic.d-DTQbMYh8.cjs';
2
- import { IView } from './IView.cjs';
3
-
4
- /**
5
- * Inherits prototype properties from a target class to a viewer class with proxification, excluding specified keys.
6
- */
7
- declare function inheritProxifiedPrototype<Viewer extends IView<Target>, Target extends object, Omitted extends PropertyKey[] = []>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, omitKeys: Omitted): typeof ViewerClass & {
8
- prototype: Viewer & Omit<Target, Omitted[number]>;
9
- };
10
-
11
- export { inheritProxifiedPrototype };
@@ -1,11 +0,0 @@
1
- import { C as Class } from './basic.d-DTQbMYh8.js';
2
- import { IView } from './IView.js';
3
-
4
- /**
5
- * Inherits prototype properties from a target class to a viewer class with proxification, excluding specified keys.
6
- */
7
- declare function inheritProxifiedPrototype<Viewer extends IView<Target>, Target extends object, Omitted extends PropertyKey[] = []>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, omitKeys: Omitted): typeof ViewerClass & {
8
- prototype: Viewer & Omit<Target, Omitted[number]>;
9
- };
10
-
11
- export { inheritProxifiedPrototype };
@@ -1,16 +0,0 @@
1
- import { __name } from './chunk-SHUYVCID.js';
2
- import { inheritProxifiedPrototypeProperty } from './inheritProxifiedPrototypeProperty';
3
-
4
- function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
5
- Reflect.ownKeys(TargetClass.prototype).filter((k) => {
6
- return k !== "constructor" && k !== Symbol.toStringTag;
7
- }).filter((k) => {
8
- return omitKeys ? !omitKeys.includes(k) : true;
9
- }).forEach((k) => {
10
- return inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
11
- });
12
- return ViewerClass;
13
- }
14
- __name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
15
-
16
- export { inheritProxifiedPrototype };
@@ -1,45 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- function inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, key) {
6
- const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key);
7
- if (!des) {
8
- return;
9
- }
10
- if (des.value && typeof des.value === "function") {
11
- return Object.defineProperty(ViewerClass.prototype, key, {
12
- value(...args) {
13
- return this.target[key](...args);
14
- },
15
- writable: true,
16
- configurable: true,
17
- enumerable: false
18
- });
19
- } else if (des && !des.get && !des.set) {
20
- return Object.defineProperty(ViewerClass.prototype, key, {
21
- get() {
22
- return this.target[key];
23
- },
24
- set: des.writable ? /* @__PURE__ */ __name(function set(value) {
25
- this.target[key] = value;
26
- }, "set") : void 0,
27
- configurable: true,
28
- enumerable: false
29
- });
30
- } else {
31
- Object.defineProperty(ViewerClass.prototype, key, {
32
- get: des.get ? function() {
33
- return this.target[key];
34
- } : void 0,
35
- set: des.set ? function(value) {
36
- this.target[key] = value;
37
- } : void 0,
38
- configurable: true,
39
- enumerable: false
40
- });
41
- }
42
- }
43
- __name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
44
-
45
- exports.inheritProxifiedPrototypeProperty = inheritProxifiedPrototypeProperty;
@@ -1,9 +0,0 @@
1
- import { C as Class } from './basic.d-DTQbMYh8.cjs';
2
- import { IView } from './IView.cjs';
3
-
4
- /**
5
- * Inherits a single prototype property from a target class to a viewer class with proxification.
6
- */
7
- declare function inheritProxifiedPrototypeProperty<Viewer extends IView<Target>, Target extends object>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, key: keyof Target): Pick<Viewer, keyof Viewer> | undefined;
8
-
9
- export { inheritProxifiedPrototypeProperty };
@@ -1,9 +0,0 @@
1
- import { C as Class } from './basic.d-DTQbMYh8.js';
2
- import { IView } from './IView.js';
3
-
4
- /**
5
- * Inherits a single prototype property from a target class to a viewer class with proxification.
6
- */
7
- declare function inheritProxifiedPrototypeProperty<Viewer extends IView<Target>, Target extends object>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, key: keyof Target): Pick<Viewer, keyof Viewer> | undefined;
8
-
9
- export { inheritProxifiedPrototypeProperty };
@@ -1,43 +0,0 @@
1
- import { __name } from './chunk-SHUYVCID.js';
2
-
3
- function inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, key) {
4
- const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key);
5
- if (!des) {
6
- return;
7
- }
8
- if (des.value && typeof des.value === "function") {
9
- return Object.defineProperty(ViewerClass.prototype, key, {
10
- value(...args) {
11
- return this.target[key](...args);
12
- },
13
- writable: true,
14
- configurable: true,
15
- enumerable: false
16
- });
17
- } else if (des && !des.get && !des.set) {
18
- return Object.defineProperty(ViewerClass.prototype, key, {
19
- get() {
20
- return this.target[key];
21
- },
22
- set: des.writable ? /* @__PURE__ */ __name(function set(value) {
23
- this.target[key] = value;
24
- }, "set") : void 0,
25
- configurable: true,
26
- enumerable: false
27
- });
28
- } else {
29
- Object.defineProperty(ViewerClass.prototype, key, {
30
- get: des.get ? function() {
31
- return this.target[key];
32
- } : void 0,
33
- set: des.set ? function(value) {
34
- this.target[key] = value;
35
- } : void 0,
36
- configurable: true,
37
- enumerable: false
38
- });
39
- }
40
- }
41
- __name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
42
-
43
- export { inheritProxifiedPrototypeProperty };
@@ -1,227 +0,0 @@
1
- 'use strict';
2
-
3
- var View = require('../View');
4
- var object$1 = require('es-toolkit/object');
5
- var colors = require('ansi-colors');
6
- var object = require('@mono/object');
7
- var ignoreValuesFilterDefaults = require('./defaults/ignoreValuesFilterDefaults');
8
- var util = require('util');
9
- var inspectorDefaults = require('./defaults/inspectorDefaults');
10
- var compat = require('es-toolkit/compat');
11
- var esToolkit = require('es-toolkit');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
-
15
- var colors__default = /*#__PURE__*/_interopDefault(colors);
16
-
17
- var __defProp = Object.defineProperty;
18
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
- class Inspector extends View.View {
20
- static {
21
- __name(this, "Inspector");
22
- }
23
- /**
24
- * Composes a class with Inspector capabilities by adding inspection methods to its prototype.
25
- * This follows the Composition pattern to extend classes without inheritance.
26
- */
27
- static compose(cls, options = {}) {
28
- if (!object.hasProperty(cls.prototype, util.inspect.custom)) {
29
- object.defineMethod(cls.prototype, util.inspect.custom, function(depth, options2) {
30
- return this.inspector.inspect(depth, options2);
31
- });
32
- }
33
- if (!object.hasProperty(cls.prototype, "inspector")) {
34
- object.defineLazyProperty(cls.prototype, "inspector", /* @__PURE__ */ __name(function get() {
35
- return new Inspector(this);
36
- }, "get"));
37
- }
38
- if (!object.hasProperty(cls.prototype, "toJSON")) {
39
- object.defineMethod(cls.prototype, "toJSON", function() {
40
- return this.inspector.toObject();
41
- });
42
- }
43
- return options;
44
- }
45
- /**
46
- * Compile the target object and return the output as an object.
47
- */
48
- toObject(depth = 0) {
49
- const result = esToolkit.mapValues(this.compile(depth).output, (value) => {
50
- if (!value) {
51
- return value;
52
- }
53
- if (typeof value !== "object") {
54
- return value;
55
- }
56
- if (Array.isArray(value)) {
57
- return value.map((v) => {
58
- if (v.inspector && v.inspector instanceof Inspector) {
59
- return v.inspector.toObject(depth + 1);
60
- }
61
- return v;
62
- });
63
- }
64
- if (value.inspector && value.inspector instanceof Inspector) {
65
- return value.inspector.toObject(depth + 1);
66
- }
67
- return value;
68
- });
69
- return {
70
- T: this.target.constructor.name,
71
- ...result
72
- };
73
- }
74
- /**
75
- * Inspect the target object.
76
- */
77
- inspect(depth = 0, options = {}) {
78
- const { output, inspectOptions } = this.compile(depth);
79
- Object.assign(inspectOptions, options);
80
- const result = util.inspect(output, options);
81
- return result.replaceAll(/Object \[\w+] {/gm, (match) => {
82
- match = match.substring(8, match.length - 3);
83
- return `[${inspectOptions.colors ? colors__default.default.magenta(match) : match}] {`;
84
- });
85
- }
86
- /**
87
- * Compiles the output object and inspect options.
88
- * Merges prototype chain options and applies filters to determine which properties to include.
89
- */
90
- compile(depth = 0) {
91
- const output = Object.defineProperty({}, Symbol.toStringTag, {
92
- value: this.target.constructor.name,
93
- configurable: true
94
- });
95
- const options = this.mergePrototypeOptions();
96
- const keys = new Set(options.keys);
97
- if (options.autoAddBooleanKeys) {
98
- const insBooleanValueKeys = Object.entries(this.target).filter(([_key, value]) => {
99
- return typeof value === "boolean";
100
- }).map(([key]) => {
101
- return key;
102
- });
103
- const protoGetterKeys = object.getClassChain(this.target, {
104
- includeSelf: false
105
- }).map((cls) => {
106
- return Object.getOwnPropertyNames(cls.prototype).filter((key) => {
107
- return object.hasOwnProperty(Reflect.getOwnPropertyDescriptor(cls.prototype, key), "get");
108
- });
109
- }).flat(2);
110
- const booleanKeys = insBooleanValueKeys.concat(protoGetterKeys).filter((key) => {
111
- return /^(is|was|has|should)[A-Z]/.test(key);
112
- });
113
- booleanKeys.forEach((key) => {
114
- return keys.add(key);
115
- });
116
- }
117
- const ignoreFilters = Object.entries(options.ignoreValues).filter(([_name, enabled]) => {
118
- return enabled;
119
- }).map(([name]) => {
120
- return ignoreValuesFilterDefaults.ignoreValuesFilterDefaults[name];
121
- });
122
- const objectValues = [];
123
- const arrayValues = [];
124
- for (const key of keys) {
125
- const value = this.target[key];
126
- if (!ignoreFilters.every((filter) => {
127
- return filter(value);
128
- })) {
129
- continue;
130
- }
131
- if (!options.filters.every((filter) => {
132
- return filter.call(this.target, value, key, depth, output);
133
- })) {
134
- continue;
135
- }
136
- if (Array.isArray(value)) {
137
- arrayValues.push(() => {
138
- return object.defineValue(output, key, value);
139
- });
140
- } else if (compat.isObjectLike(value)) {
141
- objectValues.push(() => {
142
- return object.defineValue(output, key, value);
143
- });
144
- } else {
145
- object.defineValue(output, key, value);
146
- }
147
- }
148
- objectValues.forEach((fn) => {
149
- return fn();
150
- });
151
- arrayValues.forEach((fn) => {
152
- return fn();
153
- });
154
- return {
155
- output,
156
- inspectOptions: options.inspect
157
- };
158
- }
159
- /**
160
- * Walks the prototype chain and merges Inspector options from all classes.
161
- * Subclass options override superclass options following inheritance semantics.
162
- */
163
- mergePrototypeOptions() {
164
- const defaults = this.getDefaults();
165
- let inspectOptions = defaults.inspect;
166
- const keys = new Set(defaults.keys);
167
- let autoAddBooleanKeys = defaults.autoAddBooleanKeys;
168
- const ignoreKeys = new Set(defaults.ignoreKeys);
169
- const ignoreValues = defaults.ignoreValues;
170
- const customFilters = defaults.filters;
171
- const prototypeChainOptions = object.getClassChain(this.target.constructor, {
172
- includeSelf: true
173
- }).reverse().map((cls) => {
174
- return cls.inspector ?? {};
175
- });
176
- for (const options of prototypeChainOptions) {
177
- if (options.inspect) {
178
- inspectOptions = {
179
- ...inspectOptions,
180
- ...options.inspect
181
- };
182
- }
183
- options.keys?.forEach((elem) => {
184
- return keys.add(elem);
185
- });
186
- if (options.autoAddBooleanKeys != null) {
187
- autoAddBooleanKeys = options.autoAddBooleanKeys;
188
- }
189
- keys.forEach((elem) => {
190
- return ignoreKeys.delete(elem);
191
- });
192
- options.ignoreKeys?.forEach((elem) => {
193
- return ignoreKeys.add(elem);
194
- });
195
- ignoreKeys.forEach((elem) => {
196
- return keys.delete(elem);
197
- });
198
- if (options.ignoreValues) {
199
- Object.assign(ignoreValues, options.ignoreValues);
200
- }
201
- options.filters?.forEach((filter) => {
202
- return customFilters.push(filter);
203
- });
204
- }
205
- return {
206
- inspect: inspectOptions,
207
- ignoreValues,
208
- autoAddBooleanKeys,
209
- keys: Array.from(keys),
210
- ignoreKeys: Array.from(ignoreKeys),
211
- filters: customFilters
212
- };
213
- }
214
- /**
215
- * Returns a deep clone of the default Inspector options.
216
- */
217
- getDefaults() {
218
- const filters = inspectorDefaults.inspectorDefaults.filters.slice();
219
- const rest = object$1.cloneDeep(compat.omit(inspectorDefaults.inspectorDefaults, "filters"));
220
- return {
221
- ...rest,
222
- filters
223
- };
224
- }
225
- }
226
-
227
- exports.Inspector = Inspector;
@@ -1,4 +0,0 @@
1
- export { c as Inspector, e as InspectorTarget } from '../Inspector-CrOT_QD4.cjs';
2
- import 'util';
3
- import '../View.cjs';
4
- import '../IView.cjs';
@@ -1,4 +0,0 @@
1
- export { c as Inspector, e as InspectorTarget } from '../Inspector-DAN0uRqw.js';
2
- import 'util';
3
- import '../View.js';
4
- import '../IView.js';