@bem-react/di
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -66,7 +66,6 @@ 'use strict'; | ||
var registryHocMark = 'RegistryHoc'; | ||
function getBaseComponentNotFoundMessage(hoc) { | ||
return "Not found base component for enhance HOC: " + hoc.toString(); | ||
} | ||
function withBase(hoc) { | ||
var fakeComponent = function () { throw new Error(getBaseComponentNotFoundMessage(hoc)); }; | ||
var fakeComponent = function () { | ||
throw new Error("Not found base component for enhance HOC: " + hoc.toString()); | ||
}; | ||
fakeComponent.$symbol = registryHocMark; | ||
@@ -112,3 +111,6 @@ fakeComponent.hoc = hoc; | ||
Registry.prototype.fill = function (componentsSet) { | ||
this.components = __assign({}, this.components, componentsSet); | ||
// tslint:disable-next-line:forin | ||
for (var key in componentsSet) { | ||
this.components[key] = componentsSet[key]; | ||
} | ||
return this; | ||
@@ -163,3 +165,3 @@ }; | ||
if (!base) | ||
throw new Error(getBaseComponentNotFoundMessage(overrides.hoc)); | ||
return overrides; | ||
if (isHoc(base)) { | ||
@@ -166,0 +168,0 @@ // If both components are hocs, then create compose-hoc |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),__assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},registryContext=React.createContext({}),RegistryProvider=registryContext.Provider,RegistryConsumer=registryContext.Consumer;function withRegistry(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var r=function(r){return React.createElement(RegistryConsumer,null,function(n){var o=__assign({},n);return e.forEach(function(e){var t=n[e.id];o[e.id]=e.overridable?t?e.merge(t):e:e&&t?t.merge(e):e}),React.createElement(RegistryProvider,{value:o},React.createElement(t,__assign({},r)))})};return r.displayName="RegistryResolver("+e.map(function(e){return e.id}).join(", ")+")",r}}var ComponentRegistryConsumer=function(e){return React.createElement(RegistryConsumer,null,function(t){return e.children(t[e.id].snapshot())})},useRegistries=function(){return React.useContext(registryContext)},useComponentRegistry=function(e){return useRegistries()[e].snapshot()},registryHocMark="RegistryHoc";function getBaseComponentNotFoundMessage(e){return"Not found base component for enhance HOC: "+e.toString()}function withBase(e){var t=function(){throw new Error(getBaseComponentNotFoundMessage(e))};return t.$symbol=registryHocMark,t.hoc=e,t}function isHoc(e){return e.$symbol===registryHocMark}var Registry=function(){function e(e){var t=e.id,r=e.overridable,n=void 0===r||r;this.components={},this.id=t,this.overridable=n}return e.prototype.set=function(e,t){return this.components[e]=t,this},e.prototype.extends=function(e,t){return this.components[e]=withBase(t),this},e.prototype.fill=function(e){return this.components=__assign({},this.components,e),this},e.prototype.get=function(e){return this.components[e]},e.prototype.snapshot=function(){return this.components},e.prototype.merge=function(t){var r=new e({id:this.id,overridable:this.overridable});if(r.fill(this.components),!t)return r;var n=t.snapshot();for(var o in n)n.hasOwnProperty(o)&&(r.components[o]=this.mergeComponents(r.components[o],n[o]));return r},e.prototype.mergeComponents=function(e,t){if(isHoc(t)){if(!e)throw new Error(getBaseComponentNotFoundMessage(t.hoc));return isHoc(e)?withBase(function(r){return t.hoc(e.hoc(r))}):t.hoc(e)}return t},e}();exports.ComponentRegistryConsumer=ComponentRegistryConsumer,exports.Registry=Registry,exports.RegistryConsumer=RegistryConsumer,exports.registryContext=registryContext,exports.useComponentRegistry=useComponentRegistry,exports.useRegistries=useRegistries,exports.withRegistry=withRegistry; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),__assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},registryContext=React.createContext({}),RegistryProvider=registryContext.Provider,RegistryConsumer=registryContext.Consumer;function withRegistry(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){var r=function(r){return React.createElement(RegistryConsumer,null,function(n){var o=__assign({},n);return e.forEach(function(e){var t=n[e.id];o[e.id]=e.overridable?t?e.merge(t):e:e&&t?t.merge(e):e}),React.createElement(RegistryProvider,{value:o},React.createElement(t,__assign({},r)))})};return r.displayName="RegistryResolver("+e.map(function(e){return e.id}).join(", ")+")",r}}var ComponentRegistryConsumer=function(e){return React.createElement(RegistryConsumer,null,function(t){return e.children(t[e.id].snapshot())})},useRegistries=function(){return React.useContext(registryContext)},useComponentRegistry=function(e){return useRegistries()[e].snapshot()},registryHocMark="RegistryHoc";function withBase(e){var t=function(){throw new Error("Not found base component for enhance HOC: "+e.toString())};return t.$symbol=registryHocMark,t.hoc=e,t}function isHoc(e){return e.$symbol===registryHocMark}var Registry=function(){function e(e){var t=e.id,r=e.overridable,n=void 0===r||r;this.components={},this.id=t,this.overridable=n}return e.prototype.set=function(e,t){return this.components[e]=t,this},e.prototype.extends=function(e,t){return this.components[e]=withBase(t),this},e.prototype.fill=function(e){for(var t in e)this.components[t]=e[t];return this},e.prototype.get=function(e){return this.components[e]},e.prototype.snapshot=function(){return this.components},e.prototype.merge=function(t){var r=new e({id:this.id,overridable:this.overridable});if(r.fill(this.components),!t)return r;var n=t.snapshot();for(var o in n)n.hasOwnProperty(o)&&(r.components[o]=this.mergeComponents(r.components[o],n[o]));return r},e.prototype.mergeComponents=function(e,t){return isHoc(t)&&e?isHoc(e)?withBase(function(r){return t.hoc(e.hoc(r))}):t.hoc(e):t},e}();exports.ComponentRegistryConsumer=ComponentRegistryConsumer,exports.Registry=Registry,exports.RegistryConsumer=RegistryConsumer,exports.registryContext=registryContext,exports.useComponentRegistry=useComponentRegistry,exports.useRegistries=useRegistries,exports.withRegistry=withRegistry; |
@@ -6,2 +6,12 @@ # Change Log | ||
## [2.2.2](https://github.com/bem/bem-react/compare/@bem-react/di@2.2.1...@bem-react/di@2.2.2) (2020-03-02) | ||
### Bug Fixes | ||
- **di:** fixes a way to extends components ([629b2a5](https://github.com/bem/bem-react/commit/629b2a508d92997b30a2f7a9342b2f0fd4337e4b)) | ||
### Performance Improvements | ||
- **di:** improving performance ([469966f](https://github.com/bem/bem-react/commit/469966f01f4c11f27971625d8681f38beabcd773)) | ||
## [2.2.1](https://github.com/bem/bem-react/compare/@bem-react/di@2.2.0...@bem-react/di@2.2.1) (2019-12-27) | ||
@@ -8,0 +18,0 @@ |
{ | ||
"name": "@bem-react/di", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "BEM React Dependency Injection", | ||
@@ -51,3 +51,3 @@ "homepage": "https://github.com/bem/bem-react/tree/master/packages/di", | ||
}, | ||
"gitHead": "dcb03d8b22168beeb9f0e372c10efaf4c7d29e51" | ||
"gitHead": "66c9e7002906b49f716747c96123dd1bdeddf6ca" | ||
} |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
43148
8
266
3