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

@urql/exchange-graphcache

Package Overview
Dependencies
Maintainers
19
Versions
298
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/exchange-graphcache - npm Package Compare versions

Comparing version 6.4.1 to 6.4.2-canary-969935c6

2

dist/urql-exchange-graphcache.min.js

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

Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@urql/core"),r=require("@0no-co/graphql.web"),t=require("wonka"),i="\nhttps://bit.ly/2XbVrpR#";function a(e,r,t){if(!e){var a=new Error((r||"Minfied Error #"+t+"\n")+i+t);throw a.name="Graphcache Error",a}}new Set;var n={},o=e=>e._directives||n,s=e=>e.name.value,l=e=>e.typeCondition.name.value,d=e=>e.alias?e.alias.value:e.name.value,u=[],p=e=>e.selectionSet?e.selectionSet.selections:u,v=e=>e.typeCondition?e.typeCondition.name.value:null,f=(e,t)=>{var i=null;if(e.arguments)for(var a=0,n=e.arguments.length;a<n;a++){var o=e.arguments[a],l=r.valueFromASTUntyped(o.value,t);null!=l&&(i||(i={}),i[s(o)]=l)}return i},y=(e,r)=>{if(r&&e.variableDefinitions){for(var t={},i=0,a=e.variableDefinitions.length;i<a;i++){var n=s(e.variableDefinitions[i].variable);t[n]=r[n]}return t}},c=(e,t)=>{var i={};if(!t)return i;if(e.variableDefinitions)for(var a=0,n=e.variableDefinitions.length;a<n;a++){var o=e.variableDefinitions[a],l=s(o.variable);i[l]=void 0===t[l]&&o.defaultValue?r.valueFromASTUntyped(o.defaultValue,t):t[l]}for(var d in t)d in i||(i[d]=t[d]);return i};function m(e){for(var t=0;t<e.definitions.length;t++)if(e.definitions[t].kind===r.Kind.OPERATION_DEFINITION)return e.definitions[t];a(!1,"",1)}var h=e=>{for(var t={},i=0;i<e.definitions.length;i++){var a=e.definitions[i];a.kind===r.Kind.FRAGMENT_DEFINITION&&(t[s(a)]=a)}return t},g=(e,t)=>{var i=o(e);if(i.include||i.skip)for(var a in i){var n=i[a];if(n&&("include"===a||"skip"===a)&&n.arguments&&n.arguments[0]&&"if"===s(n.arguments[0])){var l=r.valueFromASTUntyped(n.arguments[0].value,t);return"include"===a?!!l:!l}}return!0},k=(e,t)=>{var{defer:i}=o(e);if(i){for(var a of i.arguments||[])if("if"===s(a))return!!r.valueFromASTUntyped(a.value,t);return!0}return!1},_=(e,r,t,i)=>{var a=b(e,r,t,i);return!!a&&"NON_NULL"!==a.type.kind},O=(e,r,t,i)=>{var a=b(e,r,t,i);if(!a)return!1;var n="NON_NULL"===a.type.kind?a.type.ofType:a.type;return"LIST"===n.kind&&"NON_NULL"!==n.ofType.kind},w=(e,r,t)=>{if(!t)return!1;var i=v(r);return!i||t===i||(e.types.has(i)&&"OBJECT"===e.types.get(i).kind?i===t:(function(e,r){a(e.types.has(r)&&("INTERFACE"===e.types.get(r).kind||"UNION"===e.types.get(r).kind),"",5)}(e,i),N(e,t),e.isSubType(i,t)))},b=(e,r,t,i)=>{if(0!==t.indexOf("__")&&0!==r.indexOf("__"))return N(e,r),e.types.get(r).fields()[t]};function N(e,r){a(e.types.has(r)&&"OBJECT"===e.types.get(r).kind,"",3)}var q=(r,t)=>t?`${r}(${e.stringifyVariables(t)})`:r,x=(e,r)=>`${e}.${r}`,K=e=>{var r=e.indexOf("(");return r>-1?{fieldKey:e,fieldName:e.slice(0,r),arguments:JSON.parse(e.slice(r+1,-1))}:{fieldKey:e,fieldName:e,arguments:null}},S=e=>{var r=e.indexOf(".");return{entityKey:e.slice(0,r).replace(/%2e/g,"."),fieldKey:e.slice(r+1)}},E=null,A=null,M=null,T=null,D=null,F=null,I=!1,C=!1;function L(e,r){var t;if(e){if(E.has(e))return e;t=A.get(e)}return null==t&&(t=r?[]:{}),e&&A.set(e,t),E.add(t),t}var $=e=>!!e&&E.has(e),R=(e,r,t,i,a)=>{E=new WeakSet,A=new WeakMap,D=e,M=r,F=new Set,C=!!i,I=!!a,t?"read"===D?T=t:i||r.hydrating||r.optimisticOrder.length>1?(i||r.commutativeKeys.has(t)?i&&(-1===r.optimisticOrder.indexOf(t)||r.commutativeKeys.has(t)||r.optimisticOrder.splice(r.optimisticOrder.indexOf(t),1),r.commutativeKeys.delete(t)):ee(r,t),T=t,re(r,t)):(T=null,ie(r,t)):T=null},P=()=>{var e=M,r=T;if(C=!1,T=null,!e.hydrating&&r&&e.optimisticOrder.indexOf(r)>-1)for(var t=e.optimisticOrder.length;--t>=0&&e.dirtyKeys.has(e.optimisticOrder[t])&&e.commutativeKeys.has(e.optimisticOrder[t]);)ae(e.optimisticOrder[t]);E=null,A=null,D=null,M=null,F=null,e.defer||!e.storage&&e.optimisticOrder.length||(e.defer=!0,setTimeout((()=>{R("read",e,null),G(),oe(),P(),e.defer=!1})))},j=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),R("write",e,r,t),P()},U=(e,r,t,i)=>{var a=T?e.optimistic.get(T):e.base,n=a.get(r);void 0===n&&a.set(r,n=Object.create(null)),void 0!==i||T?n[t]=i:delete n[t]},J=(e,r,t)=>{for(var i,a=!C&&"read"===D&&T&&M.commutativeKeys.has(T),n=0,o=M.optimisticOrder.length;n<o;n++){var s=M.optimisticOrder[n],l=e.optimistic.get(s);if(a=a&&s!==T,l&&(!a||!M.commutativeKeys.has(s))&&(!C||"write"===D||M.commutativeKeys.has(s))&&void 0!==(i=l.get(r))&&t in i)return i[t]}return void 0!==(i=e.base.get(r))?i[t]:void 0},Q=(e,r)=>{if(Array.isArray(e))for(var t=0,i=e.length;t<i;t++)Q(e[t],r);else"string"==typeof e&&((e,r)=>{var t=M.refCount.get(e)||0,i=t+r>0?t+r:0;M.refCount.set(e,i),i?!t&&i&&M.gc.delete(e):M.gc.add(e)})(e,r)},B=(e,r,t)=>{if(void 0!==t)for(var i in t)r.has(i)||(e.push(K(i)),r.add(i))},V=(e,r,t,i)=>{B(e,r,i.base.get(t));for(var a=0,n=M.optimisticOrder.length;a<n;a++){var o=i.optimistic.get(M.optimisticOrder[a]);void 0!==o&&B(e,r,o.get(t))}},G=()=>{if(!M.optimisticOrder.length)for(var e of M.gc.keys())if(M.gc.delete(e),!((M.refCount.get(e)||0)>0)){M.refCount.delete(e),M.records.base.delete(e);var r=M.links.base.get(e);if(r)for(var t in M.links.base.delete(e),r)Q(r[t],-1)}},z=(e,r)=>{e!==M.queryRootKey?F.add(e):void 0!==r&&"__typename"!==r&&F.add(x(e,r))},H=(e,r)=>{!C&&M.storage&&M.persist.add(((e,r)=>`${e.replace(/\./g,"%2e")}.${r}`)(e,r))},W=(e,r)=>(z(e,r),J(M.records,e,r)),X=(e,r)=>(z(e,r),J(M.links,e,r)),Y=(e,r,t)=>{z(e,r),H(e,r),U(M.records,e,r,t)},Z=(e,r,t)=>{var i=T?M.links.optimistic.get(T):M.links.base;if(!T){var a=i&&i.get(e);Q(a&&a[r],-1),Q(t,1)}z(e,r),H(e,r),U(M.links,e,r,t)},ee=(e,r,t)=>{var i=e.optimisticOrder.indexOf(r);if(i>-1&&e.optimisticOrder.splice(i,1),t)for(e.deferredKeys.add(r),i=i>-1?i:0;i<e.optimisticOrder.length&&!e.deferredKeys.has(e.optimisticOrder[i])&&(!e.dirtyKeys.has(e.optimisticOrder[i])||!e.commutativeKeys.has(e.optimisticOrder[i]));i++);else e.deferredKeys.delete(r),i>-1&&!e.commutativeKeys.has(r)&&te(e,r),i=0;e.optimisticOrder.splice(i,0,r),e.commutativeKeys.add(r)},re=(e,r)=>{-1===e.optimisticOrder.indexOf(r)&&e.optimisticOrder.unshift(r),e.dirtyKeys.has(r)||(e.dirtyKeys.add(r),e.links.optimistic.set(r,new Map),e.records.optimistic.set(r,new Map))},te=(e,r)=>{e.dirtyKeys.has(r)&&(e.dirtyKeys.delete(r),e.records.optimistic.delete(r),e.links.optimistic.delete(r),e.deferredKeys.delete(r))},ie=(e,r)=>{var t=e.optimisticOrder.indexOf(r);t>-1&&(e.optimisticOrder.splice(t,1),e.commutativeKeys.delete(r)),te(e,r)},ae=e=>{var r=F;F=new Set,D="write";var t=M.links.optimistic.get(e);if(t)for(var i of t.entries()){var a=i[0],n=i[1];for(var o in n)Z(a,o,n[o])}var s=M.records.optimistic.get(e);if(s)for(var l of s.entries()){var d=l[0],u=l[1];for(var p in u)Y(d,p,u[p])}F=r,ie(M,e)},ne=e=>{var{links:r,records:t}=M,i=[],a=new Set;return z(e),V(i,a,e,r),V(i,a,e,t),i},oe=()=>{if(M.storage){C=!0,D="read";var r={};for(var t of M.persist.keys()){var{entityKey:i,fieldKey:a}=S(t),n=void 0;r[t]=void 0!==(n=X(i,a))?`:${e.stringifyVariables(n)}`:void 0!==(n=W(i,a))?e.stringifyVariables(n):void 0}C=!1,M.storage.writeData(r),M.persist.clear()}},se=null,le=!1,de=e=>e.__internal.path.length>0&&e.__internal.errorMap?e.__internal.errorMap[e.__internal.path.join(".")]:void 0,ue=(e,r,t,i,a,n)=>{le=!1;var o={store:e,variables:r,fragments:t,parent:{__typename:i},parentTypeName:i,parentKey:a,parentFieldKey:"",fieldName:"",error:void 0,partial:!1,hasNext:!1,optimistic:C,__internal:{path:[],errorMap:void 0}};if(n&&n.graphQLErrors)for(var s=0;s<n.graphQLErrors.length;s++){var l=n.graphQLErrors[s];l.path&&l.path.length&&(o.__internal.errorMap||(o.__internal.errorMap=Object.create(null)),o.__internal.errorMap[l.path.join(".")]=l)}return o},pe=(e,r,t,i,a,n)=>{se=e,e.parent=r,e.parentTypeName=t,e.parentKey=i,e.parentFieldKey=a,e.fieldName=n,e.error=de(e)},ve=(e,t,i,a,n)=>{if(!t)return!1;var o=v(e);return!o||t===o||"write"===D||!p(e).some((e=>{if(e.kind!==r.Kind.FIELD)return!1;var t=q(s(e),f(e,a));return!((e,r)=>void 0!==W(e,r)||void 0!==X(e,r))(i,t)}))},fe=(e,t,i,a,n)=>{var o,l=0;return function(){for(var d;o||l<a.length;)if(d=void 0,le=i,o){if(d=o())return d;o=void 0}else{var u=a[l++];if(g(u,n.variables))if(u.kind!==r.Kind.FIELD){var v=u.kind!==r.Kind.INLINE_FRAGMENT?n.fragments[s(u)]:u;v&&(!v.typeCondition||(n.store.schema?w(n.store.schema,v,e):ve(v,e,t,n.variables)))&&(o=fe(e,t,i||k(u,n.variables),p(v),n))}else if("write"===D||!u._generated)return u}}},ye=e=>null==e?null:e,ce=(e,r)=>{if(!r)return r||null;if(Array.isArray(r)){for(var t=new Array(r.length),i=0,a=t.length;i<a;i++)t[i]=ce(e,r[i]);return t}return e.keyOfEntity(r)},me=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s=r.rootFields[o.operation],l=p(o),d=ue(r,c(o,t.variables),h(n),s,s,a),u=s!==d.store.rootFields.query?he(d,s,l,i||L()):_e(d,s,l,i||L());return{dependencies:F,partial:d.partial||!u,hasNext:d.hasNext,data:u||null}},he=(e,r,t,i)=>{if("string"!=typeof(e.store.rootNames[r]?r:i.__typename))return i;for(var a,n=fe(r,r,le,t,e),o=I,s=L(i);a=n();){var l,u=d(a),v=i[u];e.__internal.path.push(u),l=a.selectionSet&&null!==v?ge(e,p(a),ye(v)):v,o=o||l!==v,void 0!==l&&(s[u]=l),e.__internal.path.pop()}return o?s:i},ge=(e,r,t)=>{if(Array.isArray(t)){for(var i=new Array(t.length),a=I,n=0,o=t.length;n<o;n++)e.__internal.path.push(n),i[n]=ge(e,r,t[n]),a=a||i[n]!==t[n],e.__internal.path.pop();return a?i:t}if(null===t)return null;var s=e.store.keyOfEntity(t);return null!==s?_e(e,s,r,t)||null:he(e,t.__typename,r,t)};function ke(e,r,t,i){var a=i.store.resolvers[r],n=a&&a[t];for(var o in e){var s=e[o];if(s&&"include"!==o&&"skip"!==o&&i.store.directives[o])return i.store.directives[o](f(s,i.variables))}return n}var _e=(e,r,t,i,a)=>{var{store:n}=e,l=r===n.rootFields.query,u=a&&n.keyOfEntity(a)||r,v=l?r:W(u,"__typename")||a&&a.__typename;if("string"==typeof v&&(!a||v===a.__typename)){for(var y,c=fe(v,u,le,t,e),m=!1,h=!1,g=I,k=e.partial,O=L(i);void 0!==(y=c());){var w=s(y),b=f(y,e.variables),N=d(y),K=o(y),S=ke(K,v,w,e),E=q(w,b),A=x(u,E),M=W(u,E),T=a?a[w]:void 0;e.__internal.path.push(N);var F=void 0;if("__typename"===w)F=v;else if(void 0!==T&&void 0===y.selectionSet)F=T;else if("read"===D&&S){var C=O;if(void 0===y.selectionSet&&void 0!==M&&(C={...O,[N]:M,[w]:M}),pe(e,C,v,u,E,w),F=S(C,b||{},n,e),y.selectionSet&&(F=Oe(e,v,w,A,p(y),void 0!==O[N]?O[N]:i[N],F,$(i))),n.schema&&null===F&&!_(n.schema,v,w,e.store.logger))return}else if(y.selectionSet)if(void 0!==T)F=Oe(e,v,w,A,p(y),void 0!==O[N]?O[N]:i[N],T,$(i));else{var R=X(u,E);void 0!==R?F=we(e,R,v,w,p(y),void 0!==O[N]?O[N]:i[N],$(i)):"object"==typeof M&&null!==M&&(F=M)}else F=M;if(!le&&void 0===F&&(K.optional||de(e)||n.schema&&_(n.schema,v,w,e.store.logger))?(e.partial=!0,F=null):null===F&&K.required?F=void 0:m=m||"__typename"!==w,e.__internal.path.pop(),g=g||F!==i[N],void 0!==F)O[N]=F;else{if(!le)return void(e.partial=k);h=!0}}return e.partial=e.partial||k,e.hasNext=e.hasNext||h,l&&e.partial&&!m?void 0:g?O:i}},Oe=(e,r,t,i,a,n,o,s)=>{if(Array.isArray(o)){for(var{store:l}=e,d=!!l.schema&&O(l.schema,r,t,e.store.logger),u=e.partial,p=L(n,!0),v=I||!Array.isArray(n)||o.length!==n.length,f=0,y=o.length;f<y;f++){e.__internal.path.push(f);var c=Oe(e,r,t,x(i,`${f}`),a,null!=n?n[f]:void 0,o[f],s);if(e.__internal.path.pop(),void 0===c&&!d)return void(e.partial=u);e.partial=e.partial||void 0===c&&d,p[f]=null!=c?c:null,v=v||p[f]!==n[f]}return v?p:n}if(null==o)return o;if(s&&null===n)return null;if(be(o)){var m=n||L(n);return"string"==typeof o?_e(e,o,a,m):_e(e,i,a,m,o)}},we=(e,r,t,i,a,n,o)=>{if(Array.isArray(r)){for(var{store:s}=e,l=!!s.schema&&O(s.schema,t,i,e.store.logger),d=L(n,!0),u=e.partial,p=I||!Array.isArray(n)||r.length!==n.length,v=0,f=r.length;v<f;v++){e.__internal.path.push(v);var y=we(e,r[v],t,i,a,null!=n?n[v]:void 0,o);if(e.__internal.path.pop(),void 0===y&&!l)return void(e.partial=u);e.partial=e.partial||void 0===y&&l,d[v]=y||null,p=p||d[v]!==n[v]}return p?d:n}return null===r||null===n&&o?null:_e(e,r,a,n||L(n))},be=e=>"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename,Ne=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s={data:i||L(),dependencies:F},l=r.rootFields[o.operation],d=ue(r,c(o,t.variables),h(n),l,l,a);return qe(d,l,p(o),s.data),s},qe=(e,r,t,i)=>{var a=e.store.rootNames[r]||"query",n=!!e.store.rootNames[r],o=n?r:i.__typename;if(!o&&r&&e.optimistic&&(o=W(r,"__typename")),o){!n&&r&&Y(r,"__typename",o);for(var l,u=e.store.updates[o],v=fe(o,r||o,le,t,e);l=v();){var y=s(l),c=f(l,e.variables),m=q(y,c),h=d(l),g=i[e.optimistic?y:h];if(!("__typename"===y||void 0===g&&(le||e.optimistic&&"query"===a))){e.__internal.path.push(h);var k=void 0;if(e.optimistic&&"mutation"===a){if(!(k=e.store.optimisticMutations[y]))continue}else e.optimistic&&"function"==typeof g&&(k=g);if(k&&(pe(e,i,o,r||o,m,y),g=ye(k(c||{},e.store,e))),void 0!==g){if(l.selectionSet)if(r&&"query"===a){var _=x(r,m),O=xe(e,p(l),ye(g),_,e.optimistic?X(r||o,m):void 0);Z(r||o,m,O)}else xe(e,p(l),ye(g));else r&&"query"===a&&Y(r||o,m,null===g&&de(e)?void 0:g);var w=u&&u[y];w&&(pe(e,i,o,r||o,m,y),i[y]=g,w(i,c||{},e.store,e)),e.__internal.path.pop()}}}}},xe=(e,r,t,i,a)=>{if(Array.isArray(t)){for(var n=new Array(t.length),o=0,s=t.length;o<s;o++){e.__internal.path.push(o);var l=i?x(i,`${o}`):void 0,d=xe(e,r,t[o],l,null!=a?a[o]:void 0);n[o]=d,e.__internal.path.pop()}return n}if(null===t)return de(e)?void 0:null;var u=e.store.keyOfEntity(t)||("string"==typeof a?a:null)||i;return qe(e,u,r,t),u||null};class Ke{constructor(e){e||(e={}),this.logger=e.logger,this.resolvers=e.resolvers||{},this.directives=e.directives||{},this.optimisticMutations=e.optimistic||{},this.keys=e.keys||{},this.globalIDs=Array.isArray(e.globalIDs)?new Set(e.globalIDs):!!e.globalIDs;var r,t="Query",i="Mutation",a="Subscription";if(e.schema){var n=(({__schema:e})=>{var r=new Map,t=e=>{var r;return()=>{if(!r){r={};for(var t=0;t<e.length;t++)r[e[t].name]=e[t]}return r}},i=e=>{switch(e.kind){case"OBJECT":case"INTERFACE":return{name:e.name,kind:e.kind,interfaces:t(e.interfaces||[]),fields:t(e.fields.map((e=>({name:e.name,type:e.type,args:t(e.args)}))))};case"UNION":return{name:e.name,kind:e.kind,types:t(e.possibleTypes||[])}}},a={query:e.queryType?e.queryType.name:null,mutation:e.mutationType?e.mutationType.name:null,subscription:e.subscriptionType?e.subscriptionType.name:null,types:void 0,isSubType(e,t){var i=r.get(e),a=r.get(t);return!!(i&&a&&("UNION"===i.kind?i.types()[t]:"OBJECT"!==i.kind&&"OBJECT"===a.kind?a.interfaces()[e]:e===t))}};if(e.types){a.types=r;for(var n=0;n<e.types.length;n++){var o=e.types[n];if(o&&o.name){var s=i(o);s&&r.set(o.name,s)}}}return a})(e.schema);t=n.query||t,i=n.mutation||i,a=n.subscription||a,n.types&&(this.schema=n)}this.updates=e.updates||{},this.rootFields={query:t,mutation:i,subscription:a},this.rootNames={[t]:"query",[i]:"mutation",[a]:"subscription"},this.data=(r=t,{hydrating:!1,defer:!1,gc:new Set,persist:new Set,queryRootKey:r,refCount:new Map,links:{optimistic:new Map,base:new Map},records:{optimistic:new Map,base:new Map},deferredKeys:new Set,commutativeKeys:new Set,dirtyKeys:new Set,optimisticOrder:[],storage:null})}keyOfField(e,r){return q(e,r)}keyOfEntity(e){if(se&&e===se.parent)return se.parentKey;if(null==e||"string"==typeof e)return e||null;if(!e.__typename)return null;if(this.rootNames[e.__typename])return e.__typename;var r=null;this.keys[e.__typename]?r=this.keys[e.__typename](e)||null:null!=e.id?r=`${e.id}`:null!=e._id&&(r=`${e._id}`);var t=e.__typename;return!0===this.globalIDs||this.globalIDs&&this.globalIDs.has(t)||!r?r:`${t}:${r}`}resolve(e,r,t){var i=null,a=this.keyOfEntity(e);if(a){var n=q(r,t);void 0===(i=W(a,n))&&(i=X(a,n))}return i}resolveFieldByKey(e,r,t){return this.resolve(e,r,t)}invalidate(e,r,t){var i=this.keyOfEntity(e);a(i,"",19),((e,r,t)=>{for(var i=r?[{fieldKey:q(r,t)}]:ne(e),a=0,n=i.length;a<n;a++){var{fieldKey:o}=i[a];void 0!==X(e,o)?Z(e,o,void 0):Y(e,o,void 0)}})(i,r,t)}inspectFields(e){var r=this.keyOfEntity(e);return r?ne(r):[]}updateQuery(r,t){var i=e.createRequest(r.query,r.variables),a=t(this.readQuery(i));null!==a&&Ne(this,i,a,void 0)}readQuery(r){var t=e.createRequest(r.query,r.variables);return me(this,t,void 0,void 0).data}readFragment(r,t,i,a){return((e,r,t,i,a)=>{var n,o=h(r);if(a){if(!(n=o[a]))return null}else if(!(n=o[Object.keys(o)[0]]))return null;var s=l(n);"string"==typeof t||t.__typename||(t.__typename=s);var d=e.keyOfEntity(t);if(!d)return null;var u=ue(e,i||{},o,s,d,void 0);return _e(u,d,p(n),L())||null})(this,e.formatDocument(r),t,i,a)}writeFragment(r,t,i,a){((e,r,t,i,a)=>{var n,o=h(r);if(a){if(!(n=o[a]))return null}else if(!(n=o[Object.keys(o)[0]]))return null;var s=l(n),d={__typename:s,...t},u=e.keyOfEntity(d);if(u){var v=ue(e,i||{},o,s,u,void 0);qe(v,u,p(n),d)}})(this,e.formatDocument(r),t,i,a)}link(e,r,...t){var i=2===t.length?t[0]:null,a=2===t.length?t[1]:t[0],n=this.keyOfEntity(e);n&&Z(n,q(r,i),ce(this,a))}}var Se=(r,t)=>e.makeOperation(r.kind,r,{...r.context,requestPolicy:t}),Ee=r=>({forward:i,client:a})=>{var n=new Ke(r);r&&r.storage&&(n.data.hydrating=!0,r.storage.readData().then((e=>{((e,r,t)=>{for(var i in R("write",e,null),t){var a=t[i];if(void 0!==a){var{entityKey:n,fieldKey:o}=S(i);":"===a[0]?void 0===X(n,o)&&Z(n,o,JSON.parse(a.slice(1))):void 0===W(n,o)&&Y(n,o,JSON.parse(a))}}e.storage=r,e.hydrating=!1,P()})(n.data,r.storage,e),r.storage.onCacheHydrated&&r.storage.onCacheHydrated()})));var o=new Map,s=[],l=new Map,d=new Map,u=new Set,p=new Set,v=new Map,f=new Set,c=new Set,h=e=>{for(var r of e.values())if(u.has(r))return!0;return!1},g=(e,r)=>{if(r)for(var t of r.values()){var i=v.get(t);if(i)for(var a of i.values())e.add(a)}},k=(e,r,t)=>{for(var i of r.values())if(i!==e.key){var n=l.get(i);if(n){"query"===e.kind&&c.add(i);var o="cache-first";p.has(i)&&(p.delete(i),o="cache-and-network"),a.reexecuteOperation(Se(n,o))}}if(!t){var s=f;"query"===e.kind&&(f=c).add(e.key),(c=s).clear()}},_=r=>{var t=!1;if("query"===r.kind)ee(n.data,r.key),l.set(r.key,r);else{if("teardown"===r.kind)return l.delete(r.key),d.delete(r.key),f.delete(r.key),j(n.data,r.key),r;if("mutation"===r.kind&&"network-only"!==r.context.requestPolicy){l.set(r.key,r),R("write",n.data,r.key,!0,!1);var{dependencies:i}=Ne(n,r,void 0,void 0);if(P(),i.size){for(var a of i.values())u.add(a);o.set(r.key,i);var s=new Set;g(s,i),k(r,s,!0),t=!0}}}return e.makeOperation(r.kind,{key:r.key,query:e.formatDocument(r.query),variables:r.variables?y(m(r.query),r.variables):r.variables},{...r.context,optimistic:t})},O=(e,r)=>{for(var t of r.values()){var i=v.get(t);i||v.set(t,i=new Set),i.add(e.key)}},w=e=>{R("read",n.data,void 0,!1,!1);var r=me(n,e,d.get(e.key),void 0);P();var t=r.data?r.partial||r.hasNext?"partial":"hit":"miss";return d.set(e.key,r.data),l.set(e.key,e),O(e,r.dependencies),{outcome:t,operation:e,data:r.data,dependencies:r.dependencies,hasNext:r.hasNext}},b=(e,r)=>{var t,i=l.get(e.operation.key)||e.operation;if("mutation"===i.kind){var a=o.get(i.key);g(r,a),o.delete(i.key)}("subscription"===i.kind||e.hasNext)&&ee(n.data,i.key,!0);var s=e.data;if(s){R("write",n.data,i.key,!1,!1);var u=Ne(n,i,s,e.error).dependencies;P(),g(r,u);var p="query"===i.kind?d.get(i.key):null;R("read",n.data,i.key,!1,p!==s);var v=me(n,i,p||s,e.error);P(),s=v.data,"query"===i.kind&&(g(r,t=v.dependencies),d.set(i.key,s))}else j(n.data,i.key);return t&&O(e.operation,t),{operation:i,data:s,error:e.error,extensions:e.extensions,hasNext:e.hasNext,stale:e.stale}};return e=>{var r=t.share(t.map(w)(t.filter((e=>"query"===e.kind&&"network-only"!==e.context.requestPolicy))(e))),d=t.filter((e=>"query"!==e.kind||"network-only"===e.context.requestPolicy))(e),v=t.map((e=>e.operation))(t.filter((e=>"miss"===e.outcome&&"cache-only"!==e.operation.context.requestPolicy&&!h(e.dependencies)&&!f.has(e.operation.key)))(r)),y=t.map((e=>{var r,t,{requestPolicy:i}=e.operation.context,o="cache-only"!==i&&(e.hasNext||"cache-and-network"===i||"cache-first"===i&&"partial"===e.outcome&&!f.has(e.operation.key)),s="cache-only"!==i&&(o||"partial"===e.outcome&&f.has(e.operation.key)&&((r=n.data).commutativeKeys.has(t=e.operation.key)||r.optimisticOrder.indexOf(t)>-1)),d={operation:e.operation,data:e.data,error:e.error,extensions:e.extensions,stale:s&&!e.hasNext,hasNext:o&&e.hasNext};return o&&(h(e.dependencies)?"cache-and-network"===i&&p.add(e.operation.key):a.reexecuteOperation(Se(l.get(e.operation.key)||e.operation,"network-only"))),d}))(t.filter((e=>"miss"!==e.outcome||"cache-only"===e.operation.context.requestPolicy))(r)),c=i(t.map(_)(t.merge([d,v]))),m=t.map((e=>{var r=new Set,t=b(e,r);return k(e.operation,r,!1),t}))(t.filter((e=>!o.has(e.operation.key)))(c)),g=t.mergeMap((e=>{if(s.push(e)<o.size)return t.empty;for(var r=0;r<s.length;r++)ee(n.data,s[r].operation.key);u.clear();for(var i,a=[],l=new Set;i=s.shift();)a.push(b(i,l));return k(e.operation,l,!1),t.fromArray(a)}))(t.filter((e=>o.has(e.operation.key)))(c));return t.merge([m,g,y])}},Ae={"cache-only":0,"cache-first":1,"network-only":2,"cache-and-network":3};exports.Store=Ke,exports.cacheExchange=Ee,exports.offlineExchange=r=>i=>{var{storage:a}=r,n=r.isOfflineError||(e=>e&&e.networkError&&!e.response&&("undefined"!=typeof navigator&&!1===navigator.onLine||/request failed|failed to fetch|network\s?error/i.test(e.networkError.message)));if(a&&a.onOnline&&a.readMetadata&&a.writeMetadata){var{forward:o,client:s,dispatchDebug:l}=i,{source:d,next:u}=t.makeSubject(),p=[],v=!1,f=!1,y=()=>{if(v){for(var r=[],t=0;t<p.length;t++){var i=p[t];"mutation"===i.kind&&r.push({query:e.stringifyDocument(i.query),variables:i.variables,extensions:i.extensions})}a.writeMetadata(r)}},c=e=>{for(var r=p.length-1;r>=0;r--)p[r].key===e&&p.splice(r,1)},m=()=>{if(!f){var r=new Set;f=!0;for(var t=0;t<p.length;t++){var i=p[t];if("mutation"===i.kind||!r.has(i.key))if(r.add(i.key),"subscription"!==i.kind){u(e.makeOperation("teardown",i));for(var a="cache-first",n=0;n<p.length;n++){var{requestPolicy:o}=p[n].context;Ae[o]>Ae[a]&&(a=o)}u(Se(i,a))}else u(Se(i,"cache-first"))}f=!1,p.length=0,y()}},h=Ee({...r,storage:{...a,readData(){var r=a.readData();return{async then(t){for(var i=await a.readMetadata(),n=0;i&&n<i.length;n++)p.push(s.createRequestOperation("mutation",e.createRequest(i[n].query,i[n].variables),i[n].extensions));t(await r),a.onOnline(m),v=!0,m()}}}}})({client:s,dispatchDebug:l,forward:e=>t.share(t.filter((e=>!(v&&"mutation"===e.operation.kind&&e.operation.context.optimistic&&n(e.error,e)&&(p.push(e.operation),y(),1))))(o(e)))});return e=>{var r=t.merge([d,t.onPush((e=>{"query"!==e.kind||v?"teardown"===e.kind&&c(e.key):p.push(e)}))(e)]);return t.filter((e=>{if("query"===e.operation.kind){if(n(e.error,e))return u(Se(e.operation,"cache-only")),p.push(e.operation),!1;v||c(e.operation.key)}return!0}))(h(r))}}return Ee(r)(i)};
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@urql/core"),r=require("@0no-co/graphql.web"),t=require("wonka"),i="\nhttps://bit.ly/2XbVrpR#";function a(e,r,t){if(!e){var a=new Error((r||"Minfied Error #"+t+"\n")+i+t);throw a.name="Graphcache Error",a}}new Set;var n={},o=e=>e._directives||n,s=e=>e.name.value,l=e=>e.typeCondition.name.value,d=e=>e.alias?e.alias.value:e.name.value,u=[],p=e=>e.selectionSet?e.selectionSet.selections:u,v=e=>e.typeCondition?e.typeCondition.name.value:null,f=(e,t)=>{var i=null;if(e.arguments)for(var a=0,n=e.arguments.length;a<n;a++){var o=e.arguments[a],l=r.valueFromASTUntyped(o.value,t);null!=l&&(i||(i={}),i[s(o)]=l)}return i},y=(e,r)=>{if(r&&e.variableDefinitions){for(var t={},i=0,a=e.variableDefinitions.length;i<a;i++){var n=s(e.variableDefinitions[i].variable);t[n]=r[n]}return t}},c=(e,t)=>{var i={};if(!t)return i;if(e.variableDefinitions)for(var a=0,n=e.variableDefinitions.length;a<n;a++){var o=e.variableDefinitions[a],l=s(o.variable);i[l]=void 0===t[l]&&o.defaultValue?r.valueFromASTUntyped(o.defaultValue,t):t[l]}for(var d in t)d in i||(i[d]=t[d]);return i};function m(e){for(var t=0;t<e.definitions.length;t++)if(e.definitions[t].kind===r.Kind.OPERATION_DEFINITION)return e.definitions[t];a(!1,"",1)}var h=e=>{for(var t={},i=0;i<e.definitions.length;i++){var a=e.definitions[i];a.kind===r.Kind.FRAGMENT_DEFINITION&&(t[s(a)]=a)}return t},g=(e,t)=>{var i=o(e);if(i.include||i.skip)for(var a in i){var n=i[a];if(n&&("include"===a||"skip"===a)&&n.arguments&&n.arguments[0]&&"if"===s(n.arguments[0])){var l=r.valueFromASTUntyped(n.arguments[0].value,t);return"include"===a?!!l:!l}}return!0},k=(e,t)=>{var{defer:i}=o(e);if(i){for(var a of i.arguments||[])if("if"===s(a))return!!r.valueFromASTUntyped(a.value,t);return!0}return!1},_=(e,r,t,i)=>{var a=b(e,r,t,i);return!!a&&"NON_NULL"!==a.type.kind},O=(e,r,t,i)=>{var a=b(e,r,t,i);if(!a)return!1;var n="NON_NULL"===a.type.kind?a.type.ofType:a.type;return"LIST"===n.kind&&"NON_NULL"!==n.ofType.kind},w=(e,r,t)=>{if(!t)return!1;var i=v(r);return!i||t===i||(e.types.has(i)&&"OBJECT"===e.types.get(i).kind?i===t:(function(e,r){a(e.types.has(r)&&("INTERFACE"===e.types.get(r).kind||"UNION"===e.types.get(r).kind),"",5)}(e,i),N(e,t),e.isSubType(i,t)))},b=(e,r,t,i)=>{if(0!==t.indexOf("__")&&0!==r.indexOf("__"))return N(e,r),e.types.get(r).fields()[t]};function N(e,r){a(e.types.has(r)&&"OBJECT"===e.types.get(r).kind,"",3)}var q=(r,t)=>t?`${r}(${e.stringifyVariables(t)})`:r,x=(e,r)=>`${e}.${r}`,K=e=>{var r=e.indexOf("(");return r>-1?{fieldKey:e,fieldName:e.slice(0,r),arguments:JSON.parse(e.slice(r+1,-1))}:{fieldKey:e,fieldName:e,arguments:null}},S=e=>{var r=e.indexOf(".");return{entityKey:e.slice(0,r).replace(/%2e/g,"."),fieldKey:e.slice(r+1)}},E=null,A=null,M=null,T=null,D=null,F=null,I=!1,C=!1;function L(e,r){var t;if(e){if(E.has(e))return e;t=A.get(e)}return null==t&&(t=r?[]:{}),e&&A.set(e,t),E.add(t),t}var $=e=>!!e&&E.has(e),R=(e,r,t,i,a)=>{E=new WeakSet,A=new WeakMap,D=e,M=r,F=new Set,C=!!i,I=!!a,t?"read"===D?T=t:i||r.hydrating||r.optimisticOrder.length>1?(i||r.commutativeKeys.has(t)?i&&(-1===r.optimisticOrder.indexOf(t)||r.commutativeKeys.has(t)||r.optimisticOrder.splice(r.optimisticOrder.indexOf(t),1),r.commutativeKeys.delete(t)):ee(r,t),T=t,re(r,t)):(T=null,ie(r,t)):T=null},P=()=>{var e=M,r=T;if(C=!1,T=null,!e.hydrating&&r&&e.optimisticOrder.indexOf(r)>-1)for(var t=e.optimisticOrder.length;--t>=0&&e.dirtyKeys.has(e.optimisticOrder[t])&&e.commutativeKeys.has(e.optimisticOrder[t]);)ae(e.optimisticOrder[t]);E=null,A=null,D=null,M=null,F=null,e.defer||!e.storage&&e.optimisticOrder.length||(e.defer=!0,setTimeout((()=>{R("read",e,null),G(),oe(),P(),e.defer=!1})))},j=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),R("write",e,r,t),P()},U=(e,r,t,i)=>{var a=T?e.optimistic.get(T):e.base,n=a.get(r);void 0===n&&a.set(r,n=Object.create(null)),void 0!==i||T?n[t]=i:delete n[t]},J=(e,r,t)=>{for(var i,a=!C&&"read"===D&&T&&M.commutativeKeys.has(T),n=0,o=M.optimisticOrder.length;n<o;n++){var s=M.optimisticOrder[n],l=e.optimistic.get(s);if(a=a&&s!==T,l&&(!a||!M.commutativeKeys.has(s))&&(!C||"write"===D||M.commutativeKeys.has(s))&&void 0!==(i=l.get(r))&&t in i)return i[t]}return void 0!==(i=e.base.get(r))?i[t]:void 0},Q=(e,r)=>{if(Array.isArray(e))for(var t=0,i=e.length;t<i;t++)Q(e[t],r);else"string"==typeof e&&((e,r)=>{var t=M.refCount.get(e)||0,i=t+r>0?t+r:0;M.refCount.set(e,i),i?!t&&i&&M.gc.delete(e):M.gc.add(e)})(e,r)},B=(e,r,t)=>{if(void 0!==t)for(var i in t)r.has(i)||(e.push(K(i)),r.add(i))},V=(e,r,t,i)=>{B(e,r,i.base.get(t));for(var a=0,n=M.optimisticOrder.length;a<n;a++){var o=i.optimistic.get(M.optimisticOrder[a]);void 0!==o&&B(e,r,o.get(t))}},G=()=>{if(!M.optimisticOrder.length)for(var e of M.gc.keys())if(M.gc.delete(e),!((M.refCount.get(e)||0)>0)){M.refCount.delete(e),M.records.base.delete(e);var r=M.links.base.get(e);if(r)for(var t in M.links.base.delete(e),r)Q(r[t],-1)}},z=(e,r)=>{e!==M.queryRootKey?F.add(e):void 0!==r&&"__typename"!==r&&F.add(x(e,r))},H=(e,r)=>{!C&&M.storage&&M.persist.add(((e,r)=>`${e.replace(/\./g,"%2e")}.${r}`)(e,r))},W=(e,r)=>(z(e,r),J(M.records,e,r)),X=(e,r)=>(z(e,r),J(M.links,e,r)),Y=(e,r,t)=>{z(e,r),H(e,r),U(M.records,e,r,t)},Z=(e,r,t)=>{var i=T?M.links.optimistic.get(T):M.links.base;if(!T){var a=i&&i.get(e);Q(a&&a[r],-1),Q(t,1)}z(e,r),H(e,r),U(M.links,e,r,t)},ee=(e,r,t)=>{var i=e.optimisticOrder.indexOf(r);if(i>-1&&e.optimisticOrder.splice(i,1),t)for(e.deferredKeys.add(r),i=i>-1?i:0;i<e.optimisticOrder.length&&!e.deferredKeys.has(e.optimisticOrder[i])&&(!e.dirtyKeys.has(e.optimisticOrder[i])||!e.commutativeKeys.has(e.optimisticOrder[i]));i++);else e.deferredKeys.delete(r),i>-1&&!e.commutativeKeys.has(r)&&te(e,r),i=0;e.optimisticOrder.splice(i,0,r),e.commutativeKeys.add(r)},re=(e,r)=>{-1===e.optimisticOrder.indexOf(r)&&e.optimisticOrder.unshift(r),e.dirtyKeys.has(r)||(e.dirtyKeys.add(r),e.links.optimistic.set(r,new Map),e.records.optimistic.set(r,new Map))},te=(e,r)=>{e.dirtyKeys.has(r)&&(e.dirtyKeys.delete(r),e.records.optimistic.delete(r),e.links.optimistic.delete(r),e.deferredKeys.delete(r))},ie=(e,r)=>{var t=e.optimisticOrder.indexOf(r);t>-1&&(e.optimisticOrder.splice(t,1),e.commutativeKeys.delete(r)),te(e,r)},ae=e=>{var r=F;F=new Set,D="write";var t=M.links.optimistic.get(e);if(t)for(var i of t.entries()){var a=i[0],n=i[1];for(var o in n)Z(a,o,n[o])}var s=M.records.optimistic.get(e);if(s)for(var l of s.entries()){var d=l[0],u=l[1];for(var p in u)Y(d,p,u[p])}F=r,ie(M,e)},ne=e=>{var{links:r,records:t}=M,i=[],a=new Set;return z(e),V(i,a,e,r),V(i,a,e,t),i},oe=()=>{if(M.storage){C=!0,D="read";var r={};for(var t of M.persist.keys()){var{entityKey:i,fieldKey:a}=S(t),n=void 0;r[t]=void 0!==(n=X(i,a))?`:${e.stringifyVariables(n)}`:void 0!==(n=W(i,a))?e.stringifyVariables(n):void 0}C=!1,M.storage.writeData(r),M.persist.clear()}},se=null,le=!1,de=e=>e.__internal.path.length>0&&e.__internal.errorMap?e.__internal.errorMap[e.__internal.path.join(".")]:void 0,ue=(e,r,t,i,a,n)=>{le=!1;var o={store:e,variables:r,fragments:t,parent:{__typename:i},parentTypeName:i,parentKey:a,parentFieldKey:"",fieldName:"",error:void 0,partial:!1,hasNext:!1,optimistic:C,__internal:{path:[],errorMap:void 0}};if(n&&n.graphQLErrors)for(var s=0;s<n.graphQLErrors.length;s++){var l=n.graphQLErrors[s];l.path&&l.path.length&&(o.__internal.errorMap||(o.__internal.errorMap=Object.create(null)),o.__internal.errorMap[l.path.join(".")]=l)}return o},pe=(e,r,t,i,a,n)=>{se=e,e.parent=r,e.parentTypeName=t,e.parentKey=i,e.parentFieldKey=a,e.fieldName=n,e.error=de(e)},ve=(e,t,i,a,n)=>{if(!t)return!1;var o=v(e);return!o||t===o||"write"===D||!p(e).some((e=>{if(e.kind!==r.Kind.FIELD)return!1;var t=q(s(e),f(e,a));return!((e,r)=>void 0!==W(e,r)||void 0!==X(e,r))(i,t)}))},fe=(e,t,i,a,n)=>{var o,l=0;return function(){for(var d;o||l<a.length;)if(d=void 0,le=i,o){if(d=o())return d;o=void 0}else{var u=a[l++];if(g(u,n.variables))if(u.kind!==r.Kind.FIELD){var v=u.kind!==r.Kind.INLINE_FRAGMENT?n.fragments[s(u)]:u;v&&(!v.typeCondition||(n.store.schema?w(n.store.schema,v,e):ve(v,e,t,n.variables)))&&(o=fe(e,t,i||k(u,n.variables),p(v),n))}else if("write"===D||!u._generated)return u}}},ye=e=>null==e?null:e,ce=(e,r)=>{if(!r)return r||null;if(Array.isArray(r)){for(var t=new Array(r.length),i=0,a=t.length;i<a;i++)t[i]=ce(e,r[i]);return t}return e.keyOfEntity(r)},me=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s=r.rootFields[o.operation],l=p(o),d=ue(r,c(o,t.variables),h(n),s,s,a),u=s!==d.store.rootFields.query?he(d,s,l,i||L()):_e(d,s,l,i||L());return{dependencies:F,partial:d.partial||!u,hasNext:d.hasNext,data:u||null}},he=(e,r,t,i)=>{if("string"!=typeof(e.store.rootNames[r]?r:i.__typename))return i;for(var a,n=fe(r,r,le,t,e),o=I,s=L(i);a=n();){var l,u=d(a),v=i[u];e.__internal.path.push(u),l=a.selectionSet&&null!==v?ge(e,p(a),ye(v)):v,o=o||l!==v,void 0!==l&&(s[u]=l),e.__internal.path.pop()}return o?s:i},ge=(e,r,t)=>{if(Array.isArray(t)){for(var i=new Array(t.length),a=I,n=0,o=t.length;n<o;n++)e.__internal.path.push(n),i[n]=ge(e,r,t[n]),a=a||i[n]!==t[n],e.__internal.path.pop();return a?i:t}if(null===t)return null;var s=e.store.keyOfEntity(t);return null!==s?_e(e,s,r,t)||null:he(e,t.__typename,r,t)};function ke(e,r,t,i){var a=i.store.resolvers[r],n=a&&a[t];for(var o in e){var s=e[o];if(s&&"include"!==o&&"skip"!==o&&i.store.directives[o])return i.store.directives[o](f(s,i.variables))}return n}var _e=(e,r,t,i,a)=>{var{store:n}=e,l=r===n.rootFields.query,u=a&&n.keyOfEntity(a)||r,v=l?r:W(u,"__typename")||a&&a.__typename;if("string"==typeof v&&(!a||v===a.__typename)){for(var y,c=fe(v,u,le,t,e),m=!1,h=!1,g=I,k=e.partial,O=L(i);void 0!==(y=c());){var w=s(y),b=f(y,e.variables),N=d(y),K=o(y),S=ke(K,v,w,e),E=q(w,b),A=x(u,E),M=W(u,E),T=a?a[w]:void 0;e.__internal.path.push(N);var F=void 0;if("__typename"===w)F=v;else if(void 0!==T&&void 0===y.selectionSet)F=T;else if("read"===D&&S){var C=O;if(void 0===y.selectionSet&&void 0!==M&&(C={...O,[N]:M,[w]:M}),pe(e,C,v,u,E,w),F=S(C,b||{},n,e),y.selectionSet&&(F=Oe(e,v,w,A,p(y),void 0!==O[N]?O[N]:i[N],F,$(i))),n.schema&&null===F&&!_(n.schema,v,w,e.store.logger))return}else if(y.selectionSet)if(void 0!==T)F=Oe(e,v,w,A,p(y),void 0!==O[N]?O[N]:i[N],T,$(i));else{var R=X(u,E);void 0!==R?F=we(e,R,v,w,p(y),void 0!==O[N]?O[N]:i[N],$(i)):"object"==typeof M&&null!==M&&(F=M)}else F=M;if(!le&&void 0===F&&(K.optional||de(e)||n.schema&&_(n.schema,v,w,e.store.logger))?(e.partial=!0,F=null):null===F&&K.required?F=void 0:m=m||"__typename"!==w,e.__internal.path.pop(),g=g||F!==i[N],void 0!==F)O[N]=F;else{if(!le)return void(e.partial=k);h=!0}}return e.partial=e.partial||k,e.hasNext=e.hasNext||h,l&&e.partial&&!m?void 0:g?O:i}},Oe=(e,r,t,i,a,n,o,s)=>{if(Array.isArray(o)){for(var{store:l}=e,d=!!l.schema&&O(l.schema,r,t,e.store.logger),u=e.partial,p=L(n,!0),v=I||!Array.isArray(n)||o.length!==n.length,f=0,y=o.length;f<y;f++){e.__internal.path.push(f);var c=Oe(e,r,t,x(i,`${f}`),a,null!=n?n[f]:void 0,o[f],s);if(e.__internal.path.pop(),void 0===c&&!d)return void(e.partial=u);e.partial=e.partial||void 0===c&&d,p[f]=null!=c?c:null,v=v||p[f]!==n[f]}return v?p:n}if(null==o)return o;if(s&&null===n)return null;if(be(o)){var m=n||L(n);return"string"==typeof o?_e(e,o,a,m):_e(e,i,a,m,o)}},we=(e,r,t,i,a,n,o)=>{if(Array.isArray(r)){for(var{store:s}=e,l=!!s.schema&&O(s.schema,t,i,e.store.logger),d=L(n,!0),u=e.partial,p=I||!Array.isArray(n)||r.length!==n.length,v=0,f=r.length;v<f;v++){e.__internal.path.push(v);var y=we(e,r[v],t,i,a,null!=n?n[v]:void 0,o);if(e.__internal.path.pop(),void 0===y&&!l)return void(e.partial=u);e.partial=e.partial||void 0===y&&l,d[v]=y||null,p=p||d[v]!==n[v]}return p?d:n}return null===r||null===n&&o?null:_e(e,r,a,n||L(n))},be=e=>"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename,Ne=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s={data:i||L(),dependencies:F},l=r.rootFields[o.operation],d=ue(r,c(o,t.variables),h(n),l,l,a);return qe(d,l,p(o),s.data),s},qe=(e,r,t,i)=>{var a=e.store.rootNames[r]||"query",n=!!e.store.rootNames[r],o=n?r:i.__typename;if(!o&&r&&e.optimistic&&(o=W(r,"__typename")),o){!n&&r&&Y(r,"__typename",o);for(var l,u=e.store.updates[o],v=fe(o,r||o,le,t,e);l=v();){var y=s(l),c=f(l,e.variables),m=q(y,c),h=d(l),g=i[e.optimistic?y:h];if(!("__typename"===y||void 0===g&&(le||e.optimistic&&"query"===a))){e.__internal.path.push(h);var k=void 0;if(e.optimistic&&"mutation"===a){if(!(k=e.store.optimisticMutations[y]))continue}else e.optimistic&&"function"==typeof g&&(k=g);if(k&&(pe(e,i,o,r||o,m,y),g=ye(k(c||{},e.store,e))),void 0!==g){if(l.selectionSet)if(r&&"query"===a){var _=x(r,m),O=xe(e,p(l),ye(g),_,e.optimistic?X(r||o,m):void 0);Z(r||o,m,O)}else xe(e,p(l),ye(g));else r&&"query"===a&&Y(r||o,m,null===g&&de(e)?void 0:g);var w=u&&u[y];w&&(pe(e,i,o,r||o,m,y),i[y]=g,w(i,c||{},e.store,e)),e.__internal.path.pop()}}}}},xe=(e,r,t,i,a)=>{if(Array.isArray(t)){for(var n=new Array(t.length),o=0,s=t.length;o<s;o++){e.__internal.path.push(o);var l=i?x(i,`${o}`):void 0,d=xe(e,r,t[o],l,null!=a?a[o]:void 0);n[o]=d,e.__internal.path.pop()}return n}if(null===t)return de(e)?void 0:null;var u=e.store.keyOfEntity(t)||("string"==typeof a?a:null)||i;return qe(e,u,r,t),u||null};class Ke{constructor(e){e||(e={}),this.logger=e.logger,this.resolvers=e.resolvers||{},this.directives=e.directives||{},this.optimisticMutations=e.optimistic||{},this.keys=e.keys||{},this.globalIDs=Array.isArray(e.globalIDs)?new Set(e.globalIDs):!!e.globalIDs;var r,t="Query",i="Mutation",a="Subscription";if(e.schema){var n=(({__schema:e})=>{var r=new Map,t=e=>{var r;return()=>{if(!r){r={};for(var t=0;t<e.length;t++)r[e[t].name]=e[t]}return r}},i=e=>{switch(e.kind){case"OBJECT":case"INTERFACE":return{name:e.name,kind:e.kind,interfaces:t(e.interfaces||[]),fields:t(e.fields.map((e=>({name:e.name,type:e.type,args:t(e.args)}))))};case"UNION":return{name:e.name,kind:e.kind,types:t(e.possibleTypes||[])}}},a={query:e.queryType?e.queryType.name:null,mutation:e.mutationType?e.mutationType.name:null,subscription:e.subscriptionType?e.subscriptionType.name:null,types:void 0,isSubType(e,t){var i=r.get(e),a=r.get(t);return!!(i&&a&&("UNION"===i.kind?i.types()[t]:"OBJECT"!==i.kind&&"OBJECT"===a.kind?a.interfaces()[e]:e===t))}};if(e.types){a.types=r;for(var n=0;n<e.types.length;n++){var o=e.types[n];if(o&&o.name){var s=i(o);s&&r.set(o.name,s)}}}return a})(e.schema);t=n.query||t,i=n.mutation||i,a=n.subscription||a,n.types&&(this.schema=n)}this.updates=e.updates||{},this.rootFields={query:t,mutation:i,subscription:a},this.rootNames={[t]:"query",[i]:"mutation",[a]:"subscription"},this.data=(r=t,{hydrating:!1,defer:!1,gc:new Set,persist:new Set,queryRootKey:r,refCount:new Map,links:{optimistic:new Map,base:new Map},records:{optimistic:new Map,base:new Map},deferredKeys:new Set,commutativeKeys:new Set,dirtyKeys:new Set,optimisticOrder:[],storage:null})}keyOfField(e,r){return q(e,r)}keyOfEntity(e){if(se&&e===se.parent)return se.parentKey;if(null==e||"string"==typeof e)return e||null;if(!e.__typename)return null;if(this.rootNames[e.__typename])return e.__typename;var r=null;this.keys[e.__typename]?r=this.keys[e.__typename](e)||null:null!=e.id?r=`${e.id}`:null!=e._id&&(r=`${e._id}`);var t=e.__typename;return!0===this.globalIDs||this.globalIDs&&this.globalIDs.has(t)||!r?r:`${t}:${r}`}resolve(e,r,t){var i=this.keyOfEntity(e);if(i){var a=q(r,t),n=W(i,a);if(void 0!==n)return n;var o=X(i,a);return void 0!==o&&(o=ce(this,o)),o}}resolveFieldByKey(e,r,t){return this.resolve(e,r,t)}invalidate(e,r,t){var i=this.keyOfEntity(e);a(i,"",19),((e,r,t)=>{for(var i=r?[{fieldKey:q(r,t)}]:ne(e),a=0,n=i.length;a<n;a++){var{fieldKey:o}=i[a];void 0!==X(e,o)?Z(e,o,void 0):Y(e,o,void 0)}})(i,r,t)}inspectFields(e){var r=this.keyOfEntity(e);return r?ne(r):[]}updateQuery(r,t){var i=e.createRequest(r.query,r.variables),a=t(this.readQuery(i));null!==a&&Ne(this,i,a,void 0)}readQuery(r){var t=e.createRequest(r.query,r.variables);return me(this,t,void 0,void 0).data}readFragment(r,t,i,a){return((e,r,t,i,a)=>{var n,o=h(r);if(a){if(!(n=o[a]))return null}else if(!(n=o[Object.keys(o)[0]]))return null;var s=l(n);"string"==typeof t||t.__typename||(t.__typename=s);var d=e.keyOfEntity(t);if(!d)return null;var u=ue(e,i||{},o,s,d,void 0);return _e(u,d,p(n),L())||null})(this,e.formatDocument(r),t,i,a)}writeFragment(r,t,i,a){((e,r,t,i,a)=>{var n,o=h(r);if(a){if(!(n=o[a]))return null}else if(!(n=o[Object.keys(o)[0]]))return null;var s=l(n),d={__typename:s,...t},u=e.keyOfEntity(d);if(u){var v=ue(e,i||{},o,s,u,void 0);qe(v,u,p(n),d)}})(this,e.formatDocument(r),t,i,a)}link(e,r,...t){var i=2===t.length?t[0]:null,a=2===t.length?t[1]:t[0],n=this.keyOfEntity(e);n&&Z(n,q(r,i),ce(this,a))}}var Se=(r,t)=>e.makeOperation(r.kind,r,{...r.context,requestPolicy:t}),Ee=r=>({forward:i,client:a})=>{var n=new Ke(r);r&&r.storage&&(n.data.hydrating=!0,r.storage.readData().then((e=>{((e,r,t)=>{for(var i in R("write",e,null),t){var a=t[i];if(void 0!==a){var{entityKey:n,fieldKey:o}=S(i);":"===a[0]?void 0===X(n,o)&&Z(n,o,JSON.parse(a.slice(1))):void 0===W(n,o)&&Y(n,o,JSON.parse(a))}}e.storage=r,e.hydrating=!1,P()})(n.data,r.storage,e),r.storage.onCacheHydrated&&r.storage.onCacheHydrated()})));var o=new Map,s=[],l=new Map,d=new Map,u=new Set,p=new Set,v=new Map,f=new Set,c=new Set,h=e=>{for(var r of e.values())if(u.has(r))return!0;return!1},g=(e,r)=>{if(r)for(var t of r.values()){var i=v.get(t);if(i)for(var a of i.values())e.add(a)}},k=(e,r,t)=>{for(var i of r.values())if(i!==e.key){var n=l.get(i);if(n){"query"===e.kind&&c.add(i);var o="cache-first";p.has(i)&&(p.delete(i),o="cache-and-network"),a.reexecuteOperation(Se(n,o))}}if(!t){var s=f;"query"===e.kind&&(f=c).add(e.key),(c=s).clear()}},_=r=>{var t=!1;if("query"===r.kind)ee(n.data,r.key),l.set(r.key,r);else{if("teardown"===r.kind)return l.delete(r.key),d.delete(r.key),f.delete(r.key),j(n.data,r.key),r;if("mutation"===r.kind&&"network-only"!==r.context.requestPolicy){l.set(r.key,r),R("write",n.data,r.key,!0,!1);var{dependencies:i}=Ne(n,r,void 0,void 0);if(P(),i.size){for(var a of i.values())u.add(a);o.set(r.key,i);var s=new Set;g(s,i),k(r,s,!0),t=!0}}}return e.makeOperation(r.kind,{key:r.key,query:e.formatDocument(r.query),variables:r.variables?y(m(r.query),r.variables):r.variables},{...r.context,optimistic:t})},O=(e,r)=>{for(var t of r.values()){var i=v.get(t);i||v.set(t,i=new Set),i.add(e.key)}},w=e=>{R("read",n.data,void 0,!1,!1);var r=me(n,e,d.get(e.key),void 0);P();var t=r.data?r.partial||r.hasNext?"partial":"hit":"miss";return d.set(e.key,r.data),l.set(e.key,e),O(e,r.dependencies),{outcome:t,operation:e,data:r.data,dependencies:r.dependencies,hasNext:r.hasNext}},b=(e,r)=>{var t,i=l.get(e.operation.key)||e.operation;if("mutation"===i.kind){var a=o.get(i.key);g(r,a),o.delete(i.key)}("subscription"===i.kind||e.hasNext)&&ee(n.data,i.key,!0);var s=e.data;if(s){R("write",n.data,i.key,!1,!1);var u=Ne(n,i,s,e.error).dependencies;P(),g(r,u);var p="query"===i.kind?d.get(i.key):null;R("read",n.data,i.key,!1,p!==s);var v=me(n,i,p||s,e.error);P(),s=v.data,"query"===i.kind&&(g(r,t=v.dependencies),d.set(i.key,s))}else j(n.data,i.key);return t&&O(e.operation,t),{operation:i,data:s,error:e.error,extensions:e.extensions,hasNext:e.hasNext,stale:e.stale}};return e=>{var r=t.share(t.map(w)(t.filter((e=>"query"===e.kind&&"network-only"!==e.context.requestPolicy))(e))),d=t.filter((e=>"query"!==e.kind||"network-only"===e.context.requestPolicy))(e),v=t.map((e=>e.operation))(t.filter((e=>"miss"===e.outcome&&"cache-only"!==e.operation.context.requestPolicy&&!h(e.dependencies)&&!f.has(e.operation.key)))(r)),y=t.map((e=>{var r,t,{requestPolicy:i}=e.operation.context,o="cache-only"!==i&&(e.hasNext||"cache-and-network"===i||"cache-first"===i&&"partial"===e.outcome&&!f.has(e.operation.key)),s="cache-only"!==i&&(o||"partial"===e.outcome&&f.has(e.operation.key)&&((r=n.data).commutativeKeys.has(t=e.operation.key)||r.optimisticOrder.indexOf(t)>-1)),d={operation:e.operation,data:e.data,error:e.error,extensions:e.extensions,stale:s&&!e.hasNext,hasNext:o&&e.hasNext};return o&&(h(e.dependencies)?"cache-and-network"===i&&p.add(e.operation.key):a.reexecuteOperation(Se(l.get(e.operation.key)||e.operation,"network-only"))),d}))(t.filter((e=>"miss"!==e.outcome||"cache-only"===e.operation.context.requestPolicy))(r)),c=i(t.map(_)(t.merge([d,v]))),m=t.map((e=>{var r=new Set,t=b(e,r);return k(e.operation,r,!1),t}))(t.filter((e=>!o.has(e.operation.key)))(c)),g=t.mergeMap((e=>{if(s.push(e)<o.size)return t.empty;for(var r=0;r<s.length;r++)ee(n.data,s[r].operation.key);u.clear();for(var i,a=[],l=new Set;i=s.shift();)a.push(b(i,l));return k(e.operation,l,!1),t.fromArray(a)}))(t.filter((e=>o.has(e.operation.key)))(c));return t.merge([m,g,y])}},Ae={"cache-only":0,"cache-first":1,"network-only":2,"cache-and-network":3};exports.Store=Ke,exports.cacheExchange=Ee,exports.offlineExchange=r=>i=>{var{storage:a}=r,n=r.isOfflineError||(e=>e&&e.networkError&&!e.response&&("undefined"!=typeof navigator&&!1===navigator.onLine||/request failed|failed to fetch|network\s?error/i.test(e.networkError.message)));if(a&&a.onOnline&&a.readMetadata&&a.writeMetadata){var{forward:o,client:s,dispatchDebug:l}=i,{source:d,next:u}=t.makeSubject(),p=[],v=!1,f=!1,y=()=>{if(v){for(var r=[],t=0;t<p.length;t++){var i=p[t];"mutation"===i.kind&&r.push({query:e.stringifyDocument(i.query),variables:i.variables,extensions:i.extensions})}a.writeMetadata(r)}},c=e=>{for(var r=p.length-1;r>=0;r--)p[r].key===e&&p.splice(r,1)},m=()=>{if(!f){var r=new Set;f=!0;for(var t=0;t<p.length;t++){var i=p[t];if("mutation"===i.kind||!r.has(i.key))if(r.add(i.key),"subscription"!==i.kind){u(e.makeOperation("teardown",i));for(var a="cache-first",n=0;n<p.length;n++){var{requestPolicy:o}=p[n].context;Ae[o]>Ae[a]&&(a=o)}u(Se(i,a))}else u(Se(i,"cache-first"))}f=!1,p.length=0,y()}},h=Ee({...r,storage:{...a,readData(){var r=a.readData();return{async then(t){for(var i=await a.readMetadata(),n=0;i&&n<i.length;n++)p.push(s.createRequestOperation("mutation",e.createRequest(i[n].query,i[n].variables),i[n].extensions));t(await r),a.onOnline(m),v=!0,m()}}}}})({client:s,dispatchDebug:l,forward:e=>t.share(t.filter((e=>!(v&&"mutation"===e.operation.kind&&e.operation.context.optimistic&&n(e.error,e)&&(p.push(e.operation),y(),1))))(o(e)))});return e=>{var r=t.merge([d,t.onPush((e=>{"query"!==e.kind||v?"teardown"===e.kind&&c(e.key):p.push(e)}))(e)]);return t.filter((e=>{if("query"===e.operation.kind){if(n(e.error,e))return u(Se(e.operation,"cache-only")),p.push(e.operation),!1;v||c(e.operation.key)}return!0}))(h(r))}}return Ee(r)(i)};
//# sourceMappingURL=urql-exchange-graphcache.min.js.map
{
"name": "@urql/exchange-graphcache",
"version": "6.4.1",
"version": "6.4.2-canary-969935c6",
"description": "A normalized and configurable cache exchange for urql",

@@ -58,3 +58,3 @@ "sideEffects": false,

"@0no-co/graphql.web": "^1.0.1",
"@urql/core": ">=4.2.0",
"@urql/core": "4.3.0-canary-969935c6",
"wonka": "^6.3.2"

@@ -68,4 +68,4 @@ },

"react-dom": "^17.0.1",
"@urql/core": "4.3.0-canary-969935c6",
"@urql/exchange-execute": "2.2.2",
"@urql/core": "4.2.3",
"@urql/introspection": "1.0.3",

@@ -72,0 +72,0 @@ "urql": "4.0.6"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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