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

concave

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concave - npm Package Compare versions

Comparing version 0.0.9-alpha2 to 0.0.9-alpha3

21

dist/concave.es.js

@@ -319,8 +319,10 @@ var __defProp = Object.defineProperty;

ExternalStoreContext.displayName = "Lens(ExternalStoreContext)";
const createUse2 = (lens2) => (shouldUpdate) => {
const store = React.useContext(ExternalStoreContext);
if (store === NOTHING) {
throw new Error("Cannot call `lens.use()` in a component outside of <LensProvider />");
}
return useSyncExternalStoreWithLens(store, lens2, shouldUpdate);
const createUse2 = (lens2) => {
return function useLens(shouldUpdate) {
const store = React.useContext(ExternalStoreContext);
if (store === NOTHING) {
throw new Error("Cannot call `lens.use()` in a component outside of <LensProvider />");
}
return useSyncExternalStoreWithLens(store, lens2, shouldUpdate);
};
};

@@ -353,5 +355,10 @@ const lens = proxyLens({

const store = externalStore(initialState);
const createUse2 = (lens2) => {
return function useLens(shouldUpdate) {
return useSyncExternalStoreWithLens(store, lens2, shouldUpdate);
};
};
const lens = proxyLens({
lens: basicLens(),
createUse: (lens2) => (shouldUpdate) => useSyncExternalStoreWithLens(store, lens2, shouldUpdate),
createUse: createUse2,
meta: { keyPath: [] }

@@ -358,0 +365,0 @@ });

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

var M=Object.defineProperty,W=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var A=(c,l,i)=>l in c?M(c,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[l]=i,h=(c,l)=>{for(var i in l||(l={}))q.call(l,i)&&A(c,i,l[i]);if(L)for(var i of L(l))z.call(l,i)&&A(c,i,l[i]);return c},S=(c,l)=>W(c,Y(l));(function(c,l){typeof exports=="object"&&typeof module!="undefined"?l(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],l):(c=typeof globalThis!="undefined"?globalThis:c||self,l(c.Concave={},c.React))})(this,function(c,l){"use strict";function i(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var f=i(l);const P=e=>Object.prototype.toString.call(e)==="[object Object]",_=e=>JSON.parse(JSON.stringify(e)),N=e=>P(e)?h({},e):Array.isArray(e)?[...e]:_(e),T=Object.freeze({get(e){return e},set(e,r){return r}}),m=()=>T,D=(e,r,n)=>({get(s){const t=e.get(s);return r(t)},set(s,t){const o=e.get(s);return e.set(s,n(o,t))}}),V=(e,r)=>D(e,n=>n[r],(n,s)=>{const t=N(n);return t[r]=s,t}),j=(e,r)=>n=>{const s=e.get(n),t=r(s);return Object.is(s,t)?n:e.set(n,r(s))},w=e=>{const r=new Set;let n=e;return{subscribe(s){return r.add(s),()=>r.delete(s)},getSnapshot(){return n},update(s){const t=s(n);Object.is(t,n)||(n=t,r.forEach(o=>o()))}}},I={isCalledInsideReactDevtools:()=>{var r;return(r=new Error().stack)==null?void 0:r.includes("react_devtools_backend")}},p=Symbol(),O=Symbol(),$=Symbol(),F=e=>Array.isArray(e)||P(e),H=(e,r)=>{const n=e.createUse(e.lens);return s=>{const[t,o]=n(s);return[E(t,r),o]}},E=(e,r)=>{if(!F(e))return e;if(Reflect.has(e,p))return Reflect.get(e,p);let n;const s=new Proxy(e,{get(t,o){if(o===p)return s;if(o==="toJSON")return n!=null||(n=()=>t),n;if(o==="toLens")return r[O];const a=t[o],u=r[o];return E(a,u)},ownKeys(t){return[...Reflect.ownKeys(t),"toLens","toJSON"]},getOwnPropertyDescriptor(t,o){return o===p?{enumerable:!1,value:s}:{configurable:!0,enumerable:!0,value:s[o]}},preventExtensions(){return!0},isExtensible(){return!1},set(){throw new Error("Cannot set property on ProxyValue")},deleteProperty(){throw new Error("Cannot delete property on ProxyValue")}});return Object.defineProperty(e,p,{value:s,enumerable:!1}),s},v=e=>{const r={};let n,s,t;const o=new Proxy({},{get(a,u){if(u!=="$$typeof"){if(u==="$key")return t!=null||(t=`Lens(${e.meta.keyPath.join(".")})`),t;if(u===O)return s!=null||(s=()=>o),s;if(u==="use")return n!=null||(n=H(e,o)),n;if(r[u]===void 0){const g=S(h({},e),{meta:S(h({},e.meta),{keyPath:[...e.meta.keyPath,u]}),lens:V(e.lens,u)}),y=v(g);r[u]=y}return r[u]}},ownKeys(a){return["$key","use",$]},getOwnPropertyDescriptor(a,u){if(u==="$key"||u==="use")return{configurable:!0,enumerable:!0,value:o[u]};if(I.isCalledInsideReactDevtools())return{configurable:!0,enumerable:!1,value:void 0};throw new Error("ProxyLens threw because you tried to access all property descriptors\u2014probably through `{ ...lens }` or `Object.assign({}, lens)`. Doing this will break the type safety offered by this library so it is forbidden. Sorry, buddy pal.")},getPrototypeOf(){return null},preventExtensions(){return!0},isExtensible(){return!1},set(){throw new Error("Cannot set property on ProxyLens")},deleteProperty(){throw new Error("Cannot delete property on ProxyLens")}});return o},x=e=>{if(typeof e=="boolean")return(r,n)=>e?r!==n:!1;if(typeof e=="function")return e;if(Array.isArray(e)){const r=Object.fromEntries(e.map(n=>[n,!0]));return x(r)}return(r,n)=>{let s=!1,t=!1,o,a;if(Array.isArray(r)?(s=!0,o=r):o=[r],Array.isArray(n)?(t=!0,a=n):a=[n],t!==s||o.length!==a.length)return!0;for(let u=0;u<o.length;u++){const g=o[u],y=a[u];for(const d in e)if(x(e[d])(g[d],y[d]))return!0}return!1}},b=Symbol(),C=(e,r,n=!0)=>{const s=f.default.useRef(b),t=f.default.useRef(n),o=f.default.useRef(b);t.current!==n&&(o.current=b),t.current=n;const a=()=>{const y=s.current,d=r.get(e.getSnapshot());return Object.is(y,d)?y:y===b||(o.current===b&&(o.current=x(n)),o.current(y,d))?d:y},u=f.default.useSyncExternalStore(e.subscribe,a,a),g=f.default.useCallback(y=>e.update(j(r,y)),[e]);return s.current=u,[u,g]},R=Symbol(),J=()=>{const e=f.default.createContext(R);e.displayName="Lens(ExternalStoreContext)";const r=t=>o=>{const a=f.default.useContext(e);if(a===R)throw new Error("Cannot call `lens.use()` in a component outside of <LensProvider />");return C(a,t,o)},n=v({lens:m(),createUse:r,meta:{keyPath:[]}}),s=t=>{const o=f.default.useRef();o.current||(o.current=w(t.value));const a=o.current;return f.default.useEffect(()=>{a.getSnapshot()!==t.value&&a.update(()=>t.value)},[t.value]),f.default.useEffect(()=>a.subscribe(()=>t.onChange(a.getSnapshot())),[t.onChange]),f.default.createElement(e.Provider,{value:a},t.children)};return s.displayName="Lens(Provider)",[n,s]},K=e=>{const r=w(e);return[v({lens:m(),createUse:t=>o=>C(r,t,o),meta:{keyPath:[]}}),{get current(){return r.getSnapshot()},set current(t){r.update(()=>t)}}]};c.stateful=K,c.stateless=J,Object.defineProperty(c,"__esModule",{value:!0}),c[Symbol.toStringTag]="Module"});
var M=Object.defineProperty,W=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var A=(c,l,i)=>l in c?M(c,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[l]=i,h=(c,l)=>{for(var i in l||(l={}))q.call(l,i)&&A(c,i,l[i]);if(R)for(var i of R(l))z.call(l,i)&&A(c,i,l[i]);return c},S=(c,l)=>W(c,Y(l));(function(c,l){typeof exports=="object"&&typeof module!="undefined"?l(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],l):(c=typeof globalThis!="undefined"?globalThis:c||self,l(c.Concave={},c.React))})(this,function(c,l){"use strict";function i(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var f=i(l);const P=e=>Object.prototype.toString.call(e)==="[object Object]",_=e=>JSON.parse(JSON.stringify(e)),N=e=>P(e)?h({},e):Array.isArray(e)?[...e]:_(e),T=Object.freeze({get(e){return e},set(e,r){return r}}),m=()=>T,D=(e,r,t)=>({get(o){const n=e.get(o);return r(n)},set(o,n){const s=e.get(o);return e.set(o,t(s,n))}}),V=(e,r)=>D(e,t=>t[r],(t,o)=>{const n=N(t);return n[r]=o,n}),j=(e,r)=>t=>{const o=e.get(t),n=r(o);return Object.is(o,n)?t:e.set(t,r(o))},w=e=>{const r=new Set;let t=e;return{subscribe(o){return r.add(o),()=>r.delete(o)},getSnapshot(){return t},update(o){const n=o(t);Object.is(n,t)||(t=n,r.forEach(s=>s()))}}},I={isCalledInsideReactDevtools:()=>{var r;return(r=new Error().stack)==null?void 0:r.includes("react_devtools_backend")}},p=Symbol(),O=Symbol(),$=Symbol(),F=e=>Array.isArray(e)||P(e),H=(e,r)=>{const t=e.createUse(e.lens);return o=>{const[n,s]=t(o);return[E(n,r),s]}},E=(e,r)=>{if(!F(e))return e;if(Reflect.has(e,p))return Reflect.get(e,p);let t;const o=new Proxy(e,{get(n,s){if(s===p)return o;if(s==="toJSON")return t!=null||(t=()=>n),t;if(s==="toLens")return r[O];const a=n[s],u=r[s];return E(a,u)},ownKeys(n){return[...Reflect.ownKeys(n),"toLens","toJSON"]},getOwnPropertyDescriptor(n,s){return s===p?{enumerable:!1,value:o}:{configurable:!0,enumerable:!0,value:o[s]}},preventExtensions(){return!0},isExtensible(){return!1},set(){throw new Error("Cannot set property on ProxyValue")},deleteProperty(){throw new Error("Cannot delete property on ProxyValue")}});return Object.defineProperty(e,p,{value:o,enumerable:!1}),o},v=e=>{const r={};let t,o,n;const s=new Proxy({},{get(a,u){if(u!=="$$typeof"){if(u==="$key")return n!=null||(n=`Lens(${e.meta.keyPath.join(".")})`),n;if(u===O)return o!=null||(o=()=>s),o;if(u==="use")return t!=null||(t=H(e,s)),t;if(r[u]===void 0){const g=S(h({},e),{meta:S(h({},e.meta),{keyPath:[...e.meta.keyPath,u]}),lens:V(e.lens,u)}),y=v(g);r[u]=y}return r[u]}},ownKeys(a){return["$key","use",$]},getOwnPropertyDescriptor(a,u){if(u==="$key"||u==="use")return{configurable:!0,enumerable:!0,value:s[u]};if(I.isCalledInsideReactDevtools())return{configurable:!0,enumerable:!1,value:void 0};throw new Error("ProxyLens threw because you tried to access all property descriptors\u2014probably through `{ ...lens }` or `Object.assign({}, lens)`. Doing this will break the type safety offered by this library so it is forbidden. Sorry, buddy pal.")},getPrototypeOf(){return null},preventExtensions(){return!0},isExtensible(){return!1},set(){throw new Error("Cannot set property on ProxyLens")},deleteProperty(){throw new Error("Cannot delete property on ProxyLens")}});return s},x=e=>{if(typeof e=="boolean")return(r,t)=>e?r!==t:!1;if(typeof e=="function")return e;if(Array.isArray(e)){const r=Object.fromEntries(e.map(t=>[t,!0]));return x(r)}return(r,t)=>{let o=!1,n=!1,s,a;if(Array.isArray(r)?(o=!0,s=r):s=[r],Array.isArray(t)?(n=!0,a=t):a=[t],n!==o||s.length!==a.length)return!0;for(let u=0;u<s.length;u++){const g=s[u],y=a[u];for(const d in e)if(x(e[d])(g[d],y[d]))return!0}return!1}},b=Symbol(),C=(e,r,t=!0)=>{const o=f.default.useRef(b),n=f.default.useRef(t),s=f.default.useRef(b);n.current!==t&&(s.current=b),n.current=t;const a=()=>{const y=o.current,d=r.get(e.getSnapshot());return Object.is(y,d)?y:y===b||(s.current===b&&(s.current=x(t)),s.current(y,d))?d:y},u=f.default.useSyncExternalStore(e.subscribe,a,a),g=f.default.useCallback(y=>e.update(j(r,y)),[e]);return o.current=u,[u,g]},L=Symbol(),J=()=>{const e=f.default.createContext(L);e.displayName="Lens(ExternalStoreContext)";const r=n=>function(a){const u=f.default.useContext(e);if(u===L)throw new Error("Cannot call `lens.use()` in a component outside of <LensProvider />");return C(u,n,a)},t=v({lens:m(),createUse:r,meta:{keyPath:[]}}),o=n=>{const s=f.default.useRef();s.current||(s.current=w(n.value));const a=s.current;return f.default.useEffect(()=>{a.getSnapshot()!==n.value&&a.update(()=>n.value)},[n.value]),f.default.useEffect(()=>a.subscribe(()=>n.onChange(a.getSnapshot())),[n.onChange]),f.default.createElement(e.Provider,{value:a},n.children)};return o.displayName="Lens(Provider)",[t,o]},K=e=>{const r=w(e),t=s=>function(u){return C(r,s,u)};return[v({lens:m(),createUse:t,meta:{keyPath:[]}}),{get current(){return r.getSnapshot()},set current(s){r.update(()=>s)}}]};c.stateful=K,c.stateless=J,Object.defineProperty(c,"__esModule",{value:!0}),c[Symbol.toStringTag]="Module"});
//# sourceMappingURL=concave.umd.js.map
{
"name": "concave",
"version": "0.0.9-alpha2",
"version": "0.0.9-alpha3",
"description": "A Lens-like interface for state management in React",

@@ -5,0 +5,0 @@ "main": "dist/concave.umd.js",

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