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

@trpc/client

Package Overview
Dependencies
Maintainers
3
Versions
1066
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trpc/client - npm Package Compare versions

Comparing version 3.0.0-y.0 to 3.0.0

dist/helpers.d.ts

72

dist/client.cjs.development.js

@@ -901,2 +901,30 @@ 'use strict';

function getWindow() {
if (typeof window !== 'undefined') {
return window;
}
return global;
}
function getAbortController(ac) {
var win = getWindow();
return ac || win.AbortController || null;
}
function getFetch(f) {
if (f) {
return f;
}
var win = getWindow();
if (win.fetch) {
return win.fetch;
}
throw new Error('No fetch implementation found');
}
/* istanbul ignore next */
var retryDelay = function retryDelay(attemptIndex) {

@@ -926,2 +954,4 @@ return attemptIndex === 0 ? 0 : Math.min(1000 * Math.pow(2, attemptIndex), 30000);

}( /*#__PURE__*/_wrapNativeSuper(Error));
/* istanbul ignore next */
var NextInputError = /*#__PURE__*/function (_Error2) {

@@ -941,35 +971,2 @@ _inheritsLoose(NextInputError, _Error2);

}( /*#__PURE__*/_wrapNativeSuper(Error));
function getAbortController(ac) {
if (ac) {
return ac;
}
if (typeof window !== 'undefined' && window.AbortController) {
return window.AbortController;
}
if (typeof global !== 'undefined' && global.AbortController) {
return global.AbortController;
}
return null;
}
function getFetch(f) {
if (f) {
return f;
}
if (typeof window !== 'undefined' && window.fetch) {
return window.fetch;
}
if (typeof global !== 'undefined' && global.fetch) {
return global.fetch;
}
throw new Error('No fetch implementation found');
}
var TRPCClient = /*#__PURE__*/function () {

@@ -1112,2 +1109,3 @@ function TRPCClient(opts) {

var reqOptsFn = reqOptsMap[type];
/* istanbul ignore next */

@@ -1153,3 +1151,5 @@ if (!reqOptsFn) {

});
};
}
/* istanbul ignore next */
;

@@ -1233,3 +1233,5 @@ _proto.subscriptionOnce = function subscriptionOnce(path, input) {

return promise;
};
}
/* istanbul ignore next */
;

@@ -1236,0 +1238,0 @@ _proto.subscription = function subscription(path, opts) {

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

"use strict";function t(t,r,e,n,o,i,u){try{var a=t[i](u),c=a.value}catch(t){return void e(t)}a.done?r(c):Promise.resolve(c).then(n,o)}function r(r){return function(){var e=this,n=arguments;return new Promise((function(o,i){var u=r.apply(e,n);function a(r){t(u,o,i,a,c,"next",r)}function c(r){t(u,o,i,a,c,"throw",r)}a(void 0)}))}}function e(){return(e=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t}).apply(this,arguments)}function n(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,i(t,r)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,r){return(i=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function a(t,r,e){return(a=u()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(t,n));return e&&i(o,e.prototype),o}).apply(null,arguments)}function c(t){var r="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return a(t,arguments,o(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i(e,t)})(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,r){return t(r={exports:{}},r.exports),r.exports}Object.defineProperty(exports,"__esModule",{value:!0});var f=l((function(t){var r=function(t){var r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",u=n.toStringTag||"@@toStringTag";function a(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{a({},"")}catch(t){a=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=Object.create((r&&r.prototype instanceof f?r:f).prototype),i=new O(n||[]);return o._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(e.method=o,e.arg=i;;){var u=e.delegate;if(u){var a=b(u,e);if(a){if(a===l)continue;return a}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=s(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}(t,e,i),o}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function p(){}function h(){}var v={};v[o]=function(){return this};var d=Object.getPrototypeOf,y=d&&d(d(j([])));y&&y!==r&&e.call(y,o)&&(v=y);var g=h.prototype=f.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(r){a(t,r,(function(t){return this._invoke(r,t)}))}))}function m(t,r){var n;this._invoke=function(o,i){function u(){return new r((function(n,u){!function n(o,i,u,a){var c=s(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&e.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,u,a)}),(function(t){n("throw",t,u,a)})):r.resolve(f).then((function(t){l.value=t,u(l)}),(function(t){return n("throw",t,u,a)}))}a(c.arg)}(o,i,n,u)}))}return n=n?n.then(u,u):u()}}function b(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,b(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function x(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function E(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function j(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=g.constructor=h,h.constructor=p,p.displayName=a(h,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===p||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,a(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(m.prototype),m.prototype[i]=function(){return this},t.AsyncIterator=m,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var u=new m(c(r,e,n,o),i);return t.isGeneratorFunction(e)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},w(g),a(g,u,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return u.type="throw",u.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=e.call(i,"catchLoc"),c=e.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=r,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(u)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),l},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),E(e),l}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;E(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:j(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}})),p=function(t){return 0===t?0:Math.min(1e3*Math.pow(2,t),3e4)},h=function(t){function r(e,n){var o,i=n.res,u=n.json,a=n.originalError;return(o=t.call(this,e)||this).message=e,o.res=i,o.json=u,o.originalError=a,Object.setPrototypeOf(s(o),r.prototype),o}return n(r,t),r}(c(Error)),v=function(t){function r(e){var n;return(n=t.call(this,"nextInput() threw an error - subscription is stopped: "+e.message)||this).originalError=e,Object.setPrototypeOf(s(n),r.prototype),n}return n(r,t),r}(c(Error)),d=function(){function t(t){var r,e=t.fetchOpts;this.opts=t;var n=function(t){if(t)return t;if("undefined"!=typeof window&&window.fetch)return window.fetch;if("undefined"!=typeof global&&global.fetch)return global.fetch;throw new Error("No fetch implementation found")}(null==e?void 0:e.fetch);this.fetch=function(){return n.apply(void 0,arguments)},this.AC=(null==e?void 0:e.AbortController)||("undefined"!=typeof window&&window.AbortController?window.AbortController:"undefined"!=typeof global&&global.AbortController?global.AbortController:null),this.transformer=null!=(r=t.transformer)?r:{serialize:function(t){return t},deserialize:function(t){return t}}}var n=t.prototype;return n.serializeInput=function(t){return void 0!==t?this.transformer.serialize(t):t},n.handleResponse=function(){var t=r(f.mark((function t(r){var e,n,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=null,n=null,t.prev=2,t.next=5,r;case 5:return e=t.sent,t.next=8,e.json();case 8:if(!(n=this.transformer.deserialize(t.sent)).ok){t.next=13;break}return this.opts.onSuccess&&this.opts.onSuccess(n),t.abrupt("return",n.data);case 13:throw new h(n.error.message,{json:n,res:e});case 16:throw t.prev=16,t.t0=t.catch(2),(o=t.t0)instanceof h||(o=new h(t.t0.message,{originalError:t.t0,res:e,json:n})),this.opts.onError&&this.opts.onError(o),o;case 22:case"end":return t.stop()}}),t,this,[[2,16]])})));return function(r){return t.apply(this,arguments)}}(),n.getHeaders=function(){return e({"content-type":"application/json"},this.opts.getHeaders?this.opts.getHeaders():{})},n.request=function(t){var r=this,n=t.type,o=t.input,i=t.path,u=this.opts.url,a={subscription:function(){return{method:"PATCH",body:JSON.stringify({input:r.serializeInput(o)}),url:u+"/"+i}},mutation:function(){return{method:"POST",body:JSON.stringify({input:r.serializeInput(o)}),url:u+"/"+i}},query:function(){return{method:"GET",url:u+"/"+i+(null!=o?"?input="+encodeURIComponent(JSON.stringify(r.serializeInput(o))):"")}}}[n];if(!a)throw new Error('Unhandled type "'+n+'"');var c=this.AC?new this.AC:null,s=a(),l=s.url,f=e({},function(t,r){if(null==t)return{};var e,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r.indexOf(e=i[n])>=0||(o[e]=t[e]);return o}(s,["url"]),{signal:null==c?void 0:c.signal,headers:this.getHeaders()}),p=this.handleResponse(this.fetch(l,f));return p.cancel=function(){null==c||c.abort()},p},n.query=function(t){return this.request({type:"query",path:t,input:arguments.length<=1?void 0:arguments[1]})},n.mutation=function(t){return this.request({type:"mutation",path:t,input:arguments.length<=1?void 0:arguments[1]})},n.subscriptionOnce=function(t,e){var n=this,o=!1,i=null,u=new Promise((function(u,a){var c=function(){var s=r(f.mark((function r(){var s,l;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!o){r.next=2;break}return r.abrupt("return");case 2:return r.prev=2,i=n.request({type:"subscription",input:e,path:t}),r.next=6,i;case 6:u(r.sent),r.next=14;break;case 10:r.prev=10,r.t0=r.catch(2),408===(null==(s=(l=r.t0).json)?void 0:s.statusCode)?c():a(l);case 14:case"end":return r.stop()}}),r,null,[[2,10]])})));return function(){return s.apply(this,arguments)}}();c()}));return u.cancel=function(){var t;o=!0,clearTimeout(void 0),(null==(t=i)?void 0:t.cancel)&&i.cancel()},u},n.subscription=function(t,e){var n=this,o=!1,i=null,u=0,a=function(){var t;o=!0,null==(t=i)||t.cancel(),i=null},c=function(){var s=r(f.mark((function r(s){var l,h,d;return f.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,i=n.subscriptionOnce(t,s),r.next=4,i;case 4:l=r.sent,u=0,e.onData&&e.onData(l),r.prev=7,h=e.nextInput(l),c(h),r.next=18;break;case 12:return r.prev=12,r.t0=r.catch(7),d=new v(r.t0),e.onError&&e.onError(d),a(),r.abrupt("return");case 18:r.next=27;break;case 20:if(r.prev=20,r.t1=r.catch(0),!o){r.next=24;break}return r.abrupt("return");case 24:e.onError&&e.onError(r.t1),u++,setTimeout((function(){c(s)}),p(u));case 27:case"end":return r.stop()}}),r,null,[[0,20],[7,12]])})));return function(t){return s.apply(this,arguments)}}();return c(e.initialInput),a},t}();exports.NextInputError=v,exports.TRPCClient=d,exports.TRPCClientError=h,exports.createTRPCClient=function(t){return new d(t)};
"use strict";function t(t,r,e,n,o,i,u){try{var a=t[i](u),c=a.value}catch(t){return void e(t)}a.done?r(c):Promise.resolve(c).then(n,o)}function r(r){return function(){var e=this,n=arguments;return new Promise((function(o,i){var u=r.apply(e,n);function a(r){t(u,o,i,a,c,"next",r)}function c(r){t(u,o,i,a,c,"throw",r)}a(void 0)}))}}function e(){return(e=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t}).apply(this,arguments)}function n(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,i(t,r)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,r){return(i=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function a(t,r,e){return(a=u()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(t,n));return e&&i(o,e.prototype),o}).apply(null,arguments)}function c(t){var r="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return a(t,arguments,o(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i(e,t)})(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t,r){return t(r={exports:{}},r.exports),r.exports}Object.defineProperty(exports,"__esModule",{value:!0});var l=f((function(t){var r=function(t){var r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",u=n.toStringTag||"@@toStringTag";function a(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{a({},"")}catch(t){a=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=Object.create((r&&r.prototype instanceof l?r:l).prototype),i=new O(n||[]);return o._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(e.method=o,e.arg=i;;){var u=e.delegate;if(u){var a=b(u,e);if(a){if(a===f)continue;return a}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=s(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}(t,e,i),o}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function l(){}function p(){}function h(){}var v={};v[o]=function(){return this};var y=Object.getPrototypeOf,d=y&&y(y(j([])));d&&d!==r&&e.call(d,o)&&(v=d);var g=h.prototype=l.prototype=Object.create(v);function m(t){["next","throw","return"].forEach((function(r){a(t,r,(function(t){return this._invoke(r,t)}))}))}function w(t,r){var n;this._invoke=function(o,i){function u(){return new r((function(n,u){!function n(o,i,u,a){var c=s(t[o],t,i);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==typeof l&&e.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,u,a)}),(function(t){n("throw",t,u,a)})):r.resolve(l).then((function(t){f.value=t,u(f)}),(function(t){return n("throw",t,u,a)}))}a(c.arg)}(o,i,n,u)}))}return n=n?n.then(u,u):u()}}function b(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,b(t,r),"throw"===r.method))return f;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,f;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,f):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function x(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function E(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function j(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=g.constructor=h,h.constructor=p,p.displayName=a(h,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===p||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,a(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var u=new w(c(r,e,n,o),i);return t.isGeneratorFunction(e)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},m(g),a(g,u,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return u.type="throw",u.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=e.call(i,"catchLoc"),c=e.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=r,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(u)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),E(e),f}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;E(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:j(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}}));function p(){return"undefined"!=typeof window?window:global}var h=function(t){return 0===t?0:Math.min(1e3*Math.pow(2,t),3e4)},v=function(t){function r(e,n){var o,i=n.res,u=n.json,a=n.originalError;return(o=t.call(this,e)||this).message=e,o.res=i,o.json=u,o.originalError=a,Object.setPrototypeOf(s(o),r.prototype),o}return n(r,t),r}(c(Error)),y=function(t){function r(e){var n;return(n=t.call(this,"nextInput() threw an error - subscription is stopped: "+e.message)||this).originalError=e,Object.setPrototypeOf(s(n),r.prototype),n}return n(r,t),r}(c(Error)),d=function(){function t(t){var r,e=t.fetchOpts;this.opts=t;var n,o,i=function(t){if(t)return t;var r=p();if(r.fetch)return r.fetch;throw new Error("No fetch implementation found")}(null==e?void 0:e.fetch);this.fetch=function(){return i.apply(void 0,arguments)},this.AC=(n=null==e?void 0:e.AbortController,o=p(),n||o.AbortController||null),this.transformer=null!=(r=t.transformer)?r:{serialize:function(t){return t},deserialize:function(t){return t}}}var n=t.prototype;return n.serializeInput=function(t){return void 0!==t?this.transformer.serialize(t):t},n.handleResponse=function(){var t=r(l.mark((function t(r){var e,n,o;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=null,n=null,t.prev=2,t.next=5,r;case 5:return e=t.sent,t.next=8,e.json();case 8:if(!(n=this.transformer.deserialize(t.sent)).ok){t.next=13;break}return this.opts.onSuccess&&this.opts.onSuccess(n),t.abrupt("return",n.data);case 13:throw new v(n.error.message,{json:n,res:e});case 16:throw t.prev=16,t.t0=t.catch(2),(o=t.t0)instanceof v||(o=new v(t.t0.message,{originalError:t.t0,res:e,json:n})),this.opts.onError&&this.opts.onError(o),o;case 22:case"end":return t.stop()}}),t,this,[[2,16]])})));return function(r){return t.apply(this,arguments)}}(),n.getHeaders=function(){return e({"content-type":"application/json"},this.opts.getHeaders?this.opts.getHeaders():{})},n.request=function(t){var r=this,n=t.type,o=t.input,i=t.path,u=this.opts.url,a={subscription:function(){return{method:"PATCH",body:JSON.stringify({input:r.serializeInput(o)}),url:u+"/"+i}},mutation:function(){return{method:"POST",body:JSON.stringify({input:r.serializeInput(o)}),url:u+"/"+i}},query:function(){return{method:"GET",url:u+"/"+i+(null!=o?"?input="+encodeURIComponent(JSON.stringify(r.serializeInput(o))):"")}}}[n];if(!a)throw new Error('Unhandled type "'+n+'"');var c=this.AC?new this.AC:null,s=a(),f=s.url,l=e({},function(t,r){if(null==t)return{};var e,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r.indexOf(e=i[n])>=0||(o[e]=t[e]);return o}(s,["url"]),{signal:null==c?void 0:c.signal,headers:this.getHeaders()}),p=this.handleResponse(this.fetch(f,l));return p.cancel=function(){null==c||c.abort()},p},n.query=function(t){return this.request({type:"query",path:t,input:arguments.length<=1?void 0:arguments[1]})},n.mutation=function(t){return this.request({type:"mutation",path:t,input:arguments.length<=1?void 0:arguments[1]})},n.subscriptionOnce=function(t,e){var n=this,o=!1,i=null,u=new Promise((function(u,a){var c=function(){var s=r(l.mark((function r(){var s,f;return l.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!o){r.next=2;break}return r.abrupt("return");case 2:return r.prev=2,i=n.request({type:"subscription",input:e,path:t}),r.next=6,i;case 6:u(r.sent),r.next=14;break;case 10:r.prev=10,r.t0=r.catch(2),408===(null==(s=(f=r.t0).json)?void 0:s.statusCode)?c():a(f);case 14:case"end":return r.stop()}}),r,null,[[2,10]])})));return function(){return s.apply(this,arguments)}}();c()}));return u.cancel=function(){var t;o=!0,clearTimeout(void 0),(null==(t=i)?void 0:t.cancel)&&i.cancel()},u},n.subscription=function(t,e){var n=this,o=!1,i=null,u=0,a=function(){var t;o=!0,null==(t=i)||t.cancel(),i=null},c=function(){var s=r(l.mark((function r(s){var f,p,v;return l.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,i=n.subscriptionOnce(t,s),r.next=4,i;case 4:f=r.sent,u=0,e.onData&&e.onData(f),r.prev=7,p=e.nextInput(f),c(p),r.next=18;break;case 12:return r.prev=12,r.t0=r.catch(7),v=new y(r.t0),e.onError&&e.onError(v),a(),r.abrupt("return");case 18:r.next=27;break;case 20:if(r.prev=20,r.t1=r.catch(0),!o){r.next=24;break}return r.abrupt("return");case 24:e.onError&&e.onError(r.t1),u++,setTimeout((function(){c(s)}),h(u));case 27:case"end":return r.stop()}}),r,null,[[0,20],[7,12]])})));return function(t){return s.apply(this,arguments)}}();return c(e.initialInput),a},t}();exports.NextInputError=y,exports.TRPCClient=d,exports.TRPCClientError=v,exports.createTRPCClient=function(t){return new d(t)};
//# sourceMappingURL=client.cjs.production.min.js.map

@@ -897,2 +897,30 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {

function getWindow() {
if (typeof window !== 'undefined') {
return window;
}
return global;
}
function getAbortController(ac) {
var win = getWindow();
return ac || win.AbortController || null;
}
function getFetch(f) {
if (f) {
return f;
}
var win = getWindow();
if (win.fetch) {
return win.fetch;
}
throw new Error('No fetch implementation found');
}
/* istanbul ignore next */
var retryDelay = function retryDelay(attemptIndex) {

@@ -922,2 +950,4 @@ return attemptIndex === 0 ? 0 : Math.min(1000 * Math.pow(2, attemptIndex), 30000);

}( /*#__PURE__*/_wrapNativeSuper(Error));
/* istanbul ignore next */
var NextInputError = /*#__PURE__*/function (_Error2) {

@@ -937,35 +967,2 @@ _inheritsLoose(NextInputError, _Error2);

}( /*#__PURE__*/_wrapNativeSuper(Error));
function getAbortController(ac) {
if (ac) {
return ac;
}
if (typeof window !== 'undefined' && window.AbortController) {
return window.AbortController;
}
if (typeof global !== 'undefined' && global.AbortController) {
return global.AbortController;
}
return null;
}
function getFetch(f) {
if (f) {
return f;
}
if (typeof window !== 'undefined' && window.fetch) {
return window.fetch;
}
if (typeof global !== 'undefined' && global.fetch) {
return global.fetch;
}
throw new Error('No fetch implementation found');
}
var TRPCClient = /*#__PURE__*/function () {

@@ -1108,2 +1105,3 @@ function TRPCClient(opts) {

var reqOptsFn = reqOptsMap[type];
/* istanbul ignore next */

@@ -1149,3 +1147,5 @@ if (!reqOptsFn) {

});
};
}
/* istanbul ignore next */
;

@@ -1229,3 +1229,5 @@ _proto.subscriptionOnce = function subscriptionOnce(path, input) {

return promise;
};
}
/* istanbul ignore next */
;

@@ -1232,0 +1234,0 @@ _proto.subscription = function subscription(path, opts) {

{
"name": "@trpc/client",
"version": "3.0.0-y.0",
"version": "3.0.0",
"description": "TRPC Client lib",

@@ -30,3 +30,3 @@ "author": "KATT",

"devDependencies": {
"@trpc/server": "^3.0.0-y.0"
"@trpc/server": "^3.0.0"
},

@@ -36,3 +36,3 @@ "publishConfig": {

},
"gitHead": "40eacdf44b6a061d2eadc36b48198ce57315b90c"
"gitHead": "5b3917ec0222e813803763efdfc79ee06a9b618b"
}

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