New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.0.0 to 1.0.1

6

development/lib/controllers/context-consumer.d.ts

@@ -6,4 +6,4 @@ /**

*/
import { Context, ContextType } from '../create-context.js';
import { ReactiveController, ReactiveElement } from 'lit';
import type { Context, ContextType } from '../create-context.js';
import type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element';
export interface Options<C extends Context<unknown, unknown>> {

@@ -26,3 +26,3 @@ context: C;

*/
export declare class ContextConsumer<C extends Context<unknown, unknown>, HostElement extends ReactiveElement> implements ReactiveController {
export declare class ContextConsumer<C extends Context<unknown, unknown>, HostElement extends ReactiveControllerHost & HTMLElement> implements ReactiveController {
protected host: HostElement;

@@ -29,0 +29,0 @@ private context;

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

import { ContextRequestEvent } from '../context-request-event.js';
import { Context, ContextType } from '../create-context.js';
import { ValueNotifier } from '../value-notifier.js';
import { ReactiveController, ReactiveElement } from 'lit';
import type { Context, ContextType } from '../create-context.js';
import type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element';
declare global {

@@ -32,2 +32,3 @@ interface HTMLElementEventMap {

}
type ReactiveElementHost = ReactiveControllerHost & HTMLElement;
/**

@@ -41,8 +42,8 @@ * A ReactiveController which adds context provider behavior to a

*/
export declare class ContextProvider<T extends Context<unknown, unknown>> extends ValueNotifier<ContextType<T>> implements ReactiveController {
protected readonly host: ReactiveElement;
export declare class ContextProvider<T extends Context<unknown, unknown>, HostElement extends ReactiveElementHost = ReactiveElementHost> extends ValueNotifier<ContextType<T>> implements ReactiveController {
protected readonly host: HostElement;
private readonly context;
constructor(host: ReactiveElement, options: Options<T>);
constructor(host: HostElement, options: Options<T>);
/** @deprecated Use new ContextProvider(host, options) */
constructor(host: ReactiveElement, context: T, initialValue?: ContextType<T>);
constructor(host: HostElement, context: T, initialValue?: ContextType<T>);
onContextRequest: (ev: ContextRequestEvent<Context<unknown, unknown>>) => void;

@@ -59,2 +60,3 @@ /**

}
export {};
//# sourceMappingURL=context-provider.d.ts.map

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

type ConsumeDecorator<ValueType> = {
<K extends PropertyKey, Proto extends Interface<ReactiveElement>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchProvidedType<Proto, K, ValueType>;
<C extends Interface<ReactiveElement>, V extends ValueType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
<K extends PropertyKey, Proto extends Interface<Omit<ReactiveElement, 'renderRoot'>>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchProvidedType<Proto, K, ValueType>;
<C extends Interface<Omit<ReactiveElement, 'renderRoot'>>, V extends ValueType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
};

@@ -50,0 +50,0 @@ type DecoratorReturn = void | any;

@@ -9,24 +9,17 @@ /**

/**
* A property decorator that adds a ContextConsumer controller to the component
* which will try and retrieve a value for the property via the Context API.
* A property decorator that adds a ContextProvider controller to the component
* making it respond to any `context-request` events from its children consumer.
*
* @param context A Context identifier value created via `createContext`
* @param multiple An optional boolean which when true allows the value to be updated
* multiple times.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* @example
*
* ```ts
* import {consume} from '@lit/context';
* import {loggerContext} from 'community-protocols/logger';
* import {provide} from '@lit/context';
* import {Logger} from 'my-logging-library';
* import {loggerContext} from './logger-context.js';
*
* class MyElement {
* @provide({context: loggerContext})
* logger;
*
* doThing() {
* this.logger.log('thing was done');
* }
* logger = new Logger();
* }

@@ -48,4 +41,4 @@ * ```

type ProvideDecorator<ContextType> = {
<K extends PropertyKey, Proto extends Interface<ReactiveElement>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchContextType<Proto, K, ContextType>;
<C extends Interface<ReactiveElement>, V extends ContextType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
<K extends PropertyKey, Proto extends Interface<Omit<ReactiveElement, 'renderRoot'>>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchContextType<Proto, K, ContextType>;
<C extends Interface<Omit<ReactiveElement, 'renderRoot'>>, V extends ContextType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
};

@@ -52,0 +45,0 @@ type DecoratorReturn = void | any;

@@ -14,24 +14,17 @@ /**

/**
* A property decorator that adds a ContextConsumer controller to the component
* which will try and retrieve a value for the property via the Context API.
* A property decorator that adds a ContextProvider controller to the component
* making it respond to any `context-request` events from its children consumer.
*
* @param context A Context identifier value created via `createContext`
* @param multiple An optional boolean which when true allows the value to be updated
* multiple times.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* @example
*
* ```ts
* import {consume} from '@lit/context';
* import {loggerContext} from 'community-protocols/logger';
* import {provide} from '@lit/context';
* import {Logger} from 'my-logging-library';
* import {loggerContext} from './logger-context.js';
*
* class MyElement {
* @provide({context: loggerContext})
* logger;
*
* doThing() {
* this.logger.log('thing was done');
* }
* logger = new Logger();
* }

@@ -38,0 +31,0 @@ * ```

@@ -6,4 +6,4 @@ /**

*/
import { Context, ContextType } from '../create-context.js';
import { ReactiveController, ReactiveElement } from 'lit';
import type { Context, ContextType } from '../create-context.js';
import type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element';
export interface Options<C extends Context<unknown, unknown>> {

@@ -26,3 +26,3 @@ context: C;

*/
export declare class ContextConsumer<C extends Context<unknown, unknown>, HostElement extends ReactiveElement> implements ReactiveController {
export declare class ContextConsumer<C extends Context<unknown, unknown>, HostElement extends ReactiveControllerHost & HTMLElement> implements ReactiveController {
protected host: HostElement;

@@ -29,0 +29,0 @@ private context;

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

import { ContextRequestEvent } from '../context-request-event.js';
import { Context, ContextType } from '../create-context.js';
import { ValueNotifier } from '../value-notifier.js';
import { ReactiveController, ReactiveElement } from 'lit';
import type { Context, ContextType } from '../create-context.js';
import type { ReactiveController, ReactiveControllerHost } from '@lit/reactive-element';
declare global {

@@ -32,2 +32,3 @@ interface HTMLElementEventMap {

}
type ReactiveElementHost = ReactiveControllerHost & HTMLElement;
/**

@@ -41,8 +42,8 @@ * A ReactiveController which adds context provider behavior to a

*/
export declare class ContextProvider<T extends Context<unknown, unknown>> extends ValueNotifier<ContextType<T>> implements ReactiveController {
protected readonly host: ReactiveElement;
export declare class ContextProvider<T extends Context<unknown, unknown>, HostElement extends ReactiveElementHost = ReactiveElementHost> extends ValueNotifier<ContextType<T>> implements ReactiveController {
protected readonly host: HostElement;
private readonly context;
constructor(host: ReactiveElement, options: Options<T>);
constructor(host: HostElement, options: Options<T>);
/** @deprecated Use new ContextProvider(host, options) */
constructor(host: ReactiveElement, context: T, initialValue?: ContextType<T>);
constructor(host: HostElement, context: T, initialValue?: ContextType<T>);
onContextRequest: (ev: ContextRequestEvent<Context<unknown, unknown>>) => void;

@@ -59,2 +60,3 @@ /**

}
export {};
//# sourceMappingURL=context-provider.d.ts.map

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

type ConsumeDecorator<ValueType> = {
<K extends PropertyKey, Proto extends Interface<ReactiveElement>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchProvidedType<Proto, K, ValueType>;
<C extends Interface<ReactiveElement>, V extends ValueType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
<K extends PropertyKey, Proto extends Interface<Omit<ReactiveElement, 'renderRoot'>>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchProvidedType<Proto, K, ValueType>;
<C extends Interface<Omit<ReactiveElement, 'renderRoot'>>, V extends ValueType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
};

@@ -50,0 +50,0 @@ type DecoratorReturn = void | any;

@@ -9,24 +9,17 @@ /**

/**
* A property decorator that adds a ContextConsumer controller to the component
* which will try and retrieve a value for the property via the Context API.
* A property decorator that adds a ContextProvider controller to the component
* making it respond to any `context-request` events from its children consumer.
*
* @param context A Context identifier value created via `createContext`
* @param multiple An optional boolean which when true allows the value to be updated
* multiple times.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* @example
*
* ```ts
* import {consume} from '@lit/context';
* import {loggerContext} from 'community-protocols/logger';
* import {provide} from '@lit/context';
* import {Logger} from 'my-logging-library';
* import {loggerContext} from './logger-context.js';
*
* class MyElement {
* @provide({context: loggerContext})
* logger;
*
* doThing() {
* this.logger.log('thing was done');
* }
* logger = new Logger();
* }

@@ -48,4 +41,4 @@ * ```

type ProvideDecorator<ContextType> = {
<K extends PropertyKey, Proto extends Interface<ReactiveElement>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchContextType<Proto, K, ContextType>;
<C extends Interface<ReactiveElement>, V extends ContextType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
<K extends PropertyKey, Proto extends Interface<Omit<ReactiveElement, 'renderRoot'>>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchContextType<Proto, K, ContextType>;
<C extends Interface<Omit<ReactiveElement, 'renderRoot'>>, V extends ContextType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
};

@@ -52,0 +45,0 @@ type DecoratorReturn = void | any;

{
"name": "@lit/context",
"version": "1.0.0",
"version": "1.0.1",
"description": "Helpers and controllers for using Context protocol",

@@ -38,2 +38,4 @@ "license": "BSD-3-Clause",

"build:ts:std-decorators-tests": "wireit",
"build:ts:lit2-tests": "wireit",
"build:ts:lit2": "wireit",
"build:ts:types": "wireit",

@@ -52,2 +54,3 @@ "build:rollup": "wireit",

"build:ts:std-decorators-tests",
"build:ts:lit2-tests",
"build:ts:types",

@@ -93,2 +96,47 @@ "../lit:build",

},
"build:ts:lit2-tests": {
"#comment": "Run this to install and build additional cross-version type tests.",
"command": "tsc --pretty --project tsconfig.lit2-tests.json",
"clean": "if-file-deleted",
"dependencies": [
"build:ts:lit2",
"install:lit2"
],
"files": [
"src/test/**/*.ts",
"!src/test/std-decorators/**/*.ts",
"tsconfig.lit2-tests.json"
],
"output": [
"lit2/context/test",
"tsconfig.lit2-tests.tsbuildinfo"
]
},
"install:lit2": {
"command": "cd lit2/lit2-scope && npm ci",
"clean": "if-file-deleted",
"dependencies": [],
"files": [
"lit2/lit2-scope/package.json",
"lit2/lit2-scope/package-lock.json"
],
"output": []
},
"build:ts:lit2": {
"#comment": "This is a separate script from build:ts because it needs a tsconfig that maps in lit@2.",
"command": "tsc --pretty --project tsconfig.lit2.json",
"clean": "if-file-deleted",
"dependencies": [
"build:ts"
],
"files": [
"src/**/*.ts",
"!src/test/**/*.ts",
"tsconfig.lit2.json"
],
"output": [
"lit2/lit2-scope/context",
"lit2/lit2-scope/tsconfig.lit2.tsbuildinfo"
]
},
"build:ts:types": {

@@ -141,3 +189,2 @@ "command": "treemirror development . \"**/*.d.ts{,.map}\" \"!test\"",

"build:ts",
"build:ts:std-decorators-tests",
"../tests:build"

@@ -157,3 +204,2 @@ ],

"build",
"build:ts:std-decorators-tests",
"../tests:build"

@@ -172,10 +218,10 @@ ],

"dependencies": {
"@lit/reactive-element": "^1.6.2 || ^2.0.0",
"lit": "^2.7.5 || ^3.0.0"
"@lit/reactive-element": "^1.6.2 || ^2.0.0"
},
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@lit-internal/scripts": "^1.0.1-pre.0",
"@lit-labs/testing": "^0.2.2-pre.0",
"@types/trusted-types": "^2.0.2"
"@lit-internal/scripts": "^1.0.1",
"@lit-labs/testing": "^0.2.2",
"@types/trusted-types": "^2.0.2",
"lit": "^3.0.0"
},

@@ -182,0 +228,0 @@ "publishConfig": {

@@ -11,4 +11,7 @@ /**

} from '../context-request-event.js';
import {Context, ContextType} from '../create-context.js';
import {ReactiveController, ReactiveElement} from 'lit';
import type {Context, ContextType} from '../create-context.js';
import type {
ReactiveController,
ReactiveControllerHost,
} from '@lit/reactive-element';

@@ -35,3 +38,3 @@ export interface Options<C extends Context<unknown, unknown>> {

C extends Context<unknown, unknown>,
HostElement extends ReactiveElement
HostElement extends ReactiveControllerHost & HTMLElement
> implements ReactiveController

@@ -38,0 +41,0 @@ {

@@ -8,5 +8,8 @@ /**

import {ContextRequestEvent} from '../context-request-event.js';
import {Context, ContextType} from '../create-context.js';
import {ValueNotifier} from '../value-notifier.js';
import {ReactiveController, ReactiveElement} from 'lit';
import type {Context, ContextType} from '../create-context.js';
import type {
ReactiveController,
ReactiveControllerHost,
} from '@lit/reactive-element';

@@ -43,2 +46,4 @@ declare global {

type ReactiveElementHost = ReactiveControllerHost & HTMLElement;
/**

@@ -52,14 +57,17 @@ * A ReactiveController which adds context provider behavior to a

*/
export class ContextProvider<T extends Context<unknown, unknown>>
export class ContextProvider<
T extends Context<unknown, unknown>,
HostElement extends ReactiveElementHost = ReactiveElementHost
>
extends ValueNotifier<ContextType<T>>
implements ReactiveController
{
protected readonly host: ReactiveElement;
protected readonly host: HostElement;
private readonly context: T;
constructor(host: ReactiveElement, options: Options<T>);
constructor(host: HostElement, options: Options<T>);
/** @deprecated Use new ContextProvider(host, options) */
constructor(host: ReactiveElement, context: T, initialValue?: ContextType<T>);
constructor(host: HostElement, context: T, initialValue?: ContextType<T>);
constructor(
host: ReactiveElement,
host: HostElement,
contextOrOptions: T | Options<T>,

@@ -66,0 +74,0 @@ initialValue?: ContextType<T>

@@ -95,3 +95,6 @@ /**

// legacy
<K extends PropertyKey, Proto extends Interface<ReactiveElement>>(
<
K extends PropertyKey,
Proto extends Interface<Omit<ReactiveElement, 'renderRoot'>>
>(
protoOrDescriptor: Proto,

@@ -102,3 +105,6 @@ name?: K

// standard
<C extends Interface<ReactiveElement>, V extends ValueType>(
<
C extends Interface<Omit<ReactiveElement, 'renderRoot'>>,
V extends ValueType
>(
value: ClassAccessorDecoratorTarget<C, V>,

@@ -105,0 +111,0 @@ context: ClassAccessorDecoratorContext<C, V>

@@ -19,24 +19,17 @@ /**

/**
* A property decorator that adds a ContextConsumer controller to the component
* which will try and retrieve a value for the property via the Context API.
* A property decorator that adds a ContextProvider controller to the component
* making it respond to any `context-request` events from its children consumer.
*
* @param context A Context identifier value created via `createContext`
* @param multiple An optional boolean which when true allows the value to be updated
* multiple times.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
*
* @example
*
* ```ts
* import {consume} from '@lit/context';
* import {loggerContext} from 'community-protocols/logger';
* import {provide} from '@lit/context';
* import {Logger} from 'my-logging-library';
* import {loggerContext} from './logger-context.js';
*
* class MyElement {
* @provide({context: loggerContext})
* logger;
*
* doThing() {
* this.logger.log('thing was done');
* }
* logger = new Logger();
* }

@@ -130,3 +123,6 @@ * ```

// legacy
<K extends PropertyKey, Proto extends Interface<ReactiveElement>>(
<
K extends PropertyKey,
Proto extends Interface<Omit<ReactiveElement, 'renderRoot'>>
>(
protoOrDescriptor: Proto,

@@ -137,3 +133,6 @@ name?: K

// standard
<C extends Interface<ReactiveElement>, V extends ContextType>(
<
C extends Interface<Omit<ReactiveElement, 'renderRoot'>>,
V extends ContextType
>(
value: ClassAccessorDecoratorTarget<C, V>,

@@ -140,0 +139,0 @@ context: ClassAccessorDecoratorContext<C, V>

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

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