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

@lit/context

Package Overview
Dependencies
Maintainers
9
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lit/context - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

development/lib/create-context.d.ts

@@ -23,3 +23,3 @@ /**

*
* Contexts are compared with with strict equality.
* Contexts are compared with strict equality.
*

@@ -26,0 +26,0 @@ * If you want two separate `createContext()` calls to referer to the same

@@ -9,3 +9,3 @@ /**

*
* Contexts are compared with with strict equality.
* Contexts are compared with strict equality.
*

@@ -12,0 +12,0 @@ * If you want two separate `createContext()` calls to referer to the same

@@ -46,4 +46,3 @@ /**

callback: (value) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this[nameOrContext.name] = value;
protoOrTarget.set.call(this, value);
},

@@ -50,0 +49,0 @@ subscribe,

@@ -68,6 +68,6 @@ /**

newDescriptor = {
get: function () {
get() {
return valueMap.get(this);
},
set: function (value) {
set(value) {
controllerMap.get(this).setValue(value);

@@ -84,3 +84,3 @@ valueMap.set(this, value);

...descriptor,
set: function (value) {
set(value) {
controllerMap.get(this).setValue(value);

@@ -87,0 +87,0 @@ oldSetter?.call(this, value);

@@ -23,3 +23,3 @@ /**

*
* Contexts are compared with with strict equality.
* Contexts are compared with strict equality.
*

@@ -26,0 +26,0 @@ * If you want two separate `createContext()` calls to referer to the same

@@ -6,3 +6,3 @@ import{ContextConsumer as t}from"../controllers/context-consumer.js";

* SPDX-License-Identifier: BSD-3-Clause
*/function c({context:c,subscribe:e}){return(o,n)=>{"object"==typeof n?n.addInitializer((function(){new t(this,{context:c,callback:t=>{this[n.name]=t},subscribe:e})})):o.constructor.addInitializer((o=>{new t(o,{context:c,callback:t=>{o[n]=t},subscribe:e})}))}}export{c as consume};
*/function c({context:c,subscribe:e}){return(o,n)=>{"object"==typeof n?n.addInitializer((function(){new t(this,{context:c,callback:t=>{o.set.call(this,t)},subscribe:e})})):o.constructor.addInitializer((o=>{new t(o,{context:c,callback:t=>{o[n]=t},subscribe:e})}))}}export{c as consume};
//# sourceMappingURL=consume.js.map

@@ -6,3 +6,3 @@ import{ContextProvider as t}from"../controllers/context-provider.js";

* SPDX-License-Identifier: BSD-3-Clause
*/function e({context:e}){return(n,i)=>{const o=new WeakMap;if("object"==typeof i)return i.addInitializer((function(){o.set(this,new t(this,{context:e}))})),{get(){return n.get.call(this)},set(t){return o.get(this)?.setValue(t),n.set.call(this,t)},init(t){return o.get(this)?.setValue(t),t}};{n.constructor.addInitializer((n=>{o.set(n,new t(n,{context:e}))}));const r=Object.getOwnPropertyDescriptor(n,i);let s;if(void 0===r){const t=new WeakMap;s={get:function(){return t.get(this)},set:function(e){o.get(this).setValue(e),t.set(this,e)},configurable:!0,enumerable:!0}}else{const t=r.set;s={...r,set:function(e){o.get(this).setValue(e),t?.call(this,e)}}}return void Object.defineProperty(n,i,s)}}}export{e as provide};
*/function e({context:e}){return(n,r)=>{const i=new WeakMap;if("object"==typeof r)return r.addInitializer((function(){i.set(this,new t(this,{context:e}))})),{get(){return n.get.call(this)},set(t){return i.get(this)?.setValue(t),n.set.call(this,t)},init(t){return i.get(this)?.setValue(t),t}};{n.constructor.addInitializer((n=>{i.set(n,new t(n,{context:e}))}));const o=Object.getOwnPropertyDescriptor(n,r);let s;if(void 0===o){const t=new WeakMap;s={get(){return t.get(this)},set(e){i.get(this).setValue(e),t.set(this,e)},configurable:!0,enumerable:!0}}else{const t=o.set;s={...o,set(e){i.get(this).setValue(e),t?.call(this,e)}}}return void Object.defineProperty(n,r,s)}}}export{e as provide};
//# sourceMappingURL=provide.js.map
{
"name": "@lit/context",
"version": "1.1.1",
"version": "1.1.2",
"description": "Helpers and controllers for using Context protocol",

@@ -215,3 +215,3 @@ "license": "BSD-3-Clause",

"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"chai": "^5.1.0",
"@lit-internal/scripts": "^1.0.1",

@@ -218,0 +218,0 @@ "@lit-labs/testing": "^0.2.2",

@@ -26,3 +26,3 @@ /**

*
* Contexts are compared with with strict equality.
* Contexts are compared with strict equality.
*

@@ -29,0 +29,0 @@ * If you want two separate `createContext()` calls to referer to the same

@@ -50,14 +50,15 @@ /**

}): ConsumeDecorator<ValueType> {
return (<C extends ReactiveElement, V extends ValueType>(
protoOrTarget: ClassAccessorDecoratorTarget<C, V>,
nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>
return ((
protoOrTarget: ClassAccessorDecoratorTarget<ReactiveElement, ValueType>,
nameOrContext:
| PropertyKey
| ClassAccessorDecoratorContext<ReactiveElement, ValueType>
) => {
if (typeof nameOrContext === 'object') {
// Standard decorators branch
nameOrContext.addInitializer(function (this: ReactiveElement): void {
nameOrContext.addInitializer(function () {
new ContextConsumer(this, {
context,
callback: (value: ValueType) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this as any)[nameOrContext.name] = value;
callback: (value) => {
protoOrTarget.set.call(this, value);
},

@@ -73,3 +74,3 @@ subscribe,

context,
callback: (value: ValueType) => {
callback: (value) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -76,0 +77,0 @@ (element as any)[nameOrContext] = value;

@@ -43,5 +43,7 @@ /**

}): ProvideDecorator<ValueType> {
return (<C extends ReactiveElement, V extends ValueType>(
protoOrTarget: ClassAccessorDecoratorTarget<C, V>,
nameOrContext: PropertyKey | ClassAccessorDecoratorContext<C, V>
return ((
protoOrTarget: ClassAccessorDecoratorTarget<ReactiveElement, ValueType>,
nameOrContext:
| PropertyKey
| ClassAccessorDecoratorContext<ReactiveElement, ValueType>
) => {

@@ -55,3 +57,3 @@ // Map of instances to controllers

// Standard decorators branch
nameOrContext.addInitializer(function (this: ReactiveElement) {
nameOrContext.addInitializer(function () {
controllerMap.set(this, new ContextProvider(this, {context}));

@@ -61,9 +63,9 @@ });

get(this: ReactiveElement) {
return protoOrTarget.get.call(this as unknown as C);
return protoOrTarget.get.call(this);
},
set(this: ReactiveElement, value: V) {
set(this: ReactiveElement, value: ValueType) {
controllerMap.get(this)?.setValue(value);
return protoOrTarget.set.call(this as unknown as C, value);
return protoOrTarget.set.call(this, value);
},
init(this: ReactiveElement, value: V) {
init(this: ReactiveElement, value: ValueType) {
controllerMap.get(this)?.setValue(value);

@@ -90,6 +92,6 @@ return value;

newDescriptor = {
get: function (this: ReactiveElement) {
get(this: ReactiveElement) {
return valueMap.get(this);
},
set: function (this: ReactiveElement, value: ValueType) {
set(this: ReactiveElement, value: ValueType) {
controllerMap.get(this)!.setValue(value);

@@ -105,3 +107,3 @@ valueMap.set(this, value);

...descriptor,
set: function (this: ReactiveElement, value: ValueType) {
set(this: ReactiveElement, value: ValueType) {
controllerMap.get(this)!.setValue(value);

@@ -108,0 +110,0 @@ oldSetter?.call(this, value);

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc