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 7.0.1 to 7.0.2-canary-b73de94f

2

dist/urql-exchange-graphcache-chunk.d.ts
import { FormattedNode, ErrorLike, DocumentInput, TypedDocumentNode, AnyVariables, RequestExtensions } from '@urql/core';
import { FragmentDefinitionNode, DocumentNode } from '@0no-co/graphql.web';
/*!@ts-ignore*/
/*@ts-ignore*/
import * as GraphQL from 'graphql';

@@ -5,0 +5,0 @@

@@ -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,y=(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},f=(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=>{var{optional:r,required:t}=o(e);return!t&&(!!r||void 0)},O=(e,r,t,i)=>{var a=N(e,r,t,i);return!!a&&"NON_NULL"!==a.type.kind},w=(e,r,t,i)=>{var a=N(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},b=(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),q(e,t),e.isSubType(i,t)))},N=(e,r,t,i)=>{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 x=(r,t)=>t?`${r}(${e.stringifyVariables(t)})`:r,K=(e,r)=>`${e}.${r}`,S=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}},E=e=>{var r=e.indexOf(".");return{entityKey:e.slice(0,r).replace(/%2e/g,"."),fieldKey:e.slice(r+1)}},M=null,T=null,A=null,D=null,C=null,F=null,I=!1,L=!1;function $(e,r){var t;if(e){if(M.has(e))return e;t=T.get(e)}return null==t&&(t=r?[]:{}),e&&T.set(e,t),M.add(t),t}var R=e=>!!e&&M.has(e),j=(e,r,t,i,a)=>{M=new WeakSet,T=new WeakMap,C=e,A=r,F=new Set,L=!!i,I=!!a,t?"read"===C?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)):ae(r,t),D=t,ne(r,t)):(D=null,se(r,t)):D=null},P=()=>{var e=A,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]);)le(e.optimisticOrder[t]);M=null,T=null,C=null,A=null,F=null,e.defer||!e.storage&&e.optimisticOrder.length||(e.defer=!0,setTimeout((()=>{j("read",e,null),W(),ue(),P(),e.defer=!1})))},U=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),j("write",e,r,t),P()},J=new Set,Q=(e,r,t,i)=>{var a=D?e.optimistic.get(D):e.base,n=a.get(r);void 0===n&&a.set(r,n=Object.create(null)),void 0!==i||D?n[t]=i:delete n[t]},V=(e,r,t)=>{for(var i,a=!L&&"read"===C&&D&&A.commutativeKeys.has(D),n=0,o=A.optimisticOrder.length;n<o;n++){var s=A.optimisticOrder[n],l=e.optimistic.get(s);if(a=a&&s!==D,l&&(!a||!A.commutativeKeys.has(s))&&(!L||"write"===C||A.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};function B(e){return A.refCount.get(e)||0}var z=(e,r)=>{if(Array.isArray(e))for(var t=0,i=e.length;t<i;t++)z(e[t],r);else"string"==typeof e&&((e,r)=>{var t=B(e),i=t+r>0?t+r:0;A.refCount.set(e,i),i?!t&&i&&A.gc.delete(e):A.gc.add(e)})(e,r)},G=(e,r,t)=>{if(void 0!==t)for(var i in t)r.has(i)||(e.push(S(i)),r.add(i))},H=(e,r,t,i)=>{G(e,r,i.base.get(t));for(var a=0,n=A.optimisticOrder.length;a<n;a++){var o=i.optimistic.get(A.optimisticOrder[a]);void 0!==o&&G(e,r,o.get(t))}},W=()=>{if(!A.optimisticOrder.length)for(var e of A.gc.keys())if(A.gc.delete(e),!(B(e)>0)){var r=A.records.base.get(e);A.refCount.delete(e),A.records.base.delete(e);var t=r&&r.__typename;if(t){var i=A.types.get(t);i&&i.delete(e)}var a=A.links.base.get(e);if(a)for(var n in A.links.base.delete(e),a)z(a[n],-1)}},X=(e,r)=>{e!==A.queryRootKey?F.add(e):void 0!==r&&"__typename"!==r&&F.add(K(e,r))},Y=(e,r)=>{!L&&A.storage&&A.persist.add(((e,r)=>`${e.replace(/\./g,"%2e")}.${r}`)(e,r))},Z=(e,r)=>(X(e,r),V(A.records,e,r)),ee=(e,r)=>(X(e,r),V(A.links,e,r)),re=(e,r)=>{var t=A.abstractToConcreteMap.get(e);if(t)t.add(r);else{var i=new Set;i.add(r),A.abstractToConcreteMap.set(e,i)}},te=(e,r,t)=>{X(e,r),Y(e,r),Q(A.records,e,r,t)},ie=(e,r,t)=>{var i=D?A.links.optimistic.get(D):A.links.base;if(!D){var a=i&&i.get(e);z(a&&a[r],-1),z(t,1)}X(e,r),Y(e,r),Q(A.links,e,r,t)},ae=(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)&&oe(e,r),i=0;e.optimisticOrder.splice(i,0,r),e.commutativeKeys.add(r)},ne=(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))},oe=(e,r)=>{e.dirtyKeys.has(r)&&(e.dirtyKeys.delete(r),e.records.optimistic.delete(r),e.links.optimistic.delete(r),e.deferredKeys.delete(r))},se=(e,r)=>{var t=e.optimisticOrder.indexOf(r);t>-1&&(e.optimisticOrder.splice(t,1),e.commutativeKeys.delete(r)),oe(e,r)},le=e=>{var r=F;F=new Set,C="write";var t=A.links.optimistic.get(e);if(t)for(var i of t.entries()){var a=i[0],n=i[1];for(var o in n)ie(a,o,n[o])}var s=A.records.optimistic.get(e);if(s)for(var l of s.entries()){var d=l[0],u=l[1];for(var p in u)te(d,p,u[p])}F=r,se(A,e)},de=e=>{var{links:r,records:t}=A,i=[],a=new Set;return X(e),H(i,a,e,r),H(i,a,e,t),i},ue=()=>{if(A.storage){L=!0,C="read";var r={};for(var t of A.persist.keys()){var{entityKey:i,fieldKey:a}=E(t),n=void 0;r[t]=void 0!==(n=ee(i,a))?`:${e.stringifyVariables(n)}`:void 0!==(n=Z(i,a))?e.stringifyVariables(n):void 0}L=!1,A.storage.writeData(r),A.persist.clear()}},pe=null,ve=!1,ye=void 0,fe=e=>e.__internal.path.length>0&&e.__internal.errorMap?e.__internal.errorMap[e.__internal.path.join(".")]:void 0,ce=(e,r,t,i,a,n)=>{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:L,__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},me=(e,r,t,i,a,n)=>{pe=e,e.parent=r,e.parentTypeName=t,e.parentKey=i,e.parentFieldKey=a,e.fieldName=n,e.error=fe(e)},he=(e,t,i,a,n)=>{if(!t)return!1;var o=v(e);return!o||t===o||"write"===C||!p(e).some((e=>{if(e.kind!==r.Kind.FIELD)return!1;var t=x(s(e),y(e,a));return!((e,r)=>void 0!==Z(e,r)||void 0!==ee(e,r))(i,t)}))};function ge(e,t,i,a,n,o){var l,d=0;return function(){for(var u;l||d<n.length;)if(u=void 0,ve=i,ye=a,l){if(u=l())return u;l=void 0}else{var v=n[d++];if(g(v,o.variables))if(v.kind!==r.Kind.FIELD){var y=v.kind!==r.Kind.INLINE_FRAGMENT?o.fragments[s(v)]:v;if(y&&(!y.typeCondition||(o.store.schema?b(o.store.schema,y,e):"read"===C&&ke(y.typeCondition.name.value,e)||he(y,e,t,o.variables)))){var f=_(v);y.typeCondition&&e!==y.typeCondition.name.value&&re(y.typeCondition.name.value,e),l=ge(e,t,i||k(v,o.variables),void 0!==f?f:a,p(y),o)}}else if("write"===C||!v._generated)return v}}}var ke=(e,r)=>{if(!r)return!1;if(e===r)return!0;var t=(e=>A.abstractToConcreteMap.get(e)||J)(e);return t.size&&t.has(r)},_e=e=>null==e?null:e,Oe=(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]=Oe(e,r[i]);return t}return e.keyOfEntity(r)},we=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s=r.rootFields[o.operation],l=p(o),d=ce(r,c(o,t.variables),h(n),s,s,a),u=s!==d.store.rootFields.query?be(d,s,l,i||$()):xe(d,s,l,i||$());return{dependencies:F,partial:d.partial||!u,hasNext:d.hasNext,data:u||null}},be=(e,r,t,i)=>{if("string"!=typeof(e.store.rootNames[r]?r:i.__typename))return i;for(var a,n=ge(r,r,!1,void 0,t,e),o=I,s=$(i);a=n();){var l,u=d(a),v=i[u];e.__internal.path.push(u),l=a.selectionSet&&null!==v?Ne(e,p(a),_e(v)):v,o=o||l!==v,void 0!==l&&(s[u]=l),e.__internal.path.pop()}return o?s:i},Ne=(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]=Ne(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?xe(e,s,r,t)||null:be(e,t.__typename,r,t)};function qe(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](y(s,i.variables))}return n}var xe=(e,r,t,i,a)=>{var{store:n}=e,l=r===n.rootFields.query,u=a&&n.keyOfEntity(a)||r,v=l?r:Z(u,"__typename")||a&&a.__typename;if("string"==typeof v&&(!a||v===a.__typename)){for(var f,c=ge(v,u,!1,void 0,t,e),m=!1,h=!1,g=I,k=e.partial,_=$(i);void 0!==(f=c());){var w=s(f),b=y(f,e.variables),N=d(f),q=o(f),S=qe(q,v,w,e),E=x(w,b),M=K(u,E),T=Z(u,E),A=a?a[w]:void 0;e.__internal.path.push(N);var D=void 0;if("__typename"===w)D=v;else if(void 0!==A&&void 0===f.selectionSet)D=A;else if("read"===C&&S){var F=_;if(void 0===f.selectionSet&&void 0!==T&&(F={..._,[N]:T,[w]:T}),me(e,F,v,u,E,w),D=S(F,b||{},n,e),f.selectionSet&&(D=Ke(e,v,w,M,p(f),void 0!==_[N]?_[N]:i[N],D,R(i))),n.schema&&null===D&&!O(n.schema,v,w,e.store.logger))return}else if(f.selectionSet)if(void 0!==A)D=Ke(e,v,w,M,p(f),void 0!==_[N]?_[N]:i[N],A,R(i));else{var L=ee(u,E);void 0!==L?D=Se(e,L,v,w,p(f),void 0!==_[N]?_[N]:i[N],R(i)):"object"==typeof T&&null!==T&&(D=T)}else D=T;if(!ve&&void 0===D&&(q.optional||ye&&!q.required||fe(e)||n.schema&&O(n.schema,v,w,e.store.logger))?(e.partial=!0,D=null):null!==D||!q.required&&!1!==ye?m=m||"__typename"!==w:D=void 0,e.__internal.path.pop(),g=g||D!==i[N],void 0!==D)_[N]=D;else{if(!ve)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?_:i}},Ke=(e,r,t,i,a,n,o,s)=>{if(Array.isArray(o)){for(var{store:l}=e,d=!!l.schema&&w(l.schema,r,t,e.store.logger),u=e.partial,p=$(n,!0),v=I||!Array.isArray(n)||o.length!==n.length,y=0,f=o.length;y<f;y++){e.__internal.path.push(y);var c=Ke(e,r,t,K(i,`${y}`),a,null!=n?n[y]:void 0,o[y],s);if(e.__internal.path.pop(),void 0===c&&!d)return void(e.partial=u);e.partial=e.partial||void 0===c&&d,p[y]=null!=c?c:null,v=v||p[y]!==n[y]}return v?p:n}if(null==o)return o;if(s&&null===n)return null;if(Ee(o)){var m=n||$(n);return"string"==typeof o?xe(e,o,a,m):xe(e,i,a,m,o)}},Se=(e,r,t,i,a,n,o)=>{if(Array.isArray(r)){for(var{store:s}=e,l=!!s.schema&&w(s.schema,t,i,e.store.logger),d=$(n,!0),u=e.partial,p=I||!Array.isArray(n)||r.length!==n.length,v=0,y=r.length;v<y;v++){e.__internal.path.push(v);var f=Se(e,r[v],t,i,a,null!=n?n[v]:void 0,o);if(e.__internal.path.pop(),void 0===f&&!l)return void(e.partial=u);e.partial=e.partial||void 0===f&&l,d[v]=f||null,p=p||d[v]!==n[v]}return p?d:n}return null===r||null===n&&o?null:xe(e,r,a,n||$(n))},Ee=e=>"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename,Me=(e,r,t)=>{for(var i=r?[{fieldKey:x(r,t)}]:de(e),a=0,n=i.length;a<n;a++){var{fieldKey:o}=i[a];void 0!==ee(e,o)?ie(e,o,void 0):te(e,o,void 0)}},Te=(e,r)=>{var t=(e=>A.types.get(e)||J)(e);for(var i of t)r.includes(i)||Me(i)},Ae=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s={data:i||$(),dependencies:F},l=r.rootFields[o.operation],d=ce(r,c(o,t.variables),h(n),l,l,a);return De(d,l,p(o),s.data),s},De=(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=Z(r,"__typename")),o){!n&&r&&(te(r,"__typename",o),((e,r)=>{var t=A.types.get(e);if(t)t.add(r);else{var i=new Set;i.add(r),A.types.set(e,i)}})(o,r));for(var l,u=e.store.updates[o],v=ge(o,r||o,!1,void 0,t,e);l=v();){var f=s(l),c=y(l,e.variables),m=x(f,c),h=d(l),g=i[e.optimistic?f:h];if(!("__typename"===f||void 0===g&&(ve||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&&(me(e,i,o,r||o,m,f),g=_e(k(c||{},e.store,e))),void 0!==g){if(l.selectionSet)if(r&&"query"===a){var _=K(r,m),O=Ce(e,p(l),_e(g),_,e.optimistic?ee(r||o,m):void 0);ie(r||o,m,O)}else Ce(e,p(l),_e(g));else r&&"query"===a&&te(r||o,m,null===g&&fe(e)?void 0:g);var w=u&&u[f];if(w)me(e,i,o,r||o,m,f),i[f]=g,w(i,c||{},e.store,e);else if(o===e.store.rootFields.mutation&&!e.optimistic)if(g&&Array.isArray(g))for(var b=g.map((r=>e.store.keyOfEntity(r)||"")),N=0,q=g.length;N<q;N++){var S=b[N];if(S&&g[N].__typename){var E=Z(S,"__typename"),M=B(S);E&&!M&&Te(g[N].__typename,b)}}else if(g&&"object"==typeof g){var T=e.store.keyOfEntity(g);if(T){var D=Z(T,"__typename"),C=B(T);D&&C||!g.__typename||Te(g.__typename,[T])}}e.__internal.path.pop()}}}}},Ce=(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?K(i,`${o}`):void 0,d=Ce(e,r,t[o],l,null!=a?a[o]:void 0);n[o]=d,e.__internal.path.pop()}return n}if(null===t)return fe(e)?void 0:null;var u=e.store.keyOfEntity(t)||("string"==typeof a?a:null)||i;return De(e,u,r,t),u||null};class Fe{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,types:new Map,persist:new Set,queryRootKey:r,refCount:new Map,links:{optimistic:new Map,base:new Map},abstractToConcreteMap: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 x(e,r)}keyOfEntity(e){if(pe&&e===pe.parent)return pe.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=x(r,t),n=Z(i,a);if(void 0!==n)return n;var o=ee(i,a);return void 0!==o&&(o=Oe(this,o)),o}}invalidate(e,r,t){var i=this.keyOfEntity(e);!e||"string"!=typeof e||r||t||this.resolve(e,"__typename")?(a(i,"",19),Me(i,r,t)):Te(e,[])}inspectFields(e){var r=this.keyOfEntity(e);return r?de(r):[]}updateQuery(r,t){var i=e.createRequest(r.query,r.variables),a=t(this.readQuery(i));null!==a&&Ae(this,i,a,void 0)}readQuery(r){var t=e.createRequest(r.query,r.variables);return we(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=ce(e,i||{},o,s,d,void 0);return xe(u,d,p(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 s=l(n),d={__typename:s,...t},u=e.keyOfEntity(d);if(u){var v=ce(e,i||{},o,s,u,void 0);De(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&&ie(n,x(r,i),Oe(this,a))}}var Ie=(r,t)=>e.makeOperation(r.kind,r,{...r.context,requestPolicy:t}),Le=r=>({forward:i,client:a})=>{var n=new Fe(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:o}=E(i);":"===a[0]?void 0===ee(n,o)&&ie(n,o,JSON.parse(a.slice(1))):void 0===Z(n,o)&&te(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,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,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(Ie(n,o))}}if(!t){var s=y;"query"===e.kind&&(y=c).add(e.key),(c=s).clear()}},_=r=>{var t=!1;if("query"===r.kind)ae(n.data,r.key),l.set(r.key,r);else{if("teardown"===r.kind)return l.delete(r.key),d.delete(r.key),y.delete(r.key),U(n.data,r.key),r;if("mutation"===r.kind&&"network-only"!==r.context.requestPolicy){l.set(r.key,r),j("write",n.data,r.key,!0,!1);var{dependencies:i}=Ae(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?f(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=>{j("read",n.data,void 0,!1,!1);var r=we(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)&&ae(n.data,i.key,!0);var s=e.data;if(s){j("write",n.data,i.key,!1,!1);var u=Ae(n,i,s,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!==s);var v=we(n,i,p||s,e.error);P(),s=v.data,"query"===i.kind&&(g(r,t=v.dependencies),d.set(i.key,s))}else U(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)&&!y.has(e.operation.key)))(r)),f=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&&!y.has(e.operation.key)),s="cache-only"!==i&&(o||"partial"===e.outcome&&y.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(Ie(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++)ae(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,f])}},$e={"cache-only":0,"cache-first":1,"network-only":2,"cache-and-network":3};exports.Store=Fe,exports.cacheExchange=Le,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,y=!1,f=()=>{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(!y){var r=new Set;y=!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;$e[o]>$e[a]&&(a=o)}u(Ie(i,a))}else u(Ie(i,"cache-first"))}y=!1,p.length=0,f()}},h=Le({...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),f(),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(Ie(e.operation,"cache-only")),p.push(e.operation),!1;v||c(e.operation.key)}return!0}))(h(r))}}return Le(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,y=(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},f=(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=>{var{optional:r,required:t}=o(e);return!t&&(!!r||void 0)},O=(e,r,t,i)=>{var a=N(e,r,t,i);return!!a&&"NON_NULL"!==a.type.kind},w=(e,r,t,i)=>{var a=N(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},b=(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),q(e,t),e.isSubType(i,t)))},N=(e,r,t,i)=>{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 x=(r,t)=>t?`${r}(${e.stringifyVariables(t)})`:r,K=(e,r)=>`${e}.${r}`,S=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}},E=e=>{var r=e.indexOf(".");return{entityKey:e.slice(0,r).replace(/%2e/g,"."),fieldKey:e.slice(r+1)}},A=null,M=null,T=null,D=null,C=null,F=null,I=!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,C=e,T=r,F=new Set,L=!!i,I=!!a,t?"read"===C?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)):ae(r,t),D=t,ne(r,t)):(D=null,se(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]);)le(e.optimisticOrder[t]);A=null,M=null,C=null,T=null,F=null,e.defer||!e.storage&&e.optimisticOrder.length||(e.defer=!0,setTimeout((()=>{j("read",e,null),W(),ue(),P(),e.defer=!1})))},U=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),j("write",e,r,t),P()},J=new Set,Q=(e,r,t,i)=>{var a=D?e.optimistic.get(D):e.base,n=a.get(r);void 0===n&&a.set(r,n=Object.create(null)),void 0!==i||D?n[t]=i:delete n[t]},V=(e,r,t)=>{for(var i,a=!L&&"read"===C&&D&&T.commutativeKeys.has(D),n=0,o=T.optimisticOrder.length;n<o;n++){var s=T.optimisticOrder[n],l=e.optimistic.get(s);if(a=a&&s!==D,l&&(!a||!T.commutativeKeys.has(s))&&(!L||"write"===C||T.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};function B(e){return T.refCount.get(e)||0}var z=(e,r)=>{if(Array.isArray(e))for(var t=0,i=e.length;t<i;t++)z(e[t],r);else"string"==typeof e&&((e,r)=>{var t=B(e),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)},G=(e,r,t)=>{if(void 0!==t)for(var i in t)r.has(i)||(e.push(S(i)),r.add(i))},H=(e,r,t,i)=>{G(e,r,i.base.get(t));for(var a=0,n=T.optimisticOrder.length;a<n;a++){var o=i.optimistic.get(T.optimisticOrder[a]);void 0!==o&&G(e,r,o.get(t))}},W=()=>{if(!T.optimisticOrder.length)for(var e of T.gc.keys())if(T.gc.delete(e),!(B(e)>0)){var r=T.records.base.get(e);T.refCount.delete(e),T.records.base.delete(e);var t=r&&r.__typename;if(t){var i=T.types.get(t);i&&i.delete(e)}var a=T.links.base.get(e);if(a)for(var n in T.links.base.delete(e),a)z(a[n],-1)}},X=(e,r)=>{e!==T.queryRootKey?F.add(e):void 0!==r&&"__typename"!==r&&F.add(K(e,r))},Y=(e,r)=>{!L&&T.storage&&T.persist.add(((e,r)=>`${e.replace(/\./g,"%2e")}.${r}`)(e,r))},Z=(e,r)=>("read"===C&&X(e,r),V(T.records,e,r)),ee=(e,r)=>("read"===C&&X(e,r),V(T.links,e,r)),re=(e,r)=>{var t=T.abstractToConcreteMap.get(e);if(t)t.add(r);else{var i=new Set;i.add(r),T.abstractToConcreteMap.set(e,i)}},te=(e,r,t)=>{pe(V(T.records,e,r),t)||(X(e,r),Y(e,r)),Q(T.records,e,r,t)},ie=(e,r,t)=>{var i=D?T.links.optimistic.get(D):T.links.base;if(!D){var a=i&&i.get(e);z(a&&a[r],-1),z(t,1)}pe(V(T.links,e,r),t)||(X(e,r),Y(e,r)),Q(T.links,e,r,t)},ae=(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)&&oe(e,r),i=0;e.optimisticOrder.splice(i,0,r),e.commutativeKeys.add(r)},ne=(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))},oe=(e,r)=>{e.dirtyKeys.has(r)&&(e.dirtyKeys.delete(r),e.records.optimistic.delete(r),e.links.optimistic.delete(r),e.deferredKeys.delete(r))},se=(e,r)=>{var t=e.optimisticOrder.indexOf(r);t>-1&&(e.optimisticOrder.splice(t,1),e.commutativeKeys.delete(r)),oe(e,r)},le=e=>{var r=F;F=new Set,C="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 o in n)ie(a,o,n[o])}var s=T.records.optimistic.get(e);if(s)for(var l of s.entries()){var d=l[0],u=l[1];for(var p in u)te(d,p,u[p])}F=r,se(T,e)},de=e=>{var{links:r,records:t}=T,i=[],a=new Set;return X(e),H(i,a,e,r),H(i,a,e,t),i},ue=()=>{if(T.storage){L=!0,C="read";var r={};for(var t of T.persist.keys()){var{entityKey:i,fieldKey:a}=E(t),n=void 0;r[t]=void 0!==(n=ee(i,a))?`:${e.stringifyVariables(n)}`:void 0!==(n=Z(i,a))?e.stringifyVariables(n):void 0}L=!1,T.storage.writeData(r),T.persist.clear()}};function pe(e,r){return typeof e==typeof r&&e===r&&(!Array.isArray(e)||!Array.isArray(r)||e.length===r.length&&!e.some(((e,t)=>e!==r[t])))}var ve=null,ye=!1,fe=void 0,ce=e=>e.__internal.path.length>0&&e.__internal.errorMap?e.__internal.errorMap[e.__internal.path.join(".")]:void 0,me=(e,r,t,i,a,n)=>{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:L,__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},he=(e,r,t,i,a,n)=>{ve=e,e.parent=r,e.parentTypeName=t,e.parentKey=i,e.parentFieldKey=a,e.fieldName=n,e.error=ce(e)},ge=(e,t,i,a,n)=>{if(!t)return!1;var o=v(e);return!o||t===o||"write"===C||!p(e).some((e=>{if(e.kind!==r.Kind.FIELD)return!1;var t=x(s(e),y(e,a));return!((e,r)=>void 0!==Z(e,r)||void 0!==ee(e,r))(i,t)}))};function ke(e,t,i,a,n,o){var l,d=0;return function(){for(var u;l||d<n.length;)if(u=void 0,ye=i,fe=a,l){if(u=l())return u;l=void 0}else{var v=n[d++];if(g(v,o.variables))if(v.kind!==r.Kind.FIELD){var y=v.kind!==r.Kind.INLINE_FRAGMENT?o.fragments[s(v)]:v;if(y&&(!y.typeCondition||(o.store.schema?b(o.store.schema,y,e):"read"===C&&_e(y.typeCondition.name.value,e)||ge(y,e,t,o.variables)))){var f=_(v);y.typeCondition&&e!==y.typeCondition.name.value&&re(y.typeCondition.name.value,e),l=ke(e,t,i||k(v,o.variables),void 0!==f?f:a,p(y),o)}}else if("write"===C||!v._generated)return v}}}var _e=(e,r)=>{if(!r)return!1;if(e===r)return!0;var t=(e=>T.abstractToConcreteMap.get(e)||J)(e);return t.size&&t.has(r)},Oe=e=>null==e?null:e,we=(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]=we(e,r[i]);return t}return e.keyOfEntity(r)},be=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s=r.rootFields[o.operation],l=p(o),d=me(r,c(o,t.variables),h(n),s,s,a),u=s!==d.store.rootFields.query?Ne(d,s,l,i||$()):Ke(d,s,l,i||$());return{dependencies:F,partial:d.partial||!u,hasNext:d.hasNext,data:u||null}},Ne=(e,r,t,i)=>{if("string"!=typeof(e.store.rootNames[r]?r:i.__typename))return i;for(var a,n=ke(r,r,!1,void 0,t,e),o=I,s=$(i);a=n();){var l,u=d(a),v=i[u];e.__internal.path.push(u),l=a.selectionSet&&null!==v?qe(e,p(a),Oe(v)):v,o=o||l!==v,void 0!==l&&(s[u]=l),e.__internal.path.pop()}return o?s:i},qe=(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]=qe(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?Ke(e,s,r,t)||null:Ne(e,t.__typename,r,t)};function xe(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](y(s,i.variables))}return n}var Ke=(e,r,t,i,a)=>{var{store:n}=e,l=r===n.rootFields.query,u=a&&n.keyOfEntity(a)||r,v=l?r:Z(u,"__typename")||a&&a.__typename;if("string"==typeof v&&(!a||v===a.__typename)){for(var f,c=ke(v,u,!1,void 0,t,e),m=!1,h=!1,g=I,k=e.partial,_=$(i);void 0!==(f=c());){var w=s(f),b=y(f,e.variables),N=d(f),q=o(f),S=xe(q,v,w,e),E=x(w,b),A=K(u,E),M=Z(u,E),T=a?a[w]:void 0;e.__internal.path.push(N);var D=void 0;if("__typename"===w)D=v;else if(void 0!==T&&void 0===f.selectionSet)D=T;else if("read"===C&&S){var F=_;if(void 0===f.selectionSet&&void 0!==M&&(F={..._,[N]:M,[w]:M}),he(e,F,v,u,E,w),D=S(F,b||{},n,e),f.selectionSet&&(D=Se(e,v,w,A,p(f),void 0!==_[N]?_[N]:i[N],D,R(i))),n.schema&&null===D&&!O(n.schema,v,w,e.store.logger))return}else if(f.selectionSet)if(void 0!==T)D=Se(e,v,w,A,p(f),void 0!==_[N]?_[N]:i[N],T,R(i));else{var L=ee(u,E);void 0!==L?D=Ee(e,L,v,w,p(f),void 0!==_[N]?_[N]:i[N],R(i)):"object"==typeof M&&null!==M&&(D=M)}else D=M;if(!ye&&void 0===D&&(q.optional||fe&&!q.required||ce(e)||n.schema&&O(n.schema,v,w,e.store.logger))?(e.partial=!0,D=null):null!==D||!q.required&&!1!==fe?m=m||"__typename"!==w:D=void 0,e.__internal.path.pop(),g=g||D!==i[N],void 0!==D)_[N]=D;else{if(!ye)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?_:i}},Se=(e,r,t,i,a,n,o,s)=>{if(Array.isArray(o)){for(var{store:l}=e,d=!!l.schema&&w(l.schema,r,t,e.store.logger),u=e.partial,p=$(n,!0),v=I||!Array.isArray(n)||o.length!==n.length,y=0,f=o.length;y<f;y++){e.__internal.path.push(y);var c=Se(e,r,t,K(i,`${y}`),a,null!=n?n[y]:void 0,o[y],s);if(e.__internal.path.pop(),void 0===c&&!d)return void(e.partial=u);e.partial=e.partial||void 0===c&&d,p[y]=null!=c?c:null,v=v||p[y]!==n[y]}return v?p:n}if(null==o)return o;if(s&&null===n)return null;if(Ae(o)){var m=n||$(n);return"string"==typeof o?Ke(e,o,a,m):Ke(e,i,a,m,o)}},Ee=(e,r,t,i,a,n,o)=>{if(Array.isArray(r)){for(var{store:s}=e,l=!!s.schema&&w(s.schema,t,i,e.store.logger),d=$(n,!0),u=e.partial,p=I||!Array.isArray(n)||r.length!==n.length,v=0,y=r.length;v<y;v++){e.__internal.path.push(v);var f=Ee(e,r[v],t,i,a,null!=n?n[v]:void 0,o);if(e.__internal.path.pop(),void 0===f&&!l)return void(e.partial=u);e.partial=e.partial||void 0===f&&l,d[v]=f||null,p=p||d[v]!==n[v]}return p?d:n}return null===r||null===n&&o?null:Ke(e,r,a,n||$(n))},Ae=e=>"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename,Me=(e,r,t)=>{for(var i=r?[{fieldKey:x(r,t)}]:de(e),a=0,n=i.length;a<n;a++){var{fieldKey:o}=i[a];void 0!==ee(e,o)?ie(e,o,void 0):te(e,o,void 0)}},Te=(e,r)=>{var t=(e=>T.types.get(e)||J)(e);for(var i of t)r.includes(i)||Me(i)},De=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s={data:i||$(),dependencies:F},l=r.rootFields[o.operation],d=me(r,c(o,t.variables),h(n),l,l,a);return Ce(d,l,p(o),s.data),s},Ce=(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=Z(r,"__typename")),o){!n&&r&&(te(r,"__typename",o),((e,r)=>{var t=T.types.get(e);if(t)t.add(r);else{var i=new Set;i.add(r),T.types.set(e,i)}})(o,r));for(var l,u=e.store.updates[o],v=ke(o,r||o,!1,void 0,t,e);l=v();){var f=s(l),c=y(l,e.variables),m=x(f,c),h=d(l),g=i[e.optimistic?f:h];if(!("__typename"===f||void 0===g&&(ye||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&&(he(e,i,o,r||o,m,f),g=Oe(k(c||{},e.store,e))),void 0!==g){if(l.selectionSet)if(r&&"query"===a){var _=K(r,m),O=Fe(e,p(l),Oe(g),_,e.optimistic?ee(r||o,m):void 0);ie(r||o,m,O)}else Fe(e,p(l),Oe(g));else r&&"query"===a&&te(r||o,m,null===g&&ce(e)?void 0:g);var w=u&&u[f];if(w)he(e,i,o,r||o,m,f),i[f]=g,w(i,c||{},e.store,e);else if(o===e.store.rootFields.mutation&&!e.optimistic)if(g&&Array.isArray(g))for(var b=g.map((r=>e.store.keyOfEntity(r)||"")),N=0,q=g.length;N<q;N++){var S=b[N];if(S&&g[N].__typename){var E=Z(S,"__typename"),A=B(S);E&&!A&&Te(g[N].__typename,b)}}else if(g&&"object"==typeof g){var M=e.store.keyOfEntity(g);if(M){var D=Z(M,"__typename"),C=B(M);D&&C||!g.__typename||Te(g.__typename,[M])}}e.__internal.path.pop()}}}}},Fe=(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?K(i,`${o}`):void 0,d=Fe(e,r,t[o],l,null!=a?a[o]:void 0);n[o]=d,e.__internal.path.pop()}return n}if(null===t)return ce(e)?void 0:null;var u=e.store.keyOfEntity(t)||("string"==typeof a?a:null)||i;return Ce(e,u,r,t),u||null};class Ie{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,types:new Map,persist:new Set,queryRootKey:r,refCount:new Map,links:{optimistic:new Map,base:new Map},abstractToConcreteMap: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 x(e,r)}keyOfEntity(e){if(ve&&e===ve.parent)return ve.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=x(r,t),n=Z(i,a);if(void 0!==n)return n;var o=ee(i,a);return void 0!==o&&(o=we(this,o)),o}}invalidate(e,r,t){var i=this.keyOfEntity(e);!e||"string"!=typeof e||r||t||this.resolve(e,"__typename")?(a(i,"",19),Me(i,r,t)):Te(e,[])}inspectFields(e){var r=this.keyOfEntity(e);return r?de(r):[]}updateQuery(r,t){var i=e.createRequest(r.query,r.variables),a=t(this.readQuery(i));null!==a&&De(this,i,a,void 0)}readQuery(r){var t=e.createRequest(r.query,r.variables);return be(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=me(e,i||{},o,s,d,void 0);return Ke(u,d,p(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 s=l(n),d={__typename:s,...t},u=e.keyOfEntity(d);if(u){var v=me(e,i||{},o,s,u,void 0);Ce(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&&ie(n,x(r,i),we(this,a))}}var Le=(r,t)=>e.makeOperation(r.kind,r,{...r.context,requestPolicy:t}),$e=r=>({forward:i,client:a})=>{var n=new Ie(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:o}=E(i);":"===a[0]?void 0===ee(n,o)&&ie(n,o,JSON.parse(a.slice(1))):void 0===Z(n,o)&&te(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,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,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(Le(n,o))}}if(!t){var s=y;"query"===e.kind&&(y=c).add(e.key),(c=s).clear()}},_=r=>{var t=!1;if("query"===r.kind)ae(n.data,r.key),l.set(r.key,r);else{if("teardown"===r.kind)return l.delete(r.key),d.delete(r.key),y.delete(r.key),U(n.data,r.key),r;if("mutation"===r.kind&&"network-only"!==r.context.requestPolicy){l.set(r.key,r),j("write",n.data,r.key,!0,!1);var{dependencies:i}=De(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?f(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=>{j("read",n.data,void 0,!1,!1);var r=be(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)&&ae(n.data,i.key,!0);var s=e.data;if(s){j("write",n.data,i.key,!1,!1);var u=De(n,i,s,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!==s);var v=be(n,i,p||s,e.error);P(),s=v.data,"query"===i.kind&&(g(r,t=v.dependencies),d.set(i.key,s))}else U(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)&&!y.has(e.operation.key)))(r)),f=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&&!y.has(e.operation.key)),s="cache-only"!==i&&(o||"partial"===e.outcome&&y.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(Le(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++)ae(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,f])}},Re={"cache-only":0,"cache-first":1,"network-only":2,"cache-and-network":3};exports.Store=Ie,exports.cacheExchange=$e,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,y=!1,f=()=>{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(!y){var r=new Set;y=!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;Re[o]>Re[a]&&(a=o)}u(Le(i,a))}else u(Le(i,"cache-first"))}y=!1,p.length=0,f()}},h=$e({...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),f(),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(Le(e.operation,"cache-only")),p.push(e.operation),!1;v||c(e.operation.key)}return!0}))(h(r))}}return $e(r)(i)};
//# sourceMappingURL=urql-exchange-graphcache.min.js.map
{
"name": "@urql/exchange-graphcache",
"version": "7.0.1",
"version": "7.0.2-canary-b73de94f",
"description": "A normalized and configurable cache exchange for urql",

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

"react-dom": "^17.0.1",
"@urql/core": "5.0.0",
"@urql/core": "5.0.1",
"@urql/introspection": "1.0.3",
"@urql/exchange-execute": "2.2.2",
"@urql/introspection": "1.0.3",
"urql": "4.0.7"

@@ -72,0 +72,0 @@ },

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