@commercetools/sdk-middleware-user-agent
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -41,2 +41,244 @@ (function (global, factory) { | ||
var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}; | ||
// shim for using process in browser | ||
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function defaultClearTimeout() { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
var cachedSetTimeout = defaultSetTimout; | ||
var cachedClearTimeout = defaultClearTimeout; | ||
if (typeof global$1.setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} | ||
if (typeof global$1.clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} // if setTimeout wasn't available but was latter defined | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch (e) { | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch (e) { | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} // if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e) { | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e) { | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
} | ||
} | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while (len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
function nextTick(fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
} // v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
var title = 'browser'; | ||
var platform = 'browser'; | ||
var browser = true; | ||
var env = {}; | ||
var argv = []; | ||
var version = ''; // empty string to avoid regexp issues | ||
var versions = {}; | ||
var release = {}; | ||
var config = {}; | ||
function noop() {} | ||
var on = noop; | ||
var addListener = noop; | ||
var once = noop; | ||
var off = noop; | ||
var removeListener = noop; | ||
var removeAllListeners = noop; | ||
var emit = noop; | ||
function binding(name) { | ||
throw new Error('process.binding is not supported'); | ||
} | ||
function cwd() { | ||
return '/'; | ||
} | ||
function chdir(dir) { | ||
throw new Error('process.chdir is not supported'); | ||
} | ||
function umask() { | ||
return 0; | ||
} // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js | ||
var performance = global$1.performance || {}; | ||
var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () { | ||
return new Date().getTime(); | ||
}; // generate timestamp or delta | ||
// see http://nodejs.org/api/process.html#process_process_hrtime | ||
function hrtime(previousTimestamp) { | ||
var clocktime = performanceNow.call(performance) * 1e-3; | ||
var seconds = Math.floor(clocktime); | ||
var nanoseconds = Math.floor(clocktime % 1 * 1e9); | ||
if (previousTimestamp) { | ||
seconds = seconds - previousTimestamp[0]; | ||
nanoseconds = nanoseconds - previousTimestamp[1]; | ||
if (nanoseconds < 0) { | ||
seconds--; | ||
nanoseconds += 1e9; | ||
} | ||
} | ||
return [seconds, nanoseconds]; | ||
} | ||
var startTime = new Date(); | ||
function uptime() { | ||
var currentTime = new Date(); | ||
var dif = currentTime - startTime; | ||
return dif / 1000; | ||
} | ||
var process = { | ||
nextTick: nextTick, | ||
title: title, | ||
browser: browser, | ||
env: env, | ||
argv: argv, | ||
version: version, | ||
versions: versions, | ||
on: on, | ||
addListener: addListener, | ||
once: once, | ||
off: off, | ||
removeListener: removeListener, | ||
removeAllListeners: removeAllListeners, | ||
emit: emit, | ||
binding: binding, | ||
cwd: cwd, | ||
chdir: chdir, | ||
umask: umask, | ||
hrtime: hrtime, | ||
platform: platform, | ||
release: release, | ||
config: config, | ||
uptime: uptime | ||
}; | ||
/* global window */ | ||
@@ -43,0 +285,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).CommercetoolsSdkMiddlewareUserAgent={})}(this,function(e){"use strict";function c(o){for(var e=1;e<arguments.length;e++){var c=null!=arguments[e]?arguments[e]:{},n=Object.keys(c);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(c).filter(function(e){return Object.getOwnPropertyDescriptor(c,e).enumerable}))),n.forEach(function(e){var n,t,r;n=o,r=c[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r})}return o}var o=function(){return"undefined"!=typeof window&&window.document&&9===window.document.nodeType};function n(e){if(!e||0===Object.keys(e).length||!{}.hasOwnProperty.call(e,"name"))throw new Error("Missing required option `name`");var n,t,r=e.version?"".concat(e.name,"/").concat(e.version):e.name;return e.libraryName&&!e.libraryVersion?n=e.libraryName:e.libraryName&&e.libraryVersion&&(n="".concat(e.libraryName,"/").concat(e.libraryVersion)),e.contactUrl&&!e.contactEmail?t="(+".concat(e.contactUrl,")"):!e.contactUrl&&e.contactEmail?t="(+".concat(e.contactEmail,")"):e.contactUrl&&e.contactEmail&&(t="(+".concat(e.contactUrl,"; +").concat(e.contactEmail,")")),[r,function(){if(o())return window.navigator.userAgent;var e=process.version.slice(1),n="(".concat(process.platform,"; ").concat(process.arch,")");return"Node.js/".concat(e," ").concat(n)}(),n,t].filter(function(e){return Boolean(e)}).join(" ")}e.createUserAgentMiddleware=function(e){var o=n(c({name:"commercetools-js-sdk"},e));return function(r){return function(e,n){var t=c({},e,{headers:c({},e.headers,{"User-Agent":o})});r(t,n)}}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).CommercetoolsSdkMiddlewareUserAgent={})}(this,function(e){"use strict";function i(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),n.forEach(function(e){var n,t,r;n=o,r=i[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r})}return o}var n="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function t(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}var o=t,c=r;function a(n){if(o===setTimeout)return setTimeout(n,0);if((o===t||!o)&&setTimeout)return o=setTimeout,setTimeout(n,0);try{return o(n,0)}catch(e){try{return o.call(null,n,0)}catch(e){return o.call(this,n,0)}}}"function"==typeof n.setTimeout&&(o=setTimeout),"function"==typeof n.clearTimeout&&(c=clearTimeout);var u,l=[],f=!1,s=-1;function m(){f&&u&&(f=!1,u.length?l=u.concat(l):s=-1,l.length&&d())}function d(){if(!f){var e=a(m);f=!0;for(var n=l.length;n;){for(u=l,l=[];++s<n;)u&&u[s].run();s=-1,n=l.length}u=null,f=!1,function(n){if(c===clearTimeout)return clearTimeout(n);if((c===r||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(n);try{c(n)}catch(e){try{return c.call(null,n)}catch(e){return c.call(this,n)}}}(e)}}function w(e,n){this.fun=e,this.array=n}w.prototype.run=function(){this.fun.apply(null,this.array)};function h(){}var p=h,y=h,b=h,v=h,g=h,T=h,j=h;var E=n.performance||{},O=E.now||E.mozNow||E.msNow||E.oNow||E.webkitNow||function(){return(new Date).getTime()};var N=new Date;var U={nextTick:function(e){var n=new Array(arguments.length-1);if(1<arguments.length)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];l.push(new w(e,n)),1!==l.length||f||a(d)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:p,addListener:y,once:b,off:v,removeListener:g,removeAllListeners:T,emit:j,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var n=.001*O.call(E),t=Math.floor(n),r=Math.floor(n%1*1e9);return e&&(t-=e[0],(r-=e[1])<0&&(t--,r+=1e9)),[t,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-N)/1e3}},k=function(){return"undefined"!=typeof window&&window.document&&9===window.document.nodeType};function A(e){if(!e||0===Object.keys(e).length||!{}.hasOwnProperty.call(e,"name"))throw new Error("Missing required option `name`");var n,t,r=e.version?"".concat(e.name,"/").concat(e.version):e.name;return e.libraryName&&!e.libraryVersion?n=e.libraryName:e.libraryName&&e.libraryVersion&&(n="".concat(e.libraryName,"/").concat(e.libraryVersion)),e.contactUrl&&!e.contactEmail?t="(+".concat(e.contactUrl,")"):!e.contactUrl&&e.contactEmail?t="(+".concat(e.contactEmail,")"):e.contactUrl&&e.contactEmail&&(t="(+".concat(e.contactUrl,"; +").concat(e.contactEmail,")")),[r,function(){if(k())return window.navigator.userAgent;var e=U.version.slice(1),n="(".concat(U.platform,"; ").concat(U.arch,")");return"Node.js/".concat(e," ").concat(n)}(),n,t].filter(function(e){return Boolean(e)}).join(" ")}e.createUserAgentMiddleware=function(e){var o=A(i({name:"commercetools-js-sdk"},e));return function(r){return function(e,n){var t=i({},e,{headers:i({},e.headers,{"User-Agent":o})});r(t,n)}}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=commercetools-sdk-middleware-user-agent.umd.min.js.map |
@@ -7,3 +7,3 @@ { | ||
"name": "@commercetools/sdk-middleware-user-agent", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Middleware for setting the User-Agent on the HTTP request, to use with @commercetools/sdk-client", | ||
@@ -39,5 +39,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@commercetools/http-user-agent": "^2.0.0" | ||
"@commercetools/http-user-agent": "^2.1.0" | ||
}, | ||
"gitHead": "4940fcb75927c288c6f832d9c6471be6a581009a" | ||
"gitHead": "4dc966050b39b73e3875d7bd32a89c82f92fdfa2" | ||
} |
Sorry, the diff of this file is not supported yet
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
67434
456