unsplash-js
Advanced tools
Comparing version 4.8.0 to 5.0.0
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Unsplash=e():t.Unsplash=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return"function"==typeof t.json?t.json():t}Object.defineProperty(e,"__esModule",{value:!0});var u=function(){function t(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,r,o){return r&&t(e.prototype,r),o&&t(e,o),e}}();e.toJson=i;var s=r(1),a=r(2),c=r(4),l=o(c),h=r(7),p=o(h),f=r(11),d=o(f),v=r(8),y=o(v),_=r(5),g=o(_),b=r(6),m=o(b),q=r(9),T=o(q),j=r(10),O=o(j),E=function(){function t(e){n(this,t),this._apiUrl=e.apiUrl||s.API_URL,this._apiVersion=e.apiVersion||s.API_VERSION,this._applicationId=e.applicationId,this._secret=e.secret,this._callbackUrl=e.callbackUrl,this._bearerToken=e.bearerToken,this._headers=e.headers||{},this.auth=l["default"].bind(this)(),this.currentUser=p["default"].bind(this)(),this.users=d["default"].bind(this)(),this.photos=y["default"].bind(this)(),this.categories=g["default"].bind(this)(),this.collections=m["default"].bind(this)(),this.search=T["default"].bind(this)(),this.stats=O["default"].bind(this)()}return u(t,[{key:"request",value:function(t){var e=a.buildFetchOptions.bind(this)(t),r=e.url,o=e.options;return fetch(r,o)}}]),t}();e["default"]=E},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.API_URL="https://api.unsplash.com",e.API_VERSION="v1",e.OAUTH_AUTHORIZE_URL="https://unsplash.com/oauth/authorize",e.OAUTH_TOKEN_URL="https://unsplash.com/oauth/token"},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t){return(0,l["default"])(t)}function i(t){return(0,p["default"])(t,{},!0)}function u(t){var e=t.method,r=t.query,o=t.oauth,i=t.body,u=o===!0?t.url:""+this._apiUrl+t.url,c=s({},this._headers,t.headers,{"Accept-Version":this._apiVersion,Authorization:this._bearerToken?"Bearer "+this._bearerToken:"Client-ID "+this._applicationId});return i&&(c["Content-Type"]="application/x-www-form-urlencoded"),r&&(u=decodeURIComponent(u+"?"+(0,a.stringify)(r))),{url:u,options:{method:e,headers:c,body:"GET"!==e&&i?n(i):void 0}}}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};e.formUrlEncode=n,e.getUrlComponents=i,e.buildFetchOptions=u;var a=r(3),c=r(12),l=o(c),h=r(18),p=o(h)},function(t,e,r){"use strict";e.decode=e.parse=r(14),e.encode=e.stringify=r(15)},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(){var t=this;return{getAuthenticationUrl:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["public"],r=u["default"].stringify({client_id:t._applicationId,redirect_uri:t._callbackUrl,response_type:"code",scope:e.length>1?e.join("+"):e.toString()});return decodeURIComponent(s.OAUTH_AUTHORIZE_URL+"?"+r)},userAuthentication:function(e){var r=s.OAUTH_TOKEN_URL;return t.request({url:r,method:"POST",body:{client_id:t._applicationId,client_secret:t._secret,redirect_uri:t._callbackUrl,grant_type:"authorization_code",code:e},oauth:!0})},setBearerToken:function(e){e&&(t._bearerToken=e)}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(3),u=o(i),s=r(1)},function(t,e){"use strict";function r(){var t=this;return{listCategories:function(){var e="/categories";return t.request({url:e,method:"GET"})},category:function(e){var r="/categories/"+e;return t.request({url:r,method:"GET"})},categoryPhotos:function(e,r,o){var n="/categories/"+e+"/photos",i={page:r,per_page:o};return t.request({url:n,method:"GET",query:i})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{listCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},listCuratedCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections/curated",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},listFeaturedCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections/featured",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},getCollection:o.bind(this,!1),getCuratedCollection:o.bind(this,!0),getCuratedCollectionPhotos:n.bind(this,!0),getCollectionPhotos:n.bind(this,!1),createCollection:i.bind(this,null),updateCollection:i.bind(this),deleteCollection:function(e){var r="/collections/"+e;return t.request({url:r,method:"DELETE"})},addPhotoToCollection:function(e,r){var o="/collections/"+e+"/add";return t.request({url:o,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(e,r){var o="/collections/"+e+"/remove?photo_id="+r;return t.request({url:o,method:"DELETE"})},listRelatedCollections:function(e){var r="/collections/"+e+"/related";return t.request({url:r,method:"GET"})}}}function o(t,e){var r=t?"/collections/curated/"+e:"/collections/"+e;return this.request({url:r,method:"GET"})}function n(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"latest",i=t?"/collections/curated/"+e+"/photos":"/collections/"+e+"/photos",u={page:r,per_page:o,order_by:n};return this.request({url:i,method:"GET",query:u})}function i(t,e,r,o){var n=t?"/collections/"+t:"/collections",i={title:e,description:r,"private":o};return this.request({url:n,method:t?"PUT":"POST",body:i})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(){var e="/me";return t.request({url:e,method:"GET"})},updateProfile:function(e){var r="/me",o=e.username,n=e.firstName,i=e.lastName,u=e.email,s=e.url,a=e.location,c=e.bio,l=e.instagramUsername,h={username:o,first_name:n,last_name:i,email:u,url:s,location:a,bio:c,instagram_username:l};return Object.keys(h).forEach(function(t){h[t]||delete h[t]}),t.request({url:r,method:"PUT",body:h})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(){var t=this;return{listPhotos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",n="/photos",i={page:e,per_page:r,order_by:o};return t.request({url:n,method:"GET",query:i})},listCuratedPhotos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",n="/photos/curated",i={page:e,per_page:r,order_by:o};return t.request({url:n,method:"GET",query:i})},searchPhotos:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[""],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,i="/photos/search",u={query:e,category:r.length>1?r.join(","):r.toString(),page:o,per_page:n};return t.request({url:i,method:"GET",query:u})},getPhoto:function(e,r,o,n){var i="/photos/"+e,u={w:r,h:o,rect:n};return t.request({url:i,method:"GET",query:u})},getPhotoStats:function(e){var r="/photos/"+e+"/stats";return t.request({url:r,method:"GET"})},getRandomPhoto:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/photos/random",o=e.category||[],n=e.collections||[],i={featured:e.featured,username:e.username,orientation:e.orientation,category:o.join(),collections:n.join(),query:e.query,w:e.width,h:e.height,c:e.cacheBuster||(new Date).getTime(),count:e.count};return Object.keys(i).forEach(function(t){i[t]||delete i[t]}),t.request({url:r,method:"GET",query:i})},uploadPhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos";return t.request({url:r,method:"POST",body:{photo:e}})},likePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"POST"})},unlikePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"DELETE"})},downloadPhoto:function(e){var r=(0,s["default"])(e,"links.download_location",void 0);if(void 0===r)throw new Error("Object received is not a photo. "+e);var o=(0,i.getUrlComponents)(r);return t.request({url:o.pathname,method:"GET",query:o.query})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(2),u=r(13),s=o(u)},function(t,e){"use strict";function r(){return{all:o.bind(this,"/search"),photos:o.bind(this,"/search/photos"),users:o.bind(this,"/search/users"),collections:o.bind(this,"/search/collections")}}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,n={query:e,page:r,per_page:o};return this.request({url:t,method:"GET",query:n})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{total:function(){var e="/stats/total";return t.request({url:e,method:"GET"})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(e){var r="/users/"+e;return t.request({url:r,method:"GET"})},photos:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],u="/users/"+e+"/photos",s={page:r,per_page:o,order_by:n,stats:i};return t.request({url:u,method:"GET",query:s})},likes:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i="/users/"+e+"/likes",u={page:r,per_page:o,order_by:n};return t.request({url:i,method:"GET",query:u})},collections:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"published",i="/users/"+e+"/collections",u={page:r,per_page:o,order_by:n};return t.request({url:i,method:"GET",query:u})},statistics:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"days",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,n="/users/"+e+"/statistics",i={resolution:r,quantity:o};return t.request({url:n,method:"GET",query:i})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){t.exports=function(t,e){function r(t){return String(t).replace(/[^ !'()~\*]*/g,encodeURIComponent).replace(/ /g,"+").replace(/[!'()~\*]/g,function(t){return"%"+t.charCodeAt().toString(16).slice(-2).toUpperCase()})}function o(t){var r=Object.keys(t);return e.sorted?r.sort():r}function n(t){return t.filter(function(t){return t}).join("&")}function i(t,e){return n(o(e).map(function(r){return s(t+"["+r+"]",e[r])}))}function u(t,e){return n(e.map(function(e){return s(t+"[]",e)}))}function s(t,o){var n=typeof o,s=null;return o===s?s=e.ignorenull?s:r(t)+"="+s:/string|number|boolean/.test(n)?s=r(t)+"="+r(o):Array.isArray(o)?s=u(t,o):"object"===n&&(s=i(t,o)),s}return e="object"==typeof e?e:{},n(o(t).map(function(e){return s(e,t[e])}))}},function(t,e){(function(e){function r(t,e){return null==t?void 0:t[e]}function o(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}function n(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function i(){this.__data__=yt?yt(null):{}}function u(t){return this.has(t)&&delete this.__data__[t]}function s(t){var e=this.__data__;if(yt){var r=e[t];return r===H?void 0:r}return lt.call(e,t)?e[t]:void 0}function a(t){var e=this.__data__;return yt?void 0!==e[t]:lt.call(e,t)}function c(t,e){var r=this.__data__;return r[t]=yt&&void 0===e?H:e,this}function l(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function h(){this.__data__=[]}function p(t){var e=this.__data__,r=T(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():dt.call(e,r,1),!0}function f(t){var e=this.__data__,r=T(e,t);return r<0?void 0:e[r][1]}function d(t){return T(this.__data__,t)>-1}function v(t,e){var r=this.__data__,o=T(r,t);return o<0?r.push([t,e]):r[o][1]=e,this}function y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function _(){this.__data__={hash:new n,map:new(vt||l),string:new n}}function g(t){return P(this,t)["delete"](t)}function b(t){return P(this,t).get(t)}function m(t){return P(this,t).has(t)}function q(t,e){return P(this,t).set(t,e),this}function T(t,e){for(var r=t.length;r--;)if(G(t[r][0],e))return r;return-1}function j(t,e){e=U(e,t)?[e]:w(e);for(var r=0,o=e.length;null!=t&&r<o;)t=t[R(e[r++])];return r&&r==o?t:void 0}function O(t){if(!M(t)||A(t))return!1;var e=S(t)||o(t)?pt:tt;return e.test(x(t))}function E(t){if("string"==typeof t)return t;if($(t))return gt?gt.call(t):"";var e=t+"";return"0"==e&&1/t==-V?"-0":e}function w(t){return mt(t)?t:bt(t)}function P(t,e){var r=t.__data__;return k(e)?r["string"==typeof e?"string":"hash"]:r.map}function C(t,e){var o=r(t,e);return O(o)?o:void 0}function U(t,e){if(mt(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!$(t))||(J.test(t)||!B.test(t)||null!=e&&t in Object(e))}function k(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function A(t){return!!at&&at in t}function R(t){if("string"==typeof t||$(t))return t;var e=t+"";return"0"==e&&1/t==-V?"-0":e}function x(t){if(null!=t){try{return ct.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function I(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(z);var r=function(){var o=arguments,n=e?e.apply(this,o):o[0],i=r.cache;if(i.has(n))return i.get(n);var u=t.apply(this,o);return r.cache=i.set(n,u),u};return r.cache=new(I.Cache||y),r}function G(t,e){return t===e||t!==t&&e!==e}function S(t){var e=M(t)?ht.call(t):"";return e==D||e==K}function M(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function L(t){return!!t&&"object"==typeof t}function $(t){return"symbol"==typeof t||L(t)&&ht.call(t)==Z}function N(t){return null==t?"":E(t)}function F(t,e,r){var o=null==t?void 0:j(t,e);return void 0===o?r:o}var z="Expected a function",H="__lodash_hash_undefined__",V=1/0,D="[object Function]",K="[object GeneratorFunction]",Z="[object Symbol]",B=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,Q=/^\./,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,X=/[\\^$.*+?()[\]{}|]/g,Y=/\\(\\)?/g,tt=/^\[object .+?Constructor\]$/,et="object"==typeof e&&e&&e.Object===Object&&e,rt="object"==typeof self&&self&&self.Object===Object&&self,ot=et||rt||Function("return this")(),nt=Array.prototype,it=Function.prototype,ut=Object.prototype,st=ot["__core-js_shared__"],at=function(){var t=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ct=it.toString,lt=ut.hasOwnProperty,ht=ut.toString,pt=RegExp("^"+ct.call(lt).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ft=ot.Symbol,dt=nt.splice,vt=C(ot,"Map"),yt=C(Object,"create"),_t=ft?ft.prototype:void 0,gt=_t?_t.toString:void 0;n.prototype.clear=i,n.prototype["delete"]=u,n.prototype.get=s,n.prototype.has=a,n.prototype.set=c,l.prototype.clear=h,l.prototype["delete"]=p,l.prototype.get=f,l.prototype.has=d,l.prototype.set=v,y.prototype.clear=_,y.prototype["delete"]=g,y.prototype.get=b,y.prototype.has=m,y.prototype.set=q;var bt=I(function(t){t=N(t);var e=[];return Q.test(t)&&e.push(""),t.replace(W,function(t,r,o,n){e.push(o?n.replace(Y,"$1"):r||t)}),e});I.Cache=y;var mt=Array.isArray;t.exports=F}).call(e,function(){return this}())},function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,o,n){e=e||"&",o=o||"=";var i={};if("string"!=typeof t||0===t.length)return i;var u=/\+/g;t=t.split(e);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var a=t.length;s>0&&a>s&&(a=s);for(var c=0;c<a;++c){var l,h,p,f,d=t[c].replace(u,"%20"),v=d.indexOf(o);v>=0?(l=d.substr(0,v),h=d.substr(v+1)):(l=d,h=""),p=decodeURIComponent(l),f=decodeURIComponent(h),r(i,p)?Array.isArray(i[p])?i[p].push(f):i[p]=[i[p],f]:i[p]=f}return i}},function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,o,n){return e=e||"&",o=o||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(n){var i=encodeURIComponent(r(n))+o;return Array.isArray(t[n])?t[n].map(function(t){return i+encodeURIComponent(r(t))}).join(e):i+encodeURIComponent(r(t[n]))}).join(e):n?encodeURIComponent(r(n))+o+encodeURIComponent(r(t)):""}},function(t,e){"use strict";function r(t){return decodeURIComponent(t.replace(/\+/g," "))}function o(t){for(var e,o=/([^=?&]+)=?([^&]*)/g,n={};e=o.exec(t);n[r(e[1])]=r(e[2]));return n}function n(t,e){e=e||"";var r=[];"string"!=typeof e&&(e="?");for(var o in t)i.call(t,o)&&r.push(encodeURIComponent(o)+"="+encodeURIComponent(t[o]));return r.length?e+r.join("&"):""}var i=Object.prototype.hasOwnProperty;e.stringify=n,e.parse=o},function(t,e){"use strict";t.exports=function(t,e){if(e=e.split(":")[0],t=+t,!t)return!1;switch(e){case"http":case"ws":return 80!==t;case"https":case"wss":return 443!==t;case"ftp":return 21!==t;case"gopher":return 70!==t;case"file":return!1}return 0!==t}},function(t,e,r){(function(e){"use strict";function o(t){t=t||e.location||{};var r,o={},n=typeof t;if("blob:"===t.protocol)o=new u(unescape(t.pathname),{});else if("string"===n){o=new u(t,{});for(r in d)delete o[r]}else if("object"===n){for(r in t)r in d||(o[r]=t[r]);void 0===o.slashes&&(o.slashes=p.test(t.href))}return o}function n(t){var e=h.exec(t);return{protocol:e[1]?e[1].toLowerCase():"",slashes:!!e[2],rest:e[3]}}function i(t,e){for(var r=(e||"/").split("/").slice(0,-1).concat(t.split("/")),o=r.length,n=r[o-1],i=!1,u=0;o--;)"."===r[o]?r.splice(o,1):".."===r[o]?(r.splice(o,1),u++):u&&(0===o&&(i=!0),r.splice(o,1),u--);return i&&r.unshift(""),"."!==n&&".."!==n||r.push(""),r.join("/")}function u(t,e,r){if(!(this instanceof u))return new u(t,e,r);var s,a,h,p,d,v,y=f.slice(),_=typeof e,g=this,b=0;for("object"!==_&&"string"!==_&&(r=e,e=null),r&&"function"!=typeof r&&(r=l.parse),e=o(e),a=n(t||""),s=!a.protocol&&!a.slashes,g.slashes=a.slashes||s&&e.slashes,g.protocol=a.protocol||e.protocol||"",t=a.rest,a.slashes||(y[2]=[/(.*)/,"pathname"]);b<y.length;b++)p=y[b],h=p[0],v=p[1],h!==h?g[v]=t:"string"==typeof h?~(d=t.indexOf(h))&&("number"==typeof p[2]?(g[v]=t.slice(0,d),t=t.slice(d+p[2])):(g[v]=t.slice(d),t=t.slice(0,d))):(d=h.exec(t))&&(g[v]=d[1],t=t.slice(0,d.index)),g[v]=g[v]||(s&&p[3]?e[v]||"":""),p[4]&&(g[v]=g[v].toLowerCase());r&&(g.query=r(g.query)),s&&e.slashes&&"/"!==g.pathname.charAt(0)&&(""!==g.pathname||""!==e.pathname)&&(g.pathname=i(g.pathname,e.pathname)),c(g.port,g.protocol)||(g.host=g.hostname,g.port=""),g.username=g.password="",g.auth&&(p=g.auth.split(":"),g.username=p[0]||"",g.password=p[1]||""),g.origin=g.protocol&&g.host&&"file:"!==g.protocol?g.protocol+"//"+g.host:"null",g.href=g.toString()}function s(t,e,r){var o=this;switch(t){case"query":"string"==typeof e&&e.length&&(e=(r||l.parse)(e)),o[t]=e;break;case"port":o[t]=e,c(e,o.protocol)?e&&(o.host=o.hostname+":"+e):(o.host=o.hostname,o[t]="");break;case"hostname":o[t]=e,o.port&&(e+=":"+o.port),o.host=e;break;case"host":o[t]=e,/:\d+$/.test(e)?(e=e.split(":"),o.port=e.pop(),o.hostname=e.join(":")):(o.hostname=e,o.port="");break;case"protocol":o.protocol=e.toLowerCase(),o.slashes=!r;break;case"pathname":case"hash":if(e){var n="pathname"===t?"/":"#";o[t]=e.charAt(0)!==n?n+e:e}else o[t]=e;break;default:o[t]=e}for(var i=0;i<f.length;i++){var u=f[i];u[4]&&(o[u[1]]=o[u[1]].toLowerCase())}return o.origin=o.protocol&&o.host&&"file:"!==o.protocol?o.protocol+"//"+o.host:"null",o.href=o.toString(),o}function a(t){t&&"function"==typeof t||(t=l.stringify);var e,r=this,o=r.protocol;o&&":"!==o.charAt(o.length-1)&&(o+=":");var n=o+(r.slashes?"//":"");return r.username&&(n+=r.username,r.password&&(n+=":"+r.password),n+="@"),n+=r.host+r.pathname,e="object"==typeof r.query?t(r.query):r.query,e&&(n+="?"!==e.charAt(0)?"?"+e:e),r.hash&&(n+=r.hash),n}var c=r(17),l=r(16),h=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,p=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,f=[["#","hash"],["?","query"],["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],d={hash:1,query:1};u.prototype={set:s,toString:a},u.extractProtocol=n,u.location=o,u.qs=l,t.exports=u}).call(e,function(){return this}())}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Unsplash=e():t.Unsplash=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return"function"==typeof t.json?t.json():t}Object.defineProperty(e,"__esModule",{value:!0});var u=function(){function t(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,r,o){return r&&t(e.prototype,r),o&&t(e,o),e}}();e.toJson=i;var s=r(1),a=r(2),c=r(4),l=o(c),h=r(7),f=o(h),p=r(11),d=o(p),v=r(8),y=o(v),_=r(5),g=o(_),b=r(6),m=o(b),q=r(9),T=o(q),j=r(10),O=o(j),w=function(){function t(e){n(this,t),this._apiUrl=e.apiUrl||s.API_URL,this._apiVersion=e.apiVersion||s.API_VERSION,this._applicationId=e.applicationId,this._secret=e.secret,this._callbackUrl=e.callbackUrl,this._bearerToken=e.bearerToken,this._headers=e.headers||{},this.auth=l["default"].bind(this)(),this.currentUser=f["default"].bind(this)(),this.users=d["default"].bind(this)(),this.photos=y["default"].bind(this)(),this.categories=g["default"].bind(this)(),this.collections=m["default"].bind(this)(),this.search=T["default"].bind(this)(),this.stats=O["default"].bind(this)()}return u(t,[{key:"request",value:function(t){var e=a.buildFetchOptions.bind(this)(t),r=e.url,o=e.options;return fetch(r,o)}}]),t}();e["default"]=w},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.API_URL="https://api.unsplash.com",e.API_VERSION="v1",e.OAUTH_AUTHORIZE_URL="https://unsplash.com/oauth/authorize",e.OAUTH_TOKEN_URL="https://unsplash.com/oauth/token"},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(t){return(0,l["default"])(t)}function i(t){return(0,f["default"])(t,{},!0)}function u(t){var e=t.method,r=t.query,o=t.oauth,i=t.body,u=o===!0?t.url:""+this._apiUrl+t.url,c=s({},this._headers,t.headers,{"Accept-Version":this._apiVersion,Authorization:this._bearerToken?"Bearer "+this._bearerToken:"Client-ID "+this._applicationId});return i&&(c["Content-Type"]="application/x-www-form-urlencoded"),r&&(u=decodeURIComponent(u+"?"+(0,a.stringify)(r))),{url:u,options:{method:e,headers:c,body:"GET"!==e&&i?n(i):void 0}}}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};e.formUrlEncode=n,e.getUrlComponents=i,e.buildFetchOptions=u;var a=r(3),c=r(12),l=o(c),h=r(18),f=o(h)},function(t,e,r){"use strict";e.decode=e.parse=r(14),e.encode=e.stringify=r(15)},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(){var t=this;return{getAuthenticationUrl:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["public"],r=u["default"].stringify({client_id:t._applicationId,redirect_uri:t._callbackUrl,response_type:"code",scope:e.length>1?e.join("+"):e.toString()});return decodeURIComponent(s.OAUTH_AUTHORIZE_URL+"?"+r)},userAuthentication:function(e){var r=s.OAUTH_TOKEN_URL;return t.request({url:r,method:"POST",body:{client_id:t._applicationId,client_secret:t._secret,redirect_uri:t._callbackUrl,grant_type:"authorization_code",code:e},oauth:!0})},setBearerToken:function(e){e&&(t._bearerToken=e)}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(3),u=o(i),s=r(1)},function(t,e){"use strict";function r(){var t=this;return{listCategories:function(){var e="/categories";return t.request({url:e,method:"GET"})},category:function(e){var r="/categories/"+e;return t.request({url:r,method:"GET"})},categoryPhotos:function(e,r,o){var n="/categories/"+e+"/photos",i={page:r,per_page:o};return t.request({url:n,method:"GET",query:i})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{listCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},listCuratedCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections/curated",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},listFeaturedCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections/featured",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},getCollection:o.bind(this,!1),getCuratedCollection:o.bind(this,!0),getCuratedCollectionPhotos:n.bind(this,!0),getCollectionPhotos:n.bind(this,!1),createCollection:i.bind(this,null),updateCollection:i.bind(this),deleteCollection:function(e){var r="/collections/"+e;return t.request({url:r,method:"DELETE"})},addPhotoToCollection:function(e,r){var o="/collections/"+e+"/add";return t.request({url:o,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(e,r){var o="/collections/"+e+"/remove?photo_id="+r;return t.request({url:o,method:"DELETE"})},listRelatedCollections:function(e){var r="/collections/"+e+"/related";return t.request({url:r,method:"GET"})}}}function o(t,e){var r=t?"/collections/curated/"+e:"/collections/"+e;return this.request({url:r,method:"GET"})}function n(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"latest",i=t?"/collections/curated/"+e+"/photos":"/collections/"+e+"/photos",u={page:r,per_page:o,order_by:n};return this.request({url:i,method:"GET",query:u})}function i(t,e,r,o){var n=t?"/collections/"+t:"/collections",i={title:e,description:r,"private":o};return this.request({url:n,method:t?"PUT":"POST",body:i})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(){var e="/me";return t.request({url:e,method:"GET"})},updateProfile:function(e){var r="/me",o=e.username,n=e.firstName,i=e.lastName,u=e.email,s=e.url,a=e.location,c=e.bio,l=e.instagramUsername,h={username:o,first_name:n,last_name:i,email:u,url:s,location:a,bio:c,instagram_username:l};return Object.keys(h).forEach(function(t){h[t]||delete h[t]}),t.request({url:r,method:"PUT",body:h})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(){var t=this;return{listPhotos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",n="/photos",i={page:e,per_page:r,order_by:o};return t.request({url:n,method:"GET",query:i})},listCuratedPhotos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",n="/photos/curated",i={page:e,per_page:r,order_by:o};return t.request({url:n,method:"GET",query:i})},searchPhotos:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[""],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,i="/photos/search",u={query:e,category:r.length>1?r.join(","):r.toString(),page:o,per_page:n};return t.request({url:i,method:"GET",query:u})},getPhoto:function(e,r,o,n){var i="/photos/"+e,u={w:r,h:o,rect:n};return t.request({url:i,method:"GET",query:u})},getPhotoStats:function(e){var r="/photos/"+e+"/stats";return t.request({url:r,method:"GET"})},getRandomPhoto:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/photos/random",o=e.category||[],n=e.collections||[],i={featured:e.featured,username:e.username,orientation:e.orientation,category:o.join(),collections:n.join(),query:e.query,w:e.width,h:e.height,c:e.cacheBuster||(new Date).getTime(),count:e.count};return Object.keys(i).forEach(function(t){i[t]||delete i[t]}),t.request({url:r,method:"GET",query:i})},uploadPhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos";return t.request({url:r,method:"POST",body:{photo:e}})},likePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"POST"})},unlikePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"DELETE"})},downloadPhoto:function(e){var r=(0,s["default"])(e,"links.download_location",void 0);if(void 0===r)throw new Error("Object received is not a photo. "+e);var o=(0,i.getUrlComponents)(r);return t.request({url:o.pathname,method:"GET",query:o.query})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(2),u=r(13),s=o(u)},function(t,e){"use strict";function r(){return{all:o.bind(this,"/search"),photos:o.bind(this,"/search/photos"),users:o.bind(this,"/search/users"),collections:o.bind(this,"/search/collections")}}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,n={query:e,page:r,per_page:o};return this.request({url:t,method:"GET",query:n})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{total:function(){var e="/stats/total";return t.request({url:e,method:"GET"})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(e){var r="/users/"+e;return t.request({url:r,method:"GET"})},photos:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],u="/users/"+e+"/photos",s={page:r,per_page:o,order_by:n,stats:i};return t.request({url:u,method:"GET",query:s})},likes:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i="/users/"+e+"/likes",u={page:r,per_page:o,order_by:n};return t.request({url:i,method:"GET",query:u})},collections:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"published",i="/users/"+e+"/collections",u={page:r,per_page:o,order_by:n};return t.request({url:i,method:"GET",query:u})},statistics:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"days",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,n="/users/"+e+"/statistics",i={resolution:r,quantity:o};return t.request({url:n,method:"GET",query:i})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){t.exports=function(t,e){function r(t){return String(t).replace(/[^ !'()~\*]*/g,encodeURIComponent).replace(/ /g,"+").replace(/[!'()~\*]/g,function(t){return"%"+t.charCodeAt().toString(16).slice(-2).toUpperCase()})}function o(t){var r=Object.keys(t);return e.sorted?r.sort():r}function n(t){return t.filter(function(t){return t}).join("&")}function i(t,e){return n(o(e).map(function(r){return s(t+"["+r+"]",e[r])}))}function u(t,e){return n(e.map(function(e){return s(t+"[]",e)}))}function s(t,o){var n=typeof o,s=null;return o===s?s=e.ignorenull?s:r(t)+"="+s:/string|number|boolean/.test(n)?s=r(t)+"="+r(o):Array.isArray(o)?s=u(t,o):"object"===n&&(s=i(t,o)),s}return e="object"==typeof e?e:{},n(o(t).map(function(e){return s(e,t[e])}))}},function(t,e){(function(e){function r(t,e){return null==t?void 0:t[e]}function o(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}function n(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function i(){this.__data__=yt?yt(null):{}}function u(t){return this.has(t)&&delete this.__data__[t]}function s(t){var e=this.__data__;if(yt){var r=e[t];return r===H?void 0:r}return lt.call(e,t)?e[t]:void 0}function a(t){var e=this.__data__;return yt?void 0!==e[t]:lt.call(e,t)}function c(t,e){var r=this.__data__;return r[t]=yt&&void 0===e?H:e,this}function l(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function h(){this.__data__=[]}function f(t){var e=this.__data__,r=T(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():dt.call(e,r,1),!0}function p(t){var e=this.__data__,r=T(e,t);return r<0?void 0:e[r][1]}function d(t){return T(this.__data__,t)>-1}function v(t,e){var r=this.__data__,o=T(r,t);return o<0?r.push([t,e]):r[o][1]=e,this}function y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function _(){this.__data__={hash:new n,map:new(vt||l),string:new n}}function g(t){return P(this,t)["delete"](t)}function b(t){return P(this,t).get(t)}function m(t){return P(this,t).has(t)}function q(t,e){return P(this,t).set(t,e),this}function T(t,e){for(var r=t.length;r--;)if(G(t[r][0],e))return r;return-1}function j(t,e){e=U(e,t)?[e]:E(e);for(var r=0,o=e.length;null!=t&&r<o;)t=t[R(e[r++])];return r&&r==o?t:void 0}function O(t){if(!M(t)||A(t))return!1;var e=S(t)||o(t)?ft:tt;return e.test(x(t))}function w(t){if("string"==typeof t)return t;if(N(t))return gt?gt.call(t):"";var e=t+"";return"0"==e&&1/t==-V?"-0":e}function E(t){return mt(t)?t:bt(t)}function P(t,e){var r=t.__data__;return k(e)?r["string"==typeof e?"string":"hash"]:r.map}function C(t,e){var o=r(t,e);return O(o)?o:void 0}function U(t,e){if(mt(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!N(t))||(J.test(t)||!B.test(t)||null!=e&&t in Object(e))}function k(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function A(t){return!!at&&at in t}function R(t){if("string"==typeof t||N(t))return t;var e=t+"";return"0"==e&&1/t==-V?"-0":e}function x(t){if(null!=t){try{return ct.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function I(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(z);var r=function(){var o=arguments,n=e?e.apply(this,o):o[0],i=r.cache;if(i.has(n))return i.get(n);var u=t.apply(this,o);return r.cache=i.set(n,u),u};return r.cache=new(I.Cache||y),r}function G(t,e){return t===e||t!==t&&e!==e}function S(t){var e=M(t)?ht.call(t):"";return e==D||e==K}function M(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function L(t){return!!t&&"object"==typeof t}function N(t){return"symbol"==typeof t||L(t)&&ht.call(t)==Z}function $(t){return null==t?"":w(t)}function F(t,e,r){var o=null==t?void 0:j(t,e);return void 0===o?r:o}var z="Expected a function",H="__lodash_hash_undefined__",V=1/0,D="[object Function]",K="[object GeneratorFunction]",Z="[object Symbol]",B=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,Q=/^\./,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,X=/[\\^$.*+?()[\]{}|]/g,Y=/\\(\\)?/g,tt=/^\[object .+?Constructor\]$/,et="object"==typeof e&&e&&e.Object===Object&&e,rt="object"==typeof self&&self&&self.Object===Object&&self,ot=et||rt||Function("return this")(),nt=Array.prototype,it=Function.prototype,ut=Object.prototype,st=ot["__core-js_shared__"],at=function(){var t=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ct=it.toString,lt=ut.hasOwnProperty,ht=ut.toString,ft=RegExp("^"+ct.call(lt).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pt=ot.Symbol,dt=nt.splice,vt=C(ot,"Map"),yt=C(Object,"create"),_t=pt?pt.prototype:void 0,gt=_t?_t.toString:void 0;n.prototype.clear=i,n.prototype["delete"]=u,n.prototype.get=s,n.prototype.has=a,n.prototype.set=c,l.prototype.clear=h,l.prototype["delete"]=f,l.prototype.get=p,l.prototype.has=d,l.prototype.set=v,y.prototype.clear=_,y.prototype["delete"]=g,y.prototype.get=b,y.prototype.has=m,y.prototype.set=q;var bt=I(function(t){t=$(t);var e=[];return Q.test(t)&&e.push(""),t.replace(W,function(t,r,o,n){e.push(o?n.replace(Y,"$1"):r||t)}),e});I.Cache=y;var mt=Array.isArray;t.exports=F}).call(e,function(){return this}())},function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,o,n){e=e||"&",o=o||"=";var i={};if("string"!=typeof t||0===t.length)return i;var u=/\+/g;t=t.split(e);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var a=t.length;s>0&&a>s&&(a=s);for(var c=0;c<a;++c){var l,h,f,p,d=t[c].replace(u,"%20"),v=d.indexOf(o);v>=0?(l=d.substr(0,v),h=d.substr(v+1)):(l=d,h=""),f=decodeURIComponent(l),p=decodeURIComponent(h),r(i,f)?Array.isArray(i[f])?i[f].push(p):i[f]=[i[f],p]:i[f]=p}return i}},function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,o,n){return e=e||"&",o=o||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(n){var i=encodeURIComponent(r(n))+o;return Array.isArray(t[n])?t[n].map(function(t){return i+encodeURIComponent(r(t))}).join(e):i+encodeURIComponent(r(t[n]))}).join(e):n?encodeURIComponent(r(n))+o+encodeURIComponent(r(t)):""}},function(t,e){"use strict";function r(t){return decodeURIComponent(t.replace(/\+/g," "))}function o(t){for(var e,o=/([^=?&]+)=?([^&]*)/g,n={};e=o.exec(t);){var i=r(e[1]),u=r(e[2]);i in n||(n[i]=u)}return n}function n(t,e){e=e||"";var r,o,n=[];"string"!=typeof e&&(e="?");for(o in t)u.call(t,o)&&(r=t[o],r||null!==r&&r!==i&&!isNaN(r)||(r=""),n.push(encodeURIComponent(o)+"="+encodeURIComponent(r)));return n.length?e+n.join("&"):""}var i,u=Object.prototype.hasOwnProperty;e.stringify=n,e.parse=o},function(t,e){"use strict";t.exports=function(t,e){if(e=e.split(":")[0],t=+t,!t)return!1;switch(e){case"http":case"ws":return 80!==t;case"https":case"wss":return 443!==t;case"ftp":return 21!==t;case"gopher":return 70!==t;case"file":return!1}return 0!==t}},function(t,e,r){(function(e){"use strict";function o(t){var r;r="undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:{};var o=r.location||{};t=t||o;var n,i={},s=typeof t;if("blob:"===t.protocol)i=new u(unescape(t.pathname),{});else if("string"===s){i=new u(t,{});for(n in d)delete i[n]}else if("object"===s){for(n in t)n in d||(i[n]=t[n]);void 0===i.slashes&&(i.slashes=f.test(t.href))}return i}function n(t){var e=h.exec(t);return{protocol:e[1]?e[1].toLowerCase():"",slashes:!!e[2],rest:e[3]}}function i(t,e){for(var r=(e||"/").split("/").slice(0,-1).concat(t.split("/")),o=r.length,n=r[o-1],i=!1,u=0;o--;)"."===r[o]?r.splice(o,1):".."===r[o]?(r.splice(o,1),u++):u&&(0===o&&(i=!0),r.splice(o,1),u--);return i&&r.unshift(""),"."!==n&&".."!==n||r.push(""),r.join("/")}function u(t,e,r){if(!(this instanceof u))return new u(t,e,r);var s,a,h,f,d,v,y=p.slice(),_=typeof e,g=this,b=0;for("object"!==_&&"string"!==_&&(r=e,e=null),r&&"function"!=typeof r&&(r=l.parse),e=o(e),a=n(t||""),s=!a.protocol&&!a.slashes,g.slashes=a.slashes||s&&e.slashes,g.protocol=a.protocol||e.protocol||"",t=a.rest,a.slashes||(y[3]=[/(.*)/,"pathname"]);b<y.length;b++)f=y[b],"function"!=typeof f?(h=f[0],v=f[1],h!==h?g[v]=t:"string"==typeof h?~(d=t.indexOf(h))&&("number"==typeof f[2]?(g[v]=t.slice(0,d),t=t.slice(d+f[2])):(g[v]=t.slice(d),t=t.slice(0,d))):(d=h.exec(t))&&(g[v]=d[1],t=t.slice(0,d.index)),g[v]=g[v]||(s&&f[3]?e[v]||"":""),f[4]&&(g[v]=g[v].toLowerCase())):t=f(t);r&&(g.query=r(g.query)),s&&e.slashes&&"/"!==g.pathname.charAt(0)&&(""!==g.pathname||""!==e.pathname)&&(g.pathname=i(g.pathname,e.pathname)),c(g.port,g.protocol)||(g.host=g.hostname,g.port=""),g.username=g.password="",g.auth&&(f=g.auth.split(":"),g.username=f[0]||"",g.password=f[1]||""),g.origin=g.protocol&&g.host&&"file:"!==g.protocol?g.protocol+"//"+g.host:"null",g.href=g.toString()}function s(t,e,r){var o=this;switch(t){case"query":"string"==typeof e&&e.length&&(e=(r||l.parse)(e)),o[t]=e;break;case"port":o[t]=e,c(e,o.protocol)?e&&(o.host=o.hostname+":"+e):(o.host=o.hostname,o[t]="");break;case"hostname":o[t]=e,o.port&&(e+=":"+o.port),o.host=e;break;case"host":o[t]=e,/:\d+$/.test(e)?(e=e.split(":"),o.port=e.pop(),o.hostname=e.join(":")):(o.hostname=e,o.port="");break;case"protocol":o.protocol=e.toLowerCase(),o.slashes=!r;break;case"pathname":case"hash":if(e){var n="pathname"===t?"/":"#";o[t]=e.charAt(0)!==n?n+e:e}else o[t]=e;break;default:o[t]=e}for(var i=0;i<p.length;i++){var u=p[i];u[4]&&(o[u[1]]=o[u[1]].toLowerCase())}return o.origin=o.protocol&&o.host&&"file:"!==o.protocol?o.protocol+"//"+o.host:"null",o.href=o.toString(),o}function a(t){t&&"function"==typeof t||(t=l.stringify);var e,r=this,o=r.protocol;o&&":"!==o.charAt(o.length-1)&&(o+=":");var n=o+(r.slashes?"//":"");return r.username&&(n+=r.username,r.password&&(n+=":"+r.password),n+="@"),n+=r.host+r.pathname,e="object"==typeof r.query?t(r.query):r.query,e&&(n+="?"!==e.charAt(0)?"?"+e:e),r.hash&&(n+=r.hash),n}var c=r(17),l=r(16),h=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,f=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,p=[["#","hash"],["?","query"],function(t){return t.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],d={hash:1,query:1};u.prototype={set:s,toString:a},u.extractProtocol=n,u.location=o,u.qs=l,t.exports=u}).call(e,function(){return this}())}])}); |
{ | ||
"name": "unsplash-js", | ||
"version": "4.8.0", | ||
"version": "5.0.0", | ||
"description": "A Universal JavaScript wrapper for the Unsplash API", | ||
@@ -77,4 +77,4 @@ "main": "lib/unsplash.js", | ||
"querystring": "0.2.0", | ||
"url-parse": "1.2.0" | ||
"url-parse": "1.4.4" | ||
} | ||
} |
118
README.md
@@ -5,2 +5,3 @@ # Unsplash | ||
[![Travis](https://img.shields.io/travis/unsplash/unsplash-js/master.svg?style=flat-square)](https://travis-ci.org/unsplash/unsplash-js/branches) | ||
[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=RzJud09PSXV6TCtRWTY3V0czQUxrUVN5eWZJVDYvTmpGRUFCNEpuQ2Mzcz0tLVZaenhaUlM4RTRtdEZxaEhOblZLNWc9PQ==--a90a25acdadf06f74cf787ed47eb08cedd6f3935%)](https://www.browserstack.com/automate/public-build/RzJud09PSXV6TCtRWTY3V0czQUxrUVN5eWZJVDYvTmpGRUFCNEpuQ2Mzcz0tLVZaenhaUlM4RTRtdEZxaEhOblZLNWc9PQ==--a90a25acdadf06f74cf787ed47eb08cedd6f3935%) | ||
[![Coveralls](https://img.shields.io/coveralls/unsplash/unsplash-js/master.svg?style=flat-square)](https://coveralls.io/github/unsplash/unsplash-js?branch=master) | ||
@@ -10,3 +11,3 @@ | ||
Before using the Unsplash API, you need to [register as a developer](https://unsplash.com/developers) and read the [API Guidelines](https://medium.com/unsplash/unsplash-api-guidelines-28e0216e6daa). | ||
Before using the Unsplash API, you need to [register as a developer](https://unsplash.com/developers) and read the [API Guidelines](https://help.unsplash.com/api-guidelines/unsplash-api-guidelines). | ||
@@ -28,3 +29,3 @@ ## Browser Support | ||
**Note:** Every application must abide by the [API Guidelines](https://medium.com/unsplash/unsplash-api-guidelines-28e0216e6daa). Specifically, remember to [hotlink images](https://medium.com/unsplash/unsplash-api-guidelines-hotlinking-images-6c6b51030d2a) and [trigger a download when appropriate](https://medium.com/unsplash/unsplash-api-guidelines-triggering-a-download-c39b24e99e02). | ||
**Note:** Every application must abide by the [API Guidelines](https://help.unsplash.com/api-guidelines/unsplash-api-guidelines). Specifically, remember to [hotlink images](https://help.unsplash.com/api-guidelines/more-on-each-guideline/guideline-hotlinking-images), [attribute photographers](https://help.unsplash.com/api-guidelines/more-on-each-guideline/guideline-attribution), and [trigger a download when appropriate](https://help.unsplash.com/api-guidelines/more-on-each-guideline/guideline-triggering-a-download). | ||
@@ -50,11 +51,14 @@ ## Documentation | ||
### Creating an instance | ||
To create an instance, simply provide an _Object_ with your `applicationId`, `secret` and `callbackUrl`. | ||
To create an instance, simply provide an _Object_ with your `access key` and `secret`. | ||
```js | ||
// ES Modules syntax | ||
import Unsplash from 'unsplash-js'; | ||
// require syntax | ||
const Unsplash = require('unsplash-js').default; | ||
const unsplash = new Unsplash({ | ||
applicationId: "{APP_ID}", | ||
secret: "{APP_SECRET}", | ||
callbackUrl: "{CALLBACK_URL}" | ||
applicationId: "{APP_ACCESS_KEY}", | ||
secret: "{APP_SECRET}" | ||
}); | ||
@@ -67,3 +71,3 @@ ``` | ||
const unsplash = new Unsplash({ | ||
applicationId: "{APP_ID}", | ||
applicationId: "{APP_ACCESS_KEY}", | ||
secret: "{APP_SECRET}", | ||
@@ -79,5 +83,4 @@ callbackUrl: "{CALLBACK_URL}", | ||
const unsplash = new Unsplash({ | ||
applicationId: "{APP_ID}", | ||
applicationId: "{APP_ACCESS_KEY}", | ||
secret: "{APP_SECRET}", | ||
callbackUrl: "{CALLBACK_URL}", | ||
headers: { | ||
@@ -399,23 +402,2 @@ "X-Custom-Header": "foo" | ||
### photos.listCuratedPhotos(page, perPage, orderBy) | ||
Get a single page from the list of the curated photos. | ||
__Arguments__ | ||
| Argument | Type | Opt/Required | | ||
|---|---|---| | ||
|__`page`__|_number_|Optional| | ||
|__`perPage`__|_number_|Optional| | ||
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`| | ||
__Example__ | ||
```js | ||
unsplash.photos.listCuratedPhotos(2, 15, "latest") | ||
.then(toJson) | ||
.then(json => { | ||
// Your code | ||
}); | ||
``` | ||
--- | ||
### photos.getPhoto(id, width, height, rectangle) | ||
@@ -589,22 +571,2 @@ Retrieve a single photo. | ||
### collections.listCuratedCollections(page, perPage) | ||
Get a single page from the list of curated collections. | ||
__Arguments__ | ||
| Argument | Type | Opt/Required | | ||
|---|---|---| | ||
|__`page`__|_number_|Optional| | ||
|__`perPage`__|_number_|Optional| | ||
__Example__ | ||
```js | ||
unsplash.collections.listCuratedCollections(1, 10) | ||
.then(toJson) | ||
.then(json => { | ||
// Your code | ||
}); | ||
``` | ||
--- | ||
### collections.listFeaturedCollections(page, perPage) | ||
@@ -650,22 +612,2 @@ Get a single page from the list of featured collections. | ||
### collections.getCuratedCollection(id) | ||
Or, for a curated collection: | ||
__Arguments__ | ||
| Argument | Type | Opt/Required | | ||
|---|---|---| | ||
|__`id`__|_number_|Required| | ||
__Example__ | ||
```js | ||
unsplash.collections.getCuratedCollection(88) | ||
.then(toJson) | ||
.then(json => { | ||
// Your code | ||
}); | ||
``` | ||
--- | ||
### collections.getCollectionPhotos(id, orderBy) | ||
@@ -695,25 +637,2 @@ Retrieve a collection’s photos. | ||
### collections.getCuratedCollectionPhotos(id, orderBy) | ||
Or, for a curated collection: | ||
__Arguments__ | ||
| Argument | Type | Opt/Required | Notes | | ||
|---|---|---|---| | ||
|__`id`__|_number_|Required|| | ||
|__`page`__|_number_|Optional| | ||
|__`perPage`__|_number_|Optional| | ||
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`| | ||
__Example__ | ||
```js | ||
unsplash.collections.getCuratedCollectionPhotos(88, 1, 10, "popular") | ||
.then(toJson) | ||
.then(json => { | ||
// Your code | ||
}); | ||
``` | ||
--- | ||
### collections.createCollection(title, description, private) | ||
@@ -852,3 +771,3 @@ Create a new collection. This requires the `write_collections` scope. | ||
|---|---|---|---| | ||
|__`keyword`__|_number_|Required|| | ||
|__`keyword`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
@@ -874,3 +793,3 @@ |__`per_page`__|_number_|Optional|10| | ||
|---|---|---|---| | ||
|__`keyword`__|_number_|Required|| | ||
|__`keyword`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
@@ -896,3 +815,3 @@ |__`per_page`__|_number_|Optional|10| | ||
|---|---|---|---| | ||
|__`keyword`__|_number_|Required|| | ||
|__`keyword`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
@@ -946,5 +865,4 @@ |__`per_page`__|_number_|Optional|10| | ||
const unsplash = new Unsplash({ | ||
applicationId: "{YOUR_APPLICATION_ID}", | ||
secret: "{YOUR_SECRET_KEY}", | ||
callbackUrl: "{YOUR_CALLBACK_URL}" | ||
applicationId: "{YOUR_ACCESS_KEY}", | ||
secret: "{YOUR_SECRET_KEY}" | ||
}); | ||
@@ -965,3 +883,3 @@ | ||
## License | ||
Copyright (c) 2015, [Unsplash](https://unsplash.com) | ||
Copyright (c) 2019, [Unsplash](https://unsplash.com) | ||
@@ -968,0 +886,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -22,3 +22,3 @@ /* @flow */ | ||
_secret: string; | ||
_callbackUrl: string; | ||
_callbackUrl: ?string; | ||
_bearerToken: ?string; | ||
@@ -43,3 +43,3 @@ _headers: ?Object; | ||
secret: string, | ||
callbackUrl: string, | ||
callbackUrl?: string, | ||
bearerToken?: string, | ||
@@ -46,0 +46,0 @@ headers?: Object |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3966
341606
54
888
+ Addedquerystringify@2.2.0(transitive)
+ Addedurl-parse@1.4.4(transitive)
- Removedquerystringify@1.0.0(transitive)
- Removedurl-parse@1.2.0(transitive)
Updatedurl-parse@1.4.4