mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).UniversalCookie=t()}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,t){return e(t={exports:{}},t.exports),t.exports}function o(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");for(var o={},r=t||{},n=e.split(l),i=r.decode||p,a=0;a<n.length;a++){var s=n[a],u=s.indexOf("=");if(!(u<0)){var c=s.substr(0,u).trim(),f=s.substr(++u,s.length).trim();'"'==f[0]&&(f=f.slice(1,-1)),null==o[c]&&(o[c]=d(f,i))}}return o}function r(e,t,o){var r=o||{},n=r.encode||u;if("function"!=typeof n)throw new TypeError("option encode is invalid");if(!c.test(e))throw new TypeError("argument name is invalid");var i=n(t);if(i&&!c.test(i))throw new TypeError("argument val is invalid");var a=e+"="+i;if(null!=r.maxAge){var s=r.maxAge-0;if(isNaN(s))throw new Error("maxAge should be a Number");a+="; Max-Age="+Math.floor(s)}if(r.domain){if(!c.test(r.domain))throw new TypeError("option domain is invalid");a+="; Domain="+r.domain}if(r.path){if(!c.test(r.path))throw new TypeError("option path is invalid");a+="; Path="+r.path}if(r.expires){if("function"!=typeof r.expires.toUTCString)throw new TypeError("option expires is invalid");a+="; Expires="+r.expires.toUTCString()}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite){switch("string"==typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a}var p=decodeURIComponent,u=encodeURIComponent,l=/; */,c=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function d(t,e){try{return e(t)}catch(e){return t}}var f={parse:o,serialize:r},y=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.hasDocumentCookie=function(){return"object"===("undefined"==typeof document?"undefined":s(document))&&"string"==typeof document.cookie},t.cleanCookies=function(){document.cookie.split(";").forEach(function(e){document.cookie=e.replace(/^ +/,"").replace(/=.*/,"=;expires="+(new Date).toUTCString()+";path=/")})},t.parseCookies=function(e,t){return"string"==typeof e?o.parse(e,t):"object"===s(e)&&null!==e?e:{}},t.isParsingCookie=r,t.readCookie=function(e,t){void 0===t&&(t={});var o=function(e){if(e&&"j"===e[0]&&":"===e[1])return e.substr(2);return e}(e);if(r(o,t.doNotParse))try{return JSON.parse(o)}catch(e){}return e};var o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==s(e)&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var o={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=r?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(o,n,i):o[n]=e[n]}o.default=e,t&&t.set(e,o);return o}(f);function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){return void 0===t&&(t=!e||"{"!==e[0]&&"["!==e[0]&&'"'!==e[0]),!t}});e(y);y.hasDocumentCookie,y.cleanCookies,y.parseCookies,y.isParsingCookie,y.readCookie;var n=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==s(e)&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var o={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=r?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(o,n,i):o[n]=e[n]}o.default=e,t&&t.set(e,o);return o}(f);function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=function(){return(i=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function o(e,t){var o=this;this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.cookies=(0,y.parseCookies)(e,t),new Promise(function(){o.HAS_DOCUMENT_COOKIE=(0,y.hasDocumentCookie)()}).catch(function(){})}var r=(o.prototype._updateBrowserValues=function(e){this.HAS_DOCUMENT_COOKIE&&(this.cookies=n.parse(document.cookie,e))},o.prototype._emitChange=function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)},o.prototype.get=function(e,t,o){return void 0===t&&(t={}),this._updateBrowserValues(o),(0,y.readCookie)(this.cookies[e],t)},o.prototype.getAll=function(e,t){void 0===e&&(e={}),this._updateBrowserValues(t);var o={};for(var r in this.cookies)o[r]=(0,y.readCookie)(this.cookies[r],e);return o},o.prototype.set=function(e,t,o){var r;"object"===s(t)&&(t=JSON.stringify(t)),this.cookies=i(i({},this.cookies),((r={})[e]=t,r)),this.HAS_DOCUMENT_COOKIE&&(document.cookie=n.serialize(e,t,o)),this._emitChange({name:e,value:t,options:o})},o.prototype.remove=function(e,t){var o=t=i(i({},t),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=i({},this.cookies),delete this.cookies[e],this.HAS_DOCUMENT_COOKIE&&(document.cookie=n.serialize(e,"",o)),this._emitChange({name:e,value:void 0,options:t})},o.prototype.addChangeListener=function(e){this.changeListeners.push(e)},o.prototype.removeChangeListener=function(e){var t=this.changeListeners.indexOf(e);0<=t&&this.changeListeners.splice(t,1)},o);t.default=r,e.exports=t.default});return e(n),e(t(function(e,t){var o;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=((o=n)&&o.__esModule?o:{default:o}).default;t.default=r,e.exports=t.default}))});
|