Comparing version 0.0.8-alpha1 to 0.0.8-alpha2
@@ -159,2 +159,5 @@ var __defProp = Object.defineProperty; | ||
get(_target, key) { | ||
if (key === "$$typeof") { | ||
return void 0; | ||
} | ||
if (key === "$key") { | ||
@@ -182,29 +185,16 @@ $key != null ? $key : $key = proxyLensKey(); | ||
ownKeys(target) { | ||
return [...Object.keys(cache), "$key", "use", TO_LENS]; | ||
return ["$key", "use", TO_LENS]; | ||
}, | ||
getOwnPropertyDescriptor(target, key) { | ||
if (key === "$key") { | ||
if (key === "$key" || key === "use" || key === TO_LENS) { | ||
return { | ||
configurable: true, | ||
enumerable: true, | ||
value: proxy.$key | ||
value: proxy[key] | ||
}; | ||
} | ||
if (key === "use") { | ||
return { | ||
configurable: true, | ||
enumerable: true, | ||
value: proxy.use | ||
}; | ||
} | ||
if (key === TO_LENS) { | ||
return { | ||
configurable: true, | ||
enumerable: true, | ||
value: proxy[TO_LENS] | ||
}; | ||
} | ||
if (key in cache) { | ||
if (!showCopyLensWarning) { | ||
showCopyLensWarning = true; | ||
debugger; | ||
console.warn(`"%c${String(key)}" as a key on ProxyLens is only available because it has been previously accessed. If you are iterating through keys of this object via \`{ ...obj }\` or \`Object.assign({}, obj)\`, please consider an alternative approach.`, "color: red; font-weight: bold;"); | ||
@@ -211,0 +201,0 @@ } |
@@ -1,2 +0,2 @@ | ||
var W=Object.defineProperty,q=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var R=(c,l,i)=>l in c?W(c,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):c[l]=i,h=(c,l)=>{for(var i in l||(l={}))X.call(l,i)&&R(c,i,l[i]);if(A)for(var i of A(l))Y.call(l,i)&&R(c,i,l[i]);return c},N=(c,l)=>q(c,z(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 w=e=>Object.prototype.toString.call(e)==="[object Object]",j=e=>JSON.parse(JSON.stringify(e)),_=e=>w(e)?h({},e):Array.isArray(e)?[...e]:j(e),$=Object.freeze({get(e){return e},set(e,r){return r}}),O=()=>$,T=(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)=>T(e,n=>n[r],(n,s)=>{const t=_(n);return t[r]=s,t}),F=(e,r)=>n=>{const s=e.get(n),t=r(s);return Object.is(s,t)?n:e.set(n,r(s))},P=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()))}}},d=Symbol(),g=Symbol();let m=!1,I=0;const K=()=>`$$ProxyLens(${I++})`,D=e=>Array.isArray(e)||w(e),J=(e,r)=>{const n=e.createUse(e.lens);return s=>{const[t,o]=n(s);return[L(t,r),o]}},L=(e,r)=>{if(!D(e))return e;if(Reflect.has(e,d))return Reflect.get(e,d);let n;const s=new Proxy(e,{get(t,o){if(o===d)return s;if(o==="toJSON")return n!=null||(n=()=>t),n;if(o==="toLens")return r[g];const a=t[o],u=r[o];return L(a,u)},ownKeys(t){return[...Reflect.ownKeys(t),"toLens","toJSON"]},getOwnPropertyDescriptor(t,o){return o===d?{enumerable:!1,value:s}:{configurable:!0,enumerable:!0,value:s[o]}},set(){throw new Error("Cannot set property on ProxyValue")},deleteProperty(){throw new Error("Cannot delete property on ProxyValue")}});return Object.defineProperty(e,d,{value:s,enumerable:!1}),s},S=e=>{const r={};let n,s,t;const o=new Proxy({},{get(a,u){if(u==="$key")return t!=null||(t=K()),t;if(u===g)return s!=null||(s=()=>o),s;if(u==="use")return n!=null||(n=J(e,o)),n;if(r[u]===void 0){const x=N(h({},e),{lens:V(e.lens,u)}),y=S(x);r[u]=y}return r[u]},ownKeys(a){return[...Object.keys(r),"$key","use",g]},getOwnPropertyDescriptor(a,u){if(u==="$key")return{configurable:!0,enumerable:!0,value:o.$key};if(u==="use")return{configurable:!0,enumerable:!0,value:o.use};if(u===g)return{configurable:!0,enumerable:!0,value:o[g]};if(u in r)return m||(m=!0,console.warn(`"%c${String(u)}" as a key on ProxyLens is only available because it has been previously accessed. If you are iterating through keys of this object via \`{ ...obj }\` or \`Object.assign({}, obj)\`, please consider an alternative approach.`,"color: red; font-weight: bold;")),{configurable:!0,enumerable:!0,value:r[u]}},set(){throw new Error("Cannot set property on ProxyLens")},deleteProperty(){throw new Error("Cannot delete property on ProxyLens")}});return o},v=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 v(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 x=o[u],y=a[u];for(const p in e)if(v(e[p])(x[p],y[p]))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,p=r.get(e.getSnapshot());return Object.is(y,p)?y:y===b||(o.current===b&&(o.current=v(n)),o.current(y,p))?p:y},u=f.default.useSyncExternalStore(e.subscribe,a,a),x=f.default.useCallback(y=>e.update(F(r,y)),[e]);return s.current=u,[u,x]},E=Symbol(),G=()=>{const e=f.default.createContext(E);e.displayName="Lens(ExternalStoreContext)";const r=t=>o=>{const a=f.default.useContext(e);if(a===E)throw new Error("Cannot call `lens.use()` in a component outside of <LensProvider />");return C(a,t,o)},n=S({lens:O(),createUse:r}),s=t=>{const o=f.default.useRef();o.current||(o.current=P(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]},H=e=>{const r=P(e);return[S({lens:O(),createUse:t=>o=>C(r,t,o)}),{get current(){return r.getSnapshot()},set current(t){r.update(()=>t)}}]};c.stateful=H,c.stateless=G,Object.defineProperty(c,"__esModule",{value:!0}),c[Symbol.toStringTag]="Module"}); | ||
var W=Object.defineProperty,q=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var R=(a,l,i)=>l in a?W(a,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[l]=i,h=(a,l)=>{for(var i in l||(l={}))X.call(l,i)&&R(a,i,l[i]);if(A)for(var i of A(l))Y.call(l,i)&&R(a,i,l[i]);return a},N=(a,l)=>q(a,z(l));(function(a,l){typeof exports=="object"&&typeof module!="undefined"?l(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],l):(a=typeof globalThis!="undefined"?globalThis:a||self,l(a.Concave={},a.React))})(this,function(a,l){"use strict";function i(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var f=i(l);const w=e=>Object.prototype.toString.call(e)==="[object Object]",$=e=>JSON.parse(JSON.stringify(e)),j=e=>w(e)?h({},e):Array.isArray(e)?[...e]:$(e),_=Object.freeze({get(e){return e},set(e,n){return n}}),P=()=>_,T=(e,n,r)=>({get(o){const t=e.get(o);return n(t)},set(o,t){const s=e.get(o);return e.set(o,r(s,t))}}),V=(e,n)=>T(e,r=>r[n],(r,o)=>{const t=j(r);return t[n]=o,t}),F=(e,n)=>r=>{const o=e.get(r),t=n(o);return Object.is(o,t)?r:e.set(r,n(o))},O=e=>{const n=new Set;let r=e;return{subscribe(o){return n.add(o),()=>n.delete(o)},getSnapshot(){return r},update(o){const t=o(r);Object.is(t,r)||(r=t,n.forEach(s=>s()))}}},d=Symbol(),x=Symbol();let m=!1,I=0;const K=()=>`$$ProxyLens(${I++})`,D=e=>Array.isArray(e)||w(e),J=(e,n)=>{const r=e.createUse(e.lens);return o=>{const[t,s]=r(o);return[L(t,n),s]}},L=(e,n)=>{if(!D(e))return e;if(Reflect.has(e,d))return Reflect.get(e,d);let r;const o=new Proxy(e,{get(t,s){if(s===d)return o;if(s==="toJSON")return r!=null||(r=()=>t),r;if(s==="toLens")return n[x];const c=t[s],u=n[s];return L(c,u)},ownKeys(t){return[...Reflect.ownKeys(t),"toLens","toJSON"]},getOwnPropertyDescriptor(t,s){return s===d?{enumerable:!1,value:o}:{configurable:!0,enumerable:!0,value:o[s]}},set(){throw new Error("Cannot set property on ProxyValue")},deleteProperty(){throw new Error("Cannot delete property on ProxyValue")}});return Object.defineProperty(e,d,{value:o,enumerable:!1}),o},S=e=>{const n={};let r,o,t;const s=new Proxy({},{get(c,u){if(u!=="$$typeof"){if(u==="$key")return t!=null||(t=K()),t;if(u===x)return o!=null||(o=()=>s),o;if(u==="use")return r!=null||(r=J(e,s)),r;if(n[u]===void 0){const b=N(h({},e),{lens:V(e.lens,u)}),y=S(b);n[u]=y}return n[u]}},ownKeys(c){return["$key","use",x]},getOwnPropertyDescriptor(c,u){if(u==="$key"||u==="use"||u===x)return{configurable:!0,enumerable:!0,value:s[u]};if(u in n){if(!m){m=!0;debugger;console.warn(`"%c${String(u)}" as a key on ProxyLens is only available because it has been previously accessed. If you are iterating through keys of this object via \`{ ...obj }\` or \`Object.assign({}, obj)\`, please consider an alternative approach.`,"color: red; font-weight: bold;")}return{configurable:!0,enumerable:!0,value:n[u]}}},set(){throw new Error("Cannot set property on ProxyLens")},deleteProperty(){throw new Error("Cannot delete property on ProxyLens")}});return s},v=e=>{if(typeof e=="boolean")return(n,r)=>e?n!==r:!1;if(typeof e=="function")return e;if(Array.isArray(e)){const n=Object.fromEntries(e.map(r=>[r,!0]));return v(n)}return(n,r)=>{let o=!1,t=!1,s,c;if(Array.isArray(n)?(o=!0,s=n):s=[n],Array.isArray(r)?(t=!0,c=r):c=[r],t!==o||s.length!==c.length)return!0;for(let u=0;u<s.length;u++){const b=s[u],y=c[u];for(const p in e)if(v(e[p])(b[p],y[p]))return!0}return!1}},g=Symbol(),C=(e,n,r=!0)=>{const o=f.default.useRef(g),t=f.default.useRef(r),s=f.default.useRef(g);t.current!==r&&(s.current=g),t.current=r;const c=()=>{const y=o.current,p=n.get(e.getSnapshot());return Object.is(y,p)?y:y===g||(s.current===g&&(s.current=v(r)),s.current(y,p))?p:y},u=f.default.useSyncExternalStore(e.subscribe,c,c),b=f.default.useCallback(y=>e.update(F(n,y)),[e]);return o.current=u,[u,b]},E=Symbol(),G=()=>{const e=f.default.createContext(E);e.displayName="Lens(ExternalStoreContext)";const n=t=>s=>{const c=f.default.useContext(e);if(c===E)throw new Error("Cannot call `lens.use()` in a component outside of <LensProvider />");return C(c,t,s)},r=S({lens:P(),createUse:n}),o=t=>{const s=f.default.useRef();s.current||(s.current=O(t.value));const c=s.current;return f.default.useEffect(()=>{c.getSnapshot()!==t.value&&c.update(()=>t.value)},[t.value]),f.default.useEffect(()=>c.subscribe(()=>t.onChange(c.getSnapshot())),[t.onChange]),f.default.createElement(e.Provider,{value:c},t.children)};return o.displayName="Lens(Provider)",[r,o]},H=e=>{const n=O(e);return[S({lens:P(),createUse:t=>s=>C(n,t,s)}),{get current(){return n.getSnapshot()},set current(t){n.update(()=>t)}}]};a.stateful=H,a.stateless=G,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module"}); | ||
//# sourceMappingURL=concave.umd.js.map |
{ | ||
"name": "concave", | ||
"version": "0.0.8-alpha1", | ||
"version": "0.0.8-alpha2", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32370
475