@bemoje/composition 3.0.0 → 3.0.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.
- package/lib/index.cjs +70 -156
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +94 -1007
- package/lib/index.d.ts +94 -1007
- package/lib/index.js +70 -156
- package/lib/index.js.map +1 -0
- package/package.json +7 -5
package/lib/index.js
CHANGED
|
@@ -116,9 +116,7 @@ __name(hasOwnProperty, "hasOwnProperty");
|
|
|
116
116
|
|
|
117
117
|
// ../object/src/hasPrototypeChainProperty.ts
|
|
118
118
|
function hasPrototypeChainProperty(object, key) {
|
|
119
|
-
return getClassChain(object).some((ctor) =>
|
|
120
|
-
return hasOwnProperty(ctor.prototype, key);
|
|
121
|
-
});
|
|
119
|
+
return getClassChain(object).some((ctor) => hasOwnProperty(ctor.prototype, key));
|
|
122
120
|
}
|
|
123
121
|
__name(hasPrototypeChainProperty, "hasPrototypeChainProperty");
|
|
124
122
|
|
|
@@ -134,16 +132,12 @@ function OptionsConfigurator(schemaOrProps, defaultKeys) {
|
|
|
134
132
|
const schema = KindGuard.IsObject(schemaOrProps) ? schemaOrProps : Type.Object(props);
|
|
135
133
|
const defaults = entriesOf(props).reduce((acc, [key, prop]) => {
|
|
136
134
|
if ("default" in prop) {
|
|
137
|
-
Reflect.set(acc, key, typeof prop.default === "function" ? prop.default : () =>
|
|
138
|
-
return prop.default;
|
|
139
|
-
});
|
|
135
|
+
Reflect.set(acc, key, typeof prop.default === "function" ? prop.default : () => prop.default);
|
|
140
136
|
}
|
|
141
137
|
return acc;
|
|
142
138
|
}, {});
|
|
143
139
|
const requiredKeys = schema.required;
|
|
144
|
-
const optionalKeys = keysOf(props).filter((k) =>
|
|
145
|
-
return !requiredKeys.includes(k);
|
|
146
|
-
});
|
|
140
|
+
const optionalKeys = keysOf(props).filter((k) => !requiredKeys.includes(k));
|
|
147
141
|
const create = createConfigurator({
|
|
148
142
|
defaults,
|
|
149
143
|
requiredKeys,
|
|
@@ -154,27 +148,13 @@ function OptionsConfigurator(schemaOrProps, defaultKeys) {
|
|
|
154
148
|
const options = callback(builder);
|
|
155
149
|
return options;
|
|
156
150
|
}, "build");
|
|
157
|
-
build.getSchemaProps = () =>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
build.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
build.
|
|
164
|
-
return defaults;
|
|
165
|
-
};
|
|
166
|
-
build.getDefaultKeys = () => {
|
|
167
|
-
return defaultKeys;
|
|
168
|
-
};
|
|
169
|
-
build.cast = (v) => {
|
|
170
|
-
return v;
|
|
171
|
-
};
|
|
172
|
-
build.getCreate = () => {
|
|
173
|
-
return create;
|
|
174
|
-
};
|
|
175
|
-
build.getBuild = () => {
|
|
176
|
-
return build;
|
|
177
|
-
};
|
|
151
|
+
build.getSchemaProps = () => props;
|
|
152
|
+
build.getSchema = () => schema;
|
|
153
|
+
build.getDefaults = () => defaults;
|
|
154
|
+
build.getDefaultKeys = () => defaultKeys;
|
|
155
|
+
build.cast = (v) => v;
|
|
156
|
+
build.getCreate = () => create;
|
|
157
|
+
build.getBuild = () => build;
|
|
178
158
|
build.createFunction = (func) => {
|
|
179
159
|
function fn(arg0) {
|
|
180
160
|
const options = typeof arg0 === "function" ? build(arg0) : Value.Default(schema, arg0);
|
|
@@ -196,32 +176,30 @@ function OptionsConfigurator(schemaOrProps, defaultKeys) {
|
|
|
196
176
|
});
|
|
197
177
|
return fn;
|
|
198
178
|
};
|
|
199
|
-
build.createBaseClass = () => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
};
|
|
179
|
+
build.createBaseClass = () => class Base {
|
|
180
|
+
static {
|
|
181
|
+
__name(this, "Base");
|
|
182
|
+
}
|
|
183
|
+
static get OptionsConfigurator() {
|
|
184
|
+
return build;
|
|
185
|
+
}
|
|
186
|
+
options;
|
|
187
|
+
constructor(arg0) {
|
|
188
|
+
this.options = typeof arg0 === "function" ? build(arg0) : Value.Default(schema, arg0);
|
|
189
|
+
this.initialize();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Called by the constructor
|
|
193
|
+
*/
|
|
194
|
+
initialize() {
|
|
195
|
+
this.assertValidOptions();
|
|
196
|
+
}
|
|
197
|
+
isValidOptions() {
|
|
198
|
+
return Value.Check(schema, this.options);
|
|
199
|
+
}
|
|
200
|
+
assertValidOptions() {
|
|
201
|
+
assertValidSchema(schema, this.options, "Invalid options");
|
|
202
|
+
}
|
|
225
203
|
};
|
|
226
204
|
return build;
|
|
227
205
|
}
|
|
@@ -346,34 +324,18 @@ __name(inheritProxifiedPrototypeProperty, "inheritProxifiedPrototypeProperty");
|
|
|
346
324
|
|
|
347
325
|
// src/inheritProxifiedPrototype.ts
|
|
348
326
|
function inheritProxifiedPrototype(ViewerClass, TargetClass, omitKeys) {
|
|
349
|
-
Reflect.ownKeys(TargetClass.prototype).filter((k) =>
|
|
350
|
-
return k !== "constructor" && k !== Symbol.toStringTag;
|
|
351
|
-
}).filter((k) => {
|
|
352
|
-
return omitKeys ? !omitKeys.includes(k) : true;
|
|
353
|
-
}).forEach((k) => {
|
|
354
|
-
return inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k);
|
|
355
|
-
});
|
|
327
|
+
Reflect.ownKeys(TargetClass.prototype).filter((k) => k !== "constructor" && k !== Symbol.toStringTag).filter((k) => omitKeys ? !omitKeys.includes(k) : true).forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k));
|
|
356
328
|
return ViewerClass;
|
|
357
329
|
}
|
|
358
330
|
__name(inheritProxifiedPrototype, "inheritProxifiedPrototype");
|
|
359
331
|
|
|
360
332
|
// src/inspector/defaults/ignoreValuesFilterDefaults.ts
|
|
361
333
|
var ignoreValuesFilterDefaults = {
|
|
362
|
-
noFalse: /* @__PURE__ */ __name((value) =>
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}, "noNull"),
|
|
368
|
-
noUndefined: /* @__PURE__ */ __name((value) => {
|
|
369
|
-
return value !== void 0;
|
|
370
|
-
}, "noUndefined"),
|
|
371
|
-
noEmptyArray: /* @__PURE__ */ __name((value) => {
|
|
372
|
-
return !Array.isArray(value) || !!value.length;
|
|
373
|
-
}, "noEmptyArray"),
|
|
374
|
-
noEmptyObject: /* @__PURE__ */ __name((value) => {
|
|
375
|
-
return !value || typeof value !== "object" || Array.isArray(value) || !!Object.keys(value).length;
|
|
376
|
-
}, "noEmptyObject")
|
|
334
|
+
noFalse: /* @__PURE__ */ __name((value) => value !== false, "noFalse"),
|
|
335
|
+
noNull: /* @__PURE__ */ __name((value) => value !== null, "noNull"),
|
|
336
|
+
noUndefined: /* @__PURE__ */ __name((value) => value !== void 0, "noUndefined"),
|
|
337
|
+
noEmptyArray: /* @__PURE__ */ __name((value) => !Array.isArray(value) || !!value.length, "noEmptyArray"),
|
|
338
|
+
noEmptyObject: /* @__PURE__ */ __name((value) => !value || typeof value !== "object" || Array.isArray(value) || !!Object.keys(value).length, "noEmptyObject")
|
|
377
339
|
};
|
|
378
340
|
|
|
379
341
|
// src/inspector/defaults/ignoreValuesDefaults.ts
|
|
@@ -484,62 +446,34 @@ var Inspector = class _Inspector extends View {
|
|
|
484
446
|
const options = this.mergePrototypeOptions();
|
|
485
447
|
const keys = new Set(options.keys);
|
|
486
448
|
if (options.autoAddBooleanKeys) {
|
|
487
|
-
const insBooleanValueKeys = Object.entries(this.target).filter(([_key, value]) =>
|
|
488
|
-
return typeof value === "boolean";
|
|
489
|
-
}).map(([key]) => {
|
|
490
|
-
return key;
|
|
491
|
-
});
|
|
449
|
+
const insBooleanValueKeys = Object.entries(this.target).filter(([_key, value]) => typeof value === "boolean").map(([key]) => key);
|
|
492
450
|
const protoGetterKeys = getClassChain(this.target, {
|
|
493
451
|
includeSelf: false
|
|
494
|
-
}).map((cls) =>
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
});
|
|
498
|
-
}).flat(2);
|
|
499
|
-
const booleanKeys = insBooleanValueKeys.concat(protoGetterKeys).filter((key) => {
|
|
500
|
-
return /^(is|was|has|should)[A-Z]/.test(key);
|
|
501
|
-
});
|
|
502
|
-
booleanKeys.forEach((key) => {
|
|
503
|
-
return keys.add(key);
|
|
504
|
-
});
|
|
452
|
+
}).map((cls) => Object.getOwnPropertyNames(cls.prototype).filter((key) => hasOwnProperty(Reflect.getOwnPropertyDescriptor(cls.prototype, key), "get"))).flat(2);
|
|
453
|
+
const booleanKeys = insBooleanValueKeys.concat(protoGetterKeys).filter((key) => /^(is|was|has|should)[A-Z]/.test(key));
|
|
454
|
+
booleanKeys.forEach((key) => keys.add(key));
|
|
505
455
|
}
|
|
506
|
-
const ignoreFilters = Object.entries(options.ignoreValues).filter(([_name, enabled]) =>
|
|
507
|
-
return enabled;
|
|
508
|
-
}).map(([name]) => {
|
|
509
|
-
return ignoreValuesFilterDefaults[name];
|
|
510
|
-
});
|
|
456
|
+
const ignoreFilters = Object.entries(options.ignoreValues).filter(([_name, enabled]) => enabled).map(([name]) => ignoreValuesFilterDefaults[name]);
|
|
511
457
|
const objectValues = [];
|
|
512
458
|
const arrayValues = [];
|
|
513
459
|
for (const key of keys) {
|
|
514
460
|
const value = this.target[key];
|
|
515
|
-
if (!ignoreFilters.every((filter) => {
|
|
516
|
-
return filter(value);
|
|
517
|
-
})) {
|
|
461
|
+
if (!ignoreFilters.every((filter) => filter(value))) {
|
|
518
462
|
continue;
|
|
519
463
|
}
|
|
520
|
-
if (!options.filters.every((filter) => {
|
|
521
|
-
return filter.call(this.target, value, key, depth, output);
|
|
522
|
-
})) {
|
|
464
|
+
if (!options.filters.every((filter) => filter.call(this.target, value, key, depth, output))) {
|
|
523
465
|
continue;
|
|
524
466
|
}
|
|
525
467
|
if (Array.isArray(value)) {
|
|
526
|
-
arrayValues.push(() =>
|
|
527
|
-
return defineValue(output, key, value);
|
|
528
|
-
});
|
|
468
|
+
arrayValues.push(() => defineValue(output, key, value));
|
|
529
469
|
} else if (isObjectLike(value)) {
|
|
530
|
-
objectValues.push(() =>
|
|
531
|
-
return defineValue(output, key, value);
|
|
532
|
-
});
|
|
470
|
+
objectValues.push(() => defineValue(output, key, value));
|
|
533
471
|
} else {
|
|
534
472
|
defineValue(output, key, value);
|
|
535
473
|
}
|
|
536
474
|
}
|
|
537
|
-
objectValues.forEach((fn) =>
|
|
538
|
-
|
|
539
|
-
});
|
|
540
|
-
arrayValues.forEach((fn) => {
|
|
541
|
-
return fn();
|
|
542
|
-
});
|
|
475
|
+
objectValues.forEach((fn) => fn());
|
|
476
|
+
arrayValues.forEach((fn) => fn());
|
|
543
477
|
return {
|
|
544
478
|
output,
|
|
545
479
|
inspectOptions: options.inspect
|
|
@@ -559,9 +493,7 @@ var Inspector = class _Inspector extends View {
|
|
|
559
493
|
const customFilters = defaults.filters;
|
|
560
494
|
const prototypeChainOptions = getClassChain(this.target.constructor, {
|
|
561
495
|
includeSelf: true
|
|
562
|
-
}).reverse().map((cls) => {
|
|
563
|
-
return cls.inspector ?? {};
|
|
564
|
-
});
|
|
496
|
+
}).reverse().map((cls) => cls.inspector ?? {});
|
|
565
497
|
for (const options of prototypeChainOptions) {
|
|
566
498
|
if (options.inspect) {
|
|
567
499
|
inspectOptions = {
|
|
@@ -569,27 +501,17 @@ var Inspector = class _Inspector extends View {
|
|
|
569
501
|
...options.inspect
|
|
570
502
|
};
|
|
571
503
|
}
|
|
572
|
-
options.keys?.forEach((elem) =>
|
|
573
|
-
return keys.add(elem);
|
|
574
|
-
});
|
|
504
|
+
options.keys?.forEach((elem) => keys.add(elem));
|
|
575
505
|
if (options.autoAddBooleanKeys != null) {
|
|
576
506
|
autoAddBooleanKeys = options.autoAddBooleanKeys;
|
|
577
507
|
}
|
|
578
|
-
keys.forEach((elem) =>
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
options.ignoreKeys?.forEach((elem) => {
|
|
582
|
-
return ignoreKeys.add(elem);
|
|
583
|
-
});
|
|
584
|
-
ignoreKeys.forEach((elem) => {
|
|
585
|
-
return keys.delete(elem);
|
|
586
|
-
});
|
|
508
|
+
keys.forEach((elem) => ignoreKeys.delete(elem));
|
|
509
|
+
options.ignoreKeys?.forEach((elem) => ignoreKeys.add(elem));
|
|
510
|
+
ignoreKeys.forEach((elem) => keys.delete(elem));
|
|
587
511
|
if (options.ignoreValues) {
|
|
588
512
|
Object.assign(ignoreValues, options.ignoreValues);
|
|
589
513
|
}
|
|
590
|
-
options.filters?.forEach((filter) =>
|
|
591
|
-
return customFilters.push(filter);
|
|
592
|
-
});
|
|
514
|
+
options.filters?.forEach((filter) => customFilters.push(filter));
|
|
593
515
|
}
|
|
594
516
|
return {
|
|
595
517
|
inspect: inspectOptions,
|
|
@@ -675,18 +597,14 @@ var ParentRelationTypes = class _ParentRelationTypes extends View {
|
|
|
675
597
|
...Array.from(this.parentTypesStats.keys())
|
|
676
598
|
]);
|
|
677
599
|
return Array.from(classes).map((cls) => {
|
|
678
|
-
const parents = Array.from(this.parentTypesStats.get(cls).multiplicities()).map(([cls2, count]) =>
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
cls2.name,
|
|
687
|
-
count
|
|
688
|
-
];
|
|
689
|
-
});
|
|
600
|
+
const parents = Array.from(this.parentTypesStats.get(cls).multiplicities()).map(([cls2, count]) => [
|
|
601
|
+
cls2.name,
|
|
602
|
+
count
|
|
603
|
+
]);
|
|
604
|
+
const children = Array.from(this.childTypesStats.get(cls).multiplicities()).map(([cls2, count]) => [
|
|
605
|
+
cls2.name,
|
|
606
|
+
count
|
|
607
|
+
]);
|
|
690
608
|
const result = {
|
|
691
609
|
class: cls.name
|
|
692
610
|
};
|
|
@@ -721,12 +639,8 @@ var ParentRelationTypes = class _ParentRelationTypes extends View {
|
|
|
721
639
|
console.log();
|
|
722
640
|
}
|
|
723
641
|
}
|
|
724
|
-
static childTypesStats = new DefaultMap(() =>
|
|
725
|
-
|
|
726
|
-
});
|
|
727
|
-
static parentTypesStats = new DefaultMap(() => {
|
|
728
|
-
return new MultiSet();
|
|
729
|
-
});
|
|
642
|
+
static childTypesStats = new DefaultMap(() => new MultiSet());
|
|
643
|
+
static parentTypesStats = new DefaultMap(() => new MultiSet());
|
|
730
644
|
};
|
|
731
645
|
var Parenting = class _Parenting extends View {
|
|
732
646
|
static {
|
|
@@ -801,9 +715,9 @@ var Parenting = class _Parenting extends View {
|
|
|
801
715
|
/**
|
|
802
716
|
* A WeakMap for parent references.
|
|
803
717
|
*/
|
|
804
|
-
static parentWeakRefMap = new DefaultMap(() =>
|
|
805
|
-
return /* @__PURE__ */ new WeakMap();
|
|
806
|
-
});
|
|
718
|
+
static parentWeakRefMap = new DefaultMap(() => /* @__PURE__ */ new WeakMap());
|
|
807
719
|
};
|
|
808
720
|
|
|
809
721
|
export { Inspector, OptionsConfigurator, ParentRelationTypes, Parenting, View, ignoreValuesDefaults, ignoreValuesFilterDefaults, inheritProxifiedPrototype, inheritProxifiedPrototypeProperty, inspectDefaults, inspectorDefaults };
|
|
722
|
+
//# sourceMappingURL=index.js.map
|
|
723
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../tschema/src/SchemaValidationError.ts","../../../tschema/src/assertValidSchema.ts","../../../object/src/defineGetter.ts","../../../object/src/defineValue.ts","../../../object/src/defineLazyProperty.ts","../../../object/src/defineMethod.ts","../../../object/src/entriesOf.ts","../../../object/src/keysOf.ts","../../../object/src/getClassChain.ts","../../../object/src/hasOwnProperty.ts","../../../object/src/hasPrototypeChainProperty.ts","../../../object/src/hasProperty.ts","../../src/OptionsConfigurator.ts","../../src/View.ts","../../src/inheritProxifiedPrototypeProperty.ts","../../src/inheritProxifiedPrototype.ts","../../src/inspector/defaults/ignoreValuesFilterDefaults.ts","../../src/inspector/defaults/ignoreValuesDefaults.ts","../../src/inspector/defaults/inspectDefaults.ts","../../src/inspector/defaults/inspectorDefaults.ts","../../src/inspector/Inspector.ts","../../src/parenting/ParentRelationTypes.ts","../../src/parenting/Parenting.ts"],"names":["SchemaValidationError","Error","value","errors","message","name","Array","isArray","ValueErrorIterator","from","Value","Errors","assertValidSchema","schema","data","isValid","Check","defineGetter","obj","key","get","des","Object","defineProperty","configurable","enumerable","defineValue","defineLazyProperty","getter","call","defineMethod","writable","entriesOf","entries","keysOf","keys","getClassChain","target","options","ctor","result","includeSelf","push","current","Reflect","getPrototypeOf","Function","prototype","hasOwnProperty","object","hasPrototypeChainProperty","some","hasProperty","OptionsConfigurator","schemaOrProps","defaultKeys","props","KindGuard","IsObject","properties","Type","defaults","reduce","acc","prop","set","default","requiredKeys","required","optionalKeys","filter","k","includes","create","createConfigurator","build","callback","builder","getSchemaProps","getSchema","getDefaults","getDefaultKeys","cast","v","getCreate","getBuild","createFunction","func","fn","arg0","Default","createBaseClass","Base","initialize","assertValidOptions","isValidOptions","CFG","$data","done","applyDefaults","forEach","dfValue","undefined","df","Set","configurator","ins","TARGET_SYMBOL","View","Symbol","toStringTag","inheritProxifiedPrototypeProperty","ViewerClass","TargetClass","getOwnPropertyDescriptor","args","inheritProxifiedPrototype","omitKeys","ownKeys","ignoreValuesFilterDefaults","noFalse","noNull","noUndefined","noEmptyArray","length","noEmptyObject","ignoreValuesDefaults","inspectDefaults","inspect","defaultOptions","customInspect","maxStringLength","maxArrayLength","breakLength","colors","depth","compact","numericSeparator","inspectorDefaults","ignoreValues","autoAddBooleanKeys","ignoreKeys","filters","Inspector","compose","cls","custom","inspector","toObject","mapValues","compile","output","map","T","inspectOptions","assign","replaceAll","match","substring","magenta","mergePrototypeOptions","insBooleanValueKeys","_key","protoGetterKeys","getOwnPropertyNames","flat","booleanKeys","concat","test","add","ignoreFilters","_name","enabled","objectValues","arrayValues","every","isObjectLike","customFilters","prototypeChainOptions","reverse","elem","delete","slice","rest","cloneDeep","omit","ParentRelationTypes","registerParent","parentType","parentTypesStats","childTypesStats","hasParent","has","getParentTypes","hasChildren","getChildTypes","isRoot","isLeaf","isIsolated","getAllChildTypesStats","res","multimap","forEachMultiplicity","count","getAllParentTypesStats","getAllStats","classes","parents","multiplicities","children","class","fromEntries","printAllStats","console","log","bold","yellow","stats","prefix","dim","parent","blue","String","repeat","child","green","DefaultMap","MultiSet","Parenting","onInstance","targetClass","parentingTargetConstructor","parentWeakRefMap","parenting","getParent","iterateAncestors","node","seen","WeakMap"],"mappings":";;;;;;;;;;;;AASO,IAAMA,qBAAAA,GAAN,cAAoCC,KAAAA,CAAAA;EAR3C;;;AASWC,EAAAA,KAAAA;AACAC,EAAAA,MAAAA;EACT,WAAA,CAAYA,MAAAA,EAAqDD,OAAgBE,OAAAA,EAAiB;AAChG,IAAA,KAAA,CAAMA,OAAAA,CAAAA;AACN,IAAA,IAAA,CAAKC,IAAAA,GAAO,uBAAA;AACZ,IAAA,IAAA,CAAKH,KAAAA,GAAQA,KAAAA;AACb,IAAA,IAAA,CAAKC,SAASG,KAAAA,CAAMC,OAAAA,CAAQJ,MAAAA,CAAAA,GACxBA,MAAAA,GACAA,kBAAkBK,kBAAAA,GAChBF,KAAAA,CAAMG,IAAAA,CAAKN,MAAAA,IACXG,KAAAA,CAAMG,IAAAA,CAAKC,MAAMC,MAAAA,CAAOR,MAAAA,EAAQD,KAAAA,CAAAA,CAAAA;AACxC,EAAA;AACF,CAAA;ACdO,SAASU,iBAAAA,CACdC,MAAAA,EACAC,IAAAA,EACAV,OAAAA,EAAe;AAEf,EAAA,MAAMW,OAAAA,GAAUL,KAAA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A,MAAMC,IAAAA,uBAAWrI,GAAAA,EAAAA;AACjB,IAAA,OAAOoI,IAAAA,EAAM;AACX,MAAA,IAAIC,IAAAA,CAAK7C,GAAAA,CAAI4C,IAAAA,CAAAA,EAAO;AAClB,QAAA;AACF,MAAA;AACAC,MAAAA,IAAAA,CAAKpE,IAAImE,IAAAA,CAAAA;AACT,MAAA,MAAMA,IAAAA;AACNA,MAAAA,IAAAA,GAAQA,IAAAA,EAA8BH,WAAWC,SAAAA,EAAAA;AACnD,IAAA;AACF,EAAA;;;;AAKA,EAAA,IAAInG,KAAAA,GAAgB;AAClB,IAAA,OAAO;AAAI,MAAA,GAAA,IAAA,CAAKoG,gBAAAA;AAAoB/G,KAAAA,CAAAA,MAAAA;AACtC,EAAA;;;;AAKA,EAAA,IAAI2G,0BAAAA,GAAyD;AAC3D,IAAA,OAAO,KAAKlM,MAAAA,CAAO,WAAA;AACrB,EAAA;;;;AAKA,EAAA,OAAwBmM,mBAAmB,IAAIN,UAAAA,CAG7C,sBAAM,IAAIY,SAAAA,CAAAA;AACd","file":"index.js","sourcesContent":["import type { TSchema } from '@sinclair/typebox'\nimport { Value } from '@sinclair/typebox/value'\nimport type { ValueError } from '@sinclair/typebox/compiler'\nimport { ValueErrorIterator } from '@sinclair/typebox/compiler'\n\n/**\n * Error thrown when a value does not match a given schema.\n * Contains an array of ValueError instances with details about each violation.\n */\nexport class SchemaValidationError extends Error {\n readonly value: unknown\n readonly errors: ValueError[]\n constructor(errors: TSchema | ValueError[] | ValueErrorIterator, value: unknown, message: string) {\n super(message)\n this.name = 'SchemaValidationError'\n this.value = value\n this.errors = Array.isArray(errors)\n ? errors\n : errors instanceof ValueErrorIterator\n ? Array.from(errors)\n : Array.from(Value.Errors(errors, value))\n }\n}\n","import { SchemaValidationError } from './SchemaValidationError'\nimport type { Static } from '@sinclair/typebox'\nimport type { TSchema } from '@sinclair/typebox'\nimport { Value } from '@sinclair/typebox/value'\n\n/**\n * Asserts that data conforms to a TypeBox schema, throwing a SchemaValidationError if it doesn't.\n */\nexport function assertValidSchema<Schema extends TSchema>(\n schema: Schema,\n data: unknown,\n message: string\n): asserts data is Static<Schema> {\n const isValid = Value.Check(schema, data)\n if (!isValid) {\n throw new SchemaValidationError(Value.Errors(schema, data), data, message)\n }\n}\n","import type { AccessorDescriptor } from './isAccessorDescriptor'\n\n/**\n * Define a getter property on an object with enhanced descriptor handling.\n */\nexport function defineGetter<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n get: () => V,\n des: Omit<AccessorDescriptor<V>, 'get'> = {}\n) {\n return Object.defineProperty<T>(obj, key, { configurable: true, enumerable: false, get, ...des })\n}\n","import type { AccessorDescriptor } from './isAccessorDescriptor'\nimport type { ValueDescriptor } from './isValueDescriptor'\n\n/**\n * Define a value property on an object with enhanced descriptor handling.\n */\nexport function defineValue<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n value: V,\n des: ValueDescriptor<T> | AccessorDescriptor<T> = {}\n) {\n return Object.defineProperty<T>(obj, key, { configurable: true, value, enumerable: true, ...des })\n}\n","import type { AccessorDescriptor } from './isAccessorDescriptor'\nimport { defineGetter } from './defineGetter'\nimport { defineValue } from './defineValue'\n\n/**\n * Define a lazy property that evaluates its getter on first access and then caches the value.\n */\nexport function defineLazyProperty<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n get: () => V,\n des: Omit<AccessorDescriptor<V>, 'get'> = {}\n) {\n function getter(this: T) {\n const value = get.call(this)\n defineValue(this, key, value)\n return value\n }\n return defineGetter(obj, key, getter, des)\n}\n","import type { AccessorDescriptor } from './isAccessorDescriptor'\nimport type { ValueDescriptor } from './isValueDescriptor'\n\n/**\n * Define a method property on an object with enhanced descriptor handling.\n */\nexport function defineMethod<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n value: V,\n des: ValueDescriptor<T> | AccessorDescriptor<T> = {}\n) {\n return Object.defineProperty<T>(obj, key, {\n value,\n configurable: true,\n writable: true,\n enumerable: false,\n ...des,\n })\n}\n","import type { StringKeyOf } from '@mono/types'\n\n/**\n * Same as Object.entries except the keys are typed as keyof T.\n */\nexport function entriesOf<T extends object>(obj: T): [StringKeyOf<T>, T[StringKeyOf<T>]][] {\n return Object.entries(obj) as [StringKeyOf<T>, T[StringKeyOf<T>]][]\n}\n","import type { StringKeyOf } from '@mono/types'\n\n/**\n * Same as Object.keys except the keys are typed as string keys of T.\n */\nexport function keysOf<T extends object>(obj: T) {\n return Object.keys(obj) as StringKeyOf<T>[]\n}\n","import type { AnyConstructor } from '@mono/types'\n\n/**\n * Get the class constructor chain for any target (constructor, prototype, or instance).\n * Always returns constructors/classes, never prototype objects.\n * By default excludes the target's own constructor (returns superclasses only).\n */\nexport function getClassChain(\n target: object | AnyConstructor,\n options?: { includeSelf?: boolean }\n): AnyConstructor[] {\n const ctor = (typeof target === 'function' ? target : target.constructor) as AnyConstructor\n const result: AnyConstructor[] = []\n\n if (options?.includeSelf) {\n result.push(ctor)\n }\n\n let current: object | null = ctor\n while ((current = Reflect.getPrototypeOf(current))) {\n if (current === Function.prototype || current === Object.prototype) {\n result.push(Object)\n break\n }\n result.push(current as AnyConstructor)\n }\n\n return result\n}\n","/**\n * Object.prototype.hasOwnProperty.call\n */\nexport function hasOwnProperty<T extends object>(object: T, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(object, key)\n}\n","import { getClassChain } from './getClassChain'\nimport { hasOwnProperty } from './hasOwnProperty'\n\n/**\n * Determines if a property is defined on an object's prototype prototype chain, not\n * including the object itself.\n */\nexport function hasPrototypeChainProperty<T extends object>(object: T, key: PropertyKey): boolean {\n return getClassChain(object).some((ctor) => hasOwnProperty(ctor.prototype, key))\n}\n","import { hasOwnProperty } from './hasOwnProperty'\nimport { hasPrototypeChainProperty } from './hasPrototypeChainProperty'\n\n/**\n * Determines if a property is defined on an object, including 'own' and prototype chain.\n */\nexport function hasProperty<T extends object>(object: T, key: PropertyKey): key is keyof T {\n return hasOwnProperty(object, key) || hasPrototypeChainProperty(object, key)\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { KindGuard } from '@sinclair/typebox'\nimport type { OptionalKeysOf } from 'type-fest'\nimport type { RequiredKeysOf } from 'type-fest'\nimport { ReturnType } from '@sinclair/typebox'\nimport type { SetFieldType } from 'type-fest'\nimport type { Simplify } from 'type-fest'\nimport type { Static } from '@sinclair/typebox'\nimport type { TObject } from '@sinclair/typebox'\nimport type { TSchema } from '@sinclair/typebox'\nimport { Type } from '@sinclair/typebox'\nimport { Value } from '@sinclair/typebox/value'\nimport { assertValidSchema } from '@mono/tschema'\nimport { entriesOf } from '@mono/object'\nimport { keysOf } from '@mono/object'\n\n/**\n * Makes the given keys optional. Declared here instead of taken from type-fest: type-fest's `SetOptional` is built\n * on a type it does not export (`HomomorphicPick`), so the types inferred in this file could only name it by its\n * path in node_modules, which ended up as an import in the built declaration file.\n */\ntype SetOptional<T, K extends keyof T> = Simplify<Omit<T, K> & Partial<Pick<T, K>>>\n\n/**\n * A utility function to configure options based on a given schema or properties.\n * This function provides a builder pattern to define and validate options,\n * including handling default values, required keys, and optional keys.\n *\n * @template P - A record type representing the schema or properties.\n *\n * @param schemaOrProps - The schema or properties to configure options.\n * It can either be an object schema (`TObject<P>`) or a plain object (`P`).\n *\n * @returns A builder function that allows creating and validating options.\n * The builder function includes the following properties:\n * - `schemaProps`: The properties of the schema.\n * - `schema`: The full schema object.\n * - `defaults`: A map of default value functions for optional properties.\n * - `cast`: A utility function to cast a value to the options type.\n * - `create`: A function to create a new configurator instance.\n * - `build`: A recursive reference to the builder function itself.\n *\n * @example ````ts\n * const props = {\n * name: Type.String(),\n * age: Type.Integer(),\n * city: Type.String(),\n * state: Type.Optional(Type.String({ default: () => 'WA' })),\n * disabled: Type.Optional(Type.Boolean()),\n * }\n *\n * const configurator = OptionsConfigurator(props)\n *\n * const options = configurator((o) => {\n * return o\n * .name('Alice') //\n * .age(2)\n * .city('Seattle')\n * .done()\n * })\n *\n * console.log(options)\n * //=> { state: 'WA', name: 'Alice', age: 2, city: 'Seattle' }\n * ```\n */\nexport function OptionsConfigurator<\n const DefaultKey extends keyof Static<TObject<P>>,\n P extends Record<string, TSchema>,\n>(schemaOrProps: P | TObject<P>, defaultKeys?: DefaultKey[]) {\n const props = KindGuard.IsObject(schemaOrProps) ? schemaOrProps.properties : (schemaOrProps as P)\n const schema = KindGuard.IsObject(schemaOrProps) ? schemaOrProps : Type.Object(props)\n\n type MergedOptions = Static<typeof schema>\n type Options = SetOptional<MergedOptions, DefaultKey>\n\n const defaults = entriesOf(props).reduce(\n (acc, [key, prop]) => {\n if ('default' in prop) {\n Reflect.set(\n acc,\n key,\n (typeof prop.default === 'function' ? prop.default : () => prop.default) as () => Options[keyof Options]\n )\n }\n return acc\n },\n {} as Partial<Record<keyof Options, () => Options[keyof Options]>>\n )\n\n const requiredKeys = schema.required as RequiredKeysOf<Options>[]\n const optionalKeys = keysOf(props).filter((k) => !requiredKeys.includes(k as never)) as OptionalKeysOf<Options>[]\n\n const create = createConfigurator<Options>({ defaults, requiredKeys, optionalKeys })\n\n const build = (callback: (builder: ReturnType<typeof create>) => Options) => {\n const builder = create()\n const options = callback(builder)\n return options as MergedOptions\n }\n\n build.getSchemaProps = () => props\n build.getSchema = () => schema\n build.getDefaults = () => defaults\n build.getDefaultKeys = () => defaultKeys\n build.cast = (v?: unknown) => v as MergedOptions\n build.getCreate = () => create\n build.getBuild = () => build\n\n type Builder = Parameters<typeof build>[0]\n\n build.createFunction = <Ret>(func: (options: MergedOptions) => Ret) => {\n function fn(options: Options): Ret\n function fn(builder: Builder): Ret\n function fn(arg0: Options | Builder) {\n const options = (typeof arg0 === 'function' ? build(arg0) : Value.Default(schema, arg0)) as MergedOptions\n assertValidSchema(schema, options, 'Invalid options')\n return func(options)\n }\n if (func.name) {\n Object.defineProperty(fn, 'name', { value: func.name, configurable: true })\n }\n Object.defineProperty(fn, 'OptionsConfigurator', {\n get() {\n return build\n },\n enumerable: true,\n })\n return fn as typeof fn & { get OptionsConfigurator(): typeof build }\n }\n\n build.createBaseClass = () =>\n class Base {\n static get OptionsConfigurator() {\n return build\n }\n\n readonly options: MergedOptions\n\n constructor(options: Options)\n constructor(builder: Builder)\n constructor(arg0: Options | Builder) {\n this.options = (typeof arg0 === 'function' ? build(arg0) : Value.Default(schema, arg0)) as MergedOptions\n this.initialize()\n }\n\n /**\n * Called by the constructor\n */\n initialize() {\n this.assertValidOptions()\n }\n\n isValidOptions() {\n return Value.Check(schema, this.options)\n }\n\n assertValidOptions() {\n assertValidSchema(schema, this.options, 'Invalid options')\n }\n }\n\n return build\n}\n\n/**\n * Creates a configurator class for managing options with defaults, required keys, and optional keys.\n * The configurator allows setting values, applying defaults for missing values, and retrieving the final configuration.\n */\nfunction createConfigurator<\n T extends Record<string, any>,\n K extends keyof T = keyof T,\n V extends T[K] = T[K],\n>(options: {\n defaults: Partial<Record<K, () => V>>\n requiredKeys: RequiredKeysOf<T>[]\n optionalKeys: OptionalKeysOf<T>[]\n}) {\n class CFG<Opts extends T> {\n constructor(readonly $data: Partial<Opts>) {}\n\n /**\n * Applies defaults for missing values and then returns data.\n */\n done() {\n this.applyDefaults()\n return this.$data\n }\n\n /**\n * Set default values for missing keys.\n */\n protected applyDefaults() {\n entriesOf(options.defaults).forEach(([key, dfValue]) => {\n if (this.$data[key] === undefined) {\n const df = dfValue?.()\n if (df !== undefined) {\n this.$data[key] = df\n }\n }\n })\n return this\n }\n }\n\n // all property keys\n const keys = new Set([...options.requiredKeys, ...keysOf(options.defaults), ...options.optionalKeys] as K[])\n\n // add accessor methods to prototype\n for (const key of keys) {\n Object.defineProperty(CFG.prototype, key, {\n value: function (this: CFG<T>, value: T[typeof key]) {\n if (value === undefined) {\n if (key in options.defaults) {\n this.$data[key] = options.defaults[key]!()\n } else {\n delete this.$data[key]\n }\n } else {\n this.$data[key] = value\n }\n return new CFG(this.$data)\n },\n })\n }\n\n return function configurator() {\n const ins = new CFG({})\n return ins as TConfigurator<T>\n }\n}\n\n/**\n * @example ```ts\n * type _T = TConfigurator<{ a: number; b?: number }>\n * const _t: _T = {} as _T\n * _t.a((1))\n * ```\n */\ntype TConfigurator<\n T extends Record<string, any>,\n O extends Record<keyof T, any> = Record<keyof T, undefined>,\n> = Simplify<DataProp<T, O> & AllAccessors<T, O> & DoneMethod<T, O>>\n\ntype _T = TConfigurator<{ a: number; b?: number }>\nconst _t: _T = {} as _T\n\n// type RequiredAccessors<\n// T extends Record<string, any>, //\n// O extends Record<keyof T, any>,\n// > = {\n// [K in keyof Required<PickRequired<T>>]: (\n// value: T[K],\n// ) => ConfiguratorRecursive<Omit<T, K>, SetFieldType<O, K, T[K]>>\n// }\n\n// type OptionalAccessors<\n// T extends Record<string, any>, //\n// O extends Record<keyof T, any>,\n// > = {\n// [K in keyof Required<PickOptional<T>>]: (\n// value: T[K],\n// ) => ConfiguratorRecursive<Omit<T, K>, SetFieldType<O, K, T[K]>>\n// }\n\ntype AllAccessors<\n T extends Record<string, any>, //\n O extends Record<keyof T, any>,\n> = { [K in keyof Required<T>]: (value: T[K]) => TConfigurator<Omit<T, K>, SetFieldType<O, K, T[K]>> }\n\ntype DoneMethod<\n T extends Record<string, any>, //\n O extends Record<keyof T, any>,\n> = {\n /**\n * Applies defaults for missing values and then returns data.\n */\n done(): Simplify<Omit<T, keyof O> & O>\n}\n\ntype DataProp<\n T extends Record<string, any>, //\n O extends Record<keyof T, any>,\n> = {\n /**\n * Returns data without applying defaults for missing values.\n */\n $data: Simplify<Omit<T, keyof O> & O>\n}\n\n// /**\n// * Determine if all required keys are defined.\n// */\n// type AllRequiredDefined<\n// T extends Record<string, any>, //\n// O extends Record<string, any>,\n// > = RequiredKeysOf<T> extends RequiredKeysOf<DefinedKeys<O>> ? O : never\n\n// /**\n// * Omit all props that have value === undefined.\n// */\n// type DefinedKeys<\n// T extends Record<string, any>, //\n// > = {\n// [K in keyof T as T[K] extends undefined ? never : K]: T[K]\n// }\n","import type { IView } from './IView'\n\nconst TARGET_SYMBOL = Symbol('target')\n\n/**\n * Base class providing view functionality over a target object using the Composition pattern.\n */\nexport class View<Target extends object> implements IView<Target> {\n private [TARGET_SYMBOL]: Target\n\n constructor(target: Target) {\n this[TARGET_SYMBOL] = target\n }\n\n get [Symbol.toStringTag](): string {\n return this.constructor.name\n }\n\n get target(): Target {\n return this[TARGET_SYMBOL]\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\n\n/**\n * Inherits a single prototype property from a target class to a viewer class with proxification.\n */\nexport function inheritProxifiedPrototypeProperty<Viewer extends IView<Target>, Target extends object>(\n ViewerClass: Class<Viewer>,\n TargetClass: Class<Target>,\n key: keyof Target\n) {\n const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key)\n if (!des) {\n return\n }\n\n if (des.value && typeof des.value === 'function') {\n return Object.defineProperty(ViewerClass.prototype, key, {\n value(...args: any[]) {\n return this.target[key](...args)\n },\n writable: true,\n configurable: true,\n enumerable: false,\n })\n } else if (des && !des.get && !des.set) {\n return Object.defineProperty(ViewerClass.prototype, key, {\n get(this: Viewer) {\n return this.target[key]\n },\n set: des.writable\n ? function set(this: Viewer, value: Target[keyof Target]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n } else {\n Object.defineProperty(ViewerClass.prototype, key, {\n get: des.get\n ? function (this: Viewer) {\n return this.target[key]\n }\n : undefined,\n set: des.set\n ? function (this: Viewer, value: Target[typeof key]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\nimport { inheritProxifiedPrototypeProperty } from './inheritProxifiedPrototypeProperty'\n\n/**\n * Inherits prototype properties from a target class to a viewer class with proxification, excluding specified keys.\n */\nexport function inheritProxifiedPrototype<\n Viewer extends IView<Target>,\n Target extends object,\n Omitted extends PropertyKey[] = [],\n>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, omitKeys: Omitted) {\n Reflect.ownKeys(TargetClass.prototype)\n .filter((k) => k !== 'constructor' && k !== Symbol.toStringTag)\n .filter((k) => (omitKeys ? !omitKeys.includes(k) : true))\n .forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k as keyof Target))\n return ViewerClass as typeof ViewerClass & { prototype: Viewer & Omit<Target, Omitted[number]> }\n}\n","import type { IgnoreValuesOptions } from '../types'\n\n/**\n * Default filter functions for ignoring values during object inspection.\n */\nexport const ignoreValuesFilterDefaults: Record<keyof IgnoreValuesOptions, (value: unknown) => boolean> = {\n noFalse: (value: unknown) => value !== false,\n noNull: (value: unknown) => value !== null,\n noUndefined: (value: unknown) => value !== undefined,\n noEmptyArray: (value: unknown) => !Array.isArray(value) || !!value.length,\n noEmptyObject: (value: unknown) =>\n !value || typeof value !== 'object' || Array.isArray(value) || !!Object.keys(value!).length,\n}\n","import type { IgnoreValuesOptions } from '../types'\n\n/**\n * Default options for ignoring specific values during object inspection.\n */\nexport const ignoreValuesDefaults: IgnoreValuesOptions = {\n noEmptyArray: true,\n noEmptyObject: true,\n noNull: true,\n noUndefined: true,\n noFalse: false,\n}\n","import type { InspectOptions } from 'util'\nimport { inspect } from 'util'\n\n/**\n * Default options for Node.js util.inspect with enhanced settings for better debugging output.\n */\nexport const inspectDefaults: InspectOptions = {\n ...inspect.defaultOptions,\n customInspect: true,\n maxStringLength: 500,\n maxArrayLength: 200,\n breakLength: 100,\n colors: true,\n depth: 100,\n compact: false,\n numericSeparator: true,\n}\n","import type { InspectorOptions } from '../types'\nimport { ignoreValuesDefaults } from './ignoreValuesDefaults'\nimport { inspectDefaults } from './inspectDefaults'\n\n/**\n * The default inspector configuration options.\n */\nexport const inspectorDefaults: Required<InspectorOptions> = {\n inspect: inspectDefaults,\n ignoreValues: ignoreValuesDefaults,\n keys: [],\n autoAddBooleanKeys: false,\n ignoreKeys: [],\n filters: [],\n}\n","import type { ClassInspectorMixin } from './types'\nimport type { IgnoreValuesOptions } from './types'\nimport type { InspectOptions } from 'util'\nimport type { InspectorOptions } from './types'\nimport { View } from '../View'\nimport { cloneDeep } from 'es-toolkit/object'\nimport colors from 'ansi-colors'\nimport { defineLazyProperty } from '@mono/object'\nimport { defineMethod } from '@mono/object'\nimport { defineValue } from '@mono/object'\nimport { getClassChain } from '@mono/object'\nimport { hasOwnProperty } from '@mono/object'\nimport { hasProperty } from '@mono/object'\nimport { ignoreValuesFilterDefaults } from './defaults/ignoreValuesFilterDefaults'\nimport { inspect } from 'util'\nimport { inspectorDefaults } from './defaults/inspectorDefaults'\nimport { isObjectLike } from 'es-toolkit/compat'\nimport { mapValues } from 'es-toolkit'\nimport { omit } from 'es-toolkit/compat'\n\n/**\n * Interface that target objects must implement to be inspectable.\n * Provides standard inspection methods for debugging and serialization.\n */\nexport interface InspectorTarget {\n [inspect.custom](depth: number, options: InspectOptions): string\n get inspector(): Inspector\n toJSON(): Partial<this>\n}\n\n/**\n * Inspector provides customizable object inspection and serialization using the Composition pattern.\n * Composes target classes with inspection capabilities, allowing selective property display and custom formatting.\n */\nexport class Inspector extends View<InspectorTarget> {\n /**\n * Composes a class with Inspector capabilities by adding inspection methods to its prototype.\n * This follows the Composition pattern to extend classes without inheritance.\n */\n static compose(cls: ClassInspectorMixin, options: InspectorOptions = {}) {\n if (!hasProperty(cls.prototype, inspect.custom)) {\n defineMethod(\n cls.prototype,\n inspect.custom,\n function (this: InspectorTarget, depth?: number, options?: InspectOptions) {\n return this.inspector.inspect(depth, options)\n }\n )\n }\n\n if (!hasProperty(cls.prototype, 'inspector')) {\n defineLazyProperty(cls.prototype, 'inspector', function get(this: InspectorTarget) {\n return new Inspector(this)\n })\n }\n\n if (!hasProperty(cls.prototype, 'toJSON')) {\n defineMethod(cls.prototype, 'toJSON', function (this: InspectorTarget) {\n return this.inspector.toObject()\n })\n }\n\n return options\n }\n\n /**\n * Compile the target object and return the output as an object.\n */\n toObject(depth = 0): Partial<InspectorTarget> {\n const result = mapValues(this.compile(depth).output, (value: unknown) => {\n if (!value) {\n return value\n }\n if (typeof value !== 'object') {\n return value\n }\n if (Array.isArray(value)) {\n return value.map((v) => {\n if ((v as InspectorTarget).inspector && (v as InspectorTarget).inspector instanceof Inspector) {\n return v.inspector.toObject(depth + 1)\n }\n return v\n })\n }\n if ((value as InspectorTarget).inspector && (value as InspectorTarget).inspector instanceof Inspector) {\n return (value as InspectorTarget).inspector.toObject(depth + 1)\n }\n return value\n })\n return { T: this.target.constructor.name, ...result } as Partial<InspectorTarget>\n }\n\n /**\n * Inspect the target object.\n */\n inspect(depth = 0, options: InspectOptions = {}) {\n const { output, inspectOptions } = this.compile(depth)\n Object.assign(inspectOptions, options)\n const result = inspect(output, options)\n return result.replaceAll(/Object \\[\\w+] {/gm, (match) => {\n match = match.substring(8, match.length - 3)\n return `[${inspectOptions.colors ? colors.magenta(match) : match}] {`\n })\n }\n\n /**\n * Compiles the output object and inspect options.\n * Merges prototype chain options and applies filters to determine which properties to include.\n */\n protected compile(depth = 0): { output: Partial<InspectorTarget>; inspectOptions: InspectOptions } {\n const output = Object.defineProperty({}, Symbol.toStringTag, {\n value: this.target.constructor.name,\n configurable: true,\n }) as InspectorTarget\n\n const options = this.mergePrototypeOptions()\n\n const keys = new Set(options.keys)\n if (options.autoAddBooleanKeys) {\n const insBooleanValueKeys = Object.entries(this.target)\n .filter(([_key, value]) => typeof value === 'boolean')\n .map(([key]) => key)\n\n const protoGetterKeys = getClassChain(this.target, { includeSelf: false })\n .map((cls) =>\n Object.getOwnPropertyNames(cls.prototype).filter((key) =>\n hasOwnProperty(Reflect.getOwnPropertyDescriptor(cls.prototype, key)!, 'get')\n )\n )\n .flat(2)\n\n const booleanKeys = insBooleanValueKeys\n .concat(protoGetterKeys)\n .filter((key) => /^(is|was|has|should)[A-Z]/.test(key))\n\n booleanKeys.forEach((key) => keys.add(key))\n }\n\n const ignoreFilters = Object.entries(options.ignoreValues)\n .filter(([_name, enabled]) => enabled)\n .map(([name]) => ignoreValuesFilterDefaults[name as keyof IgnoreValuesOptions])\n\n const objectValues: (() => void)[] = []\n const arrayValues: (() => void)[] = []\n for (const key of keys) {\n const value = this.target[key as keyof InspectorTarget]\n if (!ignoreFilters.every((filter) => filter(value))) {\n continue\n }\n if (!options.filters.every((filter) => filter.call(this.target, value, key, depth, output))) {\n continue\n }\n if (Array.isArray(value)) {\n arrayValues.push(() => defineValue(output, key, value))\n } else if (isObjectLike(value)) {\n objectValues.push(() => defineValue(output, key, value))\n } else {\n defineValue(output, key, value)\n }\n }\n objectValues.forEach((fn) => fn())\n arrayValues.forEach((fn) => fn())\n\n return { output, inspectOptions: options.inspect }\n }\n\n /**\n * Walks the prototype chain and merges Inspector options from all classes.\n * Subclass options override superclass options following inheritance semantics.\n */\n protected mergePrototypeOptions(): Required<InspectorOptions> {\n const defaults = this.getDefaults()\n let inspectOptions = defaults.inspect\n const keys = new Set<string | symbol>(defaults.keys)\n let autoAddBooleanKeys = defaults.autoAddBooleanKeys\n const ignoreKeys = new Set<string | symbol>(defaults.ignoreKeys)\n const ignoreValues = defaults.ignoreValues\n const customFilters = defaults.filters\n\n // walk prototype chain and collect options where defined\n const prototypeChainOptions = getClassChain(this.target.constructor, { includeSelf: true })\n .reverse()\n .map((cls) => (cls as unknown as ClassInspectorMixin).inspector ?? {}) as InspectorOptions[]\n\n // iterate prototype and let the next subclass' options override its superclasses\n for (const options of prototypeChainOptions) {\n if (options.inspect) {\n inspectOptions = { ...inspectOptions, ...options.inspect }\n }\n options.keys?.forEach((elem) => keys.add(elem))\n if (options.autoAddBooleanKeys != null) {\n autoAddBooleanKeys = options.autoAddBooleanKeys\n }\n keys.forEach((elem) => ignoreKeys.delete(elem))\n options.ignoreKeys?.forEach((elem) => ignoreKeys.add(elem))\n ignoreKeys.forEach((elem) => keys.delete(elem))\n if (options.ignoreValues) {\n Object.assign(ignoreValues, options.ignoreValues)\n }\n options.filters?.forEach((filter) => customFilters.push(filter))\n }\n\n return {\n inspect: inspectOptions,\n ignoreValues,\n autoAddBooleanKeys,\n keys: Array.from(keys),\n ignoreKeys: Array.from(ignoreKeys),\n filters: customFilters,\n }\n }\n\n /**\n * Returns a deep clone of the default Inspector options.\n */\n protected getDefaults(): Required<InspectorOptions> {\n const filters = inspectorDefaults.filters.slice()\n const rest = cloneDeep(omit(inspectorDefaults, 'filters'))\n return { ...rest, filters }\n }\n}\n","import type { Any } from '@mono/types'\nimport { DefaultMap } from 'mnemonist'\nimport type { FunctionPrototype } from '@mono/types'\nimport { MultiSet } from 'mnemonist'\nimport type { ParentingTargetConstructor } from './types'\nimport { View } from '../View'\nimport colors from 'ansi-colors'\n\n/**\n * Manages parent-child relationships between constructor types, tracking hierarchical connections and providing debugging capabilities.\n */\nexport class ParentRelationTypes<P extends object | null = object | null> extends View<\n ParentingTargetConstructor<P>\n> {\n registerParent(parentType: FunctionPrototype) {\n ParentRelationTypes.parentTypesStats.get(this.target).add(parentType)\n ParentRelationTypes.childTypesStats.get(parentType).add(this.target)\n }\n\n get hasParent(): boolean {\n return ParentRelationTypes.parentTypesStats.has(this.target)\n }\n get getParentTypes(): MultiSet<FunctionPrototype> {\n return ParentRelationTypes.parentTypesStats.get(this.target)\n }\n\n get hasChildren(): boolean {\n return ParentRelationTypes.childTypesStats.has(this.target)\n }\n get getChildTypes(): MultiSet<FunctionPrototype> {\n return ParentRelationTypes.childTypesStats.get(this.target)\n }\n\n get isRoot(): boolean {\n return !this.hasParent && this.hasChildren\n }\n get isLeaf() {\n return this.hasParent && !this.hasChildren\n }\n get isIsolated(): boolean {\n return !this.hasParent && !this.hasChildren\n }\n\n static getAllChildTypesStats() {\n const res: Record<string, Record<string, number>> = {}\n Array.from(this.childTypesStats.entries()).map(([cls, multimap]) => {\n multimap.forEachMultiplicity((count, key) => {\n if (!res[cls.name]) {\n res[cls.name] = {}\n }\n if (!res[cls.name][key.name]) {\n res[cls.name][key.name] = count\n }\n })\n })\n return res\n }\n\n static getAllParentTypesStats() {\n const res: Record<string, Record<string, number>> = {}\n Array.from(this.parentTypesStats.entries()).map(([cls, multimap]) => {\n multimap.forEachMultiplicity((count, key) => {\n if (!res[cls.name]) {\n res[cls.name] = {}\n }\n if (!res[cls.name][key.name]) {\n res[cls.name][key.name] = count\n }\n })\n })\n return res\n }\n\n static getAllStats() {\n const classes = new Set([\n ...Array.from(this.childTypesStats.keys()),\n ...Array.from(this.parentTypesStats.keys()),\n ])\n return Array.from(classes).map((cls) => {\n const parents = Array.from(this.parentTypesStats.get(cls).multiplicities()).map(([cls, count]) => [\n cls.name,\n count,\n ])\n const children = Array.from(this.childTypesStats.get(cls).multiplicities()).map(([cls, count]) => [\n cls.name,\n count,\n ])\n const result = { class: cls.name } as Any\n if (parents.length) {\n result.parents = Object.fromEntries(parents)\n }\n if (children.length) {\n result.children = Object.fromEntries(children)\n }\n return result\n })\n }\n\n static printAllStats() {\n console.log()\n console.log(colors.bold.yellow('Parent-Child Relation Stats'))\n for (const stats of this.getAllStats()) {\n console.log(stats.class)\n if (stats.parents) {\n let prefix = ` ${colors.dim('parents : ')}`\n for (const [parent, count] of Object.entries(stats.parents)) {\n console.log(`${prefix}${colors.blue(parent)}: ${colors.yellow(String(count))}`)\n prefix = ' '.repeat(12)\n }\n }\n if (stats.children) {\n let prefix = ` ${colors.dim('children : ')}`\n for (const [child, count] of Object.entries(stats.children)) {\n console.log(`${prefix}${colors.green(child)}: ${colors.yellow(String(count))}`)\n prefix = ' '.repeat(12)\n }\n }\n console.log()\n }\n }\n\n static childTypesStats = new DefaultMap<FunctionPrototype, MultiSet<FunctionPrototype>>(() => new MultiSet())\n static parentTypesStats = new DefaultMap<FunctionPrototype, MultiSet<FunctionPrototype>>(() => new MultiSet())\n}\n","import { DefaultMap } from 'mnemonist'\nimport type { FunctionPrototype } from '@mono/types'\nimport { ParentRelationTypes } from './ParentRelationTypes'\nimport type { ParentingTarget } from './types'\nimport type { ParentingTargetConstructor } from './types'\nimport { View } from '../View'\nimport { defineLazyProperty } from '@mono/object'\nimport { hasProperty } from '@mono/object'\n\n/**\n * Class that handles the parent-child relationships between objects on their behalf.\n *\n * In order to avoid circular references, all children keep a weak reference to their parent. However,\n * it is not guaranteed. Two objects could in principle mutually be both each other's parent and child\n * at the same time which would allow circular references to exist.\n */\nexport class Parenting<TP extends object | null = object | null> extends View<ParentingTarget<TP>> {\n /**\n * Class decorator to register and correctly initialize a class as a 'parentingTarget'.\n */\n static compose(cls: ParentingTargetConstructor) {\n // static\n if (!hasProperty(cls, 'parenting')) {\n defineLazyProperty(cls, 'parenting', function <\n P extends object | null,\n >(this: ParentingTargetConstructor<P>) {\n return new ParentRelationTypes(this)\n })\n }\n\n // prototype\n if (!hasProperty(cls.prototype, 'parenting')) {\n defineLazyProperty(cls.prototype, 'parenting', function <\n P extends object | null = object | null,\n >(this: ParentingTarget<P>) {\n return new Parenting(this)\n })\n }\n }\n\n /**\n * Store a weak refences to the target object's parent.\n */\n onInstance(parent: TP | null) {\n if (!parent) {\n return\n }\n const targetClass = this.parentingTargetConstructor\n Parenting.parentWeakRefMap.get(targetClass).set(this.target, parent)\n targetClass.parenting?.registerParent(parent.constructor)\n }\n\n /**\n * Retrieve the parent object of 'target' object.\n */\n getParent(): TP {\n const map = Parenting.parentWeakRefMap.get(this.parentingTargetConstructor)!\n const parent = map.get(this.target)!\n return parent as TP\n }\n\n /**\n * Recursively get parent until no parent is found or a circular reference is detected.\n */\n *iterateAncestors<T extends object | null = object | null>(): Generator<ParentingTarget<T>> {\n let node = this.target.parenting.getParent()\n if (!node) {\n return\n }\n const seen = new Set<object>()\n while (node) {\n if (seen.has(node)) {\n return\n }\n seen.add(node)\n yield node as ParentingTarget<T>\n node = (node as ParentingTarget<TP>)?.parenting?.getParent()\n }\n }\n\n /**\n * The depth of the object in the parent-child hierarchy.\n */\n get depth(): number {\n return [...this.iterateAncestors()].length\n }\n\n /**\n * The class constructor of the target object.\n */\n get parentingTargetConstructor(): ParentingTargetConstructor {\n return this.target.constructor as ParentingTargetConstructor\n }\n\n /**\n * A WeakMap for parent references.\n */\n private static readonly parentWeakRefMap = new DefaultMap<\n FunctionPrototype,\n WeakMap<ParentingTarget, object | null>\n >(() => new WeakMap<ParentingTarget, object | null>())\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/composition",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Class composition utilities for views, proxy-based inheritance, object inspection, and parent-child relationships.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@sinclair/typebox": "^0.34.
|
|
11
|
+
"@sinclair/typebox": "^0.34.52",
|
|
12
12
|
"ansi-colors": "^4.1.3",
|
|
13
|
-
"es-toolkit": "^1.
|
|
14
|
-
"mnemonist": "^0.40.
|
|
13
|
+
"es-toolkit": "^1.53.2",
|
|
14
|
+
"mnemonist": "^0.40.8"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"composition",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"./lib/index.js",
|
|
32
32
|
"./lib/index.d.ts",
|
|
33
33
|
"./lib/index.cjs",
|
|
34
|
-
"./lib/index.d.cts"
|
|
34
|
+
"./lib/index.d.cts",
|
|
35
|
+
"./lib/index.js.map",
|
|
36
|
+
"./lib/index.cjs.map"
|
|
35
37
|
],
|
|
36
38
|
"exports": {
|
|
37
39
|
".": {
|