Socket
Socket
Sign inDemoInstall

@lifaon/class-factory

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

cjs/core/decorators/abstract-method.js

433

bundles/class-factory.core.umd.js

@@ -42,2 +42,13 @@ (function (global, factory) {

var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __generator(thisArg, body) {

@@ -106,3 +117,2 @@ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;

var EXCLUDED_PROPERTY_NAMES = new Set(__spreadArrays(['prototype', 'constructor'], GetOwnPropertyKeys(Object.prototype)));
function GetOwnPropertyKeys(target) {

@@ -112,2 +122,5 @@ return Object.getOwnPropertyNames(target)

}
function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
function GetOwnPropertyDescriptors(target) {

@@ -135,2 +148,31 @@ var keys, i, l, key;

}
var PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
function IsPrimitivePropertyName(name) {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
function GetPrototypesChain(target) {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(target !== null)) return [3, 2];
return [4, target];
case 1:
_a.sent();
target = Object.getPrototypeOf(target);
return [3, 0];
case 2: return [2];
}
});
}
var PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], function () { }].map(function (_) { return Object.getPrototypeOf(_); }));
function IsPrimitivePrototype(proto) {
return PRIMITIVE_PROTOTYPES.has(proto);
}
function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
var EXCLUDED_PROPERTY_NAMES = new Set(__spreadArrays(['prototype', 'constructor'], GetOwnPropertyKeys(Object.prototype)));
function GetPropertyDescriptors(target) {

@@ -324,5 +366,2 @@ var _keys, keys, _i, keys_1, key;

}
function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}
//# sourceMappingURL=helpers.js.map

@@ -558,48 +597,289 @@

var TRAITS = Symbol('traits');
function RegisterTraits(obj, traits) {
if (ObjectHasOwnProperty(obj, TRAITS)) {
var _traits = obj[TRAITS];
for (var i = 0, l = traits.length; i < l; i++) {
_traits.add(traits[i]);
function CallTraitFunctionAsMethod(traitFunction, target, args) {
var _a;
if (traitFunction.isImplementedBy(target)) {
return (_a = target)[traitFunction.propertyKey].apply(_a, args);
}
else {
return traitFunction.fnc.apply(target, args);
}
}
function CallTraitFunctionOrFallback(traitFunction, target, args, fallback) {
var _a;
if (traitFunction.isImplementedBy(target)) {
return (_a = target)[traitFunction.propertyKey].apply(_a, args);
}
else {
return fallback.apply(target, args);
}
}
function CallTraitMethodOrFallback(trait, target, methodName, args, fallback) {
var traitFunction = trait.get(methodName);
if (traitFunction === void 0) {
return fallback.apply(void 0, __spreadArrays([target], args));
}
else {
return CallTraitFunctionOrFallback(traitFunction, target, args, fallback);
}
}
//# sourceMappingURL=call-trait-function.js.map
var DERIVED_FUNCTION_TO_FUNCTION_MAP = new WeakMap();
var FUNCTION_TO_DERIVED_FUNCTIONS_MAP = new WeakMap();
function RegisterDerivedFunction(parentFunction, derivedFunction) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(derivedFunction)) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction) !== parentFunction) {
throw new Error("Derived function already registered as derived from: " + String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction)));
}
}
else if (IsFunctionDerivedFrom(parentFunction, derivedFunction)) {
throw new Error("Derived function already registered as derived from: " + String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction)));
}
else {
Object.defineProperty(obj, TRAITS, {
value: new WeakSet(traits),
writable: false,
enumerable: false,
configurable: false,
DERIVED_FUNCTION_TO_FUNCTION_MAP.set(derivedFunction, parentFunction);
if (FUNCTION_TO_DERIVED_FUNCTIONS_MAP.has(parentFunction)) {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.get(parentFunction).push(derivedFunction);
}
else {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.set(parentFunction, [derivedFunction]);
}
}
}
function IsFunctionDerivedFrom(functionToTest, parentFunction) {
while (true) {
if (functionToTest === parentFunction) {
return true;
}
else {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(functionToTest)) {
functionToTest = DERIVED_FUNCTION_TO_FUNCTION_MAP.get(functionToTest);
}
else {
return false;
}
}
}
}
function GetImplementForOptionsEnumerable(options) {
return ((options === void 0) || (options.enumerable === void 0)) ? false : options.enumerable;
}
function GetImplementForOptionsConfigurable(options) {
return ((options === void 0) || (options.configurable === void 0)) ? true : options.configurable;
}
function GetImplementForOptionsWritable(options) {
return ((options === void 0) || (options.writable === void 0)) ? false : options.writable;
}
function ImplementFunctionFor(target, propertyKey, functionToImplement, options) {
if ((propertyKey in target) && !IsFunctionOrParentImplementedBy(target, propertyKey, functionToImplement)) {
throw new Error("The property '" + String(propertyKey) + "' is already implemented");
}
else {
Object.defineProperty(target, propertyKey, {
value: functionToImplement,
enumerable: GetImplementForOptionsEnumerable(options),
configurable: GetImplementForOptionsConfigurable(options),
writable: GetImplementForOptionsWritable(options),
});
}
return target;
}
function ImplementTraits(obj, traits) {
RegisterTraits(obj, traits);
for (var i = 0, l = traits.length; i < l; i++) {
var trait = traits[i];
if ((trait !== null)
&& (typeof trait === 'object')
&& (Object.getPrototypeOf(trait) === Object.prototype)) {
var iterator = GetOwnPropertyDescriptors(trait);
var result = void 0;
while (!(result = iterator.next()).done) {
var _a = result.value, propertyKey = _a[0], descriptor = _a[1];
if ((propertyKey !== 'constructor') && (propertyKey !== TRAITS)) {
if (ObjectHasOwnProperty(obj, propertyKey)) {
throw new Error("The property '" + String(propertyKey) + "' is already implemented");
function IsFunctionOrDerivedImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(target[propertyKey], functionToTest);
}
function IsFunctionOrParentImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(functionToTest, target[propertyKey]);
}
var DerivableFunction = (function () {
function DerivableFunction(fnc) {
this.fnc = fnc;
}
DerivableFunction.prototype.derive = function (fnc) {
RegisterDerivedFunction(this.fnc, fnc);
return new DerivableFunction(fnc);
};
DerivableFunction.prototype.call = function (instance) {
var _a;
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return (_a = this.fnc).call.apply(_a, __spreadArrays([instance], args));
};
DerivableFunction.prototype.isDerivedFrom = function (derivableFunction) {
return IsFunctionDerivedFrom(this.fnc, derivableFunction.fnc);
};
DerivableFunction.prototype.equals = function (derivableFunction) {
return derivableFunction.fnc === this.fnc;
};
return DerivableFunction;
}());
//# sourceMappingURL=derivable-function-class.js.map
var TraitFunction = (function (_super) {
__extends(TraitFunction, _super);
function TraitFunction(propertyKey, fnc, options) {
var _this = _super.call(this, fnc) || this;
_this.propertyKey = propertyKey;
_this.enumerable = GetImplementForOptionsEnumerable(options);
_this.configurable = GetImplementForOptionsConfigurable(options);
_this.writable = GetImplementForOptionsWritable(options);
return _this;
}
TraitFunction.prototype.derive = function (derivedFunction, options) {
RegisterDerivedFunction(this.fnc, derivedFunction);
return new TraitFunction(this.propertyKey, derivedFunction, __assign({ enumerable: this.enumerable, configurable: this.configurable, writable: this.writable }, options));
};
TraitFunction.prototype.derivedFrom = function (parentFunction, options) {
RegisterDerivedFunction(parentFunction, this.fnc);
return new TraitFunction(this.propertyKey, parentFunction, __assign({ enumerable: this.enumerable, configurable: this.configurable, writable: this.writable }, options));
};
TraitFunction.prototype.implementFor = function (target, options) {
return ImplementFunctionFor(target, this.propertyKey, this.fnc, __assign({ enumerable: this.enumerable, configurable: this.configurable, writable: this.writable }, options));
};
TraitFunction.prototype.isImplementedBy = function (target) {
return IsFunctionOrDerivedImplementedBy(target, this.propertyKey, this.fnc);
};
TraitFunction.prototype.equals = function (traitFunction) {
return _super.prototype.equals.call(this, traitFunction)
&& (traitFunction.propertyKey === this.propertyKey);
};
return TraitFunction;
}(DerivableFunction));
//# sourceMappingURL=trait-function-class.js.map
var Trait = (function () {
function Trait(traitFunctions) {
this.traitFunctions = Object.freeze(Array.from(traitFunctions));
for (var i = 0, l = this.traitFunctions.length - 1; i < l; i++) {
var traitFunction = this.traitFunctions[i];
for (var j = i + 1; j <= l; j++) {
if (traitFunction.propertyKey === this.traitFunctions[j].propertyKey) {
throw new Error("Received two TraitFunction with the same property key '" + String(traitFunction.propertyKey) + "' at index " + i + " and " + j);
}
}
}
}
Trait.mix = function () {
var traits = [];
for (var _i = 0; _i < arguments.length; _i++) {
traits[_i] = arguments[_i];
}
return new Trait((traits
.map(function (trait) {
return trait.traitFunctions;
})
.flat()));
};
Trait.prototype.get = function (propertyKey) {
return this.traitFunctions.find(function (traitFunction) {
return traitFunction.propertyKey === propertyKey;
});
};
Trait.prototype.derive = function (traitFunctions) {
var traitFunctionsAsArray = Array.isArray(traitFunctions)
? traitFunctions
: Array.from(traitFunctions);
return new Trait((this.traitFunctions
.filter(function (traitFunctionA) {
return traitFunctionsAsArray.every(function (traitFunctionB, index) {
if (traitFunctionA.propertyKey === traitFunctionB.propertyKey) {
if (traitFunctionB.isDerivedFrom(traitFunctionA)) {
return false;
}
else {
Object.defineProperty(obj, propertyKey, descriptor);
throw new Error("Received a new TraitFunction with the property key '" + String(traitFunctionB.propertyKey) + "' at index " + index + ", which already exists in this Trait and is not derived from the original");
}
}
else {
return true;
}
});
})
.concat(traitFunctionsAsArray)));
};
Trait.prototype.implementFor = function (target) {
for (var i = 0, l = this.traitFunctions.length; i < l; i++) {
this.traitFunctions[i].implementFor(target);
}
return target;
};
Trait.prototype.isImplementedBy = function (target) {
for (var i = 0, l = this.traitFunctions.length; i < l; i++) {
if (!this.traitFunctions[i].isImplementedBy(target)) {
return false;
}
}
return true;
};
Trait.prototype.isDerivedFrom = function (trait) {
if (trait.traitFunctions.length >= this.traitFunctions.length) {
return this.traitFunctions.every(function (traitFunctionA) {
return trait.traitFunctions.some(function (traitFunctionB) {
return traitFunctionA.isDerivedFrom(traitFunctionB);
});
});
}
else {
throw new Error("The trait must be a plain object");
return false;
}
};
Trait.prototype.equals = function (trait) {
if (trait.traitFunctions.length === this.traitFunctions.length) {
return this.traitFunctions.every(function (traitFunctionA) {
return trait.traitFunctions.some(function (traitFunctionB) {
return traitFunctionA.equals(traitFunctionB);
});
});
}
else {
return false;
}
};
return Trait;
}());
function TraitFunctionsFromObject(target, parentTraitFunctionsMap) {
if (parentTraitFunctionsMap === void 0) { parentTraitFunctionsMap = new Map(); }
var iterator = GetOwnPropertyDescriptors(target);
var result;
while (!(result = iterator.next()).done) {
var _a = result.value, propertyKey = _a[0], descriptor = _a[1];
if (IsNotPrimitivePropertyName(propertyKey)) {
if (typeof descriptor.value === 'function') {
parentTraitFunctionsMap.set(propertyKey, ((parentTraitFunctionsMap.has(propertyKey))
? parentTraitFunctionsMap.get(propertyKey).derive(descriptor.value, descriptor)
: new TraitFunction(propertyKey, descriptor.value, descriptor)));
}
else {
throw new Error("Found property which is not a function: '" + String(propertyKey) + "'");
}
}
}
return obj;
return parentTraitFunctionsMap;
}
function SuperTrait(traits, baseClass) {
var TraitClass = (function (_super) {
function TraitFunctionsFromObjectPrototypeChain(target) {
var prototypes = Array.from(GetPrototypesChain(target)).filter(IsNotPrimitivePrototype).reverse();
var parentTraitFunctionsMap = new Map();
for (var i = 0, li = prototypes.length; i < li; i++) {
TraitFunctionsFromObject(prototypes[i], parentTraitFunctionsMap);
}
return parentTraitFunctionsMap;
}
function TraitFunctionsFromClass(_class) {
return TraitFunctionsFromObjectPrototypeChain(_class.prototype);
}
function TraitFromClass(_class) {
return new Trait(TraitFunctionsFromClass(_class).values());
}
function SuperTrait(trait, baseClass) {
var TraitClass = (baseClass === void 0)
? (function () {
function TraitClass() {
}
return TraitClass;
}()) : (function (_super) {
__extends(TraitClass, _super);

@@ -611,38 +891,44 @@ function TraitClass() {

}(baseClass));
ImplementTraits(TraitClass.prototype, traits);
trait.implementFor(TraitClass.prototype);
return TraitClass;
}
function ImplementsTrait(obj, trait) {
if ((obj !== null)
&& (typeof obj === 'object')) {
if (ObjectHasOwnProperty(obj, TRAITS)
&& obj[TRAITS].has(trait)) {
return true;
//# sourceMappingURL=super-trait.js.map
function AbstractMethod() {
return function (target, propertyKey, descriptor) {
if (descriptor === void 0) { descriptor = Object.getOwnPropertyDescriptor(target, propertyKey); }
if (descriptor === void 0) {
return {
configurable: false,
writable: false,
value: CreateAbstractMethod(propertyKey),
};
}
else {
return ImplementsTrait(Object.getPrototypeOf(obj), trait);
throw new TypeError("@AbstractProperty: the property '" + String(propertyKey) + "' should not be defined.");
}
}
else {
return false;
}
};
}
function ImplementsTraits(obj, traits) {
return traits.every(function (trait) { return ImplementsTrait(obj, trait); });
function CreateAbstractMethod(propertyKey) {
return function () {
AbstractMethodCall(propertyKey);
};
}
function TraitFromClass(classTrait) {
return classTrait.prototype;
function CreateAbstractMethodCallError(propertyKey) {
return (propertyKey === void 0)
? new Error("Cannot call an abstract method")
: new Error("Cannot call the abstract method '" + String(propertyKey) + "'");
}
function TraitsFromClasses() {
var classTrait = [];
for (var _i = 0; _i < arguments.length; _i++) {
classTrait[_i] = arguments[_i];
}
return classTrait.map(TraitFromClass);
function AbstractMethodCall(propertyKey) {
throw CreateAbstractMethodCallError(propertyKey);
}
//# sourceMappingURL=traits.js.map
exports.AbstractMethod = AbstractMethod;
exports.AbstractMethodCall = AbstractMethodCall;
exports.BaseClass = BaseClass;
exports.BindDescriptor = BindDescriptor;
exports.BindDescriptorOld = BindDescriptorOld;
exports.CallTraitFunctionAsMethod = CallTraitFunctionAsMethod;
exports.CallTraitFunctionOrFallback = CallTraitFunctionOrFallback;
exports.CallTraitMethodOrFallback = CallTraitMethodOrFallback;
exports.ClassToFactory = ClassToFactory;

@@ -657,21 +943,37 @@ exports.ConstructClassWithPrivateMembers = ConstructClassWithPrivateMembers;

exports.CopyProperties = CopyProperties;
exports.CreateAbstractMethod = CreateAbstractMethod;
exports.CreateAbstractMethodCallError = CreateAbstractMethodCallError;
exports.DERIVED_FUNCTION_TO_FUNCTION_MAP = DERIVED_FUNCTION_TO_FUNCTION_MAP;
exports.DerivableFunction = DerivableFunction;
exports.EXCLUDED_PROPERTY_NAMES = EXCLUDED_PROPERTY_NAMES;
exports.FUNCTION_TO_DERIVED_FUNCTIONS_MAP = FUNCTION_TO_DERIVED_FUNCTIONS_MAP;
exports.GenerateOverrideSuperArgumentsFunction = GenerateOverrideSuperArgumentsFunction;
exports.GetImplementForOptionsConfigurable = GetImplementForOptionsConfigurable;
exports.GetImplementForOptionsEnumerable = GetImplementForOptionsEnumerable;
exports.GetImplementForOptionsWritable = GetImplementForOptionsWritable;
exports.GetOwnPropertyDescriptors = GetOwnPropertyDescriptors;
exports.GetOwnPropertyKeys = GetOwnPropertyKeys;
exports.GetPropertyDescriptors = GetPropertyDescriptors;
exports.GetPrototypesChain = GetPrototypesChain;
exports.GetSafePropertyDescriptors = GetSafePropertyDescriptors;
exports.GetSetSuperArgsFunction = GetSetSuperArgsFunction;
exports.HasFactoryWaterMark = HasFactoryWaterMark;
exports.ImplementTraits = ImplementTraits;
exports.ImplementsTrait = ImplementsTrait;
exports.ImplementsTraits = ImplementsTraits;
exports.HasOwnProperty = HasOwnProperty;
exports.ImplementFunctionFor = ImplementFunctionFor;
exports.IsFactoryClass = IsFactoryClass;
exports.IsFunctionDerivedFrom = IsFunctionDerivedFrom;
exports.IsFunctionOrDerivedImplementedBy = IsFunctionOrDerivedImplementedBy;
exports.IsFunctionOrParentImplementedBy = IsFunctionOrParentImplementedBy;
exports.IsInstanceOf = IsInstanceOf;
exports.IsNotPrimitivePropertyName = IsNotPrimitivePropertyName;
exports.IsNotPrimitivePrototype = IsNotPrimitivePrototype;
exports.IsPrimitivePropertyName = IsPrimitivePropertyName;
exports.IsPrimitivePrototype = IsPrimitivePrototype;
exports.MakeFactory = MakeFactory;
exports.MixOverrideSuperArgumentsFunction = MixOverrideSuperArgumentsFunction;
exports.ObjectHasOwnProperty = ObjectHasOwnProperty;
exports.OwnArguments = OwnArguments;
exports.PRIMITIVE_PROPERTY_NAMES = PRIMITIVE_PROPERTY_NAMES;
exports.PRIMITIVE_PROTOTYPES = PRIMITIVE_PROTOTYPES;
exports.PROTECTED = PROTECTED;
exports.RegisterTraits = RegisterTraits;
exports.RegisterDerivedFunction = RegisterDerivedFunction;
exports.SearchSuperClass = SearchSuperClass;

@@ -684,5 +986,8 @@ exports.SetClassName = SetClassName;

exports.SuperTrait = SuperTrait;
exports.TRAITS = TRAITS;
exports.Trait = Trait;
exports.TraitFromClass = TraitFromClass;
exports.TraitsFromClasses = TraitsFromClasses;
exports.TraitFunction = TraitFunction;
exports.TraitFunctionsFromClass = TraitFunctionsFromClass;
exports.TraitFunctionsFromObject = TraitFunctionsFromObject;
exports.TraitFunctionsFromObjectPrototypeChain = TraitFunctionsFromObjectPrototypeChain;

@@ -689,0 +994,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

4

bundles/class-factory.core.umd.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],t):t((e=e||self)["class-factory"]={})}(this,(function(e){"use strict";var t=function(){},r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],e):e((t=t||self)["class-factory"]={})}(this,(function(t){"use strict";var e=function(){},r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};
/*! *****************************************************************************

@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. All rights reserved.

and limitations under the License.
***************************************************************************** */function n(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function o(e,t){var r,n,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}var a=Symbol("instanceof");function c(e,t){var r=Symbol.hasInstance in e?e[Symbol.hasInstance].bind(e):function(){return!1};Object.defineProperty(e,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value:function(e){return e instanceof t||r(e)}}),a in t||Object.defineProperty(t,a,{value:new Set}),t[a].add(e)}var i=new Set(function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],c=0,i=a.length;c<i;c++,o++)n[o]=a[c];return n}(["prototype","constructor"],u(Object.prototype)));function u(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}function s(e){var t,r,n,a;return o(this,(function(o){switch(o.label){case 0:t=u(e),r=0,n=t.length,o.label=1;case 1:return r<n?[4,[a=t[r],Object.getOwnPropertyDescriptor(e,a),e]]:[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}function l(e){var t,r,n,a,c;return o(this,(function(o){switch(o.label){case 0:t=new Set,o.label=1;case 1:if(null===e)return[3,6];r=u(e),n=0,a=r,o.label=2;case 2:return n<a.length?(c=a[n],t.has(c)?[3,4]:(t.add(c),[4,[c,Object.getOwnPropertyDescriptor(e,c),e]])):[3,5];case 3:o.sent(),o.label=4;case 4:return n++,[3,2];case 5:return e=Object.getPrototypeOf(e),[3,1];case 6:return[2]}}))}function f(e,t,r){void 0===r&&(r=i);for(var n,o=l(e);!(n=o.next()).done;){var a=n.value,c=a[0],u=a[1];r.has(c)||Object.defineProperty(t,c,u)}}function p(e,t,r){f(e.prototype,t.prototype,r)}function y(e,t,r){f(e,t,r)}function b(e,t){Object.defineProperty(e,"name",{configurable:!0,enumerable:!1,value:t,writable:!1})}function v(e,t){p(e,t),y(e,t),c(e,t)}function d(e,t,r){var n,o,a={};(a.configurable=r.configurable,a.enumerable=r.enumerable,void 0!==r.value)?(a.get=function(){return"function"==typeof e[t]?(n!==e[t]&&(n=e[t],o=n.bind(e)),o):e[t]},r.writable&&(a.set=function(r){e[t]=r})):("function"==typeof r.get&&(a.get=r.get.bind(e)),"function"==typeof r.set&&(a.set=r.set.bind(e)));return a}function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O=Symbol("is-factory-class");function g(e,t){return void 0===t&&(t=!0),!0===e[O]&&(!t||e.hasOwnProperty(O))}function m(e,t){for(var r=0;null!==e;){if(t(e))return{index:r,ctor:e};r++,e=Object.getPrototypeOf(e)}return null}function w(e,t){if(Array.isArray(e[0]))return e[0]=t,e;throw new TypeError("Expected array as argument 0")}function P(e,t){for(var r=0,n=t.length;r<n;r++)e[r]=t[r];return e}var j=Symbol("protected");var S=Symbol("traits");function C(e,t){if(h(e,S))for(var r=e[S],n=0,o=t.length;n<o;n++)r.add(t[n]);else Object.defineProperty(e,S,{value:new WeakSet(t),writable:!1,enumerable:!1,configurable:!1})}function T(e,t){C(e,t);for(var r=0,n=t.length;r<n;r++){var o=t[r];if(null===o||"object"!=typeof o||Object.getPrototypeOf(o)!==Object.prototype)throw new Error("The trait must be a plain object");for(var a=s(o),c=void 0;!(c=a.next()).done;){var i=c.value,u=i[0],l=i[1];if("constructor"!==u&&u!==S){if(h(e,u))throw new Error("The property '"+String(u)+"' is already implemented");Object.defineProperty(e,u,l)}}}return e}function A(e,t){return null!==e&&"object"==typeof e&&(!(!h(e,S)||!e[S].has(t))||A(Object.getPrototypeOf(e),t))}function x(e){return e.prototype}e.BaseClass=t,e.BindDescriptor=function(e,t,r){var n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){var o=new WeakMap;n.get=function(){var r=e(this),n=Reflect.get(r,t);return"function"==typeof n?(o.has(n)||o.set(n,n.bind(r)),o.get(n)):n},r.writable&&(n.set=function(r){var n=e(this);Reflect.set(n,t,r)})}else"function"==typeof r.get&&(n.get=function(){var t=e(this);return r.get.call(t)}),"function"==typeof r.set&&(n.set=function(t){var n=e(this);return r.set.call(n,t)});return n},e.BindDescriptorOld=d,e.ClassToFactory=function(e){return function(r,o){var a;return void 0===o&&(o="auto"),r===Object||r===t?c(r,a=function(e){function t(t){return e.apply(this,t)||this}return n(t,e),t}(e)):(a=function(t){function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var a,c=this,s=r[0];switch(c=t.apply(this,r.slice(1))||this,o){case"auto":try{void 0===(a=e.apply(c,s))&&(a=c),o="function"}catch(t){a=Reflect.construct(e,s),o="class"}break;case"function":void 0===(a=e.apply(c,s))&&(a=c);break;case"class":a=Reflect.construct(e,s)}if(c!==a){for(var f=l(Object.getPrototypeOf(a)),p=void 0;!(p=f.next()).done;){var y=p.value[0];i.has(y)||Object.defineProperty(c,y,d(a,y,p.value[1]))}for(var b=u(a),v=0,h=b;v<h.length;v++){y=h[v];i.has(y)||(y in c&&console.warn("Crossing properties !"),Object.defineProperty(c,y,d(a,y,Object.getOwnPropertyDescriptor(a,y))))}Object.seal(a)}return c}return n(r,t),r}(r),v(e,a)),b(a,e.name),a}},e.ConstructClassWithPrivateMembers=function(e,t){Object.defineProperty(e,t,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.ConstructClassWithProtectedMembers=function(e){Object.defineProperty(e,j,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.CopyClass=v,e.CopyClassName=function(e,t){var r=Object.getOwnPropertyDescriptor(e,"name");void 0===r?r={configurable:!0,enumerable:!1,value:e.name,writable:!1}:r.value=e.name,r.configurable&&Object.defineProperty(t,"name",r)},e.CopyClassPrototype=p,e.CopyClassStaticProperties=y,e.CopyOwnProperties=function(e,t,r){void 0===r&&(r=i);for(var n=0,o=u(e);n<o.length;n++){var a=o[n],c=Object.getOwnPropertyDescriptor(e,a);void 0===c||r.has(a)||Object.defineProperty(t,a,c)}},e.CopyProperties=f,e.EXCLUDED_PROPERTY_NAMES=i,e.GenerateOverrideSuperArgumentsFunction=function(e,t){var r=m(e,t);if(null===r)throw new Error("Failed to find super class of the class "+e.name);var n=r.index;return g(r.ctor)?function(e,t){if(Array.isArray(e[n]))return e.slice(0,n).concat([t(e[n])]).concat(e.slice(n+1));throw new TypeError("Expected array as argument["+n+"]")}:function(e,t){return e.slice(0,n).concat(t(e.slice(n)))}},e.GetOwnPropertyDescriptors=s,e.GetOwnPropertyKeys=u,e.GetPropertyDescriptors=l,e.GetSafePropertyDescriptors=function(e){var t,r,n,a,c;return o(this,(function(o){switch(o.label){case 0:t=l(e),o.label=1;case 1:return(r=t.next()).done?[3,4]:(n=r.value,a=n[0],(c=n[2])===Object.prototype||c===Function.prototype||i.has(a)?[3,3]:[4,r.value]);case 2:o.sent(),o.label=3;case 3:return[3,1];case 4:return[2]}}))},e.GetSetSuperArgsFunction=function(e){return e?w:P},e.HasFactoryWaterMark=function(e,t,r){return void 0===r&&(r=!0),!0===e[t]&&(!r||e.hasOwnProperty(t))},e.ImplementTraits=T,e.ImplementsTrait=A,e.ImplementsTraits=function(e,t){return t.every((function(t){return A(e,t)}))},e.IsFactoryClass=g,e.IsInstanceOf=function(e,t){return e instanceof t||!(!e.constructor||!(a in e.constructor))&&e.constructor[a].has(t)},e.MakeFactory=function(e,t,r,n){void 0===n&&(n={});for(var o=r,a=t.length-1;a>=0;a--)o=t[a](o);var i=e(o);if(Object.defineProperty(i,O,{value:!0}),"string"==typeof n.name&&Object.defineProperty(i,"name",{configurable:!0,enumerable:!1,value:n.name,writable:!1}),Array.isArray(n.waterMarks)){a=0;for(var u=n.waterMarks.length;a<u;a++)Object.defineProperty(i,n.waterMarks[a],{value:!0})}return void 0!==n.instanceOf&&c(n.instanceOf,i),i},e.MixOverrideSuperArgumentsFunction=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];for(var o=0,a=e.length;o<a;o++)t=e[o](t,r[o]);return t}},e.ObjectHasOwnProperty=h,e.OwnArguments=function(e){return e[0]},e.PROTECTED=j,e.RegisterTraits=C,e.SearchSuperClass=m,e.SetClassName=b,e.SetInstanceOf=c,e.SetSuperArgsForFactoryClass=w,e.SetSuperArgsForStandardClass=P,e.SuperArguments=function(e){return e.slice(1)},e.SuperTrait=function(e,t){var r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(t);return T(r.prototype,e),r},e.TRAITS=S,e.TraitFromClass=x,e.TraitsFromClasses=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.map(x)},Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */function n(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function a(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],a=0,u=i.length;a<u;a++,o++)n[o]=i[a];return n}var u=Symbol("instanceof");function c(t,e){var r=Symbol.hasInstance in t?t[Symbol.hasInstance].bind(t):function(){return!1};Object.defineProperty(t,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value:function(t){return t instanceof e||r(t)}}),u in e||Object.defineProperty(e,u,{value:new Set}),e[u].add(t)}function s(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}function f(t){var e,r,n,o;return i(this,(function(i){switch(i.label){case 0:e=s(t),r=0,n=e.length,i.label=1;case 1:return r<n?[4,[o=e[r],Object.getOwnPropertyDescriptor(t,o),t]]:[3,4];case 2:i.sent(),i.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}var l=new Set(["prototype","constructor"]);function p(t){return l.has(t)}function y(t){return!p(t)}function h(t){return i(this,(function(e){switch(e.label){case 0:return null===t?[3,2]:[4,t];case 1:return e.sent(),t=Object.getPrototypeOf(t),[3,0];case 2:return[2]}}))}var b=new Set(["",0,{},[],function(){}].map((function(t){return Object.getPrototypeOf(t)})));function v(t){return b.has(t)}function d(t){return!v(t)}var m=new Set(a(["prototype","constructor"],s(Object.prototype)));function g(t){var e,r,n,o,a;return i(this,(function(i){switch(i.label){case 0:e=new Set,i.label=1;case 1:if(null===t)return[3,6];r=s(t),n=0,o=r,i.label=2;case 2:return n<o.length?(a=o[n],e.has(a)?[3,4]:(e.add(a),[4,[a,Object.getOwnPropertyDescriptor(t,a),t]])):[3,5];case 3:i.sent(),i.label=4;case 4:return n++,[3,2];case 5:return t=Object.getPrototypeOf(t),[3,1];case 6:return[2]}}))}function w(t,e,r){void 0===r&&(r=m);for(var n,o=g(t);!(n=o.next()).done;){var i=n.value,a=i[0],u=i[1];r.has(a)||Object.defineProperty(e,a,u)}}function O(t,e,r){w(t.prototype,e.prototype,r)}function F(t,e,r){w(t,e,r)}function P(t,e){Object.defineProperty(t,"name",{configurable:!0,enumerable:!1,value:e,writable:!1})}function S(t,e){O(t,e),F(t,e),c(t,e)}function C(t,e,r){var n,o,i={};(i.configurable=r.configurable,i.enumerable=r.enumerable,void 0!==r.value)?(i.get=function(){return"function"==typeof t[e]?(n!==t[e]&&(n=t[e],o=n.bind(t)),o):t[e]},r.writable&&(i.set=function(r){t[e]=r})):("function"==typeof r.get&&(i.get=r.get.bind(t)),"function"==typeof r.set&&(i.set=r.set.bind(t)));return i}var j=Symbol("is-factory-class");function I(t,e){return void 0===e&&(e=!0),!0===t[j]&&(!e||t.hasOwnProperty(j))}function T(t,e){for(var r=0;null!==t;){if(e(t))return{index:r,ctor:t};r++,t=Object.getPrototypeOf(t)}return null}function E(t,e){if(Array.isArray(t[0]))return t[0]=e,t;throw new TypeError("Expected array as argument 0")}function A(t,e){for(var r=0,n=e.length;r<n;r++)t[r]=e[r];return t}var D=Symbol("protected");function M(t,e,r,n){var o;return t.isImplementedBy(e)?(o=e)[t.propertyKey].apply(o,r):n.apply(e,r)}var _=new WeakMap,x=new WeakMap;function k(t,e){if(_.has(e)){if(_.get(e)!==t)throw new Error("Derived function already registered as derived from: "+String(_.get(e)))}else{if(K(t,e))throw new Error("Derived function already registered as derived from: "+String(_.get(e)));_.set(e,t),x.has(t)?x.get(t).push(e):x.set(t,[e])}}function K(t,e){for(;;){if(t===e)return!0;if(!_.has(t))return!1;t=_.get(t)}}function N(t){return void 0!==t&&void 0!==t.enumerable&&t.enumerable}function R(t){return void 0===t||void 0===t.configurable||t.configurable}function G(t){return void 0!==t&&void 0!==t.writable&&t.writable}function B(t,e,r,n){if(e in t&&!q(t,e,r))throw new Error("The property '"+String(e)+"' is already implemented");return Object.defineProperty(t,e,{value:r,enumerable:N(n),configurable:R(n),writable:G(n)}),t}function W(t,e,r){return"function"==typeof t[e]&&K(t[e],r)}function q(t,e,r){return"function"==typeof t[e]&&K(r,t[e])}var U=function(){function t(t){this.fnc=t}return t.prototype.derive=function(e){return k(this.fnc,e),new t(e)},t.prototype.call=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return(e=this.fnc).call.apply(e,a([t],r))},t.prototype.isDerivedFrom=function(t){return K(this.fnc,t.fnc)},t.prototype.equals=function(t){return t.fnc===this.fnc},t}(),V=function(t){function e(e,r,n){var o=t.call(this,r)||this;return o.propertyKey=e,o.enumerable=N(n),o.configurable=R(n),o.writable=G(n),o}return n(e,t),e.prototype.derive=function(t,r){return k(this.fnc,t),new e(this.propertyKey,t,o({enumerable:this.enumerable,configurable:this.configurable,writable:this.writable},r))},e.prototype.derivedFrom=function(t,r){return k(t,this.fnc),new e(this.propertyKey,t,o({enumerable:this.enumerable,configurable:this.configurable,writable:this.writable},r))},e.prototype.implementFor=function(t,e){return B(t,this.propertyKey,this.fnc,o({enumerable:this.enumerable,configurable:this.configurable,writable:this.writable},e))},e.prototype.isImplementedBy=function(t){return W(t,this.propertyKey,this.fnc)},e.prototype.equals=function(e){return t.prototype.equals.call(this,e)&&e.propertyKey===this.propertyKey},e}(U),Y=function(){function t(t){this.traitFunctions=Object.freeze(Array.from(t));for(var e=0,r=this.traitFunctions.length-1;e<r;e++)for(var n=this.traitFunctions[e],o=e+1;o<=r;o++)if(n.propertyKey===this.traitFunctions[o].propertyKey)throw new Error("Received two TraitFunction with the same property key '"+String(n.propertyKey)+"' at index "+e+" and "+o)}return t.mix=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return new t(e.map((function(t){return t.traitFunctions})).flat())},t.prototype.get=function(t){return this.traitFunctions.find((function(e){return e.propertyKey===t}))},t.prototype.derive=function(e){var r=Array.isArray(e)?e:Array.from(e);return new t(this.traitFunctions.filter((function(t){return r.every((function(e,r){if(t.propertyKey===e.propertyKey){if(e.isDerivedFrom(t))return!1;throw new Error("Received a new TraitFunction with the property key '"+String(e.propertyKey)+"' at index "+r+", which already exists in this Trait and is not derived from the original")}return!0}))})).concat(r))},t.prototype.implementFor=function(t){for(var e=0,r=this.traitFunctions.length;e<r;e++)this.traitFunctions[e].implementFor(t);return t},t.prototype.isImplementedBy=function(t){for(var e=0,r=this.traitFunctions.length;e<r;e++)if(!this.traitFunctions[e].isImplementedBy(t))return!1;return!0},t.prototype.isDerivedFrom=function(t){return t.traitFunctions.length>=this.traitFunctions.length&&this.traitFunctions.every((function(e){return t.traitFunctions.some((function(t){return e.isDerivedFrom(t)}))}))},t.prototype.equals=function(t){return t.traitFunctions.length===this.traitFunctions.length&&this.traitFunctions.every((function(e){return t.traitFunctions.some((function(t){return e.equals(t)}))}))},t}();function H(t,e){void 0===e&&(e=new Map);for(var r,n=f(t);!(r=n.next()).done;){var o=r.value,i=o[0],a=o[1];if(y(i)){if("function"!=typeof a.value)throw new Error("Found property which is not a function: '"+String(i)+"'");e.set(i,e.has(i)?e.get(i).derive(a.value,a):new V(i,a.value,a))}}return e}function z(t){for(var e=Array.from(h(t)).filter(d).reverse(),r=new Map,n=0,o=e.length;n<o;n++)H(e[n],r);return r}function L(t){return z(t.prototype)}function X(t){return function(){Q(t)}}function J(t){return void 0===t?new Error("Cannot call an abstract method"):new Error("Cannot call the abstract method '"+String(t)+"'")}function Q(t){throw J(t)}t.AbstractMethod=function(){return function(t,e,r){if(void 0===r&&(r=Object.getOwnPropertyDescriptor(t,e)),void 0===r)return{configurable:!1,writable:!1,value:X(e)};throw new TypeError("@AbstractProperty: the property '"+String(e)+"' should not be defined.")}},t.AbstractMethodCall=Q,t.BaseClass=e,t.BindDescriptor=function(t,e,r){var n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){var o=new WeakMap;n.get=function(){var r=t(this),n=Reflect.get(r,e);return"function"==typeof n?(o.has(n)||o.set(n,n.bind(r)),o.get(n)):n},r.writable&&(n.set=function(r){var n=t(this);Reflect.set(n,e,r)})}else"function"==typeof r.get&&(n.get=function(){var e=t(this);return r.get.call(e)}),"function"==typeof r.set&&(n.set=function(e){var n=t(this);return r.set.call(n,e)});return n},t.BindDescriptorOld=C,t.CallTraitFunctionAsMethod=function(t,e,r){var n;return t.isImplementedBy(e)?(n=e)[t.propertyKey].apply(n,r):t.fnc.apply(e,r)},t.CallTraitFunctionOrFallback=M,t.CallTraitMethodOrFallback=function(t,e,r,n,o){var i=t.get(r);return void 0===i?o.apply(void 0,a([e],n)):M(i,e,n,o)},t.ClassToFactory=function(t){return function(r,o){var i;return void 0===o&&(o="auto"),r===Object||r===e?c(r,i=function(t){function e(e){return t.apply(this,e)||this}return n(e,t),e}(t)):(i=function(e){function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i,a=this,u=r[0];switch(a=e.apply(this,r.slice(1))||this,o){case"auto":try{void 0===(i=t.apply(a,u))&&(i=a),o="function"}catch(e){i=Reflect.construct(t,u),o="class"}break;case"function":void 0===(i=t.apply(a,u))&&(i=a);break;case"class":i=Reflect.construct(t,u)}if(a!==i){for(var c=g(Object.getPrototypeOf(i)),f=void 0;!(f=c.next()).done;){var l=f.value[0];m.has(l)||Object.defineProperty(a,l,C(i,l,f.value[1]))}for(var p=s(i),y=0,h=p;y<h.length;y++){l=h[y];m.has(l)||(l in a&&console.warn("Crossing properties !"),Object.defineProperty(a,l,C(i,l,Object.getOwnPropertyDescriptor(i,l))))}Object.seal(i)}return a}return n(r,e),r}(r),S(t,i)),P(i,t.name),i}},t.ConstructClassWithPrivateMembers=function(t,e){Object.defineProperty(t,e,{value:{},configurable:!1,writable:!1,enumerable:!1})},t.ConstructClassWithProtectedMembers=function(t){Object.defineProperty(t,D,{value:{},configurable:!1,writable:!1,enumerable:!1})},t.CopyClass=S,t.CopyClassName=function(t,e){var r=Object.getOwnPropertyDescriptor(t,"name");void 0===r?r={configurable:!0,enumerable:!1,value:t.name,writable:!1}:r.value=t.name,r.configurable&&Object.defineProperty(e,"name",r)},t.CopyClassPrototype=O,t.CopyClassStaticProperties=F,t.CopyOwnProperties=function(t,e,r){void 0===r&&(r=m);for(var n=0,o=s(t);n<o.length;n++){var i=o[n],a=Object.getOwnPropertyDescriptor(t,i);void 0===a||r.has(i)||Object.defineProperty(e,i,a)}},t.CopyProperties=w,t.CreateAbstractMethod=X,t.CreateAbstractMethodCallError=J,t.DERIVED_FUNCTION_TO_FUNCTION_MAP=_,t.DerivableFunction=U,t.EXCLUDED_PROPERTY_NAMES=m,t.FUNCTION_TO_DERIVED_FUNCTIONS_MAP=x,t.GenerateOverrideSuperArgumentsFunction=function(t,e){var r=T(t,e);if(null===r)throw new Error("Failed to find super class of the class "+t.name);var n=r.index;return I(r.ctor)?function(t,e){if(Array.isArray(t[n]))return t.slice(0,n).concat([e(t[n])]).concat(t.slice(n+1));throw new TypeError("Expected array as argument["+n+"]")}:function(t,e){return t.slice(0,n).concat(e(t.slice(n)))}},t.GetImplementForOptionsConfigurable=R,t.GetImplementForOptionsEnumerable=N,t.GetImplementForOptionsWritable=G,t.GetOwnPropertyDescriptors=f,t.GetOwnPropertyKeys=s,t.GetPropertyDescriptors=g,t.GetPrototypesChain=h,t.GetSafePropertyDescriptors=function(t){var e,r,n,o,a;return i(this,(function(i){switch(i.label){case 0:e=g(t),i.label=1;case 1:return(r=e.next()).done?[3,4]:(n=r.value,o=n[0],(a=n[2])===Object.prototype||a===Function.prototype||m.has(o)?[3,3]:[4,r.value]);case 2:i.sent(),i.label=3;case 3:return[3,1];case 4:return[2]}}))},t.GetSetSuperArgsFunction=function(t){return t?E:A},t.HasFactoryWaterMark=function(t,e,r){return void 0===r&&(r=!0),!0===t[e]&&(!r||t.hasOwnProperty(e))},t.HasOwnProperty=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t.ImplementFunctionFor=B,t.IsFactoryClass=I,t.IsFunctionDerivedFrom=K,t.IsFunctionOrDerivedImplementedBy=W,t.IsFunctionOrParentImplementedBy=q,t.IsInstanceOf=function(t,e){return t instanceof e||!(!t.constructor||!(u in t.constructor))&&t.constructor[u].has(e)},t.IsNotPrimitivePropertyName=y,t.IsNotPrimitivePrototype=d,t.IsPrimitivePropertyName=p,t.IsPrimitivePrototype=v,t.MakeFactory=function(t,e,r,n){void 0===n&&(n={});for(var o=r,i=e.length-1;i>=0;i--)o=e[i](o);var a=t(o);if(Object.defineProperty(a,j,{value:!0}),"string"==typeof n.name&&Object.defineProperty(a,"name",{configurable:!0,enumerable:!1,value:n.name,writable:!1}),Array.isArray(n.waterMarks)){i=0;for(var u=n.waterMarks.length;i<u;i++)Object.defineProperty(a,n.waterMarks[i],{value:!0})}return void 0!==n.instanceOf&&c(n.instanceOf,a),a},t.MixOverrideSuperArgumentsFunction=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];for(var o=0,i=t.length;o<i;o++)e=t[o](e,r[o]);return e}},t.OwnArguments=function(t){return t[0]},t.PRIMITIVE_PROPERTY_NAMES=l,t.PRIMITIVE_PROTOTYPES=b,t.PROTECTED=D,t.RegisterDerivedFunction=k,t.SearchSuperClass=T,t.SetClassName=P,t.SetInstanceOf=c,t.SetSuperArgsForFactoryClass=E,t.SetSuperArgsForStandardClass=A,t.SuperArguments=function(t){return t.slice(1)},t.SuperTrait=function(t,e){var r=void 0===e?function(){}:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(e);return t.implementFor(r.prototype),r},t.Trait=Y,t.TraitFromClass=function(t){return new Y(L(t).values())},t.TraitFunction=V,t.TraitFunctionsFromClass=L,t.TraitFunctionsFromObject=H,t.TraitFunctionsFromObjectPrototypeChain=z,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=class-factory.core.umd.min.js.map

@@ -37,3 +37,2 @@ (function (global, factory) {

const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
function GetOwnPropertyKeys(target) {

@@ -43,2 +42,5 @@ return Object.getOwnPropertyNames(target)

}
function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
function* GetOwnPropertyDescriptors(target) {

@@ -51,2 +53,23 @@ const keys = GetOwnPropertyKeys(target);

}
const PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
function IsPrimitivePropertyName(name) {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
function* GetPrototypesChain(target) {
while (target !== null) {
yield target;
target = Object.getPrototypeOf(target);
}
}
const PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], () => { }].map(_ => Object.getPrototypeOf(_)));
function IsPrimitivePrototype(proto) {
return PRIMITIVE_PROTOTYPES.has(proto);
}
function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
function* GetPropertyDescriptors(target) {

@@ -209,5 +232,2 @@ const _keys = new Set();

}
function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}

@@ -418,80 +438,324 @@ function MakeFactory(create, factories, superClass, options = {}) {

const TRAITS = Symbol('traits');
function RegisterTraits(obj, traits) {
if (ObjectHasOwnProperty(obj, TRAITS)) {
const _traits = obj[TRAITS];
for (let i = 0, l = traits.length; i < l; i++) {
_traits.add(traits[i]);
function CallTraitFunctionAsMethod(traitFunction, target, args) {
if (traitFunction.isImplementedBy(target)) {
return target[traitFunction.propertyKey](...args);
}
else {
return traitFunction.fnc.apply(target, args);
}
}
function CallTraitFunctionOrFallback(traitFunction, target, args, fallback) {
if (traitFunction.isImplementedBy(target)) {
return target[traitFunction.propertyKey](...args);
}
else {
return fallback.apply(target, args);
}
}
function CallTraitMethodOrFallback(trait, target, methodName, args, fallback) {
const traitFunction = trait.get(methodName);
if (traitFunction === void 0) {
return fallback(target, ...args);
}
else {
return CallTraitFunctionOrFallback(traitFunction, target, args, fallback);
}
}
const DERIVED_FUNCTION_TO_FUNCTION_MAP = new WeakMap();
const FUNCTION_TO_DERIVED_FUNCTIONS_MAP = new WeakMap();
function RegisterDerivedFunction(parentFunction, derivedFunction) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(derivedFunction)) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction) !== parentFunction) {
throw new Error(`Derived function already registered as derived from: ${String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction))}`);
}
}
else if (IsFunctionDerivedFrom(parentFunction, derivedFunction)) {
throw new Error(`Derived function already registered as derived from: ${String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction))}`);
}
else {
Object.defineProperty(obj, TRAITS, {
value: new WeakSet(traits),
writable: false,
enumerable: false,
configurable: false,
DERIVED_FUNCTION_TO_FUNCTION_MAP.set(derivedFunction, parentFunction);
if (FUNCTION_TO_DERIVED_FUNCTIONS_MAP.has(parentFunction)) {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.get(parentFunction).push(derivedFunction);
}
else {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.set(parentFunction, [derivedFunction]);
}
}
}
function IsFunctionDerivedFrom(functionToTest, parentFunction) {
while (true) {
if (functionToTest === parentFunction) {
return true;
}
else {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(functionToTest)) {
functionToTest = DERIVED_FUNCTION_TO_FUNCTION_MAP.get(functionToTest);
}
else {
return false;
}
}
}
}
function GetImplementForOptionsEnumerable(options) {
return ((options === void 0) || (options.enumerable === void 0)) ? false : options.enumerable;
}
function GetImplementForOptionsConfigurable(options) {
return ((options === void 0) || (options.configurable === void 0)) ? true : options.configurable;
}
function GetImplementForOptionsWritable(options) {
return ((options === void 0) || (options.writable === void 0)) ? false : options.writable;
}
function ImplementFunctionFor(target, propertyKey, functionToImplement, options) {
if ((propertyKey in target) && !IsFunctionOrParentImplementedBy(target, propertyKey, functionToImplement)) {
throw new Error(`The property '${String(propertyKey)}' is already implemented`);
}
else {
Object.defineProperty(target, propertyKey, {
value: functionToImplement,
enumerable: GetImplementForOptionsEnumerable(options),
configurable: GetImplementForOptionsConfigurable(options),
writable: GetImplementForOptionsWritable(options),
});
}
return target;
}
function ImplementTraits(obj, traits) {
RegisterTraits(obj, traits);
for (let i = 0, l = traits.length; i < l; i++) {
const trait = traits[i];
if ((trait !== null)
&& (typeof trait === 'object')
&& (Object.getPrototypeOf(trait) === Object.prototype)) {
const iterator = GetOwnPropertyDescriptors(trait);
let result;
while (!(result = iterator.next()).done) {
const [propertyKey, descriptor] = result.value;
if ((propertyKey !== 'constructor') && (propertyKey !== TRAITS)) {
if (ObjectHasOwnProperty(obj, propertyKey)) {
throw new Error(`The property '${String(propertyKey)}' is already implemented`);
function IsFunctionOrDerivedImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(target[propertyKey], functionToTest);
}
function IsFunctionOrParentImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(functionToTest, target[propertyKey]);
}
class DerivableFunction {
constructor(fnc) {
this.fnc = fnc;
}
derive(fnc) {
RegisterDerivedFunction(this.fnc, fnc);
return new DerivableFunction(fnc);
}
call(instance, ...args) {
return this.fnc.call(instance, ...args);
}
isDerivedFrom(derivableFunction) {
return IsFunctionDerivedFrom(this.fnc, derivableFunction.fnc);
}
equals(derivableFunction) {
return derivableFunction.fnc === this.fnc;
}
}
class TraitFunction extends DerivableFunction {
constructor(propertyKey, fnc, options) {
super(fnc);
this.propertyKey = propertyKey;
this.enumerable = GetImplementForOptionsEnumerable(options);
this.configurable = GetImplementForOptionsConfigurable(options);
this.writable = GetImplementForOptionsWritable(options);
}
derive(derivedFunction, options) {
RegisterDerivedFunction(this.fnc, derivedFunction);
return new TraitFunction(this.propertyKey, derivedFunction, {
enumerable: this.enumerable,
configurable: this.configurable,
writable: this.writable,
...options,
});
}
derivedFrom(parentFunction, options) {
RegisterDerivedFunction(parentFunction, this.fnc);
return new TraitFunction(this.propertyKey, parentFunction, {
enumerable: this.enumerable,
configurable: this.configurable,
writable: this.writable,
...options,
});
}
implementFor(target, options) {
return ImplementFunctionFor(target, this.propertyKey, this.fnc, {
enumerable: this.enumerable,
configurable: this.configurable,
writable: this.writable,
...options,
});
}
isImplementedBy(target) {
return IsFunctionOrDerivedImplementedBy(target, this.propertyKey, this.fnc);
}
equals(traitFunction) {
return super.equals(traitFunction)
&& (traitFunction.propertyKey === this.propertyKey);
}
}
class Trait {
constructor(traitFunctions) {
this.traitFunctions = Object.freeze(Array.from(traitFunctions));
for (let i = 0, l = this.traitFunctions.length - 1; i < l; i++) {
const traitFunction = this.traitFunctions[i];
for (let j = i + 1; j <= l; j++) {
if (traitFunction.propertyKey === this.traitFunctions[j].propertyKey) {
throw new Error(`Received two TraitFunction with the same property key '${String(traitFunction.propertyKey)}' at index ${i} and ${j}`);
}
}
}
}
static mix(...traits) {
return new Trait((traits
.map((trait) => {
return trait.traitFunctions;
})
.flat()));
}
get(propertyKey) {
return this.traitFunctions.find((traitFunction) => {
return traitFunction.propertyKey === propertyKey;
});
}
derive(traitFunctions) {
const traitFunctionsAsArray = Array.isArray(traitFunctions)
? traitFunctions
: Array.from(traitFunctions);
return new Trait((this.traitFunctions
.filter((traitFunctionA) => {
return traitFunctionsAsArray.every((traitFunctionB, index) => {
if (traitFunctionA.propertyKey === traitFunctionB.propertyKey) {
if (traitFunctionB.isDerivedFrom(traitFunctionA)) {
return false;
}
else {
Object.defineProperty(obj, propertyKey, descriptor);
throw new Error(`Received a new TraitFunction with the property key '${String(traitFunctionB.propertyKey)}' at index ${index}, which already exists in this Trait and is not derived from the original`);
}
}
else {
return true;
}
});
})
.concat(traitFunctionsAsArray)));
}
implementFor(target) {
for (let i = 0, l = this.traitFunctions.length; i < l; i++) {
this.traitFunctions[i].implementFor(target);
}
return target;
}
isImplementedBy(target) {
for (let i = 0, l = this.traitFunctions.length; i < l; i++) {
if (!this.traitFunctions[i].isImplementedBy(target)) {
return false;
}
}
return true;
}
isDerivedFrom(trait) {
if (trait.traitFunctions.length >= this.traitFunctions.length) {
return this.traitFunctions.every((traitFunctionA) => {
return trait.traitFunctions.some((traitFunctionB) => {
return traitFunctionA.isDerivedFrom(traitFunctionB);
});
});
}
else {
throw new Error(`The trait must be a plain object`);
return false;
}
}
return obj;
equals(trait) {
if (trait.traitFunctions.length === this.traitFunctions.length) {
return this.traitFunctions.every((traitFunctionA) => {
return trait.traitFunctions.some((traitFunctionB) => {
return traitFunctionA.equals(traitFunctionB);
});
});
}
else {
return false;
}
}
}
function SuperTrait(traits, baseClass) {
const TraitClass = class TraitClass extends baseClass {
};
ImplementTraits(TraitClass.prototype, traits);
function TraitFunctionsFromObject(target, parentTraitFunctionsMap = new Map()) {
const iterator = GetOwnPropertyDescriptors(target);
let result;
while (!(result = iterator.next()).done) {
const [propertyKey, descriptor] = result.value;
if (IsNotPrimitivePropertyName(propertyKey)) {
if (typeof descriptor.value === 'function') {
parentTraitFunctionsMap.set(propertyKey, ((parentTraitFunctionsMap.has(propertyKey))
? parentTraitFunctionsMap.get(propertyKey).derive(descriptor.value, descriptor)
: new TraitFunction(propertyKey, descriptor.value, descriptor)));
}
else {
throw new Error(`Found property which is not a function: '${String(propertyKey)}'`);
}
}
}
return parentTraitFunctionsMap;
}
function TraitFunctionsFromObjectPrototypeChain(target) {
const prototypes = Array.from(GetPrototypesChain(target)).filter(IsNotPrimitivePrototype).reverse();
const parentTraitFunctionsMap = new Map();
for (let i = 0, li = prototypes.length; i < li; i++) {
TraitFunctionsFromObject(prototypes[i], parentTraitFunctionsMap);
}
return parentTraitFunctionsMap;
}
function TraitFunctionsFromClass(_class) {
return TraitFunctionsFromObjectPrototypeChain(_class.prototype);
}
function TraitFromClass(_class) {
return new Trait(TraitFunctionsFromClass(_class).values());
}
function SuperTrait(trait, baseClass) {
const TraitClass = (baseClass === void 0)
? class TraitClass {
}
:
class TraitClass extends baseClass {
};
trait.implementFor(TraitClass.prototype);
return TraitClass;
}
function ImplementsTrait(obj, trait) {
if ((obj !== null)
&& (typeof obj === 'object')) {
if (ObjectHasOwnProperty(obj, TRAITS)
&& obj[TRAITS].has(trait)) {
return true;
function AbstractMethod() {
return (target, propertyKey, descriptor = Object.getOwnPropertyDescriptor(target, propertyKey)) => {
if (descriptor === void 0) {
return {
configurable: false,
writable: false,
value: CreateAbstractMethod(propertyKey),
};
}
else {
return ImplementsTrait(Object.getPrototypeOf(obj), trait);
throw new TypeError(`@AbstractProperty: the property '${String(propertyKey)}' should not be defined.`);
}
}
else {
return false;
}
};
}
function ImplementsTraits(obj, traits) {
return traits.every((trait) => ImplementsTrait(obj, trait));
function CreateAbstractMethod(propertyKey) {
return () => {
AbstractMethodCall(propertyKey);
};
}
function TraitFromClass(classTrait) {
return classTrait.prototype;
function CreateAbstractMethodCallError(propertyKey) {
return (propertyKey === void 0)
? new Error(`Cannot call an abstract method`)
: new Error(`Cannot call the abstract method '${String(propertyKey)}'`);
}
function TraitsFromClasses(...classTrait) {
return classTrait.map(TraitFromClass);
function AbstractMethodCall(propertyKey) {
throw CreateAbstractMethodCallError(propertyKey);
}
exports.AbstractMethod = AbstractMethod;
exports.AbstractMethodCall = AbstractMethodCall;
exports.BaseClass = BaseClass;
exports.BindDescriptor = BindDescriptor;
exports.BindDescriptorOld = BindDescriptorOld;
exports.CallTraitFunctionAsMethod = CallTraitFunctionAsMethod;
exports.CallTraitFunctionOrFallback = CallTraitFunctionOrFallback;
exports.CallTraitMethodOrFallback = CallTraitMethodOrFallback;
exports.ClassToFactory = ClassToFactory;

@@ -506,21 +770,37 @@ exports.ConstructClassWithPrivateMembers = ConstructClassWithPrivateMembers;

exports.CopyProperties = CopyProperties;
exports.CreateAbstractMethod = CreateAbstractMethod;
exports.CreateAbstractMethodCallError = CreateAbstractMethodCallError;
exports.DERIVED_FUNCTION_TO_FUNCTION_MAP = DERIVED_FUNCTION_TO_FUNCTION_MAP;
exports.DerivableFunction = DerivableFunction;
exports.EXCLUDED_PROPERTY_NAMES = EXCLUDED_PROPERTY_NAMES;
exports.FUNCTION_TO_DERIVED_FUNCTIONS_MAP = FUNCTION_TO_DERIVED_FUNCTIONS_MAP;
exports.GenerateOverrideSuperArgumentsFunction = GenerateOverrideSuperArgumentsFunction;
exports.GetImplementForOptionsConfigurable = GetImplementForOptionsConfigurable;
exports.GetImplementForOptionsEnumerable = GetImplementForOptionsEnumerable;
exports.GetImplementForOptionsWritable = GetImplementForOptionsWritable;
exports.GetOwnPropertyDescriptors = GetOwnPropertyDescriptors;
exports.GetOwnPropertyKeys = GetOwnPropertyKeys;
exports.GetPropertyDescriptors = GetPropertyDescriptors;
exports.GetPrototypesChain = GetPrototypesChain;
exports.GetSafePropertyDescriptors = GetSafePropertyDescriptors;
exports.GetSetSuperArgsFunction = GetSetSuperArgsFunction;
exports.HasFactoryWaterMark = HasFactoryWaterMark;
exports.ImplementTraits = ImplementTraits;
exports.ImplementsTrait = ImplementsTrait;
exports.ImplementsTraits = ImplementsTraits;
exports.HasOwnProperty = HasOwnProperty;
exports.ImplementFunctionFor = ImplementFunctionFor;
exports.IsFactoryClass = IsFactoryClass;
exports.IsFunctionDerivedFrom = IsFunctionDerivedFrom;
exports.IsFunctionOrDerivedImplementedBy = IsFunctionOrDerivedImplementedBy;
exports.IsFunctionOrParentImplementedBy = IsFunctionOrParentImplementedBy;
exports.IsInstanceOf = IsInstanceOf;
exports.IsNotPrimitivePropertyName = IsNotPrimitivePropertyName;
exports.IsNotPrimitivePrototype = IsNotPrimitivePrototype;
exports.IsPrimitivePropertyName = IsPrimitivePropertyName;
exports.IsPrimitivePrototype = IsPrimitivePrototype;
exports.MakeFactory = MakeFactory;
exports.MixOverrideSuperArgumentsFunction = MixOverrideSuperArgumentsFunction;
exports.ObjectHasOwnProperty = ObjectHasOwnProperty;
exports.OwnArguments = OwnArguments;
exports.PRIMITIVE_PROPERTY_NAMES = PRIMITIVE_PROPERTY_NAMES;
exports.PRIMITIVE_PROTOTYPES = PRIMITIVE_PROTOTYPES;
exports.PROTECTED = PROTECTED;
exports.RegisterTraits = RegisterTraits;
exports.RegisterDerivedFunction = RegisterDerivedFunction;
exports.SearchSuperClass = SearchSuperClass;

@@ -533,5 +813,8 @@ exports.SetClassName = SetClassName;

exports.SuperTrait = SuperTrait;
exports.TRAITS = TRAITS;
exports.Trait = Trait;
exports.TraitFromClass = TraitFromClass;
exports.TraitsFromClasses = TraitsFromClasses;
exports.TraitFunction = TraitFunction;
exports.TraitFunctionsFromClass = TraitFunctionsFromClass;
exports.TraitFunctionsFromObject = TraitFunctionsFromObject;
exports.TraitFunctionsFromObjectPrototypeChain = TraitFunctionsFromObjectPrototypeChain;

@@ -538,0 +821,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,2 +0,2 @@

((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],t):t((e=e||self)["class-factory"]={})})(this,(function(e){"use strict";class t{}const n=Symbol("instanceof");function r(e,t){const r=Symbol.hasInstance in e?e[Symbol.hasInstance].bind(e):()=>!1;Object.defineProperty(e,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value(e){return e instanceof t||r(e)}}),n in t||Object.defineProperty(t,n,{value:new Set}),t[n].add(e)}const o=new Set(["prototype","constructor",...c(Object.prototype)]);function c(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}function*s(e){const t=c(e);for(let n=0,r=t.length;r>n;n++){const r=t[n];yield[r,Object.getOwnPropertyDescriptor(e,r),e]}}function*i(e){const t=new Set;for(;null!==e;){const n=c(e);for(const r of n)t.has(r)||(t.add(r),yield[r,Object.getOwnPropertyDescriptor(e,r),e]);e=Object.getPrototypeOf(e)}}function a(e,t,n=o){const r=i(e);let c;for(;!(c=r.next()).done;){const[e,r]=c.value;n.has(e)||Object.defineProperty(t,e,r)}}function u(e,t,n){a(e.prototype,t.prototype,n)}function l(e,t,n){a(e,t,n)}function f(e,t){Object.defineProperty(e,"name",{configurable:!0,enumerable:!1,value:t,writable:!1})}function p(e,t){u(e,t),l(e,t),r(e,t)}function y(e,t,n){const r={};if(r.configurable=n.configurable,r.enumerable=n.enumerable,void 0!==n.value){let o,c;r.get=()=>"function"==typeof e[t]?(o!==e[t]&&(o=e[t],c=o.bind(e)),c):e[t],n.writable&&(r.set=n=>{e[t]=n})}else"function"==typeof n.get&&(r.get=n.get.bind(e)),"function"==typeof n.set&&(r.set=n.set.bind(e));return r}function b(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const d=Symbol("is-factory-class");function O(e,t=!0){return!0===e[d]&&(!t||e.hasOwnProperty(d))}function g(e,t){let n=0;for(;null!==e;){if(t(e))return{index:n,ctor:e};n++,e=Object.getPrototypeOf(e)}return null}function m(e,t){if(Array.isArray(e[0]))return e[0]=t,e;throw new TypeError("Expected array as argument 0")}function h(e,t){for(let n=0,r=t.length;r>n;n++)e[n]=t[n];return e}const P=Symbol("protected");const w=Symbol("traits");function j(e,t){if(b(e,w)){const n=e[w];for(let e=0,r=t.length;r>e;e++)n.add(t[e])}else Object.defineProperty(e,w,{value:new WeakSet(t),writable:!1,enumerable:!1,configurable:!1})}function S(e,t){j(e,t);for(let n=0,r=t.length;r>n;n++){const r=t[n];if(null===r||"object"!=typeof r||Object.getPrototypeOf(r)!==Object.prototype)throw new Error("The trait must be a plain object");{const t=s(r);let n;for(;!(n=t.next()).done;){const[t,r]=n.value;if("constructor"!==t&&t!==w){if(b(e,t))throw new Error(`The property '${String(t)}' is already implemented`);Object.defineProperty(e,t,r)}}}}return e}function v(e,t){return null!==e&&"object"==typeof e&&(!(!b(e,w)||!e[w].has(t))||v(Object.getPrototypeOf(e),t))}function C(e){return e.prototype}e.BaseClass=t,e.BindDescriptor=function(e,t,n){const r={};if(r.configurable=n.configurable,r.enumerable=n.enumerable,void 0!==n.value){let o=new WeakMap;r.get=function(){const n=e(this),r=Reflect.get(n,t);return"function"==typeof r?(o.has(r)||o.set(r,r.bind(n)),o.get(r)):r},n.writable&&(r.set=function(n){const r=e(this);Reflect.set(r,t,n)})}else"function"==typeof n.get&&(r.get=function(){const t=e(this);return n.get.call(t)}),"function"==typeof n.set&&(r.set=function(t){const r=e(this);return n.set.call(r,t)});return r},e.BindDescriptorOld=y,e.ClassToFactory=function(e){return function(n,s="auto"){let a;return n===Object||n===t?(a=class extends e{constructor(e){super(...e)}},r(n,a)):(a=class extends n{constructor(...t){const n=t[0];let r;switch(super(...t.slice(1)),s){case"auto":try{r=e.apply(this,n),void 0===r&&(r=this),s="function"}catch(t){r=Reflect.construct(e,n),s="class"}break;case"function":r=e.apply(this,n),void 0===r&&(r=this);break;case"class":r=Reflect.construct(e,n)}if(this!==r){const e=i(Object.getPrototypeOf(r));let t;for(;!(t=e.next()).done;){const e=t.value[0];o.has(e)||Object.defineProperty(this,e,y(r,e,t.value[1]))}const n=c(r);for(const e of n)o.has(e)||(e in this&&console.warn("Crossing properties !"),Object.defineProperty(this,e,y(r,e,Object.getOwnPropertyDescriptor(r,e))));Object.seal(r)}}},p(e,a)),f(a,e.name),a}},e.ConstructClassWithPrivateMembers=function(e,t){Object.defineProperty(e,t,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.ConstructClassWithProtectedMembers=function(e){Object.defineProperty(e,P,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.CopyClass=p,e.CopyClassName=function(e,t){let n=Object.getOwnPropertyDescriptor(e,"name");void 0===n?n={configurable:!0,enumerable:!1,value:e.name,writable:!1}:n.value=e.name,n.configurable&&Object.defineProperty(t,"name",n)},e.CopyClassPrototype=u,e.CopyClassStaticProperties=l,e.CopyOwnProperties=function(e,t,n=o){const r=c(e);for(const o of r){const r=Object.getOwnPropertyDescriptor(e,o);void 0===r||n.has(o)||Object.defineProperty(t,o,r)}},e.CopyProperties=a,e.EXCLUDED_PROPERTY_NAMES=o,e.GenerateOverrideSuperArgumentsFunction=function(e,t){const n=g(e,t);if(null===n)throw new Error("Failed to find super class of the class "+e.name);{const e=n.index;return O(n.ctor)?(t,n)=>{if(Array.isArray(t[e]))return t.slice(0,e).concat([n(t[e])]).concat(t.slice(e+1));throw new TypeError(`Expected array as argument[${e}]`)}:(t,n)=>t.slice(0,e).concat(n(t.slice(e)))}},e.GetOwnPropertyDescriptors=s,e.GetOwnPropertyKeys=c,e.GetPropertyDescriptors=i,e.GetSafePropertyDescriptors=function*(e){const t=i(e);let n;for(;!(n=t.next()).done;){const[e,,t]=n.value;t===Object.prototype||t===Function.prototype||o.has(e)||(yield n.value)}},e.GetSetSuperArgsFunction=function(e){return e?m:h},e.HasFactoryWaterMark=function(e,t,n=!0){return!0===e[t]&&(!n||e.hasOwnProperty(t))},e.ImplementTraits=S,e.ImplementsTrait=v,e.ImplementsTraits=function(e,t){return t.every(t=>v(e,t))},e.IsFactoryClass=O,e.IsInstanceOf=function(e,t){return e instanceof t||!(!e.constructor||!(n in e.constructor))&&e.constructor[n].has(t)},e.MakeFactory=function(e,t,n,o={}){let c=n;for(let e=t.length-1;e>=0;e--)c=t[e](c);const s=e(c);if(Object.defineProperty(s,d,{value:!0}),"string"==typeof o.name&&Object.defineProperty(s,"name",{configurable:!0,enumerable:!1,value:o.name,writable:!1}),Array.isArray(o.waterMarks))for(let e=0,t=o.waterMarks.length;t>e;e++)Object.defineProperty(s,o.waterMarks[e],{value:!0});return void 0!==o.instanceOf&&r(o.instanceOf,s),s},e.MixOverrideSuperArgumentsFunction=function(...e){return(t,...n)=>{for(let r=0,o=e.length;o>r;r++)t=e[r](t,n[r]);return t}},e.ObjectHasOwnProperty=b,e.OwnArguments=function(e){return e[0]},e.PROTECTED=P,e.RegisterTraits=j,e.SearchSuperClass=g,e.SetClassName=f,e.SetInstanceOf=r,e.SetSuperArgsForFactoryClass=m,e.SetSuperArgsForStandardClass=h,e.SuperArguments=function(e){return e.slice(1)},e.SuperTrait=function(e,t){const n=class extends t{};return S(n.prototype,e),n},e.TRAITS=w,e.TraitFromClass=C,e.TraitsFromClasses=function(...e){return e.map(C)},Object.defineProperty(e,"__esModule",{value:!0})}));
((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],t):t((e=e||self)["class-factory"]={})})(this,(function(e){"use strict";class t{}const r=Symbol("instanceof");function n(e,t){const n=Symbol.hasInstance in e?e[Symbol.hasInstance].bind(e):()=>!1;Object.defineProperty(e,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value(e){return e instanceof t||n(e)}}),r in t||Object.defineProperty(t,r,{value:new Set}),t[r].add(e)}function o(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}function*i(e){const t=o(e);for(let r=0,n=t.length;n>r;r++){const n=t[r];yield[n,Object.getOwnPropertyDescriptor(e,n),e]}}const s=new Set(["prototype","constructor"]);function c(e){return s.has(e)}function a(e){return!c(e)}function*u(e){for(;null!==e;)yield e,e=Object.getPrototypeOf(e)}const l=new Set(["",0,{},[],()=>{}].map(e=>Object.getPrototypeOf(e)));function f(e){return l.has(e)}function p(e){return!f(e)}const y=new Set(["prototype","constructor",...o(Object.prototype)]);function*d(e){const t=new Set;for(;null!==e;){const r=o(e);for(const n of r)t.has(n)||(t.add(n),yield[n,Object.getOwnPropertyDescriptor(e,n),e]);e=Object.getPrototypeOf(e)}}function h(e,t,r=y){const n=d(e);let o;for(;!(o=n.next()).done;){const[e,n]=o.value;r.has(e)||Object.defineProperty(t,e,n)}}function b(e,t,r){h(e.prototype,t.prototype,r)}function m(e,t,r){h(e,t,r)}function g(e,t){Object.defineProperty(e,"name",{configurable:!0,enumerable:!1,value:t,writable:!1})}function w(e,t){b(e,t),m(e,t),n(e,t)}function O(e,t,r){const n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){let o,i;n.get=()=>"function"==typeof e[t]?(o!==e[t]&&(o=e[t],i=o.bind(e)),i):e[t],r.writable&&(n.set=r=>{e[t]=r})}else"function"==typeof r.get&&(n.get=r.get.bind(e)),"function"==typeof r.set&&(n.set=r.set.bind(e));return n}const v=Symbol("is-factory-class");function F(e,t=!0){return!0===e[v]&&(!t||e.hasOwnProperty(v))}function P(e,t){let r=0;for(;null!==e;){if(t(e))return{index:r,ctor:e};r++,e=Object.getPrototypeOf(e)}return null}function C(e,t){if(Array.isArray(e[0]))return e[0]=t,e;throw new TypeError("Expected array as argument 0")}function S(e,t){for(let r=0,n=t.length;n>r;r++)e[r]=t[r];return e}const j=Symbol("protected");function I(e,t,r,n){return e.isImplementedBy(t)?t[e.propertyKey](...r):n.apply(t,r)}const T=new WeakMap,E=new WeakMap;function A(e,t){if(T.has(t)){if(T.get(t)!==e)throw new Error("Derived function already registered as derived from: "+String(T.get(t)))}else{if(D(e,t))throw new Error("Derived function already registered as derived from: "+String(T.get(t)));T.set(t,e),E.has(e)?E.get(e).push(t):E.set(e,[t])}}function D(e,t){for(;;){if(e===t)return!0;if(!T.has(e))return!1;e=T.get(e)}}function M(e){return void 0!==e&&void 0!==e.enumerable&&e.enumerable}function x(e){return void 0===e||void 0===e.configurable||e.configurable}function K(e){return void 0!==e&&void 0!==e.writable&&e.writable}function N(e,t,r,n){if(t in e&&!_(e,t,r))throw new Error(`The property '${String(t)}' is already implemented`);return Object.defineProperty(e,t,{value:r,enumerable:M(n),configurable:x(n),writable:K(n)}),e}function R(e,t,r){return"function"==typeof e[t]&&D(e[t],r)}function _(e,t,r){return"function"==typeof e[t]&&D(r,e[t])}class k{constructor(e){this.fnc=e}derive(e){return A(this.fnc,e),new k(e)}call(e,...t){return this.fnc.call(e,...t)}isDerivedFrom(e){return D(this.fnc,e.fnc)}equals(e){return e.fnc===this.fnc}}class B extends k{constructor(e,t,r){super(t),this.propertyKey=e,this.enumerable=M(r),this.configurable=x(r),this.writable=K(r)}derive(e,t){return A(this.fnc,e),new B(this.propertyKey,e,{enumerable:this.enumerable,configurable:this.configurable,writable:this.writable,...t})}derivedFrom(e,t){return A(e,this.fnc),new B(this.propertyKey,e,{enumerable:this.enumerable,configurable:this.configurable,writable:this.writable,...t})}implementFor(e,t){return N(e,this.propertyKey,this.fnc,{enumerable:this.enumerable,configurable:this.configurable,writable:this.writable,...t})}isImplementedBy(e){return R(e,this.propertyKey,this.fnc)}equals(e){return super.equals(e)&&e.propertyKey===this.propertyKey}}class G{constructor(e){this.traitFunctions=Object.freeze(Array.from(e));for(let e=0,t=this.traitFunctions.length-1;t>e;e++){const r=this.traitFunctions[e];for(let n=e+1;t>=n;n++)if(r.propertyKey===this.traitFunctions[n].propertyKey)throw new Error(`Received two TraitFunction with the same property key '${String(r.propertyKey)}' at index ${e} and ${n}`)}}static mix(...e){return new G(e.map(e=>e.traitFunctions).flat())}get(e){return this.traitFunctions.find(t=>t.propertyKey===e)}derive(e){const t=Array.isArray(e)?e:Array.from(e);return new G(this.traitFunctions.filter(e=>t.every((t,r)=>{if(e.propertyKey===t.propertyKey){if(t.isDerivedFrom(e))return!1;throw new Error(`Received a new TraitFunction with the property key '${String(t.propertyKey)}' at index ${r}, which already exists in this Trait and is not derived from the original`)}return!0})).concat(t))}implementFor(e){for(let t=0,r=this.traitFunctions.length;r>t;t++)this.traitFunctions[t].implementFor(e);return e}isImplementedBy(e){for(let t=0,r=this.traitFunctions.length;r>t;t++)if(!this.traitFunctions[t].isImplementedBy(e))return!1;return!0}isDerivedFrom(e){return e.traitFunctions.length>=this.traitFunctions.length&&this.traitFunctions.every(t=>e.traitFunctions.some(e=>t.isDerivedFrom(e)))}equals(e){return e.traitFunctions.length===this.traitFunctions.length&&this.traitFunctions.every(t=>e.traitFunctions.some(e=>t.equals(e)))}}function $(e,t=new Map){const r=i(e);let n;for(;!(n=r.next()).done;){const[e,r]=n.value;if(a(e)){if("function"!=typeof r.value)throw new Error(`Found property which is not a function: '${String(e)}'`);t.set(e,t.has(e)?t.get(e).derive(r.value,r):new B(e,r.value,r))}}return t}function W(e){const t=Array.from(u(e)).filter(p).reverse(),r=new Map;for(let e=0,n=t.length;n>e;e++)$(t[e],r);return r}function q(e){return W(e.prototype)}function U(e){return()=>{Y(e)}}function V(e){return void 0===e?new Error("Cannot call an abstract method"):new Error(`Cannot call the abstract method '${String(e)}'`)}function Y(e){throw V(e)}e.AbstractMethod=function(){return(e,t,r=Object.getOwnPropertyDescriptor(e,t))=>{if(void 0===r)return{configurable:!1,writable:!1,value:U(t)};throw new TypeError(`@AbstractProperty: the property '${String(t)}' should not be defined.`)}},e.AbstractMethodCall=Y,e.BaseClass=t,e.BindDescriptor=function(e,t,r){const n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){let o=new WeakMap;n.get=function(){const r=e(this),n=Reflect.get(r,t);return"function"==typeof n?(o.has(n)||o.set(n,n.bind(r)),o.get(n)):n},r.writable&&(n.set=function(r){const n=e(this);Reflect.set(n,t,r)})}else"function"==typeof r.get&&(n.get=function(){const t=e(this);return r.get.call(t)}),"function"==typeof r.set&&(n.set=function(t){const n=e(this);return r.set.call(n,t)});return n},e.BindDescriptorOld=O,e.CallTraitFunctionAsMethod=function(e,t,r){return e.isImplementedBy(t)?t[e.propertyKey](...r):e.fnc.apply(t,r)},e.CallTraitFunctionOrFallback=I,e.CallTraitMethodOrFallback=function(e,t,r,n,o){const i=e.get(r);return void 0===i?o(t,...n):I(i,t,n,o)},e.ClassToFactory=function(e){return function(r,i="auto"){let s;return r===Object||r===t?(s=class extends e{constructor(e){super(...e)}},n(r,s)):(s=class extends r{constructor(...t){const r=t[0];let n;switch(super(...t.slice(1)),i){case"auto":try{n=e.apply(this,r),void 0===n&&(n=this),i="function"}catch(t){n=Reflect.construct(e,r),i="class"}break;case"function":n=e.apply(this,r),void 0===n&&(n=this);break;case"class":n=Reflect.construct(e,r)}if(this!==n){const e=d(Object.getPrototypeOf(n));let t;for(;!(t=e.next()).done;){const e=t.value[0];y.has(e)||Object.defineProperty(this,e,O(n,e,t.value[1]))}const r=o(n);for(const e of r)y.has(e)||(e in this&&console.warn("Crossing properties !"),Object.defineProperty(this,e,O(n,e,Object.getOwnPropertyDescriptor(n,e))));Object.seal(n)}}},w(e,s)),g(s,e.name),s}},e.ConstructClassWithPrivateMembers=function(e,t){Object.defineProperty(e,t,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.ConstructClassWithProtectedMembers=function(e){Object.defineProperty(e,j,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.CopyClass=w,e.CopyClassName=function(e,t){let r=Object.getOwnPropertyDescriptor(e,"name");void 0===r?r={configurable:!0,enumerable:!1,value:e.name,writable:!1}:r.value=e.name,r.configurable&&Object.defineProperty(t,"name",r)},e.CopyClassPrototype=b,e.CopyClassStaticProperties=m,e.CopyOwnProperties=function(e,t,r=y){const n=o(e);for(const o of n){const n=Object.getOwnPropertyDescriptor(e,o);void 0===n||r.has(o)||Object.defineProperty(t,o,n)}},e.CopyProperties=h,e.CreateAbstractMethod=U,e.CreateAbstractMethodCallError=V,e.DERIVED_FUNCTION_TO_FUNCTION_MAP=T,e.DerivableFunction=k,e.EXCLUDED_PROPERTY_NAMES=y,e.FUNCTION_TO_DERIVED_FUNCTIONS_MAP=E,e.GenerateOverrideSuperArgumentsFunction=function(e,t){const r=P(e,t);if(null===r)throw new Error("Failed to find super class of the class "+e.name);{const e=r.index;return F(r.ctor)?(t,r)=>{if(Array.isArray(t[e]))return t.slice(0,e).concat([r(t[e])]).concat(t.slice(e+1));throw new TypeError(`Expected array as argument[${e}]`)}:(t,r)=>t.slice(0,e).concat(r(t.slice(e)))}},e.GetImplementForOptionsConfigurable=x,e.GetImplementForOptionsEnumerable=M,e.GetImplementForOptionsWritable=K,e.GetOwnPropertyDescriptors=i,e.GetOwnPropertyKeys=o,e.GetPropertyDescriptors=d,e.GetPrototypesChain=u,e.GetSafePropertyDescriptors=function*(e){const t=d(e);let r;for(;!(r=t.next()).done;){const[e,,t]=r.value;t===Object.prototype||t===Function.prototype||y.has(e)||(yield r.value)}},e.GetSetSuperArgsFunction=function(e){return e?C:S},e.HasFactoryWaterMark=function(e,t,r=!0){return!0===e[t]&&(!r||e.hasOwnProperty(t))},e.HasOwnProperty=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.ImplementFunctionFor=N,e.IsFactoryClass=F,e.IsFunctionDerivedFrom=D,e.IsFunctionOrDerivedImplementedBy=R,e.IsFunctionOrParentImplementedBy=_,e.IsInstanceOf=function(e,t){return e instanceof t||!(!e.constructor||!(r in e.constructor))&&e.constructor[r].has(t)},e.IsNotPrimitivePropertyName=a,e.IsNotPrimitivePrototype=p,e.IsPrimitivePropertyName=c,e.IsPrimitivePrototype=f,e.MakeFactory=function(e,t,r,o={}){let i=r;for(let e=t.length-1;e>=0;e--)i=t[e](i);const s=e(i);if(Object.defineProperty(s,v,{value:!0}),"string"==typeof o.name&&Object.defineProperty(s,"name",{configurable:!0,enumerable:!1,value:o.name,writable:!1}),Array.isArray(o.waterMarks))for(let e=0,t=o.waterMarks.length;t>e;e++)Object.defineProperty(s,o.waterMarks[e],{value:!0});return void 0!==o.instanceOf&&n(o.instanceOf,s),s},e.MixOverrideSuperArgumentsFunction=function(...e){return(t,...r)=>{for(let n=0,o=e.length;o>n;n++)t=e[n](t,r[n]);return t}},e.OwnArguments=function(e){return e[0]},e.PRIMITIVE_PROPERTY_NAMES=s,e.PRIMITIVE_PROTOTYPES=l,e.PROTECTED=j,e.RegisterDerivedFunction=A,e.SearchSuperClass=P,e.SetClassName=g,e.SetInstanceOf=n,e.SetSuperArgsForFactoryClass=C,e.SetSuperArgsForStandardClass=S,e.SuperArguments=function(e){return e.slice(1)},e.SuperTrait=function(e,t){const r=void 0===t?class{}:class extends t{};return e.implementFor(r.prototype),r},e.Trait=G,e.TraitFromClass=function(e){return new G(q(e).values())},e.TraitFunction=B,e.TraitFunctionsFromClass=q,e.TraitFunctionsFromObject=$,e.TraitFunctionsFromObjectPrototypeChain=W,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=class-factory.esnext.core.umd.min.js.map

@@ -37,3 +37,2 @@ (function (global, factory) {

const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
function GetOwnPropertyKeys(target) {

@@ -43,2 +42,5 @@ return Object.getOwnPropertyNames(target)

}
function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
function* GetOwnPropertyDescriptors(target) {

@@ -51,2 +53,23 @@ const keys = GetOwnPropertyKeys(target);

}
const PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
function IsPrimitivePropertyName(name) {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
function* GetPrototypesChain(target) {
while (target !== null) {
yield target;
target = Object.getPrototypeOf(target);
}
}
const PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], () => { }].map(_ => Object.getPrototypeOf(_)));
function IsPrimitivePrototype(proto) {
return PRIMITIVE_PROTOTYPES.has(proto);
}
function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
function* GetPropertyDescriptors(target) {

@@ -209,5 +232,2 @@ const _keys = new Set();

}
function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}

@@ -418,80 +438,324 @@ function MakeFactory(create, factories, superClass, options = {}) {

const TRAITS = Symbol('traits');
function RegisterTraits(obj, traits) {
if (ObjectHasOwnProperty(obj, TRAITS)) {
const _traits = obj[TRAITS];
for (let i = 0, l = traits.length; i < l; i++) {
_traits.add(traits[i]);
function CallTraitFunctionAsMethod(traitFunction, target, args) {
if (traitFunction.isImplementedBy(target)) {
return target[traitFunction.propertyKey](...args);
}
else {
return traitFunction.fnc.apply(target, args);
}
}
function CallTraitFunctionOrFallback(traitFunction, target, args, fallback) {
if (traitFunction.isImplementedBy(target)) {
return target[traitFunction.propertyKey](...args);
}
else {
return fallback.apply(target, args);
}
}
function CallTraitMethodOrFallback(trait, target, methodName, args, fallback) {
const traitFunction = trait.get(methodName);
if (traitFunction === void 0) {
return fallback(target, ...args);
}
else {
return CallTraitFunctionOrFallback(traitFunction, target, args, fallback);
}
}
const DERIVED_FUNCTION_TO_FUNCTION_MAP = new WeakMap();
const FUNCTION_TO_DERIVED_FUNCTIONS_MAP = new WeakMap();
function RegisterDerivedFunction(parentFunction, derivedFunction) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(derivedFunction)) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction) !== parentFunction) {
throw new Error(`Derived function already registered as derived from: ${String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction))}`);
}
}
else if (IsFunctionDerivedFrom(parentFunction, derivedFunction)) {
throw new Error(`Derived function already registered as derived from: ${String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction))}`);
}
else {
Object.defineProperty(obj, TRAITS, {
value: new WeakSet(traits),
writable: false,
enumerable: false,
configurable: false,
DERIVED_FUNCTION_TO_FUNCTION_MAP.set(derivedFunction, parentFunction);
if (FUNCTION_TO_DERIVED_FUNCTIONS_MAP.has(parentFunction)) {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.get(parentFunction).push(derivedFunction);
}
else {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.set(parentFunction, [derivedFunction]);
}
}
}
function IsFunctionDerivedFrom(functionToTest, parentFunction) {
while (true) {
if (functionToTest === parentFunction) {
return true;
}
else {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(functionToTest)) {
functionToTest = DERIVED_FUNCTION_TO_FUNCTION_MAP.get(functionToTest);
}
else {
return false;
}
}
}
}
function GetImplementForOptionsEnumerable(options) {
return ((options === void 0) || (options.enumerable === void 0)) ? false : options.enumerable;
}
function GetImplementForOptionsConfigurable(options) {
return ((options === void 0) || (options.configurable === void 0)) ? true : options.configurable;
}
function GetImplementForOptionsWritable(options) {
return ((options === void 0) || (options.writable === void 0)) ? false : options.writable;
}
function ImplementFunctionFor(target, propertyKey, functionToImplement, options) {
if ((propertyKey in target) && !IsFunctionOrParentImplementedBy(target, propertyKey, functionToImplement)) {
throw new Error(`The property '${String(propertyKey)}' is already implemented`);
}
else {
Object.defineProperty(target, propertyKey, {
value: functionToImplement,
enumerable: GetImplementForOptionsEnumerable(options),
configurable: GetImplementForOptionsConfigurable(options),
writable: GetImplementForOptionsWritable(options),
});
}
return target;
}
function ImplementTraits(obj, traits) {
RegisterTraits(obj, traits);
for (let i = 0, l = traits.length; i < l; i++) {
const trait = traits[i];
if ((trait !== null)
&& (typeof trait === 'object')
&& (Object.getPrototypeOf(trait) === Object.prototype)) {
const iterator = GetOwnPropertyDescriptors(trait);
let result;
while (!(result = iterator.next()).done) {
const [propertyKey, descriptor] = result.value;
if ((propertyKey !== 'constructor') && (propertyKey !== TRAITS)) {
if (ObjectHasOwnProperty(obj, propertyKey)) {
throw new Error(`The property '${String(propertyKey)}' is already implemented`);
function IsFunctionOrDerivedImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(target[propertyKey], functionToTest);
}
function IsFunctionOrParentImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(functionToTest, target[propertyKey]);
}
class DerivableFunction {
constructor(fnc) {
this.fnc = fnc;
}
derive(fnc) {
RegisterDerivedFunction(this.fnc, fnc);
return new DerivableFunction(fnc);
}
call(instance, ...args) {
return this.fnc.call(instance, ...args);
}
isDerivedFrom(derivableFunction) {
return IsFunctionDerivedFrom(this.fnc, derivableFunction.fnc);
}
equals(derivableFunction) {
return derivableFunction.fnc === this.fnc;
}
}
class TraitFunction extends DerivableFunction {
constructor(propertyKey, fnc, options) {
super(fnc);
this.propertyKey = propertyKey;
this.enumerable = GetImplementForOptionsEnumerable(options);
this.configurable = GetImplementForOptionsConfigurable(options);
this.writable = GetImplementForOptionsWritable(options);
}
derive(derivedFunction, options) {
RegisterDerivedFunction(this.fnc, derivedFunction);
return new TraitFunction(this.propertyKey, derivedFunction, {
enumerable: this.enumerable,
configurable: this.configurable,
writable: this.writable,
...options,
});
}
derivedFrom(parentFunction, options) {
RegisterDerivedFunction(parentFunction, this.fnc);
return new TraitFunction(this.propertyKey, parentFunction, {
enumerable: this.enumerable,
configurable: this.configurable,
writable: this.writable,
...options,
});
}
implementFor(target, options) {
return ImplementFunctionFor(target, this.propertyKey, this.fnc, {
enumerable: this.enumerable,
configurable: this.configurable,
writable: this.writable,
...options,
});
}
isImplementedBy(target) {
return IsFunctionOrDerivedImplementedBy(target, this.propertyKey, this.fnc);
}
equals(traitFunction) {
return super.equals(traitFunction)
&& (traitFunction.propertyKey === this.propertyKey);
}
}
class Trait {
constructor(traitFunctions) {
this.traitFunctions = Object.freeze(Array.from(traitFunctions));
for (let i = 0, l = this.traitFunctions.length - 1; i < l; i++) {
const traitFunction = this.traitFunctions[i];
for (let j = i + 1; j <= l; j++) {
if (traitFunction.propertyKey === this.traitFunctions[j].propertyKey) {
throw new Error(`Received two TraitFunction with the same property key '${String(traitFunction.propertyKey)}' at index ${i} and ${j}`);
}
}
}
}
static mix(...traits) {
return new Trait((traits
.map((trait) => {
return trait.traitFunctions;
})
.flat()));
}
get(propertyKey) {
return this.traitFunctions.find((traitFunction) => {
return traitFunction.propertyKey === propertyKey;
});
}
derive(traitFunctions) {
const traitFunctionsAsArray = Array.isArray(traitFunctions)
? traitFunctions
: Array.from(traitFunctions);
return new Trait((this.traitFunctions
.filter((traitFunctionA) => {
return traitFunctionsAsArray.every((traitFunctionB, index) => {
if (traitFunctionA.propertyKey === traitFunctionB.propertyKey) {
if (traitFunctionB.isDerivedFrom(traitFunctionA)) {
return false;
}
else {
Object.defineProperty(obj, propertyKey, descriptor);
throw new Error(`Received a new TraitFunction with the property key '${String(traitFunctionB.propertyKey)}' at index ${index}, which already exists in this Trait and is not derived from the original`);
}
}
else {
return true;
}
});
})
.concat(traitFunctionsAsArray)));
}
implementFor(target) {
for (let i = 0, l = this.traitFunctions.length; i < l; i++) {
this.traitFunctions[i].implementFor(target);
}
return target;
}
isImplementedBy(target) {
for (let i = 0, l = this.traitFunctions.length; i < l; i++) {
if (!this.traitFunctions[i].isImplementedBy(target)) {
return false;
}
}
return true;
}
isDerivedFrom(trait) {
if (trait.traitFunctions.length >= this.traitFunctions.length) {
return this.traitFunctions.every((traitFunctionA) => {
return trait.traitFunctions.some((traitFunctionB) => {
return traitFunctionA.isDerivedFrom(traitFunctionB);
});
});
}
else {
throw new Error(`The trait must be a plain object`);
return false;
}
}
return obj;
equals(trait) {
if (trait.traitFunctions.length === this.traitFunctions.length) {
return this.traitFunctions.every((traitFunctionA) => {
return trait.traitFunctions.some((traitFunctionB) => {
return traitFunctionA.equals(traitFunctionB);
});
});
}
else {
return false;
}
}
}
function SuperTrait(traits, baseClass) {
const TraitClass = class TraitClass extends baseClass {
};
ImplementTraits(TraitClass.prototype, traits);
function TraitFunctionsFromObject(target, parentTraitFunctionsMap = new Map()) {
const iterator = GetOwnPropertyDescriptors(target);
let result;
while (!(result = iterator.next()).done) {
const [propertyKey, descriptor] = result.value;
if (IsNotPrimitivePropertyName(propertyKey)) {
if (typeof descriptor.value === 'function') {
parentTraitFunctionsMap.set(propertyKey, ((parentTraitFunctionsMap.has(propertyKey))
? parentTraitFunctionsMap.get(propertyKey).derive(descriptor.value, descriptor)
: new TraitFunction(propertyKey, descriptor.value, descriptor)));
}
else {
throw new Error(`Found property which is not a function: '${String(propertyKey)}'`);
}
}
}
return parentTraitFunctionsMap;
}
function TraitFunctionsFromObjectPrototypeChain(target) {
const prototypes = Array.from(GetPrototypesChain(target)).filter(IsNotPrimitivePrototype).reverse();
const parentTraitFunctionsMap = new Map();
for (let i = 0, li = prototypes.length; i < li; i++) {
TraitFunctionsFromObject(prototypes[i], parentTraitFunctionsMap);
}
return parentTraitFunctionsMap;
}
function TraitFunctionsFromClass(_class) {
return TraitFunctionsFromObjectPrototypeChain(_class.prototype);
}
function TraitFromClass(_class) {
return new Trait(TraitFunctionsFromClass(_class).values());
}
function SuperTrait(trait, baseClass) {
const TraitClass = (baseClass === void 0)
? class TraitClass {
}
:
class TraitClass extends baseClass {
};
trait.implementFor(TraitClass.prototype);
return TraitClass;
}
function ImplementsTrait(obj, trait) {
if ((obj !== null)
&& (typeof obj === 'object')) {
if (ObjectHasOwnProperty(obj, TRAITS)
&& obj[TRAITS].has(trait)) {
return true;
function AbstractMethod() {
return (target, propertyKey, descriptor = Object.getOwnPropertyDescriptor(target, propertyKey)) => {
if (descriptor === void 0) {
return {
configurable: false,
writable: false,
value: CreateAbstractMethod(propertyKey),
};
}
else {
return ImplementsTrait(Object.getPrototypeOf(obj), trait);
throw new TypeError(`@AbstractProperty: the property '${String(propertyKey)}' should not be defined.`);
}
}
else {
return false;
}
};
}
function ImplementsTraits(obj, traits) {
return traits.every((trait) => ImplementsTrait(obj, trait));
function CreateAbstractMethod(propertyKey) {
return () => {
AbstractMethodCall(propertyKey);
};
}
function TraitFromClass(classTrait) {
return classTrait.prototype;
function CreateAbstractMethodCallError(propertyKey) {
return (propertyKey === void 0)
? new Error(`Cannot call an abstract method`)
: new Error(`Cannot call the abstract method '${String(propertyKey)}'`);
}
function TraitsFromClasses(...classTrait) {
return classTrait.map(TraitFromClass);
function AbstractMethodCall(propertyKey) {
throw CreateAbstractMethodCallError(propertyKey);
}
exports.AbstractMethod = AbstractMethod;
exports.AbstractMethodCall = AbstractMethodCall;
exports.BaseClass = BaseClass;
exports.BindDescriptor = BindDescriptor;
exports.BindDescriptorOld = BindDescriptorOld;
exports.CallTraitFunctionAsMethod = CallTraitFunctionAsMethod;
exports.CallTraitFunctionOrFallback = CallTraitFunctionOrFallback;
exports.CallTraitMethodOrFallback = CallTraitMethodOrFallback;
exports.ClassToFactory = ClassToFactory;

@@ -506,21 +770,37 @@ exports.ConstructClassWithPrivateMembers = ConstructClassWithPrivateMembers;

exports.CopyProperties = CopyProperties;
exports.CreateAbstractMethod = CreateAbstractMethod;
exports.CreateAbstractMethodCallError = CreateAbstractMethodCallError;
exports.DERIVED_FUNCTION_TO_FUNCTION_MAP = DERIVED_FUNCTION_TO_FUNCTION_MAP;
exports.DerivableFunction = DerivableFunction;
exports.EXCLUDED_PROPERTY_NAMES = EXCLUDED_PROPERTY_NAMES;
exports.FUNCTION_TO_DERIVED_FUNCTIONS_MAP = FUNCTION_TO_DERIVED_FUNCTIONS_MAP;
exports.GenerateOverrideSuperArgumentsFunction = GenerateOverrideSuperArgumentsFunction;
exports.GetImplementForOptionsConfigurable = GetImplementForOptionsConfigurable;
exports.GetImplementForOptionsEnumerable = GetImplementForOptionsEnumerable;
exports.GetImplementForOptionsWritable = GetImplementForOptionsWritable;
exports.GetOwnPropertyDescriptors = GetOwnPropertyDescriptors;
exports.GetOwnPropertyKeys = GetOwnPropertyKeys;
exports.GetPropertyDescriptors = GetPropertyDescriptors;
exports.GetPrototypesChain = GetPrototypesChain;
exports.GetSafePropertyDescriptors = GetSafePropertyDescriptors;
exports.GetSetSuperArgsFunction = GetSetSuperArgsFunction;
exports.HasFactoryWaterMark = HasFactoryWaterMark;
exports.ImplementTraits = ImplementTraits;
exports.ImplementsTrait = ImplementsTrait;
exports.ImplementsTraits = ImplementsTraits;
exports.HasOwnProperty = HasOwnProperty;
exports.ImplementFunctionFor = ImplementFunctionFor;
exports.IsFactoryClass = IsFactoryClass;
exports.IsFunctionDerivedFrom = IsFunctionDerivedFrom;
exports.IsFunctionOrDerivedImplementedBy = IsFunctionOrDerivedImplementedBy;
exports.IsFunctionOrParentImplementedBy = IsFunctionOrParentImplementedBy;
exports.IsInstanceOf = IsInstanceOf;
exports.IsNotPrimitivePropertyName = IsNotPrimitivePropertyName;
exports.IsNotPrimitivePrototype = IsNotPrimitivePrototype;
exports.IsPrimitivePropertyName = IsPrimitivePropertyName;
exports.IsPrimitivePrototype = IsPrimitivePrototype;
exports.MakeFactory = MakeFactory;
exports.MixOverrideSuperArgumentsFunction = MixOverrideSuperArgumentsFunction;
exports.ObjectHasOwnProperty = ObjectHasOwnProperty;
exports.OwnArguments = OwnArguments;
exports.PRIMITIVE_PROPERTY_NAMES = PRIMITIVE_PROPERTY_NAMES;
exports.PRIMITIVE_PROTOTYPES = PRIMITIVE_PROTOTYPES;
exports.PROTECTED = PROTECTED;
exports.RegisterTraits = RegisterTraits;
exports.RegisterDerivedFunction = RegisterDerivedFunction;
exports.SearchSuperClass = SearchSuperClass;

@@ -533,5 +813,8 @@ exports.SetClassName = SetClassName;

exports.SuperTrait = SuperTrait;
exports.TRAITS = TRAITS;
exports.Trait = Trait;
exports.TraitFromClass = TraitFromClass;
exports.TraitsFromClasses = TraitsFromClasses;
exports.TraitFunction = TraitFunction;
exports.TraitFunctionsFromClass = TraitFunctionsFromClass;
exports.TraitFunctionsFromObject = TraitFunctionsFromObject;
exports.TraitFunctionsFromObjectPrototypeChain = TraitFunctionsFromObjectPrototypeChain;

@@ -538,0 +821,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],t):t((e=e||self)["class-factory"]={})}(this,(function(e){"use strict";class t{}const n=Symbol("instanceof");function r(e,t){const r=Symbol.hasInstance in e?e[Symbol.hasInstance].bind(e):()=>!1;Object.defineProperty(e,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value:e=>e instanceof t||r(e)}),n in t||Object.defineProperty(t,n,{value:new Set}),t[n].add(e)}const o=new Set(["prototype","constructor",...c(Object.prototype)]);function c(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}function*s(e){const t=c(e);for(let n=0,r=t.length;n<r;n++){const r=t[n];yield[r,Object.getOwnPropertyDescriptor(e,r),e]}}function*i(e){const t=new Set;for(;null!==e;){const n=c(e);for(const r of n)t.has(r)||(t.add(r),yield[r,Object.getOwnPropertyDescriptor(e,r),e]);e=Object.getPrototypeOf(e)}}function a(e,t,n=o){const r=i(e);let c;for(;!(c=r.next()).done;){const[e,r]=c.value;n.has(e)||Object.defineProperty(t,e,r)}}function u(e,t,n){a(e.prototype,t.prototype,n)}function l(e,t,n){a(e,t,n)}function f(e,t){Object.defineProperty(e,"name",{configurable:!0,enumerable:!1,value:t,writable:!1})}function p(e,t){u(e,t),l(e,t),r(e,t)}function y(e,t,n){const r={};if(r.configurable=n.configurable,r.enumerable=n.enumerable,void 0!==n.value){let o,c;r.get=()=>"function"==typeof e[t]?(o!==e[t]&&(o=e[t],c=o.bind(e)),c):e[t],n.writable&&(r.set=n=>{e[t]=n})}else"function"==typeof n.get&&(r.get=n.get.bind(e)),"function"==typeof n.set&&(r.set=n.set.bind(e));return r}function b(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const d=Symbol("is-factory-class");function O(e,t=!0){return!0===e[d]&&(!t||e.hasOwnProperty(d))}function g(e,t){let n=0;for(;null!==e;){if(t(e))return{index:n,ctor:e};n++,e=Object.getPrototypeOf(e)}return null}function m(e,t){if(Array.isArray(e[0]))return e[0]=t,e;throw new TypeError("Expected array as argument 0")}function h(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n];return e}const P=Symbol("protected");const w=Symbol("traits");function j(e,t){if(b(e,w)){const n=e[w];for(let e=0,r=t.length;e<r;e++)n.add(t[e])}else Object.defineProperty(e,w,{value:new WeakSet(t),writable:!1,enumerable:!1,configurable:!1})}function S(e,t){j(e,t);for(let n=0,r=t.length;n<r;n++){const r=t[n];if(null===r||"object"!=typeof r||Object.getPrototypeOf(r)!==Object.prototype)throw new Error("The trait must be a plain object");{const t=s(r);let n;for(;!(n=t.next()).done;){const[t,r]=n.value;if("constructor"!==t&&t!==w){if(b(e,t))throw new Error(`The property '${String(t)}' is already implemented`);Object.defineProperty(e,t,r)}}}}return e}function v(e,t){return null!==e&&"object"==typeof e&&(!(!b(e,w)||!e[w].has(t))||v(Object.getPrototypeOf(e),t))}function C(e){return e.prototype}e.BaseClass=t,e.BindDescriptor=function(e,t,n){const r={};if(r.configurable=n.configurable,r.enumerable=n.enumerable,void 0!==n.value){let o=new WeakMap;r.get=function(){const n=e(this),r=Reflect.get(n,t);return"function"==typeof r?(o.has(r)||o.set(r,r.bind(n)),o.get(r)):r},n.writable&&(r.set=function(n){const r=e(this);Reflect.set(r,t,n)})}else"function"==typeof n.get&&(r.get=function(){const t=e(this);return n.get.call(t)}),"function"==typeof n.set&&(r.set=function(t){const r=e(this);return n.set.call(r,t)});return r},e.BindDescriptorOld=y,e.ClassToFactory=function(e){return function(n,s="auto"){let a;return n===Object||n===t?(a=class extends e{constructor(e){super(...e)}},r(n,a)):(a=class extends n{constructor(...t){const n=t[0];let r;switch(super(...t.slice(1)),s){case"auto":try{r=e.apply(this,n),void 0===r&&(r=this),s="function"}catch(t){r=Reflect.construct(e,n),s="class"}break;case"function":r=e.apply(this,n),void 0===r&&(r=this);break;case"class":r=Reflect.construct(e,n)}if(this!==r){const e=i(Object.getPrototypeOf(r));let t;for(;!(t=e.next()).done;){const e=t.value[0];o.has(e)||Object.defineProperty(this,e,y(r,e,t.value[1]))}const n=c(r);for(const e of n)o.has(e)||(e in this&&console.warn("Crossing properties !"),Object.defineProperty(this,e,y(r,e,Object.getOwnPropertyDescriptor(r,e))));Object.seal(r)}}},p(e,a)),f(a,e.name),a}},e.ConstructClassWithPrivateMembers=function(e,t){Object.defineProperty(e,t,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.ConstructClassWithProtectedMembers=function(e){Object.defineProperty(e,P,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.CopyClass=p,e.CopyClassName=function(e,t){let n=Object.getOwnPropertyDescriptor(e,"name");void 0===n?n={configurable:!0,enumerable:!1,value:e.name,writable:!1}:n.value=e.name,n.configurable&&Object.defineProperty(t,"name",n)},e.CopyClassPrototype=u,e.CopyClassStaticProperties=l,e.CopyOwnProperties=function(e,t,n=o){const r=c(e);for(const o of r){const r=Object.getOwnPropertyDescriptor(e,o);void 0===r||n.has(o)||Object.defineProperty(t,o,r)}},e.CopyProperties=a,e.EXCLUDED_PROPERTY_NAMES=o,e.GenerateOverrideSuperArgumentsFunction=function(e,t){const n=g(e,t);if(null===n)throw new Error("Failed to find super class of the class "+e.name);{const e=n.index;return O(n.ctor)?(t,n)=>{if(Array.isArray(t[e]))return t.slice(0,e).concat([n(t[e])]).concat(t.slice(e+1));throw new TypeError(`Expected array as argument[${e}]`)}:(t,n)=>t.slice(0,e).concat(n(t.slice(e)))}},e.GetOwnPropertyDescriptors=s,e.GetOwnPropertyKeys=c,e.GetPropertyDescriptors=i,e.GetSafePropertyDescriptors=function*(e){const t=i(e);let n;for(;!(n=t.next()).done;){const[e,,t]=n.value;t===Object.prototype||t===Function.prototype||o.has(e)||(yield n.value)}},e.GetSetSuperArgsFunction=function(e){return e?m:h},e.HasFactoryWaterMark=function(e,t,n=!0){return!0===e[t]&&(!n||e.hasOwnProperty(t))},e.ImplementTraits=S,e.ImplementsTrait=v,e.ImplementsTraits=function(e,t){return t.every(t=>v(e,t))},e.IsFactoryClass=O,e.IsInstanceOf=function(e,t){return e instanceof t||!(!e.constructor||!(n in e.constructor))&&e.constructor[n].has(t)},e.MakeFactory=function(e,t,n,o={}){let c=n;for(let e=t.length-1;e>=0;e--)c=t[e](c);const s=e(c);if(Object.defineProperty(s,d,{value:!0}),"string"==typeof o.name&&Object.defineProperty(s,"name",{configurable:!0,enumerable:!1,value:o.name,writable:!1}),Array.isArray(o.waterMarks))for(let e=0,t=o.waterMarks.length;e<t;e++)Object.defineProperty(s,o.waterMarks[e],{value:!0});return void 0!==o.instanceOf&&r(o.instanceOf,s),s},e.MixOverrideSuperArgumentsFunction=function(...e){return(t,...n)=>{for(let r=0,o=e.length;r<o;r++)t=e[r](t,n[r]);return t}},e.ObjectHasOwnProperty=b,e.OwnArguments=function(e){return e[0]},e.PROTECTED=P,e.RegisterTraits=j,e.SearchSuperClass=g,e.SetClassName=f,e.SetInstanceOf=r,e.SetSuperArgsForFactoryClass=m,e.SetSuperArgsForStandardClass=h,e.SuperArguments=function(e){return e.slice(1)},e.SuperTrait=function(e,t){const n=class extends t{};return S(n.prototype,e),n},e.TRAITS=w,e.TraitFromClass=C,e.TraitsFromClasses=function(...e){return e.map(C)},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],t):t((e=e||self)["class-factory"]={})}(this,(function(e){"use strict";class t{}const r=Symbol("instanceof");function n(e,t){const n=Symbol.hasInstance in e?e[Symbol.hasInstance].bind(e):()=>!1;Object.defineProperty(e,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value:e=>e instanceof t||n(e)}),r in t||Object.defineProperty(t,r,{value:new Set}),t[r].add(e)}function o(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}function*i(e){const t=o(e);for(let r=0,n=t.length;r<n;r++){const n=t[r];yield[n,Object.getOwnPropertyDescriptor(e,n),e]}}const s=new Set(["prototype","constructor"]);function c(e){return s.has(e)}function a(e){return!c(e)}function*u(e){for(;null!==e;)yield e,e=Object.getPrototypeOf(e)}const l=new Set(["",0,{},[],()=>{}].map(e=>Object.getPrototypeOf(e)));function f(e){return l.has(e)}function p(e){return!f(e)}const y=new Set(["prototype","constructor",...o(Object.prototype)]);function*d(e){const t=new Set;for(;null!==e;){const r=o(e);for(const n of r)t.has(n)||(t.add(n),yield[n,Object.getOwnPropertyDescriptor(e,n),e]);e=Object.getPrototypeOf(e)}}function h(e,t,r=y){const n=d(e);let o;for(;!(o=n.next()).done;){const[e,n]=o.value;r.has(e)||Object.defineProperty(t,e,n)}}function b(e,t,r){h(e.prototype,t.prototype,r)}function m(e,t,r){h(e,t,r)}function g(e,t){Object.defineProperty(e,"name",{configurable:!0,enumerable:!1,value:t,writable:!1})}function w(e,t){b(e,t),m(e,t),n(e,t)}function O(e,t,r){const n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){let o,i;n.get=()=>"function"==typeof e[t]?(o!==e[t]&&(o=e[t],i=o.bind(e)),i):e[t],r.writable&&(n.set=r=>{e[t]=r})}else"function"==typeof r.get&&(n.get=r.get.bind(e)),"function"==typeof r.set&&(n.set=r.set.bind(e));return n}const v=Symbol("is-factory-class");function F(e,t=!0){return!0===e[v]&&(!t||e.hasOwnProperty(v))}function P(e,t){let r=0;for(;null!==e;){if(t(e))return{index:r,ctor:e};r++,e=Object.getPrototypeOf(e)}return null}function C(e,t){if(Array.isArray(e[0]))return e[0]=t,e;throw new TypeError("Expected array as argument 0")}function S(e,t){for(let r=0,n=t.length;r<n;r++)e[r]=t[r];return e}const j=Symbol("protected");function I(e,t,r,n){return e.isImplementedBy(t)?t[e.propertyKey](...r):n.apply(t,r)}const T=new WeakMap,E=new WeakMap;function A(e,t){if(T.has(t)){if(T.get(t)!==e)throw new Error("Derived function already registered as derived from: "+String(T.get(t)))}else{if(D(e,t))throw new Error("Derived function already registered as derived from: "+String(T.get(t)));T.set(t,e),E.has(e)?E.get(e).push(t):E.set(e,[t])}}function D(e,t){for(;;){if(e===t)return!0;if(!T.has(e))return!1;e=T.get(e)}}function M(e){return void 0!==e&&void 0!==e.enumerable&&e.enumerable}function x(e){return void 0===e||void 0===e.configurable||e.configurable}function K(e){return void 0!==e&&void 0!==e.writable&&e.writable}function N(e,t,r,n){if(t in e&&!_(e,t,r))throw new Error(`The property '${String(t)}' is already implemented`);return Object.defineProperty(e,t,{value:r,enumerable:M(n),configurable:x(n),writable:K(n)}),e}function R(e,t,r){return"function"==typeof e[t]&&D(e[t],r)}function _(e,t,r){return"function"==typeof e[t]&&D(r,e[t])}class k{constructor(e){this.fnc=e}derive(e){return A(this.fnc,e),new k(e)}call(e,...t){return this.fnc.call(e,...t)}isDerivedFrom(e){return D(this.fnc,e.fnc)}equals(e){return e.fnc===this.fnc}}class B extends k{constructor(e,t,r){super(t),this.propertyKey=e,this.enumerable=M(r),this.configurable=x(r),this.writable=K(r)}derive(e,t){return A(this.fnc,e),new B(this.propertyKey,e,{enumerable:this.enumerable,configurable:this.configurable,writable:this.writable,...t})}derivedFrom(e,t){return A(e,this.fnc),new B(this.propertyKey,e,{enumerable:this.enumerable,configurable:this.configurable,writable:this.writable,...t})}implementFor(e,t){return N(e,this.propertyKey,this.fnc,{enumerable:this.enumerable,configurable:this.configurable,writable:this.writable,...t})}isImplementedBy(e){return R(e,this.propertyKey,this.fnc)}equals(e){return super.equals(e)&&e.propertyKey===this.propertyKey}}class G{constructor(e){this.traitFunctions=Object.freeze(Array.from(e));for(let e=0,t=this.traitFunctions.length-1;e<t;e++){const r=this.traitFunctions[e];for(let n=e+1;n<=t;n++)if(r.propertyKey===this.traitFunctions[n].propertyKey)throw new Error(`Received two TraitFunction with the same property key '${String(r.propertyKey)}' at index ${e} and ${n}`)}}static mix(...e){return new G(e.map(e=>e.traitFunctions).flat())}get(e){return this.traitFunctions.find(t=>t.propertyKey===e)}derive(e){const t=Array.isArray(e)?e:Array.from(e);return new G(this.traitFunctions.filter(e=>t.every((t,r)=>{if(e.propertyKey===t.propertyKey){if(t.isDerivedFrom(e))return!1;throw new Error(`Received a new TraitFunction with the property key '${String(t.propertyKey)}' at index ${r}, which already exists in this Trait and is not derived from the original`)}return!0})).concat(t))}implementFor(e){for(let t=0,r=this.traitFunctions.length;t<r;t++)this.traitFunctions[t].implementFor(e);return e}isImplementedBy(e){for(let t=0,r=this.traitFunctions.length;t<r;t++)if(!this.traitFunctions[t].isImplementedBy(e))return!1;return!0}isDerivedFrom(e){return e.traitFunctions.length>=this.traitFunctions.length&&this.traitFunctions.every(t=>e.traitFunctions.some(e=>t.isDerivedFrom(e)))}equals(e){return e.traitFunctions.length===this.traitFunctions.length&&this.traitFunctions.every(t=>e.traitFunctions.some(e=>t.equals(e)))}}function $(e,t=new Map){const r=i(e);let n;for(;!(n=r.next()).done;){const[e,r]=n.value;if(a(e)){if("function"!=typeof r.value)throw new Error(`Found property which is not a function: '${String(e)}'`);t.set(e,t.has(e)?t.get(e).derive(r.value,r):new B(e,r.value,r))}}return t}function W(e){const t=Array.from(u(e)).filter(p).reverse(),r=new Map;for(let e=0,n=t.length;e<n;e++)$(t[e],r);return r}function q(e){return W(e.prototype)}function U(e){return()=>{Y(e)}}function V(e){return void 0===e?new Error("Cannot call an abstract method"):new Error(`Cannot call the abstract method '${String(e)}'`)}function Y(e){throw V(e)}e.AbstractMethod=function(){return(e,t,r=Object.getOwnPropertyDescriptor(e,t))=>{if(void 0===r)return{configurable:!1,writable:!1,value:U(t)};throw new TypeError(`@AbstractProperty: the property '${String(t)}' should not be defined.`)}},e.AbstractMethodCall=Y,e.BaseClass=t,e.BindDescriptor=function(e,t,r){const n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){let o=new WeakMap;n.get=function(){const r=e(this),n=Reflect.get(r,t);return"function"==typeof n?(o.has(n)||o.set(n,n.bind(r)),o.get(n)):n},r.writable&&(n.set=function(r){const n=e(this);Reflect.set(n,t,r)})}else"function"==typeof r.get&&(n.get=function(){const t=e(this);return r.get.call(t)}),"function"==typeof r.set&&(n.set=function(t){const n=e(this);return r.set.call(n,t)});return n},e.BindDescriptorOld=O,e.CallTraitFunctionAsMethod=function(e,t,r){return e.isImplementedBy(t)?t[e.propertyKey](...r):e.fnc.apply(t,r)},e.CallTraitFunctionOrFallback=I,e.CallTraitMethodOrFallback=function(e,t,r,n,o){const i=e.get(r);return void 0===i?o(t,...n):I(i,t,n,o)},e.ClassToFactory=function(e){return function(r,i="auto"){let s;return r===Object||r===t?(s=class extends e{constructor(e){super(...e)}},n(r,s)):(s=class extends r{constructor(...t){const r=t[0];let n;switch(super(...t.slice(1)),i){case"auto":try{n=e.apply(this,r),void 0===n&&(n=this),i="function"}catch(t){n=Reflect.construct(e,r),i="class"}break;case"function":n=e.apply(this,r),void 0===n&&(n=this);break;case"class":n=Reflect.construct(e,r)}if(this!==n){const e=d(Object.getPrototypeOf(n));let t;for(;!(t=e.next()).done;){const e=t.value[0];y.has(e)||Object.defineProperty(this,e,O(n,e,t.value[1]))}const r=o(n);for(const e of r)y.has(e)||(e in this&&console.warn("Crossing properties !"),Object.defineProperty(this,e,O(n,e,Object.getOwnPropertyDescriptor(n,e))));Object.seal(n)}}},w(e,s)),g(s,e.name),s}},e.ConstructClassWithPrivateMembers=function(e,t){Object.defineProperty(e,t,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.ConstructClassWithProtectedMembers=function(e){Object.defineProperty(e,j,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.CopyClass=w,e.CopyClassName=function(e,t){let r=Object.getOwnPropertyDescriptor(e,"name");void 0===r?r={configurable:!0,enumerable:!1,value:e.name,writable:!1}:r.value=e.name,r.configurable&&Object.defineProperty(t,"name",r)},e.CopyClassPrototype=b,e.CopyClassStaticProperties=m,e.CopyOwnProperties=function(e,t,r=y){const n=o(e);for(const o of n){const n=Object.getOwnPropertyDescriptor(e,o);void 0===n||r.has(o)||Object.defineProperty(t,o,n)}},e.CopyProperties=h,e.CreateAbstractMethod=U,e.CreateAbstractMethodCallError=V,e.DERIVED_FUNCTION_TO_FUNCTION_MAP=T,e.DerivableFunction=k,e.EXCLUDED_PROPERTY_NAMES=y,e.FUNCTION_TO_DERIVED_FUNCTIONS_MAP=E,e.GenerateOverrideSuperArgumentsFunction=function(e,t){const r=P(e,t);if(null===r)throw new Error("Failed to find super class of the class "+e.name);{const e=r.index;return F(r.ctor)?(t,r)=>{if(Array.isArray(t[e]))return t.slice(0,e).concat([r(t[e])]).concat(t.slice(e+1));throw new TypeError(`Expected array as argument[${e}]`)}:(t,r)=>t.slice(0,e).concat(r(t.slice(e)))}},e.GetImplementForOptionsConfigurable=x,e.GetImplementForOptionsEnumerable=M,e.GetImplementForOptionsWritable=K,e.GetOwnPropertyDescriptors=i,e.GetOwnPropertyKeys=o,e.GetPropertyDescriptors=d,e.GetPrototypesChain=u,e.GetSafePropertyDescriptors=function*(e){const t=d(e);let r;for(;!(r=t.next()).done;){const[e,,t]=r.value;t===Object.prototype||t===Function.prototype||y.has(e)||(yield r.value)}},e.GetSetSuperArgsFunction=function(e){return e?C:S},e.HasFactoryWaterMark=function(e,t,r=!0){return!0===e[t]&&(!r||e.hasOwnProperty(t))},e.HasOwnProperty=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.ImplementFunctionFor=N,e.IsFactoryClass=F,e.IsFunctionDerivedFrom=D,e.IsFunctionOrDerivedImplementedBy=R,e.IsFunctionOrParentImplementedBy=_,e.IsInstanceOf=function(e,t){return e instanceof t||!(!e.constructor||!(r in e.constructor))&&e.constructor[r].has(t)},e.IsNotPrimitivePropertyName=a,e.IsNotPrimitivePrototype=p,e.IsPrimitivePropertyName=c,e.IsPrimitivePrototype=f,e.MakeFactory=function(e,t,r,o={}){let i=r;for(let e=t.length-1;e>=0;e--)i=t[e](i);const s=e(i);if(Object.defineProperty(s,v,{value:!0}),"string"==typeof o.name&&Object.defineProperty(s,"name",{configurable:!0,enumerable:!1,value:o.name,writable:!1}),Array.isArray(o.waterMarks))for(let e=0,t=o.waterMarks.length;e<t;e++)Object.defineProperty(s,o.waterMarks[e],{value:!0});return void 0!==o.instanceOf&&n(o.instanceOf,s),s},e.MixOverrideSuperArgumentsFunction=function(...e){return(t,...r)=>{for(let n=0,o=e.length;n<o;n++)t=e[n](t,r[n]);return t}},e.OwnArguments=function(e){return e[0]},e.PRIMITIVE_PROPERTY_NAMES=s,e.PRIMITIVE_PROTOTYPES=l,e.PROTECTED=j,e.RegisterDerivedFunction=A,e.SearchSuperClass=P,e.SetClassName=g,e.SetInstanceOf=n,e.SetSuperArgsForFactoryClass=C,e.SetSuperArgsForStandardClass=S,e.SuperArguments=function(e){return e.slice(1)},e.SuperTrait=function(e,t){const r=void 0===t?class{}:class extends t{};return e.implementFor(r.prototype),r},e.Trait=G,e.TraitFromClass=function(e){return new G(q(e).values())},e.TraitFunction=B,e.TraitFunctionsFromClass=q,e.TraitFunctionsFromObject=$,e.TraitFunctionsFromObjectPrototypeChain=W,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=class-factory.esnext.umd.min.js.map

@@ -42,2 +42,13 @@ (function (global, factory) {

var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __generator(thisArg, body) {

@@ -106,3 +117,2 @@ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;

var EXCLUDED_PROPERTY_NAMES = new Set(__spreadArrays(['prototype', 'constructor'], GetOwnPropertyKeys(Object.prototype)));
function GetOwnPropertyKeys(target) {

@@ -112,2 +122,5 @@ return Object.getOwnPropertyNames(target)

}
function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
function GetOwnPropertyDescriptors(target) {

@@ -135,2 +148,31 @@ var keys, i, l, key;

}
var PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
function IsPrimitivePropertyName(name) {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
function GetPrototypesChain(target) {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(target !== null)) return [3, 2];
return [4, target];
case 1:
_a.sent();
target = Object.getPrototypeOf(target);
return [3, 0];
case 2: return [2];
}
});
}
var PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], function () { }].map(function (_) { return Object.getPrototypeOf(_); }));
function IsPrimitivePrototype(proto) {
return PRIMITIVE_PROTOTYPES.has(proto);
}
function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
var EXCLUDED_PROPERTY_NAMES = new Set(__spreadArrays(['prototype', 'constructor'], GetOwnPropertyKeys(Object.prototype)));
function GetPropertyDescriptors(target) {

@@ -324,5 +366,2 @@ var _keys, keys, _i, keys_1, key;

}
function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}
//# sourceMappingURL=helpers.js.map

@@ -558,48 +597,289 @@

var TRAITS = Symbol('traits');
function RegisterTraits(obj, traits) {
if (ObjectHasOwnProperty(obj, TRAITS)) {
var _traits = obj[TRAITS];
for (var i = 0, l = traits.length; i < l; i++) {
_traits.add(traits[i]);
function CallTraitFunctionAsMethod(traitFunction, target, args) {
var _a;
if (traitFunction.isImplementedBy(target)) {
return (_a = target)[traitFunction.propertyKey].apply(_a, args);
}
else {
return traitFunction.fnc.apply(target, args);
}
}
function CallTraitFunctionOrFallback(traitFunction, target, args, fallback) {
var _a;
if (traitFunction.isImplementedBy(target)) {
return (_a = target)[traitFunction.propertyKey].apply(_a, args);
}
else {
return fallback.apply(target, args);
}
}
function CallTraitMethodOrFallback(trait, target, methodName, args, fallback) {
var traitFunction = trait.get(methodName);
if (traitFunction === void 0) {
return fallback.apply(void 0, __spreadArrays([target], args));
}
else {
return CallTraitFunctionOrFallback(traitFunction, target, args, fallback);
}
}
//# sourceMappingURL=call-trait-function.js.map
var DERIVED_FUNCTION_TO_FUNCTION_MAP = new WeakMap();
var FUNCTION_TO_DERIVED_FUNCTIONS_MAP = new WeakMap();
function RegisterDerivedFunction(parentFunction, derivedFunction) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(derivedFunction)) {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction) !== parentFunction) {
throw new Error("Derived function already registered as derived from: " + String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction)));
}
}
else if (IsFunctionDerivedFrom(parentFunction, derivedFunction)) {
throw new Error("Derived function already registered as derived from: " + String(DERIVED_FUNCTION_TO_FUNCTION_MAP.get(derivedFunction)));
}
else {
Object.defineProperty(obj, TRAITS, {
value: new WeakSet(traits),
writable: false,
enumerable: false,
configurable: false,
DERIVED_FUNCTION_TO_FUNCTION_MAP.set(derivedFunction, parentFunction);
if (FUNCTION_TO_DERIVED_FUNCTIONS_MAP.has(parentFunction)) {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.get(parentFunction).push(derivedFunction);
}
else {
FUNCTION_TO_DERIVED_FUNCTIONS_MAP.set(parentFunction, [derivedFunction]);
}
}
}
function IsFunctionDerivedFrom(functionToTest, parentFunction) {
while (true) {
if (functionToTest === parentFunction) {
return true;
}
else {
if (DERIVED_FUNCTION_TO_FUNCTION_MAP.has(functionToTest)) {
functionToTest = DERIVED_FUNCTION_TO_FUNCTION_MAP.get(functionToTest);
}
else {
return false;
}
}
}
}
function GetImplementForOptionsEnumerable(options) {
return ((options === void 0) || (options.enumerable === void 0)) ? false : options.enumerable;
}
function GetImplementForOptionsConfigurable(options) {
return ((options === void 0) || (options.configurable === void 0)) ? true : options.configurable;
}
function GetImplementForOptionsWritable(options) {
return ((options === void 0) || (options.writable === void 0)) ? false : options.writable;
}
function ImplementFunctionFor(target, propertyKey, functionToImplement, options) {
if ((propertyKey in target) && !IsFunctionOrParentImplementedBy(target, propertyKey, functionToImplement)) {
throw new Error("The property '" + String(propertyKey) + "' is already implemented");
}
else {
Object.defineProperty(target, propertyKey, {
value: functionToImplement,
enumerable: GetImplementForOptionsEnumerable(options),
configurable: GetImplementForOptionsConfigurable(options),
writable: GetImplementForOptionsWritable(options),
});
}
return target;
}
function ImplementTraits(obj, traits) {
RegisterTraits(obj, traits);
for (var i = 0, l = traits.length; i < l; i++) {
var trait = traits[i];
if ((trait !== null)
&& (typeof trait === 'object')
&& (Object.getPrototypeOf(trait) === Object.prototype)) {
var iterator = GetOwnPropertyDescriptors(trait);
var result = void 0;
while (!(result = iterator.next()).done) {
var _a = result.value, propertyKey = _a[0], descriptor = _a[1];
if ((propertyKey !== 'constructor') && (propertyKey !== TRAITS)) {
if (ObjectHasOwnProperty(obj, propertyKey)) {
throw new Error("The property '" + String(propertyKey) + "' is already implemented");
function IsFunctionOrDerivedImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(target[propertyKey], functionToTest);
}
function IsFunctionOrParentImplementedBy(target, propertyKey, functionToTest) {
return (typeof target[propertyKey] === 'function')
&& IsFunctionDerivedFrom(functionToTest, target[propertyKey]);
}
var DerivableFunction = (function () {
function DerivableFunction(fnc) {
this.fnc = fnc;
}
DerivableFunction.prototype.derive = function (fnc) {
RegisterDerivedFunction(this.fnc, fnc);
return new DerivableFunction(fnc);
};
DerivableFunction.prototype.call = function (instance) {
var _a;
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return (_a = this.fnc).call.apply(_a, __spreadArrays([instance], args));
};
DerivableFunction.prototype.isDerivedFrom = function (derivableFunction) {
return IsFunctionDerivedFrom(this.fnc, derivableFunction.fnc);
};
DerivableFunction.prototype.equals = function (derivableFunction) {
return derivableFunction.fnc === this.fnc;
};
return DerivableFunction;
}());
//# sourceMappingURL=derivable-function-class.js.map
var TraitFunction = (function (_super) {
__extends(TraitFunction, _super);
function TraitFunction(propertyKey, fnc, options) {
var _this = _super.call(this, fnc) || this;
_this.propertyKey = propertyKey;
_this.enumerable = GetImplementForOptionsEnumerable(options);
_this.configurable = GetImplementForOptionsConfigurable(options);
_this.writable = GetImplementForOptionsWritable(options);
return _this;
}
TraitFunction.prototype.derive = function (derivedFunction, options) {
RegisterDerivedFunction(this.fnc, derivedFunction);
return new TraitFunction(this.propertyKey, derivedFunction, __assign({ enumerable: this.enumerable, configurable: this.configurable, writable: this.writable }, options));
};
TraitFunction.prototype.derivedFrom = function (parentFunction, options) {
RegisterDerivedFunction(parentFunction, this.fnc);
return new TraitFunction(this.propertyKey, parentFunction, __assign({ enumerable: this.enumerable, configurable: this.configurable, writable: this.writable }, options));
};
TraitFunction.prototype.implementFor = function (target, options) {
return ImplementFunctionFor(target, this.propertyKey, this.fnc, __assign({ enumerable: this.enumerable, configurable: this.configurable, writable: this.writable }, options));
};
TraitFunction.prototype.isImplementedBy = function (target) {
return IsFunctionOrDerivedImplementedBy(target, this.propertyKey, this.fnc);
};
TraitFunction.prototype.equals = function (traitFunction) {
return _super.prototype.equals.call(this, traitFunction)
&& (traitFunction.propertyKey === this.propertyKey);
};
return TraitFunction;
}(DerivableFunction));
//# sourceMappingURL=trait-function-class.js.map
var Trait = (function () {
function Trait(traitFunctions) {
this.traitFunctions = Object.freeze(Array.from(traitFunctions));
for (var i = 0, l = this.traitFunctions.length - 1; i < l; i++) {
var traitFunction = this.traitFunctions[i];
for (var j = i + 1; j <= l; j++) {
if (traitFunction.propertyKey === this.traitFunctions[j].propertyKey) {
throw new Error("Received two TraitFunction with the same property key '" + String(traitFunction.propertyKey) + "' at index " + i + " and " + j);
}
}
}
}
Trait.mix = function () {
var traits = [];
for (var _i = 0; _i < arguments.length; _i++) {
traits[_i] = arguments[_i];
}
return new Trait((traits
.map(function (trait) {
return trait.traitFunctions;
})
.flat()));
};
Trait.prototype.get = function (propertyKey) {
return this.traitFunctions.find(function (traitFunction) {
return traitFunction.propertyKey === propertyKey;
});
};
Trait.prototype.derive = function (traitFunctions) {
var traitFunctionsAsArray = Array.isArray(traitFunctions)
? traitFunctions
: Array.from(traitFunctions);
return new Trait((this.traitFunctions
.filter(function (traitFunctionA) {
return traitFunctionsAsArray.every(function (traitFunctionB, index) {
if (traitFunctionA.propertyKey === traitFunctionB.propertyKey) {
if (traitFunctionB.isDerivedFrom(traitFunctionA)) {
return false;
}
else {
Object.defineProperty(obj, propertyKey, descriptor);
throw new Error("Received a new TraitFunction with the property key '" + String(traitFunctionB.propertyKey) + "' at index " + index + ", which already exists in this Trait and is not derived from the original");
}
}
else {
return true;
}
});
})
.concat(traitFunctionsAsArray)));
};
Trait.prototype.implementFor = function (target) {
for (var i = 0, l = this.traitFunctions.length; i < l; i++) {
this.traitFunctions[i].implementFor(target);
}
return target;
};
Trait.prototype.isImplementedBy = function (target) {
for (var i = 0, l = this.traitFunctions.length; i < l; i++) {
if (!this.traitFunctions[i].isImplementedBy(target)) {
return false;
}
}
return true;
};
Trait.prototype.isDerivedFrom = function (trait) {
if (trait.traitFunctions.length >= this.traitFunctions.length) {
return this.traitFunctions.every(function (traitFunctionA) {
return trait.traitFunctions.some(function (traitFunctionB) {
return traitFunctionA.isDerivedFrom(traitFunctionB);
});
});
}
else {
throw new Error("The trait must be a plain object");
return false;
}
};
Trait.prototype.equals = function (trait) {
if (trait.traitFunctions.length === this.traitFunctions.length) {
return this.traitFunctions.every(function (traitFunctionA) {
return trait.traitFunctions.some(function (traitFunctionB) {
return traitFunctionA.equals(traitFunctionB);
});
});
}
else {
return false;
}
};
return Trait;
}());
function TraitFunctionsFromObject(target, parentTraitFunctionsMap) {
if (parentTraitFunctionsMap === void 0) { parentTraitFunctionsMap = new Map(); }
var iterator = GetOwnPropertyDescriptors(target);
var result;
while (!(result = iterator.next()).done) {
var _a = result.value, propertyKey = _a[0], descriptor = _a[1];
if (IsNotPrimitivePropertyName(propertyKey)) {
if (typeof descriptor.value === 'function') {
parentTraitFunctionsMap.set(propertyKey, ((parentTraitFunctionsMap.has(propertyKey))
? parentTraitFunctionsMap.get(propertyKey).derive(descriptor.value, descriptor)
: new TraitFunction(propertyKey, descriptor.value, descriptor)));
}
else {
throw new Error("Found property which is not a function: '" + String(propertyKey) + "'");
}
}
}
return obj;
return parentTraitFunctionsMap;
}
function SuperTrait(traits, baseClass) {
var TraitClass = (function (_super) {
function TraitFunctionsFromObjectPrototypeChain(target) {
var prototypes = Array.from(GetPrototypesChain(target)).filter(IsNotPrimitivePrototype).reverse();
var parentTraitFunctionsMap = new Map();
for (var i = 0, li = prototypes.length; i < li; i++) {
TraitFunctionsFromObject(prototypes[i], parentTraitFunctionsMap);
}
return parentTraitFunctionsMap;
}
function TraitFunctionsFromClass(_class) {
return TraitFunctionsFromObjectPrototypeChain(_class.prototype);
}
function TraitFromClass(_class) {
return new Trait(TraitFunctionsFromClass(_class).values());
}
function SuperTrait(trait, baseClass) {
var TraitClass = (baseClass === void 0)
? (function () {
function TraitClass() {
}
return TraitClass;
}()) : (function (_super) {
__extends(TraitClass, _super);

@@ -611,38 +891,44 @@ function TraitClass() {

}(baseClass));
ImplementTraits(TraitClass.prototype, traits);
trait.implementFor(TraitClass.prototype);
return TraitClass;
}
function ImplementsTrait(obj, trait) {
if ((obj !== null)
&& (typeof obj === 'object')) {
if (ObjectHasOwnProperty(obj, TRAITS)
&& obj[TRAITS].has(trait)) {
return true;
//# sourceMappingURL=super-trait.js.map
function AbstractMethod() {
return function (target, propertyKey, descriptor) {
if (descriptor === void 0) { descriptor = Object.getOwnPropertyDescriptor(target, propertyKey); }
if (descriptor === void 0) {
return {
configurable: false,
writable: false,
value: CreateAbstractMethod(propertyKey),
};
}
else {
return ImplementsTrait(Object.getPrototypeOf(obj), trait);
throw new TypeError("@AbstractProperty: the property '" + String(propertyKey) + "' should not be defined.");
}
}
else {
return false;
}
};
}
function ImplementsTraits(obj, traits) {
return traits.every(function (trait) { return ImplementsTrait(obj, trait); });
function CreateAbstractMethod(propertyKey) {
return function () {
AbstractMethodCall(propertyKey);
};
}
function TraitFromClass(classTrait) {
return classTrait.prototype;
function CreateAbstractMethodCallError(propertyKey) {
return (propertyKey === void 0)
? new Error("Cannot call an abstract method")
: new Error("Cannot call the abstract method '" + String(propertyKey) + "'");
}
function TraitsFromClasses() {
var classTrait = [];
for (var _i = 0; _i < arguments.length; _i++) {
classTrait[_i] = arguments[_i];
}
return classTrait.map(TraitFromClass);
function AbstractMethodCall(propertyKey) {
throw CreateAbstractMethodCallError(propertyKey);
}
//# sourceMappingURL=traits.js.map
exports.AbstractMethod = AbstractMethod;
exports.AbstractMethodCall = AbstractMethodCall;
exports.BaseClass = BaseClass;
exports.BindDescriptor = BindDescriptor;
exports.BindDescriptorOld = BindDescriptorOld;
exports.CallTraitFunctionAsMethod = CallTraitFunctionAsMethod;
exports.CallTraitFunctionOrFallback = CallTraitFunctionOrFallback;
exports.CallTraitMethodOrFallback = CallTraitMethodOrFallback;
exports.ClassToFactory = ClassToFactory;

@@ -657,21 +943,37 @@ exports.ConstructClassWithPrivateMembers = ConstructClassWithPrivateMembers;

exports.CopyProperties = CopyProperties;
exports.CreateAbstractMethod = CreateAbstractMethod;
exports.CreateAbstractMethodCallError = CreateAbstractMethodCallError;
exports.DERIVED_FUNCTION_TO_FUNCTION_MAP = DERIVED_FUNCTION_TO_FUNCTION_MAP;
exports.DerivableFunction = DerivableFunction;
exports.EXCLUDED_PROPERTY_NAMES = EXCLUDED_PROPERTY_NAMES;
exports.FUNCTION_TO_DERIVED_FUNCTIONS_MAP = FUNCTION_TO_DERIVED_FUNCTIONS_MAP;
exports.GenerateOverrideSuperArgumentsFunction = GenerateOverrideSuperArgumentsFunction;
exports.GetImplementForOptionsConfigurable = GetImplementForOptionsConfigurable;
exports.GetImplementForOptionsEnumerable = GetImplementForOptionsEnumerable;
exports.GetImplementForOptionsWritable = GetImplementForOptionsWritable;
exports.GetOwnPropertyDescriptors = GetOwnPropertyDescriptors;
exports.GetOwnPropertyKeys = GetOwnPropertyKeys;
exports.GetPropertyDescriptors = GetPropertyDescriptors;
exports.GetPrototypesChain = GetPrototypesChain;
exports.GetSafePropertyDescriptors = GetSafePropertyDescriptors;
exports.GetSetSuperArgsFunction = GetSetSuperArgsFunction;
exports.HasFactoryWaterMark = HasFactoryWaterMark;
exports.ImplementTraits = ImplementTraits;
exports.ImplementsTrait = ImplementsTrait;
exports.ImplementsTraits = ImplementsTraits;
exports.HasOwnProperty = HasOwnProperty;
exports.ImplementFunctionFor = ImplementFunctionFor;
exports.IsFactoryClass = IsFactoryClass;
exports.IsFunctionDerivedFrom = IsFunctionDerivedFrom;
exports.IsFunctionOrDerivedImplementedBy = IsFunctionOrDerivedImplementedBy;
exports.IsFunctionOrParentImplementedBy = IsFunctionOrParentImplementedBy;
exports.IsInstanceOf = IsInstanceOf;
exports.IsNotPrimitivePropertyName = IsNotPrimitivePropertyName;
exports.IsNotPrimitivePrototype = IsNotPrimitivePrototype;
exports.IsPrimitivePropertyName = IsPrimitivePropertyName;
exports.IsPrimitivePrototype = IsPrimitivePrototype;
exports.MakeFactory = MakeFactory;
exports.MixOverrideSuperArgumentsFunction = MixOverrideSuperArgumentsFunction;
exports.ObjectHasOwnProperty = ObjectHasOwnProperty;
exports.OwnArguments = OwnArguments;
exports.PRIMITIVE_PROPERTY_NAMES = PRIMITIVE_PROPERTY_NAMES;
exports.PRIMITIVE_PROTOTYPES = PRIMITIVE_PROTOTYPES;
exports.PROTECTED = PROTECTED;
exports.RegisterTraits = RegisterTraits;
exports.RegisterDerivedFunction = RegisterDerivedFunction;
exports.SearchSuperClass = SearchSuperClass;

@@ -684,5 +986,8 @@ exports.SetClassName = SetClassName;

exports.SuperTrait = SuperTrait;
exports.TRAITS = TRAITS;
exports.Trait = Trait;
exports.TraitFromClass = TraitFromClass;
exports.TraitsFromClasses = TraitsFromClasses;
exports.TraitFunction = TraitFunction;
exports.TraitFunctionsFromClass = TraitFunctionsFromClass;
exports.TraitFunctionsFromObject = TraitFunctionsFromObject;
exports.TraitFunctionsFromObjectPrototypeChain = TraitFunctionsFromObjectPrototypeChain;

@@ -689,0 +994,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],t):t((e=e||self)["class-factory"]={})}(this,(function(e){"use strict";var t=function(){},r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("class-factory",["exports"],e):e((t=t||self)["class-factory"]={})}(this,(function(t){"use strict";var e=function(){},r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};
/*! *****************************************************************************

@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. All rights reserved.

and limitations under the License.
***************************************************************************** */function n(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function o(e,t){var r,n,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}var a=Symbol("instanceof");function c(e,t){var r=Symbol.hasInstance in e?e[Symbol.hasInstance].bind(e):function(){return!1};Object.defineProperty(e,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value:function(e){return e instanceof t||r(e)}}),a in t||Object.defineProperty(t,a,{value:new Set}),t[a].add(e)}var i=new Set(function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],c=0,i=a.length;c<i;c++,o++)n[o]=a[c];return n}(["prototype","constructor"],u(Object.prototype)));function u(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}function s(e){var t,r,n,a;return o(this,(function(o){switch(o.label){case 0:t=u(e),r=0,n=t.length,o.label=1;case 1:return r<n?[4,[a=t[r],Object.getOwnPropertyDescriptor(e,a),e]]:[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}function l(e){var t,r,n,a,c;return o(this,(function(o){switch(o.label){case 0:t=new Set,o.label=1;case 1:if(null===e)return[3,6];r=u(e),n=0,a=r,o.label=2;case 2:return n<a.length?(c=a[n],t.has(c)?[3,4]:(t.add(c),[4,[c,Object.getOwnPropertyDescriptor(e,c),e]])):[3,5];case 3:o.sent(),o.label=4;case 4:return n++,[3,2];case 5:return e=Object.getPrototypeOf(e),[3,1];case 6:return[2]}}))}function f(e,t,r){void 0===r&&(r=i);for(var n,o=l(e);!(n=o.next()).done;){var a=n.value,c=a[0],u=a[1];r.has(c)||Object.defineProperty(t,c,u)}}function p(e,t,r){f(e.prototype,t.prototype,r)}function y(e,t,r){f(e,t,r)}function b(e,t){Object.defineProperty(e,"name",{configurable:!0,enumerable:!1,value:t,writable:!1})}function v(e,t){p(e,t),y(e,t),c(e,t)}function d(e,t,r){var n,o,a={};(a.configurable=r.configurable,a.enumerable=r.enumerable,void 0!==r.value)?(a.get=function(){return"function"==typeof e[t]?(n!==e[t]&&(n=e[t],o=n.bind(e)),o):e[t]},r.writable&&(a.set=function(r){e[t]=r})):("function"==typeof r.get&&(a.get=r.get.bind(e)),"function"==typeof r.set&&(a.set=r.set.bind(e)));return a}function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O=Symbol("is-factory-class");function g(e,t){return void 0===t&&(t=!0),!0===e[O]&&(!t||e.hasOwnProperty(O))}function m(e,t){for(var r=0;null!==e;){if(t(e))return{index:r,ctor:e};r++,e=Object.getPrototypeOf(e)}return null}function w(e,t){if(Array.isArray(e[0]))return e[0]=t,e;throw new TypeError("Expected array as argument 0")}function P(e,t){for(var r=0,n=t.length;r<n;r++)e[r]=t[r];return e}var j=Symbol("protected");var S=Symbol("traits");function C(e,t){if(h(e,S))for(var r=e[S],n=0,o=t.length;n<o;n++)r.add(t[n]);else Object.defineProperty(e,S,{value:new WeakSet(t),writable:!1,enumerable:!1,configurable:!1})}function T(e,t){C(e,t);for(var r=0,n=t.length;r<n;r++){var o=t[r];if(null===o||"object"!=typeof o||Object.getPrototypeOf(o)!==Object.prototype)throw new Error("The trait must be a plain object");for(var a=s(o),c=void 0;!(c=a.next()).done;){var i=c.value,u=i[0],l=i[1];if("constructor"!==u&&u!==S){if(h(e,u))throw new Error("The property '"+String(u)+"' is already implemented");Object.defineProperty(e,u,l)}}}return e}function A(e,t){return null!==e&&"object"==typeof e&&(!(!h(e,S)||!e[S].has(t))||A(Object.getPrototypeOf(e),t))}function x(e){return e.prototype}e.BaseClass=t,e.BindDescriptor=function(e,t,r){var n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){var o=new WeakMap;n.get=function(){var r=e(this),n=Reflect.get(r,t);return"function"==typeof n?(o.has(n)||o.set(n,n.bind(r)),o.get(n)):n},r.writable&&(n.set=function(r){var n=e(this);Reflect.set(n,t,r)})}else"function"==typeof r.get&&(n.get=function(){var t=e(this);return r.get.call(t)}),"function"==typeof r.set&&(n.set=function(t){var n=e(this);return r.set.call(n,t)});return n},e.BindDescriptorOld=d,e.ClassToFactory=function(e){return function(r,o){var a;return void 0===o&&(o="auto"),r===Object||r===t?c(r,a=function(e){function t(t){return e.apply(this,t)||this}return n(t,e),t}(e)):(a=function(t){function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var a,c=this,s=r[0];switch(c=t.apply(this,r.slice(1))||this,o){case"auto":try{void 0===(a=e.apply(c,s))&&(a=c),o="function"}catch(t){a=Reflect.construct(e,s),o="class"}break;case"function":void 0===(a=e.apply(c,s))&&(a=c);break;case"class":a=Reflect.construct(e,s)}if(c!==a){for(var f=l(Object.getPrototypeOf(a)),p=void 0;!(p=f.next()).done;){var y=p.value[0];i.has(y)||Object.defineProperty(c,y,d(a,y,p.value[1]))}for(var b=u(a),v=0,h=b;v<h.length;v++){y=h[v];i.has(y)||(y in c&&console.warn("Crossing properties !"),Object.defineProperty(c,y,d(a,y,Object.getOwnPropertyDescriptor(a,y))))}Object.seal(a)}return c}return n(r,t),r}(r),v(e,a)),b(a,e.name),a}},e.ConstructClassWithPrivateMembers=function(e,t){Object.defineProperty(e,t,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.ConstructClassWithProtectedMembers=function(e){Object.defineProperty(e,j,{value:{},configurable:!1,writable:!1,enumerable:!1})},e.CopyClass=v,e.CopyClassName=function(e,t){var r=Object.getOwnPropertyDescriptor(e,"name");void 0===r?r={configurable:!0,enumerable:!1,value:e.name,writable:!1}:r.value=e.name,r.configurable&&Object.defineProperty(t,"name",r)},e.CopyClassPrototype=p,e.CopyClassStaticProperties=y,e.CopyOwnProperties=function(e,t,r){void 0===r&&(r=i);for(var n=0,o=u(e);n<o.length;n++){var a=o[n],c=Object.getOwnPropertyDescriptor(e,a);void 0===c||r.has(a)||Object.defineProperty(t,a,c)}},e.CopyProperties=f,e.EXCLUDED_PROPERTY_NAMES=i,e.GenerateOverrideSuperArgumentsFunction=function(e,t){var r=m(e,t);if(null===r)throw new Error("Failed to find super class of the class "+e.name);var n=r.index;return g(r.ctor)?function(e,t){if(Array.isArray(e[n]))return e.slice(0,n).concat([t(e[n])]).concat(e.slice(n+1));throw new TypeError("Expected array as argument["+n+"]")}:function(e,t){return e.slice(0,n).concat(t(e.slice(n)))}},e.GetOwnPropertyDescriptors=s,e.GetOwnPropertyKeys=u,e.GetPropertyDescriptors=l,e.GetSafePropertyDescriptors=function(e){var t,r,n,a,c;return o(this,(function(o){switch(o.label){case 0:t=l(e),o.label=1;case 1:return(r=t.next()).done?[3,4]:(n=r.value,a=n[0],(c=n[2])===Object.prototype||c===Function.prototype||i.has(a)?[3,3]:[4,r.value]);case 2:o.sent(),o.label=3;case 3:return[3,1];case 4:return[2]}}))},e.GetSetSuperArgsFunction=function(e){return e?w:P},e.HasFactoryWaterMark=function(e,t,r){return void 0===r&&(r=!0),!0===e[t]&&(!r||e.hasOwnProperty(t))},e.ImplementTraits=T,e.ImplementsTrait=A,e.ImplementsTraits=function(e,t){return t.every((function(t){return A(e,t)}))},e.IsFactoryClass=g,e.IsInstanceOf=function(e,t){return e instanceof t||!(!e.constructor||!(a in e.constructor))&&e.constructor[a].has(t)},e.MakeFactory=function(e,t,r,n){void 0===n&&(n={});for(var o=r,a=t.length-1;a>=0;a--)o=t[a](o);var i=e(o);if(Object.defineProperty(i,O,{value:!0}),"string"==typeof n.name&&Object.defineProperty(i,"name",{configurable:!0,enumerable:!1,value:n.name,writable:!1}),Array.isArray(n.waterMarks)){a=0;for(var u=n.waterMarks.length;a<u;a++)Object.defineProperty(i,n.waterMarks[a],{value:!0})}return void 0!==n.instanceOf&&c(n.instanceOf,i),i},e.MixOverrideSuperArgumentsFunction=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];for(var o=0,a=e.length;o<a;o++)t=e[o](t,r[o]);return t}},e.ObjectHasOwnProperty=h,e.OwnArguments=function(e){return e[0]},e.PROTECTED=j,e.RegisterTraits=C,e.SearchSuperClass=m,e.SetClassName=b,e.SetInstanceOf=c,e.SetSuperArgsForFactoryClass=w,e.SetSuperArgsForStandardClass=P,e.SuperArguments=function(e){return e.slice(1)},e.SuperTrait=function(e,t){var r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(t);return T(r.prototype,e),r},e.TRAITS=S,e.TraitFromClass=x,e.TraitsFromClasses=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.map(x)},Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */function n(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function a(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],a=0,u=i.length;a<u;a++,o++)n[o]=i[a];return n}var u=Symbol("instanceof");function c(t,e){var r=Symbol.hasInstance in t?t[Symbol.hasInstance].bind(t):function(){return!1};Object.defineProperty(t,Symbol.hasInstance,{configurable:!0,enumerable:!1,writable:!1,value:function(t){return t instanceof e||r(t)}}),u in e||Object.defineProperty(e,u,{value:new Set}),e[u].add(t)}function s(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}function f(t){var e,r,n,o;return i(this,(function(i){switch(i.label){case 0:e=s(t),r=0,n=e.length,i.label=1;case 1:return r<n?[4,[o=e[r],Object.getOwnPropertyDescriptor(t,o),t]]:[3,4];case 2:i.sent(),i.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}var l=new Set(["prototype","constructor"]);function p(t){return l.has(t)}function y(t){return!p(t)}function h(t){return i(this,(function(e){switch(e.label){case 0:return null===t?[3,2]:[4,t];case 1:return e.sent(),t=Object.getPrototypeOf(t),[3,0];case 2:return[2]}}))}var b=new Set(["",0,{},[],function(){}].map((function(t){return Object.getPrototypeOf(t)})));function v(t){return b.has(t)}function d(t){return!v(t)}var m=new Set(a(["prototype","constructor"],s(Object.prototype)));function g(t){var e,r,n,o,a;return i(this,(function(i){switch(i.label){case 0:e=new Set,i.label=1;case 1:if(null===t)return[3,6];r=s(t),n=0,o=r,i.label=2;case 2:return n<o.length?(a=o[n],e.has(a)?[3,4]:(e.add(a),[4,[a,Object.getOwnPropertyDescriptor(t,a),t]])):[3,5];case 3:i.sent(),i.label=4;case 4:return n++,[3,2];case 5:return t=Object.getPrototypeOf(t),[3,1];case 6:return[2]}}))}function w(t,e,r){void 0===r&&(r=m);for(var n,o=g(t);!(n=o.next()).done;){var i=n.value,a=i[0],u=i[1];r.has(a)||Object.defineProperty(e,a,u)}}function O(t,e,r){w(t.prototype,e.prototype,r)}function F(t,e,r){w(t,e,r)}function P(t,e){Object.defineProperty(t,"name",{configurable:!0,enumerable:!1,value:e,writable:!1})}function S(t,e){O(t,e),F(t,e),c(t,e)}function C(t,e,r){var n,o,i={};(i.configurable=r.configurable,i.enumerable=r.enumerable,void 0!==r.value)?(i.get=function(){return"function"==typeof t[e]?(n!==t[e]&&(n=t[e],o=n.bind(t)),o):t[e]},r.writable&&(i.set=function(r){t[e]=r})):("function"==typeof r.get&&(i.get=r.get.bind(t)),"function"==typeof r.set&&(i.set=r.set.bind(t)));return i}var j=Symbol("is-factory-class");function I(t,e){return void 0===e&&(e=!0),!0===t[j]&&(!e||t.hasOwnProperty(j))}function T(t,e){for(var r=0;null!==t;){if(e(t))return{index:r,ctor:t};r++,t=Object.getPrototypeOf(t)}return null}function E(t,e){if(Array.isArray(t[0]))return t[0]=e,t;throw new TypeError("Expected array as argument 0")}function A(t,e){for(var r=0,n=e.length;r<n;r++)t[r]=e[r];return t}var D=Symbol("protected");function M(t,e,r,n){var o;return t.isImplementedBy(e)?(o=e)[t.propertyKey].apply(o,r):n.apply(e,r)}var _=new WeakMap,x=new WeakMap;function k(t,e){if(_.has(e)){if(_.get(e)!==t)throw new Error("Derived function already registered as derived from: "+String(_.get(e)))}else{if(K(t,e))throw new Error("Derived function already registered as derived from: "+String(_.get(e)));_.set(e,t),x.has(t)?x.get(t).push(e):x.set(t,[e])}}function K(t,e){for(;;){if(t===e)return!0;if(!_.has(t))return!1;t=_.get(t)}}function N(t){return void 0!==t&&void 0!==t.enumerable&&t.enumerable}function R(t){return void 0===t||void 0===t.configurable||t.configurable}function G(t){return void 0!==t&&void 0!==t.writable&&t.writable}function B(t,e,r,n){if(e in t&&!q(t,e,r))throw new Error("The property '"+String(e)+"' is already implemented");return Object.defineProperty(t,e,{value:r,enumerable:N(n),configurable:R(n),writable:G(n)}),t}function W(t,e,r){return"function"==typeof t[e]&&K(t[e],r)}function q(t,e,r){return"function"==typeof t[e]&&K(r,t[e])}var U=function(){function t(t){this.fnc=t}return t.prototype.derive=function(e){return k(this.fnc,e),new t(e)},t.prototype.call=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return(e=this.fnc).call.apply(e,a([t],r))},t.prototype.isDerivedFrom=function(t){return K(this.fnc,t.fnc)},t.prototype.equals=function(t){return t.fnc===this.fnc},t}(),V=function(t){function e(e,r,n){var o=t.call(this,r)||this;return o.propertyKey=e,o.enumerable=N(n),o.configurable=R(n),o.writable=G(n),o}return n(e,t),e.prototype.derive=function(t,r){return k(this.fnc,t),new e(this.propertyKey,t,o({enumerable:this.enumerable,configurable:this.configurable,writable:this.writable},r))},e.prototype.derivedFrom=function(t,r){return k(t,this.fnc),new e(this.propertyKey,t,o({enumerable:this.enumerable,configurable:this.configurable,writable:this.writable},r))},e.prototype.implementFor=function(t,e){return B(t,this.propertyKey,this.fnc,o({enumerable:this.enumerable,configurable:this.configurable,writable:this.writable},e))},e.prototype.isImplementedBy=function(t){return W(t,this.propertyKey,this.fnc)},e.prototype.equals=function(e){return t.prototype.equals.call(this,e)&&e.propertyKey===this.propertyKey},e}(U),Y=function(){function t(t){this.traitFunctions=Object.freeze(Array.from(t));for(var e=0,r=this.traitFunctions.length-1;e<r;e++)for(var n=this.traitFunctions[e],o=e+1;o<=r;o++)if(n.propertyKey===this.traitFunctions[o].propertyKey)throw new Error("Received two TraitFunction with the same property key '"+String(n.propertyKey)+"' at index "+e+" and "+o)}return t.mix=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return new t(e.map((function(t){return t.traitFunctions})).flat())},t.prototype.get=function(t){return this.traitFunctions.find((function(e){return e.propertyKey===t}))},t.prototype.derive=function(e){var r=Array.isArray(e)?e:Array.from(e);return new t(this.traitFunctions.filter((function(t){return r.every((function(e,r){if(t.propertyKey===e.propertyKey){if(e.isDerivedFrom(t))return!1;throw new Error("Received a new TraitFunction with the property key '"+String(e.propertyKey)+"' at index "+r+", which already exists in this Trait and is not derived from the original")}return!0}))})).concat(r))},t.prototype.implementFor=function(t){for(var e=0,r=this.traitFunctions.length;e<r;e++)this.traitFunctions[e].implementFor(t);return t},t.prototype.isImplementedBy=function(t){for(var e=0,r=this.traitFunctions.length;e<r;e++)if(!this.traitFunctions[e].isImplementedBy(t))return!1;return!0},t.prototype.isDerivedFrom=function(t){return t.traitFunctions.length>=this.traitFunctions.length&&this.traitFunctions.every((function(e){return t.traitFunctions.some((function(t){return e.isDerivedFrom(t)}))}))},t.prototype.equals=function(t){return t.traitFunctions.length===this.traitFunctions.length&&this.traitFunctions.every((function(e){return t.traitFunctions.some((function(t){return e.equals(t)}))}))},t}();function H(t,e){void 0===e&&(e=new Map);for(var r,n=f(t);!(r=n.next()).done;){var o=r.value,i=o[0],a=o[1];if(y(i)){if("function"!=typeof a.value)throw new Error("Found property which is not a function: '"+String(i)+"'");e.set(i,e.has(i)?e.get(i).derive(a.value,a):new V(i,a.value,a))}}return e}function z(t){for(var e=Array.from(h(t)).filter(d).reverse(),r=new Map,n=0,o=e.length;n<o;n++)H(e[n],r);return r}function L(t){return z(t.prototype)}function X(t){return function(){Q(t)}}function J(t){return void 0===t?new Error("Cannot call an abstract method"):new Error("Cannot call the abstract method '"+String(t)+"'")}function Q(t){throw J(t)}t.AbstractMethod=function(){return function(t,e,r){if(void 0===r&&(r=Object.getOwnPropertyDescriptor(t,e)),void 0===r)return{configurable:!1,writable:!1,value:X(e)};throw new TypeError("@AbstractProperty: the property '"+String(e)+"' should not be defined.")}},t.AbstractMethodCall=Q,t.BaseClass=e,t.BindDescriptor=function(t,e,r){var n={};if(n.configurable=r.configurable,n.enumerable=r.enumerable,void 0!==r.value){var o=new WeakMap;n.get=function(){var r=t(this),n=Reflect.get(r,e);return"function"==typeof n?(o.has(n)||o.set(n,n.bind(r)),o.get(n)):n},r.writable&&(n.set=function(r){var n=t(this);Reflect.set(n,e,r)})}else"function"==typeof r.get&&(n.get=function(){var e=t(this);return r.get.call(e)}),"function"==typeof r.set&&(n.set=function(e){var n=t(this);return r.set.call(n,e)});return n},t.BindDescriptorOld=C,t.CallTraitFunctionAsMethod=function(t,e,r){var n;return t.isImplementedBy(e)?(n=e)[t.propertyKey].apply(n,r):t.fnc.apply(e,r)},t.CallTraitFunctionOrFallback=M,t.CallTraitMethodOrFallback=function(t,e,r,n,o){var i=t.get(r);return void 0===i?o.apply(void 0,a([e],n)):M(i,e,n,o)},t.ClassToFactory=function(t){return function(r,o){var i;return void 0===o&&(o="auto"),r===Object||r===e?c(r,i=function(t){function e(e){return t.apply(this,e)||this}return n(e,t),e}(t)):(i=function(e){function r(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i,a=this,u=r[0];switch(a=e.apply(this,r.slice(1))||this,o){case"auto":try{void 0===(i=t.apply(a,u))&&(i=a),o="function"}catch(e){i=Reflect.construct(t,u),o="class"}break;case"function":void 0===(i=t.apply(a,u))&&(i=a);break;case"class":i=Reflect.construct(t,u)}if(a!==i){for(var c=g(Object.getPrototypeOf(i)),f=void 0;!(f=c.next()).done;){var l=f.value[0];m.has(l)||Object.defineProperty(a,l,C(i,l,f.value[1]))}for(var p=s(i),y=0,h=p;y<h.length;y++){l=h[y];m.has(l)||(l in a&&console.warn("Crossing properties !"),Object.defineProperty(a,l,C(i,l,Object.getOwnPropertyDescriptor(i,l))))}Object.seal(i)}return a}return n(r,e),r}(r),S(t,i)),P(i,t.name),i}},t.ConstructClassWithPrivateMembers=function(t,e){Object.defineProperty(t,e,{value:{},configurable:!1,writable:!1,enumerable:!1})},t.ConstructClassWithProtectedMembers=function(t){Object.defineProperty(t,D,{value:{},configurable:!1,writable:!1,enumerable:!1})},t.CopyClass=S,t.CopyClassName=function(t,e){var r=Object.getOwnPropertyDescriptor(t,"name");void 0===r?r={configurable:!0,enumerable:!1,value:t.name,writable:!1}:r.value=t.name,r.configurable&&Object.defineProperty(e,"name",r)},t.CopyClassPrototype=O,t.CopyClassStaticProperties=F,t.CopyOwnProperties=function(t,e,r){void 0===r&&(r=m);for(var n=0,o=s(t);n<o.length;n++){var i=o[n],a=Object.getOwnPropertyDescriptor(t,i);void 0===a||r.has(i)||Object.defineProperty(e,i,a)}},t.CopyProperties=w,t.CreateAbstractMethod=X,t.CreateAbstractMethodCallError=J,t.DERIVED_FUNCTION_TO_FUNCTION_MAP=_,t.DerivableFunction=U,t.EXCLUDED_PROPERTY_NAMES=m,t.FUNCTION_TO_DERIVED_FUNCTIONS_MAP=x,t.GenerateOverrideSuperArgumentsFunction=function(t,e){var r=T(t,e);if(null===r)throw new Error("Failed to find super class of the class "+t.name);var n=r.index;return I(r.ctor)?function(t,e){if(Array.isArray(t[n]))return t.slice(0,n).concat([e(t[n])]).concat(t.slice(n+1));throw new TypeError("Expected array as argument["+n+"]")}:function(t,e){return t.slice(0,n).concat(e(t.slice(n)))}},t.GetImplementForOptionsConfigurable=R,t.GetImplementForOptionsEnumerable=N,t.GetImplementForOptionsWritable=G,t.GetOwnPropertyDescriptors=f,t.GetOwnPropertyKeys=s,t.GetPropertyDescriptors=g,t.GetPrototypesChain=h,t.GetSafePropertyDescriptors=function(t){var e,r,n,o,a;return i(this,(function(i){switch(i.label){case 0:e=g(t),i.label=1;case 1:return(r=e.next()).done?[3,4]:(n=r.value,o=n[0],(a=n[2])===Object.prototype||a===Function.prototype||m.has(o)?[3,3]:[4,r.value]);case 2:i.sent(),i.label=3;case 3:return[3,1];case 4:return[2]}}))},t.GetSetSuperArgsFunction=function(t){return t?E:A},t.HasFactoryWaterMark=function(t,e,r){return void 0===r&&(r=!0),!0===t[e]&&(!r||t.hasOwnProperty(e))},t.HasOwnProperty=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t.ImplementFunctionFor=B,t.IsFactoryClass=I,t.IsFunctionDerivedFrom=K,t.IsFunctionOrDerivedImplementedBy=W,t.IsFunctionOrParentImplementedBy=q,t.IsInstanceOf=function(t,e){return t instanceof e||!(!t.constructor||!(u in t.constructor))&&t.constructor[u].has(e)},t.IsNotPrimitivePropertyName=y,t.IsNotPrimitivePrototype=d,t.IsPrimitivePropertyName=p,t.IsPrimitivePrototype=v,t.MakeFactory=function(t,e,r,n){void 0===n&&(n={});for(var o=r,i=e.length-1;i>=0;i--)o=e[i](o);var a=t(o);if(Object.defineProperty(a,j,{value:!0}),"string"==typeof n.name&&Object.defineProperty(a,"name",{configurable:!0,enumerable:!1,value:n.name,writable:!1}),Array.isArray(n.waterMarks)){i=0;for(var u=n.waterMarks.length;i<u;i++)Object.defineProperty(a,n.waterMarks[i],{value:!0})}return void 0!==n.instanceOf&&c(n.instanceOf,a),a},t.MixOverrideSuperArgumentsFunction=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];for(var o=0,i=t.length;o<i;o++)e=t[o](e,r[o]);return e}},t.OwnArguments=function(t){return t[0]},t.PRIMITIVE_PROPERTY_NAMES=l,t.PRIMITIVE_PROTOTYPES=b,t.PROTECTED=D,t.RegisterDerivedFunction=k,t.SearchSuperClass=T,t.SetClassName=P,t.SetInstanceOf=c,t.SetSuperArgsForFactoryClass=E,t.SetSuperArgsForStandardClass=A,t.SuperArguments=function(t){return t.slice(1)},t.SuperTrait=function(t,e){var r=void 0===e?function(){}:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(e);return t.implementFor(r.prototype),r},t.Trait=Y,t.TraitFromClass=function(t){return new Y(L(t).values())},t.TraitFunction=V,t.TraitFunctionsFromClass=L,t.TraitFunctionsFromObject=H,t.TraitFunctionsFromObjectPrototypeChain=z,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=class-factory.umd.min.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseClass = void 0;
var BaseClass = (function () {
function BaseClass() {
}
return BaseClass;
}());
class BaseClass {
}
exports.BaseClass = BaseClass;
//# sourceMappingURL=base-class.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetSetSuperArgsFunction = exports.SetSuperArgsForStandardClass = exports.SetSuperArgsForFactoryClass = exports.MixOverrideSuperArgumentsFunction = exports.GenerateOverrideSuperArgumentsFunction = exports.SuperArguments = exports.OwnArguments = exports.SearchSuperClass = exports.IsFactoryClass = exports.HasFactoryWaterMark = exports.ClassToFactory = exports.MakeFactory = void 0;
var instance_of_1 = require("./instance-of");
var base_class_1 = require("./base-class");
var helpers_1 = require("./helpers");
function MakeFactory(create, factories, superClass, options) {
if (options === void 0) { options = {}; }
var _superClass = superClass;
for (var i = factories.length - 1; i >= 0; i--) {
const instance_of_1 = require("./instance-of");
const base_class_1 = require("./base-class");
const helpers_1 = require("./helpers");
function MakeFactory(create, factories, superClass, options = {}) {
let _superClass = superClass;
for (let i = factories.length - 1; i >= 0; i--) {
_superClass = factories[i](_superClass);
}
var _class = create(_superClass);
const _class = create(_superClass);
Object.defineProperty(_class, IS_FACTORY_CLASS, {

@@ -39,3 +25,3 @@ value: true,

if (Array.isArray(options.waterMarks)) {
for (var i = 0, l = options.waterMarks.length; i < l; i++) {
for (let i = 0, l = options.waterMarks.length; i < l; i++) {
Object.defineProperty(_class, options.waterMarks[i], {

@@ -53,34 +39,25 @@ value: true,

function ClassToFactory(source) {
return function (superClass, mode) {
if (mode === void 0) { mode = 'auto'; }
var _class;
return function (superClass, mode = 'auto') {
let _class;
if ((superClass === Object)
|| (superClass === base_class_1.BaseClass)) {
_class = (function (_super) {
__extends(class_1, _super);
function class_1(args) {
return _super.apply(this, args) || this;
_class = class extends source {
constructor(args) {
super(...args);
}
return class_1;
}(source));
};
instance_of_1.SetInstanceOf(superClass, _class);
}
else {
_class = (function (_super) {
__extends(class_2, _super);
function class_2() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this_1 = this;
var ownArgs = args[0];
_this_1 = _super.apply(this, args.slice(1)) || this;
var _this;
_class = class extends superClass {
constructor(...args) {
const ownArgs = args[0];
super(...args.slice(1));
let _this;
switch (mode) {
case 'auto':
try {
_this = source.apply(_this_1, ownArgs);
_this = source.apply(this, ownArgs);
if (_this === void 0) {
_this = _this_1;
_this = this;
}

@@ -95,5 +72,5 @@ mode = 'function';

case 'function':
_this = source.apply(_this_1, ownArgs);
_this = source.apply(this, ownArgs);
if (_this === void 0) {
_this = _this_1;
_this = this;
}

@@ -105,19 +82,18 @@ break;

}
if (_this_1 !== _this) {
var iterator = helpers_1.GetPropertyDescriptors(Object.getPrototypeOf(_this));
var result = void 0;
if (this !== _this) {
const iterator = helpers_1.GetPropertyDescriptors(Object.getPrototypeOf(_this));
let result;
while (!(result = iterator.next()).done) {
var key = result.value[0];
const key = result.value[0];
if (!helpers_1.EXCLUDED_PROPERTY_NAMES.has(key)) {
Object.defineProperty(_this_1, key, helpers_1.BindDescriptorOld(_this, key, result.value[1]));
Object.defineProperty(this, key, helpers_1.BindDescriptorOld(_this, key, result.value[1]));
}
}
var keys = helpers_1.GetOwnPropertyKeys(_this);
for (var _a = 0, keys_1 = keys; _a < keys_1.length; _a++) {
var key = keys_1[_a];
const keys = helpers_1.GetOwnPropertyKeys(_this);
for (const key of keys) {
if (!helpers_1.EXCLUDED_PROPERTY_NAMES.has(key)) {
if (key in _this_1) {
console.warn("Crossing properties !");
if (key in this) {
console.warn(`Crossing properties !`);
}
Object.defineProperty(_this_1, key, helpers_1.BindDescriptorOld(_this, key, Object.getOwnPropertyDescriptor(_this, key)));
Object.defineProperty(this, key, helpers_1.BindDescriptorOld(_this, key, Object.getOwnPropertyDescriptor(_this, key)));
}

@@ -127,6 +103,4 @@ }

}
return _this_1;
}
return class_2;
}(superClass));
};
helpers_1.CopyClass(source, _class);

@@ -139,10 +113,8 @@ }

exports.ClassToFactory = ClassToFactory;
function HasFactoryWaterMark(_class, waterMark, direct) {
if (direct === void 0) { direct = true; }
function HasFactoryWaterMark(_class, waterMark, direct = true) {
return (_class[waterMark] === true) && (direct ? _class.hasOwnProperty(waterMark) : true);
}
exports.HasFactoryWaterMark = HasFactoryWaterMark;
var IS_FACTORY_CLASS = Symbol('is-factory-class');
function IsFactoryClass(_class, direct) {
if (direct === void 0) { direct = true; }
const IS_FACTORY_CLASS = Symbol('is-factory-class');
function IsFactoryClass(_class, direct = true) {
return (_class[IS_FACTORY_CLASS] === true) && (direct ? _class.hasOwnProperty(IS_FACTORY_CLASS) : true);

@@ -152,7 +124,7 @@ }

function SearchSuperClass(_class, filter) {
var index = 0;
let index = 0;
while (_class !== null) {
if (filter(_class)) {
return {
index: index,
index,
ctor: _class

@@ -178,18 +150,18 @@ };

function GenerateOverrideSuperArgumentsFunction(_class, filter) {
var result = SearchSuperClass(_class, filter);
const result = SearchSuperClass(_class, filter);
if (result === null) {
throw new Error("Failed to find super class of the class " + _class.name);
throw new Error(`Failed to find super class of the class ${_class.name}`);
}
else {
var index_1 = result.index;
const index = result.index;
if (IsFactoryClass(result.ctor)) {
return function (args, getNewArguments) {
if (Array.isArray(args[index_1])) {
return (args, getNewArguments) => {
if (Array.isArray(args[index])) {
return args
.slice(0, index_1)
.concat([getNewArguments(args[index_1])])
.concat(args.slice(index_1 + 1));
.slice(0, index)
.concat([getNewArguments(args[index])])
.concat(args.slice(index + 1));
}
else {
throw new TypeError("Expected array as argument[" + index_1 + "]");
throw new TypeError(`Expected array as argument[${index}]`);
}

@@ -199,6 +171,6 @@ };

else {
return function (args, getNewArguments) {
return (args, getNewArguments) => {
return args
.slice(0, index_1)
.concat(getNewArguments(args.slice(index_1)));
.slice(0, index)
.concat(getNewArguments(args.slice(index)));
};

@@ -209,13 +181,5 @@ }

exports.GenerateOverrideSuperArgumentsFunction = GenerateOverrideSuperArgumentsFunction;
function MixOverrideSuperArgumentsFunction() {
var functions = [];
for (var _i = 0; _i < arguments.length; _i++) {
functions[_i] = arguments[_i];
}
return function (args) {
var getNewArgumentsFunctions = [];
for (var _i = 1; _i < arguments.length; _i++) {
getNewArgumentsFunctions[_i - 1] = arguments[_i];
}
for (var i = 0, l = functions.length; i < l; i++) {
function MixOverrideSuperArgumentsFunction(...functions) {
return (args, ...getNewArgumentsFunctions) => {
for (let i = 0, l = functions.length; i < l; i++) {
args = functions[i](args, getNewArgumentsFunctions[i]);

@@ -233,3 +197,3 @@ }

else {
throw new TypeError("Expected array as argument 0");
throw new TypeError(`Expected array as argument 0`);
}

@@ -239,3 +203,3 @@ }

function SetSuperArgsForStandardClass(args, superArgs) {
for (var i = 0, l = superArgs.length; i < l; i++) {
for (let i = 0, l = superArgs.length; i < l; i++) {
args[i] = superArgs[i];

@@ -242,0 +206,0 @@ }

"use strict";
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectHasOwnProperty = exports.BindDescriptorOld = exports.BindDescriptor = exports.CopyClass = exports.SetClassName = exports.CopyClassName = exports.CopyClassStaticProperties = exports.CopyClassPrototype = exports.CopyOwnProperties = exports.CopyProperties = exports.GetSafePropertyDescriptors = exports.GetPropertyDescriptors = exports.GetOwnPropertyDescriptors = exports.GetOwnPropertyKeys = exports.EXCLUDED_PROPERTY_NAMES = void 0;
var instance_of_1 = require("./instance-of");
exports.EXCLUDED_PROPERTY_NAMES = new Set(__spreadArrays(['prototype', 'constructor'], GetOwnPropertyKeys(Object.prototype)));
exports.BindDescriptorOld = exports.BindDescriptor = exports.CopyClass = exports.SetClassName = exports.CopyClassName = exports.CopyClassStaticProperties = exports.CopyClassPrototype = exports.CopyOwnProperties = exports.CopyProperties = exports.GetSafePropertyDescriptors = exports.GetPropertyDescriptors = exports.EXCLUDED_PROPERTY_NAMES = exports.IsNotPrimitivePrototype = exports.IsPrimitivePrototype = exports.PRIMITIVE_PROTOTYPES = exports.GetPrototypesChain = exports.IsNotPrimitivePropertyName = exports.IsPrimitivePropertyName = exports.PRIMITIVE_PROPERTY_NAMES = exports.GetOwnPropertyDescriptors = exports.HasOwnProperty = exports.GetOwnPropertyKeys = void 0;
const instance_of_1 = require("./instance-of");
function GetOwnPropertyKeys(target) {

@@ -45,86 +10,72 @@ return Object.getOwnPropertyNames(target)

exports.GetOwnPropertyKeys = GetOwnPropertyKeys;
function GetOwnPropertyDescriptors(target) {
var keys, i, l, key;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
keys = GetOwnPropertyKeys(target);
i = 0, l = keys.length;
_a.label = 1;
case 1:
if (!(i < l)) return [3, 4];
key = keys[i];
return [4, [key, Object.getOwnPropertyDescriptor(target, key), target]];
case 2:
_a.sent();
_a.label = 3;
case 3:
i++;
return [3, 1];
case 4: return [2];
}
});
function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
exports.HasOwnProperty = HasOwnProperty;
function* GetOwnPropertyDescriptors(target) {
const keys = GetOwnPropertyKeys(target);
for (let i = 0, l = keys.length; i < l; i++) {
const key = keys[i];
yield [key, Object.getOwnPropertyDescriptor(target, key), target];
}
}
exports.GetOwnPropertyDescriptors = GetOwnPropertyDescriptors;
function GetPropertyDescriptors(target) {
var _keys, keys, _i, keys_1, key;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_keys = new Set();
_a.label = 1;
case 1:
if (!(target !== null)) return [3, 6];
keys = GetOwnPropertyKeys(target);
_i = 0, keys_1 = keys;
_a.label = 2;
case 2:
if (!(_i < keys_1.length)) return [3, 5];
key = keys_1[_i];
if (!!_keys.has(key)) return [3, 4];
exports.PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
function IsPrimitivePropertyName(name) {
return exports.PRIMITIVE_PROPERTY_NAMES.has(name);
}
exports.IsPrimitivePropertyName = IsPrimitivePropertyName;
function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
exports.IsNotPrimitivePropertyName = IsNotPrimitivePropertyName;
function* GetPrototypesChain(target) {
while (target !== null) {
yield target;
target = Object.getPrototypeOf(target);
}
}
exports.GetPrototypesChain = GetPrototypesChain;
exports.PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], () => { }].map(_ => Object.getPrototypeOf(_)));
function IsPrimitivePrototype(proto) {
return exports.PRIMITIVE_PROTOTYPES.has(proto);
}
exports.IsPrimitivePrototype = IsPrimitivePrototype;
function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
exports.IsNotPrimitivePrototype = IsNotPrimitivePrototype;
exports.EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
function* GetPropertyDescriptors(target) {
const _keys = new Set();
while (target !== null) {
const keys = GetOwnPropertyKeys(target);
for (const key of keys) {
if (!_keys.has(key)) {
_keys.add(key);
return [4, [key, Object.getOwnPropertyDescriptor(target, key), target]];
case 3:
_a.sent();
_a.label = 4;
case 4:
_i++;
return [3, 2];
case 5:
target = Object.getPrototypeOf(target);
return [3, 1];
case 6: return [2];
yield [key, Object.getOwnPropertyDescriptor(target, key), target];
}
}
});
target = Object.getPrototypeOf(target);
}
}
exports.GetPropertyDescriptors = GetPropertyDescriptors;
function GetSafePropertyDescriptors(target) {
var iterator, result, _a, propertyName, target_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
iterator = GetPropertyDescriptors(target);
_b.label = 1;
case 1:
if (!!(result = iterator.next()).done) return [3, 4];
_a = result.value, propertyName = _a[0], target_1 = _a[2];
if (!((target_1 !== Object.prototype)
&& (target_1 !== Function.prototype)
&& !exports.EXCLUDED_PROPERTY_NAMES.has(propertyName))) return [3, 3];
return [4, result.value];
case 2:
_b.sent();
_b.label = 3;
case 3: return [3, 1];
case 4: return [2];
function* GetSafePropertyDescriptors(target) {
const iterator = GetPropertyDescriptors(target);
let result;
while (!(result = iterator.next()).done) {
const [propertyName, , target] = result.value;
if ((target !== Object.prototype)
&& (target !== Function.prototype)
&& !exports.EXCLUDED_PROPERTY_NAMES.has(propertyName)) {
yield result.value;
}
});
}
}
exports.GetSafePropertyDescriptors = GetSafePropertyDescriptors;
function CopyProperties(source, destination, exclude) {
if (exclude === void 0) { exclude = exports.EXCLUDED_PROPERTY_NAMES; }
var iterator = GetPropertyDescriptors(source);
var result;
function CopyProperties(source, destination, exclude = exports.EXCLUDED_PROPERTY_NAMES) {
const iterator = GetPropertyDescriptors(source);
let result;
while (!(result = iterator.next()).done) {
var _a = result.value, propertyName = _a[0], descriptor = _a[1];
const [propertyName, descriptor] = result.value;
if (!exclude.has(propertyName)) {

@@ -136,8 +87,6 @@ Object.defineProperty(destination, propertyName, descriptor);

exports.CopyProperties = CopyProperties;
function CopyOwnProperties(source, destination, exclude) {
if (exclude === void 0) { exclude = exports.EXCLUDED_PROPERTY_NAMES; }
var keys = GetOwnPropertyKeys(source);
for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
var key = keys_2[_i];
var descriptor = Object.getOwnPropertyDescriptor(source, key);
function CopyOwnProperties(source, destination, exclude = exports.EXCLUDED_PROPERTY_NAMES) {
const keys = GetOwnPropertyKeys(source);
for (const key of keys) {
const descriptor = Object.getOwnPropertyDescriptor(source, key);
if ((descriptor !== void 0) && !exclude.has(key)) {

@@ -158,3 +107,3 @@ Object.defineProperty(destination, key, descriptor);

function CopyClassName(source, destination) {
var descriptor = Object.getOwnPropertyDescriptor(source, 'name');
let descriptor = Object.getOwnPropertyDescriptor(source, 'name');
if (descriptor === void 0) {

@@ -192,15 +141,15 @@ descriptor = {

function BindDescriptor(mapInstance, key, descriptor) {
var _descriptor = {};
const _descriptor = {};
_descriptor.configurable = descriptor.configurable;
_descriptor.enumerable = descriptor.enumerable;
if (typeof descriptor.value !== 'undefined') {
var cachedFunctions_1 = new WeakMap();
let cachedFunctions = new WeakMap();
_descriptor.get = function () {
var instance = mapInstance(this);
var value = Reflect.get(instance, key);
const instance = mapInstance(this);
const value = Reflect.get(instance, key);
if (typeof value === 'function') {
if (!cachedFunctions_1.has(value)) {
cachedFunctions_1.set(value, value.bind(instance));
if (!cachedFunctions.has(value)) {
cachedFunctions.set(value, value.bind(instance));
}
return cachedFunctions_1.get(value);
return cachedFunctions.get(value);
}

@@ -213,3 +162,3 @@ else {

_descriptor.set = function (value) {
var instance = mapInstance(this);
const instance = mapInstance(this);
Reflect.set(instance, key, value);

@@ -222,3 +171,3 @@ };

_descriptor.get = function () {
var instance = mapInstance(this);
const instance = mapInstance(this);
return descriptor.get.call(instance);

@@ -229,3 +178,3 @@ };

_descriptor.set = function (value) {
var instance = mapInstance(this);
const instance = mapInstance(this);
return descriptor.set.call(instance, value);

@@ -239,15 +188,15 @@ };

function BindDescriptorOld(instance, key, descriptor) {
var _descriptor = {};
const _descriptor = {};
_descriptor.configurable = descriptor.configurable;
_descriptor.enumerable = descriptor.enumerable;
if (typeof descriptor.value !== 'undefined') {
var cachedFunction_1;
var cachedFunctionWithBind_1;
_descriptor.get = function () {
let cachedFunction;
let cachedFunctionWithBind;
_descriptor.get = () => {
if (typeof instance[key] === 'function') {
if (cachedFunction_1 !== instance[key]) {
cachedFunction_1 = instance[key];
cachedFunctionWithBind_1 = cachedFunction_1.bind(instance);
if (cachedFunction !== instance[key]) {
cachedFunction = instance[key];
cachedFunctionWithBind = cachedFunction.bind(instance);
}
return cachedFunctionWithBind_1;
return cachedFunctionWithBind;
}

@@ -259,3 +208,3 @@ else {

if (descriptor.writable) {
_descriptor.set = function (value) {
_descriptor.set = (value) => {
instance[key] = value;

@@ -276,6 +225,2 @@ };

exports.BindDescriptorOld = BindDescriptorOld;
function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}
exports.ObjectHasOwnProperty = ObjectHasOwnProperty;
//# sourceMappingURL=helpers.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsInstanceOf = exports.SetInstanceOf = void 0;
var INSTANCE_OF_SYMBOL = Symbol('instanceof');
const INSTANCE_OF_SYMBOL = Symbol('instanceof');
function SetInstanceOf(source, destination) {
var hasInstance = (Symbol.hasInstance in source)
const hasInstance = (Symbol.hasInstance in source)
? source[Symbol.hasInstance].bind(source)
: (function () { return false; });
: (() => false);
Object.defineProperty(source, Symbol.hasInstance, {

@@ -13,3 +13,3 @@ configurable: true,

writable: false,
value: function (instance) {
value: (instance) => {
return (instance instanceof destination)

@@ -16,0 +16,0 @@ || hasInstance(instance);

@@ -10,3 +10,3 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -20,3 +20,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

__exportStar(require("./private-members"), exports);
__exportStar(require("./traits"), exports);
__exportStar(require("./traits/public"), exports);
__exportStar(require("./decorators/public"), exports);
//# sourceMappingURL=public.js.map

@@ -10,3 +10,3 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -10,3 +10,3 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

import { SetInstanceOf } from './instance-of';
export const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
export function GetOwnPropertyKeys(target) {

@@ -7,2 +6,5 @@ return Object.getOwnPropertyNames(target)

}
export function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
export function* GetOwnPropertyDescriptors(target) {

@@ -15,2 +17,23 @@ const keys = GetOwnPropertyKeys(target);

}
export const PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
export function IsPrimitivePropertyName(name) {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
export function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
export function* GetPrototypesChain(target) {
while (target !== null) {
yield target;
target = Object.getPrototypeOf(target);
}
}
export const PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], () => { }].map(_ => Object.getPrototypeOf(_)));
export function IsPrimitivePrototype(proto) {
return PRIMITIVE_PROTOTYPES.has(proto);
}
export function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
export const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
export function* GetPropertyDescriptors(target) {

@@ -173,5 +196,2 @@ const _keys = new Set();

}
export function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}
//# sourceMappingURL=helpers.js.map

@@ -7,3 +7,4 @@ export * from './types/public';

export * from './private-members';
export * from './traits';
export * from './traits/public';
export * from './decorators/public';
//# sourceMappingURL=public.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=class-types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=factory-types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=misc-types.js.map
import { __generator, __spreadArrays } from "tslib";
import { SetInstanceOf } from './instance-of';
export var EXCLUDED_PROPERTY_NAMES = new Set(__spreadArrays(['prototype', 'constructor'], GetOwnPropertyKeys(Object.prototype)));
export function GetOwnPropertyKeys(target) {

@@ -8,2 +7,5 @@ return Object.getOwnPropertyNames(target)

}
export function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
export function GetOwnPropertyDescriptors(target) {

@@ -31,2 +33,31 @@ var keys, i, l, key;

}
export var PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
export function IsPrimitivePropertyName(name) {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
export function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
export function GetPrototypesChain(target) {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(target !== null)) return [3, 2];
return [4, target];
case 1:
_a.sent();
target = Object.getPrototypeOf(target);
return [3, 0];
case 2: return [2];
}
});
}
export var PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], function () { }].map(function (_) { return Object.getPrototypeOf(_); }));
export function IsPrimitivePrototype(proto) {
return PRIMITIVE_PROTOTYPES.has(proto);
}
export function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
export var EXCLUDED_PROPERTY_NAMES = new Set(__spreadArrays(['prototype', 'constructor'], GetOwnPropertyKeys(Object.prototype)));
export function GetPropertyDescriptors(target) {

@@ -220,5 +251,2 @@ var _keys, keys, _i, keys_1, key;

}
export function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}
//# sourceMappingURL=helpers.js.map

@@ -7,3 +7,4 @@ export * from './types/public';

export * from './private-members';
export * from './traits';
export * from './traits/public';
export * from './decorators/public';
//# sourceMappingURL=public.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=class-types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=factory-types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=misc-types.js.map
import { SetInstanceOf } from './instance-of';
export const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
export function GetOwnPropertyKeys(target) {

@@ -7,2 +6,5 @@ return Object.getOwnPropertyNames(target)

}
export function HasOwnProperty(target, propertyKey) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
export function* GetOwnPropertyDescriptors(target) {

@@ -15,2 +17,23 @@ const keys = GetOwnPropertyKeys(target);

}
export const PRIMITIVE_PROPERTY_NAMES = new Set(['prototype', 'constructor']);
export function IsPrimitivePropertyName(name) {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
export function IsNotPrimitivePropertyName(name) {
return !IsPrimitivePropertyName(name);
}
export function* GetPrototypesChain(target) {
while (target !== null) {
yield target;
target = Object.getPrototypeOf(target);
}
}
export const PRIMITIVE_PROTOTYPES = new Set(['', 0, {}, [], () => { }].map(_ => Object.getPrototypeOf(_)));
export function IsPrimitivePrototype(proto) {
return PRIMITIVE_PROTOTYPES.has(proto);
}
export function IsNotPrimitivePrototype(proto) {
return !IsPrimitivePrototype(proto);
}
export const EXCLUDED_PROPERTY_NAMES = new Set(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
export function* GetPropertyDescriptors(target) {

@@ -173,5 +196,2 @@ const _keys = new Set();

}
export function ObjectHasOwnProperty(obj, propertyKey) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}
//# sourceMappingURL=helpers.js.map

@@ -7,3 +7,4 @@ export * from './types/public';

export * from './private-members';
export * from './traits';
export * from './traits/public';
export * from './decorators/public';
//# sourceMappingURL=public.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=class-types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=factory-types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=misc-types.js.map
{
"name": "@lifaon/class-factory",
"version": "1.2.0",
"version": "1.3.0",
"description": "Description",

@@ -31,3 +31,3 @@ "main": "./index.js",

"tslib": "^1.11.1",
"typescript": "3.9.3",
"typescript": "4.0.1-rc",
"typescript-tuple": "^2.2.1",

@@ -34,0 +34,0 @@ "wait-on": "^4.0.2"

@@ -1,4 +0,1 @@

/***** MAKE *****/
import { AbstractClass, Constructor } from './types/class-types';

@@ -14,2 +11,5 @@ import {

/***** MAKE *****/
/**

@@ -16,0 +16,0 @@ * Creates a new class from :

@@ -5,18 +5,38 @@ import { AbstractClass } from './types/class-types';

export const EXCLUDED_PROPERTY_NAMES: Set<PropertyKey> = new Set<PropertyKey>(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
/*---- OBJECT OPERATIONS ON OWN PROPERTIES ----*/
/**
* Returns the list of all own properties of an Object
* Returns the list of all own properties of an object
*/
export function GetOwnPropertyKeys(target: Object): PropertyKey[] {
return (Object.getOwnPropertyNames(target) as PropertyKey[])
.concat(Object.getOwnPropertySymbols(target));
export function GetOwnPropertyKeys<GTarget>(target: GTarget): (keyof GTarget)[] {
return (Object.getOwnPropertyNames(target) as (keyof GTarget)[])
.concat(Object.getOwnPropertySymbols(target) as (keyof GTarget)[]);
}
/**
* Returns true if 'target' has 'propertyKey' as own property
*/
export function HasOwnProperty<GTarget, GPropertyKey extends PropertyKey>(
target: GTarget,
propertyKey: GPropertyKey,
): target is (GTarget & Record<GPropertyKey, any>) {
return Object.prototype.hasOwnProperty.call(target, propertyKey);
}
// export function IsPrototypeOf<GTarget, GPropertyKey extends PropertyKey>(
// target: GTarget,
// propertyKey: GPropertyKey,
// ): target is (GTarget & Record<GPropertyKey, any>) {
// return Object.prototype.isPrototypeOf.call(target, propertyKey);
// }
export function * GetOwnPropertyDescriptors(target: Object): Generator<[PropertyKey, PropertyDescriptor, Object], void, void> {
const keys: PropertyKey[] = GetOwnPropertyKeys(target);
/**
* Returns the list of all own descriptors of an object
*/
export function * GetOwnPropertyDescriptors<GTarget>(
target: GTarget
): Generator<[keyof GTarget, PropertyDescriptor, Object], void, void> {
const keys: (keyof GTarget)[] = GetOwnPropertyKeys<GTarget>(target);
for (let i = 0, l = keys.length; i < l; i++) {
const key: PropertyKey = keys[i];
const key: (keyof GTarget) = keys[i];
yield [key, Object.getOwnPropertyDescriptor(target, key) as PropertyDescriptor, target];

@@ -26,3 +46,48 @@ }

// list of property names that are common to every objects (should probably not be changed)
export const PRIMITIVE_PROPERTY_NAMES = new Set<PropertyKey>(['prototype', 'constructor']);
export function IsPrimitivePropertyName(name: PropertyKey): boolean {
return PRIMITIVE_PROPERTY_NAMES.has(name);
}
export function IsNotPrimitivePropertyName(name: PropertyKey): boolean {
return !IsPrimitivePropertyName(name);
}
/*---- PROTOTYPES CHAIN ----*/
/**
* Returns the list of all prototypes of an object (includes object itself)
*/
export function * GetPrototypesChain(
target: any,
): Generator<any, void, void> {
while (target !== null) {
yield target;
target = Object.getPrototypeOf(target);
}
}
// common (but non exhaustive) list of prototypes that are native to js
export const PRIMITIVE_PROTOTYPES = new Set<any>(['', 0, {}, [], () => {}].map(_ => Object.getPrototypeOf(_)));
export function IsPrimitivePrototype(proto: any): boolean {
return PRIMITIVE_PROTOTYPES.has(proto);
}
export function IsNotPrimitivePrototype(proto: any): boolean {
return !IsPrimitivePrototype(proto);
}
/*--*/
export const EXCLUDED_PROPERTY_NAMES: Set<PropertyKey> = new Set<PropertyKey>(['prototype', 'constructor', ...GetOwnPropertyKeys(Object.prototype)]);
/**
* Returns all descriptors following prototype inheritance for a 'target'

@@ -62,3 +127,2 @@ * @returns iterator [property key, descriptor, target]

/**

@@ -241,5 +305,8 @@ * Copies deeply all properties of 'source' into 'destination'

export function ObjectHasOwnProperty<GObj extends any, GPropertyKey extends PropertyKey>(obj: GObj, propertyKey: GPropertyKey): obj is (GObj & { [GKey in GPropertyKey]: any }) {
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
}

@@ -7,2 +7,3 @@ export * from './types/public';

export * from './private-members';
export * from './traits';
export * from './traits/public';
export * from './decorators/public';

@@ -41,1 +41,9 @@ export interface Constructor<Instance = any, Args extends any[] = any[]> extends Function {

export type TBaseClassIsUndefinedOrVoid<GBaseClass extends (Constructor | void | undefined)>
= [void] extends [GBaseClass]
? true
: (
[undefined] extends [GBaseClass]
? true
: false
);
// kind of any, but different => sometimes better for inference
export type Any = boolean | string | number | object | symbol | null | undefined | any[];
export type TGenericFunction = (...args: any[]) => any;
export type TInferFunctionThis<GFunction extends TGenericFunction> =
GFunction extends (this: infer GThis, ...args: any[]) => any
? GThis
: never;
// converts a tuple type (ex: [number, string]) to an union of types => 'number' | 'string'

@@ -13,2 +20,5 @@ export type TupleTypes<T> = { [P in keyof T]: T[P] } extends { [key: number]: infer V } ? V : never; // type A = TupleTypes<[1, "hello", true]>; // === 1 | "hello" | true

export type UnionToObject<T extends [PropertyKey, any]> = { [key in T[0]]: Extract<T, [key, any]>[1] };
// converts a pure tuple to an array like tuple

@@ -15,0 +25,0 @@ export type TupleArray<TTuple extends any[], TArray> = Array<TArray> & TTuple;

@@ -1,73 +0,385 @@

import { TMakeTypedConstructor } from '../core/types/class-types';
import {
ImplementsTrait, ImplementsTraits, SuperTrait, TMakeSuperTrait, TraitFromClass, TraitsFromClasses
} from '../core/traits';
import { SuperTrait, Trait, TraitFromClass, TraitFunction } from '../core/traits/public';
class A<T> {
propA: T;
constructor(value: T) {
this.propA = value;
// export async function debugTrait1() {
// class A<T> {
// propA: T;
//
// constructor(value: T) {
// this.propA = value;
// }
// }
//
//
// abstract class ATrait<T> {
// methodA(this: A<T>, value: T) {
// this.propA = value;
// }
//
// [Symbol.iterator]() {
//
// }
// }
//
// abstract class CTrait<T> {
// methodC(this: A<T>) {
// console.log(this.propA);
// }
// }
//
// // class B<T> extends SuperTrait<[ATrait<number>], TMakeTypedConstructor<A<number>, [number], typeof A>>(TraitsFromClasses(ATrait), A) {
// //
// // }
//
//
// type BTypedConstructor<T> = TMakeSuperTrait<[ATrait<T>, CTrait<T>], TMakeTypedConstructor<A<T>, [T], typeof A>>;
//
// type BConstructor = {
// new<T>(...args: ConstructorParameters<BTypedConstructor<T>>): InstanceType<BTypedConstructor<T>>;
// };
//
// const B: BConstructor = class B<T> extends SuperTraits(TraitsFromClasses(ATrait, CTrait), A) {
//
// } as BConstructor;
//
// (globalThis as any).ATrait = ATrait;
// // const B = SuperTrait(TraitsFromClasses(ATrait), A);
// type T = TMakeTypedConstructor<A<number>, [number], typeof A>;
// const b = new B<number>(1);
// // b.methodA('h');
// b.methodA(5);
// console.log('debug trait');
//
// if (ImplementsTrait(b, TraitFromClass(ATrait))) {
// // if (ImplementsTrait(B.prototype, TraitFromClass(ATrait))) {
// console.log('implements A trait');
// }
//
// if (ImplementsTrait(b, TraitFromClass(CTrait))) {
// console.log('implements C trait');
// }
//
// const c: A<number> = b;
// // if (ImplementsTrait(c, TraitFromClass(ATrait))) {
// if (ImplementsTraits(c, TraitsFromClasses(ATrait, CTrait))) {
// c.methodA('g');
// console.log('implements A & C traits');
// }
//
// (globalThis as any).B = B;
// (globalThis as any).b = b;
// }
//
//
// export async function debugTrait2() {
//
// class Container {
// value: number;
// }
//
// abstract class MyTrait {
// propTraitA(this: Container): number {
// return this.value;
// }
//
// abstract propTraitB(): number;
// }
//
// // type A = typeof MyTrait.prototype;
// // type A = TInferClassTrait<MyTrait>;
// console.log(MyTrait.prototype);
// }
//
//
// export async function debugTrait3() {
//
// interface IContainer {
// value: number;
// }
//
// interface IMyTrait {
// propTraitA(this: IContainer): number;
// propTraitB(): number;
// }
//
// /*--*/
//
// type TTraitConstraint<GTrait> = {
// [GKey in keyof GTrait]: GTrait[GKey] extends ((...args: any[]) => any)
// ? object
// : never;
// };
//
// class Trait<GTrait extends TTraitConstraint<GTrait>> {
// constructor(
// properties: GTrait
// ) {
// }
// }
//
//
// class Container {
// value: number;
// }
//
// abstract class MyTrait implements IMyTrait {
// propTraitA(this: Container): number {
// return this.value;
// }
//
// propTraitB(): number {
// AbstractMethodCall();
// };
// }
//
// // type StrictType = 'ab';
// // type Type = (void | undefined | StrictType);
// // const b: ([Type] extends [void | undefined] ? true: false) = null as any;
// // const c: ([void | undefined] extends [Type] ? true: false) = null as any;
// // const d: ([void | undefined] extends [StrictType] ? true: false) = null as any;
// // const e: ([void] extends [undefined | void] ? true: false) = null as any;
//
// const a = SuperTraits(TraitsFromClasses(MyTrait));
// const b = SuperTraits<[], void>([]);
// class MyClass extends SuperTraits(TraitsFromClasses(MyTrait)) {
// propTraitB(): number {
// return 5;
// }
// }
//
// // type A = typeof MyTrait.prototype;
// // type A = TInferClassTrait<MyTrait>;
// console.log(MyTrait.prototype);
// }
//
// export async function debugTrait4() {
//
// abstract class TraitA {
// methodA() {
// return 'a';
// }
// }
//
// abstract class TraitB extends TraitA {
// methodB() {
// return 'b';
// }
// }
//
// class A extends SuperTraits(TraitsFromClasses(TraitB)) {
//
// }
//
// // console.log(Array.from(GetSafePropertyDescriptors(TraitB.prototype)));
// const a = new A();
//
// console.log('a', a);
// console.log('ImplementsTrait TraitB', ImplementsTrait(a, TraitFromClass(TraitB)));
// console.log('ImplementsTrait TraitA', ImplementsTrait(a, TraitFromClass(TraitA)));
// }
//
export async function debugTrait5() {
class A {
propA: number;
constructor(
propA: number
) {
this.propA = propA;
}
}
class B extends A {
propB: number;
constructor(
propA: number,
propB: number,
) {
super(propA);
this.propB = propB;
}
}
const traitFnc1 = new TraitFunction('methodA', function methodA(this: A, value: number) {
return this.propA * value * 2;
});
const traitFnc2 = traitFnc1.derive(function methodA(this: B, value: number) {
return this.propB * traitFnc1.call(this, value);
});
// const traitFnc3 = traitFnc1.derive(function methodA(this: A) {
// return 1;
// });
// const traitFnc2 = new TraitFunction('methodB', function (value: number) {
// return value * 2;
// });
// console.log(traitFnc1.call(new A(3), 4));
// console.log(traitFnc2.call(new B(3, 5), 4));
traitFnc1.implementFor(A.prototype);
traitFnc2.implementFor(B.prototype);
// traitFnc3.implementFor(A.prototype);
const a: any = new A(3);
console.log(a.methodA(4));
console.log('traitFnc2.isDerivedFrom traitFnc1', traitFnc2.isDerivedFrom(traitFnc1));
console.log('traitFnc1.isImplementedBy A', traitFnc1.isImplementedBy(new A(0)));
console.log('traitFnc1.isImplementedBy B', traitFnc1.isImplementedBy(new B(0, 0)));
console.log('traitFnc2.isImplementedBy B', traitFnc2.isImplementedBy(new B(0, 0)));
}
export async function debugTrait6() {
class A {
propA: number;
abstract class ATrait<T> {
methodA(this: A<T>, value: T) {
this.propA = value;
constructor(
propA: number
) {
this.propA = propA;
}
}
[Symbol.iterator]() {
class B extends A {
propB: number;
constructor(
propA: number,
propB: number,
) {
super(propA);
this.propB = propB;
}
}
}
abstract class CTrait<T> {
methodC(this: A<T>) {
console.log(this.propA);
class TraitA {
methodA(this: A, value: number) {
return this.propA * value * 2;
}
}
}
// class B<T> extends SuperTrait<[ATrait<number>], TMakeTypedConstructor<A<number>, [number], typeof A>>(TraitsFromClasses(ATrait), A) {
//
// }
class TraitB extends TraitA {
methodA(this: B, value: number) {
return this.propB * TraitA.prototype.methodA.call(this, value);
}
}
const traitFnc1 = new TraitFunction('methodA', function methodA(this: A, value: number) {
return this.propA * value * 2;
});
type BTypedConstructor<T> = TMakeSuperTrait<[ATrait<T>, CTrait<T>], TMakeTypedConstructor<A<T>, [T], typeof A>>;
const traitFnc2 = new TraitFunction('methodB', function methodB(this: A, value: number) {
return this.propA * value * 3;
});
type BConstructor = {
new<T>(...args: ConstructorParameters<BTypedConstructor<T>>): InstanceType<BTypedConstructor<T>>;
};
const traitFnc3 = traitFnc1.derive(function methodA(this: A, value: number, optional?: string) {
return 1;
});
const B: BConstructor = class B<T> extends SuperTrait(TraitsFromClasses(ATrait, CTrait), A) {
const traitFnc4 = new TraitFunction('methodB', function methodB(this: A, value: number) {
return 2;
});
} as BConstructor;
const trait1 = new Trait([
traitFnc1,
traitFnc2,
]);
export async function debugTrait() {
(globalThis as any).ATrait = ATrait;
// const B = SuperTrait(TraitsFromClasses(ATrait), A);
type T = TMakeTypedConstructor<A<number>, [number], typeof A>;
const b = new B<number>(1);
// b.methodA('h');
b.methodA(5);
console.log('debug trait');
const trait2 = trait1.derive([
traitFnc3,
// traitFnc4,
]);
if (ImplementsTrait(b, TraitFromClass(ATrait))) {
// if (ImplementsTrait(B.prototype, TraitFromClass(ATrait))) {
console.log('implements A trait');
const a = trait1.implementFor(A.prototype);
// const b: typeof a.methodA;
//const b = trait1.implementFor(A.prototype);
// type T1 = typeof a.methodA;
// console.log('trait1.isImplementedBy A', trait1.isImplementedBy(new A(0)));
console.log('traitFnc3.isDerivedFrom(traitFnc1)', traitFnc3.isDerivedFrom(traitFnc1));
console.log('trait1.isDerivedFrom(trait2)', trait1.isDerivedFrom(trait2));
console.log('trait2.isDerivedFrom(trait1)', trait2.isDerivedFrom(trait1));
const b = trait2.implementFor(A.prototype);
type T2 = typeof b.methodA;
type T3 = typeof b.methodB;
console.log(b.methodA(5));
}
export async function debugTrait7() {
class A {
propA: number;
constructor(
propA: number
) {
this.propA = propA;
}
}
if (ImplementsTrait(b, TraitFromClass(CTrait))) {
console.log('implements C trait');
class B extends A {
propB: number;
constructor(
propA: number,
propB: number,
) {
super(propA);
this.propB = propB;
}
}
const c: A<number> = b;
// if (ImplementsTrait(c, TraitFromClass(ATrait))) {
if (ImplementsTraits(c, TraitsFromClasses(ATrait, CTrait))) {
c.methodA('g');
console.log('implements A & C traits');
class TraitA {
methodA(this: A, value: number) {
return this.propA * value * 2;
}
}
(globalThis as any).B = B;
(globalThis as any).b = b;
class TraitB extends TraitA {
methodA(this: B, value: number) {
return this.propB * TraitA.prototype.methodA.call(this, value);
}
}
class TraitC {
methodC() {
return 'c';
}
}
const traitA = TraitFromClass(TraitA);
const traitB = TraitFromClass(TraitB);
const traitC = TraitFromClass(TraitC);
console.log(traitA);
console.log(traitB);
console.log(TraitFromClass(TraitA).equals(TraitFromClass(TraitA)));
console.log(traitB.isDerivedFrom(traitA));
// const A1 = traitA.implementFor(A.prototype);
// const mixedTrait = Trait.mix(traitB, traitC);
class C extends SuperTrait(Trait.mix(traitB, traitC), B) {
}
const c = new C(1, 2);
console.log('c', c);
console.log(c.methodA(5));
console.log(c.methodC());
}
export async function debugTrait() {
// await debugTrait1();
// await debugTrait2();
// await debugTrait3();
// await debugTrait4();
// await debugTrait5();
// await debugTrait6();
await debugTrait7();
}

@@ -1,4 +0,4 @@

/***** MAKE *****/
import { AbstractClass, Constructor } from './types/class-types';
import { IMakeFactoryOptions, TMakeFactoryClass, TMakeFactoryCreateSuperClass, TMakeFactoryFactories } from './types/factory-types';
/***** MAKE *****/
/**

@@ -5,0 +5,0 @@ * Creates a new class from :

import { AbstractClass } from './types/class-types';
export declare const EXCLUDED_PROPERTY_NAMES: Set<PropertyKey>;
/**
* Returns the list of all own properties of an Object
* Returns the list of all own properties of an object
*/
export declare function GetOwnPropertyKeys(target: Object): PropertyKey[];
export declare function GetOwnPropertyDescriptors(target: Object): Generator<[PropertyKey, PropertyDescriptor, Object], void, void>;
export declare function GetOwnPropertyKeys<GTarget>(target: GTarget): (keyof GTarget)[];
/**
* Returns true if 'target' has 'propertyKey' as own property
*/
export declare function HasOwnProperty<GTarget, GPropertyKey extends PropertyKey>(target: GTarget, propertyKey: GPropertyKey): target is (GTarget & Record<GPropertyKey, any>);
/**
* Returns the list of all own descriptors of an object
*/
export declare function GetOwnPropertyDescriptors<GTarget>(target: GTarget): Generator<[keyof GTarget, PropertyDescriptor, Object], void, void>;
export declare const PRIMITIVE_PROPERTY_NAMES: Set<string | number | symbol>;
export declare function IsPrimitivePropertyName(name: PropertyKey): boolean;
export declare function IsNotPrimitivePropertyName(name: PropertyKey): boolean;
/**
* Returns the list of all prototypes of an object (includes object itself)
*/
export declare function GetPrototypesChain(target: any): Generator<any, void, void>;
export declare const PRIMITIVE_PROTOTYPES: Set<any>;
export declare function IsPrimitivePrototype(proto: any): boolean;
export declare function IsNotPrimitivePrototype(proto: any): boolean;
export declare const EXCLUDED_PROPERTY_NAMES: Set<PropertyKey>;
/**
* Returns all descriptors following prototype inheritance for a 'target'

@@ -44,4 +61,1 @@ * @returns iterator [property key, descriptor, target]

export declare function BindDescriptorOld(instance: object, key: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor;
export declare function ObjectHasOwnProperty<GObj extends any, GPropertyKey extends PropertyKey>(obj: GObj, propertyKey: GPropertyKey): obj is (GObj & {
[GKey in GPropertyKey]: any;
});

@@ -7,2 +7,3 @@ export * from './types/public';

export * from './private-members';
export * from './traits';
export * from './traits/public';
export * from './decorators/public';

@@ -26,1 +26,4 @@ export interface Constructor<Instance = any, Args extends any[] = any[]> extends Function {

};
export declare type TBaseClassIsUndefinedOrVoid<GBaseClass extends (Constructor | void | undefined)> = [void] extends [GBaseClass] ? true : ([
undefined
] extends [GBaseClass] ? true : false);
export declare type Any = boolean | string | number | object | symbol | null | undefined | any[];
export declare type TGenericFunction = (...args: any[]) => any;
export declare type TInferFunctionThis<GFunction extends TGenericFunction> = GFunction extends (this: infer GThis, ...args: any[]) => any ? GThis : never;
export declare type TupleTypes<T> = {

@@ -9,2 +11,5 @@ [P in keyof T]: T[P];

export declare type TupleToIntersection<T> = UnionToIntersection<TupleTypes<T>>;
export declare type UnionToObject<T extends [PropertyKey, any]> = {
[key in T[0]]: Extract<T, [key, any]>[1];
};
export declare type TupleArray<TTuple extends any[], TArray> = Array<TArray> & TTuple;

@@ -82,3 +87,7 @@ export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

}[Left extends [] ? 'emptyLeft' : Left extends [any] ? 'singleLeft' : TupleIsFinite<Left, 'multiLeft', 'infiniteLeft'>];
export declare type TupleEquals<T, S> = [T] extends [S] ? ([S] extends [T] ? true : false) : false;
export declare type TupleEquals<T, S> = [
T
] extends [S] ? ([
S
] extends [T] ? true : false) : false;
export declare type CreateRange<N, T extends number[] = []> = {

@@ -100,4 +109,6 @@ 0: T;

export declare type IsIntersection<T> = Clone<T> extends T ? false : true;
export declare type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : Not<IsIntersection<T>>;
export declare type IsUnion<T> = [
T
] extends [UnionToIntersection<T>] ? false : Not<IsIntersection<T>>;
export declare type IsSingleton<T> = Clone<T> extends T ? [T] extends [UnionToIntersection<T>] ? true : false : false;
export declare type IsType<TargetType, T> = false extends (TargetType extends T ? T extends TargetType ? true : false : false) ? false : true;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc