import { $CONSTRUCTOR, MetaContext } from '../MetaContext'; import { $name as _object } from '../types/builtins/_object'; import { $CONSTRUCT, genericConstruct } from '../operations/base/$construct'; export const $SUPER = '$super'; export const withRegisterClass = MetaContext>(MetaContextBase: TMetaContextBase) => class extends MetaContextBase { registerClass(props: any) { const $constructor = props[$CONSTRUCTOR]; if (typeof $constructor === 'function') { const $baseConstructor = Object.getPrototypeOf($constructor); if ($baseConstructor !== Function.prototype) { const $super = this.getConstructor($baseConstructor); if ($super !== undefined) return this.register({ ...$super, [$SUPER]: $super, ...props }); } const $super = this.resolveName(_object); return this.register({ ...$super, [$SUPER]: $super, [$CONSTRUCT]: genericConstruct, ...props }); } return this.register(props); } };