@urql/exchange-graphcache
Advanced tools
Comparing version 6.1.5-canary-7ddccc13 to 6.1.5-canary-c37a0fc3
@@ -11,5 +11,5 @@ { | ||
".": { | ||
"types": "../dist/urql-exchange-graphcache-default-storage.d.ts", | ||
"import": "../dist/urql-exchange-graphcache-default-storage.mjs", | ||
"require": "../dist/urql-exchange-graphcache-default-storage.js", | ||
"types": "../dist/urql-exchange-graphcache-default-storage.d.ts", | ||
"source": "../src/default-storage/index.ts" | ||
@@ -19,2 +19,2 @@ }, | ||
} | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
import { DocumentInput, ErrorLike, TypedDocumentNode, AnyVariables, RequestExtensions } from '@urql/core'; | ||
import { FragmentDefinitionNode } from '@0no-co/graphql.web'; | ||
import { FormattedNode, ErrorLike, DocumentInput, TypedDocumentNode, AnyVariables, RequestExtensions } from '@urql/core'; | ||
import { FragmentDefinitionNode, DocumentNode } from '@0no-co/graphql.web'; | ||
/*!@ts-ignore*/ | ||
@@ -106,3 +106,3 @@ import * as GraphQL from 'graphql'; | ||
interface Fragments { | ||
[fragmentName: string]: void | FragmentDefinitionNode; | ||
[fragmentName: string]: void | FormattedNode<FragmentDefinitionNode>; | ||
} | ||
@@ -250,3 +250,3 @@ /** Non-object JSON values as serialized by a GraphQL API | ||
interface OperationRequest { | ||
query: Exclude<DocumentInput<any, any>, string>; | ||
query: FormattedNode<DocumentNode> | DocumentNode; | ||
variables?: any; | ||
@@ -253,0 +253,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=e=>e.name.value,o=e=>e.typeCondition.name.value,s=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,o=e.arguments.length;a<o;a++){var s=e.arguments[a],l=r.valueFromASTUntyped(s.value,t);null!=l&&(i||(i={}),i[n(s)]=l)}return i},f=(e,r)=>{if(r&&e.variableDefinitions){for(var t={},i=0,a=e.variableDefinitions.length;i<a;i++){var o=n(e.variableDefinitions[i].variable);t[o]=r[o]}return t}},c=(e,t)=>{var i={};if(!t)return i;if(e.variableDefinitions)for(var a=0,o=e.variableDefinitions.length;a<o;a++){var s=e.variableDefinitions[a],l=n(s.variable);i[l]=void 0===t[l]&&s.defaultValue?r.valueFromASTUntyped(s.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],o=n(a);if(("include"===o||"skip"===o)&&a.arguments&&a.arguments[0]&&"if"===n(a.arguments[0])){var s=r.valueFromASTUntyped(a.arguments[0].value,t);return"include"===o?!!s:!s}}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 o=0;a.arguments&&o<a.arguments.length;o++){var s=a.arguments[i];if("if"===n(s))return!!r.valueFromASTUntyped(s.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),P=(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},j=()=>{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((()=>{P("read",e,null),z(),se(),j(),e.defer=!1})))},U=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),P("write",e,r,t),j()},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,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"===F||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},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 o=i.optimistic.get(T.optimisticOrder[a]);void 0!==o&&V(e,r,o.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 o in n)ee(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)Z(d,p,u[p])}I=r,ae(T,e)},oe=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},se=()=>{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 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},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 o,s=0;return function(){for(var l;o||s<i.length;)if(l=void 0,de=t,o){if(l=o())return l;o=void 0}else{var u=i[s++];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)))&&(o=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],o=d(a),s=pe(e,c(a,r.variables),h(r.query),n,n,i),l=n!==s.store.rootFields.query?ge(s,n,o,t||$()):_e(s,n,o,t||$());return{dependencies:I,partial:s.partial||!l,hasNext:s.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),o=C,l=$(i);a=n();){var u,p=s(a),v=i[p];e.__internal.path.push(p),u=a.selectionSet&&null!==v?ke(e,d(a),ce(v)):v,o=o||u!==v,void 0!==u&&(l[p]=u),e.__internal.path.pop()}return o?l:i},ke=(e,r,t)=>{if(Array.isArray(t)){for(var i=new Array(t.length),a=C,n=0,o=t.length;n<o;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 s=e.store.keyOfEntity(t);return null!==s?_e(e,s,r,t)||null:ge(e,t.__typename,r,t)},_e=(e,r,t,i,a)=>{var{store:o}=e,l=r===o.rootFields.query,u=a&&o.keyOfEntity(a)||r,p=l?r:H(u,"__typename")||a&&a.__typename;if("string"==typeof p&&(!a||p===a.__typename)){for(var v,f=o.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=s(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||{},o,e),v.selectionSet&&(M=Oe(e,p,w,S,d(v),void 0!==O[q]?O[q]:i[q],M,R(i))),o.schema&&null===M&&!_(o.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&&(o.schema&&_(o.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,o,s)=>{if(Array.isArray(o)){for(var{store:l}=e,d=!!l.schema&&O(l.schema,r,t),u=$(n,!0),p=C||!Array.isArray(n)||o.length!==n.length,v=0,y=o.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,o[v],s);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==o)return o;if(!s&&null===n)return null;if(be(o)){var c=n||$(n);return"string"==typeof o?_e(e,o,a,c):_e(e,i,a,c,o)}},we=(e,r,t,i,a,n,o)=>{if(Array.isArray(r)){for(var{store:s}=e,l=!!s.schema&&O(s.schema,t,i),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,o);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&&o?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},o=e.rootFields[a.operation],s=pe(e,c(a,r.variables),h(r.query),o,o,i);return Ne(s,o,d(a),n.data),n},Ne=(e,r,t,i)=>{var a=e.store.rootNames[r]||"query",o=!!e.store.rootNames[r],l=o?r:i.__typename;if(!l&&r&&e.optimistic&&(l=H(r,"__typename")),l){!o&&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=s(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,r||l,m,f),g=ce(k(c||{},e.store,e))),void 0!==g){if(u.selectionSet)if(r&&"query"===a){var _=x(r,m),O=xe(e,d(u),ce(g),_,e.optimistic?Y(r||l,m):void 0);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,r||l,x(l,m),f),i[f]=g,w(i,c||{},e.store,e)),e.__internal.path.pop()}}}}},xe=(e,r,t,i,a)=>{if(Array.isArray(t)){for(var n=new Array(t.length),o=0,s=t.length;o<s;o++){e.__internal.path.push(o);var l=i?x(i,`${o}`):void 0,d=xe(e,r,t[o],l,null!=a?a[o]:void 0);n[o]=d,e.__internal.path.pop()}return n}if(null===t)return ue(e)?void 0:null;var u=e.store.keyOfEntity(t)||("string"==typeof a?a:null)||i;return Ne(e,u,r,t),u||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 o=e.types[n];if(o&&o.name){var s=i(o);s&&r.set(o.name,s)}}}return a})(e.schema);t=n.query||t,i=n.mutation||i,a=n.subscription||a,n.types&&(this.schema=n)}this.updates=e.updates||{},this.rootFields={query:t,mutation:i,subscription:a},this.rootNames={[t]:"query",[i]:"mutation",[a]:"subscription"},this.data=(r=t,{hydrating:!1,defer:!1,gc:new Set,persist:new Set,queryRootKey:r,refCount:new Map,links:{optimistic:new Map,base:new Map},records:{optimistic:new Map,base:new Map},deferredKeys:new Set,commutativeKeys:new Set,dirtyKeys:new Set,optimisticOrder:[],storage:null})}keyOfField(e,r){return N(e,r)}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(e,r,t){return this.resolve(e,r,t)}invalidate(e,r,t){var i=this.keyOfEntity(e);a(i,"",19),((e,r,t)=>{for(var i=r?[{fieldKey:N(r,t)}]:oe(e),a=0,n=i.length;a<n;a++){var{fieldKey:o}=i[a];void 0!==Y(e,o)?ee(e,o,void 0):Z(e,o,void 0)}})(i,r,t)}inspectFields(e){var r=this.keyOfEntity(e);return r?oe(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,s=h(r);if(a){if(!(n=s[a]))return null}else if(!(n=s[Object.keys(s)[0]]))return null;var l=o(n);"string"==typeof t||t.__typename||(t.__typename=l);var u=e.keyOfEntity(t);if(!u)return null;var p=pe(e,i||{},s,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,s=h(r);if(a){if(!(n=s[a]))return null}else if(!(n=s[Object.keys(s)[0]]))return null;var l=o(n),u={__typename:l,...t},p=e.keyOfEntity(u);if(p){var v=pe(e,i||{},s,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,o=me(this,e);"string"==typeof o&&ee(o,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 P("write",e,null),t){var a=t[i];if(void 0!==a){var{entityKey:n,fieldKey:o}=S(i);":"===a[0]?void 0===Y(n,o)&&ee(n,o,JSON.parse(a.slice(1))):void 0===H(n,o)&&Z(n,o,JSON.parse(a))}}e.storage=r,e.hydrating=!1,j()})(n.data,r.storage,e)})));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(Se(n,o))}}if(!t){var s=y;"query"===e.kind&&(y=c).add(e.key),(c=s).clear()}},_=r=>{var t;if("query"===r.kind)re(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),P("write",n.data,r.key,!0,!1);var{dependencies:i}=qe(n,r,void 0,void 0);if(j(),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={optimistic:!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,...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=>{P("read",n.data,void 0,!1,!1);var r=he(n,e,d.get(e.key),void 0);j();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)&&re(n.data,i.key,!0);var s=e.data;if(s){P("write",n.data,i.key,!1,!1);var u=qe(n,i,s,e.error).dependencies;j(),g(r,u);var p="query"===i.kind?d.get(i.key):null;P("read",n.data,i.key,!1,p!==s);var v=he(n,i,p||s,e.error);j(),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{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,!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++)re(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])}},Ae={"cache-only":0,"cache-first":1,"network-only":2,"cache-and-network":3};exports.Store=Ke,exports.cacheExchange=Ee,exports.offlineExchange=r=>i=>{var{storage:a}=r,n=r.isOfflineError||(e=>e&&e.networkError&&!e.response&&("undefined"!=typeof navigator&&!1===navigator.onLine||/request failed|failed to fetch|network\s?error/i.test(e.networkError.message)));if(a&&a.onOnline&&a.readMetadata&&a.writeMetadata){var{forward:o,client:s,dispatchDebug:l}=i,{source:d,next:u}=t.makeSubject(),p=[],v=!1,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;Ae[o]>Ae[a]&&(a=o)}u(Se(i,a))}else u(Se(i,"cache-first"))}y=!1,p.length=0,f()}},h=Ee({...r,storage:{...a,readData(){var r=a.readData();return{async then(t){for(var i=await a.readMetadata(),n=0;i&&n<i.length;n++)p.push(s.createRequestOperation("mutation",e.createRequest(i[n].query,i[n].variables),i[n].extensions));t(await r),a.onOnline(m),v=!0,m()}}}}})({client:s,dispatchDebug:l,forward:e=>t.share(t.filter((e=>!(v&&"mutation"===e.operation.kind&&e.operation.context.optimistic&&n(e.error,e)&&(p.push(e.operation),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(Se(e.operation,"cache-only")),p.push(e.operation),!1;v||c(e.operation.key)}return!0}))(h(r))}}return Ee(r)(i)}; | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@urql/core"),r=require("@0no-co/graphql.web"),t=require("wonka"),i="\nhttps://bit.ly/2XbVrpR#";function a(e,r,t){if(!e){var a=new Error((r||"Minfied Error #"+t+"\n")+i+t);throw a.name="Graphcache Error",a}}new Set;var n={},o=e=>e._directives||n,s=e=>e.name.value,l=e=>e.typeCondition.name.value,d=e=>e.alias?e.alias.value:e.name.value,u=[],p=e=>e.selectionSet?e.selectionSet.selections:u,v=e=>e.typeCondition?e.typeCondition.name.value:null,f=(e,t)=>{var i=null;if(e.arguments)for(var a=0,n=e.arguments.length;a<n;a++){var o=e.arguments[a],l=r.valueFromASTUntyped(o.value,t);null!=l&&(i||(i={}),i[s(o)]=l)}return i},y=(e,r)=>{if(r&&e.variableDefinitions){for(var t={},i=0,a=e.variableDefinitions.length;i<a;i++){var n=s(e.variableDefinitions[i].variable);t[n]=r[n]}return t}},c=(e,t)=>{var i={};if(!t)return i;if(e.variableDefinitions)for(var a=0,n=e.variableDefinitions.length;a<n;a++){var o=e.variableDefinitions[a],l=s(o.variable);i[l]=void 0===t[l]&&o.defaultValue?r.valueFromASTUntyped(o.defaultValue,t):t[l]}for(var d in t)d in i||(i[d]=t[d]);return i};function m(e){for(var t=0;t<e.definitions.length;t++)if(e.definitions[t].kind===r.Kind.OPERATION_DEFINITION)return e.definitions[t];a(!1,"",1)}var h=e=>{for(var t={},i=0;i<e.definitions.length;i++){var a=e.definitions[i];a.kind===r.Kind.FRAGMENT_DEFINITION&&(t[s(a)]=a)}return t},g=(e,t)=>{var i=o(e);if(i.include||i.skip)for(var a in i){var n=i[a];if(n&&("include"===a||"skip"===a)&&n.arguments&&n.arguments[0]&&"if"===s(n.arguments[0])){var l=r.valueFromASTUntyped(n.arguments[0].value,t);return"include"===a?!!l:!l}}return!0},k=(e,t)=>{var{defer:i}=o(e);if(i){for(var a of i.arguments||[])if("if"===s(a))return!!r.valueFromASTUntyped(a.value,t);return!0}return!1},_=(e,r,t)=>{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=v(r);return!i||t===i||(e.types.has(i)&&"OBJECT"===e.types.get(i).kind?i===t:(function(e,r){a(e.types.has(r)&&("INTERFACE"===e.types.get(r).kind||"UNION"===e.types.get(r).kind),"",5)}(e,i),N(e,t),e.isSubType(i,t)))},b=(e,r,t)=>{if(0!==t.indexOf("__")&&0!==r.indexOf("__"))return N(e,r),e.types.get(r).fields()[t]};function N(e,r){a(e.types.has(r)&&"OBJECT"===e.types.get(r).kind,"",3)}var x=(r,t)=>t?`${r}(${e.stringifyVariables(t)})`:r,q=(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),P=(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},j=()=>{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((()=>{P("read",e,null),z(),se(),j(),e.defer=!1})))},U=(e,r,t)=>{r&&!t&&e.deferredKeys.delete(r),P("write",e,r,t),j()},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,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"===F||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},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 o=i.optimistic.get(T.optimisticOrder[a]);void 0!==o&&V(e,r,o.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(q(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 o in n)ee(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)Z(d,p,u[p])}I=r,ae(T,e)},oe=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},se=()=>{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 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},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)},fe=(e,t,i,a)=>{if(!t)return!1;var n=v(e);return!n||t===n||"write"===F||!p(e).some((e=>{if(e.kind!==r.Kind.FIELD)return!1;var t=x(s(e),f(e,a));return!((e,r)=>void 0!==H(e,r)||void 0!==Y(e,r))(i,t)}))},ye=(e,t,i,a,n)=>{var o,l=0;return function(){for(var d;o||l<a.length;)if(d=void 0,de=i,o){if(d=o())return d;o=void 0}else{var u=a[l++];if(g(u,n.variables))if(u.kind!==r.Kind.FIELD){var v=u.kind!==r.Kind.INLINE_FRAGMENT?n.fragments[s(u)]:u;v&&(!v.typeCondition||(n.store.schema?w(n.store.schema,v,e):fe(v,e,t,n.variables)))&&(o=ye(e,t,i||k(u,n.variables),p(v),n))}else if("write"===F||!u._generated)return u}}},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=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s=r.rootFields[o.operation],l=p(o),d=pe(r,c(o,t.variables),h(n),s,s,a),u=s!==d.store.rootFields.query?ge(d,s,l,i||$()):_e(d,s,l,i||$());return{dependencies:I,partial:d.partial||!u,hasNext:d.hasNext,data:u||null}},ge=(e,r,t,i)=>{if("string"!=typeof(e.store.rootNames[r]?r:i.__typename))return i;for(var a,n=ye(r,r,de,t,e),o=C,s=$(i);a=n();){var l,u=d(a),v=i[u];e.__internal.path.push(u),l=a.selectionSet&&null!==v?ke(e,p(a),ce(v)):v,o=o||l!==v,void 0!==l&&(s[u]=l),e.__internal.path.pop()}return o?s:i},ke=(e,r,t)=>{if(Array.isArray(t)){for(var i=new Array(t.length),a=C,n=0,o=t.length;n<o;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 s=e.store.keyOfEntity(t);return null!==s?_e(e,s,r,t)||null:ge(e,t.__typename,r,t)},_e=(e,r,t,i,a)=>{var{store:n}=e,o=r===n.rootFields.query,l=a&&n.keyOfEntity(a)||r,u=o?r:H(l,"__typename")||a&&a.__typename;if("string"==typeof u&&(!a||u===a.__typename)){for(var v,y=n.resolvers[u],c=ye(u,l,de,t,e),m=!1,h=!1,g=!1,k=C,O=$(i);void 0!==(v=c());){var w=s(v),b=f(v,e.variables),N=d(v),K=x(w,b),S=q(l,K),E=H(l,K),A=a?a[w]:void 0;e.__internal.path.push(N);var M=void 0;if("__typename"===w)M=u;else if(void 0!==A&&void 0===v.selectionSet)M=A;else if("read"===F&&y&&y[w]){if(ve(e,O,u,l,S,w),void 0!==E&&(O[N]=E),M=y[w](O,b||{},n,e),v.selectionSet&&(M=Oe(e,u,w,S,p(v),void 0!==O[N]?O[N]:i[N],M,R(i))),n.schema&&null===M&&!_(n.schema,u,w))return}else if(v.selectionSet)if(void 0!==A)M=Oe(e,u,w,S,p(v),void 0!==O[N]?O[N]:i[N],A,R(i));else{var T=Y(l,K);void 0!==T?M=we(e,T,u,w,p(v),void 0!==O[N]?O[N]:i[N],R(i)):"object"==typeof E&&null!==E&&(M=E)}else M=E;if(void 0===M&&de)g=!0;else if(void 0===M&&(n.schema&&_(n.schema,u,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[N],void 0!==M&&(O[N]=M)}return e.partial=e.partial||h,e.hasNext=e.hasNext||g,o&&h&&!m?void 0:k?O:i}},Oe=(e,r,t,i,a,n,o,s)=>{if(Array.isArray(o)){for(var{store:l}=e,d=!!l.schema&&O(l.schema,r,t),u=$(n,!0),p=C||!Array.isArray(n)||o.length!==n.length,v=0,f=o.length;v<f;v++){e.__internal.path.push(v);var y=Oe(e,r,t,q(i,`${v}`),a,null!=n?n[v]:void 0,o[v],s);if(e.__internal.path.pop(),void 0===y&&!d)return;e.partial=e.partial||void 0===y&&d,u[v]=null!=y?y:null,p=p||u[v]!==n[v]}return p?u:n}if(null==o)return o;if(!s&&null===n)return null;if(be(o)){var c=n||$(n);return"string"==typeof o?_e(e,o,a,c):_e(e,i,a,c,o)}},we=(e,r,t,i,a,n,o)=>{if(Array.isArray(r)){for(var{store:s}=e,l=!!s.schema&&O(s.schema,t,i),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 f=we(e,r[p],t,i,a,null!=n?n[p]:void 0,o);if(e.__internal.path.pop(),void 0===f&&!l)return;e.partial=e.partial||void 0===f&&l,d[p]=f||null,u=u||d[p]!==n[p]}return u?d:n}return null===r||null===n&&o?null:_e(e,r,a,n||$(n))},be=e=>"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename,Ne=(r,t,i,a)=>{var n=e.formatDocument(t.query),o=m(n),s={data:i||$(),dependencies:I},l=r.rootFields[o.operation],d=pe(r,c(o,t.variables),h(n),l,l,a);return xe(d,l,p(o),s.data),s},xe=(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=H(r,"__typename")),o){!n&&r&&Z(r,"__typename",o);for(var l,u=e.store.updates[o],v=ye(o,r||o,de,t,e);l=v();){var y=s(l),c=f(l,e.variables),m=x(y,c),h=d(l),g=i[e.optimistic?y:h];if(!("__typename"===y||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[y]))continue}else e.optimistic&&"function"==typeof g&&(k=g);if(k&&(ve(e,i,o,r||o,m,y),g=ce(k(c||{},e.store,e))),void 0!==g){if(l.selectionSet)if(r&&"query"===a){var _=q(r,m),O=qe(e,p(l),ce(g),_,e.optimistic?Y(r||o,m):void 0);ee(r||o,m,O)}else qe(e,p(l),ce(g));else r&&"query"===a&&Z(r||o,m,null===g&&ue(e)?void 0:g);var w=u&&u[y];w&&(ve(e,i,o,r||o,q(o,m),y),i[y]=g,w(i,c||{},e.store,e)),e.__internal.path.pop()}}}}},qe=(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?q(i,`${o}`):void 0,d=qe(e,r,t[o],l,null!=a?a[o]:void 0);n[o]=d,e.__internal.path.pop()}return n}if(null===t)return ue(e)?void 0:null;var u=e.store.keyOfEntity(t)||("string"==typeof a?a:null)||i;return xe(e,u,r,t),u||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 o=e.types[n];if(o&&o.name){var s=i(o);s&&r.set(o.name,s)}}}return a})(e.schema);t=n.query||t,i=n.mutation||i,a=n.subscription||a,n.types&&(this.schema=n)}this.updates=e.updates||{},this.rootFields={query:t,mutation:i,subscription:a},this.rootNames={[t]:"query",[i]:"mutation",[a]:"subscription"},this.data=(r=t,{hydrating:!1,defer:!1,gc:new Set,persist:new Set,queryRootKey:r,refCount:new Map,links:{optimistic:new Map,base:new Map},records:{optimistic:new Map,base:new Map},deferredKeys:new Set,commutativeKeys:new Set,dirtyKeys:new Set,optimisticOrder:[],storage:null})}keyOfField(e,r){return x(e,r)}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=x(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(e,r,t){return this.resolve(e,r,t)}invalidate(e,r,t){var i=this.keyOfEntity(e);a(i,"",19),((e,r,t)=>{for(var i=r?[{fieldKey:x(r,t)}]:oe(e),a=0,n=i.length;a<n;a++){var{fieldKey:o}=i[a];void 0!==Y(e,o)?ee(e,o,void 0):Z(e,o,void 0)}})(i,r,t)}inspectFields(e){var r=this.keyOfEntity(e);return r?oe(r):[]}updateQuery(r,t){var i=e.createRequest(r.query,r.variables),a=t(this.readQuery(i));null!==a&&Ne(this,i,a,void 0)}readQuery(r){var t=e.createRequest(r.query,r.variables);return 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 s=l(n);"string"==typeof t||t.__typename||(t.__typename=s);var d=e.keyOfEntity(t);if(!d)return null;var u=pe(e,i||{},o,s,d,void 0);return _e(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=pe(e,i||{},o,s,u,void 0);xe(v,u,p(n),d)}})(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,o=me(this,e);"string"==typeof o&&ee(o,x(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 P("write",e,null),t){var a=t[i];if(void 0!==a){var{entityKey:n,fieldKey:o}=S(i);":"===a[0]?void 0===Y(n,o)&&ee(n,o,JSON.parse(a.slice(1))):void 0===H(n,o)&&Z(n,o,JSON.parse(a))}}e.storage=r,e.hydrating=!1,j()})(n.data,r.storage,e)})));var o=new Map,s=[],l=new Map,d=new Map,u=new Set,p=new Set,v=new Map,f=new Set,c=new Set,h=e=>{for(var r of e.values())if(u.has(r))return!0;return!1},g=(e,r)=>{if(r)for(var t of r.values()){var i=v.get(t);if(i)for(var a of i.values())e.add(a)}},k=(e,r,t)=>{for(var i of r.values())if(i!==e.key){var n=l.get(i);if(n){"query"===e.kind&&c.add(i);var o="cache-first";p.has(i)&&(p.delete(i),o="cache-and-network"),a.reexecuteOperation(Se(n,o))}}if(!t){var s=f;"query"===e.kind&&(f=c).add(e.key),(c=s).clear()}},_=r=>{if("query"===r.kind)re(n.data,r.key),l.set(r.key,r);else if("teardown"===r.kind)return l.delete(r.key),d.delete(r.key),f.delete(r.key),U(n.data,r.key),r;var t=e.formatDocument(r.query);if("mutation"===(r=e.makeOperation(r.kind,{key:r.key,query:t,variables:r.variables?y(m(t),r.variables):r.variables},{...r.context})).kind&&"network-only"!==r.context.requestPolicy){l.set(r.key,r),P("write",n.data,r.key,!0,!1);var{dependencies:i}=Ne(n,r,void 0,void 0);if(j(),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),r.context.optimistic=!0}}return r},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=>{P("read",n.data,void 0,!1,!1);var r=he(n,e,d.get(e.key),void 0);j();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,{operation:i}=e;if("mutation"===i.kind){var a=o.get(i.key);g(r,a),o.delete(i.key)}("subscription"===i.kind||e.hasNext)&&re(n.data,i.key,!0);var s=e.data;if(s){P("write",n.data,i.key,!1,!1);var l=Ne(n,i,s,e.error).dependencies;j(),g(r,l);var u="query"===i.kind?d.get(i.key):null;P("read",n.data,i.key,!1,u!==s);var p=he(n,i,u||s,e.error);j(),s=p.data,"query"===i.kind&&(g(r,t=p.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)&&!f.has(e.operation.key)))(r)),y=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&&!f.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,!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++)re(n.data,s[r].operation.key);u.clear();for(var i,a=[],l=new Set;i=s.shift();)a.push(b(i,l));return k(e.operation,l,!1),t.fromArray(a)}))(t.filter((e=>o.has(e.operation.key)))(c));return t.merge([m,g,y])}},Ae={"cache-only":0,"cache-first":1,"network-only":2,"cache-and-network":3};exports.Store=Ke,exports.cacheExchange=Ee,exports.offlineExchange=r=>i=>{var{storage:a}=r,n=r.isOfflineError||(e=>e&&e.networkError&&!e.response&&("undefined"!=typeof navigator&&!1===navigator.onLine||/request failed|failed to fetch|network\s?error/i.test(e.networkError.message)));if(a&&a.onOnline&&a.readMetadata&&a.writeMetadata){var{forward:o,client:s,dispatchDebug:l}=i,{source:d,next:u}=t.makeSubject(),p=[],v=!1,f=!1,y=()=>{if(v){for(var r=[],t=0;t<p.length;t++){var i=p[t];"mutation"===i.kind&&r.push({query:e.stringifyDocument(i.query),variables:i.variables,extensions:i.extensions})}a.writeMetadata(r)}},c=e=>{for(var r=p.length-1;r>=0;r--)p[r].key===e&&p.splice(r,1)},m=()=>{if(!f){var r=new Set;f=!0;for(var t=0;t<p.length;t++){var i=p[t];if("mutation"===i.kind||!r.has(i.key))if(r.add(i.key),"subscription"!==i.kind){u(e.makeOperation("teardown",i));for(var a="cache-first",n=0;n<p.length;n++){var{requestPolicy:o}=p[n].context;Ae[o]>Ae[a]&&(a=o)}u(Se(i,a))}else u(Se(i,"cache-first"))}f=!1,p.length=0,y()}},h=Ee({...r,storage:{...a,readData(){var r=a.readData();return{async then(t){for(var i=await a.readMetadata(),n=0;i&&n<i.length;n++)p.push(s.createRequestOperation("mutation",e.createRequest(i[n].query,i[n].variables),i[n].extensions));t(await r),a.onOnline(m),v=!0,m()}}}}})({client:s,dispatchDebug:l,forward:e=>t.share(t.filter((e=>!(v&&"mutation"===e.operation.kind&&e.operation.context.optimistic&&n(e.error,e)&&(p.push(e.operation),y(),1))))(o(e)))});return e=>{var r=t.merge([d,t.onPush((e=>{"query"!==e.kind||v?"teardown"===e.kind&&c(e.key):p.push(e)}))(e)]);return t.filter((e=>{if("query"===e.operation.kind){if(n(e.error,e))return u(Se(e.operation,"cache-only")),p.push(e.operation),!1;v||c(e.operation.key)}return!0}))(h(r))}}return Ee(r)(i)}; | ||
//# sourceMappingURL=urql-exchange-graphcache.min.js.map |
@@ -11,5 +11,5 @@ { | ||
".": { | ||
"types": "../dist/urql-exchange-graphcache-extras.d.ts", | ||
"import": "../dist/urql-exchange-graphcache-extras.mjs", | ||
"require": "../dist/urql-exchange-graphcache-extras.js", | ||
"types": "../dist/urql-exchange-graphcache-extras.d.ts", | ||
"source": "../src/extras/index.ts" | ||
@@ -19,2 +19,2 @@ }, | ||
} | ||
} | ||
} |
{ | ||
"name": "@urql/exchange-graphcache", | ||
"version": "6.1.5-canary-7ddccc13", | ||
"version": "6.1.5-canary-c37a0fc3", | ||
"description": "A normalized and configurable cache exchange for urql", | ||
@@ -58,3 +58,3 @@ "sideEffects": false, | ||
"@0no-co/graphql.web": "^1.0.1", | ||
"@urql/core": "4.0.12-canary-7ddccc13", | ||
"@urql/core": "4.1.0-canary-c37a0fc3", | ||
"wonka": "^6.3.2" | ||
@@ -68,3 +68,3 @@ }, | ||
"react-dom": "^17.0.1", | ||
"@urql/core": "4.0.12-canary-7ddccc13", | ||
"@urql/core": "4.1.0-canary-c37a0fc3", | ||
"@urql/exchange-execute": "2.2.2", | ||
@@ -71,0 +71,0 @@ "@urql/introspection": "1.0.2", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1184664
6007
+ Added@urql/core@4.1.0-canary-c37a0fc3(transitive)
- Removed@urql/core@4.0.12-canary-7ddccc13(transitive)