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

@urql/exchange-graphcache

Package Overview
Dependencies
Maintainers
25
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.1.0 to 6.1.1

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=e=>e.name.value,s=e=>e.typeCondition.name.value,o=e=>e.alias?e.alias.value:e.name.value,l=[],d=e=>e.selectionSet?e.selectionSet.selections:l,u=e=>e.typeCondition?e.typeCondition.name.value:null,p=e=>e.kind===r.Kind.FIELD,v=e=>e.kind===r.Kind.INLINE_FRAGMENT,y=(e,t)=>{var i=null;if(e.arguments)for(var a=0,s=e.arguments.length;a<s;a++){var o=e.arguments[a],l=r.valueFromASTUntyped(o.value,t);null!=l&&(i||(i={}),i[n(o)]=l)}return i},f=(e,r)=>{if(r&&e.variableDefinitions){for(var t={},i=0,a=e.variableDefinitions.length;i<a;i++){var s=n(e.variableDefinitions[i].variable);t[s]=r[s]}return t}},c=(e,t)=>{var i={};if(!t)return i;if(e.variableDefinitions)for(var a=0,s=e.variableDefinitions.length;a<s;a++){var o=e.variableDefinitions[a],l=n(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},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)},h=e=>{for(var t={},i=0;i<e.definitions.length;i++){var a=e.definitions[i];a.kind===r.Kind.FRAGMENT_DEFINITION&&(t[n(a)]=a)}return t},g=(e,t)=>{for(var i=0;e.directives&&i<e.directives.length;i++){var a=e.directives[i],s=n(a);if(("include"===s||"skip"===s)&&a.arguments&&a.arguments[0]&&"if"===n(a.arguments[0])){var o=r.valueFromASTUntyped(a.arguments[0].value,t);return"include"===s?!!o:!o}}return!0},k=(e,t)=>{for(var i=0;e.directives&&i<e.directives.length;i++){var a=e.directives[i];if("defer"===n(a)){for(var s=0;a.arguments&&s<a.arguments.length;s++){var o=a.arguments[i];if("if"===n(o))return!!r.valueFromASTUntyped(o.value,t)}return!0}}return!1},_=(e,r,t)=>{var i=w(e,r,t);return!!i&&"NON_NULL"!==i.type.kind},O=(e,r,t)=>{var i=w(e,r,t);if(!i)return!1;var a="NON_NULL"===i.type.kind?i.type.ofType:i.type;return"LIST"===a.kind&&"NON_NULL"!==a.ofType.kind},b=(e,r,t)=>{if(!t)return!1;var i=u(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),q(e,t),e.isSubType(i,t)))},w=(e,r,t)=>{if(0!==t.indexOf("__")&&0!==r.indexOf("__"))return q(e,r),e.types.get(r).fields()[t]};function q(e,r){a(e.types.has(r)&&"OBJECT"===e.types.get(r).kind,"",3)}var N=(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=()=>Object.create(null),A=null,M=null,T=null,D=null,F=null,I=null,C=!1,L=!1;function $(e,r){var t;if(e){if(A.has(e))return e;t=M.get(e)}return null==t&&(t=r?[]:{}),e&&M.set(e,t),A.add(t),t}var R=e=>!!e&&A.has(e),j=(e,r,t,i,a)=>{A=new WeakSet,M=new WeakMap,F=e,T=r,I=new Set,L=!!i,C=!!a,t?"read"===F?D=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)):re(r,t),D=t,te(r,t)):(D=null,ae(r,t)):D=null},P=()=>{var e=T,r=D;if(L=!1,D=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]);)ne(e.optimisticOrder[t]);A=null,M=null,F=null,T=null,I=null,e.defer||!e.storage&&e.optimisticOrder.length||(e.defer=!0,setTimeout((()=>{j("read",e,null),z(),oe(),P(),e.defer=!1})))},U=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),j("write",e,r,t),P()},J=(e,r,t,i)=>{var a=D?e.optimistic.get(D):e.base,n=a.get(r);void 0===n&&a.set(r,n=E()),void 0!==i||D?n[t]=i:delete n[t]},Q=(e,r,t)=>{for(var i,a=!L&&"read"===F&&D&&T.commutativeKeys.has(D),n=0,s=T.optimisticOrder.length;n<s;n++){var o=T.optimisticOrder[n],l=e.optimistic.get(o);if(a=a&&o!==D,l&&(!a||!T.commutativeKeys.has(o))&&(!L||"write"===F||T.commutativeKeys.has(o))&&void 0!==(i=l.get(r))&&t in i)return i[t]}return void 0!==(i=e.base.get(r))?i[t]:void 0},B=(e,r)=>{if(Array.isArray(e))for(var t=0,i=e.length;t<i;t++)B(e[t],r);else"string"==typeof e&&((e,r)=>{var t=T.refCount.get(e)||0,i=t+r>0?t+r:0;T.refCount.set(e,i),i?!t&&i&&T.gc.delete(e):T.gc.add(e)})(e,r)},V=(e,r,t)=>{if(void 0!==t)for(var i in t)r.has(i)||(e.push(K(i)),r.add(i))},G=(e,r,t,i)=>{V(e,r,i.base.get(t));for(var a=0,n=T.optimisticOrder.length;a<n;a++){var s=i.optimistic.get(T.optimisticOrder[a]);void 0!==s&&V(e,r,s.get(t))}},z=()=>{if(!T.optimisticOrder.length)for(var e of T.gc.keys())if(T.gc.delete(e),!((T.refCount.get(e)||0)>0)){T.refCount.delete(e),T.records.base.delete(e);var r=T.links.base.get(e);if(r)for(var t in T.links.base.delete(e),r)B(r[t],-1)}},W=(e,r)=>{"__typename"!==r&&(e!==T.queryRootKey?I.add(e):void 0!==r&&I.add(x(e,r)))},X=(e,r)=>{!L&&T.storage&&T.persist.add(((e,r)=>`${e.replace(/\./g,"%2e")}.${r}`)(e,r))},H=(e,r)=>(W(e,r),Q(T.records,e,r)),Y=(e,r)=>(W(e,r),Q(T.links,e,r)),Z=(e,r,t)=>{W(e,r),X(e,r),J(T.records,e,r,t)},ee=(e,r,t)=>{var i=D?T.links.optimistic.get(D):T.links.base;if(!D){var a=i&&i.get(e);B(a&&a[r],-1),B(t,1)}W(e,r),X(e,r),J(T.links,e,r,t)},re=(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)&&ie(e,r),i=0;e.optimisticOrder.splice(i,0,r),e.commutativeKeys.add(r)},te=(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))},ie=(e,r)=>{e.dirtyKeys.has(r)&&(e.dirtyKeys.delete(r),e.records.optimistic.delete(r),e.links.optimistic.delete(r),e.deferredKeys.delete(r))},ae=(e,r)=>{var t=e.optimisticOrder.indexOf(r);t>-1&&(e.optimisticOrder.splice(t,1),e.commutativeKeys.delete(r)),ie(e,r)},ne=e=>{var r=I;I=new Set,F="write";var t=T.links.optimistic.get(e);if(t)for(var i of t.entries()){var a=i[0],n=i[1];for(var s in n)ee(a,s,n[s])}var o=T.records.optimistic.get(e);if(o)for(var l of o.entries()){var d=l[0],u=l[1];for(var p in u)Z(d,p,u[p])}I=r,ae(T,e)},se=e=>{var{links:r,records:t}=T,i=[],a=new Set;return W(e),G(i,a,e,r),G(i,a,e,t),i},oe=()=>{if(T.storage){L=!0,F="read";var r=E();for(var t of T.persist.keys()){var{entityKey:i,fieldKey:a}=S(t),n=void 0;r[t]=void 0!==(n=Y(i,a))?`:${e.stringifyVariables(n)}`:void 0!==(n=H(i,a))?e.stringifyVariables(n):void 0}L=!1,T.storage.writeData(r),T.persist.clear()}},le=null,de=!1,ue=e=>e.__internal.path.length>0&&e.__internal.errorMap?e.__internal.errorMap[e.__internal.path.join(".")]:void 0,pe=(e,r,t,i,a,n)=>{var s={store:e,variables:r,fragments:t,parent:{__typename:i},parentTypeName:i,parentKey:a,parentFieldKey:"",fieldName:"",error:void 0,partial:!1,hasNext:!1,optimistic:L,__internal:{path:[],errorMap:void 0}};if(n&&n.graphQLErrors)for(var o=0;o<n.graphQLErrors.length;o++){var l=n.graphQLErrors[o];l.path&&l.path.length&&(s.__internal.errorMap||(s.__internal.errorMap=Object.create(null)),s.__internal.errorMap[l.path.join(".")]=l)}return s},ve=(e,r,t,i,a,n)=>{le=e,e.parent=r,e.parentTypeName=t,e.parentKey=i,e.parentFieldKey=a,e.fieldName=n,e.error=ue(e)},ye=(e,r,t,i)=>{if(!r)return!1;var a=u(e);return!a||r===a||"write"===F||!d(e).some((e=>{if(!p(e))return!1;var r=N(n(e),y(e,i));return!((e,r)=>void 0!==H(e,r)||void 0!==Y(e,r))(t,r)}))},fe=(e,r,t,i,a)=>{var s,o=0;return function(){for(var l;s||o<i.length;)if(l=void 0,de=t,s){if(l=s())return l;s=void 0}else{var u=i[o++];if(g(u,a.variables)){if(p(u))return u;var y=v(u)?u:a.fragments[n(u)];y&&(!y.typeCondition||(a.store.schema?b(a.store.schema,y,e):ye(y,e,r,a.variables)))&&(s=fe(e,r,t||k(u,a.variables),d(y),a))}}}},ce=e=>null==e?null:e,me=(e,r)=>{if(null==r)return r;if(Array.isArray(r)){for(var t=new Array(r.length),i=0,a=t.length;i<a;i++)t[i]=me(e,r[i]);return t}return e.keyOfEntity(r)},he=(e,r,t,i)=>{var a=m(r.query),n=e.rootFields[a.operation],s=d(a),o=pe(e,c(a,r.variables),h(r.query),n,n,i),l=n!==o.store.rootFields.query?ge(o,n,s,t||$()):_e(o,n,s,t||$());return{dependencies:I,partial:o.partial||!l,hasNext:o.hasNext,data:l||null}},ge=(e,r,t,i)=>{if("string"!=typeof(e.store.rootNames[r]?r:i.__typename))return i;for(var a,n=fe(r,r,de,t,e),s=C,l=$(i);a=n();){var u,p=o(a),v=i[p];e.__internal.path.push(p),u=a.selectionSet&&null!==v?ke(e,d(a),ce(v)):v,s=s||u!==v,void 0!==u&&(l[p]=u),e.__internal.path.pop()}return s?l:i},ke=(e,r,t)=>{if(Array.isArray(t)){for(var i=new Array(t.length),a=C,n=0,s=t.length;n<s;n++)e.__internal.path.push(n),i[n]=ke(e,r,t[n]),a=a||i[n]!==t[n],e.__internal.path.pop();return a?i:t}if(null===t)return null;var o=e.store.keyOfEntity(t);return null!==o?_e(e,o,r,t)||null:ge(e,t.__typename,r,t)},_e=(e,r,t,i,a)=>{var{store:s}=e,l=r===s.rootFields.query,u=a&&s.keyOfEntity(a)||r,p=l?r:H(u,"__typename")||a&&a.__typename;if("string"==typeof p&&(!a||p===a.__typename)){for(var v,f=s.resolvers[p],c=fe(p,u,de,t,e),m=!1,h=!1,g=!1,k=C,O=$(i);void 0!==(v=c());){var b=n(v),w=y(v,e.variables),q=o(v),K=N(b,w),S=x(u,K),E=H(u,K),A=a?a[b]:void 0;e.__internal.path.push(q);var M=void 0;if("__typename"===b)M=p;else if(void 0!==A&&void 0===v.selectionSet)M=A;else if("read"===F&&f&&f[b]){if(ve(e,O,p,u,S,b),void 0!==E&&(O[q]=E),M=f[b](O,w||{},s,e),v.selectionSet&&(M=Oe(e,p,b,S,d(v),void 0!==O[q]?O[q]:i[q],M,R(i))),s.schema&&null===M&&!_(s.schema,p,b))return}else if(v.selectionSet)if(void 0!==A)M=Oe(e,p,b,S,d(v),void 0!==O[q]?O[q]:i[q],A,R(i));else{var T=Y(u,K);void 0!==T?M=be(e,T,p,b,d(v),void 0!==O[q]?O[q]:i[q],R(i)):"object"==typeof E&&null!==E&&(M=E)}else M=E;if(void 0===M&&de)g=!0;else if(void 0===M&&(s.schema&&_(s.schema,p,b)||ue(e)))h=!0,M=null;else{if(void 0===M)return void e.__internal.path.pop();m=m||"__typename"!==b}e.__internal.path.pop(),k=k||M!==i[q],void 0!==M&&(O[q]=M)}return e.partial=e.partial||h,e.hasNext=e.hasNext||g,l&&h&&!m?void 0:k?O:i}},Oe=(e,r,t,i,a,n,s,o)=>{if(Array.isArray(s)){for(var{store:l}=e,d=!!l.schema&&O(l.schema,r,t),u=$(n,!0),p=C||!Array.isArray(n)||s.length!==n.length,v=0,y=s.length;v<y;v++){e.__internal.path.push(v);var f=Oe(e,r,t,x(i,`${v}`),a,null!=n?n[v]:void 0,s[v],o);if(e.__internal.path.pop(),void 0===f&&!d)return;e.partial=e.partial||void 0===f&&d,u[v]=null!=f?f:null,p=p||u[v]!==n[v]}return p?u:n}if(null==s)return s;if(!o&&null===n)return null;if(we(s)){var c=n||$(n);return"string"==typeof s?_e(e,s,a,c):_e(e,i,a,c,s)}},be=(e,r,t,i,a,n,s)=>{if(Array.isArray(r)){for(var{store:o}=e,l=!!o.schema&&O(o.schema,t,i),d=$(n,!0),u=C||!Array.isArray(n)||r.length!==n.length,p=0,v=r.length;p<v;p++){e.__internal.path.push(p);var y=be(e,r[p],t,i,a,null!=n?n[p]:void 0,s);if(e.__internal.path.pop(),void 0===y&&!l)return;e.partial=e.partial||void 0===y&&l,d[p]=y||null,u=u||d[p]!==n[p]}return u?d:n}return null===r||null===n&&s?null:_e(e,r,a,n||$(n))},we=e=>"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename,qe=(e,r,t,i)=>{var a=m(r.query),n={data:t||$(),dependencies:I},s=e.rootFields[a.operation],o=pe(e,c(a,r.variables),h(r.query),s,s,i);return Ne(o,s,d(a),n.data),n},Ne=(e,r,t,i)=>{var a=e.store.rootNames[r]||"query",s=!!e.store.rootNames[r],l=s?r:i.__typename;if(l){!s&&r&&Z(r,"__typename",l);for(var u,p=e.store.updates[l],v=fe(l,r||l,de,t,e);u=v();){var f=n(u),c=y(u,e.variables),m=N(f,c),h=o(u),g=i[e.optimistic?f:h];if(!("__typename"===f||void 0===g&&(de||e.optimistic&&"query"===a))){e.__internal.path.push(h);var k=void 0;if(e.optimistic&&"mutation"===a){if(!(k=e.store.optimisticMutations[f]))continue}else e.optimistic&&"function"==typeof g&&(k=g);if(k&&(ve(e,i,l,l,m,f),g=ce(k(c||{},e.store,e))),u.selectionSet)if(r&&"query"===a){var _=x(r,m),O=xe(e,d(u),ce(g),_);ee(r||l,m,O)}else xe(e,d(u),ce(g));else r&&"query"===a&&Z(r||l,m,null===g&&ue(e)?void 0:g);var b=p&&p[f];b&&(ve(e,i,l,l,x(l,m),f),i[f]=g,b(i,c||{},e.store,e)),e.__internal.path.pop()}}}},xe=(e,r,t,i)=>{if(Array.isArray(t)){for(var a=new Array(t.length),n=0,s=t.length;n<s;n++){e.__internal.path.push(n);var o=i?x(i,`${n}`):void 0,l=xe(e,r,t[n],o);a[n]=l,e.__internal.path.pop()}return a}if(null===t)return ue(e)?void 0:null;var d=e.store.keyOfEntity(t)||i;return Ne(e,d,r,t),d||null};class Ke{constructor(e){e||(e={}),this.resolvers=e.resolvers||{},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 s=e.types[n];if(s&&s.name){var o=i(s);o&&r.set(s.name,o)}}}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=N;keyOfEntity(e){if(le&&e===le.parent)return le.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=N(r,t),a=this.keyOfEntity(e);if(!a)return null;var n=H(a,i);return void 0!==n?n:Y(a,i)||null}resolveFieldByKey=this.resolve;invalidate(e,r,t){var i=this.keyOfEntity(e);a(i,"",19),((e,r,t)=>{for(var i=r?[{fieldKey:N(r,t)}]:se(e),a=0,n=i.length;a<n;a++){var{fieldKey:s}=i[a];void 0!==Y(e,s)?ee(e,s,void 0):Z(e,s,void 0)}})(i,r,t)}inspectFields(e){var r=this.keyOfEntity(e);return r?se(r):[]}updateQuery(r,t){var i=e.createRequest(r.query,r.variables);i.query=e.formatDocument(i.query);var a=t(this.readQuery(i));null!==a&&qe(this,i,a,void 0)}readQuery(r){var t=e.createRequest(r.query,r.variables);return t.query=e.formatDocument(t.query),he(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 l=s(n);"string"==typeof t||t.__typename||(t.__typename=l);var u=e.keyOfEntity(t);if(!u)return null;var p=pe(e,i||{},o,l,u,void 0);return _e(p,u,d(n),$())||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 l=s(n),u={__typename:l,...t},p=e.keyOfEntity(u);if(p){var v=pe(e,i||{},o,l,p,void 0);Ne(v,p,d(n),u)}})(this,e.formatDocument(r),t,i,a)}link(e,r,t,i){var a=void 0!==i?t:null,n=void 0!==i?i:t,s=me(this,e);"string"==typeof s&&ee(s,N(r,a),me(this,n))}}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 j("write",e,null),t){var a=t[i];if(void 0!==a){var{entityKey:n,fieldKey:s}=S(i);":"===a[0]?void 0===Y(n,s)&&ee(n,s,JSON.parse(a.slice(1))):void 0===H(n,s)&&Z(n,s,JSON.parse(a))}}e.storage=r,e.hydrating=!1,P()})(n.data,r.storage,e)})));var s=new Map,o=[],l=new Map,d=new Map,u=new Set,p=new Set,v=new Map,y=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)=>{for(var t of r.values())if(t!==e.key){var i=l.get(t);if(i){"query"===e.kind&&c.add(t);var n="cache-first";p.has(t)&&(p.delete(t),n="cache-and-network"),a.reexecuteOperation(Se(i,n))}}var s=y;"query"===e.kind&&(y=c).add(e.key),(c=s).clear()},_=r=>{if("query"===r.kind)re(n.data,r.key),l.set(r.key,r);else if("teardown"===r.kind)l.delete(r.key),d.delete(r.key),y.delete(r.key),U(n.data,r.key);else if("mutation"===r.kind&&"network-only"!==r.context.requestPolicy){l.set(r.key,r),j("write",n.data,r.key,!0,!1);var{dependencies:t}=qe(n,r,void 0,void 0);if(P(),t.size){for(var i of t.values())u.add(i);s.set(r.key,t);var a=new Set;g(a,t),k(r,a)}}return e.makeOperation(r.kind,{key:r.key,query:e.formatDocument(r.query),variables:r.variables?f(m(r.query),r.variables):r.variables},r.context)},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)}},b=e=>{j("read",n.data,void 0,!1,!1);var r=he(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}},w=(e,r)=>{var t,i=l.get(e.operation.key)||e.operation;if("mutation"===i.kind){var a=s.get(i.key);g(r,a),s.delete(i.key)}("subscription"===i.kind||e.hasNext)&&re(n.data,i.key,!0);var o=e.data;if(o){j("write",n.data,i.key,!1,!1);var u=qe(n,i,o,e.error).dependencies;P(),g(r,u);var p="query"===i.kind?d.get(i.key):null;j("read",n.data,i.key,!1,p!==o);var v=he(n,i,p||o,e.error);P(),o=v.data,"query"===i.kind&&(g(r,t=v.dependencies),d.set(i.key,o))}else U(n.data,i.key);return t&&O(e.operation,t),{operation:i,data:o,error:e.error,extensions:e.extensions,hasNext:e.hasNext,stale:e.stale}};return e=>{var r=t.share(t.map(b)(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)&&!y.has(e.operation.key)))(r)),f=t.map((e=>{var{requestPolicy:r}=e.operation.context,t="cache-only"!==r&&(e.hasNext||"cache-and-network"===r||"cache-first"===r&&"partial"===e.outcome&&!y.has(e.operation.key)),i={operation:e.operation,data:e.data,error:e.error,extensions:e.extensions,stale:t&&!e.hasNext,hasNext:t&&e.hasNext};return t&&(h(e.dependencies)?"cache-and-network"===r&&p.add(e.operation.key):a.reexecuteOperation(Se(l.get(e.operation.key)||e.operation,"network-only"))),i}))(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=w(e,r);return k(e.operation,r),t}))(t.filter((e=>!s.has(e.operation.key)))(c)),g=t.mergeMap((e=>{if(o.push(e)<s.size)return t.empty;for(var r=0;r<o.length;r++)re(n.data,o[r].operation.key);u.clear();for(var i,a=[],l=new Set;i=o.shift();)a.push(w(i,l));return k(e.operation,l),t.fromArray(a)}))(t.filter((e=>s.has(e.operation.key)))(c));return t.merge([m,g,f])}};exports.Store=Ke,exports.cacheExchange=Ee,exports.offlineExchange=r=>i=>{var{storage:a}=r,s=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:l,dispatchDebug:u}=i,{source:y,next:f}=t.makeSubject(),c=r.optimistic||{},k=[],_=!1,O=!1,b=()=>{if(_){for(var r=[],t=0;t<k.length;t++){var i=k[t];"mutation"===i.kind&&r.push({query:e.stringifyDocument(i.query),variables:i.variables,extensions:i.extensions})}a.writeMetadata(r)}},w=()=>{if(!O){O=!0;for(var r=new Set,t=0;t<k.length;t++){var i=k[t];"mutation"!==i.kind&&r.has(i.key)||("subscription"!==i.kind&&f(e.makeOperation("teardown",i)),r.add(i.key),f(Se(i,"cache-first")))}k.length=0,O=!1,b()}},q=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++)k.push(l.createRequestOperation("mutation",e.createRequest(i[n].query,i[n].variables),i[n].extensions));t(await r),a.onOnline(w),_=!0,w()}}}}})({client:l,dispatchDebug:u,forward:e=>t.share(t.filter((e=>!(_&&"mutation"===e.operation.kind&&s(e.error,e)&&((e,r)=>{for(var t,i=r.variables||{},a=h(r.query),s=[...d(m(r.query))];t=s.pop();)if(g(t,i))if(p(t)){if(e[n(t)])return!0}else{var o=v(t)?t:a[n(t)];o&&s.push(...d(o))}return!1})(c,e.operation)&&(k.push(e.operation),b(),1))))(o(e)))});return e=>{var r=t.merge([y,t.onPush((e=>{"query"!==e.kind||_||k.push(e)}))(e)]);return t.filter((e=>"query"!==e.operation.kind||!s(e.error,e)||(f(Se(e.operation,"cache-only")),k.push(e.operation),!1)))(q(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=e=>e.name.value,s=e=>e.typeCondition.name.value,o=e=>e.alias?e.alias.value:e.name.value,l=[],d=e=>e.selectionSet?e.selectionSet.selections:l,u=e=>e.typeCondition?e.typeCondition.name.value:null,p=e=>e.kind===r.Kind.FIELD,v=e=>e.kind===r.Kind.INLINE_FRAGMENT,y=(e,t)=>{var i=null;if(e.arguments)for(var a=0,s=e.arguments.length;a<s;a++){var o=e.arguments[a],l=r.valueFromASTUntyped(o.value,t);null!=l&&(i||(i={}),i[n(o)]=l)}return i},f=(e,r)=>{if(r&&e.variableDefinitions){for(var t={},i=0,a=e.variableDefinitions.length;i<a;i++){var s=n(e.variableDefinitions[i].variable);t[s]=r[s]}return t}},c=(e,t)=>{var i={};if(!t)return i;if(e.variableDefinitions)for(var a=0,s=e.variableDefinitions.length;a<s;a++){var o=e.variableDefinitions[a],l=n(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},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)},h=e=>{for(var t={},i=0;i<e.definitions.length;i++){var a=e.definitions[i];a.kind===r.Kind.FRAGMENT_DEFINITION&&(t[n(a)]=a)}return t},g=(e,t)=>{for(var i=0;e.directives&&i<e.directives.length;i++){var a=e.directives[i],s=n(a);if(("include"===s||"skip"===s)&&a.arguments&&a.arguments[0]&&"if"===n(a.arguments[0])){var o=r.valueFromASTUntyped(a.arguments[0].value,t);return"include"===s?!!o:!o}}return!0},k=(e,t)=>{for(var i=0;e.directives&&i<e.directives.length;i++){var a=e.directives[i];if("defer"===n(a)){for(var s=0;a.arguments&&s<a.arguments.length;s++){var o=a.arguments[i];if("if"===n(o))return!!r.valueFromASTUntyped(o.value,t)}return!0}}return!1},_=(e,r,t)=>{var i=b(e,r,t);return!!i&&"NON_NULL"!==i.type.kind},O=(e,r,t)=>{var i=b(e,r,t);if(!i)return!1;var a="NON_NULL"===i.type.kind?i.type.ofType:i.type;return"LIST"===a.kind&&"NON_NULL"!==a.ofType.kind},w=(e,r,t)=>{if(!t)return!1;var i=u(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),q(e,t),e.isSubType(i,t)))},b=(e,r,t)=>{if(0!==t.indexOf("__")&&0!==r.indexOf("__"))return q(e,r),e.types.get(r).fields()[t]};function q(e,r){a(e.types.has(r)&&"OBJECT"===e.types.get(r).kind,"",3)}var N=(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=()=>Object.create(null),A=null,M=null,T=null,D=null,F=null,I=null,C=!1,L=!1;function $(e,r){var t;if(e){if(A.has(e))return e;t=M.get(e)}return null==t&&(t=r?[]:{}),e&&M.set(e,t),A.add(t),t}var R=e=>!!e&&A.has(e),j=(e,r,t,i,a)=>{A=new WeakSet,M=new WeakMap,F=e,T=r,I=new Set,L=!!i,C=!!a,t?"read"===F?D=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)):re(r,t),D=t,te(r,t)):(D=null,ae(r,t)):D=null},P=()=>{var e=T,r=D;if(L=!1,D=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]);)ne(e.optimisticOrder[t]);A=null,M=null,F=null,T=null,I=null,e.defer||!e.storage&&e.optimisticOrder.length||(e.defer=!0,setTimeout((()=>{j("read",e,null),z(),oe(),P(),e.defer=!1})))},U=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),j("write",e,r,t),P()},J=(e,r,t,i)=>{var a=D?e.optimistic.get(D):e.base,n=a.get(r);void 0===n&&a.set(r,n=E()),void 0!==i||D?n[t]=i:delete n[t]},Q=(e,r,t)=>{for(var i,a=!L&&"read"===F&&D&&T.commutativeKeys.has(D),n=0,s=T.optimisticOrder.length;n<s;n++){var o=T.optimisticOrder[n],l=e.optimistic.get(o);if(a=a&&o!==D,l&&(!a||!T.commutativeKeys.has(o))&&(!L||"write"===F||T.commutativeKeys.has(o))&&void 0!==(i=l.get(r))&&t in i)return i[t]}return void 0!==(i=e.base.get(r))?i[t]:void 0},B=(e,r)=>{if(Array.isArray(e))for(var t=0,i=e.length;t<i;t++)B(e[t],r);else"string"==typeof e&&((e,r)=>{var t=T.refCount.get(e)||0,i=t+r>0?t+r:0;T.refCount.set(e,i),i?!t&&i&&T.gc.delete(e):T.gc.add(e)})(e,r)},V=(e,r,t)=>{if(void 0!==t)for(var i in t)r.has(i)||(e.push(K(i)),r.add(i))},G=(e,r,t,i)=>{V(e,r,i.base.get(t));for(var a=0,n=T.optimisticOrder.length;a<n;a++){var s=i.optimistic.get(T.optimisticOrder[a]);void 0!==s&&V(e,r,s.get(t))}},z=()=>{if(!T.optimisticOrder.length)for(var e of T.gc.keys())if(T.gc.delete(e),!((T.refCount.get(e)||0)>0)){T.refCount.delete(e),T.records.base.delete(e);var r=T.links.base.get(e);if(r)for(var t in T.links.base.delete(e),r)B(r[t],-1)}},W=(e,r)=>{"__typename"!==r&&(e!==T.queryRootKey?I.add(e):void 0!==r&&I.add(x(e,r)))},X=(e,r)=>{!L&&T.storage&&T.persist.add(((e,r)=>`${e.replace(/\./g,"%2e")}.${r}`)(e,r))},H=(e,r)=>(W(e,r),Q(T.records,e,r)),Y=(e,r)=>(W(e,r),Q(T.links,e,r)),Z=(e,r,t)=>{W(e,r),X(e,r),J(T.records,e,r,t)},ee=(e,r,t)=>{var i=D?T.links.optimistic.get(D):T.links.base;if(!D){var a=i&&i.get(e);B(a&&a[r],-1),B(t,1)}W(e,r),X(e,r),J(T.links,e,r,t)},re=(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)&&ie(e,r),i=0;e.optimisticOrder.splice(i,0,r),e.commutativeKeys.add(r)},te=(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))},ie=(e,r)=>{e.dirtyKeys.has(r)&&(e.dirtyKeys.delete(r),e.records.optimistic.delete(r),e.links.optimistic.delete(r),e.deferredKeys.delete(r))},ae=(e,r)=>{var t=e.optimisticOrder.indexOf(r);t>-1&&(e.optimisticOrder.splice(t,1),e.commutativeKeys.delete(r)),ie(e,r)},ne=e=>{var r=I;I=new Set,F="write";var t=T.links.optimistic.get(e);if(t)for(var i of t.entries()){var a=i[0],n=i[1];for(var s in n)ee(a,s,n[s])}var o=T.records.optimistic.get(e);if(o)for(var l of o.entries()){var d=l[0],u=l[1];for(var p in u)Z(d,p,u[p])}I=r,ae(T,e)},se=e=>{var{links:r,records:t}=T,i=[],a=new Set;return W(e),G(i,a,e,r),G(i,a,e,t),i},oe=()=>{if(T.storage){L=!0,F="read";var r=E();for(var t of T.persist.keys()){var{entityKey:i,fieldKey:a}=S(t),n=void 0;r[t]=void 0!==(n=Y(i,a))?`:${e.stringifyVariables(n)}`:void 0!==(n=H(i,a))?e.stringifyVariables(n):void 0}L=!1,T.storage.writeData(r),T.persist.clear()}},le=null,de=!1,ue=e=>e.__internal.path.length>0&&e.__internal.errorMap?e.__internal.errorMap[e.__internal.path.join(".")]:void 0,pe=(e,r,t,i,a,n)=>{var s={store:e,variables:r,fragments:t,parent:{__typename:i},parentTypeName:i,parentKey:a,parentFieldKey:"",fieldName:"",error:void 0,partial:!1,hasNext:!1,optimistic:L,__internal:{path:[],errorMap:void 0}};if(n&&n.graphQLErrors)for(var o=0;o<n.graphQLErrors.length;o++){var l=n.graphQLErrors[o];l.path&&l.path.length&&(s.__internal.errorMap||(s.__internal.errorMap=Object.create(null)),s.__internal.errorMap[l.path.join(".")]=l)}return s},ve=(e,r,t,i,a,n)=>{le=e,e.parent=r,e.parentTypeName=t,e.parentKey=i,e.parentFieldKey=a,e.fieldName=n,e.error=ue(e)},ye=(e,r,t,i)=>{if(!r)return!1;var a=u(e);return!a||r===a||"write"===F||!d(e).some((e=>{if(!p(e))return!1;var r=N(n(e),y(e,i));return!((e,r)=>void 0!==H(e,r)||void 0!==Y(e,r))(t,r)}))},fe=(e,r,t,i,a)=>{var s,o=0;return function(){for(var l;s||o<i.length;)if(l=void 0,de=t,s){if(l=s())return l;s=void 0}else{var u=i[o++];if(g(u,a.variables)){if(p(u))return u;var y=v(u)?u:a.fragments[n(u)];y&&(!y.typeCondition||(a.store.schema?w(a.store.schema,y,e):ye(y,e,r,a.variables)))&&(s=fe(e,r,t||k(u,a.variables),d(y),a))}}}},ce=e=>null==e?null:e,me=(e,r)=>{if(null==r)return r;if(Array.isArray(r)){for(var t=new Array(r.length),i=0,a=t.length;i<a;i++)t[i]=me(e,r[i]);return t}return e.keyOfEntity(r)},he=(e,r,t,i)=>{var a=m(r.query),n=e.rootFields[a.operation],s=d(a),o=pe(e,c(a,r.variables),h(r.query),n,n,i),l=n!==o.store.rootFields.query?ge(o,n,s,t||$()):_e(o,n,s,t||$());return{dependencies:I,partial:o.partial||!l,hasNext:o.hasNext,data:l||null}},ge=(e,r,t,i)=>{if("string"!=typeof(e.store.rootNames[r]?r:i.__typename))return i;for(var a,n=fe(r,r,de,t,e),s=C,l=$(i);a=n();){var u,p=o(a),v=i[p];e.__internal.path.push(p),u=a.selectionSet&&null!==v?ke(e,d(a),ce(v)):v,s=s||u!==v,void 0!==u&&(l[p]=u),e.__internal.path.pop()}return s?l:i},ke=(e,r,t)=>{if(Array.isArray(t)){for(var i=new Array(t.length),a=C,n=0,s=t.length;n<s;n++)e.__internal.path.push(n),i[n]=ke(e,r,t[n]),a=a||i[n]!==t[n],e.__internal.path.pop();return a?i:t}if(null===t)return null;var o=e.store.keyOfEntity(t);return null!==o?_e(e,o,r,t)||null:ge(e,t.__typename,r,t)},_e=(e,r,t,i,a)=>{var{store:s}=e,l=r===s.rootFields.query,u=a&&s.keyOfEntity(a)||r,p=l?r:H(u,"__typename")||a&&a.__typename;if("string"==typeof p&&(!a||p===a.__typename)){for(var v,f=s.resolvers[p],c=fe(p,u,de,t,e),m=!1,h=!1,g=!1,k=C,O=$(i);void 0!==(v=c());){var w=n(v),b=y(v,e.variables),q=o(v),K=N(w,b),S=x(u,K),E=H(u,K),A=a?a[w]:void 0;e.__internal.path.push(q);var M=void 0;if("__typename"===w)M=p;else if(void 0!==A&&void 0===v.selectionSet)M=A;else if("read"===F&&f&&f[w]){if(ve(e,O,p,u,S,w),void 0!==E&&(O[q]=E),M=f[w](O,b||{},s,e),v.selectionSet&&(M=Oe(e,p,w,S,d(v),void 0!==O[q]?O[q]:i[q],M,R(i))),s.schema&&null===M&&!_(s.schema,p,w))return}else if(v.selectionSet)if(void 0!==A)M=Oe(e,p,w,S,d(v),void 0!==O[q]?O[q]:i[q],A,R(i));else{var T=Y(u,K);void 0!==T?M=we(e,T,p,w,d(v),void 0!==O[q]?O[q]:i[q],R(i)):"object"==typeof E&&null!==E&&(M=E)}else M=E;if(void 0===M&&de)g=!0;else if(void 0===M&&(s.schema&&_(s.schema,p,w)||ue(e)))h=!0,M=null;else{if(void 0===M)return void e.__internal.path.pop();m=m||"__typename"!==w}e.__internal.path.pop(),k=k||M!==i[q],void 0!==M&&(O[q]=M)}return e.partial=e.partial||h,e.hasNext=e.hasNext||g,l&&h&&!m?void 0:k?O:i}},Oe=(e,r,t,i,a,n,s,o)=>{if(Array.isArray(s)){for(var{store:l}=e,d=!!l.schema&&O(l.schema,r,t),u=$(n,!0),p=C||!Array.isArray(n)||s.length!==n.length,v=0,y=s.length;v<y;v++){e.__internal.path.push(v);var f=Oe(e,r,t,x(i,`${v}`),a,null!=n?n[v]:void 0,s[v],o);if(e.__internal.path.pop(),void 0===f&&!d)return;e.partial=e.partial||void 0===f&&d,u[v]=null!=f?f:null,p=p||u[v]!==n[v]}return p?u:n}if(null==s)return s;if(!o&&null===n)return null;if(be(s)){var c=n||$(n);return"string"==typeof s?_e(e,s,a,c):_e(e,i,a,c,s)}},we=(e,r,t,i,a,n,s)=>{if(Array.isArray(r)){for(var{store:o}=e,l=!!o.schema&&O(o.schema,t,i),d=$(n,!0),u=C||!Array.isArray(n)||r.length!==n.length,p=0,v=r.length;p<v;p++){e.__internal.path.push(p);var y=we(e,r[p],t,i,a,null!=n?n[p]:void 0,s);if(e.__internal.path.pop(),void 0===y&&!l)return;e.partial=e.partial||void 0===y&&l,d[p]=y||null,u=u||d[p]!==n[p]}return u?d:n}return null===r||null===n&&s?null:_e(e,r,a,n||$(n))},be=e=>"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename,qe=(e,r,t,i)=>{var a=m(r.query),n={data:t||$(),dependencies:I},s=e.rootFields[a.operation],o=pe(e,c(a,r.variables),h(r.query),s,s,i);return Ne(o,s,d(a),n.data),n},Ne=(e,r,t,i)=>{var a=e.store.rootNames[r]||"query",s=!!e.store.rootNames[r],l=s?r:i.__typename;if(l){!s&&r&&Z(r,"__typename",l);for(var u,p=e.store.updates[l],v=fe(l,r||l,de,t,e);u=v();){var f=n(u),c=y(u,e.variables),m=N(f,c),h=o(u),g=i[e.optimistic?f:h];if(!("__typename"===f||void 0===g&&(de||e.optimistic&&"query"===a))){e.__internal.path.push(h);var k=void 0;if(e.optimistic&&"mutation"===a){if(!(k=e.store.optimisticMutations[f]))continue}else e.optimistic&&"function"==typeof g&&(k=g);if(k&&(ve(e,i,l,l,m,f),g=ce(k(c||{},e.store,e))),u.selectionSet)if(r&&"query"===a){var _=x(r,m),O=xe(e,d(u),ce(g),_);ee(r||l,m,O)}else xe(e,d(u),ce(g));else r&&"query"===a&&Z(r||l,m,null===g&&ue(e)?void 0:g);var w=p&&p[f];w&&(ve(e,i,l,l,x(l,m),f),i[f]=g,w(i,c||{},e.store,e)),e.__internal.path.pop()}}}},xe=(e,r,t,i)=>{if(Array.isArray(t)){for(var a=new Array(t.length),n=0,s=t.length;n<s;n++){e.__internal.path.push(n);var o=i?x(i,`${n}`):void 0,l=xe(e,r,t[n],o);a[n]=l,e.__internal.path.pop()}return a}if(null===t)return ue(e)?void 0:null;var d=e.store.keyOfEntity(t)||i;return Ne(e,d,r,t),d||null};class Ke{constructor(e){e||(e={}),this.resolvers=e.resolvers||{},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 s=e.types[n];if(s&&s.name){var o=i(s);o&&r.set(s.name,o)}}}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=N;keyOfEntity(e){if(le&&e===le.parent)return le.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=N(r,t),a=this.keyOfEntity(e);if(!a)return null;var n=H(a,i);return void 0!==n?n:Y(a,i)||null}resolveFieldByKey=this.resolve;invalidate(e,r,t){var i=this.keyOfEntity(e);a(i,"",19),((e,r,t)=>{for(var i=r?[{fieldKey:N(r,t)}]:se(e),a=0,n=i.length;a<n;a++){var{fieldKey:s}=i[a];void 0!==Y(e,s)?ee(e,s,void 0):Z(e,s,void 0)}})(i,r,t)}inspectFields(e){var r=this.keyOfEntity(e);return r?se(r):[]}updateQuery(r,t){var i=e.createRequest(r.query,r.variables);i.query=e.formatDocument(i.query);var a=t(this.readQuery(i));null!==a&&qe(this,i,a,void 0)}readQuery(r){var t=e.createRequest(r.query,r.variables);return t.query=e.formatDocument(t.query),he(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 l=s(n);"string"==typeof t||t.__typename||(t.__typename=l);var u=e.keyOfEntity(t);if(!u)return null;var p=pe(e,i||{},o,l,u,void 0);return _e(p,u,d(n),$())||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 l=s(n),u={__typename:l,...t},p=e.keyOfEntity(u);if(p){var v=pe(e,i||{},o,l,p,void 0);Ne(v,p,d(n),u)}})(this,e.formatDocument(r),t,i,a)}link(e,r,t,i){var a=void 0!==i?t:null,n=void 0!==i?i:t,s=me(this,e);"string"==typeof s&&ee(s,N(r,a),me(this,n))}}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 j("write",e,null),t){var a=t[i];if(void 0!==a){var{entityKey:n,fieldKey:s}=S(i);":"===a[0]?void 0===Y(n,s)&&ee(n,s,JSON.parse(a.slice(1))):void 0===H(n,s)&&Z(n,s,JSON.parse(a))}}e.storage=r,e.hydrating=!1,P()})(n.data,r.storage,e)})));var s=new Map,o=[],l=new Map,d=new Map,u=new Set,p=new Set,v=new Map,y=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)=>{for(var t of r.values())if(t!==e.key){var i=l.get(t);if(i){"query"===e.kind&&c.add(t);var n="cache-first";p.has(t)&&(p.delete(t),n="cache-and-network"),a.reexecuteOperation(Se(i,n))}}var s=y;"query"===e.kind&&(y=c).add(e.key),(c=s).clear()},_=r=>{if("query"===r.kind)re(n.data,r.key),l.set(r.key,r);else if("teardown"===r.kind)l.delete(r.key),d.delete(r.key),y.delete(r.key),U(n.data,r.key);else if("mutation"===r.kind&&"network-only"!==r.context.requestPolicy){l.set(r.key,r),j("write",n.data,r.key,!0,!1);var{dependencies:t}=qe(n,r,void 0,void 0);if(P(),t.size){for(var i of t.values())u.add(i);s.set(r.key,t);var a=new Set;g(a,t),k(r,a)}}return e.makeOperation(r.kind,{key:r.key,query:e.formatDocument(r.query),variables:r.variables?f(m(r.query),r.variables):r.variables},r.context)},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=>{j("read",n.data,void 0,!1,!1);var r=he(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=s.get(i.key);g(r,a),s.delete(i.key)}("subscription"===i.kind||e.hasNext)&&re(n.data,i.key,!0);var o=e.data;if(o){j("write",n.data,i.key,!1,!1);var u=qe(n,i,o,e.error).dependencies;P(),g(r,u);var p="query"===i.kind?d.get(i.key):null;j("read",n.data,i.key,!1,p!==o);var v=he(n,i,p||o,e.error);P(),o=v.data,"query"===i.kind&&(g(r,t=v.dependencies),d.set(i.key,o))}else U(n.data,i.key);return t&&O(e.operation,t),{operation:i,data:o,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)&&!y.has(e.operation.key)))(r)),f=t.map((e=>{var{requestPolicy:r}=e.operation.context,t="cache-only"!==r&&(e.hasNext||"cache-and-network"===r||"cache-first"===r&&"partial"===e.outcome&&!y.has(e.operation.key)),i={operation:e.operation,data:e.data,error:e.error,extensions:e.extensions,stale:t&&!e.hasNext,hasNext:t&&e.hasNext};return t&&(h(e.dependencies)?"cache-and-network"===r&&p.add(e.operation.key):a.reexecuteOperation(Se(l.get(e.operation.key)||e.operation,"network-only"))),i}))(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),t}))(t.filter((e=>!s.has(e.operation.key)))(c)),g=t.mergeMap((e=>{if(o.push(e)<s.size)return t.empty;for(var r=0;r<o.length;r++)re(n.data,o[r].operation.key);u.clear();for(var i,a=[],l=new Set;i=o.shift();)a.push(b(i,l));return k(e.operation,l),t.fromArray(a)}))(t.filter((e=>s.has(e.operation.key)))(c));return t.merge([m,g,f])}};exports.Store=Ke,exports.cacheExchange=Ee,exports.offlineExchange=r=>i=>{var{storage:a}=r,s=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:l,dispatchDebug:u}=i,{source:y,next:f}=t.makeSubject(),c=r.optimistic||{},k=[],_=!1,O=!1,w=()=>{if(_){for(var r=[],t=0;t<k.length;t++){var i=k[t];"mutation"===i.kind&&r.push({query:e.stringifyDocument(i.query),variables:i.variables,extensions:i.extensions})}a.writeMetadata(r)}},b=()=>{if(!O){O=!0;for(var r=new Set,t=0;t<k.length;t++){var i=k[t];"mutation"!==i.kind&&r.has(i.key)||("subscription"!==i.kind&&f(e.makeOperation("teardown",i)),r.add(i.key),f(Se(i,"cache-first")))}k.length=0,O=!1,w()}},q=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++)k.push(l.createRequestOperation("mutation",e.createRequest(i[n].query,i[n].variables),i[n].extensions));t(await r),a.onOnline(b),_=!0,b()}}}}})({client:l,dispatchDebug:u,forward:e=>t.share(t.filter((e=>!(_&&"mutation"===e.operation.kind&&s(e.error,e)&&((e,r)=>{for(var t,i=r.variables||{},a=h(r.query),s=[...d(m(r.query))];t=s.pop();)if(g(t,i))if(p(t)){if(e[n(t)])return!0}else{var o=v(t)?t:a[n(t)];o&&s.push(...d(o))}return!1})(c,e.operation)&&(k.push(e.operation),w(),1))))(o(e)))});return e=>{var r=t.merge([y,t.onPush((e=>{if("query"!==e.kind||_){if("teardown"===e.kind)for(var r=k.length-1;r>=0;r--)k[r].key===e.key&&k.splice(r,1)}else k.push(e)}))(e)]);return t.filter((e=>"query"!==e.operation.kind||!s(e.error,e)||(f(Se(e.operation,"cache-only")),k.push(e.operation),!1)))(q(r))}}return Ee(r)(i)};
//# sourceMappingURL=urql-exchange-graphcache.min.js.map
{
"name": "@urql/exchange-graphcache",
"version": "6.1.0",
"version": "6.1.1",
"description": "A normalized and configurable cache exchange for urql",

@@ -5,0 +5,0 @@ "sideEffects": false,

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