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

@urql/core

Package Overview
Dependencies
Maintainers
31
Versions
263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/core - npm Package Compare versions

Comparing version 1.14.0 to 1.14.1

dist/0cc80063.min.js

6

CHANGELOG.md
# @urql/core
## 1.14.1
### Patch Changes
- ⚠️ Fix the production build overwriting the development build. Specifically in the previous release we mistakenly replaced all development bundles with production bundles. This doesn't have any direct influence on how these packages work, but prevented development warnings from being logged or full errors from being thrown, by [@kitten](https://github.com/kitten) (See [#1097](https://github.com/FormidableLabs/urql/pull/1097))
## 1.14.0

@@ -4,0 +10,0 @@

215

dist/3fe74c44.js

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

"use strict";var e=require("wonka"),r=require("graphql");function t(){return(t=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t,n=arguments[r];for(t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e}).apply(this,arguments)}var n=function(e){return"string"==typeof e?new r.GraphQLError(e):"object"==typeof e&&e.message?new r.GraphQLError(e.message,e.nodes,e.source,e.positions,e.path,e,e.extensions||{}):e};function o(){return this.message}var i=function(e){function r(r){var t=r.networkError,o=r.response,i=function(e,r){var t="";return void 0!==e?t="[Network] "+e.message:(void 0!==r&&r.forEach((function(e){t+="[GraphQL] "+e.message+"\n"})),t.trim())}(t,r=(r.graphQLErrors||[]).map(n));e.call(this,i),this.name="CombinedError",this.message=i,this.graphQLErrors=r,this.networkError=t,this.response=o}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r.prototype.toString=o,r}(Error),s=function(e,r){e|=0;for(var t=0,n=0|r.length;t<n;t++)e=(e<<5)+e+r.charCodeAt(t);return e},a=new Set,u=new WeakMap,c=function(e){if(null===e||a.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return c(e.toJSON());if(Array.isArray(e)){for(var r="[",t=0,n=e.length;t<n;t++){0<t&&(r+=",");var o=c(e[t]);r+=0<o.length?o:"null"}return r+"]"}if(!(r=Object.keys(e).sort()).length&&e.constructor&&e.constructor!==Object)return r=u.get(e)||Math.random().toString(36).slice(2),u.set(e,r),'{"__key":"'+r+'"}';for(a.add(e),t="{",n=0,o=r.length;n<o;n++){var i=r[n],s=c(e[i]);s&&(1<t.length&&(t+=","),t+=c(i)+":"+s)}return a.delete(e),t+"}"},p=function(e){return a.clear(),c(e)},f=function(e){return function(e){return s(5381,e)>>>0}(e.replace(/([\s,]|#[^\n\r]+)+/g," ").trim())},h=Object.create(null),l=function(e){for(var t=0,n=e.definitions.length;t<n;t++){var o=e.definitions[t];if(o.kind===r.Kind.OPERATION_DEFINITION&&o.name)return o.name.value}},d=function(e,r,t){return{operation:e,data:r.data,error:Array.isArray(r.errors)?new i({graphQLErrors:r.errors,response:t}):void 0,extensions:"object"==typeof r.extensions&&r.extensions||void 0}},v=function(e,r,t){return{operation:e,data:void 0,error:new i({networkError:r,response:t}),extensions:void 0}},y=function(e){return"query"===e.kind&&!!e.context.preferGetMethod};exports.CombinedError=i,exports._extends=t,exports.createRequest=function(e,t){if("string"==typeof e){var n=f(e);e=void 0!==h[n]?h[n]:r.parse(e,{noLocation:!0})}else void 0!==e.__key?n=e.__key:(n=f(r.print(e)),e=void 0!==h[n]?h[n]:e);return h[n]=e,e.__key=n,{key:t?s(n,p(t))>>>0:n,query:e,variables:t||{}}},exports.makeErrorResult=v,exports.makeFetchBody=function(e){return{query:r.print(e.query),operationName:l(e.query),variables:e.variables||void 0,extensions:void 0}},exports.makeFetchOptions=function(e,r){var n=y(e);return t({},e="function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions||{},{body:!n&&r?JSON.stringify(r):void 0,method:n?"GET":"POST",headers:n?e.headers:t({},{"content-type":"application/json"},e.headers)})},exports.makeFetchSource=function(r,t,n){return e.make((function(e){var o=e.next,i=e.complete,s="undefined"!=typeof AbortController?new AbortController:null,a=!1;return Promise.resolve().then((function(){if(!a)return s&&(n.signal=s.signal),function(e,r,t){var n,o=!1;return(e.context.fetch||fetch)(r,t).then((function(e){return n=e,o=200>e.status||e.status>=("manual"===t.redirect?400:300),e.json()})).then((function(r){if(!("data"in r)&&!("errors"in r))throw Error("No Content");return d(e,r,n)})).catch((function(r){if("AbortError"!==r.name)return v(e,o?Error(n.statusText):r,n)}))}(r,t,n)})).then((function(e){a||(a=!0,e&&o(e),i())})),function(){a=!0,s&&s.abort()}}))},exports.makeFetchURL=function(e,r){var t=y(e);return e=e.context.url,t&&r?(t=[],r.operationName&&t.push("operationName="+encodeURIComponent(r.operationName)),r.query&&t.push("query="+encodeURIComponent(r.query.replace(/([\s,]|#[^\n\r]+)+/g," ").trim())),r.variables&&t.push("variables="+encodeURIComponent(p(r.variables))),r.extensions&&t.push("extensions="+encodeURIComponent(p(r.extensions))),e+"?"+t.join("&")):e},exports.makeResult=d,exports.stringifyVariables=p;
"use strict";
function _extends() {
return (_extends = Object.assign || function(a) {
var b, c, d;
for (b = 1; b < arguments.length; b++) {
c = arguments[b];
for (d in c) {
Object.prototype.hasOwnProperty.call(c, d) && (a[d] = c[d]);
}
}
return a;
}).apply(this, arguments);
}
function _toString() {
return this.message;
}
var wonka = require("wonka"), graphql = require("graphql"), generateErrorMessage = function(a, b) {
var d = "";
if (void 0 !== a) {
return d = "[Network] " + a.message;
}
void 0 !== b && b.forEach((function c(a) {
d += "[GraphQL] " + a.message + "\n";
}));
return d.trim();
}, rehydrateGraphQlError = function(a) {
return "string" == typeof a ? new graphql.GraphQLError(a) : "object" == typeof a && a.message ? new graphql.GraphQLError(a.message, a.nodes, a.source, a.positions, a.path, a, a.extensions || {}) : a;
}, CombinedError = function(a) {
function b(c) {
var f, b = c.networkError, e = c.response;
c = (c.graphQLErrors || []).map(rehydrateGraphQlError);
f = generateErrorMessage(b, c);
a.call(this, f);
this.name = "CombinedError";
this.message = f;
this.graphQLErrors = c;
this.networkError = b;
this.response = e;
}
a && (b.__proto__ = a);
(b.prototype = Object.create(a && a.prototype)).constructor = b;
b.prototype.toString = _toString;
return b;
}(Error), phash = function(a, b) {
a |= 0;
for (var c = 0, d = 0 | b.length; c < d; c++) {
a = (a << 5) + a + b.charCodeAt(c);
}
return a;
}, hash = function(a) {
return phash(5381, a) >>> 0;
}, seen = new Set, cache = new WeakMap, stringify = function(a) {
var b, c, d, e, f, g;
if (null === a || seen.has(a)) {
return "null";
}
if ("object" != typeof a) {
return JSON.stringify(a) || "";
}
if (a.toJSON) {
return stringify(a.toJSON());
}
if (Array.isArray(a)) {
for (b = "[", c = 0, d = a.length; c < d; c++) {
0 < c && (b += ",");
b += 0 < (e = stringify(a[c])).length ? e : "null";
}
return b + "]";
}
if (!(b = Object.keys(a).sort()).length && a.constructor && a.constructor !== Object) {
return b = cache.get(a) || Math.random().toString(36).slice(2), cache.set(a, b),
'{"__key":"' + b + '"}';
}
seen.add(a);
c = "{";
d = 0;
for (e = b.length; d < e; d++) {
(g = stringify(a[f = b[d]])) && (1 < c.length && (c += ","), c += stringify(f) + ":" + g);
}
seen.delete(a);
return c + "}";
}, stringifyVariables = function(a) {
seen.clear();
return stringify(a);
}, hashQuery = function(a) {
return hash(a.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim());
}, docs = Object.create(null), createRequest = function(a, b) {
if ("string" == typeof a) {
var c = hashQuery(a);
a = void 0 !== docs[c] ? docs[c] : graphql.parse(a, {
noLocation: !0
});
} else {
void 0 !== a.__key ? c = a.__key : (c = hashQuery(graphql.print(a)), a = void 0 !== docs[c] ? docs[c] : a);
}
docs[c] = a;
a.__key = c;
return {
key: b ? phash(c, stringifyVariables(b)) >>> 0 : c,
query: a,
variables: b || {}
};
}, getOperationName = function(a) {
var b, c, d;
for (b = 0, c = a.definitions.length; b < c; b++) {
if ((d = a.definitions[b]).kind === graphql.Kind.OPERATION_DEFINITION && d.name) {
return d.name.value;
}
}
}, makeResult = function(a, b, c) {
return {
operation: a,
data: b.data,
error: Array.isArray(b.errors) ? new CombinedError({
graphQLErrors: b.errors,
response: c
}) : void 0,
extensions: "object" == typeof b.extensions && b.extensions || void 0
};
}, makeErrorResult = function(a, b, c) {
return {
operation: a,
data: void 0,
error: new CombinedError({
networkError: b,
response: c
}),
extensions: void 0
};
}, shouldUseGet = function(a) {
return "query" === a.kind && !!a.context.preferGetMethod;
}, makeFetchBody = function(a) {
return {
query: graphql.print(a.query),
operationName: getOperationName(a.query),
variables: a.variables || void 0,
extensions: void 0
};
}, makeFetchURL = function(a, b) {
var c = shouldUseGet(a);
a = a.context.url;
if (!c || !b) {
return a;
}
c = [];
b.operationName && c.push("operationName=" + encodeURIComponent(b.operationName));
b.query && c.push("query=" + encodeURIComponent(b.query.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim()));
b.variables && c.push("variables=" + encodeURIComponent(stringifyVariables(b.variables)));
b.extensions && c.push("extensions=" + encodeURIComponent(stringifyVariables(b.extensions)));
return a + "?" + c.join("&");
}, makeFetchOptions = function(a, b) {
var c = shouldUseGet(a);
return _extends({}, a = "function" == typeof a.context.fetchOptions ? a.context.fetchOptions() : a.context.fetchOptions || {}, {
body: !c && b ? JSON.stringify(b) : void 0,
method: c ? "GET" : "POST",
headers: c ? a.headers : _extends({}, {
"content-type": "application/json"
}, a.headers)
});
}, executeFetch = function(a, b, c) {
var e, d = !1;
return (a.context.fetch || fetch)(b, c).then((function(a) {
e = a;
d = 200 > a.status || a.status >= ("manual" === c.redirect ? 400 : 300);
return a.json();
})).then((function(b) {
if (!("data" in b) && !("errors" in b)) {
throw Error("No Content");
}
return makeResult(a, b, e);
})).catch((function(b) {
if ("AbortError" !== b.name) {
return makeErrorResult(a, d ? Error(e.statusText) : b, e);
}
}));
}, makeFetchSource = function(a, b, c) {
return wonka.make((function(d) {
var e = d.next, f = d.complete, g = "undefined" != typeof AbortController ? new AbortController : null, h = !1;
Promise.resolve().then((function() {
if (!h) {
return g && (c.signal = g.signal), executeFetch(a, b, c);
}
})).then((function(a) {
h || (h = !0, a && e(a), f());
}));
return function() {
h = !0;
g && g.abort();
};
}));
};
exports.CombinedError = CombinedError;
exports._extends = _extends;
exports.createRequest = createRequest;
exports.makeErrorResult = makeErrorResult;
exports.makeFetchBody = makeFetchBody;
exports.makeFetchOptions = makeFetchOptions;
exports.makeFetchSource = makeFetchSource;
exports.makeFetchURL = makeFetchURL;
exports.makeResult = makeResult;
exports.stringifyVariables = stringifyVariables;
//# sourceMappingURL=3fe74c44.js.map

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

"use strict";var e=require("./3fe74c44.js");exports.makeFetchBody=e.makeFetchBody,exports.makeFetchOptions=e.makeFetchOptions,exports.makeFetchSource=e.makeFetchSource,exports.makeFetchURL=e.makeFetchURL;
"use strict";
var fetchSource = require("./3fe74c44.js");
exports.makeFetchBody = fetchSource.makeFetchBody;
exports.makeFetchOptions = fetchSource.makeFetchOptions;
exports.makeFetchSource = fetchSource.makeFetchSource;
exports.makeFetchURL = fetchSource.makeFetchURL;
//# sourceMappingURL=urql-core-internal.js.map

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

"use strict";var e=require("./3fe74c44.js"),t=require("wonka"),r=require("graphql"),n=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){n(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):n(e[r],t);return t};function o(e,t,r){return r.indexOf(e)===t}var i=function(e){return n(e).filter(o)};function u(e){return e.kind===r.Kind.FIELD&&"__typename"===e.name.value}var a=function(t){if(t.selectionSet&&!t.selectionSet.selections.some(u))return e._extends({},t,{selectionSet:e._extends({},t.selectionSet,{selections:t.selectionSet.selections.concat([{kind:r.Kind.FIELD,name:{kind:r.Kind.NAME,value:"__typename"}}])})})},c=function(e){var t=r.visit(e,{Field:a,InlineFragment:a});return t.__key=e.__key,t},s=function(e){return e&&"object"==typeof e?Object.keys(e).reduce((function(t,r){var n=e[r];return"__typename"===r?Object.defineProperty(t,"__typename",{enumerable:!1,value:n}):t[r]=Array.isArray(n)?n.map(s):n&&"object"==typeof n&&"__typename"in n?s(n):n,t}),{}):e};function f(e){return e.toPromise=function(){return t.toPromise(t.take(1)(e))},e}function p(e,t,r){return r||(r=t.context),{key:t.key,query:t.query,variables:t.variables,kind:e,context:r,get operationName(){return this.kind}}}var h=function(t,r){return p(t.kind,t,e._extends({},t.context,{meta:e._extends({},t.context.meta,r)}))},d=function(){},l=function(e){return"subscription"!==(e=e.kind)&&"query"!==e};function y(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var k=function(e){return"mutation"!==(e=e.kind)&&"query"!==e};function v(e){var t=p(e.kind,e);return t.query=c(e.query),t}function x(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}function m(e){return h(e,{cacheOutcome:"miss"})}function q(e){return k(e)}var g=function(r){function n(t){var r=s.get(t.key);return r=e._extends({},r,{operation:h(t,{cacheOutcome:r?"hit":"miss"})}),"cache-and-network"===t.context.requestPolicy&&(r.stale=!0,b(c,t)),r}function o(e){return!k(e)&&y(e)}function i(e){e.operation&&"mutation"===e.operation.kind?d(e):e.operation&&"query"===e.operation.kind&&l(e)}function u(e){return!k(e)&&!y(e)}var a=r.forward,c=r.client;r=r.dispatchDebug;var s=new Map,f=Object.create(null),p=v,d=O(s,f,c,r),l=E(s,f),y=function(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(e){var r=t.share(e);return e=t.map(n)(t.filter(o)(r)),r=t.tap(i)(a(t.filter(x)(t.map(m)(t.merge([t.map(p)(t.filter(u)(r)),t.filter(q)(r)]))))),t.merge([e,r])}},b=function(t,r){return t.reexecuteOperation(p(r.kind,r,e._extends({},r.context,{requestPolicy:"network-only"})))},O=function(e,t,r,n){function o(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),b(r,n)}}return function(e){function r(e){n.add(e)}var n=new Set,u=e.operation.context.additionalTypenames;(e=i(e.data).concat(u||[])).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),n.forEach(o)}},E=function(e,t){return function(r){var n=r.operation,o=r.data,u=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),i(r.data).concat(u||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},w=function(e){var r=e.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.kind)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(e){return e=t.filter(o)(e),t.tap(i)(r(e))}};function _(e){return"query"===e.kind||"mutation"===e.kind}function S(e){return"query"!==e.kind&&"mutation"!==e.kind}var R=function(r){var n=r.forward;return function(r){var o=t.share(r);r=t.mergeMap((function(r){var n=r.key,i=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(o),u=e.makeFetchBody(r),a=e.makeFetchURL(r,u);return u=e.makeFetchOptions(r,u),t.onPush((function(e){}))(t.takeUntil(i)(e.makeFetchSource(r,a,u)))}))(t.filter(_)(o));var i=n(t.filter(S)(o));return t.merge([r,i])}};function P(){return!1}var M=function(e){function r(e){}return function(e){return t.filter(P)(t.tap(r)(e))}},Q=M(),j=function(e){return function(t){var r=t.client;return e.reduceRight((function(e,t){return t({client:r,forward:e,dispatchDebug:function(e){}})}),t.forward)}},C=[w,g,R],D=function(r){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(t){return e._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},t,{requestPolicy:(t||{}).requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return p(e,t,n.createOperationContext(r))},this.executeQuery=function(e,r){e=n.createRequestOperation("query",e,r);var o=n.executeRequestOperation(e);return(e=e.context.pollInterval)?t.switchMap((function(){return o}))(t.merge([t.fromValue(0),t.interval(e)])):o},this.executeSubscription=function(e,t){return e=n.createRequestOperation("subscription",e,t),n.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=n.createRequestOperation("mutation",e,t),n.executeRequestOperation(e)};var o=d;this.url=r.url,this.fetchOptions=r.fetchOptions,this.fetch=r.fetch,this.suspense=!!r.suspense,this.requestPolicy=r.requestPolicy||"cache-first",this.preferGetMethod=!!r.preferGetMethod,this.maskTypename=!!r.maskTypename;var i=t.makeSubject(),u=i.next;this.operations$=i.source;var a=!1;this.dispatchOperation=function(e){for(a=!0,e&&u(e);e=n.queue.shift();)u(e);a=!1},this.reexecuteOperation=function(e){("mutation"===e.kind||0<(n.activeOperations[e.key]||0))&&(n.queue.push(e),a||Promise.resolve().then(n.dispatchOperation))},r=j(void 0!==r.exchanges?r.exchanges:C),this.results$=t.share(r({client:this,dispatchDebug:o,forward:M()})(this.operations$)),t.publish(this.results$)};function L(e){return e.data=s(e.data),e}D.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},D.prototype.onOperationEnd=function(e){var t=e.key,r=this.activeOperations[t]||0;0>=(this.activeOperations[t]=0>=r?0:r-1)&&this.dispatchOperation(p("teardown",e,e.context))},D.prototype.executeRequestOperation=function(e){var r=this,n=e.key,o=e.kind,i=t.filter((function(e){return e.operation.key===n}))(this.results$);if(this.maskTypename&&(i=t.map(L)(i)),"mutation"===o)return t.take(1)(t.onStart((function(){return r.dispatchOperation(e)}))(i));var u=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(this.operations$);return i=t.onEnd((function(){r.onOperationEnd(e)}))(t.onStart((function(){r.onOperationStart(e)}))(t.takeUntil(u)(i))),!1!==e.context.suspense&&this.suspense&&"query"===o?function(e){return function(r){var n=t.share(e),o=!1,i=!1;if(t.onPush((function(){return o=!0}))(t.takeWhile((function(){return!i}))(n))(r),!o)throw i=!0,r(0),t.toPromise(t.take(1)(n))}}(i):i},D.prototype.query=function(t,r,n){return n&&"boolean"==typeof n.suspense||(n=e._extends({},n,{suspense:!1})),f(this.executeQuery(e.createRequest(t,r),n))},D.prototype.readQuery=function(r,n,o){var i=null;return t.subscribe((function(e){i=e}))(this.executeQuery(e.createRequest(r,n),o)).unsubscribe(),i},D.prototype.subscription=function(t,r,n){return this.executeSubscription(e.createRequest(t,r),n)},D.prototype.mutation=function(t,r,n){return f(this.executeMutation(e.createRequest(t,r),n))},exports.CombinedError=e.CombinedError,exports.createRequest=e.createRequest,exports.makeErrorResult=e.makeErrorResult,exports.makeResult=e.makeResult,exports.stringifyVariables=e.stringifyVariables,exports.Client=D,exports.cacheExchange=g,exports.composeExchanges=j,exports.createClient=function(e){return new D(e)},exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=w,exports.defaultExchanges=C,exports.errorExchange=function(e){function r(e){var t=e.error;e=e.operation,t&&n(t,e)}var n=e.onError;return function(e){var n=e.forward;return function(e){return t.tap(r)(n(e))}}},exports.fallbackExchangeIO=Q,exports.fetchExchange=R,exports.formatDocument=c,exports.makeOperation=p,exports.maskTypename=s,exports.ssrExchange=function(r){function n(){for(var e;e=s.shift();)delete c[e]}function o(e){return!p(e)}function i(t){return function(t,r){var n=r.error;return{operation:t,data:(r=r.data)?JSON.parse(r):void 0,extensions:void 0,error:n?new e.CombinedError({networkError:n.networkError?Error(n.networkError):void 0,graphQLErrors:n.graphQLErrors&&n.graphQLErrors.length?n.graphQLErrors:void 0}):void 0}}(t,c[t.key])}function u(e){return p(e)}function a(e){var t=e.operation;l(t)||(e=function(e){var t=e.error;return e={data:JSON.stringify(e.data),error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(y),networkError:t.networkError?""+t.networkError:void 0}),e}(e),c[t.key]=e)}var c={},s=[],f=function(e){s.push(e.operation.key),1===s.length&&Promise.resolve().then(n)},p=function(e){return!l(e)&&void 0!==c[e.key]},h=function(e){var n=e.client,c=e.forward;return function(e){var s=r&&"boolean"==typeof r.isClient?!!r.isClient:!n.suspense,p=t.share(e);return e=c(t.filter(o)(p)),p=t.map(i)(t.filter(u)(p)),s?p=t.tap(f)(p):e=t.tap(a)(e),t.merge([e,p])}};return h.restoreData=function(t){return e._extends(c,t)},h.extractData=function(){return e._extends({},c)},r&&r.initialState&&h.restoreData(r.initialState),h},exports.subscriptionExchange=function(n){function o(e){return"subscription"===(e=e.kind)||!!u&&("query"===e||"mutation"===e)}var i=n.forwardSubscription,u=n.enableAllOperations;return function(n){function u(e){return!f(e)}var a=n.client,c=n.forward,s=function(n){var o=i({key:n.key.toString(36),query:r.print(n.query),variables:n.variables,context:e._extends({},n.context)});return t.make((function(t){function r(t){return s(e.makeResult(n,t))}function i(t){return s(e.makeErrorResult(n,t))}function u(){h||(h=!0,"subscription"===n.kind&&a.reexecuteOperation(p("teardown",n,n.context)),f())}var c,s=t.next,f=t.complete,h=!1;return Promise.resolve().then((function(){h||(c=o.subscribe({next:r,error:i,complete:u}))})),function(){h=!0,c&&c.unsubscribe()}}))},f=o;return function(e){var r=t.share(e);e=t.mergeMap((function(e){var n=e.key,o=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(r);return t.takeUntil(o)(s(e))}))(t.filter(f)(r));var n=c(t.filter(u)(r));return t.merge([e,n])}}};
"use strict";
function _ref2(a, b, c) {
return c.indexOf(a) === b;
}
function _ref3(a) {
return a.kind === graphql.Kind.FIELD && "__typename" === a.name.value;
}
function withPromise(a) {
a.toPromise = function() {
return wonka.toPromise(wonka.take(1)(a));
};
return a;
}
function makeOperation(a, b, c) {
c || (c = b.context);
return {
key: b.key,
query: b.query,
variables: b.variables,
kind: a,
context: c,
get operationName() {
"production" !== process.env.NODE_ENV && deprecationWarning(DEPRECATED_operationName);
return this.kind;
}
};
}
function _ref(a) {
return a.path || a.extensions ? {
message: a.message,
path: a.path,
extensions: a.extensions
} : a.message;
}
function _ref$1(a) {
var b = makeOperation(a.kind, a);
b.query = formatDocument(a.query);
return b;
}
function _ref5(a) {
return "query" !== a.kind || "cache-only" !== a.context.requestPolicy;
}
function _ref6(a) {
return addMetadata(a, {
cacheOutcome: "miss"
});
}
function _ref8(a) {
return shouldSkip$1(a);
}
function _ref2$1(a) {
return console.log("[Exchange debug]: Completed operation: ", a);
}
function _ref3$1(a) {
return console.log("[Exchange debug]: Incoming operation: ", a);
}
function _ref$2(a) {
return "query" === a.kind || "mutation" === a.kind;
}
function _ref2$2(a) {
return "query" !== a.kind && "mutation" !== a.kind;
}
function _ref$3() {
return !1;
}
function _ref3$2(a) {
a.data = maskTypename(a.data);
return a;
}
var fetchSource = require("./3fe74c44.js"), wonka = require("wonka"), graphql = require("graphql"), collectTypes = function(a, b) {
void 0 === b && (b = []);
if (Array.isArray(a)) {
a.forEach((function c(a) {
collectTypes(a, b);
}));
} else if ("object" == typeof a && null !== a) {
for (var d in a) {
"__typename" === d && "string" == typeof a[d] ? b.push(a[d]) : collectTypes(a[d], b);
}
}
return b;
}, collectTypesFromResponse = function(a) {
return collectTypes(a).filter(_ref2);
}, formatNode = function(a) {
if (a.selectionSet && !a.selectionSet.selections.some(_ref3)) {
return fetchSource._extends({}, a, {
selectionSet: fetchSource._extends({}, a.selectionSet, {
selections: a.selectionSet.selections.concat([ {
kind: graphql.Kind.FIELD,
name: {
kind: graphql.Kind.NAME,
value: "__typename"
}
} ])
})
});
}
}, formatDocument = function(a) {
var b = graphql.visit(a, {
Field: formatNode,
InlineFragment: formatNode
});
b.__key = a.__key;
return b;
}, toSuspenseSource = function(a) {
return function(b) {
var c = wonka.share(a), d = !1, f = !1;
wonka.onPush((function() {
return d = !0;
}))(wonka.takeWhile((function() {
return !f;
}))(c))(b);
if (!d) {
throw f = !0, b(0), wonka.toPromise(wonka.take(1)(c));
}
};
}, maskTypename = function(a) {
return a && "object" == typeof a ? Object.keys(a).reduce((function(b, c) {
var d = a[c];
"__typename" === c ? Object.defineProperty(b, "__typename", {
enumerable: !1,
value: d
}) : Array.isArray(d) ? b[c] = d.map(maskTypename) : b[c] = d && "object" == typeof d && "__typename" in d ? maskTypename(d) : d;
return b;
}), {}) : a;
}, issuedWarnings = {}, deprecationWarning = function(a) {
var b = a.key;
a = a.message;
issuedWarnings[b] || (console.warn("[WARNING: Deprecated] " + a), issuedWarnings[b] = !0);
}, DEPRECATED_operationName = {
key: "Operation.operationName",
message: 'The "Operation.operationName" property has been deprecated and will be removed in a future release of urql. Use "Operation.kind" instead.'
}, addMetadata = function(a, b) {
return makeOperation(a.kind, a, fetchSource._extends({}, a.context, {
meta: fetchSource._extends({}, a.context.meta, b)
}));
}, noop = function() {}, shouldSkip = function(a) {
return "subscription" !== (a = a.kind) && "query" !== a;
}, serializeResult = function(a) {
var b = a.error;
a = {
data: JSON.stringify(a.data),
error: void 0
};
b && (a.error = {
graphQLErrors: b.graphQLErrors.map(_ref),
networkError: b.networkError ? "" + b.networkError : void 0
});
return a;
}, deserializeResult = function(a, b) {
var c = b.error;
return {
operation: a,
data: (b = b.data) ? JSON.parse(b) : void 0,
extensions: void 0,
error: c ? new fetchSource.CombinedError({
networkError: c.networkError ? Error(c.networkError) : void 0,
graphQLErrors: c.graphQLErrors && c.graphQLErrors.length ? c.graphQLErrors : void 0
}) : void 0
};
}, ssrExchange = function(a) {
function b() {
for (var a; a = g.shift(); ) {
delete k[a];
}
}
function c(a) {
return !m(a);
}
function d(a) {
return deserializeResult(a, k[a.key]);
}
function f(a) {
return m(a);
}
function h(a) {
var b = a.operation;
shouldSkip(b) || (a = serializeResult(a), k[b.key] = a);
}
var k = {}, g = [], e = function(a) {
g.push(a.operation.key);
1 === g.length && Promise.resolve().then(b);
}, m = function(a) {
return !shouldSkip(a) && void 0 !== k[a.key];
}, l = function(b) {
var k = b.client, q = b.forward;
return function(b) {
var l = a && "boolean" == typeof a.isClient ? !!a.isClient : !k.suspense, g = wonka.share(b);
b = q(wonka.filter(c)(g));
g = wonka.map(d)(wonka.filter(f)(g));
l ? g = wonka.tap(e)(g) : b = wonka.tap(h)(b);
return wonka.merge([ b, g ]);
};
};
l.restoreData = function(a) {
return fetchSource._extends(k, a);
};
l.extractData = function() {
return fetchSource._extends({}, k);
};
a && a.initialState && l.restoreData(a.initialState);
return l;
}, shouldSkip$1 = function(a) {
return "mutation" !== (a = a.kind) && "query" !== a;
}, cacheExchange = function(a) {
function b(a) {
var b = e.get(a.key);
"production" !== process.env.NODE_ENV && g(fetchSource._extends({}, {
operation: a
}, b ? {
type: "cacheHit",
message: "The result was successfully retried from the cache"
} : {
type: "cacheMiss",
message: "The result could not be retrieved from the cache"
}));
b = fetchSource._extends({}, b, {
operation: addMetadata(a, {
cacheOutcome: b ? "hit" : "miss"
})
});
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(k, a));
return b;
}
function c(a) {
return !shouldSkip$1(a) && n(a);
}
function d(a) {
a.operation && "mutation" === a.operation.kind ? l(a) : a.operation && "query" === a.operation.kind && p(a);
}
function f(a) {
return !shouldSkip$1(a) && !n(a);
}
var m, l, p, n, h = a.forward, k = a.client, g = a.dispatchDebug, e = new Map;
a = Object.create(null);
m = _ref$1, l = afterMutation(e, a, k, g), p = afterQuery(e, a), n = function(a) {
var c = a.context.requestPolicy;
return "query" === a.kind && "network-only" !== c && ("cache-only" === c || e.has(a.key));
};
return function(a) {
var e = wonka.share(a);
a = wonka.map(b)(wonka.filter(c)(e));
e = wonka.tap(d)(h(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(m)(wonka.filter(f)(e)), wonka.filter(_ref8)(e) ])))));
return wonka.merge([ a, e ]);
};
}, reexecuteOperation = function(a, b) {
return a.reexecuteOperation(makeOperation(b.kind, b, fetchSource._extends({}, b.context, {
requestPolicy: "network-only"
})));
}, afterMutation = function(a, b, c, d) {
function f(b) {
if (a.has(b)) {
var d = a.get(b).operation;
a.delete(b);
reexecuteOperation(c, d);
}
}
return function(a) {
function c(a) {
g.add(a);
}
var g = new Set, e = a.operation.context.additionalTypenames;
e = collectTypesFromResponse(a.data).concat(e || []);
"production" !== process.env.NODE_ENV && d({
type: "cacheInvalidation",
message: "The following typenames have been invalidated: " + e,
operation: a.operation,
data: {
typenames: e,
response: a
},
source: "cacheExchange"
});
e.forEach((function(a) {
(a = b[a] || (b[a] = new Set)).forEach(c);
a.clear();
}));
g.forEach(f);
};
}, afterQuery = function(a, b) {
return function(c) {
var d = c.operation, f = c.data, h = d.context.additionalTypenames;
null != f && (a.set(d.key, {
operation: d,
data: f,
error: c.error
}), collectTypesFromResponse(c.data).concat(h || []).forEach((function(a) {
(b[a] || (b[a] = new Set)).add(d.key);
})));
};
}, subscriptionExchange = function(a) {
function b(a) {
return "subscription" === (a = a.kind) || !!d && ("query" === a || "mutation" === a);
}
var c = a.forwardSubscription, d = a.enableAllOperations;
return function(a) {
function d(a) {
return !m(a);
}
var f = a.client, g = a.forward, e = function(a) {
var b = c({
key: a.key.toString(36),
query: graphql.print(a.query),
variables: a.variables,
context: fetchSource._extends({}, a.context)
});
return wonka.make((function(c) {
function d(b) {
return g(fetchSource.makeResult(a, b));
}
function e(b) {
return g(fetchSource.makeErrorResult(a, b));
}
function k() {
l || (l = !0, "subscription" === a.kind && f.reexecuteOperation(makeOperation("teardown", a, a.context)),
h());
}
var m, g = c.next, h = c.complete, l = !1;
Promise.resolve().then((function() {
l || (m = b.subscribe({
next: d,
error: e,
complete: k
}));
}));
return function() {
l = !0;
m && m.unsubscribe();
};
}));
}, m = b;
return function(a) {
var c, b = wonka.share(a);
a = wonka.mergeMap((function(a) {
var c = a.key, d = wonka.filter((function(a) {
return "teardown" === a.kind && a.key === c;
}))(b);
return wonka.takeUntil(d)(e(a));
}))(wonka.filter(m)(b));
c = g(wonka.filter(d)(b));
return wonka.merge([ a, c ]);
};
};
}, debugExchange = function(a) {
var d = a.forward;
return "production" === process.env.NODE_ENV ? function b(a) {
return d(a);
} : function c(a) {
return wonka.tap(_ref2$1)(d(wonka.tap(_ref3$1)(a)));
};
}, dedupExchange = function(a) {
var b = a.forward, c = a.dispatchDebug, d = new Set, f = function(a) {
var b = a.key, e = a.kind;
if ("teardown" === e) {
return d.delete(b), !0;
}
if ("query" !== e && "subscription" !== e) {
return !0;
}
e = d.has(b);
d.add(b);
e && "production" !== process.env.NODE_ENV && c({
type: "dedup",
message: "An operation has been deduped.",
operation: a,
source: "dedupExchange"
});
return !e;
}, h = function(a) {
d.delete(a.operation.key);
};
return function(a) {
a = wonka.filter(f)(a);
return wonka.tap(h)(b(a));
};
}, fetchExchange = function(a) {
var b = a.forward, c = a.dispatchDebug;
return function(a) {
var h, d = wonka.share(a);
a = wonka.mergeMap((function(a) {
var b = a.key, e = wonka.filter((function(a) {
return "teardown" === a.kind && a.key === b;
}))(d), f = fetchSource.makeFetchBody(a), h = fetchSource.makeFetchURL(a, f), k = fetchSource.makeFetchOptions(a, f);
"production" !== process.env.NODE_ENV && c({
type: "fetchRequest",
message: "A fetch request is being executed.",
operation: a,
data: {
url: h,
fetchOptions: k
},
source: "fetchExchange"
});
return wonka.onPush((function(b) {
var d = b.data ? void 0 : b.error;
"production" !== process.env.NODE_ENV && c({
type: d ? "fetchError" : "fetchSuccess",
message: "A " + (d ? "failed" : "successful") + " fetch response has been returned.",
operation: a,
data: {
url: h,
fetchOptions: k,
value: d || b
},
source: "fetchExchange"
});
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, h, k)));
}))(wonka.filter(_ref$2)(d));
h = b(wonka.filter(_ref2$2)(d));
return wonka.merge([ a, h ]);
};
}, fallbackExchange = function(a) {
function b(a) {
if ("teardown" !== a.kind && "production" !== process.env.NODE_ENV) {
var b = 'No exchange has handled operations of kind "' + a.kind + "\". Check whether you've added an exchange responsible for these operations.";
"production" !== process.env.NODE_ENV && c({
type: "fallbackCatch",
message: b,
operation: a,
source: "fallbackExchange"
});
console.warn(b);
}
}
var c = a.dispatchDebug;
return function(a) {
return wonka.filter(_ref$3)(wonka.tap(b)(a));
};
}, fallbackExchangeIO = fallbackExchange({
dispatchDebug: noop
}), composeExchanges = function(a) {
return function(b) {
var c = b.client, d = b.dispatchDebug;
return a.reduceRight((function(a, b) {
return b({
client: c,
forward: a,
dispatchDebug: function(a) {
"production" !== process.env.NODE_ENV && d(fetchSource._extends({}, {
timestamp: Date.now(),
source: b.name
}, a));
}
});
}), b.forward);
};
}, errorExchange = function(a) {
function b(a) {
var b = a.error;
a = a.operation;
b && c(b, a);
}
var c = a.onError;
return function(a) {
var c = a.forward;
return function(a) {
return wonka.tap(b)(c(a));
};
};
}, defaultExchanges = [ dedupExchange, cacheExchange, fetchExchange ], createClient = function(a) {
return new Client(a);
}, Client = function(a) {
var d, f, h, k, g, c = this;
this.activeOperations = Object.create(null);
this.queue = [];
this.createOperationContext = function(a) {
return fetchSource._extends({}, {
url: c.url,
fetchOptions: c.fetchOptions,
fetch: c.fetch,
preferGetMethod: c.preferGetMethod
}, a, {
requestPolicy: (a || {}).requestPolicy || c.requestPolicy
});
};
this.createRequestOperation = function(a, b, d) {
return makeOperation(a, b, c.createOperationContext(d));
};
this.executeQuery = function(a, b) {
a = c.createRequestOperation("query", a, b);
var e = c.executeRequestOperation(a);
return (a = a.context.pollInterval) ? wonka.switchMap((function d() {
return e;
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a) ])) : e;
};
this.executeSubscription = function(a, b) {
a = c.createRequestOperation("subscription", a, b);
return c.executeRequestOperation(a);
};
this.executeMutation = function(a, b) {
a = c.createRequestOperation("mutation", a, b);
return c.executeRequestOperation(a);
};
if ("production" !== process.env.NODE_ENV && !a.url) {
throw Error("You are creating an urql-client without a url.");
}
d = noop;
if ("production" !== process.env.NODE_ENV) {
f = (d = wonka.makeSubject()).next, h = d.source;
this.subscribeToDebugTarget = function b(a) {
return wonka.subscribe(a)(h);
};
d = f;
}
this.url = a.url;
this.fetchOptions = a.fetchOptions;
this.fetch = a.fetch;
this.suspense = !!a.suspense;
this.requestPolicy = a.requestPolicy || "cache-first";
this.preferGetMethod = !!a.preferGetMethod;
this.maskTypename = !!a.maskTypename;
f = wonka.makeSubject();
k = f.next;
this.operations$ = f.source;
g = !1;
this.dispatchOperation = function(a) {
g = !0;
for (a && k(a); a = c.queue.shift(); ) {
k(a);
}
g = !1;
};
this.reexecuteOperation = function(a) {
if ("mutation" === a.kind || 0 < (c.activeOperations[a.key] || 0)) {
c.queue.push(a), g || Promise.resolve().then(c.dispatchOperation);
}
};
a = composeExchanges(void 0 !== a.exchanges ? a.exchanges : defaultExchanges);
this.results$ = wonka.share(a({
client: this,
dispatchDebug: d,
forward: fallbackExchange({
dispatchDebug: d
})
})(this.operations$));
wonka.publish(this.results$);
};
Client.prototype.onOperationStart = function(a) {
var b = a.key;
this.activeOperations[b] = (this.activeOperations[b] || 0) + 1;
this.dispatchOperation(a);
};
Client.prototype.onOperationEnd = function(a) {
var b = a.key, c = this.activeOperations[b] || 0;
0 >= (this.activeOperations[b] = 0 >= c ? 0 : c - 1) && this.dispatchOperation(makeOperation("teardown", a, a.context));
};
Client.prototype.executeRequestOperation = function(a) {
var k, c = this, d = a.key, f = a.kind, h = wonka.filter((function(a) {
return a.operation.key === d;
}))(this.results$);
this.maskTypename && (h = wonka.map(_ref3$2)(h));
if ("mutation" === f) {
return wonka.take(1)(wonka.onStart((function b() {
return c.dispatchOperation(a);
}))(h));
}
k = wonka.filter((function(a) {
return "teardown" === a.kind && a.key === d;
}))(this.operations$);
h = wonka.onEnd((function() {
c.onOperationEnd(a);
}))(wonka.onStart((function() {
c.onOperationStart(a);
}))(wonka.takeUntil(k)(h)));
return !1 !== a.context.suspense && this.suspense && "query" === f ? toSuspenseSource(h) : h;
};
Client.prototype.query = function(a, b, c) {
c && "boolean" == typeof c.suspense || (c = fetchSource._extends({}, c, {
suspense: !1
}));
return withPromise(this.executeQuery(fetchSource.createRequest(a, b), c));
};
Client.prototype.readQuery = function(a, b, c) {
var d = null;
wonka.subscribe((function(a) {
d = a;
}))(this.executeQuery(fetchSource.createRequest(a, b), c)).unsubscribe();
return d;
};
Client.prototype.subscription = function(a, b, c) {
return this.executeSubscription(fetchSource.createRequest(a, b), c);
};
Client.prototype.mutation = function(a, b, c) {
return withPromise(this.executeMutation(fetchSource.createRequest(a, b), c));
};
exports.CombinedError = fetchSource.CombinedError;
exports.createRequest = fetchSource.createRequest;
exports.makeErrorResult = fetchSource.makeErrorResult;
exports.makeResult = fetchSource.makeResult;
exports.stringifyVariables = fetchSource.stringifyVariables;
exports.Client = Client;
exports.cacheExchange = cacheExchange;
exports.composeExchanges = composeExchanges;
exports.createClient = createClient;
exports.debugExchange = debugExchange;
exports.dedupExchange = dedupExchange;
exports.defaultExchanges = defaultExchanges;
exports.errorExchange = errorExchange;
exports.fallbackExchangeIO = fallbackExchangeIO;
exports.fetchExchange = fetchExchange;
exports.formatDocument = formatDocument;
exports.makeOperation = makeOperation;
exports.maskTypename = maskTypename;
exports.ssrExchange = ssrExchange;
exports.subscriptionExchange = subscriptionExchange;
//# sourceMappingURL=urql-core.js.map

2

package.json
{
"name": "@urql/core",
"version": "1.14.0",
"version": "1.14.1",
"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

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