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

wc-context

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wc-context - npm Package Compare versions

Comparing version 0.14.0 to 0.14.1

36

core.js

@@ -70,2 +70,10 @@ const noContext = Symbol('noContext')

/**
* @typedef Context
*/
/**
* @param {string} key Identify the context
* @return {Context}
*/
function createContext(key) {

@@ -80,2 +88,9 @@ return {

/**
* @param {HTMLElement} provider HTMLElement acting as a context provider
* @param {Object} options
* @param {Function} options.getter
* @param {*} options.payload
* @return {*}
*/
function getProviderValue(provider, { getter, payload }) {

@@ -85,2 +100,7 @@ return getter(provider, payload)

/**
* @param {HTMLElement} provider HTMLElement acting as a context provider
* @param {*} payload Options passed to the callback
* @return {*}
*/
function providerGetter(provider, payload) {

@@ -90,2 +110,10 @@ return payload

/**
*
*
* @param {HTMLElement} provider HTMLElement acting as a context provider
* @param {string | Context} context Context identifier
* @param {*} payload Value passed to getter
* @param {Function} [getter=providerGetter]
*/
function registerContext(provider, context, payload, getter = providerGetter) {

@@ -193,2 +221,10 @@ const observerMap =

/**
*
*
* @param {HTMLElement} consumer HTMLElement that consumes a context
* @param {string | Context} context Context identifier
* @param {*} [payload=context] Value passed to setter
* @param {Function} [setter=consumerSetter]
*/
function observeContext(

@@ -195,0 +231,0 @@ consumer,

30

lit.js

@@ -16,3 +16,3 @@ import { noChange } from 'lit'

const withContext = (Base) => {
function createClass(Base) {
return class extends Base {

@@ -101,2 +101,30 @@ static getPropertyDescriptor(name, key, options) {

/**
* @typedef {import('@lit/reactive-element/decorators/base.js').ClassDescriptor} ClassDescriptor
*/
/**
* @template ElementClass
* @param {ElementClass | ClassDescriptor} classOrDescriptor - Base element class or decorator descriptor
* @returns {ElementClass}
*/
function withContext(classOrDescriptor) {
// current state of decorators sucks. Lets abuse of duck typing
if (typeof classOrDescriptor === 'function') {
// constructor -> typescript decorator
return createClass(classOrDescriptor)
}
if (classOrDescriptor.kind === 'class') {
// descriptor -> spec decorator
const { kind, elements } = classOrDescriptor
return {
kind,
elements,
finisher(ctor) {
return createClass(ctor)
},
}
}
}
class ContextProviderDirective extends Directive {

@@ -103,0 +131,0 @@ context

13

package.json
{
"name": "wc-context",
"version": "0.14.0",
"version": "0.14.1",
"description": "Context for HTML custom elements / web components",

@@ -26,3 +26,4 @@ "repository": "blikblum/wc-context",

"controllers.js",
"mixin.js"
"mixin.js",
"types"
],

@@ -37,2 +38,6 @@ "jest": {

"devDependencies": {
"@types/istanbul-lib-report": "^3.0.0",
"@types/istanbul-reports": "^3.0.1",
"@types/jsdom": "^21.1.1",
"@types/node": "^20.2.5",
"@web/dev-server": "^0.1.35",

@@ -45,2 +50,3 @@ "eslint": "^8.32.0",

"prettier": "^2.5.1",
"typescript": "^5.1.3",
"vitepress": "^1.0.0-alpha.46",

@@ -66,4 +72,5 @@ "vue": "^3.2.47"

"start:watch": "web-dev-server --open examples/ --node-resolve --watch",
"test": "yarn node --experimental-vm-modules $(yarn bin jest)"
"test": "yarn node --experimental-vm-modules $(yarn bin jest)",
"types": "tsc"
}
}
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