@bem-react/di
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -162,3 +162,3 @@ 'use strict'; | ||
continue; | ||
clone.entities[entityName] = this.mergeEntities(this.id, clone.entities[entityName], otherRegistryEntities[entityName]); | ||
clone.entities[entityName] = this.mergeEntities(clone.entities[entityName], otherRegistryEntities[entityName]); | ||
} | ||
@@ -170,11 +170,9 @@ return clone; | ||
* | ||
* @param id entity entry id | ||
* @param base base implementation | ||
* @param overrides overridden implementation | ||
*/ | ||
Registry.prototype.mergeEntities = function (id, base, overrides) { | ||
Registry.prototype.mergeEntities = function (base, overrides) { | ||
if (isOverload(overrides)) { | ||
if (!base && true) { | ||
throw new Error("Overload has no base in Registry '" + id + "'."); | ||
} | ||
if (!base) | ||
return overrides; | ||
if (isOverload(base)) { | ||
@@ -181,0 +179,0 @@ // If both entities are hocs, then create compose-hoc |
@@ -1,1 +0,1 @@ | ||
'use strict';function e(e){return{$symbol:f,overload:e}}function t(e){return e.$symbol===f}Object.defineProperty(exports,'__esModule',{value:!0});var r=require('react'),n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=r.createContext({}),o=i.Consumer,s=i.Provider,u=function(e){return r.createElement(o,null,function(t){return e.children(t[e.id].snapshot())})},a=u,l=function(){return r.useContext(i)},c=function(e){return l()[e].snapshot()},p=c,f='RegistryOverloadHMark',h=function(){function r(e){var t=e.id,r=e.overridable,n=void 0===r||r;this.entities={},this.id=t,this.overridable=n}return r.prototype.set=function(e,t){return this.entities[e]=t,this},r.prototype.extends=function(t,r){return this.entities[t]=e(r),this},r.prototype.fill=function(e){for(var t in e)this.entities[t]=e[t];return this},r.prototype.get=function(e){return this.entities[e]},r.prototype.snapshot=function(){return this.entities},r.prototype.merge=function(e){var t=new r({id:this.id,overridable:this.overridable});if(t.fill(this.entities),!e)return t;var n=e.snapshot();for(var i in n)n.hasOwnProperty(i)&&(t.entities[i]=this.mergeEntities(this.id,t.entities[i],n[i]));return t},r.prototype.mergeEntities=function(r,n,i){return t(i)?t(n)?e(function(e){return i.overload(n.overload(e))}):i.overload(n):i},r}();exports.ComponentRegistryConsumer=a,exports.Registry=h,exports.RegistryConsumer=u,exports.registryContext=i,exports.useComponentRegistry=p,exports.useRegistries=l,exports.useRegistry=c,exports.withRegistry=function(){var e=[].slice.call(arguments);return function(t){return function(i){var u=r.useRef(null);return r.createElement(o,null,function(o){if(null===u.current){for(var a=n({},o),l=0;l<e.length;l++){var c=e[l],p=a[c.id];a[c.id]=c.overridable?p?c.merge(p):c:c&&p?p.merge(c):c}u.current=a}return r.createElement(s,{value:u.current},r.createElement(t,i))})}}}; | ||
'use strict';function e(e){return{$symbol:f,overload:e}}function t(e){return e.$symbol===f}Object.defineProperty(exports,'__esModule',{value:!0});var r=require('react'),n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=r.createContext({}),o=i.Consumer,s=i.Provider,u=function(e){return r.createElement(o,null,function(t){return e.children(t[e.id].snapshot())})},a=u,l=function(){return r.useContext(i)},c=function(e){return l()[e].snapshot()},p=c,f='RegistryOverloadHMark',h=function(){function r(e){var t=e.id,r=e.overridable,n=void 0===r||r;this.entities={},this.id=t,this.overridable=n}return r.prototype.set=function(e,t){return this.entities[e]=t,this},r.prototype.extends=function(t,r){return this.entities[t]=e(r),this},r.prototype.fill=function(e){for(var t in e)this.entities[t]=e[t];return this},r.prototype.get=function(e){return this.entities[e]},r.prototype.snapshot=function(){return this.entities},r.prototype.merge=function(e){var t=new r({id:this.id,overridable:this.overridable});if(t.fill(this.entities),!e)return t;var n=e.snapshot();for(var i in n)n.hasOwnProperty(i)&&(t.entities[i]=this.mergeEntities(t.entities[i],n[i]));return t},r.prototype.mergeEntities=function(r,n){return t(n)&&r?t(r)?e(function(e){return n.overload(r.overload(e))}):n.overload(r):n},r}();exports.ComponentRegistryConsumer=a,exports.Registry=h,exports.RegistryConsumer=u,exports.registryContext=i,exports.useComponentRegistry=p,exports.useRegistries=l,exports.useRegistry=c,exports.withRegistry=function(){var e=[].slice.call(arguments);return function(t){return function(i){var u=r.useRef(null);return r.createElement(o,null,function(o){if(null===u.current){for(var a=n({},o),l=0;l<e.length;l++){var c=e[l],p=a[c.id];a[c.id]=c.overridable?p?c.merge(p):c:c&&p?p.merge(c):c}u.current=a}return r.createElement(s,{value:u.current},r.createElement(t,i))})}}}; |
@@ -6,2 +6,8 @@ # Change Log | ||
## [3.1.1](https://github.com/bem/bem-react/compare/@bem-react/di@3.1.0...@bem-react/di@3.1.1) (2021-06-29) | ||
### Bug Fixes | ||
- **di:** fix partial merge of registries ([3ef511d](https://github.com/bem/bem-react/commit/3ef511dc18b01676d9528b62e71b81c9ca16d71d)) | ||
# [3.1.0](https://github.com/bem/bem-react/compare/@bem-react/di@3.0.0...@bem-react/di@3.1.0) (2021-06-23) | ||
@@ -8,0 +14,0 @@ |
@@ -77,3 +77,2 @@ import React, { ReactNode, FC, ComponentType } from 'react'; | ||
* | ||
* @param id entity entry id | ||
* @param base base implementation | ||
@@ -80,0 +79,0 @@ * @param overrides overridden implementation |
{ | ||
"name": "@bem-react/di", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "BEM React Dependency Injection", | ||
@@ -33,3 +33,3 @@ "homepage": "https://github.com/bem/bem-react/tree/master/packages/di", | ||
}, | ||
"gitHead": "88afc379bb048e9e5f4633e5430c9d28d5b6d693" | ||
"gitHead": "442128551bfd755e87aa9ea63dca4677c7e64709" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
46140
0
284