Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bem-react/di

Package Overview
Dependencies
Maintainers
6
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bem-react/di - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

10

build/di.development.js

@@ -21,4 +21,4 @@ 'use strict';

var registryContext = React.createContext({});
var RegistriesConsumer = registryContext.Consumer;
var RegistryProvider = registryContext.Provider;
var RegistryConsumer = registryContext.Consumer;
function withRegistry() {

@@ -30,3 +30,3 @@ // Use arguments instead of rest-arguments to get faster and more compact code.

var providedRegistriesRef = React.useRef(null);
return (React.createElement(RegistryConsumer, null, function (contextRegistries) {
return (React.createElement(RegistriesConsumer, null, function (contextRegistries) {
if (providedRegistriesRef.current === null) {

@@ -59,3 +59,3 @@ var providedRegistries = __assign({}, contextRegistries);

}
var ComponentRegistryConsumer = function (props) { return (React.createElement(RegistryConsumer, null, function (registries) {
var RegistryConsumer = function (props) { return (React.createElement(RegistriesConsumer, null, function (registries) {
{

@@ -68,2 +68,6 @@ if (!registries[props.id]) {

})); };
/**
* @deprecated consider using 'RegistryConsumer' instead
*/
var ComponentRegistryConsumer = RegistryConsumer;
var useRegistries = function () {

@@ -70,0 +74,0 @@ return React.useContext(registryContext);

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

'use strict';function e(e){return{$symbol:c,overload:e}}function t(e){return e.$symbol===c}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.Provider,s=i.Consumer,u=function(){return r.useContext(i)},a=function(e){return u()[e].snapshot()},l=a,c='RegistryOverloadHMark',p=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=function(e){return r.createElement(s,null,function(t){return e.children(t[e.id].snapshot())})},exports.Registry=p,exports.RegistryConsumer=s,exports.registryContext=i,exports.useComponentRegistry=l,exports.useRegistries=u,exports.useRegistry=a,exports.withRegistry=function(){var e=[].slice.call(arguments);return function(t){return function(i){var u=r.useRef(null);return r.createElement(s,null,function(s){if(null===u.current){for(var a=n({},s),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(o,{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(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))})}}};

@@ -6,2 +6,8 @@ # Change Log

# [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)
### Features
- **di:** rename ComponentRegistryConsumer to RegistryConsumer ([2420041](https://github.com/bem/bem-react/commit/24200415e8b54868ab7932a9531e5313d316b526))
# [3.0.0](https://github.com/bem/bem-react/compare/@bem-react/di@2.2.8...@bem-react/di@3.0.0) (2021-06-22)

@@ -8,0 +14,0 @@

import React, { ReactNode, FC, ComponentType } from 'react';
export declare type RegistryContext = Record<string, Registry>;
export declare const registryContext: React.Context<Record<string, Registry>>;
export declare const RegistryConsumer: React.ExoticComponent<React.ConsumerProps<Record<string, Registry>>>;
export declare function withRegistry(...registries: Registry[]): <P>(Component: ComponentType<P>) => FC<P>;
export interface IComponentRegistryConsumerProps {
export interface IRegistryConsumerProps {
id: string;
children: (registry: any) => ReactNode;
}
export declare const ComponentRegistryConsumer: FC<IComponentRegistryConsumerProps>;
export declare const RegistryConsumer: FC<IRegistryConsumerProps>;
/**
* @deprecated consider using 'RegistryConsumer' instead
*/
export declare const ComponentRegistryConsumer: React.FunctionComponent<IRegistryConsumerProps>;
export declare const useRegistries: () => Record<string, Registry>;

@@ -12,0 +15,0 @@ export declare const useRegistry: <T extends {}>(id: string) => T;

{
"name": "@bem-react/di",
"version": "3.0.0",
"version": "3.1.0",
"description": "BEM React Dependency Injection",

@@ -33,3 +33,3 @@ "homepage": "https://github.com/bem/bem-react/tree/master/packages/di",

},
"gitHead": "2ad5610fd32e66840afa1f04aa6222346f7f002b"
"gitHead": "88afc379bb048e9e5f4633e5430c9d28d5b6d693"
}

@@ -141,3 +141,3 @@ # @bem-react/di &middot; [![npm (scoped)](https://img.shields.io/npm/v/@bem-react/di.svg)](https://www.npmjs.com/package/@bem-react/di) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@bem-react/di.svg)](https://bundlephobia.com/result?p=@bem-react/di)

with `ComponentRegistryConsumer`
with `RegistryConsumer`

@@ -147,3 +147,3 @@ ```tsx

import { cn } from '@bem-react/classname'
import { ComponentRegistryConsumer } from '@bem-react/di'
import { RegistryConsumer } from '@bem-react/di'

@@ -155,3 +155,3 @@ // No Header or Footer imports

export const App = () => (
<ComponentRegistryConsumer id={cnApp()}>
<RegistryConsumer id={cnApp()}>
{({ Header, Footer }) => (

@@ -163,3 +163,3 @@ <>

)}
</ComponentRegistryConsumer>
</RegistryConsumer>
)

@@ -166,0 +166,0 @@ ```

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc