@urql/core
Advanced tools
Comparing version 4.1.4 to 4.2.0-canary-94e0c310
@@ -737,2 +737,14 @@ var graphql_web = require('@0no-co/graphql.web'); | ||
} | ||
async function* parseMaybeJSON(response) { | ||
var text = await response.text(); | ||
try { | ||
var result = JSON.parse(text); | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(`Found response with content-type "text/plain" but it had a valid "application/json" response.`); | ||
} | ||
yield result; | ||
} catch (e) { | ||
throw new Error(text); | ||
} | ||
} | ||
async function* fetchOperation(operation, url, fetchOptions) { | ||
@@ -756,3 +768,3 @@ var networkMode = true; | ||
} else { | ||
throw new Error(await response.text()); | ||
results = parseMaybeJSON(response); | ||
} | ||
@@ -759,0 +771,0 @@ var pending; |
@@ -1,2 +0,2 @@ | ||
var e=require("@0no-co/graphql.web"),r=require("wonka"),t=r=>r&&r.message&&(r.extensions||"GraphQLError"===r.name)?r:"object"==typeof r&&r.message?new e.GraphQLError(r.message,r.nodes,r.source,r.positions,r.path,r,r.extensions||{}):new e.GraphQLError(r);class n extends Error{constructor(e){var r=(e.graphQLErrors||[]).map(t),n=((e,r)=>{var t="";if(e)return`[Network] ${e.message}`;if(r)for(var n of r)t&&(t+="\n"),t+=`[GraphQL] ${n.message}`;return t})(e.networkError,r);super(n),this.name="CombinedError",this.message=n,this.graphQLErrors=r,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var a=(e,r)=>{for(var t=0|(r||5381),n=0,a=0|e.length;n<a;n++)t=(t<<5)+t+e.charCodeAt(n);return t},o=new Set,s=new WeakMap,i=e=>{if(null===e||o.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return i(e.toJSON());if(Array.isArray(e)){var r="[";for(var t of e)r.length>1&&(r+=","),r+=i(t)||"null";return r+"]"}if(p!==c&&e instanceof p||d!==c&&e instanceof d)return"null";var n=Object.keys(e).sort();if(!n.length&&e.constructor&&e.constructor!==Object){var a=s.get(e)||Math.random().toString(36).slice(2);return s.set(e,a),i({__key:a})}o.add(e);var f="{";for(var l of n){var u=i(e[l]);u&&(f.length>1&&(f+=","),f+=i(l)+":"+u)}return o.delete(e),f+"}"},f=(e,r,t)=>{if(null==t||"object"!=typeof t||t.toJSON||o.has(t));else if(Array.isArray(t))for(var n=0,a=t.length;n<a;n++)f(e,`${r}.${n}`,t[n]);else if(t instanceof p||t instanceof d)e.set(r,t);else for(var s of(o.add(t),Object.keys(t)))f(e,`${r}.${s}`,t[s])},l=e=>(o.clear(),i(e));class c{}var p="undefined"!=typeof File?File:c,d="undefined"!=typeof Blob?Blob:c,u=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,y=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,h=(e,r)=>r%2==0?e.replace(y,"\n"):e,v=e=>e.split(u).map(h).join("").trim(),x=new Map,g=new Map,m=r=>{var t;return"string"==typeof r?t=v(r):r.loc&&g.get(r.__key)===r?t=r.loc.source.body:(t=x.get(r)||v(e.print(r)),x.set(r,t)),"string"==typeof r||r.loc||(r.loc={start:0,end:t.length,source:{body:t,name:"gql",locationOffset:{line:1,column:1}}}),t},b=e=>{var r=a(m(e));if(e.definitions){var t=k(e);t&&(r=a(`\n# ${t}`,r))}return r},w=r=>{var t,n;return"string"==typeof r?(t=b(r),n=g.get(t)||e.parse(r,{noLocation:!0})):(t=r.__key||b(r),n=g.get(t)||r),n.loc||m(n),n.__key=t,g.set(t,n),n},k=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.name?t.name.value:void 0},N=(e,r,t)=>{if(!("data"in r||"errors"in r&&Array.isArray(r.errors)))throw new Error("No Content");var a="subscription"===e.kind;return{operation:e,data:r.data,error:Array.isArray(r.errors)?new n({graphQLErrors:r.errors,response:t}):void 0,extensions:r.extensions?{...r.extensions}:void 0,hasNext:null==r.hasNext?a:r.hasNext,stale:!1}},O=(e,r)=>{if("object"==typeof e&&null!=e&&(!e.constructor||e.constructor===Object||Array.isArray(e))){for(var t of(e=Array.isArray(e)?[...e]:{...e},Object.keys(r)))e[t]=O(e[t],r[t]);return e}return r},E=(e,r,t,a)=>{var o=e.error?e.error.graphQLErrors:[],s=!!e.extensions||!!r.extensions,i={...e.extensions,...r.extensions},f=r.incremental;"path"in r&&(f=[r]);var l={data:e.data};if(f){var c=function(e){Array.isArray(e.errors)&&o.push(...e.errors),e.extensions&&(Object.assign(i,e.extensions),s=!0);var r="data",t=l,n=[];if(e.path)n=e.path;else if(a){var f=a.find((r=>r.id===e.id));n=e.subPath?[...f.path,...e.subPath]:f.path}for(var c=0,p=n.length;c<p;r=n[c++])t=t[r]=Array.isArray(t[r])?[...t[r]]:{...t[r]};if(e.items)for(var d=+r>=0?r:0,u=0,y=e.items.length;u<y;u++)t[d+u]=O(t[d+u],e.items[u]);else void 0!==e.data&&(t[r]=O(t[r],e.data))};for(var p of f)c(p)}else l.data=r.data||e.data,o=r.errors||o;return{operation:e.operation,data:l.data,error:o.length?new n({graphQLErrors:o,response:t}):void 0,extensions:s?i:void 0,hasNext:null!=r.hasNext?r.hasNext:e.hasNext,stale:!1}},A=(e,r,t)=>({operation:e,data:void 0,error:new n({networkError:r,response:t}),extensions:void 0,hasNext:!1,stale:!1}),j="undefined"!=typeof TextDecoder?new TextDecoder:null,S=/boundary="?([^=";]+)"?/i,q=/data: ?([^\n]+)/,L=e=>"Buffer"===e.constructor.name?e.toString():j.decode(e);async function*T(e){if(e.body[Symbol.asyncIterator])for await(var r of e.body)yield L(r);else{var t,n=e.body.getReader();try{for(;!(t=await n.read()).done;)yield L(t.value)}finally{n.cancel()}}}async function*_(e,r){var t,n="";for await(var a of e)for(n+=a;(t=n.indexOf(r))>-1;)yield n.slice(0,t),n=n.slice(t+r.length)}exports.CombinedError=n,exports.createRequest=(e,r,t)=>{var n=r||{},o=w(e),s=l(n),i=o.__key;return"{}"!==s&&(i=a(s,i)),{key:i,query:o,variables:n,extensions:t}},exports.getOperationType=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.operation},exports.keyDocument=w,exports.makeErrorResult=A,exports.makeFetchBody=function(e){return{query:e.extensions&&e.extensions.persistedQuery&&!e.extensions.persistedQuery.miss?void 0:m(e.query),operationName:k(e.query),variables:e.variables||void 0,extensions:e.extensions}},exports.makeFetchOptions=(e,r)=>{var t={accept:"subscription"===e.kind?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},n=("function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions)||{};if(n.headers)for(var a in n.headers)t[a.toLowerCase()]=n.headers[a];var s=((e,r)=>{var t,n;if(r&&("query"!==e.kind||!e.context.preferGetMethod)){var a=l(r),s=(t=r.variables,n=new Map,p===c&&d===c||(o.clear(),f(n,"variables",t)),n);if(s.size){var i=new FormData;i.append("operations",a),i.append("map",l({...[...s.keys()].map((e=>[e]))}));var u=0;for(var y of s.values())i.append(""+u++,y);return i}return a}})(e,r);return"string"!=typeof s||t["content-type"]||(t["content-type"]="application/json"),{...n,method:s?"POST":"GET",body:s,headers:t}},exports.makeFetchSource=function(e,t,n){var a;return"undefined"!=typeof AbortController&&(n.signal=(a=new AbortController).signal),r.onEnd((()=>{a&&a.abort()}))(r.filter((e=>!!e))(r.fromAsyncIterable(async function*(e,r,t){var n,a=!0,o=null;try{yield await Promise.resolve();var s,i,f=(n=await(e.context.fetch||fetch)(r,t)).headers.get("Content-Type")||"";if(/multipart\/mixed/i.test(f))s=async function*(e,r){var t,n=e.match(S),a="--"+(n?n[1]:"-"),o=!0;for await(var s of _(T(r),"\r\n"+a)){if(o){o=!1;var i=s.indexOf(a);if(!(i>-1))continue;s=s.slice(i+a.length)}try{yield t=JSON.parse(s.slice(s.indexOf("\r\n\r\n")+4))}catch(e){if(!t)throw e}if(t&&!1===t.hasNext)break}t&&!1!==t.hasNext&&(yield{hasNext:!1})}(f,n);else if(/text\/event-stream/i.test(f))s=async function*(e){var r;for await(var t of _(T(e),"\n\n")){var n=t.match(q);if(n){var a=n[1];try{yield r=JSON.parse(a)}catch(e){if(!r)throw e}if(r&&!1===r.hasNext)break}}r&&!1!==r.hasNext&&(yield{hasNext:!1})}(n);else{if(/text\//i.test(f))throw new Error(await n.text());s=async function*(e){yield JSON.parse(await e.text())}(n)}for await(var l of s)l.pending&&!o?i=l.pending:l.pending&&(i=[...i,...l.pending]),o=o?E(o,l,n,i):N(e,l,n),a=!1,yield o,a=!0;o||(yield o=N(e,{},n))}catch(r){if(!a)throw r;yield A(e,n&&(n.status<200||n.status>=300)&&n.statusText?new Error(n.statusText):r,n)}}(e,t,n))))},exports.makeFetchURL=(e,r)=>{var t="query"===e.kind&&e.context.preferGetMethod;if(!t||!r)return e.context.url;var n=new URL(e.context.url);for(var a in r){var o=r[a];o&&n.searchParams.set(a,"object"==typeof o?l(o):o)}var s=n.toString();return s.length>2047&&"force"!==t?(e.context.preferGetMethod=!1,e.context.url):s},exports.makeResult=N,exports.mergeResultPatch=E,exports.stringifyDocument=m,exports.stringifyVariables=l; | ||
var e=require("@0no-co/graphql.web"),r=require("wonka"),t=r=>r&&r.message&&(r.extensions||"GraphQLError"===r.name)?r:"object"==typeof r&&r.message?new e.GraphQLError(r.message,r.nodes,r.source,r.positions,r.path,r,r.extensions||{}):new e.GraphQLError(r);class a extends Error{constructor(e){var r=(e.graphQLErrors||[]).map(t),a=((e,r)=>{var t="";if(e)return`[Network] ${e.message}`;if(r)for(var a of r)t&&(t+="\n"),t+=`[GraphQL] ${a.message}`;return t})(e.networkError,r);super(a),this.name="CombinedError",this.message=a,this.graphQLErrors=r,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var n=(e,r)=>{for(var t=0|(r||5381),a=0,n=0|e.length;a<n;a++)t=(t<<5)+t+e.charCodeAt(a);return t},o=new Set,s=new WeakMap,i=e=>{if(null===e||o.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return i(e.toJSON());if(Array.isArray(e)){var r="[";for(var t of e)r.length>1&&(r+=","),r+=i(t)||"null";return r+"]"}if(p!==l&&e instanceof p||d!==l&&e instanceof d)return"null";var a=Object.keys(e).sort();if(!a.length&&e.constructor&&e.constructor!==Object){var n=s.get(e)||Math.random().toString(36).slice(2);return s.set(e,n),i({__key:n})}o.add(e);var f="{";for(var c of a){var u=i(e[c]);u&&(f.length>1&&(f+=","),f+=i(c)+":"+u)}return o.delete(e),f+"}"},f=(e,r,t)=>{if(null==t||"object"!=typeof t||t.toJSON||o.has(t));else if(Array.isArray(t))for(var a=0,n=t.length;a<n;a++)f(e,`${r}.${a}`,t[a]);else if(t instanceof p||t instanceof d)e.set(r,t);else for(var s of(o.add(t),Object.keys(t)))f(e,`${r}.${s}`,t[s])},c=e=>(o.clear(),i(e));class l{}var p="undefined"!=typeof File?File:l,d="undefined"!=typeof Blob?Blob:l,u=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,y=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,h=(e,r)=>r%2==0?e.replace(y,"\n"):e,v=e=>e.split(u).map(h).join("").trim(),x=new Map,g=new Map,m=r=>{var t;return"string"==typeof r?t=v(r):r.loc&&g.get(r.__key)===r?t=r.loc.source.body:(t=x.get(r)||v(e.print(r)),x.set(r,t)),"string"==typeof r||r.loc||(r.loc={start:0,end:t.length,source:{body:t,name:"gql",locationOffset:{line:1,column:1}}}),t},b=e=>{var r=n(m(e));if(e.definitions){var t=k(e);t&&(r=n(`\n# ${t}`,r))}return r},w=r=>{var t,a;return"string"==typeof r?(t=b(r),a=g.get(t)||e.parse(r,{noLocation:!0})):(t=r.__key||b(r),a=g.get(t)||r),a.loc||m(a),a.__key=t,g.set(t,a),a},k=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.name?t.name.value:void 0},N=(e,r,t)=>{if(!("data"in r||"errors"in r&&Array.isArray(r.errors)))throw new Error("No Content");var n="subscription"===e.kind;return{operation:e,data:r.data,error:Array.isArray(r.errors)?new a({graphQLErrors:r.errors,response:t}):void 0,extensions:r.extensions?{...r.extensions}:void 0,hasNext:null==r.hasNext?n:r.hasNext,stale:!1}},O=(e,r)=>{if("object"==typeof e&&null!=e&&(!e.constructor||e.constructor===Object||Array.isArray(e))){for(var t of(e=Array.isArray(e)?[...e]:{...e},Object.keys(r)))e[t]=O(e[t],r[t]);return e}return r},E=(e,r,t,n)=>{var o=e.error?e.error.graphQLErrors:[],s=!!e.extensions||!!r.extensions,i={...e.extensions,...r.extensions},f=r.incremental;"path"in r&&(f=[r]);var c={data:e.data};if(f){var l=function(e){Array.isArray(e.errors)&&o.push(...e.errors),e.extensions&&(Object.assign(i,e.extensions),s=!0);var r="data",t=c,a=[];if(e.path)a=e.path;else if(n){var f=n.find((r=>r.id===e.id));a=e.subPath?[...f.path,...e.subPath]:f.path}for(var l=0,p=a.length;l<p;r=a[l++])t=t[r]=Array.isArray(t[r])?[...t[r]]:{...t[r]};if(e.items)for(var d=+r>=0?r:0,u=0,y=e.items.length;u<y;u++)t[d+u]=O(t[d+u],e.items[u]);else void 0!==e.data&&(t[r]=O(t[r],e.data))};for(var p of f)l(p)}else c.data=r.data||e.data,o=r.errors||o;return{operation:e.operation,data:c.data,error:o.length?new a({graphQLErrors:o,response:t}):void 0,extensions:s?i:void 0,hasNext:null!=r.hasNext?r.hasNext:e.hasNext,stale:!1}},A=(e,r,t)=>({operation:e,data:void 0,error:new a({networkError:r,response:t}),extensions:void 0,hasNext:!1,stale:!1}),S="undefined"!=typeof TextDecoder?new TextDecoder:null,j=/boundary="?([^=";]+)"?/i,q=/data: ?([^\n]+)/,L=e=>"Buffer"===e.constructor.name?e.toString():S.decode(e);async function*T(e){if(e.body[Symbol.asyncIterator])for await(var r of e.body)yield L(r);else{var t,a=e.body.getReader();try{for(;!(t=await a.read()).done;)yield L(t.value)}finally{a.cancel()}}}async function*_(e,r){var t,a="";for await(var n of e)for(a+=n;(t=a.indexOf(r))>-1;)yield a.slice(0,t),a=a.slice(t+r.length)}exports.CombinedError=a,exports.createRequest=(e,r,t)=>{var a=r||{},o=w(e),s=c(a),i=o.__key;return"{}"!==s&&(i=n(s,i)),{key:i,query:o,variables:a,extensions:t}},exports.getOperationType=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.operation},exports.keyDocument=w,exports.makeErrorResult=A,exports.makeFetchBody=function(e){return{query:e.extensions&&e.extensions.persistedQuery&&!e.extensions.persistedQuery.miss?void 0:m(e.query),operationName:k(e.query),variables:e.variables||void 0,extensions:e.extensions}},exports.makeFetchOptions=(e,r)=>{var t={accept:"subscription"===e.kind?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},a=("function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions)||{};if(a.headers)for(var n in a.headers)t[n.toLowerCase()]=a.headers[n];var s=((e,r)=>{var t,a;if(r&&("query"!==e.kind||!e.context.preferGetMethod)){var n=c(r),s=(t=r.variables,a=new Map,p===l&&d===l||(o.clear(),f(a,"variables",t)),a);if(s.size){var i=new FormData;i.append("operations",n),i.append("map",c({...[...s.keys()].map((e=>[e]))}));var u=0;for(var y of s.values())i.append(""+u++,y);return i}return n}})(e,r);return"string"!=typeof s||t["content-type"]||(t["content-type"]="application/json"),{...a,method:s?"POST":"GET",body:s,headers:t}},exports.makeFetchSource=function(e,t,a){var n;return"undefined"!=typeof AbortController&&(a.signal=(n=new AbortController).signal),r.onEnd((()=>{n&&n.abort()}))(r.filter((e=>!!e))(r.fromAsyncIterable(async function*(e,r,t){var a,n=!0,o=null;try{yield await Promise.resolve();var s,i,f=(a=await(e.context.fetch||fetch)(r,t)).headers.get("Content-Type")||"";for await(var c of(s=/multipart\/mixed/i.test(f)?async function*(e,r){var t,a=e.match(j),n="--"+(a?a[1]:"-"),o=!0;for await(var s of _(T(r),"\r\n"+n)){if(o){o=!1;var i=s.indexOf(n);if(!(i>-1))continue;s=s.slice(i+n.length)}try{yield t=JSON.parse(s.slice(s.indexOf("\r\n\r\n")+4))}catch(e){if(!t)throw e}if(t&&!1===t.hasNext)break}t&&!1!==t.hasNext&&(yield{hasNext:!1})}(f,a):/text\/event-stream/i.test(f)?async function*(e){var r;for await(var t of _(T(e),"\n\n")){var a=t.match(q);if(a){var n=a[1];try{yield r=JSON.parse(n)}catch(e){if(!r)throw e}if(r&&!1===r.hasNext)break}}r&&!1!==r.hasNext&&(yield{hasNext:!1})}(a):/text\//i.test(f)?async function*(e){var r=await e.text();try{var t=JSON.parse(r);yield t}catch(e){throw new Error(r)}}(a):async function*(e){yield JSON.parse(await e.text())}(a),s))c.pending&&!o?i=c.pending:c.pending&&(i=[...i,...c.pending]),o=o?E(o,c,a,i):N(e,c,a),n=!1,yield o,n=!0;o||(yield o=N(e,{},a))}catch(r){if(!n)throw r;yield A(e,a&&(a.status<200||a.status>=300)&&a.statusText?new Error(a.statusText):r,a)}}(e,t,a))))},exports.makeFetchURL=(e,r)=>{var t="query"===e.kind&&e.context.preferGetMethod;if(!t||!r)return e.context.url;var a=new URL(e.context.url);for(var n in r){var o=r[n];o&&a.searchParams.set(n,"object"==typeof o?c(o):o)}var s=a.toString();return s.length>2047&&"force"!==t?(e.context.preferGetMethod=!1,e.context.url):s},exports.makeResult=N,exports.mergeResultPatch=E,exports.stringifyDocument=m,exports.stringifyVariables=c; | ||
//# sourceMappingURL=urql-core-chunk.min.js.map |
{ | ||
"name": "@urql/core", | ||
"version": "4.1.4", | ||
"version": "4.2.0-canary-94e0c310", | ||
"description": "The shared core for the highly customizable and versatile GraphQL client", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
918099
5400
3
40