New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-transporter

Package Overview
Dependencies
Maintainers
0
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-transporter - npm Package Compare versions

Comparing version 1.0.0-alpha.7 to 1.0.0-alpha.8

2

dist/react-transporter.umd.min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-native"),require("graphql/utilities/valueFromASTUntyped")):"function"==typeof define&&define.amd?define(["exports","react","react-native","graphql/utilities/valueFromASTUntyped"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["react-transporter"]={},t.React,t.reactNative,t.valueFromASTUntyped)}(this,(function(t,e,r,n){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=i(e);function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),t}function f(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach((function(e){f(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function d(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function m(t,e,r){return(m=y()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i}).apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return(g=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return m(t,arguments,v(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)})(t)}function w(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)r=o[n],e.indexOf(r)>=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)r=o[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}function b(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function E(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?b(t):e}function q(t){var e=y();return function(){var r,n=v(t);if(e){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E(this,r)}}function O(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{n||null==u.return||u.return()}finally{if(i)throw o}}return r}(t,e)||k(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t){return function(t){if(Array.isArray(t))return j(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||k(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(t,e){if(t){if("string"==typeof t)return j(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?j(t,e):void 0}}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var A=o.default.createContext(),R="undefined"==typeof window,D=!r.Platform||"web"===r.Platform.OS,F="pending",N="fulfilled",_="rejected",P="__typename",x="id",C="__ref",T=function t(e){var r=this;u(this,t),f(this,"promise",void 0),f(this,"status",F),f(this,"response",void 0),f(this,"read",(function(){switch(r.status){case F:throw r.promise;case _:throw r.response;default:return r.response}})),this.promise=e(),this.promise.then((function(t){r.status=N,r.response=t}),(function(t){r.status=_,r.response=t}))};T.all=function(t){var e=[],r=t.map((function(t){try{return t()}catch(t){if(t instanceof Promise)return e.push(t);throw t}}));if(e.length>0)throw Promise.all(e);return r};var Q=function(t){d(r,t);var e=q(r);function r(){var t;return u(this,r),(t=e.call(this,"Loading proxy resource.")).name="LoadingError",t}return r}(g(Error));var B=function t(e){var r=this;u(this,t),f(this,"status",N),f(this,"response",void 0),f(this,"read",(function(){return r.response})),this.response=e},I=function(t){return t.__esModule?t.default:t.default||t};function M(t){if(t.payload&&t.payload._result){var e=t.payload._result;return"function"==typeof e?new T((function(){return e()})):R||!D?new T((function(){return t.load().then((function(){return t}))})):function(t){var e=t.resolve();return"undefined"!=typeof __webpack_modules__&&!!__webpack_modules__[e]}(e)?new B(I(e.requireSync())):new T((function(){return e.requireAsync().then((function(t){return I(t)}))}))}return t.bundle?new T((function(){return t.bundle().then((function(t){return I(t)}))})):new B(t)}var U=function(t){d(r,t);var e=q(r);function r(t){var n;return u(this,r),f(b(n=e.call(this,"GraphQL response error.")),"data",void 0),n.data=t,n.name="GraphQLError",n}return r}(g(Error)),L=function(t){d(r,t);var e=q(r);function r(t,n){var i;return u(this,r),f(b(i=e.call(this,"Http error.")),"response",void 0),f(b(i),"data",void 0),i.response=t,i.data=n,i.name="HttpError",i}return r}(g(Error)),W=function(t){d(r,t);var e=q(r);function r(t,n){var i;return u(this,r),(i=e.call(this,t,n)).name="TransporterError",i}return r}(g(Error)),G=function(t){return null===t?null:"object"===a(t)?J(t):JSON.stringify(t)},J=function(t){var e=Object.keys(t);e.sort();var r=e.map((function(e){var r=G(t[e]);return null===r?r:'"'.concat(e,'":').concat(r)})).filter((function(t){return null!==t}));return 0===r.length?null:"{".concat(r.join(","),"}")};function H(t,e){var r=J(e);return"".concat(t).concat(r?"(".concat(r,")"):"")}var V=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;u(this,t),f(this,"ref",void 0),this.ref=null===e?null:[e[P],e.id]}return c(t,[{key:"toNative",value:function(){return this.ref}}],[{key:"fromNative",value:function(e){var r=new t;return r.ref=e,r}}]),t}(),Y=function(t){return(Array.isArray(t)?t:[t]).map((function(t){return[t[P],t.id]}))},K=function(t,e){return t.filter((function(t){var r=O(t,2),n=r[0],i=r[1];return!e.some((function(t){var e=O(t,2),r=e[0],o=e[1];return r===n&&o===i}))}))},$=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];u(this,t),f(this,"refs",void 0),this.refs=Y(e)}return c(t,[{key:"prepend",value:function(t){return this.refs=[].concat(S(Y(t)),S(this.refs)),this}},{key:"append",value:function(t){return this.refs=[].concat(S(this.refs),S(Y(t))),this}},{key:"syncPrepend",value:function(t){var e=Y(t),r=K(this.refs,e);return this.refs=[].concat(S(e),S(r)),this}},{key:"syncAppend",value:function(t){var e=Y(t),r=K(this.refs,e);return this.refs=[].concat(S(r),S(e)),this}},{key:"detach",value:function(t){var e=Y(t);return this.refs=K(this.refs,e),this}},{key:"toNative",value:function(){return this.refs}}],[{key:"fromNative",value:function(e){var r=new t;return r.refs=e,r}}]),t}();var z=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0};if(null===e)throw new Error("Key not found. This can happen if there is a deleted entity that is still in use.");return Object.keys(e).some((function(e){return void 0!==t[e]&&r(e)}))},X=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(t){return t};if(!r)return h(h({},t),e);var n=h({},t);return Object.entries(e).forEach((function(e){var i=O(e,2),o=i[0],a=i[1];n[o]=void 0===t[o]?a:r(o)})),n},Z=function(t,e,r){return void 0===r?e:(null!=e&&null!==r&&a(e)!==a(r)&&console.warn("Key ".concat(t,' had value "').concat(e,'" and was updated with value of different type "').concat(r,'".')),r)},tt=function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,t),f(this,"roots",void 0),f(this,"entities",void 0),f(this,"get",(function(t,r){var n,i,o=null===(n=e.entities[t])||void 0===n?void 0:n[r];return o?h((f(i={},P,t),f(i,x,r),i),o):null})),f(this,"getRoots",(function(){return e.roots})),f(this,"intersectWith",(function(t){var r=t.roots,n=t.entities;return z(e.roots,r)||z(e.entities,n,(function(t){return z(e.entities[t],n[t],(function(r){return z(e.entities[t][r],n[t][r])}))}))})),f(this,"add",(function(t){var r=t.roots,n=t.entities;e.roots=X(e.roots,r),e.entities=X(e.entities,n,(function(t){return X(e.entities[t],n[t],(function(r){var i=e.entities[t][r],o=n[t][r];if(null===o)return null;var a=h({},i);return Object.keys(o).forEach((function(t){a[t]=Z(t,i[t],o[t])})),a}))}))})),f(this,"merge",(function(r){var n=new t({roots:e.roots,entities:e.entities});return n.add(r),n})),f(this,"extract",(function(){return{roots:e.roots,entities:e.entities}}));var n=r.roots,i=void 0===n?{}:n,o=r.entities,a=void 0===o?{}:o;this.roots=i,this.entities=a},et=function(t,e,r){return"".concat(t,".").concat(e,".").concat(r)},rt=function t(){var e=this;u(this,t),f(this,"query",null),f(this,"fragments",{}),f(this,"getQuery",(function(){return e.query})),f(this,"setQuery",(function(t){e.query=t})),f(this,"getFragment",(function(t,r,n){var i=et(t,r,n);return e.fragments[i]})),f(this,"setFragment",(function(t,r,n,i){var o=et(t,r,n);e.fragments[o]=i})),f(this,"update",(function(t){var r=!1;return e.query&&e.query!==t.query&&(e.query=t.query,r=!0),Object.keys(e.fragments).forEach((function(n){e.fragments[n]!==t.fragments[n]&&(e.fragments[n]=t.fragments[n],r=!0)})),r}))},nt=function(t){d(r,t);var e=q(r);function r(t,n){var i;return u(this,r),f(b(i=e.call(this,t)),"path",void 0),i.path=n,i.name="ValueError",i}return r}(g(Error)),it=function(t,e,r){var i=t.name.value;if(0===t.arguments.length||r)return i;var o={};return t.arguments.forEach((function(t){o[t.name.value]=n.valueFromASTUntyped(t.value,e)})),H(i,o)},ot=function t(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=n.cache,u=n.handleFragment,s=n.keyWithArgs,c=a.request,f=c.ast,l=c.options,h={};return e.selections.forEach((function(e){if("Field"===e.kind){var a=it(e,l.variables,o),c=s?a:e.name.value;h[c]=at(e.selectionSet,r[a],n,[].concat(S(i),[c]))}if("InlineFragment"===e.kind)try{Object.assign(h,t(e.selectionSet,r,n,i))}catch(t){if("ValueError"!==t.name)throw t;if(e.typeCondition.name.value===r[P])throw new Error('Inline fragment "'.concat(e.typeCondition.name.value,'" has an undefined value and has been skipped.'))}if("FragmentSpread"===e.kind){var d=f.definitions.find((function(t){return"FragmentDefinition"===t.kind&&t.name.value===e.name.value}));try{var v=t(d.selectionSet,r,n);Object.assign(h,u(d.name.value,r[P],r.id,v))}catch(t){if("ValueError"!==t.name)throw t;if(d.typeCondition.name.value===r[P])throw new Error('Fragment "'.concat(d.name.value,'" at [').concat(i,"]: ").concat(t.message))}}})),h},at=function(t,e,r,n){return void 0===t?e:Array.isArray(e)?e.map((function(e,i){return st(t,e,r,[].concat(S(n),[i]))})):st(t,e,r,n)},ut=function(t,e,r,n){if(null===e)return null;var i=r.cache,o=r.handleEntity,a=O(e,2),u=a[0],s=a[1],c=i.data.get(u,s);if(!c)throw new nt("Entity [".concat(u,", ").concat(s,"] not found."),n);return o(u,s,ot(t,c,r,n))},st=function(t,e,r,n){if(void 0===e)throw new nt("Undefined value.",n);if(null===e)return null;if(!(C in e))return ot(t,e,r,n);var i=e.__ref,o=r.handleLink;return 2!==i.length||Array.isArray(i[0])?o(i.map((function(e,i){return ut(t,e,r,[].concat(S(n),[i]))}))):o(ut(t,i,r,n))};function ct(t,e){var r=e.handleFragment,n=e.handleEntity,i=e.handleLink,o=e.keyWithArgs,a=void 0!==o&&o,u=t.request.ast.definitions.find((function(t){return"OperationDefinition"===t.kind})),s=t.data.getRoots(),c={cache:t,handleFragment:r,handleEntity:n,handleLink:i,keyWithArgs:a};try{return ot(u.selectionSet,s,c,[],"mutation"===u.operation)}catch(t){if("ValueError"!==t.name)throw t;var f=t.path,l=t.message;throw new Error('Query "'.concat(u.name.value,'" at [').concat(f.join("."),"]: ").concat(l))}}var ft=function(t,e){return JSON.stringify(t)===JSON.stringify(e)};function lt(t){var e,r=new rt,n=ct(t,{handleFragment:function(e,n,i,o){var a,u,s=null===(a=t.graphData)||void 0===a?void 0:a.getFragment(e,n,i);return r.setFragment(e,n,i,ft(o,s)?s:h((f(u={},P,n),f(u,x,i),u),o)),{}},handleEntity:function(t,e,r){var n;return h((f(n={},P,t),f(n,x,e),n),r)},handleLink:function(t){return t}}),i=null===(e=t.graphData)||void 0===e?void 0:e.getQuery();return r.setQuery(ft(n,i)?i:n),r}var ht=function t(e,r){var n=this;u(this,t),f(this,"request",void 0),f(this,"original",void 0),f(this,"updates",[]),f(this,"dirty",!1),f(this,"data",void 0),f(this,"graphData",void 0),f(this,"addUpdate",(function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(n.data.intersectWith(t)){n.dirty=!0;var r=n.data.merge(t),i={optimistic:e,data:t,cache:r};n.data=r,n.updates=[].concat(S(n.updates),[i])}})),f(this,"removeUpdate",(function(t){var e,r=!1,i=[];n.updates.forEach((function(o){if(o.data===t){n.dirty=!0,r=!0;var a=i.length;e=a>0?i[a-1].cache:n.original}else if(r){var u=i.length,s=u>0?i[u-1].cache:n.original;e=s.merge(t),i.push(h(h({},o),{},{cache:e}))}else i.push(o)})),e&&(n.data=e),n.updates=i})),f(this,"commit",(function(){var t,e,r;n.dirty&&(n.graphData=lt(n),n.updates.some((function(t){return t.optimistic}))||(n.original=(t=n,e=new tt,r=ct(t,{handleFragment:function(t,e,r,n){return n},handleEntity:function(t,r,n){return e.add({entities:f({},t,f({},r,n))}),[t,r]},handleLink:function(t){return f({},C,t)},keyWithArgs:!0}),e.add({roots:r}),e),n.data=n.original,n.updates=[]),n.dirty=!1)})),this.request=e,this.original=r,this.data=r,this.graphData=lt(this)};function dt(t,e,r){return new Promise((function(n,i){var o;t(e.loc.source.body,r).then((function(t){return(o=t).json()})).then((function(t){if(o.ok)return t.errors?(t.errors.forEach((function(t){console.error("GraphQLError: ".concat(t.message))})),void i(new W("Request failed (GraphQLError).",{cause:new U(t.errors)}))):void n(t);i(new W("Request failed (HttpError - ".concat(o.status,")."),{cause:new L(o,t)}))})).catch((function(t){i(new W("Request failed.",{cause:t}))}))}))}var vt=function t(){u(this,t),f(this,"promise",void 0),f(this,"read",(function(){throw new Q})),this.promise=new Promise((function(){}))},pt=function t(e,r){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,t),f(this,"client",void 0),f(this,"ast",void 0),f(this,"options",void 0),f(this,"resource",void 0),f(this,"selectors",[]),f(this,"loading",!1),f(this,"aborted",!1),f(this,"mounted",!1),f(this,"interval",null),f(this,"cache",null),f(this,"read",(function(){n.resource.read()})),f(this,"isEqual",(function(t,e){return n.ast===t&&JSON.stringify(n.options.variables)===JSON.stringify(e)})),f(this,"isAborted",(function(){return n.aborted})),f(this,"sync",(function(){n.loading||n.aborted||n.cache.commit()})),f(this,"mount",(function(){n.mounted=!0})),f(this,"unmount",(function(){n.mounted=!1,n.aborted=!0,n.interval&&clearInterval(n.interval),n.client.queries.delete(n.options.name)})),this.client=e,this.ast=r,this.options=i;var o=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!n.aborted){var i=new tt(t.data);if(n.cache||(n.cache=new ht(n,i)),!R&&!r){var o=new tt({entities:i.entities});e.queries.forEach((function(t){t.cache.addUpdate(o)}))}e.queries.set(n.options.name,n),R||r||e.refresh()}},a=e.cache,s=a[this.options.name];s?(this.resource=new B(s),o({data:s},!0),delete a[this.options.name]):(this.loading=!0,R&&!e.ssr?this.resource=new vt:(this.resource=new T((function(){return dt(e.request,r,i.variables)})),this.resource.promise.then((function(t){n.loading=!1,R&&(a[n.options.name]=t),o(t)}),(function(){n.loading=!1,n.aborted=!0})))),!R&&i.refetchInterval&&(this.interval=setInterval((function(){n.loading=!0;var t=new T((function(){return dt(e.request,r,i.variables)}));i.refetchIntervalInBackground||(n.resource=t,n.cache=null,e.refresh()),t.promise.then((function(e){n.loading=!1,i.refetchIntervalInBackground&&(n.resource=t),o(e)}),(function(){n.loading=!1,n.aborted=!0}))}),i.refetchInterval))},yt=function(){function t(){u(this,t)}return c(t,null,[{key:"fromNative",value:function(e){if(Array.isArray(e))return e.map((function(e){return t.fromNative(e)}));if("object"===a(e)){if(C in e){var r=e.__ref;return 2!==r.length||Array.isArray(r[0])?$.fromNative(r):V.fromNative(r)}var n={};return Object.entries(e).forEach((function(e){var r=O(e,2),i=r[0],o=r[1];n[i]=t.fromNative(o)})),n}return e}},{key:"toNative",value:function(e){if(e instanceof V||e instanceof $)return f({},C,e.toNative());if(r=e,"[object Date]"===Object.prototype.toString.call(r))return e.toISOString();var r;if(Array.isArray(e))return e.map((function(e){return t.toNative(e)}));if(e&&"object"===a(e)){var n={};return Object.entries(e).forEach((function(e){var r=O(e,2),i=r[0],o=r[1];n[i]=t.toNative(o)})),n}return e}}]),t}(),mt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,t),f(this,"original",void 0),f(this,"values",{}),this.original=e}return c(t,[{key:"set",value:function(t,e){var r,n=Array.isArray(t)?H.apply(void 0,S(t)):t;"function"==typeof e?("function"==typeof this.original&&(this.original=this.original()||{}),r=e(yt.fromNative(n in this.values?this.values[n]:this.original[n]))):r=e;this.values[n]=yt.toNative(r)}},{key:"fill",value:function(t){var e=this;Object.keys(t).forEach((function(r){e.set(r,t[r])}))}}]),t}();function gt(t,e,r,n){if(!e)return r;var i=r;return e({insert:function(t,e,r){var n=new mt;"function"==typeof r?r(n):n.fill(r),i.add({entities:f({},t,f({},e,n.values))})},update:function(e,r){var n=e[P],o=e.id,a=new mt((function(){return h(h({},function(t,e,r){var n=null;return t.queries.forEach((function(t){var i=t.cache.data.get(e,r);if(i){if(t.cache.updates.some((function(t){return t.optimistic&&t.data.get(e,r)})))throw new Error("Cannot perform update on optimistically updated record. [".concat(e,".").concat(r,"]"));n=h(h({},n),i)}})),n}(t,n,o)),i.get(n,o))}));"function"==typeof r?r(a):a.fill(r),i.add({entities:f({},n,f({},o,a.values))})},updateRoots:function(e){var r=new mt((function(){return function(t){var e=null;return t.queries.forEach((function(t){var r=t.cache.data.getRoots();e=h(h({},e),r)})),e}(t)}));e(r),i.add({roots:r.values})},delete:function(t){var e=t[P],r=t.id;i.add({entities:f({},e,f({},r,null))})}},null==n?void 0:n.graphData.getQuery()),i}var wt=function t(e,r){u(this,t),f(this,"request",void 0),f(this,"data",void 0),f(this,"graphData",void 0),this.request=e,this.data=r,this.graphData=lt(this)},bt=function t(e,r){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,t),f(this,"ast",void 0),f(this,"options",void 0),f(this,"resource",void 0),f(this,"cache",void 0),this.ast=r,this.options=i;var o=gt(e,i.optimisticUpdater,new tt);e.queries.forEach((function(t){t.cache.addUpdate(o,!0)})),e.refresh(),this.resource=new T((function(){return dt(e.request,r,i.variables)})),this.resource.promise.then((function(t){var r=new tt(t.data);n.cache=new wt(n,r),o&&e.queries.forEach((function(t){t.cache.removeUpdate(o)}));var a=gt(e,i.updater,new tt({entities:t.data.entities}),n.cache);e.queries.forEach((function(t){t.cache.addUpdate(a)})),e.refresh()}),(function(t){t.message&&console.error("Mutation Error: ".concat(t.message)),o&&(e.queries.forEach((function(t){t.cache.removeUpdate(o)})),e.refresh())}))},Et=function t(e,r){var n=this;u(this,t),f(this,"parentStore",void 0),f(this,"executeQuery",void 0),f(this,"children",[]),f(this,"requests",void 0),f(this,"graphDataByRequest",void 0),f(this,"listeners",[]),f(this,"marker",{}),f(this,"mounted",!1),f(this,"preload",(function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.name||(null===(e=t.definitions.find((function(t){return"OperationDefinition"===t.kind})))||void 0===e?void 0:e.name.value);if(!i)throw new Error("No query name found.");var o=n.requests.get(i);return o&&!o.isEqual(t,r.variables)&&(n.requests.delete(i),n.graphDataByRequest.delete(o),o.unmount(),o=null),o||(o=n.executeQuery(t,h(h({},r),{},{name:i})),n.requests.set(i,o)),i})),f(this,"load",(function(t,e){var r=n.preload(t,e);return n.select(r)})),f(this,"getRequest",(function(t){var e=n.requests.get(t);if(!e){if(!n.parentStore)throw new Error('Query "'.concat(t,'" was not found.'));e=n.parentStore.getRequest(t)}return e})),f(this,"select",(function(t){var e=n.getRequest(t);e.read();var r=e.cache.graphData.getQuery();return n.graphDataByRequest.has(e)||n.graphDataByRequest.set(e,new rt),n.graphDataByRequest.get(e).setQuery(r),r})),f(this,"waitForAll",(function(){n.requests.forEach((function(t){t.read()})),n.parentStore&&n.parentStore.waitForAll()})),f(this,"getFragmentRequest",(function(t,e,r){var i=Array.from(n.requests.values()).find((function(n){var i=n.cache;return null==i?void 0:i.graphData.getFragment(t,e,r)}));if(!i){if(!n.parentStore)throw new Error('Fragment "'.concat(t,'" (entry: [').concat(e,", ").concat(r,"]) was not found."));i=n.parentStore.getFragmentRequest(t,e,r)}return i})),f(this,"selectFragment",(function(t,e){var r=e[P],i=e.id,o=n.getFragmentRequest(t,r,i);o.read();var a=o.cache.graphData.getFragment(t,r,i);return n.graphDataByRequest.has(o)||n.graphDataByRequest.set(o,new rt),n.graphDataByRequest.get(o).setFragment(t,r,i,a),a})),f(this,"addChild",(function(t){n.children=[].concat(S(n.children),[t])})),f(this,"removeChild",(function(t){n.children=n.children.filter((function(e){return e!==t}))})),f(this,"subscribe",(function(t){return n.listeners=[].concat(S(n.listeners),[t]),function(){n.listeners=n.listeners.filter((function(e){return e!==t}))}})),f(this,"getSnapshot",(function(){return n.marker})),f(this,"refresh",(function(){n.requests.forEach((function(t){t.sync()})),n.children.forEach((function(t){t.refresh()})),n.graphDataByRequest.forEach((function(t,e){e.cache||n.graphDataByRequest.delete(e),e.cache&&!t.update(e.cache.graphData)||n.update()}))})),f(this,"resetAborted",(function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];n.requests.forEach((function(t,e){t.isAborted()&&(n.requests.delete(e),n.graphDataByRequest.delete(t),t.unmount())})),n.children.forEach((function(t){t.resetAborted(!1)})),t&&n.update()})),f(this,"reset",(function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];n.requests.forEach((function(t){t.unmount()})),n.requests=new Map,n.graphDataByRequest=new Map,n.children.forEach((function(t){t.reset(!1)})),t&&n.update()})),f(this,"update",(function(){n.marker={},n.listeners.forEach((function(t){t()}))})),f(this,"mount",(function(){n.mounted=!0,n.parentStore.addChild(n),n.requests.forEach((function(t){t.mount()}))})),f(this,"unmount",(function(){n.mounted=!1,n.parentStore.removeChild(n),n.requests.forEach((function(t){t.unmount()}))})),this.parentStore=e,this.executeQuery=r,this.requests=new Map,this.graphDataByRequest=new Map};var qt="pending",Ot="fulfilled",St="rejected",kt=function(t){var e=t.current;return 0===e.length?null:e[e.length-1]};function jt(){var t=e.useContext(A);if(!t)throw new Error("Dispatcher hook is used outside of TransporterContext.");var r=e.useRef([]);return{dispatch:function(e,n){var i,o=null===(i=e.definitions.find((function(t){return"OperationDefinition"===t.kind})))||void 0===i?void 0:i.operation;if("query"!==o&&"mutation"!==o)throw new Error('No operation found. Must be either "query" or "mutation".');var a="query"===o?t.client.query(e,n):t.client.mutate(e,n);return r.current.push(a),a.resource.promise.then((function(){return a.cache.graphData.getQuery()}))},get ok(){var t=kt(r);return t&&t.status!==qt?t.status===Ot:null},get loading(){var t=kt(r);return!!t&&t.status===qt},get executed(){var t=kt(r);return!!t&&(t.status===Ot||t.status===St)},get error(){var t=kt(r);return t&&t.status===St?t.response:null}}}t.GraphQLError=U,t.HttpError=L,t.Link=V,t.ManyLink=$,t.Resource=T,t.Transporter=function t(e){var r=this,n=e.request,i=e.cache,o=void 0===i?{}:i,a=e.ssr,s=void 0!==a&&a;u(this,t),f(this,"request",void 0),f(this,"rootStore",void 0),f(this,"cache",void 0),f(this,"ssr",void 0),f(this,"queries",void 0),f(this,"query",(function(t,e){var n=r.queries.get(e.name);return n&&!n.mounted?n:new pt(r,t,e)})),f(this,"createStore",(function(t){return new Et(t,r.query)})),f(this,"mutate",(function(t,e){return new bt(r,t,e)})),f(this,"refresh",(function(){r.rootStore.refresh()})),f(this,"reset",(function(){r.rootStore.reset(),r.queries=new Map})),f(this,"extract",(function(){var t={};return r.queries.forEach((function(e,r){t[r]=e.cache.data.extract()})),t})),this.request=n,this.rootStore=this.createStore(null),this.cache=o,this.ssr=s,this.queries=new Map},t.TransporterError=W,t.TransporterProvider=function(t){var r=t.children,n=t.client;if(!n)throw new Error("TransporterProvider: You must provide a Transporter instance.");var i=n.rootStore;return e.useSyncExternalStore(i.subscribe,i.getSnapshot,(function(){return null})),o.default.createElement(A.Provider,{value:{client:n,store:i}},r)},t.createContainer=function(t){var r=t.component,n=w(t,["component"]);if(!r)throw new Error('You must define a container "component".');var i=function(t,e){var r,n;return{load:function(){if(!n){r||(r=M(t));var i=r.read();n=e?e(i):i}return n},resetOnError:function(){try{r.read()}catch(e){if(e instanceof Promise)return;r=M(t)}}}}(r,n.renderer),a=function(t,r){var n=r.data||function(){};return function(i){var o=e.useRef(!1),a=e.useContext(A),u=a.client,s=a.store;e.useSyncExternalStore(s.subscribe,s.getSnapshot,(function(){return null}));try{var c=O(T.all([function(){return n(s,i)},function(){return t.load()}]),2),f=c[0],l=c[1];return r.waitForAll&&s.waitForAll(),e.createElement(l,f)}catch(t){if(!R)throw t;if(t instanceof Promise){if(!u.ssr)return r.loading&&e.createElement(r.loading);throw o.current||(o.current=!0),t}if(t instanceof Q)return r.loading&&e.createElement(r.loading);if(u.ssr&&o.current)return r.loading&&e.createElement(r.loading);if(r.throwOnError)throw t;return r.error&&e.createElement(r.error,{error:t,reset:function(){},resetAll:function(){}})}}}(i,n),s=function(t){d(s,t);var r=q(s);function s(t){var e;return u(this,s),f(b(e=r.call(this,t)),"store",void 0),e.state={error:null},e}return c(s,[{key:"componentDidMount",value:function(){this.store.mount()}},{key:"componentWillUnmount",value:function(){this.store.unmount()}},{key:"renderContainer",value:function(){var t=this,r=this.context.client,u=this.state.error;if(u){return n.error&&e.createElement(n.error,{error:u,reset:function(){i.resetOnError(),t.store.resetAborted(),t.setState({error:null})}})}var s=o.default.createElement(a,this.props);return R&&!r.ssr?s:o.default.createElement(o.default.Suspense,{fallback:n.loading&&e.createElement(n.loading)},s)}},{key:"render",value:function(){var t=this.context,e=t.client,r=t.store;return this.store||(i.resetOnError(),this.store=e.createStore(r)),o.default.createElement(A.Provider,{value:{client:e,store:this.store}},this.renderContainer())}}]),s}(o.default.Component);n.throwOnError||(s.getDerivedStateFromError=function(t){return{error:t}}),s.contextType=A;var l=r.displayName||r.name;return s.displayName=l?"Container(".concat(l,")"):"Container",s},t.createNode=function(t){var r=t.component,n=w(t,["component"]);if(!t.component)throw new Error("React Transporter Node: You must define a node component.");function i(t){var i=e.useContext(A).store;if(!!!i.parentStore.parentStore)throw new Error("React Transporter Node: A node must be wrapped in a container.");var o=n.data||function(){return null};return e.createElement(r,o(i,t))}var o=r.displayName||r.name;return i.displayName=o?"ContainerNode(".concat(o,")"):"ContainerNode",i},t.key=H,t.ref=function(t,e){var r;return f(r={},P,t),f(r,x,e),r},t.useDispatcher=jt,t.useMutation=function(t,e){var r=O(jt(),2),n=r[0];return h(h({},r[1]),{},{dispatch:function(r){return n(t,h(h({},e),r))}})},t.useQuery=function(t,e){var r=O(jt(),2),n=r[0];return h(h({},r[1]),{},{dispatch:function(r){return n(t,h(h({},e),r))}})},t.useReset=function(){var t=e.useContext(A);if(!t)throw new Error('"useReset" hook is used outside of TransporterContext.');var r=t.client;return function(){r.reset()}},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-native"),require("graphql/utilities/valueFromASTUntyped")):"function"==typeof define&&define.amd?define(["exports","react","react-native","graphql/utilities/valueFromASTUntyped"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["react-transporter"]={},t.React,t.reactNative,t.valueFromASTUntyped)}(this,(function(t,e,r,n){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=i(e);function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),t}function f(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach((function(e){f(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function d(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function m(t,e,r){return(m=y()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i}).apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return(g=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return m(t,arguments,v(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)})(t)}function w(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)r=o[n],e.indexOf(r)>=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)r=o[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}function b(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function E(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?b(t):e}function q(t){var e=y();return function(){var r,n=v(t);if(e){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E(this,r)}}function S(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{n||null==u.return||u.return()}finally{if(i)throw o}}return r}(t,e)||k(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t){return function(t){if(Array.isArray(t))return j(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||k(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(t,e){if(t){if("string"==typeof t)return j(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?j(t,e):void 0}}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var A=o.default.createContext(),R="undefined"==typeof window,D=!r.Platform||"web"===r.Platform.OS,F="pending",N="fulfilled",_="rejected",x="__typename",P="id",C="__ref",T=function t(e){var r=this;u(this,t),f(this,"promise",void 0),f(this,"status",F),f(this,"response",void 0),f(this,"read",(function(){switch(r.status){case F:throw r.promise;case _:throw r.response;default:return r.response}})),this.promise=e(),this.promise.then((function(t){r.status=N,r.response=t}),(function(t){r.status=_,r.response=t}))};T.all=function(t){var e=[],r=t.map((function(t){try{return t()}catch(t){if(t instanceof Promise)return e.push(t);throw t}}));if(e.length>0)throw Promise.all(e);return r};var Q=function(t){d(r,t);var e=q(r);function r(){var t;return u(this,r),(t=e.call(this,"Loading proxy resource.")).name="LoadingError",t}return r}(g(Error));var B=function t(e){var r=this;u(this,t),f(this,"status",N),f(this,"response",void 0),f(this,"read",(function(){return r.response})),this.response=e},I=function(t){return t.__esModule?t.default:t.default||t};function M(t){if(t.payload&&t.payload._result){var e=t.payload._result;return"function"==typeof e?new T((function(){return e()})):R||!D?new T((function(){return t.load().then((function(){return t}))})):function(t){var e=t.resolve();return"undefined"!=typeof __webpack_modules__&&!!__webpack_modules__[e]}(e)?new B(I(e.requireSync())):new T((function(){return e.requireAsync().then((function(t){return I(t)}))}))}return t.bundle?new T((function(){return t.bundle().then((function(t){return I(t)}))})):new B(t)}var U=function(t){d(r,t);var e=q(r);function r(t){var n;return u(this,r),f(b(n=e.call(this,"GraphQL response error.")),"data",void 0),n.data=t,n.name="GraphQLError",n}return r}(g(Error)),L=function(t){d(r,t);var e=q(r);function r(t,n){var i;return u(this,r),f(b(i=e.call(this,"Http error.")),"response",void 0),f(b(i),"data",void 0),i.response=t,i.data=n,i.name="HttpError",i}return r}(g(Error)),W=function(t){d(r,t);var e=q(r);function r(t,n){var i;return u(this,r),(i=e.call(this,t,n)).name="TransporterError",i}return r}(g(Error)),G=function(t){return null===t?null:"object"===a(t)?J(t):JSON.stringify(t)},J=function(t){var e=Object.keys(t);e.sort();var r=e.map((function(e){var r=G(t[e]);return null===r?r:'"'.concat(e,'":').concat(r)})).filter((function(t){return null!==t}));return 0===r.length?null:"{".concat(r.join(","),"}")};function H(t,e){var r=J(e);return"".concat(t).concat(r?"(".concat(r,")"):"")}var V=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;u(this,t),f(this,"ref",void 0),this.ref=null===e?null:[e[x],e.id]}return c(t,[{key:"toNative",value:function(){return this.ref}}],[{key:"fromNative",value:function(e){var r=new t;return r.ref=e,r}}]),t}(),Y=function(t){return(Array.isArray(t)?t:[t]).map((function(t){return[t[x],t.id]}))},K=function(t,e){return t.filter((function(t){var r=S(t,2),n=r[0],i=r[1];return!e.some((function(t){var e=S(t,2),r=e[0],o=e[1];return r===n&&o===i}))}))},$=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];u(this,t),f(this,"refs",void 0),this.refs=Y(e)}return c(t,[{key:"prepend",value:function(t){return this.refs=[].concat(O(Y(t)),O(this.refs)),this}},{key:"append",value:function(t){return this.refs=[].concat(O(this.refs),O(Y(t))),this}},{key:"syncPrepend",value:function(t){var e=Y(t),r=K(this.refs,e);return this.refs=[].concat(O(e),O(r)),this}},{key:"syncAppend",value:function(t){var e=Y(t),r=K(this.refs,e);return this.refs=[].concat(O(r),O(e)),this}},{key:"detach",value:function(t){var e=Y(t);return this.refs=K(this.refs,e),this}},{key:"toNative",value:function(){return this.refs}}],[{key:"fromNative",value:function(e){var r=new t;return r.refs=e,r}}]),t}();var z=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0};if(null===e)throw new Error("Key not found. This can happen if there is a deleted entity that is still in use.");return Object.keys(e).some((function(e){return void 0!==t[e]&&r(e)}))},X=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(t){return t};if(!r)return h(h({},t),e);var n=h({},t);return Object.entries(e).forEach((function(e){var i=S(e,2),o=i[0],a=i[1];n[o]=void 0===t[o]?a:r(o)})),n},Z=function(t,e,r){return void 0===r?e:(null!=e&&null!==r&&a(e)!==a(r)&&console.warn("Key ".concat(t,' had value "').concat(e,'" and was updated with value of different type "').concat(r,'".')),r)},tt=function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,t),f(this,"roots",void 0),f(this,"entities",void 0),f(this,"get",(function(t,r){var n,i,o=null===(n=e.entities[t])||void 0===n?void 0:n[r];return o?h((f(i={},x,t),f(i,P,r),i),o):null})),f(this,"getRoots",(function(){return e.roots})),f(this,"intersectWith",(function(t){var r=t.roots,n=t.entities;return z(e.roots,r)||z(e.entities,n,(function(t){return z(e.entities[t],n[t],(function(r){return z(e.entities[t][r],n[t][r])}))}))})),f(this,"add",(function(t){var r=t.roots,n=t.entities;e.roots=X(e.roots,r),e.entities=X(e.entities,n,(function(t){return X(e.entities[t],n[t],(function(r){var i=e.entities[t][r],o=n[t][r];if(null===o)return null;var a=h({},i);return Object.keys(o).forEach((function(t){a[t]=Z(t,i[t],o[t])})),a}))}))})),f(this,"merge",(function(r){var n=new t({roots:e.roots,entities:e.entities});return n.add(r),n})),f(this,"extract",(function(){return{roots:e.roots,entities:e.entities}}));var n=r.roots,i=void 0===n?{}:n,o=r.entities,a=void 0===o?{}:o;this.roots=i,this.entities=a},et=function(t,e,r){return"".concat(t,".").concat(e,".").concat(r)},rt=function t(){var e=this;u(this,t),f(this,"query",null),f(this,"fragments",{}),f(this,"getQuery",(function(){return e.query})),f(this,"setQuery",(function(t){e.query=t})),f(this,"getFragment",(function(t,r,n){var i=et(t,r,n);return e.fragments[i]})),f(this,"setFragment",(function(t,r,n,i){var o=et(t,r,n);e.fragments[o]=i})),f(this,"update",(function(t){var r=!1;return e.query&&e.query!==t.query&&(e.query=t.query,r=!0),Object.keys(e.fragments).forEach((function(n){e.fragments[n]!==t.fragments[n]&&(e.fragments[n]=t.fragments[n],r=!0)})),r}))},nt=function(t){d(r,t);var e=q(r);function r(t,n){var i;return u(this,r),f(b(i=e.call(this,t)),"path",void 0),i.path=n,i.name="ValueError",i}return r}(g(Error)),it=function(t,e,r){var i=t.name.value;if(0===t.arguments.length||r)return i;var o={};return t.arguments.forEach((function(t){o[t.name.value]=n.valueFromASTUntyped(t.value,e)})),H(i,o)},ot=function t(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=n.cache,u=n.handleFragment,s=n.keyWithArgs,c=a.request,f=c.ast,l=c.options,h={};return e.selections.forEach((function(e){if("Field"===e.kind){var a=it(e,l.variables,o),c=s?a:e.name.value;h[c]=at(e.selectionSet,r[a],n,[].concat(O(i),[c]))}if("InlineFragment"===e.kind)try{Object.assign(h,t(e.selectionSet,r,n,i))}catch(t){if("ValueError"!==t.name)throw t;if(e.typeCondition.name.value===r[x])throw new Error('Inline fragment "'.concat(e.typeCondition.name.value,'" has an undefined value and has been skipped.'))}if("FragmentSpread"===e.kind){var d=f.definitions.find((function(t){return"FragmentDefinition"===t.kind&&t.name.value===e.name.value}));try{var v=t(d.selectionSet,r,n);Object.assign(h,u(d.name.value,r[x],r.id,v))}catch(t){if("ValueError"!==t.name)throw t;if(d.typeCondition.name.value===r[x])throw new Error('Fragment "'.concat(d.name.value,'" at [').concat(i,"]: ").concat(t.message))}}})),h},at=function(t,e,r,n){return void 0===t?e:Array.isArray(e)?e.map((function(e,i){return st(t,e,r,[].concat(O(n),[i]))})):st(t,e,r,n)},ut=function(t,e,r,n){if(null===e)return null;var i=r.cache,o=r.handleEntity,a=S(e,2),u=a[0],s=a[1],c=i.data.get(u,s);if(!c)throw new nt("Entity [".concat(u,", ").concat(s,"] not found."),n);return o(u,s,ot(t,c,r,n))},st=function(t,e,r,n){if(void 0===e)throw new nt("Undefined value.",n);if(null===e)return null;if(!(C in e))return ot(t,e,r,n);var i=e.__ref,o=r.handleLink;return 2!==i.length||Array.isArray(i[0])?o(i.map((function(e,i){return ut(t,e,r,[].concat(O(n),[i]))}))):o(ut(t,i,r,n))};function ct(t,e){var r=e.handleFragment,n=e.handleEntity,i=e.handleLink,o=e.keyWithArgs,a=void 0!==o&&o,u=t.request.ast.definitions.find((function(t){return"OperationDefinition"===t.kind})),s=t.data.getRoots(),c={cache:t,handleFragment:r,handleEntity:n,handleLink:i,keyWithArgs:a};try{return ot(u.selectionSet,s,c,[],"mutation"===u.operation)}catch(t){if("ValueError"!==t.name)throw t;var f=t.path,l=t.message;throw new Error('Query "'.concat(u.name.value,'" at [').concat(f.join("."),"]: ").concat(l))}}var ft=function(t,e){return JSON.stringify(t)===JSON.stringify(e)};function lt(t){var e,r=new rt,n=ct(t,{handleFragment:function(e,n,i,o){var a,u,s=null===(a=t.graphData)||void 0===a?void 0:a.getFragment(e,n,i);return r.setFragment(e,n,i,ft(o,s)?s:h((f(u={},x,n),f(u,P,i),u),o)),{}},handleEntity:function(t,e,r){var n;return h((f(n={},x,t),f(n,P,e),n),r)},handleLink:function(t){return t}}),i=null===(e=t.graphData)||void 0===e?void 0:e.getQuery();return r.setQuery(ft(n,i)?i:n),r}var ht=function t(e,r){var n=this;u(this,t),f(this,"request",void 0),f(this,"original",void 0),f(this,"updates",[]),f(this,"dirty",!1),f(this,"data",void 0),f(this,"graphData",void 0),f(this,"addUpdate",(function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(n.data.intersectWith(t)){n.dirty=!0;var r=n.data.merge(t),i={optimistic:e,data:t,cache:r};n.data=r,n.updates=[].concat(O(n.updates),[i])}})),f(this,"removeUpdate",(function(t){var e,r=!1,i=[];n.updates.forEach((function(o){if(o.data===t){n.dirty=!0,r=!0;var a=i.length;e=a>0?i[a-1].cache:n.original}else if(r){var u=i.length,s=u>0?i[u-1].cache:n.original;e=s.merge(t),i.push(h(h({},o),{},{cache:e}))}else i.push(o)})),e&&(n.data=e),n.updates=i})),f(this,"commit",(function(){var t,e,r;n.dirty&&(n.graphData=lt(n),n.updates.some((function(t){return t.optimistic}))||(n.original=(t=n,e=new tt,r=ct(t,{handleFragment:function(t,e,r,n){return n},handleEntity:function(t,r,n){return e.add({entities:f({},t,f({},r,n))}),[t,r]},handleLink:function(t){return f({},C,t)},keyWithArgs:!0}),e.add({roots:r}),e),n.data=n.original,n.updates=[]),n.dirty=!1)})),this.request=e,this.original=r,this.data=r,this.graphData=lt(this)};function dt(t,e,r){return new Promise((function(n,i){var o;t(e.loc.source.body,r).then((function(t){return(o=t).json()})).then((function(t){if(o.ok)return t.errors?(t.errors.forEach((function(t){console.error("GraphQLError: ".concat(t.message))})),void i(new W("Request failed (GraphQLError).",{cause:new U(t.errors)}))):void n(t);i(new W("Request failed (HttpError - ".concat(o.status,")."),{cause:new L(o,t)}))})).catch((function(t){i(new W("Request failed.",{cause:t}))}))}))}var vt=function t(){u(this,t),f(this,"promise",void 0),f(this,"read",(function(){throw new Q})),this.promise=new Promise((function(){}))},pt=function t(e,r){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,t),f(this,"client",void 0),f(this,"ast",void 0),f(this,"options",void 0),f(this,"resource",void 0),f(this,"selectors",[]),f(this,"loading",!1),f(this,"aborted",!1),f(this,"mounted",!1),f(this,"interval",null),f(this,"cache",null),f(this,"read",(function(){n.resource.read()})),f(this,"isEqual",(function(t,e){return n.ast===t&&JSON.stringify(n.options.variables)===JSON.stringify(e)})),f(this,"isAborted",(function(){return n.aborted})),f(this,"sync",(function(){n.loading||n.aborted||n.cache.commit()})),f(this,"mount",(function(){n.mounted=!0})),f(this,"unmount",(function(){n.mounted=!1,n.aborted=!0,n.interval&&clearInterval(n.interval),n.client.queries.delete(n.options.name)})),this.client=e,this.ast=r,this.options=i;var o=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!n.aborted){var i=new tt(t.data);if(n.cache||(n.cache=new ht(n,i)),!R&&!r){var o=new tt({entities:i.entities});e.queries.forEach((function(t){t.cache.addUpdate(o)}))}e.queries.set(n.options.name,n),R||r||e.refresh()}},a=e.cache,s=a[this.options.name];s?(this.resource=new B(s),o({data:s},!0),delete a[this.options.name]):(this.loading=!0,R&&!e.ssr?this.resource=new vt:(this.resource=new T((function(){return dt(e.request,r,i.variables)})),this.resource.promise.then((function(t){n.loading=!1,R&&(a[n.options.name]=t),o(t)}),(function(){n.loading=!1,n.aborted=!0})))),!R&&i.refetchInterval&&(this.interval=setInterval((function(){n.loading=!0;var t=new T((function(){return dt(e.request,r,i.variables)}));i.refetchIntervalInBackground||(n.resource=t,n.cache=null,e.refresh()),t.promise.then((function(e){n.loading=!1,i.refetchIntervalInBackground&&(n.resource=t),o(e)}),(function(){n.loading=!1,n.aborted=!0}))}),i.refetchInterval))},yt=function(){function t(){u(this,t)}return c(t,null,[{key:"fromNative",value:function(e){if(Array.isArray(e))return e.map((function(e){return t.fromNative(e)}));if("object"===a(e)){if(C in e){var r=e.__ref;return 2!==r.length||Array.isArray(r[0])?$.fromNative(r):V.fromNative(r)}var n={};return Object.entries(e).forEach((function(e){var r=S(e,2),i=r[0],o=r[1];n[i]=t.fromNative(o)})),n}return e}},{key:"toNative",value:function(e){if(e instanceof V||e instanceof $)return f({},C,e.toNative());if(r=e,"[object Date]"===Object.prototype.toString.call(r))return e.toISOString();var r;if(Array.isArray(e))return e.map((function(e){return t.toNative(e)}));if(e&&"object"===a(e)){var n={};return Object.entries(e).forEach((function(e){var r=S(e,2),i=r[0],o=r[1];n[i]=t.toNative(o)})),n}return e}}]),t}(),mt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,t),f(this,"original",void 0),f(this,"values",{}),this.original=e}return c(t,[{key:"set",value:function(t,e){var r,n=Array.isArray(t)?H.apply(void 0,O(t)):t;"function"==typeof e?("function"==typeof this.original&&(this.original=this.original()||{}),r=e(yt.fromNative(n in this.values?this.values[n]:this.original[n]))):r=e;this.values[n]=yt.toNative(r)}},{key:"fill",value:function(t){var e=this;Object.keys(t).forEach((function(r){e.set(r,t[r])}))}}]),t}();function gt(t,e,r,n){if(!e)return r;var i=r;return e({insert:function(t,e,r){var n=new mt;"function"==typeof r?r(n):n.fill(r),i.add({entities:f({},t,f({},e,n.values))})},update:function(e,r){var n=e[x],o=e.id,a=new mt((function(){return h(h({},function(t,e,r){var n=null;return t.queries.forEach((function(t){var i=t.cache.data.get(e,r);if(i){if(t.cache.updates.some((function(t){return t.optimistic&&t.data.get(e,r)})))throw new Error("Cannot perform update on optimistically updated record. [".concat(e,".").concat(r,"]"));n=h(h({},n),i)}})),n}(t,n,o)),i.get(n,o))}));"function"==typeof r?r(a):a.fill(r),i.add({entities:f({},n,f({},o,a.values))})},updateRoots:function(e){var r=new mt((function(){return function(t){var e=null;return t.queries.forEach((function(t){var r=t.cache.data.getRoots();e=h(h({},e),r)})),e}(t)}));e(r),i.add({roots:r.values})},delete:function(t){var e=t[x],r=t.id;i.add({entities:f({},e,f({},r,null))})}},null==n?void 0:n.graphData.getQuery()),i}var wt=function t(e,r){u(this,t),f(this,"request",void 0),f(this,"data",void 0),f(this,"graphData",void 0),this.request=e,this.data=r,this.graphData=lt(this)},bt=function t(e,r){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,t),f(this,"ast",void 0),f(this,"options",void 0),f(this,"resource",void 0),f(this,"cache",void 0),this.ast=r,this.options=i;var o=gt(e,i.optimisticUpdater,new tt);e.queries.forEach((function(t){t.cache.addUpdate(o,!0)})),e.refresh(),this.resource=new T((function(){return dt(e.request,r,i.variables)})),this.resource.promise.then((function(t){var r=new tt(t.data);n.cache=new wt(n,r),o&&e.queries.forEach((function(t){t.cache.removeUpdate(o)}));var a=gt(e,i.updater,new tt({entities:t.data.entities}),n.cache);e.queries.forEach((function(t){t.cache.addUpdate(a)})),e.refresh()}),(function(t){t.message&&console.error("Mutation Error: ".concat(t.message)),o&&(e.queries.forEach((function(t){t.cache.removeUpdate(o)})),e.refresh())}))},Et=function t(e,r){var n=this;u(this,t),f(this,"parentStore",void 0),f(this,"executeQuery",void 0),f(this,"children",[]),f(this,"requests",void 0),f(this,"graphDataByRequest",void 0),f(this,"listeners",[]),f(this,"marker",{}),f(this,"mounted",!1),f(this,"preload",(function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.name||(null===(e=t.definitions.find((function(t){return"OperationDefinition"===t.kind})))||void 0===e?void 0:e.name.value);if(!i)throw new Error("No query name found.");var o=n.requests.get(i);return o&&!o.isEqual(t,r.variables)&&(n.requests.delete(i),n.graphDataByRequest.delete(o),o.unmount(),o=null),o||(o=n.executeQuery(t,h(h({},r),{},{name:i})),n.requests.set(i,o)),i})),f(this,"load",(function(t,e){var r=n.preload(t,e);return n.select(r)})),f(this,"getRequest",(function(t){var e=n.requests.get(t);if(!e){if(!n.parentStore)throw new Error('Query "'.concat(t,'" was not found.'));e=n.parentStore.getRequest(t)}return e})),f(this,"select",(function(t){var e=n.getRequest(t);e.read();var r=e.cache.graphData.getQuery();return n.graphDataByRequest.has(e)||n.graphDataByRequest.set(e,new rt),n.graphDataByRequest.get(e).setQuery(r),r})),f(this,"waitForAll",(function(){n.requests.forEach((function(t){t.read()})),n.parentStore&&n.parentStore.waitForAll()})),f(this,"getFragmentRequest",(function(t,e,r){var i=Array.from(n.requests.values()).find((function(n){var i=n.cache;return null==i?void 0:i.graphData.getFragment(t,e,r)}));if(!i){if(!n.parentStore)throw new Error('Fragment "'.concat(t,'" (entry: [').concat(e,", ").concat(r,"]) was not found."));i=n.parentStore.getFragmentRequest(t,e,r)}return i})),f(this,"selectFragment",(function(t,e){var r=e[x],i=e.id,o=n.getFragmentRequest(t,r,i);o.read();var a=o.cache.graphData.getFragment(t,r,i);return n.graphDataByRequest.has(o)||n.graphDataByRequest.set(o,new rt),n.graphDataByRequest.get(o).setFragment(t,r,i,a),a})),f(this,"addChild",(function(t){n.children=[].concat(O(n.children),[t])})),f(this,"removeChild",(function(t){n.children=n.children.filter((function(e){return e!==t}))})),f(this,"subscribe",(function(t){return n.listeners=[].concat(O(n.listeners),[t]),function(){n.listeners=n.listeners.filter((function(e){return e!==t}))}})),f(this,"getSnapshot",(function(){return n.marker})),f(this,"refresh",(function(){n.requests.forEach((function(t){t.sync()})),n.children.forEach((function(t){t.refresh()})),n.graphDataByRequest.forEach((function(t,e){e.cache||n.graphDataByRequest.delete(e),e.cache&&!t.update(e.cache.graphData)||n.update()}))})),f(this,"resetAborted",(function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];n.requests.forEach((function(t,e){t.isAborted()&&(n.requests.delete(e),n.graphDataByRequest.delete(t),t.unmount())})),n.children.forEach((function(t){t.resetAborted(!1)})),t&&n.update()})),f(this,"reset",(function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];n.requests.forEach((function(t){t.unmount()})),n.requests=new Map,n.graphDataByRequest=new Map,n.children.forEach((function(t){t.reset(!1)})),t&&n.update()})),f(this,"update",(function(){n.marker={},n.listeners.forEach((function(t){t()}))})),f(this,"mount",(function(){n.mounted=!0,n.parentStore.addChild(n),n.requests.forEach((function(t){t.mount()}))})),f(this,"unmount",(function(){n.mounted=!1,n.parentStore.removeChild(n),n.requests.forEach((function(t){t.unmount()}))})),this.parentStore=e,this.executeQuery=r,this.requests=new Map,this.graphDataByRequest=new Map};var qt="pending",St="fulfilled",Ot="rejected";function kt(){var t=e.useContext(A);if(!t)throw new Error("Dispatcher hook is used outside of TransporterContext.");var r=S(e.useState({ok:null,loading:!1,executed:!1,error:null}),2),n=r[0],i=r[1],o=e.useRef([]),a=function(t){if(function(t){var e=t.current;return 0===e.length?null:e[e.length-1]}(o)===t){var e=t.resource.status;i({ok:e===qt?null:e===St,loading:e===qt,executed:e===St||e===Ot,error:e!==Ot?null:t.resource.response})}};return[function(e,r){var n,i=null===(n=e.definitions.find((function(t){return"OperationDefinition"===t.kind})))||void 0===n?void 0:n.operation;if("query"!==i&&"mutation"!==i)throw new Error('No operation found. Must be either "query" or "mutation".');var u="query"===i?t.client.query(e,r):t.client.mutate(e,r);return o.current.push(u),a(u),u.resource.promise.then((function(){return a(u),u.cache.graphData.getQuery()}),(function(t){throw a(u),t}))},n]}t.GraphQLError=U,t.HttpError=L,t.Link=V,t.ManyLink=$,t.Resource=T,t.Transporter=function t(e){var r=this,n=e.request,i=e.cache,o=void 0===i?{}:i,a=e.ssr,s=void 0!==a&&a;u(this,t),f(this,"request",void 0),f(this,"rootStore",void 0),f(this,"cache",void 0),f(this,"ssr",void 0),f(this,"queries",void 0),f(this,"query",(function(t,e){var n=r.queries.get(e.name);return n&&!n.mounted?n:new pt(r,t,e)})),f(this,"createStore",(function(t){return new Et(t,r.query)})),f(this,"mutate",(function(t,e){return new bt(r,t,e)})),f(this,"refresh",(function(){r.rootStore.refresh()})),f(this,"reset",(function(){r.rootStore.reset(),r.queries=new Map})),f(this,"extract",(function(){var t={};return r.queries.forEach((function(e,r){t[r]=e.cache.data.extract()})),t})),this.request=n,this.rootStore=this.createStore(null),this.cache=o,this.ssr=s,this.queries=new Map},t.TransporterError=W,t.TransporterProvider=function(t){var r=t.children,n=t.client;if(!n)throw new Error("TransporterProvider: You must provide a Transporter instance.");var i=n.rootStore;return e.useSyncExternalStore(i.subscribe,i.getSnapshot,(function(){return null})),o.default.createElement(A.Provider,{value:{client:n,store:i}},r)},t.createContainer=function(t){var r=t.component,n=w(t,["component"]);if(!r)throw new Error('You must define a container "component".');var i=function(t,e){var r,n;return{load:function(){if(!n){r||(r=M(t));var i=r.read();n=e?e(i):i}return n},resetOnError:function(){try{r.read()}catch(e){if(e instanceof Promise)return;r=M(t)}}}}(r,n.renderer),a=function(t,r){var n=r.data||function(){};return function(i){var o=e.useRef(!1),a=e.useContext(A),u=a.client,s=a.store;e.useSyncExternalStore(s.subscribe,s.getSnapshot,(function(){return null}));try{var c=S(T.all([function(){return n(s,i)},function(){return t.load()}]),2),f=c[0],l=c[1];return r.waitForAll&&s.waitForAll(),e.createElement(l,f)}catch(t){if(!R)throw t;if(t instanceof Promise){if(!u.ssr)return r.loading&&e.createElement(r.loading);throw o.current||(o.current=!0),t}if(t instanceof Q)return r.loading&&e.createElement(r.loading);if(u.ssr&&o.current)return r.loading&&e.createElement(r.loading);if(r.throwOnError)throw t;return r.error&&e.createElement(r.error,{error:t,reset:function(){},resetAll:function(){}})}}}(i,n),s=function(t){d(s,t);var r=q(s);function s(t){var e;return u(this,s),f(b(e=r.call(this,t)),"store",void 0),e.state={error:null},e}return c(s,[{key:"componentDidMount",value:function(){this.store.mount()}},{key:"componentWillUnmount",value:function(){this.store.unmount()}},{key:"renderContainer",value:function(){var t=this,r=this.context.client,u=this.state.error;if(u){return n.error&&e.createElement(n.error,{error:u,reset:function(){i.resetOnError(),t.store.resetAborted(),t.setState({error:null})}})}var s=o.default.createElement(a,this.props);return R&&!r.ssr?s:o.default.createElement(o.default.Suspense,{fallback:n.loading&&e.createElement(n.loading)},s)}},{key:"render",value:function(){var t=this.context,e=t.client,r=t.store;return this.store||(i.resetOnError(),this.store=e.createStore(r)),o.default.createElement(A.Provider,{value:{client:e,store:this.store}},this.renderContainer())}}]),s}(o.default.Component);n.throwOnError||(s.getDerivedStateFromError=function(t){return{error:t}}),s.contextType=A;var l=r.displayName||r.name;return s.displayName=l?"Container(".concat(l,")"):"Container",s},t.createNode=function(t){var r=t.component,n=w(t,["component"]);if(!t.component)throw new Error("React Transporter Node: You must define a node component.");function i(t){var i=e.useContext(A).store;if(!!!i.parentStore.parentStore)throw new Error("React Transporter Node: A node must be wrapped in a container.");var o=n.data||function(){return null};return e.createElement(r,o(i,t))}var o=r.displayName||r.name;return i.displayName=o?"ContainerNode(".concat(o,")"):"ContainerNode",i},t.key=H,t.ref=function(t,e){var r;return f(r={},x,t),f(r,P,e),r},t.useDispatcher=kt,t.useMutation=function(t,e){var r=S(kt(),2),n=r[0];return h(h({},r[1]),{},{dispatch:function(r){return n(t,h(h({},e),r))}})},t.useQuery=function(t,e){var r=S(kt(),2),n=r[0];return h(h({},r[1]),{},{dispatch:function(r){return n(t,h(h({},e),r))}})},t.useReset=function(){var t=e.useContext(A);if(!t)throw new Error('"useReset" hook is used outside of TransporterContext.');var r=t.client;return function(){r.reset()}},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "react-transporter",
"version": "1.0.0-alpha.7",
"version": "1.0.0-alpha.8",
"description": "React.js GraphQL client",

@@ -5,0 +5,0 @@ "author": "Markus Wetzel <markuswetzel@gmx.net>",

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 too big to display

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