-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.min.js
1 lines (1 loc) · 8.66 KB
/
client.min.js
1
var furver=function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o,s={exports:{}};function a(){if(o)return r;o=1;var e=1e3,t=60*e,n=60*t,s=24*n,a=7*s,c=365.25*s;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return r=function(r,o){o=o||{};var u=typeof r;if("string"===u&&r.length>0)return function(r){if((r=String(r)).length>100)return;var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!o)return;var i=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*c;case"weeks":case"week":case"w":return i*a;case"days":case"day":case"d":return i*s;case"hours":case"hour":case"hrs":case"hr":case"h":return i*n;case"minutes":case"minute":case"mins":case"min":case"m":return i*t;case"seconds":case"second":case"secs":case"sec":case"s":return i*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}(r);if("number"===u&&isFinite(r))return o.long?function(r){var o=Math.abs(r);if(o>=s)return i(r,o,s,"day");if(o>=n)return i(r,o,n,"hour");if(o>=t)return i(r,o,t,"minute");if(o>=e)return i(r,o,e,"second");return r+" ms"}(r):function(r){var o=Math.abs(r);if(o>=s)return Math.round(r/s)+"d";if(o>=n)return Math.round(r/n)+"h";if(o>=t)return Math.round(r/t)+"m";if(o>=e)return Math.round(r/e)+"s";return r+"ms"}(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))}}var c=function(e){function t(e){let r,o,s,a=null;function c(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];if(!c.enabled)return;const s=c,a=Number(new Date),i=a-(r||a);s.diff=i,s.prev=r,s.curr=a,r=a,n[0]=t.coerce(n[0]),"string"!=typeof n[0]&&n.unshift("%O");let u=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,((e,r)=>{if("%%"===e)return"%";u++;const o=t.formatters[r];if("function"==typeof o){const t=n[u];e=o.call(s,t),n.splice(u,1),u--}return e})),t.formatArgs.call(s,n);(s.log||t.log).apply(s,n)}return c.namespace=e,c.useColors=t.useColors(),c.color=t.selectColor(e),c.extend=n,c.destroy=t.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{a=e}}),"function"==typeof t.init&&t.init(c),c}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=a(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=c(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(s,s.exports);var i=s.exports,u=t({__proto__:null,default:n(i)},[i]);const{default:l}=u;var f=l("furver");function d(){let e=[];return{promise(){const t=function(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return n.resolve=e,n.reject=t,n}();return e.push(t),t},resolve:t=>(e.forEach((e=>e.resolve(t))),e=[],t),reject:t=>(e.forEach((e=>e.reject(t))),e=[],t)}}function C(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{resolve:n,reject:r,promise:o}=d();let s;async function a(){for(var r=arguments.length,c=new Array(r),i=0;i<r;i++)c[i]=arguments[i];return a.calls.push(c),s&&clearTimeout(s),s=setTimeout((()=>{n(e(a.calls)),a.calls=[]}),t),o()}return a.calls=[],a.reject=r,a}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0);return async function(){const e=t.calls.length;return(await t(...arguments))[e]}}class h extends Error{}class m extends h{}const g=Symbol("schema"),p=f.extend("client"),y=e=>C((t=>{const[[n,r]]=t,o=["array",...t.map((e=>{let[,{body:t}]=e;return t}))],s={...r,body:JSON.stringify(o)};return p(n,s),e(n,s)})),F=y((async(e,t)=>{const n=await fetch(e,{credentials:"include",...t,method:"post"});if(!n.ok)throw n;return await n.json()})),w=y((async(e,t)=>{const{body:n,...r}=t||{},o=new URLSearchParams({body:n}),s=new URL(e);s.search=o;const a=await fetch(s.toString(),{credentials:"include",...r});if(!a.ok)throw a;return await a.json()}));v.schema=async function(e){p("fetching schema from ".concat(e));const t=await fetch(e);return await t.json()};const b=e=>(e=>"function"==typeof e)(e)?e:()=>e;async function v(e){let{endpoint:t="http://localhost:3000",fetch:n=F,schema:r=v.schema}=e;const o={};return p("client initialized with endpoint",t),r&&(e=>{if(o[g]=e,!Array.isArray(e))throw new m("Not a valid schema");e.reduce(((e,r)=>{let[o]=r;return e[o]=function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return n(t,{body:[o,...r]})},e[o].toJSON=()=>["ref",o],e}),o)})(await b(r)("/"===t?"/schema":"".concat(t,"/schema"))),o.call=e=>n(t,{body:e}),o.call.toJSON=()=>["ref","call"],o}return e.bulk=y,e.client=v,e.default=v,e.get=w,e.post=F,e.schema=function(e){return e[g]},Object.defineProperty(e,"__esModule",{value:!0}),e}({});