UNPKG

@flyyer/flyyer-lite

Version:

Flyyer.io helper classes and methods to generate smart URL to render images.

3 lines (2 loc) 2.63 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("qs/lib/stringify"))&&"object"==typeof t&&"default"in t?t.default:t,r="https://cdn.flyyer.io";function i(t){return void 0===t}function n(t){return i(t)?((new Date).getTime()/1e3).toFixed(0):null!==t?t:void 0}function s(t,r){return e(t,Object.assign({addQueryPrefix:!1,format:"RFC1738"},r))}function a(t,e){if(!t)throw new Error("Flyyer invariant failed")}function o(t){return[].concat(t).filter((function(t){return t||0===t})).map((function(t){return String(t).replace(/^\/+/,"").replace(/\/+$/,"")})).join("/")}var h=function(){function t(t){t||a(!1),this.project=t.project,this.path=t.path,this.default=t.default,this.extension=t.extension,this.variables=t.variables||{},this.meta=t.meta||{},this.secret=t.secret,this.strategy=t.strategy}var e=t.prototype;return e.sign=function(t,e,r,i,n){},e.params=function(t,e){var r=this.meta,i={__v:n(r.v),__id:r.id,_w:r.width,_h:r.height,_res:r.resolution,_ua:r.agent,_def:this.default,_ext:this.extension};return s(Object.assign(i,this.variables,t),e)},e.href=function(){var t=this.project;i(t)&&a(!1);var e=o(this.path),h=this.strategy,u=this.secret,c=this.sign(t,e,this.params({__v:void 0}),h,u),f=this.params()||"_";if(h&&"JWT"===h.toUpperCase()){var v=s({__v:n(this.meta.v)},{addQueryPrefix:!0});return r+"/v2/"+t+"/jwt-"+c+v}return r+"/v2/"+t+"/"+(c||"_")+"/"+f+"/"+e},e.toString=function(){return this.href()},t}(),u=function(){function t(t){t||a(!1),this.tenant=t.tenant,this.deck=t.deck,this.template=t.template,this.version=t.version,this.extension=t.extension,this.variables=t.variables||{},this.meta=t.meta||{},this.secret=t.secret,this.strategy=t.strategy}var e=t.prototype;return e.sign=function(t,e,r,i,n,s,a,o){},e.querystring=function(t,e){var r=this.meta,i={__v:n(r.v),__id:r.id,_w:r.width,_h:r.height,_res:r.resolution,_ua:r.agent,_loc:r.locale};return s(Object.assign(i,this.variables,t),e)},e.href=function(){var t=this.tenant,e=this.deck,o=this.template,h=this.strategy,u=this.secret,c=this.version,f=this.extension,v=this.variables,_=this.meta;i(t)&&a(!1),i(e)&&a(!1),i(o)&&a(!1);var l=this.sign(e,o,c,f,v,_,h,u);if(h&&"JWT"===h.toUpperCase()){var p=s({__jwt:l,__v:n(_.v)},{addQueryPrefix:!0});return r+"/r/v2/"+t+p}var d=this.querystring({__hmac:l},{addQueryPrefix:!0}),y=r+"/r/v2/"+t+"/"+e+"/"+o;return c&&f?y+"."+c+"."+f+d:c?y+"."+c+d:f?y+"."+f+d:""+y+d},e.toString=function(){return this.href()},t}();exports.Flyyer=h,exports.FlyyerRender=u,exports.__V=n,exports.invariant=a,exports.normalizePath=o,exports.toQuery=s; //# sourceMappingURL=flyyer-lite.cjs.production.min.js.map